Commit Graph

3525 Commits

Author SHA1 Message Date
Vic Yang
48eed0bebc bq27541: report battery present state
The battery driver is not reporting battery present state, and as a
result, is_present flag always remain NOT_SURE. Fix it.

BRANCH=Ryu
BUG=None
TEST=On Ryu, 'chgstate' and see 'is_present = YES'.

Change-Id: I84bedc390158797bf1e67e612d0bb3f526292dfa
Signed-off-by: Vic Yang <victoryang@google.com>
Reviewed-on: https://chromium-review.googlesource.com/242970
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Commit-Queue: Vic Yang <victoryang@chromium.org>
Tested-by: Vic Yang <victoryang@chromium.org>
2015-01-24 01:45:47 +00:00
Vincent Palatin
6f4af26809 pd: poll PD events only on Google accessories
Poll USB PD accessories for event log entries only after we have
performed a Discover Identity and identified them as a Google device
(USB VID = 0x18d1) in order to avoid confusing third party devices with
our logging VDM.

Signed-off-by: Vincent Palatin <vpalatin@chromium.org>

BRANCH=samus
BUG=chrome-os-partner:35858
TEST=connect Zinger to Samus and see the proper PD log entries.

Change-Id: I022fa0d19dc012e46a27b786a724ff251280eeaf
Reviewed-on: https://chromium-review.googlesource.com/242871
Reviewed-by: Todd Broch <tbroch@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
2015-01-24 00:32:33 +00:00
Myles Watson
c171751654 driver: BQ27621 scaling bug fix
Design capacity and Design Energy need to be multiplied by the scaling factor.

BUG=None
TEST=Manual test with hadoken without charging enabled.  Observed the battery
level decreasing.
BRANCH=NONE

Change-Id: Icb5f74766c2416128277df4fe1bb00fc7307f5e5
Signed-off-by: Myles Watson <mylesgw@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/242890
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-01-24 00:32:29 +00:00
Myles Watson
4ada7739f9 nrf51: implement soft reset and hard reset
TEST=manual test with the console command.  Reset flags are set correctly.
BRANCH=NONE
BUG=None

Change-Id: I3ea4301206be6fe4e79a4b49c002c020980c516d
Signed-off-by: Myles Watson <mylesgw@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/242901
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2015-01-24 00:32:25 +00:00
Myles Watson
ad06ead062 nrf51: add the watchdog registers.
The definitions for the watchdog registers are needed for hard reset.

BRANCH=NONE
BUG=None
TEST=make buildall -j

Change-Id: Ief73b98fbe6fc198c3eda28394e76bdf05568fef
Signed-off-by: Myles Watson <mylesgw@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/242900
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-01-24 00:32:21 +00:00
Alec Berg
35c00bf3d9 pd: fix power swap to sink could get wedged if missing PS_RDY
Fix bug if we are executing a power swap to a sink, and we don't
get PS_RDY from port partner, then we transition to SNK_DISCONNECTED
without switching our power role to sink, which could cause us to
get wedged in the wrong state if we also receive a hard reset a
little later because we will have Rd asserted but are will transition
to source role and can never get out of it.

BUG=none
BRANCH=samus
TEST=load onto two samus' and executing a bunch of power swaps. load
custom code on one samus to never send PS_RDY when switching from sink
to source and make sure when power swap occurs the state machine does
not get wedged with the wrong role.

Change-Id: I7eb2bd4d48f32770b8d7a754fee8ac8da35fa949
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/242760
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2015-01-23 19:56:42 +00:00
Vincent Palatin
ad03068620 lm4: workaround to force __enter_hibernate in SRAM
The new toolchain is putting again the __enter_hibernate function in
flash (.text) rather than in SRAM (.iram.text) after inlining both the
hibernate() and __enter_hibernate() function.
Workaround this issue by forcing "noinline" on __enter_hibernate().

Signed-off-by: Vincent Palatin <vpalatin@chromium.org>

BRANCH=all
BUG=chrome-os-partner:35774
TEST=make BOARD=samus dis
and check the disassembly, the __enter_hibernate is called in SRAM
through a veneer.

Change-Id: I015928ebe18ba8fd93252eece3e8a0fcf4b2a037
Reviewed-on: https://chromium-review.googlesource.com/242691
Trybot-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
2015-01-23 19:56:32 +00:00
Vincent Palatin
3df8bd8772 cortex-m: allow to lock/unlock empty MPU region
When the MPU region to modify is empty (size == 0) returns EC_SUCCESS
rather than EC_ERROR_INVAL, so we are not failing MPU activation on
systems without anything in the .iram.text section.

