Commit Graph

1813 Commits

Author SHA1 Message Date
Nick Sanders
a4bfc663a3 sweetberry: add dwc usb support
stm32f446 uses a synopsys designware USB block
rather than the typical ST one. This change adds driver support
for the new block, including usb console support.

BUG=chromium:608039
TEST=usb console works
BRANCH=None

Change-Id: I0e143758ae0b5285f1c94ea2ec5aee159e22e00c
Signed-off-by: Nick Sanders <nsanders@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/365448
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-09-01 22:56:22 -07:00
Mulin Chao
5b54e8c065 npcx: Fixed bug which only handles VW event of SUS_WARN# in rising edge.
During removing primary power of CPU, EC also needs to handle VW event
of SUS_WARN# in espi driver. Modify the MIWU trigger mode of it from
EDGE_RISING to EDGE_ANYING to solve it.

Modified sources:
1. espi.c: Handling VW event of SUS_WARN# in both edge.

BRANCH=none
BUG=chrome-os-partner:34346
TEST=make BOARD=wheatley; test power sequence on espi POC of wheatley.

Change-Id: I9e45115f3c274d08cdc694911d38599bc8da70c5
Signed-off-by: Mulin Chao <mlchao@nuvoton.com>
Reviewed-on: https://chromium-review.googlesource.com/377780
Reviewed-by: CH Lin <chlin56@nuvoton.com>
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-09-01 19:53:02 -07:00
Douglas Anderson
da9c06a2e7 kevin / gru: Enable PD on SHI signals
The SHI lines connected from the EC to the AP and the AP might not be
turned on.  We should have a pull down on these lines to avoid them
glitching when the AP is in S3 or S5.

BRANCH=None
BUG=chrome-os-partner:56683
TEST=Verify S3/S5 power is decreased, and SHI interface is still
functional in S0 and on sysjump.

Change-Id: I3a9b018e6e8a5eddb1f23e004f1af3da3e503709
Signed-off-by: Douglas Anderson <dianders@chromium.org>
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/376360
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Mulin Chao <mlchao@nuvoton.com>
2016-09-01 19:53:01 -07:00
Mary Ruthven
e47eaaf2e8 cr50: unlock console
UART0 RX only needs to be disabled on reef. This change uses a system
property instead of a #define to disable UART0 RX that way it can just
be done on Reef not Gru or the dev board.

BUG=chrome-os-partner:55510
BRANCH=none
TEST=manual
	rw 0x4060000c shows a value of 1 for reef and 3 for gru

	gru kevin and reef still boot.

	Connect DIOA13 to DIOA1 on the dev board and verify the console
	can be used.

Change-Id: I5ee3559c2b35f959c0d67f233d1dfa40743b4064
Signed-off-by: Mary Ruthven <mruthven@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/378336
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-by: Scott Collyer <scollyer@chromium.org>
2016-09-01 07:39:38 -07:00
Mary Ruthven
5e6da91fe8 cr50: remove internal pull up on DIOM0
There is leakage on SYS_RST_ODL from the internal pullup cr50 has on
DIOM0. This change removes the internal pullup.

Without the internal pull up SYS_RST_ODL is asserted when the EC is off.
This change modifies how sys_rst_asserted is handled so cr50 will ignore
the sys_rst interrupt whenever rbox asserts EC_RST to make sure cr50
doesn't reset itself every time it resets the EC. If the EC resets
itself and sys_rst_l is no longer pulled up, it is fine if cr50 resets.

BUG=chrome-os-partner:53544
CQ-DEPEND=CL:377504
BRANCH=none
TEST=manual
	'rw 0x40550010 1' causes the EC to reset but not cr50

	On the development board verify DIOM0 is not pulled up.

	Test cr50 boots normally on reef, gru and kevin dvt1

Change-Id: Id8e8f6f7bb91741da34bdd6fec89eb841dd94f35
Signed-off-by: Mary Ruthven <mruthven@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/376886
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2016-08-31 21:35:30 +00:00
Bill Richardson
6c7fccf356 Cr50: Implement the console unlock dance
In order to disable the restricted console lock, the user has to
poke the power button repeatedly for some time. This CL
implements the logic to tell when this is happening, and whether
it is successful or not.

With this CL, unlocking only takes 10 seconds. This period will
be extended for production use. Right now we're just testing.

BUG=chrome-os-partner:55322
BUG=chrome-os-partner:55510
BRANCH=none
TEST=make buildall; test on cr50 hardware

At the console, run the "lock" command to see if it's already
disabled. If it is, run "lock enable" to lock it.

To unlock it, run "lock disable". A countdown will appear, after
which you will need to poke the Power button every 2 seconds for
10 seconds. If you do so, the console will be unlocked.

