Commit Graph

9061 Commits

Author SHA1 Message Date
Fabien Parent
cd89b400a2 charge_manager: handle gracefully dedicated port
charge_manager_fill_power_info can be called to fill the power info
of the dedicated port. This function might call
charge_manager_get_source_current with the dedicated port, we don't
want to use assert in that case, but just fail gracefully by returning
0.

BRANCH=None
BUG=chromium:841944
TEST=Check that the function returns 0 for dedicated and not 0 for USB.

Change-Id: I357c056647e01bdb0e77a08a6c6b492aa3dbb503
Signed-off-by: Fabien Parent <fparent@baylibre.com>
Reviewed-on: https://chromium-review.googlesource.com/1059248
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
2018-05-16 05:08:36 -07:00
Aseda Aboagye
1d114ffa3c nocturne: Fix accel/gyro reference.
The BMI160 driver requires that the macro I2C_PORT_ACCEL is defined.
This commit simply defines that macro and defines a matrix to rotate the
sensor data into the standard frame.

BUG=b:79715267
BRANCH=master
TEST=Flash nocturne, verify that the BMI160 initializes successfully.
Verify that when device is struck from the left edge, positive
acceleration is seen on the X axis.  When device is struck from the
bottom edge, positive acceleration is seen on Y axis.

Change-Id: I6407b21fdfe311fa8ac7d83a8050ebfb27b4e0d8
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/1059535
Commit-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
2018-05-16 05:08:35 -07:00
Nicolas Boichat
9be407f10e chip/npcx: Increase default stack size for tasks
Usually, we enable CONFIG_FPU on NPCX, which requires larger
stack size. Also, NPCX has very deep call patch in I2C transactions
(in particular, I2C recovery path), so it generally requires larger
stack.

To make the code fit, however, we need to reduce the accelerometer
fifo depth from 1024 to 512, on a few boards.

BRANCH=none
BUG=b:75234824
TEST=make buildall -j, stackanalyzer result on poppy looks a little
     better.

Change-Id: I37b5a2a97a760dc4fd225253c23962d74e25605a
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/967963
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2018-05-16 05:08:30 -07:00
Ilja H. Friedel
f139d3a0ca Revert "npcx: CEC: Send CEC message in mkbp event"
This reverts commit 74b5a2ccb5.

Suspected to have broken perf tests by keeping a CPU busy on kevin/bob.

BUG=chromium:842873, b:76467407

Change-Id: Iebbbb4623116840b851656e3ec28e75dc99cff79
Reviewed-on: https://chromium-review.googlesource.com/1060073
Reviewed-by: Ilja H. Friedel <ihf@chromium.org>
Tested-by: Ilja H. Friedel <ihf@chromium.org>
2018-05-15 17:00:53 +00:00
Scott Collyer
f11169fa8d tcpci: Adjust pd task event/wake when processing alerts
Processing of TCPC alerts takes place in the PDCMD task and the result
of processing alerts is to wake the PD task. When the PD task runs,
it's possible that it may attempt to put the TCPC into low power mode
prior to the remainder of the alert processing function completing. So
there may be pending TCPC accesses in the alert handler function which
called subsequent to the PD task putting the TCPC into low power
mode. The TCPC access in the PDCMD task will cause the TCPC to exit
low power mode. With the ANX7447 TCPC, this process will repeat
indefinitely.

This CL replaces the calls to task_set_event and task_wake with
indications stored in a local variable. Then at the end of the
function the task_set_event is made if necessary. This change in order
removes one guaranteed source of pending TCPC accesses from causing
the TCPC to exit low power mode.

BRANCH=none
BUG=b:77544959
TEST=Was using Salea logic analyzer and testing in conjunction with
low power mode. Verified that prior to this change I2C accesses were
attempted and NAKd after the command I2CIDLE was sent on the bus. Also
tested basic type C operation as both SNK/SRC.

Change-Id: I8879c655a48a2b16e0445522497002482dc9ca33
Signed-off-by: Scott Collyer <scollyer@google.com>
Reviewed-on: https://chromium-review.googlesource.com/1044868
Commit-Ready: Scott Collyer <scollyer@chromium.org>
Tested-by: Scott Collyer <scollyer@chromium.org>
Reviewed-by: Jett Rink <jettrink@chromium.org>
2018-05-14 23:56:58 -07:00
Philip Chen
163263c9a3 scarlet: Clamp reported battery SOC when charge terminates
After we set TE (CL:958295), rt946x terminates charging when
the charge current is below IEOC in constant-voltage mode.

When AC is plugged and rt946x terminates, we see cases that
battery SOC falls below BATTERY_LEVEL_NEAR_FULL but rt946x doesn't
re-enable charging yet, which leads to amber LED. The Chrome OS UI
might also show battery is not full in this case.

Let's clamp the reported battery SOC in this scenario to
avoid user confusion.

BUG=b:77870927
BRANCH=scarlet
TEST=When AC is on, charge terminates, and BATTERY_LEVEL_NEAR_FULL
is hit, confirm battery SOC is overwritten.