Signed-off-by: Vincent Palatin <vpalatin@chromium.org>

BRANCH=all
BUG=chrome-os-partner:35774
TEST=on Samus, with WP, try "sysjump disable" on the EC command line
and see "RAM locked. Exclusion 20006ee0-20006ee0" message.

Change-Id: I0103e0f7aa81ee64a70dd47ffb1c50067ce5a6ee
Reviewed-on: https://chromium-review.googlesource.com/242690
Trybot-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
2015-01-23 19:56:17 +00:00
Alexandru M Stan
4a8ce9ac34 Rockchip: Wait till we actually power down in power_off()
If we don't do this, some code later on (like the S3 hook) might check the
POWER_GOOD too early, note that it's on and move to the wrong state:

[8.457344 power button not released in time]
[8.457541 long-press button, shutdown]
// power_off() happens:
[8.459853 power shutdown complete]
[8.593443 power state 7 = S0->S3, in 0x0001]
[8.593653 power state 2 = S3, in 0x0001]
// power_get_signals check happens here ^^^, but POWER_GOOD did not have enough
// time to fall and cause the power_update_signals interrupt
[8.593863 power state 6 = S3->S0, in 0x0001]
[8.594132 power state 3 = S0, in 0x0000]
// system is actually off here

BUG=chrome-os-partner:34816
TEST=Hold Power+Refresh, release after about 10 seconds, the ec should not
have an assertion error and reboot
BRANCH=veyron

Change-Id: Ic7a06a5d255f2b8d056b0b454fc32a4c05c998b4
Signed-off-by: Alexandru M Stan <amstan@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/242620
Reviewed-by: Randall Spangler <rspangler@chromium.org>
(cherry picked from commit 5f954620fa3d36e8e1a88bf7d3963dc7996ec445)
Reviewed-on: https://chromium-review.googlesource.com/242711
2015-01-23 19:55:54 +00:00
Shelley Chen
7e9fc466b0 flash_ec: fixing servo v3 support for beaglebone
Adding setup_openocd function to take care of setup of either servo v2 and or
servo v3 setup (setting up OCD_PATH and OCD_CFG variables).  Have modified
flash_link, flash_lm4, and flash_npcx functions to use setup_openocd function.

BUG=chromium:412249
BRANCH=None
TEST=made sure that outputted flash_ec command lines prior/after change on host
     are identical for link and peppy.  Also made sure that flash_ec command
     works on peppy with updated image on beaglebone.  Also ran "make runtests".

Change-Id: Iacf42fae1f175d6acd08bbd16352afb8f3bd21b0
Signed-off-by: Shelley Chen <shchen@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/242043
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-01-23 00:28:49 +00:00
Vincent Palatin
da733f3aae lm4: ignore overlapping LPC commands
If the AP ignores the LPC_ST_BUSY bit (which is software-defined) and
tries to send a second host command while the first one is still
processed, we discard it.
This doesn't prevent the host to re-write the command arguments stored
in LPC shared mem (aka LPC_POOL_CMD_DATA) but when we will call
host_packet_receive, we will have either the old arguments or the new
arguments (or even a mix of both, which is less unlikely to pass the
checksum check), and we will copy them once before calling the HOSTCMD
task. So the host command task will have a single coherent (not
changing) view of the arguments when performing its input validation.

Signed-off-by: Vincent Palatin <vpalatin@chromium.org>

BRANCH=samus
BUG=chrome-os-partner:31492 chrome-os-partner:23806
TEST=Boot Samus and play with ectool

Change-Id: I9aa1b8cdac05e323b91998188bd873826e83c274
Reviewed-on: https://chromium-review.googlesource.com/242593
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
Trybot-Ready: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Kees Cook <keescook@chromium.org>
2015-01-23 00:28:45 +00:00
Vic Yang
f39dc50213 glower: Set internal VCC_PWRGD to high
The VCC_PWRGD pin is used as an indication of VCC2 state and controls
the internal VCC_PWRGD signal. On Glower, the pin is floating so we
can't use it as is. Instead, configure the pin as a GPIO so that the
internal VCC_PWRGD is gated high.

Without this, nSIO_RESET would be kept asserted and most LPC-related
peripheral won't work.

BRANCH=None
BUG=chrome-os-partner:35308
TEST=Without this, the interrupt status of LRESET# cannot be cleared.
After applying this patch, LRESET# interrupt can be cleared properly.

