Commit Graph

7782 Commits

Author SHA1 Message Date
Vincent Palatin
406302ffb0 twinkie: enable WebUSB
Prepare the future and return a WebUSB descriptor to be able to use the
dongle from this website.

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

BRANCH=twinkie
BUG=none
TEST=manual: enumerate WebUSB descriptors with lsusb and connect to
a WebUSB page in Chrome R61+.

Change-Id: I6a36538667ac114fc4b40cb87b2d6e946e265c4d
Reviewed-on: https://chromium-review.googlesource.com/677285
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-09-25 11:32:18 -07:00
Gwendal Grignou
2faae86c08 Kahlee: FIXUP: Optimize g-sensor setting
Kionix Accel does not have FIFO, enable force mode for it.
Chrome needs sensor for screen orientation, set to to 10Hz
in S0 in the EC.

BRANCH=none
BUG=b:62029360
TEST=none

Change-Id: I5545580f2073e9d1145bd86cfcd594164119cae7
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/675575
Tested-by: Gwendal Grignou <gwendal@google.com>
Reviewed-by: Gwendal Grignou <gwendal@google.com>
2017-09-24 00:02:04 -07:00
Aseda Aboagye
1914a56ebc zoombini: Enable TCPC interrupts.
The TCPC interrupts were setup, but they weren't enabled yet.  This
commit enables the interrupts.

Additionally, a "tcpcdump" debug command is added.  This can be removed
later or expanded upon to be more generic.

BUG=None
BRANCH=None
TEST=Flash zoombini;  Verify that we respond to TCPC alerts.

Change-Id: Iba9523cbfb96a570b76e7bdc0ba21dd782854f24
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/670063
Commit-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-09-23 11:27:29 -07:00
Daisuke Nojiri
cbfb59f118 Fizz: Pulse LED using deferred call
This patch makes LED pulse using deferred call to save RAM and
CPU cycles.

This patch also adds led_alert API. It blinks LED as a warning.

BUG=b:37646390
BRANCH=none
TEST=Verify LED on in S0, pulse in S3, and off in S5.
Run 'led alert' command.

Change-Id: I8c61f91f095eed562d2ee9582868879241df626f
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/675749
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-09-22 13:22:54 -07:00
Vincent Palatin
77f011206c Add WebUSB descriptor support
The WebUSB specification defines a specific Platform Descriptor in the
Binary Object Store:
https://wicg.github.io/webusb/#webusb-platform-capability-descriptor
This descriptor provides a special 'Landing page' URL to the host
browser and associated privileges for it.

Bump the USB version for BOS descriptors to 2.1 to be compatible with
Chrome implementation.

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

BUG=none
BRANCH=twinkie
TEST=manual: on Twinkie (chip/stm32) and HG proto2 (chip/g), enumerate
WebUSB descriptors with lsusb and connect to a WebUSB page in Chrome
R61+.

Change-Id: I7211ab554f4a6c156c1e8e79a3d9f0d6644217c6
Reviewed-on: https://chromium-review.googlesource.com/664813
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-09-22 10:18:50 -07:00
Furquan Shaikh
e3333972d5 poppy: Dynamically disable effect of SLP_S0# on all VRs
Just setting the global VRMODECTRL register is not enough to disable
the effect of SLP_S0# signal. Each VR control register needs to be set
correctly to ignore the effect as well. However, disabling VR decay on
SLP_S0# assertion by default results in additional power consumption
during S0ix. In order to prevent this, VR decay on SLP_S0# assertion
needs to be enabled and disabled dynamically as follows:

1. By default on EC boot, PMIC will be initialized to disable VR decay
on SLP_S0# assertion.
2. When host indicates intent to enter S0ix, EC will enable decay of
VRs on SLP_S0# assertion.
3. When host exits from S0ix and updates the intent to no longer enter
S0ix using host command, EC will disable decay of VRs on SLP_S0#
assertion.

 actual SLP_S0# assertion because PMIC seems to honor the setting only
 at SLP_S0# assertion and not if it is already asserted.

BUG=b:65732924
BRANCH=None
TEST=Verified with this change that the failing Lux device is stable
for a long time even with runtime S0ix.

