Skip to contentSkip to conversation

Add Starfive JH7110 Cadence USB driver

PATCH Superseded Minda Chen 4 participants 14 messages Oct 12, 2024 – Dec 19, 2024

Subsystems (7)

v5 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
author maintainer
#1 lore raw

PATCH v5 1/8 usb: cdns3: Set USB PHY mode in cdns3_drd_update_mode()

In reply to Minda Chen

USB PHY maybe need to set PHY mode in different USB dr mode. So translate USB PHY mode to generic PHY mode and call generic_phy_set_mode().

---
 drivers/usb/cdns3/drd.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
drivers/usb/cdns3/drd.c +14 -0
index 47874fec29e..cbb13342343 100644
@@ -217,15 +217,19 @@ static int cdns3_init_otg_mode(struct cdns3 *cdns)
 int cdns3_drd_update_mode(struct cdns3 *cdns)
 {
 	int ret = 0;
+	int mode;
 
 	switch (cdns->dr_mode) {
 	case USB_DR_MODE_PERIPHERAL:
+		mode = PHY_MODE_USB_DEVICE;
 		ret = cdns3_set_mode(cdns, USB_DR_MODE_PERIPHERAL);
 		break;
 	case USB_DR_MODE_HOST:
+		mode = PHY_MODE_USB_HOST;
 		ret = cdns3_set_mode(cdns, USB_DR_MODE_HOST);
 		break;
 	case USB_DR_MODE_OTG:
+		mode = PHY_MODE_USB_OTG;
 		ret = cdns3_init_otg_mode(cdns);
 		break;
 	default:
@@ -234,6 +238,16 @@ int cdns3_drd_update_mode(struct cdns3 *cdns)
 		return -EINVAL;
 	}
 
+	ret = generic_phy_set_mode(&cdns->usb2_phy, mode, 0);
+	if (ret) {
+		dev_err(cdns->dev, "Set usb 2.0 PHY mode failed %d\n", ret);
+		return ret;
+	}
+
+	ret = generic_phy_set_mode(&cdns->usb3_phy, mode, 0);
+	if (ret)
+		dev_err(cdns->dev, "Set usb 3.0 PHY mode failed %d\n", ret);
+
 	return ret;
 }
 
Signature · 1 line
2.17.1
author maintainer
#3 lore raw

PATCH v5 3/8 phy: starfive: Add Starfive JH7110 PCIe 2.0 PHY driver

In reply to Minda Chen

Add Starfive JH7110 PCIe 2.0 PHY driver, which is generic PHY driver and can be used as USB 3.0 driver.

---
 drivers/phy/starfive/Kconfig           |   7 +
 drivers/phy/starfive/Makefile          |   1 +
 drivers/phy/starfive/phy-jh7110-pcie.c | 239 +++++++++++++++++++++++++
 3 files changed, 247 insertions(+)
 create mode 100644 drivers/phy/starfive/phy-jh7110-pcie.c
drivers/phy/starfive/Kconfig +7 -0
index a7cf0a55dff..d11338ed484 100644
@@ -4,6 +4,13 @@
 
 menu "Starfive PHY driver"
 
+config PHY_STARFIVE_JH7110_PCIE
+	bool "Starfive JH7110 PCIe 2.0 PHY driver"
+	depends on PHY
+	help
+	  Enable this to support the Starfive JH7110 PCIE 2.0/USB 3.0 PHY.
+	  Generic PHY driver JH7110 USB 3.0/ PCIe 2.0.
+
 config PHY_STARFIVE_JH7110_USB2
 	bool "Starfive JH7110 USB 2.0 PHY driver"
 	depends on PHY
drivers/phy/starfive/Makefile +1 -0
index a405a75e34c..82f25aa21b7 100644
@@ -3,4 +3,5 @@
 # Copyright (C) 2023 Starfive
 #
 
+obj-$(CONFIG_PHY_STARFIVE_JH7110_PCIE)	+= phy-jh7110-pcie.o
 obj-$(CONFIG_PHY_STARFIVE_JH7110_USB2)	+= phy-jh7110-usb2.o
drivers/phy/starfive/phy-jh7110-pcie.c new file +239 -0

239 lines not on this page · raw message

Signature · 1 line
2.17.1
author maintainer
#2 lore raw

PATCH v5 2/8 phy: starfive: Add Starfive JH7110 USB 2.0 PHY driver

In reply to Minda Chen

Add Starfive JH7110 USB 2.0 PHY driver, which is generic PHY driver.

---
 drivers/phy/Kconfig                          |   1 +
 drivers/phy/Makefile                         |   1 +
 drivers/phy/starfive/Kconfig                 |  14 ++
 drivers/phy/starfive/Makefile                |   6 +
 drivers/phy/starfive/phy-jh7110-usb-syscon.h |   9 ++
 drivers/phy/starfive/phy-jh7110-usb2.c       | 162 +++++++++++++++++++
 6 files changed, 193 insertions(+)
 create mode 100644 drivers/phy/starfive/Kconfig
 create mode 100644 drivers/phy/starfive/Makefile
 create mode 100644 drivers/phy/starfive/phy-jh7110-usb-syscon.h
 create mode 100644 drivers/phy/starfive/phy-jh7110-usb2.c
drivers/phy/Kconfig +1 -0
index e12347e8a03..f940648fe58 100644
@@ -309,5 +309,6 @@ source "drivers/phy/cadence/Kconfig"
 source "drivers/phy/ti/Kconfig"
 source "drivers/phy/qcom/Kconfig"
 source "drivers/phy/renesas/Kconfig"
+source "drivers/phy/starfive/Kconfig"
 
 endmenu
drivers/phy/Makefile +1 -0
index 7a2b764492b..6ac867350cb 100644
@@ -44,3 +44,4 @@ obj-y += cadence/
 obj-y += ti/
 obj-y += qcom/
 obj-y += renesas/