Change-Id: I4575e562873d149d6f349ddb578334d107e21776
Signed-off-by: Philip Chen <philipchen@google.com>
Reviewed-on: https://chromium-review.googlesource.com/1055194
Commit-Ready: Philip Chen <philipchen@chromium.org>
Tested-by: Philip Chen <philipchen@chromium.org>
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
2018-05-14 23:56:58 -07:00
Philip Chen
492b1aceeb charger/rt946x: Add an interface to check charge termination
After we set TE (CL:958295), rt946x terminates charging when
the charge current is below IEOC in constant-voltage mode.

Let's add an interface to check charge termination status.

BUG=b:77870927
BRANCH=scarlet
TEST=charge scarlet, confirm rt946x_is_charge_done() returns 0 when
battery is charging and returns 1 when charge terminates (battery is
full). Then keep AC plugged and wait, confirm rt946x_is_charge_done()
returns 0 when rt946x restarts charging.

Change-Id: I559d328aa0d7c5c4cd5bf7178370ea039aa80204
Signed-off-by: Philip Chen <philipchen@google.com>
Reviewed-on: https://chromium-review.googlesource.com/1044768
Commit-Ready: Philip Chen <philipchen@chromium.org>
Tested-by: Philip Chen <philipchen@chromium.org>
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
2018-05-14 23:56:57 -07:00
Daisuke Nojiri
fa6c5abae5 ectool: Allow cbi set to accept 4 byte filed
This patch makes 'cbi set' command accept a 4 byte field.

Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>

BUG=b:79514391
BRANCH=none
TEST=Run ectool cbi set 2 0xabc 4 on Nami.

Change-Id: I4ebfa6d35bf6dccbae80ec91ffd6bcc01fec03e5
Reviewed-on: https://chromium-review.googlesource.com/1056199
Commit-Ready: Daisuke Nojiri <dnojiri@chromium.org>
Tested-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2018-05-14 21:29:46 -07:00
Nick Sanders
88ffd86551 servo_v4: add more stack for PD
C0 PD would occasionally get stack overflow.
Add venti stack.

BRANCH=servo
BUG=b:79266510
TEST=no more crash

Change-Id: Id1d7174af954b5e5716ba402ae5b993e2971464d
Signed-off-by: Nick Sanders <nsanders@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1056488
Reviewed-by: Mary Ruthven <mruthven@chromium.org>
2018-05-14 18:56:55 -07:00
Wai-Hong Tam
f8e3859a67 cheza: Disable EC hibernate temporarily
EC can't be waked up once it enters hibernate. Need to figure out the
cause. Disable it temporarily in order not to block others.

BRANCH=none
BUG=b:79348203
TEST=Ran "help" on console and not "hibernate" command.

Change-Id: Ifba2b95df26b03e4389616ebb3fc217bb5a24d54
Signed-off-by: Wai-Hong Tam <waihong@google.com>
Reviewed-on: https://chromium-review.googlesource.com/1050748
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2018-05-14 18:56:53 -07:00
Scott Collyer
cbe7c128d0 charge_state_v2: Add explicit check for battery disconnect state
The charge_prevent_power_on() function checks for battery presence and
its charge level as a condition to prevent AP power on. In order to
deal with the short (up to a few seconds) time window where the fuel
gauge can be read but the discharge FET is not yet enabled, the
status of battery_get_disconnect_state() has been added as a condition
to many board's battery_is_present() function.

The problem with this approach is that the return value of
battery_is_present() is also used by charge_state_v2 as a condition to
force the charge state to ST_IDLE. Then, if the config option
CONFIG_CHARGER_MAINTAIN_VBAT is not defined, the value of requested
current and voltage will be forced to 0 as long as the state remains
in ST_IDLE. When the battery is dead or has been cutoff its discharge
FET will be disabled. In order to for the discharge FET to be enabled
the charger must provide at least a precharge level of current to the
battery. But, if the FET status is used as a condition for
battery_is_present which in turn forces the charge state to ST_IDLE
which can lead to requested_current being forced to 0.

This CL enables a way to remove battery_get_disconnect_state() as a
condition from battery_is_present and instead call
battery_get_disconnect_state() directly in the function
charge_prevent_power_on. Therefore AP power can still be gated by the
battery FET status, but the charge state will not be stuck in ST_IDLE.

This new check is guarded by CONFIG_BATTERY_REVIVE_DISCONNECT. Boards
which currently condition battery_is_present on the value of
battery_get_disconnect_state() don't change at all, but a board which
needs to remove that condition on battery_is_present can still use the
FET check to prevent AP power on.

BUG=b:79133101
BRANCH=none
TEST=Tested on Yorp and verifed that when using either a dead battery
or a battery that had been cutoff, prevent_power_on was set to 1 until
the FET status was correct for the battery to provide power.