Change-Id: I9c5afb408694b3b467e85dcea723f7574bc639c1
Signed-off-by: Furquan Shaikh <furquan@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/674034
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
2017-09-22 10:18:48 -07:00
Furquan Shaikh
f1375bec42 power: Provide chipset and board callbacks on host sleep event command
This change allows chipset and board to perform any action when host
indicates intention to enter sleep state. Chipset can take action like
enable/disable power signal interrupts and boards can enable/disable
decay of VRs on host intent to enter/exit S0ix.

BUG=b:65732924
BRANCH=None
TEST=make -j buildall

Change-Id: I6298825d4ee96a07b93523c2f366527ae2be8a27
Signed-off-by: Furquan Shaikh <furquan@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/677498
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
2017-09-22 10:18:48 -07:00
Vincent Palatin
6f07b9212c twinkie: replace combined firmware bash script
In order to get a Twinkie firmware image with the regular Twinkie sniffer
firmware in the RO partition and a firmware behaving as a USB PD sink in
the RW partition, I had created the (questionable) build_rw_variant bash
script.
Now the EC build can do this natively, so remove the script and the
dedicated task list and use conditional task declaration in the
ec.tasklist.

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

BRANCH=twinkie
BUG=none
TEST=build the former firmware with './board/twinkie/build_rw_variant',
build the new one with this patch and 'make BOARD=twinkie' -j,
compare the 2 resulting binaries, they are identical.

Change-Id: I3adb24e2c2825e5bd6f43a7440f829efd70038cc
Reviewed-on: https://chromium-review.googlesource.com/677284
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-09-22 08:08:57 -07:00
Nicolas Boichat
877842889c charge_state_v2: dump_charge_state: Add cflush
The dump_charge_state (chgstate console command) is quite large,
and may get truncated, let's add 2 cflush at approximately
each third of the output.

BRANCH=none
BUG=b:66575472
TEST=On wand, type chgstate in EC console

Change-Id: Iaa87a6a77b9b6edb0bd8235a87297f8d63fe3085
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/678755
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-09-22 08:08:55 -07:00
Nicolas Boichat
c124d5aeed charge_state_v2: Allow charger operation without a host
update_dynamic/static_battery_info update information in the memmap
shared with the host. When there is not host, these functions
cannot do anything.

The battery information will, eventually, have to be passed to
host (through lid EC), but this will be implemented later.

BRANCH=none
BUG=b:66575472
TEST=make BOARD=wand -j

Change-Id: I1640bb0c5a9eb242183b957ccbef4d4999112160
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/678754
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-09-22 08:08:55 -07:00
Shawn Nematbakhsh
7b473c8efd pd: Apply consistent Rp at boot
CONFIG_USB_PD_MAX_SINGLE_SOURCE_CURRENT Rp is applied when neither port
is a source, so apply it at boot to be consistent.

BUG=chromium:766814
BRANCH=gru
TEST=On kevin, verify 3A Rp is applied to both ports at boot.

Change-Id: Ib62a96063783e8ef9ac9240800f445fa9e5a59af
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/675845
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-09-21 11:54:26 -07:00
Furquan Shaikh
babc3b9e5d poppy/soraka: Do not disable charge port in critical battery state
When battery is at critical charge level, reject charge port disable
request. Since battery is not able to provide enough power to the EC
on boot, we should not cut off our input power, regardless of
dual-role determination or other charging policy.

(Reference:
https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/351224)

BUG=b:64703097
BRANCH=None
TEST=make -j buildall. Verified that both right and left port are
able to boot the EC up successfully. No reboot loops observed in
critical battery conditions.

Change-Id: I098083036388783c0975ac772da3a3412895e26f
Signed-off-by: Furquan Shaikh <furquan@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/675586
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
2017-09-21 01:08:04 -07:00
Daisuke Nojiri
220c75bd16 EFS: Allow EC to switch slot on reboot
Chromebox ECs performs EFS: verifying firmware before the AP boots.
This patch updates host commands which are required for the EFS.

When EC_REBOOT_FLAG_SWITCH_RW_SLOT is specified, EC_CMD_REBOOT_EC
changes the active slot before it reboots the system.

BUG=b:65264494
BRANCH=none
TEST=On Fizz, verify:
1. RW_B is old and updated by soft sync. RW_B is activated and
   executed after reboot. System continues to boot to OS.
2. RW_A is old and updated by soft sync. RW_A is activated and
   executed after reboot. System continues to boot to OS.