Change-Id: I6e250b8dff5d38e61ee84500da8236db35395a81
Signed-off-by: Vic Yang <victoryang@google.com>
Reviewed-on: https://chromium-review.googlesource.com/242130
Tested-by: Vic Yang <victoryang@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Queue: Vic Yang <victoryang@chromium.org>
2015-01-23 00:28:40 +00:00
Shawn Nematbakhsh
d71d217ce9 charge state v2: Initialize batt params before inhibiting power-on
If our battery params seem uninitialized when calling
charge_prevent_power_on, try to retrieve them and make a decision based
upon the retrieved data. This should prevent the case where power-up is
incorrectly prevented early in the boot process.

BUG=chrome-os-partner:35762
TEST=Manual on Samus. Write protect unit and run "reboot" from the
console, verify that unit powers up. Verify that unit still correctly
prevents low-power power-on and correctly allows non-low-power power-on.
BRANCH=Samus

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: I9030a2d5e526f4b03996a89bf2c801533683bb67
Reviewed-on: https://chromium-review.googlesource.com/242560
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
2015-01-22 21:15:02 +00:00
Alec Berg
e33c30c149 pd: make sure all host commands range check type-C port arg
Add range checking of type-C port arg to host commands that weren't
already doing so.

BUG=chrome-os-partner:31492
BRANCH=samus
TEST=make -j buildall
> ectool --dev=1 usbpd 2
EC result 3 (INVALID_PARAM)

Change-Id: I0bd7677857f28fc002a039c477e87efa876d0134
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/242423
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2015-01-22 05:13:36 +00:00
Alec Berg
a84e315792 samus: only wake PD task if the task has started
On VBUS event, only wake PD task if task_start() has already
been called.

BUG=none
BRANCH=samus
TEST=make buildall. use similar patch on ryu and sysjump
back and forth while toggling vbus and make sure we don't
crash.

Change-Id: I79152cd2325949dea080d432d80600ff62d37085
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/242231
Reviewed-by: Vic Yang <victoryang@chromium.org>
2015-01-21 23:39:16 +00:00
Alec Berg
83b4a9644e samus: lightbar: Set tap for battery red threshold to match kernel
Set the battery threshold for tap for battery to show red to match
the kernel percentage at which the battery icon turns red. This
threshold is 14% real battery percentage which is equivalent to 10%
battery for what the user is shown.

Note: due to rounding we may still be off, but this closes the window
at which these will differ.

BUG=chrome-os-partner:35664
BRANCH=samus
TEST=make buildall. compare to CL:48904 where we made a similar change
for the lightbar color to turn red when running.

Change-Id: I31d3c4544c57bc11967d0ba7a54d26e543f6bf5b
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/242255
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2015-01-21 23:39:11 +00:00
Vic Yang
3120dc950f ryu: Only wake PD task if the task has started
On VBUS event, we should only wake the PD task if task_start() is
already called.

BRANCH=None
BUG=None
TEST=Repeatedly do sysjump while VBUS is toggling. Doesn't see crash
anymore.

Change-Id: Ie37e248b758e81e5fb9b7c1fd89fbff39f036086
Signed-off-by: Vic Yang <victoryang@google.com>
Reviewed-on: https://chromium-review.googlesource.com/242126
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Commit-Queue: Vic Yang <victoryang@chromium.org>
Tested-by: Vic Yang <victoryang@chromium.org>
2015-01-21 20:41:26 +00:00
Vic Yang
10c8a41571 ryu: Remove printf in interrupt handlers
We should avoid printing log in interrupt handlers:
  - Move VBUS logging to a deferred function.
  - Remove unused interrupt handler.

BRANCH=Ryu
BUG=None
TEST=Run on Ryu P3 and see VBUS logging when VBUS changes.

Change-Id: I06ffe62a656d63fdd63b5d1c5e2f6481eeddc445
Signed-off-by: Vic Yang <victoryang@google.com>
Reviewed-on: https://chromium-review.googlesource.com/242180
Tested-by: Vic Yang <victoryang@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Commit-Queue: Vic Yang <victoryang@chromium.org>
2015-01-21 20:41:20 +00:00
Todd Broch
edf0648a0a pd: dingdong/hoho: Disable USB Billboard on mode entry.
If UFP fails to enter mode after tAMETimeout, UFPs should advertise
there USB Billboard class.  If at a later time, DFP does successfully
enter a mode the USB device should disconnect permanently.

Signed-off-by: Todd Broch <tbroch@chromium.org>

BRANCH=samus
BUG=chrome-os-partner:33968
TEST=manual,

Change UFPs response to 'discover identity' to be busy until after
tAMETimeout and see hoho enumerate (18d1:5010).  Then see it
disconnect after DisplayPort mode is entered.