Change-Id: Ic27f42610a7b751394b29a013c4dd17030a3df31
Signed-off-by: Scott Collyer <scollyer@google.com>
Reviewed-on: https://chromium-review.googlesource.com/1053095
Commit-Ready: Scott Collyer <scollyer@chromium.org>
Tested-by: Scott Collyer <scollyer@chromium.org>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2018-05-14 18:56:51 -07:00
Philip Chen
82133f4b1c Revert "scarlet: Limit the maximal acceptable VBUS to 9.5V"
This reverts commit 73686dafb0177e44582586b614234eb2e053b5d4.

BUG=b:78792296
BRANCH=scarlet
TEST=none

Change-Id: If36f7b1a470c8476d80e4c0d0ffad49cfdc36e5b
Signed-off-by: Philip Chen <philipchen@google.com>
Reviewed-on: https://chromium-review.googlesource.com/1034106
Reviewed-by: Brian Norris <briannorris@chromium.org>
Commit-Queue: Philip Chen <philipchen@chromium.org>
Tested-by: Philip Chen <philipchen@chromium.org>
Trybot-Ready: Philip Chen <philipchen@chromium.org>
(cherry picked from commit 10050b1ebbcea44fe11b917eb14e8ec84f297949)
Reviewed-on: https://chromium-review.googlesource.com/1055269
Commit-Ready: Philip Chen <philipchen@chromium.org>
Reviewed-by: Philip Chen <philipchen@chromium.org>
2018-05-14 15:33:06 -07:00
Alexandru M Stan
1d518fb85c motion_sense: Lower jitter of EC->AP timestamp
When the EC sends an interrupt to the AP notifying it of new
accelerometer data we need to make sure the spot we record the timestamp
of the event is virtually identical to the spot the AP records the same
point in time.

Therefore a better spot for that is right next to the gpio toggling of
the interrupt line.

BUG=b:67743747
TEST=In the kernel, fifo_info->info.timestamp still has sane values.
TEST=CTS should still pass
BRANCH=master

Change-Id: Ic77101a045123e779f576c46b401c765304976fd
Signed-off-by: Alexandru M Stan <amstan@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/802976
Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2018-05-14 15:32:47 -07:00
Alexandru M Stan
fda59e57ff host: add __hw_clock_source_read
Sometimes common code needs __hw_clock_source_read, add it.

The implementation is similar of what common/timer.c does to create a ts
for get_time(), but in reverse.

TEST=Unit tests pass again for the next CL
BRANCH=master
BUG=None

Change-Id: I10564abedabe88e4789723bc97bac170ae020c69
Signed-off-by: Alexandru M Stan <amstan@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1055191
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2018-05-14 15:32:47 -07:00
Alexandru M Stan
6c2cbf567e zoombini: Disable motion sense FIFO and vsync
zoombini does not have MKBP enabled, it's nonsensical to have the sensor EC
side FIFO enabled. while it does compile (currently) it makes no sense to have
one without the other.

The next patch in this series will add more cross coupling between them (MKBP
set_gpio time will have to be communicated to the sensor fifo code). And
buildall is failing due to this half inclusion.

This patch disables FIFO stuff on zoombini as a fix. With that we also need
to disable the vsync sensor, since that depends on FIFO. #ifdefs everywhere!

TEST=FIFO stuff will not get compiled in when there's no MKBP
TEST=Next patch doesn't fail buildall anymore.
BRANCH=master
BUG=None

Change-Id: I6877fd131b84e9d42f32c5628c928a1355a5774c
Signed-off-by: Alexandru M Stan <amstan@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1055189
Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
2018-05-14 15:32:46 -07:00
Vadim Bendebury
361f3a74ba make: add size calculations
Room remaining in flash is an ever important property of many EC
images. This patch adds a makefile rule with will calculate how much
free room is left in the RW partition with the current image.

The calculation uses two variables set by the linker: 'FLASH' which
shows how much room is allocated to the image and '__image_size' which
shows how much room is actually taken. The difference is how much room
is still available.

Wnen building with V=0, size is not reported.

BRANCH=cr50, cr50-mp
BUG=b:65253310
TEST=observed reported values:
    $ make BOARD=cr50 -j
    ...
    *** 7864 bytes still available in flash on cr50 ****
    $ rm -rf build/cr50/
    $ make BOARD=cr50 CR50_DEV=1 -j
    *** 4488 bytes still available in flash on cr50 ****

Change-Id: I66e23dc72905988b21666c5dc9608d92e3fead50
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1030909
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2018-05-14 12:28:05 -07:00
Jade Philipoom
69d0740bd4 g: add AES CMAC according to RFC 4493
AES-CMAC implementation based on extant 128-bit AES, following closely
to the description in RFC 4493. Timing depends only on the length of the
message, not the content or the keys.

Signed-off-by: Jade Philipoom <jadep@google.com>

BRANCH=cr50
BUG=b:72788497
TEST=Passed the four test vectors provided in the RFC; these tests are defined as commands in aes_cmac.c and can be run with
"test_cmac 1 2 3 4" when CRYPTO_TEST_SETUP is defined.