Change-Id: Ib5a94172080e627f3268d50d2587ec58bf8d9473
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/377621
Reviewed-by: Mary Ruthven <mruthven@chromium.org>
2016-08-31 18:05:11 +00:00
Bill Richardson
8c4421759d Cr50: Mark several console commands as safe
Even when CONFIG_RESTRICTED_CONSOLE_COMMANDS is enabled, there
are many commands that can't do anything dangerous. This marks
some of those commands as safe to use, even when restrictions are
enforced.

I'm only marking commands that are used by the Cr50, since that's
the only board that has restrictions.

BUG=chrome-os-partner:55322
BRANCH=none
TEST=make buildall, test on Cr50 hardware

Change-Id: I6289d332830175b6adcb6b20cb4c21d01d27a25e
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/376188
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-08-31 17:20:26 +00:00
Dom Rizzo
9bbce57c0f Added additional macros for the TIMEUS module.
BUG=none
BRANCH=none
TEST=make buildall

Change-Id: I5a63ae85441d492b7322a98bb05e42d9d236e005
Signed-off-by: Dom Rizzo <domrizzo@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/377150
Commit-Ready: Dominic Rizzo <domrizzo@google.com>
Tested-by: Dominic Rizzo <domrizzo@google.com>
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2016-08-29 13:31:01 -07:00
Vadim Bendebury
ae5f642975 usb_updater: implement version 4 on the cr50 side
Version 4 of the update protocol provides the host with version
numbers of currently running RO and RW.

Another enhancement is that flash erase is postponed til the moment
the first chunk of data for the section arrives. This allows to quiry
running firmware versions in a non-destructive fashion.

BRANCH=none
BUG=chrome-os-partner:49954

TEST=ran usb_update on a Reef with an old cr50 image on it. Observed
      it complete once with exit code of 2 (RO could not be updated),
      ran it again, observed it succeed, and verified that both RO and
      RW on the Reef got updated.

Change-Id: I27841c464cd0a414fa8959b686b59d8f07765387
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/374760
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2016-08-26 21:51:34 +00:00
Vadim Bendebury
fcbea6a324 usb_updater: move to protocol version 4
Trying to use usb_updater in the upstart script made its shortcomings
very obvious: it is difficult to tell if the cr50 needs to have both
RO and RW updated, and if so - if it is even capable of updating RW.

Also, it is not clear that the target should erase its backup sections
as soon as it receives the transfer originating PDU. It is not known
in advance if the host has a newer RW section, of if the host is even
going to transfer the RO section.

These issues are addressed by version 4 of the image transfer
protocol.

The target now reports versions of its currently active RO and RW
sections back to the host. The host compares versions running on the
target with the versions retrieved from the image prepared for the
update and decides which sections, if any, need to be transferred.

The host also takes into account protocol version currently running by
the target's RW: versions below 3 do not allow RO updates.

In the development environment USB transfer ends with the target
reset. This is not desirable when the update is happening on a
Chromebook running production code. Also, in the development
environment there could exist multiple versions of the image with the
same signer header version fields, with only difference in the
timestamp. We want to be able to update using these images in
development environment, but in production we want to rely to the
header version fields.

These two mode (dev versus production) are now controlled by the
-u/--upstart command line flag.

The updater now can return four different exit values:

  - 0 means that the update was not required, the device is already
    running the current code.

  - 1 means update was completed, the target must be reset for the
    update to kick in.

  - 2 means that the RW transfer was completed, but the RO transfer
    could bot be attempted, because the target is running an early
    protocol version and is not capable of the RO updates.

    This exit value is the indicator that the utility needs to be run
    again after target restated, so that the new RW version can accept
    an RO update.

  - 3 means the update failed due to some internal error.

BRANCH=none
BUG=chrome-os-partner:49954
TEST=updates of targets running earlier protocol version still work
     fine.

Change-Id: Ia56f63072eaf88dcdefebf621b7341535748c7d7
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/374759
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2016-08-26 21:49:30 +00:00
Bill Richardson
608852b840 g: Add help message for test_rdd command
BUG=none
BRANCH=none
TEST=make buildall

Before:

  > help test_rdd
  Usage: test_rdd

  >

After:

  > help test_rdd
  Usage: test_rdd
  Fake an RDD-detected interrupt
  >

Change-Id: I41bcc6c642bcad6577834e81436be712324ae64d
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/376098
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
2016-08-25 21:59:13 -07:00
Vadim Bendebury
87a0b0a878 Revert "cr50: remove internal pull up on DIOM0"
This reverts commit d0383d8814.