Change-Id: I2d72ed968302fbf74e70f76891a758c47f3773b4
Reviewed-on: https://chromium-review.googlesource.com/242148
Tested-by: Todd Broch <tbroch@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Commit-Queue: Duncan Laurie <dlaurie@chromium.org>
2015-01-21 08:25:47 +00:00
Shawn Nematbakhsh
dd57f6340b samus_pd: Increase pericom debounce time
Increase debounce time to decrease the probability of misidentification
on slow plug insert.

BUG=chrome-os-partner:35633
TEST=Manual on Samus. Plug 1A Apple charger, verify detection is
correct.
BRANCH=Samus

Change-Id: I031f1cfdbf6b2aabe7c8b64e0e6a740d4b5df14d
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/242093
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2015-01-21 06:44:48 +00:00
Eric Caruso
fdf68bdcd2 samus: remove T6, T8, T10 from fan table
These numbers are too low right now and keep the fans going
even in idle states. We should repopulate this table with
better numbers when we get them.

BUG=chrome-os-partner:34598, chrome-os-partner:34789
TEST=flash, check fan rpm
BRANCH=ToT, samus

Signed-off-by: Eric Caruso <ejcaruso@chromium.org>
Change-Id: I651f82610b924ee9f1be5ade856bdc18d7cfc066
Reviewed-on: https://chromium-review.googlesource.com/242042
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2015-01-21 06:44:44 +00:00
Shawn Nematbakhsh
2f6f8b3548 pi3usb9281: Lock access to MUX GPIO while in use
Lock access to the MUX GPIO to prevent other tasks from toggling away
from our active chip while in use.

BUG=chrome-os-partner:35567
TEST=Manual on samus_pd. Boot system, verify that no "write failed"
print is seen. Also verify that charger detection functions as expected.
BRANCH=Samus

Change-Id: Ica02b8fbd8f9ee04f6389ce0b0e5bd58104ff698
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/242125
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2015-01-21 06:44:41 +00:00
Vincent Palatin
194bde6367 ectool: more compact PD event log format
Use one line per entry and display the real time for the events.

Signed-off-by: Vincent Palatin <vpalatin@chromium.org>

BRANCH=samus
BUG=chrome-os-partner:33248
TEST=ectool --name=cros_pd pdlog
and see a nice log like:
2015-01-20 15:14:02.974 P0 Disconnected
2015-01-20 15:14:05.676 P0 SNK Charger Type-C 4958mV max 5000mV / 500mA
2015-01-20 15:14:11.810 P1 SRC
2015-01-20 15:14:14.460 P0 Disconnected
2015-01-20 15:14:17.277 P0 SNK Charger Type-C 5185mV max 5000mV / 3000mA
2015-01-20 15:14:17.287 P0 SNK Charger PD 5015mV max 20000mV / 3000mA
2015-01-20 15:14:17.383 P0 SNK Charger PD 20198mV max 20000mV / 3000mA
--- END OF LOG ---

Change-Id: Ibf189cdb9e5d9ba74cb1fb241a2945439dfb50f7
Reviewed-on: https://chromium-review.googlesource.com/242082
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Commit-Queue: Alec Berg <alecaberg@chromium.org>
2015-01-21 06:44:38 +00:00
Vincent Palatin
b13063c247 pd: retrieve logs from accessories
Send the VDO_CMD_GET_LOG VDM to accessories to get their PD event log
and append it to the PD MCU log.

Signed-off-by: Vincent Palatin <vpalatin@chromium.org>

BRANCH=samus
BUG=chrome-os-partner:33248 chrome-os-partner:32785
TEST=ectool --name=cros_pd pdlog

Change-Id: Ib52d1e2cae5f77dcec6d0489eaa49527388b02b6
Reviewed-on: https://chromium-review.googlesource.com/242013
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Commit-Queue: Alec Berg <alecaberg@chromium.org>
2015-01-21 06:44:33 +00:00
Shawn Nematbakhsh
3075113c85 pd: Clear type-c charge_manager supplier when VBUS disappears
When VBUS is initially present, we set a type-c charge_manager supplier.
Therefore, when we clear our VBUS present flag, we also need to zero our
supplier.

BUG=None
TEST=Manual on Samus. Quickly plug + unplug SDP charger, verify that pd
correctly detects that no charger is present on the board.
BRANCH=Samus

Change-Id: Ie72503f8a9b0f749b7529cfd6ff0675bd5640257
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/242092
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2015-01-21 06:44:26 +00:00
Vincent Palatin
9e07dfb6cb pd: export the data role to the AP
For dual-role USB ports (host/device), let the AP know whether we are
currently DFP (USB host) or UFP (USB device) by exporting the data role
in addition to the power role in the EC_CMD_USB_PD_CONTROL response.