Change-Id: I96fb4f29927c11970a6a17c0fd583694aa945c91
Reviewed-on: https://chromium-review.googlesource.com/975181
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2018-05-14 03:14:46 -07:00
Jett Rink
5550ae7f8d bip: update flash script to use dut_i2c_mux
Bip has an I2C mux that we need to set before we can program the ITE8320
chip. Set the dut's i2c mux to pass through to the EC.

BRANCH=none
BUG=b:79533605
TEST=flash bip and reef_it8320
CQ-DEPEND=CL:1054559

Change-Id: I690aa253c757c37dfb276d5be897b92a9aa1545e
Signed-off-by: Jett Rink <jettrink@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1054560
Reviewed-by: Furquan Shaikh <furquan@chromium.org>
Reviewed-by: Nick Sanders <nsanders@chromium.org>
2018-05-13 12:00:21 -07:00
Stefan Adolfsson
74b5a2ccb5 npcx: CEC: Send CEC message in mkbp event
Instead of fetching incoming CEC messages using a specific read
command, extend the standard mkbp event so the CEC message can
be delivered directly inside the event.

Signed-off-by: Stefan Adolfsson <sadolfsson@chromium.org>

BUG=b:76467407
BRANCH=none
TEST="ectool cec read" still working with a kernel that has support
for the increased mkbp size.
CQ-DEPEND=CL:1046186,CL:1051085

Change-Id: Id9d944be86ba85084b979d1df9057f7f3e7a1fd0
Reviewed-on: https://chromium-review.googlesource.com/1051105
Commit-Ready: Stefan Adolfsson <sadolfsson@chromium.org>
Tested-by: Stefan Adolfsson <sadolfsson@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2018-05-12 12:06:06 -07:00
Nick Sanders
53f61a76b7 servo_updater: support old and new updater
Add support for usb_updater2 in servo_updater.
This allows update back and forth between servo-9040.B
releases and builds from master, although they have
different updater enpoint interfaces.

Also add '-n' no force reboot to usb_updater2 as force reboot
is incompatible with servo_updater's flow.

BRANCH=None
BUG=b:69016431
TEST=update servo v4

Change-Id: I18809590c2e7e1cfcf60c4c97e956dfc22d85856
Signed-off-by: Nick Sanders <nsanders@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1056157
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
2018-05-11 23:22:26 -07:00
Caveh Jalali
0b6da3c5d8 charge_state_v2: keep track of AC_PRESENT flag
the EC should not clear the AC_PRESENT flag in the ACPI flags when we
know that we're on a charger.  ACPI rules on the AP side do special
things when they see AC_PRESENT off, like forcing the EC to limit the
charge current to 512mA.

BUG=b:78509594
BRANCH=none
TEST=chargestate current no longer stuck at 512mA

Change-Id: I54ddea6d2661a9d6b1593431a5912a8a60db572d
Signed-off-by: Caveh Jalali <caveh@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1050917
Commit-Ready: Caveh Jalali <caveh@google.com>
Tested-by: Caveh Jalali <caveh@google.com>
Reviewed-by: Duncan Laurie <dlaurie@google.com>
Reviewed-by: Jett Rink <jettrink@chromium.org>
2018-05-11 23:22:15 -07:00
Daisuke Nojiri
344e8220b5 lm3509: Avoid setting brightness to 100% on power-up
This patch makes lm3509 avoid setting the LED brightness to 100% on
power-up. It removes brighness control from lm3509_power entirely.
The brightness is controlled by the OS.

Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>

BUG=b:78360907
BRANCH=none
TEST=Verify keyboard backlight turn on off on Nami as expected. No
flashing on start-up or resume is observed.

Change-Id: Ife82c83501d57aeb540acb1cccb95597fd1d19a0
Reviewed-on: https://chromium-review.googlesource.com/1054408
Commit-Ready: Daisuke Nojiri <dnojiri@chromium.org>
Tested-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
2018-05-11 12:10:44 -07:00
Daisuke Nojiri
94b4c511a6 kblight: Add keyboard backlight control module
This patch promotes board/nami/keyboard_backlight.c to common
directory.
Board customization is done via board_kblight_init callback.
It currently supports two drivers: direct PWM control and lm3509.

Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>

BUG=b:78360907,b:78141647
BRANCH=none
TEST=On Nami (for lm3509) and Sona (pwm), verify the followings:
1. Alt + brightness up/down works
2. After suspend-resume, brightness is restored
3. Lid close/open
4. After screen is off, keyboard backlight is turned off

Change-Id: I584c06e8702fe7b289999698f277311cfd3400bd
Reviewed-on: https://chromium-review.googlesource.com/1051027
Commit-Ready: Daisuke Nojiri <dnojiri@chromium.org>
Tested-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
2018-05-11 12:10:44 -07:00
Daisuke Nojiri
f21a0681c7 Nami: Read CBI early and cache it
This patch adds a HOOK_INIT handler which reads CBI. This handler runs
as early as I2C controller is ready so that all subsequent code can refer
to cached CBI.

Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>

BUG=none
BRANCH=none
TEST=Verify CBI is read reliably on Nami at boot.

