Add CIX Sky1 USB3/USBSSP support
Subsystems (6)
cover Add CIX Sky1 USB3/USBSSP support
Add USB3 PHY driver, Cadence USBSSP glue driver, and USB4/USB5 device tree nodes for the CIX Sky1 SoC.
This series adds support for the USB4 and USB5 controllers (based on Cadence USBSSP DRD) found on the CIX Sky1 SoC, along with their associated multi-port USB3 PHY.
Hongliang Yang (4):
dt-bindings: Add CIX Sky1 USB bindings
phy: cix: Add CIX Sky1 USB3 PHY driver
usb: cdns3: Add CIX Sky1 glue driver
arm64: dts: cix: Add USB4/USB5 nodes for Sky1
.../bindings/phy/cix,sky1-usb3-phy.yaml | 109 +++ .../bindings/usb/cix,sky1-usbssp.yaml | 153 ++++ MAINTAINERS | 3 + arch/arm64/boot/dts/cix/sky1-orion-o6.dts | 36 + arch/arm64/boot/dts/cix/sky1.dtsi | 133 ++++ drivers/phy/Kconfig | 1 + drivers/phy/Makefile | 1 + drivers/phy/cix/Kconfig | 20 + drivers/phy/cix/Makefile | 6 + drivers/phy/cix/phy-cix-usb3.c | 410 +++++++++++ drivers/phy/cix/phy-cix-usbdp.h | 310 ++++++++ drivers/usb/cdns3/Kconfig | 13 + drivers/usb/cdns3/Makefile | 1 + drivers/usb/cdns3/cdnsp-sky1.c | 682 ++++++++++++++++++ drivers/usb/cdns3/cdnsp-sky1.h | 127 ++++ 15 files changed, 2005 insertions(+) create mode 100644 Documentation/devicetree/bindings/phy/cix,sky1-usb3-phy.yaml create mode 100644 Documentation/devicetree/bindings/usb/cix,sky1-usbssp.yaml create mode 100644 drivers/phy/cix/Kconfig create mode 100644 drivers/phy/cix/Makefile create mode 100644 drivers/phy/cix/phy-cix-usb3.c create mode 100644 drivers/phy/cix/phy-cix-usbdp.h create mode 100644 drivers/usb/cdns3/cdnsp-sky1.c create mode 100644 drivers/usb/cdns3/cdnsp-sky1.h
base-commit: dc59e4fea9d83f03bad6bddf3fa2e52491777482
Signature · 1 line
2.54.0
PATCH 1/4 dt-bindings: Add CIX Sky1 USB bindings
Add device tree bindings for CIX Sky1 USB3 PHY and Cadence USBSSP controller glue layer.
--- .../bindings/phy/cix,sky1-usb3-phy.yaml | 109 +++++++++++++ .../bindings/usb/cix,sky1-usbssp.yaml | 153 ++++++++++++++++++ MAINTAINERS | 3 + 3 files changed, 265 insertions(+) create mode 100644 Documentation/devicetree/bindings/phy/cix,sky1-usb3-phy.yaml create mode 100644 Documentation/devicetree/bindings/usb/cix,sky1-usbssp.yaml
Documentation/devicetree/bindings/phy/cix,sky1-usb3-phy.yaml new file +109 -0
@@ -0,0 +1,109 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/phy/cix,sky1-usb3-phy.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: CIX Sky1 USB3 PHY + +maintainers: + - Hongliang Yang <[email protected]> + +description: + The CIX Sky1 USB3 PHY is a multi-port SuperSpeedPlus PHY that + supports up to two USB3 lanes. Each port is represented as a + child node of the PHY controller. + +properties: + compatible: + const: cix,sky1-usb3-phy + + reg: + maxItems: 1 + + clocks: + items: + - description: APB register interface clock + - description: PHY reference clock + + clock-names: + items: + - const: apb_clk + - const: ref_clk + + resets: + items: + - description: PHY reset + - description: PHY APB preset + + reset-names: + items: + - const: reset + - const: preset + + "#address-cells": + const: 1 + + "#size-cells": + const: 0 + +patternProperties: + "^usb-port@[0-9a-f]+$": + type: object + description: + A single USB3 PHY port/lane. + + properties: + reg: + maxItems: 1 + + "#phy-cells": + const: 0 + + required: + - reg + - "#phy-cells" + + additionalProperties: false + +required: + - compatible + - reg + - clocks + - clock-names + - resets + - reset-names + - "#address-cells" + - "#size-cells" + +unevaluatedProperties: false + +examples: + - | + #include <dt-bindings/clock/cix,sky1.h> + #include <dt-bindings/reset/cix,sky1-s5-system-control.h> + + usb-phy@9210000 { + compatible = "cix,sky1-usb3-phy"; + reg = <0x09210000 0x40000>; + #address-cells = <1>; + #size-cells = <0>; + + resets = <&s5_syscon SKY1_USBPHY_SS_RST_N>, + <&s5_syscon SKY1_USBPHY_SS_PST_N>; + reset-names = "reset", "preset"; + + clocks = <&scmi_clk CLK_TREE_USB3A_PHY3_GATE>, + <&scmi_clk CLK_TREE_USB3A_PHY_x2_REF>; + clock-names = "apb_clk", "ref_clk"; + + usb-port@0 { + reg = <0>; + #phy-cells = <0>; + }; + + usb-port@1 { + reg = <1>; + #phy-cells = <0>; + }; + };
Documentation/devicetree/bindings/usb/cix,sky1-usbssp.yaml new file +153 -0
153 lines not on this page · raw message
MAINTAINERS +3 -0
@@ -2775,8 +2775,11 @@ S: Maintained T: git git://git.kernel.org/pub/scm/linux/kernel/git/peter.chen/cix.git F: Documentation/devicetree/bindings/arm/cix.yaml F: Documentation/devicetree/bindings/mailbox/cix,sky1-mbox.yaml +F: Documentation/devicetree/bindings/phy/cix,sky1-usb3-phy.yaml +F: Documentation/devicetree/bindings/usb/cix,sky1-usbssp.yaml F: arch/arm64/boot/dts/cix/ F: drivers/mailbox/cix-mailbox.c +F: drivers/phy/cix/ K: \bcix\b ARM/CLKDEV SUPPORT
Signature · 1 line
2.54.0
[email protected]
AI reviewRe: [PATCH v1 1/4] dt-bindings: Add CIX Sky1 USB bindings
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [Low] Custom devicetree properties do not follow standard naming conventions (missing vendor prefix and…
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Low] Custom devicetree properties do not follow standard naming conventions (missing vendor prefix and using underscores).
- [Low] The unit-address in the example node name does not match the first address in its 'reg' property. --
commit a013b6f9b48698942425d14e2f091ce0c4c04f8c
Author: Hongliang Yang <[email protected]>
dt-bindings: Add CIX Sky1 USB bindings
This commit adds device tree bindings for the CIX Sky1 USB3 PHY and Cadence USBSSP controller glue layer.
Quoted 5 lines
Documentation/devicetree/bindings/usb/cix,sky1-usbssp.yaml new file +0
-0
[ ... ]
Documentation/devicetree/bindings/usb/cix,sky1-usbssp.yaml line 6
Quoted 7 lines
Documentation/devicetree/bindings/usb/cix,sky1-usbssp.yaml new file +6
-0@@ -0,0 +1,153 @@ + reset-names: + items: + - const: usb_preset + - const: usb_reset + + cix,usb_syscon:
[Severity: Low]
Does this property name follow the standard devicetree naming conventions? Standard convention strongly prefers hyphens over underscores in property names (e.g., cix,usb-syscon).
Documentation/devicetree/bindings/usb/cix,sky1-usbssp.yaml line 62
Quoted 6 lines
Documentation/devicetree/bindings/usb/cix,sky1-usbssp.yaml new file +6
-0+ $ref: /schemas/types.yaml#/definitions/phandle + description: + Phandle to the Sky1 S5 system controller used to program USB mode + strap controls. + + axi_bmax_value:
[Severity: Low]
Does this property need a vendor prefix and hyphens instead of underscores? Custom hardware-specific properties require a vendor prefix to avoid collisions with standard properties (e.g., cix,axi-bmax-value).
Quoted 4 lines
Documentation/devicetree/bindings/usb/cix,sky1-usbssp.yaml new file +4
-0+ $ref: /schemas/types.yaml#/definitions/uint32 + default: 0x7 + description: + AXI bus maximum burst length configuration value.
[ ... ]
Documentation/devicetree/bindings/usb/cix,sky1-usbssp.yaml line 109
Quoted 11 lines
Documentation/devicetree/bindings/usb/cix,sky1-usbssp.yaml new file +11
-0+examples: + - | + #include <dt-bindings/clock/cix,sky1.h> + #include <dt-bindings/interrupt-controller/arm-gic.h> + #include <dt-bindings/reset/cix,sky1-s5-system-control.h> + + soc { + #address-cells = <2>; + #size-cells = <2>; + + usb@91c0300 {
[Severity: Low]
Does the unit address 91c0300 match the first address in the reg property? The Devicetree Specification requires that the unit address in a node name exactly matches the first address specified in the node's reg property. Here, it does not match the actual base register address 091c0314, which will trigger a simple_bus_reg warning when the devicetree compiler evaluates the example.
Quoted 7 lines
Documentation/devicetree/bindings/usb/cix,sky1-usbssp.yaml new file +7
-0+ compatible = "cix,sky1-usbssp"; + #address-cells = <2>; + #size-cells = <2>; + ranges; + + reg = <0x00 0x091c0314 0x00 0x4>, + <0x00 0x091c0400 0x00 0x4>;
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Re: [PATCH v1 1/4] dt-bindings: Add CIX Sky1 USB bindings
In reply to Hongliang YangQuoted 7 lines · Hongliang Yang
Add device tree bindings for CIX Sky1 USB3 PHY and Cadence USBSSP controller glue layer.
Signed-off-by Hongliang Yang <[email protected]>--- .../bindings/phy/cix,sky1-usb3-phy.yaml | 109 +++++++++++++ .../bindings/usb/cix,sky1-usbssp.yaml | 153 ++++++++++++++++++
Two patches please.
Quoted 33 lines
MAINTAINERS | 3 + 3 files changed, 265 insertions(+) create mode 100644 Documentation/devicetree/bindings/phy/cix,sky1-usb3-phy.yaml create mode 100644 Documentation/devicetree/bindings/usb/cix,sky1-usbssp.yamlDocumentation/devicetree/bindings/phy/cix,sky1-usb3-phy.yaml new file +22
-0@@ -0,0 +1,109 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/phy/cix,sky1-usb3-phy.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: CIX Sky1 USB3 PHY + +maintainers: + - Hongliang Yang <[email protected]> + +description: + The CIX Sky1 USB3 PHY is a multi-port SuperSpeedPlus PHY that + supports up to two USB3 lanes. Each port is represented as a + child node of the PHY controller. + +properties: + compatible: + const: cix,sky1-usb3-phy + + reg: + maxItems: 1
Documentation/devicetree/bindings/phy/cix,sky1-usb3-phy.yaml line 32
Quoted 10 lines
Documentation/devicetree/bindings/phy/cix,sky1-usb3-phy.yaml new file +10
-0+ + clocks: + items: + - description: APB register interface clock + - description: PHY reference clock + + clock-names: + items: + - const: apb_clk + - const: ref_clk
drop "_clk", they're both clocks..
pw-bot: changes-requested
Documentation/devicetree/bindings/phy/cix,sky1-usb3-phy.yaml line 42
Quoted 10 lines
Documentation/devicetree/bindings/phy/cix,sky1-usb3-phy.yaml new file +10
-0+ + resets: + items: + - description: PHY reset + - description: PHY APB preset + + reset-names: + items: + - const: reset + - const: preset
drop "reset" from here, they're both resets. Call them "core" and "apb" or something instead.
Quoted 109 lines
Documentation/devicetree/bindings/phy/cix,sky1-usb3-phy.yaml new file +67
-0+ + "#address-cells": + const: 1 + + "#size-cells": + const: 0 + +patternProperties: + "^usb-port@[0-9a-f]+$": + type: object + description: + A single USB3 PHY port/lane. + + properties: + reg: + maxItems: 1 + + "#phy-cells": + const: 0 + + required: + - reg + - "#phy-cells" + + additionalProperties: false + +required: + - compatible + - reg + - clocks + - clock-names + - resets + - reset-names + - "#address-cells" + - "#size-cells" + +unevaluatedProperties: false + +examples: + - | + #include <dt-bindings/clock/cix,sky1.h> + #include <dt-bindings/reset/cix,sky1-s5-system-control.h> + + usb-phy@9210000 { + compatible = "cix,sky1-usb3-phy"; + reg = <0x09210000 0x40000>; + #address-cells = <1>; + #size-cells = <0>; + + resets = <&s5_syscon SKY1_USBPHY_SS_RST_N>, + <&s5_syscon SKY1_USBPHY_SS_PST_N>; + reset-names = "reset", "preset"; + + clocks = <&scmi_clk CLK_TREE_USB3A_PHY3_GATE>, + <&scmi_clk CLK_TREE_USB3A_PHY_x2_REF>; + clock-names = "apb_clk", "ref_clk"; + + usb-port@0 { + reg = <0>; + #phy-cells = <0>; + }; + + usb-port@1 { + reg = <1>; + #phy-cells = <0>; + }; + };Documentation/devicetree/bindings/usb/cix,sky1-usbssp.yaml new file +34
-0@@ -0,0 +1,153 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/usb/cix,sky1-usbssp.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: CIX Sky1 Cadence USBSSP Controller + +maintainers: + - Hongliang Yang <[email protected]> + +description: + The CIX Sky1 USBSSP controller is based on the Cadence USBSSP DRD + controller. The integration adds glue registers and mode strap controls + in the Sky1 S5 system controller. The CIX glue node wraps a Cadence + USBSSP core as a child node. + +properties: + compatible: + const: cix,sky1-usbssp + + reg: + items: + - description: AXI property configuration register + - description: Controller status register + + reg-names: + items: + - const: axi_property + - const: controller_status + + clocks: + items: + - description: Start-of-frame clock
Documentation/devicetree/bindings/usb/cix,sky1-usbssp.yaml line 44
Quoted 10 lines
Documentation/devicetree/bindings/usb/cix,sky1-usbssp.yaml new file +10
-0+ - description: AXI bus clock + - description: Low-power mode clock + - description: APB register interface clock + + clock-names: + items: + - const: sof_clk + - const: usb_aclk + - const: lpm_clk + - const: usb_pclk
Same stuff here on naming
Documentation/devicetree/bindings/usb/cix,sky1-usbssp.yaml line 54
Quoted 10 lines
Documentation/devicetree/bindings/usb/cix,sky1-usbssp.yaml new file +10
-0+ + resets: + items: + - description: APB register reset + - description: Controller reset + + reset-names: + items: + - const: usb_preset + - const: usb_reset
and here.
Documentation/devicetree/bindings/usb/cix,sky1-usbssp.yaml line 56
Quoted 2 lines
Documentation/devicetree/bindings/usb/cix,sky1-usbssp.yaml new file +2
-0+ + cix,usb_syscon:
No underscores in property names.
Documentation/devicetree/bindings/usb/cix,sky1-usbssp.yaml line 62
Quoted 6 lines
Documentation/devicetree/bindings/usb/cix,sky1-usbssp.yaml new file +6
-0+ $ref: /schemas/types.yaml#/definitions/phandle + description: + Phandle to the Sky1 S5 system controller used to program USB mode + strap controls. + + axi_bmax_value:
Missing vendor prefix.
No underscores in property names.
Why is this not a fixed value per SoC?
Cheers,
Conor.
Quoted 110 lines
Documentation/devicetree/bindings/usb/cix,sky1-usbssp.yaml new file +91
-0+ $ref: /schemas/types.yaml#/definitions/uint32 + default: 0x7 + description: + AXI bus maximum burst length configuration value. + + "#address-cells": + const: 2 + + "#size-cells": + const: 2 + + ranges: true + +patternProperties: + "^usb-controller@[0-9a-f]+$": + $ref: cdns,usb3.yaml# + description: + The Cadence USBSSP core controller node. See cdns,usb3.yaml + for properties such as dr_mode, maximum-speed, phys, and interrupts. + unevaluatedProperties: false + +required: + - compatible + - reg + - reg-names + - clocks + - clock-names + - resets + - reset-names + - cix,usb_syscon + - "#address-cells" + - "#size-cells" + - ranges + +unevaluatedProperties: false + +examples: + - | + #include <dt-bindings/clock/cix,sky1.h> + #include <dt-bindings/interrupt-controller/arm-gic.h> + #include <dt-bindings/reset/cix,sky1-s5-system-control.h> + + soc { + #address-cells = <2>; + #size-cells = <2>; + + usb@91c0300 { + compatible = "cix,sky1-usbssp"; + #address-cells = <2>; + #size-cells = <2>; + ranges; + + reg = <0x00 0x091c0314 0x00 0x4>, + <0x00 0x091c0400 0x00 0x4>; + reg-names = "axi_property", "controller_status"; + + resets = <&src SKY1_USBC_SS2_PRST_N>, + <&src SKY1_USBC_SS2_RST_N>; + reset-names = "usb_preset", "usb_reset"; + + clocks = <&scmi_clk CLK_TREE_USB3A_H0_CLK_SOF>, + <&scmi_clk CLK_TREE_USB3A_0_AXI_GATE>, + <&scmi_clk CLK_TREE_USB3A_H0_CLK_LPM>, + <&scmi_clk CLK_TREE_USB3A_0_APB_GATE>; + clock-names = "sof_clk", "usb_aclk", "lpm_clk", "usb_pclk"; + + cix,usb_syscon = <&src>; + axi_bmax_value = <0x7>; + + usb-controller@91d0000 { + compatible = "cdns,usb3"; + reg = <0x00 0x91d0000 0x00 0x4000>, + <0x00 0x91d8000 0x00 0x8000>, + <0x00 0x91d4000 0x00 0x4000>; + reg-names = "otg", "xhci", "dev"; + + interrupts = <GIC_SPI 168 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 169 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 170 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 171 IRQ_TYPE_LEVEL_HIGH>; + interrupt-names = "host", "peripheral", "otg", "wakeup"; + + /* Cadence USBSSP core properties - see cdns,usb3.yaml */ + maximum-speed = "super-speed-plus"; + dr_mode = "otg"; + + phys = <&usb3_phy4_0>, <&usb2_phy6>; + phy-names = "cdns3,usb3-phy", "cdns3,usb2-phy"; + }; + }; + };MAINTAINERS +3
-0@@ -2775,8 +2775,11 @@ S: Maintained T: git git://git.kernel.org/pub/scm/linux/kernel/git/peter.chen/cix.git F: Documentation/devicetree/bindings/arm/cix.yaml F: Documentation/devicetree/bindings/mailbox/cix,sky1-mbox.yaml +F: Documentation/devicetree/bindings/phy/cix,sky1-usb3-phy.yaml +F: Documentation/devicetree/bindings/usb/cix,sky1-usbssp.yaml F: arch/arm64/boot/dts/cix/ F: drivers/mailbox/cix-mailbox.c +F: drivers/phy/cix/ K: \bcix\b ARM/CLKDEV SUPPORTSignature · 1 line
2.54.0
Re: [PATCH v1 1/4] dt-bindings: Add CIX Sky1 USB bindings
In reply to Hongliang YangQuoted 7 lines · Hongliang Yang
Add device tree bindings for CIX Sky1 USB3 PHY and Cadence USBSSP controller glue layer.
Signed-off-by Hongliang Yang <[email protected]>--- .../bindings/phy/cix,sky1-usb3-phy.yaml | 109 +++++++++++++ .../bindings/usb/cix,sky1-usbssp.yaml | 153 ++++++++++++++++++
Please use subject prefixes matching the subsystem. You can get them for example with git log --oneline -- DIRECTORY_OR_FILE on the directory your patch is touching. For bindings, the preferred subjects are explained here:
https://www.kernel.org/doc/html/latest/devicetree/bindings/submitting-patches.html#i-for-patch-submitters
A nit, subject: drop second/last, redundant "bindings". The "dt-bindings" prefix is already stating that these are bindings. See also:
https://elixir.bootlin.com/linux/v7.1-rc7/source/Documentation/devicetree/bindings/submitting-patches.rst#L23
And do not combine USB patches with other subsystems.
Quoted 16 lines
MAINTAINERS | 3 + 3 files changed, 265 insertions(+) create mode 100644 Documentation/devicetree/bindings/phy/cix,sky1-usb3-phy.yaml create mode 100644 Documentation/devicetree/bindings/usb/cix,sky1-usbssp.yamlDocumentation/devicetree/bindings/phy/cix,sky1-usb3-phy.yaml new file +5
-0@@ -0,0 +1,109 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/phy/cix,sky1-usb3-phy.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml#
Documentation/devicetree/bindings/phy/cix,sky1-usb3-phy.yaml line 15
Quoted 10 lines
Documentation/devicetree/bindings/phy/cix,sky1-usb3-phy.yaml new file +10
-0+ +title: CIX Sky1 USB3 PHY + +maintainers: + - Hongliang Yang <[email protected]> + +description: + The CIX Sky1 USB3 PHY is a multi-port SuperSpeedPlus PHY that + supports up to two USB3 lanes. Each port is represented as a + child node of the PHY controller.
Please read and follow DTS coding style.
Quoted 54 lines
Documentation/devicetree/bindings/phy/cix,sky1-usb3-phy.yaml new file +54
-0+ +properties: + compatible: + const: cix,sky1-usb3-phy + + reg: + maxItems: 1 + + clocks: + items: + - description: APB register interface clock + - description: PHY reference clock + + clock-names: + items: + - const: apb_clk + - const: ref_clk + + resets: + items: + - description: PHY reset + - description: PHY APB preset + + reset-names: + items: + - const: reset + - const: preset + + "#address-cells": + const: 1 + + "#size-cells": + const: 0 + +patternProperties: + "^usb-port@[0-9a-f]+$": + type: object + description: + A single USB3 PHY port/lane. + + properties: + reg: + maxItems: 1 + + "#phy-cells": + const: 0 + + required: + - reg + - "#phy-cells" + + additionalProperties: false + +required:
Documentation/devicetree/bindings/phy/cix,sky1-usb3-phy.yaml line 79
Quoted 10 lines
Documentation/devicetree/bindings/phy/cix,sky1-usb3-phy.yaml new file +10
-0+ - compatible + - reg + - clocks + - clock-names + - resets + - reset-names + - "#address-cells" + - "#size-cells" + +unevaluatedProperties: false
Which other schema do you want to reference?
Quoted 51 lines
Documentation/devicetree/bindings/phy/cix,sky1-usb3-phy.yaml new file +30
-0+ +examples: + - | + #include <dt-bindings/clock/cix,sky1.h> + #include <dt-bindings/reset/cix,sky1-s5-system-control.h> + + usb-phy@9210000 { + compatible = "cix,sky1-usb3-phy"; + reg = <0x09210000 0x40000>; + #address-cells = <1>; + #size-cells = <0>; + + resets = <&s5_syscon SKY1_USBPHY_SS_RST_N>, + <&s5_syscon SKY1_USBPHY_SS_PST_N>; + reset-names = "reset", "preset"; + + clocks = <&scmi_clk CLK_TREE_USB3A_PHY3_GATE>, + <&scmi_clk CLK_TREE_USB3A_PHY_x2_REF>; + clock-names = "apb_clk", "ref_clk"; + + usb-port@0 { + reg = <0>; + #phy-cells = <0>; + }; + + usb-port@1 { + reg = <1>; + #phy-cells = <0>; + }; + };Documentation/devicetree/bindings/usb/cix,sky1-usbssp.yaml new file +15
-0@@ -0,0 +1,153 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/usb/cix,sky1-usbssp.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: CIX Sky1 Cadence USBSSP Controller + +maintainers: + - Hongliang Yang <[email protected]> + +description: + The CIX Sky1 USBSSP controller is based on the Cadence USBSSP DRD + controller. The integration adds glue registers and mode strap controls + in the Sky1 S5 system controller. The CIX glue node wraps a Cadence
Documentation/devicetree/bindings/usb/cix,sky1-usbssp.yaml line 25
Quoted 10 lines
Documentation/devicetree/bindings/usb/cix,sky1-usbssp.yaml new file +10
-0+ USBSSP core as a child node. + +properties: + compatible: + const: cix,sky1-usbssp + + reg: + items: + - description: AXI property configuration register + - description: Controller status register
Registers are not address spaces. Devices do not have address spaces of one register, so this is not a real device.
Documentation/devicetree/bindings/usb/cix,sky1-usbssp.yaml line 29
Quoted 4 lines
Documentation/devicetree/bindings/usb/cix,sky1-usbssp.yaml new file +4
-0+ + reg-names: + items: + - const: axi_property
axi
Documentation/devicetree/bindings/usb/cix,sky1-usbssp.yaml line 30
Quoted 1 line
Documentation/devicetree/bindings/usb/cix,sky1-usbssp.yaml new file +1
-0+ - const: controller_status
controller
Quoted 20 lines
Documentation/devicetree/bindings/usb/cix,sky1-usbssp.yaml new file +20
-0+ + clocks: + items: + - description: Start-of-frame clock + - description: AXI bus clock + - description: Low-power mode clock + - description: APB register interface clock + + clock-names: + items: + - const: sof_clk + - const: usb_aclk + - const: lpm_clk + - const: usb_pclk + + resets: + items: + - description: APB register reset + - description: Controller reset +
Documentation/devicetree/bindings/usb/cix,sky1-usbssp.yaml line 60
Quoted 10 lines
Documentation/devicetree/bindings/usb/cix,sky1-usbssp.yaml new file +10
-0+ reset-names: + items: + - const: usb_preset + - const: usb_reset + + cix,usb_syscon: + $ref: /schemas/types.yaml#/definitions/phandle + description: + Phandle to the Sky1 S5 system controller used to program USB mode + strap controls.
So this is part of that device most likely.
Quoted 7 lines
Documentation/devicetree/bindings/usb/cix,sky1-usbssp.yaml new file +7
-0+ + axi_bmax_value: + $ref: /schemas/types.yaml#/definitions/uint32 + default: 0x7 + description: + AXI bus maximum burst length configuration value. +
Documentation/devicetree/bindings/usb/cix,sky1-usbssp.yaml line 77
Quoted 10 lines
Documentation/devicetree/bindings/usb/cix,sky1-usbssp.yaml new file +10
-0+ "#address-cells": + const: 2 + + "#size-cells": + const: 2 + + ranges: true + +patternProperties: + "^usb-controller@[0-9a-f]+$":
Why using completely different names than entire Linux kernel?
Documentation/devicetree/bindings/usb/cix,sky1-usbssp.yaml line 81
Quoted 4 lines
Documentation/devicetree/bindings/usb/cix,sky1-usbssp.yaml new file +4
-0+ $ref: cdns,usb3.yaml# + description: + The Cadence USBSSP core controller node. See cdns,usb3.yaml + for properties such as dr_mode, maximum-speed, phys, and interrupts.
Redundant description.
Quoted 25 lines
Documentation/devicetree/bindings/usb/cix,sky1-usbssp.yaml new file +25
-0+ unevaluatedProperties: false + +required: + - compatible + - reg + - reg-names + - clocks + - clock-names + - resets + - reset-names + - cix,usb_syscon + - "#address-cells" + - "#size-cells" + - ranges + +unevaluatedProperties: false + +examples: + - | + #include <dt-bindings/clock/cix,sky1.h> + #include <dt-bindings/interrupt-controller/arm-gic.h> + #include <dt-bindings/reset/cix,sky1-s5-system-control.h> + + soc { + #address-cells = <2>;
Documentation/devicetree/bindings/usb/cix,sky1-usbssp.yaml line 116
Quoted 10 lines
Documentation/devicetree/bindings/usb/cix,sky1-usbssp.yaml new file +10
-0+ #size-cells = <2>; + + usb@91c0300 { + compatible = "cix,sky1-usbssp"; + #address-cells = <2>; + #size-cells = <2>; + ranges; + + reg = <0x00 0x091c0314 0x00 0x4>, + <0x00 0x091c0400 0x00 0x4>;
Nope. You do not have a device with two registers.
Best regards,
Krzysztof
Re: [PATCH v1 1/4] dt-bindings: Add CIX Sky1 USB bindings
Hi Krzysztof,
Thank you for the review. Most of the comments are already addressed in v2 [1]; the remaining points are answered inline below.
[1] https://lore.kernel.org/all/[email protected]/
Quoted 6 lines · Krzysztof Kozlowski
Please use subject prefixes matching the subsystem. You can get them for example with
git log --oneline -- DIRECTORY_OR_FILEon the directory your patch is touching. For bindings, the preferred subjects are explained here:
https://www.kernel.org/doc/html/latest/devicetree/bindings/submitting-patches.html#i-for-patch-submitters
Quoted 6 lines
A nit, subject: drop second/last, redundant "bindings". The "dt-bindings" prefix is already stating that these are bindings. See also:
https://elixir.bootlin.com/linux/v7.1-rc7/source/Documentation/devicetree/bindings/submitting-patches.rst#L23And do not combine USB patches with other subsystems.
Done in v2: the combined bindings patch is split into separate patches with "dt-bindings: phy:" and "dt-bindings: usb:" subject prefixes, one schema per patch, e.g.
dt-bindings: phy: Add CIX Sky1 USB3 PHY
dt-bindings: usb: Add CIX Sky1 USBSSP controller
Quoted 1 line
Please read and follow DTS coding style.
Done in v2: the schemas and the new DTS regions now pass dt-check-style in strict mode.
Quoted 3 lines
Quoted 1 line
+unevaluatedProperties: false
Which other schema do you want to reference?
None. Changed to additionalProperties: false in v2.
Quoted 7 lines
Documentation/devicetree/bindings/usb/cix,sky1-usbssp.yaml line 25
Quoted 4 lines
Documentation/devicetree/bindings/usb/cix,sky1-usbssp.yaml new file +4
-0+ reg: + items: + - description: AXI property configuration register + - description: Controller status registerRegisters are not address spaces. Devices do not have address spaces of one register, so this is not a real device.
I understand the concern, and we looked at this again against the SoC documentation. These two registers are RCSU (system configuration unit) registers, but each of them is dedicated to one USB controller and not shared with any other device:
- The first register is the controller's Control Register for the AXI cache attributes. Its bit fields are awcache[3:0] (bits 3:0) and arcache[3:0] (bits 7:4), i.e. the AXI cache attributes of the controller's own AXI master interface. The glue driver programs it once during initialization.
- The second register is a status register providing the AXI clock valid status the driver polls while enabling the controller.
The two instances submitted in this series illustrate the per-device
offsets: the USB4 controller uses 0x091c0314 (AXI cache attributes) and 0x091c0400 (status), while USB5 uses 0x091c0324 and 0x091c0410.
The reason they end up in a separate node from the Cadence USBSSP core is purely physical: on Sky1 the controller's control registers and the Cadence USBSSP core registers are two disjoint regions in the address map (e.g. 0x091c0314 vs 0x091d0000 for the USB4 controller). The glue node therefore describes the Sky1-specific control registers, clocks and resets, while the core node is the Cadence USBSSP core itself, describing the actual register windows the cdns3 driver maps ("otg", "xhci", "dev").
That said, the register windows are admittedly tiny, so if you prefer this modelled differently we are open to suggestions. One alternative we considered was folding the control register file into the core node and referencing the Sky1 glue properties from there, but that would mix the Cadence core registers with Sky1-specific ones and lose the 1:1 mapping to the hardware topology.
Quoted 7 lines
Quoted 1 line
+ - const:
axi_propertyaxi
Quoted 1 line
+ - const:
controller_statuscontroller
Renamed in v2 (reg-names = "axi", "controller").
Quoted 7 lines
Documentation/devicetree/bindings/usb/cix,sky1-usbssp.yaml line 60
Quoted 5 lines
Documentation/devicetree/bindings/usb/cix,sky1-usbssp.yaml new file +5
-0+ cix,usb_syscon: + $ref: /schemas/types.yaml#/definitions/phandle + description: + Phandle to the Sky1 S5 system controller used to program USB mode + strap controls.So this is part of that device most likely.
The OTG mode strap bits live in the S5 power-management controller, which is a separate hardware block shared by several subsystems, so they are not part of the USB controller's register file. That is why the strap is accessed through the syscon phandle instead of a reg entry, while the per-controller registers discussed above stay in the USB node's own reg.
Quoted 5 lines
Documentation/devicetree/bindings/usb/cix,sky1-usbssp.yaml line 66
Quoted 5 lines
Documentation/devicetree/bindings/usb/cix,sky1-usbssp.yaml new file +5
-0+ axi_bmax_value: + $ref: /schemas/types.yaml#/definitions/uint32 + default: 0x7 + description: + AXI bus maximum burst length configuration value.
Dropped in v2: the value is fixed for the SoC, so the driver now uses a compile-time constant and the property is gone.
Quoted 4 lines
Documentation/devicetree/bindings/usb/cix,sky1-usbssp.yaml line 77
Quoted 2 lines
Documentation/devicetree/bindings/usb/cix,sky1-usbssp.yaml new file +2
-0+patternProperties: + "^usb-controller@[0-9a-f]+$":Why using completely different names than entire Linux kernel?
Renamed to "usb@..." in v2, matching the cdns,usb3 nodes elsewhere.
Quoted 6 lines
Documentation/devicetree/bindings/usb/cix,sky1-usbssp.yaml line 81
Quoted 4 lines
Documentation/devicetree/bindings/usb/cix,sky1-usbssp.yaml new file +4
-0+ $ref: cdns,usb3.yaml# + description: + The Cadence USBSSP core controller node. See cdns,usb3.yaml + for properties such as dr_mode, maximum-speed, phys, and interrupts.Redundant description.
Shortened in v2.
Best regards,
Hongliang Yang
Re: [PATCH v1 1/4] dt-bindings: Add CIX Sky1 USB bindings
Quoted 20 lines · Hongliang Yang
Quoted 8 lines
Documentation/devicetree/bindings/usb/cix,sky1-usbssp.yaml line 25
Quoted 5 lines
Documentation/devicetree/bindings/usb/cix,sky1-usbssp.yaml new file +4
-0+ reg: + items: + - description: AXI property configuration register + - description: Controller status registerRegisters are not address spaces. Devices do not have address spaces of one register, so this is not a real device.
I understand the concern, and we looked at this again against the SoC documentation. These two registers are RCSU (system configuration unit) registers, but each of them is dedicated to one USB controller and not shared with any other device:
- The first register is the controller's Control Register for the AXI cache attributes. Its bit fields are awcache[3:0] (bits 3:0) and arcache[3:0] (bits 7:4), i.e. the AXI cache attributes of the controller's own AXI master interface. The glue driver programs it once during initialization.
Quoted 6 lines
- The second register is a status register providing the AXI clock valid status the driver polls while enabling the controller.
The two instances submitted in this series illustrate the per-device
offsets: the USB4 controller uses0x091c0314(AXI cache attributes) and0x091c0400(status), while USB5 uses0x091c0324and0x091c0410.
You need to describe the address ranges, hierarchy, not the registers.
Best regards,
Krzysztof
v3 cover Add CIX Sky1 USB3/USBSSP support
In reply to Krzysztof KozlowskiAdd USB3 PHY binding and driver, Cadence USBSSP glue binding and driver, and USB4/USB5 device tree nodes for the CIX Sky1 SoC.
This series adds support for the USB4 and USB5 controllers (based on Cadence USBSSP DRD) found on the CIX Sky1 SoC, along with their associated multi-port USB3 PHY.
The two wrapper nodes each carry two 4-byte register windows: these are per-controller RCSU control/status registers (AXI cache attribute and clock-status) that live inside the shared RCSU aperture, so they cannot be expressed as a syscon; the OTG mode straps live in the S5 system control block and are referenced through the cix,usb-syscon phandle. This was discussed during review of v1 [1].
Changes in v3:
Device tree:
- Fix the interrupt specifiers of the usb4/usb5 child nodes: the Sky1 GICv3 interrupt controller uses 4 cells, so add the missing fourth (empty) cell to every entry. Without it the controller IRQs cannot be resolved (platform_get_irq_byname() returns -ENXIO).
USB3 PHY driver:
- Assert the hardware resets before registering the PHY provider, so a consumer cannot race with the probe-time assertion.
- Disable the clocks in LIFO order (ref before apb) in phy_exit().
- Reorder the error unroll path of phy_init() to assert the resets before disabling the clocks, matching the teardown sequence, and fix the goto targets so clocks that were never enabled are not disabled.
- Check fwnode_get_name() for NULL and only match "usb-port@" child nodes exactly, instead of any name with a "usb-port" or "USB" prefix.
USBSSP glue driver:
- Add error cleanup to the probe paths: unmap the xhci/dev registers, assert the resets and disable the clocks.
- Replace the static of_dev_auxdata array with a probe-local one and allocate the platform data with devm_kzalloc(), so repeated probes cannot corrupt shared state or leak the allocation.
- Quiesce the hardware on remove: assert (not deassert) the resets before disabling the clocks, and balance the runtime PM usage count with pm_runtime_disable()/pm_runtime_set_suspended()/ pm_runtime_put_noidle().
- Check cdns->host_dev for NULL before dereferencing it in the platform suspend callback.
- Drop the reference of the OF node returned by of_get_next_child().
- Stop clearing the clock pointers in the enable error paths, which left NULL pointers in the driver state on later resume attempts.
- Take device references in the shutdown child-iteration callbacks and drop them after use to avoid a use-after-free.
- Use BIT(31) instead of a signed 1 << 31 shift.
- Assign the system sleep callbacks with SYSTEM_SLEEP_PM_OPS() and pm_sleep_ptr() instead of a plain dev_pm_ops behind #ifdef.
[1] https://lore.kernel.org/linux-phy/[email protected]/
Hongliang Yang (5):
dt-bindings: phy: Add CIX Sky1 USB3 PHY
dt-bindings: usb: Add CIX Sky1 USBSSP controller
phy: cix: Add CIX Sky1 USB3 PHY driver
usb: cdns3: Add CIX Sky1 glue driver
arm64: dts: cix: Add USB4/USB5 nodes for Sky1
.../bindings/phy/cix,sky1-usb3-phy.yaml | 107 +++ .../bindings/usb/cix,sky1-usbssp.yaml | 137 ++++ MAINTAINERS | 3 + arch/arm64/boot/dts/cix/sky1-orion-o6.dts | 54 ++ arch/arm64/boot/dts/cix/sky1.dtsi | 118 +++ drivers/phy/Kconfig | 1 + drivers/phy/Makefile | 1 + drivers/phy/cix/Kconfig | 20 + drivers/phy/cix/Makefile | 6 + drivers/phy/cix/phy-cix-usb3.c | 410 +++++++++++ drivers/phy/cix/phy-cix-usbdp.h | 310 ++++++++ drivers/usb/cdns3/Kconfig | 13 + drivers/usb/cdns3/Makefile | 1 + drivers/usb/cdns3/cdnsp-sky1.c | 696 ++++++++++++++++++ drivers/usb/cdns3/cdnsp-sky1.h | 127 ++++ 15 files changed, 2004 insertions(+) create mode 100644 Documentation/devicetree/bindings/phy/cix,sky1-usb3-phy.yaml create mode 100644 Documentation/devicetree/bindings/usb/cix,sky1-usbssp.yaml create mode 100644 drivers/phy/cix/Kconfig create mode 100644 drivers/phy/cix/Makefile create mode 100644 drivers/phy/cix/phy-cix-usb3.c create mode 100644 drivers/phy/cix/phy-cix-usbdp.h create mode 100644 drivers/usb/cdns3/cdnsp-sky1.c create mode 100644 drivers/usb/cdns3/cdnsp-sky1.h
Signature · 1 line
2.54.0
PATCH v3 1/5 dt-bindings: phy: Add CIX Sky1 USB3 PHY
Add device tree binding for the CIX Sky1 USB3 PHY, a multi-port SuperSpeedPlus PHY supporting up to two USB3 lanes.
--- .../bindings/phy/cix,sky1-usb3-phy.yaml | 107 ++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 Documentation/devicetree/bindings/phy/cix,sky1-usb3-phy.yaml
Documentation/devicetree/bindings/phy/cix,sky1-usb3-phy.yaml new file +107 -0
@@ -0,0 +1,107 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/phy/cix,sky1-usb3-phy.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: CIX Sky1 USB3 PHY + +maintainers: + - Hongliang Yang <[email protected]> + +description: + The CIX Sky1 USB3 PHY is a multi-port SuperSpeedPlus PHY that + supports up to two USB3 lanes. Each port is represented as a + child node of the PHY controller. + +properties: + compatible: + const: cix,sky1-usb3-phy + + reg: + maxItems: 1 + + clocks: + items: + - description: APB register interface clock + - description: PHY reference clock + + clock-names: + items: + - const: apb + - const: ref + + resets: + items: + - description: PHY reset + - description: PHY APB preset + + reset-names: + items: + - const: core + - const: apb + + "#address-cells": + const: 1 + + "#size-cells": + const: 0 + +patternProperties: + "^usb-port@[0-9a-f]+$": + type: object + description: + A single USB3 PHY port/lane. + + properties: + reg: + maxItems: 1 + + "#phy-cells": + const: 0 + + required: + - reg + - "#phy-cells" + + additionalProperties: false + +required: + - compatible + - reg + - clocks + - clock-names + - resets + - reset-names + - "#address-cells" + - "#size-cells" + +additionalProperties: false + +examples: + - | + #include <dt-bindings/clock/cix,sky1.h> + #include <dt-bindings/reset/cix,sky1-s5-system-control.h> + + usb-phy@9210000 { + compatible = "cix,sky1-usb3-phy"; + reg = <0x9210000 0x40000>; + #address-cells = <1>; + clocks = <&scmi_clk CLK_TREE_USB3A_PHY3_GATE>, + <&scmi_clk CLK_TREE_USB3A_PHY_x2_REF>; + clock-names = "apb", "ref"; + resets = <&s5_syscon SKY1_USBPHY_SS_RST_N>, + <&s5_syscon SKY1_USBPHY_SS_PST_N>; + reset-names = "core", "apb"; + #size-cells = <0>; + + usb-port@0 { + reg = <0>; + #phy-cells = <0>; + }; + + usb-port@1 { + reg = <1>; + #phy-cells = <0>; + }; + };
Signature · 1 line
2.54.0
PATCH v3 2/5 dt-bindings: usb: Add CIX Sky1 USBSSP controller
In reply to Hongliang YangAdd device tree binding for the CIX Sky1 Cadence USBSSP controller glue layer. The integration adds glue registers and mode strap controls in the Sky1 S5 system controller. The CIX glue node wraps a Cadence USBSSP core as a child node.
--- .../bindings/usb/cix,sky1-usbssp.yaml | 137 ++++++++++++++++++ MAINTAINERS | 3 + 2 files changed, 140 insertions(+) create mode 100644 Documentation/devicetree/bindings/usb/cix,sky1-usbssp.yaml
Documentation/devicetree/bindings/usb/cix,sky1-usbssp.yaml new file +137 -0
@@ -0,0 +1,137 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/usb/cix,sky1-usbssp.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: CIX Sky1 Cadence USBSSP Controller + +maintainers: + - Hongliang Yang <[email protected]> + +description: + The CIX Sky1 USBSSP controller is based on the Cadence USBSSP DRD + controller. The integration adds glue registers and mode strap controls + in the Sky1 S5 system controller. The CIX glue node wraps a Cadence + USBSSP core as a child node. + +properties: + compatible: + const: cix,sky1-usbssp + + reg: + items: + - description: AXI property configuration register + - description: Controller status register + + reg-names: + items: + - const: axi + - const: controller + + clocks: + items: + - description: Start-of-frame clock + - description: AXI bus clock + - description: Low-power mode clock + - description: APB register interface clock + + clock-names: + items: + - const: sof + - const: axi + - const: lpm + - const: apb + + resets: + items: + - description: APB register reset + - description: Controller reset + + reset-names: + items: + - const: apb + - const: core + + cix,usb-syscon: + $ref: /schemas/types.yaml#/definitions/phandle + description: + Phandle to the Sky1 S5 system controller used to program USB mode + strap controls. + + "#address-cells": + const: 2 + + "#size-cells": + const: 2 + + ranges: true + +patternProperties: + "^usb@[0-9a-f]+$": + $ref: cdns,usb3.yaml# + +required: + - compatible + - reg + - reg-names + - clocks + - clock-names + - resets + - reset-names + - cix,usb-syscon + - "#address-cells" + - "#size-cells" + - ranges + +unevaluatedProperties: false + +examples: + - | + #include <dt-bindings/clock/cix,sky1.h> + #include <dt-bindings/interrupt-controller/arm-gic.h> + #include <dt-bindings/reset/cix,sky1-s5-system-control.h> + + soc { + #address-cells = <2>; + #size-cells = <2>; + + usb@91c0314 { + compatible = "cix,sky1-usbssp"; + reg = <0x00 0x091c0314 0x00 0x4>, + <0x00 0x091c0400 0x00 0x4>; + reg-names = "axi", "controller"; + ranges; + #address-cells = <2>; + + clocks = <&scmi_clk CLK_TREE_USB3A_H0_CLK_SOF>, + <&scmi_clk CLK_TREE_USB3A_0_AXI_GATE>, + <&scmi_clk CLK_TREE_USB3A_H0_CLK_LPM>, + <&scmi_clk CLK_TREE_USB3A_0_APB_GATE>; + clock-names = "sof", "axi", "lpm", "apb"; + resets = <&src SKY1_USBC_SS2_PRST_N>, + <&src SKY1_USBC_SS2_RST_N>; + reset-names = "apb", "core"; + #size-cells = <2>; + cix,usb-syscon = <&src>; + + usb@91d0000 { + compatible = "cdns,usb3"; + reg = <0x00 0x91d0000 0x00 0x4000>, + <0x00 0x91d8000 0x00 0x8000>, + <0x00 0x91d4000 0x00 0x4000>; + reg-names = "otg", "xhci", "dev"; + dr_mode = "otg"; + + interrupts = <GIC_SPI 168 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 169 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 170 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 171 IRQ_TYPE_LEVEL_HIGH>; + interrupt-names = "host", "peripheral", "otg", "wakeup"; + maximum-speed = "super-speed-plus"; + + phys = <&usb3_phy4_0>, <&usb2_phy6>; + phy-names = "cdns3,usb3-phy", "cdns3,usb2-phy"; + }; + }; + };
MAINTAINERS +3 -0
@@ -2775,8 +2775,11 @@ S: Maintained T: git git://git.kernel.org/pub/scm/linux/kernel/git/peter.chen/cix.git F: Documentation/devicetree/bindings/arm/cix.yaml F: Documentation/devicetree/bindings/mailbox/cix,sky1-mbox.yaml +F: Documentation/devicetree/bindings/phy/cix,sky1-usb3-phy.yaml +F: Documentation/devicetree/bindings/usb/cix,sky1-usbssp.yaml F: arch/arm64/boot/dts/cix/ F: drivers/mailbox/cix-mailbox.c +F: drivers/phy/cix/ K: \bcix\b ARM/CLKDEV SUPPORT
Signature · 1 line
2.54.0
Re: [PATCH v3 2/5] dt-bindings: usb: Add CIX Sky1 USBSSP controller
Quoted 4 lines · Hongliang Yang
Add device tree binding for the CIX Sky1 Cadence USBSSP controller glue layer. The integration adds glue registers and mode strap controls in the Sky1 S5 system controller. The CIX glue node wraps a Cadence USBSSP core as a child node.
Do not attach (thread) your patchsets to some other threads (unrelated or older versions). This buries them deep in the mailbox and might interfere with applying entire sets. See also:
https://elixir.bootlin.com/linux/v6.16-rc2/source/Documentation/process/submitting-patches.rst#L830
Quoted 29 lines
Signed-off-by Hongliang Yang <[email protected]>--- .../bindings/usb/cix,sky1-usbssp.yaml | 137 ++++++++++++++++++ MAINTAINERS | 3 + 2 files changed, 140 insertions(+) create mode 100644 Documentation/devicetree/bindings/usb/cix,sky1-usbssp.yamlDocumentation/devicetree/bindings/usb/cix,sky1-usbssp.yaml new file +15
-0@@ -0,0 +1,137 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/usb/cix,sky1-usbssp.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: CIX Sky1 Cadence USBSSP Controller + +maintainers: + - Hongliang Yang <[email protected]> + +description: + The CIX Sky1 USBSSP controller is based on the Cadence USBSSP DRD + controller. The integration adds glue registers and mode strap controls + in the Sky1 S5 system controller. The CIX glue node wraps a Cadence
Documentation/devicetree/bindings/usb/cix,sky1-usbssp.yaml line 25
Quoted 10 lines
Documentation/devicetree/bindings/usb/cix,sky1-usbssp.yaml new file +10
-0+ USBSSP core as a child node. + +properties: + compatible: + const: cix,sky1-usbssp + + reg: + items: + - description: AXI property configuration register + - description: Controller status register
Same comments. Individual registers are not a device.
What is the actual memory map there?
Best regards,
Krzysztof
PATCH v3 3/5 phy: cix: Add CIX Sky1 USB3 PHY driver
In reply to Hongliang YangAdd PHY driver for the USB3 PHY found on CIX Sky1 SoCs. The driver handles initialization, reset, and clock management for the multi-port USB3 PHY.
--- drivers/phy/Kconfig | 1 + drivers/phy/Makefile | 1 + drivers/phy/cix/Kconfig | 20 ++ drivers/phy/cix/Makefile | 6 + drivers/phy/cix/phy-cix-usb3.c | 410 ++++++++++++++++++++++++++++++++ drivers/phy/cix/phy-cix-usbdp.h | 310 ++++++++++++++++++++++++ 6 files changed, 748 insertions(+) create mode 100644 drivers/phy/cix/Kconfig create mode 100644 drivers/phy/cix/Makefile create mode 100644 drivers/phy/cix/phy-cix-usb3.c create mode 100644 drivers/phy/cix/phy-cix-usbdp.h
drivers/phy/Kconfig +1 -0
@@ -175,6 +175,7 @@ source "drivers/phy/axiado/Kconfig" source "drivers/phy/broadcom/Kconfig" source "drivers/phy/cadence/Kconfig" source "drivers/phy/canaan/Kconfig" +source "drivers/phy/cix/Kconfig" source "drivers/phy/eswin/Kconfig" source "drivers/phy/freescale/Kconfig" source "drivers/phy/hisilicon/Kconfig"
drivers/phy/Makefile +1 -0
@@ -27,6 +27,7 @@ obj-$(CONFIG_GENERIC_PHY) += allwinner/ \ broadcom/ \ cadence/ \ canaan/ \ + cix/ \ eswin/ \ freescale/ \ hisilicon/ \
drivers/phy/cix/Kconfig new file +20 -0
@@ -0,0 +1,20 @@ +# SPDX-License-Identifier: GPL-2.0-only +# +# Phy drivers for Cix PHYs +# + +if ARCH_CIX || COMPILE_TEST + +config PHY_CIX_USB3 + tristate "Cix USB3 PHY Driver" + depends on OF && HAS_IOMEM + select GENERIC_PHY + help + Enable this to support the CIX USB3 PHY for TYPEA Connection. + + This driver provides initialization and power management for + the USB3 PHY found on CIX Sky1 SoCs. + + If unsure, say N. + +endif # ARCH_CIX || COMPILE_TEST
drivers/phy/cix/Makefile new file +6 -0
@@ -0,0 +1,6 @@ +# SPDX-License-Identifier: GPL-2.0 +# +# Makefile for the Cix phy drivers. +# + +obj-$(CONFIG_PHY_CIX_USB3) += phy-cix-usb3.o
drivers/phy/cix/phy-cix-usb3.c new file +410 -0
410 lines not on this page · raw message
drivers/phy/cix/phy-cix-usbdp.h new file +310 -0
310 lines not on this page · raw message
Signature · 1 line
2.54.0
[email protected]
AI reviewRe: [PATCH v3 3/5] phy: cix: Add CIX Sky1 USB3 PHY driver
Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider: - [Low] Incorrect format specifier for printing `device_node` pointer. - [Low] Missing `devm_mutex_init()`…
Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
- [Low] Incorrect format specifier for printing device_node pointer.
- [Low] Missing devm_mutex_init() for devm-allocated mutex.
- [Low] Missing explicit inclusion of <linux/property.h>.
- [Low] Unused data structures and enumerations in the header file.
--
commit 5cad48211eb5758f9a40687789544cb07846cb4a
Author: Hongliang Yang <[email protected]>
phy: cix: Add CIX Sky1 USB3 PHY driver
Add PHY driver for the USB3 PHY found on CIX Sky1 SoCs. The driver handles initialization, reset, and clock management for the multi-port USB3 PHY.
Quoted 14 lines
drivers/phy/cix/phy-cix-usb3.c new file +8
-0@@ -0,0 +1,410 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* phy driver for cdn_sd0803_t7g_typea +* +* Author: Hongliang Yang <[email protected]> +*/ + +#include <linux/clk.h>
drivers/phy/cix/phy-cix-usb3.c line 18
Quoted 10 lines
drivers/phy/cix/phy-cix-usb3.c new file +10
-0+#include <linux/io.h> +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/mutex.h> +#include <linux/of.h> +#include <linux/phy/phy.h> +#include <linux/platform_device.h> +#include <linux/regmap.h> +#include <linux/reset.h> +#include "phy-cix-usbdp.h"
[Severity: Low]
Since the driver uses device_for_each_child_node_scoped(), should <linux/property.h> be explicitly included here to avoid relying on implicit dependencies from other headers?
[ ... ]
Quoted 8 lines
drivers/phy/cix/phy-cix-usb3.c new file +8
-0+static int cix_u3phy_probe (struct platform_device *pdev) +{ +struct cix_u3phy *u3phy; +struct device *dev = &pdev->dev; +struct phy_provider *phy_provider; +struct device_node *np = dev->of_node; +struct device_node *child_np; +struct phy *phy;
drivers/phy/cix/phy-cix-usb3.c line 326
Quoted 10 lines
drivers/phy/cix/phy-cix-usb3.c new file +10
-0+int ret; + + u3phy =devm_kzalloc (dev,sizeof (*u3phy),GFP_KERNEL ); +if (!u3phy) +return -ENOMEM ; +dev_set_drvdata (dev, u3phy); + u3phy->dev = dev; + u3phy->cfg =device_get_match_data (dev); +if (!u3phy->cfg) { +dev_err (dev,"no OF data can be matched with %p node\n" , np);
[Severity: Low]
Will this print the raw pointer address instead of the device node name? Since np is a device_node pointer, should the %pOF format specifier be used instead?
Quoted 3 lines
drivers/phy/cix/phy-cix-usb3.c new file +3
-0+return -EINVAL ; + } + u3phy->reset =devm_reset_control_get_exclusive (dev,"core" );
[ ... ]
drivers/phy/cix/phy-cix-usb3.c line 357
Quoted 9 lines
drivers/phy/cix/phy-cix-usb3.c new file +9
-0+ u3phy->base =devm_platform_ioremap_resource (pdev,0 ); +if (IS_ERR (u3phy->base)) +return PTR_ERR (u3phy->base); + u3phy->phy_regmap =devm_regmap_init (dev,NULL , u3phy, &cix_u3phy_regmap_cfg); +if (IS_ERR (u3phy->phy_regmap)) { +dev_err (dev,"failed to remap phy register\n" ); +return PTR_ERR (u3phy->phy_regmap); + } +mutex_init (&u3phy->mutex);
[Severity: Low]
Since u3phy is allocated using devm_kzalloc(), the memory will be automatically freed on driver unbind. When initialized with mutex_init(), mutex_destroy() won't be called automatically, which skips cleanup steps expected by the resource management API for devm-allocated mutexes. Should devm_mutex_init() be used here instead?
Quoted 2 lines
drivers/phy/cix/phy-cix-usb3.c new file +2
-0+device_for_each_child_node_scoped (dev, child_fn) { +const char *name =fwnode_get_name (child_fn);
[ ... ]
Quoted 6 lines
drivers/phy/cix/phy-cix-usbdp.h new file +0
-0@@ -0,0 +1,310 @@
[ ... ]
Quoted 10 lines
drivers/phy/cix/phy-cix-usbdp.h new file +10
-0+/* gop status address */ +#define GOP_STATUS_ADDRESS 0x83E05000 +#define GOP_STATUS_SIZE 0x04 + +struct gop_status { +unsigned char phy_status[4 ]; +}; + +/* +* 0: usb
drivers/phy/cix/phy-cix-usbdp.h line 308
Quoted 10 lines
drivers/phy/cix/phy-cix-usbdp.h new file +10
-0+* 1: 2 lane usb+ 2 lane dp +* 2: usb device +* 3: usb2.0 + 4 lane dp +*/ +enum phy_role { +USB_ROLE_NONE , +USB_ROLE_HOST , +USB_ROLE_DEVICE , +USB_ROLE_HOST_20 , +};
[Severity: Low]
Are this struct and enum needed? Neither gop_status nor phy_role appear to be used anywhere in the provided code.
Quoted 2 lines
drivers/phy/cix/phy-cix-usbdp.h new file +2
-0+ +#endif
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
PATCH v3 4/5 usb: cdns3: Add CIX Sky1 glue driver
In reply to Hongliang YangAdd a glue layer driver for the Cadence USBSSP controller integrated in the CIX Sky1 SoC. The driver manages the controller clocks, resets, and the mode strap controls located in the Sky1 S5 system controller.
--- drivers/usb/cdns3/Kconfig | 13 + drivers/usb/cdns3/Makefile | 1 + drivers/usb/cdns3/cdnsp-sky1.c | 696 +++++++++++++++++++++++++++++++++ drivers/usb/cdns3/cdnsp-sky1.h | 127 ++++++ 4 files changed, 837 insertions(+) create mode 100644 drivers/usb/cdns3/cdnsp-sky1.c create mode 100644 drivers/usb/cdns3/cdnsp-sky1.h
drivers/usb/cdns3/Kconfig +13 -0
@@ -77,6 +77,19 @@ config USB_CDNSP_PCI If you choose to build this driver as module it will be dynamically linked and module will be called cdnsp-pci.ko +config USB_CDNSP_SKY1 + tristate "Cadence USB3 support on CIX Sky1 SoC platforms" + depends on USB_CDNS3 + depends on ARCH_CIX || COMPILE_TEST + default USB_CDNS3 + help + Glue driver for the Cadence USB dual-role controllers on CIX Sky1 + (device tree compatible cix,sky1-usb3). It enables clocks and resets + from the SoC, then uses the shared cdns3 platform core (cdns.ko). + + If built as a module, the module is named cdnsp-sky1.ko and must be + loaded after the cdns core module when both are loadable modules. + config USB_CDNS3_TI tristate "Cadence USB3 support on TI platforms" depends on ARCH_K3 || COMPILE_TEST
drivers/usb/cdns3/Makefile +1 -0
@@ -28,3 +28,4 @@ obj-$(CONFIG_USB_CDNSP_PCI) += cdnsp-pci.o obj-$(CONFIG_USB_CDNS3_TI) += cdns3-ti.o obj-$(CONFIG_USB_CDNS3_IMX) += cdns3-imx.o obj-$(CONFIG_USB_CDNS3_STARFIVE) += cdns3-starfive.o +obj-$(CONFIG_USB_CDNSP_SKY1) += cdnsp-sky1.o
drivers/usb/cdns3/cdnsp-sky1.c new file +696 -0
696 lines not on this page · raw message
drivers/usb/cdns3/cdnsp-sky1.h new file +127 -0
127 lines not on this page · raw message
Signature · 1 line
2.54.0
[email protected]
AI reviewRe: [PATCH v3 4/5] usb: cdns3: Add CIX Sky1 glue driver
Thank you for your contribution! Sashiko AI review found 7 potential issue(s) to consider: - [High] Double disable of clocks on probe error path causes reference count underflows. - [High] Incorrect…
Thank you for your contribution! Sashiko AI review found 7 potential issue(s) to consider:
- [High] Double disable of clocks on probe error path causes reference count underflows.
- [High] Incorrect operation order and disable_irq() on a shared IRQ in cdnsp_sky1_shutdown.
- [High] Lockless access to cdns->host_dev during system suspend and shutdown leads to a Use-After-Free.
- [Medium] Incorrect PM wrapper macro used for the dev_pm_ops structure pointer.
- [Medium] Fragile lookup of Device Tree child nodes for register addresses.
- [Medium] Unconditional disabling of AXI and SOF clocks during suspend breaks Wake-on-USB.
- [Low] Missing inclusion of <linux/iopoll.h>.
--
commit 5ad3503fa82899af71645298ce56167ad8a8a82d
Author: Hongliang Yang <[email protected]> Date: Thu Sep 3 02:35:20 2026 +0000
usb: cdns3: Add CIX Sky1 glue driver
This patch adds a glue layer driver for the Cadence USBSSP controller integrated into the CIX Sky1 SoC. It enables the controller clocks, resets, and handles mode strap controls via the Sky1 S5 system controller.
Quoted 2 lines
drivers/usb/cdns3/cdnsp-sky1.c new file +0
-0
[ ... ]
drivers/usb/cdns3/cdnsp-sky1.c line 170
Quoted 8 lines
drivers/usb/cdns3/cdnsp-sky1.c new file +8
-0+static int sky1_handshake (void __iomem *ptr,u32 mask,u32 done,u64 timeout_us) +{ +u32 result; +int ret; + + ret =readl_poll_timeout (ptr, result, + (result & mask) == done || result ==U32_MAX , +10 , timeout_us);
[Severity: Low]
Could this fail to compile on certain architectures or configurations?
The readl_poll_timeout macro is used here, but its defining header <linux/iopoll.h> is not included in the file.
[ ... ]
drivers/usb/cdns3/cdnsp-sky1.c line 180
Quoted 5 lines
drivers/usb/cdns3/cdnsp-sky1.c new file +5
-0+static int cdns_sky1_platform_suspend (struct device *dev, +bool suspend,bool wakeup) +{ +struct cdns *cdns =dev_get_drvdata (dev); +struct platform_device *xhci_dev = cdns->host_dev;
[Severity: High]
Is it safe to read cdns->host_dev here without holding cdns->mutex?
If a concurrent OTG role switch triggers while the system executes this suspend callback, could this lead to a use-after-free when the host_dev is freed?
[ ... ]
drivers/usb/cdns3/cdnsp-sky1.c line 399
Quoted 11 lines
drivers/usb/cdns3/cdnsp-sky1.c new file +11
-0+static void __iomem *sky1_of_get_addr_by_name (struct device_node *parent,const char *name) +{ +void __iomem *addr =NULL ; +struct device_node *node; +int index; + + node =of_get_next_child (parent,NULL ); +if (!node) +return NULL ; + + index =of_property_match_string (node,"reg-names" , name);
[Severity: Medium]
Could this lookup be fragile against changes in the device tree ordering?
By passing NULL to of_get_next_child, it blindly assumes the target device node is always the very first child.
If the structure is ordered differently, this might abort the probe.
[ ... ]
drivers/usb/cdns3/cdnsp-sky1.c line 529
Quoted 4 lines
drivers/usb/cdns3/cdnsp-sky1.c new file +4
-0+err_quiesce: +reset_control_assert (data->reset); +reset_control_assert (data->preset); +cdnsp_sky1_clk_disable_all (dev);
[Severity: High]
Could this cause a reference count underflow on the clocks?
If cdnsp_sky1_clk_enable_all fails mid-initialization, it cleanly unwinds its own prepared clocks.
Returning the error then propagates up to the probe function which jumps to err_quiesce and unconditionally calls cdnsp_sky1_clk_disable_all, disabling the already unwound clocks a second time.
[ ... ]
drivers/usb/cdns3/cdnsp-sky1.c line 569
Quoted 11 lines
drivers/usb/cdns3/cdnsp-sky1.c new file +11
-0+static int cdnsp_sky1_system_suspend (struct device *dev) +{ +struct cdnsp_sky1 *data =dev_get_drvdata (dev); + +if (!data->wakeup) { +reset_control_assert (data->reset); +reset_control_assert (data->preset); + } +cdnsp_sky1_clk_disable_suspend (dev); +return 0 ; +}
[Severity: Medium]
Does unconditionally disabling the AXI and SOF clocks here break Wake-on-USB functionality?
The comment earlier mentions that closing the axi and sof clock will result in the inability to generate port status change interrupts, yet the disable function is called unconditionally, outside the !data->wakeup block.
[ ... ]
Quoted 7 lines
drivers/usb/cdns3/cdnsp-sky1.c new file +7
-0+static void cdnsp_sky1_shutdown (struct platform_device *pdev) +{ +struct device *dev = &pdev->dev; +struct cdnsp_sky1 *data =dev_get_drvdata (dev); +struct device *cdns_dev =NULL ; +struct device *gadget_dev =NULL ; +struct cdns *cdns =NULL ;
[ ... ]
drivers/usb/cdns3/cdnsp-sky1.c line 659
Quoted 2 lines
drivers/usb/cdns3/cdnsp-sky1.c new file +2
-0+if (cdns && cdns->host_dev) { +struct usb_hcd *hcd =platform_get_drvdata (cdns->host_dev);
[Severity: High]
Similar to the suspend callback, is there a risk of a use-after-free here if an interleaving OTG role switch frees cdns->host_dev right before platform_get_drvdata is called, since this is accessed without cdns->mutex?
drivers/usb/cdns3/cdnsp-sky1.c line 671
Quoted 12 lines
drivers/usb/cdns3/cdnsp-sky1.c new file +12
-0+ +if (hcd && hcd->irq >0 ) { +disable_irq (hcd->irq); +synchronize_irq (hcd->irq); +/* +* Clear HCD_FLAG_HW_ACCESSIBLE before disable_irq. +* This prevents usb_hcd_irq from calling xhci_irq +* (which reads USBSTS) after clocks are disabled. +*/ +clear_bit (HCD_FLAG_HW_ACCESSIBLE , &hcd->flags); + } + }
[Severity: High]
Does calling disable_irq on a potentially shared IRQ line risk breaking other devices on the same line?
Additionally, the comment explicitly states that HCD_FLAG_HW_ACCESSIBLE must be cleared before disable_irq to prevent the interrupt handler from reading USBSTS after clocks are disabled.
However, the implementation executes disable_irq and synchronize_irq before clear_bit.
Could this out-of-order execution risk interrupt handlers firing inappropriately during teardown?
[ ... ]
drivers/usb/cdns3/cdnsp-sky1.c line 689
Quoted 10 lines
drivers/usb/cdns3/cdnsp-sky1.c new file +10
-0+static struct platform_driver cdnsp_sky1_driver = { + .probe = cdnsp_sky1_probe, + .remove = cdnsp_sky1_remove, + .shutdown = cdnsp_sky1_shutdown, + .driver = { + .name ="cdnsp-sky1" , + .of_match_table = cdns_sky1_of_match, + .pm =pm_sleep_ptr (&cdnsp_sky1_pm_ops), + }, +};
[Severity: Medium]
Should the dev_pm_ops structure pointer use the pm_ptr macro instead of pm_sleep_ptr?
If the kernel is built with CONFIG_PM=y but CONFIG_PM_SLEEP=n, using pm_sleep_ptr erroneously excludes the structure pointer, leading to dead code and bypassed power management.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=4
PATCH v3 5/5 arm64: dts: cix: Add USB4/USB5 nodes for Sky1
In reply to Hongliang YangAdd USB4 and USB5 controller nodes and their associated USB3 PHY nodes for the CIX Sky1 SoC. Enable USB4 and USB5 in host mode on the Radxa Orion O6 board.
--- arch/arm64/boot/dts/cix/sky1-orion-o6.dts | 54 ++++++++++ arch/arm64/boot/dts/cix/sky1.dtsi | 118 ++++++++++++++++++++++ 2 files changed, 172 insertions(+)
arch/arm64/boot/dts/cix/sky1-orion-o6.dts +54 -0
@@ -80,6 +80,22 @@ pins { }; }; + + pinctrl_usb4: usb4-power-on-cfg { + pins { + bias-pull-down; + drive-strength = <8>; + pinmux = <CIX_PAD_GPIO041_FUNC_USB_DRIVE_VBUS4>; + }; + }; + + pinctrl_usb5: usb5-power-on-cfg { + pins { + bias-pull-down; + drive-strength = <8>; + pinmux = <CIX_PAD_GPIO042_FUNC_USB_DRIVE_VBUS5>; + }; + }; }; &pcie_x8_rc {
@@ -117,3 +133,41 @@ &s5_gpio2 { &uart2 { status = "okay"; }; + +&usb4 { + pinctrl-0 = <&pinctrl_usb4>; + pinctrl-names = "default"; + + status = "okay"; +}; + +&usbss_4 { + dr_mode = "host"; + + status = "okay"; +}; + +&usb5 { + pinctrl-0 = <&pinctrl_usb5>; + pinctrl-names = "default"; + + status = "okay"; +}; + +&usbss_5 { + dr_mode = "host"; + + status = "okay"; +}; + +&usb3_phy4 { + status = "okay"; + + usb-port@0 { + status = "okay"; + }; + + usb-port@1 { + status = "okay"; + }; +};
arch/arm64/boot/dts/cix/sky1.dtsi +118 -0
136 lines not on this page · raw message
Signature · 1 line
2.54.0
Quoted 7 lines · Hongliang Yang
Add USB3 PHY binding and driver, Cadence USBSSP glue binding and driver, and USB4/USB5 device tree nodes for the CIX Sky1 SoC.
This series adds support for the USB4 and USB5 controllers (based on Cadence USBSSP DRD) found on the CIX Sky1 SoC, along with their associated multi-port USB3 PHY.
Quoted 9 lines
The two wrapper nodes each carry two 4-byte register windows: these are per-controller RCSU control/status registers (AXI cache attribute and clock-status) that live inside the shared RCSU aperture, so they cannot be expressed as a syscon; the OTG mode straps live in the S5 system control block and are referenced through the cix,usb-syscon phandle. This was discussed during review of v1 [1].
Changes in v3:
I do not see how you addressed my feedback from v1. I asked, not to combine USB patches with other subsystems, within one patchset. These are separate patchsets.
Best regards,
Krzysztof
PATCH 2/4 phy: cix: Add CIX Sky1 USB3 PHY driver
In reply to Hongliang YangAdd PHY driver for the USB3 PHY found on CIX Sky1 SoCs. This driver handles PHY initialization, reset, and clock management for the multi-port USB3 PHY.
--- drivers/phy/Kconfig | 1 + drivers/phy/Makefile | 1 + drivers/phy/cix/Kconfig | 20 ++ drivers/phy/cix/Makefile | 6 + drivers/phy/cix/phy-cix-usb3.c | 410 ++++++++++++++++++++++++++++++++ drivers/phy/cix/phy-cix-usbdp.h | 310 ++++++++++++++++++++++++ 6 files changed, 748 insertions(+) create mode 100644 drivers/phy/cix/Kconfig create mode 100644 drivers/phy/cix/Makefile create mode 100644 drivers/phy/cix/phy-cix-usb3.c create mode 100644 drivers/phy/cix/phy-cix-usbdp.h
drivers/phy/Kconfig +1 -0
@@ -175,6 +175,7 @@ source "drivers/phy/axiado/Kconfig" source "drivers/phy/broadcom/Kconfig" source "drivers/phy/cadence/Kconfig" source "drivers/phy/canaan/Kconfig" +source "drivers/phy/cix/Kconfig" source "drivers/phy/eswin/Kconfig" source "drivers/phy/freescale/Kconfig" source "drivers/phy/hisilicon/Kconfig"
drivers/phy/Makefile +1 -0
@@ -27,6 +27,7 @@ obj-$(CONFIG_GENERIC_PHY) += allwinner/ \ broadcom/ \ cadence/ \ canaan/ \ + cix/ \ eswin/ \ freescale/ \ hisilicon/ \
drivers/phy/cix/Kconfig new file +20 -0
@@ -0,0 +1,20 @@ +# SPDX-License-Identifier: GPL-2.0-only +# +# Phy drivers for Cix PHYs +# + +if ARCH_CIX || COMPILE_TEST + +config PHY_CIX_USB3 + tristate "Cix USB3 PHY Driver" + depends on OF && HAS_IOMEM + select GENERIC_PHY + help + Enable this to support the CIX USB3 PHY for TYPEA Connection. + + This driver provides initialization and power management for + the USB3 PHY found on CIX Sky1 SoCs. + + If unsure, say N. + +endif # ARCH_CIX || COMPILE_TEST
drivers/phy/cix/Makefile new file +6 -0
@@ -0,0 +1,6 @@ +# SPDX-License-Identifier: GPL-2.0 +# +# Makefile for the Cix phy drivers. +# + +obj-$(CONFIG_PHY_CIX_USB3) += phy-cix-usb3.o
drivers/phy/cix/phy-cix-usb3.c new file +410 -0
410 lines not on this page · raw message
drivers/phy/cix/phy-cix-usbdp.h new file +310 -0
310 lines not on this page · raw message
Signature · 1 line
2.54.0
[email protected]
AI reviewRe: [PATCH v1 2/4] phy: cix: Add CIX Sky1 USB3 PHY driver
Thank you for your contribution! Sashiko AI review found 6 potential issue(s) to consider: - [High] Uninitialized pointer dereference and double-free of OF node reference on probe error path.…
Thank you for your contribution! Sashiko AI review found 6 potential issue(s) to consider:
- [High] Uninitialized pointer dereference and double-free of OF node reference on probe error path.
- [High] The probe function fails to propagate error codes and always returns 0 (success) on failure paths.
- [High] Missing cleanup for dynamically allocated phy_lookup entries causes a memory leak and Use-After-Free.
- [High] Hardware resets are unconditionally asserted without locking after the PHY provider is registered, creating a race condition with consumer initialization.
- [Medium] The error path in sky1_u3phy_init mistakenly deasserts the hardware resets instead of asserting them.
- [Medium] Missing MODULE_DEVICE_TABLE(of, ...) macro prevents automatic module loading.
--
commit 2c8f0e43d1973dd21cdeec9d0d419e0f7d1939aa
Author: Hongliang Yang <[email protected]>
phy: cix: Add CIX Sky1 USB3 PHY driver
This patch adds a new PHY driver for the USB3 PHY found on CIX Sky1 SoCs. The driver handles initialization, reset, and clock management for the multi-port USB3 PHY.
Quoted 5 lines
drivers/phy/cix/phy-cix-usb3.c new file +0
-0
[ ... ]
Quoted 2 lines
drivers/phy/cix/phy-cix-usb3.c new file +2
-0+static int sky1_u3phy_init (struct cix_u3phy *u3phy) +{
[ ... ]
drivers/phy/cix/phy-cix-usb3.c line 216
Quoted 7 lines
drivers/phy/cix/phy-cix-usb3.c new file +7
-0+disable_ref_clk: +clk_disable_unprepare (u3phy->ref_clk); +disable_apb_clk: +clk_disable_unprepare (u3phy->apb_clk); +assert_reset_preset: +reset_control_deassert (u3phy->preset); +reset_control_deassert (u3phy->reset);
[Severity: Medium]
Does this error path correctly assert the reset lines?
The code calls reset_control_deassert() instead of reset_control_assert(), which leaves the PHY in a deasserted reset state while its clocks are disabled. This might violate the intended quiescent hardware state and could potentially lead to hardware lockups or excessive power consumption.
Quoted 3 lines
drivers/phy/cix/phy-cix-usb3.c new file +3
-0+ u3phy->init = false; +return ret; +}
[ ... ]
Quoted 2 lines
drivers/phy/cix/phy-cix-usb3.c new file +2
-0+static int cix_u3phy_probe (struct platform_device *pdev) +{
[ ... ]
drivers/phy/cix/phy-cix-usb3.c line 371
Quoted 11 lines
drivers/phy/cix/phy-cix-usb3.c new file +11
-0+device_for_each_child_node (dev, child_fn) { + child_np =to_of_node (child_fn); +if (!strncmp (fwnode_get_name (child_fn),"usb-port" ,8 ) || + !strncmp (fwnode_get_name (child_fn),"USB" ,3 )) + phy =devm_phy_create (dev, child_np, &cix_u3phy_ops); +else +continue ; +if (IS_ERR (phy)) { +dev_err (dev,"failed to create phy: %s\n" , +fwnode_get_name (child_fn)); + goto put_child;
[Severity: High]
Does this error path intentionally return 0 instead of propagating the error code?
The variable 'ret' is initialized to 0 and is not updated with the error from devm_phy_create() before jumping to the cleanup label. This causes the kernel framework to consider the driver successfully probed despite the initialization failure.
drivers/phy/cix/phy-cix-usb3.c line 374
Quoted 3 lines
drivers/phy/cix/phy-cix-usb3.c new file +3
-0+ } +phy_set_drvdata (phy, u3phy); +phy_create_lookup (phy,fwnode_get_name (child_fn),dev_name (dev));
[Severity: High]
Is there a corresponding cleanup mechanism for this dynamically allocated phy_lookup entry?
The driver creates lookup entries using phy_create_lookup() but does not seem to provide a .remove callback or devres action to call phy_remove_lookup(). When the driver is unbound, devres frees the struct phy, leaving dangling pointers in the global lookup list which could cause a use-after-free for subsequent lookups by consumers.
drivers/phy/cix/phy-cix-usb3.c line 379
Quoted 5 lines
drivers/phy/cix/phy-cix-usb3.c new file +5
-0+ } + phy_provider =devm_of_phy_provider_register (dev, of_phy_simple_xlate); +if (IS_ERR (phy_provider)) { +dev_err (dev,"failed to register phy provider\n" ); + goto put_child;
[Severity: High]
Similar to the devm_phy_create() error path, does this drop the error code from devm_of_phy_provider_register()?
Additionally, does jumping to put_child here cause a double-free or a dereference of an uninitialized pointer?
If the device_for_each_child_node loop executed zero times, child_np is completely uninitialized. If the loop executed at least once and completed normally, child_np holds a pointer to the last child whose reference was already released by the iterator's final condition check.
drivers/phy/cix/phy-cix-usb3.c line 186
Quoted 3 lines
drivers/phy/cix/phy-cix-usb3.c new file +3
-0+ } +reset_control_assert (u3phy->reset); +reset_control_assert (u3phy->preset);
[Severity: High]
Is it safe to unconditionally assert these hardware resets here without locking after the PHY provider is registered?
A deferred consumer could immediately acquire the exposed PHY and call phy_init(), which initializes the PHY and deasserts resets while holding a mutex. Concurrently, this probe function unconditionally executes reset_control_assert() without holding the mutex, which might forcefully reset the active PHY hardware.
Quoted 4 lines
drivers/phy/cix/phy-cix-usb3.c new file +4
-0+return 0 ; + +put_child: +of_node_put (child_np);
drivers/phy/cix/phy-cix-usb3.c line 396
Quoted 10 lines
drivers/phy/cix/phy-cix-usb3.c new file +10
-0+return ret; +} + +static const struct of_device_id cix_u3phy_dt_match[] = { + { + .compatible ="cix,sky1-usb3-phy" , + .data = &sky1_u3phy_cfg + }, + {/* sentinel */ } +};
[Severity: Medium]
Is the MODULE_DEVICE_TABLE(of, ...) macro missing here?
Without it, the driver module cannot be automatically loaded by udev or kmod based on the Device Tree compatible string.
Quoted 8 lines
drivers/phy/cix/phy-cix-usb3.c new file +8
-0+ +static struct platform_driver cix_usb3_phy_driver = { + .probe = cix_u3phy_probe, + .driver = { + .name ="cix-usb3-phy" , + .of_match_table = cix_u3phy_dt_match, + }, +};
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
PATCH 3/4 usb: cdns3: Add CIX Sky1 glue driver
In reply to Hongliang YangAdd glue layer for the Cadence USBSSP DRD controller on CIX Sky1 SoCs. The glue driver handles platform-specific initialization including clocks, resets, and PHY configuration.
--- drivers/usb/cdns3/Kconfig | 13 + drivers/usb/cdns3/Makefile | 1 + drivers/usb/cdns3/cdnsp-sky1.c | 682 +++++++++++++++++++++++++++++++++ drivers/usb/cdns3/cdnsp-sky1.h | 127 ++++++ 4 files changed, 823 insertions(+) create mode 100644 drivers/usb/cdns3/cdnsp-sky1.c create mode 100644 drivers/usb/cdns3/cdnsp-sky1.h
drivers/usb/cdns3/Kconfig +13 -0
@@ -77,6 +77,19 @@ config USB_CDNSP_PCI If you choose to build this driver as module it will be dynamically linked and module will be called cdnsp-pci.ko +config USB_CDNSP_SKY1 + tristate "Cadence USB3 support on CIX Sky1 SoC platforms" + depends on USB_CDNS3 + depends on ARCH_CIX || COMPILE_TEST + default USB_CDNS3 + help + Glue driver for the Cadence USB dual-role controllers on CIX Sky1 + (device tree compatible cix,sky1-usb3). It enables clocks and resets + from the SoC, then uses the shared cdns3 platform core (cdns.ko). + + If built as a module, the module is named cdnsp-sky1.ko and must be + loaded after the cdns core module when both are loadable modules. + config USB_CDNS3_TI tristate "Cadence USB3 support on TI platforms" depends on ARCH_K3 || COMPILE_TEST
drivers/usb/cdns3/Makefile +1 -0
@@ -28,3 +28,4 @@ obj-$(CONFIG_USB_CDNSP_PCI) += cdnsp-pci.o obj-$(CONFIG_USB_CDNS3_TI) += cdns3-ti.o obj-$(CONFIG_USB_CDNS3_IMX) += cdns3-imx.o obj-$(CONFIG_USB_CDNS3_STARFIVE) += cdns3-starfive.o +obj-$(CONFIG_USB_CDNSP_SKY1) += cdnsp-sky1.o
drivers/usb/cdns3/cdnsp-sky1.c new file +682 -0
682 lines not on this page · raw message
drivers/usb/cdns3/cdnsp-sky1.h new file +127 -0
127 lines not on this page · raw message
Signature · 1 line
2.54.0
[email protected]
AI reviewRe: [PATCH v1 3/4] usb: cdns3: Add CIX Sky1 glue driver
Thank you for your contribution! Sashiko AI review found 11 potential issue(s) to consider: - [High] IOMEM, clock, and reset leaks on probe error paths. - [High] Missing get_device() causes unsafe…
Thank you for your contribution! Sashiko AI review found 11 potential issue(s) to consider:
- [High] IOMEM, clock, and reset leaks on probe error paths.
- [High] Missing get_device() causes unsafe device pointer storage in match function, leading to Use-After-Free.
- [High] Global state corruption of shared static cdns_sky1_auxdata array in probe.
- [High] Flawed platform_data memory management causes leaks or double-frees when multiple or zero children exist.
- [High] Unbalanced Runtime PM state during driver removal.
- [High] Incorrect hardware reset logic during driver removal.
- [High] Signed integer overflow in clock frequency calculations.
- [High] Writing inverted AXI_HALT bitmask to the capability register inadvertently sets all other bits to 1.
- [Medium] Device node reference leak in sky1_of_get_addr_by_name.
- [Medium] Clock error recovery paths destructively nullify devres managed clock pointers.
- [Low] Signed integer overflow when defining CFG_3XPORT_MODE_DIS_SSP.
--
commit f5b41d8b4e76c0521bdb8557f0e54b6023714500
Author: Hongliang Yang <[email protected]>
usb: cdns3: Add CIX Sky1 glue driver
Add glue layer for the Cadence USBSSP DRD controller on CIX Sky1 SoCs. The glue driver handles platform-specific initialization including clocks, resets, and PHY configuration.
Quoted 5 lines
drivers/usb/cdns3/cdnsp-sky1.c new file +0
-0@@ -0,0 +1,682 @@
[ ... ]
Quoted 2 lines
drivers/usb/cdns3/cdnsp-sky1.c new file +2
-0+static int cdnsp_sky1_clk_enable_resume (struct device *dev) +{
[ ... ]
drivers/usb/cdns3/cdnsp-sky1.c line 99
Quoted 5 lines
drivers/usb/cdns3/cdnsp-sky1.c new file +5
-0+err_usb_clks: + cix_usb_clks[i] =NULL ; +while (--i >=0 ) { +clk_disable_unprepare (cix_usb_clks[i]); + cix_usb_clks[i] =NULL ;
[Severity: Medium]
Is it safe to nullify these clock pointers?
Because the clocks are devres-managed, devres will still properly free them, but nullifying the pointers destroys the driver's ability to ever reference them again.
If a transient error occurs during a resume attempt, any subsequent retry or cleanup will fail because the driver lost its internal pointers.
Quoted 3 lines
drivers/usb/cdns3/cdnsp-sky1.c new file +3
-0+ } +return ret; +};
[ ... ]
Quoted 2 lines
drivers/usb/cdns3/cdnsp-sky1.c new file +2
-0+static void cdnsp_sky1_configure_controller (struct cdnsp_sky1 *data) +{
[ ... ]
drivers/usb/cdns3/cdnsp-sky1.c line 264
Quoted 6 lines
drivers/usb/cdns3/cdnsp-sky1.c new file +6
-0+writel (AXI_HALT , data->device_base +D_XEC_AXI_CAP ); +writel (AXI_HALT , data->xhci_base +D_XEC_AXI_CAP ); +writel (data->axi_bmax_value, data->device_base +D_XEC_AXI_CTRL0 ); +writel (data->axi_bmax_value, data->xhci_base +D_XEC_AXI_CTRL0 ); +writel ((~(u32)(AXI_HALT )), data->device_base +D_XEC_AXI_CAP ); +writel ((~(u32)(AXI_HALT )), data->xhci_base +D_XEC_AXI_CAP );
[Severity: High]
Does this inadvertently overwrite other capability bits?
AXI_HALT is defined as BIT(31). Blindly writing ~(u32)(AXI_HALT) yields 0x7FFFFFFF, which sets bits 0 through 30 to 1 rather than preserving their existing state with a read-modify-write or clearing them with 0.
Overwriting 31 capability bits with 1s can enable unintended modes or cause unpredictable hardware behavior.
Quoted 4 lines
drivers/usb/cdns3/cdnsp-sky1.c new file +4
-0+ clk = data->sof_clk_freq; + v0 =25 * clk /100000000 ; + v1 = clk /10000 ; + v2 = clk /10 ;
drivers/usb/cdns3/cdnsp-sky1.c line 278
Quoted 10 lines
drivers/usb/cdns3/cdnsp-sky1.c new file +10
-0+writel (((v0 >1 ) ? v0 -1 :1 ), data->device_base + +D_XEC_PRE_REG_250NS ); +writel ((unsigned int )((v1 /100 >1 ) >0 ? (v1 /100 ) -1 :1 ), + data->device_base +D_XEC_PRE_REG_1US ); +writel ((unsigned int )((v1 /10 >1 ) >0 ? (v1 /10 ) -1 :1 ), + data->device_base +D_XEC_PRE_REG_10US ); +writel (((v1) >1 ? v1 -1 :1 ), data->device_base + +D_XEC_PRE_REG_100US ); +writel ((unsigned int )((125 * clk /1000000 ) >1 ? (125 * clk /1000000 ) :1 ), + data->device_base +D_XEC_PRE_REG_125US );
[Severity: High]
Will this calculation overflow for frequencies above 17.1 MHz?
Because clk is typed as a signed 32-bit int, 125 * clk will exceed INT_MAX (2,147,483,647) and overflow for values above approximately 17.1 MHz. This yields a negative value that improperly configures the hardware pre-scaler registers.
Could this be mitigated by using an unsigned 64-bit cast, such as 125ULL * clk?
[ ... ]
drivers/usb/cdns3/cdnsp-sky1.c line 402
Quoted 13 lines
drivers/usb/cdns3/cdnsp-sky1.c new file +13
-0+static void *sky1_of_get_addr_by_name (struct device_node *parent,char *name) +{ +struct device_node *node; +int index; + + node =of_get_next_child (parent,NULL ); +if (node) { + index =of_property_match_string (node,"reg-names" , name); +if (index >=0 ) +return of_iomap (node, index); + } +return NULL ; +}
[Severity: Medium]
Can this leak the device node reference?
of_get_next_child() acquires and returns a device node with an incremented reference count, but the reference is never released with of_node_put() on either the success or failure paths.
[ ... ]
Quoted 9 lines
drivers/usb/cdns3/cdnsp-sky1.c new file +9
-0+static struct of_dev_auxdata cdns_sky1_auxdata[] = { + { + .compatible ="cdns,usb3" , + }, + {}, +}; + +static int cdnsp_sky1_probe (struct platform_device *pdev) +{
[ ... ]
drivers/usb/cdns3/cdnsp-sky1.c line 497
Quoted 8 lines
drivers/usb/cdns3/cdnsp-sky1.c new file +8
-0+ data->device_base =sky1_get_addr_by_name (dev,"dev" ); +if (!data->device_base) +return -ENODEV ; + ret =cdnsp_sky1_drd_init (data); +if (ret == -ETIMEDOUT ) +return -EPROBE_DEFER ; +if (ret) +return ret;
[Severity: High]
Do these error paths leak the IOMEM regions, hardware clocks, and resets?
cdnsp_sky1_probe() manually maps IOMEM regions using sky1_get_addr_by_name() and enables hardware clocks in cdnsp_sky1_drd_init(). If subsequent initialization steps fail, the function returns directly or jumps to the err label without unmapping the IOMEM with iounmap(), disabling the clocks, or re-asserting the hardware resets.
Since probe can be retried multiple times, these leaked resources will accumulate.
drivers/usb/cdns3/cdnsp-sky1.c line 510
Quoted 13 lines
drivers/usb/cdns3/cdnsp-sky1.c new file +13
-0+ data->oc_gpio =devm_gpiod_get_optional (data->dev,"oc" ,GPIOD_IN ); +if (IS_ERR (data->oc_gpio)) { +dev_err (data->dev,"can not get oc_gpio\n" ); + ret =PTR_ERR (data->oc_gpio); +return ret; + } +if (data->oc_gpio) { + ret =gpiod_direction_input (data->oc_gpio); +if (ret <0 ) +dev_err (data->dev,"set oc_gpio input failed:%d\n" , ret); + } +/* release by platform_device_release */ + cdns_sky1_pdata =kzalloc (sizeof (*cdns_sky1_pdata),GFP_KERNEL );
[Severity: High]
Can this cause a memory leak or double-free of cdns_sky1_pdata?
The instance-specific structure cdns_sky1_pdata is allocated here and passed to child devices via of_platform_populate(). If of_platform_populate() matches zero children, the pointer is never attached to a device and permanently leaks.
If it matches multiple children, all children receive the exact same pointer, resulting in a double-free kernel panic when each child's release function attempts to free the same pointer upon unbind.
drivers/usb/cdns3/cdnsp-sky1.c line 516
Quoted 6 lines
drivers/usb/cdns3/cdnsp-sky1.c new file +6
-0+if (!cdns_sky1_pdata) +return -ENOMEM ; + cdns_sky1_pdata->platform_suspend = cdns_sky1_platform_suspend; + cdns_sky1_pdata->quirks =CDNS3_DEFAULT_PM_RUNTIME_ALLOW ; + cdns_sky1_auxdata->platform_data = cdns_sky1_pdata; + ret =of_platform_populate (node,NULL , cdns_sky1_auxdata, dev);
[Severity: High]
Does this corrupt the global cdns_sky1_auxdata array?
cdns_sky1_auxdata is defined as a statically shared array for the driver, but a dynamically allocated, instance-specific pointer (cdns_sky1_pdata) is assigned to cdns_sky1_auxdata->platform_data.
Because the device tree contains multiple instances of this driver, probing them concurrently or sequentially will race to overwrite this shared global state, causing cross-device memory corruption and dangling pointers.
[ ... ]
drivers/usb/cdns3/cdnsp-sky1.c line 540
Quoted 11 lines
drivers/usb/cdns3/cdnsp-sky1.c new file +11
-0+static void cdnsp_sky1_remove (struct platform_device *pdev) +{ +struct device *dev = &pdev->dev; +struct cdnsp_sky1 *data =dev_get_drvdata (dev); + +pm_runtime_get_sync (dev); +of_platform_depopulate (dev); +sky1_put_addr (data->xhci_base); +sky1_put_addr (data->device_base); +reset_control_deassert (data->reset); +reset_control_deassert (data->preset);
[Severity: High]
Should these resets be asserted instead of deasserted?
The driver attempts to tear down the hardware but incorrectly calls reset_control_deassert() again instead of reset_control_assert(). This fails to reset the hardware and leaves it active while its clocks are subsequently disabled, which can hang the system or cause undefined hardware behavior.
drivers/usb/cdns3/cdnsp-sky1.c line 543
Quoted 3 lines
drivers/usb/cdns3/cdnsp-sky1.c new file +3
-0+cdnsp_sky1_clk_disable_all (dev); +platform_set_drvdata (pdev,NULL ); +}
[Severity: High]
Does this leave the device's runtime PM subsystem in an unbalanced state?
cdnsp_sky1_probe() enables runtime PM, but cdnsp_sky1_remove() omits a call to pm_runtime_disable() before exiting.
Additionally, cdnsp_sky1_remove() calls pm_runtime_get_sync() at the start of the function but omits a balancing pm_runtime_put() call, permanently leaking the device's usage counter.
[ ... ]
Quoted 2 lines
drivers/usb/cdns3/cdnsp-sky1.c new file +2
-0+static int cdnsp_sky1_find_gadget_match (struct device *dev,void *data) +{
[ ... ]
Quoted 10 lines
drivers/usb/cdns3/cdnsp-sky1.c new file +10
-0+if (name && dev->bus && !strcmp (dev->bus->name,"gadget" ) && + !strncmp (name, gadget_prefix,sizeof (gadget_prefix) -1 )) { + *gadget_dev = dev; +return 1 ; + } +return 0 ; +} + +static void cdnsp_sky1_shutdown (struct platform_device *pdev) +{
[ ... ]
drivers/usb/cdns3/cdnsp-sky1.c line 645
Quoted 13 lines
drivers/usb/cdns3/cdnsp-sky1.c new file +13
-0+if (!device_may_wakeup (dev)) { +/* +* Find the cdns3 child device, then find its gadget device +* and release the function driver before disabling clocks. +* This ensures all register accesses in gadget_unbind_driver +* complete before clocks are turned off. +*/ +device_for_each_child (dev, &cdns, cdnsp_sky1_find_cdns); +if (cdns) +device_for_each_child (cdns->dev, &gadget_dev, + cdnsp_sky1_find_gadget_match); +if (gadget_dev) +device_release_driver (gadget_dev);
[Severity: High]
Can this result in a use-after-free condition?
In cdnsp_sky1_find_gadget_match(), a pointer to the matched device is stored without acquiring a persistent reference via get_device(). The iterator device_for_each_child() immediately drops its reference when advancing or returning, leaving a bare pointer.
If the gadget device is removed concurrently immediately before device_release_driver() is called, the pointer becomes dangling.
[ ... ]
Quoted 5 lines
drivers/usb/cdns3/cdnsp-sky1.h new file +0
-0@@ -0,0 +1,127 @@
[ ... ]
drivers/usb/cdns3/cdnsp-sky1.h line 92
Quoted 3 lines
drivers/usb/cdns3/cdnsp-sky1.h new file +3
-0+#define D_XEC_CFG_3XPORT_MODE_VALUE 0xa0031e07 +#define XEC_CFG_3XPORT_MODE_VALUE 0xa0031e07 +#define CFG_3XPORT_MODE_DIS_SSP (~(1 << 31))
[Severity: Low]
Does this trigger undefined behavior?
1 is treated as a signed 32-bit integer, and shifting it left by 31 bits overflows the sign bit. Should this be explicitly unsigned, such as (~(1U << 31)) or ~BIT(31)?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
Re: [PATCH v1 3/4] usb: cdns3: Add CIX Sky1 glue driver
In reply to Hongliang YangQuoted 15 lines · Hongliang Yang
Add glue layer for the Cadence USBSSP DRD controller on CIX Sky1 SoCs. The glue driver handles platform-specific initialization including clocks, resets, and PHY configuration.
Signed-off-by Hongliang Yang <[email protected]>Reviewed-by Gary Yang <[email protected]>--- drivers/usb/cdns3/Kconfig | 13 + drivers/usb/cdns3/Makefile | 1 + drivers/usb/cdns3/cdnsp-sky1.c | 682 +++++++++++++++++++++++++++++++++ drivers/usb/cdns3/cdnsp-sky1.h | 127 ++++++ 4 files changed, 823 insertions(+) create mode 100644 drivers/usb/cdns3/cdnsp-sky1.c create mode 100644 drivers/usb/cdns3/cdnsp-sky1.h
[...]
Quoted 6 lines
drivers/usb/cdns3/cdnsp-sky1.c new file +0
-0@@ -0,0 +1,682 @@
[...]
Quoted 12 lines
drivers/usb/cdns3/cdnsp-sky1.c new file +12
-0+static int cdnsp_sky1_probe (struct platform_device *pdev) +{ +struct device *dev = &pdev->dev; +struct device_node *node = dev->of_node; +struct cdnsp_sky1 *data; +int ret =0 ; +struct cdns3_platform_data *cdns_sky1_pdata; + + data =devm_kzalloc (dev,sizeof (*data),GFP_KERNEL ); +if (!data) +return -ENOMEM ; + data->axi_base =devm_platform_ioremap_resource_byname (pdev,"axi_property" );
drivers/usb/cdns3/cdnsp-sky1.c line 443
Quoted 10 lines
drivers/usb/cdns3/cdnsp-sky1.c new file +10
-0+if (IS_ERR (data->axi_base)) { +dev_err (dev,"can't map IOMEM resource\n" ); +return PTR_ERR (data->axi_base); + } + data->ctst_base =devm_platform_ioremap_resource_byname (pdev,"controller_status" ); +if (IS_ERR (data->ctst_base)) { +dev_err (dev,"can't map IOMEM resource\n" ); +return PTR_ERR (data->ctst_base); + } + data->reset =devm_reset_control_get (&pdev->dev,"usb_reset" );
Please use devm_reset_control_get_exclusive() directly.
regards
Philipp
PATCH 4/4 arm64: dts: cix: Add USB4/USB5 nodes for Sky1
In reply to Hongliang YangAdd USB4 and USB5 controller nodes (based on Cadence USBSSP DRD) and their associated USB3 PHY nodes for the CIX Sky1 SoC. Enable USB4 and USB5 in host mode on the Radxa Orion O6 board.
--- arch/arm64/boot/dts/cix/sky1-orion-o6.dts | 36 ++++++ arch/arm64/boot/dts/cix/sky1.dtsi | 133 ++++++++++++++++++++++ 2 files changed, 169 insertions(+)
arch/arm64/boot/dts/cix/sky1-orion-o6.dts +36 -0
@@ -80,6 +80,22 @@ pins { }; }; + + pinctrl_usb4: usb4-power-on-cfg { + pins { + pinmux = <CIX_PAD_GPIO041_FUNC_USB_DRIVE_VBUS4>; + bias-pull-down; + drive-strength = <8>; + }; + }; + + pinctrl_usb5: usb5-power-on-cfg { + pins { + pinmux = <CIX_PAD_GPIO042_FUNC_USB_DRIVE_VBUS5>; + bias-pull-down; + drive-strength = <8>; + }; + }; }; &pcie_x8_rc {
@@ -117,3 +133,23 @@ &s5_gpio2 { &uart2 { status = "okay"; }; + +&usb4 { + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_usb4>; +}; + +&usbss_4 { + status = "okay"; + dr_mode = "host"; +}; + +&usb5 { + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_usb5>; +}; + +&usbss_5 { + status = "okay"; + dr_mode = "host"; +};
arch/arm64/boot/dts/cix/sky1.dtsi +133 -0
151 lines not on this page · raw message
Signature · 1 line
2.54.0
[email protected]
AI reviewRe: [PATCH v1 4/4] arm64: dts: cix: Add USB4/USB5 nodes for Sky1
Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider: - [High] The parent USB wrapper nodes (`usb4`, `usb5`) and the required USB PHY node (`usb3_phy4`) are left…
Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
- [High] The parent USB wrapper nodes (usb4, usb5) and the required USB PHY node (usb3_phy4) are left disabled in the board device tree, preventing the USB controllers from probing.
- [Low] The unit addresses for the usb4 and usb5 nodes do not match their first reg address, violating the Device Tree specification.
- [Low] The usb-port child nodes inside usb3_phy4 use unit addresses but lack the required reg properties.
- [Low] Incorrect reg-names order for the cdns,usb3 controllers violates the DT schema binding.
--
commit fb5456e6e85188c30dcbeb49499209cebdd39407
Author: Hongliang Yang <[email protected]>
arm64: dts: cix: Add USB4/USB5 nodes for Sky1
Add USB4 and USB5 controller nodes and their associated USB3 PHY nodes for the CIX Sky1 SoC. Enable USB4 and USB5 in host mode on the Radxa Orion O6 board.
Quoted 4 lines
arch/arm64/boot/dts/cix/sky1-orion-o6.dts +0
-0
[ ... ]
arch/arm64/boot/dts/cix/sky1-orion-o6.dts &s5_gpio2 { · line 140
Quoted 9 lines
arch/arm64/boot/dts/cix/sky1-orion-o6.dts +5
-0@@ -117,3 +133,23 @@ &s5_gpio2 { &uart2 { status = "okay"; }; + +&usb4 { + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_usb4>; +};
[Severity: High]
Are the usb4 and usb5 parent nodes intentionally left disabled in the board configuration?
The parent nodes usb4 and usb5 are marked as status = "disabled" in the DTSI. Although this patch adds pin control configurations for them, it omits status = "okay";. The Linux DT core will not instantiate disabled platform devices, which would prevent their children (usbss_4, usbss_5) from probing.
Quoted 5 lines
arch/arm64/boot/dts/cix/sky1-orion-o6.dts +5
-0+ +&usbss_4 { + status = "okay"; + dr_mode = "host"; +};
arch/arm64/boot/dts/cix/sky1-orion-o6.dts &s5_gpio2 { · line 155
Quoted 10 lines
arch/arm64/boot/dts/cix/sky1-orion-o6.dts +10
-0+ +&usb5 { + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_usb5>; +}; + +&usbss_5 { + status = "okay"; + dr_mode = "host"; +};
[Severity: High]
Is the required PHY node (usb3_phy4) missing its enablement in this board file?
The PHY is marked disabled by default in sky1.dtsi, but it is completely omitted from the board file. This could cause PHY consumer requests to fail with -ENODEV even if the controllers did probe, preventing USB4 and USB5 from functioning.
Quoted 4 lines
arch/arm64/boot/dts/cix/sky1.dtsi +0
-0
[ ... ]
arch/arm64/boot/dts/cix/sky1.dtsi mbox_ap2sfh: mailbox@80a0000 { · line 590
Quoted 11 lines
arch/arm64/boot/dts/cix/sky1.dtsi +7
-0@@ -574,6 +581,132 @@ mbox_ap2sfh: mailbox@80a0000 { cix,mbox-dir = "tx"; }; + usb4: usb@91c0300 { + compatible = "cix,sky1-usbssp"; + #address-cells = <2>; + #size-cells = <2>; + ranges; + + reg = <0x00 0x091c0314 0x00 0x4>,
[Severity: Low]
Does the unit address @91c0300 need to be updated to match the first reg address 0x091c0314? The DeviceTree specification mandates that the unit address must exactly match the first address in the node's reg property, which could trigger validation warnings.
Quoted 3 lines
arch/arm64/boot/dts/cix/sky1.dtsi +3
-0+ <0x00 0x091c0400 0x00 0x4>; + reg-names = "axi_property", "controller_status"; +
[ ... ]
arch/arm64/boot/dts/cix/sky1.dtsi mbox_ap2sfh: mailbox@80a0000 { · line 615
Quoted 6 lines
arch/arm64/boot/dts/cix/sky1.dtsi +6
-0+ usbss_4: usb-controller@91d0000 { + compatible = "cdns,usb3"; + reg = <0x00 0x91d0000 0x00 0x4000>, + <0x00 0x91d4000 0x00 0x4000>, + <0x00 0x91d8000 0x00 0x8000>; + reg-names = "otg", "dev", "xhci";
[Severity: Low]
Is the order of the reg-names correct here?
The device tree binding for Cadence USB3 controllers requires the reg-names property to be strictly ordered as "otg", "xhci", "dev". Do the names and the corresponding reg tuples need to be reordered so that the "xhci" memory region matches the required order to avoid schema validation errors?
Quoted 2 lines
arch/arm64/boot/dts/cix/sky1.dtsi +2
-0+ + interrupts = <GIC_SPI 252 IRQ_TYPE_LEVEL_HIGH 0>,
[ ... ]
arch/arm64/boot/dts/cix/sky1.dtsi mbox_ap2sfh: mailbox@80a0000 { · line 640
Quoted 7 lines
arch/arm64/boot/dts/cix/sky1.dtsi +7
-0+ usb5: usb@91c0304 { + compatible = "cix,sky1-usbssp"; + #address-cells = <2>; + #size-cells = <2>; + ranges; + + reg = <0x00 0x091c0324 0x00 0x4>,
[Severity: Low]
Similarly, does the unit address @91c0304 need to be updated to match the first reg address 0x091c0324 to avoid validation warnings?
Quoted 3 lines
arch/arm64/boot/dts/cix/sky1.dtsi +3
-0+ <0x00 0x091c0410 0x00 0x4>; + reg-names = "axi_property", "controller_status"; +
[ ... ]
arch/arm64/boot/dts/cix/sky1.dtsi mbox_ap2sfh: mailbox@80a0000 { · line 665
Quoted 6 lines
arch/arm64/boot/dts/cix/sky1.dtsi +6
-0+ usbss_5: usb-controller@91e0000 { + compatible = "cdns,usb3"; + reg = <0x00 0x91e0000 0x00 0x4000>, + <0x00 0x91e4000 0x00 0x4000>, + <0x00 0x91e8000 0x00 0x8000>; + reg-names = "otg", "dev", "xhci";
[Severity: Low]
Does the order of the reg-names and corresponding reg tuples for usbss_5 also need to be adjusted to "otg", "xhci", "dev" to match the binding schema?
Quoted 2 lines
arch/arm64/boot/dts/cix/sky1.dtsi +2
-0+ + interrupts = <GIC_SPI 257 IRQ_TYPE_LEVEL_HIGH 0>,
[ ... ]
Quoted 9 lines
arch/arm64/boot/dts/cix/sky1.dtsi +9
-0+ usb3_phy4: usb-phy@9210000 { + #address-cells = <1>; + #size-cells = <0>; + compatible = "cix,sky1-usb3-phy"; + reg = <0x00 0x09210000 0x00 0x40000>; + status = "disabled"; + + resets = <&s5_syscon SKY1_USBPHY_SS_RST_N>, + <&s5_syscon SKY1_USBPHY_SS_PST_N>;
arch/arm64/boot/dts/cix/sky1.dtsi mbox_ap2sfh: mailbox@80a0000 { · line 702
Quoted 10 lines
arch/arm64/boot/dts/cix/sky1.dtsi +10
-0+ reset-names = "reset", "preset"; + + clocks = <&scmi_clk CLK_TREE_USB3A_PHY3_GATE>, + <&scmi_clk CLK_TREE_USB3A_PHY_x2_REF>; + clock-names = "apb_clk", "ref_clk"; + + usb3_phy4_0: usb-port@0 { + #phy-cells = <0>; + status = "disabled"; + };
[Severity: Low]
Since this node has a unit-address (@0) and the parent has #address-cells = <1>;, should it include a reg = <0>; property?
The DeviceTree specification states that if a node has a unit-address in its name, it must have a corresponding reg property.
arch/arm64/boot/dts/cix/sky1.dtsi mbox_ap2sfh: mailbox@80a0000 { · line 707
Quoted 5 lines
arch/arm64/boot/dts/cix/sky1.dtsi +5
-0+ + usb3_phy4_1: usb-port@1 { + #phy-cells = <0>; + status = "disabled"; + };
[Severity: Low]
Should this node also include a reg = <1>; property for the unit-address @1?
Quoted 1 line
arch/arm64/boot/dts/cix/sky1.dtsi +1
-0+ };
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=4
PATCH v2 1/5 dt-bindings: phy: Add CIX Sky1 USB3 PHY
In reply to Hongliang YangAdd device tree binding for the CIX Sky1 USB3 PHY, a multi-port SuperSpeedPlus PHY supporting up to two USB3 lanes.
--- .../bindings/phy/cix,sky1-usb3-phy.yaml | 107 ++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 Documentation/devicetree/bindings/phy/cix,sky1-usb3-phy.yaml
Documentation/devicetree/bindings/phy/cix,sky1-usb3-phy.yaml new file +107 -0
@@ -0,0 +1,107 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/phy/cix,sky1-usb3-phy.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: CIX Sky1 USB3 PHY + +maintainers: + - Hongliang Yang <[email protected]> + +description: + The CIX Sky1 USB3 PHY is a multi-port SuperSpeedPlus PHY that + supports up to two USB3 lanes. Each port is represented as a + child node of the PHY controller. + +properties: + compatible: + const: cix,sky1-usb3-phy + + reg: + maxItems: 1 + + clocks: + items: + - description: APB register interface clock + - description: PHY reference clock + + clock-names: + items: + - const: apb + - const: ref + + resets: + items: + - description: PHY reset + - description: PHY APB preset + + reset-names: + items: + - const: core + - const: apb + + "#address-cells": + const: 1 + + "#size-cells": + const: 0 + +patternProperties: + "^usb-port@[0-9a-f]+$": + type: object + description: + A single USB3 PHY port/lane. + + properties: + reg: + maxItems: 1 + + "#phy-cells": + const: 0 + + required: + - reg + - "#phy-cells" + + additionalProperties: false + +required: + - compatible + - reg + - clocks + - clock-names + - resets + - reset-names + - "#address-cells" + - "#size-cells" + +additionalProperties: false + +examples: + - | + #include <dt-bindings/clock/cix,sky1.h> + #include <dt-bindings/reset/cix,sky1-s5-system-control.h> + + usb-phy@9210000 { + compatible = "cix,sky1-usb3-phy"; + reg = <0x9210000 0x40000>; + #address-cells = <1>; + clocks = <&scmi_clk CLK_TREE_USB3A_PHY3_GATE>, + <&scmi_clk CLK_TREE_USB3A_PHY_x2_REF>; + clock-names = "apb", "ref"; + resets = <&s5_syscon SKY1_USBPHY_SS_RST_N>, + <&s5_syscon SKY1_USBPHY_SS_PST_N>; + reset-names = "core", "apb"; + #size-cells = <0>; + + usb-port@0 { + reg = <0>; + #phy-cells = <0>; + }; + + usb-port@1 { + reg = <1>; + #phy-cells = <0>; + }; + };
Signature · 1 line
2.54.0
PATCH v2 2/5 dt-bindings: usb: Add CIX Sky1 USBSSP controller
In reply to Hongliang YangAdd device tree binding for the CIX Sky1 Cadence USBSSP controller glue layer. The integration adds glue registers and mode strap controls in the Sky1 S5 system controller. The CIX glue node wraps a Cadence USBSSP core as a child node.
--- .../bindings/usb/cix,sky1-usbssp.yaml | 137 ++++++++++++++++++ MAINTAINERS | 3 + 2 files changed, 140 insertions(+) create mode 100644 Documentation/devicetree/bindings/usb/cix,sky1-usbssp.yaml
Documentation/devicetree/bindings/usb/cix,sky1-usbssp.yaml new file +137 -0
@@ -0,0 +1,137 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/usb/cix,sky1-usbssp.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: CIX Sky1 Cadence USBSSP Controller + +maintainers: + - Hongliang Yang <[email protected]> + +description: + The CIX Sky1 USBSSP controller is based on the Cadence USBSSP DRD + controller. The integration adds glue registers and mode strap controls + in the Sky1 S5 system controller. The CIX glue node wraps a Cadence + USBSSP core as a child node. + +properties: + compatible: + const: cix,sky1-usbssp + + reg: + items: + - description: AXI property configuration register + - description: Controller status register + + reg-names: + items: + - const: axi + - const: controller + + clocks: + items: + - description: Start-of-frame clock + - description: AXI bus clock + - description: Low-power mode clock + - description: APB register interface clock + + clock-names: + items: + - const: sof + - const: axi + - const: lpm + - const: apb + + resets: + items: + - description: APB register reset + - description: Controller reset + + reset-names: + items: + - const: apb + - const: core + + cix,usb-syscon: + $ref: /schemas/types.yaml#/definitions/phandle + description: + Phandle to the Sky1 S5 system controller used to program USB mode + strap controls. + + "#address-cells": + const: 2 + + "#size-cells": + const: 2 + + ranges: true + +patternProperties: + "^usb@[0-9a-f]+$": + $ref: cdns,usb3.yaml# + +required: + - compatible + - reg + - reg-names + - clocks + - clock-names + - resets + - reset-names + - cix,usb-syscon + - "#address-cells" + - "#size-cells" + - ranges + +unevaluatedProperties: false + +examples: + - | + #include <dt-bindings/clock/cix,sky1.h> + #include <dt-bindings/interrupt-controller/arm-gic.h> + #include <dt-bindings/reset/cix,sky1-s5-system-control.h> + + soc { + #address-cells = <2>; + #size-cells = <2>; + + usb@91c0314 { + compatible = "cix,sky1-usbssp"; + reg = <0x00 0x091c0314 0x00 0x4>, + <0x00 0x091c0400 0x00 0x4>; + reg-names = "axi", "controller"; + ranges; + #address-cells = <2>; + + clocks = <&scmi_clk CLK_TREE_USB3A_H0_CLK_SOF>, + <&scmi_clk CLK_TREE_USB3A_0_AXI_GATE>, + <&scmi_clk CLK_TREE_USB3A_H0_CLK_LPM>, + <&scmi_clk CLK_TREE_USB3A_0_APB_GATE>; + clock-names = "sof", "axi", "lpm", "apb"; + resets = <&src SKY1_USBC_SS2_PRST_N>, + <&src SKY1_USBC_SS2_RST_N>; + reset-names = "apb", "core"; + #size-cells = <2>; + cix,usb-syscon = <&src>; + + usb@91d0000 { + compatible = "cdns,usb3"; + reg = <0x00 0x91d0000 0x00 0x4000>, + <0x00 0x91d8000 0x00 0x8000>, + <0x00 0x91d4000 0x00 0x4000>; + reg-names = "otg", "xhci", "dev"; + dr_mode = "otg"; + + interrupts = <GIC_SPI 168 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 169 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 170 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 171 IRQ_TYPE_LEVEL_HIGH>; + interrupt-names = "host", "peripheral", "otg", "wakeup"; + maximum-speed = "super-speed-plus"; + + phys = <&usb3_phy4_0>, <&usb2_phy6>; + phy-names = "cdns3,usb3-phy", "cdns3,usb2-phy"; + }; + }; + };
MAINTAINERS +3 -0
@@ -2775,8 +2775,11 @@ S: Maintained T: git git://git.kernel.org/pub/scm/linux/kernel/git/peter.chen/cix.git F: Documentation/devicetree/bindings/arm/cix.yaml F: Documentation/devicetree/bindings/mailbox/cix,sky1-mbox.yaml +F: Documentation/devicetree/bindings/phy/cix,sky1-usb3-phy.yaml +F: Documentation/devicetree/bindings/usb/cix,sky1-usbssp.yaml F: arch/arm64/boot/dts/cix/ F: drivers/mailbox/cix-mailbox.c +F: drivers/phy/cix/ K: \bcix\b ARM/CLKDEV SUPPORT
Signature · 1 line
2.54.0
PATCH v2 3/5 phy: cix: Add CIX Sky1 USB3 PHY driver
In reply to Hongliang YangAdd PHY driver for the USB3 PHY found on CIX Sky1 SoCs. The driver handles initialization, reset, and clock management for the multi-port USB3 PHY.
--- drivers/phy/Kconfig | 1 + drivers/phy/Makefile | 1 + drivers/phy/cix/Kconfig | 20 ++ drivers/phy/cix/Makefile | 6 + drivers/phy/cix/phy-cix-usb3.c | 407 ++++++++++++++++++++++++++++++++ drivers/phy/cix/phy-cix-usbdp.h | 310 ++++++++++++++++++++++++ 6 files changed, 745 insertions(+) create mode 100644 drivers/phy/cix/Kconfig create mode 100644 drivers/phy/cix/Makefile create mode 100644 drivers/phy/cix/phy-cix-usb3.c create mode 100644 drivers/phy/cix/phy-cix-usbdp.h
drivers/phy/Kconfig +1 -0
@@ -175,6 +175,7 @@ source "drivers/phy/axiado/Kconfig" source "drivers/phy/broadcom/Kconfig" source "drivers/phy/cadence/Kconfig" source "drivers/phy/canaan/Kconfig" +source "drivers/phy/cix/Kconfig" source "drivers/phy/eswin/Kconfig" source "drivers/phy/freescale/Kconfig" source "drivers/phy/hisilicon/Kconfig"
drivers/phy/Makefile +1 -0
@@ -27,6 +27,7 @@ obj-$(CONFIG_GENERIC_PHY) += allwinner/ \ broadcom/ \ cadence/ \ canaan/ \ + cix/ \ eswin/ \ freescale/ \ hisilicon/ \
drivers/phy/cix/Kconfig new file +20 -0
@@ -0,0 +1,20 @@ +# SPDX-License-Identifier: GPL-2.0-only +# +# Phy drivers for Cix PHYs +# + +if ARCH_CIX || COMPILE_TEST + +config PHY_CIX_USB3 + tristate "Cix USB3 PHY Driver" + depends on OF && HAS_IOMEM + select GENERIC_PHY + help + Enable this to support the CIX USB3 PHY for TYPEA Connection. + + This driver provides initialization and power management for + the USB3 PHY found on CIX Sky1 SoCs. + + If unsure, say N. + +endif # ARCH_CIX || COMPILE_TEST
drivers/phy/cix/Makefile new file +6 -0
@@ -0,0 +1,6 @@ +# SPDX-License-Identifier: GPL-2.0 +# +# Makefile for the Cix phy drivers. +# + +obj-$(CONFIG_PHY_CIX_USB3) += phy-cix-usb3.o
drivers/phy/cix/phy-cix-usb3.c new file +407 -0
407 lines not on this page · raw message
drivers/phy/cix/phy-cix-usbdp.h new file +310 -0
310 lines not on this page · raw message
Signature · 1 line
2.54.0
[email protected]
AI reviewRe: [PATCH v2 3/5] phy: cix: Add CIX Sky1 USB3 PHY driver
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider: - [High] Hardware resets asserted after exposing the PHY provider, risking a race condition with consumers.…
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [High] Hardware resets asserted after exposing the PHY provider, risking a race condition with consumers.
- [Medium] Teardown asymmetry and inverted unroll order for hardware clocks and resets.
- [Medium] Unsafe string comparison using fwnode_get_name() without NULL check.
--
commit dd0ea5bd301cf4c2946f4bb80843b35c7ad1ab64
Author: Hongliang Yang <[email protected]>
phy: cix: Add CIX Sky1 USB3 PHY driver
This commit adds a PHY driver for the USB3 PHY on CIX Sky1 SoCs, handling initialization, reset, and clock management for the multi-port USB3 PHY.
Quoted 4 lines
drivers/phy/cix/phy-cix-usb3.c new file +0
-0
[ ... ]
drivers/phy/cix/phy-cix-usb3.c line 173
Quoted 8 lines
drivers/phy/cix/phy-cix-usb3.c new file +8
-0+static int sky1_u3phy_exit (struct cix_u3phy *u3phy) +{ + u3phy->init_count--; +if (u3phy->init && u3phy->init_count ==0 ) { +reset_control_assert (u3phy->reset); +reset_control_assert (u3phy->preset); +clk_disable_unprepare (u3phy->apb_clk); +clk_disable_unprepare (u3phy->ref_clk);
[Severity: Medium]
Does this disable the clocks in the correct order? The initialization path enables apb_clk before ref_clk. To ensure a proper LIFO teardown sequence, should ref_clk be disabled before apb_clk here?
[ ... ]
Quoted 2 lines
drivers/phy/cix/phy-cix-usb3.c new file +2
-0+static int sky1_u3phy_init (struct cix_u3phy *u3phy) +{
[ ... ]
drivers/phy/cix/phy-cix-usb3.c line 216
Quoted 7 lines
drivers/phy/cix/phy-cix-usb3.c new file +7
-0+disable_ref_clk: +clk_disable_unprepare (u3phy->ref_clk); +disable_apb_clk: +clk_disable_unprepare (u3phy->apb_clk); +assert_reset_preset: +reset_control_assert (u3phy->preset); +reset_control_assert (u3phy->reset);
[Severity: Medium]
Will this error unroll sequence leave the hardware in an unrecoverable state?
This path disables the clocks before asserting the hardware resets. This contradicts the normal teardown sequence in sky1_u3phy_exit(), which asserts the resets before disabling the clocks.
[ ... ]
Quoted 2 lines
drivers/phy/cix/phy-cix-usb3.c new file +2
-0+static int cix_u3phy_probe (struct platform_device *pdev) +{
[ ... ]
drivers/phy/cix/phy-cix-usb3.c line 363
Quoted 4 lines
drivers/phy/cix/phy-cix-usb3.c new file +4
-0+device_for_each_child_node_scoped (dev, child_fn) { + child_np =to_of_node (child_fn); +if (!strncmp (fwnode_get_name (child_fn),"usb-port" ,8 ) || + !strncmp (fwnode_get_name (child_fn),"USB" ,3 ))
[Severity: Medium]
Can this trigger a NULL pointer dereference? fwnode_get_name() can return NULL for certain software nodes.
Additionally, does using strncmp() with a fixed length incorrectly match arbitrary suffixes like "usb-port-foo" while failing to properly handle unit addresses like "usb-port@0"? Could fwnode_name_eq() be used here instead?
[ ... ]
drivers/phy/cix/phy-cix-usb3.c line 382
Quoted 8 lines
drivers/phy/cix/phy-cix-usb3.c new file +8
-0+ phy_provider =devm_of_phy_provider_register (dev, of_phy_simple_xlate); +if (IS_ERR (phy_provider)) { + ret =PTR_ERR (phy_provider); +dev_err (dev,"failed to register phy provider\n" ); +return ret; + } +reset_control_assert (u3phy->reset); +reset_control_assert (u3phy->preset);
[Severity: High]
Does asserting these resets after exposing the PHY provider create a race condition with consumers?
Once devm_of_phy_provider_register() completes, a consumer driver could concurrently probe and call phy_init(). If the consumer initializes the PHY and deasserts the resets, this probe thread will then continue and unconditionally assert the resets without holding u3phy->mutex. This would destroy the initialized state while the consumer is actively using the PHY.
Quoted 2 lines
drivers/phy/cix/phy-cix-usb3.c new file +2
-0+return 0 ; +}
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
PATCH v2 4/5 usb: cdns3: Add CIX Sky1 glue driver
In reply to Hongliang YangAdd a glue layer driver for the Cadence USBSSP controller integrated in the CIX Sky1 SoC. The driver manages the controller clocks, resets, and the mode strap controls located in the Sky1 S5 system controller.
--- drivers/usb/cdns3/Kconfig | 13 + drivers/usb/cdns3/Makefile | 1 + drivers/usb/cdns3/cdnsp-sky1.c | 673 +++++++++++++++++++++++++++++++++ drivers/usb/cdns3/cdnsp-sky1.h | 127 +++++++ 4 files changed, 814 insertions(+) create mode 100644 drivers/usb/cdns3/cdnsp-sky1.c create mode 100644 drivers/usb/cdns3/cdnsp-sky1.h
drivers/usb/cdns3/Kconfig +13 -0
@@ -77,6 +77,19 @@ config USB_CDNSP_PCI If you choose to build this driver as module it will be dynamically linked and module will be called cdnsp-pci.ko +config USB_CDNSP_SKY1 + tristate "Cadence USB3 support on CIX Sky1 SoC platforms" + depends on USB_CDNS3 + depends on ARCH_CIX || COMPILE_TEST + default USB_CDNS3 + help + Glue driver for the Cadence USB dual-role controllers on CIX Sky1 + (device tree compatible cix,sky1-usb3). It enables clocks and resets + from the SoC, then uses the shared cdns3 platform core (cdns.ko). + + If built as a module, the module is named cdnsp-sky1.ko and must be + loaded after the cdns core module when both are loadable modules. + config USB_CDNS3_TI tristate "Cadence USB3 support on TI platforms" depends on ARCH_K3 || COMPILE_TEST
drivers/usb/cdns3/Makefile +1 -0
@@ -28,3 +28,4 @@ obj-$(CONFIG_USB_CDNSP_PCI) += cdnsp-pci.o obj-$(CONFIG_USB_CDNS3_TI) += cdns3-ti.o obj-$(CONFIG_USB_CDNS3_IMX) += cdns3-imx.o obj-$(CONFIG_USB_CDNS3_STARFIVE) += cdns3-starfive.o +obj-$(CONFIG_USB_CDNSP_SKY1) += cdnsp-sky1.o
drivers/usb/cdns3/cdnsp-sky1.c new file +673 -0
673 lines not on this page · raw message
drivers/usb/cdns3/cdnsp-sky1.h new file +127 -0
127 lines not on this page · raw message
Signature · 1 line
2.54.0
[email protected]
AI reviewRe: [PATCH v2 4/5] usb: cdns3: Add CIX Sky1 glue driver
Thank you for your contribution! Sashiko AI review found 10 potential issue(s) to consider: - [High] Massive resource leak on probe error paths (I/O memory, clocks, and resets). - [High]…
Thank you for your contribution! Sashiko AI review found 10 potential issue(s) to consider:
- [High] Massive resource leak on probe error paths (I/O memory, clocks, and resets).
- [High] Thread-safety and double-free vulnerability due to modifying a static global of_dev_auxdata array during probe.
- [High] Unbalanced runtime PM usage count and missing PM disable in cdnsp_sky1_remove.
- [High] Incorrect reset control assertion logic in remove path fails to quiesce hardware.
- [High] NULL pointer dereference when accessing xhci_dev->dev in platform_suspend.
- [Medium] OF node reference leak in sky1_of_get_addr_by_name() because the reference obtained by of_get_next_child() is never released.
- [Medium] Destructive error handling in cdnsp_sky1_clk_enable_resume corrupts internal clock pointers.
- [Medium] Potential Use-After-Free (UAF) due to missing device refcounting in iterator callbacks during shutdown.
- [Medium] Undefined behavior due to bitwise shift into the sign bit.
- [Medium] PM subsystem guideline violation: PM sleep callbacks are assigned without the required pm_sleep_ptr() wrapper. --
commit 0232318426cffe797c62a93651116101c396ebb4
Author: Hongliang Yang <[email protected]>
usb: cdns3: Add CIX Sky1 glue driver
This commit adds a glue layer driver for the Cadence USBSSP controller integrated in the CIX Sky1 SoC. The driver manages the controller clocks, resets, and the mode strap controls located in the Sky1 S5 system controller.
Quoted 5 lines
drivers/usb/cdns3/cdnsp-sky1.c new file +0
-0
[ ... ]
Quoted 14 lines
drivers/usb/cdns3/cdnsp-sky1.c new file +14
-0+static int cdnsp_sky1_clk_enable_resume (struct device *dev) +{ +int i, ret; +struct cdnsp_sky1 *data =dev_get_drvdata (dev); +struct clk **cix_usb_clks = data->cix_usb_clks; + +for (i =0 ; i <CIX_USB_CLK_OFF_NUM ; i++) { + ret =clk_prepare_enable (cix_usb_clks[i]); +if (ret) { +dev_err (dev,"failed to enable clock %s: %d\n" , + cix_usb_clk_names[i], ret); + goto err_usb_clks; + } + }
drivers/usb/cdns3/cdnsp-sky1.c line 150
Quoted 10 lines
drivers/usb/cdns3/cdnsp-sky1.c new file +10
-0+return 0 ; + +err_usb_clks: + cix_usb_clks[i] =NULL ; +while (--i >=0 ) { +clk_disable_unprepare (cix_usb_clks[i]); + cix_usb_clks[i] =NULL ; + } +return ret; +};
[Severity: Medium]
Does setting cix_usb_clks[i] to NULL here permanently wipe the devm-managed clock references from the driver's private state? If a system clock fails to resume, won't subsequent calls to enable or disable these clocks receive NULL pointers and silently fail to configure the hardware?
[ ... ]
Quoted 8 lines
drivers/usb/cdns3/cdnsp-sky1.c new file +8
-0+static int cdns_sky1_platform_suspend (struct device *dev, +bool suspend,bool wakeup) +{ +struct cdns *cdns =dev_get_drvdata (dev); +struct platform_device *xhci_dev = cdns->host_dev; +struct usb_hcd *hcd; +struct device *parent = cdns->dev->parent; +struct cdnsp_sky1 *data =dev_get_drvdata (parent);
drivers/usb/cdns3/cdnsp-sky1.c line 199
Quoted 10 lines
drivers/usb/cdns3/cdnsp-sky1.c new file +10
-0+u32 value; +int ret =0 ; +int count =3 ; + + data->wakeup = wakeup; + +if (cdns->role !=USB_ROLE_HOST ) +return 0 ; + + hcd =dev_get_drvdata (&xhci_dev->dev);
[Severity: High]
Could xhci_dev be NULL if the host initialization failed or was unbound? If so, would accessing &xhci_dev->dev lead to an out-of-bounds pointer dereference during system suspend?
[ ... ]
drivers/usb/cdns3/cdnsp-sky1.c line 402
Quoted 13 lines
drivers/usb/cdns3/cdnsp-sky1.c new file +13
-0+static void *sky1_of_get_addr_by_name (struct device_node *parent,char *name) +{ +struct device_node *node; +int index; + + node =of_get_next_child (parent,NULL ); +if (node) { + index =of_property_match_string (node,"reg-names" , name); +if (index >=0 ) +return of_iomap (node, index); + } +return NULL ; +}
[Severity: Medium]
Does of_get_next_child() return the node with an incremented reference count? Should there be a call to of_node_put(node) before returning to prevent a memory leak?
[ ... ]
Quoted 7 lines
drivers/usb/cdns3/cdnsp-sky1.c new file +7
-0+static int cdnsp_sky1_probe (struct platform_device *pdev) +{ +struct device *dev = &pdev->dev; +struct device_node *node = dev->of_node; +struct cdnsp_sky1 *data; +int ret =0 ; +struct cdns3_platform_data *cdns_sky1_pdata;
[ ... ]
drivers/usb/cdns3/cdnsp-sky1.c line 488
Quoted 5 lines
drivers/usb/cdns3/cdnsp-sky1.c new file +5
-0+ ret =cdnsp_sky1_drd_init (data); +if (ret == -ETIMEDOUT ) +return -EPROBE_DEFER ; +if (ret) +return ret;
[Severity: High]
If probe fails here and returns directly, are the I/O memory mappings for xhci_base and device_base (which were mapped via non-devm of_iomap) left active? Should they be unmapped and the clocks/resets cleaned up?
[ ... ]
drivers/usb/cdns3/cdnsp-sky1.c line 507
Quoted 8 lines
drivers/usb/cdns3/cdnsp-sky1.c new file +8
-0+/* release by platform_device_release */ + cdns_sky1_pdata =kzalloc (sizeof (*cdns_sky1_pdata),GFP_KERNEL ); +if (!cdns_sky1_pdata) +return -ENOMEM ; + cdns_sky1_pdata->platform_suspend = cdns_sky1_platform_suspend; + cdns_sky1_pdata->quirks =CDNS3_DEFAULT_PM_RUNTIME_ALLOW ; + cdns_sky1_auxdata->platform_data = cdns_sky1_pdata; + ret =of_platform_populate (node,NULL , cdns_sky1_auxdata, dev);
[Severity: High]
Is it safe to assign a dynamically allocated instance-specific pointer (cdns_sky1_pdata) to the statically allocated global array cdns_sky1_auxdata? Could this lead to a double-free vulnerability if multiple controller instances exist or if the driver is repeatedly unbound and rebound?
drivers/usb/cdns3/cdnsp-sky1.c line 519
Quoted 12 lines
drivers/usb/cdns3/cdnsp-sky1.c new file +12
-0+if (ret) { +dev_err (dev,"failed to create children: %d\n" , ret); + goto err; + } +device_set_wakeup_capable (dev, true); +pm_runtime_set_active (dev); +pm_runtime_enable (dev); +return 0 ; +err: +kfree (cdns_sky1_pdata); +return ret; +}
[Severity: High]
Does this shared error path fail to clean up the I/O memory mappings, assert resets, and disable clocks before returning?
drivers/usb/cdns3/cdnsp-sky1.c line 531
Quoted 11 lines
drivers/usb/cdns3/cdnsp-sky1.c new file +11
-0+static void cdnsp_sky1_remove (struct platform_device *pdev) +{ +struct device *dev = &pdev->dev; +struct cdnsp_sky1 *data =dev_get_drvdata (dev); + +pm_runtime_get_sync (dev); +of_platform_depopulate (dev); +sky1_put_addr (data->xhci_base); +sky1_put_addr (data->device_base); +reset_control_deassert (data->reset); +reset_control_deassert (data->preset);
[Severity: High]
Should these be reset_control_assert() instead of deassert() to correctly quiesce the hardware before the clocks are disabled?
drivers/usb/cdns3/cdnsp-sky1.c line 534
Quoted 3 lines
drivers/usb/cdns3/cdnsp-sky1.c new file +3
-0+cdnsp_sky1_clk_disable_all (dev); +platform_set_drvdata (pdev,NULL ); +}
[Severity: High]
Does this function need to call pm_runtime_put_sync() and pm_runtime_disable()? Because pm_runtime_get_sync(dev) increments the usage counter at the start of the function, could omitting the decrement lead to a leaked usage count and a broken PM state machine for the device on subsequent binds?
[ ... ]
drivers/usb/cdns3/cdnsp-sky1.c line 574
Quoted 4 lines
drivers/usb/cdns3/cdnsp-sky1.c new file +4
-0+static const struct dev_pm_ops cdnsp_sky1_pm_ops = { + .suspend = cdnsp_sky1_system_suspend, + .resume = cdnsp_sky1_system_resume, +};
[Severity: Medium]
Should these sleep callbacks be wrapped with pm_sleep_ptr()? Without it, if CONFIG_PM is enabled but CONFIG_PM_SLEEP is disabled, could this generate dead code warnings for the suspend and resume functions?
[ ... ]
Quoted 10 lines
drivers/usb/cdns3/cdnsp-sky1.c new file +10
-0+static void cdnsp_sky1_shutdown (struct platform_device *pdev) +{ +struct device *dev = &pdev->dev; +struct cdnsp_sky1 *data =dev_get_drvdata (dev); +struct cdns *cdns =NULL ; +struct device *gadget_dev =NULL ; + +if (!device_may_wakeup (dev)) { +/* +* Find the cdns3 child device, then find its gadget device
drivers/usb/cdns3/cdnsp-sky1.c line 636
Quoted 10 lines
drivers/usb/cdns3/cdnsp-sky1.c new file +10
-0+* and release the function driver before disabling clocks. +* This ensures all register accesses in gadget_unbind_driver +* complete before clocks are turned off. +*/ +device_for_each_child (dev, &cdns, cdnsp_sky1_find_cdns); +if (cdns) +device_for_each_child (cdns->dev, &gadget_dev, + cdnsp_sky1_find_gadget_match); +if (gadget_dev) +device_release_driver (gadget_dev);
[Severity: Medium]
Does device_for_each_child() release the reference on the child device immediately after the callback returns?
If so, could extracting the cdns and gadget_dev pointers out of the iterator loop without acquiring references create a use-after-free window when they are subsequently dereferenced?
Quoted 5 lines
drivers/usb/cdns3/cdnsp-sky1.h new file +0
-0
[ ... ]
drivers/usb/cdns3/cdnsp-sky1.h line 92
Quoted 3 lines
drivers/usb/cdns3/cdnsp-sky1.h new file +3
-0+#define D_XEC_CFG_3XPORT_MODE_VALUE 0xa0031e07 +#define XEC_CFG_3XPORT_MODE_VALUE 0xa0031e07 +#define CFG_3XPORT_MODE_DIS_SSP (~(1 << 31))
[Severity: Medium]
Does shifting 1 by 31 bits here trigger undefined behavior since 1 is a signed int? Could this use 1U or BIT(31) instead?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=4
PATCH v2 5/5 arm64: dts: cix: Add USB4/USB5 nodes for Sky1
In reply to Hongliang YangAdd USB4 and USB5 controller nodes and their associated USB3 PHY nodes for the CIX Sky1 SoC. Enable USB4 and USB5 in host mode on the Radxa Orion O6 board.
--- arch/arm64/boot/dts/cix/sky1-orion-o6.dts | 54 ++++++++++ arch/arm64/boot/dts/cix/sky1.dtsi | 118 ++++++++++++++++++++++ 2 files changed, 172 insertions(+)
arch/arm64/boot/dts/cix/sky1-orion-o6.dts +54 -0
@@ -80,6 +80,22 @@ pins { }; }; + + pinctrl_usb4: usb4-power-on-cfg { + pins { + bias-pull-down; + drive-strength = <8>; + pinmux = <CIX_PAD_GPIO041_FUNC_USB_DRIVE_VBUS4>; + }; + }; + + pinctrl_usb5: usb5-power-on-cfg { + pins { + bias-pull-down; + drive-strength = <8>; + pinmux = <CIX_PAD_GPIO042_FUNC_USB_DRIVE_VBUS5>; + }; + }; }; &pcie_x8_rc {
@@ -117,3 +133,41 @@ &s5_gpio2 { &uart2 { status = "okay"; }; + +&usb4 { + pinctrl-0 = <&pinctrl_usb4>; + pinctrl-names = "default"; + + status = "okay"; +}; + +&usbss_4 { + dr_mode = "host"; + + status = "okay"; +}; + +&usb5 { + pinctrl-0 = <&pinctrl_usb5>; + pinctrl-names = "default"; + + status = "okay"; +}; + +&usbss_5 { + dr_mode = "host"; + + status = "okay"; +}; + +&usb3_phy4 { + status = "okay"; + + usb-port@0 { + status = "okay"; + }; + + usb-port@1 { + status = "okay"; + }; +};
arch/arm64/boot/dts/cix/sky1.dtsi +118 -0
136 lines not on this page · raw message
Signature · 1 line
2.54.0
v2 cover Add CIX Sky1 USB3/USBSSP support
In reply to Hongliang YangAdd USB3 PHY binding and driver, Cadence USBSSP glue binding and driver, and USB4/USB5 device tree nodes for the CIX Sky1 SoC.
This series adds support for the USB4 and USB5 controllers (based on Cadence USBSSP DRD) found on the CIX Sky1 SoC, along with their associated multi-port USB3 PHY.
Changes in v2:
- Split the dt-bindings patch into separate PHY and USBSSP binding patches with proper subsystem subject prefixes.
- Follow the DTS coding style in the bindings and DTS (property ordering, no redundant unit-address suffixes in examples); examples pass dt-check-style in strict mode.
- Drop the redundant "_clk" suffix and "reset"/"usb" prefixes from clock-names and reset-names ("apb_clk" -> "apb", "ref_clk" -> "ref", "reset"/"preset" -> "core"/"apb", "usb_preset"/"usb_reset" -> "apb"/"core", "sof_clk"/"usb_aclk"/"lpm_clk"/"usb_pclk" -> "sof"/"axi"/"lpm"/"apb").
- Rename reg-names "axi_property"/"controller_status" to "axi"/"controller".
- Rename the Cadence core child nodes from usb-controller@ to the conventional usb@ node name.
- Drop the cix,axi-bmax-value, sof_clk_freq and lpm_clk_freq properties. These are fixed per SoC and are now hardcoded in the glue driver.
- Rename cix,usb_syscon -> cix,usb-syscon to follow devicetree property naming conventions.
- Use additionalProperties: false instead of
unevaluatedProperties: false in the PHY binding (no other schema is referenced).
- Fix unit addresses in the binding example and DTS nodes to match the first reg address (usb@91c0314, usb@91c0324).
- Enable the usb4/usb5 wrapper nodes, usb3_phy4 PHY and its ports in the Orion O6 board file so the controllers can probe.
- Add reg properties to the usb-port@0/usb-port@1 child nodes.
- Fix the reg-names order of the cdns,usb3 child nodes to "otg", "xhci", "dev" as required by the binding schema.
- Use devm_reset_control_get_exclusive() instead of the deprecated devm_reset_control_get() in the USB3 PHY and glue drivers.
- Propagate error codes from the PHY driver probe paths instead of returning 0 unconditionally.
- Use device_for_each_child_node_scoped() to drop the manual of_node_put() and fix the double-put/uninitialized access on the probe error path.
- Remove the phy_create_lookup() entries which leaked on unbind and were unused (consumers reference the PHY via the DT "phys" phandle).
- Assert (not deassert) the hardware resets on the sky1_u3phy_init() error path.
- Add MODULE_DEVICE_TABLE(of, ...) for automatic module loading.
Hongliang Yang (5):
dt-bindings: phy: Add CIX Sky1 USB3 PHY
dt-bindings: usb: Add CIX Sky1 USBSSP controller
phy: cix: Add CIX Sky1 USB3 PHY driver
usb: cdns3: Add CIX Sky1 glue driver
arm64: dts: cix: Add USB4/USB5 nodes for Sky1
.../bindings/phy/cix,sky1-usb3-phy.yaml | 107 +++ .../bindings/usb/cix,sky1-usbssp.yaml | 137 ++++ MAINTAINERS | 3 + arch/arm64/boot/dts/cix/sky1-orion-o6.dts | 50 ++ arch/arm64/boot/dts/cix/sky1.dtsi | 125 ++++ drivers/phy/Kconfig | 1 + drivers/phy/Makefile | 1 + drivers/phy/cix/Kconfig | 20 + drivers/phy/cix/Makefile | 6 + drivers/phy/cix/phy-cix-usb3.c | 407 +++++++++++ drivers/phy/cix/phy-cix-usbdp.h | 310 ++++++++ drivers/usb/cdns3/Kconfig | 13 + drivers/usb/cdns3/Makefile | 1 + drivers/usb/cdns3/cdnsp-sky1.c | 673 ++++++++++++++++++ drivers/usb/cdns3/cdnsp-sky1.h | 127 ++++ 15 files changed, 1981 insertions(+) create mode 100644 Documentation/devicetree/bindings/phy/cix,sky1-usb3-phy.yaml create mode 100644 Documentation/devicetree/bindings/usb/cix,sky1-usbssp.yaml create mode 100644 drivers/phy/cix/Kconfig create mode 100644 drivers/phy/cix/Makefile create mode 100644 drivers/phy/cix/phy-cix-usb3.c create mode 100644 drivers/phy/cix/phy-cix-usbdp.h create mode 100644 drivers/usb/cdns3/cdnsp-sky1.c create mode 100644 drivers/usb/cdns3/cdnsp-sky1.h
Signature · 1 line
2.54.0