Signed-off-by: Vincent Palatin <vpalatin@chromium.org>

BRANCH=samus
BUG=none
TEST=ectool --name=cros_pd usbpd 0
plug various accessories on the port and see properly "SRC DFP" for the
USB key, "SNK DFP" for the power supply and "SNK UFP" for a regular
C-to-A charging cable.

Change-Id: I292da15fa8cf3566109dd05995ef1d00bed6f92d
Reviewed-on: https://chromium-review.googlesource.com/242012
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Trybot-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
2015-01-21 05:05:53 +00:00
Bill Richardson
43806f07e3 samus: Add scale factor to account for ALS attenuation
This adds a sensor-specific attentuation factor, which will be
applied to the ALS raw sensor readings on the EC. This is to
account for the attenutation due to glass, tinting, etc.

BUG=chrome-os-partner:34590
BRANCH=ToT,Samus
TEST=manual

In a root shell, run this:

  cd /sys/bus/acpi/drivers/acpi_als/ACPI0008:00/iio:device1
  while true; do cat in_illuminance_raw; sleep 1 ;done

Shine a flashlight on the ALS. Note that the readings are 5X
higher than they were before this CL.

Change-Id: I2a53872ecb5fab62e5f443d43588a26d3d7e697f
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/241191
Reviewed-by: Bryan Freed <bfreed@chromium.org>
2015-01-21 05:05:47 +00:00
Alec Berg
b1f0de7b37 zinger: increase time from PD RX edge to allowing sleep to 100ms
Increase the time from the last USB PD RX edge to allow deep sleep
to 100ms to allow us to receive retries if we miss the first attempt.

BUG=chrome-os-partner:34624
BRANCH=samus
TEST=make -j buildall

Change-Id: Id4dd5614b52c9bcd97997e95b0c5f21fbd9b2cf3
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/241954
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2015-01-20 22:10:30 +00:00
Todd Broch
d7f40b91ad pd: Remove verbosity from console during pd flashing.
Commit 74fd6f9 largely got rid of default printing of VDM traffic to console but
one in custom_vdm was missed.  Lets remove it too.  Note can still view these by
'pd dump 1'

Signed-off-by: Todd Broch <tbroch@chromium.org>

BRANCH=samus
BUG=none
TEST=manual when pd flashing samus_pd console (chan usbpd) is quiet.

Change-Id: Idc04750de09572df8d5b15afcdde63f6afc4b5e2
Reviewed-on: https://chromium-review.googlesource.com/241952
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Commit-Queue: Todd Broch <tbroch@chromium.org>
Tested-by: Todd Broch <tbroch@chromium.org>
2015-01-20 20:56:53 +00:00
Divya Jyothi
4353f609aa Strago: emerge-strago build error fixed
TEST=None
BUG=None
BRANCH=None

Change-Id: Ib4c42264f105ac96558e4a03f22f9b71b2781c11
Signed-off-by: Divya Jyothi <divya.jyothi@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/240930
Reviewed-by: Vic Yang <victoryang@chromium.org>
2015-01-20 20:56:49 +00:00
Vic Yang
8a5c38420b Initial Glower commit
The first commit for the Glower board.

BRANCH=None
BUG=chrome-os-partner:35308
TEST=Boot on Glower and check console is responsive.

Change-Id: I73bc60b8d54b3c570f0822824ad9a66e0fe467a1
Signed-off-by: Vic Yang <victoryang@google.com>
Reviewed-on: https://chromium-review.googlesource.com/239257
Tested-by: Vic Yang <victoryang@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Queue: Vic Yang <victoryang@chromium.org>
2015-01-20 20:56:43 +00:00
Todd Broch
815cb84866 pd: ectool: fix bug in infopddev command.
Change 94515d9e failed to set ec param port prior to sending the host command.

Signed-off-by: Todd Broch <tbroch@chromium.org>

BRANCH=samus
BUG=none
TEST=manual, with two devices with different vid:pid see correct values now.

Change-Id: I6a0b9d30905509847c9481c222fa7e3c9a0264a1
Reviewed-on: https://chromium-review.googlesource.com/241951
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Commit-Queue: Todd Broch <tbroch@chromium.org>
Tested-by: Todd Broch <tbroch@chromium.org>
2015-01-20 20:56:38 +00:00
Shawn Nematbakhsh
310b1df076 samus_pd: Allow system to be locked
BUG=chrome-os-partner:35128
TEST=Manual on samus. Run "sysinfo" on pd console, verify unlocked flag.
Run "flashwp enable" then "reboot" then "sysinfo". Verify locked flag.
Remove WP screw then "reboot". Verify unlocked flag.
BRANCH=Samus