Change-Id: I979947d6bd63ce0cdc1400ba561c543d9ed7b40e
Reviewed-on: https://chromium-review.googlesource.com/1054341
Commit-Ready: Daisuke Nojiri <dnojiri@chromium.org>
Tested-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
2018-05-11 12:10:43 -07:00
Stefan Adolfsson
89b8653e70 npcx: CEC: Add unit suffixes
Add unit suffixes to all timing constants and variables so it is
clear that it is ticks, not usec we are dealing with.

Signed-off-by: Stefan Adolfsson <sadolfsson@chromium.org>

BUG=b:76467407
BRANCH=none
TEST=emerge chromeos-ec
CQ-DEPEND=CL:1030371

Change-Id: I02883108b6f844a7a2d8f0fcd75edaecbbb8e403
Reviewed-on: https://chromium-review.googlesource.com/1046186
Commit-Ready: Stefan Adolfsson <sadolfsson@chromium.org>
Tested-by: Stefan Adolfsson <sadolfsson@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2018-05-11 09:30:36 -07:00
Stefan Adolfsson
6415c19415 CEC: Group ectool subcommands under "ectool cec"
Instead of e.g. "ectool cecwrite", use "ectool cec write" to
not clutter the command list.

BUG=b:76467407
BRANCH=none
TEST=Run "cec read/write/get/set" and make sure they still
work.
CQ-DEPEND=CL:1030218

Change-Id: Id515782f5a5ff0861fb95ab63c45dc8ab153f0bb
Signed-off-by: Stefan Adolfsson <sadolfsson@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1046185
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
2018-05-11 09:30:36 -07:00
Stefan Adolfsson
64cf05b7e8 npcx: CEC: Respect the present initiator free-time
When sending multiple frames, the free-time is a bit
higher to make it easier for other senders to get
a chance to send.

Signed-off-by: Stefan Adolfsson <sadolfsson@chromium.org>

BUG=b:76467407
BRANCH=none
TEST=none
CQ-DEPEND=CL:1030370

Change-Id: I19e510ec0b6e987e0d8477fa5549e0b29ef594ee
Reviewed-on: https://chromium-review.googlesource.com/1030371
Commit-Ready: Stefan Adolfsson <sadolfsson@chromium.org>
Tested-by: Stefan Adolfsson <sadolfsson@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2018-05-11 09:30:35 -07:00
Stefan Adolfsson
ad01d0518b npcx: CEC: Get/set logical address
Logical address selection is best done from the AP since
it depends on what kind of CEC device type we want to be.

Signed-off-by: Stefan Adolfsson <sadolfsson@chromium.org>

BUG=b:76467407
BRANCH=none
TEST=Set address to different values and verify that it
only receives messages on that address (or broadcast)
CQ-DEPEND=CL:1030229

Change-Id: Ia5ef182b22f2345831caaa7f29cc9f009f932c99
Reviewed-on: https://chromium-review.googlesource.com/1030370
Commit-Ready: Stefan Adolfsson <sadolfsson@chromium.org>
Tested-by: Stefan Adolfsson <sadolfsson@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2018-05-11 09:30:35 -07:00
Stefan Adolfsson
edac0b1924 npcx: CEC: Add software debouncing
If pulses shorter than the CEC specification allows are detected,
ignore the bus for a while. This avoids CPU stress if there is a
misbehaving device sending short pulses on the CEC bus.

Signed-off-by: Stefan Adolfsson <sadolfsson@chromium.org>

BUG=b:76467407
BRANCH=none
TEST=none
CQ-DEPEND=CL:1030228

Change-Id: I55819f9437a00799718e235c30f256508465bf4c
Reviewed-on: https://chromium-review.googlesource.com/1030229
Commit-Ready: Stefan Adolfsson <sadolfsson@chromium.org>
Tested-by: Stefan Adolfsson <sadolfsson@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2018-05-11 09:30:34 -07:00
Stefan Adolfsson
394ede0e6e npcx: CEC: Improve pulse-width measurements
Take into account the time from the interrupt is triggered until
the timer is set when recharging the timer.

Signed-off-by: Stefan Adolfsson <sadolfsson@chromium.org>

BUG=b:76467407
BRANCH=none
TEST=Using temprorary debug-prints.
CQ-DEPEND=CL:1030227

Change-Id: Ia36bd73ff5efcff719db7b7915212f30a8e555f3
Reviewed-on: https://chromium-review.googlesource.com/1030228
Commit-Ready: Stefan Adolfsson <sadolfsson@chromium.org>
Tested-by: Stefan Adolfsson <sadolfsson@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2018-05-11 09:30:34 -07:00
Stefan Adolfsson
38d90756cb npcx: CEC: Event-handling for incoming messages
When an incoming message is complete, store it in a
internal circular buffer and notify the AP so the
message can be read out.

Signed-off-by: Stefan Adolfsson <sadolfsson@chromium.org>

BUG=b:76467407
BRANCH=none
TEST=Write different type of messages from one EC to another EC
using ectool. Also use ectool on the second EC to verify that
they are received correctly.
CQ-DEPEND=CL:1030226