+obj-y += starfive/
drivers/phy/starfive/Kconfig new file +14 -0
new file mode 100644
index 00000000000..a7cf0a55dff
@@ -0,0 +1,14 @@
+#
+# PHY drivers for Starfive platforms
+#
+
+menu "Starfive PHY driver"
+
+config PHY_STARFIVE_JH7110_USB2
+	bool "Starfive JH7110 USB 2.0 PHY driver"
+	depends on PHY
+	help
+	  Enable this to support the Starfive JH7110 USB 2.0 PHY.
+	  Generic PHY driver JH7110 USB 2.0.
+
+endmenu
drivers/phy/starfive/Makefile new file +6 -0
new file mode 100644
index 00000000000..a405a75e34c
@@ -0,0 +1,6 @@
+# SPDX-License-Identifier: GPL-2.0+
+#
+# Copyright (C) 2023 Starfive
+#
+
+obj-$(CONFIG_PHY_STARFIVE_JH7110_USB2)	+= phy-jh7110-usb2.o
drivers/phy/starfive/phy-jh7110-usb-syscon.h new file +9 -0
new file mode 100644
index 00000000000..0eb66f0d859
@@ -0,0 +1,9 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+
+#ifndef PHY_JH7110_USB_SYSCON_H_
+#define PHY_JH7110_USB_SYSCON_H_
+
+#define SYSCON_USB_PDRSTN_REG_OFFSET	0x18
+#define USB_PDRSTN_SPLIT_BIT		 17
+
+#endif
drivers/phy/starfive/phy-jh7110-usb2.c new file +162 -0

162 lines not on this page · raw message

Signature · 1 line
2.17.1

Minda Chen

author maintainer
#0 lore raw

v5 cover Add Starfive JH7110 Cadence USB driver

Add Starfive JH7110 Cadence USB driver and related PHY driver. So the codes can be used in visionfive2 and star64 7110 board.

The driver is almost the same with kernel driver.

Test with Star64 JH7110 board USB 3.0 + USB 2.0 host. The code can work.

