Skip to contentSkip to conversation

riscv: dts: spacemit: k3: Add USB/PCIe devices

PATCH Applied Inochi Amaoto 3 participants 7 messages Jul 27 – Aug 2

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

v2 cover riscv: dts: spacemit: k3: Add USB/PCIe devices

DTS for series:
https://lore.kernel.org/linux-pci/[email protected]
https://lore.kernel.org/linux-phy/[email protected]

Changed from v1:
1. Fix clock of usb3d_u2phy.

Inochi Amaoto (2):
riscv: dts: spacemit: k3: add USB controller and USB phy support
riscv: dts: spacemit: k3: Add PCIe device node

 arch/riscv/boot/dts/spacemit/k3-pico-itx.dts |  51 ++++
 arch/riscv/boot/dts/spacemit/k3-pinctrl.dtsi |  33 +++
 arch/riscv/boot/dts/spacemit/k3.dtsi         | 237 +++++++++++++++++++
 3 files changed, 321 insertions(+)

--
2.55.0

#1 lore raw

PATCH v2 1/2 riscv: dts: spacemit: k3: add USB controller and USB phy support

Add all USB device node to the Spacemit K3.

---
 arch/riscv/boot/dts/spacemit/k3-pico-itx.dts | 13 ++++++
 arch/riscv/boot/dts/spacemit/k3.dtsi         | 42 ++++++++++++++++++++
 2 files changed, 55 insertions(+)
arch/riscv/boot/dts/spacemit/k3-pico-itx.dts +13 -0
index b89c1521e664..2a6d35a64d5c 100644
@@ -182,6 +182,11 @@ dldo7: dldo7 {
 	};
 };
 
