summaryrefslogtreecommitdiff
path: root/driver/charger
Commit message (Collapse)AuthorAgeFilesLines
* charger: Move charger_state_v2.h into charge_state.hSimon Glass2023-05-113-3/+3
| | | | | | | | | | | | | | | | | | | | We don't have a v1 anymore, so the name makes no sense. Move it into the existing file. Include charge_state.h instead of v2, doing this in the same change to avoid build errors. This makes no functional change. BUG=b:218332694 TEST=make buildall Change-Id: Ic3e3adc45e4d002c2cd5ba8aa65e24686e01d628 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4516191 Reviewed-by: Tim Van Patten <timvp@google.com> Commit-Queue: Simon Glass <sjg@chromium.org> Tested-by: Simon Glass <sjg@chromium.org> Reviewed-by: Yuval Peress <peress@google.com>
* charger: Rename charge_get_state() to led_pwr_get_state()Simon Glass2023-05-111-1/+1
| | | | | | | | | | | | | | | | | | We have a new 'charge state' in struct charge_state_data as part of the charge_state_v2.h file. This is confusing. Rename this function to match the enum it is referencing. This makes no functional change. BUG=b:218332694 TEST=make buildall Change-Id: I7f08dd4fb11e2939e0ef779018c1e3206ebc8d20 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4516188 Commit-Queue: Simon Glass <sjg@chromium.org> Tested-by: Simon Glass <sjg@chromium.org> Reviewed-by: Aaron Massey <aaronmassey@google.com>
* sm5803: restore load-bearing ERROR_UNIMPLEMENTEDPeter Marheine2023-05-051-1/+1
| | | | | | | | | | | | | | | | | | | | | | The OCPC code seems to use ERROR_UNIMPLEMENTED as a signal that it should do some work, and SUCCESS as a signal that everything has been done. Always returning success appears to cause incorrect charging behavior: restore the unconditional ERROR_UNIMPLEMENTED that was removed in commit ae68afbb5d58ce7af0be3e04f833900b105021cd and change the test to reflect this. A note is added to the definition of this driver field to document that ERROR_UNIMPLEMENTED is an expected normal result. BUG=b:280530115 TEST=Battery once again charges on Yaviks port C1 when connected to a charger. Change-Id: I491247148c523123206fefcdbcde62a92ea8caf4 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4506012 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Tested-by: Peter Marheine <pmarheine@chromium.org> Commit-Queue: Peter Marheine <pmarheine@chromium.org>
* sm5803: implement more driver testsPeter Marheine2023-05-041-1/+1
| | | | | | | | | | | | | | | | | | | | There are two behavioral changes: * sm5803_set_otg_current_voltage is modified to ensure it never attempts to program an output voltage less than the minimum supported by the chip, because that would program unintended bits. * the SM5803 emulator is fixed to still build correctly if no interrupt GPIO is specified, because not all users of the emulator care about the interrupts (such as the newly-introduced secondary charger for this test, allowing it to exercise OCPC-specific functionality). BUG=b:242544165 TEST=./twister -ci -T zephyr/tests/drivers -s drivers.sm5803 Change-Id: I9df854d5e9666a833d209a0d98d6987c7b29e953 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4482276 Tested-by: Peter Marheine <pmarheine@chromium.org> Reviewed-by: Tristan Honscheid <honscheid@google.com> Commit-Queue: Peter Marheine <pmarheine@chromium.org>
* sm5803: add tests for set_vsys_compensationPeter Marheine2023-04-271-2/+2
| | | | | | | | | | | | | | | | | | | Two bugs in the driver were exposed by this test and are fixed: * All 8 bits of IR_COMP_REG2 are used as resistance value (in addition to bits 6 and 7 of IR_COMP_REG1), but the driver incorrectly masked off bit 7 which would cause incorrect values to be programmed when resistance is greater than 212 mΩ. * sm5803_set_vsys_compensation always returned an error, which apparently goes unchecked by regular charger code. BUG=b:242544165 TEST=./twister -ci -T zephyr/test/drivers/ -s drivers.sm5803 BRANCH=none Change-Id: I761c3523d9903c3498cfe30d93ddb56b004cc4ef Signed-off-by: Peter Marheine <pmarheine@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4482275 Reviewed-by: Tristan Honscheid <honscheid@google.com>
* Reland "zephyr/tests: emulator and tests for sm5803"Peter Marheine2023-04-201-7/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a reland of commit fd2415cda6a261b92390aad04829f46f33ffc9e6, with sleeps in test_lpm increased from 4 to 10 seconds. This seems to fix the flakiness that was observed, verified with no failures over 8 CQ builds. Original change's description: > zephyr/tests: emulator and tests for sm5803 > > This implements an emulator and some tests for the SM5803 charger. The > current tests do not exercise the driver as comprehensively as intended, > but those will be added in a later change. > > One discovered bug in the driver is fixed, where some interrupts were > disabled immediately after being enabled. > > BUG=b:242544165 > TEST=twister -ciC -s drivers/drivers.sm5803 > BRANCH=nissa > > Change-Id: I9fc6abd26cd1b2e0cbc05b8e45cf94fc83abd08c > Signed-off-by: Peter Marheine <pmarheine@chromium.org> > Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4290087 > Reviewed-by: Tristan Honscheid <honscheid@google.com> BUG=b:242544165,b:278890420 TEST=`bb add chromeos/cq/firmware-zephyr-cov-cq -commit https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4451846` 8 times, verified success for all builds. Change-Id: Ifd0d486a45be2242023e6efba6457e7907aaedd2 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4451846 Reviewed-by: Tristan Honscheid <honscheid@google.com> Commit-Queue: Tristan Honscheid <honscheid@google.com> Reviewed-by: Aaron Massey <aaronmassey@google.com> Tested-by: Peter Marheine <pmarheine@chromium.org>
* Revert "zephyr/tests: emulator and tests for sm5803"Aaron Massey2023-04-191-5/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit fd2415cda6a261b92390aad04829f46f33ffc9e6. Reason for revert: http://b/278890420 - test was flakily blocking CQ Original change's description: > zephyr/tests: emulator and tests for sm5803 > > This implements an emulator and some tests for the SM5803 charger. The > current tests do not exercise the driver as comprehensively as intended, > but those will be added in a later change. > > One discovered bug in the driver is fixed, where some interrupts were > disabled immediately after being enabled. > > BUG=b:242544165 > TEST=twister -ciC -s drivers/drivers.sm5803 > BRANCH=nissa > > Change-Id: I9fc6abd26cd1b2e0cbc05b8e45cf94fc83abd08c > Signed-off-by: Peter Marheine <pmarheine@chromium.org> > Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4290087 > Reviewed-by: Tristan Honscheid <honscheid@google.com> Bug: b:242544165 Change-Id: I315d36d1e08035f13d847ea1a21756ee3790216e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4448966 Commit-Queue: Aaron Massey <aaronmassey@google.com> Tested-by: Aaron Massey <aaronmassey@google.com> Reviewed-by: Keith Short <keithshort@chromium.org>
* zephyr/tests: emulator and tests for sm5803Peter Marheine2023-04-191-7/+5
| | | | | | | | | | | | | | | | | | This implements an emulator and some tests for the SM5803 charger. The current tests do not exercise the driver as comprehensively as intended, but those will be added in a later change. One discovered bug in the driver is fixed, where some interrupts were disabled immediately after being enabled. BUG=b:242544165 TEST=twister -ciC -s drivers/drivers.sm5803 BRANCH=nissa Change-Id: I9fc6abd26cd1b2e0cbc05b8e45cf94fc83abd08c Signed-off-by: Peter Marheine <pmarheine@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4290087 Reviewed-by: Tristan Honscheid <honscheid@google.com>
* RAA489110: Add RAA489110 driverDaisuke Nojiri2023-04-122-16/+35
| | | | | | | | | | | | | | | RAA489110 is an EPR capable version of ISL9241. BUG=b:277280318 BRANCH=None TEST=make BOARD=hades TEST=./twister --toolchain host -T zephyr/test/drivers -s drivers.isl9241 Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Change-Id: I15eb1f652027f157ccb6b3a2d509531bef0c7c6c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4409986 Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org> Commit-Queue: Paul Fagerburg <pfagerburg@chromium.org>
* ISL9241: Fix ACProchot reg <-> mA conversionDaisuke Nojiri2023-04-122-17/+17
| | | | | | | | | | | | | | | | | | This CL fixes expressions used to convert ACProchot register values to/from the current. There is no functionality change because the register happens to use identical conversion. That is, 128 mA <-> 0x80, for example. BUG=b:277280318 BRANCH=None TEST=./twister --toolchain host -T zephyr/test/drivers -s drivers.isl9241 Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Change-Id: I7c2d6c8b1819c5031306de4ea421193828359290 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4409985 Commit-Queue: Paul Fagerburg <pfagerburg@chromium.org> Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org>
* ISL9241: Fix frequency range checksDiana Z2023-03-311-1/+1
| | | | | | | | | | | | | | | | There was a typo in the frequency ranges, which resulted in 656kHz not being set when given as an input. Correct the check point to 628kHz, the value in between both register options similar to the other clauses. BRANCH=skyrim BUG=None TEST=./twister -T ./zephyr/test Change-Id: Iffa99a6c77006bd4c11b8f6e63afafa27a788de2 Signed-off-by: Diana Z <dzigterman@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4387134 Reviewed-by: Keith Short <keithshort@chromium.org> Commit-Queue: Keith Short <keithshort@chromium.org>
* Charger: CONFIG gate bypass modeDiana Z2023-03-311-0/+4
| | | | | | | | | | | | | | | | Only two boards need the charger bypass mode feature, and it takes a fair amount of code space in flash (1.2k). Make this code logic opt-in to enable the bypass mode and enable the two boards which do use it. BRANCH=None BUG=b:273722902 TEST=util/compare_build.sh -b hades and util/compare_build.sh -b agah passes, other boards build and consume less flash space Change-Id: I90d781340389eb2f259d13b69eb2882b16bf0c4d Signed-off-by: Diana Z <dzigterman@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4388379 Reviewed-by: Keith Short <keithshort@chromium.org>
* frostflow: Modify charger frequence for power consumption.Logan_Liao2023-03-151-0/+48
| | | | | | | | | | | | | | | | | | To avoid charger enter CCM mode, modify isl9241 frequence to 600kHz from 1020kHz in S5. BUG=b:271704154 BRANCH=none TEST=power team test power consumption is lower than 1020kHz. Change-Id: I9906f2795582c2c8e4a63a674404c0e5a5dfbc96 Signed-off-by: Logan_Liao <Logan_Liao@compal.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4333276 Reviewed-by: SamSP Liu <samsp_liu2@compal.corp-partner.google.com> Tested-by: Logan Liao <logan_liao@compal.corp-partner.google.com> Reviewed-by: Chao Gui <chaogui@google.com> Commit-Queue: Logan Liao <logan_liao@compal.corp-partner.google.com> Reviewed-by: Logan Liao <logan_liao@compal.corp-partner.google.com>
* isl9241: Prevent isl9241_nvdc_to_bypass from locking control3 mutex twiceDaisuke Nojiri2023-02-181-7/+18
| | | | | | | | | | | | | | | | | | | isl9241_nvdc_to_bypass locks control3 mutex and calls isl9241_get_vsys_voltage, which tries to lock the same mutex. This deadlocks whatever task calling isl9241_nvdc_to_bypass. This patch makes isl9241_nvdc_to_bypass call an internal version of isl9241_get_vsys_voltage, which skips mutex lock. BUG=b:266742386 BRANCH=None TEST=Agah Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Change-Id: I690dd0011f05f7488be6566146b7863bf747d9e6 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4261958 Reviewed-by: Jes Klinke <jbk@chromium.org> Tested-by: Jes Klinke <jbk@chromium.org>
* geralt: disable bc1.2Ting Shen2023-02-141-0/+2
| | | | | | | | | | | | | | | | Remove CONFIG_USB_CHARGER and hide related driver code inside #ifdef. BUG=b:267989266 TEST=no USB_CHG task in `kernel thread` BRANCH=none LOW_COVERAGE_REASON=early bringup Change-Id: Iebd80267f64149fde148a436212c9998824c6564 Signed-off-by: Ting Shen <phoenixshen@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4248932 Tested-by: Ting Shen <phoenixshen@chromium.org> Reviewed-by: Eric Yilun Lin <yllin@google.com> Commit-Queue: Ting Shen <phoenixshen@chromium.org>
* raa489000: never report ACOK when sourcing VBUSPeter Marheine2023-02-061-1/+22
| | | | | | | | | | | | | | | | | | | | | | This chip sometimes ACOK when sourcing VBUS because the ACOK status bit actually indicates whether VBUS is above approximately 3.6V and the charger is not overcurrent or over-temperature, though it also seems to report ACOK correctly when the port comes up as a source rather than going through a PRS. This change makes raa489000_is_acok return a correct value (not-OK) in all situations when sourcing VBUS. BUG=b:263691951,b:262663436 TEST=On Nivviks, `hibernate` now correctly hibernates following fast role swap from sink to source on port C0 (with C1 disconnected), where previously it refused to hibernate with the "AC on, skip hibernate" message. BRANCH=nissa Change-Id: I314988d7dfcc8b4d576224f934cd5dc693e7f54f Signed-off-by: Peter Marheine <pmarheine@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4222772 Reviewed-by: Adam Mills <adamjmills@google.com> Reviewed-by: Arthur Lin <arthur.lin@lcfc.corp-partner.google.com>
* raa489000: support AC_PRESENT_CONTROL without OCPCPeter Marheine2023-02-011-5/+9
| | | | | | | | | | | | | | | | | | | The comparator inversion logic for the RAA489000 is relevant regardless of whether a given system uses an OCPC charger topology or something else; include the code even when OCPC is disabled so single-charger boards can use this feature. BUG=b:262663436,b:263691951 TEST=On pujjo (which does not use OCPC), GSC console now shows AC status bounce from off to on and back off as expected when a charger is disconnected from a hub that does not support fast role swap. BRANCH=nissa LOW_COVERAGE_REASON=AC_PRESENT_CONTROL is not currently tested Change-Id: Ib7c00fcc9644e79ccff62f519764b4fef5d1898a Signed-off-by: Peter Marheine <pmarheine@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4211348 Reviewed-by: Adam Mills <adamjmills@google.com>
* charger/isl9238c: Add BUCK_PHASE_VOLTAGE configjohnwc_yeh2023-01-302-0/+8
| | | | | | | | | | | | | | | | Adjusts the phase comparator threshold offset for forward buck and buck-boost. LOW_COVERAGE_REASON=No isl9238c emulator BUG=b:265862821 BRANCH=none TEST=fix charger stuck in CCM problem and S5 power consumption can meet < 0.5W criteria. Change-Id: Idc10c266e97c104f221eabc51b28c6c243ce17be Signed-off-by: johnwc_yeh <johnwc_yeh@compal.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4179434 Reviewed-by: Diana Z <dzigterman@chromium.org>
* raa489000: Support AC_PRESENT when OTG modeAndrew McRae2023-01-232-0/+64
| | | | | | | | | | | | | | | | | | Flip the comparator inverter output when the charger chip is running in OTG mode so that the AC_PRESENT signal is correctly generated. The AC_PRESENT relies on the ACOK signal, but during OTG mode, ACOK is on when the charger is sourcing power to the port, so AC_PRESENT should be off. BUG=b:263691951 TEST=Verify with nivviks that AC_PRESENT is generated correctly BRANCH=none Change-Id: I004b8caaa63a902dd54288840c044bbe920e1347 Signed-off-by: Andrew McRae <amcrae@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4179436 Reviewed-by: Peter Marheine <pmarheine@chromium.org>
* charger/isl9238c: enable force buck modejohnwc_yeh2022-12-202-0/+11
| | | | | | | | | | | | | | | | | Enable force buck mode for isl9238c. LOW_COVERAGE_REASON=No isl9238c emulator BUG=b:257851736 BRANCH=none TEST=check ISL9238C control0 bit1 can set Change-Id: I9be2c2ad5f0c42797548c2e99b231244de30c51c Signed-off-by: johnwc_yeh <johnwc_yeh@compal.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4091087 Code-Coverage: Diana Z <dzigterman@chromium.org> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Elthan Huang <elthan_huang@compal.corp-partner.google.com> Reviewed-by: Diana Z <dzigterman@chromium.org>
* driver/isl9241: Add CONTROL3 mutexRobert Zieba2022-12-091-19/+44
| | | | | | | | | | | | | | | | | | The CONTROL3 register does not currently seem to be accessed from different threads. However, the recently added PROCHOT info dumping function could access/modify this register from a separate thread. This commit protects CONTROL3 with a mutex. BRANCH=none BUG=b:227768313 TEST=Ran 1000 cycles of charger factory test LOW_COVERAGE_REASON=No isl9241 emulator Change-Id: I9e4b446c7466f28d7d6eb504d9a5606ae158b287 Signed-off-by: Robert Zieba <robertzieba@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4064419 Reviewed-by: Diana Z <dzigterman@chromium.org> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
* driver/charger/isl9241: Add function to help debug PROCHOTRobert Zieba2022-12-092-0/+188
| | | | | | | | | | | | | | | | | | This commit adds the `isl9241_dump_prochot_status` function to dump out prochot information to help debug what caused the prochot. This function is behind a config to help conserve flash space as it includes a fair amount of strings. BRANCH=none BUG=b:227768313 TEST=Verified that `isl9241_dump_prochot_status` works LOW_COVERAGE_REASON=No isl9241 emulator yet Change-Id: Ib6202f8264bbf3b98a71f7f05c2444512a7d1960 Signed-off-by: Robert Zieba <robertzieba@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3994441 Reviewed-by: Diana Z <dzigterman@chromium.org> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
* driver: Sort header filesJeremy Bettis2022-11-2910-17/+17
| | | | | | | | | | | | | | | | | | | | | Sort all includes in driver with the clang-format rules used by the zephyr project. BRANCH=None BUG=b:247100970 TEST=zmake build -a TEST=./twister --clobber -v -i TEST=make -j72 buildall_only runtests TEST=zmake compare-builds -a Signed-off-by: Jeremy Bettis <jbettis@google.com> Change-Id: I675e0db416b6b7cbcfce031c97fd24ad97b66f4f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4052767 Reviewed-by: Yuval Peress <peress@google.com> Commit-Queue: Jeremy Bettis <jbettis@chromium.org> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Tested-by: Jeremy Bettis <jbettis@chromium.org> Reviewed-by: Tom Hughes <tomhughes@chromium.org>
* Rename CONFIG_CHARGER_INPUT_CURRENT to _CHARGER_DEFAULT_CURRENT_LIMITPeter Marheine2022-11-295-11/+12
| | | | | | | | | | | | | | | | | | | "Default input current" is not a very clear name, so rename this option to better express its use as a default value that is set in the charger. This is made possible by splitting other uses into CHARGER_MIN_INPUT_CURRENT_LIMIT, making the only use for CHARGER_INPUT_CURRENT be as a default. BUG=b:163093572 TEST=make buildall; zmake build -a BRANCH=none LOW_COVERAGE_REASON=isl9241 and sm5803 currently lack emulators Signed-off-by: Peter Marheine <pmarheine@chromium.org> Change-Id: Ia9c1df9061825b15477466e85343afeb2a371288 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4025404 Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Keith Short <keithshort@chromium.org>
* isl923x: fix index checkBoris Mittelberg2022-11-181-2/+2
| | | | | | | | | | | | | | | Fix chgnum bound check to avoid out-of-bound access BUG=b:64477774 BRANCH=none TEST=make -j buildall Signed-off-by: Boris Mittelberg <bmbm@google.com> Change-Id: I293732c2a751f71552b6cf17bc9c9e9e2df70391 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4032281 Reviewed-by: caveh jalali <caveh@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
* rt9490: disable special TA detectionalvishsu2022-11-112-0/+7
| | | | | | | | | | | | | | | | | | | ChromeOS doesn't support any non-standard TA other than SDP/CDP/DCP, so disable this feature to make behavior consistent. BUG=b:249226376 TEST=zmake BRANCH=corsola Change-Id: I86bffc94f8ef36b5119f471618955ab77ea16bf2 Signed-off-by: Ting Shen <phoenixshen@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3949344 Reviewed-by: Eric Yilun Lin <yllin@google.com> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Commit-Queue: Ting Shen <phoenixshen@chromium.org> Tested-by: Ting Shen <phoenixshen@chromium.org> Code-Coverage: Eric Yilun Lin <yllin@google.com>
* rt9490: disable the force B-FET on experimental featureTing Shen2022-10-282-0/+29
| | | | | | | | | | | | | | | | | | | | See b:254186078. This is a workaround that applies to all devices, so it's implemented in the common driver code. BUG=b:254186078, b:253568743 TEST=`i2c read_byte I2C_PWR_CBI 0x53 0x6f` returns 0x5e (bit5=0) on tentacruel BRANCH=corsola Signed-off-by: Ting Shen <phoenixshen@google.com> Change-Id: I6c2864423a5bb04fefdc261f20209f44dce8053e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3985083 Reviewed-by: Eric Yilun Lin <yllin@google.com> Commit-Queue: Ting Shen <phoenixshen@chromium.org> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Tested-by: Ting Shen <phoenixshen@chromium.org>
* RAA48900 : Modify configuring trickle charge current codejimmy.wu2022-10-281-1/+1
| | | | | | | | | | | | | | | | | Change requested by power team. Modify register value calculation formula to fit RAA48900 bit. Set PLATFORM_EC_RAA489000_TRICKLE_CHARGE_CURRENT value directly by project.conf. BUG=b:253154031 BRANCH=none TEST=Power team verified get possitive result. Signed-off-by: jimmy.wu <jimmy.wu@lcfc.corp-partner.google.com> Change-Id: I5f5c9e2bb2ce2c2849967621c333269aafea160b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3980705 Code-Coverage: Andrew McRae <amcrae@google.com> Reviewed-by: Peter Marheine <pmarheine@chromium.org>
* isl923x: Add ISL9238C CMOUT latch disable functionYu-An Chen2022-10-282-0/+7
| | | | | | | | | | | | | | | Add ISL9238C CMOUT latch disable function BUG=b:255697209 BRANCH=none TEST=check ISL9238C control6 bit3 can set Signed-off-by: Yu-An Chen <yu-an.chen@quanta.corp-partner.google.com> Change-Id: I9b07aec9065a86b261a0ab76ced3f95bdef7387b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3980939 Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Sam Hurst <shurst@google.com> Reviewed-by: Bob Moragues <moragues@chromium.org>
* rt9490: disable EOC-Force-CCMalvishsu2022-10-282-1/+13
| | | | | | | | | | | | | | | | | | | RT9490 enables EOC-Force-CCM from ES2 to improve IEOC accuracy, while causes other serious problems, like causing Vsys drop randomly when removing the AC. BUG=b:254187010 TEST=Check IEOC accuracy is still tolerable (200~240mA), and 0x11[3]==1'b1 BRANCH=none Signed-off-by: Alvis Hsu <alvishsu@google.com> Change-Id: I9427262d495234360ccd192ef1b83196652615b4 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3943273 Reviewed-by: Eric Yilun Lin <yllin@google.com> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Commit-Queue: Eric Yilun Lin <yllin@google.com> Reviewed-by: Ting Shen <phoenixshen@chromium.org>
* test: chg_ramp_is_detected()Aaron Massey2022-10-251-1/+1
| | | | | | | | | | | | | | | Add a test that verifies the chg_ramp_is_detected() function fetched the charge ramping detection state from driver-specific functions. BRANCH=none BUG=b:255357127 TEST=twister -i -s zephyr/test/drivers/drivers.common_charger Signed-off-by: Aaron Massey <aaronmassey@google.com> Change-Id: I0621f899da731d1b21e5a1d29ffc95c60d4fb586 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3975972 Reviewed-by: Tristan Honscheid <honscheid@google.com> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
* test: chg_ramp_is_stable()Aaron Massey2022-10-251-1/+1
| | | | | | | | | | | | | | | | | Add drivers test library for testing `common/charger.c` functions. Include a test that verifies the chg_ramp_is_stable() function calls the driver-specific function for fetching whether charge ramping has reached a stable state. BRANCH=none BUG=b:255357127 TEST=twister -i -s zephyr/test/drivers/drivers.common_charger Signed-off-by: Aaron Massey <aaronmassey@google.com> Change-Id: I3955ba2b585b149bc8a75997a64aa9512ecd0bf7 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3975971 Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Wai-Hong Tam <waihong@google.com>
* RAA48900 : Allow configuring trickle charge currentjimmy.wu2022-10-241-0/+11
| | | | | | | | | | | | | | | | Change requested by power team. Allow configuring trickle charge current. BUG=b:253154031 BRANCH=none TEST=Power team verified get possitive result. Signed-off-by: jimmy.wu <jimmy.wu@lcfc.corp-partner.google.com> Change-Id: I5a3b4aa8e42d8516cfb16e25863eb9d5df2c65f4 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3955084 Code-Coverage: Andrew McRae <amcrae@google.com> Commit-Queue: Andrew McRae <amcrae@google.com> Reviewed-by: Peter Marheine <pmarheine@chromium.org>
* tree: Enable warning for fallthrough in switch statementsTom Hughes2022-10-192-1/+2
| | | | | | | | | | | | | | | | | | | | | | | The EC code has generally been good about adding comments about intentional fallthrough in switch statements, but there were a few cases without comments (e.g., https://crrev.com/c/3949622). Enabling -Wimplicit-fallthrough generates a compiler warning if the fallthrough is not annotated with __attribute__((fallthrough)). For convenience, we add a "__fallthrough" macro for this attribute. See https://clang.llvm.org/docs/AttributeReference.html#fallthrough and https://gcc.gnu.org/onlinedocs/gcc/Statement-Attributes.html. BRANCH=none BUG=b:253644823 TEST=make buildall LOW_COVERAGE_REASON=legacy code Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: I9f4d6049f4507a25ce706675d159b70e28b4b825 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3957420 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
* Revert "rt9490: remove set_mode function"stabilize-15185.B-mainstabilize-15185.7.B-mainEric Yilun Lin2022-10-141-0/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 48ed43a6f372ea3588ccc7e14ff5da1501050216. Reason for revert: charger_task need set_mode function to prevent error. Original change's description: > rt9490: remove set_mode function > > The flags we implemented is not used anywhere in the codebase. > > BUG=none > TEST=zmake > BRANCH=none > > Signed-off-by: Ting Shen <phoenixshen@google.com> > Change-Id: I72b01806463aec903b1bfe23bb1c12a58a97265d > Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3896556 > Tested-by: Ting Shen <phoenixshen@chromium.org> > Reviewed-by: Eric Yilun Lin <yllin@google.com> > Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> > Commit-Queue: Ting Shen <phoenixshen@chromium.org> Bug: none Change-Id: I5a3942111dbe2e707c34f79a7e5d170be635d69e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3949076 Reviewed-by: Sung-Chi Li <lschyi@chromium.org> Auto-Submit: Eric Yilun Lin <yllin@google.com> Code-Coverage: Sung-Chi Li <lschyi@chromium.org> Commit-Queue: Eric Yilun Lin <yllin@google.com> Tested-by: Eric Yilun Lin <yllin@google.com>
* rt9490: remove set_mode functionTing Shen2022-10-071-28/+0
| | | | | | | | | | | | | | | | The flags we implemented is not used anywhere in the codebase. BUG=none TEST=zmake BRANCH=none Signed-off-by: Ting Shen <phoenixshen@google.com> Change-Id: I72b01806463aec903b1bfe23bb1c12a58a97265d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3896556 Tested-by: Ting Shen <phoenixshen@chromium.org> Reviewed-by: Eric Yilun Lin <yllin@google.com> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Commit-Queue: Ting Shen <phoenixshen@chromium.org>
* sm5803: disable sinking before other reconfigurationPeter Marheine2022-10-061-5/+11
| | | | | | | | | | | | | | | | | | | | | Silicon Mitus say that writing to flow2 enable bits when flow1 is set to an active state (sinking or sourcing) will have no effect, and a silently failed write like that may lead to unexpected (but not dangerous) behavior because the enable bits will not be in the expected state. Most code paths already satisfy this, but disabling the sink currently does not: change sm5803_vbus_sink_enable to disable sinking before updating other configuration, the mirror of ordering when enabling sinking. BUG=none TEST=nereid battery still charges/discharges as expected when PD source is connected or disconnected BRANCH=none LOW_COVERAGE_REASON=no emulators currently exist for sm5803 Signed-off-by: Peter Marheine <pmarheine@chromium.org> Change-Id: I50c7bf20569d7cad058c19aa238aeed8eaf2aa56 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3930177 Reviewed-by: Andrew McRae <amcrae@google.com>
* charger: Detect the number of battery cellsKyle Lin2022-09-281-0/+24
| | | | | | | | | | | | | | | | | | | | | The charging mode of SM5803 charger is configured by sensing an external resistors. The number of battery cells can be determined from the charging mode. To support 2S and 3S batteries in one model(project), the number of battery cells should be detected at run time. BUG=b:242477985 BRANCH=none TEST='make buildall' and 'zmake build -a' Change-Id: Icb7af51ab7b3b27a6fb7ad4ac4b8fe87331108fe Signed-off-by: Kyle Lin <kylelinck@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3892078 Code-Coverage: Andrew McRae <amcrae@google.com> Tested-by: Zick Wei <zick.wei@quanta.corp-partner.google.com> Reviewed-by: Andrew McRae <amcrae@google.com> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Commit-Queue: Andrew McRae <amcrae@google.com> Reviewed-by: Zhuohao Lee <zhuohao@chromium.org>
* rt9490: implement get/set_optionEric Yilun Lin2022-09-261-0/+15
| | | | | | | | | | | | | | | | | | | RT9490 doesn't support charger options, but we still need to implement this function in case of the charger_task reports charge problem and it caused the busy charger_task. BUG=b:246704732 TEST=no charge_problem at the krabby's console BRANCH=none Change-Id: I2a2518d9ef501a1ee9a80603a54772ad5c2bf990 Signed-off-by: Eric Yilun Lin <yllin@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3906518 Tested-by: Eric Yilun Lin <yllin@google.com> Auto-Submit: Eric Yilun Lin <yllin@google.com> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Ting Shen <phoenixshen@chromium.org> Commit-Queue: Ting Shen <phoenixshen@chromium.org>
* rt9490: various bug fixTing Shen2022-09-221-3/+5
| | | | | | | | | | | | | | | | Fixes some bug caught during writing unittest. BUG=b:244233556 TEST=pass all tests BRANCH=none Signed-off-by: Ting Shen <phoenixshen@google.com> Change-Id: Icceed42e100ba71207b99eabb3a79a74e8c9a32d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3896555 Tested-by: Ting Shen <phoenixshen@chromium.org> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Eric Yilun Lin <yllin@google.com> Commit-Queue: Ting Shen <phoenixshen@chromium.org>
* Update license boilerplate text in source code filesMike Frysinger2022-09-1221-21/+21
| | | | | | | | | | | | | | | Normally we don't do this, but enough changes have accumulated that we're doing a tree-wide one-off update of the name & style. BRANCH=none BUG=chromium:1098010 TEST=`repo upload` works Change-Id: Icd3a1723c20595356af83d190b2c6a9078b3013b Signed-off-by: Mike Frysinger <vapier@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3891203 Reviewed-by: Jeremy Bettis <jbettis@chromium.org> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* sm5803: add the CONFIG_BATTERY for the battery apiZhuohao Lee2022-09-081-42/+60
| | | | | | | | | | | | | | | | | | In order to support the HW design which includes a charger ic but doesn't include a battery, we add some checks and only call the battery api when the CONFIG_BATTERY is defined. LOW_COVERAGE_REASON=no SM5803 emulator set up yet BUG=b:242949656 BRANCH=none TEST=build pass with/without CONFIG_BATTERY build pass with `make buildall` Change-Id: I2a8903cb620a70aff5c639eef46607c4c535c7f1 Signed-off-by: Zhuohao Lee <zhuohao@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3865213 Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Diana Z <dzigterman@chromium.org>
* tree-wide: const-ify argv for console commandsCaveh Jalali2022-09-013-6/+6
| | | | | | | | | | | | | | | | | | | | | | | This updates the API for console commands from "int cmd(int argc, char **argv)" to "int cmd(int argc, const char **argv)" which is more accurate and in line with common convention. BRANCH=none BUG=b:244387210 TEST="make buildall" passes TEST="zmake build -a" passes TEST="util/compare_build.sh -b all" passes TEST="./twister -v -T zephyr/test" passes Cq-Depend: chrome-internal:4960125 Cq-Depend: chrome-internal:4959932 Change-Id: I57de9f35b85b8f3c7119df36aefb2abf25d2625f Signed-off-by: Caveh Jalali <caveh@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3863941 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Tom Hughes <tomhughes@chromium.org> Reviewed-by: Keith Short <keithshort@chromium.org>
* temp-sensor-rt9490: migrate to common thermistor codeTing Shen2022-09-012-63/+19
| | | | | | | | | | | | | | | | | | | Reuse existing linear interpolation algorithm and dts structure for rt9490 temperature calculation. BUG=none TEST=`temps` in ec console looks reasonable: ec:~$ temps ambient 324 K (= 51 C) charger 322 K (= 49 C) BRANCH=none Signed-off-by: Ting Shen <phoenixshen@google.com> Change-Id: If69d9332d81a5b23b851c76c2e0539d62cbdfe09 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3865584 Tested-by: Ting Shen <phoenixshen@chromium.org> Reviewed-by: Eric Yilun Lin <yllin@google.com> Commit-Queue: Ting Shen <phoenixshen@chromium.org>
* charger/rt9490: fix incorrect unit in ADC measurementTing Shen2022-08-301-3/+3
| | | | | | | | | | | | | | | The units returned from charger is mV/mA, no need to multiply 1000. BUG=none TEST=manually checked datasheet BRANCH=none Signed-off-by: Ting Shen <phoenixshen@google.com> Change-Id: Icdb56294b6508f684a3d0eebeeadf786f5ef2086 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3744039 Commit-Queue: Ting Shen <phoenixshen@chromium.org> Reviewed-by: Eric Yilun Lin <yllin@google.com> Tested-by: Ting Shen <phoenixshen@chromium.org>
* RT9490 : Use ADC thermistor on RT9490jeffrey2022-08-292-0/+76
| | | | | | | | | | | | | | | | | Use thermistor RT9490 for charger temperature. BUG=b:242267801 TEST=ectool temps all to check it can read thermistor temperature. BRANCH=None Signed-off-by: jeffrey <jeffrey_lin@pegatron.corp-partner.google.com> Change-Id: I91a01adafdc6aca7fcd2afb14c4e6a099826e46e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3853779 Reviewed-by: Ting Shen <phoenixshen@chromium.org> Reviewed-by: Jeffrey Lin <jeffrey_lin@pegatron.corp-partner.google.com> Commit-Queue: Jeffrey Lin <jeffrey_lin@pegatron.corp-partner.google.com> Tested-by: Jeffrey Lin <jeffrey_lin@pegatron.corp-partner.google.com>
* charger/rt9490: workaround code cleanupTing Shen2022-08-251-5/+4
| | | | | | | | | | | | | | | | | | Rearrange the workaround code and common init code: Workaround goes to zephyr/project/corsola, and limit its access to Krabby and Tentacruel only. BUG=none TEST=manually check charger works fine on tentacruel BRANCH=none Signed-off-by: Ting Shen <phoenixshen@google.com> Change-Id: Ieb7526f9e8aa36ac8457a6388f427a63ce4a105e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3853777 Reviewed-by: Eric Yilun Lin <yllin@google.com> Tested-by: Ting Shen <phoenixshen@chromium.org> Commit-Queue: Ting Shen <phoenixshen@chromium.org>
* RT9490: Update CHARGE_I_MIN setting.jeffrey2022-08-241-4/+3
| | | | | | | | | | | | | | | | According to newest vendor datasheet, modify CHARGE_I_MIN from 50 to 150mA BUG=b:238980988 TEST=zmake build tentacruel --clobber to solve tentacruel Ac only boot fail issue. BRANCH=none Signed-off-by: jeffrey <jeffrey_lin@pegatron.corp-partner.google.com> Change-Id: I57db22f290a863ed669092ff7929fd2563b7a6e6 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3849362 Reviewed-by: Ting Shen <phoenixshen@chromium.org> Reviewed-by: Alvis Hsu <alvishsu@google.com> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
* sm5803: avoid requesting 0 fast-charge currentPeter Marheine2022-08-151-0/+12
| | | | | | | | | | | | | | | | | | | Silicon Mitus claim that setting the fast charge current to zero can cause charger instability, so force requests for zero current to set a nominal value instead of zero. This should be safe because this function only sets the fast charge current limit, and situations where the charge manager sets zero current should be outside the domain where the charger will use fast-charge mode. BUG=b:230712704 TEST=Fast charge current limit on Nereid is set to 100 mA instead of zero when the battery is fully charged; no errors are reported. BRANCH=none Signed-off-by: Peter Marheine <pmarheine@chromium.org> Change-Id: I3f625552913d40a7a8f8b3d0ac9874e3af7f0a56 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3826712 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* util: remove unused includesYuval Peress2022-08-052-0/+2
| | | | | | | | | | | | | | | | Remove these includes as they're not needed in this header. Instead, the includes should go where they're actually being used. BRANCH=none BUG=b:240574048 TEST=make buildall -j TEST=zmake build -a Signed-off-by: Yuval Peress <peress@google.com> Change-Id: I64b10af3216654b2a20caa1cabd267661a0bca39 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3791980 Reviewed-by: Tristan Honscheid <honscheid@google.com> Commit-Queue: Tristan Honscheid <honscheid@google.com>