diff options
author | Simon Glass <sjg@chromium.org> | 2020-12-11 10:44:31 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-12-24 01:37:41 +0000 |
commit | 461f56040ea8fa2d2d3f2f7a5842601c296b5d4f (patch) | |
tree | 570b592d1608d5ea9a59e1844607a6158b279396 /zephyr/Kconfig.usbc | |
parent | 97a2b7b25b87eb4ff95100ef80519782635b9065 (diff) | |
download | chrome-ec-461f56040ea8fa2d2d3f2f7a5842601c296b5d4f.tar.gz |
zephyr: Add initial USB-C support
This includes a variety of things to get volteer to build with some
amount of USB-C support.
It seems to charge the battery and prevent booting when the battery is
too low.
Much work remains.
In particular:
- check the Kconfig help and add missing help
- possibly add a TCPM Kconfig option for grouping
- BCI1.2 event handler
- TCPMv2 event generator
BUG=b:175434113, b:176171475
BRANCH=none
TEST=build and run on volteer:
20-12-11 17:43:12.344 uart:~$ tcpci_dump 0
20-12-11 17:44:45.493 VENDOR_ID (0x00) = 0x0451
20-12-11 17:44:45.493 PRODUCT_ID (0x02) = 0x0422
20-12-11 17:44:45.493 BCD_DEV (0x04) = 0x0100
20-12-11 17:44:45.504 TC_REV (0x06) = 0x0011
20-12-11 17:44:45.504 PD_REV (0x08) = 0x2011
20-12-11 17:44:45.504 PD_INT_REV (0x0a) = 0x1010
20-12-11 17:44:45.515 ALERT (0x10) = 0x000f
20-12-11 17:44:45.515 ALERT_MASK (0x12) = 0x007f
20-12-11 17:44:45.526 POWER_STATUS_MASK (0x14) = 0x04
20-12-11 17:44:45.526 FAULT_STATUS_MASK (0x15) = 0x7f
20-12-11 17:44:45.526 EXT_STATUS_MASK (0x16) = 0x00
20-12-11 17:44:45.536 ALERT_EXTENDED_MASK (0x17) = 0x00
20-12-11 17:44:45.536 CONFIG_STD_OUTPUT (0x18) = 0x60
20-12-11 17:44:45.536 TCPC_CTRL (0x19) = 0x11
20-12-11 17:44:45.547 ROLE_CTRL (0x1a) = 0x1a
20-12-11 17:44:45.547 FAULT_CTRL (0x1b) = 0x06
20-12-11 17:44:45.558 POWER_CTRL (0x1c) = 0x70
20-12-11 17:44:45.558 CC_STATUS (0x1d) = 0x13
20-12-11 17:44:45.558 POWER_STATUS (0x1e) = 0x8c
20-12-11 17:44:45.569 FAULT_STATUS (0x1f) = 0x00
20-12-11 17:44:45.569 EXT_STATUS (0x20) = 0x00
20-12-11 17:44:45.580 ALERT_EXT (0x21) = 0x00
20-12-11 17:44:45.580 DEV_CAP_1 (0x24) = 0x1e98
20-12-11 17:44:45.580 DEV_CAP_2 (0x26) = 0x00c5
20-12-11 17:44:45.592 STD_INPUT_CAP (0x28) = 0x00
20-12-11 17:44:45.592 STD_OUTPUT_CAP (0x29) = 0x00
20-12-11 17:44:45.592 CONFIG_EXT_1 (0x2a) = 0x00
20-12-11 17:44:45.602 MSG_HDR_INFO (0x2e) = 0x02
20-12-11 17:44:45.602 RX_DETECT (0x2f) = 0x00
20-12-11 17:44:45.613 RX_BYTE_CNT (0x30) = 0x00
20-12-11 17:44:45.613 RX_BUF_FRAME_TYPE (0x31) = 0x00
20-12-11 17:44:45.613 TRANSMIT (0x50) = 0x00
20-12-11 17:44:45.624 VBUS_VOLTAGE (0x70) = 0x0000
20-12-11 17:44:45.624 VBUS_SINK_DISCONNECT_THRESH (0x72) = 0x0000
20-12-11 17:44:45.633 VBUS_STOP_DISCHARGE_THRESH (0x74) = 0x0000
20-12-11 17:44:45.633 VBUS_VOLTAGE_ALARM_HI_CFG (0x76) = 0x0000
20-12-11 17:44:45.633 VBUS_VOLTAGE_ALARM_LO_CFG (0x78) = 0x0000
20-12-11 17:44:49.544 uart:~$ ppc_dump 0
20-12-11 17:45:09.838 FUNC_SET1 [50h] = 0x0b
20-12-11 17:45:09.838 FUNC_SET2 [51h] = 0x18
20-12-11 17:45:09.838 FUNC_SET3 [52h] = 0x6a
20-12-11 17:45:09.838 FUNC_SET4 [53h] = 0xfe
20-12-11 17:45:09.838 FUNC_SET5 [54h] = 0x37
20-12-11 17:45:09.838 FUNC_SET6 [55h] = 0xc1
20-12-11 17:45:09.847 FUNC_SET7 [56h] = 0x70
20-12-11 17:45:09.847 FUNC_SET8 [57h] = 0xbd
20-12-11 17:45:09.847 FUNC_SET9 [58h] = 0x34
20-12-11 17:45:09.847 FUNC_SET10 [59h] = 0x70
20-12-11 17:45:09.847 FUNC_SET11 [5ah] = 0x24
20-12-11 17:45:09.858 FUNC_SET12 [5bh] = 0x70
20-12-11 17:45:09.858 INT_STATUS_REG1 [2fh] = 0x00
20-12-11 17:45:09.858 INT_STATUS_REG2 [30h] = 0x80
20-12-11 17:45:09.858 INT_STATUS_REG3 [31h] = 0x09
20-12-11 17:45:09.858 INT_STATUS_REG4 [32h] = 0x08
20-12-11 17:45:09.862 INT_TRIP_RISE_REG1 [20h] = 0x80
20-12-11 17:45:09.862 INT_TRIP_RISE_REG2 [21h] = 0x00
20-12-11 17:45:09.874 INT_TRIP_RISE_REG3 [22h] = 0x05
20-12-11 17:45:09.874 INT_TRIP_FALL_REG1 [23h] = 0x80
20-12-11 17:45:09.874 INT_TRIP_FALL_REG2 [24h] = 0x00
20-12-11 17:45:09.879 INT_TRIP_FALL_REG3 [25h] = 0x05
20-12-11 17:45:09.879 INT_MASK_RISE_REG1 [26h] = 0xef
20-12-11 17:45:09.879 INT_MASK_RISE_REG2 [27h] = 0xe1
20-12-11 17:45:09.892 INT_MASK_RISE_REG3 [28h] = 0xff
20-12-11 17:45:09.892 INT_MASK_FALL_REG1 [29h] = 0xff
20-12-11 17:45:09.892 INT_MASK_FALL_REG2 [2ah] = 0xef
20-12-11 17:45:09.892 INT_MASK_FALL_REG3 [2bh] = 0x8f
...
20-12-11 18:21:17.576 battery
20-12-11 18:21:17.933 Status: 0x0080 INIT
20-12-11 18:21:17.933 Param flags:00000003
20-12-11 18:21:17.933 Temp: 0x0b64 = %.1d K (%.1d C)
20-12-11 18:21:17.933 V: 0x2aa8 = 10920 mV
20-12-11 18:21:17.933 V-desired: 0x3390 = 13200 mV
20-12-11 18:21:17.944 I: 0x00bd = 189 mA(CHG)
20-12-11 18:21:17.944 I-desired: 0x0a19 = 2585 mA
20-12-11 18:21:17.944 Charging: Allowed
20-12-11 18:21:17.944 Charge: 3 %
20-12-11 18:21:17.948 Manuf: LG
20-12-11 18:21:17.948 Device: AC17A8
20-12-11 18:21:17.953 Chem: LIO
20-12-11 18:21:17.960 Serial: 0xb754
20-12-11 18:21:17.960 V-design: 0x2d1e = 11550 mV
20-12-11 18:21:17.965 Mode: 0x6001
20-12-11 18:21:17.965 Abs charge:3 %
20-12-11 18:21:17.974 Remaining: 139 mAh
20-12-11 18:21:17.974 Cap-full: 5093 mAh (4991 mAh with 98 % compensation)
20-12-11 18:21:17.983 Display: 0.0 %
20-12-11 18:21:17.983 Design: 5360 mAh
20-12-11 18:21:17.993 Time-full: 26h:21
20-12-11 18:21:17.993 Empty: 0h:0
Cq-Depend: chromium:2585918
Change-Id: I0d852169c9cbbc70603944b70f4708111abd5b42
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2587225
Reviewed-by: Keith Short <keithshort@chromium.org>
Diffstat (limited to 'zephyr/Kconfig.usbc')
-rw-r--r-- | zephyr/Kconfig.usbc | 364 |
1 files changed, 364 insertions, 0 deletions
diff --git a/zephyr/Kconfig.usbc b/zephyr/Kconfig.usbc new file mode 100644 index 0000000000..924349b6bc --- /dev/null +++ b/zephyr/Kconfig.usbc @@ -0,0 +1,364 @@ +# Copyright 2020 The Chromium OS Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +config PLATFORM_EC_USBC + bool "Enable USB Type-C functionality" + default y + help + Enable this to support various USB Type-C features chosen by the + options below. USB-C is widely used on modern Chromebooks and the EC's + role is to negotiate power contracts (for sourcing or sinking power + over USB). The EC is also responsible for discovering the capabilities + of attached USB-C partners and enabling alternate operational modes, + including Display Port, Thunderbolt, and USB4. + +if PLATFORM_EC_USBC + +config PLATFORM_EC_USB_POWER_DELIVERY + bool "Enable support for USB Type-C Power Delivery" + default y + help + USB has always provided basic power to an attached peripheral. USB-C + PD is part of the USB 3.0 standard and allows a lot more functionality + than the basic 500mA @ 5V. It allows negotiating power delivery over + the USB cable to select voltages up to 20V with current up to 5A. + + This option also enables the Type-C Port Manager (TCPM) on the EC. The + TCPM deals with the various state changes in the system as devices are + plugged and unplugged, as well as changes in power requirements from + those devices. + +config PLATFORM_EC_CHARGE_MANAGER + bool "Enable the charge manager" + default y + help + The EC charge manager manages charging the battery from all supported + power sources. This includes dedicated charge ports (such as a + barrel jack connector), BC1.2 (Battery Charging 1.2) sources, and + USB-C sources. When multiple charge sources are connected to a + Chromebook simultaneously, the charge manager is responsible for + picking the best source. + + Note that the charge manager assumes that at least one USB-C power + source is available on the hardware, so cannot be built without + PLATFORM_EC_USBC. + +config PLATFORM_EC_CHARGER_INPUT_CURRENT + int "Charger input current in mA" + default 512 + help + This is the default input current for the board in mA. Many boards + also use this as the least maximum input current during transients. + + This value should depend on external power adapter, designed charging + voltage, and the maximum power of the running system. For type-C + chargers, this should be set to 512 mA in order to not brown-out + low-current USB charge ports in accordance with USB-PD r3.0 Sec. 7.3 + +config PLATFORM_EC_USBC_OCP + bool + help + USB-C overcurrent protection: Enable this to detect when a connected + USB-C partner draws too much power from the Chromebook and + automatically shut off power to the USB-C partner. + + This should be enabled by drivers which can detect over-current. It + cannot be set otherwise, even in prj.conf + +config PLATFORM_EC_USB_PD_HOST_CMD + bool "Enable host commands related to USB Power Delivery" + default y + help + This enables host commands which allow finding out the capabilities + of USB PD, checking is status and controlling how it operates. For + devices which support firmware update, this is provided as well, + with the firmware being sent from the AP. + +config PLATFORM_EC_USB_PD_PORT_MAX_COUNT + int "Maximum number of USB PD ports supported" + default 2 + help + This sets the limit on the number of PD ports supported on the + device. This is used to set the size for tables used by devices. + + TODO(b/176237074): Can we calculate this from the devicetree at some + point? Or update the sn5S330 driver to use an 8-bit flag byte for + source_enabled[] so that plenty of ports are supported without this + configuration option? + +choice "Measuring VBUS voltage" + prompt "Select how VBUS voltage is measured" + +config PLATFORM_EC_USB_PD_VBUS_MEASURE_NOT_PRESENT + bool "VBUS voltage cannot be read" + help + Enable this if the board does not provide any mechanism for the EC to + read the analog VBUS voltage. + +config PLATFORM_EC_USB_PD_VBUS_MEASURE_CHARGER + bool "On-board charger supports VBUS measurement" + help + Enable this if the VBUS voltage can be read using a charger on the + board. + +config PLATFORM_EC_USB_PD_VBUS_MEASURE_TCPC + bool "Type-C Port Controller supports VBUS measurement" + help + Enable this if the VBUS voltage can be read using the on-board + TCPC. + +config PLATFORM_EC_USB_PD_VBUS_MEASURE_ADC_EACH_PORT + bool "VBUS on each port is measured using an ADC channel" + help + Enable this is there is a separate ADC channel for each USB-C VBUS + voltage. + +endchoice # Measuring VBUS voltage + +config PLATFORM_EC_USB_PD_DUAL_ROLE + bool "Board can act as a dual-role Power Delivery port" + default y + help + This enables support for switching between source and sink during + operation. This means that the port can accept power (e.g. to charge + up its battery), or send out power to an attached device on the same + port. + +config PLATFORM_EC_USB_PD_DUAL_ROLE_AUTO_TOGGLE + bool "Board can use TCPC-controlled DRP toggle" + depends on PLATFORM_EC_USB_PD_DUAL_ROLE + default y + help + Enable this if the USB Type-C Port Controllers (TCPC) used on the + board supports toggling of the power role autonomously. When this is + disabled, the USB power delivery task is responsible for manually + toggling the power role. + +config PLATFORM_EC_USB_PD_DISCHARGE + bool "Board can discharge VBUS" + default y + help + Enable this if the board can enable VBUS discharge (eg. through a + GPIO-controlled discharge circuit, or through port controller + registers) to discharge VBUS rapidly on disconnect + +choice "Discharge method" + prompt "Select the discharge method" + depends on PLATFORM_EC_USB_PD_DISCHARGE + +config PLATFORM_EC_USB_PD_DISCHARGE_GPIO + bool "GPIO control" + help + Enable this if the discharge circuit is controlled by a GPIO + + TODO: How to specify the GPIO? + +config PLATFORM_EC_USB_PD_DISCHARGE_TCPC + bool "Discharge circuit is provided by the TCPC" + help + Enable this if the discharge circuit is provided by Power-Delivery + resistors on the USB Type-C Port Controller (TCPC). + +config PLATFORM_EC_USB_PD_DISCHARGE_PPC + bool "Discharge circuit is provided by the PPC" + help + Enable this if the discharge circuit is using Power Delivery + resistors on the Power Path Controller. + +endchoice # Discharge method + +if PLATFORM_EC_USB_POWER_DELIVERY + +config PLATFORM_EC_CONFIG_USB_PD_REV30 + bool "Enable USB PD Rev3.0 functionality" + default y + help + Enable this to allow Rev3.0 functionality, including features such as + Fast Role Swap, advertising the available power across all ports of a + multi-port charger, and USB4. If disabled, only USB Power Delivery + Rev2.0 functionality is supported. + + This defaults to y because PD Rev3.0 is required for USB4 + functionality. + +choice "VBUS detection method" + prompt "Select the method to detect VBUS" + +config PLATFORM_EC_USB_PD_VBUS_DETECT_TCPC + bool "TCPC detects VBUS" + help + Choose this option if the TCPC can detect the presence of VBUS + +config PLATFORM_EC_USB_PD_VBUS_DETECT_CHARGER + bool "Charger detects VBUS" + help + Choose this option if the battery charger can detect the presence + of VBUS + +config PLATFORM_EC_USB_PD_VBUS_DETECT_PPC + bool "PPC detects VBUS" + help + Choose this option if the Power-Path Controller (PPC) can detect the + presence of VBUS + +config PLATFORM_EC_USB_PD_VBUS_DETECT_NONE + bool "No way to detect VBUS" + help + Choose this option if it is not possible to detect VBUS. + +endchoice # VBUS detection method + +config PLATFORM_EC_USB_TYPEC_SM + bool "Enable Type-C (TC) physical-layer state machine" + default y + help + This enables the bottom layer of the TCPMv2 state machine which + handles using CC lines to set the voltage-level of the power supplied. + You should normally define this unless you want to override it in your + board code, which is not recommended. + +config PLATFORM_EC_USB_PRL_SM + bool "Enable protocol layer (PRL) state machine" + default y + help + This enables the middle layer of the power-delivery (PD) protocol, + which deals with the flow of power messages across the USB Type-C + interface. You should normally define this unless you want to override + it in your board code, which is not recommended. + +config PLATFORM_EC_USB_PE_SM + bool "Enable policy engine (PE) state machine" + default y + help + This enables the top layer of the power-delivery (PD) protocol, which + deals with the actually PD messages that are exchanged with attached + USB devices. You should normally define this unless you want to + override it in your board code, which is not recommended. + +config PLATFORM_EC_USB_PD_DECODE_SOP + def_bool y # Required for TCPMV2 + help + This enables support for encoding of the message's Start Of Packet + (SOP, SOP' and SOP'', collectively called SOP*) in bits 31-28 of the + 32-bit msg header type. + +choice "USB-C device type" + prompt "Select the USB-C device type" + default PLATFORM_EC_USB_DRP_ACC_TRYSRC + +config PLATFORM_EC_USB_VPD + bool "VCONN-Powered Device" + help + This enables support for supplying power to devices that accept power + over the USB VCONN line. + + See here for details: + + https://www.usb.org/sites/default/files/D1T2-3a%20-%20CTVPDs%20and%20Making%20Your%20Own%20USB-C%20Thingamajig.pdf + +config PLATFORM_EC_USB_CTVPD + bool "Charge-Through VCONN-Powered Device" + help + This enables support for supplying power to devices, with a circuit + that deals with this without needing the involvement of the main + device. + +config PLATFORM_EC_USB_DRP_ACC_TRYSRC + bool "Dual-Role Port, Audio Accessory, and Try.SRC Device" + help + This is the most flexible option, allowing the port to operate in + a dual-role capacity, so that power can be accepted or supplied on + a port. + +endchoice # USB-C device type + +endif # PLATFORM_EC_USB_POWER_DELIVERY + +config PLATFORM_EC_USBC_PPC + bool "Enable support for USB Type-C Power Path Controller" + default y + help + Enable this to support the USB Type-C PPC on your board. This enables + common routines for things like figuring out whether power is being + supplied to the Chromebook over USB-C, whether the Chromebook is + supplying power to another device, etc. + +if PLATFORM_EC_USBC_PPC + +config PLATFORM_EC_USBC_PPC_SN5S330 + bool "Support the TI SN5S330 PD 3.0 power mux" + select PLATFORM_EC_USBC_OCP + help + This is a USB Type-C Power Delivery 3.0 Bidirectional Power Mux with + CC and SBU short-to-VBUS Protection and Integrated Dead Battery + LDO. This chips provides protection against pins shorting to Vbus as + well as ESD (Electostatic discharge) protection. It provides a simple + I2C interface for for Mode Selection, Fast Role Swap, and Fault + Reporting. + +config PLATFORM_EC_USBC_PPC_SYV682X + bool "Support the SYV682X which is some kind of chip" + select PLATFORM_EC_USBC_OCP + help + The SYV682A is a 2 to 1 power mux switch for USB PD applications. The + SYV682A supports dead battery wake up function and Fast Role Swap + features. It provides protection against overcurrent, overvoltage, + thermal shutdown, and undervoltage conditions. + +config PLATFORM_EC_USB_PD_TCPM_TUSB422 + bool "Support the TI TUSB422 Port Control with USB PD" + help + This is a a USB PD PHY that enables a USB Type-C port with the + Configuration Channel (CC) logic needed for USB Type-C ecosystems. It + integrates the physical layer of the USB BMC power delivery (PD) + protocol to allow up to 100-W of power and support for alternate mode + interfaces. An external microprocessor, containing USB Type-C Port + Manager (TCPM), communicates with the TUSB422 through an I2C + interface. + +choice "Type-C Port Manager (TCPM)" + prompt "Choose a Type-C Port Manager (TCPM) to manage TCPC" + +config PLATFORM_EC_USB_PD_TCPM_TCPCI + bool "Use TCPCI" + help + Enable a TCPC compatible with the Type-C Port Controller Interface + (TCPCI) Specification. This driver supports both Rev1 v1.2 and Rev2 + v1.0 of the TCPCI specification. Select this driver directly only + if your specific TCPC chip is not listed as a separate config option. + + Note: most of the TCPC will depend on PLATFORM_EC_USB_PD_TCPM_TCPCI. + +# TODO: Add other choices: +# CONFIG_USB_PD_TCPM_STUB +# CONFIG_USB_PD_TCPM_FUSB302 +# CONFIG_USB_PD_TCPM_ITE_ON_CHIP +# CONFIG_USB_PD_TCPM_ANX3429 +# CONFIG_USB_PD_TCPM_ANX740X +# CONFIG_USB_PD_TCPM_ANX741X +# CONFIG_USB_PD_TCPM_ANX7447 +# CONFIG_USB_PD_TCPM_ANX7688 +# CONFIG_USB_PD_TCPM_NCT38XX +# CONFIG_USB_PD_TCPM_MT6370 +# CONFIG_USB_PD_TCPM_TUSB422 +# CONFIG_USB_PD_TCPM_RAA489000 +# CONFIG_USB_PD_TCPM_RT1715 +# CONFIG_USB_PD_TCPM_FUSB307 +# CONFIG_USB_PD_TCPM_STM32GX + +endchoice # Type-C Port Manager (TCPM) + +config PLATFORM_EC_CONSOLE_CMD_PPC_DUMP + bool "Enable ppc_dump command" + depends on PLATFORM_EC_USBC_PPC + default y + +config PLATFORM_EC_CMD_TCPC_DUMP + bool "Enable tcpi_dump command" + default y + # TODO: depends on ?? + +endif # PLATFORM_EC_USBC_PPC + +endif # PLATFORM_EC_USBC |