Change-Id: Ie4370b0c954befe81a055cd5dff7d7f13dbefbd0
Reviewed-on: https://chromium-review.googlesource.com/1030227
Commit-Ready: Stefan Adolfsson <sadolfsson@chromium.org>
Tested-by: Stefan Adolfsson <sadolfsson@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2018-05-11 09:30:34 -07:00
Stefan Adolfsson
8ba061a449 npcx: CEC: Handle incoming CEC messages
Adds handling of incoming messages:
* Start-bit detection
* ACK incoming messages
* Broadcast handling
* Pulse-width validation
* EOM detection

Signed-off-by: Stefan Adolfsson <sadolfsson@chromium.org>

BUG=b:76467407
BRANCH=none
TEST=Tested in later CL when messages are plumbed all the
way back to the AP.
CQ-DEPEND=CL:1030225

Change-Id: I541072b8afa3d911b310628f09f0b665f11a0a15
Reviewed-on: https://chromium-review.googlesource.com/1030226
Commit-Ready: Stefan Adolfsson <sadolfsson@chromium.org>
Tested-by: Stefan Adolfsson <sadolfsson@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2018-05-11 09:30:33 -07:00
Stefan Adolfsson
ea5d72e85b npcx: CEC: Add bus-contention handling
If low-impedance is detected during the time from free-time
until the end of the initiator address, the current send is
postponed until the bus is free again.

Signed-off-by: Stefan Adolfsson <sadolfsson@chromium.org>

BUG=b:76467407
BRANCH=none
TEST=none
CQ-DEPEND=CL:1030224

Change-Id: If4b9ed43306cf2e38770085603f7fa83a1f76ddc
Reviewed-on: https://chromium-review.googlesource.com/1030225
Commit-Ready: Stefan Adolfsson <sadolfsson@chromium.org>
Tested-by: Stefan Adolfsson <sadolfsson@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2018-05-11 09:30:33 -07:00
Stefan Adolfsson
e317b78cd3 npcx: CEC: Handle enable/disable command
The Linux kernel has enable/disable hooks in the CEC
driver API. Make it possible to use those calls on
the EC CEC implementation.

Signed-off-by: Stefan Adolfsson <sadolfsson@chromium.org>

BUG=b:76467407
BRANCH=none
TEST=Verify with logical analyzer that nothing happens on
the bus in disable mode and it still works in enable mode.
CQ-DEPEND=CL:1030223

Change-Id: Ib5255d76427f288862740cd2e3299ba47f39d998
Reviewed-on: https://chromium-review.googlesource.com/1030224
Commit-Ready: Stefan Adolfsson <sadolfsson@chromium.org>
Tested-by: Stefan Adolfsson <sadolfsson@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2018-05-11 09:30:32 -07:00
Stefan Adolfsson
2d1d3d68b0 npcx: CEC: Notify AP of CEC send result
Signed-off-by: Stefan Adolfsson <sadolfsson@chromium.org>

BUG=b:76467407
BRANCH=none
TEST=ectool cecwrite with and without sink. Reports
success if there is a sink, else it fails.
CQ-DEPEND=CL:1030222

Change-Id: I28f12fd8e226e1e261efaeeefe60f257c0afadf9
Reviewed-on: https://chromium-review.googlesource.com/1030223
Commit-Ready: Stefan Adolfsson <sadolfsson@chromium.org>
Tested-by: Stefan Adolfsson <sadolfsson@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2018-05-11 09:30:32 -07:00
Stefan Adolfsson
1ddb719bd0 npcx: CEC: Add resend-logic to CEC driver
According to the CEC specification, a resend must be
attempted at least once and up to five times after NAK.
This fix does it five times.

Signed-off-by: Stefan Adolfsson <sadolfsson@chromium.org>

BUG=b:76467407
BRANCH=none
TEST=Write CEC message without sink. Verify with logical
analyzer that it resends 5 times.
CQ-DEPEND=CL:1030221

Change-Id: Id296e12b6657b9e7ca0453a2deb06e8aaf17f839
Reviewed-on: https://chromium-review.googlesource.com/1030222
Commit-Ready: Stefan Adolfsson <sadolfsson@chromium.org>
Tested-by: Stefan Adolfsson <sadolfsson@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2018-05-11 09:30:31 -07:00
Stefan Adolfsson
e89486c9b6 npcx: CEC: Write messages on the CEC bus
Add hooks that ectool or AP will use to send CEC messages.
Messages are sent by setting a timer and flipping
a GPIO in the timer interrupt. The timer is then
recharged in inside that interrupt depending on
where it is in the CEC state-machine.

Signed-off-by: Stefan Adolfsson <sadolfsson@chromium.org>

BUG=b:76467407
BRANCH=none
TEST=Switched on and off a TV:
ectool cecwrite 0x40 0x04
ectool cecwrite 0x40 0x36
CQ-DEPEND=CL:1030220