- Star64 using USB 3.0 and USB 2.0 host must add below board dts setting. (Vbus bin setting. If usb host in Other JH7110 board vbus pin is not GPIO, don't require to set this)

1. usb pin setting

	usb_pins: usb0-0 {
		driver-vbus-pin {
			pinmux = <GPIOMUX(25, GPOUT_SYS_USB_DRIVE_VBUS,
					  GPOEN_ENABLE,
					  GPI_NONE)>;
			bias-disable;
			input-disable;
			input-schmitt-disable;
			slew-rate = <0>;
		};
	};

2. related dts node setting(USB 3.0 host)

&pcie0 {
	status = "disabled";
};
&pciephy0 {
	starfive,sys-syscon = <&sys_syscon>;
	starfive,stg-syscon = <&stg_syscon 0x148 0x1f4>;
	status = "okay";
};
&usb0 {
	pinctrl-names = "default";
	pinctrl-0 = <&usb_pins>;
	dr_mode = "host";
	status = "okay";
};
&usb_cdns3 {
	phys = <&usbphy0>, <&pciephy0>;
	phy-names = "cdns3,usb2-phy", "cdns3,usb3-phy";
};

- If other board is USB 2.0 host, Just set dr mode is OKay.

&usb0 {
	dr_mode = "host";
	status = "okay";
};

- previous version
v1: https://patchwork.ozlabs.org/project/uboot/cover/[email protected]/
v2: https://patchwork.ozlabs.org/project/uboot/cover/[email protected]/
v3: https://patchwork.ozlabs.org/project/uboot/cover/[email protected]/
v4: https://patchwork.ozlabs.org/project/uboot/cover/[email protected]/

- patch description.

patch1: Add set phy mode function in cdns3 core driver
which is used by Starfive JH7110.
patch2-3: USB and PCIe 2.0 (usb 3.0) PHY drivier
patch4: Cadence USB wrapper driver.
patch5: Add JH7110 USB default overcurrent pin. patch6-7 dts, config update.
patch8: MAINTAINERS update

- change:
v5:
- patch 2-4 format changed.
- For pareparing enable OF_UPSTREAM, patch4 get the dr mode from parent device dts node not the cdns core device dts.
- patch2 add a common usb syscon setting headfile.
- delete v4 patch8 and the star64 dts setting can be setting int star64 board dts configuration if the OF_UPSTREAM is enable.
v4:
- patch 2 Add usb split setting, default set USB 2.0 only.
- patch 5 move to spl stage.
- Add a new patch 8 for star64 board usb host, vbus pin setting and usb 3.0
v3:
- patch 1 Move the added code to cdns3_drd_update_mode().
- patch 1-4 correct the code format.(follow Rogers's comments.)
- patch 3 using regmap_field.

v2:
- patch 1 Move the added code to cdns3_core_init_role(). Must set PHY mode before calling cdns3 role start function.
- patch 1-4 correct the code format.(follow Marek's comments.)
- patch 2 Add set 125M clock in PHY init function.
- Add new patch5.

Minda Chen (8):
usb: cdns3: Set USB PHY mode in cdns3_drd_update_mode()
phy: starfive: Add Starfive JH7110 USB 2.0 PHY driver
phy: starfive: Add Starfive JH7110 PCIe 2.0 PHY driver
usb: cdns: starfive: Add cdns USB driver
spl: starfive: visionfive2: Disable USB overcurrent pin by default.
configs: starfive: Add visionfive2 cadence USB configuration
dts: starfive: Add JH7110 Cadence USB dts node
MAINTAINERS: Update Starfive visionfive2 maintain files.

 .../dts/jh7110-starfive-visionfive-2.dtsi     |   5 +
 arch/riscv/dts/jh7110.dtsi                    |  53 ++++
 arch/riscv/include/asm/arch-jh7110/gpio.h     |   5 +
 board/starfive/visionfive2/MAINTAINERS        |   2 +
 board/starfive/visionfive2/spl.c              |   3 +
 configs/starfive_visionfive2_defconfig        |  10 +
 drivers/phy/Kconfig                           |   1 +
 drivers/phy/Makefile                          |   1 +
 drivers/phy/starfive/Kconfig                  |  21 ++
 drivers/phy/starfive/Makefile                 |   7 +
 drivers/phy/starfive/phy-jh7110-pcie.c        | 239 ++++++++++++++++++
 drivers/phy/starfive/phy-jh7110-usb-syscon.h  |   9 +
 drivers/phy/starfive/phy-jh7110-usb2.c        | 162 ++++++++++++
 drivers/usb/cdns3/Kconfig                     |   7 +
 drivers/usb/cdns3/Makefile                    |   2 +
 drivers/usb/cdns3/cdns3-starfive.c            | 183 ++++++++++++++
 drivers/usb/cdns3/core.c                      |   3 +
 drivers/usb/cdns3/drd.c                       |  14 +
 18 files changed, 727 insertions(+)
 create mode 100644 drivers/phy/starfive/Kconfig
 create mode 100644 drivers/phy/starfive/Makefile
 create mode 100644 drivers/phy/starfive/phy-jh7110-pcie.c
 create mode 100644 drivers/phy/starfive/phy-jh7110-usb-syscon.h
 create mode 100644 drivers/phy/starfive/phy-jh7110-usb2.c
 create mode 100644 drivers/usb/cdns3/cdns3-starfive.c

base-commit: c530f6079c70219e01022142b404bf8a6b572366

Signature · 1 line
2.17.1
author maintainer
#4 lore raw

PATCH v5 4/8 usb: cdns: starfive: Add cdns USB driver

Add cdns USB3 wrapper driver. And cdns core driver also get dr mode from wrapper devcie dts node to make it is same with Starfive cdns USB Linux kernel driver, preparing for enable OF_UPSTREAM.

---
 drivers/usb/cdns3/Kconfig          |   7 ++
 drivers/usb/cdns3/Makefile         |   2 +
 drivers/usb/cdns3/cdns3-starfive.c | 183 +++++++++++++++++++++++++++++
 drivers/usb/cdns3/core.c           |   3 +
 4 files changed, 195 insertions(+)
 create mode 100644 drivers/usb/cdns3/cdns3-starfive.c
drivers/usb/cdns3/Kconfig +7 -0
index 35b61497d9c..6c9595c3c49 100644
@@ -55,4 +55,11 @@ config USB_CDNS3_TI
 	help
 	  Say 'Y' here if you are building for Texas Instruments
 	  platforms that contain Cadence USB3 controller core. E.g.: J721e.
+
+config USB_CDNS3_STARFIVE
+	tristate "Cadence USB3 support on Starfive platforms"
+	default y if STARFIVE_JH7110
+	help
+	  Say 'Y' here if you are building for Starfive platforms
+	  that contain Cadence USB3 controller core. E.g.: JH7110.
 endif
drivers/usb/cdns3/Makefile +2 -0
index 18d7190755d..03d1eadb2ff 100644
@@ -9,3 +9,5 @@ cdns3-$(CONFIG_$(SPL_)USB_CDNS3_GADGET)	+= gadget.o ep0.o
 cdns3-$(CONFIG_$(SPL_)USB_CDNS3_HOST)	+= host.o
 
 obj-$(CONFIG_USB_CDNS3_TI)		+= cdns3-ti.o
+
+obj-$(CONFIG_USB_CDNS3_STARFIVE)	+= cdns3-starfive.o
drivers/usb/cdns3/cdns3-starfive.c new file +183 -0

183 lines not on this page · raw message

drivers/usb/cdns3/core.c +3 -0
index cbe06a9e7b6..9d0a56fd0e7 100644
@@ -410,6 +410,9 @@ int cdns3_bind(struct udevice *parent)
 	name = ofnode_get_name(node);
 	dr_mode = usb_get_dr_mode(node);
 
+	if (dr_mode == USB_DR_MODE_UNKNOWN)
+		dr_mode = usb_get_dr_mode(dev_ofnode(parent));
+
 	switch (dr_mode) {
 #if defined(CONFIG_SPL_USB_HOST) || \
 	(!defined(CONFIG_SPL_BUILD) && defined(CONFIG_USB_HOST))
Signature · 1 line
2.17.1
author maintainer
#8 lore raw

PATCH v5 5/8 spl: starfive: visionfive2: Disable USB overcurrent pin by default.

In reply to Minda Chen

For some JH7110 boards, USB host overcurent pin is not reserved, To make USB host work, overcurrent pin must be disabled. So set the pin default disabled in spl stage.

---
 arch/riscv/include/asm/arch-jh7110/gpio.h | 5 +++++
 board/starfive/visionfive2/spl.c          | 3 +++
 2 files changed, 8 insertions(+)
arch/riscv/include/asm/arch-jh7110/gpio.h +5 -0
index 90aa2f8a9ed..be2a1e0d1c8 100644
@@ -63,6 +63,11 @@ enum gpio_state {
 			GPIO_DIN_MASK << GPIO_SHIFT(gpi), \
 			((gpio + 2) & GPIO_DIN_MASK) << GPIO_SHIFT(gpi))
 
+#define SYS_IOMUX_DIN_DISABLED(gpi)\
+	clrsetbits_le32(JH7110_SYS_IOMUX + GPIO_DIN + GPIO_OFFSET(gpi), \
+			GPIO_DIN_MASK << GPIO_SHIFT(gpi), \
+			((0x1) & GPIO_DIN_MASK) << GPIO_SHIFT(gpi))
+
 #define SYS_IOMUX_SET_DS(gpio, ds) \
 	clrsetbits_le32(JH7110_SYS_IOMUX + GPIO_CONFIG + gpio * 4, \
 			GPIO_DS_MASK, (ds) << GPIO_DS_SHIFT)
board/starfive/visionfive2/spl.c +3 -0
index f55c6b5d34c..0c9798f32b8 100644
@@ -461,6 +461,9 @@ void board_init_f(ulong dummy)
 			JH7110_CLK_CPU_ROOT_MASK,
 			BIT(JH7110_CLK_CPU_ROOT_SHIFT));
 
+	/* Set USB overcurrent overflow pin disable */
+	SYS_IOMUX_DIN_DISABLED(2);
+
 	ret = spl_board_init_f();
 	if (ret) {
 		debug("spl_board_init_f init failed: %d\n", ret);
Signature · 1 line
2.17.1
author maintainer
#10 lore raw

PATCH v5 7/8 dts: starfive: Add JH7110 Cadence USB dts node

In reply to Minda Chen

Add Jh7110 Cadence USB dts node, Visionfive2 default setting is USB 2.0 device.

---
 .../dts/jh7110-starfive-visionfive-2.dtsi     |  5 ++
 arch/riscv/dts/jh7110.dtsi                    | 53 +++++++++++++++++++
 2 files changed, 58 insertions(+)
arch/riscv/dts/jh7110-starfive-visionfive-2.dtsi +5 -0
index e11babc1cde..f62582cf93e 100644
@@ -378,3 +378,8 @@
 		};
 	};
 };
+
+&usb0 {
+	dr_mode = "peripheral";
+	status = "okay";
+};
arch/riscv/dts/jh7110.dtsi +53 -0

59 lines not on this page · raw message

Signature · 1 line
2.17.1
author maintainer
#9 lore raw

PATCH v5 6/8 configs: starfive: Add visionfive2 cadence USB configuration

In reply to Minda Chen

Add cadence USB confiuration.

---
 configs/starfive_visionfive2_defconfig | 10 ++++++++++
 1 file changed, 10 insertions(+)
configs/starfive_visionfive2_defconfig +10 -0
index 174ac24dc74..4329c8705ec 100644
@@ -69,6 +69,7 @@ CONFIG_SYS_EEPROM_SIZE=512
 CONFIG_SYS_EEPROM_PAGE_WRITE_BITS=4
 CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS=5
 CONFIG_CMD_MEMINFO=y
+# CONFIG_CMD_BIND is not set
 CONFIG_CMD_I2C=y
 CONFIG_CMD_PCI=y
 CONFIG_CMD_USB=y
@@ -112,6 +113,9 @@ CONFIG_NVME_PCI=y
 CONFIG_DM_PCI_COMPAT=y
 CONFIG_PCI_REGION_MULTI_ENTRY=y
 CONFIG_PCIE_STARFIVE_JH7110=y
+CONFIG_PHY=y
+CONFIG_PHY_STARFIVE_JH7110_PCIE=y
+CONFIG_PHY_STARFIVE_JH7110_USB2=y
 CONFIG_PINCTRL=y
 CONFIG_PINCONF=y
 CONFIG_SPL_PINCTRL=y
@@ -127,13 +131,19 @@ CONFIG_CADENCE_QSPI=y
 CONFIG_SYSRESET=y
 CONFIG_TIMER_EARLY=y
 CONFIG_USB=y
+CONFIG_DM_USB_GADGET=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_PCI=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_EHCI_PCI=y
 CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_OHCI_PCI=y
+CONFIG_USB_CDNS3=y
+CONFIG_USB_CDNS3_GADGET=y
+CONFIG_USB_CDNS3_HOST=y
+# CONFIG_USB_CDNS3_TI is not set
 CONFIG_USB_KEYBOARD=y
+CONFIG_USB_GADGET=y
 # CONFIG_WATCHDOG is not set
 # CONFIG_WATCHDOG_AUTOSTART is not set
 CONFIG_WDT=y
Signature · 1 line
2.17.1
author maintainer
#12 lore raw

PATCH v5 8/8 MAINTAINERS: Update Starfive visionfive2 maintain files.

In reply to Minda Chen

Add USB related files to Starfive visionfive2 MAINTAINERS.

---
 board/starfive/visionfive2/MAINTAINERS | 2 ++
 1 file changed, 2 insertions(+)
board/starfive/visionfive2/MAINTAINERS +2 -0
index d7f638f9b41..1faf83f581c 100644
@@ -6,3 +6,5 @@ F:	board/starfive/visionfive2/
 F:	include/configs/starfive-visionfive2.h
 F:	configs/starfive_visionfive2_defconfig
 F:	drivers/pci/pcie_starfive_jh7110.c
+F:	drivers/phy/starfive/
+F:	drivers/usb/cdns3/cdns3-starfive.c
Signature · 1 line
2.17.1
#5 lore raw

Re: [PATCH v5 4/8] usb: cdns: starfive: Add cdns USB driver

In reply to Minda Chen
Quoted 20 lines · Minda Chen

Add cdns USB3 wrapper driver. And cdns core driver also get dr mode from wrapper devcie dts node to make it is same with Starfive cdns USB Linux kernel driver, preparing for enable OF_UPSTREAM.

---
  drivers/usb/cdns3/Kconfig          |   7 ++
  drivers/usb/cdns3/Makefile         |   2 +
  drivers/usb/cdns3/cdns3-starfive.c | 183 +++++++++++++++++++++++++++++
  drivers/usb/cdns3/core.c           |   3 +
  4 files changed, 195 insertions(+)

create mode 100644 drivers/usb/cdns3/cdns3-starfive.c

drivers/usb/cdns3/Kconfig +0 -0
index 35b61497d9c..6c9595c3c49 100644
@@ -55,4 +55,11 @@ config USB_CDNS3_TI
  	help

drivers/usb/cdns3/Kconfig config USB_CDNS3_TI · line 65

Quoted 10 lines
drivers/usb/cdns3/Kconfig +7 -0
  	  Say 'Y' here if you are building for Texas Instruments
  	  platforms that contain Cadence USB3 controller core. E.g.: J721e.
+
+config USB_CDNS3_STARFIVE
+	tristate "Cadence USB3 support on Starfive platforms"
+	default y if STARFIVE_JH7110
+	help
+	  Say 'Y' here if you are building for Starfive platforms
+	  that contain Cadence USB3 controller core. E.g.: JH7110.
  endif

Keep the list sorted.

drivers/usb/cdns3/Makefile cdns3-$(CONFIG_$(SPL_)USB_CDNS3_GADGET) += gadget.o ep0.o · line 13

Quoted 10 lines
drivers/usb/cdns3/Makefile +2 -0
index 18d7190755d..03d1eadb2ff 100644
@@ -9,3 +9,5 @@ cdns3-$(CONFIG_$(SPL_)USB_CDNS3_GADGET)	+= gadget.o ep0.o
  cdns3-$(CONFIG_$(SPL_)USB_CDNS3_HOST)	+= host.o
 
  obj-$(CONFIG_USB_CDNS3_TI)		+= cdns3-ti.o
+
+obj-$(CONFIG_USB_CDNS3_STARFIVE)	+= cdns3-starfive.o

Keep the list sorted.

Quoted 53 lines
drivers/usb/cdns3/cdns3-starfive.c new file +47 -0
new file mode 100644
index 00000000000..fad05451c80
@@ -0,0 +1,183 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * cdns3-starfive.c - StarFive specific Glue layer for Cadence USB Controller
+ *
+ * Copyright (C) 2024 StarFive Technology Co., Ltd.
+ *
+ * Author:	Minda Chen <[email protected]>
+ */
+
+#include <asm/io.h>
+#include <clk.h>
+#include <dm.h>
+#include <dm/device_compat.h>
+#include <linux/bitops.h>
+#include <linux/usb/otg.h>
+#include <reset.h>
+#include <regmap.h>
+#include <syscon.h>
+#include <malloc.h>
+
+#include "core.h"
+
+#define USB_STRAP_HOST			BIT(17)
+#define USB_STRAP_DEVICE		BIT(18)
+#define USB_STRAP_MASK			GENMASK(18, 16)
+
+#define USB_SUSPENDM_HOST		BIT(19)
+#define USB_SUSPENDM_MASK		BIT(19)
+
+#define USB_MISC_CFG_MASK		GENMASK(23, 20)
+#define USB_SUSPENDM_BYPS		BIT(20)
+#define USB_PLL_EN			BIT(22)
+#define USB_REFCLK_MODE			BIT(23)
+
+struct cdns_starfive {
+	struct udevice *dev;
+	struct regmap *stg_syscon;
+	struct reset_ctl_bulk resets;
+	struct clk_bulk clks;
+	u32 stg_usb_mode;
+	enum usb_dr_mode mode;
+};
+
+static void cdns_mode_init(struct cdns_starfive *data, enum usb_dr_mode mode)
+{
+	unsigned int strap, suspendm;
+

drivers/usb/cdns3/cdns3-starfive.c line 57

Quoted 10 lines
drivers/usb/cdns3/cdns3-starfive.c new file +10 -0
+	regmap_update_bits(data->stg_syscon, data->stg_usb_mode,
+			   USB_MISC_CFG_MASK,
+			   USB_SUSPENDM_BYPS | USB_PLL_EN | USB_REFCLK_MODE);
+
+	switch (mode) {
+	case USB_DR_MODE_HOST:
+		strap = USB_STRAP_HOST;
+		suspendm = USB_SUSPENDM_HOST;
+		break;
+

Drop the newline please.

Quoted 12 lines
drivers/usb/cdns3/cdns3-starfive.c new file +12 -0
+	case USB_DR_MODE_PERIPHERAL:
+		strap = USB_STRAP_DEVICE;
+		suspendm = 0;
+		break;
+	default:
+		return;
+	}
+
+	regmap_update_bits(data->stg_syscon, data->stg_usb_mode,
+			   USB_SUSPENDM_MASK | USB_STRAP_MASK,
+			   strap | suspendm);
+}

[...]

drivers/usb/cdns3/core.c int cdns3_bind(struct udevice *parent) · line 414

Quoted 10 lines
drivers/usb/cdns3/core.c +2 -0
index cbe06a9e7b6..9d0a56fd0e7 100644
@@ -410,6 +410,9 @@ int cdns3_bind(struct udevice *parent)
  	name = ofnode_get_name(node);
  	dr_mode = usb_get_dr_mode(node);
 
+	if (dr_mode == USB_DR_MODE_UNKNOWN)
+		dr_mode = usb_get_dr_mode(dev_ofnode(parent));

Separate patch for core changes please.

#13 lore raw
In reply to Minda Chen
Quoted 135 lines · Minda Chen

Add Starfive JH7110 Cadence USB driver and related PHY driver. So the codes can be used in visionfive2 and star64 7110 board.

The driver is almost the same with kernel driver.

Test with Star64 JH7110 board USB 3.0 + USB 2.0 host. The code can work.

- Star64 using USB 3.0 and USB 2.0 host must add below board dts setting. (Vbus bin setting. If usb host in Other JH7110 board vbus pin is not GPIO, don't require to set this)

1. usb pin setting

        usb_pins: usb0-0 {
                driver-vbus-pin {
                        pinmux = <GPIOMUX(25, GPOUT_SYS_USB_DRIVE_VBUS,
                                          GPOEN_ENABLE,
                                          GPI_NONE)>;
                        bias-disable;
                        input-disable;
                        input-schmitt-disable;
                        slew-rate = <0>;
                };
        };

2. related dts node setting(USB 3.0 host)

&pcie0 {
        status = "disabled";
};
&pciephy0 {
        starfive,sys-syscon = <&sys_syscon>;
        starfive,stg-syscon = <&stg_syscon 0x148 0x1f4>;
        status = "okay";
};
&usb0 {
        pinctrl-names = "default";
        pinctrl-0 = <&usb_pins>;
        dr_mode = "host";
        status = "okay";
};
&usb_cdns3 {
        phys = <&usbphy0>, <&pciephy0>;
        phy-names = "cdns3,usb2-phy", "cdns3,usb3-phy";
};

- If other board is USB 2.0 host, Just set dr mode is OKay.

&usb0 {
        dr_mode = "host";
        status = "okay";
};

- previous version
v1: https://patchwork.ozlabs.org/project/uboot/cover/[email protected]/
v2: https://patchwork.ozlabs.org/project/uboot/cover/[email protected]/
v3: https://patchwork.ozlabs.org/project/uboot/cover/[email protected]/
v4: https://patchwork.ozlabs.org/project/uboot/cover/[email protected]/

- patch description.

patch1: Add set phy mode function in cdns3 core driver
which is used by Starfive JH7110.
patch2-3: USB and PCIe 2.0 (usb 3.0) PHY drivier
patch4: Cadence USB wrapper driver.
patch5: Add JH7110 USB default overcurrent pin. patch6-7 dts, config update.
patch8: MAINTAINERS update

- change:
v5:
- patch 2-4 format changed.
- For pareparing enable OF_UPSTREAM, patch4 get the dr mode from parent device dts node not the cdns core device dts.
- patch2 add a common usb syscon setting headfile.
- delete v4 patch8 and the star64 dts setting can be setting int star64 board dts configuration if the OF_UPSTREAM is enable.
v4:
- patch 2 Add usb split setting, default set USB 2.0 only.
- patch 5 move to spl stage.
- Add a new patch 8 for star64 board usb host, vbus pin setting and usb 3.0
v3:
- patch 1 Move the added code to cdns3_drd_update_mode().
- patch 1-4 correct the code format.(follow Rogers's comments.)
- patch 3 using regmap_field.

v2:
- patch 1 Move the added code to cdns3_core_init_role(). Must set PHY mode before calling cdns3 role start function.
- patch 1-4 correct the code format.(follow Marek's comments.)
- patch 2 Add set 125M clock in PHY init function.
- Add new patch5.

Minda Chen (8):
usb: cdns3: Set USB PHY mode in cdns3_drd_update_mode()
phy: starfive: Add Starfive JH7110 USB 2.0 PHY driver
phy: starfive: Add Starfive JH7110 PCIe 2.0 PHY driver
usb: cdns: starfive: Add cdns USB driver
spl: starfive: visionfive2: Disable USB overcurrent pin by default.
configs: starfive: Add visionfive2 cadence USB configuration
dts: starfive: Add JH7110 Cadence USB dts node
MAINTAINERS: Update Starfive visionfive2 maintain files.

 .../dts/jh7110-starfive-visionfive-2.dtsi     |   5 +
 arch/riscv/dts/jh7110.dtsi                    |  53 ++++
 arch/riscv/include/asm/arch-jh7110/gpio.h     |   5 +
 board/starfive/visionfive2/MAINTAINERS        |   2 +
 board/starfive/visionfive2/spl.c              |   3 +
 configs/starfive_visionfive2_defconfig        |  10 +
 drivers/phy/Kconfig                           |   1 +
 drivers/phy/Makefile                          |   1 +
 drivers/phy/starfive/Kconfig                  |  21 ++
 drivers/phy/starfive/Makefile                 |   7 +
 drivers/phy/starfive/phy-jh7110-pcie.c        | 239 ++++++++++++++++++
 drivers/phy/starfive/phy-jh7110-usb-syscon.h  |   9 +
 drivers/phy/starfive/phy-jh7110-usb2.c        | 162 ++++++++++++
 drivers/usb/cdns3/Kconfig                     |   7 +
 drivers/usb/cdns3/Makefile                    |   2 +
 drivers/usb/cdns3/cdns3-starfive.c            | 183 ++++++++++++++
 drivers/usb/cdns3/core.c                      |   3 +
 drivers/usb/cdns3/drd.c                       |  14 +
 18 files changed, 727 insertions(+)
 create mode 100644 drivers/phy/starfive/Kconfig
 create mode 100644 drivers/phy/starfive/Makefile
 create mode 100644 drivers/phy/starfive/phy-jh7110-pcie.c
 create mode 100644 drivers/phy/starfive/phy-jh7110-usb-syscon.h
 create mode 100644 drivers/phy/starfive/phy-jh7110-usb2.c
 create mode 100644 drivers/usb/cdns3/cdns3-starfive.c
Quoted 4 lines

base-commit: c530f6079c70219e01022142b404bf8a6b572366 --
2.17.1

Hi Minda,

Can you please depend on series "Support OF_UPSTREAM for StarFive JH7110", and with changes requested by Marek?

Also I have patches for review on Linux kernel mailing list to provide some of the dts nodes we will need to allow host USB mode on Star64 and Mars:
"riscv: dts: starfive: jh7110-pine64-star64: enable usb0 host function" "riscv: dts: starfive: jh7110-milkv-mars: enable usb0 host function"

This can allow your series to apply on U-Boot without extra dts?

Thanks,

-E

#11 lore raw

Re: [PATCH v5 7/8] dts: starfive: Add JH7110 Cadence USB dts node

In reply to Minda Chen
Quoted 76 lines · Minda Chen

Add Jh7110 Cadence USB dts node, Visionfive2 default setting is USB 2.0 device.

---
  .../dts/jh7110-starfive-visionfive-2.dtsi     |  5 ++
  arch/riscv/dts/jh7110.dtsi                    | 53 +++++++++++++++++++
  2 files changed, 58 insertions(+)
arch/riscv/dts/jh7110-starfive-visionfive-2.dtsi +5 -0
index e11babc1cde..f62582cf93e 100644
@@ -378,3 +378,8 @@
  		};
  	};
  };
+
+&usb0 {
+	dr_mode = "peripheral";
+	status = "okay";
+};
arch/riscv/dts/jh7110.dtsi +46 -0
index 2cdc683d49b..c770da2fedd 100644
@@ -371,6 +371,59 @@
  			status = "disabled";
  		};
 
