Commit Graph

3189 Commits

Author SHA1 Message Date
Philip Chen
472d50b729 scarlet: Enable software-controlled input current limit
By default the input current on Scarlet is limited to 500mA,
which is defined by ILIM pin.
We need to disable the control from ILIM pin to draw more
current from the source.

BUG=b:64821815
BRANCH=none
TEST=manually monitor the charging current

Change-Id: Ia356a2397b3671c178479a581b44a17215fee83d
Signed-off-by: Philip Chen <philipchen@google.com>
Reviewed-on: https://chromium-review.googlesource.com/639918
Commit-Ready: Philip Chen <philipchen@chromium.org>
Tested-by: Philip Chen <philipchen@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-08-29 19:37:04 -07:00
Aseda Aboagye
88abd3ee72 zoombini: Add USB-A charge control support.
BUG=None
BRANCH=None
TEST=make -j buildall

Change-Id: I8ee0ec01d06343a158f4271e1f9ecdb3d8895659
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/634275
Commit-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-08-28 15:24:10 -07:00
Aseda Aboagye
52789bd7fd usb_port_power_smart: Add CDP/SDP only option.
For some boards, the control lines to the charging port controller are
all tied to a power rail.  In essence, this leaves the ILIM_SEL as the
only signal able to be controlled, which means that we only support
CDP/SDP.

This commit adds a new CONFIG_* option which describes this.

    CONFIG_USB_PORT_POWER_SMART_CDP_SDP_ONLY

Additionally, some cleanup is made to not always assume the number of
smart power ports.

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

Change-Id: I080ccd67ffc20ccccf1e6b33a3cf9374a6b70ad6
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/634274
Commit-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-08-28 15:24:10 -07:00
Randall Spangler
1154a307e1 cr50: Split EC state machine into its own file
The device state machines aren't quite similar enough to use common
code.  Split the EC state machine out, the way we split out BattPrsnt
and CCD_MODE.