Change-Id: I08050c985ce0b27b30cb842e6b5b4660f32e5211
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/648450
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-09-21 01:07:55 -07:00
Daisuke Nojiri
729a4ba2bd EFS: Switch active slot when current slot is invalid
When EFS finds the active slot is invalid, it tries the other slot.
This patch makes the other slot active so that the following boots
will try the other slot first.

This patch also replaces enum flash_rw_slot with system_image_copy_t.
The new APIs are therefore renamed from *_slot to *_copy. Basically,
this makes vboot see slots as a conceptual place instead of physical
spaces bound to flash storage.

BUG=b:65028930
BRANCH=none
TEST=On Fizz, verify:
1. RW_B is old and updated by soft sync. RW_B is activated and
   executed after reboot. System continues to boot to OS.
2. RW_A is old and updated by soft sync. RW_A is activated and
   executed after reboot. System continues to boot to OS.

Change-Id: Icf97da13e651e7a931b9d507052b9422566eb16c
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/648449
2017-09-21 01:07:55 -07:00
Aseda Aboagye
60b77099e0 zoombini: Correct Vbus ADC channel.
The Vbus adc channel was defined as 0 in the enum, however, we don't
actually have a Vbus ADC channel, therefore it should be defined as -1.

BUG=None
BRANCH=None
TEST=Flash zoombini; Verify that when charge manager tries to read the
Vbus voltage, the EC doesn't panic due to a non-existing channel.

Change-Id: I53dd3259afc7ae76f587e5b7925ce2f9daa06402
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/670123
Commit-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-09-21 01:07:53 -07:00
Aseda Aboagye
d9a7b48d35 zoombini: Add Power Switch Logic support.
This commit enables the PSL pins for zoombini.  Previously, we were
initializing the PSL_OUT pin to high, but it actually turns out that
setting the output from a 0 to a 1 indicates that the firmware wants to
remove Vcc1.  This caused the EC to not boot up.  This commit removes
the improper initialization of the GPIO and additionally sets up the
hibernate wake pins accordingly such that they can be used by the PSL
glue logic.

BUG=b:65647213
BRANCH=None
TEST=Flash zoombini without rework.  Verify board comes up okay.
TEST=Enter `hibernate` on console; Verify board goes to sleep.  Verify
that each hibernate wake pins wakes up the board successfully.

Change-Id: Ife1b82eec7957b44bbe409cdeba9c3972168812f
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/670062
Commit-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-09-21 01:07:53 -07:00
Aseda Aboagye
d2e5de8529 zoombini: Update the keyboard config.
The keyboard config was the old chrome OS keyboard, but it should be the
new one introduced in April of this year.

Additionally, change KSO2 inverted to be push-pull instead of open
drain.  This was causing the entire row to not be detected.

BUG=None
BRANCH=None
TEST=Flash zoombini; Verify that every key on the keyboard is detected.

Change-Id: I408739eed84f06bd9a2df5a9053c75859f8aaa0b
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/670061
Commit-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-09-21 01:07:53 -07:00
Aseda Aboagye
cf696d75d5 zoombini: led: Invert duty cycle.
The LEDs were on when they were intended to be off.  This commit just
inverts the duty cycles.

BUG=None
BRANCH=None
TEST=Flash zoombini.  Verify all LEDs are off.  Plug in battery, verify
that Red LED is on.

Change-Id: I78e2bce45603fd223ebaeacb024a210c5db70123
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/670060
Commit-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-09-21 01:07:52 -07:00
Aseda Aboagye
d738db7ede zoombini: Change battery i2c bus speed to 100KHz.
BUG=b:65681152
BRANCH=none
TEST=flash zoombini; verify that smart battery shows up on i2c bus.

Change-Id: Icc38c153b3c140d221e1981cf97dc1ca935d65e2
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/667940
Commit-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
2017-09-20 21:46:09 -07:00
Aseda Aboagye
692033ad6f zoombini: Change TCPC ports to match schematics.
BUG=None
BRANCH=None
TEST=Verify that the TCPC ports correspond to the schematic.

Change-Id: Ic05448b6144754162ced26993948599930307786
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/665893
Commit-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-09-20 21:46:09 -07:00
Gwendal Grignou
ad918d6c56 driver: bm160: Fix minimal gyro frequency
Was set in Hz unit instead of mHz.
The minimal frequency of the gyroscope is 25Hz.
By setting it at 25mHz, we make believe that the gyro was also
supporting 5Hz or 10Hz: the test would complain when instead the samples
came with a 25Hz.

