summaryrefslogtreecommitdiff
path: root/driver
Commit message (Collapse)AuthorAgeFilesLines
* ec: change usage of "sane" per inclusive languagePaul Fagerburg2020-07-221-1/+1
| | | | | | | | | | | | | | | | Google is working to change its source code to use more inclusive language. To that end, replace the terms "sane", "sanity check", and similar with inclusive/non-stigmatizing alternatives. BUG=b:161832469 BRANCH=None TEST=`make buildall -j` succeeds. `grep -Eir "sane|sanity" .` shows results only in third-party code or documentation. Signed-off-by: Paul Fagerburg <pfagerburg@chromium.org> Change-Id: I29e78ab27f84f17b1ded75cfa10868fa4e5ae88c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2311169 Reviewed-by: Jett Rink <jettrink@chromium.org>
* ps8805: Follow the sequence to enable the DCI register accessWai-Hong Tam2020-07-211-4/+23
| | | | | | | | | | | | | | Follow the sequence in the programming guide to enable the DCI register access, even they are always enabled in the firmware. BRANCH=None BUG=b:161202452, b:147772854 TEST=Tested Trogdor negotiate >5V charging and source power to USB devices. Change-Id: Ia121855cf097fe4b517ceefa461568fbec67b63d Signed-off-by: Wai-Hong Tam <waihong@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2304264 Reviewed-by: Marco Chen <marcochen@chromium.org>
* sm5803: Set precharge termination thresholdAseda Aboagye2020-07-212-0/+28
| | | | | | | | | | | | | | | | | | | | | | | | | The default precharge termination threshold is set by default to 4V/cell. This is not suitable for all batteries and would often be too high resulting in a reduced charging rate for the batteries. This commit changes the SM5803 driver to use the battery's defined minimum voltage as the precharge threshold. This will be determined when the system decides to charge the battery. BUG=b:161408901 BRANCH=None TEST=Build and flash waddledee rev 1, plug in battery with 1% SOC, verify that the DUT ends up charging the battery at the desired current rate instead of just 500mA. TEST=Cut battery off, plug in charger, verify that when battery wakes up, it is charging at the desired current rate. Signed-off-by: Aseda Aboagye <aaboagye@google.com> Change-Id: I363cf09bf43c4078234f49a3c67d0a953c4e255a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2300845 Tested-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org> Commit-Queue: Aseda Aboagye <aaboagye@chromium.org>
* sm5803: Use VBUS ADCs for VBUS presenceAseda Aboagye2020-07-211-5/+6
| | | | | | | | | | | | | | | | | | | | | | | | For some reason, using the CHG_DET bit in the status register does not always leave us with the right result for VBUS presence. However, the VBUS threshold interrupts seem very reliable. There could be some timing issue at play. This commit changes the init to use the VBUS ADC measurements to determine whether VBUS is present or not to be consistent with the run-time notification triggered from the VBUS threshold interrupts. BUG=b:161269327 BRANCH=None TEST=Build and flash waddledee, with other CL to change extpower to consult the VBUS ADCs, verify that AC presence is notified in the system correctly during run-time and at init. Signed-off-by: Aseda Aboagye <aaboagye@google.com> Change-Id: I6e694611cf58a59f20fa6843cf145421d33d0784 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2297982 Tested-by: Aseda Aboagye <aaboagye@chromium.org> Commit-Queue: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org>
* sm5803: Update charge procedure for new SiAseda Aboagye2020-07-212-4/+51
| | | | | | | | | | | | | | | | | For the SM5803A, there's a new procedure that needs to be done when starting to charge. This commit adds support for that new procedure. BUG=b:160918663 BRANCH=None TEST=Build and flash waddledee proto 1, verify that charging still works. Signed-off-by: Aseda Aboagye <aaboagye@google.com> Change-Id: I032b3a645a3d7a2482fab91bbf1d7202e2fc58aa Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2297232 Tested-by: Aseda Aboagye <aaboagye@chromium.org> Commit-Queue: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org>
* OCPC: Calculate system & battery resistanceAseda Aboagye2020-07-211-9/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In order to optimize charging from the auxiliary charger, we need to calculate the system resistance as well as the battery resistance. This allows some charger ICs to compensate for the losses from their output node to the battery. In order to perform this calculation, we must do it when the AP is off (or in suspend) which provides the condition that nearly all of the charge current is entering the battery and isn't being largely consumed by the rest of the system. The combined Rsys+Rbatt calculation is relatively straightforward as it's the delta between the VSYS output and the battery voltage divided by the current entering the battery. In order to separate out the two terms, we can look at the delta between the VSYS output and the VSYS node that's connected to the BFET as well as look at the egress current from the auxiliary charger and the current entering the battery. This commit adds this system resistance measurements and enables it for the RAA489000. The resistances are updated in S5/G3 when charging from the auxiliary charger every ~2.4s. BUG=b:148980020 BRANCH=None TEST=Build and flash waddledoo, verify that charging continues to work in all power states and battery can become full. TEST=Verify that charge current is still close to the target without excessively exceeding it. TEST=Verify charging in constant load via `stressapptest`. TEST=Verify charging in bursty workload via `stressapptest` with pauses for power spikes while monitoring charge current with a current probe. TEST=Verify charging works out of battery cutoff from the auxiliary charger. Signed-off-by: Aseda Aboagye <aaboagye@google.com> Change-Id: I1faa3a0b2b3d8f4fd44d72cd1f546226268df0c6 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2290058 Reviewed-by: Diana Z <dzigterman@chromium.org> Tested-by: Aseda Aboagye <aaboagye@chromium.org> Commit-Queue: Aseda Aboagye <aaboagye@chromium.org>
* battery: Expose battery_manufacture_date() as APIWai-Hong Tam2020-07-214-0/+20
| | | | | | | | | | | | | | | | | | | | | | | The newer kernels request this data. Add the battery_manufacture_date() as a new API. Checked the TRMs of the following batteries. They don't have any way to query the manufacture date, so return EC_ERROR_UNIMPLEMENTED. * bq27541 * bq27621_g1 * max17055 * mm8013 BRANCH=None BUG=b:160784792 TEST=Hacked to print the manufacture date, on both battery present and not. Change-Id: I1deefb64f6cc594828d6c10c42fa7107dadd7559 Signed-off-by: Wai-Hong Tam <waihong@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2300689 Commit-Queue: Douglas Anderson <dianders@chromium.org> Reviewed-by: Douglas Anderson <dianders@chromium.org>
* retimer/tusb544: set the HPD pin for DP/Dock modeDivagar Mohandass2020-07-181-3/+7
| | | | | | | | | | | | | | | DP lanes are getting disabled if the HPD pin are not set. Drive the HPD_IN pin in USB type-c DP/Dock mode and clear it in the no MUX mode. BRANCH=None BUG=b:160572502 TEST=Check DP/HDMI display out on Waddledee USB type-c sub board Signed-off-by: Divagar Mohandass <divagar.mohandass@intel.com> Change-Id: Ie5a467572a88471155fe84e1054ffe64de5f7964 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2304239 Reviewed-by: Diana Z <dzigterman@chromium.org>
* battery: Fix obtaining battery manufacture dateWai-Hong Tam2020-07-171-5/+5
| | | | | | | | | | | | | | | * Fix the typo: should be SB_MANUFACTURE_DATE (manufacture without r) * Fix the register, i.e. SB_MANUFACTURE_DATE, not SB_SPECIFICATION_INFO * Fix the format parsing. The LSB of year is bit-9, not bit-8. BRANCH=None BUG=b:160784792 TEST=With the later CL, checked the manufacture date. Change-Id: I5b5f2bfefec4bbe700bb1ec0d9d6048123f4ad16 Signed-off-by: Wai-Hong Tam <waihong@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2300688 Reviewed-by: Douglas Anderson <dianders@chromium.org>
* zork: Use CBI only and remove retimer probe codeDenis Brockus2020-07-174-35/+0
| | | | | | | | | | | | | | | | | | | Before CBI was being used, zork used I2C probing to detect basic hardware configuration. Now that CBI is supporting FW_CONFIG, this is being removed. BUG=b:151232257 BRANCH=none TEST=verify zork still boots with valid configuration Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: I267d99f8f3894aff2f6301df167c470db373509e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2304380 Commit-Queue: Denis Brockus <dbrockus@chromium.org> Commit-Queue: Edward Hill <ecgh@chromium.org> Tested-by: Denis Brockus <dbrockus@chromium.org> Auto-Submit: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Edward Hill <ecgh@chromium.org>
* SM5803: Update initsDiana Z2020-07-171-0/+9
| | | | | | | | | | | | | | | This updates one charging-related register, and also disables the Vbus PROCHOT comparator as it's currently triggering falsely. BRANCH=None BUG=b:161214528 TEST=on waddledee proto 1, boot and charge on MB Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: Ia547803e7d70e47be31c0d4bb66aa7c45211c302 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2303812 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Commit-Queue: Aseda Aboagye <aaboagye@chromium.org>
* syv682X: Add support for FRSEric Herrmann2020-07-171-9/+105
| | | | | | | | | | | | | | | | | | | | | Add interrupt for FRS signal and implement function to enable FRS by setting the FRS gpio. Only the TCPMv2 stack works with FRS. There are 2 workarounds in this CL for this version of the SYV682: 1. Only use the CC trigger when charging at 5V. If charging at greater than vSafe5V, just use VBUS falling to detect an FRS. 2. Use the TCPC CC trigger if available to signal FRS to the TCPM. BUG=b:148144711 TEST=make buildall TEST=After enabling FRS config options, check that FRS occurs and is properly signaled to the TCPM BRANCH=none Change-Id: Icd1ef8902925817ea5948b42f03b292a97a2b5bd Signed-off-by: Eric Herrmann <eherrmann@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2277209 Reviewed-by: Keith Short <keithshort@chromium.org>
* USB PD: Move board FRS configuration out of TCPCIEric Herrmann2020-07-171-6/+1
| | | | | | | | | | | | | | | | | Board FRS configuration is more board-specific than TCPC-specific. Move the board FRS configuration from TCPCI to usb_common. Implementing the board-level frs configuration is optional for each project. BUG=b:148144711 TEST=Can build volteer image with CONFIG_USB_PD_TCPC set BRANCH=none Change-Id: I43d13ec0b23f71273807f58db35e7dd333089efa Signed-off-by: Eric Herrmann <eherrmann@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2290838 Reviewed-by: Keith Short <keithshort@chromium.org>
* driver/tcpm: set PD_EVENT_RX_HARD_RESET event when receive hard resetRuibin Chang2020-07-144-10/+7
| | | | | | | | | | | | | | | | | | | | | | | | When we receive hard reset, we should do Vbus on-off cycle and should keep cc connection. So I change the event setting from PD_EVENT_TCPC_RESET to PD_EVENT_RX_HARD_RESET for ITE TCPC. Stand alone TCPCs also use hard reset event instead of calling pd_execute_hard_reset(), because waked up pd_task() may have chance setting to other state. BRANCH=None BUG=b:159394180 TEST=On board reef_it8320, and it81202_pdevb: 1.TCPMv1: Rx Hard reset -> done Vbus cycle, and keep cc connection, When we're SRC and SNK. 2.TCPMv2: Rx Hard reset -> done Vbus cycle, and keep cc connection, When we're SRC and SNK. Signed-off-by: Ruibin Chang <Ruibin.Chang@ite.com.tw> Change-Id: Ie94757580e8fed4fb33896f9c1e071def49ff03d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2284504 Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Eric Yilun Lin <yllin@chromium.org>
* raa489000: Add instantaneous curr/volt readingsAseda Aboagye2020-07-142-1/+25
| | | | | | | | | | | | | | | | | | | | The RAA489000 can provide instantaneous charge current and VSYSS voltage measurements via its ADCs. This commit adds the register for the charge current ADC and then updates a couple of the driver functions to use these instantaneous registers. BUG=b:148980020 BRANCH=None TEST=Build and flash waddledoo, verify that instantaneous readings are reported for charge current and VSYS. TEST=`make -j buildall` Signed-off-by: Aseda Aboagye <aaboagye@google.com> Change-Id: I8f0380d48f9d24f2fb133c001236357c4449cecb Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2290057 Tested-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org> Commit-Queue: Aseda Aboagye <aaboagye@chromium.org>
* raa489000: Reset BFET to normal during initAseda Aboagye2020-07-141-0/+12
| | | | | | | | | | | | | | | | | | | | | | When the system goes into hibernate, we disable the BFET to reduce power. However, we weren't returning the BFET back to normal operation during initialization. This was causing charging to not work coming out of EC hibernate. This commit simply resets the BFET to normal operation during init. BUG=b:158695492 BRANCH=none TEST=Build and flash waddledoo; hibernate DUT, wake via power button, plug in AC adapter verify that DUT is charging. Signed-off-by: Aseda Aboagye <aaboagye@google.com> Change-Id: Iba8aabad2036acf9dd4e3cefb3d7f937bccf8a29 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2274638 Tested-by: Aseda Aboagye <aaboagye@chromium.org> Commit-Queue: Aseda Aboagye <aaboagye@chromium.org> Auto-Submit: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org>
* TCPCI: Update alert mask to allow FRS alertsEric Herrmann2020-07-141-0/+3
| | | | | | | | | | | | | | | | | | The TCPCI unmask init wasn't umasking the extended alerts. They need to be unmasked for FRS detection. FRS is only supported as part of the TCPCI spec Rev 2.0. In rev 1.0, the relevant registers are reserved so Rev 1 TCPCs should ignore any writes. BUG=b:148144711 TEST=make buildall BRANCH=none Change-Id: If3164dba508df5a8fe686ebc1130ac72293fb306 Signed-off-by: Eric Herrmann <eherrmann@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2290841 Reviewed-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* OCPC: Use enum chg_id valuesDiana Z2020-07-111-10/+10
| | | | | | | | | | | | | | Remove redundancy between the OCPC header and "enum chg_id" BRANCH=None BUG=None TEST=make -j buildall Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: I4058e2395ec1cbd50ce197775eb07d3bcfad95f3 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2277834 Commit-Queue: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* Charger: Add dynamic charger chip countDiana Z2020-07-111-1/+1
| | | | | | | | | | | | | | | | Different DB options may cause different numbers of charger chips to be present on the system. Remove constant count for charger chips, and instead always call into the overridable function to query the count. BRANCH=None BUG=b:155963446 TEST=make -j buildall Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: I0e65b8af351ecabe6f7b823e0e56f1932cc280a6 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2277833 Commit-Queue: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* SM5803: Only enable auto charge when battery is connectedDiana Z2020-07-101-1/+1
| | | | | | | | | | | | | | | | | When the battery is physically present, but still in a disconnected state the board may brown out once the battery connects and the charger chip believes the end of charge condition is met. Only start auto charging bits when the battery has connected. BRANCH=None BUG=None TEST=on waddledee starting with cutoff battery, board doesn't brownout when battery connects Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: I8b4622de91ac9a9ae2ac734bcf52eb1f4c2acc8c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2290835 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* SM5803: Add 2S battery initsDiana Z2020-07-101-0/+34
| | | | | | | | | | | | | | Adding 2S battery inits from vendor, with check on platform ID to identify the 2S units. BRANCH=None BUG=b:155218826 TEST=make -j buildall Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: I0580acf9dc812edc699b6ea04ef18a1f84415657 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2289033 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* SM5803: Update 3S initsDiana Z2020-07-101-1/+2
| | | | | | | | | | | | | | Update 3S battery inits per vendor suggestion. Also correct upper range of 3S battery platform values. BRANCH=None BUG=b:155218826 TEST=make -j buildall Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: If104233eb3e8ee13faa7417d4083aadf588902a2 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2289032 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* bmi260: Add support for using compressed configKeith Short2020-07-101-11/+190
| | | | | | | | | | | | | | | | | | | | Add a new config option CONFIG_ACCELGYRO_BMI160_COMPRESSED_CONFIG for boards that need to save space. This is intended to be a temporary option until the BMI260 config file can be read from the AP at runtime. This option saves 916 bytes in RW flash space on Volteer. BUG=b:160330682 BRANCH=none TEST=make buildall TEST=boot Volteer, run "ectool motionsense" to verify sensor data is valid. Signed-off-by: Keith Short <keithshort@chromium.org> Change-Id: I294e5e0c3f919527b51e6f7361e74c7bf4afc543 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2289216 Reviewed-by: Abe Levkoy <alevkoy@chromium.org> Commit-Queue: Abe Levkoy <alevkoy@chromium.org>
* TCPM driver: Add prototype for tcpm frs enableEric Herrmann2020-07-091-16/+18
| | | | | | | | | | | | | | | | Add a prototype for tcpm_set_frs_enable so that we can compile if CONFIG_USB_PD_FRS is defined but not CONFIG_USB_PD_FRS_TCPC. BUG=b:148144711 TEST="make --board volteer" with CONFIG_USB_PD_FRS_PPC defined but not CONFIG_USB_PD_TCPC defined BRANCH=none Signed-off-by: Eric Herrmann <eherrmann@chromium.org> Change-Id: Icb1adea5ef8a90fd7b427a517dd05426a8f1957d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2289037 Reviewed-by: Denis Brockus <dbrockus@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org>
* Revert "TCPMv2: make sure Vbus is not sourced in AttachWait.SRC"Denis Brockus2020-07-081-10/+0
| | | | | | | | | | | | | | | | | | | | | | | | Commit sha 57b95363c05bdab7b7e57d553a9514128393247d Reverting a CL that was a temporary fix while a real solution was found. This will now be implemented with the following CLs https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2282691 https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2282699 https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2283697 BUG=none BRANCH=none TEST=make buildall Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: I76b92388f5ee5bae4bdb945a82f18eb3df3ab1fd Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2284728 Tested-by: Denis Brockus <dbrockus@chromium.org> Auto-Submit: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Edward Hill <ecgh@chromium.org> Commit-Queue: Edward Hill <ecgh@chromium.org>
* TCPMv2: manual control to DBG_ACC in TCPCDenis Brockus2020-07-084-0/+18
| | | | | | | | | | | | | | | | | | | | With TCPCI being changed to allow TCPM to control the DBG_ACC enable instead of the TCPC, it is probably a good idea to actually toggle the bit for any TCPC that uses this signal for internal logic. BUG=b:160253746 BRANCH=none TEST=verify DBG and nonDBG attaches Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: Ifb91afa0127689e0ca371e64495d80f30bf93c26 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2283697 Tested-by: Denis Brockus <dbrockus@chromium.org> Auto-Submit: Denis Brockus <dbrockus@chromium.org> Commit-Queue: Edward Hill <ecgh@chromium.org> Reviewed-by: Edward Hill <ecgh@chromium.org>
* tcpci: Set TCPC_REG_TCPC_CTRL_DEBUG_ACC_CONTROLEdward Hill2020-07-082-6/+14
| | | | | | | | | | | | | | | | | | | Set TCPC_CONTROL.DebugAccessoryControl = 1 to control by TCPM, not TCPC. If TCPC is left in control, then it will enable VBus when Sink Debug accessory device is detected (which is during AttachWait.SRC). We want to instead control this ourselves from TCPM. BUG=b:160253746 BRANCH=none TEST=dut-control servo_v4_role:snk (with CL:2276463 reverted) Signed-off-by: Edward Hill <ecgh@chromium.org> Change-Id: Ib71f2b76949eeb25e24669e5bf297123d2685be3 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2282691 Tested-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Amit Maoz <amit.maoz@nuvoton.corp-partner.google.com>
* TUSB422: Add support for FRSEric Herrmann2020-07-073-5/+62
| | | | | | | | | | | | | | | | | The TUSB422 does not officially support FRS. support is being added to workaround bugs in the SYV682. BUG=b:148144711 TEST=Check that FRS is signaled to the TCPM from the TUSB422 driver when CONFIG_USB_PD_FRS_TCPC is set TEST=make buildall BRANCH=none Change-Id: I4c8fefbf0f01b327f345d4b4f09b6c422aaa2e5d Signed-off-by: Eric Herrmann <eherrmann@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2278354 Reviewed-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* SYV682X: Add 100ms source current limit deglitchEric Herrmann2020-07-071-61/+84
| | | | | | | | | | | | | | | | | | | | | | The SYV682X source current limit is not a hard current limit, but rather will clamp the current to the setpoint. It still generates an interrupt, but will not cut off the channel until thermal shutdown. Disabling the channel at thermal shutdown isn't acceptable for safety reasons. Instead, disable the channel and signal overcurrent to the TCPM if the overcurrent status remains for 100ms. BUG=b:159161457,b:160335402,b:148144711 TEST=Check that we don't trip overcurrent with devices which spike VBUS TEST=With a load which exceeds the source setpoint, confirm that VBUS is disabled after 100ms +/- 10ms once the current passes the setpoint. TEST=make buildall BRANCH=none Change-Id: I8121b91e9c3b6aa6b9eee05d34012c0ab063bdfc Signed-off-by: Eric Herrmann <eherrmann@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2277881 Reviewed-by: Abe Levkoy <alevkoy@chromium.org> Commit-Queue: Abe Levkoy <alevkoy@chromium.org>
* usbc: only try to use ppc_set_frs_enable if it existsPeter Marheine2020-07-061-0/+2
| | | | | | | | | | | | | | | | The driver function to set FRS enable only exists if CONFIG_USB_PD_FRS_PPC is enabled, so we must also make its callers conditional in the same way. For consistency, also revise the TCPC FRS code paths to be conditional. BUG=b:146393213 BRANCH=None TEST=make buildall Signed-off-by: Peter Marheine <pmarheine@chromium.org> Change-Id: I3fb14c711dd2abdf6ef77d469b2103f37daac182 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2276125 Reviewed-by: Denis Brockus <dbrockus@chromium.org>
* mt6360: implement led driverTing Shen2020-07-022-0/+48
| | | | | | | | | | | | | BUG=b:151802370 TEST=with CL:2203474, see led lit BRANCH=master Signed-off-by: Ting Shen <phoenixshen@google.com> Change-Id: If64a851377f93aea125b7402a3f4afb771abe6e7 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2203473 Reviewed-by: Eric Yilun Lin <yllin@chromium.org> Tested-by: Ting Shen <phoenixshen@chromium.org> Commit-Queue: Ting Shen <phoenixshen@chromium.org>
* ppc: string de-duplicationKeith Short2020-07-024-42/+41
| | | | | | | | | | | | | | | De-duplicate strings in PPC drivers. Saves 312 bytes on Volteer. Average flash increase of 211 bytes. BUG=b:158572770 BRANCH=none TEST=make buildall Signed-off-by: Keith Short <keithshort@chromium.org> Change-Id: I5ca5c935f974b04216ce4d90e6f6d6b9103e8b75 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2278586 Commit-Queue: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Denis Brockus <dbrockus@chromium.org>
* TCPMv2: make sure Vbus is not sourced in AttachWait.SRCDenis Brockus2020-07-011-0/+10
| | | | | | | | | | | | | | | | | | | | | | | The TCPC on zork appears to enable Vbus sourcing some of the time when we come out of auto-toggle. It looks like about a 60ms delay before it is enabled. We then go to AttachWait.SRC and since the exit condition to get to Attached.SRC is a debounced/valid Attached.SRC CC and Safe0V, it has to be disabled manually in order to move to Attached.SRC BUG=b:160227699,b:160253746 BRANCH=none TEST=dut-control servo_v4_role:snk should attach Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: I1dfc5d2536aaa4d7a5ffc7bbb52c647b15764196 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2276463 Tested-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org> Reviewed-by: Keith Short <keithshort@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org> Auto-Submit: Denis Brockus <dbrockus@chromium.org>
* bb_retimer: add power up timingKeith Short2020-07-012-3/+25
| | | | | | | | | | | | | | | | | Ensure the Burnside Bridge is held in reset when the AP is off and add a delay to reset de-assertion to meet Burnside Bridge requirements. BUG=b:159743964 BRANCH=none TEST=make buildall TEST=Verify BB initialization is skipped when the AP is off (verified with extra debug) TEST=Verify operation of USB, DP, and USB4 devices on Burnside bridge. Signed-off-by: Keith Short <keithshort@chromium.org> Change-Id: I4a4f05aaf84bf93b3c3032998bc811591c8fbf35 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2271697 Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* tcpm: allow returning a status from set_frs_enablePeter Marheine2020-07-011-2/+5
| | | | | | | | | | | | | | | | | | | | | The old declaration with void is incompatible with the use of tcpci_tcpc_fast_role_swap_enable in the one driver that currently implements that function, causing build failure when CONFIG_USB_PC_FRS_TCPC is enabled and using the nct38xx TCPC driver. Because the underlying function may fail, walk up the stack and make all users capable of failure as well (however the top level user currently ignores the result). BUG=b:146393213 BRANCH=None TEST=make buildall Change-Id: Ib8cabf4a435731ed804a3cc4696dfea97eef3c98 Signed-off-by: Peter Marheine <pmarheine@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2276124 Commit-Queue: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Denis Brockus <dbrockus@chromium.org>
* driver: bmi160: Increase the deadline for gyro calibrationInno.Park2020-06-301-3/+19
| | | | | | | | | | | | | | | | | | | Current calibration timeout, 400ms, is not enough for gyro. Accel has done calibration under 100ms, whereas gyro usually takes 300ms ~ 700ms. So we need to increase timeout to 800ms in case of gyro. In addition, temporary set the least range during calibration to perform with full sensitivity. BUG=b:159557101 BRANCH=none TEST=check if gyro calibrated well without an error. 'echo 1 > /sys/bus/iio/devices/iio:device[gyro-index]/calibrate' Change-Id: Ib8c190d2969f6295e70cadd990999dfddf7a1b53 Signed-off-by: Inno.Park <ih.yoo.park@samsung.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2256967 Reviewed-by: Bob Moragues <moragues@chromium.org> Reviewed-by: Gwendal Grignou <gwendal@chromium.org> Commit-Queue: Bob Moragues <moragues@chromium.org>
* driver/bc12: implement mt6360 driverTing Shen2020-06-293-0/+215
| | | | | | | | | | | | | BUG=b:151802370 TEST=with CL:2189624, verify bc12 detection works correctly BRANCH=master Signed-off-by: Ting Shen <phoenixshen@google.com> Change-Id: I0fee8e7309178be4d933ed5c246ea107ca5931bf Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2117871 Commit-Queue: Ting Shen <phoenixshen@chromium.org> Tested-by: Ting Shen <phoenixshen@chromium.org> Reviewed-by: Eric Yilun Lin <yllin@chromium.org>
* ps8xxx: patch ps8815 A1 chip Device IDCaveh Jalali2020-06-292-3/+45
| | | | | | | | | | | | | | | | | | | | | | this adds a config option for the ps8815 to override the TCPCI Device ID field based on the chip hardware revision reported in vendor defined registers. early ps8815 A1 firmware still reports the same Device ID value as the A0 chip which makes the two chips indistinguishable using standard methods. so, we check a vendor defined register to distinguish the two parts and "patch" the Device ID. newer ps8815 firmware will correct this, so after we have flushed out early firmware, we can disable this override feature. BRANCH=none BUG=b:158857815,b:159289062 TEST=reflashed FW on ps8815 A0 and A1 Change-Id: I2db3150740c15a77836dea0e9db72e5d99fdc050 Signed-off-by: Caveh Jalali <caveh@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2254992 Tested-by: Keith Short <keithshort@chromium.org> Reviewed-by: Keith Short <keithshort@chromium.org> Commit-Queue: Keith Short <keithshort@chromium.org>
* ps8xxx: add helper function to access alternate I2C pagesCaveh Jalali2020-06-292-6/+6
| | | | | | | | | | | | | | | this provides a helper function for computing the I2C page address of alternate I2C pages available on the ps8xxx family of chips. BRANCH=none BUG=b:158857815,b:159289062 TEST=buildall passes Signed-off-by: Caveh Jalali <caveh@chromium.org> Change-Id: I121ec9f2beaadf3e4e3c429d177fe38eb2976be8 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2271700 Reviewed-by: Keith Short <keithshort@chromium.org> Commit-Queue: Keith Short <keithshort@chromium.org>
* usb_pd: Remove pd_cable dependent Thunderbolt code from common codeAyushee2020-06-261-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | 1. Separated the common functions needed to check for port/cable's Thunderbolt mode compatibility back into TCPMv1. 2. Refactored the common Thunderbolt mode functions using pd_cable structure for mode information by adding a. Generic function that returns the Discover Mode response of specified SVID. b. Thunderbolt specific functiion that returns Discover Mode response of Intel SVID. 3. Removed the redundant pd_cable structure from DRP state machine policy engine. BUG=b:158294748 b:150611251 BRANCH=None TEST=1. Able to enter into Thunderbolt mode on TCPMv1 Change-Id: I30c8f1a007228408e08520502db00601ca3a2521 Signed-off-by: Ayushee <ayushee.shah@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2249020 Reviewed-by: Abe Levkoy <alevkoy@chromium.org> Commit-Queue: Abe Levkoy <alevkoy@chromium.org>
* Swap system_jumped_to_this_image with _late for common codeDaisuke Nojiri2020-06-261-1/+1
| | | | | | | | | | | | | | | | | EFS2 boards need to call system_jumped_late in HOOK_INIT to avoid running init code twice per boot. system_jumped_to_this_image and system_jumped_late are functionally equivalent for non EFS2 boards. BUG=chromium:1072743 BRANCH=none TEST=buildall Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Change-Id: Iecfd4f6d3e9d43cea535cfd503d6bcf7b79bc4fa Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2267684 Reviewed-by: Keith Short <keithshort@chromium.org>
* sn5s330: initialize chip after EFS2 sysjumpCaveh Jalali2020-06-251-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | this fixes an issue where the pcc was not fully initialized as intended due to EFS2 interactions. when EFS2 is enabled, we sysjump to RW very early - before INIT_HOOKS run. any code in pd_task that is predicated by system_jumped_to_this_image() will either always run or never run. this is not the intended behavior. sn5s330_init() is called from ppc_init() which runs as part of initialization done by pd_task(). we now need to check system_jumped_late() instead of system_jumped_to_this_image() to get the intended behavior. BRANCH=none BUG=b:159769490, chromium:1072743 TEST=verified all of sn5s330_init() now runs using additional debug printfs. Change-Id: I3a8e6627e6e57e22b287b3f97bc79b0f3a07e5fa Signed-off-by: Caveh Jalali <caveh@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2265608 Reviewed-by: Keith Short <keithshort@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Commit-Queue: Keith Short <keithshort@chromium.org> Tested-by: Keith Short <keithshort@chromium.org>
* isl9241: set current limit after EFS2 sysjumpCaveh Jalali2020-06-251-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | this fixes an issue where the charger current limit is not set as early as intended due to EFS2 interactions. when EFS2 is enabled, we sysjump to RW very early - before INIT_HOOKS run. any code in INIT_HOOK functions that is predicated by system_jumped_to_this_image() will either always run or never run. this is not the intended behavior. charger_chips_init() is called from INIT_HOOKS, and that's where we call isl9241_init(). we now need to check system_jumped_late() instead of system_jumped_to_this_image() to get the intended behavior. BRANCH=none BUG=b:159769490, chromium:1072743 TEST=isl9241_init now sets current limit to 512mA right after EFS2 sysjump (verified with additional debug printfs) Change-Id: I6de12d947ea9abb8e6db85dee0129a7053d0708c Signed-off-by: Caveh Jalali <caveh@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2265303 Reviewed-by: Keith Short <keithshort@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Commit-Queue: Keith Short <keithshort@chromium.org> Tested-by: Keith Short <keithshort@chromium.org>
* tcpm: Change the get_chip_info() to prevent race conditionsWai-Hong Tam2020-06-257-41/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The original get_chip_info() returns a point of point to the chip_info. This way helps to cache the chip_info to a static variable and the function just returns the pointer to the static variable. This static variable has a race condition on the PS8805 chip. The PS8805 chip returns a different PID when the firmware is corrupted, i.e. 0x8803 instead of 0x8805. The !live case fixes the PID, by modifying the static variable directly. When another task calls the same function for the live case, the static variable is modified and has a race condition. This change fixes the issue by changing the get_chip_info() parameter to a point of the chip_info. The caller has to allocate a buffer in the stack and pass the address to the function. For the !live case, the function copies the cache value from the static variable to the buffer. So the static variable doesn't have a race condition. BRANCH=None BUG=b:159588335 TEST=Used ectool to check the PD chip PID 0x8805 (was 0x8803). localhost ~ # ectool pdchipinfo 1 vendor_id: 0x1da0 product_id: 0x8805 device_id: 0x1 fw_version: 0x0 min_req_fw_version: 0x0 Change-Id: Ic24615af77ea58016d286480572d2a282c4fa09a Signed-off-by: Wai-Hong Tam <waihong@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2264477 Reviewed-by: Julius Werner <jwerner@chromium.org>
* tcpm: add attached_wait decision to common after auto-toggleDenis Brockus2020-06-241-0/+5
| | | | | | | | | | | | | | | | | | Need to verify auto toggle connections and non auto toggle connections still work. I will verify on trembyle BUG=b:159736927 BRANCH=none TEST=check basic functionality Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: I378ddf520026591d8129986078875ce46f1e0ad8 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2264472 Tested-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Jett Rink <jettrink@chromium.org> Auto-Submit: Denis Brockus <dbrockus@chromium.org>
* tcpci: debug cleanupDenis Brockus2020-06-241-8/+43
| | | | | | | | | | | | | | | | | | | | | | | DEBUG_GET_CC was already present to output CC information on every get_cc call. This CL adds in spam reduction to not continue to output the values if they are the same as they were the last time they were output. DEBUG_ROLE_CTRL_UPDATES was added to output RoleControl register information every time it is written in the TCPCI code. BUG=none BRANCH=none TEST=make buildall Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: Ic6eeadce8813908f1b89e4b756e90e95b1f9ca01 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2250093 Tested-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org>
* tcpmv2: only enable AutoDischargeDisconnect when attachedDenis Brockus2020-06-244-165/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | Connecting a non-PD charger the DUT performs a TRY switch to become SRC. During this TRY path the AutoDischargeDisconnect had been enabled and the fact the non-PD charger will never allow Vbus to drop to Safe0V causes the fault. AutoDischargeDisconnect should only be enabled when there is a known stable attach and when this stops being the case the feature should return back to disabled. Verified on Trembyle NCT3807 platform BUG=b:158751942 BRANCH=none TEST=verify try does not fault on 5V charger Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: I9ab507a1bbc5b84948620b6174f946f07befde90 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2250092 Tested-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org>
* tcpci: add 16-bit TCPC I2C accessorsCaveh Jalali2020-06-232-13/+21
| | | | | | | | | | | | | | | | this extends the TCPC I2C access API to provide 16-bit accessors for vendor specific pages of a TCPC. some TCPCs, like the ps8xxx series define registers in pages beyond the TCPCI definition for vendor specific functions. BRANCH=none BUG=b:158857815 TEST=buildall -j succeeds Change-Id: I115ab305317a0816e625718676b2bedfaa39e70d Signed-off-by: Caveh Jalali <caveh@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2254991 Reviewed-by: Keith Short <keithshort@chromium.org>
* usb_mux: Add check if port is available in every exposed functionPatryk Duda2020-06-231-0/+20
| | | | | | | | | | | | BUG=b:154602760 BRANCH=none TEST=make buildall -j Signed-off-by: Patryk Duda <pdk@semihalf.com> Change-Id: I9a5097ed6746c917cb88a8e6bf5e98fa01267808 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2250681 Reviewed-by: Diana Z <dzigterman@chromium.org> Commit-Queue: Jett Rink <jettrink@chromium.org>
* tusb422: Ensure auto discharge disconnect disabledKeith Short2020-06-201-1/+17
| | | | | | | | | | | | | | | | | | | | The TUSB422 requires auto discharge disconnect to be enabled when in active mode (defined as not unattached). Make sure auto discharge disconnect is disabled prior to enable of DRP toggling as required by the USB Port Controller Specification. BUG=b:159160125 BRANCH=none TEST=make buildall TEST=On Volteer CC line toggling when unattached and verify connection of SNK devices. Signed-off-by: Keith Short <keithshort@chromium.org> Change-Id: I583085dae2547026e64c2b6162912b85805f0137 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2255329 Reviewed-by: Denis Brockus <dbrockus@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org>