+&combophy {
+	spacemit,apmu = <&syscon_apmu 0x11>;
+	status = "okay";
+};
+
 &eth0 {
 	pinctrl-names = "default";
 	pinctrl-0 = <&gmac0_rgmii_0_cfg>, <&gmac0_phy_0_cfg>;
@@ -221,3 +226,11 @@ hub@1 {
 &usb2_phy {
 	status = "okay";
 };
+
+&usb3d_u2phy {
+	status = "okay";
+};
+
+&usb3d {
+	status = "okay";
+};
arch/riscv/boot/dts/spacemit/k3.dtsi +42 -0

54 lines not on this page · raw message

Signature · 1 line
2.55.0
#2 lore raw

Re: [PATCH v2 1/2] riscv: dts: spacemit: k3: add USB controller and USB phy support

Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:

Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:

New issues:
- [High] The spacemit,k3-combo-phy compatible string is undocumented and lacks a driver, causing the usb3d controller to endlessly defer probing.
- [Medium] The phy_type property is ignored by the DWC3 controller driver; the standard snps,hsphy_interface should be used instead.
- [Medium] The combophy node violates devicetree layering by defining internal SoC routing at the board level, relies on undocumented properties, and omits hardware dependencies.

Pre-existing issues:
- [High] DWC3 hardware resets are toggled before clocks are enabled, violating synchronous reset constraints. --

--- Patch [1]: [PATCH v2 1/2] riscv: dts: spacemit: k3: add USB controller and USB phy support --- commit fc8b62c47a78ea5ec792c1be2a1f162dc04c118a
Author: Inochi Amaoto <[email protected]>

riscv: dts: spacemit: k3: add USB controller and USB phy support

This commit adds USB device nodes to the Spacemit K3 SoC devicetree. It introduces configurations for the DWC3 controller, USB2 PHY, and a combo PHY, enabling them for the K3 Pico-ITX board.

Quoted 3 lines
arch/riscv/boot/dts/spacemit/k3-pico-itx.dts +0 -0

[ ... ]

arch/riscv/boot/dts/spacemit/k3-pico-itx.dts dldo7: dldo7 { · line 186

Quoted 6 lines
arch/riscv/boot/dts/spacemit/k3-pico-itx.dts +2 -0
@@ -182,6 +182,11 @@ dldo7: dldo7 {
 	};
 };
 
+&combophy {
+	spacemit,apmu = <&syscon_apmu 0x11>;

[Severity: Medium]
Since spacemit,apmu defines an internal SoC connection between the PHY and the APMU, should this property be placed in k3.dtsi rather than the board-level file to avoid duplicating internal topology across boards?

Quoted 3 lines
arch/riscv/boot/dts/spacemit/k3-pico-itx.dts +3 -0
+	status = "okay";
+};
+

[ ... ]

Quoted 3 lines
arch/riscv/boot/dts/spacemit/k3.dtsi +0 -0

[ ... ]

arch/riscv/boot/dts/spacemit/k3.dtsi soc: soc { · line 442

Quoted 5 lines
arch/riscv/boot/dts/spacemit/k3.dtsi +1 -0
@@ -438,6 +439,47 @@ soc: soc {
 		dma-noncoherent;
 		ranges;
 
+		usb3d: usb@81a00000 {

[Severity: High]
This is a pre-existing issue, but it directly affects the initialization of the newly added usb3d controller here.

The core hardware sequencing in dwc3_generic_probe() asserts and deasserts hardware resets before enabling clocks:

drivers/usb/dwc3/dwc3-generic-plat.c:dwc3_generic_probe() {
    ...
    ret = reset_control_assert(dwc3g->resets);
    ...
    ret = reset_control_deassert(dwc3g->resets);
    ...
    ret = devm_clk_bulk_get_all_enabled(dwc3g->dev, &dwc3g->clks);
    ...
}

For synchronous bus architectures (AHB/AXI), does the clock need to be actively toggling for the reset signal to propagate through internal flip-flops? Toggling a synchronous reset while the IP's clocks are gated might mean the hardware ignores the reset, leading to a synchronous bus hang or initialization failure.

arch/riscv/boot/dts/spacemit/k3.dtsi soc: soc { · line 454

Quoted 12 lines
arch/riscv/boot/dts/spacemit/k3.dtsi +12 -0
+			compatible = "spacemit,k3-dwc3";
+			reg = <0x0 0x81a00000 0x0 0x10000>;
+			interrupts = <149 IRQ_TYPE_LEVEL_HIGH>;
+			interrupt-parent = <&saplic>;
+			clocks = <&syscon_apmu CLK_APMU_USB3_PORTD_BUS>;
+			clock-names = "usbdrd30";
+			resets = <&syscon_apmu RESET_APMU_USB3_D_AHB>,
+				 <&syscon_apmu RESET_APMU_USB3_D_VCC>,
+				 <&syscon_apmu RESET_APMU_USB3_D_PHY>;
+			reset-names = "ahb", "vcc", "phy";
+			phys = <&usb3d_u2phy>,
+			       <&combophy 4 PHY_TYPE_USB3>;

[Severity: High]
The spacemit,k3-combo-phy driver does not appear to exist in the tree. Because the dwc3 controller explicitly depends on this PHY via the phys property, will devm_phy_get() indefinitely return -EPROBE_DEFER and prevent the USB controller from ever initializing?

arch/riscv/boot/dts/spacemit/k3.dtsi soc: soc { · line 456

Quoted 2 lines
arch/riscv/boot/dts/spacemit/k3.dtsi +2 -0
+			phy-names = "usb2-phy", "usb3-phy";
+			phy_type = "utmi";

[Severity: Medium]
The Synopsys DesignWare Core (DWC3) driver does not read the phy_type property. It strictly relies on the vendor-specific snps,hsphy_interface property.

Could this cause the controller to silently fall back to suboptimal hardware defaults instead of the intended UTMI configuration?

Quoted 1 line
arch/riscv/boot/dts/spacemit/k3.dtsi +1 -0
+			snps,dis_enblslpm_quirk;

[ ... ]

arch/riscv/boot/dts/spacemit/k3.dtsi soc: soc { · line 479

Quoted 5 lines
arch/riscv/boot/dts/spacemit/k3.dtsi +5 -0
+		combophy: phy@81d00000 {
+			compatible = "spacemit,k3-combo-phy";
+			reg = <0x0 0x81d00000 0x0 0x600000>;
+			#phy-cells = <2>;
+			spacemit,apb-spare = <&pll>;

[Severity: Medium]
The spacemit,apb-spare property appears to be undocumented and points to a clock controller instead of a syscon.

Additionally, this node maps 6MB of register space but omits the clocks and resets properties. Are these properties required to safely access the memory-mapped IP block?

Quoted 2 lines
arch/riscv/boot/dts/spacemit/k3.dtsi +2 -0
+			status = "disabled";
+		};

[ ... ]

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
maintainer Reviewed-by on v2 1/2
#3 lore raw

Re: [PATCH v2 1/2] riscv: dts: spacemit: k3: add USB controller and USB phy support

In reply to Inochi Amaoto

Hi Inochi,

Quoted 3 lines · Inochi Amaoto

Add all USB device node to the Spacemit K3.

Quoted 5 lines
---
 arch/riscv/boot/dts/spacemit/k3-pico-itx.dts | 13 ++++++
 arch/riscv/boot/dts/spacemit/k3.dtsi         | 42 ++++++++++++++++++++
 2 files changed, 55 insertions(+)
Signature · 1 line
Yixun Lan (dlan)
#4 lore raw

PATCH v2 2/2 riscv: dts: spacemit: k3: Add PCIe device node

In reply to Inochi Amaoto

Add all PCIe device node for Spacemit K3.

---
 arch/riscv/boot/dts/spacemit/k3-pico-itx.dts |  38 ++++
 arch/riscv/boot/dts/spacemit/k3-pinctrl.dtsi |  33 ++++
 arch/riscv/boot/dts/spacemit/k3.dtsi         | 195 +++++++++++++++++++
 3 files changed, 266 insertions(+)
arch/riscv/boot/dts/spacemit/k3-pico-itx.dts +38 -0
index 2a6d35a64d5c..1eb5abbc61f9 100644
@@ -205,6 +205,44 @@ phy0: phy@1 {
 	};
 };
 
+&pcie0_rc {
+	pinctrl-names = "default";
+	pinctrl-0 = <&pcie0_0_cfg>;
+	num-lanes = <4>;
+	status = "okay";
+
+	pcie@0 {
+		vpcie3v3-supply = <&reg_aux_vcc3v3>;
+		phys = <&combophy 0 PHY_TYPE_PCIE>,
+		       <&combophy 1 PHY_TYPE_PCIE>;
+	};
+};
+
+&pcie2_rc {
+	pinctrl-names = "default";
+	pinctrl-0 = <&pcie2_0_cfg>;
+	num-lanes = <2>;
+	status = "okay";
+
+	pcie@0 {
+		vpcie3v3-supply = <&reg_aux_vcc3v3>;
+		phys = <&combophy 2 PHY_TYPE_PCIE>,
+		       <&combophy 3 PHY_TYPE_PCIE>;
+	};
+};
+
+&pcie4_rc {
+	pinctrl-names = "default";
+	pinctrl-0 = <&pcie4_0_cfg>;
+	num-lanes = <1>;
+	status = "okay";
+
+	pcie@0 {
+		vpcie3v3-supply = <&reg_aux_vcc3v3>;
+		phys = <&combophy 5 PHY_TYPE_PCIE>;
+	};
+};
+
 &uart0 {
 	pinctrl-names = "default";
 	pinctrl-0 = <&uart0_0_cfg>;
arch/riscv/boot/dts/spacemit/k3-pinctrl.dtsi +33 -0
index 3ee1471f3798..68aa21a5279f 100644
@@ -689,4 +689,37 @@ uart0-0-pins {
 			drive-strength = <25>;
 		};
 	};
+
+	pcie0_0_cfg: pcie0-0-cfg {
+		pcie0-0-pins {
+			pinmux = <K3_PADCONF(79, 5)>,   /* pcie0 perst */
+				 <K3_PADCONF(81, 5)>;	/* pcie0 clkreq */
+
+			bias-pull-up = <1>;
+			drive-strength = <33>;
+			power-source = <1800>;
+		};
+	};
+
+	pcie2_0_cfg: pcie2-0-cfg {
+		pcie2-0-pins {
+			pinmux = <K3_PADCONF(25, 4)>,	/* pcie2 perst */
+				 <K3_PADCONF(27, 4)>;	/* pcie2 clkreq */
+
+			drive-strength = <38>;
+			power-source = <3300>;
+		};
+	};
+
+	pcie4_0_cfg: pcie4-0-cfg {
+		pcie4-0-pins {
+			pinmux = <K3_PADCONF(76, 5)>,	/* pcie4 perst */
+				 <K3_PADCONF(77, 5)>,	/* pcie4 wake */
+				 <K3_PADCONF(78, 5)>;	/* pcie4 clkreq */
+
+			bias-pull-up = <1>;
+			drive-strength = <33>;
+			power-source = <1800>;
+		};
+	};
 };
arch/riscv/boot/dts/spacemit/k3.dtsi +195 -0

201 lines not on this page · raw message

Signature · 1 line
2.55.0
#5 lore raw

Re: [PATCH v2 2/2] riscv: dts: spacemit: k3: Add PCIe device node

Thank you for your contribution! Sashiko AI review found 5 potential issue(s) to consider: - [High] The PCIe host controller nodes lack the required 'interrupts' property for native host controller…

Thank you for your contribution! Sashiko AI review found 5 potential issue(s) to consider:
- [High] The PCIe host controller nodes lack the required 'interrupts' property for native host controller events and legacy INTx IRQ routing properties.
- [High] Incorrect device tree mapping for PCI I/O address ranges.
- [High] Hardware lane configuration mismatch in pcie0_rc specifies 4 lanes but only provisions 2 PHYs.
- [Medium] The 'spacemit,k3-pcie' compatible string is undocumented and its nodes violate established schema constraints.
- [Medium] Inconsistent property placement for 'bus-range' between host controllers.
--

--- Patch [2]: [PATCH v2 2/2] riscv: dts: spacemit: k3: Add PCIe device node --- commit 6adf11d50db9bcfba7141ad15e1666cad3b96e91
Author: Inochi Amaoto <[email protected]>

riscv: dts: spacemit: k3: Add PCIe device node

This commit adds PCIe device nodes for the Spacemit K3 SoC. It includes pinctrl configurations and board-level properties for the Pico-ITX board.

Quoted 4 lines
arch/riscv/boot/dts/spacemit/k3-pico-itx.dts +0 -0
index 2a6d35a64d5ce..1eb5abbc61f97 100644

[ ... ]

Quoted 4 lines
arch/riscv/boot/dts/spacemit/k3-pico-itx.dts +0 -0
@@ -205,6 +205,44 @@ phy0: phy@1 {
 	};
 };
 

arch/riscv/boot/dts/spacemit/k3-pico-itx.dts phy0: phy@1 { · line 217

Quoted 10 lines
arch/riscv/boot/dts/spacemit/k3-pico-itx.dts +10 -0
+&pcie0_rc {
+	pinctrl-names = "default";
+	pinctrl-0 = <&pcie0_0_cfg>;
+	num-lanes = <4>;
+	status = "okay";
+
+	pcie@0 {
+		vpcie3v3-supply = <&reg_aux_vcc3v3>;
+		phys = <&combophy 0 PHY_TYPE_PCIE>,
+		       <&combophy 1 PHY_TYPE_PCIE>;

[Severity: High]
Does this lane configuration match the provisioned PHYs? This controller specifies 4 lanes via num-lanes, but only 2 PHYs are provided here. Could this cause link training failures or PHY framework errors if the driver expects 4 PHYs, especially given lanes 2 and 3 are assigned to pcie2_rc elsewhere?

[Severity: Medium]
Since the phys array contains multiple items, shouldn't there be a corresponding phy-names array? Omitting it violates standard constraints for unnamed PHYs in port nodes.

Quoted 2 lines
arch/riscv/boot/dts/spacemit/k3-pico-itx.dts +2 -0
+	};
+};

[ ... ]

Quoted 4 lines
arch/riscv/boot/dts/spacemit/k3.dtsi +0 -0
index 7863ab7dd308c..314dea88b4a4a 100644

[ ... ]

arch/riscv/boot/dts/spacemit/k3.dtsi soc: soc { · line 443

Quoted 6 lines
arch/riscv/boot/dts/spacemit/k3.dtsi +2 -0
@@ -439,6 +439,201 @@ soc: soc {
 		dma-noncoherent;
 		ranges;
 
+		pcie0_rc: pcie@80000000 {
+			compatible = "spacemit,k3-pcie";

[Severity: Medium]
Is this compatible string documented? I couldn't find a device tree binding schema for spacemit,k3-pcie.

[Severity: High]
Are there missing interrupt properties here? The host controller lacks an interrupts property for native host controller events like AER, PME, or link state changes.

Furthermore, is legacy INTx routing supported? Omitting #interrupt-cells, interrupt-map, and interrupt-map-mask will prevent the PCI subsystem from routing INTA/B/C/D interrupts for downstream devices.

arch/riscv/boot/dts/spacemit/k3.dtsi soc: soc { · line 449

Quoted 6 lines
arch/riscv/boot/dts/spacemit/k3.dtsi +6 -0
+			reg = <0x0 0x80000000 0x0 0x00001000>,
+			      <0x0 0x80300000 0x0 0x00003f20>,
+			      <0x11 0x00000000 0x0 0x00010000>,
+			      <0x0 0x82900000 0x0 0x00001000>,
+			      <0x0 0x80100000 0x0 0x00001000>;
+			reg-names = "dbi", "atu", "config", "link", "dbi2";

[Severity: Medium]
Will this pass dt_binding_check validation? The node introduces a fifth register region named dbi2, which exceeds the typical 4-item limit seen in similar bindings like spacemit,k1-pcie-host.yaml.

arch/riscv/boot/dts/spacemit/k3.dtsi soc: soc { · line 458

Quoted 9 lines
arch/riscv/boot/dts/spacemit/k3.dtsi +9 -0
+			device_type = "pci";
+			#address-cells = <3>;
+			#size-cells = <2>;
+			clocks = <&syscon_apmu CLK_APMU_PCIE_PORTA_DBI>,
+				 <&syscon_apmu CLK_APMU_PCIE_PORTA_MSTE>,
+				 <&syscon_apmu CLK_APMU_PCIE_PORTA_SLV>;
+			clock-names = "dbi", "mstr", "slv";
+			msi-parent = <&simsic>;
+			ranges = <0x01000000 0x00 0x00010000 0x11 0x00010000 0x0 0x00100000>,

[Severity: High]
Does this map the I/O window correctly? Mapping the I/O window to start at a PCI address of 0x00010000 skips the critical first 64KB.

Will this prevent the PCI subsystem from assigning valid I/O BARs for legacy PCIe cards that expect 16-bit I/O space starting at 0x0000? I notice that pcie2_rc correctly starts its mapping at 0x00000000.

Quoted 2 lines
arch/riscv/boot/dts/spacemit/k3.dtsi +2 -0
+				 <0x02000000 0x0 0x00110000 0x11 0x00110000 0x0 0x7fef0000>,
+				 <0x43000000 0x18 0x00000000 0x18 0x00000000 0x1 0x00000000>;

[ ... ]

Quoted 1 line
arch/riscv/boot/dts/spacemit/k3.dtsi +1 -0
+		pcie3_rc: pcie@80c00000 {

[ ... ]

arch/riscv/boot/dts/spacemit/k3.dtsi soc: soc { · line 583

Quoted 2 lines
arch/riscv/boot/dts/spacemit/k3.dtsi +2 -0
+			linux,pci-domain = <3>;
+			bus-range = <0x00 0xff>;

[Severity: Medium]
Is the placement of the bus-range property correct here? For the other host controllers, bus-range is located in the child port node (pcie@0).

Placing it in the parent node instead might cause subsystem enumeration issues for this bridge.

Quoted 13 lines
arch/riscv/boot/dts/spacemit/k3.dtsi +13 -0
+			max-link-speed = <3>;
+			spacemit,apmu = <&syscon_apmu 0x1e0>;
+			status = "disabled";
+
+			pcie3_port: pcie@0 {
+				device_type = "pci";
+				compatible = "pciclass,0604";
+				reg = <0x0 0x0 0x0 0x0 0x0>;
+				#address-cells = <3>;
+				#size-cells = <2>;
+				ranges;
+			};
+		};
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
maintainer Applied
#6 lore raw

Re: (subset) [PATCH v2 0/2] riscv: dts: spacemit: k3: Add USB/PCIe devices

In reply to Inochi Amaoto
Quoted 8 lines · Inochi Amaoto

DTS for series:
https://lore.kernel.org/linux-pci/[email protected]
https://lore.kernel.org/linux-phy/[email protected]

Changed from v1:
1. Fix clock of usb3d_u2phy.

[...]

Applied, thanks!

[1/2] riscv: dts: spacemit: k3: add USB controller and USB phy support

      https://git.kernel.org/pub/scm/linux/kernel/git/spacemit/linux.git/commit/?id=46380e4b1534c1626cecd7f4d0abb5e0cce09af6

Best regards,

Signature · 1 line
Yixun Lan <[email protected]>