dt-bindings: usb: Document ST UCPD
Subsystems (4)
PATCH 1/4 dt-bindings: usb: Document ST UCPD
Document ST UCPD Type-C block. The UCPD integrates the physical layer of the Power Delivery (PD), with CC signaling method, for operation with Type-C cables. Vbus and Vconn control is performed using an external chip, usually ST TCPP01/TCPP02/TCPP03 or similar.
---
Cc: Alexandre Torgue <[email protected]>
Cc: Conor Dooley <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>
Cc: Heikki Krogerus <[email protected]>
Cc: Krzysztof Kozlowski <[email protected]>
Cc: Maxime Coquelin <[email protected]>
Cc: Rob Herring <[email protected]>
Cc: Sebastian Reichel <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
--- .../bindings/usb/st,stm32mp25-ucpd.yaml | 154 ++++++++++++++++++ 1 file changed, 154 insertions(+) create mode 100644 Documentation/devicetree/bindings/usb/st,stm32mp25-ucpd.yaml
Documentation/devicetree/bindings/usb/st,stm32mp25-ucpd.yaml new file +154 -0
@@ -0,0 +1,154 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/usb/st,stm32mp25-ucpd.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: STMicroelectronics STM32MP25 UCPD Type-C controller + +maintainers: + - Marek Vasut <[email protected]> + +description: + The UCPD integrates the physical layer of the Power Delivery (PD), + with CC signaling method, for operation with Type-C cables. Vbus + and Vconn control is performed using an external chip, usually + ST TCPP01/TCPP02/TCPP03 or similar. + +properties: + compatible: + const: st,stm32mp25-ucpd + + reg: + maxItems: 1 + + access-controllers: + maxItems: 1 + + clocks: + minItems: 2 + maxItems: 2 + + clock-names: + items: + - const: apb + - const: ker + + interrupts: + maxItems: 1 + + nvmem-cells: + maxItems: 1 + + nvmem-cell-names: + const: trim + + power-domains: + maxItems: 1 + + resets: + maxItems: 1 + + reset-names: + const: phy + + vconn-gpios: + description: GPIOs used to control CC1 and CC2 Vconn + + vdd33-supply: + description: Regulator that supplies the CC lines driver + + connector: + type: object + $ref: /schemas/connector/usb-connector.yaml# + unevaluatedProperties: false + + properties: + compatible: + const: usb-c-connector + + power-role: true + + typec-power-opmode: true + + required: + - compatible + +required: + - compatible + - reg + - clocks + - clock-names + - interrupts + - nvmem-cells + - nvmem-cell-names + - power-domains + - resets + - reset-names + +unevaluatedProperties: false + +examples: + - | + #include <dt-bindings/clock/st,stm32mp25-rcc.h> + #include <dt-bindings/interrupt-controller/arm-gic.h> + #include <dt-bindings/reset/st,stm32mp25-rcc.h> + + ucpd: phy@480a0000 { + compatible = "st,stm32mp25-ucpd"; + reg = <0x480a0000 0x1000>; + access-controllers = <&rifsc 69>; + clocks = <&rcc CK_BUS_USBTC>, <&rcc CK_KER_USBTC>; + clock-names = "apb", "ker"; + interrupts = <46 IRQ_TYPE_LEVEL_HIGH>; + nvmem-cells = <&ucpdtrim>; + nvmem-cell-names = "trim"; + power-domains = <&cluster_pd>; + resets = <&rcc USBTC_R>; + reset-names = "phy"; + + vconn-gpios = <&tcpp 0 0>, <&tcpp 1 0>; + vdd33-supply = <&scmi_vdd33ucpd>; + + connector { + compatible = "usb-c-connector"; + label = "USB-C"; + data-role = "dual"; + power-role = "source"; + self-powered; + vbus-gpios = <&gpioa 10 0>; + vbus-supply = <®_usbc_vbus>; + + altmodes { + displayport { + svid = /bits/ 16 <0xff01>; + vdo = <0xffffffff>; + }; + }; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@0 { + reg = <0>; + usbc0_hs_ep: endpoint { + remote-endpoint = <&usb_drd0_hs_ep>; + }; + }; + port@1 { + reg = <1>; + usbc0_ss_ep: endpoint { + remote-endpoint = <&usb_drd0_ss_ep>; + }; + }; + + port@2 { + reg = <2>; + usbc0_sbu_ep: endpoint { + remote-endpoint = <&usb_sbu_ep>; + }; + }; + }; + }; + };
Signature · 1 line
2.53.0
PATCH 2/4 usb: typec: ucpd: Add ST UCPD driver
Add ST UCPD Type-C block driver. The UCPD integrates the physical layer of the Power Delivery (PD), with CC signaling method, for operation with Type-C cables. Vbus and Vconn control is performed using an external chip, usually ST TCPP01/TCPP02/TCPP03 or similar.
---
Cc: Alexandre Torgue <[email protected]>
Cc: Conor Dooley <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>
Cc: Heikki Krogerus <[email protected]>
Cc: Krzysztof Kozlowski <[email protected]>
Cc: Maxime Coquelin <[email protected]>
Cc: Rob Herring <[email protected]>
Cc: Sebastian Reichel <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
--- drivers/usb/typec/tcpm/Kconfig | 9 + drivers/usb/typec/tcpm/Makefile | 1 + drivers/usb/typec/tcpm/ucpd.c | 951 ++++++++++++++++++++++++++++++++ 3 files changed, 961 insertions(+) create mode 100644 drivers/usb/typec/tcpm/ucpd.c
drivers/usb/typec/tcpm/Kconfig +9 -0
@@ -91,4 +91,13 @@ config TYPEC_QCOM_PMIC This driver enables Type-C role switching, orientation, Alternate mode and Power Delivery support both for VBUS and VCONN. +config TYPEC_ST_UCPD + tristate "ST UCPD Type-C Port Controller Manager driver" + depends on ARCH_STM32 || COMPILE_TEST + help + The ST UCPD Type-C block integrates the physical layer of the + Power Delivery (PD), with CC signaling method, for operation + with Type-C cables. Vbus and Vconn control is performed using + an external chip, usually ST TCPP01/TCPP02/TCPP03 or similar. + endif # TYPEC_TCPM
drivers/usb/typec/tcpm/Makefile +1 -0
@@ -10,3 +10,4 @@ obj-$(CONFIG_TYPEC_TCPCI_MT6370) += tcpci_mt6370.o obj-$(CONFIG_TYPEC_TCPCI_MAXIM) += tcpci_maxim.o tcpci_maxim-y += tcpci_maxim_core.o maxim_contaminant.o obj-$(CONFIG_TYPEC_QCOM_PMIC) += qcom/ +obj-$(CONFIG_TYPEC_ST_UCPD) += ucpd.o
drivers/usb/typec/tcpm/ucpd.c new file +951 -0
951 lines not on this page · raw message
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH 2/4] usb: typec: ucpd: Add ST UCPD driver
Thank you for your contribution! Sashiko AI review found 10 potential issue(s) to consider: - [Critical] Stack buffer overflow in `ucpd_pd_read_message` due to unbounded reading of incoming PD…
Thank you for your contribution! Sashiko AI review found 10 potential issue(s) to consider:
- [Critical] Stack buffer overflow in ucpd_pd_read_message due to unbounded reading of incoming PD messages.
- [High] Uninitialized variable ret is returned from tcpm_set_vconn on early bail-out paths.
- [High] Resource leaks for fwnode_handle and typec_switch in ucpd_probe and ucpd_remove.
- [High] Invalid use of IS_ERR() to check the return value of device_get_named_child_node().
- [High] The threaded IRQ handler is requested before the TCPM port is fully registered, causing a NULL pointer dereference on early interrupts.
- [High] The IRQ handler remains active after the TCPM port's workqueue is destroyed, leading to a Use-After-Free during teardown.
- [High] The function tcpm_decode_cc maps CC voltage states incorrectly when operating as a Sink.
- [High] Manual software generation of a GoodCRC for invalid or truncated PD messages inside a threaded IRQ violates USB PD requirements.
- [High] Ignoring the timeout when waiting for the previous transmission to complete can corrupt the hardware state.
- [Medium] Data race on port roles (pwr_role and data_role) as they are updated without a lock but read under a lock. --
--- Patch [2]: [PATCH 2/4] usb: typec: ucpd: Add ST UCPD driver --- commit 2b9c556a7989ba29cde859ea3a479a2ad6876950
Author: Marek Vasut <[email protected]>
usb: typec: ucpd: Add ST UCPD driver
Add ST UCPD Type-C block driver. The UCPD integrates the physical layer of the Power Delivery (PD), with CC signaling method, for operation with Type-C cables.
Quoted 5 lines
drivers/usb/typec/tcpm/ucpd.c new file +0
-0
[ ... ]
drivers/usb/typec/tcpm/ucpd.c line 391
Quoted 9 lines
drivers/usb/typec/tcpm/ucpd.c new file +9
-0+static enum typec_cc_status tcpm_decode_cc (const int cr,const int cc) +{ +bool sink = !!(cr &UCPD_CR_ANAMODE ); + +switch (cc) { +case UCPD_SR_TYPEC_VSTATE_CC_LOWEST : +return TYPEC_CC_RA ; +case UCPD_SR_TYPEC_VSTATE_CC_LOW : +return TYPEC_CC_RD ;
[Severity: High]
When operating as a Sink, the CC line is pulled up by the partner's Rp. A LOWEST state (0V) means unattached (TYPEC_CC_OPEN), and a LOW state corresponds to TYPEC_CC_RP_DEF.
Does returning TYPEC_CC_RA and TYPEC_CC_RD unconditionally here cause the TCPM state machine to fail to detect chargers correctly?
Quoted 6 lines
drivers/usb/typec/tcpm/ucpd.c new file +6
-0+case UCPD_SR_TYPEC_VSTATE_CC_HIGH : +return sink ?TYPEC_CC_RP_1_5 :TYPEC_CC_OPEN ; +default : +return sink ?TYPEC_CC_RP_3_0 :TYPEC_CC_OPEN ; + } +}
[ ... ]
drivers/usb/typec/tcpm/ucpd.c line 454
Quoted 7 lines
drivers/usb/typec/tcpm/ucpd.c new file +7
-0+static int tcpm_set_vconn (struct tcpc_dev *dev,bool on) +{ +struct ucpd *ucpd =tcpm_to_ucpd (dev); + DECLARE_BITMAP(bitmap, 2) = { }; +enum typec_cc_status cc1, cc2; +int cr, sr; +int ret;
[Severity: High]
Is it possible for this code to return an uninitialized ret?
If we take the early goto done path below due to ucpd->vconn_on == on or an unknown CC polarity, ret will be returned without ever being initialized.
Quoted 6 lines
drivers/usb/typec/tcpm/ucpd.c new file +6
-0+ +mutex_lock (&ucpd->lock); +if (ucpd->vconn_on == on) { +dev_err (ucpd->dev,"vconn is already %d\n" , on); + goto done; + }
[ ... ]
Quoted 8 lines
drivers/usb/typec/tcpm/ucpd.c new file +8
-0+if (cc1 ==TYPEC_CC_OPEN || cc1 ==TYPEC_CC_RA ) { + ucpd->cc_polarity =TYPEC_POLARITY_CC2 ; + }else if (cc2 ==TYPEC_CC_OPEN || cc2 ==TYPEC_CC_RA ) { + ucpd->cc_polarity =TYPEC_POLARITY_CC1 ; + }else { +dev_err (ucpd->dev,"unknown CC polarity %d %d\n" , cc1, cc2); + goto done; + }
[ ... ]
Quoted 5 lines
drivers/usb/typec/tcpm/ucpd.c new file +5
-0+done: +mutex_unlock (&ucpd->lock); + +return ret; +}
[ ... ]
drivers/usb/typec/tcpm/ucpd.c line 576
Quoted 7 lines
drivers/usb/typec/tcpm/ucpd.c new file +7
-0+static int tcpm_set_roles (struct tcpc_dev *dev,bool attached, +enum typec_role pwr,enum typec_data_role data) +{ +struct ucpd *ucpd =tcpm_to_ucpd (dev); + + ucpd->pwr_role = pwr; + ucpd->data_role = data;
[Severity: Medium]
Should this state update be protected by ucpd->lock?
These roles are read concurrently under the lock in ucpd_pd_read_message(), which could lead to a race condition and a GoodCRC message being transmitted with torn role bits.
Quoted 3 lines
drivers/usb/typec/tcpm/ucpd.c new file +3
-0+ +return 0 ; +}
[ ... ]
Quoted 3 lines
drivers/usb/typec/tcpm/ucpd.c new file +3
-0+static int ucpd_pd_send_message (struct ucpd *ucpd,enum tcpm_transmit_type type, +const struct pd_message *msg) +{
[ ... ]
drivers/usb/typec/tcpm/ucpd.c line 626
Quoted 4 lines
drivers/usb/typec/tcpm/ucpd.c new file +4
-0+if (ucpd->tx_pending) { +regmap_read_poll_timeout (ucpd->regmap,UCPD_SR , + val, val &UCPD_SR_TXMSGSENT , +0 ,100000 );
[Severity: High]
Could ignoring the return value of regmap_read_poll_timeout() lead to hardware state corruption?
If the hardware is stuck or still busy transmitting and the timeout occurs, the code proceeds to unconditionally overwrite TX registers, potentially corrupting the ongoing transfer.
Quoted 3 lines
drivers/usb/typec/tcpm/ucpd.c new file +3
-0+regmap_write (ucpd->regmap,UCPD_ICR ,UCPD_ICR_TXMSGSENTCF ); + ucpd->tx_pending = false; + }
[ ... ]
Quoted 2 lines
drivers/usb/typec/tcpm/ucpd.c new file +2
-0+static void ucpd_pd_read_message (struct ucpd *ucpd) +{
[ ... ]
drivers/usb/typec/tcpm/ucpd.c line 735
Quoted 10 lines
drivers/usb/typec/tcpm/ucpd.c new file +10
-0+if (val &UCPD_SR_RXNE ) { +regmap_read (ucpd->regmap,UCPD_RXDR , &rxdata); + +/* First two bytes are header, rest is message */ +if (count <2 ) + mh[count] = rxdata &0xff ; +else + mp[count -2 ] = rxdata &0xff ; + count++; + }
[Severity: Critical]
Can this unbounded loop overflow the pd_msg stack buffer?
An external device sending an oversized or malformed packet could cause count to grow past the 30-byte payload limit before the length check is ever reached, overwriting the kernel stack.
Quoted 6 lines
drivers/usb/typec/tcpm/ucpd.c new file +6
-0+ +if (val &UCPD_SR_RXMSGEND ) { +regmap_write (ucpd->regmap,UCPD_ICR ,UCPD_ICR_RXMSGENDCF ); +break ; + } + }
[ ... ]
drivers/usb/typec/tcpm/ucpd.c line 772
Quoted 12 lines
drivers/usb/typec/tcpm/ucpd.c new file +12
-0+if (!len && (pd_header_type_le (pd_msg.header) ==PD_CTRL_GOOD_CRC )) { +tcpm_pd_transmit_complete (ucpd->tcpm_port,TCPC_TX_SUCCESS ); + }else { +struct pd_message msg = { + .header =PD_HEADER_LE (PD_CTRL_GOOD_CRC , + ucpd->pwr_role, + ucpd->data_role, +pd_header_rev_le (pd_msg.header), +pd_header_msgid_le (pd_msg.header), +0 ), + }; +ucpd_pd_send_message (ucpd,TCPC_TX_SOP , &msg);
[Severity: High]
Does generating a GoodCRC in software inside a threaded IRQ violate the 195us tTransmit USB PD requirement?
It seems like this might lead to connection drops. Also, for truncated messages, it constructs a GoodCRC with a zeroed header acknowledging corrupted data.
Quoted 3 lines
drivers/usb/typec/tcpm/ucpd.c new file +3
-0+tcpm_pd_receive (ucpd->tcpm_port, &pd_msg,TCPC_TX_SOP ); + } +}
[ ... ]
Quoted 2 lines
drivers/usb/typec/tcpm/ucpd.c new file +2
-0+static int ucpd_probe (struct platform_device *pdev) +{
[ ... ]
drivers/usb/typec/tcpm/ucpd.c line 882
Quoted 3 lines
drivers/usb/typec/tcpm/ucpd.c new file +3
-0+ ucpd->tcpc_dev.fwnode =device_get_named_child_node (dev,"connector" ); +if (IS_ERR (ucpd->tcpc_dev.fwnode)) +return PTR_ERR (ucpd->tcpc_dev.fwnode);
[Severity: High]
Should this check be if (!ucpd->tcpc_dev.fwnode) instead?
device_get_named_child_node() returns NULL on failure, not an error pointer, which would cause this check to falsely pass and proceed with a NULL fwnode.
Quoted 2 lines
drivers/usb/typec/tcpm/ucpd.c new file +2
-0+ +platform_set_drvdata (pdev, ucpd);
[ ... ]
drivers/usb/typec/tcpm/ucpd.c line 904
Quoted 5 lines
drivers/usb/typec/tcpm/ucpd.c new file +5
-0+ ucpd->orient_sw =fwnode_typec_switch_get (ucpd->tcpc_dev.fwnode); +if (IS_ERR (ucpd->orient_sw)) { +return dev_err_probe (dev,PTR_ERR (ucpd->orient_sw), +"Failed to get orientation switch\n" ); + }
[Severity: High]
Does this early return bypass the tcpm_put_fwnode error path, leaking the fwnode handle?
Additionally, it looks like typec_switch_put() is missing in both the probe error path and in driver removal.
drivers/usb/typec/tcpm/ucpd.c line 911
Quoted 7 lines
drivers/usb/typec/tcpm/ucpd.c new file +7
-0+ + ret =devm_request_threaded_irq (dev, irq,NULL , ucpd_irq, +IRQF_ONESHOT ,"ucpd" , ucpd); +if (ret <0 ) + goto tcpm_put_fwnode; + + ucpd->tcpm_port =tcpm_register_port (dev, &ucpd->tcpc_dev);
[Severity: High]
Could an interrupt fire right after it is requested but before ucpd->tcpm_port is fully registered?
tcpm_init() is called synchronously during port registration and unmasks hardware interrupts, which might cause ucpd_irq() to dereference a NULL ucpd->tcpm_port.
Quoted 8 lines
drivers/usb/typec/tcpm/ucpd.c new file +8
-0+if (IS_ERR (ucpd->tcpm_port)) { + ret =PTR_ERR (ucpd->tcpm_port); + goto tcpm_put_fwnode; + } + +return ret; + +tcpm_put_fwnode:
drivers/usb/typec/tcpm/ucpd.c line 929
Quoted 10 lines
drivers/usb/typec/tcpm/ucpd.c new file +10
-0+fwnode_handle_put (ucpd->tcpc_dev.fwnode); + +return ret; +} + +static void ucpd_remove (struct platform_device *pdev) +{ +struct ucpd *ucpd =platform_get_drvdata (pdev); + +tcpm_unregister_port (ucpd->tcpm_port);
[Severity: High]
Could this trigger a use-after-free if an interrupt fires during removal?
tcpm_unregister_port() destroys the internal workqueue synchronously, but hardware interrupts are not masked and the devm-managed IRQ is still active until after remove completes. If an interrupt fires during this window, ucpd_irq() will queue work on the destroyed TCPM workqueue.
Quoted 2 lines
drivers/usb/typec/tcpm/ucpd.c new file +2
-0+fwnode_handle_put (ucpd->tcpc_dev.fwnode); +}
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
PATCH 3/4 arm64: dts: st: Add UCPD node on stm32mp231
In reply to Marek VasutAdd ST UCPD Type-C block node on stm32mp231. The UCPD integrates the physical layer of the Power Delivery (PD), with CC signaling method, for operation with Type-C cables. Vbus and Vconn control is performed using an external chip, usually ST TCPP01/TCPP02/TCPP03 or similar. The UCPD Rp/Rd resistor trimming values are part of OTP, add the nvmem subnode and include a phandle to it.
---
Cc: Alexandre Torgue <[email protected]>
Cc: Conor Dooley <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>
Cc: Heikki Krogerus <[email protected]>
Cc: Krzysztof Kozlowski <[email protected]>
Cc: Maxime Coquelin <[email protected]>
Cc: Rob Herring <[email protected]>
Cc: Sebastian Reichel <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
--- arch/arm64/boot/dts/st/stm32mp231.dtsi | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
arch/arm64/boot/dts/st/stm32mp231.dtsi +20 -0
@@ -715,6 +715,21 @@ dcmipp: dcmipp@48030000 { status = "disabled"; }; + ucpd: phy@480a0000 { + compatible = "st,stm32mp25-ucpd"; + reg = <0x480a0000 0x1000>; + access-controllers = <&rifsc 69>; + clocks = <&rcc CK_BUS_USBTC>, <&rcc CK_KER_USBTC>; + clock-names = "apb", "ker"; + interrupts-extended = <&exti1 46 IRQ_TYPE_LEVEL_HIGH>; + nvmem-cells = <&ucpdtrim>; + nvmem-cell-names = "trim"; + power-domains = <&cluster_pd>; + resets = <&rcc USBTC_R>; + reset-names = "phy"; + status = "disabled"; + }; + sdmmc1: mmc@48220000 { compatible = "st,stm32mp25-sdmmc2", "arm,pl18x", "arm,primecell"; reg = <0x48220000 0x400>, <0x44230400 0x8>;
@@ -794,6 +809,11 @@ package-otp@1e8 { reg = <0x1e8 0x1>; bits = <0 3>; }; + + ucpdtrim: atrim3@1e8 { + reg = <0x1e8 0x4>; + bits = <4 16>; + }; }; rcc: clock-controller@44200000 {
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH 3/4] arm64: dts: st: Add UCPD node on stm32mp231
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Low] Duplicate unit-address for sibling NVMEM cell nodes 'package-otp@1e8' and 'atrim3@1e8'. --
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] Duplicate unit-address for sibling NVMEM cell nodes 'package-otp@1e8' and 'atrim3@1e8'. --
--- Patch [3]: [PATCH 3/4] arm64: dts: st: Add UCPD node on stm32mp231 --- commit 73383f2b2e9f887b4df27458fed89459eba124e2
Author: Marek Vasut <[email protected]>
arm64: dts: st: Add UCPD node on stm32mp231
This commit adds the ST UCPD Type-C block node to the stm32mp231 device tree. It also adds the UCPD Rp/Rd resistor trimming values as a new nvmem cell subnode pointing to the OTP registers.
Quoted 4 lines
arch/arm64/boot/dts/st/stm32mp231.dtsi +0
-0
[ ... ]
arch/arm64/boot/dts/st/stm32mp231.dtsi package-otp@1e8 { · line 813
Quoted 6 lines
arch/arm64/boot/dts/st/stm32mp231.dtsi +2
-0@@ -794,6 +809,11 @@ package-otp@1e8 { reg = <0x1e8 0x1>; bits = <0 3>; }; + + ucpdtrim: atrim3@1e8 {
[Severity: Low]
Does this duplicate unit address cause a dtc warning during the build?
Both package-otp and the newly added atrim3 node share the @1e8 unit address, which violates the device tree specification requirement for unique sibling unit addresses.
Quoted 6 lines
arch/arm64/boot/dts/st/stm32mp231.dtsi +3
-0+ reg = <0x1e8 0x4>; + bits = <4 16>; + }; }; rcc: clock-controller@44200000 {
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
PATCH 4/4 arm64: dts: st: Add UCPD node on stm32mp251
In reply to Marek VasutAdd ST UCPD Type-C block node on stm32mp251. The UCPD integrates the physical layer of the Power Delivery (PD), with CC signaling method, for operation with Type-C cables. Vbus and Vconn control is performed using an external chip, usually ST TCPP01/TCPP02/TCPP03 or similar. The UCPD Rp/Rd resistor trimming values are part of OTP, add the nvmem subnode and include a phandle to it.
---
Cc: Alexandre Torgue <[email protected]>
Cc: Conor Dooley <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>
Cc: Heikki Krogerus <[email protected]>
Cc: Krzysztof Kozlowski <[email protected]>
Cc: Maxime Coquelin <[email protected]>
Cc: Rob Herring <[email protected]>
Cc: Sebastian Reichel <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
--- arch/arm64/boot/dts/st/stm32mp251.dtsi | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
arch/arm64/boot/dts/st/stm32mp251.dtsi +20 -0
@@ -1637,6 +1637,21 @@ dcmipp: dcmipp@48030000 { status = "disabled"; }; + ucpd: phy@480a0000 { + compatible = "st,stm32mp25-ucpd"; + reg = <0x480a0000 0x1000>; + access-controllers = <&rifsc 69>; + clocks = <&rcc CK_BUS_USBTC>, <&rcc CK_KER_USBTC>; + clock-names = "apb", "ker"; + interrupts-extended = <&exti1 46 IRQ_TYPE_LEVEL_HIGH>; + nvmem-cells = <&ucpdtrim>; + nvmem-cell-names = "trim"; + power-domains = <&CLUSTER_PD>; + resets = <&rcc USBTC_R>; + reset-names = "phy"; + status = "disabled"; + }; + combophy: phy@480c0000 { compatible = "st,stm32mp25-combophy"; reg = <0x480c0000 0x1000>;
@@ -1781,6 +1796,11 @@ package-otp@1e8 { reg = <0x1e8 0x1>; bits = <0 3>; }; + + ucpdtrim: atrim3@1e8 { + reg = <0x1e8 0x4>; + bits = <4 16>; + }; }; hdp: pinctrl@44090000 {
Signature · 1 line
2.53.0
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [Low] Missing array bounds constraint for `vconn-gpios` property - [Low] Invalid 2-cell `interrupts`…
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Low] Missing array bounds constraint for vconn-gpios property
- [Low] Invalid 2-cell interrupts property in the GIC example
--
--- Patch [1]: [PATCH 1/4] dt-bindings: usb: Document ST UCPD --- commit aa08ea31b02f8625de21d6b8fefbebccc2a9ddcf
Author: Marek Vasut <[email protected]>
dt-bindings: usb: Document ST UCPD
This commit introduces the device tree binding documentation for the ST UCPD Type-C controller on STM32MP25. It describes the physical layer of Power Delivery, CC signaling, and required external Vbus/Vconn controls.
Quoted 4 lines
Documentation/devicetree/bindings/usb/st,stm32mp25-ucpd.yaml new file +0
-0
[ ... ]
Documentation/devicetree/bindings/usb/st,stm32mp25-ucpd.yaml line 56
Quoted 8 lines
Documentation/devicetree/bindings/usb/st,stm32mp25-ucpd.yaml new file +8
-0+ resets: + maxItems: 1 + + reset-names: + const: phy + + vconn-gpios: + description: GPIOs used to control CC1 and CC2 Vconn
[Severity: Low]
Should this property have a constraint like maxItems: 2?
Since the description specifies it controls CC1 and CC2 Vconn, adding an explicit array bounds constraint would prevent device tree validation from silently accepting an arbitrary number of GPIOs.
Quoted 3 lines
Documentation/devicetree/bindings/usb/st,stm32mp25-ucpd.yaml new file +3
-0+ + vdd33-supply: + description: Regulator that supplies the CC lines driver
[ ... ]
Documentation/devicetree/bindings/usb/st,stm32mp25-ucpd.yaml line 103
Quoted 13 lines
Documentation/devicetree/bindings/usb/st,stm32mp25-ucpd.yaml new file +13
-0+examples: + - | + #include <dt-bindings/clock/st,stm32mp25-rcc.h> + #include <dt-bindings/interrupt-controller/arm-gic.h> + #include <dt-bindings/reset/st,stm32mp25-rcc.h> + + ucpd: phy@480a0000 { + compatible = "st,stm32mp25-ucpd"; + reg = <0x480a0000 0x1000>; + access-controllers = <&rifsc 69>; + clocks = <&rcc CK_BUS_USBTC>, <&rcc CK_KER_USBTC>; + clock-names = "apb", "ker"; + interrupts = <46 IRQ_TYPE_LEVEL_HIGH>;
[Severity: Low]
Is this interrupt definition missing a cell?
The example includes arm-gic.h, which expects a 3-cell interrupt definition such as <GIC_SPI 46 IRQ_TYPE_LEVEL_HIGH>.
Using a 2-cell definition here might cause the dtbs_check validation to complain about standard interrupt controllers, or it might lead developers to copy an invalid configuration into their device trees.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Quoted 4 lines · Marek Vasut
Document ST UCPD Type-C block. The UCPD integrates the physical layer of the Power Delivery (PD), with CC signaling method, for operation with Type-C cables. Vbus and Vconn control is performed using an external chip, usually ST TCPP01/TCPP02/TCPP03 or similar.
Hi Marek, All,
I've sent a series for the complete case. Please check and review here:
https://lore.kernel.org/linux-usb/20260821-ucpd-host-fusb340-v7-2-rfc-v1-0-c5e27cbc0795@foss.st.com/
Thanks,
BR,
Fabrice
Quoted 182 lines
Signed-off-by Marek Vasut <[email protected]>---
Cc: Alexandre Torgue <[email protected]>
Cc: Conor Dooley <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>
Cc: Heikki Krogerus <[email protected]>
Cc: Krzysztof Kozlowski <[email protected]>
Cc: Maxime Coquelin <[email protected]>
Cc: Rob Herring <[email protected]>
Cc: Sebastian Reichel <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]--- .../bindings/usb/st,stm32mp25-ucpd.yaml | 154 ++++++++++++++++++ 1 file changed, 154 insertions(+) create mode 100644 Documentation/devicetree/bindings/usb/st,stm32mp25-ucpd.yamlDocumentation/devicetree/bindings/usb/st,stm32mp25-ucpd.yaml new file +154
-0@@ -0,0 +1,154 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/usb/st,stm32mp25-ucpd.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: STMicroelectronics STM32MP25 UCPD Type-C controller + +maintainers: + - Marek Vasut <[email protected]> + +description: + The UCPD integrates the physical layer of the Power Delivery (PD), + with CC signaling method, for operation with Type-C cables. Vbus + and Vconn control is performed using an external chip, usually + ST TCPP01/TCPP02/TCPP03 or similar. + +properties: + compatible: + const: st,stm32mp25-ucpd + + reg: + maxItems: 1 + + access-controllers: + maxItems: 1 + + clocks: + minItems: 2 + maxItems: 2 + + clock-names: + items: + - const: apb + - const: ker + + interrupts: + maxItems: 1 + + nvmem-cells: + maxItems: 1 + + nvmem-cell-names: + const: trim + + power-domains: + maxItems: 1 + + resets: + maxItems: 1 + + reset-names: + const: phy + + vconn-gpios: + description: GPIOs used to control CC1 and CC2 Vconn + + vdd33-supply: + description: Regulator that supplies the CC lines driver + + connector: + type: object + $ref: /schemas/connector/usb-connector.yaml# + unevaluatedProperties: false + + properties: + compatible: + const: usb-c-connector + + power-role: true + + typec-power-opmode: true + + required: + - compatible + +required: + - compatible + - reg + - clocks + - clock-names + - interrupts + - nvmem-cells + - nvmem-cell-names + - power-domains + - resets + - reset-names + +unevaluatedProperties: false + +examples: + - | + #include <dt-bindings/clock/st,stm32mp25-rcc.h> + #include <dt-bindings/interrupt-controller/arm-gic.h> + #include <dt-bindings/reset/st,stm32mp25-rcc.h> + + ucpd: phy@480a0000 { + compatible = "st,stm32mp25-ucpd"; + reg = <0x480a0000 0x1000>; + access-controllers = <&rifsc 69>; + clocks = <&rcc CK_BUS_USBTC>, <&rcc CK_KER_USBTC>; + clock-names = "apb", "ker"; + interrupts = <46 IRQ_TYPE_LEVEL_HIGH>; + nvmem-cells = <&ucpdtrim>; + nvmem-cell-names = "trim"; + power-domains = <&cluster_pd>; + resets = <&rcc USBTC_R>; + reset-names = "phy"; + + vconn-gpios = <&tcpp 0 0>, <&tcpp 1 0>; + vdd33-supply = <&scmi_vdd33ucpd>; + + connector { + compatible = "usb-c-connector"; + label = "USB-C"; + data-role = "dual"; + power-role = "source"; + self-powered; + vbus-gpios = <&gpioa 10 0>; + vbus-supply = <®_usbc_vbus>; + + altmodes { + displayport { + svid = /bits/ 16 <0xff01>; + vdo = <0xffffffff>; + }; + }; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@0 { + reg = <0>; + usbc0_hs_ep: endpoint { + remote-endpoint = <&usb_drd0_hs_ep>; + }; + }; + port@1 { + reg = <1>; + usbc0_ss_ep: endpoint { + remote-endpoint = <&usb_drd0_ss_ep>; + }; + }; + + port@2 { + reg = <2>; + usbc0_sbu_ep: endpoint { + remote-endpoint = <&usb_sbu_ep>; + }; + }; + }; + }; + };
Quoted 10 lines · Fabrice Gasnier
Quoted 4 lines · Marek Vasut
Document ST UCPD Type-C block. The UCPD integrates the physical layer of the Power Delivery (PD), with CC signaling method, for operation with Type-C cables. Vbus and Vconn control is performed using an external chip, usually ST TCPP01/TCPP02/TCPP03 or similar.
Hi Marek, All,
I've sent a series for the complete case. Please check and review here:
https://lore.kernel.org/linux-usb/20260821-ucpd-host-fusb340-v7-2-rfc-v1-0-c5e27cbc0795@foss.st.com/
What is the difference between this driver and the ^ driver ?
Why is this driver not covering "the complete case" , what is missing here and not missing there ?
Quoted 7 lines · Marek Vasut
Quoted 6 lines · Fabrice Gasnier
Quoted 4 lines · Marek Vasut
Document ST UCPD Type-C block. The UCPD integrates the physical layer of the Power Delivery (PD), with CC signaling method, for operation with Type-C cables. Vbus and Vconn control is performed using an external chip, usually ST TCPP01/TCPP02/TCPP03 or similar.
Quoted 8 lines
Quoted 5 lines
Hi Marek, All,
I've sent a series for the complete case. Please check and review here:
https://lore.kernel.org/linux-usb/20260821-ucpd-host-fusb340-v7-2-rfc-
[email protected]/What is the difference between this driver and the ^ driver ?
Hello Marek,
That includes the TCCP I2C driver (and an example on ST boards).
Quoted 2 lines
Why is this driver not covering "the complete case" , what is missing here and not missing there ?
I intended to show a complete case, e.g. UCPD controller driver and external TCPP I2C protection chip driver. The TCPP is a companion, complementary, e.g. provider/consumer relationship.
You've pointed some "horribleness" there. I guess you talk about the straight forward approach e.g. EXPORT_SYMBOL() macros. That's an on-going work, a prototype. I could have sent as an RFC. I wanted to be transparent, so the correct level of APIs gets used.
You propose to turn the TCPP into a GPIO chip ? That seems smart, at least for the CC lines switches. What about Vbus and Vconn, it could also fit regulator API ?
There are various functions, the bindings should be extensible enough for later use of additional functions. I'm thinking of:
- Over-current events for Vbus & Vconn
Could be represented as interrupt controller ?
Or could benefit from a regulator notifier (if used) ?
- Vbus sensing
My point is that, that can impact the dt-bindings or functionality. Sending UCPD driver only, without the TCCP binding & driver, I find it is a bit hard to review or test at my end without having a more complete view.
I'm not sure which way you'd like to proceed ?
Best Regards,
Fabrice
On 8/26/26 3:24 PM, Fabrice Gasnier wrote:
Hello Fabrice,
Quoted 14 lines
Quoted 6 lines
Quoted 3 lines
I've sent a series for the complete case. Please check and review here:
https://lore.kernel.org/linux-usb/20260821-ucpd-host-fusb340-v7-2-rfc-
[email protected]/What is the difference between this driver and the ^ driver ?
Hello Marek,
That includes the TCCP I2C driver (and an example on ST boards).
Quoted 2 lines
Why is this driver not covering "the complete case" , what is missing here and not missing there ?
Quoted 7 lines
I intended to show a complete case, e.g. UCPD controller driver and external TCPP I2C protection chip driver. The TCPP is a companion, complementary, e.g. provider/consumer relationship.
You've pointed some "horribleness" there. I guess you talk about the straight forward approach e.g.
EXPORT_SYMBOL()macros. That's an on-going work, a prototype. I could have sent as an RFC.
Yes please.
Quoted 3 lines
I wanted to be transparent, so the correct level of APIs gets used.
You propose to turn the TCPP into a GPIO chip ?
I think yes, it is after all four flip switches on I2C.
Quoted 2 lines
That seems smart, at least for the CC lines switches. What about Vbus and Vconn, it could also fit regulator API ?
It would, but, aren't those also flip switches ?
It seems to me, that TCPP02/03 can enable/disable Vconn on CC1/CC2 (that sound like two GPIOs), enable/disable gate driver (GPIO?) and enable/disable gate source (GPIO?) .
Quoted 6 lines
There are various functions, the bindings should be extensible enough for later use of additional functions. I'm thinking of:
- Over-current events for Vbus & Vconn
Could be represented as interrupt controller ?
Or could benefit from a regulator notifier (if used) ?
- Vbus sensing
Could extcon cover those ?
Quoted 6 lines
My point is that, that can impact the dt-bindings or functionality. Sending UCPD driver only, without the TCCP binding & driver, I find it is a bit hard to review or test at my end without having a more complete view.
I'm not sure which way you'd like to proceed ?
I am wondering whether maybe we should slow down a bit, get USB sorted out and upstream first, and focus on UCPD/TCPP as the second step (not in parallel to USB) ?
Quoted 6 lines · Marek Vasut
Document ST UCPD Type-C block. The UCPD integrates the physical layer of the Power Delivery (PD), with CC signaling method, for operation with Type-C cables. Vbus and Vconn control is performed using an external chip, usually ST TCPP01/TCPP02/TCPP03 or similar.
Signed-off-by Marek Vasut <[email protected]>
Unresolved Sashiko comments.
Best regards,
Krzysztof