Fix up of cl/482703

BUG=b:65000611
TEST=compile
BRANCH=caroline,eve,twinkie

Change-Id: I162d0d2e9b545af82698d8d484875761f426efe4
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/674003
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2017-09-20 16:37:57 -07:00
Gwendal Grignou
13fcc5ad84 driver: lsm6dsm/lsm6dsl: Fix LSM6DSM_ODR_TO_NORMALIZE macro
Using builtin function in macro.
Compact macros.

BUG=none
BRANCH=master
TEST=Tested on discovery BOARD with LSM6DSM sensor connected
to I2C master interface of target board.
Using accelrate motion sense console command is possible to
test with different data rate: all supported ODR has been tested
for acc and gyro

Change-Id: Icb11f90254521715dfb2abb5bac6eb87ce45b92d
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Signed-off-by: Mario Tesi <mario.tesi@st.com>
Reviewed-on: https://chromium-review.googlesource.com/465375
Commit-Ready: mario tesi <mario.tesi@st.com>
Tested-by: mario tesi <mario.tesi@st.com>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2017-09-20 05:50:22 -07:00
Ryan Zhang
207b3b4e5f Fizz: add CONFIG_LED_COMMON
This is used for factory test with following command

1. ectool command
	ectool led power query
	ectool led power green=100
	ectool led power red=100
	ectool led power amber=100
	ectool led power off
	ectool led power auto

2. console command
	led debug	>> enter debug mode
	led green
	led red
	led amber
	led off
	led debug	>> exit debug mode

BUG=b:65651340
BRANCH=master
TEST=`ectool ...` works good

Change-Id: Icb87e479075d90f509d60121a3e1df0afe66d41f
Signed-off-by: Ryan Zhang <ryan.zhang@quanta.corp-partner.google.com>
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/666418
2017-09-19 21:46:25 -07:00
Daisuke Nojiri
d8612351ea Fizz: Pulse LED
This change makes the power LEDs pulse using PWM.
S0: solid green.
S3: pulsing amber (= mix of green and red)
S5: off

BUG=b:64975836
BRANCH=none
TEST=Verify LED behavior described above on Proto3

Change-Id: I696cf8279dd762236b7b7f000a316820d58916bf
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/669773
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
2017-09-19 21:46:24 -07:00
Philip Chen
253fe7adc3 scarlet: Disable TRY_SRC
BUG=b:65698085
BRANCH=none
TEST=manually on scarlet:
Sink: can be charged with PD charger or 'PD charger through USB-C hub'
Source: can power a usb stick

Change-Id: I7a6541cdc3fdd721ae9529c7dbe422adb0dc3000
Signed-off-by: Philip Chen <philipchen@google.com>
Reviewed-on: https://chromium-review.googlesource.com/669904
Commit-Ready: Philip Chen <philipchen@chromium.org>
Tested-by: Philip Chen <philipchen@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-09-19 17:30:54 -07:00
Aseda Aboagye
d7117c6801 zoombini: Fix WWAN macro.
WIRLESS_SWITCH_WWAN *is* the WWAN power switch.  This commit simply
renames the macro previously defined as WIRELESS_SWITCH_WWAN_POWER.

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

Change-Id: I3d9b1ea03b31702e73c3400b35ac08ea2c3c9f74
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/666290
Commit-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-09-19 17:30:54 -07:00
Philip Chen
5a5fca7753 scarlet: Update the battery capacity to 9000mAh
BUG=b:65422913
BRANCH=none
TEST=manually check capacity from 'battery' ec command

Change-Id: I5e19c4498d635d5e30b28a32085d5f9fc96a0a72
Signed-off-by: Philip Chen <philipchen@google.com>
Reviewed-on: https://chromium-review.googlesource.com/667816
Commit-Ready: Philip Chen <philipchen@chromium.org>
Tested-by: Philip Chen <philipchen@chromium.org>
Reviewed-by: David Schneider <dnschneid@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-09-19 15:42:42 -07:00
Daisuke Nojiri
2f951e9a86 Fizz: Blink power LED in suspend state
BUG=b:37646390
BRANCH=none
TEST=Verify green LED blink in S3 on Fizz proto3.

