summaryrefslogtreecommitdiff
path: root/board/servo_v4/board.c
Commit message (Collapse)AuthorAgeFilesLines
* servo_v4: Disable CCD (monitoring SBU) when DTS-mode disabled by a userWai-Hong Tam2019-09-281-5/+6
| | | | | | | | | | | | | | | | | | | | | | | | The SBU monitoring logic is used for muxing the correct polarity for CCD. If the DTS-mode is disabled by a user, meaning that CCD is supposed not being used, the SBU monitoring logic can be disabled. For DP alt-mode, the SBU lines are used for AUX channel. This SBU monitoring logic affects the AUX channel, due to the strong pull-up on the USB D+ line. It should be disabled. Remove the original calls of ccd_enable(), which is called when supplying power and detecting DUT Rd/Rd or Rp/Rp. This requires PD comm. We don't want CCD depends on PD comm. BRANCH=servo BUG=b:137219603 TEST=The default role "cc srcdts", CCD works on both phyical polarity. TEST=Called "cc src", checked GPIO SBU_MUX_EN 0. Change-Id: I8f2f7bda88426e6097f0f4efd811114b7a1135c3 Signed-off-by: Wai-Hong Tam <waihong@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1815557 Reviewed-by: Nick Sanders <nsanders@chromium.org>
* Remove __7b, __8b and __7bfDenis Brockus2019-07-201-9/+9
| | | | | | | | | | | | | | | | | | | The extentions were added to make the compiler perform most of the verification that the conversion was being done correctly to remove 8bit addressing as the standard I2C/SPI address type. Now that the compiler has verified the code, the extra extentions are being removed BUG=chromium:971296 BRANCH=none TEST=make buildall -j TEST=verify sensor functionality on arcada_ish Change-Id: I36894f8bb9daefb5b31b5e91577708f6f9af2a4f Signed-off-by: Denis Brockus <dbrockus@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1704792 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* Use 7bit I2C/SPI slave addresses in ECDenis Brockus2019-07-191-9/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* servo_v4: Enable VBUS detection interrupts to wake PD tasks fast enoughWai-Hong Tam2019-06-181-0/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It fixes a hard reset issue. After a hard reset, the PD state goes to SNK_HARD_RESET_RECOVER state and waits for the VBUS "off" and then back "on" again. When the VBUS goes back to "on", it then transits to SNK_DISCOVERY state that replies the Source_Cap message. In order to make the VBUS detection fast enough, these interrupts are needed to wake the PD tasks up; otherwise, it missed the Source_Cap message BUG=b:134701032 BRANCH=servo TEST=Made servo v4 as sink and issued Hard_Reset on either DUT or servo. 2019-06-14 13:55:04 > cc snk 2019-06-14 13:55:06 cc: on 2019-06-14 13:55:06 dts mode: off 2019-06-14 13:55:06 chg mode: off 2019-06-14 13:55:06 chg allowed: off 2019-06-14 13:55:06 > C1 st3 SNK_DISCONNECTED_DEBOUNCE 2019-06-14 13:55:06 C1 st5 SNK_DISCOVERY 2019-06-14 13:55:06 C1 Req [1] 5000mV 3000mA 2019-06-14 13:55:06 C1 st6 SNK_REQUESTED 2019-06-14 13:55:06 C1 st7 SNK_TRANSITION 2019-06-14 13:55:06 C1 st8 SNK_READY 2019-06-14 13:55:07 2019-06-14 13:55:07 > pd 1 hard 2019-06-14 13:55:16 C1 st34 HARD_RESET_SEND 2019-06-14 13:55:16 > C1 st35 HARD_RESET_EXECUTE 2019-06-14 13:55:16 C1 HARD RST TX 2019-06-14 13:55:16 C1 st4 SNK_HARD_RESET_RECOVER 2019-06-14 13:55:16 Repeat msg_id[0] port[1] 2019-06-14 13:55:16 Repeat msg_id[0] port[1] 2019-06-14 13:55:16 Repeat msg_id[0] port[1] 2019-06-14 13:55:16 C1 st5 SNK_DISCOVERY 2019-06-14 13:55:16 Repeat msg_id[0] port[1] 2019-06-14 13:55:16 C1 HARD RST RX 2019-06-14 13:55:16 C1 st4 SNK_HARD_RESET_RECOVER 2019-06-14 13:55:17 C1 st5 SNK_DISCOVERY 2019-06-14 13:55:17 C1 Req [1] 5000mV 3000mA 2019-06-14 13:55:17 C1 st6 SNK_REQUESTED 2019-06-14 13:55:17 C1 st7 SNK_TRANSITION 2019-06-14 13:55:18 C1 st8 SNK_READY 2019-06-14 13:55:18 C1 Req [1] 5000mV 3000mA 2019-06-14 13:55:18 C1 st6 SNK_REQUESTED 2019-06-14 13:55:18 C1 st7 SNK_TRANSITION 2019-06-14 13:55:18 C1 st8 SNK_READY Issued "pd 0 hard" on DUT: 2019-06-14 13:56:07 > C1 HARD RST RX 2019-06-14 13:56:11 C1 st4 SNK_HARD_RESET_RECOVER 2019-06-14 13:56:12 C1 st5 SNK_DISCOVERY 2019-06-14 13:56:12 C1 Req [1] 5000mV 3000mA 2019-06-14 13:56:12 C1 st6 SNK_REQUESTED 2019-06-14 13:56:12 C1 st7 SNK_TRANSITION 2019-06-14 13:56:12 C1 st8 SNK_READY Change-Id: I0cc80515df8044ec07fa6795d3723aca2a3dc0ef Signed-off-by: Wai-Hong Tam <waihong@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1660125 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* Revert "servo_v4: Enable VBUS voltage and current measurement"Wai-Hong Tam2019-06-011-5/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 2fa7472da15a402ba8649344016ab5351cb768e7. Reason for revert: Use servo I2C driver to access the INA's instead. Don't need the INA driver and the console command in servo v4 firmware. Original change's description: > servo_v4: Enable VBUS voltage and current measurement > > Enable the INA functions on the VBUS of the DUT port (PP_DUT) and the > VBUS of the CHG port (PP_CHG). > > BUG=b:132807223 > BRANCH=servo > TEST=Typed the console command "ina 0" and returned: > > ina 0 > Configuration: 4127 > Shunt voltage: 10d9 => 10782 uV > Bus voltage : 3d3a => 19592 mV > Power : 069b => 42275 mW > Current : 086d => 2157 mA > Calibration : 0400 > Mask/Enable : 0008 > Alert limit : 0000 > > Used a multimeter to measure the VBUS on the DUT port. The measured > voltage and current are close to the above values. > > Did the same thing on the CHG port. > > Change-Id: I1d49540b4685f299437821251cd6422b1c0ac0b8 > Signed-off-by: Wai-Hong Tam <waihong@google.com> > Reviewed-on: https://chromium-review.googlesource.com/1613805 > Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org> > Reviewed-by: Scott Collyer <scollyer@chromium.org> Bug: b:132807223 Change-Id: If8517ceb5255e38bb2824e6cb9fe1848142950c8 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1638718 Reviewed-by: Wai-Hong Tam <waihong@google.com> Tested-by: Wai-Hong Tam <waihong@google.com> Commit-Queue: Wai-Hong Tam <waihong@google.com>
* servo_v4: Enable VBUS voltage and current measurementWai-Hong Tam2019-05-201-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Enable the INA functions on the VBUS of the DUT port (PP_DUT) and the VBUS of the CHG port (PP_CHG). BUG=b:132807223 BRANCH=servo TEST=Typed the console command "ina 0" and returned: > ina 0 Configuration: 4127 Shunt voltage: 10d9 => 10782 uV Bus voltage : 3d3a => 19592 mV Power : 069b => 42275 mW Current : 086d => 2157 mA Calibration : 0400 Mask/Enable : 0008 Alert limit : 0000 Used a multimeter to measure the VBUS on the DUT port. The measured voltage and current are close to the above values. Did the same thing on the CHG port. Change-Id: I1d49540b4685f299437821251cd6422b1c0ac0b8 Signed-off-by: Wai-Hong Tam <waihong@google.com> Reviewed-on: https://chromium-review.googlesource.com/1613805 Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org> Reviewed-by: Scott Collyer <scollyer@chromium.org>
* servo_v4: fix in displaying CCD polarityNamyoon Woo2019-05-171-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | From crrev.com/c/1529724, servo-v4 console displays the ccd polarity in opposite manner. 2019-05-15 11:53:59 [583.849805 CCD: connected noflip] 2019-05-15 11:54:01 adC 2019-05-15 11:54:01 CHG_CC1_PD = 1708 2019-05-15 11:54:01 CHG_CC2_PD = 33 2019-05-15 11:54:01 DUT_CC1_PD = 1637 2019-05-15 11:54:01 DUT_CC2_PD = 1625 2019-05-15 11:54:01 SBU1_DET = 3092 2019-05-15 11:54:01 SBU2_DET = 24 2019-05-15 11:54:01 SUB_C_REF = 569 2019-05-15 11:54:20 C1 st3 2019-05-15 11:54:20 C1 st5 2019-05-15 11:54:20 [604.585404 CCD: connected flip] 2019-05-15 11:54:23 adc 2019-05-15 11:54:24 CHG_CC1_PD = 1712 2019-05-15 11:54:24 CHG_CC2_PD = 32 2019-05-15 11:54:24 DUT_CC1_PD = 1616 2019-05-15 11:54:24 DUT_CC2_PD = 1644 2019-05-15 11:54:24 SBU1_DET = 20 2019-05-15 11:54:24 SBU2_DET = 2955 2019-05-15 11:54:24 SUB_C_REF = 611 BUG=None BRANCH=None TEST=manually build fw and checked. 2019-05-15 12:07:46 [27.057955 CCD: connected noflip] 2019-05-15 12:07:47 adc 2019-05-15 12:07:48 CHG_CC1_PD = 1705 2019-05-15 12:07:48 CHG_CC2_PD = 4 2019-05-15 12:07:48 DUT_CC1_PD = 1617 2019-05-15 12:07:48 DUT_CC2_PD = 1645 2019-05-15 12:07:48 SBU1_DET = 20 2019-05-15 12:07:48 SBU2_DET = 3102 2019-05-15 12:07:48 SUB_C_REF = 592 2019-05-15 12:08:05 [45.191161 CCD: connected flip] 2019-05-15 12:08:06 adc 2019-05-15 12:08:08 CHG_CC1_PD = 1704 2019-05-15 12:08:08 CHG_CC2_PD = 4 2019-05-15 12:08:08 DUT_CC1_PD = 1638 2019-05-15 12:08:08 DUT_CC2_PD = 1625 2019-05-15 12:08:08 SBU1_DET = 2970 2019-05-15 12:08:08 SBU2_DET = 23 2019-05-15 12:08:08 SUB_C_REF = 563 Change-Id: I0e8540fb30460827772fefd63a3426d67fa85092 Signed-off-by: Namyoon Woo <namyoon@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1613650 Reviewed-by: Nick Sanders <nsanders@chromium.org>
* servo_v4: detect SBU more reliablyNick Sanders2019-03-281-104/+93
| | | | | | | | | | | | | | | | | | | | | SBU orientation was detected in a one-shot check, that didn't ensure that the line was idle. Change to detect SBU orientation independently of PD state, and only while it's disconnected from the host. Delete keepalive and ccd_enable as they aren't meaningful for the new mechanism. BUG=b:128646723, chromium:942130 BRANCH=servo TEST=unplug a lot of times, orientation always correct. Signed-off-by: Nick Sanders <nsanders@chromium.org> Change-Id: I16c770b9d8d7a0c2d90aa214cb8cdec4c36a7303 Reviewed-on: https://chromium-review.googlesource.com/1529724 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Reviewed-by: Todd Broch <tbroch@chromium.org>
* common: bit change 1 << constants with BIT(constants)Gwendal Grignou2019-03-261-2/+2
| | | | | | | | | | | | | | | | | Mechanical replacement of bit operation where operand is a constant. More bit operation exist, but prone to errors. Reveal a bug in npcx: chip/npcx/system-npcx7.c:114:54: error: conversion from 'long unsigned int' to 'uint8_t' {aka 'volatile unsigned char'} changes value from '16777215' to '255' [-Werror=overflow] BUG=None BRANCH=None TEST=None Change-Id: I006614026143fa180702ac0d1cc2ceb1b3c6eeb0 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1518660 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* common: replace 1 << digits, with BIT(digits)Gwendal Grignou2019-03-261-5/+5
| | | | | | | | | | | | | | | | Requested for linux integration, use BIT instead of 1 << First step replace bit operation with operand containing only digits. Fix an error in motion_lid try to set bit 31 of a signed integer. BUG=None BRANCH=None TEST=compile Change-Id: Ie843611f2f68e241f0f40d4067f7ade726951d29 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1518659 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* Revert "Servo v4: reduce RO flash size"Todd Broch2019-03-061-6/+2
| | | | | | | | | | | | | | | | | | | | | This reverts commit 590a45db85507787af77cf6bfc8ae63499cbf1cc. BRANCH=none BUG=b:124465253 TEST=manual, Running sudo servo_updater -b servo_v4 --force -f build/servo_v4/ec.bin sudo servo_updater -b servo_v4 --force -f build/servo_v4/ec.bin passes without failure, servo_updater.ServoUpdaterException: usb_updater2 exit with res = 3 Change-Id: Ied9939192c30342bb6314e6dccfcd56d950659ab Signed-off-by: Todd Broch <tbroch@google.com> Reviewed-on: https://chromium-review.googlesource.com/1497438 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: Todd Broch <tbroch@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org>
* Servo v4: reduce RO flash sizeDiana Z2018-11-201-2/+6
| | | | | | | | | | | | | | | Currently, the servo_v4 build is within 48 bytes of exceeding its RO flash size. With this change to remove the USART3 code from the RO image, there should be just about 350 free bytes of space. BRANCH=None BUG=None TEST=builds, hey_flash_used in RO elf file shows 0x170 free bytes Change-Id: I7ee8f6c964eb3e0fb009fba61430bab656c03c2e Signed-off-by: Diana Z <dzigterman@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1340545 Reviewed-by: Nick Sanders <nsanders@chromium.org>
* servo_v4: clear bbram PD state on rebootNick Sanders2018-08-251-0/+6
| | | | | | | | | | | | | | | Preserved bbram state causes failure to reinit on reboot. Clear on board init. BRANCH=None BUG=b:111573811 TEST=PD reinits on reboot. Change-Id: Ifdf98b5793cb99e2900ac5dc53263a86317b6b07 Signed-off-by: Nick Sanders <nsanders@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1187883 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* usb_i2c: Remove usb_i2c_board_enable/disableNicolas Boichat2017-11-201-2/+1
| | | | | | | | | | | | | | | | These functions are not used by usb_i2c.c on chip/stm32, let's move them to board/cr50 which is the only place where they are used. BRANCH=none BUG=None TEST=make buildall -j Change-Id: I8c1b292838b8dbee9a9001add9332e0add80c342 Signed-off-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/778749 Reviewed-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* servo_v4: disable USB3 interfaceNick Sanders2017-11-161-2/+5
| | | | | | | | | | | | | | | | This change switches the SS lines off in the main USB mux. There has been some general flakyness regarding USB3 peripherals and this change might address it. BUG=chromium:718075 BRANCH=None TEST=lsusb -t indicates 5000M before, 480M after. Change-Id: Id201fb20dc6489c4a071cb1c9c0624d7aa54652d Reviewed-on: https://chromium-review.googlesource.com/509130 Commit-Ready: Nick Sanders <nsanders@chromium.org> Tested-by: Nick Sanders <nsanders@chromium.org> Reviewed-by: Shawn N <shawnn@chromium.org>
* servo_v4: remove gpio endpoint.Nick Sanders2017-11-041-54/+2
| | | | | | | | | | | | | | | | | | | | We have an ec3po gpio driver that also works. Let's save some flash space by using that instead, and deleting the gpio usb endpoint. Saves 448 bytes. BUG=None BRANCH=servo TEST=servod still runs. Signed-off-by: Nick Sanders <nsanders@chromium.org> Change-Id: If1c764c97fba4798f8501a0c0364d2690d2fd2f0 Reviewed-on: https://chromium-review.googlesource.com/750593 Commit-Ready: Nick Sanders <nsanders@chromium.org> Tested-by: Nick Sanders <nsanders@chromium.org> Reviewed-by: Scott Collyer <scollyer@chromium.org> Reviewed-by: Wai-Hong Tam <waihong@google.com> Reviewed-by: Shawn N <shawnn@chromium.org>
* servo_v4: fix board version GPIO accessNick Sanders2017-11-021-15/+24
| | | | | | | | | | | | | | | Ensure GPIOs are inputs when read: Initialize GPIO direction on startup, and clean up register accesses using reg names rather than magic numbers. Add board version reporting with CONFIG_BOARD_SPECIFIC_VERSION. BUG=None BRANCH=servo TEST=version is correctly 3 Signed-off-by: Nick Sanders <nsanders@chromium.org> Change-Id: Ia04b01932fc36540af64b48b5e0bb6516f1529e2 Reviewed-on: https://chromium-review.googlesource.com/749693 Reviewed-by: Shawn N <shawnn@chromium.org>
* servo_v4: Add CHG / DUT port voltage synchronizationShawn Nematbakhsh2017-10-191-5/+3
| | | | | | | | | | | | | | | | | | | | | | The previous method of negotiating > 5V on CHG port followed by asynchronously negotiating > 5V on DUT port (and then switching DUT VBUS source from internal 5V to DUT) will often not function correctly due to VBUS glitching on the switchover. Instead, immediately switch VBUS source to CHG when detected, and negotiate > 5V on CHG only after DUT has requested a transition. BUG=chromium:775542 BRANCH=servo TEST=Attach {kevin, scarlet} to servo_v4, attach Apple charger to servo_v4, verify DUTs charge at 9V and consoles are reachable on scarlet. Change-Id: I1e53f1e74e5ab1cd32a252243c23faaa8fce107b Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/724683 Commit-Ready: Shawn N <shawnn@chromium.org> Tested-by: Shawn N <shawnn@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* pd: Remove ACCESSORY statesShawn Nematbakhsh2017-10-191-4/+3
| | | | | | | | | | | | | | | | | | | According to the USB-C spec, when a debug accessory is identified, we may optionally establish USB PD communication over CC. Some DTS partners (eg. servo_v4) expect us to speak PD, so let's make it so. There is no need for special ACCESSORY states, these do not exist in the PD spec. BRANCH=servo BUG=chromium:737755,b:65837068 TEST=On scarlet, attach servo_v4 and verify scarlet charges. Also verify EC and cr50 consoles are available through servo_v4. Change-Id: I59d1ca50b4766509eccf38562cdf926578138585 Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/693294 Commit-Ready: Shawn N <shawnn@chromium.org> Tested-by: Shawn N <shawnn@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* chip/stm32/usart: Add flags to usart_configNicolas Boichat2017-10-181-0/+2
| | | | | | | | | | | | | Allows setting TXINV/RXINV bits. BRANCH=none BUG=b:65697962 TEST=make BOARD=wand -j Change-Id: Ib1bb290cd9758c53b98c8fc1ca1a9369c8cff39e Signed-off-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/694561 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* servo_v4: Add a CCD 'keepalive' console command.Aseda Aboagye2017-09-061-3/+73
| | | | | | | | | | | | | | | | | | | | | | | | | | | Servo v4 monitors the SBU lines on USB-C connects in order to determine which direction to set the orientation of the SBU mux. However, when there's traffic on the lines, for example when the EC is rebooting, it can lead to the wrong conclusions and terminate the USB connection. This commit adds a CCD keepalive console command. Additonally, when the Type-C cable is unplugged from the DUT for at least 900ms, the CCD keepalive will be cleared. This is such that if the cable is unplugged and then replugged in a different orientation, the detection will still work. BUG=b:64903997 BRANCH=servo TEST=Flash servo_v4; `keepalive enable`. Run `dut-control power_state:reset` > 100 times and verify that the USB connection stays alive. Change-Id: I5c8f9ab3361d4f52f906161ab5da471a36725a4e Signed-off-by: Aseda Aboagye <aaboagye@google.com> Reviewed-on: https://chromium-review.googlesource.com/647031 Commit-Ready: Aseda Aboagye <aaboagye@chromium.org> Tested-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Nick Sanders <nsanders@chromium.org>
* usb_i2c: Fail if board I2C bridge is disabledRandall Spangler2017-07-311-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add usb_i2c_board_is_enabled(). On Cr50, this is now also connected to the I2C CCD capability. The USB-I2C bridge can only be used when the capability is available. On other platforms (Servo V4, etc.) where usb_i2c_board_enable() is a no-op, add a dummy implementation which always returns true. See go/cr50-ccd-wp for more information. BUG=b:62537474 BRANCH=cr50 TEST=manual with CR50_DEV=1 Connect host PC to dev board USB port On host PC: sudo servod -c ccd_cr50.xml -c reef_r1_inas.xml dut-control pp3300_ec_shv_reg --> fail, error 0x8001 ccdoops --> reset I2C config ccd i2c disable --> I2C disabled On host PC: sudo servod -c ccd_cr50.xml -c reef_r1_inas.xml dut-control pp3300_ec_shv_reg --> fail, error 0x0006 ccd i2c enable --> I2C enabled ccdunlock --> I2C disabled ccdoops --> I2C enabled ccdset i2c unlesslocked ccdlock --> I2C disabled ccdunlock --> I2C enabled Change-Id: Ia3df32e239a5f7c5915bc6c7e408ce0dc8b26c89 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/590577 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Mary Ruthven <mruthven@chromium.org>
* servo_v4: enable usb port by defaultNick Sanders2017-06-081-0/+12
| | | | | | | | | | | | | | | Set the USB mux and power enable to default to route the USB3 port to the DUT and enable VBUS. BUG=b:38391443 BRANCH=None TEST=ensure that blue port works on power on. Change-Id: Ie46e422bc083e435379470132159df32f6d644d3 Reviewed-on: https://chromium-review.googlesource.com/527992 Commit-Ready: Nick Sanders <nsanders@chromium.org> Tested-by: Nick Sanders <nsanders@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* servo_v4: Added support for HW board ID and limit on VBUS voltageScott Collyer2017-05-181-0/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The first two versions of servo_v4 (red and blue) have the TPD2E001 ESD between VBUS and CC1/CC2. This part has a breakdown min voltage of 11V. Therefore for these versions of servo_v4, need to limit VBUS to less than the default 20V value. This CL adds support to read two board ID gpios attached to the gpio expansion part. The max VBUS voltage is limited to 9V for red/blue and allowed to be 20V for black. BUG=b:38351574 BRANCH=servo_v4 TEST=Manual Modified a servo_v4 to add the 2 new pullup resistors. Tested with this unit and with a unit that does not have the pullups. Verified that without the pullups the version ID reads a 0 and the max VBUS voltage that will be requested by the CHG port is 9V. Wih the modified servo_v4, verified that the version reads 3 and the CHG port will request up to 20V. Change-Id: Ic41fcbe3a5c000282552c7322b5ab18ebb203cd2 Signed-off-by: Scott Collyer <scollyer@google.com> Reviewed-on: https://chromium-review.googlesource.com/507027 Commit-Ready: Scott Collyer <scollyer@chromium.org> Tested-by: Scott Collyer <scollyer@chromium.org> Reviewed-by: Nick Sanders <nsanders@chromium.org>
* common/update_fw: Remove board-specific rw_sectionsNicolas Boichat2017-04-151-20/+0
| | | | | | | | | | | | | | | | | | | | | | rw_sections is defined in the exact same way on all common code boards, let's remove it, and hard-code the values in update_fw.c instead. Take this as an opportunity to fold set_valid_section in fw_update_start (this will be useful later on, as we also want to return the inactive region version). BRANCH=none BUG=b:35587171 TEST=make buildall -j TEST=Can update hammer over USB using usb_updater2 Change-Id: I4dd3224f17f89c1851c379255f1195dc54528b3d Reviewed-on: https://chromium-review.googlesource.com/476451 Commit-Ready: Nicolas Boichat <drinkcat@chromium.org> Tested-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-by: Nick Sanders <nsanders@chromium.org> Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
* servo_v4: Don't disable SBU mux when TypeC detach occursScott2017-04-041-12/+12
| | | | | | | | | | | | | | | | | | | | | | | When a USB PD connection is made, servo_v4 senses the polarity of the SBU signals and sets the SBU mux for the deteted polarity. If the DUT is reset, the SBU mux needs to retain the same state so the H1 console USB endpoint is not disrupted. Modified the CCD_MODE_DISABLED case to no longer disable the SBU mux. In addition, removed the static variable ccd_mode as it was being set, but not ever being checked, so wasn't serving any purpose. BUG=b:36561120 BRANCH=servo_v4 TEST=Connect servo_v4 to Electro. On Electro EC console enter 'reboot' verify the H1 USB console remains connected. Change-Id: I4f0f5167221c04314ca5be063411f200896bbdf6 Signed-off-by: Scott <scollyer@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/464068 Commit-Ready: Scott Collyer <scollyer@chromium.org> Tested-by: Scott Collyer <scollyer@chromium.org> Reviewed-by: Mary Ruthven <mruthven@chromium.org>
* cr50: Have INAs and I2Cm enabled when rdd is attachedScott2017-02-061-3/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The INAs are only used for development and testing purposes. Therefore, the 3.3V rail to the INAs is off by default and the I2Cm module is not enabled. Enabling INA power and connecting the I2Cm module was done at the beginning of each USB to I2C request. The problem with this approach is that INA measurments didn't always succeed due to not enough time for the INAs to initialize. Rather than add some arbitrary delay, it is better to tie the INAs to when rdd is attached/detached. It is only when rdd is attached that the INAs will be accessed, so there is no need to enable/disable for each individual I2C transaction. This CL ties the enabling/disabling of the INA and I2Cm module to the rdd state. This change makes the previous use of usb_i2c_board_enable() and usb_i2c_board_disable() obslete. BRANCH=none BUG=chrome-os-partner:62375 TEST=manual Connect servo with suzyq connected: sudo servod -p 0x5014 -b eve -c eve_r0_inas.xml Then execute single INA reads dut-control pp3300_dx_edp_mv and verify that it returns meaningful numbers. Without this CL single reads via dut-control would always return 0. Change-Id: I799552bfd0701efd1828a0d720ac2a6cedee5ca1 Signed-off-by: Scott <scollyer@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/436864 Commit-Ready: Scott Collyer <scollyer@chromium.org> Tested-by: Scott Collyer <scollyer@chromium.org> Reviewed-by: Mary Ruthven <mruthven@chromium.org>
* servo_v4: Support to enable Type C DTS modeScott2017-02-011-203/+50
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Defined the config option CONFIG_USB_PD_DTS to board.h. - Added ccd_set_mode function in board.c - Removed ccd attach/detach functions from board.c as that function is - now integrated in the the usb_pd state machine. - Removed the fixed polarity that was being used in usb_pd_config.h so that the DUT port could connect as a SNK device. - Defined PD_ROLE_DEFAULT to override the value in usb_Pd.h so that CHG is SNK and DUT is SRC This set of changes allows servo_v4 to act like a suzyq. Hoever, PD messaging is still not supported. The CHG port can still connect as a SNK device, but VBUS on the DUT is only being provided by the host and not the CHG port. BUG=chrome-os-partner:61878 BRANCH=None TEST=Manual Connected zinger to CHG port and verifed via servo_v4 console that it reached SNK_READY. Connected DUT port to Reef and verified that it reached SRC_ACCESSORY state and that the correct SBU polarity was selected and that lsusb shows H1 as a USB device. Bus 003 Device 042: ID 18d1:5014 Google Inc. Change-Id: I4a0ab2468f383a3ba4db3a3236bb18df6a2c405a Signed-off-by: Scott <scollyer@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/428309 Commit-Ready: Scott Collyer <scollyer@chromium.org> Tested-by: Scott Collyer <scollyer@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* servo_v4: Added initial USB PD support for both CHG/DUT portsScott2017-01-091-3/+42
| | | | | | | | | | | | | | | | | | | | | | | - CHG port can connect as SNK at different voltage levels - DUT port presents as SNK only - DUT port uses fixed polarity since it has a fixed cable - Not supporting ALT or ALT_DP modes in terms of svdm messages at this point. - No support yet for USB mux. BUG=chromium:571476 BRANCH=None TEST=Manual CHG port: Tested with Zinger and Plankton and 5/12/20V VBUS levels. DUT port: Tested against Reef and verified that port reached SNK_READY. Change-Id: Ib645872790912f9e0a0d4adddc10345a59145d3e Signed-off-by: Scott <scollyer@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/424413 Commit-Ready: Scott Collyer <scollyer@chromium.org> Tested-by: Scott Collyer <scollyer@chromium.org> Reviewed-by: Nick Sanders <nsanders@chromium.org> Reviewed-by: Shawn N <shawnn@chromium.org>
* Revert "servo_v4: Added initial USB PD support for both CHG/DUT ports"Scott Collyer2016-12-281-42/+3
| | | | | | | | | | | This reverts commit 167f7e51d8e7693a277077d6c24294d2997e1c55. This CL followed https://chromium-review.googlesource.com/#/c/422450/ which needs to be reverted because PSTATE is required for keeping serial numbers. Change-Id: Icb26043e1ce3145a9d9d5ad159dc709e6b8bf98d Reviewed-on: https://chromium-review.googlesource.com/422480 Commit-Ready: Scott Collyer <scollyer@chromium.org> Tested-by: Scott Collyer <scollyer@chromium.org> Reviewed-by: Nick Sanders <nsanders@chromium.org> Reviewed-by: Shawn N <shawnn@chromium.org>
* servo_v4: Added initial USB PD support for both CHG/DUT portsScott2016-12-211-3/+42
| | | | | | | | | | | | | | | | | | | | | | - CHG port can connect as SNK at different voltage levels - DUT port presents as SNK only - DUT port uses fixed polarity since it has a fixed cable - Not supporting ALT or ALT_DP modes in terms of svdm messages at this point. - No support yet for USB mux. BUG=chromium:571476 BRANCH=None TEST=Manual CHG port: Tested with Zinger and Plankton and 5/12/20V VBUS levels. DUT port: Tested against Reef and verified that port reached SNK_READY. Change-Id: Idbdc963ba077a14efad9eea3b047f35a5a605bd6 Signed-off-by: Scott <scollyer@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/419117 Commit-Ready: Scott Collyer <scollyer@chromium.org> Tested-by: Scott Collyer <scollyer@chromium.org> Reviewed-by: Shawn N <shawnn@chromium.org>
* usb_i2c: refactor into commonNick Sanders2016-11-021-2/+3
| | | | | | | | | | | | | | | | This combines stm32 and chip/g usb_i2c interfaces so they will not diverge. Note that this fixes the chip/g implementation to use 8-bit i2c addresses. BUG=chrome-os-partner:57059 BRANCH=none TEST=servod interacts with servo_micro and servo_v4 Change-Id: Ibff217d84b132556202c8a71e3d42c07d546c634 Reviewed-on: https://chromium-review.googlesource.com/405108 Commit-Ready: Nick Sanders <nsanders@chromium.org> Tested-by: Nick Sanders <nsanders@chromium.org> Reviewed-by: Mary Ruthven <mruthven@chromium.org>
* servo_v4: support autodetect of CCDNick Sanders2016-10-141-2/+214
| | | | | | | | | | | | | | | This allows a servo_v4 to export case closed debugging automatically, if it detects that it's been plugged into a ccd device. BUG=chromium:571476 TEST=Connect to reef in both orientations. BRANCH=None Change-Id: I8e2781056b22e834132bc4bb839ef2763fa0b4b8 Signed-off-by: Nick Sanders <nsanders@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/375359 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* servo_v4: update uservo port init for tca6416Nick Sanders2016-10-071-9/+41
| | | | | | | | | | | | | | Make sure that ioexpander is set to output, and that the uservo usb power enable is set. BUG=chromium:651860 TEST=check that servo micro is initialized properly BRANCH=None Change-Id: Iff994c63cd333933d51db38202a41b7b6fc86d66 Signed-off-by: Nick Sanders <nsanders@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/395186 Reviewed-by: Kevin Cheng <kevcheng@chromium.org>
* servo_v4: allow gpio modification of DUT_HUB_USB_RESET_LNick Sanders2016-09-011-1/+1
| | | | | | | | | | | | | | DUT_HUB_USB_RESET_L was set to input as part of power sequencing but servod would like to write to it. We'll allow this. BUG=chromium:571476 TEST=dut-control dut_hub_usb_reset:on BRANCH=None Change-Id: I39997e7f7875b833a64f95a1e2ea9434f3523762 Signed-off-by: Nick Sanders <nsanders@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/378395 Reviewed-by: Kevin Cheng <kevcheng@chromium.org>
* servo_v4: add usb-c gpio configsNick Sanders2016-08-021-1/+4
| | | | | | | | | | | | | | Default to set DUT_CC1 to RD to enable USB and indicate USB SS orientation. Add ADC entries for SBU detect. BUG=chromium:571476 TEST=check that ADC maps to the right pins, check that usb3 initializes. BRANCH=None Change-Id: Ic9f7c6d1506b9ef83ed3b93a98516ab10b1a471c Signed-off-by: Nick Sanders <nsanders@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/364301 Reviewed-by: Todd Broch <tbroch@chromium.org>
* servo_v4: add USB updaterNick Sanders2016-07-211-0/+23
| | | | | | | | | | | | | | This adds a Google FW update endpoint to servo v4. BUG=chromium:571476 TEST=successfully update servo v4 via usb BRANCH=None Change-Id: I79cb46364d416300e430708db25814f861a6d7c9 Signed-off-by: Nick Sanders <nsanders@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/361833 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* servo v4: Add new GPIO mappings for rev2Nick Sanders2016-07-191-8/+22
| | | | | | | | | | | | | | | | | | Servo V4 rev2 has slightly different gpio mappings. Note that this change will cause rev1 to not work. Allow uservo routing before servod init. Further work is needed on uservo port preinit as servod will reset the port on startup, disconnecting uservo. BRANCH=none BUG=chromium:571476 TEST=Boot, use dut-control, see uservo. Change-Id: I6436eed030cfdd329c5bd0cbca49038b268c2b71 Signed-off-by: Nick Sanders <nsanders@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/359620 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* servo_v4: add initial servo_v4 buildNick Sanders2016-04-271-0/+220
Add initial servo_v4 build, GPIOs, etc. Supports most features other than PD passthrough. BUG=chromium:571476 BRANCH=None TEST=updated servod is able to control gpio, gpio extender on servo v4 Change-Id: I71c9cb2bf24b732dd6a2e101d7b1c849c9f88af8 Signed-off-by: Nick Sanders <nsanders@google.com> Reviewed-on: https://chromium-review.googlesource.com/332803 Commit-Ready: Nick Sanders <nsanders@chromium.org> Tested-by: Nick Sanders <nsanders@chromium.org> Reviewed-by: Todd Broch <tbroch@chromium.org>