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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>