Change-Id: I76cac7902b0cd25300393efcf205cdbe9ade82c0
Reviewed-on: https://chromium-review.googlesource.com/376132
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
Commit-Queue: Vadim Bendebury <vbendeb@chromium.org>
Tested-by: Vadim Bendebury <vbendeb@chromium.org>
2016-08-26 04:18:31 +00:00
Mary Ruthven
613be38789 cr50: connect to AP phy on reef when not in ccd
Cr50 needs to connect to the AP phy when not in ccd so cr50 can be
updated and used as a gnubby. This change uses the strapping options
to detect when it is on reef and modifies the ccd behavior to
initialize usb on the AP phy when ccd is disabled. On gru the cr50
behavior is unchanged.

In RDD this change removes the checks that the current_map is the
correct one based on the detected debug state. rdd_init calls
rdd_interrupt to set up the usb and ccd state correctly. Having that
check prevents that initial rdd_interrupt from calling rdd_detached.
Before rdd_detached just disabled usb and we knew during init it
would already be disabled. Now we want to make sure it is called if a
debug accessory is not attached to initialize usb on the AP PHY.

BUG=chrome-os-partner:56098
BRANCH=none
TEST=manual
	verify ccd still works on gru

	disconnect suzyq and reset reef.

	run lsusb on the AP and verify it shows cr50 as a device.

	connect suzyq and check that the AP no longer sees cr50.

	disconnect suzyq and verify the AP sees it again

Change-Id: I3c1ccc54895835bce12302f3ea43fc2e751b4c97
Signed-off-by: Mary Ruthven <mruthven@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/372920
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
2016-08-25 01:46:39 -07:00
Bill Richardson
3071b82b58 Remove unused CONFIG_CONSOLE_RESTRICTED_INPUT option
Nothing has used this config option since Spring and Skate, back
in early 2014. There's nothing in ToT that uses it at all. I want
to add something similar for other purposes, and having two
similar-sounding options will just cause confusion.

NOTE: Although the comments in include/system.h said that the two
functions

  system_get_console_force_enabled()
  system_set_console_force_enabled()

were only useful when CONFIG_CONSOLE_RESTRICTED_INPUT is defined,
they were being used in chip/stm32/system.c. But since the
bkpdata registers are only accessible to the EC, there was no way
to initialize or modify the one relevant bit that those functions
cared about, so they almost certainly had no effect.

BUG=chrome-os-partner:55322
BRANCH=none
TEST=make buildall

Change-Id: Id41541193d4559f5c507bdd0268b049166af4497
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/374525
2016-08-24 17:41:12 -07:00
Bill Richardson
862644b9bb Cr50: Tweak some comments about UART0_RX
Just adding a TODO comment to the gpio.inc file.

BUG=chrome-os-partner:56540
BRANCH=none
TEST=make buildall; test on Cr50 hardware

Change-Id: I5fa1a765232fd31b03d8825324a3a6a964504b5a
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/374619
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
2016-08-24 17:41:00 -07:00
Johnnie Chan
dbd62c36da Modified flash API batch write logic to respect row boundaries.
* Added MACRO for specifying row size of flash device.
* Set chip/g specific values for flash row size.

The flash API for g/chip will segment large write operations into a
maximum of 32 word blocks for batch writes to flash memory. Prior to
the change in this commit, the segmentation will adhere to avoiding
crossing page boundaries (2048B) but will not respect row boundaries
(256B). The flash controller will reject any write op that crosses a
row boundary and set a row boundary violation code on its error
register.

BRANCH=none
BUG=b:30819377
TEST=make BOARD=haven_dev
Change-Id: I489122ec0f0db6374dd373a1385c3012bdface20
Reviewed-on: https://chromium-review.googlesource.com/371003
Commit-Ready: Bill Richardson <wfrichar@chromium.org>
Commit-Ready: Johnnie Chan <johnniec@google.com>
Tested-by: Johnnie Chan <johnniec@google.com>
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
2016-08-24 17:40:39 -07:00
Bill Richardson
bb15561db5 cleanup: DECLARE_CONSOLE_COMMAND only needs 4 args
Since pretty much always, we've declared console commands to take
a "longhelp" argument with detailed explanations of what the
command does. But since almost as long, we've never actually used
that argument for anything - we just silently throw it away in
the macro. There's only one command (usbchargemode) that even
thinks it defines that argument.

We're never going to use this, let's just get rid of it.

BUG=none
BRANCH=none
CQ-DEPEND=CL:*279060
CQ-DEPEND=CL:*279158
CQ-DEPEND=CL:*279037
TEST=make buildall; tested on Cr50 hardware

Everything builds. Since we never used this arg anyway, there had
better not be any difference in the result.

Change-Id: Id3f71a53d02e3dc625cfcc12aa71ecb50e35eb9f
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/374163
Reviewed-by: Myles Watson <mylesgw@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-08-24 16:30:10 +00:00
Martin Roth
681284ca22 npcx/i2c.c: Verify that controller value is not negative before using it
The function i2c_port_to_controller() returns a negative value if
the port value was out of range.  This wasn't being checked before the
controller value was getting used which could lead to using an invalid
value as a pointer to a structure.

