usb: typec: add CIX Type-C PD controller driver
Subsystems (5)
Gary Yang
maintainercover usb: typec: add CIX Type-C PD controller driver
This series adds a Type-C PD controller driver for CIX platforms and enables it on the Radxa Orion O6.
The first supported controller is the Realtek RTS5453H, a stand-alone port controller: the CC and USB Power Delivery state machines run in its firmware and are configured through vendor registers rather than the TCPC register interface, so it cannot be driven by the tcpm framework. The driver translates the controller status registers into Type-C class notifications and drives the platform PHY's orientation switch and mode mux.
The driver is named after the CIX platform integration rather than the RTS5453H so that further register-compatible PD controllers can be supported without renaming it.
Patch 1 adds the devicetree binding, patch 2 adds the driver and its MAINTAINERS entry, patch 3 fixes the I2C bus #address-cells/#size-cells on Sky1 so that child devices can be described on the buses, and patch 4 adds the two controllers and the I2C1 pinmux to the Orion O6 board.
Orientation switching and USB/DisplayPort lane muxing are performed by the platform combo PHY. That PHY driver is not upstream yet, so the DTS does not link the connector to it in this series; the ports are still registered and their state is reported through the Type-C class.
Tested on a Radxa Orion O6 (Sky1): attach/detach, USB-only and DP-only alt modes, cable orientation detection and HPD reporting all work.
Gary Yang (4):
dt-bindings: usb: add Realtek RTS5453H Type-C port controller
usb: typec: add CIX Type-C PD controller driver
arm64: dts: cix: fix I2C bus address and size cells on Sky1
arm64: dts: cix: add RTS5453 PD controllers to Orion O6
.../bindings/usb/realtek,rts5453h.yaml | 126 +++ MAINTAINERS | 7 + arch/arm64/boot/dts/cix/sky1-orion-o6.dts | 51 ++ arch/arm64/boot/dts/cix/sky1.dtsi | 16 + drivers/usb/typec/Kconfig | 11 + drivers/usb/typec/Makefile | 1 + drivers/usb/typec/cix_pd.c | 777 ++++++++++++++++++ 7 files changed, 989 insertions(+) create mode 100644 Documentation/devicetree/bindings/usb/realtek,rts5453h.yaml create mode 100644 drivers/usb/typec/cix_pd.c
base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
Signature · 1 line
2.50.1
Gary Yang
maintainerPATCH 1/4 dt-bindings: usb: add Realtek RTS5453H Type-C port controller
Document the Realtek RTS5453H stand-alone USB Type-C port controller. The controller is connected over I2C and manages a single USB Type-C connector, described with the generic USB connector binding.
The connector's OF graph links to the Type-C orientation switch and mode mux provided by the platform PHY.
--- .../bindings/usb/realtek,rts5453h.yaml | 126 ++++++++++++++++++ 1 file changed, 126 insertions(+) create mode 100644 Documentation/devicetree/bindings/usb/realtek,rts5453h.yaml
Documentation/devicetree/bindings/usb/realtek,rts5453h.yaml new file +126 -0
@@ -0,0 +1,126 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/usb/realtek,rts5453h.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Realtek RTS5453H USB Type-C port controller + +description: | + The RTS5453H is a stand-alone USB Type-C port controller with USB + Power Delivery support. It is controlled over I2C and reports + changes of the port state through an interrupt line. + + Orientation switching and USB/DisplayPort lane muxing are performed by + the platform PHY. The controller finds the Type-C switch and mux + through the OF graph of its connector node. + +maintainers: + - Gary Yang <[email protected]> + +properties: + compatible: + const: realtek,rts5453h + + reg: + maxItems: 1 + + '#address-cells': + const: 1 + + '#size-cells': + const: 0 + + interrupts: + maxItems: 1 + +patternProperties: + '^connector@[0-9a-f]+$': + type: object + $ref: /schemas/connector/usb-connector.yaml# + unevaluatedProperties: false + description: + The USB Type-C connector managed by this controller. + + required: + - reg + - data-role + - power-role + - try-power-role + +required: + - compatible + - reg + - '#address-cells' + - '#size-cells' + - interrupts + +additionalProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/irq.h> + + i2c { + #address-cells = <1>; + #size-cells = <0>; + + typec@30 { + compatible = "realtek,rts5453h"; + reg = <0x30>; + #address-cells = <1>; + #size-cells = <0>; + interrupt-parent = <&gpio0>; + interrupts = <8 IRQ_TYPE_LEVEL_LOW>; + + connector@0 { + compatible = "usb-c-connector"; + reg = <0>; + data-role = "host"; + power-role = "source"; + try-power-role = "source"; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@0 { + reg = <0>; + + typec_hs_ep: endpoint { + remote-endpoint = <&usb_hs_ep>; + }; + }; + + port@1 { + reg = <1>; + + typec_ss_ep: endpoint { + remote-endpoint = <&usb_ss_ep>; + }; + }; + }; + }; + }; + }; + + usb { + usb-role-switch; + + port { + usb_hs_ep: endpoint { + remote-endpoint = <&typec_hs_ep>; + }; + }; + }; + + usb-mux { + orientation-switch; + mode-switch; + + port { + usb_ss_ep: endpoint { + remote-endpoint = <&typec_ss_ep>; + }; + }; + };
Signature · 1 line
2.50.1
Gary Yang
maintainerPATCH 3/4 arm64: dts: cix: fix I2C bus address and size cells on Sky1
In reply to Gary YangThe I2C controller nodes inherit #address-cells = <2> and #size-cells = <2> from the soc@0 bus, but I2C child devices always use a single-cell address and no size. With the inherited values every child node triggers a reg_format warning, and a device described on the bus would be decoded with the wrong address layout.
Set #address-cells = <1> and #size-cells = <0> on all eight I2C controllers, matching the I3C nodes that already do so.
--- arch/arm64/boot/dts/cix/sky1.dtsi | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
arch/arm64/boot/dts/cix/sky1.dtsi +16 -0
@@ -290,6 +290,8 @@ soc@0 { i2c0: i2c@4010000 { compatible = "cdns,i2c-r1p14"; reg = <0x0 0x04010000 0x0 0x10000>; + #address-cells = <1>; + #size-cells = <0>; clock-frequency = <400000>; clocks = <&scmi_clk CLK_TREE_FCH_I2C0_APB>; interrupts = <GIC_SPI 286 IRQ_TYPE_LEVEL_HIGH 0>;
@@ -299,6 +301,8 @@ i2c0: i2c@4010000 { i2c1: i2c@4020000 { compatible = "cdns,i2c-r1p14"; reg = <0x0 0x04020000 0x0 0x10000>; + #address-cells = <1>; + #size-cells = <0>; clock-frequency = <400000>; clocks = <&scmi_clk CLK_TREE_FCH_I2C1_APB>; interrupts = <GIC_SPI 287 IRQ_TYPE_LEVEL_HIGH 0>;
@@ -308,6 +312,8 @@ i2c1: i2c@4020000 { i2c2: i2c@4030000 { compatible = "cdns,i2c-r1p14"; reg = <0x0 0x04030000 0x0 0x10000>; + #address-cells = <1>; + #size-cells = <0>; clock-frequency = <400000>; clocks = <&scmi_clk CLK_TREE_FCH_I2C2_APB>; interrupts = <GIC_SPI 288 IRQ_TYPE_LEVEL_HIGH 0>;
@@ -317,6 +323,8 @@ i2c2: i2c@4030000 { i2c3: i2c@4040000 { compatible = "cdns,i2c-r1p14"; reg = <0x0 0x04040000 0x0 0x10000>; + #address-cells = <1>; + #size-cells = <0>; clock-frequency = <400000>; clocks = <&scmi_clk CLK_TREE_FCH_I2C3_APB>; interrupts = <GIC_SPI 289 IRQ_TYPE_LEVEL_HIGH 0>;
@@ -326,6 +334,8 @@ i2c3: i2c@4040000 { i2c4: i2c@4050000 { compatible = "cdns,i2c-r1p14"; reg = <0x0 0x04050000 0x0 0x10000>; + #address-cells = <1>; + #size-cells = <0>; clock-frequency = <400000>; clocks = <&scmi_clk CLK_TREE_FCH_I2C4_APB>; interrupts = <GIC_SPI 290 IRQ_TYPE_LEVEL_HIGH 0>;
@@ -335,6 +345,8 @@ i2c4: i2c@4050000 { i2c5: i2c@4060000 { compatible = "cdns,i2c-r1p14"; reg = <0x0 0x04060000 0x0 0x10000>; + #address-cells = <1>; + #size-cells = <0>; clock-frequency = <400000>; clocks = <&scmi_clk CLK_TREE_FCH_I2C5_APB>; interrupts = <GIC_SPI 291 IRQ_TYPE_LEVEL_HIGH 0>;
@@ -344,6 +356,8 @@ i2c5: i2c@4060000 { i2c6: i2c@4070000 { compatible = "cdns,i2c-r1p14"; reg = <0x0 0x04070000 0x0 0x10000>; + #address-cells = <1>; + #size-cells = <0>; clock-frequency = <400000>; clocks = <&scmi_clk CLK_TREE_FCH_I2C6_APB>; interrupts = <GIC_SPI 292 IRQ_TYPE_LEVEL_HIGH 0>;
@@ -353,6 +367,8 @@ i2c6: i2c@4070000 { i2c7: i2c@4080000 { compatible = "cdns,i2c-r1p14"; reg = <0x0 0x04080000 0x0 0x10000>; + #address-cells = <1>; + #size-cells = <0>; clock-frequency = <400000>; clocks = <&scmi_clk CLK_TREE_FCH_I2C7_APB>; interrupts = <GIC_SPI 293 IRQ_TYPE_LEVEL_HIGH 0>;
Signature · 1 line
2.50.1
Gary Yang
maintainerPATCH 4/4 arm64: dts: cix: add RTS5453 PD controllers to Orion O6
In reply to Gary YangDescribe the two Realtek RTS5453H port controllers on the Orion O6 I2C1 bus and add the I2C1 pin configuration.
The controllers route orientation and DisplayPort mode changes through the USB/DP combo PHY lane switches, but that PHY support is not upstream yet, so the connector graph endpoints are left out for now. The Type-C ports are still registered and reported, only the lane switching is deferred until the PHY nodes are available.
Both controllers report through the same level-triggered interrupt line, which the driver handles with a shared interrupt. The I2C bus runs at 100 kHz because the RTS5453H I2C interface does not support higher rates.
--- arch/arm64/boot/dts/cix/sky1-orion-o6.dts | 51 +++++++++++++++++++++++ 1 file changed, 51 insertions(+)
arch/arm64/boot/dts/cix/sky1-orion-o6.dts +51 -0
@@ -52,6 +52,48 @@ &fch_gpio3 { status = "okay"; }; +&i2c1 { + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_fch_i2c1>; + clock-frequency = <100000>; + + status = "okay"; + + typec@30 { + compatible = "realtek,rts5453h"; + reg = <0x30>; + #address-cells = <1>; + #size-cells = <0>; + interrupt-parent = <&s5_gpio0>; + interrupts = <8 IRQ_TYPE_LEVEL_LOW>; + + connector@0 { + compatible = "usb-c-connector"; + reg = <0>; + data-role = "host"; + power-role = "source"; + try-power-role = "source"; + }; + }; + + typec@31 { + compatible = "realtek,rts5453h"; + reg = <0x31>; + #address-cells = <1>; + #size-cells = <0>; + interrupt-parent = <&s5_gpio0>; + interrupts = <8 IRQ_TYPE_LEVEL_LOW>; + + connector@2 { + compatible = "usb-c-connector"; + reg = <2>; + data-role = "host"; + power-role = "source"; + try-power-role = "source"; + }; + }; +}; + &iomuxc { pinctrl-names = "default"; pinctrl-0 = <&pinctrl_hog>;
@@ -66,6 +108,15 @@ pins { drive-strength = <8>; }; }; + + pinctrl_fch_i2c1: i2c1-cfg { + pins { + pinmux = <CIX_PAD_I2C1_CLK_FUNC_I2C1_CLK>, + <CIX_PAD_I2C1_SDA_FUNC_I2C1_SDA>; + bias-pull-up; + drive-strength = <12>; + }; + }; }; &iomuxc_s5 {
Signature · 1 line
2.50.1
Gary Yang
maintainerPATCH 2/4 usb: typec: add CIX Type-C PD controller driver
In reply to Gary YangAdd a driver for the CIX Type-C PD controller, which is connected over I2C and reports power, data and plug orientation changes through a level-triggered interrupt. The Realtek RTS5453H is the first supported device.
The controller runs the Type-C and PD state machines in firmware and exposes the current port status over I2C. The driver translates that into Type-C class notifications, driving the orientation switch and mode mux registered by the platform PHY for the DisplayPort alternate mode. A USB role switch is registered so that the USB controller can follow the negotiated data role.
Several controller instances can share a single interrupt line, so each instance registers a handler on it with IRQF_SHARED and only accesses its own registers.
The driver is named after the CIX platform integration rather than the RTS5453H so that further register-compatible PD controllers can be supported without renaming it.
--- MAINTAINERS | 7 + drivers/usb/typec/Kconfig | 11 + drivers/usb/typec/Makefile | 1 + drivers/usb/typec/cix_pd.c | 777 +++++++++++++++++++++++++++++++++++++ 4 files changed, 796 insertions(+) create mode 100644 drivers/usb/typec/cix_pd.c
MAINTAINERS +7 -0
@@ -6522,6 +6522,13 @@ M: Satish Kharat <[email protected]> S: Supported F: drivers/infiniband/hw/usnic/ +CIX USB TYPE-C PD CONTROLLER +M: Gary Yang <[email protected]> +L: [email protected] +S: Maintained +F: Documentation/devicetree/bindings/usb/realtek,rts5453h.yaml +F: drivers/usb/typec/cix_pd.c + CLANG CONTEXT ANALYSIS M: Marco Elver <[email protected]> R: Bart Van Assche <[email protected]>
drivers/usb/typec/Kconfig +11 -0
@@ -110,6 +110,17 @@ config TYPEC_WUSB3801 If you choose to build this driver as a dynamically linked module, the module will be called wusb3801.ko. +config TYPEC_CIX_PD + tristate "CIX Type-C PD controller driver" + depends on I2C + select REGMAP_I2C + help + Say Y or M here if your system has a CIX Type-C PD controller. + This driver currently supports the Realtek RTS5453H controller. + + If you choose to build this driver as a dynamically linked module, the + module will be called cix_pd.ko. + source "drivers/usb/typec/mux/Kconfig" source "drivers/usb/typec/altmodes/Kconfig"
drivers/usb/typec/Makefile +1 -0
@@ -11,4 +11,5 @@ obj-$(CONFIG_TYPEC_HD3SS3220) += hd3ss3220.o obj-$(CONFIG_TYPEC_STUSB160X) += stusb160x.o obj-$(CONFIG_TYPEC_RT1719) += rt1719.o obj-$(CONFIG_TYPEC_WUSB3801) += wusb3801.o +obj-$(CONFIG_TYPEC_CIX_PD) += cix_pd.o obj-$(CONFIG_TYPEC) += mux/
drivers/usb/typec/cix_pd.c new file +777 -0
777 lines not on this page · raw message
Signature · 1 line
2.50.1
[email protected]
AI reviewRe: [PATCH 1/4] dt-bindings: usb: add Realtek RTS5453H Type-C port controller
In reply to Gary YangThank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [Low] dt-bindings: usb: rts5453h uses addressed connector pattern for single port - [Low] dt-bindings: usb…
Thank you for your contribution! Sashiko AI review found 2 potential issues to consider:
- [Low] dt-bindings: usb: rts5453h uses addressed connector pattern for single port
- [Low] dt-bindings: usb: rts5453h unconditionally requires try-power-role
--
commit bf789180bfcb329a121d357c95111fa527217ccf
Author: Gary Yang <[email protected]>
dt-bindings: usb: add Realtek RTS5453H Type-C port controller
This commit adds the Device Tree binding schema for the Realtek RTS5453H I2C-connected USB Type-C port controller.
Quoted 6 lines
Documentation/devicetree/bindings/usb/realtek,rts5453h.yaml new file +0
-0@@ -0,0 +1,126 @@
[ ... ]
Quoted 12 lines
Documentation/devicetree/bindings/usb/realtek,rts5453h.yaml new file +12
-0+ '#address-cells': + const: 1 + + '#size-cells': + const: 0 + + interrupts: + maxItems: 1 + +patternProperties: + '^connector@[0-9a-f]+$': + type: object
Documentation/devicetree/bindings/usb/realtek,rts5453h.yaml line 49
Quoted 10 lines
Documentation/devicetree/bindings/usb/realtek,rts5453h.yaml new file +10
-0+ $ref: /schemas/connector/usb-connector.yaml# + unevaluatedProperties: false + description: + The USB Type-C connector managed by this controller. + + required: + - reg + - data-role + - power-role + - try-power-role
[Severity: Low]
Should try-power-role be optional here instead of required?
In usb-connector.yaml and typec_get_fw_cap(), try-power-role only applies when power-role is "dual" and is optional even for dual-role ports. Requiring it unconditionally forces fixed source-only or sink-only ports (including the example below with power-role = "source") and dual-role ports without a preferred role to specify an inapplicable property.
Documentation/devicetree/bindings/usb/realtek,rts5453h.yaml line 56
Quoted 7 lines
Documentation/devicetree/bindings/usb/realtek,rts5453h.yaml new file +7
-0+ +required: + - compatible + - reg + - '#address-cells' + - '#size-cells' + - interrupts
[Severity: Low]
Since the RTS5453H manages a single USB Type-C connector, should this define a single "connector" object property in properties (and list "connector" in required) instead of using patternProperties with unit addresses?
Using '^connector@[0-9a-f]+$' with '#address-cells', '#size-cells', and reg allows multiple connector child nodes at arbitrary unit addresses while leaving the connector node itself optional on the controller.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 12 potential issues to consider: - [High] usb: typec: cix_pd: unbalanced disable_irq() on shared IRQ in cix_pd_remove() - [Medium] usb…
Thank you for your contribution! Sashiko AI review found 12 potential issues to consider:
- [High] usb: typec: cix_pd: unbalanced disable_irq() on shared IRQ in cix_pd_remove()
- [Medium] usb: typec: cix_pd: NULL altmode passed to mux in cix_pd_typec_port_update()
- [Medium] usb: typec: cix_pd: invalid unconditional DP partner altmode registration
- [Medium] usb: typec: cix_pd: wrong USB 2.0 orientation and mux state in port update
- [Medium] usb: typec: cix_pd: role cached on switch failure and skipped on restore
- [Medium] usb: typec: Kconfig: missing USB_ROLE_SWITCH dependency for TYPEC_CIX_PD
- [Medium] usb: typec: cix_pd: missing .poweroff callback and broken PM state handling
- [Low] usb: typec: cix_pd: missing static qualifier on DEVICE_ATTR_RW() definition
- [Low] usb: typec: cix_pd: cix_pd_typec_parse_port_props() duplicates typec_get_fw_cap()
- [Low] usb: typec: cix_pd: deferred-probe churn and mux state in cix_pd_init_ports()
- [Low] usb: typec: cix_pd: non-static and undocumented disable_pd_interrupt sysfs attr
- [Low] usb: typec: cix_pd: positional struct i2c_device_id initializer in cix_pd_id
--
commit 580ec433cd2d8c9792fdacbbc473c28e5cbfb4c8
Author: Gary Yang <[email protected]>
usb: typec: add CIX Type-C PD controller driver
This commit adds an I2C driver for the CIX Type-C PD controller (initially supporting the Realtek RTS5453H) to report orientation, USB role, and DisplayPort alternate mode state to the Type-C class, mux, and USB role switch frameworks.
drivers/usb/typec/Kconfig config TYPEC_WUSB3801 · line 116
Quoted 12 lines
drivers/usb/typec/Kconfig +4
-0@@ -110,6 +110,17 @@ config TYPEC_WUSB3801 If you choose to build this driver as a dynamically linked module, the module will be called wusb3801.ko. +config TYPEC_CIX_PD + tristate "CIX Type-C PD controller driver" + depends on I2C + select REGMAP_I2C
[Severity: Medium]
Does TYPEC_CIX_PD need a dependency on USB_ROLE_SWITCH? Building with CONFIG_TYPEC_CIX_PD=y and CONFIG_USB_ROLE_SWITCH=m fails to link with undefined references to fwnode_usb_role_switch_get(), usb_role_switch_set_role(), and usb_role_switch_put(), while CONFIG_USB_ROLE_SWITCH=n causes fwnode_usb_role_switch_get() to return ERR_PTR(-ENODEV) and fail cix_pd_probe() unconditionally.
Quoted 5 lines
drivers/usb/typec/cix_pd.c new file +0
-0
[ ... ]
Quoted 71 lines
drivers/usb/typec/cix_pd.c new file +71
-0+static const struct typec_altmode_desc cix_pd_dp_altmode = { + .svid =USB_TYPEC_DP_SID , + .mode =USB_TYPEC_DP_MODE , +}; + +static int cix_pd_typec_port_update (struct cix_pd *typec) + struct typec_displayport_data *dp_data = &typec->dp_data; +enum typec_orientation orientation; +enum usb_role role; +bool connected; +int ret =0 ; + +if (!(typec->data_status[1 ] &USB3_2_CONNECTION ) && + !(typec->data_status[2 ] &DP_CONNECTION )) + orientation =TYPEC_ORIENTATION_NONE ; +else if (typec->data_status[1 ] &CONNECTION_ORIENTATION ) + orientation =TYPEC_ORIENTATION_REVERSE ; +else + orientation =TYPEC_ORIENTATION_NORMAL ; + + ret =typec_set_orientation (typec->port, orientation); +if (ret) +return ret; + +if (!(typec->data_status[1 ] &USB3_2_CONNECTION ) && + !(typec->data_status[1 ] &USB2_CONNECTION )) + role =USB_ROLE_NONE ; +else if (typec->data_status[1 ] &USB_DATA_ROLE ) + role =USB_ROLE_DEVICE ; +else + role =USB_ROLE_HOST ; + +if (typec->data_status[2 ] &DEBUG_ACCESSORY_ATTACHED ) +dev_err (typec->dev, +"debug accessory mode not supported, try another usb cable\n" ); + +/* +* Update the partner before building the mux state so that the DP +* alternate mode handed to the mux is always a registered one. +* Debug accessories are treated as not connected, since they are +* not supported. +*/ + connected = !(typec->data_status[2 ] &DEBUG_ACCESSORY_ATTACHED ) && + ((typec->data_status[1 ] & (USB2_CONNECTION |USB3_2_CONNECTION )) || + (typec->data_status[2 ] &DP_CONNECTION )); +if (!connected) { +if (typec->partner) { +dev_info (typec->dev,"typec port(%d): unregister partner\n" , + typec->id); +typec_unregister_altmode (typec->partner_altmode); + typec->partner_altmode =NULL ; +typec_unregister_partner (typec->partner); + typec->partner =NULL ; + } + }else { +if (!typec->partner) { +dev_info (typec->dev,"typec port(%d): register partner\n" , + typec->id); + typec->partner =typec_register_partner (typec->port, + &typec->desc); +if (IS_ERR (typec->partner)) { +dev_err (typec->dev, +"typec port(%d): failed to register partner: %ld\n" , + typec->id,PTR_ERR (typec->partner)); + typec->partner =NULL ; + } + } + +if (typec->partner && !typec->partner_altmode) { + typec->partner_altmode = + typec_partner_register_altmode(typec->partner,
drivers/usb/typec/cix_pd.c line 201
Quoted 10 lines
drivers/usb/typec/cix_pd.c new file +10
-0+ &cix_pd_dp_altmode); +if (IS_ERR (typec->partner_altmode)) { +dev_err (typec->dev, +"typec port(%d): failed to register DP altmode: %ld\n" , + typec->id, +PTR_ERR (typec->partner_altmode)); + typec->partner_altmode =NULL ; + } + } + }
[Severity: Medium]
Should typec->partner_altmode only be registered when DP_CONNECTION is set?
Calling typec_partner_register_altmode() for every connected partner exposes a DisplayPort alternate mode in sysfs even for plain USB 2.0 or USB 3.2 devices. In addition, cix_pd_dp_altmode leaves .vdo = 0 and the registration runs before typec_set_data_role(), so when CONFIG_TYPEC_DP_ALTMODE is enabled, dp_altmode_probe() fails with -EPROTO or -ENODEV on every attach. typec_altmode_update_active() is also never called on typec->partner_altmode, and cix_pd_typec_parse_port_props() does not set cap->no_mode_control = true even though firmware manages alternate modes autonomously.
Quoted 12 lines
drivers/usb/typec/cix_pd.c new file +12
-0+if ((typec->data_status[1 ] &USB3_2_CONNECTION ) && + (typec->data_status[2 ] &DP_CONNECTION )) { +/* usb + dp */ + dp_data->status =DP_STATUS_ENABLED ; +if (typec->data_status[2 ] &HPD_STATE ) + dp_data->status |=DP_STATUS_HPD_STATE ; +if (typec->data_status[2 ] &HPD_IRQ ) + dp_data->status |=DP_STATUS_IRQ_HPD ; + + typec->state.data = dp_data; + typec->state.mode =TYPEC_DP_STATE_D ; + typec->state.alt = typec->partner_altmode;
drivers/usb/typec/cix_pd.c line 224
Quoted 10 lines
drivers/usb/typec/cix_pd.c new file +10
-0+ }else if (typec->data_status[2 ] &DP_CONNECTION ) { +/* dp only */ + dp_data->status =DP_STATUS_ENABLED ; +if (typec->data_status[2 ] &HPD_STATE ) + dp_data->status |=DP_STATUS_HPD_STATE ; +if (typec->data_status[2 ] &HPD_IRQ ) + dp_data->status |=DP_STATUS_IRQ_HPD ; + typec->state.data = dp_data; + typec->state.mode =TYPEC_DP_STATE_E ; + typec->state.alt = typec->partner_altmode;
[Severity: Medium]
Can this pass a NULL state.alt to typec_mux_set() when state.mode is TYPEC_DP_STATE_D or TYPEC_DP_STATE_E?
If typec_register_partner() or typec_partner_register_altmode() fails, or if DEBUG_ACCESSORY_ATTACHED is set alongside DP_CONNECTION, typec->partner_altmode is NULL, but execution continues into the DP_CONNECTION branches and calls typec_mux_set() with a modal state and state.alt == NULL, which mux drivers dereference directly (e.g. state->alt->svid). DEBUG_ACCESSORY_ATTACHED is also ignored when computing orientation, role, and mux state above, despite the comment stating that debug accessories are treated as not connected.
drivers/usb/typec/cix_pd.c line 237
Quoted 13 lines
drivers/usb/typec/cix_pd.c new file +13
-0+ }else if (typec->data_status[1 ] &USB3_2_CONNECTION ) { +/* usb only */ + dp_data->status =0 ; + typec->state.mode =TYPEC_STATE_USB ; + typec->state.alt =NULL ; + typec->state.data =NULL ; + }else { +/* disconnect */ + dp_data->status =0 ; + typec->state.mode =TYPEC_STATE_SAFE ; + typec->state.alt =NULL ; + typec->state.data =NULL ; + }
[Severity: Medium]
Does cix_pd_typec_port_update() mishandle USB 2.0-only connections in the orientation and mux state checks?
When USB2_CONNECTION is set without USB3_2_CONNECTION or DP_CONNECTION, connected is true and a partner is registered, but the orientation check at the top of the function sets TYPEC_ORIENTATION_NONE and the mux check here falls into the disconnect branch (TYPEC_STATE_SAFE) and logs "disconnect state" on attach.
Quoted 11 lines
drivers/usb/typec/cix_pd.c new file +11
-0+ ret =typec_mux_set (typec->mux, &typec->state); +if (ret) +return ret; + +if ((typec->data_status[3 ] &POWER_MASK ) ==POWER_SOURCE ) { +typec_set_pwr_role (typec->port,TYPEC_SOURCE ); + }else if ((typec->data_status[3 ] &POWER_MASK ) ==POWER_SINK ) { +typec_set_pwr_role (typec->port,TYPEC_SINK ); + }else { +dev_dbg (typec->dev,"typec port(%d): unknown power state %d\n" , + typec->id, typec->data_status[3 ]);
drivers/usb/typec/cix_pd.c line 259
Quoted 10 lines
drivers/usb/typec/cix_pd.c new file +10
-0+ } + +if (typec->role != role) { + typec->role = role; + ret =usb_role_switch_set_role (typec->role_sw, role); +if (role ==USB_ROLE_DEVICE ) +typec_set_data_role (typec->port,TYPEC_DEVICE ); +else if (role ==USB_ROLE_HOST ) +typec_set_data_role (typec->port,TYPEC_HOST ); + }
[Severity: Medium]
If usb_role_switch_set_role() fails, does caching typec->role = role first prevent later status updates from retrying the role switch? It also calls typec_set_data_role() despite the failure, and during hibernation restore (cix_pd_restore() -> cix_pd_event_handler()), usb_role_switch_set_role() will be skipped if the post-hibernation role matches the pre-hibernation typec->role.
[ ... ]
Quoted 29 lines
drivers/usb/typec/cix_pd.c new file +29
-0+static int cix_pd_typec_parse_port_props (struct typec_capability *cap, +struct fwnode_handle *fwnode, +struct device *dev) +{ +const char *buf; +int ret; + +memset (cap,0 ,sizeof (*cap)); + ret =fwnode_property_read_string (fwnode,"power-role" , &buf); +if (ret) { +dev_err (dev,"power-role not found: %d\n" , ret); +return ret; + } + ret =typec_find_port_power_role (buf); +if (ret <0 ) +return ret; + cap->type = ret; + ret =fwnode_property_read_string (fwnode,"data-role" , &buf); +if (ret) { +dev_err (dev,"data-role not found: %d\n" , ret); +return ret; + } + ret =typec_find_port_data_role (buf); +if (ret <0 ) +return ret; + cap->data = ret; + ret =fwnode_property_read_string (fwnode,"try-power-role" , &buf); +if (ret) { +dev_err (dev,"try-power-role not found: %d\n" , ret);
drivers/usb/typec/cix_pd.c line 407
Quoted 10 lines
drivers/usb/typec/cix_pd.c new file +10
-0+return ret; + } + ret =typec_find_power_role (buf); +if (ret <0 ) +return ret; + cap->prefer_role = ret; + cap->fwnode =fwnode_handle_get (fwnode); + cap->orientation_aware =1 ; +return 0 ; +}
[Severity: Low]
Could this use the exported typec_get_fw_cap() helper instead of open-coding the fwnode property parsing? cix_pd_typec_parse_port_props() also requires "try-power-role" and "data-role" unconditionally, whereas typec_get_fw_cap() and usb-connector.yaml treat "data-role" as optional and only parse "try-power-role" for DRP ports.
[ ... ]
Quoted 9 lines
drivers/usb/typec/cix_pd.c new file +9
-0+static void cix_pd_unregister_ports (struct cix_pd *typec) +{ +if (!IS_ERR_OR_NULL (typec->port)) { + typec->state.alt =NULL ; + typec->state.mode =TYPEC_STATE_USB ; + typec->state.data =NULL ; +usb_role_switch_set_role (typec->role_sw,USB_ROLE_NONE ); +typec_set_orientation (typec->port,TYPEC_ORIENTATION_NONE ); +typec_mux_set (typec->mux, &typec->state);
[ ... ]
Quoted 2 lines
drivers/usb/typec/cix_pd.c new file +2
-0+static int cix_pd_init_ports (struct cix_pd *typec) +{
[ ... ]
Quoted 12 lines
drivers/usb/typec/cix_pd.c new file +12
-0+ typec->port =typec_register_port (dev, &typec->caps); +if (IS_ERR (typec->port)) { + ret =PTR_ERR (typec->port); + typec->port =NULL ; +dev_err (dev,"Failed to register port: %d\n" , ret); + goto unregister_ports; + } + + desc.roles = typec->caps.data; + typec->port_altmode =typec_port_register_altmode (typec->port, + &desc); +if (IS_ERR (typec->port_altmode)) {
drivers/usb/typec/cix_pd.c line 519
Quoted 10 lines
drivers/usb/typec/cix_pd.c new file +10
-0+ ret =PTR_ERR (typec->port_altmode); + typec->port_altmode =NULL ; +dev_err (dev,"Failed to register DP altmode: %d\n" , ret); + goto unregister_ports; + } + + ret =cix_pd_typec_get_handles (typec, fwnode, dev); +if (ret) + goto unregister_ports; + }
[Severity: Low]
Should cix_pd_typec_get_handles() be called before typec_register_port(), and should the port and altmode registration errors use dev_err_probe()?
typec_register_port() and typec_port_register_altmode() can return ERR_PTR(-EPROBE_DEFER), so dev_err() logs error messages on deferred probe, and deferring in cix_pd_typec_get_handles() after registering the port causes unnecessary sysfs registration and removal churn. Also, in cix_pd_unregister_ports(), should typec->state.mode be set to TYPEC_STATE_SAFE rather than TYPEC_STATE_USB when disconnecting the mux?
[ ... ]
Quoted 13 lines
drivers/usb/typec/cix_pd.c new file +13
-0+static void cix_pd_sync_irq (struct cix_pd *rts) +{ +bool disable = rts->pd_int_disabled || rts->suspended; + +if (!rts->irq_requested || rts->irq_disabled == disable) +return ; + + rts->irq_disabled = disable; +if (disable) +disable_irq (rts->irq); +else +enable_irq (rts->irq); +}
[ ... ]
Quoted 1 line
+DEVICE_ATTR_RW(disable_pd_interrupt);
[Severity: Low]
Should DEVICE_ATTR_RW(disable_pd_interrupt) be declared static so dev_attr_disable_pd_interrupt does not pollute the global namespace or trigger a -Wmissing-variable-declarations warning?
Also, this sysfs attribute is undocumented in Documentation/ABI/, is created via device_create_file() after device registration instead of .dev_groups (or debugfs for a compliance-test knob), and its show output ("enabled" / "disabled") is rejected with -EINVAL by kstrtobool() in disable_pd_interrupt_store().
Quoted 2 lines
drivers/usb/typec/cix_pd.c new file +2
-0+static int cix_pd_probe (struct i2c_client *client) +{
[ ... ]
Quoted 11 lines
drivers/usb/typec/cix_pd.c new file +11
-0+if (client->irq >0 ) { +irq_set_status_flags (client->irq,IRQ_DISABLE_UNLAZY ); + ret =request_threaded_irq (client->irq,NULL , cix_pd_irq_handle, +IRQF_SHARED |IRQF_ONESHOT , +dev_name (&client->dev), rts); +if (ret) { +dev_err (&client->dev,"failed to request irq: %d\n" , ret); + goto err_unregister_ports; + } + rts->irq_requested = true; + }
[ ... ]
Quoted 11 lines
drivers/usb/typec/cix_pd.c new file +11
-0+static void cix_pd_remove (struct i2c_client *client) +{ +struct cix_pd *rts =i2c_get_clientdata (client); + +device_remove_file (&client->dev, &dev_attr_disable_pd_interrupt); + +mutex_lock (&rts->irq_lock); +if (rts->irq_requested) { + rts->suspended = true; +cix_pd_sync_irq (rts); +if (rts->wake_enabled) {
drivers/usb/typec/cix_pd.c line 673
Quoted 10 lines
drivers/usb/typec/cix_pd.c new file +10
-0+disable_irq_wake (rts->irq); + rts->wake_enabled = false; + } +free_irq (rts->irq, rts); + rts->irq_requested = false; + } +mutex_unlock (&rts->irq_lock); + +cix_pd_unregister_ports (rts); +}
[Severity: High]
Does cix_pd_remove() leave the shared IRQ permanently disabled for all other controller instances sharing client->irq?
Because the interrupt is requested with IRQF_SHARED, calling cix_pd_sync_irq() in cix_pd_remove() (or earlier via disable_pd_interrupt_store()) calls disable_irq(rts->irq), which increments desc->depth on the shared irq_desc, and then free_irq() is called without a matching enable_irq(). When another instance remains registered on the shared line, __free_irq() does not call irq_shutdown(), leaving desc->depth elevated and the hardware interrupt masked forever for sibling ports.
More generally, calling disable_irq() in cix_pd_sync_irq() and setting IRQ_DISABLE_UNLAZY on a shared line affects all sibling instances:
disabling interrupts on one port via sysfs masks the line for all ports, and in cix_pd_suspend() calling disable_irq() with IRQ_DISABLE_UNLAZY masks the hardware IRQ before enable_irq_wake() (and increments desc->depth once per instance, so suspend_device_irq() cannot re-enable it when two instances share the line). Also, irq_clear_status_flags() is not called if request_threaded_irq() fails in cix_pd_probe(), and cix_pd_irq_handle() unconditionally acknowledges the interrupt and returns IRQ_HANDLED without checking whether that instance actually asserted the shared interrupt.
drivers/usb/typec/cix_pd.c line 684
Quoted 10 lines
drivers/usb/typec/cix_pd.c new file +10
-0+static const struct of_device_id cix_pd_of_match[] = { + { .compatible ="realtek,rts5453h" , }, + {} +}; +MODULE_DEVICE_TABLE (of, cix_pd_of_match); + +static const struct i2c_device_id cix_pd_id[] = { + {"rts5453h" }, + {} +};
[Severity: Low]
This isn't a bug, but I2C subsystem conventions prefer named initializers for new struct i2c_device_id entries (i.e. { .name = "rts5453h" }).
[ ... ]
Quoted 17 lines
drivers/usb/typec/cix_pd.c new file +17
-0+static int __maybe_unused cix_pd_restore (struct device *dev) +{ +struct i2c_client *client =to_i2c_client (dev); +struct cix_pd *rts =i2c_get_clientdata (client); +int ret; + + ret =cix_pd_resume (dev); +if (ret) +return ret; + +/* Re-trigger PD event if PD event occurs during std */ + ret =cix_pd_event_handler (rts,0 ); +if (ret) +dev_err (&client->dev,"typec event handling error %d\n" , ret); + +return ret; +}
[ ... ]
drivers/usb/typec/cix_pd.c line 758
Quoted 7 lines
drivers/usb/typec/cix_pd.c new file +7
-0+static const struct dev_pm_ops cix_pd_pm_ops = { + .suspend =pm_sleep_ptr (cix_pd_suspend), + .resume =pm_sleep_ptr (cix_pd_resume), + .freeze =pm_sleep_ptr (cix_pd_suspend), + .thaw =pm_sleep_ptr (cix_pd_resume), + .restore =pm_sleep_ptr (cix_pd_restore), +};
[Severity: Medium]
Is cix_pd_pm_ops missing a .poweroff callback for hibernation?
During hibernation, the PM core runs .freeze, creates the image, runs .thaw (cix_pd_resume(), which clears rts->suspended, disables wake, and re-enables the IRQ), and then runs .poweroff; without .poweroff, the IRQ is left enabled and wakeup is not armed when powering off. In addition, cix_pd_restore() returns the internal -ESHUTDOWN error code from cix_pd_event_handler() directly to the PM core instead of translating it to -EIO as cix_pd_probe() does, and cix_pd_resume() does not call cix_pd_event_handler() to refresh port state after S3 suspend.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
[email protected]
AI reviewRe: [PATCH 3/4] arm64: dts: cix: fix I2C bus address and size cells on Sky1
In reply to Gary YangSashiko has reviewed this patch and found no issues.
Quoted 6 lines
The I2C controller nodes inherit #address-cells = <2> and #size-cells = <2> from the soc@0 bus, but I2C child devices always use a single-cell address and no size. With the inherited values every child node triggers a
reg_formatwarning, and a device described on the bus would be decoded with the wrong address layout.
Quoted 6 lines
Set #address-cells = <1> and #size-cells = <0> on all eight I2C controllers, matching the I3C nodes that already do so.
Fixes fad32e8ac460 ("arm64: dts: cix: add DT nodes for all I2C and I3C ports for sky1")Signed-off-by Gary Yang <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
[email protected]
AI reviewRe: [PATCH 4/4] arm64: dts: cix: add RTS5453 PD controllers to Orion O6
In reply to Gary YangSashiko has reviewed this patch and found no issues.
Quoted 9 lines
Describe the two Realtek RTS5453H port controllers on the Orion O6 I2C1 bus and add the I2C1 pin configuration.
The controllers route orientation and DisplayPort mode changes through the USB/DP combo PHY lane switches, but that PHY support is not upstream yet, so the connector graph endpoints are left out for now. The Type-C ports are still registered and reported, only the lane switching is deferred until the PHY nodes are available.
Quoted 6 lines
Both controllers report through the same level-triggered interrupt line, which the driver handles with a shared interrupt. The I2C bus runs at 100 kHz because the RTS5453H I2C interface does not support higher rates.
Signed-off-by Gary Yang <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=4
Re: [PATCH 3/4] arm64: dts: cix: fix I2C bus address and size cells on Sky1
In reply to Gary YangQuoted 6 lines · Gary Yang
The I2C controller nodes inherit #address-cells = <2> and #size-cells = <2> from the soc@0 bus, but I2C child devices always use a single-cell address and no size. With the inherited values every child node triggers a
reg_formatwarning, and a device described on the bus would be decoded with the wrong address layout.
Quoted 6 lines
Set #address-cells = <1> and #size-cells = <0> on all eight I2C controllers, matching the I3C nodes that already do so.
Fixes fad32e8ac460 ("arm64: dts: cix: add DT nodes for all I2C and I3C ports for sky1")Signed-off-by Gary Yang <[email protected]>
1. Fixes cannot depend on the driver.
2. Also, explain what is the bug here. Your commit msg has absolutely no indication of the bug.
3. DTS cannot be combined in this patchset and must be split. Don't mix patches from independent subsystems when you send something explicitly targeting only one subsystem.
See also: Documentation/devicetree/bindings/submitting-patches.rst
Quoted 9 lines
--- arch/arm64/boot/dts/cix/sky1.dtsi | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)arch/arm64/boot/dts/cix/sky1.dtsi +0
-0
arch/arm64/boot/dts/cix/sky1.dtsi soc@0 { · line 294
Quoted 5 lines
arch/arm64/boot/dts/cix/sky1.dtsi +2
-0@@ -290,6 +290,8 @@ soc@0 { i2c0: i2c@4010000 { compatible = "cdns,i2c-r1p14"; reg = <0x0 0x04010000 0x0 0x10000>; + #address-cells = <1>; + #size-cells = <0>;
How is this a fix? Really.
Best regards,
Krzysztof
Re: [PATCH 4/4] arm64: dts: cix: add RTS5453 PD controllers to Orion O6
In reply to Gary YangQuoted 14 lines · Gary Yang
Describe the two Realtek RTS5453H port controllers on the Orion O6 I2C1 bus and add the I2C1 pin configuration.
The controllers route orientation and DisplayPort mode changes through the USB/DP combo PHY lane switches, but that PHY support is not upstream yet, so the connector graph endpoints are left out for now. The Type-C ports are still registered and reported, only the lane switching is deferred until the PHY nodes are available.
Both controllers report through the same level-triggered interrupt line, which the driver handles with a shared interrupt. The I2C bus runs at 100 kHz because the RTS5453H I2C interface does not support higher rates.
Quoted 4 lines
Signed-off-by Gary Yang <[email protected]>--- arch/arm64/boot/dts/cix/sky1-orion-o6.dts | 51 +++++++++++++++++++++++ 1 file changed, 51 insertions(+)
DTS cannot be combined in this patchset and must be split. Don't mix patches from independent subsystems when you send something explicitly targeting only one subsystem.
See also: Documentation/devicetree/bindings/submitting-patches.rst
Best regards,
Krzysztof
Re: [PATCH 1/4] dt-bindings: usb: add Realtek RTS5453H Type-C port controller
In reply to Gary YangQuoted 4 lines · Gary Yang
Document the Realtek RTS5453H stand-alone USB Type-C port controller. The controller is connected over I2C and manages a single USB Type-C connector, described with the generic USB connector binding.
Quoted 9 lines
The connector's OF graph links to the Type-C orientation switch and mode mux provided by the platform PHY.
Signed-off-by Gary Yang <[email protected]>--- .../bindings/usb/realtek,rts5453h.yaml | 126 ++++++++++++++++++ 1 file changed, 126 insertions(+) create mode 100644 Documentation/devicetree/bindings/usb/realtek,rts5453h.yaml
Valid comments from Sashiko.
Best regards,
Krzysztof
Quoted 8 lines · Gary Yang
CLANG CONTEXT ANALYSIS
M: Marco Elver <[email protected]>
R: Bart Van Assche <[email protected]>drivers/usb/typec/Kconfig +0
-0
drivers/usb/typec/Kconfig config TYPEC_WUSB3801 · line 115
Quoted 6 lines
drivers/usb/typec/Kconfig +3
-0@@ -110,6 +110,17 @@ config TYPEC_WUSB3801 If you choose to build this driver as a dynamically linked module, the module will be called wusb3801.ko. +config TYPEC_CIX_PD + tristate "CIX Type-C PD controller driver" + depends on I2C
depends on your ARCH || COMPILE_TEST
Quoted 7 lines
drivers/usb/typec/Kconfig +7
-0+ select REGMAP_I2C + help + Say Y or M here if your system has a CIX Type-C PD controller. + This driver currently supports the Realtek RTS5453H controller. + + If you choose to build this driver as a dynamically linked module, the + module will be called cix_pd.ko.
...
Quoted 101 lines
drivers/usb/typec/Kconfig +101
-0+static int cix_pd_init_ports(struct cix_pd *typec) +{ + struct device *dev = typec->dev; + struct typec_altmode_desc desc = cix_pd_dp_altmode; + int ret, nports; + + nports = device_get_child_node_count(dev); + if (nports == 0) { + dev_err(dev, "No port entries found.\n"); + return -ENODEV; + } + + if (nports > 1) { + dev_err(dev, "More ports listed than can be supported.\n"); + return -EINVAL; + } + + device_for_each_child_node_scoped(dev, fwnode) { + ret = fwnode_property_read_u32(fwnode, "reg", &typec->id); + if (ret) + goto unregister_ports; + + ret = cix_pd_typec_parse_port_props(&typec->caps, fwnode, + dev); + if (ret) + goto unregister_ports; + + typec->port = typec_register_port(dev, &typec->caps); + if (IS_ERR(typec->port)) { + ret = PTR_ERR(typec->port); + typec->port = NULL; + dev_err(dev, "Failed to register port: %d\n", ret); + goto unregister_ports; + } + + desc.roles = typec->caps.data; + typec->port_altmode = typec_port_register_altmode(typec->port, + &desc); + if (IS_ERR(typec->port_altmode)) { + ret = PTR_ERR(typec->port_altmode); + typec->port_altmode = NULL; + dev_err(dev, "Failed to register DP altmode: %d\n", ret); + goto unregister_ports; + } + + ret = cix_pd_typec_get_handles(typec, fwnode, dev); + if (ret) + goto unregister_ports; + } + + return 0; + +unregister_ports: + cix_pd_unregister_ports(typec); + return ret; +} + +/* + * The IRQ is disabled when either the user asked for it or the device is + * suspended. Keep the disable/enable calls balanced and idempotent. + */ +static void cix_pd_sync_irq(struct cix_pd *rts) +{ + bool disable = rts->pd_int_disabled || rts->suspended; + + if (!rts->irq_requested || rts->irq_disabled == disable) + return; + + rts->irq_disabled = disable; + if (disable) + disable_irq(rts->irq); + else + enable_irq(rts->irq); +} + +static ssize_t disable_pd_interrupt_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct i2c_client *client = to_i2c_client(dev); + struct cix_pd *rts = i2c_get_clientdata(client); + const char *p; + + if (rts->pd_int_disabled) + p = "disabled"; + else + p = "enabled"; + + return sysfs_emit(buf, "%s\n", p); +} + +static ssize_t disable_pd_interrupt_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) +{ + struct i2c_client *client = to_i2c_client(dev); + struct cix_pd *rts = i2c_get_clientdata(client); + bool value; + int ret; + + ret = kstrtobool(buf, &value);
drivers/usb/typec/Kconfig
Quoted 10 lines
drivers/usb/typec/Kconfig +10
-0+ if (ret) + return ret; + + mutex_lock(&rts->irq_lock); + rts->pd_int_disabled = value; + cix_pd_sync_irq(rts); + mutex_unlock(&rts->irq_lock); + + dev_alert(dev, "Only for USB Compliance test, PD int is %s\n", + value ? "disabled" : "enabled");
What?
drivers/usb/typec/Kconfig
Quoted 5 lines
drivers/usb/typec/Kconfig +5
-0+ + return count; +} + +DEVICE_ATTR_RW(disable_pd_interrupt);
You need to document the ABI. But really, we do not enable/disable interrupts through custom sysfs hooks. Drop.
drivers/usb/typec/Kconfig
Quoted 7 lines
drivers/usb/typec/Kconfig +7
-0+ +static int cix_pd_probe(struct i2c_client *client) +{ + struct cix_pd *rts; + int ret; + + dev_dbg(&client->dev, "IRQ %d supplied\n", client->irq);
Drop
Quoted 157 lines
drivers/usb/typec/Kconfig +157
-0+ rts = devm_kzalloc(&client->dev, sizeof(*rts), GFP_KERNEL); + if (!rts) + return -ENOMEM; + + rts->dev = &client->dev; + rts->irq = client->irq; + mutex_init(&rts->lock); + mutex_init(&rts->irq_lock); + cix_pd_typec_init_state(rts); + + if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) + return dev_err_probe(&client->dev, -ENODEV, + "i2c check functionality failed\n"); + + rts->regmap = devm_regmap_init_i2c(client, &cix_pd_regmap_config); + if (IS_ERR(rts->regmap)) + return dev_err_probe(&client->dev, PTR_ERR(rts->regmap), + "failed to init regmap\n"); + + i2c_set_clientdata(client, rts); + + ret = cix_pd_init_ports(rts); + if (ret) + return ret; + + ret = cix_pd_event_handler(rts, 0); + if (ret) { + dev_err(&client->dev, "failed to read initial status: %d\n", ret); + if (ret == -ESHUTDOWN) + ret = -EIO; + goto err_unregister_ports; + } + + if (client->irq > 0) { + irq_set_status_flags(client->irq, IRQ_DISABLE_UNLAZY); + ret = request_threaded_irq(client->irq, NULL, cix_pd_irq_handle, + IRQF_SHARED | IRQF_ONESHOT, + dev_name(&client->dev), rts); + if (ret) { + dev_err(&client->dev, "failed to request irq: %d\n", ret); + goto err_unregister_ports; + } + rts->irq_requested = true; + } + + ret = device_create_file(&client->dev, &dev_attr_disable_pd_interrupt); + if (ret) + dev_warn(&client->dev, + "Failed to create sysfs attribute, ret = %d\n", ret); + + device_set_wakeup_capable(&client->dev, true); + + return 0; + +err_unregister_ports: + cix_pd_unregister_ports(rts); + return ret; +} + +static void cix_pd_remove(struct i2c_client *client) +{ + struct cix_pd *rts = i2c_get_clientdata(client); + + device_remove_file(&client->dev, &dev_attr_disable_pd_interrupt); + + mutex_lock(&rts->irq_lock); + if (rts->irq_requested) { + rts->suspended = true; + cix_pd_sync_irq(rts); + if (rts->wake_enabled) { + disable_irq_wake(rts->irq); + rts->wake_enabled = false; + } + free_irq(rts->irq, rts); + rts->irq_requested = false; + } + mutex_unlock(&rts->irq_lock); + + cix_pd_unregister_ports(rts); +} + +static const struct of_device_id cix_pd_of_match[] = { + { .compatible = "realtek,rts5453h", }, + {} +}; +MODULE_DEVICE_TABLE(of, cix_pd_of_match); + +static const struct i2c_device_id cix_pd_id[] = { + { "rts5453h" }, + {} +}; + +static int __maybe_unused cix_pd_suspend(struct device *dev) +{ + struct i2c_client *client = to_i2c_client(dev); + struct cix_pd *rts = i2c_get_clientdata(client); + + mutex_lock(&rts->irq_lock); + if (rts->irq_requested) { + rts->suspended = true; + cix_pd_sync_irq(rts); + if (device_may_wakeup(dev)) { + enable_irq_wake(rts->irq); + rts->wake_enabled = true; + } + } + mutex_unlock(&rts->irq_lock); + + return 0; +} + +static int __maybe_unused cix_pd_resume(struct device *dev) +{ + struct i2c_client *client = to_i2c_client(dev); + struct cix_pd *rts = i2c_get_clientdata(client); + + mutex_lock(&rts->irq_lock); + if (rts->irq_requested) { + if (rts->wake_enabled) { + disable_irq_wake(rts->irq); + rts->wake_enabled = false; + } + rts->suspended = false; + cix_pd_sync_irq(rts); + } + mutex_unlock(&rts->irq_lock); + + return 0; +} + +static int __maybe_unused cix_pd_restore(struct device *dev) +{ + struct i2c_client *client = to_i2c_client(dev); + struct cix_pd *rts = i2c_get_clientdata(client); + int ret; + + ret = cix_pd_resume(dev); + if (ret) + return ret; + + /* Re-trigger PD event if PD event occurs during std */ + ret = cix_pd_event_handler(rts, 0); + if (ret) + dev_err(&client->dev, "typec event handling error %d\n", ret); + + return ret; +} + +static void cix_pd_shutdown(struct i2c_client *client) +{ + struct cix_pd *rts = i2c_get_clientdata(client); + + mutex_lock(&rts->irq_lock); + rts->suspended = true; + cix_pd_sync_irq(rts); + mutex_unlock(&rts->irq_lock); +}
drivers/usb/typec/Kconfig
Quoted 10 lines
drivers/usb/typec/Kconfig +10
-0+ +static const struct dev_pm_ops cix_pd_pm_ops = { + .suspend = pm_sleep_ptr(cix_pd_suspend), + .resume = pm_sleep_ptr(cix_pd_resume), + .freeze = pm_sleep_ptr(cix_pd_suspend), + .thaw = pm_sleep_ptr(cix_pd_resume), + .restore = pm_sleep_ptr(cix_pd_restore), +}; + +MODULE_DEVICE_TABLE(i2c, cix_pd_id);
This is placed next to the table.
Quoted 7 lines
drivers/usb/typec/Kconfig +7
-0+static struct i2c_driver cix_pd_i2c_driver = { + .driver = { + .name = "rts5453h", + .of_match_table = cix_pd_of_match, + .pm = pm_ptr(&cix_pd_pm_ops), + }, + .id_table = cix_pd_id,
drivers/usb/typec/Kconfig
Quoted 10 lines
drivers/usb/typec/Kconfig +10
-0+ .probe = cix_pd_probe, + .remove = cix_pd_remove, + .shutdown = cix_pd_shutdown, +}; + +module_i2c_driver(cix_pd_i2c_driver); +MODULE_DESCRIPTION("CIX Type-C PD controller driver"); +MODULE_AUTHOR("Chao Zeng <[email protected]>"); +MODULE_AUTHOR("Gary Yang <[email protected]>"); +MODULE_LICENSE("GPL");
Best regards,
Krzysztof
kernel test robot
build botkernel test robot noticed the following build errors:
Hi Gary,
kernel test robot noticed the following build errors:
[auto build test ERROR on 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4]
url: https://github.com/intel-lab-lkp/linux/commits/Gary-Yang/dt-bindings-usb-add-Realtek-RTS5453H-Type-C-port-controller/20261107-091009 base: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4 patch link: https://lore.kernel.org/r/20261107011012.3655873-3-gary.yang%40cixtech.com patch subject: [PATCH 2/4] usb: typec: add CIX Type-C PD controller driver config: sparc64-allmodconfig (https://download.01.org/0day-ci/archive/20261107/[email protected]/config) compiler: clang version 20.1.8 (https://github.com/llvm/llvm-project 87f0227cb60147a26a1eeb4fb06e3b505e9c7261) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20261107/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
>> drivers/usb/typec/cix_pd.c:628:3: error: call to undeclared function 'irq_set_status_flags'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
628 | irq_set_status_flags(client->irq, IRQ_DISABLE_UNLAZY);
| ^
>> drivers/usb/typec/cix_pd.c:628:37: error: use of undeclared identifier 'IRQ_DISABLE_UNLAZY'
628 | irq_set_status_flags(client->irq, IRQ_DISABLE_UNLAZY);
| ^2 errors generated.
vim +/irq_set_status_flags +628 drivers/usb/typec/cix_pd.c
587
588 static int cix_pd_probe(struct i2c_client *client)
589 {
590 struct cix_pd *rts;
591 int ret;
592
593 dev_dbg(&client->dev, "IRQ %d supplied\n", client->irq);
594 rts = devm_kzalloc(&client->dev, sizeof(*rts), GFP_KERNEL);
595 if (!rts)
596 return -ENOMEM;
597
598 rts->dev = &client->dev;
599 rts->irq = client->irq;
600 mutex_init(&rts->lock);
601 mutex_init(&rts->irq_lock);
602 cix_pd_typec_init_state(rts);
603
604 if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C))
605 return dev_err_probe(&client->dev, -ENODEV,
606 "i2c check functionality failed\n");
607
608 rts->regmap = devm_regmap_init_i2c(client, &cix_pd_regmap_config);
609 if (IS_ERR(rts->regmap))
610 return dev_err_probe(&client->dev, PTR_ERR(rts->regmap),
611 "failed to init regmap\n");
612
613 i2c_set_clientdata(client, rts);
614
615 ret = cix_pd_init_ports(rts);
616 if (ret)
617 return ret;
618
619 ret = cix_pd_event_handler(rts, 0);
620 if (ret) {
621 dev_err(&client->dev, "failed to read initial status: %d\n", ret);
622 if (ret == -ESHUTDOWN)
623 ret = -EIO;
624 goto err_unregister_ports;
625 }
626
627 if (client->irq > 0) {
> 628 irq_set_status_flags(client->irq, IRQ_DISABLE_UNLAZY);
629 ret = request_threaded_irq(client->irq, NULL, cix_pd_irq_handle,
630 IRQF_SHARED | IRQF_ONESHOT,
631 dev_name(&client->dev), rts);
632 if (ret) {
633 dev_err(&client->dev, "failed to request irq: %d\n", ret);
634 goto err_unregister_ports;
635 }
636 rts->irq_requested = true;
637 }
638
639 ret = device_create_file(&client->dev, &dev_attr_disable_pd_interrupt);
640 if (ret)
641 dev_warn(&client->dev,
642 "Failed to create sysfs attribute, ret = %d\n", ret);
643
644 device_set_wakeup_capable(&client->dev, true);
645
646 return 0;
647
648 err_unregister_ports:
649 cix_pd_unregister_ports(rts);
650 return ret;
651 }
652
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
kernel test robot
build botkernel test robot noticed the following build errors:
Hi Gary,
kernel test robot noticed the following build errors:
[auto build test ERROR on 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4]
url: https://github.com/intel-lab-lkp/linux/commits/Gary-Yang/dt-bindings-usb-add-Realtek-RTS5453H-Type-C-port-controller/20261107-091009 base: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4 patch link: https://lore.kernel.org/r/20261107011012.3655873-3-gary.yang%40cixtech.com patch subject: [PATCH 2/4] usb: typec: add CIX Type-C PD controller driver config: s390-allyesconfig (https://download.01.org/0day-ci/archive/20261108/[email protected]/config) compiler: s390-linux-gcc (GCC) 16.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20261108/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
drivers/usb/typec/cix_pd.c: In function 'cix_pd_probe':
>> drivers/usb/typec/cix_pd.c:628:17: error: implicit declaration of function 'irq_set_status_flags' [-Wimplicit-function-declaration]
628 | irq_set_status_flags(client->irq, IRQ_DISABLE_UNLAZY);
| ^~~~~~~~~~~~~~~~~~~~
>> drivers/usb/typec/cix_pd.c:628:51: error: 'IRQ_DISABLE_UNLAZY' undeclared (first use in this function)
628 | irq_set_status_flags(client->irq, IRQ_DISABLE_UNLAZY);
| ^~~~~~~~~~~~~~~~~~ drivers/usb/typec/cix_pd.c:628:51: note: each undeclared identifier is reported only once for each function it appears in
vim +/irq_set_status_flags +628 drivers/usb/typec/cix_pd.c
587
588 static int cix_pd_probe(struct i2c_client *client)
589 {
590 struct cix_pd *rts;
591 int ret;
592
593 dev_dbg(&client->dev, "IRQ %d supplied\n", client->irq);
594 rts = devm_kzalloc(&client->dev, sizeof(*rts), GFP_KERNEL);
595 if (!rts)
596 return -ENOMEM;
597
598 rts->dev = &client->dev;
599 rts->irq = client->irq;
600 mutex_init(&rts->lock);
601 mutex_init(&rts->irq_lock);
602 cix_pd_typec_init_state(rts);
603
604 if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C))
605 return dev_err_probe(&client->dev, -ENODEV,
606 "i2c check functionality failed\n");
607
608 rts->regmap = devm_regmap_init_i2c(client, &cix_pd_regmap_config);
609 if (IS_ERR(rts->regmap))
610 return dev_err_probe(&client->dev, PTR_ERR(rts->regmap),
611 "failed to init regmap\n");
612
613 i2c_set_clientdata(client, rts);
614
615 ret = cix_pd_init_ports(rts);
616 if (ret)
617 return ret;
618
619 ret = cix_pd_event_handler(rts, 0);
620 if (ret) {
621 dev_err(&client->dev, "failed to read initial status: %d\n", ret);
622 if (ret == -ESHUTDOWN)
623 ret = -EIO;
624 goto err_unregister_ports;
625 }
626
627 if (client->irq > 0) {
> 628 irq_set_status_flags(client->irq, IRQ_DISABLE_UNLAZY);
629 ret = request_threaded_irq(client->irq, NULL, cix_pd_irq_handle,
630 IRQF_SHARED | IRQF_ONESHOT,
631 dev_name(&client->dev), rts);
632 if (ret) {
633 dev_err(&client->dev, "failed to request irq: %d\n", ret);
634 goto err_unregister_ports;
635 }
636 rts->irq_requested = true;
637 }
638
639 ret = device_create_file(&client->dev, &dev_attr_disable_pd_interrupt);
640 if (ret)
641 dev_warn(&client->dev,
642 "Failed to create sysfs attribute, ret = %d\n", ret);
643
644 device_set_wakeup_capable(&client->dev, true);
645
646 return 0;
647
648 err_unregister_ports:
649 cix_pd_unregister_ports(rts);
650 return ret;
651 }
652
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
Gary Yang
maintainerRe: [PATCH 4/4] arm64: dts: cix: add RTS5453 PD controllers to Orion O6
In reply to Krzysztof Kozlowskihi Krzysztof:
Thanks for your comments!
Quoted 22 lines · Krzysztof Kozlowski
EXTERNAL EMAIL
Quoted 14 lines · Gary Yang
Describe the two Realtek RTS5453H port controllers on the Orion O6 I2C1 bus and add the I2C1 pin configuration.
The controllers route orientation and DisplayPort mode changes through the USB/DP combo PHY lane switches, but that PHY support is not upstream yet, so the connector graph endpoints are left out for now. The Type-C ports are still registered and reported, only the lane switching is deferred until the PHY nodes are available.
Both controllers report through the same level-triggered interrupt line, which the driver handles with a shared interrupt. The I2C bus runs at 100 kHz because the RTS5453H I2C interface does not support higher rates.
Quoted 4 lines
Signed-off-by Gary Yang <[email protected]>--- arch/arm64/boot/dts/cix/sky1-orion-o6.dts | 51 +++++++++++++++++++++++ 1 file changed, 51 insertions(+)
Quoted 5 lines
DTS cannot be combined in this patchset and must be split. Don't mix patches from independent subsystems when you send something explicitly targeting only one subsystem.
See also:Documentation/devicetree/bindings/submitting-patches.rst
Do you mean the driver does not depend on DTS? Previously, it was acceptable to put the DTS at the end of a patchset or place the DTS in a separate patchset. That’s why I put the DTS at the end of the patchset. Has the rule changed now?
Best Regards,
Gary
Quoted 3 lines
Best regards,
Krzysztof
Gary Yang
maintainerHi Krzysztof:
Thanks for your comments!
Quoted 14 lines · Krzysztof Kozlowski
EXTERNAL EMAIL
Quoted 11 lines · Gary Yang
CLANG CONTEXT ANALYSIS
M: Marco Elver <[email protected]>
R: Bart Van Assche <[email protected]>drivers/usb/typec/Kconfig +0
-0@@ -110,6 +110,17 @@ config TYPEC_WUSB3801 If you choose to build this driver as a dynamically linked module, the module will be called wusb3801.ko.
Quoted 5 lines
drivers/usb/typec/Kconfig config TYPEC_WUSB3801 · line 115
Quoted 3 lines
drivers/usb/typec/Kconfig +3
-0+config TYPEC_CIX_PD + tristate "CIX Type-C PD controller driver" + depends on I2Cdepends on your ARCH ||
COMPILE_TEST
agree. add it in v2.
Quoted 127 lines
Quoted 8 lines
drivers/usb/typec/Kconfig +7
-0+ select REGMAP_I2C + help + Say Y or M here if your system has a CIX Type-C PD controller. + This driver currently supports the Realtek RTS5453H controller. + + If you choose to build this driver as a dynamically linked module, the + module will be called cix_pd.ko....
Quoted 101 lines
drivers/usb/typec/Kconfig +101
-0+static int cix_pd_init_ports(struct cix_pd *typec) +{ + struct device *dev = typec->dev; + struct typec_altmode_desc desc = cix_pd_dp_altmode; + int ret, nports; + + nports = device_get_child_node_count(dev); + if (nports == 0) { + dev_err(dev, "No port entries found.\n"); + return -ENODEV; + } + + if (nports > 1) { + dev_err(dev, "More ports listed than can be supported.\n"); + return -EINVAL; + } + + device_for_each_child_node_scoped(dev, fwnode) { + ret = fwnode_property_read_u32(fwnode, "reg", &typec->id); + if (ret) + goto unregister_ports; + + ret = cix_pd_typec_parse_port_props(&typec->caps, fwnode, + dev); + if (ret) + goto unregister_ports; + + typec->port = typec_register_port(dev, &typec->caps); + if (IS_ERR(typec->port)) { + ret = PTR_ERR(typec->port); + typec->port = NULL; + dev_err(dev, "Failed to register port: %d\n", ret); + goto unregister_ports; + } + + desc.roles = typec->caps.data; + typec->port_altmode = typec_port_register_altmode(typec->port, + &desc); + if (IS_ERR(typec->port_altmode)) { + ret = PTR_ERR(typec->port_altmode); + typec->port_altmode = NULL; + dev_err(dev, "Failed to register DP altmode: %d\n", ret); + goto unregister_ports; + } + + ret = cix_pd_typec_get_handles(typec, fwnode, dev); + if (ret) + goto unregister_ports; + } + + return 0; + +unregister_ports: + cix_pd_unregister_ports(typec); + return ret; +} + +/* + * The IRQ is disabled when either the user asked for it or the device is + * suspended. Keep the disable/enable calls balanced and idempotent. + */ +static void cix_pd_sync_irq(struct cix_pd *rts) +{ + bool disable = rts->pd_int_disabled || rts->suspended; + + if (!rts->irq_requested || rts->irq_disabled == disable) + return; + + rts->irq_disabled = disable; + if (disable) + disable_irq(rts->irq); + else + enable_irq(rts->irq); +} + +static ssize_t disable_pd_interrupt_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct i2c_client *client = to_i2c_client(dev); + struct cix_pd *rts = i2c_get_clientdata(client); + const char *p; + + if (rts->pd_int_disabled) + p = "disabled"; + else + p = "enabled"; + + return sysfs_emit(buf, "%s\n", p); +} + +static ssize_t disable_pd_interrupt_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) +{ + struct i2c_client *client = to_i2c_client(dev); + struct cix_pd *rts = i2c_get_clientdata(client); + bool value; + int ret; + + ret = kstrtobool(buf, &value);drivers/usb/typec/Kconfig
Quoted 10 lines
drivers/usb/typec/Kconfig +10
-0+ if (ret) + return ret; + + mutex_lock(&rts->irq_lock); + rts->pd_int_disabled = value; + cix_pd_sync_irq(rts); + mutex_unlock(&rts->irq_lock); + + dev_alert(dev, "Only for USB Compliance test, PD int is %s\n", + value ? "disabled" : "enabled");What?
Quoted 9 lines
drivers/usb/typec/Kconfig
Quoted 5 lines
drivers/usb/typec/Kconfig +5
-0+ + return count; +} + +DEVICE_ATTR_RW(disable_pd_interrupt);You need to document the ABI. But really, we do not enable/disable interrupts through custom sysfs hooks. Drop.
agree. drop it in v2
Quoted 9 lines
drivers/usb/typec/Kconfig
Quoted 7 lines
drivers/usb/typec/Kconfig +7
-0+ +static int cix_pd_probe(struct i2c_client *client) +{ + struct cix_pd *rts; + int ret; + + dev_dbg(&client->dev, "IRQ %d supplied\n", client->irq);Drop
agree
Quoted 162 lines
Quoted 162 lines
drivers/usb/typec/Kconfig +161
-0+ rts = devm_kzalloc(&client->dev, sizeof(*rts), GFP_KERNEL); + if (!rts) + return -ENOMEM; + + rts->dev = &client->dev; + rts->irq = client->irq; + mutex_init(&rts->lock); + mutex_init(&rts->irq_lock); + cix_pd_typec_init_state(rts); + + if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) + return dev_err_probe(&client->dev, -ENODEV, + "i2c check functionality failed\n"); + + rts->regmap = devm_regmap_init_i2c(client, &cix_pd_regmap_config); + if (IS_ERR(rts->regmap)) + return dev_err_probe(&client->dev, PTR_ERR(rts->regmap), + "failed to init regmap\n"); + + i2c_set_clientdata(client, rts); + + ret = cix_pd_init_ports(rts); + if (ret) + return ret; + + ret = cix_pd_event_handler(rts, 0); + if (ret) { + dev_err(&client->dev, "failed to read initial status: %d\n", ret); + if (ret == -ESHUTDOWN) + ret = -EIO; + goto err_unregister_ports; + } + + if (client->irq > 0) { + irq_set_status_flags(client->irq, IRQ_DISABLE_UNLAZY); + ret = request_threaded_irq(client->irq, NULL, cix_pd_irq_handle, + IRQF_SHARED | IRQF_ONESHOT, + dev_name(&client->dev), rts); + if (ret) { + dev_err(&client->dev, "failed to request irq: %d\n", ret); + goto err_unregister_ports; + } + rts->irq_requested = true; + } + + ret = device_create_file(&client->dev, &dev_attr_disable_pd_interrupt); + if (ret) + dev_warn(&client->dev, + "Failed to create sysfs attribute, ret = %d\n", ret); + + device_set_wakeup_capable(&client->dev, true); + + return 0; + +err_unregister_ports: + cix_pd_unregister_ports(rts); + return ret; +} + +static void cix_pd_remove(struct i2c_client *client) +{ + struct cix_pd *rts = i2c_get_clientdata(client); + + device_remove_file(&client->dev, &dev_attr_disable_pd_interrupt); + + mutex_lock(&rts->irq_lock); + if (rts->irq_requested) { + rts->suspended = true; + cix_pd_sync_irq(rts); + if (rts->wake_enabled) { + disable_irq_wake(rts->irq); + rts->wake_enabled = false; + } + free_irq(rts->irq, rts); + rts->irq_requested = false; + } + mutex_unlock(&rts->irq_lock); + + cix_pd_unregister_ports(rts); +} + +static const struct of_device_id cix_pd_of_match[] = { + { .compatible = "realtek,rts5453h", }, + {} +}; +MODULE_DEVICE_TABLE(of, cix_pd_of_match); + +static const struct i2c_device_id cix_pd_id[] = { + { "rts5453h" }, + {} +}; + +static int __maybe_unused cix_pd_suspend(struct device *dev) +{ + struct i2c_client *client = to_i2c_client(dev); + struct cix_pd *rts = i2c_get_clientdata(client); + + mutex_lock(&rts->irq_lock); + if (rts->irq_requested) { + rts->suspended = true; + cix_pd_sync_irq(rts); + if (device_may_wakeup(dev)) { + enable_irq_wake(rts->irq); + rts->wake_enabled = true; + } + } + mutex_unlock(&rts->irq_lock); + + return 0; +} + +static int __maybe_unused cix_pd_resume(struct device *dev) +{ + struct i2c_client *client = to_i2c_client(dev); + struct cix_pd *rts = i2c_get_clientdata(client); + + mutex_lock(&rts->irq_lock); + if (rts->irq_requested) { + if (rts->wake_enabled) { + disable_irq_wake(rts->irq); + rts->wake_enabled = false; + } + rts->suspended = false; + cix_pd_sync_irq(rts); + } + mutex_unlock(&rts->irq_lock); + + return 0; +} + +static int __maybe_unused cix_pd_restore(struct device *dev) +{ + struct i2c_client *client = to_i2c_client(dev); + struct cix_pd *rts = i2c_get_clientdata(client); + int ret; + + ret = cix_pd_resume(dev); + if (ret) + return ret; + + /* Re-trigger PD event if PD event occurs during std */ + ret = cix_pd_event_handler(rts, 0); + if (ret) + dev_err(&client->dev, "typec event handling error %d\n", ret); + + return ret; +} + +static void cix_pd_shutdown(struct i2c_client *client) +{ + struct cix_pd *rts = i2c_get_clientdata(client); + + mutex_lock(&rts->irq_lock); + rts->suspended = true; + cix_pd_sync_irq(rts); + mutex_unlock(&rts->irq_lock); +} + +static const struct dev_pm_ops cix_pd_pm_ops = { + .suspend = pm_sleep_ptr(cix_pd_suspend), + .resume = pm_sleep_ptr(cix_pd_resume),
Quoted 8 lines
drivers/usb/typec/Kconfig
Quoted 6 lines
drivers/usb/typec/Kconfig +6
-0+ .freeze = pm_sleep_ptr(cix_pd_suspend), + .thaw = pm_sleep_ptr(cix_pd_resume), + .restore = pm_sleep_ptr(cix_pd_restore), +}; + +MODULE_DEVICE_TABLE(i2c, cix_pd_id);This is placed next to the table.
Yes, you're right. It's my mistakes and fix it in v2.
If I miss your any information, please kindly remind me.
Best Regards,
Gary
Quoted 22 lines
Quoted 8 lines
drivers/usb/typec/Kconfig +7
-0+static struct i2c_driver cix_pd_i2c_driver = { + .driver = { + .name = "rts5453h", + .of_match_table = cix_pd_of_match, + .pm = pm_ptr(&cix_pd_pm_ops), + }, + .id_table = cix_pd_id,drivers/usb/typec/Kconfig
Quoted 10 lines
drivers/usb/typec/Kconfig +10
-0+ .probe = cix_pd_probe, + .remove = cix_pd_remove, + .shutdown = cix_pd_shutdown, +}; + +module_i2c_driver(cix_pd_i2c_driver); +MODULE_DESCRIPTION("CIX Type-C PD controller driver"); +MODULE_AUTHOR("Chao Zeng <[email protected]>"); +MODULE_AUTHOR("Gary Yang <[email protected]>"); +MODULE_LICENSE("GPL");Best regards,
Krzysztof
Re: [PATCH 4/4] arm64: dts: cix: add RTS5453 PD controllers to Orion O6
In reply to Gary YangQuoted 34 lines · Gary Yang
hi Krzysztof:
Thanks for your comments!
Quoted 22 lines · Krzysztof Kozlowski
EXTERNAL EMAIL
Quoted 14 lines · Gary Yang
Describe the two Realtek RTS5453H port controllers on the Orion O6 I2C1 bus and add the I2C1 pin configuration.
The controllers route orientation and DisplayPort mode changes through the USB/DP combo PHY lane switches, but that PHY support is not upstream yet, so the connector graph endpoints are left out for now. The Type-C ports are still registered and reported, only the lane switching is deferred until the PHY nodes are available.
Both controllers report through the same level-triggered interrupt line, which the driver handles with a shared interrupt. The I2C bus runs at 100 kHz because the RTS5453H I2C interface does not support higher rates.
Quoted 4 lines
Signed-off-by Gary Yang <[email protected]>--- arch/arm64/boot/dts/cix/sky1-orion-o6.dts | 51 +++++++++++++++++++++++ 1 file changed, 51 insertions(+)Quoted 5 lines
DTS cannot be combined in this patchset and must be split. Don't mix patches from independent subsystems when you send something explicitly targeting only one subsystem.
See also:Documentation/devicetree/bindings/submitting-patches.rst
Quoted 4 lines
Do you mean the driver does not depend on DTS? Previously, it was acceptable to put the DTS at the end of a patchset or place the DTS in a separate patchset. That’s why I put the DTS at the end of the patchset. Has the rule changed now?
Why can't you read the docs I pointed?
Best regards,
Krzysztof