Change-Id: I93182c428ad6855e9107c3f0575a42ced4ff47a0
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/241520
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Commit-Queue: Shawn N <shawnn@gmail.com>
2015-01-20 03:36:31 +00:00
Alec Berg
a0c5faf1a1 pd: fix bug where sysjump could cause PD state to wedge
Fix bug in USB PD initialization after a sysjump. Since the CC pull
resistors weren't being initialized after a sysjump, we would sometimes
end up stuck in sink debounce state because we would have Rp applied
and our initial state of sink disconnected would think that a source
was attached. And since we continued to apply Rp, we would never make
a connection with a charger, so we would be stuck in sink debounce
until a reboot.

BUG=chrome-os-partner:35608
BRANCH=samus
TEST=load on samus and keep rebooting and sysjumping and making sure
that we don't falsely go to the sink debounce state.

Change-Id: Ic81fe02be78f3f4ffe00e3e3e378f5befe8545a5
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/241874
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2015-01-19 23:37:45 +00:00
Alec Berg
83ef084f95 pd: fix PD power swap when lots of protocol erros
Fix a couple bugs that cause problems when executing a power
swap with a poor PD connection.

1) If we are a sink switching to a source and we have turned on
vbus and then get an error, then make sure to turn off vbus.
2) If we are a sink switching to a source and we receive a
redundant PD_RDY, then ignore it.

BUG=chrome-os-partner:32392
BRANCH=samus
TEST=load on samus and connect port 0 to 1 creating a poor
PD connection with a lot of retries and missed responses. with
this change, I swapped power ~20 times with "pd 0 swap power"
and each time it was eventually successful.

Change-Id: Ib6b97961c7e40186a14ca1d2922b2ce6a6598180
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/241872
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2015-01-19 22:19:21 +00:00
Alec Berg
476e1cedae pd: set previous protocol state appropriately after a hard reset
Set the PD protocol last state to hard reset when executing a
hard reset. This fixes a bug in which if we receive a hard reset
while in one of the hard reset recovery states the last state
doesn't change, which means we don't restart timeout periods and
it is possible to be indefinitely stuck in the hard reset recovery
state until PD MCU reboots.

BUG=none
BRANCH=samus
TEST=when connecting samus port 0 to port 1 we get a very crappy
PD connection and about 1 in 5 times it causes us to get stuck in
SNK_HARD_RESET_RECOVER until a reboot. with this fix, we never get
stuck.

Change-Id: I294462ffa56a804ca613535ab9bdc466175f8066
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/241871
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2015-01-19 22:19:17 +00:00
Alec Berg
cea3f26d5d charge state v2: allow boot without battery when unlocked
Change charge_state_v2 to set the maximum input current limit when
there is no battery present AND the system is not locked. This allows
us to boot without a battery.

Note that using the max input current limit may cause us to overcurrent
our charger, but that's no worse than putting a limit on it and having
the system brownout. Either way you must have a high enough power
charger to boot without a battery.

BUG=chrome-os-partner:35570
BRANCH=samus
TEST=load on samus, remove battery and plug in zinger. check "charger"
has input current limit of 8128mA, and on PD MCU jump back and forth
between RO and RW and make sure system doesn't power off. Note that
without this CL, if you sysjump on the PD MCU it causes input current
limit to reset to 500mA and causes AP to shutoff.

Change-Id: Ie13d97a6b5c0937510cff0cf05fb032898c3b131
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/241762
Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
2015-01-19 22:19:11 +00:00
Duncan Laurie
9da3dfb29f charge_state_v2: Fixes for battery present reporting
Fix some issues with how the battery present flag is reported
up to the host.

If there is no battery presence GPIO or custom function then
errors updating the smart battery info can result in the
battery present flag reporting BP_NOT_SURE and indicating to the
host that the battery is missing.  In order to prevent spurious
events require a second back-to-back read of a missing battery
before the host is notified.

When the battery presence does change, the host needs to be told
to re-read the static battery info with EC_HOST_EVENT_BATTERY,
passed to the OS via Notify command to tell the OS to re-execute
_BIF/_BIX method on the ACPI battery device.

When sending these events to the host the battery flags should
first be updated in LPC shared memory so if the host handles
the event quickly it will read the correct updated flags value.

BUG=chrome-os-partner:34011
BRANCH=broadwell
TEST=manual testing on samus:
1) add a console command that allows the smart battery update
function to set batt.is_present to BP_NOT_SURE for a specified
number of update cycles.
2) ensure that when the smart battery update only returns the
battery missing for one update cycle that it does not result in
an event to the host.
3) ensure that if the smart battery update indicates the battery
is missing for more than one update cycle, such that the host is
notified the battery is missing, that it correctly gets an event
to re-read the battery info when it is indicated as present again.

