summaryrefslogtreecommitdiff
path: root/driver
Commit message (Collapse)AuthorAgeFilesLines
* pi3usb9201: Fix typo in structure name.Keith Short2019-07-302-6/+6
| | | | | | | | | | | | | | | | The structure used by board files to define the I2C connections to the PI3USB9201 driver had digits in the part number transposed. BUG=b:138650914 BRANCH=none TEST=make buildall Change-Id: Iaa7897a35f3172dd71fccca4e203b1d0e6a18ef7 Signed-off-by: Keith Short <keithshort@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1725959 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-by: Edward Hill <ecgh@chromium.org> Reviewed-by: Denis Brockus <dbrockus@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>
* driver: Add support for calibration modeGwendal Grignou2019-07-243-3/+8
| | | | | | | | | | | | | | | | | For TCS3400, performing calibration is not just a one-shot event: The RBG sensor stays in calibration mode: returns raw value in R, G, B space. When out of calibration, it returns light information in X, Y and Z space. BUG=b:124512628 BRANCH=hatch,flapjack TEST=unit test Change-Id: I6766907054c8e79a3cbcb629ef91a0967ea0780a Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1702543 Reviewed-by: Nick Vaccaro <nvaccaro@google.com>
* driver: IO expander: nct38xx: add support for NCT38XX series chipsCHLin2019-07-244-0/+240
| | | | | | | | | | | | | | | | | | | Nuvoton TCPC NCT38XX series chips have some pins which can be used as GPIO function. we can treat it as the IO expander chip also. This commit adds the driver to support it. BRANCH=none BUG=none TEST=No error for "make buildall" TEST=Apply this and related CLs, manually test each API, make sure each function works correctly with NCT3807 and NCT3808 at the same time. Change-Id: I2254c2e867445e55d1c261172e4b7175d22f28ef Signed-off-by: CHLin <CHLIN56@nuvoton.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1657859 Commit-Queue: CH Lin <chlin56@nuvoton.com> Tested-by: CH Lin <chlin56@nuvoton.com> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* driver/tcpm: block bad config combinations at compile timeTing Shen2019-07-243-0/+13
| | | | | | | | | | | | | | | | | The unimplemented fields in tcpm_drv may cause ec jumping into some undefined address. Prevent this happen by checking flags at compile time. BUG=None TEST=make buildall -j BRANCH=master Change-Id: I68f47cdc34046e7551f00f72267850b4f0464200 Signed-off-by: Ting Shen <phoenixshen@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1710211 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Commit-Queue: Ting Shen <phoenixshen@chromium.org> Tested-by: Ting Shen <phoenixshen@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-20120-774/+765
| | | | | | | | | | | | | | | | | | | 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>
* drivers/tcpm/ps8xxx: Return hardcoded vendor and product idKarthikeyan Ramasubramanian2019-07-201-0/+5
| | | | | | | | | | | | | | | | | | When the requester does not expect the chip information from the live target, return the hardcoded vendor and product id. BUG=b:128820536,b:119046668 BRANCH=None TEST=Boot to ChromeOS Change-Id: I74affb00951411a3483258a8db165038e7eb683f Signed-off-by: Karthikeyan Ramasubramanian <kramasub@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1617894 Tested-by: Karthikeyan Ramasubramanian <kramasub@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org> Commit-Queue: Karthikeyan Ramasubramanian <kramasub@chromium.org> Auto-Submit: Karthikeyan Ramasubramanian <kramasub@chromium.org>
* ec_commands: Rename 'renew' to 'live' in EC_CMD_USB_PD_CHIP_INFOKarthikeyan Ramasubramanian2019-07-206-13/+13
| | | | | | | | | | | | | | | | | | | | | | Semantics of renew field in EC_CMD_USB_PD_CHIP_INFO is changing as follows: 0 -> Return hard-coded info for Vendor ID/Product ID and cached info for the Firmware Version 1 -> Return the live chip info for Vendor ID/Product ID/Firmware Version Also rename the 'renew' field to 'live' to match the new semantics. BUG=b:128820536,b:119046668 BRANCH=None TEST=make -j buildall; Boot to ChromeOS. Change-Id: Ie3dd022336b0be5c9728bb0ebabef32b7a6b5d57 Signed-off-by: Karthikeyan Ramasubramanian <kramasub@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1617893 Tested-by: Karthikeyan Ramasubramanian <kramasub@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org> Commit-Queue: Karthikeyan Ramasubramanian <kramasub@chromium.org> Auto-Submit: Karthikeyan Ramasubramanian <kramasub@chromium.org>
* Use 7bit I2C/SPI slave addresses in ECDenis Brockus2019-07-19121-884/+1179
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* driver/tcs3400: make error message in sensor read less spammy.Ting Shen2019-07-181-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | In EMULATED_IRQ_EVENT mode, we try to estimate the time between a read request and data ready. If the estimated time is shorter, an error message is printed to the console on every retry. On Kukui, this caused ec console spamming one line per second. Change the behavior to print only when returning error. No need to adjust the estimate time because one retry per read is still good enough. BUG=b:137345336 TEST=manually, verify that error message disappeared. BRANCH=None Change-Id: Ie85e8f1a80ea36ca5c50f57a19eba35f3f79f86d Signed-off-by: Ting Shen <phoenixshen@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1697889 Tested-by: Fei Shao <fshao@chromium.org> Commit-Queue: Ting Shen <phoenixshen@chromium.org> Reviewed-by: Nick Vaccaro <nvaccaro@chromium.org> Reviewed-by: Nick Vaccaro <nvaccaro@google.com> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* common: remove CONFIG_SMBUS dead codeDenis Brockus2019-07-171-20/+0
| | | | | | | | | | | | | | | | | CONFIG_SMBUS is not used. Cleaning up the code by removing this. Added a comment to document the removal and why. This will give a way to find the code if we ever needed to bring it back BUG=chromium:982316 BRANCH=none TEST=make buildall Change-Id: I40703a95bc849538e1aee32f6f96beab811285bd Signed-off-by: Denis Brockus <dbrockus@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1704279 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* cleanup: refactor CPRINTF("[%T ...]\n") to CPRINTSJack Rosenthal2019-07-174-15/+14
| | | | | | | | | | | | | | | | Looking at where the non-standard %T printf modifier is used in EC codebase, the majority is cases where CPRINTS could have been used instead of CPRINTF. This is a somewhat-mechanical refactor of these cases, which will make implementing a standard printf easier. BUG=chromium:984041 BRANCH=none TEST=buildall Change-Id: I75ea0be261bfbfa50fb850a0a37fe2ca6ab67cb9 Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1703128 Reviewed-by: Evan Green <evgreen@chromium.org>
* cleanup: Segregate USB MUX related drivers in usb_mux folderVijay Hiremath2019-07-1710-14/+14
| | | | | | | | | | | BUG=none BRANCH=none TEST=make buildall -j Change-Id: If44a363d1288cbfabe5c6545e550f2b8fc623227 Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1700793 Reviewed-by: Jett Rink <jettrink@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>
* driver: add an option to emulate irq event in TCS3400Ting Shen2019-06-251-6/+30
| | | | | | | | | | | | | | | | | Krane does not reserve an interrupt pin for ALS, so we need another way to trigger the irq handler. Add a new config option CONFIG_ALS_TCS3400_EMULATED_IRQ_EVENT to support this use case. BUG=b:129419982 BRANCH=None TEST=verify that `accelread 3` outputs reasonable data on krane. Change-Id: I960df249d29c0ac21810057e25f14d4bac3e14f5 Signed-off-by: Ting Shen <phoenixshen@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1621449 Reviewed-by: Nick Vaccaro <nvaccaro@google.com> Commit-Queue: Ting Shen <phoenixshen@chromium.org> Tested-by: Ting Shen <phoenixshen@chromium.org>
* driver:lis2mdl: Remove todoYuval Peress2019-06-221-1/+4
| | | | | | | | | | | | | | | | | | | | After some digging around I've found that the issue wasn't in the call to init_mag_cal. Instead it was the fact that we weren't resetting the chip using the LIS2MDL_FLAG_SW_RESET flag every time we reset the calibration. Instead of resetting every time, it actually improves performance to ignore no-op calls here. So the comment can be resolved. BUG=b:130417518 TEST=Added reset flag to set ODR command and remove early bail. Everything works. BRANCH=None Change-Id: Ida4afefc4aad0630bb60a4e25371aa050f0886d0 Signed-off-by: Yuval Peress <peress@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1672207 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Commit-Queue: Jack Rosenthal <jrosenth@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>
* ec: Remove extraneous new line as the end of CPRINTS stringsNicolas Boichat2019-06-203-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | CPRINTS already prints a new line, no need to add another one. Spotted during boot on kukui, and then realized there are many more instances: "" [3.689239 Module 7 is not supported for clock disable ] "" BRANCH=none BUG=none TEST=make buildall -j TEST=`git grep CPRINTS | grep "\\\\n\""` shows nothing of interest. Change-Id: I4d2bbbc65a91fa56c6e6115aa5c353bfd2b384a1 Signed-off-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1660519 Tested-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* LICENSE: remove unnecessary (c) after CopyrightTom Hughes2019-06-1946-46/+46
| | | | | | | | | | | | | | | | 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>
* driver/tcs3400: disable ADC & oscillator between readsNick Vaccaro2019-06-142-14/+11
| | | | | | | | | | | | | | | | | | | | Disabling ADC and oscillator after servicing the interrupt not only saves power, but it assures the next light sample gathered will be based on a single again and atime setting. Without disabling ADC and oscillator, part of the next sample was getting sampled at one again and atime setting, but part of that sample was getting sampled using a different again or atime setting in cases where the saturation compensation mechanism changed again or atime. BUG=b:134188019 BRANCH=master TEST=Flash and boot flapjack, verify that ALS and RGB sensors are still generating data (I used alslog patch and enabled logging in EC console via "alslog" command). Change-Id: Ie599e03e1e5d8a1956a7006cc944a51dd759e8a6 Signed-off-by: Nick Vaccaro <nvaccaro@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1633270
* anx7447: USB Mux is reset when TCPM is resetSam Hurst2019-06-131-8/+14
| | | | | | | | | | | | | | | | | | | | | | | | Calling tcpm_init will reset the Analogix USB Mux on port 0. I'm not sure if this is the proper behavior but I lean towards that it's not because there is a separate function, usb_mux_init, for resetting the usb mux. Also, calling tcpm_init for the Parade does not reset it's mux. BUG=b:134829988 BRANCH=none TEST=manual HATCH (Port 0): The original and new stack was tested as follows: 1) Plug in dock 2) Depending on dock, plug in HDMI or DP 3) Plug TypeC power into dock 4) Verify projection on external monitor isn't lost Change-Id: I88d17479f4d5810be3686cd78545cc99b0c41347 Signed-off-by: Sam Hurst <shurst@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1650728 Tested-by: Sam Hurst <shurst@google.com> Reviewed-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Sam Hurst <shurst@google.com>
* 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>
* TCPC: Make tcpc_config handle other bus typesDaisuke Nojiri2019-06-104-37/+37
| | | | | | | | | | | | | | | | | | | | | Currently, tcpc_config assumes TCPCs are on I2C bus. ITE's EC has an embedded TCPC. This patch adds bus_type field to struct tcpc_config_t so that a TCPC location on other type of bus can be specified. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> BUG=none BRANCH=none TEST=buildall Change-Id: Ieac733011700b351e6323f46070dcf46d9e1154b Reviewed-on: https://chromium-review.googlesource.com/1640305 Commit-Ready: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org> Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org> Reviewed-by: Jett Rink <jettrink@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>
* driver: set Kionix accel min frequency to 12.5HzEnrico Granata2019-06-102-2/+2
| | | | | | | | | | | | | | | | | | | | | | The EC is running at 10Hz itself, so it won't be able to properly handle frequencies below that threshold, and data will end up being sent to the kernel at 10Hz. This is a source of CTS issues on some devices, as Android expects to be able to program the sensor to send data at 1Hz given the sensor's configuration parameters. Fix the issue by picking the closest frequency above 10Hz that the accelerometer supports, i.e. 12.5Hz BUG=b:134422740 BRANCH=oak TEST=run CtsSensorTestCases, observe it pass Change-Id: I56772009817e3cbd452e96637c0a78f54f3854c7 Signed-off-by: Enrico Granata <egranata@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1647363 Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
* usbpd: Fix infinite init loopDaisuke Nojiri2019-06-071-5/+5
| | | | | | | | | | | | | | | | | | | tcpci_tcpm_init can loop forever if tcpc_read or mux_read is successful but TCPC_REG_POWER_STATUS_UNINIT bit is set. This patch fixes it. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> BUG=chromium:971741 BRANCH=none TEST=buildall Change-Id: I5eeb58fc77ee0de753a6c0b049bf332e291faa29 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1647366 Reviewed-by: Scott Collyer <scollyer@chromium.org> Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org>
* common: motion_sense: Spread timestamps in motion sense fifoYuval Peress2019-06-065-66/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This changes moves the specialized logic for timestamp spreading away from the accelgyro_lsm6dsm and into the main motion_sense loop. The motion_sense_fifo_add_data function was replaced by a stage equivalent, and a commit function was added. Similarly, internal static functions for motion_sense.c were renamed to use the stage terminology. The idea is: When a sensor is read, it might provide more than one measurement though the only known timestamp is the one that caused the interrupt. Staging this data allows us to use the same fifo queue space that the entries would consume eventually anyway without making the entries readable. Upon commit, the timestamp entries are spread if needed. Note that if tight timestamps are disabled, the commit becomes a simple tail move. BUG=chromium:966506 BRANCH=None TEST=Ran CTS on arcada. Change-Id: Ib7d0a75c9c56fc4e275aed794058a5eca58ff47f Signed-off-by: Yuval Peress <peress@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1637416 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
* driver: driver/led/oz554 weak reference cleanupDenis Brockus2019-06-032-1/+11
| | | | | | | | | | | | | | | | | | oz554_board_init was prototyped as weak and this made all instances, that included that prototype, weak as well. In order to not lose information from the prototype, default and override functions, I changed to use the override weak marker symbols. BUG=none BRANCH=none TEST=make buildall -j Change-Id: I06fc1324ee05806da8816ca382e77e18196fde68 Signed-off-by: Denis Brockus <dbrockus@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1631582 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-by: Jett Rink <jettrink@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>
* driver/tcpm: Tidy tcpci_tcpm_transmitJacob Garber2019-05-281-10/+8
| | | | | | | | | | | | | | | | | - Remove hardcoded message header size - Check the return value of tcpc_write_block - Merge unnecessary assignment BUG=none BRANCH=none TEST=none Change-Id: Ic4db769f6f9d62ffb4eb10621b15dc414c0bab26 Signed-off-by: Jacob Garber <jgarber1@ualberta.ca> Found-by: Coverity CID 187542 Reviewed-on: https://chromium-review.googlesource.com/1629275 Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* FIXUP: sensor: Adjust max_frequency based on EC performanceGwendal Grignou2019-05-241-1/+1
| | | | | | | | | | | | | | | | | When chaning the macro fro BMA255, the step was set to 125Hz, so it assumes the EC can support MEMS ODR set to 125Hz. This is not the case on poppy and nautilus in the poppy branch. BRANCH=poppy BUG=b:118205424,b:118851581,chromium:615059,b:131705379 TEST=Compile Change-Id: Ib60abb3919dc1ce049211d848fc4e4de2e5e51c0 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1621188 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org> Reviewed-by: Enrico Granata <egranata@chromium.org>
* driver: lis2mdl: fix magnetometer range/resolutionGwendal Grignou2019-05-232-16/+12
| | | | | | | | | | | | | | | | | | | | | | | | | Change drv_data pointer to st_private_data, to make LIS2MDL driver compliant with other ST driver. In standalone mode we have: +--- lis2mdl_private_data ---+ | struct mag_cal_t cal; | <-------- LIS2MDL_CAL(s) | | | | struct stprivate_data data;| <-------- s->drv_data +----------------------------+ BRANCH=None BUG=b:132288982 TEST=Check scale returns 0.000625000 Checks figure-8 calibration is working Checks CTS verifier test "Magnetic Field Measurements Tests" pass. Change-Id: Iaba99b50cb0bf9bfc76f67cef0da8843a86f4838 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1616884 Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Yuval Peress <peress@chromium.org>
* driver: lsm6dsm: sensor event spreadingYuval Peress2019-05-232-12/+139
| | | | | | | | | | | | | | | | | | | | | | | | BUG=b:129159505 BRANCH=None TEST=Ran Android CTS Fixes event out of order errors in CTS. This is fixed by doing the spreading on the ec. A new queue is used (data_queue) and in place of the old call to motion_sense_fifo_add_data we now add the event to the queue and increment the sensor's sample count. At the caller (load_fifo) we then figure out the window (time between the last interrupt and the read) and the period by dividing the window by the number of samples (this is done per sensor). If the period is larger than the odr, then the odr is used (this helps with accuracy). Events are now spread between the known time the first entry was added and the read time. Change-Id: I7094a719c76b4b08a758d053e5dfbdba0a30684b Signed-off-by: Yuval Peress <peress@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1620792 Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
* driver: lsm6dsm: Fix missing eventsYuval Peress2019-05-231-8/+51
| | | | | | | | | | | | | | | | | | | | BUG=b:129159505 BRANCH=None TEST=Ran Android CTS Fixes missing event errors in CTS. This is done by updating the last_fifo_read_ts and checking the interrupt GPIO. If we find that the GPIO is still low at the end of the read, that means that we've gotten new data while reading and never fully empties the FIFO. We know this must have happened some time between the time we read the count and when we were reading the FIFO, for now we'll use the upper bound of this to be safe. Change-Id: I0461f9d2703a3801e57e7769fbfe0e8de750706a Signed-off-by: Yuval Peress <peress@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1620791 Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
* motionsense: Convert in_spoof_mode to a more generic flagsYuval Peress2019-05-232-4/+4
| | | | | | | | | | | | BUG=b:129159505 BRANCH=arcada TEST=I ran `make buildall` since this change isn't used yet it doesn't affect run-time behavior. Change-Id: I01857d679b800f9b53762c659ebd9a018cbf16db Signed-off-by: Yuval Peress <peress@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1612251 Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org>
* pi3usb9281: Mask OVP, OCP, and recovery interruptsDaisuke Nojiri2019-05-231-3/+3
| | | | | | | | | | | | | | | | | | | | Currently, we're handling only attach and detach interrupt and OVP recovery interrupt causes us to miss detach & attach events. This patch masks all unused interrupts. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> BUG=b/125176293 BRANCH=none TEST=See b/125176293 Change-Id: I8387b96abdc073e608b6373b670cbb684b342736 Reviewed-on: https://chromium-review.googlesource.com/1621881 Commit-Ready: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org> Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
* PI3USB9281: Serialize mux setting and BC12 detectionDaisuke Nojiri2019-05-231-7/+5
| | | | | | | | | | | | | | | | | | | | | | | | | Currently a PD task and a USB charger task can talk to PI3USB9281 to update mux setting and to get BC12 information interleavingly. We suspect this causes unreliable BC12 detection including detach detection. This patch makes the usb_charger_set_switches API schedule a mux update instead of changing the mux setting by itself wakes up a USB charger task. A USB charger task solely handles BC12 detection and mux setting. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> BUG=b/125176293 BRANCH=nami TEST=Verify BC1.2 and PD charger can be detected correctly and power_supply_info prints 'Discharging' when they're disconnected on Syndra. Change-Id: Iadaf9087be74a4ba0412dd08b95a40eac4e69ce1 Reviewed-on: https://chromium-review.googlesource.com/1622293 Commit-Ready: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org> Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org> Reviewed-by: Jett Rink <jettrink@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>
* FIXUP: driver: Add L3GD20H gyrometer basic driver supportGwendal Grignou2019-05-211-5/+0
| | | | | | | | | | | | | | | | set_data_rate() was called with wrong argument and is not necessary. set_range is called by motion_sensor_init. BUG=none TEST=compile BRANCH=none Change-Id: Ia21911a0d6361e819a8bf381918740f189496c59 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1620692 Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org> Reviewed-by: Enrico Granata <egranata@chromium.org> Reviewed-by: Yuval Peress <peress@chromium.org>
* USB-PD: Consolidate tcpc_config declarations in usb_pd_tcpm.hDaisuke Nojiri2019-05-211-5/+0
| | | | | | | | | | | | | | | | | | Currently, tcpc_config is declared in two places. This patch consolidates declarations in usb_pd_tcpm.h. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> BUG=none BRANCH=none TEST=buildall Change-Id: I4f30d06b1eaeb6a83b664de76116d85d65a9fc97 Reviewed-on: https://chromium-review.googlesource.com/1616007 Commit-Ready: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org> Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org> Reviewed-by: Jett Rink <jettrink@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>
* tcpci/usb_pd_fuzz: Avoid using unitialized data in payloadNicolas Boichat2019-05-161-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | Found with MSAN fuzzer: usb_pd_protocol.c may use payload data that is not initialized. Fix the test by copying over the whole payload, which is what tcpci.c's version does. Also, in tcpci.c, clear cached_messages head before using get_message_raw to fill it up, to make sure that we do not accidentally use older data in the queue. BRANCH=none BUG=chromium:963076 TEST=make TEST_MSAN=y host-usb_pd_fuzz -j MSAN_OPTIONS=log_path=stderr:exitcode=0 \ build/host/usb_pd_fuzz/usb_pd_fuzz.exe \ clusterfuzz-testcase-minimized-ec_usb_pd_fuzzer-5716775969357824 Change-Id: I74c38538440cb5a01d1714657b9e2d63e5b80cea Signed-off-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1610163 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Aaron Durbin <adurbin@chromium.org>
* FIXUP: driver: lis2mdl: add standalone supportGwendal Grignou2019-05-161-2/+2
| | | | | | | | | | | | | | Fix constant used when LIS2MDL is behind LSM6DSM. BUG=b:128619310,b:124085261 BRANCH=none TEST=meep board compile. Change-Id: I35ec3659dfedceedfa52400c37972fcf387f6375 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1610315 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Reviewed-by: Yuval Peress <peress@chromium.org>