summaryrefslogtreecommitdiff
path: root/driver/charger
Commit message (Collapse)AuthorAgeFilesLines
* charger/rt946x: fix mt6370 IEOC inaccuracyYilun Lin2019-11-211-8/+63
| | | | | | | | | | | | | | | | mt6370's IEOC is inaccurate when charging current < 900mA; the power path only partially turned on under such situation. Hence, we have to raise the IEOC setting if the current is under 900mA to compensate the IEOC original setting. BUG=b:144532905 BRANCH=kukui TEST=ensure IEOC is raised when Ichg < 900mA. Change-Id: I9f1575bb707bc91e428c06a93c4682dde22d90fc Signed-off-by: Yilun Lin <yllin@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1924167 Reviewed-by: Ting Shen <phoenixshen@chromium.org>
* rt946x: Fix MT6370 charger type detectionGene Chen2019-11-141-0/+30
| | | | | | | | | | | | | | add bc12 workaround when bc12 detect SDP BRANCH=kukui BUG=b:128049211 TEST=boot kukui, slow plug in DCP, check bc12 detect chg type Change-Id: Ie9b8780fdad6e061e967ebb127b27bf63a11db2e Signed-off-by: Gene Chen <gene_chen@mediatek.corp-partner.google.com> Signed-off-by: Yilun Lin <yllin@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1568887 Reviewed-by: Ting Shen <phoenixshen@chromium.org>
* rt946x: Fix MT6370 Charger back boost and INT miss issueAllen Chiang2019-11-132-44/+342
| | | | | | | | | | | | | | | | | | | | | | | 1. Add ADC readings. 2. Add MIVR IRQ, when trigger mivr irq then get ibus adc, if the ibus < 100mA then toggle cfo to stop LX/RX function, that can cancel the back boost voltage. 3. In order to solve the issue of missing IRQ, it is necessary to record the state of IRQs before and after reading event of IRQs. BRANCH=kukui BUG=b:134372910 TEST=boot kukui, trigger interrupt, check interrupt handler is OK. Change-Id: I695125b1c25f13ab73713304727cbb7a1d90083c Signed-off-by: Allen Chiang <allen_chiang@mediatek.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1660522 Reviewed-by: Eric Yilun Lin <yllin@chromium.org> Commit-Queue: Eric Yilun Lin <yllin@chromium.org> Tested-by: Eric Yilun Lin <yllin@chromium.org>
* Add a board specific helper to return USB PD port countKarthikeyan Ramasubramanian2019-11-091-2/+2
| | | | | | | | | | | | | | | | | | | | | Certain SKUs of certain boards have less number of USB PD ports than configured in CONFIG_USB_PD_PORT_MAX_COUNT. Hence define an overrideable board specific helper to return the number of USB PD ports. This helps to avoid initiating a PD firmware update in SKUs where there are less number of USB PD ports. Also update charge manager to ensure that absent/ invalid PD ports are skipped during port initialization and management. BUG=b:140816510, b:143196487 BRANCH=octopus TEST=make -j buildall; Boot to ChromeOS in bobba(2A + 2C config) and garg(2A + 1C + 1HDMI config). Change-Id: Ie345cef470ad878ec443ddf4797e5d17cfe1f61e Signed-off-by: Karthikeyan Ramasubramanian <kramasub@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1879338 Tested-by: Karthikeyan Ramasubramanian <kramasub@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Karthikeyan Ramasubramanian <kramasub@chromium.org>
* Kodama: SMP battery cannot be charged in over discharge statexiong.huang2019-11-082-0/+11
| | | | | | | | | | | | | | | | | | | | SMP battery uses HW pre-charge circuit and pre-charge current is limited to ~50mA. Once the charge current is lower than IEOC level within CHG_TEDG_EOC, and TE is enabled, the charging power path will be turned off. Charger vendor advice that disable EOC and TE when battery stays over discharge state, otherwise enable EOC and TE. BUG=b:142630134 TEST=Verified on both SMP battery and Celxpert battery in over discharge state, all passed. BRANCH=kukui Change-Id: I7d6907d54ab555587a489333350de6e9aeffe60e Signed-off-by: Xiong Huang <xiong.huang@bitland.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1893901 Reviewed-by: Eric Yilun Lin <yllin@chromium.org>
* kukui: Support mt6370 bc12 detect apple/samsung TATJ Wu2019-11-072-42/+190
| | | | | | | | | | | | | | | | Support mt6370 bc12 detect apple/samsung TA TEST=plug in apple/samsung TA, and use power supply check charger type BUG=b:118791032 b:122866184 BRANCH=kukui Change-Id: Ieb684f7a3d38e3b36aab9bcf27cbc823b5a7df81 Signed-off-by: TJ Wu <tj_wu@richtek.com> Signed-off-by: Yilun Lin <yllin@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1351910 Reviewed-by: Eric Yilun Lin <yllin@chromium.org> Commit-Queue: Hung-Te Lin <hungte@chromium.org> Tested-by: Hung-Te Lin <hungte@chromium.org>
* Rename CONFIG_USB_PD_PORT_COUNT as CONFIG_USB_PD_PORT_MAX_COUNTKarthikeyan Ramasubramanian2019-11-011-4/+4
| | | | | | | | | | | | | | | | | Certain SKUs of certain boards have lesser number of USB PD ports than defined by CONFIG_USB_PD_PORT_COUNT. Hence rename CONFIG_USB_PD_PORT_COUNT as CONFIG_USB_PD_PORT_MAX_COUNT. BUG=b:140816510, b:143196487 BRANCH=octopus TEST=make -j buildall; Boot to ChromeOS Change-Id: I7c33b27150730a1a3b5813b7b4a72fd24ab73c6a Signed-off-by: Karthikeyan Ramasubramanian <kramasub@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1879337 Tested-by: Karthikeyan Ramasubramanian <kramasub@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Jett Rink <jettrink@chromium.org>
* charger/mt6370: fix the disable sequence of bc12 detectionTing Shen2019-10-081-3/+12
| | | | | | | | | | | | | | | | | BC12_DET_EN should be disabled after mt6370 stops bc12 detection. Otherwise, race condition may happen because both ap and charger have access to D+ and D- pins. BUG=b:141005922 TEST=make sure b:141005922 is not reproducible after this fix. BRANCH=master Change-Id: I89750efe58ba65b72bc47ee42c4923e560d9d534 Signed-off-by: Ting Shen <phoenixshen@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1839711 Reviewed-by: Yilun Lin <yllin@chromium.org> Tested-by: Ting Shen <phoenixshen@chromium.org> Commit-Queue: Ting Shen <phoenixshen@chromium.org>
* isl9241: fix max/min/step currents in charger infoEdward Hill2019-10-051-6/+6
| | | | | | | | | | | | | | | | Remove BC_REG_TO_CURRENT conversion since for ISL9241 the max/min/step values are already in milliamps. BUG=b:141785541 BRANCH=none TEST=power on trembyle Change-Id: I77605817aa97a99b9a69a05f663b5fc8d8fd4869 Signed-off-by: Edward Hill <ecgh@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1838253 Reviewed-by: Keith Short <keithshort@chromium.org> Reviewed-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Vijay P Hiremath <vijay.p.hiremath@intel.com>
* printf: Convert %b to %pbEvan Green2019-10-051-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | In order to turn on compile-time printf format checking, non-standard specifiers like %b (binary) must be removed. Convert that into %pb, which takes a pointer to a structure containing the value to print, and how many bits to print. Use the convenience macro BINARY_VALUE() to package these values up into a struct whose pointer is passed to printf(). Technically this is slightly more limited functionality than we used to support given all the possible flags, field width, and precision. However every existing instance in our codebase was using %0NNb, where NN is some number. If more variants are needed, the parameters structure can be expanded in the future. BUG=chromium:984041 TEST=make -j buildall BRANCH=None Change-Id: I8ef995dcf97af688fbca98ab6ff59b84092b69e3 Signed-off-by: Evan Green <evgreen@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1733100 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* kukui: Raise DCP current limit to 2150mA.Yilun Lin2019-10-022-1/+8
| | | | | | | | | | | | | | | | | On mt6370, setting ACIR is equivalent to setting Input current max, and the accuracy is 7%. So if AICR=2150mA, then Max=2150mA, and Typ=Max*0.93=2000mA, and Min=Typ*0.93=1860mA. This CL also raise S0 current limit to 2150mA. TEST=Plug Krane charger, and see it could ramp to 1920mA in S0. BUG=b:137700946 BRANCH=None Change-Id: Iea6186c39c916ddf601917ea6e6b6463069c9292 Signed-off-by: Yilun Lin <yllin@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1708170 Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
* battery: add precharge voltageTing Shen2019-10-012-2/+5
| | | | | | | | | | | | | | | Add a precharge_voltage field to batt_info in case we need its value differ from voltage_min, and set precharge_voltage = 3.4V according to battery spec. BUG=b:139012899 TEST=observe the charging curve (see issue link above for test result) BRANCH=master Change-Id: I2e4b240a12cd023ed90aaeda922e10b262508624 Signed-off-by: Ting Shen <phoenixshen@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1795491 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* bq25710: Update ICO mode feature for charger hw rampScott Collyer2019-10-012-18/+33
| | | | | | | | | | | | | | | | | | | | | This CL makes some modifications to how ICO mode is utilized to support the input current hw ramp feature. ICO mode can't be used when there is no battery present, so a check has been added for battery presence. In addition, the input current limit should have been read from the IIN_DPM register. BRANCH=none BUG=b:126229130 TEST=Tested variaous legacy chargers and verfied that ICO mode completes and gives the expected current limit. Tested that when no battery is present, ICO mode is not enabled. Change-Id: Ib2dcff4c7bddea52c267d678b17c50daf1356b44 Signed-off-by: Scott Collyer <scollyer@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1827255 Tested-by: Scott Collyer <scollyer@chromium.org> Reviewed-by: Tim Wawrzynczak <twawrzynczak@chromium.org> Commit-Queue: Scott Collyer <scollyer@chromium.org>
* rt946x: raise current limit to 2A for HW rampTing Shen2019-09-091-1/+3
| | | | | | | | | | | | | | | | CL:1633930 raised DCP input current limit to 2A when SW ramp enabled, the same limit should also apply to HW ramp too. BUG=b:139012899 TEST=observe the charging curve (see issue link above for test result) BRANCH=master Change-Id: I22098bd81bb46c7d1e638e7b4db8b87cd3284533 Signed-off-by: Ting Shen <phoenixshen@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1760655 Reviewed-by: Yilun Lin <yllin@chromium.org> Commit-Queue: Ting Shen <phoenixshen@chromium.org> Tested-by: Ting Shen <phoenixshen@chromium.org>
* driver/rt946x: check wrong bit status when ADC conversionxiong.huang2019-08-211-1/+1
| | | | | | | | | | | | | | | | Base on official MT6370 datasheet, ADC_STAT status is 0 which indicates ADC conversion complete. BUG=b:139653474 BRANCH=master TEST=Add more log information, EC will check ADC_STAT status about 6 times in one loop. Change-Id: I50a10c25cfb35a1f41c569fabf360c5e29f44be2 Signed-off-by: Xiong Huang <xiong.huang@bitland.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1760661 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Philip Chen <philipchen@chromium.org>
* isl9241: add charger_get_vbus_voltageDenis Brockus2019-08-082-0/+51
| | | | | | | | | | | | BUG=b:138600692 BRANCH=none TEST=make buildall -j Change-Id: Idd20b1833945e37a84db4e7c444d8974f6059f83 Signed-off-by: Denis Brockus <dbrockus@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1742532 Commit-Queue: Edward Hill <ecgh@chromium.org> Reviewed-by: Edward Hill <ecgh@chromium.org>
* Zork: Change charger to ISL9241Denis Brockus2019-07-261-2/+4
| | | | | | | | | | | | | | | | Found a couple of compile issues when I swapped over to the ISL9241 charger. So fixed those as I changed chargers. BUG=none BRANCH=none TEST=make buildall -j Change-Id: Ifcacca859eb86f22ea0619e05dcaa689c56b0d73 Signed-off-by: Denis Brockus <dbrockus@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1720859 Reviewed-by: Edward Hill <ecgh@chromium.org> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Commit-Queue: Edward Hill <ecgh@chromium.org>
* isl923x: Check max current in isl923x_set_dc_prochotKo2019-07-262-2/+22
| | | | | | | | | | | | | | | | | | The DCProchot register takes a value in multiple of 128 up to 12800 mA. This patch makes isl923x_set_dc_prochot return error when a value exceeding the max is passed. Signed-off-by: Ko Ko <ko_ko@compal.corp-partner.google.com> BUG=b/130387567 BRANCH=Nami TEST=buildall Change-Id: If2155d7fc74c1491bf7c0a742ba8356c268a94a7 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1716673 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org>
* isl923x: Fix console messagesDaisuke Nojiri2019-07-241-3/+4
| | | | | | | | | | | | | | | | | | This patch fixes how the console messages in isl923x.c are printed. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> BUG=none BRANCH=none TEST=buildall Change-Id: I81cd1fc9f0a20a4908013b7b3051fc23953eefc2 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1670699 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org> Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org> Auto-Submit: Daisuke Nojiri <dnojiri@chromium.org>
* isl923x: Check max current in isl923x_set_ac_prochotDaisuke Nojiri2019-07-242-14/+16
| | | | | | | | | | | | | | | | | | | | | The ACProchot register takes a value in multiple of 128 up to 6400 mA. This patch makes isl923x_set_ac_prochot return error when a value exceeding the max is passed. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> BUG=b/130387567 BRANCH=Nami TEST=buildall Change-Id: I1854f091d6ee7eb042fefeff35094abeca452c2f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1669796 Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org> Auto-Submit: Daisuke Nojiri <dnojiri@chromium.org> Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org>
* charger/rt946x: notify AC_CHANGE when ext power plugged/unpluggedYilun Lin2019-07-221-0/+3
| | | | | | | | | | | | | | | | | Support hooking on AC_CHANGE when external power plugged and unplugged. BUG=b:137903027 TEST=on kukui, shutdown -h now, and plug power adapter on kukui, and see battery LED turning on immediately, and also see console prints "AC on" BRANCH=master Change-Id: I6e2704cfe2d3ed09cc6e1c76b8d03a5030a400ed Signed-off-by: Yilun Lin <yllin@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1712400 Reviewed-by: Nicolas Boichat <drinkcat@chromium.org> Commit-Queue: Yilun Lin <yllin@chromium.org> Tested-by: Yilun Lin <yllin@chromium.org>
* Remove __7b, __8b and __7bfDenis Brockus2019-07-2016-48/+48
| | | | | | | | | | | | | | | | | | | The extentions were added to make the compiler perform most of the verification that the conversion was being done correctly to remove 8bit addressing as the standard I2C/SPI address type. Now that the compiler has verified the code, the extra extentions are being removed BUG=chromium:971296 BRANCH=none TEST=make buildall -j TEST=verify sensor functionality on arcada_ish Change-Id: I36894f8bb9daefb5b31b5e91577708f6f9af2a4f Signed-off-by: Denis Brockus <dbrockus@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1704792 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* Use 7bit I2C/SPI slave addresses in ECDenis Brockus2019-07-1916-52/+66
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Opt for 7bit slave addresses in EC code. If 8bit is expected by a driver, make it local and show this in the naming. Use __7b, __7bf and __8b as name extensions for i2c/spi addresses used in the EC codebase. __7b indicates a 7bit address by itself. __7bf indicates a 7bit address with optional flags attached. __8b indicates a 8bit address by itself. Allow space for 10bit addresses, even though this is not currently being used by any of our attached devices. These extensions are for verification purposes only and will be removed in the last pass of this ticket. I want to make sure the variable names reflect the type to help eliminate future 7/8/7-flags confusion. BUG=chromium:971296 BRANCH=none TEST=make buildall -j Change-Id: I2fc3d1b52ce76184492b2aaff3060f486ca45f45 Signed-off-by: Denis Brockus <dbrockus@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1699893 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* isl9241: Enable support for hardware charge rampVijay Hiremath2019-07-022-0/+66
| | | | | | | | | | | | | | | | | | The input voltage regulation register 0x4B contains the voltage limit at which the input voltage loop tries to regulate when the input voltage is dropping. When the ADP is browning out or weak, the input voltage can droop and the input voltage loop tries to regulate to this setting by reducing battery charging current and then system power to try to hold up the input voltage. BUG=b:136198519 BRANCH=none TEST=Able to verify BC1.2 charge ramping on INTELRVP Change-Id: I0f712215c9323a75de71342d5ae5341c3e4e1fa6 Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1672211 Reviewed-by: Jett Rink <jettrink@chromium.org>
* Nami: Add Adapter PROCHOT SettingKo2019-06-202-0/+24
| | | | | | | | | | | | | | | Currently, we use default current, 3.072A for adapter current PROCHOT# threshold, add higher prochot current to improve performance on Nami. BUG=b:130387567 BRANCH=Nami TEST=Verify Nami ac prochot set to 0XD00 (3328mA) during initial. Change-Id: Iee23920b3fd3ee76d3d12716d6381062183413cc Signed-off-by: Ko <ko_ko@compal.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1628631 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* LICENSE: remove unnecessary (c) after CopyrightTom Hughes2019-06-1914-14/+14
| | | | | | | | | | | | | | | | Ran the following command: git grep -l 'Copyright (c)' | \ xargs sed -i 's/Copyright (c)/Copyright/g' BRANCH=none BUG=none TEST=make buildall -j Change-Id: I6cc4a0f7e8b30d5b5f97d53c031c299f3e164ca7 Signed-off-by: Tom Hughes <tomhughes@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1663262 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* krane: Enable BC12 detection with gpio controlled.Yilun Lin2019-06-171-2/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Support CONFIG_BC12_DETECT_POWER_ROLE_TRIGGER. Krane's BC12 detection is controlled by GPIO_BC12_DET_EN by disconnecting USB-PHY, that is: - Assert GPIO_BC12_DET_EN, then USB-PHY is disconnected - Deassert GPIO_BC12_DET_EN, then USB-PHY is connected. The current usb_chg_task will make USB devices not be enumerated, since GPIO_BC12_DET_EN is deasserted only when VBUS attached and BC12 device identified. However, peripherals won't trigger BC12 detection so GPIO_BC12_DET_EN always asserted. To fix this problem, we trigger BC12 detection only when a port is attached and hook USB_PD_CONNECTED to toggle BC12 detection. We have to - Assert GPIO_BC12_DET_EN on SRC device plugged to recognize BC12 charger. - After BC12 device detected, we have to disable BC12 to connect USB-PHY back for enumerating USB devices. - Deassert GPIO_BC12_DET_EN on SNK device plugged to enumerate USB devices. TEST=Test with https://crrev.com/c/1408751/1, and see it is able to recognize Apple 2.4A charger and 5V2A DCP charger. TEST=Boot w/ USB hub plugged (w/ and w/o external BC1.2 charger on the hub) and see USB devices are enumerated. BUG=b:122866184 BRANCH=None Change-Id: I5b3362305361c0c950288fc83072e9bc79082c08 Signed-off-by: Yilun Lin <yllin@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1575050 Tested-by: Yilun Lin <yllin@chromium.org> Auto-Submit: Yilun Lin <yllin@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Commit-Queue: Yilun Lin <yllin@chromium.org>
* rt946x: Add API for backlight LED dim.Yilun Lin2019-06-172-0/+36
| | | | | | | | | | | | | | | | Add mt6370_backlight_set_dim() for setting backlight LED dim. TEST=None BUG=b:133655155 BRANCH=None Change-Id: Ia5b80734f72c6fb8750c33f62133fc1cdd71f213 Signed-off-by: Yilun Lin <yllin@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1635137 Tested-by: Yilun Lin <yllin@chromium.org> Commit-Queue: Yilun Lin <yllin@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Auto-Submit: Yilun Lin <yllin@chromium.org>
* charger/rt946x: Support software ramping API.Yilun Lin2019-06-121-1/+14
| | | | | | | | | | | | | | | | | | Add usb_charger_ramp_allowed() and usb_Charger_ramp_max() API. Also, targets DCP ramping voltage to 2000mA(charger support maximum is 3500mA), a conservative value to prevent a bad charger. TEST=With CL:1610385, plug a DCP 5V/2.1A charger and see it ramps and drains up to 1.75A, rather than original 1.34A. BUG=b:131284131 BRANCH=None Change-Id: I1e87badbca8991862186fc37227d203cfb54bce3 Signed-off-by: Yilun Lin <yllin@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1633930 Commit-Queue: Yilun Lin <yllin@chromium.org> Tested-by: Yilun Lin <yllin@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* Flapjack: Trigger BC12 detection when AC charger is pluggedDaisuke Nojiri2019-06-102-0/+18
| | | | | | | | | | | | | | | | | | | | | | Currently, when a BC12 charger is plugged while wireless charging is taking place, rt946x does not trigger detection because VBUS is already supplied. This makes charge_manger see a BC12 charger as a WPC supplier. This patch makes EC manually trigger BC12 detection when an AC charger is plugged. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> BUG=b/127228934 BRANCH=none TEST=Start charging on WPC. Connect a BC12 charger. Verify the supplier switches to DCP (1.5A @5V). Change-Id: I8e3439682515bf2241f6756a5386a7ad3ab2e14c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1593742 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org>
* charger/rt946x: Add display bias API mt6370_db_set_voltages.Yilun Lin2019-06-032-4/+84
| | | | | | | | | | | | | | | | | | | | Add mt6370_db_set_voltages to control VBST, VPOS, and VNEG. TEST=Test with CL:1632132 on krane: i2cxfer r 0 0x68 0xb1; see output 0x36 i2cxfer r 0 0x68 0xb2; see output 0x68 i2cxfer r 0 0x68 0xb3; see output 0x64 i2cxfer r 0 0x68 0xb4; see output 0x64 BUG=b:125644770 BRANCH=None Change-Id: Ia66ba91a2af3a651a71195dd8a2d531bf1ba06e9 Signed-off-by: Yilun Lin <yllin@google.com> Reviewed-on: https://chromium-review.googlesource.com/1613257 Commit-Ready: Yilun Lin <yllin@chromium.org> Tested-by: Yilun Lin <yllin@chromium.org> Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* charger/rt946x: Keep backlight in linear modeNicolas Boichat2019-05-222-1/+10
| | | | | | | | | | | | | | | | | | | | | Backlight BLEN register default (and desired) setting is to keep backlight in linear mode ('1'), do not clear that bit when enabling the backlight. There is one more bit in the register (bled_config), but for that one, the default active low setting is correct. BRANCH=none BUG=b:132225489 TEST=Boot krane with software sync disabled, see that default backlight is reasonable. Change-Id: I2e8867ee6d39e2c5eabe64719105e8f463dec2a7 Signed-off-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1621645 Tested-by: Fei Shao <fshao@chromium.org> Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org> Reviewed-by: Yilun Lin <yllin@chromium.org>
* bq25710: Allow IDCHG to be used as a prochot triggerScott Collyer2019-05-212-0/+65
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Kohaku units are currently using a 2S+1P battery back which is not able to provide sufficient power for peak CPU load when running on battery only. The bq25710 has various triggers for prochot and one of those is IDCHG (battery discharge current). This CL adds a new config option CONFIG_CHARGER_BQ25710_IDCHG_LIMIT_MA to enable this feature in the bq25710. For prochot to be active, the bq25710 must remain in performance mode. Chispet hooks are used to request the bq25710 in/out of performace mode when the IDCHG prochot feature is active. BUG=b:132285560 BRANCH=none TEST=Manual Connected wires to VBAT, PPVAR_SYS, PROCHOT_ODL signals and had a current probe connected to measure IBAT. Verfied that without this CL, VBAT shuts off when IBAT spikes. With this CL, then verified that prochot gets asserted whenever the current spikes to values specified by CONFIG_CHARGER_BQ25710_IDCHG_LIMIT_MA. In addition verified that with this CL, the system can successfully boot and remain powered on even as CPU load gets increased. Change-Id: If13d16f561b76289936d0d75a2b984d2b71b3c37 Signed-off-by: Scott Collyer <scollyer@google.com> Reviewed-on: https://chromium-review.googlesource.com/1613797 Commit-Ready: Scott Collyer <scollyer@chromium.org> Tested-by: Scott Collyer <scollyer@chromium.org> Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org> Reviewed-by: Tim Wawrzynczak <twawrzynczak@chromium.org>
* bq25710: Adjust settings to limit VSYS droop with no batteryScott Collyer2019-05-172-7/+59
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When there is no battery present VSYS is set to the value defined in register 0x3E. The reset value of this register is based on what type of battery pack is used. In addition to this, big core systems such as CML can a peak power draw that exceeds the external USB PD adapters limit. This can lead to a VSYS collapse which then will cause the AP to sequence out of S0. This CL modifies 3 default settings for the bq25710 to reduce the likelihood of VSYS droop leading to the AP exiting S0. The primary change here is enabling prochot to be active when VSYS is operating within a threshold of VSYS_MIN. As mentioned above, in the no battery case, this will always be true which results in prochot being continuosly asserted. In addition, when a battery is present, but deeply discharged, prochot would be similarly asserted until the bq25710 exits its precharge state. In addition to the settings change, the reset register control bit is set at the beginning of the init routine to ensure that following EC resets the bq25710 always starts in the same state as it does following a power cycle event. BUG=b:130209125 BRANCH=none TEST=Verfied that when using both a 45W and 60W USB PD external charger that Hatch can boot successfully without a battery. In particular tested that without setting BQ25710_PROCHOT_PROFILE_VSYS hatch fails to boot successfully to the kernel, but does when this bit is set. Also with scope verified that prochot is continuosly asserted when there is no battery present. Change-Id: I450f735bca861baa5aae45af70fd8344a618f609 Signed-off-by: Scott Collyer <scollyer@google.com> Reviewed-on: https://chromium-review.googlesource.com/1580184 Commit-Ready: Scott Collyer <scollyer@chromium.org> Tested-by: Scott Collyer <scollyer@chromium.org> Reviewed-by: Furquan Shaikh <furquan@chromium.org>
* charger/rt946x: Mask out display bias interrupt.Yilun Lin2019-05-121-0/+2
| | | | | | | | | | | | | | | | | Though there is display bias interrupt from mt6370, we don't need to handle this. Mask out the event. TEST=Connect a display and boot to AP, and see the BC1.2 work as expected. BUG=b:132401501 BRANCH=None Change-Id: I7e5eeb6b65890f65f67e535f0848ca289f452962 Signed-off-by: Yilun Lin <yllin@google.com> Reviewed-on: https://chromium-review.googlesource.com/1605665 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: Yilun Lin <yllin@chromium.org> Reviewed-by: Ting Shen <phoenixshen@chromium.org>
* charger/rt946x,krane: Enable backlight power.Yilun Lin2019-05-122-0/+29
| | | | | | | | | | | | | | | Krane's backlight power and PWM is controlled by mt6370. TEST=See the backlight is enabled on krane. BUG=b:131125903 BRANCH=None Change-Id: I9276a73d1a36e6b1eb64b39d7e9e988cda164ada Signed-off-by: Yilun Lin <yllin@google.com> Reviewed-on: https://chromium-review.googlesource.com/1575051 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: Yilun Lin <yllin@chromium.org> Reviewed-by: Ting Shen <phoenixshen@chromium.org>
* bq25710: Add support for charger_dump commandFurquan Shaikh2019-05-091-0/+48
| | | | | | | | | | | | | | | | This change adds a debug command to dump all readable charger registers on bq25710. BUG=None BRANCH=None TEST=Verified that charger_dump command works on EC console. Change-Id: Ide4a39c6bb2a9410a3beb913aa6ebcb44919f844 Signed-off-by: Furquan Shaikh <furquan@google.com> Reviewed-on: https://chromium-review.googlesource.com/1566667 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: Scott Collyer <scollyer@chromium.org> Reviewed-by: Scott Collyer <scollyer@chromium.org>
* charger: Add basic driver code for ISL9241Vijay Hiremath2019-04-262-0/+467
| | | | | | | | | | | | | | | | | | The ISL9241 is a digitally configurable buck-boost battery charger that can support both Narrow Voltage Direct Charging (NVDC) and Hybrid Power Buck Boost (HPBB/Bypass) charging and switch between the modes using firmware control. BUG=b:131123775 BRANCH=none TEST=Able to boot intelrvp with charger & battery is charging Change-Id: If0736136778cbe7650ed7f03d04f4e011eedd1f6 Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com> Reviewed-on: https://chromium-review.googlesource.com/1579241 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: Vijay P Hiremath <vijay.p.hiremath@intel.com> Reviewed-by: Jett Rink <jettrink@chromium.org>
* rt946x: Allow board customize initialization parametersDaisuke Nojiri2019-04-232-17/+24
| | | | | | | | | | | | | | | | | Currently, initialization parameters are fixed. This patch allows a board to customize how the chip is initialized. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> BUG=b/80482240 BRANCH=none TEST=buildall Change-Id: I0be0547d73de4d3f37e80e763efaf7840fd678c2 Reviewed-on: https://chromium-review.googlesource.com/1553564 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Nick Sanders <nsanders@chromium.org>
* P9221: Add P9221 driverTony Zou2019-04-221-3/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds P9221 driver and enable it for Flapjack. The driver originates from https://android.googlesource.com/kernel /msm/+/android-msm-bluecross-4.9-pie-qpr1/drivers/power/supply/qcom /p9221_charger.c CQ-DEPEND=CL:1445133 CL:1551583 BRANCH=none BUG=b:126162615 TEST=Verify charging from PD and WPC as follows: 1. Charge with PD charger. Place DUT on WPC charger. -> PD charger continues to charge. 2. Unplug PD charger. -> WPC starts charging as GPP. 3. Plug PD charger. -> PD charger starts charging at 2A@9V TEST=Verify OTG and WPC functionality as follows: 1. Plug fan to USB port: -> Fan spins 2. Place DUT on WPC charger: -> WPC starts charging as GPP. Fan continues to spin. 3. Remove DUT from WPC charger: -> Fan continues to spin. 4. Do 1 and 2 then unplug USB fan: -> WPC starts charging. TEST=/sys/class/power_supply/CROS_USBPD_CHARGER0/usb_type is BrickID /sys/class/power_supply/sbs-12-000b/status is ok Change-Id: I5fbd0237cedd8095f98582c39973d432e733f2cd Signed-off-by: Tony Zou <zoutao@huaqin.corp-partner.google.com> Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1448193 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
* common: bit change 1 << constants with BIT(constants)Gwendal Grignou2019-03-262-40/+40
| | | | | | | | | | | | | | | | | Mechanical replacement of bit operation where operand is a constant. More bit operation exist, but prone to errors. Reveal a bug in npcx: chip/npcx/system-npcx7.c:114:54: error: conversion from 'long unsigned int' to 'uint8_t' {aka 'volatile unsigned char'} changes value from '16777215' to '255' [-Werror=overflow] BUG=None BRANCH=None TEST=None Change-Id: I006614026143fa180702ac0d1cc2ceb1b3c6eeb0 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1518660 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* common: replace 1 << digits, with BIT(digits)Gwendal Grignou2019-03-2613-250/+250
| | | | | | | | | | | | | | | | Requested for linux integration, use BIT instead of 1 << First step replace bit operation with operand containing only digits. Fix an error in motion_lid try to set bit 31 of a signed integer. BUG=None BRANCH=None TEST=compile Change-Id: Ie843611f2f68e241f0f40d4067f7ade726951d29 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1518659 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* kukui: Enable MT6370 DB_POSVOUT/DB_NEGVOUTNicolas Boichat2019-03-122-0/+26
| | | | | | | | | | | | | BRANCH=none BUG=b:123669273 TEST=Boot kukui P2, panel AVDD/AVEE looks good Change-Id: Ie9b8780fdad6e061e967ebb127b27bf63a11db2f Signed-off-by: Yilun Lin <yllin@google.com> Reviewed-on: https://chromium-review.googlesource.com/1482633 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
* bq25710: Report VBUS as 0 when VBUS is too low to measurePhilip Chen2019-03-081-3/+7
| | | | | | | | | | | | BUG=b:124968142 BRANCH=none TEST=verify VBUS measurement via 'ectool usbpdpower' Change-Id: I1966537f394016706f96e975c7b54008ea8bfa33 Signed-off-by: Philip Chen <philipchen@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1509176 Reviewed-by: Scott Collyer <scollyer@chromium.org> Reviewed-by: Furquan Shaikh <furquan@chromium.org>
* bq25710: Disable VDPM-triggered PROCHOT by defaultPhilip Chen2019-03-062-1/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | PROCHOT_VDPM is triggered in every AC detach when VBUS drops. Ideally we may want to check the battery voltage when PROCHOT_VDPM is triggered. If battery voltage is not too low, we clear the flag and release PROCHOT pin. However, this PROCHOT profile isn't very useful for the case of AC detach, because EC already knows AC detach event from GPIO_AC_PRESENT pin and can check battery voltage then. PROCHOT_VDPM does provide finer-grained monitoring for VBUS, but before we come up with a good use of this profile, we may want to just disable this profile to prevent PROCHOT pin from being asserted in every AC detach. So let's disable PROCHOT_VDPM at charger initialization. BUG=b:123931545 BRANCH=none TEST=boot hatch and then unplug AC, verify bq25710 doesn't assert PROCHOT Change-Id: Icbbbb5572f26a450d0df92890d99fc216564a981 Signed-off-by: Philip Chen <philipchen@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1479872 Reviewed-by: Scott Collyer <scollyer@chromium.org>
* bq25710: Add support for Vbus measurement by ADCPhilip Chen2019-03-012-35/+83
| | | | | | | | | | | | | | | | This CL factors out some existing ADC code to bq25710_adc_start() and then use it to implement charger_get_vbus_voltage(). BUG=b:124968142 BRANCH=none TEST=verify VBUS measurement via 'ectool usbpdpower' Change-Id: Ifd3108d459bef02acd20d6a6959fd586fc3a9ca6 Signed-off-by: Philip Chen <philipchen@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1479876 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Scott Collyer <scollyer@chromium.org>
* flapjack: Enable backlight channel for Flapjackstabilize-11839.Bstabilize-11839.3.BJessy jiang2019-02-271-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | flapjack requires to enable LED Bias to control LCD backlight. For C18 boards, three channels are required, and each channel has a current of 24 mA. For C19 boards, four channels are required, each channel having a current of 23.5mA. BUG=b:124465980 BRANCH=none TEST=1:)When the system boots, the backlight will light up. 2:)Use the ectool commands to check the channel and current. channle: ectool i2cread 8 0 104 0xA0 current: ectool i2cread 8 0 104 0xA5 If it's C18 board, get 0xfa in channel command and 0xc8 in current command. If it's C19 board, get 0xfe in channel command and 0xc4 in current command. If the SKU value of the board is empty or incorrect, the default value is the data of the C18 board. Change-Id: I2e51feec830c4cfd46e3eaec0f9db0e1cfdd620c Reviewed-on: https://chromium-review.googlesource.com/1475094 Commit-Ready: Jessy Jiang <jiangchao5@huaqin.corp-partner.google.com> Tested-by: Jessy Jiang <jiangchao5@huaqin.corp-partner.google.com> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* RT946x: Make mt6370_led_set_color accept composite colorsDaisuke Nojiri2019-02-092-15/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | Currently, mt6370_led_set_color can handle only simple colors. That is, if a green LED is turned on, other LEDs are forced to be off. To allow composite colors (e.g. red+green), this change makes mt6370_led_set_color control LEDs independently. For example, to mix green and red, it can be called as mt6370_led_set_color(LED_MASK_GREEN | LED_MASK_RED); This is consistent with other RT946x LED APIs in the sense that they also control each LED independently. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> BUG=b/123613083 BRANCH=none TEST=Verify LED behavior doesn't change on Kukui by console command Change-Id: Idb80a124462b30adca6af86621aed136be8caa99 Reviewed-on: https://chromium-review.googlesource.com/1452617 Commit-Ready: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* hatch: Add support for charging and USB type CScott Collyer2019-01-291-0/+4
| | | | | | | | | | | | | | | | | This CL adds board specific files and functions required for both battery/charging and Type C support. BRANCH=none BUG=b:122251649 TEST=make buildall, tested both port 0/1 operation at factory. Battery can be charged via both ports. Change-Id: Ia01eabe109e3df780ec053831a71a16a41047f01 Signed-off-by: Scott Collyer <scollyer@google.com> Reviewed-on: https://chromium-review.googlesource.com/1387585 Commit-Ready: Scott Collyer <scollyer@chromium.org> Tested-by: Scott Collyer <scollyer@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* kukui: Fix shipping mode VSYS leakage.Yilun Lin2018-11-192-4/+53
| | | | | | | | | | | | | | | | | | | | Follow the cut-off procedure recommended by Richtek. Also, tcpc_read/tcpc_write function will wake the TCPC up from low power mode and thus causing the TCPC re-init again, and this will break the register state we set. So, here we use mt6370_i2c_read/write to replace tcpc_read/write. TEST=boot system; Exec cutoff, and check that Vsys equals to zero. BUG=b:116682788 BRANCH=None Change-Id: I5cbd0df490ddb64b9376507e42a259c008c3ba16 Signed-off-by: Yilun Lin <yllin@google.com> Reviewed-on: https://chromium-review.googlesource.com/1335289 Commit-Ready: Yilun Lin <yllin@chromium.org> Tested-by: Yilun Lin <yllin@chromium.org> Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>