+		usb0: usb@10100000 {
+			compatible = "starfive,jh7110-usb";
+			ranges = <0x0 0x0 0x10100000 0x100000>;
+			#address-cells = <1>;
+			#size-cells = <1>;
+			starfive,stg-syscon = <&stg_syscon 0x4>;
+			clocks = <&stgcrg JH7110_STGCLK_USB_LPM>,
+				 <&stgcrg JH7110_STGCLK_USB_STB>,
+				 <&stgcrg JH7110_STGCLK_USB_APB>,
+				 <&stgcrg JH7110_STGCLK_USB_AXI>,
+				 <&stgcrg JH7110_STGCLK_USB_UTMI_APB>;
+			clock-names = "lpm", "stb", "apb", "axi", "utmi_apb";
+			resets = <&stgcrg JH7110_STGRST_USB_PWRUP>,
+				 <&stgcrg JH7110_STGRST_USB_APB>,
+				 <&stgcrg JH7110_STGRST_USB_AXI>,
+				 <&stgcrg JH7110_STGRST_USB_UTMI_APB>;
+			reset-names = "pwrup", "apb", "axi", "utmi_apb";
+			status = "disabled";
+
+			usb_cdns3: usb@0 {
+				compatible = "cdns,usb3";
+				reg = <0x0 0x10000>,
+				      <0x10000 0x10000>,
+				      <0x20000 0x10000>;
+				reg-names = "otg", "xhci", "dev";
+				interrupts = <100>, <108>, <110>;
+				interrupt-names = "host", "peripheral", "otg";
+				phys = <&usbphy0>;
+				phy-names = "cdns3,usb2-phy";
+			};
+		};
+
+		usbphy0: phy@10200000 {
+			compatible = "starfive,jh7110-usb-phy";
+			reg = <0x0 0x10200000 0x0 0x10000>;
+			clocks = <&syscrg JH7110_SYSCLK_USB_125M>,
+				 <&stgcrg JH7110_STGCLK_USB_APP_125>;
+			clock-names = "125m", "app_125m";
+			#phy-cells = <0>;
+		};
+
+		pciephy0: phy@10210000 {
+			compatible = "starfive,jh7110-pcie-phy";
+			reg = <0x0 0x10210000 0x0 0x10000>;
+			#phy-cells = <0>;
+		};