Change-Id: I055a271e2bb8fd8454d9940c90d5f71cc9025e50
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/669772
2017-09-19 13:26:51 -07:00
Cloud Lin
73b314c1d0 Kahlee: Optimize g-sensor setting
Since we only have one g-sensor, leave it in suspend mode.
And we only use it when we need it

BRANCH=none
BUG=b:62029360
TEST=none
Signed-off-by: cloud lin <cloud_lin@compal.com>

Change-Id: I7ceca0e2b6a4035d6564ac33ab43edeeeca65652
Reviewed-on: https://chromium-review.googlesource.com/643026
Commit-Ready: Daniel Kurtz <djkurtz@chromium.org>
Tested-by: Lin Cloud <cloud_lin@compal.com>
Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
2017-09-18 18:33:01 -07:00
Nicolas Boichat
4bb651b27b hammer: Include hashes in EC image (CONFIG_TOUCHPAD_HASH_FW)
BRANCH=none
BUG=b:63993173
TEST=make TOUCHPAD_FW=SA459C-1211_ForGoogleHammer_3.0.bin \
          BOARD=hammer -j
CQ-DEPEND=CL:641736

Change-Id: Ib9eadfb6be8022f774b770a03480cf8c319a8a5a
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/664501
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-09-15 23:39:26 -07:00
Nicolas Boichat
82e0892fc3 update_fw: Store complete touchpad FW hash
This will be used by the updater to first check that the touchpad
FW on AP side matches the one for which we stored hashes on EC
side.

This guarantee that we do not accidentally try to flash an
incorrect FW, which would render the touchpad non-functional.

BRANCH=none
BUG=b:63993173
TEST=make TOUCHPAD_FW=SA459C-1211_ForGoogleHammer_3.0.bin \
          BOARD=hammer -j
TEST=./usb_updater2 -t
     includes output of
     sha256sum A459C-1211_ForGoogleHammer_3.0.bin

Change-Id: Id30ab2d7c7d7e2d0f25cc893f685d218c44c022e
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/641736
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-09-15 10:50:27 -07:00
Vadim Bendebury
4fdccb6de5 util: fix bug in tagbranch
After mulptiple edits of the script, there is a case when bash
variable is not properly quoted, let's fix it.

BRANCH=cr50
BUG=b:64698702
TEST=verified proper tag description set by git

Change-Id: I5847437cde717bb6e1f4b672fe6008b8e6e6f4e3
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/667917
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-09-15 08:46:32 -07:00
Vadim Bendebury
38650d0b5d util: move 'dirty' marker to be a prefix, not a suffix
With longer git SHA1s reported by git commands and longer version
strings, the entire SHA1 could be not fitting into the 32 byte version
of the VERSION string. So, instead of adding the 'dirty' marker to the
end of SHA1 let's replace the prefix dash with it in case the tree is
dirty.

This way the length of the version string does not change (as long as
the 'dirty' marker is one character long).

BRANCH=cr50
BUG=b:64698702
TEST=verified output of running getversion.sh with a clean tree

   $ ./util/getversion.sh  | grep VERSION32
   #define CROS_EC_VERSION32 "_v1.1.7046-591608e2e"

  and a 'dirty' tree

   $ ./util/getversion.sh  | grep VERSION32
   #define CROS_EC_VERSION32 "_v1.1.7046+591608e2e"

Change-Id: I42684522beaff9e9714206cfaddaf97e6cd644be
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/665958
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-09-15 08:46:32 -07:00
Vincent Palatin
b5d9913241 g: fix short packets on USB control endpoint
In the USB 2.0 specification, the "8.5.3 Control Transfers"
chapter says that "When all of the data structure is returned to the host,
the function should indicate that the Data stage is ended by returning a
packet that is shorter than the MaxPacketSize for the pipe. If the data
structure is an exact multiple of wMaxPacketSize for the pipe, the function
will return a zero-length packet to indicate the end of the Data stage."

When doing a 'Control Read' transfer and the returned data (in IN
packets) was a multiple of MaxPacketSize, we were omitting the
zero-length packet and so the host was blocked waiting for a successful
IN transaction.

This corner-case was a regression introduced by the re-writing of the
control transfer handling done by CL 318864. So the STM32 USB code which
is similar to the former code is dealing properly with this case.

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

BRANCH=cr50
BUG=none
TEST=manual, extend the configuration descriptor to be exactly 64 bytes,
and see the enumeration is no longer failing.

