usb: typec: add CIX Type-C PD controller driver
Subsystems (3)
v7 cover usb: typec: add CIX Type-C PD controller driver
This series adds a Type-C PD controller driver for CIX platforms.
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 register addresses are agreed between CIX and the controller vendor and are configured into the PD firmware, so the host interface is not specific to the RTS5453H. The driver is therefore named after the platform integration rather than the first chip: further register-compatible controllers are supported by adding their compatible string, without renaming the driver, the module or the Kconfig symbol.
Patch 1 adds the devicetree binding and patch 2 adds the driver and its MAINTAINERS entry. The DTS patches from v1 are sent separately through the SoC tree.
Changes in v7:
- Align the register definition macros.
- Use guard(mutex) for the event handler lock.
- Return the actual I2C/regmap error from the event handler instead of -ESHUTDOWN, and drop the now-redundant -ESHUTDOWN to -EIO conversions in probe and resume.
Changes in v6:
- Explain the host interface in the commit message instead of the I2C transport, and state that the register addresses are agreed between CIX and the controller vendor and configured into the PD firmware, so the driver is not RTS5453H specific.
- Trim the commit message to the facts that are specific to the controller; the kernel-side details are kept as comments in the code.
- Drop the partner register and unregister dev_info messages and print the port state summary with dev_dbg.
Changes in v5:
- Exclude HPD_IRQ from the status comparison and handle it as an event of its own. The bit stays set until the interrupt is acknowledged, so caching it in the previous status made a repeated HPD interrupt look unchanged, and an acknowledged event look like a status change on the next interrupt of a sibling port.
- Reprogram the port only when the decoded status changed or an HPD interrupt arrived, and skip the orientation write when the orientation did not change, so a shared interrupt aimed at a sibling port no longer re-reports unchanged state to the Type-C class. Invalidate the cached status when a port update fails, so the update is retried on the next interrupt instead of being lost with the acknowledged event.
- Take the alternate mode device lock around device_is_bound() and typec_altmode_update_active(), so activation cannot race driver unbind.
- Keep the shared interrupt line masked for the whole system sleep:
->suspend() disables the line and waits for an in-flight handler, and ->resume() reads the status back and acknowledges the controller before re-enabling it. An event during suspend can no longer loop on the level-triggered line. Wake-up through this line is not offered:
the GPIO controller behind it has no irq_set_wake() callback.
Changes in v4:
- Keep the interrupt disabled across system sleep and re-enable it in ->resume() only, after the parent I2C adapter has resumed.
- Return IRQ_NONE when the port status did not change, so that the interrupt core can attribute the shared level-triggered line and disable a line that stays asserted.
- Mark the DisplayPort alternate mode active only after a driver is bound, so that the module reference taken by typec_altmode_update_active() stays balanced.
- binding: drop the nodes below the documented device from the example.
- Carry Reviewed-by from Krzysztof Kozlowski.
Changes in v3:
- Report the Type-C data role from the controller status for every connection, including DisplayPort-only configurations where no USB data role is available, instead of deriving it from the USB role switch.
- Pass the port alternate mode in the mux state, matching other firmware-driven port drivers.
- Force the USB role switch to be reprogrammed on system resume and check the enable_irq_wake() return value.
- Acknowledge a pending controller interrupt during probe so that a shared interrupt line is not left asserted.
- Do not drop the borrowed fwnode reference when parsing the connector properties fails.
- Treat all fwnode_usb_role_switch_get() errors as fatal; a connector without a role switch link returns NULL, not -ENODEV.
- Drop a redundant include.
Changes in v2:
- Drop the DTS patches from the series.
- binding: describe the single connector as a plain "connector" child node instead of an addressed node, and stop requiring "try-power-role", which only applies to dual-role ports.
- driver: add the missing USB_ROLE_SWITCH Kconfig dependency.
- driver: register the DisplayPort partner alternate mode only for actual DP connections, with a valid VDO, call typec_altmode_update_active() on attach/detach and set no_mode_control since the firmware drives mode entry.
- driver: never pass a NULL alternate mode to typec_mux_set(), and treat debug accessories as disconnected everywhere.
- driver: handle USB 2.0-only connections in orientation, role and mux state.
- driver: only cache the USB role after the role switch accepted it, and force a role refresh on resume.
- driver: use typec_get_fw_cap() instead of open-coding the connector properties.
- driver: acquire the mux and role switch before registering the port, use dev_err_probe() on probe failures and reset the mux to the safe state on teardown.
- driver: remove the undocumented disable_pd_interrupt sysfs attribute and the manual disable_irq()/IRQ_DISABLE_UNLAZY handling that could leak the shared IRQ's disable depth. This also fixes the build error reported by the kernel test robot on sparc64 and s390.
- driver: use a named i2c_device_id initializer and add the missing hibernation PM callbacks.
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 (2):
dt-bindings: usb: add Realtek RTS5453H Type-C port controller
usb: typec: add CIX Type-C PD controller driver
.../bindings/usb/realtek,rts5453h.yaml | 70 ++ MAINTAINERS | 7 + drivers/usb/typec/Kconfig | 13 + drivers/usb/typec/Makefile | 1 + drivers/usb/typec/cix_pd.c | 766 ++++++++++++++++++ 5 files changed, 857 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
PATCH v7 1/2 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 | 70 +++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 Documentation/devicetree/bindings/usb/realtek,rts5453h.yaml
Documentation/devicetree/bindings/usb/realtek,rts5453h.yaml new file +70 -0
@@ -0,0 +1,70 @@ +# 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 + + interrupts: + maxItems: 1 + + connector: + type: object + $ref: /schemas/connector/usb-connector.yaml# + unevaluatedProperties: false + description: + The USB Type-C connector managed by this controller. + + required: + - data-role + - power-role + +required: + - compatible + - reg + - interrupts + - connector + +additionalProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/irq.h> + + i2c { + #address-cells = <1>; + #size-cells = <0>; + + typec@30 { + compatible = "realtek,rts5453h"; + reg = <0x30>; + interrupt-parent = <&gpio0>; + interrupts = <8 IRQ_TYPE_LEVEL_LOW>; + + connector { + compatible = "usb-c-connector"; + data-role = "host"; + power-role = "source"; + }; + }; + };
Signature · 1 line
2.50.1
PATCH v7 2/2 usb: typec: add CIX Type-C PD controller driver
In reply to Gary YangAdd a Type-C PD controller driver for CIX platforms. The Realtek RTS5453H is the first supported device.
The controller runs the Type-C and PD state machines in its firmware. The register addresses are agreed between CIX and the controller vendor and are configured into that firmware, so the host interface is not specific to the RTS5453H: further register-compatible controllers can be supported by the same driver, each with its own compatible string. The host reads the decoded port status from the data status register (0x5F) and acknowledges port and HPD events through the data control register (0x50). The driver translates that into Type-C class notifications and drives the platform PHY's orientation switch and mode mux for the DisplayPort alternate mode, and the platform USB role switch for the negotiated data role.
--- MAINTAINERS | 7 + drivers/usb/typec/Kconfig | 13 + drivers/usb/typec/Makefile | 1 + drivers/usb/typec/cix_pd.c | 766 +++++++++++++++++++++++++++++++++++++ 4 files changed, 787 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 +13 -0
@@ -110,6 +110,19 @@ 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 USB_ROLE_SWITCH + depends on ARCH_CIX || COMPILE_TEST + 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 +766 -0
766 lines not on this page · raw message
Signature · 1 line
2.50.1
[email protected]
AI reviewSashiko has reviewed this 2-patch series and found no issues.
Sashiko has reviewed this 2-patch series and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]