arch/riscv/dts/jh7110.dtsi line 429

Quoted 10 lines
arch/riscv/dts/jh7110.dtsi +7 -0
+
+		pciephy1: phy@10220000 {
+			compatible = "starfive,jh7110-pcie-phy";
+			reg = <0x0 0x10220000 0x0 0x10000>;
+			#phy-cells = <0>;
+		};
+
  		stgcrg: clock-controller@10230000 {
  			compatible = "starfive,jh7110-stgcrg";
  			reg = <0x0 0x10230000 0x0 0x10000>;

Drop this patch. Prefer instead to depend on "Support OF_UPSTREAM for StarFive JH7110" series. I have a couple of patches into upstream Linux riscv-dt-for-next with the vbus GPIO assignment and setting host mode that should land with Linux 6.14, for Mars and for Star64 boards.

-E

#6 lore raw

Re: [PATCH v5 4/8] usb: cdns: starfive: Add cdns USB driver

In reply to Marek Vasut
Quoted 130 lines · Marek Vasut
Quoted 29 lines · Minda Chen

Add cdns USB3 wrapper driver. And cdns core driver also get dr mode from wrapper devcie dts node to make it is same with Starfive cdns USB Linux kernel driver, preparing for enable OF_UPSTREAM.

---
  drivers/usb/cdns3/Kconfig          |   7 ++ drivers/usb/cdns3/Makefile         |   2 + drivers/usb/cdns3/cdns3-starfive.c | 183 +++++++++++++++++++++++++++++ drivers/usb/cdns3/core.c           |   3 +

  4 files changed, 195 insertions(+)

  create mode 100644 drivers/usb/cdns3/cdns3-starfive.c

drivers/usb/cdns3/Kconfig +0 -0
index 35b61497d9c..6c9595c3c49 100644
@@ -55,4 +55,11 @@ config USB_CDNS3_TI

      help
        Say 'Y' here if you are building for Texas Instruments platforms that contain Cadence USB3 controller core. E.g.: J721e.

drivers/usb/cdns3/Kconfig +7 -0
+
+config USB_CDNS3_STARFIVE
+    tristate "Cadence USB3 support on Starfive platforms"
+    default y if STARFIVE_JH7110
+    help
+      Say 'Y' here if you are building for Starfive platforms
+      that contain Cadence USB3 controller core. E.g.: JH7110.
Quoted 1 line

  endif

Keep the list sorted.

drivers/usb/cdns3/Makefile cdns3-$(CONFIG_$(SPL_)USB_CDNS3_GADGET) += gadget.o ep0.o · line 13

Quoted 10 lines
drivers/usb/cdns3/Makefile +0 -0
index 18d7190755d..03d1eadb2ff 100644
@@ -9,3 +9,5 @@ cdns3-$(CONFIG_$(SPL_)USB_CDNS3_GADGET)    += gadget.o 

ep0.o
  cdns3-$(CONFIG_$(SPL_)USB_CDNS3_HOST)    += host.o obj-$(CONFIG_USB_CDNS3_TI)        += cdns3-ti.o

drivers/usb/cdns3/Makefile +2 -0
+
+obj-$(CONFIG_USB_CDNS3_STARFIVE)    += cdns3-starfive.o

Keep the list sorted.

Quoted 55 lines
drivers/usb/cdns3/cdns3-starfive.c new file +3 -0
new file mode 100644
index 00000000000..fad05451c80
@@ -0,0 +1,183 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * cdns3-starfive.c - StarFive specific Glue layer for Cadence USB 

Controller
+ *
+ * Copyright (C) 2024 StarFive Technology Co., Ltd.
+ *
+ * Author:    Minda Chen <[email protected]>
+ */

drivers/usb/cdns3/cdns3-starfive.c new file +36 -0
+
+#include <asm/io.h>
+#include <clk.h>
+#include <dm.h>
+#include <dm/device_compat.h>
+#include <linux/bitops.h>
+#include <linux/usb/otg.h>
+#include <reset.h>
+#include <regmap.h>
+#include <syscon.h>
+#include <malloc.h>
+
+#include "core.h"
+
+#define USB_STRAP_HOST            BIT(17)
+#define USB_STRAP_DEVICE        BIT(18)
+#define USB_STRAP_MASK            GENMASK(18, 16)
+
+#define USB_SUSPENDM_HOST        BIT(19)
+#define USB_SUSPENDM_MASK        BIT(19)
+
+#define USB_MISC_CFG_MASK        GENMASK(23, 20)
+#define USB_SUSPENDM_BYPS        BIT(20)
+#define USB_PLL_EN            BIT(22)
+#define USB_REFCLK_MODE            BIT(23)
+
+struct cdns_starfive {
+    struct udevice *dev;
+    struct regmap *stg_syscon;
+    struct reset_ctl_bulk resets;
+    struct clk_bulk clks;
+    u32 stg_usb_mode;
+    enum usb_dr_mode mode;
+};
+
+static void cdns_mode_init(struct cdns_starfive *data, enum 

usb_dr_mode mode)

drivers/usb/cdns3/cdns3-starfive.c new file +3 -0
+{
+    unsigned int strap, suspendm;
+

drivers/usb/cdns3/cdns3-starfive.c line 57

Quoted 10 lines
drivers/usb/cdns3/cdns3-starfive.c new file +10 -0
+    regmap_update_bits(data->stg_syscon, data->stg_usb_mode,
+               USB_MISC_CFG_MASK,
+               USB_SUSPENDM_BYPS | USB_PLL_EN | USB_REFCLK_MODE);
+
+    switch (mode) {
+    case USB_DR_MODE_HOST:
+        strap = USB_STRAP_HOST;
+        suspendm = USB_SUSPENDM_HOST;
+        break;
+

Drop the newline please.

Quoted 12 lines

+    case USB_DR_MODE_PERIPHERAL:
+        strap = USB_STRAP_DEVICE;
+        suspendm = 0;
+        break;
+    default:
+        return;
+    }

drivers/usb/cdns3/cdns3-starfive.c new file +5 -0
+
+    regmap_update_bits(data->stg_syscon, data->stg_usb_mode,
+               USB_SUSPENDM_MASK | USB_STRAP_MASK,
+               strap | suspendm);
+}

[...]

Quoted 10 lines

drivers/usb/cdns3/core.c int cdns3_bind(struct udevice *parent) · line 413

Quoted 9 lines
drivers/usb/cdns3/core.c +2 -0
index cbe06a9e7b6..9d0a56fd0e7 100644
@@ -410,6 +410,9 @@ int cdns3_bind(struct udevice *parent)
       name = ofnode_get_name(node);
       dr_mode = usb_get_dr_mode(node);
+    if (dr_mode == USB_DR_MODE_UNKNOWN)
+        dr_mode = usb_get_dr_mode(dev_ofnode(parent));

Separate patch for core changes please.

Hi, Minda, can you send v6 with requested changes by Marek and drop patch 7/8 ("dts: starfive: Add JH7110 Cadence USB dts node")? Thanks! -E

author maintainer
#7 lore raw

回复: [PATCH v5 4/8] usb: cdns: starfive: Add cdns USB driver

Quoted 148 lines · Marek Vasut
Quoted 15 lines · Minda Chen
Quoted 14 lines

Add cdns USB3 wrapper driver. And cdns core driver also get dr mode from wrapper devcie dts node to make it is same with Starfive cdns USB Linux kernel driver, preparing for enable OF_UPSTREAM.

---
  drivers/usb/cdns3/Kconfig          |   7 ++
  drivers/usb/cdns3/Makefile         |   2 +
  drivers/usb/cdns3/cdns3-starfive.c | 183
+++++++++++++++++++++++++++++
  drivers/usb/cdns3/core.c           |   3 +

  4 files changed, 195 insertions(+)

  create mode 100644 drivers/usb/cdns3/cdns3-starfive.c

Quoted 8 lines
Quoted 8 lines
drivers/usb/cdns3/Kconfig +0 -0
index 35b61497d9c..6c9595c3c49 100644
@@ -55,4 +55,11 @@ config USB_CDNS3_TI

      help
        Say 'Y' here if you are building for Texas Instruments platforms that contain Cadence USB3 controller core. E.g.:

J721e.

Quoted 44 lines
Quoted 8 lines
drivers/usb/cdns3/Kconfig +7 -0
+
+config USB_CDNS3_STARFIVE
+    tristate "Cadence USB3 support on Starfive platforms"
+    default y if STARFIVE_JH7110
+    help
+      Say 'Y' here if you are building for Starfive platforms
+      that contain Cadence USB3 controller core. E.g.: JH7110.

  endif

Keep the list sorted.

drivers/usb/cdns3/Makefile cdns3-$(CONFIG_$(SPL_)USB_CDNS3_GADGET) += gadget.o ep0.o · line 13

Quoted 10 lines
drivers/usb/cdns3/Makefile +0 -0
index 18d7190755d..03d1eadb2ff 100644
@@ -9,3 +9,5 @@ cdns3-$(CONFIG_$(SPL_)USB_CDNS3_GADGET)    +=

gadget.o ep0.o cdns3-$(CONFIG_$(SPL_)USB_CDNS3_HOST)    += host.o obj-$(CONFIG_USB_CDNS3_TI)        += cdns3-ti.o

drivers/usb/cdns3/Makefile +2 -0
+
+obj-$(CONFIG_USB_CDNS3_STARFIVE)    += cdns3-starfive.o

Keep the list sorted.

Quoted 20 lines
drivers/usb/cdns3/ renamed from drivers/usb/cdns3/cdns3-starfive.c +0 -0

cdns3-starfive.c new file mode 100644 index 00000000000..fad05451c80

drivers/usb/cdns3/cdns3-starfive.c new file +3 -0
@@ -0,0 +1,183 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * cdns3-starfive.c - StarFive specific Glue layer for Cadence USB

Controller
+ *
+ * Copyright (C) 2024 StarFive Technology Co., Ltd.
+ *
+ * Author:    Minda Chen <[email protected]> */

drivers/usb/cdns3/cdns3-starfive.c new file +7 -0
+
+#include <asm/io.h>
+#include <clk.h>
+#include <dm.h>
+#include <dm/device_compat.h>
+#include <linux/bitops.h>
+#include <linux/usb/otg.h>
Quoted 8 lines

drivers/usb/cdns3/cdns3-starfive.c

Quoted 8 lines
drivers/usb/cdns3/cdns3-starfive.c new file +8 -0
+#include <reset.h>
+#include <regmap.h>
+#include <syscon.h>
+#include <malloc.h>
+
+#include "core.h"
+
+#define USB_STRAP_HOST            BIT(17) #define

USB_STRAP_DEVICE

Quoted 3 lines

drivers/usb/cdns3/cdns3-starfive.c

Quoted 3 lines
drivers/usb/cdns3/cdns3-starfive.c new file +3 -0
+BIT(18) #define USB_STRAP_MASK            GENMASK(18, 16)
+
+#define USB_SUSPENDM_HOST        BIT(19) #define

USB_SUSPENDM_MASK

Quoted 4 lines

drivers/usb/cdns3/cdns3-starfive.c

Quoted 4 lines
drivers/usb/cdns3/cdns3-starfive.c new file +4 -0
+BIT(19)
+
+#define USB_MISC_CFG_MASK        GENMASK(23, 20) #define
+USB_SUSPENDM_BYPS        BIT(20) #define

USB_PLL_EN

Quoted 11 lines
Quoted 11 lines
drivers/usb/cdns3/cdns3-starfive.c new file +11 -0
+BIT(22) #define USB_REFCLK_MODE            BIT(23)
+
+struct cdns_starfive {
+    struct udevice *dev;
+    struct regmap *stg_syscon;
+    struct reset_ctl_bulk resets;
+    struct clk_bulk clks;
+    u32 stg_usb_mode;
+    enum usb_dr_mode mode;
+};
+
Quoted 8 lines

drivers/usb/cdns3/cdns3-starfive.c

Quoted 8 lines

+static void cdns_mode_init(struct cdns_starfive *data, enum usb_dr_mode mode)

drivers/usb/cdns3/cdns3-starfive.c new file +6 -0
+{
+    unsigned int strap, suspendm;
+
+    regmap_update_bits(data->stg_syscon, data->stg_usb_mode,
+               USB_MISC_CFG_MASK,
+               USB_SUSPENDM_BYPS | USB_PLL_EN |

USB_REFCLK_MODE);

Quoted 25 lines

drivers/usb/cdns3/cdns3-starfive.c line 57

Quoted 7 lines
drivers/usb/cdns3/cdns3-starfive.c new file +7 -0
+
+    switch (mode) {
+    case USB_DR_MODE_HOST:
+        strap = USB_STRAP_HOST;
+        suspendm = USB_SUSPENDM_HOST;
+        break;
+

Drop the newline please.

Quoted 12 lines

+    case USB_DR_MODE_PERIPHERAL:
+        strap = USB_STRAP_DEVICE;
+        suspendm = 0;
+        break;
+    default:
+        return;
+    }

drivers/usb/cdns3/cdns3-starfive.c new file +5 -0
+
+    regmap_update_bits(data->stg_syscon, data->stg_usb_mode,
+               USB_SUSPENDM_MASK | USB_STRAP_MASK,
+               strap | suspendm);
+}

[...]

Quoted 10 lines

drivers/usb/cdns3/core.c int cdns3_bind(struct udevice *parent) · line 413

Quoted 9 lines
drivers/usb/cdns3/core.c +2 -0
index cbe06a9e7b6..9d0a56fd0e7 100644
@@ -410,6 +410,9 @@ int cdns3_bind(struct udevice *parent)
       name = ofnode_get_name(node);
       dr_mode = usb_get_dr_mode(node);
+    if (dr_mode == USB_DR_MODE_UNKNOWN)
+        dr_mode = usb_get_dr_mode(dev_ofnode(parent));

Separate patch for core changes please.

Quoted 2 lines

Hi, Minda, can you send v6 with requested changes by Marek and drop patch 7/8 ("dts: starfive: Add JH7110 Cadence USB dts node")? Thanks! -E

I am busy working with another IC. Next month I will send a new version.