Change-Id: I108e8c6bb9eb727c41f3e1c607f0919fa1192d5a
Reviewed-on: https://chromium-review.googlesource.com/664814
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Marius Schilder <mschilder@chromium.org>
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-09-15 03:08:27 -07:00
Nicolas Boichat
1fe1fbac9f update_fw: Validate touchpad FW hashes before updating
Make use of the generated touchpad firmware hashes to validate
the blocks before writing them to the touchpad.

BRANCH=none
BUG=b:63993173
TEST=make TOUCHPAD_FW=SA459C-1211_ForGoogleHammer_3.0.bin \
          BOARD=hammer -j
TEST=./usb_updater2 -p SA459C-1211_ForGoogleHammer_3.0.bin works
TEST=./usb_updater2 -p SA459C-1211_ForGoogleHammer_4.0.bin fails

Change-Id: If5d2be57b63e16ee81aa9acaf840c5084f9b92de
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/616371
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-09-15 03:08:26 -07:00
Nicolas Boichat
94279fc38f Makefile: Generate hashes for the touchpad FW
Based on the passed TOUCHPAD_FW parameter to the make command, the
build system generates hashes for the touchpad FW.

To generate the hashes, gen_touchpad_hash splits the touchpad FW
in blocks of CONFIG_UPDATE_PDU_SIZE, that are hashed individually
(SHA-256), and then stored in the EC image.

This will allow the USB updater code to verify the integrity of
the touchpad firmware being flashed.

When no FW is provided, zeros are output, which do not match
any valid data.

BRANCH=none
BUG=b:63993173
TEST=make TOUCHPAD_FW=SA459C-1211_ForGoogleHammer_3.0.bin \
          BOARD=hammer -j
TEST=Using variations of
     make TOUCHPAD_FW=SA459C-1211_ForGoogleHammer_3.0.bin \
          BOARD=hammer -j
     make TOUCHPAD_FW=SA459C-1211_ForGoogleHammer_4.0.bin \
          BOARD=hammer -j
     make BOARD=hammer -j
     Check that TPHASH touchpad_fw_hash.h is only regenerated when
     the parameter changes.

Change-Id: Ie347270aa9c00342de13489c9422e45e681b94c2
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/615321
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-09-15 03:08:26 -07:00
Chun-Ta Lin
e18d9dd530 hammer: Support different IC types in touchpad FW update
Some Elan touchpad ICs have a different firmware sizes (48, 56, or 64
KB). We use CONFIG_TOUCHPAD_VIRTUAL_SIZE, set in the board file, to
determine the appropriate size, and, at runtime, we sanity check the
firmware size according to the IC type reported by the touchpad.

BRANCH=none
BUG=b:65188846
TEST=Manually modify the CONFIG_TOUCHPAD_VIRTUAL_SIZE in hammer,
     executed and verified both (1) "EC_ERROR_UNKNOWN" returned
     (2) ic_type shows 0x09 on EC console
TEST=Successfully flashing 48k firmware using CL:658920 on hammer and
     56k firmware on staff. With success here, we specifically test
     with different firmware version and make sure it reflected in
     hammerd's touchpad info.

Change-Id: Ib30917d8376d4a2e8b6137daabad2341ac48d1f8
Signed-off-by: Chun-Ta Lin <itspeter@google.com>
Reviewed-on: https://chromium-review.googlesource.com/664937
Commit-Ready: Chun-ta Lin <itspeter@chromium.org>
Tested-by: Chun-ta Lin <itspeter@chromium.org>
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
2017-09-14 22:25:02 -07:00
Daisuke Nojiri
4566523837 Fizz: Detect BJ as a power source
Proto2 board has the line ADP_IN, which is raised to 2.5 V when a BJ
adapter is plugged. This patch makes EC running on proto2 and above
use this line to detect the power source at boot (as opposed to proto1
guessing a BJ adapter is plugged if PPVAR_BOOSTIN_SENSE is 19v).

BUG=b:37573548
BRANCH=none
TEST=Boot proto3 Fizz on BJ and Type-C.

Change-Id: I4052a73729d62694ce154bfb33255974dc110841
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/626879
2017-09-14 20:14:17 -07:00
Aseda Aboagye
0697132df7 zoombini: Add support for sensor i2c bus.
BUG=None
BRANCH=None
TEST=make -j buildall.