This returns an error where it makes sense, and just ignores the
incorrect value otherwise.

TEST=Build
BUG=None
BRANCH=None

Change-Id: Ie8967bc4db87d3dd1863a2e36e35ac87e6161132
Signed-off-by: Martin Roth <martinroth@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/371400
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Mulin Chao <mlchao@nuvoton.com>
2016-08-23 15:37:13 -07:00
Mary Ruthven
d0383d8814 cr50: remove internal pull up on DIOM0
There is leakage on SYS_RST_ODL from the internal pullup cr50 has on
DIOM0. This change removes the internal pullup.

Without the internal pull up SYS_RST_ODL is not pulled up whenever the
EC is off. I changed how sys_rst_asserted is handled so it will ignore
the sys_rst interrupt whenever rbox asserts EC_RST to make sure cr50
doesn't reset itself every time it resets the EC. If the EC resets
itself and sys_rst_l is no longer pulled up, it is fine if cr50 resets.

BUG=chrome-os-partner:53544
BRANCH=none
TEST=manual
	'rw 0x40550010 1' causes the EC to reset but not cr50

	On the development board verify DIOM0 is not pulled up.

	Test cr50 boots normally on reef and gru

Change-Id: Ic1d4d160ddb0d69081cb1f194d50939dac6fc5c2
Signed-off-by: Mary Ruthven <mruthven@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/373838
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2016-08-23 15:36:59 -07:00
Levi Oliver
1e2148249a btle: Accepts and maintains connections
Can now accept and maintain a single connection indefinitely by
sending empty packets at every connection interval to keep the
connection alive.

TEST=BTLE dongle sending connect requests and connecting to NRF51
running this code. Connection was established and ran for at least
48 hours until manual termination.
BUG=None
BRANCH=None

Change-Id: Iad4bd434ecd1edd6c5c8dfe8b72ca41fd82d0bb4
Signed-off-by: Levi Oliver <levio@google.com>
Reviewed-on: https://chromium-review.googlesource.com/370839
Commit-Ready: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2016-08-23 15:36:55 -07:00
Martin Roth
866add68ed npcx/flash.c: Init return value for success
In flash_physical_erase(), if the area being erased was already
cleared, the return value would never be set, and would be returned
without being defined.  Initialize the value so that if the area
being erased is clear, we return success.

TEST=Build
BUG=None
BRANCH=None

Change-Id: Ib13e0be0ad1d3ad23c065b407c35e7b5c4db8487
Signed-off-by: Martin Roth <martinroth@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/371399
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Reviewed-by: Mulin Chao <mlchao@nuvoton.com>
2016-08-23 15:36:48 -07:00
Mulin Chao
862a325fa0 npcx: gpio: Enable wake GPIO interrupts prior to hibernate
This is necessary after the pending patch to not enable all GPIO
interrupts by default.

BRANCH=None
BUG=chrome-os-partner:56486
TEST=Manual on kevin, run 'hibernate', attach AC and verify wake occurs.

Change-Id: I04d2c6edf9fb32b1a6a7e6a5ed4d2c53895e00f0
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/374179
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2016-08-23 15:36:32 -07:00
Shawn Nematbakhsh
072d333f10 npcx: shi: Properly disable interrupts throughout sending of HC response
Expand interrupt disable to include checking of our SHI state in case
preemption occurs immediately afterward.

BUG=chrome-os-partner:55795
BRANCH=None
TEST=Manual on kevin, verify no errors through 700+ sysjumps.

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: Icb8a5bdd03dbf87f6a25b4175f73c932d48db726
Reviewed-on: https://chromium-review.googlesource.com/374021
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Mulin Chao <mlchao@nuvoton.com>
2016-08-23 15:36:31 -07:00
Shawn Nematbakhsh
8fd12a56f1 npcx: Don't enable GPIO interrupts by default
GPIO interrupts must first be enabled with a call to
gpio_enable_interrupt() to prevent ISRs from being run before
prerequiste modules are initialized.

BUG=chrome-os-partner:56486
BRANCH=None
TEST=Manual on kevin, stress test sysjump for ~1 hour (~700 sysjumps)
without failure.