Change-Id: I0da004b991ea1a89b34cd7c0f8f3628b813ffe44
Signed-off-by: Duncan Laurie <dlaurie@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/241763
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2015-01-18 22:17:27 +00:00
Shawn Nematbakhsh
7dec6938c9 pi3usb9281: Accept alternate device id
PI3USB9281A is compatible with our existing driver but has a different
device ID.

BUG=chrome-os-partner:35567
TEST=Manual on samus_pd. Verify that "invalid ID 0x18" prints are not
seen on console.
BRANCH=Samus

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: I275ed50fcbcb3c2e385292408be6de51055903fb
Reviewed-on: https://chromium-review.googlesource.com/241764
Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2015-01-18 20:04:58 +00:00
Vic Yang
80aa3da22c Only process console input after console task started
If a character is received between uart_init() and task_start(), we
shouldn't try to wake console task. Usually this shouldn't happen
because the input shouldn't be floating, but still, the EC should not
crash in this case.

BRANCH=None
BUG=chrome-os-partner:35308
TEST=Boot on Glower without servo connected. Check the LED is not
blinking.

Change-Id: I62157c3ecd50b5eca6b09c1cf594b65a605546f9
Signed-off-by: Vic Yang <victoryang@google.com>
Reviewed-on: https://chromium-review.googlesource.com/241512
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Tested-by: Vic Yang <victoryang@chromium.org>
Commit-Queue: Vic Yang <victoryang@chromium.org>
2015-01-17 23:19:58 +00:00
Alec Berg
ca228445cc pd: samus: separate macros for power supply on and off delays
Separate macros for defining delays to turn on and off VBUS on the
Raiden ports.

Tune the delays for Samus to provide extra headroom based off of
measured worst case times.

BUG=chrome-os-partner:34525
BRANCH=samus
TEST=load onto samus. connect two samus' and use twinkie to analyze
time between request and PS_RDY on connect and then on a power swap.

Change-Id: I65cec911e34c22a4aad136423362a3a65bc2ab2a
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/241761
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2015-01-17 23:19:54 +00:00
Alec Berg
7fc407a934 pd: samus: do not request voltage within boost bypass deadband
Do not request a voltage that is within the deadband where we
aren't sure if the boost or the boost bypass is on.

BUG=chrome-os-partner:34938
BRANCH=samus
TEST=test on samus with zinger. change the deadband to [10V, 20V]
and see that we only negotiate to 5V. change the deadband to
[13V, 20V] and see that we negotiate to 12V. change the deadband
to [10V, 13V] and see that we negotiate to 20V.

Change-Id: Id761aef35eeadfa2ab7d2ca31a48d4324625ab32
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/241528
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2015-01-17 23:19:47 +00:00
Shawn Nematbakhsh
1382708858 samus_pd: Restore usb data switches after pericom reset
Resetting the pericom charge detector resets all registers, so it's
necessary to restore the state of the USB data switches, in case we want
them to be open.

BUG=chrome-os-partner:35394
TEST=Manual on Samus. Trigger data swap to UFP, verify that USB switches
become open.
BRANCH=Samus

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: I32b1cf92a05abaab9ecd532537790e72f8f409bc
Reviewed-on: https://chromium-review.googlesource.com/240538
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2015-01-17 20:56:04 +00:00
Shawn Nematbakhsh
6c938998fd samus_pd: Don't re-request FW update if RW is already the latest
The AP informs us of the latest update image for a given device through
the EC_CMD_USB_PD_RW_HASH_ENTRY command. If the latest update image is
equivalent to our RW, we don't need to request an update.

BUG=chrome-os-partner:35510
TEST=Manual on Samus. Flash latest RW FW to Zinger. Verify that
subsequent Zinger insertion doesn't trigger the FW update host event.
Insert RO-stuck Zinger and verify that FW update host event is
triggered.
BRANCH=Samus

Change-Id: I300b150b3469e3fe32307e61273880a1a052ac5a
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/241172
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2015-01-17 20:55:58 +00:00
Vincent Palatin
cd90837bb7 samus_pd: remove asserts
Remove assertions to save flash space :
free up 1728 bytes.

Removing the string in assertions saves 1.1kB.
(aka CONFIG_DEBUG_ASSERT_BRIEF)
Fully removing assertion checks saves an additional 576 bytes.

Signed-off-by: Vincent Palatin <vpalatin@chromium.org>