Change-Id: I7f79e01fe2d2004a3e9df733852f25bd89033d58
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/666289
Commit-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-09-14 18:01:52 -07:00
Vadim Bendebury
a26ddda387 utils: a script to help creating EC git tags
The script tries to determine the upstream branch name, and finds out
which is the first sha1 of the current branch.

Then the script tags the branch and generates a git command strings
the operator is supposed to check for sanity and enter to push the new
tag to the server.

With the new tag set each following run of ./util/getversion.sh would
generate version strings including the new tag name and number of
patches above the branch point.

More implementation details are included in the comments in the
script.

BRANCH=cr50
BUG=b:64698702
TEST=tried  the script in cr50 and gru firmware branches:
   cr50$ <path to>/tagbranch.sh
   A new tag 'v1.9308_B.0' has been set. Use the following command
   to push it to the server

   git push --tags https://chromium.googlesource.com/chromiumos/platform/ec v1.9308_B.0

   Or if you want to delete it:

   git tag -d v1.9308_B.0
   cr50$ ./util/getversion.sh | grep -w VERSION
   #define VERSION "_v1.9308_B.192-b5c9d0aa7"
   cr50$
   cr50$ cd <path/to>gru
   gru$ <path to>/tagbranch.sh

   A new tag 'v1.8785_B.0' has been set. Use the following command
   to push it to the server

   git push --tags https://chromium.googlesource.com/chromiumos/platform/ec v1.8785_B.0

   Or if you want to delete it:

   git tag -d v1.8785_B.0

   es^o: ~/new_projects/gru-8785/src/platform/ec 175 > ./util/getversion.sh | grep -w VERSION
   gru$ #define VERSION "_v1.8785_B.218-5d857ed8c"
   gru$

Change-Id: I0c0067f6b7bb837a0c119bc14ff48cb9223a3fa5
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/656575
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-09-14 11:36:37 -07:00
Ryan Zhang
afecf86f44 Coral: expose more data to ectool
Servo / Suzy-Q related debugging methods is a big challenge
in factory especially after servo debug header is removed.

Expose some information to OS from EC will do a great help
for massive production.

+ expose charge/battery related state to ectool
	1. chg_ctl_mode
	2. manual_mode
	3. battery_seems_to_be_dead
	4. battery_seems_to_be_disconnected
	5. battery_was_removed
	6. disch_on_ac (learn mode state)
	7. battery DFET

BUG=b:65265543
BRANCH=master
TEST=`ectool chargestate param x10000~0x20006 get correct state`

Change-Id: Ib64ab3c7b68a634ea098425c93e5234361cd1936
Reviewed-on: https://chromium-review.googlesource.com/662318
Commit-Ready: Ryan Zhang <ryan.zhang@quanta.corp-partner.google.com>
Tested-by: Ryan Zhang <ryan.zhang@quanta.corp-partner.google.com>
Reviewed-by: Scott Collyer <scollyer@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-09-14 11:36:35 -07:00
Vadim Bendebury
857ab8ffa2 cr50: generate self signed images with proper header values
The self signed images generated when running 'make BOARD=cr50' use
constant default values for the epoch, major and minor image header
fields. For the purposes of continuous testing we need the generated
images have sensible values in those header fields.

Since adding a full blown C++ based parser to the signer image is too
much trouble, let's just have a very basic Python based parser, which
pays attention only to the required fields from the current manifest.

BRANCH=cr50
BUG=none
TEST=built the new image and checked its version:
  $ make BOARD=cr50
  ...
  $ ./extra/usb_updater/usb_updater -b build/cr50/ec.bin
  read 524288(0x80000) bytes from build/cr50/ec.bin
  RO_A:0.0.23 RW_A:0.0.23[00000000:00000000:00000000] RO_B:-1.-1.-1 ...

Change-Id: I822475ed0a3c481b08e9268f9c13663b0b132d4a
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/651132
Reviewed-by: Marius Schilder <mschilder@chromium.org>
Reviewed-by: Mary Ruthven <mruthven@chromium.org>
2017-09-13 21:47:07 -07:00
Lin Huang
3c2adda326 battery/max17055: update battery remaining capacity message dynamic
kernel will get the battery info through command "ectool battery",
so we need to get the remaining capacity dynamic.

BUG=b:65494883
BRANCH=none
TEST=run "ectool battery" in kernel, and get the battery info.