Change-Id: Ia640d0d035bcee9be88863046e88402c7a63c19f
Reviewed-on: https://chromium-review.googlesource.com/1030221
Commit-Ready: Stefan Adolfsson <sadolfsson@chromium.org>
Tested-by: Stefan Adolfsson <sadolfsson@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2018-05-11 09:30:31 -07:00
Stefan Adolfsson
802337c26d npcx: CEC: Add stub implementation of CEC
Add CEC stub implementation and enable it for Fizz. All
it does is print a message when the driver is initialized.

Signed-off-by: Stefan Adolfsson <sadolfsson@chromium.org>

BUG=b:76467407
BRANCH=none
TEST=Check that "CEC initialized" is printed on the
console when the EC boots.
CQ-DEPEND=CL:1030219

Change-Id: I1cf674e664e091354e344e0c08a69bd09f415904
Reviewed-on: https://chromium-review.googlesource.com/1030220
Commit-Ready: Stefan Adolfsson <sadolfsson@chromium.org>
Tested-by: Stefan Adolfsson <sadolfsson@chromium.org>
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
2018-05-11 09:30:31 -07:00
Philip Chen
13ea63266c scarlet: Enable AP throttling for battery OCP
BUG=b:74321682
BRANCH=scarlet
TEST=manually test on scarlet together with CL:994188

Change-Id: I831ca9941248835f98a1c5ea69e751f3f7413ed7
Signed-off-by: Philip Chen <philipchen@google.com>
Reviewed-on: https://chromium-review.googlesource.com/1043454
Commit-Ready: Philip Chen <philipchen@chromium.org>
Tested-by: Philip Chen <philipchen@chromium.org>
Reviewed-by: Philip Chen <philipchen@chromium.org>
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
2018-05-11 02:58:50 -07:00
Philip Chen
43db76c108 Revert "scarlet: Limit the maximal acceptable VBUS to 5.5V"
This reverts commit c4e728e6f991537b5e0f715c4f9e946b029d5bd8.

BUG=b:78792296
BRANCH=scarlet
TEST=none

Change-Id: I4dc73e85cc7883ef4b2ab83da4d671a7709d9fd3
Signed-off-by: Philip Chen <philipchen@google.com>
Reviewed-on: https://chromium-review.googlesource.com/1054121
Commit-Ready: Philip Chen <philipchen@chromium.org>
Tested-by: Philip Chen <philipchen@chromium.org>
Reviewed-by: Philip Chen <philipchen@chromium.org>
2018-05-11 02:58:49 -07:00
Fabien Parent
e4b718df7a charge_manager: fix possible out of bound read access
The port id given by the kernel is never checked and out-of-bound
read accesses can be made on available_charge. Fix it.

Change-Id: I06ed3d28c30db77d8256e9af808484a7cbdc901e
Signed-off-by: Fabien Parent <fparent@baylibre.com>
Reviewed-on: https://chromium-review.googlesource.com/1046592
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
2018-05-11 02:58:46 -07:00
Fabien Parent
7034d8b711 charge_manager: add host cmd to get port count
The kernel is only able to know the number of USB PD port through
EC_CMD_USB_PD_PORTS, but the kernel needs also to be able to know
that there is a dedicated port. Add a host command that will
return the total number of charge port (USB PD + BJ).

BRANCH=None
BUG=chromium:841944
TEST=Called command from kernel driver and checked that the port count
was the expected value.

Change-Id: I6ccd8a2dee35bbe8bb66dfbe09d1cc09c54b73a0
Signed-off-by: Fabien Parent <fparent@baylibre.com>
Reviewed-on: https://chromium-review.googlesource.com/1046593
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
2018-05-11 02:58:45 -07:00
Philip Chen
bf62593ebd charge_state_v2: Throttle AP in high battery discharge current
When EC sees discharge current hit BAT_MAX_DISCHG_CURRENT,
we kick off a timer and ask AP to throttle.

Then EC keeps monitoring discharge current. If the current doesn't
drop below BAT_MAX_DISCHG_CURRENT - BAT_OCP_HYSTERESIS, we restart
the timer and notify AP again, which shouldn't happen unless
AP misses or ignores the first notification.

When the timer expires, which means EC hasn't seen over-current
for BAT_OCP_TIMEOUT_US, we ask AP to stop throttling.

BUG=b:74321682, chromium:838754
BRANCH=scarlet
TEST=manually test on scarlet, confirm EC sends
EC_HOST_EVENT_THROTTLE_START and EC_HOST_EVENT_THROTTLE_STOP
host events when entering/exiting OCP.

Change-Id: I1e55fc23249596d8afec52a3885655ca9c1f2151
Signed-off-by: Philip Chen <philipchen@google.com>
Reviewed-on: https://chromium-review.googlesource.com/994188
Commit-Ready: Philip Chen <philipchen@chromium.org>
Tested-by: Philip Chen <philipchen@chromium.org>
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-by: Matthias Kaehlcke <mka@chromium.org>
2018-05-10 19:41:04 -07:00
Jett Rink
ec1428f96d yorp: increase current limit
We need to increase our current limit so we don't trip when we are right
at 3.0A.