BUG=b:35587387
BRANCH=cr50
TEST=manual
	Pull CCD_MODE_L high, so Cr50 detects/enables CCD
	Pull EC_DETECT high.
	reboot -> 'EC RX only', then 'EC on' at 1 second

	Pull EC_DETECT low --> See 'EC off' message
	ccd --> EC UART disabled

	Pull EC_DETECT high --> See 'EC on' message
	ccd --> EC UART RX+TX

	Pull EC_DETECT low for <1 sec then back high
	(don't see EC off/on messages)
	ccd --> EC UART RX+TX

	Reboot with EC_DETECT still low -> EC off at 1 second

	Reboot with EC_DETECT still low and then assert EC_DETECT
	within a second -> EC RX only, then EC connect at 1 second.

Change-Id: I71687e651d625cadd656934f4cb2bbadc0b58816
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/619750
Reviewed-by: Mary Ruthven <mruthven@chromium.org>
2017-08-25 19:54:11 -07:00
Rachel Nancollas
07d646ced0 zoombini: fixed gpio.inc to make power enables push-pull
Made EN_PP3300_TRACKPAD, EN_PP3300_WLAN, and EN_PP3300_WWAN push-pull
and added USB1_ENABLE.

BUG=None
TEST=Check to make sure power enables are not floating.
BRANCH=None

Change-Id: I5e63b61a83e4c5504cead6d7b28d087fc5538c3b
Signed-off-by: Rachel Nancollas <rachelsn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/630056
Commit-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2017-08-25 14:21:38 -07:00
Mary Ruthven
611887143a cr50: add board property functions
Add some board property functions that describe what behavior we are
checking instead of just using board_use_plt_rst. More devices are
getting deep sleep support. This changes some function names to make the
transition easier.

This change adds board_use_deep_sleep and board_detect_ap_with_tpm_rst.
Right now both of these just call board_use_plt_rst. This will
eventually change with the expansion of deep sleep to new devices.

BUG=none
BRANCH=cr50
TEST=run firmware_Cr50DeepSleepStress with 10 suspend/resume cycles

Change-Id: I8d9ef23f686dea788d26ac4973054ad027fdd3a4
Signed-off-by: Mary Ruthven <mruthven@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/633891
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
2017-08-24 17:20:42 -07:00
Furquan Shaikh
c859c057e1 poppy: Enable base on sysjump
Now that we enable base only on chipset state transition, sysjump
needs to be handled in a special way. On sysjump if chipset is already
in S0, then enable base right away.

BUG=b:64987346
BRANCH=None
TEST=Verified that base is enabled and connected on sysjump. Tablet
mode events work again in evtest.

Change-Id: I917b0ca84d2735a4f2b32ecea3d310eccb7c008c
Signed-off-by: Furquan Shaikh <furquan@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/631218
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
2017-08-24 01:25:52 -07:00
Ryan Zhang
f9a2ef2347 Coral: Fix FAFT failure for firmware_ECUsbPorts
+ Follow Change#386854
+ Remove gpio41: gpio41 is used for ADC and already exist.

BUG=b:64738358
BRANCH=master
TEST=`make -j BOARD=coral`, `firmware_ECUsbPorts` passed on santa MB
Signed-off-by: Ryan Zhang <ryan.zhang@quanta.corp-partner.google.com>

Change-Id: I1c08c68c5449a94a333aca3384a48244450155ab
Reviewed-on: https://chromium-review.googlesource.com/613061
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>
2017-08-23 23:13:41 -07:00
Scott Collyer
8eea86766b coral: Enable TCPC init to happen in pd_task init
This CL enables the config option CONFIG_USB_PD_TCPC_BOARD_INIT and
modifies the board level tcpc init function to wait up to 2 seconds
to ensure that the battery is out of its disconnected state.

This change was put into Eve to ensure the PD chips are not reset until
the battery is out of disconnect and delay start of the pd_task
(and PD negotiation) until the battery is out of disconnect state.
This is part of a change was initially done on Eve
https://chromium-review.googlesource.com/c/592716.

For Coral the delay of tcpc init relative to the PD task also
addresses an issue where VBUS would be dropped by the external charger
when attempting to boot with no battery connected. When no battery is
connected there is a timing issue between the Analogix TCPC and the EC
related to when the TCPC sends its auto GOODCRC. This results in a
hard reset which causes the drop of VBUS.

BUG=b:64375688
BRANCH=none
TEST=Tested by Bitland using 500 iterations and showed no occurrence
of the hard reset causing VBUS to drop. Prior to this CL, the failure
rate was 1 out 300 attempts.

Change-Id: I28fe3266eb1c0a2940e1bdacee65cf4e642d3483
Signed-off-by: Scott Collyer <scollyer@google.com>
Reviewed-on: https://chromium-review.googlesource.com/627115
Commit-Ready: Scott Collyer <scollyer@chromium.org>
Tested-by: Scott Collyer <scollyer@chromium.org>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
2017-08-23 21:17:23 -07:00
Scott Collyer
6d286d157c battery: Check physical battery presence before inhibiting power
In order to satisfy factory testing requirements we need to
boot a bare board with just an AC adapter without requiring
a power button.

However we also don't want to always allow booting of the
battery is present but cut-off (which will indicate BP_NO so
we can't use the existing battery_is_present function) or has
critically low level as it may not immediately boot.

To accomplish this add a function that allows the board to
specify a custom "hardware presence" for the battery that is
separate from the battery presence check.

This CL is taking a change done for Eve and pulling into TOT so it can
be used for other projects that have the same
requirements. https://chromium-review.googlesource.com/c/582544

BUG=b:63957122
BRANCH=none
TEST=manual

Change-Id: Ib1dc4f659adbf0eebd3dc8c3c61b39b8fa36cb4a
Signed-off-by: Scott Collyer <scollyer@google.com>
Reviewed-on: https://chromium-review.googlesource.com/627113
Commit-Ready: Scott Collyer <scollyer@chromium.org>
Tested-by: Scott Collyer <scollyer@chromium.org>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
2017-08-23 21:17:22 -07:00
Philip Chen
c361021498 scarlet: Enable waking up AP by power button
Meanwhile, we can disable waking up AP by key press,
because there is no keyboard.

BUG=none
BRANCH=none
TEST=when AP is in S3, verify 'powerbtn' command on
ec console can wake up AP

Change-Id: I60c58458cf6f7e1f16b5129c8748b386c9928415
Signed-off-by: Philip Chen <philipchen@google.com>
Reviewed-on: https://chromium-review.googlesource.com/627675
Commit-Ready: Philip Chen <philipchen@chromium.org>
Tested-by: Philip Chen <philipchen@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-08-23 19:04:20 -07:00
Randall Spangler
af85b4f30e cr50: Don't enable GPIO interrupts by default
Each GPIO interrupt should only be enabled after its state machine is
ready to accept interrupts.  Enabling them all by default may cause
undefined behavior if an interrupt occurs before state machine init.

Also, EC_TX_CR50_RX was enabled, and then explicitly disabled in
board_init() because we didn't want it.  Simpler only to enable the
interrupts we do.

BUG=b:35587228
BRANCH=cr50
TEST=boot cr50; manually wiggle platform reset and the detect GPIOs
     and see that interrupts are still generated.

Change-Id: If810eb6fee9945f0c6dfe0d4b592bdc5ff4be6e7
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/619749
Reviewed-by: Mary Ruthven <mruthven@chromium.org>
2017-08-23 17:01:21 -07:00
Randall Spangler
b91ff0a480 cr50: Refactor Rdd state machine
The code to mirror Rdd detect into CCD_MODE_L and handle keepalive is
now inside chip/g/rdd.c It uses a HOOK_SECOND state machine similar to
what's coming for EC/AP/Servo.

This also removes the explicit 'ccd enable' / 'ccd disable' commands,
since they'd be overridden by the HOOK_SECOND handler.  If you need to
force CCD enabled, use 'ccd keepalive enable'.

BUG=b:64799106
BRANCH=cr50
TEST=With a CR50_DEV=1 images:
	Disconnect CCD cable (pull RDCC1 and RDCC2 outside 0.2-2.0V)
	gpioget --> CCD_MODE_L = 1
	ccd --> CCD disabled

	Connect CCD cable --> see 'Debug accessory connected'
	gpioget --> CCD_MODE_L = 0
	ccd --> CCD enabled

	Briefly disconnect and reconnect CCD cable --> No debug output
	gpioget --> CCD_MODE_L = 0
	ccd --> CCD enabled

	Disconnect CCD cable and wait a second --> 'disconnected'
	gpioget --> CCD_MODE_L = 1
	ccd --> CCD disabled

	Force CCD_MODE_L = 0 externally, wait a second
	gpioget --> CCD_MODE_L = 0
	ccd --> CCD enabled

	Stop forcing CCD_MODE_L externally, wait a second
	gpioget --> CCD_MODE_L = 1
	ccd --> CCD disabled

	ccd keepalive enable
	gpioget --> CCD_MODE_L = 0
	ccd --> CCD enabled

	ccd keepalive disable
	gpioget --> CCD_MODE_L = 1
	ccd --> CCD disabled

Change-Id: I65110b45e76f60390828e0fbbac8f36fc2cc9b37
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/619393
Reviewed-by: Mary Ruthven <mruthven@chromium.org>
2017-08-23 17:01:21 -07:00
Scott Collyer
c592ced088 coral: Read SKU ID at initialization time
BUG=b:64705535
BRANCH=none
TEST=Tested two boards with different strapping resistors and verified
that the SKU ID logged in the EC console matches the expected values.

Change-Id: I3534e99856f25dbef810b97a2e4b90c00a65f32e
Signed-off-by: Scott Collyer <scollyer@google.com>
Reviewed-on: https://chromium-review.googlesource.com/627664
Commit-Ready: Scott Collyer <scollyer@chromium.org>
Tested-by: Patrick Georgi <pgeorgi@chromium.org>
Reviewed-by: Patrick Georgi <pgeorgi@chromium.org>
2017-08-23 12:19:09 -07:00
Philip Chen
13269c2117 scarlet: Enable RTC console/host commands
BUG=b:63908519
BRANCH=none
TEST=on scarlet, manually test 'rtc'/'rtc set' on ec console and
'ectool rtcget/rtcset/rtcgetalarm/rtcsetalarm' on ap console.

Change-Id: Ie7de53895bd0ef88af32b74d8410e2e735d1bda4
Signed-off-by: Philip Chen <philipchen@google.com>
Reviewed-on: https://chromium-review.googlesource.com/627640
Commit-Ready: Philip Chen <philipchen@chromium.org>
Tested-by: Philip Chen <philipchen@chromium.org>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2017-08-23 12:19:08 -07:00
Vadim Bendebury
e24bd63fae cr50: log tpm reset event
Use the previously introduced TPM logging framework to log TPM reset
events. The two lowest data field bits are used to communicate the
type of reset passed to tpm_reset_request(),

BRANCH=cr50
BUG=b:63760920
TEST=with the upcoming patches verified that TPM initialization is
     logged as expected

Change-Id: Ic0874723ec6df616a8237b036542398b29fe5ccc
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/620113
Reviewed-by: Mary Ruthven <mruthven@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-08-23 12:19:07 -07:00
Nicolas Boichat
9ea128966b hammer: Pull down PWM output pin
Some staff boards were accidentally built with both pull-up and
pull-down stuffed, leaving the backlight output always on when
the EC is not driving the pin.

This "fixes" the issue by adding an internal pull-down on the pin,
so that the pin is pulled low whenever the PWM is disabled.

BRANCH=none
BUG=b:64845198
TEST=staff EC console:
     pwm 0 -1 => backlight is off
     pwm 0 0 => backlight still off
     pwm 0 100 => backlight full intensity
TEST=Power consumption with PWM disabled (pwm 0 -1) and always 0
     (pwm 0 0) are comparable.

Change-Id: I32549bfc037a6506470408f8e98cae5ae56006e2
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/627345
Reviewed-by: Furquan Shaikh <furquan@chromium.org>
2017-08-23 00:04:09 -07:00
Furquan Shaikh
844b03dd0e poppy: Enable/disable power to base on chipset startup/shutdown
Instead of always enabling power to base whenever it is connected,
enable/disable power to base depending upon chipset startup/shutdown.

BUG=b:64460667
BRANCH=None
TEST=Verified following:

1. On system startup, base is connected only after chipset startup.
2. On apshutdown, base is disconnected after chipset shutdown.
3. Wake from base still works.
4. Base still works on firmware screen.

Change-Id: I39454701889650964b7c678b275c984772ecd3e7
Signed-off-by: Furquan Shaikh <furquan@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/625244
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
2017-08-22 16:43:58 -07:00
Furquan Shaikh
1fb39a4247 poppy: Return early from base_detect_change if status is unchanged
If current status is the same as requested state, then return early
from base_detect_change without taking any action.

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

Change-Id: I3c403739a2e5c43f31fe77b5633927cf49b974eb
Signed-off-by: Furquan Shaikh <furquan@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/625243
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
2017-08-22 12:38:47 -07:00
Scott Collyer
af6024cc08 coral: Remove volume up/dn button flip in gpio.inc
The Coral schematics are being changed to reflect that volume up is
connected to GPIO83 and volume down to GPIO82. The current EC code
implemented this same assignment, but introduced an intermediate
signal name to match with previous schematics which had the opposite
assignment. With the signal names fixed on the schematic, the
intermediate #defines are no longer needed.

BUG=b:64012307
BRANCH=None
TEST=manual testing on Coral proto. Verified that up button presses
cause the volume bar to go up and volume down button presses cause the
volume bar to go down.

Change-Id: Ib04f8416e8f36271972fc650bf1593a4babaeb82
Signed-off-by: Scott Collyer <scollyer@google.com>
Reviewed-on: https://chromium-review.googlesource.com/625063
Commit-Ready: Scott Collyer <scollyer@chromium.org>
Tested-by: Scott Collyer <scollyer@chromium.org>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-by: Patrick Georgi <pgeorgi@chromium.org>
2017-08-22 12:38:46 -07:00
Divya Sasidharan
577a741855 glkrvp: Enable USB MUX PS8743 driver
Add Parade PS8743 USB Type-C Redriving Switch for USB Host /
DisplayPort.

BUG=b:64598680
BRANCH=glkrvp
TEST=On glkrvp,
     Connect Apple dongle and verify mux setting with i2c read.
     1. i2cxfer r 1 0x20 0 -> 0x50 (DP/USB enabled)
     2. flip i2cxfer r 1 0x20 0 -> 0x54 (Flip bit enabled)
     Connect pluggable and verify the same.
     Similar testing was successful on second type-c port.

Change-Id: I96ec380024eb659e071b019dd58b3c640fa1cc03
Signed-off-by: Divya Sasidharan <divya.s.sasidharan@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/616075
Commit-Ready: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Tested-by: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-08-21 22:03:53 -07:00
Vijay Hiremath
309289df45 glkrvp: Enable TCPC using NXP PTN5110 AIC
BUG=b:64531818
BRANCH=glkrvp
TEST=TCPC can negotiate to 20V & 2.25A

Change-Id: I16510a510133bbb1827634303a6b9d02dec4bbc6
Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/614311
Commit-Ready: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Tested-by: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-08-21 22:03:53 -07:00
Philip Chen
a438efab9c scarlet: Define BATTERY_DESIRED_CHARGING_CURRENT
BUG=b:64821815
CQ-DEPEND=CL:621776
BRANCH=none
TEST=plug in AC, and check 'charger' command on ec console

Change-Id: I53681d21a5311ea58562acf2fae451ebc7f41d4d
Signed-off-by: Philip Chen <philipchen@google.com>
Reviewed-on: https://chromium-review.googlesource.com/621777
Commit-Ready: Philip Chen <philipchen@chromium.org>
Tested-by: Philip Chen <philipchen@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-08-21 12:52:14 -07:00
Randall Spangler
9ca5e791cc cr50: Wake on AC detect edges
Currently, we only use the AC detect interrupt for battery cutoff
support on detachable devices, and we use the RDD detect interrupt for
waking Cr50 from deep sleep.  However, Eve accidentally detects RDD
when the EC is off, so this is not a reliable signal - particularly if
Cr50 is explicitly driving EC reset.

Enable the AC detect interrupt all the time, and defer sleep for 5
seconds when it transitions.  This will have a negligible effect on
overall power (since AC is not normally transitioning) and will allow
the RDD detect code to be simplified.

BUG=b:64799106
BRANCH=cr50
TEST=manually pull DIOR5 up and down; see AC interrupt debug output.
     idle d, wait for sleep, then wiggle DIOR5 and see that cr50 wakes.

Change-Id: I7551f25e27a79573bf4527d8c38994634df621ec
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/619319
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2017-08-18 14:27:19 -07:00
Vadim Bendebury
430d55879d g: add 'recover hosed slave' i2cs capability
A common failure condition on the i2c bus is when the master
unexpectedly stops clocking the bus while the slave is driving the SDA
line low. In this case the master is not able to issue Stop or Start
sequences, which makes the bus unusable.

Good slave controllers are able to detect this condition and recover
from it by removing the pull down from the SDA line. This patch adds
this capability to the g chip i2c slave controller.

A new timer function is created which samples the SDA line twice a
second. If it detects that SDA is low in two consecutive invocations
and the number of i2cs read interrupts has not advanced, it decides
that the "hosed slave" condition is happening and reinitializes the
i2c driver, which removes the hold from the SDA line.

Even though the state of the SDA line is supposed to be accessible
through the I2CS_READVAL register, it in fact is not, reads always
return zero in the SDA bit. To work around this a GPIO (port 0, bit
14) is being allocated to allow to monitor the state of the line, it
is multiplexed to the same pin the SDA line uses.

When the AP is in low power modes the SDA line is held low, this state
should not trigger i2c reinitializations.

CQ-DEPEND=CL:616300
BRANCH=none
BUG=b:35648537
TEST=connected H1 on the test board to an I2c master capable of
     stopping clocking mid byte. Observed that the existing code would
     just sit in the "hosed" state indefinitely. The code with the fix
     recovers from the condition (drives the SDA line high) 500ms to
     1s after the failure condition is created.

Change-Id: Iafc7433bbae9e49975a72ef032a923274f8aab3b
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/614391
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2017-08-17 20:41:57 -07:00
Philip Chen
add041bd7c scarlet: Make AP_CORE_PG a non-INT pin
AP_EC_S3_S0_L and AP_CORE_PG can't be INT pins
at the same time.

BUG=b:64528567
BRANCH=none
TEST=boot scarlet rev1

Change-Id: I3e70d2ef2a1f78c0661c8c4d40db32f22dff616f
Signed-off-by: Philip Chen <philipchen@google.com>
Reviewed-on: https://chromium-review.googlesource.com/611650
Commit-Ready: Philip Chen <philipchen@chromium.org>
Tested-by: Philip Chen <philipchen@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-08-17 20:41:54 -07:00
Randall Spangler
86d7ea33af cr50: Remove BOARD_AP_USB property
We previously disabled the USB PHY to the AP.  But the BOARD_AP_USB
property lingered on.  Remove the property.

Also clean up the idle task deciding when to do utmi wakes.  With the
AP USB connection disabled, that's only necessary when the debug cable
is attached, so we can check that explicitly.

BUG=none
BRANCH=cr50
TEST=make buildall; boot CR50_DEV=1 image

Change-Id: If81a7bcfe845d9d70dcc7e16239244a4f5f2427b
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/616301
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-by: Mary Ruthven <mruthven@chromium.org>
2017-08-17 01:56:48 -07:00
Randall Spangler
f2b3aa47a6 cr50: Add helper functions for device-is-enabled
A subsequent CL will massively refactor the device state machines.
Add the helper functions which will be used by that CL, so that
the refactoring touches fewer files.

No change in functionality.

BUG=none
BRANCH=cr50
TEST=make buildall; boot cr50 with a CR50_DEV=1 image

Change-Id: I3499d45e93fa15b6de9c04ce398d1c5bfbbc01e9
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/616300
Commit-Ready: Vadim Bendebury <vbendeb@chromium.org>
Tested-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-by: Mary Ruthven <mruthven@chromium.org>
2017-08-17 01:56:48 -07:00
Caesar Wang
d7a41825d9 nefario/battery: support the 3s battery
As Nefario supports 3s battery, we can change the parameter
for board-specific instead of the charger driver.

BUG=chromium:754824
BRANCH=none
TEST=Build and check battery information
> battery
  Status:    0x0080 INIT
  Param flags:00000003
  Temp:      0x0bc0 = 300.8 K (27.7 C)
  V:         0x2e1e = 11806 mV
  V-desired: 0x32fa = 13050 mV
  I:         0x07a7 = 1959 mA(CHG)
  I-desired: 0x0fa0 = 4000 mA
  Charging:  Allowed
  Charge:    17 %
  Manuf:     sunwoda
  Device:    BBLD485595
  Chem:      LION
  Serial:    0x0064
  V-design:  0x2c88 = 11400 mV
  Mode:      0x6001
  Abs charge:17 %
  Remaining: 667 mAh
  Cap-full:  4079 mAh
    Design:  4000 mAh
  Time-full: 2h:47

Change-Id: If9a4cdd9932e3287bf06cbe0840c94085cbeea1f
Signed-off-by: Caesar Wang <wxt@rock-chips.com>
Reviewed-on: https://chromium-review.googlesource.com/616508
Reviewed-by: Philip Chen <philipchen@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-08-16 20:46:37 -07:00
Vadim Bendebury
f7f552251a cr50: enhance sleep wake indicator
Printing dots each time device wakes up from sleep causes the terminal
to be overflown with dots, especially in cases when interrupts are
generated at high rate.

Let's replace printing dots with a rotating wheel, the screen is not
going to be wiped out, and one still can tell the rate the wake
interrupts are coming at.

Also, each time the wake source changes, print its hex value.

BRANCH=none
BUG=none
TEST=verified proper printing of the spinning wheel and wake interrupt
      sources.

Change-Id: Ic32466234f91b4a19b6186f74296dc6dd765a8fa
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/611962
Tested-by: Vadim Bendebury <vbendeb@google.com>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2017-08-16 20:46:37 -07:00
Caveh Jalali
ee3fb6c6aa ps8xxx: use custom tcpm_drv
the ps8xxx family of TCPCs (ps8751, ps8805) have historically used the
generic tcpci_tcpm_drv functions, but we need to override some of
these entry points because the parade parts need to be woken up before
accessing registers.

in most cases, this doesn't matter because we access the chip in quick
succession where we can "safely" assume the chip is awake -- and the
code is structured to implicitly keep the chip awake.  the new case we
need to address here is where we need to suspend the pd_task and TCPC
at an arbitrary point in time.  the driver's .release method is called
to shut down the chip, and that involves first waking up the chip to
be able to access its regs to mask off interrupts, etc.

BUG=b:35586896
BRANCH=none
TEST=tested from depthcharge - we no longer get errors in the EC
	console logs about TCPC "release" failed.

Change-Id: Ic2a90b71050b3f68c697b1cef48d736ed88b3f41
Signed-off-by: Caveh Jalali <caveh@google.com>
Reviewed-on: https://chromium-review.googlesource.com/616460
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-08-16 20:46:36 -07:00
Nicolas Boichat
9e33d6ce3c chip/stm32/usb: Replace reset handler by generic event handler
Some USB interface handlers need to know when USB has been
successfully resumed after a wake event. For example, this is
useful so that HID keyboard can send the events at the right time.

BRANCH=none
BUG=b:35775048
TEST=Using USB HID keyboard patches to queue keys in a FIFO:
     After USB autosuspends, press a single key and hold it. Without
     this patch the endpoint data only gets reloaded on the _next_
     event.
TEST=On hammer, I2C passthrough still works.

Change-Id: I9b52b9de16767c8a66c702a5ae70369334a3d590
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/569547
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-08-16 04:03:24 -07:00
Che-yu Wu
a1abf686c3 board/elm/board.h: Remove CONFIG_CMD_HOSTCMD
The command "hostcmd" in console isn't very useful and will cause
stack overflow in console task when processing some hash commands.

BUG=chromium:755048
BRANCH=none
TEST=make BOARD=elm -j
     make BOARD=elm tests
     There should be no hostcmd command in the console of elm.

Change-Id: Ifa721a1731bc1ebfb39e12430b6631338bdccd9f
Signed-off-by: Che-yu Wu <cheyuw@google.com>
Reviewed-on: https://chromium-review.googlesource.com/616600
Reviewed-by: Rong Chang <rongchang@chromium.org>
2017-08-16 04:03:23 -07:00
Scott Collyer
8df230291a servo_v4: Tie data role preference to DTS mode setting
When servo_v4 acts as a debug test system (DTS) its expected use
case is for triggering CCD mode and Faft testing. To that end, its
desired default data role is to be a UFP so that the enet and USB
port are accessible by the DUT.  However, when servo is acting a
regular SRC port, it makes more sense for the data role pairing to
be consistent with a normal SRC port device which is SRC/DFP.

BUG=b:64720447
BRANCH=servo
TEST=Tested with Eve using twinkie USB PD analyzer. Verified that when
DTS mode is enabled a data role swap request is sent to the DUT and
when DTS mode is disabled that servo_v4 does not send a data role swap
request.

Change-Id: I071f85fc99f1c877d86ef48ec7fa38d6850d5679
Signed-off-by: Scott Collyer <scollyer@google.com>
Reviewed-on: https://chromium-review.googlesource.com/615813
Commit-Ready: Scott Collyer <scollyer@chromium.org>
Tested-by: Scott Collyer <scollyer@chromium.org>
Reviewed-by: Nick Sanders <nsanders@chromium.org>
2017-08-15 20:21:05 -07:00
Philip Chen
abd446b806 scarlet: Remap DMA channels for USART1
To enable console with DMA, we need to specifically
remap DMA channels for USART1.

ch2/3 and ch6/7 are already used by SPI1/2 modules.
So we have to remap USART1_TX to ch4 and USART1_RX to ch5.

BUG=b:64575809
BRANCH=none
TEST=confirm ec console works on scarlet rev1

Change-Id: Ie2bb141c72252aee98e4cd4a284a01b4d57605f4
Signed-off-by: Philip Chen <philipchen@google.com>
Reviewed-on: https://chromium-review.googlesource.com/611147
Commit-Ready: Philip Chen <philipchen@chromium.org>
Tested-by: Philip Chen <philipchen@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-08-15 18:29:22 -07:00
Patrick Georgi
f747f70816 coral: Add host command to fetch SKU ID
BUG=b:64468585
BRANCH=none
TEST=with the other sku-id related patches applied, coreboot obtains the
right SKU ID from EC

Change-Id: Ibf307c6e46152b4b09e94d8dca6d49ae863cb3ad
Signed-off-by: Patrick Georgi <pgeorgi@google.com>
Reviewed-on: https://chromium-review.googlesource.com/608370
Commit-Ready: Patrick Georgi <pgeorgi@chromium.org>
Tested-by: Patrick Georgi <pgeorgi@chromium.org>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
2017-08-15 06:51:58 -07:00
Caesar Wang
d2a06c36b1 nefario: remove unused gpio define
The center supply is fixed to .9V on nefario, it had not the
enable pin for controlling.

Also the Nefario unused the led for battery.

BUG=b:63408169
BRANCH=none
TEST=Tested on nefario, check the gpioget

Change-Id: I339ce2cb2fb530cec393a352d920ea21fd8a8464
Signed-off-by: Caesar Wang <wxt@rock-chips.com>
Reviewed-on: https://chromium-review.googlesource.com/612969
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Philip Chen <philipchen@chromium.org>
2017-08-14 22:19:41 -07:00
Ryan Zhang
041b90bcac Coral: Add Keyboard backlight config.
+ support Keyboard backlight Feature.

BUG=None
BRANCH=master
TEST=`make -j BOARD=coral`, `ectool pwmsetkblight 0% ~ 100%` works
Signed-off-by: Ryan Zhang <ryan.zhang@quanta.corp-partner.google.com>

Change-Id: I69038a94da97dff5d7584264b1f8fab4e3385c82
Reviewed-on: https://chromium-review.googlesource.com/611105
Commit-Ready: Ryan Zhang <ryan.zhang@quanta.corp-partner.google.com>
Tested-by: Ryan Zhang <ryan.zhang@quanta.corp-partner.google.com>
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-08-13 20:42:00 -07:00
Dino Li
021d1229f3 board: reef_it8320: disable CONFIG_CMD_I2C_XFER to save flash space
There isn't enough flash space after 'repo sync',
so disable one more console command.

BRANCH=none
BUG=none
TEST=build reef_it8320 and all.

Change-Id: I370e06d5de211b7de669f35071c680d28efb7c17
Signed-off-by: Dino Li <Dino.Li@ite.com.tw>
Reviewed-on: https://chromium-review.googlesource.com/612001
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-08-11 22:45:59 -07:00
Vijay Hiremath
a261390d75 usb_mux: Merge PS8743 & PS8740 as PS874X
Merge PS8743 & PS8740 as PS874X as both the drivers are almost same.

BUG=b:64598680
BRANCH=glkrvp
TEST=make buildall -j
     On GLKRVP, verify mux setting is correct with
     Apple dongle (VGA + USB) and Pluggable adapter.

Change-Id: Ic6d31979936ee213b07c4c71859809102ee91452
Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/612209
Commit-Ready: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Tested-by: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-08-11 20:10:23 -07:00
Aseda Aboagye
79ae73477c charge_manager: Consider port in source PDO.
When CONFIG_USB_PD_MAX_SINGLE_SOURCE_CURRENT is defined for a board, as
its name implies, the board can source a higher current if there is
only one port acting as a source.

This commit fixes an issue with selecting the right source capability
message to advertise.  charge_manager_get_source_pdo() was simply
checking if there was more than one sink connected, instead of checking
if there were any *other* sinks connected.  In the event that a sink
was connected to a different port, we would advertise the max source
PDO.

BUG=b:64037926, b:35577509
BRANCH=gru,eve,reef
TEST=Connect sink to port 1.  Connect a AMA to port 0 that claims that
VBUS isn't necessary.  Start sending source caps, verify that the max
PDO is not being advertised in the source caps.

Change-Id: Ie4145ecaf98d5b9070ad3e8b139e5653685fa801
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/610479
Commit-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-08-11 20:10:20 -07:00
Vijay Hiremath
97fe22e8d5 glkrvp: Enable switches
BUG=b:64491401
BRANCH=glkrvp
TEST=mmapinfo is updated when lidopen & lidclose are performed
     SCI/SMI gpios toggle

Change-Id: I93f1ae2cc8dbc389b3e870b49d5ee2bfff503451
Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/606892
Commit-Ready: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Tested-by: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-08-11 14:36:18 -07:00
Douglas Anderson
67644782eb kevin / nefario: Add comment to prevent reordering PWM IDs
As can be seen in <http://crosreview.com/610449> the IDs of PWMs are
directly referenced by the kernel device tree on gru / kevin / nefario
boards (technically also in bob and scarlet-rev0, but neither of those
is supported by mainline EC code).  Because of the kernel reference
it's not a great idea to change the IDs.

Let's add a comment so people don't change the ordering / IDs
accidentally.

NOTE: we can have a big argument here about whether it would be OK to
change numbering _and_ change the numbering in the kernel at the same
time.  We can talk about whether the device tree is a binary and about
whether this constitutes an ABI since Chromebooks don't ship the
device tree binary separate from the kernel.  We can talk about all
those things.  ...but we won't.  There's no good reason to change the
ID, so just don't do it.

BRANCH=None
BUG=b:63537905
TEST=None

Change-Id: Iacdedc1c91e583183034d15e99735a470d6e0951
Signed-off-by: Douglas Anderson <dianders@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/610933
Reviewed-by: Alexandru M Stan <amstan@chromium.org>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2017-08-11 10:35:53 -07:00
Vijay Hiremath
76a64e7c82 glkrvp: Enable S0iX support
BUG=b:64559696
BRANCH=glkrvp
TEST=EC console command powerindebug shows correct GPIO info

Change-Id: Iee346f61bc0a0b26d612d2966350d308be596592
Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/610304
Commit-Ready: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Tested-by: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
2017-08-10 15:39:51 -07:00
Vijay Hiremath
5dc101be09 glkrvp: Enable board version identification
BUG=b:64491133
BRANCH=glkrvp
TEST='version' works on EC console.

Change-Id: I7ed56870ec8fa817d55ab8acb362761c99f5bb29
Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/606893
Commit-Ready: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Tested-by: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-08-10 12:26:42 -07:00
Furquan Shaikh
7947687f12 poppy: Fix manufacturer access and shutdown data for poppy battery
Poppy uses 0x00 reg for manufacturer access and shutdown data 0x10
just like Soraka battery. Fix the macros for poppy.

BUG=b:64460667
BRANCH=None
TEST=Verified that battery cutoff by smb command works on poppy.

Change-Id: I5e568a31a575bc0e403362e48e64a753c094dab1
Signed-off-by: Furquan Shaikh <furquan@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/609553
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
2017-08-09 23:33:07 -07:00
Furquan Shaikh
403465caae poppy: Remove CONFIG_BATTERY_REVIVE_DISCONNECT
Now that we have a custom battery presence function, we do not need
the disconnect behavior as it will recover better by letting the state
machine handle it with precharge directly.

Without this change, EC was stuck in "battery found in disconnect
state" after battery cut-off.

(Reference: https://chromium-review.googlesource.com/c/582538)

BUG=b:64370648,b:64460667
BRANCH=None
TEST=manual testing with cut-off batteries shows more consistent
behavior to boot AP after plugging in adapter.

Change-Id: I8d1072d29c42e5b10b133d880897287882bd698b
Signed-off-by: Furquan Shaikh <furquan@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/607036
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
2017-08-09 21:46:06 -07:00
Furquan Shaikh
a4b536c0f3 poppy: Add custom battery presence function
Just checking for battery present gpio is not sufficient to determine
the state of the battery. On the lines of the changes made by Eve, add
a new battery_is_present function which:
1. Checks hardware gpio signal to determine if battery is present
2. If yes, then checks following if its status just changed to present:
   a. Battery is not in cut-off state
   b. Battery is not in disconnect state (charging and discharging
   disabled)
   c. Battery initialization is complete

Only if all the above conditions are true, then battery is considered
as present.

BUG=b:64460667,b:64370648
BRANCH=None
TEST=Verified that with this change recovering system from battery
cut-off is more consistent.

Change-Id: I10abdf603e01f404c9b8e2094e36bc068adf5450
Signed-off-by: Furquan Shaikh <furquan@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/607035
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
2017-08-09 21:46:06 -07:00
Furquan Shaikh
fdac380415 poppy: Fix charger_profile_override
When battery is cutoff, it might at times require some current to be
applied to it so that it can wake up. Thus, in case where all battery
flags indicate error in charger_profile_override, set
requested_current and requested_voltage to precharge_current and
voltage max. This allows the battery to be woken up.

BUG=b:64370648,b:64460667
BRANCH=None
TEST=Verified that on connecting AC power after battery-cutoff, there
are no "try to wake battery" messages anymore.

Change-Id: Ib88369238b492994d8310655126e19bc7e347a0c
Signed-off-by: Furquan Shaikh <furquan@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/607034
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
2017-08-09 21:46:05 -07:00
Furquan Shaikh
c90eeada8a poppy: Cut off critically low battery
Instead of going to hibernate when the battery is critically low
we should cut off power entirely.

Even with the PMIC shut down the H1 chip consumes more power than
is healthy when the battery is already critically low, depleting it
to dangerously low voltage levels faster than it should.

(Reference: https://chromium-review.googlesource.com/582543)

BUG=b:64460667
BRANCH=None
TEST=Manual testing to ensure that EC cuts off battery when it is
critically low instead of hibernating on soraka.

Change-Id: I3befd583df64c44d43d73cda69a6486219578192
Signed-off-by: Furquan Shaikh <furquan@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/605015
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
2017-08-09 21:46:05 -07:00