Change-Id: Idf824f6dc1e72acd17156c03d81c0ca87adc109f
Signed-off-by: Lin Huang <hl@rock-chips.com>
Reviewed-on: https://chromium-review.googlesource.com/658160
Reviewed-by: Philip Chen <philipchen@chromium.org>
2017-09-13 21:47:07 -07:00
Dino Li
3dc53814db i2c: rand of i2ctest console command is unsigned
We use rand to get timestamp counter low word and do random test
(test_dev = rand % i2c_test_dev_used).
But we will get a negative index (test_dev) if low word larger than
0x80000000 and cause the array to access the wrong locations and
trigger an exception.

This change also fix following error:
error: i2c_s_test may be used uninitialized in this function
[-Werror=maybe-uninitialized]

BRANCH=none
BUG=none
TEST="forcetime 0 0x80000000" then "i2ctest", no exception triggered.

Signed-off-by: Dino Li <Dino.Li@ite.com.tw>
Change-Id: Ia2f5a2ff034a6b7b96f7bd4f3b42bf5645a05aed
Reviewed-on: https://chromium-review.googlesource.com/663110
Reviewed-by: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-09-13 19:28:30 -07:00
Mary Ruthven
af4c8ebcf4 ccd_config: fix ccd_testlab print statement
BUG=none
BRANCH=cr50
TEST=ccd testlab enable/disable works ok

Change-Id: I2414c8b588d7ba78926e7a7aef3459ac7b974d42
Signed-off-by: Mary Ruthven <mruthven@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/665991
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2017-09-13 19:28:29 -07:00
Daisuke Nojiri
d94ed695bd Add USB_CHG_TYPE_DEDICATED
This patch adds USB_CHG_TYPE_DEDICATED to enum usb_chg_type. It's
for dedicated AC adapters like a barrel jack adapter used for Fizz.

BUG=b:65591971
BRANCH=none
TEST=make buildall

Change-Id: Ib883c97eb5e468753c73453d7dedd228547ae025
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/665327
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-09-13 17:13:54 -07:00
Nick Sanders
2de8d9e549 cr50: disable error printout on USB_DT_DEBUG
lsusb scans for USB_DT_DEBUG, which produces logspam
on the cr50 console. This isn't an error, just unimplemented.
Remove the printout.

BRANCH=cr50
BUG=b:65407184
TEST=no logspam on lsusb

Signed-off-by: Nick Sanders <nsanders@chromium.org>
Change-Id: Ib4fc7105015506927f45ee02f587f97e46e1ad9b
Reviewed-on: https://chromium-review.googlesource.com/663786
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-09-13 15:12:02 -07:00
Philip Chen
2be8b69dda scarlet: Define VIRTUAL_BATTERY_ADDR
This routes sbs host requests to virtual battery driver,
even if the board doesn't use a smart battery.

BUG=b:65494883
BRANCH=none
TEST='power_supply_info' from host console

Change-Id: Ie53734b12e9a28ec071d3bf97c9050c0fa075495
Signed-off-by: Philip Chen <philipchen@google.com>
Reviewed-on: https://chromium-review.googlesource.com/664359
Commit-Ready: Philip Chen <philipchen@chromium.org>
Tested-by: Alexandru M Stan <amstan@chromium.org>
Tested-by: Philip Chen <philipchen@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-09-12 23:48:28 -07:00
Vadim Bendebury
092040b0b7 cr50: prepare to release 0.0.24
There are upcoming releases from different branches.

BRANCH=cr50
BUG=b:65128360
TEST=none

Change-Id: I1abf4fe4df90b1b0f93d5d13a8b7e361ba9b2240
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/663425
Reviewed-by: Mary Ruthven <mruthven@chromium.org>
2017-09-12 18:16:28 -07:00
Daisuke Nojiri
117e59cf7b Fizz: Give highest priority to dedicated chargers
This patch gives the highest priority to dedicated chargers. It
means if a dedicated power supply is being connected, other power
supplies such as USB-C adapters will not be recognized as a new
charger.

BUG=b:65059574
BRANCH=none
TEST=Boot Fizz on BJ adapter. Verify plugging in Type-C adapter
doesn't shut down the system.

Change-Id: Ie49b128ae64f917a227f9081148565a3f5356212
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/655638
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-09-12 18:16:27 -07:00