summaryrefslogtreecommitdiff
path: root/driver
Commit message (Collapse)AuthorAgeFilesLines
* driver/led/lm3630a: Configure 261ms startup ramp timeNicolas Boichat2018-09-192-0/+17
| | | | | | | | | | | | | | | | | | | | | | It appears that, on startup, LM3630A starts by assuming some high input PWM value, so when the brightness is set to 0xff, it first drives the output, and slowly dims it as the PWM input LPF takes effect (takes about 50ms). We workaround this issue by adding a 261ms start-up ramp, to prevent LM3630A from driving backlight right after the brightness value is set. AFAICT, this has no effect on the user, even when transitioning from off to on backlight, as the ramp only applies when the brightness is first set. BRANCH=nocturne BUG=b:111010124 TEST=Connect whiskers, no backlight blip Change-Id: Ia4dafe9a54aa40a4eae865581a06670e94eb6364 Signed-off-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1230973 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* touchpad_st: handle error type 0xffWei-Han Chen2018-09-191-0/+22
| | | | | | | | | | | | | | | | | | | When ST touchpad is down, or the SPI interface is not working properly (either hardware or software issue), we might receive events filled with 0xff. In this case, try if resetting touchpad can bring it back. To prevent infinite reboot, if the touchpad is not recovered after 3 reboots, stop it. BRANCH=nocturne BUG=None TEST=manual on device Signed-off-by: Wei-Han Chen <stimim@chromium.org> Change-Id: I8d2a8f0f4aa305af11f14a63f0bc4d53c2c23a49 Reviewed-on: https://chromium-review.googlesource.com/1230393 Commit-Ready: Wei-Han Chen <stimim@chromium.org> Tested-by: Wei-Han Chen <stimim@chromium.org> Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
* isl923x: initially disable autonomous chargingJett Rink2018-09-172-0/+14
| | | | | | | | | | | | | | | | | | | We do not use autonomous charging since it is automatically disabled when ever we set the current limits manually (which we always do). Allowing autonomous charging for the short period during initialization can cause current over protection events on devices with 2S batteries. BRANCH=none BUG=b:114318779 TEST=meep can boot without battery from daughter board USB-C port without boot looping Change-Id: Id50517d7e34bb5be171fe8b781b3ccf835db1f88 Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1227411 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Reviewed-by: Justin TerAvest <teravest@chromium.org>
* pd: Don't auto toggle when DRP state is not dual role.Edward Hill2018-09-171-38/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When in PD_STATE_DRP_AUTO_TOGGLE, we were always enabling DRP auto-toggle, even when drp_state is PD_DRP_TOGGLE_OFF or PD_DRP_FORCE_SINK, which prevents us from acting as source. This caused an infinite loop of entering and exiting low power mode when a sink-only device was plugged into a PS8751 port when the system is in S5/G3. To fix this, only enable DRP auto-toggle when drp_state allows us to be dual-role. One problem with doing this is that the ANX3429 doesn't support low power mode with auto-toggle disabled. Luckily, the ANX3429 will stay in low power mode when a sink-only device is connected. BRANCH=none BUG=b:72007056,b:111663127 TEST=sink device + ANX3429: low power mode [1] TEST=sink device + PS8751: low power mode [1] TEST=charger via hub + ANX3429: 50% chance fail to charge [2] TEST=charger via hub + PS8751: starts charging (all tests with Grunt in G3) [1] dut-control pp3300_tcpc_mw -> 3.5 [2] b/72007056 still remains to be fixed. Change-Id: Id190a3daa78847871288e66d8f229a485a6522e3 Signed-off-by: Edward Hill <ecgh@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1194352 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Reviewed-by: Jett Rink <jettrink@chromium.org>
* pd: Change tcpm_set_drp_toggle() to tcpm_enable_drp_toggle()Edward Hill2018-09-174-15/+7
| | | | | | | | | | | | | | | Change tcpm_set_drp_toggle() to tcpm_enable_drp_toggle(), since enable=0 was unused. BRANCH=none BUG=b:111663127 TEST=PD and TCPC low power still work on Grunt Change-Id: I760a067b11984a579261deac856419d46400497b Signed-off-by: Edward Hill <ecgh@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1194353 Reviewed-by: Scott Collyer <scollyer@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
* pd: Add PD_FLAGS_LPM_TRANSITIONEdward Hill2018-09-171-4/+1
| | | | | | | | | | | | | | | Add PD_FLAGS_LPM_TRANSITION and use this to allow the PD task to call tcpc_read/tcpc_write from tcpm_enter_low_power_mode() and tcpm_init(). BRANCH=none BUG=b:111663127 TEST=PD and TCPC low power still work on Grunt Change-Id: I12ddb58667c171068e1be6d136f22f2062959c8c Signed-off-by: Edward Hill <ecgh@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1194351 Reviewed-by: Scott Collyer <scollyer@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
* touchpad_st: "dump_memory" can be enabled via console commandWei-Han Chen2018-09-161-4/+14
| | | | | | | | | | | | | | | | | | | | | Previously, dump_memory can only be enabled at compile time (through local build). Make this runtime configurable. Currently, it is default off, since dump_memory is very slow and might not be useful to enable for all users. The dump log through USB interface doesn't look good for now. We revisit the default value in the future. BRANCH=nocturne BUG=b:112877237 TEST=manual on whiskers Signed-off-by: Wei-Han Chen <stimim@chromium.org> Change-Id: I422a5a23392298301995df4fbf8101b7a18a62ba Reviewed-on: https://chromium-review.googlesource.com/1212665 Commit-Ready: Wei-Han Chen <stimim@chromium.org> Tested-by: Wei-Han Chen <stimim@chromium.org> Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
* touchpad_st: handle severe errorsWei-Han Chen2018-09-161-17/+165
| | | | | | | | | | | | | | | | | For errors that are noted as "FW shall halt" in spec, we should reset the touchpad, so it won't keep generating the same error and cause EC watchdog reboot the entire system. BRANCH=nocturne BUG=b:112877237 TEST=tested on whiskers Signed-off-by: Wei-Han Chen <stimim@chromium.org> Change-Id: Ie3c0a9930628caf1e55a243bd017f233756152a6 Reviewed-on: https://chromium-review.googlesource.com/1203351 Commit-Ready: Wei-Han Chen <stimim@chromium.org> Tested-by: Wei-Han Chen <stimim@chromium.org> Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
* ppc: Increase deglitch time on SN5S330Jonathan Brandmeyer2018-09-142-0/+28
| | | | | | | | | | | | | | | | | | | The default deglitch time is short enough to trip the current limit with some commercially available USB-C -> HDMI adapters. Increase the deglitch timeout to improve compatibility with those adapters. BUG=b:113777138, b:113365815 BRANCH=none TEST=Insert 7 different USB-C to HDMI adapters, including both single-function and multifunction devices, and observe that a Careena clamshell will extend the screen to include the attached monitor on both USB-C ports 0 and 1. Brands tested include SIIG, StarTech, Amazon basics, iogear, Apple, and an unlabeled device. Change-Id: I403e4a65e90c85bdaa8078230751d611d04c9c67 Signed-off-by: Jonathan Brandmeyer <jbrandmeyer@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1225354 Reviewed-by: Jett Rink <jettrink@chromium.org>
* temp_sensor: Add (basic) support for TI TMP468 Temperature SensorMoritz Fischer2018-09-133-1/+227
| | | | | | | | | | | | | | | Add (basic) support for TI TMP468 a 8 Remote + 1 Local channel temperature sensor. BUG=none BRANCH=master TEST=Hook up EVM to I2C port of a STM32F072, read temperatures Change-Id: I6d6644825af04391841847c060f8ffaeff620094 Signed-off-by: Moritz Fischer <moritz.fischer@ettus.com> Reviewed-on: https://chromium-review.googlesource.com/1213554 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* ppc: Add support for nx20p3481Scott Collyer2018-09-133-14/+120
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This CL is an incremental change to the nx20p348x driver to add support for the nx20p3481 ppc. Sink/source modes are controlled via the switch control register instead of gpio signals. Another difference is that the values of mode in register 0x1 are slightly different between the 3481 and 3483. The 3481 needs to use the switch status register to verify whether it's in sink or source mode. This register is now checked for both the 3483 and 3481. A delay is required for the switch status register to reflect the control setting just applied. In addition, the nx20p3481 supports Fast Role Swap (FRS). For FRS, only the detection is supported, and it's assumed that it's caused by the removal of an external charger, not an actual FRS event. BUG=b:111281797 BRANCH=none TEST=Verified on DragonEgg that port acts correctly as a sink. Have not been able to verify source operation. Change-Id: I2fb4200a5d9c3ce460e9b913a5b09441e458bb7e Signed-off-by: Scott Collyer <scollyer@google.com> Reviewed-on: https://chromium-review.googlesource.com/1178995 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: Scott Collyer <scollyer@chromium.org> Reviewed-by: Furquan Shaikh <furquan@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
* type: Rename vector_3_t to intv3_t.Yilun Lin2018-09-1316-28/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Naming of many vector types and matrix types are not clear enough. For example, we have: vector_3_t, which is a vector of three int. vec3_t, which is a vector of three float. size4_t, which is a vector of four size_t. mat33_t, which is a 3x3 matrix of float. matrix_3x3_t, which is a 3x3 matrix of fixed point. Besides, we have types like int8_t, uint16_t types. To clearly distinguished types, the CL propose to, For vector types, naming should be `$type + 'v' + $num + '_t'`: vector_3_t becomes intv3_t vec3_t becomes floatv3_t vector 4 of uint16_t becomes uint16v4_t (which doesn't exist yet) For matrix types, naming should be `mat$N$N_` + $type + '_t', where $N is the matrix size: matrix_3x3_t becomes mat33_fp_t # fp: fixed point mat33_t becomes mat33_float_t TEST=make buildall -j BUG=b:114662791 Change-Id: I865aa3ecbab6cb97f8585a081a679adf00febe1d Signed-off-by: Yilun Lin <yllin@google.com> Reviewed-on: https://chromium-review.googlesource.com/1215442 Commit-Ready: Yilun Lin <yllin@chromium.org> Tested-by: Yilun Lin <yllin@chromium.org> Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
* tcpc: Add driver for TI TUSB422 tcpcScott Collyer2018-09-073-0/+83
| | | | | | | | | | | | | | | | | | | Initial driver for TUSB422 TCPC which is a tcpci compliant TCPC. This TCPC does not inlude a Type C mux and uses the tcpci driver for all of the methods. BUG=b:111281797 BRANCH=none TEST=Verified operation as sink on DragonEgg. Have not verified source operation, or low power/auto-toggle modes as those config options can't be enabled on ITE at this point. Change-Id: I783a5e2c4a13bc0b8fa4da4b134588382542024c Signed-off-by: Scott Collyer <scollyer@google.com> Reviewed-on: https://chromium-review.googlesource.com/1178994 Commit-Ready: Jett Rink <jettrink@chromium.org> Tested-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
* tcpm: add TCPC RX circular buffer in ECJett Rink2018-09-0711-96/+234
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The alert line for TCPC will stay asserted as long as there are RX messages for the TCPM (i.e. EC) to pull from the TCPC. We should clear all of the RX messages we know about during a single alert handling session. This CL can stand on its own, but it is a part of a CL stack that will tighten the critical section of time between received messages from the TCPC and sending follow up message out through the TCPC. See go/usb-pd-slow-response-time for more details. BRANCH=none BUG=b:112088135,b:112344286,b:111909282,b:112848644,b:113124761 BUG=b:113057273,b:112825261 TEST=Reduces reset issue in most cases for phaser, bobba. Does not seem to adversely affect state machine negotiation. Full CL stack consistently sends a REQUEST at 18ms after a SRC_CAP GoodCRC, which is well below the 24 ms threshold we need to be under for USB PD spec compliance. Also testing pd_suspend scenario manually and EC was responsive after port 1 suspend because of "bad behavior" Change-Id: I1654b46400e9881f2927a5f6d6ace589edd182de Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1185727
* tcpm:it83xx: GRL-USB-PD TDA2.1.2.2 BIST testRuibin Chang2018-09-071-0/+10
| | | | | | | | | | | | | | | | | | | | In our design once enter BIST test data mode, Hw don't interrupt Fw due to any Rx received packet. But when port partner re-connect in this mode, it will cause that our pd port doesn't respond packet which port partner transmits. When port partner disconnects, so we need to reset our pd port protocol layer and PHY to leave BIST test data mode and let Hw can interrupt Fw. With this modify it can pass GRL-USB-PD compliance TDA2.1.2.2 test item. BUG=b:112602596 BRANCH=none TEST=GRL-USB-PD compliance test. Change-Id: I30526b5d796e3eabc9af2f524071c98bb0ef5abf Signed-off-by: Ruibin Chang <Ruibin.Chang@ite.com.tw> Reviewed-on: https://chromium-review.googlesource.com/1170718 Reviewed-by: Jett Rink <jettrink@chromium.org>
* Liara: Add supported batteriesJonathan Brandmeyer2018-09-051-2/+2
| | | | | | | | | | | | | | These are two of the three batteries for Liara. Retain the Grunt reference design battery for testing purposes only. BUG=b:113823864 TEST=buildall BRANCH=none Change-Id: Ibfdfa08298ec142504b24477746ebb87aebc913c Signed-off-by: Jonathan Brandmeyer <jbrandmeyer@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1204696 Reviewed-by: Jett Rink <jettrink@chromium.org>
* ss-mux: update semantics for TCPC/MUX only used as MUXJett Rink2018-09-059-142/+113
| | | | | | | | | | | | | | | | | | | | | | | | This converts the compile time option of CONFIG_USB_PD_TCPM_TCPCI_MUX_ONLY into a runtime option to better support draggon egg designs and reduce CONFIG complexity in general. Introduce new mux_read/write to read from tcpc_config_t or mux driver depending on new flag setting. Audited all mux drivers for any use of tcpc_read/write and updated to mux_read/write. BRANCH=none BUG=b:110937880 TEST=On Bip with CL stack: Verified by connecting DP monitor at boot; Verified plug / unplug of DP cable works; Change-Id: I968893b886ff0ccc4074beae5ec42973814ae77c Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1200062 Commit-Ready: Gaggery Tsai <gaggery.tsai@intel.corp-partner.google.com> Reviewed-by: Scott Collyer <scollyer@chromium.org>
* driver: accel: Prevent ODR from crashing the ECGwendal Grignou2018-09-053-32/+21
| | | | | | | | | | | | | | | | | | For accelerometers which are interrupt driven, setting ODR too high may exhaust the EC and trigger the watchdog timer. Use config variable to verify the ODR requested is not too big. Return an error when setting unsupported parameters. BUG=b:112672627 BRANCH=nocturne,eve TEST=Without this change, ectool motionsense odr 0 500000 crashes the EC Now, it returns EC result 3 (INVALID_PARAM) Change-Id: I64a4e522dcad450d619a7fc48a1330479f1cf81f Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1200068 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* driver: lsm6dsm: Allow roundup to work below 13HzGwendal Grignou2018-09-051-1/+1
| | | | | | | | | | | | | Recalculate ODR properly after rounding up the requested rate. BUG=b:112179405 TEST=Check ODR is set properly BRANCH=none Change-Id: I3f5abd5a1720f21d666cd3029000c2cec257c6f1 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1200067 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* ppc: Add driver for Silergy SYV682x PPCScott Collyer2018-09-043-0/+395
| | | | | | | | | | | | | | | | | | | Initial version of driver for Silergy SYV682x PPC. This version of the driver does not support the Alert line from the SYV682x. Alert will need to be support for FRS and to detect OVP or OC cases that cause the power path to be disabled. BUG=b:111281797 BRANCH=none TEST=Tested on DragonEgg and verified that can attach as both sink or source port. Change-Id: Ia0450db666b50f90d6e074024bd9b89ea7d50ed6 Signed-off-by: Scott Collyer <scollyer@google.com> Reviewed-on: https://chromium-review.googlesource.com/1159828 Commit-Ready: Scott Collyer <scollyer@chromium.org> Tested-by: Scott Collyer <scollyer@chromium.org> Reviewed-by: Furquan Shaikh <furquan@chromium.org>
* driver/touchpad_st: add more debug commandsWei-Han Chen2018-09-032-1/+49
| | | | | | | | | | | | | | | | | | | | | | The following new commands are added to help debugging touchpad issues. +ST_TP_DEBUG_CMD_RESET_TOUCHPAD 0x00 ST_TP_DEBUG_CMD_CALIBRATE 0x01 +ST_TP_DEBUG_CMD_START_SCAN 0x02 +ST_TP_DEBUG_CMD_STOP_SCAN 0x03 +ST_TP_DEBUG_CMD_READ_BUF_HEADER 0x04 +ST_TP_DEBUG_CMD_READ_EVENTS 0x05 BRANCH=none BUG=b:70482333 TEST=manual on whiskers Signed-off-by: Wei-Han Chen <stimim@chromium.org> Change-Id: Id9a604560afda9304329d5ca7c21160df225bf15 Reviewed-on: https://chromium-review.googlesource.com/1184135 Commit-Ready: Nicolas Boichat <drinkcat@chromium.org> Tested-by: Wei-Han Chen <stimim@chromium.org> Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
* whiskers: Disable keyboard scanning and touchpad in tablet modeNicolas Boichat2018-09-032-30/+88
| | | | | | | | | | | | | | | | | | | | When in tablet mode, disable keyboard scanning and touchpad. Refactor touchpad_*.c power management to take both into account (there is some duplicated code here, that we may want to merge in the future). This will also prevent magic keyboard from working, but we are ok with this, at least for now. BRANCH=none BUG=b:73133611 TEST=In tablet mode, keyboard scanning and touchpad are both disabled. Change-Id: I51b7c50b90cca9b9f574c5c611daa89fe8a480bb Signed-off-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1180639 Tested-by: Wei-Han Chen <stimim@chromium.org> Reviewed-by: Wei-Han Chen <stimim@chromium.org>
* cleanup: remove tcpc* extern function declarationsJett Rink2018-08-311-16/+1
| | | | | | | | | | | | | | We do not want to use extern when possible, so move the function declaration section in the tcpm stub c files to an appropriate header file. BRANCH=none BUG=none TEST=zinger compiler (along with everything else) Change-Id: If867661840d138e0c912669e401469a152fa3d9b Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1194083 Reviewed-by: Jonathan Brandmeyer <jbrandmeyer@chromium.org>
* touchpad_st: disable heatmap should always successWei-Han Chen2018-08-311-7/+8
| | | | | | | | | | | | | | | | | | We should only fail if host is trying to enable heatmap via `Set_Interface` command. Setting altsetting to 0 (disable heatmap) should always success. BRANCH=none BUG=b:113141452 TEST=tested on whiskers Signed-off-by: Wei-Han Chen <stimim@chromium.org> Change-Id: I540ce7af46bd2bf84dccb0d21bf0ad89ade3c9e9 Reviewed-on: https://chromium-review.googlesource.com/1198943 Commit-Ready: Wei-Han Chen <stimim@chromium.org> Tested-by: Wei-Han Chen <stimim@chromium.org> Reviewed-by: Wei-Han Chen <stimim@chromium.org> Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
* touchpad heatmap: set subclass and protocolWei-Han Chen2018-08-311-2/+2
| | | | | | | | | | | | | | BRANCH=none TEST=make buildall -j TEST=test on whiskers BUG=b:70482333 Signed-off-by: Wei-Han Chen <stimim@chromium.org> Change-Id: Ieadb743b428997ca1e7c9d45837f503d3023f779 Reviewed-on: https://chromium-review.googlesource.com/1198942 Commit-Ready: Wei-Han Chen <stimim@chromium.org> Tested-by: Wei-Han Chen <stimim@chromium.org> Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
* stm32: usb_hid_touchpad: add confidenceWei-Han Chen2018-08-312-1/+4
| | | | | | | | | | | | | | | | `confidence` is expected from a PTP-compliant touchpad BRANCH=none BUG=b:70482333 TEST=manual Signed-off-by: Wei-Han Chen <stimim@chromium.org> Change-Id: Ibe7166f43cae5fb36bbcc4e6dfd9ae6525a7225e Reviewed-on: https://chromium-review.googlesource.com/1188170 Commit-Ready: Wei-Han Chen <stimim@chromium.org> Tested-by: Wei-Han Chen <stimim@chromium.org> Reviewed-by: Wei-Han Chen <stimim@chromium.org> Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
* anx74xx: consolidating anx74xx alert handlerJett Rink2018-08-301-90/+42
| | | | | | | | | | | | | | | | | There is a unneeded level on indirection for the anx74xx alert handler that we can remove. This also make is more clear what is happening in the child CLs. See go/usb-pd-slow-response-time for more information. BRANCH=none BUG=none TEST=no change on grunt device Change-Id: I61f7caf09fc5cb5fa889fb727ee39bea681a97e9 Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1185726 Reviewed-by: Jonathan Brandmeyer <jbrandmeyer@chromium.org>
* charger/mt6370: Fix wrong init IRQ mask.Yilun Lin2018-08-291-1/+1
| | | | | | | | | | | | | | | | DPDM_IRQ_MASK register address should be at 0xE6, rather than 0xE5. Shift the mask init value to the right address. TEST=make BOARD=kukui flash_ec; Attach DCP. Check chgsup type=3. BUG=b:80160408 BRANCH=None Change-Id: I44eac570bf2d8fe11a3f460ed97f024f4be3813a Signed-off-by: Yilun Lin <yllin@google.com> Reviewed-on: https://chromium-review.googlesource.com/1192862 Commit-Ready: Yilun Lin <yllin@chromium.org> Tested-by: Yilun Lin <yllin@chromium.org> Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
* bd99992: add some more register definitionsCaveh Jalali2018-08-241-0/+6
| | | | | | | | | | | | | | | | | this adds definitions for some additional PMIC registers we're using in our codebase. BUG=b:112732855 BRANCH=none TEST=flashed atlas with new EC build Change-Id: Ibad7b11b3770f00c925c2d8fc3b24109147aa643 Signed-off-by: Caveh Jalali <caveh@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1187899 Commit-Ready: caveh jalali <caveh@chromium.org> Tested-by: caveh jalali <caveh@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: caveh jalali <caveh@chromium.org>
* cheza: Configure ANX3429 interrupt as open-drainWai-Hong Tam2018-08-232-0/+9
| | | | | | | | | | | | | | | | | This interrupt pin by default is a push-pull. It causes leak to EC VSPI power during EC watchdog reset. As in our design, we use this interrupt pin as open-drain. Should configure the register to make it open-drain. BRANCH=none BUG=b:112906111 TEST=Flashed the EC image to Cheza rev-2 board. Typed "reboot" command and then EC reset properly. Change-Id: Iee5db3cb5b5291778d97dee4fc70369d34344ce7 Signed-off-by: Wai-Hong Tam <waihong@google.com> Reviewed-on: https://chromium-review.googlesource.com/1185871 Reviewed-by: Alexandru M Stan <amstan@chromium.org> Reviewed-by: Stephen Boyd <swboyd@chromium.org>
* sn5s330: add low power modeJett Rink2018-08-232-22/+74
| | | | | | | | | | | | | | | | Add a low power mode method for PPCs behind a new config. Implement the low power method for SN5S330 based off of TI AE recommendation. BRANCH=none BUG=b:111520593,b:111006203 TEST=CL stack produce lower power during bip hibernate Change-Id: Icd22f88a8f65c2cd5ab1c95b0750b1eb61e91923 Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1166183 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Reviewed-by: Furquan Shaikh <furquan@chromium.org>
* tcpc/mt6370: Fix state debouncing when enable auto-toggling w/o battery.Yilun Lin2018-08-232-11/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | mt6370 updates CC pin information to different registers according to whether it is DRP toggling or not. When DRP toggling: CC information will update to CC_STATUS 0x1D When DRP not toggling: CC information will update to ROLE_CTRL 0x1D However, there is a situation that when we are enabling CONFIG_USB_PD_DUAL_ROLE_AUTO_TOGGLE: When we detach the battery, and plug type-c port to boot EC, the type-c port is already connected, before auto-toggling is on. mt6370 here updates CC information to ROLE_CTRL 0x1D, rather than CC_STATUS. So here, we should determine where to retrieve the CC information dynamically. BRANCH=None BUG=b:112113303 TEST=w/ battery: check state transition behaves correctly when sourcing and sinking. TEST=w/o battery: check state transition behaves correctly when sinking. Change-Id: Icf9e39f68aedb43a8fceba5d31795126a433d547 Signed-off-by: Yilun Lin <yllin@google.com> Reviewed-on: https://chromium-review.googlesource.com/1177465 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: Yilun Lin <yllin@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
* tcpm:it83xx: GRL-USB-PD TDA2.1.2.1 BMC testRuibin Chang2018-08-231-0/+22
| | | | | | | | | | | | | | | | | | According to BMC signaling scheme of PD3.0 spec, we should set different Rx threshold in SRC and SNK role for well performance of receiving data. So we add these settings and can pass GRL-USB-PD compliance TDA2.1.2.1 test item. BUG=none BRANCH=none TEST=GRL-USB-PD compliance test. Change-Id: Ie4fccaa362a83462e57237ed4f0cbe5683da2fea Signed-off-by: Ruibin Chang <Ruibin.Chang@ite.com.tw> Reviewed-on: https://chromium-review.googlesource.com/1170721 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Reviewed-by: Jett Rink <jettrink@chromium.org>
* bmi160: End IRQ handler if sensor isn't powered.Aseda Aboagye2018-08-221-1/+6
| | | | | | | | | | | | | | | | | | | It's possible for the interrupt to be triggered and then when the bottom half of the interrupt handler gets a chance to run, the sensor isn't powered anymore. This commit simply has the loop terminate early if the board indicates that the bus the sensor is on is no longer powered. BUG=b:111683988 BRANCH=nocturne TEST=Verify if IRQ handler is called when sensor is not powered, the irq_handler loop terminates. Change-Id: Iaf395902bb4b46a5b6d750c99767c4c36b1e7a99 Signed-off-by: Aseda Aboagye <aaboagye@google.com> Reviewed-on: https://chromium-review.googlesource.com/1182879 Commit-Ready: Aseda Aboagye <aaboagye@chromium.org> Tested-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Alexandru M Stan <amstan@chromium.org>
* touchpad_elan: Fix the trace number accessing for width/hight propertyKT Liao2018-08-211-2/+2
| | | | | | | | | | | | | | | | | | | Base on Elan I2C driver and Elan touchpad spec, the x trace number of touching object is in the low nibble of byte. And y trace number is in the high nibble. This is a minor bug and difficult to find in operation. I fix the byte accessing to make it right in palm detection Signed-off-by: KT Liao <kt.liao@emc.com.tw> BRANCH=poppy BUG=None TEST=Test hammer in EVTEST and check MAJOR/MINOR Change-Id: I83e5e1f224eaf815914e7001234cdc1b1af22660 Reviewed-on: https://chromium-review.googlesource.com/659478 Commit-Ready: Nicolas Boichat <drinkcat@chromium.org> Tested-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
* touchpad_st: handle new domeswitch APIWei-Han Chen2018-08-192-16/+10
| | | | | | | | | | | | | | | | In latest ST firmware, domeswitch level is already reported, there is no domeswitch_chg anymore. BRANCH=none BUG=b:70482333 TEST=manual on device Signed-off-by: Wei-Han Chen <stimim@chromium.org> Change-Id: I6ce21f48ec8aa62a4167a86581acd2e2abee7ce6 Reviewed-on: https://chromium-review.googlesource.com/1177524 Commit-Ready: Wei-Han Chen <stimim@chromium.org> Tested-by: Wei-Han Chen <stimim@chromium.org> Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
* touchpad_st: fix heatmap modeWei-Han Chen2018-08-181-2/+6
| | | | | | | | | | | | | | | | The rx_buf was set incorrectly in heat map mode. Also add debug messages to help debugging. BRANCH=none BUG=b:70482333 TEST=test on full system, enable heatmap Signed-off-by: Wei-Han Chen <stimim@chromium.org> Change-Id: I325a9b7983a16634b95eecdc592c59222e48c7aa Reviewed-on: https://chromium-review.googlesource.com/1177093 Commit-Ready: Wei-Han Chen <stimim@chromium.org> Tested-by: Wei-Han Chen <stimim@chromium.org> Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
* i2c: Split i2c_xfer into locked/unlocked versions.Jonathan Brandmeyer2018-08-164-37/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Rename i2c_xfer to i2c_xfer_unlocked. Audit all users of i2c_xfer to see if they can use simple locking semantics or require their own locking. Since locked accesses are only safe for I2C_XFER_SINGLE transactions, remove the flags parameter from i2c_xfer. This also makes the audit a bit easier. Some remaining applications hold the bus locked across several transactions that would otherwise be atomic, and a few others implement complex I2C transactions in multiple commands. Add a (nondeterministic) verification on the I2C port locking correctness. This will catch all statically incorrect locking patterns, although dynamically incorrect locking patterns may not be caught. Related: Revise the i2c_port_active_count to be a bitmap of the active ports instead of a count of the active ports. The EC's mutex does not provide an is_locked() primitive, and we would prefer not to have one. - board/glados: Custom locking for battery reset - board/mchpevb1: Custom locking for battery reset - board/oak: Custom locking for battery reset - board/samus: Custom locking for lightbar reset - board/sweetberry: simple locking - board/servo_micro: Custom locking for funky i2c transfers - capsense: simple locking - host_command_master: multi-command transactions - lb_common: manual locking to support samus power sequence - smbus: multi-command transactions - usb_i2c: simple locking - driver/tcpm/fusb302: simple locking and multi-command transactions - driver/tcpm/tcpi: Forward _unlocked and implicitly locked interface to fusb302 - driver/touchpad_elan: simple locking BUG=chromium:871851 BRANCH=none TEST=buildall; very careful audit TEST=grunt clamshell and Coral clamshell, test boot, battery charging, PD communication, and TCPC port low-power mode. Signed-off-by: Jonathan Brandmeyer <jbrandmeyer@chromium.org> Change-Id: Ieabf22bcab42780bdb994fca3ced5d8c62519d56 Reviewed-on: https://chromium-review.googlesource.com/1169913 Commit-Ready: Jonathan Brandmeyer <jbrandmeyer@chromium.org> Tested-by: Jonathan Brandmeyer <jbrandmeyer@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
* ppc: nx20p3483: Rename driver to nx20p348x to support NX20P3481Scott Collyer2018-08-164-194/+194
| | | | | | | | | | | | | | | | | | | | | | This CL doesn't change any functionality, but renames the driver from 3483 to 348x. The motivation for this is that we need to support the NX20P3481 PPC as well. Those chips use the same registers, but the 3481 adds FRS support and sink/source control is done via I2C writes instead of gpio controls. Because the chips are slighlty different the config option CONFIG_USBC_PPC_NX20P3483 needs to remain. BUG=b:111281797 BRANCH=none TEST=make -j buildall Change-Id: Ie1085140eb2ef23c0b6e1a79a6f2d7f823326c6d Signed-off-by: Scott Collyer <scollyer@google.com> Reviewed-on: https://chromium-review.googlesource.com/1176382 Commit-Ready: Scott Collyer <scollyer@chromium.org> Tested-by: Scott Collyer <scollyer@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
* it5205: put ite5202 mux into low power modeJett Rink2018-08-151-3/+18
| | | | | | | | | | | | | | | | When the SS MUX is fully disconnected, put the mux into a low power state. BRANCH=none BUG=b:111006203,b:111520593 TEST=BIP PD_A rail went from 3.97mW down to 2.65 mW during hibernate with the other corresponding PPC changes in CL:1166184 Change-Id: Ief636b569fe01db7f129ca2d457352c3799c14f9 Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1169698 Reviewed-by: Scott Collyer <scollyer@chromium.org> Reviewed-by: Furquan Shaikh <furquan@chromium.org>
* ps8751: add low power mode for PS8751 when only MUXJett Rink2018-08-151-19/+75
| | | | | | | | | | | | | Enter lower power mode for PS8751 when acting as mux only. BRANCH=none BUG=b:111664205,b:111876407,b:10937880 TEST=PS8751 as MUX on C1 Bip goes into low power mode after disconnect. Change-Id: Ifac3b76556069e1e5f6acae550d8076c29d5f1cd Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1153835 Reviewed-by: Furquan Shaikh <furquan@chromium.org>
* ss-mux: move enter_low_power_mode method to drvJett Rink2018-08-151-2/+2
| | | | | | | | | | | | | | | | | After implementing this new method twice, I realized that the enter_low_power_mode method did not need to be configured at the board level so it can move to the more common mux driver. BRANCH=none BUG=none TEST=bip low power mux operation still works Change-Id: I33d7191ae22da089972929eb60b3bae568a2c447 Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1169904 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Scott Collyer <scollyer@chromium.org> Reviewed-by: Furquan Shaikh <furquan@chromium.org>
* driver/accelgyro_lsm6dsm: prevent negative array accessPatrick Georgi2018-08-151-2/+13
| | | | | | | | | | | | | | | | While it "should" never happen, the fifo_next has some corner cases where it might return a negative index. The alternative to this approach is to make sure it never underflows, so we don't need to guard against that. Change-Id: I86b4e89598329b7a5039a2bd016fc46230b617ac Signed-off-by: Patrick Georgi <pgeorgi@google.com> Found-by: Coverity Scan #187061 Reviewed-on: https://chromium-review.googlesource.com/1160302 Commit-Ready: Patrick Georgi <pgeorgi@chromium.org> Tested-by: Patrick Georgi <pgeorgi@chromium.org> Reviewed-by: Stefan Reinauer <reinauer@google.com>
* drivers: Refactor to use high-level i2c APIsJonathan Brandmeyer2018-08-0910-112/+66
| | | | | | | | | | | | | | | | | | | | | | | | Using the high-level APIs for block transfers eliminates some code duplication and error-prone manual locking sequences. - common/cbi: Block transfers - driver/accel_bma2x2: Block transfers - driver/accel_kionix: Block transfers - driver/accelgyro_bmi160: Block transfers - driver/accelgyro_lsm6ds0: Block transfers - driver/baro_bmp280: Block and byte transfers - driver/charger/rt946x: Block transfers - driver/gyro_l3gd20h: Block transfers - driver/stm_mems_common: Block transfers - driver/tcpm: Block transfers TEST=buildall; motionsense and PD testing on Grunt convertible which exercises the bma160, kionix and tcpcm drivers. BRANCH=none BUG=chromium:871851 Change-Id: I1732253a244c3343459265ce1e1e54488cee65b8 Signed-off-by: Jonathan Brandmeyer <jbrandmeyer@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1167958 Reviewed-by: Jett Rink <jettrink@chromium.org>
* usbc_mux: Adding low power mode to USB MUXJett Rink2018-08-092-10/+76
| | | | | | | | | | | | | | | | | This is useful when the PS8751 is used solely as a SS MUX and not a TCPC. It will not get the normal low power mode commands from the PD state machine. We need to issue separate low power command and re-initialization for it. This CL is setting up the machinery for the child CL that uses it for bip. BRANCH=none BUG=b:111664205,b:111876407 TEST=verify that lower power mode is issued for bip with CL stack along with the reinitialization when exiting low power mode. Change-Id: Ida09568acf1f353298520f75505f726d95309c57 Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1153834
* sn5s330: add helper methods for common access patternJett Rink2018-08-081-58/+41
| | | | | | | | | | | | | | | Reading, toggling bits, and then writing is common in this file, so add helper methods that clean up it up. BRANCH=none BUG=none TEST=PPC operation is unaffected on bip. Change-Id: I97bac3750cc6afff5799fdfa03b05a74bd5334ef Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1166182 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Scott Collyer <scollyer@chromium.org>
* battery: Optionally prevent boot at low SOC with cell imbalance.Jonathan Brandmeyer2018-08-083-0/+45
| | | | | | | | | | | | | | | | | | | | Measure the cell imbalance with method dispatch to a per-battery method, such that families with a plurality of configurable batteries can support them all. By default, cell imbalance is taken to be 'zero' in case we don't support that battery's management IC. Provide a driver for reading cell voltages for the TI BQ4050 family. This IC is quite popular, but by no means universal. BUG=b:111214767 BRANCH=none TEST=Boot on Careena with a custom debug print statement, showing that we can measure the typical battery voltages during and after the boot at the battery status polling interval. Change-Id: I235389b252ac9c373aa9706dbd1066f7c0bbce71 Signed-off-by: Jonathan Brandmeyer <jbrandmeyer@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1162663 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* ps8751: Revert VBus hack to bypass cachingJett Rink2018-08-071-27/+1
| | | | | | | | | | | | | | | All of the boards that are using the PS8751 with the CONFIG_USB_PD_VBUS_DETECT_TCPC have upgraded their TCPC firmware version past 0x38. We can now use the standard VBus present caching mechanism. BRANCH=none BUG=b:77639399,b:110022315 TEST=phaser can negotiated Vbus on C1 still. Change-Id: I1ee69a67fc78560dde86b2affc288de0f329f53f Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1165856 Reviewed-by: Justin TerAvest <teravest@chromium.org>
* touchpad_st: remove support for 2 bytes per pixelWei-Han Chen2018-08-061-31/+4
| | | | | | | | | | | | | BRANCH=none BUG=b:70482333 TEST=test on whiskers Signed-off-by: Wei-Han Chen <stimim@chromium.org> Change-Id: If6660977ed598c8ed81eba98e7f1805dd8bb7976 Reviewed-on: https://chromium-review.googlesource.com/1163237 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: Wei-Han Chen <stimim@chromium.org> Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
* touchpad_st: send domeswitch status in heatmap modeWei-Han Chen2018-08-061-5/+36
| | | | | | | | | | | | | BRANCH=none BUG=b:70482333 TEST=test on whiskers Signed-off-by: Wei-Han Chen <stimim@chromium.org> Change-Id: I84b481b3d2dee9254cdf798aee01a3a4ce44ac88 Reviewed-on: https://chromium-review.googlesource.com/1160427 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: Wei-Han Chen <stimim@chromium.org> Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>