BRANCH=none
BUG=b:79482290
TEST=yorp can now source 3A

Change-Id: If90af7e6eeaf90d3bd0ac67462e94523d2348a0a
Signed-off-by: Jett Rink <jettrink@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1053238
Reviewed-by: Furquan Shaikh <furquan@chromium.org>
Reviewed-by: Scott Collyer <scollyer@chromium.org>
2018-05-10 15:10:16 -07:00
Nick Sanders
1356a1a5b7 usb_updater2: match by serial number
Add a serial number match to allow update of servo or
other usb devices, where mutliple devices may be attached
to one system.

BRANCH=None
BUG=chromium:718688
TEST=usb_updater2 -d 18d1:501b --serial=[C1706311869|fail]

Signed-off-by: Nick Sanders <nsanders@chromium.org>
Change-Id: Id6ec944139e685948433af703555fd185e91a9d4
Reviewed-on: https://chromium-review.googlesource.com/1050971
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
2018-05-10 02:27:11 -07:00
Ruben Rodriguez Buchillon
3db5a829b0 powerlog: allow port & addr in the .board file
Allow board & addr in the board file instead of channel, to make board
file creation and configuration simpler.
This is part of the efforts in the BUG to make sweetberry under chrome
os simpler to use. In that case, we allow now (with crrev.com/c/1051215) to
generate .board files using explicit pin and bank numbers (j2,j3,j4).

BRANCH=None
BUG=chromium:806148
TEST=manual test, works fine.

Change-Id: I6fd3bb1a4a5ffffee08b81625ecb190adceeb2e7
Signed-off-by: Ruben Rodriguez Buchillon <coconutruben@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1051212
Reviewed-by: Nick Sanders <nsanders@chromium.org>
2018-05-10 02:27:09 -07:00
Stefan Adolfsson
bdc8b02528 Fizz: Add GPIOs used for CEC
The Fizz hardware has three pins for CEC. One GPIO is used
as a pull-up. It is always an output and always high. The
second GPIO is a data output. The third GPIO is the data
input that can also be configured as a timer input (TA1).

Signed-off-by: Stefan Adolfsson <sadolfsson@chromium.org>

BUG=b:76467407
BRANCH=none
TEST=Read and write the newly added GPIOs using ectool

Change-Id: Ia33b36a0cdaa40fd1a4f7aa66a092b5833bf5cf8
Reviewed-on: https://chromium-review.googlesource.com/1030219
Commit-Ready: Stefan Adolfsson <sadolfsson@chromium.org>
Tested-by: Stefan Adolfsson <sadolfsson@chromium.org>
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
2018-05-10 02:27:07 -07:00
Stefan Adolfsson
436dd71e5d CEC: Add cecset/cecget to ectool
Set and get CEC parameters. Currently supported
parameters are "enable" and "address"

Signed-off-by: Stefan Adolfsson <sadolfsson@chromium.org>

BUG=b:76467407
BRANCH=none
TEST=Using EC firmware with CEC support, set values
and read them back.
CQ-DEPEND=CL:1030217

Change-Id: I429710f5d8897b23c5b5e54bd10cbf38d1830811
Reviewed-on: https://chromium-review.googlesource.com/1030218
Commit-Ready: Stefan Adolfsson <sadolfsson@chromium.org>
Tested-by: Stefan Adolfsson <sadolfsson@chromium.org>
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
2018-05-10 02:27:07 -07:00
Stefan Adolfsson
1c941f01db CEC: Add cecread command to ectool
Wait for a CEC event and read out the new message.

Signed-off-by: Stefan Adolfsson <sadolfsson@chromium.org>

BUG=b:76467407
BRANCH=none
TEST=Using EC firmware with CEC support:
ectool cecread -- -1
Turn on TV, cecread says the same as logical analyzer
CQ-DEPEND=CL:1030216

Change-Id: Iadd2fcfad0dc647aaaa9bd8a04c5c0f582259af5
Reviewed-on: https://chromium-review.googlesource.com/1030217
Commit-Ready: Stefan Adolfsson <sadolfsson@chromium.org>
Tested-by: Stefan Adolfsson <sadolfsson@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2018-05-10 02:27:06 -07:00
Stefan Adolfsson
d81f36efce CEC: Wait for send-event after cec writes in ectool
For factory testing purposes, make the cecwrite
return-value depend on whether it got an ACK from the sink.

Signed-off-by: Stefan Adolfsson <sadolfsson@chromium.org>

BUG=b:76467407
BRANCH=none
TEST=Using EC firmware with CEC support, ectool cecwrite with
and without sink
CQ-DEPEND=CL:1030215

Change-Id: I681243f74e4745796ac8d50e60dc0f7f9c087335
Reviewed-on: https://chromium-review.googlesource.com/1030216
Commit-Ready: Stefan Adolfsson <sadolfsson@chromium.org>
Tested-by: Stefan Adolfsson <sadolfsson@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
2018-05-10 02:27:06 -07:00