Change-Id: Ia4006ef1b0c3218dfe5c92fde6713c10b0d22d2a
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/374020
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Mulin Chao <mlchao@nuvoton.com>
2016-08-23 15:36:30 -07:00
Bill Richardson
8f080f795b Cr50: Use parse_bool() for boolean args
The parse_bool() function exists so we don't have to litter our
console commands with stuff like this:

  if (!strncasecmp(argv[1], "on") ||
     !strncasecmp(argv[1], "enable" ||
     !strncasecmp(argv[1], "true" ||
     [...]

This CL uses parse_bool instead of that kind of thing so I don't
have to remember which commands use "enable" and which use "on"
and so forth.

I only changed the commands that Cr50 uses.

BUG=none
BRANCH=none
TEST=make buildall; test on Cr50 hardware

I tested all the affected commands to ensure that they still work
correctly: usb, ccd, flashwp (which doesn't do anything anyway).

Change-Id: I7d875ab22934fb4b500e3d0f62ebe3e04101272d
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/373658
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-08-22 23:27:24 -07:00
Vadim Bendebury
bccd2f94f1 g: implement firmware upgrade protocol version 3
This patch modifies CR50 code to switch to firmware update protocol
version 3. In this version both SPI and USB updates use exactly the
same messages (apart from the size field added by USB to help
reassembly of the fragmented frames).

Bot unused RO and RW sections can be now programmed.

BRANCH=none
BUG=chrome-os-partner:55789
TEST=on a Kevin running the existing cr50 image programmed the new
     cr50 image, restarted the device, programmed the cr50 image again
     (this time using version 3), restarted the device, then
     programmed both RO and RW images and restarted the device. Each
     time verified that the proper image is running.

Change-Id: I0cf196ec6de1786510433f8252164a33ccdc6dec
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/371941
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2016-08-22 23:27:23 -07:00
Martin Roth
56cf05339f chip/g/sps: Initialize received_data pointer to NULL
I don't think that the received_data pointer in sps_rx_interrupt can
actually be used without initialization in the current code flow, but
GCC 5.3 thinks that it can, and throws an error.

sps_check_rx() always sets the pointer or returns 0.  In either case
we should be ok, but initializing it to null here won't hurt anything
since it's not masking an actual error.

BUG=None
BRANCH=None
TEST=Build all boards successfully.

Change-Id: Idaea7efd1af3067c492a3ade4c89104e975f4c1d
Signed-off-by: Martin Roth <martinroth@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/370663
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Reviewed-by: Mary Ruthven <mruthven@chromium.org>
2016-08-22 23:27:18 -07:00
Dino Li
f729672b66 it83xx: lpc: add support 'CONFIG_KEYBOARD_IRQ_GPIO' and fix lpc_init()
1. To assert keyboard IRQ GPIO pin instead of SERIRQ if keyboard data
   ready to send.
2. Clear STATUS_PROCESSING bit in lpc_init() to avoid host waiting after
   a sysjump.
3. Save and restore event masks while doing a sysjump.

Signed-off-by: Dino Li <dino.li@ite.com.tw>

BRANCH=none
BUG=none
TEST=1. keyboard work normally if host support this keyboard interrupt.
     2. Software sync done and jumping to RW and boot to kernel.
     3. EC generate SCI normally after a sysjump.

Change-Id: Ib0d9785106d4d4d21f8e9a6d1f0548f187fa7976
Reviewed-on: https://chromium-review.googlesource.com/372499
Commit-Ready: Dino Li <Dino.Li@ite.com.tw>
Tested-by: Dino Li <Dino.Li@ite.com.tw>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-08-22 23:27:05 -07:00
Bill Richardson
9a59b5ea9c g: Remove unused CONFIG_RBOX_DEBUG feature
This feature is not enabled, is awkwardly written, and shouldn't
be left lying around to use as a bad example. This CL doesn't
change any compiled code.

A followup CL will add a working RBOX interrupt handler.

BUG=none
BRANCH=none
TEST=make buildall; test on Cr50 hardware

Change-Id: I5d0701f55ab9521bf1f29e7ec18994c4401d68fb
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/373600
Tested-by: Mary Ruthven <mruthven@chromium.org>
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
2016-08-22 14:52:26 -07:00
Mulin Chao
746eb2c600 npcx: Apply deep idle bypass for hibernate
Although probability is small, we still have chance to encounter the same
symptom which CPU's behavior is abnormal after wake-up from deep idle.
Apply the same bypass in task.c but not enable interrupt to solve it.

Modified sources:
1. system.c: Apply deep idle bypass for hibernate.

BRANCH=none
BUG=chrome-os-partner:34346
TEST=make buildall; test "hibernate"&"hibernate 10" on wheatley.

Change-Id: Ib00b9932ac34414d6a177d60668664ab31284a79
Signed-off-by: Mulin Chao <mlchao@nuvoton.com>
Reviewed-on: https://chromium-review.googlesource.com/373300
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Amit Maoz <Amit.Maoz@nuvoton.com>
2016-08-22 14:52:22 -07:00
Bill Richardson
d614eaf1bf g: Remove obsolete spstpm command
At one time we could switch between TPM and HC protocols on the
SPI slave bus. We disabled the HC protocol long ago with commit
e4690f6152. This CL removes the spstpm command, since there's
no longer any point to having a console command to disable the
TPM protocol too (which would leave us with nothing listening to
incoming traffic on the SPI bus).

BUG=none
BRANCH=none
TEST=make buildall; test on Cr50 hardware

Change-Id: Ic5028dfc1631fab4ddf2584635cb48be50d05d4d
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/373638
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
2016-08-22 14:52:14 -07:00
Dino Li
ecd98091c1 it83xx: add reset cause of reset pin
If reset was caused by reset pin, we need this reset cause
for next sequence(recovery key).

Signed-off-by: Dino Li <dino.li@ite.com.tw>

BRANCH=none
BUG=none
TEST=To assert EC WRST pin and we will get the reset cause for
     both power-on and reset-pin.

Change-Id: I0361091680a148df07cbbb8f4e53635dbf48fdee
Reviewed-on: https://chromium-review.googlesource.com/371798
Commit-Ready: Dino Li <Dino.Li@ite.com.tw>
Tested-by: Dino Li <Dino.Li@ite.com.tw>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-08-22 02:37:54 -07:00
Dino Li
81fd1393fa it83xx: fix i2c module
1. If one i2c transaction includes timeout and done events
   at the same time, the transaction result will be timeout.
   Fixed: The transaction is succeed instead of timeout.

2. The interrupt of i2c will not be enabled if an i2c write transaction
   is split into two or more xfer.

Signed-off-by: Dino Li <dino.li@ite.com.tw>

BRANCH=none
BUG=none
TEST=1. Console commands:'i2cscan', 'i2cxfer', and 'battery'.
     2. Use two or more i2c_xfer(the first with flag 'I2C_XFER_START'
        and the last with flag 'I2C_XFER_STOP') to do a i2c write
        transaction and no error.

Change-Id: Ieb2cb229748ac9504cf1636a2826bbb3097aa55c
Reviewed-on: https://chromium-review.googlesource.com/360762
Commit-Ready: Dino Li <Dino.Li@ite.com.tw>
Tested-by: Dino Li <Dino.Li@ite.com.tw>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-08-22 00:11:58 -07:00
Kevin K Wong
46dc172711 npcx: set the BUSY bit while handling ACPI command write.
BUG=chrome-os-partner:55583
BRANCH=none
TEST=verified OBF status is cleared during idle without event which
     means kernel driver waited for the BUSY bit and read the data.

Change-Id: I79357fea5483fe7a175c60f54235926e105ec832
Signed-off-by: Kevin K Wong <kevin.k.wong@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/373043
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-by: Mulin Chao <mlchao@nuvoton.com>
2016-08-21 15:52:09 -07:00
Nick Sanders
cc68693cda sweetberry: add i2c support
stm32f446 has two types of i2c blocks, the traditional
stm i2c, and "fast mode plus" i2c, which need different drivers.

This commit adds both, muxed in i2c-stm32f4, as the ec
codebase doesn't really support multiple types of the same interface.

BUG=chromium:608039
TEST=i2c works on all 4 channels
BRANCH=None

Change-Id: I6a9ac632f44142bd809ffee5782a192ae47af1f0
Signed-off-by: Nick Sanders <nsanders@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/368358
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2016-08-21 04:11:10 -07:00
Vadim Bendebury
153c2cf49c usb_updater: host side support protocol version 3
This patch introduces support for the cr50 firmware update protocol
version 3. It is described in more details in the comment in the
patch, the bottom line is that both RO and RW updates are supported,
and SPI and USB modes use the same protocol now.

The notions of PDU (protocol data unit) passed between the host and
the programming function on the CR50 is introduced, and USB mode
framing is described.

BRANCH=none
BUG=chrome-os-partner:55789
TEST=verified that version 1 and 2 updates still work. Version 3 mode
      was tested later, when the device side patches were applied.

Change-Id: If51854b6a0b140730e85853bc42039233550fe8c
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/371509
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2016-08-21 04:10:38 -07:00
Vadim Bendebury
44930bef40 g: usb_updater: clean up update protocol handling
In preparation of introducing new update protocol version this patch
cleans up the existing implementation.

The receive and transmit PDU headers are separated into their own
structures and are now shared between the server and client sides.

Some comments have been added to better explain different protocol
versions' details.

BRANCH=none
BUG=chrome-os-partner:55789
TEST=verified that it is still possible to update RW_A and RW_B on a
     Kevin CR50, works using both USB and SPI.

Change-Id: Ied65b2c2a7800bae045f1d2dd64e58dd5e793d27
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/368989
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-by: Mary Ruthven <mruthven@chromium.org>
2016-08-21 04:10:33 -07:00
Shawn Nematbakhsh
152dd753e0 Revert "shi: Enable SHI interrupt from CS interrupt"
This reverts commit 77ae58a3a3. Host
command interface still getting wedged.

BUG=chrome-os-partner:55710,chrome-os-partner:55795,chrome-os-partner:56254
BRANCH=None
TEST=None

Change-Id: I2a4d39d222ebfd9aa78cc9f5231c38ebd50e80ce
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/373739
2016-08-21 00:27:56 +00:00
Shawn Nematbakhsh
77ae58a3a3 shi: Enable SHI interrupt from CS interrupt
Enable the SHI interrupt only after we have received and begun
processing our host command. Disable the SHI interrupt once our
transaction is complete (with either success or error status). This will
prevent the SHI interrupt from being asserted at the same time as the CS
interrupt, which can lead to the SHI interrupt being serviced first.
Also, it avoids needless, non-useful SHI interrupts during error
transactions.

BUG=chrome-os-partner:55710,chrome-os-partner:55795,chrome-os-partner:56254
BRANCH=None
TEST=Manual on gru. Stress test flashrom w/ unpowered Donette attached
(for host command spam), verify no errors encountered after 100 minutes.
Also verify host command interface functions properly after sysjump.

Change-Id: I41e3deb382897cd4286e6ac96f4f3066bf7a94a7
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/371510
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Mulin Chao <mlchao@nuvoton.com>
2016-08-20 23:11:23 +00:00
Furquan Shaikh
cb4b9f9fac chip/npcx/lpc: Fix SCI and SMI generation
Following steps need to be followed for SCI/SMI generation:
1. If automatic mode is being used, set SCIE/SMIE bit in HIPMIE register
during lpc_init. This step needs to be performed only once.
2. If SCI/SMI generation is required, set ST1/ST2 bit in HIPMST register
during update_host_event_status.
3. In lpc_generate_sci/smi, if automatic mode is being used, set
SCIB/SMIB bit in HIPMIC register.

BUG=chrome-os-partner:55489
BRANCH=None
TEST=lidclose behavior verified in kernel.

Change-Id: Ib6e0ee32bc06a8c51297010ac4843a7de45a99bd
Signed-off-by: Furquan Shaikh <furquan@google.com>
Reviewed-on: https://chromium-review.googlesource.com/371059
Commit-Ready: Furquan Shaikh <furquan@chromium.org>
Tested-by: Furquan Shaikh <furquan@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Mulin Chao <mlchao@nuvoton.com>
2016-08-19 14:21:25 -07:00
Vadim Bendebury
8a2fbe288b g: report RW header version along with code revision
Header version fields are instrumental when determining which of the
available images is started by the RO. Let's include the header
version when reporting the RW images' version as well as RO.

BRANCH=none
BUG=none

TEST=verified that RW header information is now included in the
     version command output:

     > vers
     Chip:    g cr50 B2
     Board:   0
     RO_A:  * 0.0.8/8755904e
     RO_B:    -1.-1.-1/ffffffff
     RW_A:    0.0.1/cr50_v1.1.5093-751a584+
     RW_B:  * 0.0.1/cr50_v1.1.5093-d27f65f
     Build:   0.0.1/cr50_v1.1.5093-d27f65f
     ...

Change-Id: I675c473a277e272f55670324fafdab8a6e6edd78
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/370939
Reviewed-by: Scott Collyer <scollyer@chromium.org>
2016-08-19 14:21:23 -07:00
Nick Sanders
6fcd163da5 stm32f446e-eval: add support for stm32f446
This adds basic support for the stm32f446.
This consists of:
* New DMA model for stm32f4
* New clock domain support.
* MCO oscillator gpio export support.
* Flash support for irregular blocks.

BUG=chromium:608039
TEST=boots w/ correct clock, stm32f0 also boots.
BRANCH=None

Change-Id: I1c5cf6ddca09009c9dac60da8a3d0c5ceedfcf4d
Signed-off-by: Nick Sanders <nsanders@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/363992
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
2016-08-17 16:19:07 -07:00
Levi Oliver
1d4d1942b8 btle: Improved stability of ble_tx function
ble_tx now resets values that could prevent its functioning.

Since there is no NRF51 shortcut from TX->RX, it also blocks until
packet is transmitted. This prevents calling RX before TX is completed,
specifically in advertising state.

Also added timeouts to prevent possibility of freezing in case of
unexpected state.

TEST=Used function before and after CL in a more fully implemented stack.
This improved reliability.
BUG=None
BRANCH=None

Change-Id: I6a5b0b6f36e37ac0102d254bbdc9dfcd29694bb8
Signed-off-by: Levi Oliver <levio@google.com>
Reviewed-on: https://chromium-review.googlesource.com/370597
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2016-08-17 12:49:22 -07:00
Levi Oliver
5a013c26ca btle: Improved stability of ble_rx function
TEST=Used function before and after CL in a more fully implemented
stack. This improved reliability and lengthened connection times.
BUG=None
BRANCH=None

Change-Id: I60680c8855d6166e4e4a6a71639ee57464fa21ce
Signed-off-by: Levi Oliver <levio@google.com>
Reviewed-on: https://chromium-review.googlesource.com/370420
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2016-08-16 00:58:03 -07:00
Mary Ruthven
e7bdf36f34 cr50: delay sleep for 3 minutes after resuming from sleep or after init
Disable sleep for the first 3 minutes after initializing cr50 and
disable sleep for 3 minutes after a wakepin interrupt has been received.

BUG=none
BRANCH=none
TEST=manual
	on a development board pull up dioa3 and dioa12 then verify cr50
	does goes to sleep after 3 minutes.

	on gru see sleep is delayed by 3 minutes when the wakeup
	interrupt is called.

	enable deep sleep and check cr50 does not go to sleep for 3
	minutes after resuming.

Change-Id: I28ec3c2f5f86326b926d403ad52ffb4fc108e7ec
Signed-off-by: Mary Ruthven <mruthven@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/367880
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
2016-08-14 02:03:21 -07:00
timothytim
8e512d9d7d Release EC_RST_L in RW after all initialization has completed
Adding a lowest priority hook init function, guaranteed to run after
all other initialization is completed, which is a good time to take
the EC out of reset.

Also moving pin hold release into the same function.

BRANCH=none
BUG=chrome-os-partner:55797
TEST=verified proper reset pulse generated on reef
     verified that reef, kevin and gru all boot up as expected

Change-Id: Ic91e871f5040b9aa02a2f11cf76d2d596c48a04c
Signed-off-by: Timothy Chen <timothytim@google.com>
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/367410
Reviewed-by: Marius Schilder <mschilder@chromium.org>
2016-08-13 17:31:34 -07:00
Mulin Chao
e0497b041a npcx: Fixed pwm bug to improve deviation of PWM frequency.
According the formula for computing prescaler of PWM, we needn't minus
one again in line 89 of pwm.c. On npcx's evb, we observe the deviation
of PWM 1 which freq is 10K is reduced from 0.6 kHz to 0.01 kHz. We also
change PWM 1's freq to 100 Hz with PWM_CONFIG_DSLEEP and the deviation
is reduced from 64.2 Hz to 9.2Hz.

Modified sources:
1. pwm.c: Modifed formula for computing prescaler of PWM.

BRANCH=none
BUG=chrome-os-partner:56052
TEST=make BOARD=npcx_evb; use "pwm 1 50" to observe deviation of freq

Change-Id: I9cd7fc0d807df62083d49a7e9ec6de1d9028be1b
Signed-off-by: Mulin Chao <mlchao@nuvoton.com>
Reviewed-on: https://chromium-review.googlesource.com/368560
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-08-12 20:49:49 -07:00
Levi Oliver
31f297da0b btle: Timeout of ble_rx now based on chip time
Previously, timeout meant the number of attempts taken to receive. Now,
it means the number of microseconds before timing out.

TEST=printouts displaying time before and after rx attempt. Not included
in CL.
BUG=None
BRANCH=None

Change-Id: I00ccfc4bbf15f77c2777f35c911dceacaff98e4f
Signed-off-by: Levi Oliver <levio@google.com>
Reviewed-on: https://chromium-review.googlesource.com/368471
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2016-08-12 20:49:45 -07:00
Martin Roth
079a0f0e68 npcx/flash: Don't print uninitialized values
In command_flash_spi_sel_lock(), and command_flash_tristate() a value
could be printed without being initialized first.

Only display the values in the paths where the variable gets read.

BUG=None
TEST=Build and boot Reef
BRANCH=None

Change-Id: I8ef86f966d017290491d6fe2b1486ce913cd09fb
Signed-off-by: Martin Roth <martinroth@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/368301
Reviewed-by: David Hendricks <dhendrix@chromium.org>
2016-08-12 13:45:18 -07:00
Levi Oliver
bf302b55e9 btle: Add framework for parsing data packets
Re-wrote ble_radio_init to work with both data and
advertising packets. Updated all calls to refactored function.

RADIO_PCNF0_ADV renamed because it applies to advertisement and
data packet formats. Updated all references to this value.

TEST=make BOARD=hadoken
BUG=None
BRANCH=None

Change-Id: I0fdbe0eb146ce5cbc40e3ac67bf4d0e5465dcc2f
Signed-off-by: Levi Oliver <levio@google.com>
Reviewed-on: https://chromium-review.googlesource.com/367732
Commit-Ready: Myles Watson <mylesgw@chromium.org>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Myles Watson <mylesgw@chromium.org>
2016-08-11 14:46:32 -07:00