BRANCH=samus
BUG=chrome-os-partner:34489
TEST=make buildall and check firmware size.
BASELINE 93bb7195
=== build/samus_pd/ ===
FLASH 59.5k / 60.0k  [ text 48.7k rodat 10.7k data  0.1k ]
RAM   11.8k / 16.0k  [ data  0.1k bss   11.7k ]

CONFIG_DEBUG_ASSERT_BRIEF
=== build/samus_pd/ ===
FLASH 58.4k / 60.0k  [ text 48.5k rodat  9.8k data  0.1k ]
RAM   11.8k / 16.0k  [ data  0.1k bss   11.7k ]

undef CONFIG_DEBUG_ASSERT
=== build/samus_pd/ ===
FLASH 57.8k / 60.0k  [ text 48.0k rodat  9.7k data  0.1k ]
RAM   11.8k / 16.0k  [ data  0.1k bss   11.7k ]

Change-Id: Iebcb54ffe2849d1ad911abe1a5e6e21f3120af86
Reviewed-on: https://chromium-review.googlesource.com/241451
Reviewed-by: Todd Broch <tbroch@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
2015-01-17 04:43:09 +00:00
Vic Yang
f2518b9f2d mec1322: Move default header location to 0x0
The current header location is too large for small SPI flash chips.
Since this value is only used for private EC SPI, it doesn't really
matter what it is. Let's just move it to 0x0.

Note that this doesn't affect shared SPI case, as we need a more
sophisticated packer for that.

BRANCH=None
BUG=chrome-os-partner:35308
TEST=Build for Glower and check the size of ec.spi.bin.

Change-Id: I96871d1677999e7cc1c7385b749563b8c09a318a
Signed-off-by: Vic Yang <victoryang@google.com>
Reviewed-on: https://chromium-review.googlesource.com/241114
Tested-by: Vic Yang <victoryang@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Queue: Vic Yang <victoryang@chromium.org>
2015-01-17 01:00:12 +00:00
Vic Yang
1d0a7f8713 mec1322: Fix I2C interrupt bug
On boot, we shouldn't enabled I2C interrupt. The interrupt is only
enabled when we are waiting for data or transfer completion.

BRANCH=None
BUG=chrome-os-partner:35308
TEST=Boot on Glower and do i2cscan.

Change-Id: I534302ac057f2592f52d80d85cee66c35c6121d2
Signed-off-by: Vic Yang <victoryang@google.com>
Reviewed-on: https://chromium-review.googlesource.com/241113
Tested-by: Vic Yang <victoryang@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Queue: Vic Yang <victoryang@chromium.org>
2015-01-17 01:00:07 +00:00
Vic Yang
7e8567fd5e mec1322: Clear interrupt status before enabling GPIO interrupt
Before enabling GPIO interrupts on boot, we should clear pending
interrupt status to make sure the interrupts don't fire unexpectedly.

BRANCH=None
BUG=chrome-os-partner:35308
TEST=Boot on Glower and make sure GPIO interrupts aren't triggered on
boot.

Change-Id: I2729b4a5046063e4ee4c08dcb7084a329bfdf042
Signed-off-by: Vic Yang <victoryang@google.com>
Reviewed-on: https://chromium-review.googlesource.com/241112
Tested-by: Vic Yang <victoryang@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Queue: Vic Yang <victoryang@chromium.org>
2015-01-17 01:00:02 +00:00
Vic Yang
535bbbb774 mec1322: Specify SPI flash size in KB
For boards without a shared SPI, it's reasonable to use a SPI flash
smaller than 1MB. Change the script to allow this.

BRANCH=None
BUG=chrome-os-partner:35308
TEST=Build strago and check the size of ec.spi.bin.

Change-Id: Iabf7065d158be5f82c55e182e430858a12b18b6e
Signed-off-by: Vic Yang <victoryang@google.com>
Reviewed-on: https://chromium-review.googlesource.com/241111
Tested-by: Vic Yang <victoryang@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Queue: Vic Yang <victoryang@chromium.org>
2015-01-16 22:58:02 +00:00
Shawn Nematbakhsh
e4073fdb31 samus_pd: Respond to EC_CMD_PD_HOST_EVENT_STATUS with correct data type
EC_CMD_PD_HOST_EVENT_STATUS should respond with
ec_response_host_event_status, not ec_response_pd_status.

TEST=Manual on Samus. Send EC_CMD_PD_HOST_EVENT_STATUS, verify that
resonse is four bytes.
BUG=chrome-os-partner:35510
BRANCH=Samus

Change-Id: I1a38591c7825f7e71c1fde8f3c1cab4be7852971
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/241193
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2015-01-16 20:37:11 +00:00