Skip to contentSkip to conversation

Add Starfive JH7110 Cadence USB driver

PATCH Superseded Minda Chen 3 participants 21 messages May 4, 2024 – Jun 24, 2024

Subsystems (7)

v1 of 7 Superseded Latest is v7 →

lore
Share & tools
lore

Minda Chen

author maintainer
#0 lore raw

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 milkv 7110 board.

The driver is almost the same with kernel driver.

patch1: Add set phy mode function in cdns3 core driver
which is used by Starfive.

patch2-3: USB and PCIe 2.0 (usb 3.0) PHY drivier
patch4: Cadence USB wrapper driver.
patch5-7 dts, config and maintainers update.

Minda Chen (7):
usb: cdns3: Set USB PHY mode in cdns3_probe()
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
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                    |  52 +++++
 board/starfive/visionfive2/MAINTAINERS        |   2 +
 configs/starfive_visionfive2_defconfig        |   9 +
 drivers/phy/Kconfig                           |   1 +
 drivers/phy/Makefile                          |   1 +
 drivers/phy/starfive/Kconfig                  |  19 ++
 drivers/phy/starfive/Makefile                 |   7 +
 drivers/phy/starfive/phy-jh7110-pcie.c        | 211 ++++++++++++++++++
 drivers/phy/starfive/phy-jh7110-usb2.c        | 135 +++++++++++
 drivers/usb/cdns3/Kconfig                     |   7 +
 drivers/usb/cdns3/Makefile                    |   2 +
 drivers/usb/cdns3/cdns3-starfive.c            | 184 +++++++++++++++
 drivers/usb/cdns3/core.c                      |  17 ++
 14 files changed, 652 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-usb2.c
 create mode 100644 drivers/usb/cdns3/cdns3-starfive.c

base-commit: 174ac987655c888017c82df1883c0c2ea0dc2495

Signature · 1 line
2.17.1
author maintainer
#1 lore raw

PATCH 1/7 usb: cdns3: Set USB PHY mode in cdns3_probe()

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

---
 drivers/usb/cdns3/core.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
drivers/usb/cdns3/core.c +17 -0
index 12a741c6ea..c1a61471f9 100644
@@ -321,6 +321,7 @@ static int cdns3_probe(struct cdns3 *cdns)
 {
 	struct udevice *dev = cdns->dev;
 	int ret;
+	int mode = PHY_MODE_INVALID;
 
 	cdns->xhci_regs = dev_remap_addr_name(dev, "xhci");
 	if (!cdns->xhci_regs)
@@ -372,6 +373,22 @@ static int cdns3_probe(struct cdns3 *cdns)
 	if (ret)
 		return ret;
 
+	if (cdns->dr_mode == USB_DR_MODE_HOST)
+		mode = PHY_MODE_USB_HOST;
+	else if (cdns->dr_mode == USB_DR_MODE_PERIPHERAL)
+		mode = PHY_MODE_USB_DEVICE;
+	else if (cdns->dr_mode == USB_DR_MODE_OTG)
+		mode = PHY_MODE_USB_OTG;
+
+	if (mode != PHY_MODE_INVALID) {
+		ret = generic_phy_set_mode(&cdns->usb2_phy, mode, 0);
+		if (ret)
+			return ret;
+		ret = generic_phy_set_mode(&cdns->usb3_phy, mode, 0);
+		if (ret)
+			return ret;
+	}
+
 	dev_dbg(dev, "Cadence USB3 core: probe succeed\n");
 
 	return 0;
Signature · 1 line
2.17.1
author maintainer
#3 lore raw

PATCH 2/7 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           |  13 +++
 drivers/phy/starfive/Makefile          |   6 ++
 drivers/phy/starfive/phy-jh7110-usb2.c | 135 +++++++++++++++++++++++++
 5 files changed, 156 insertions(+)
 create mode 100644 drivers/phy/starfive/Kconfig
 create mode 100644 drivers/phy/starfive/Makefile
 create mode 100644 drivers/phy/starfive/phy-jh7110-usb2.c
drivers/phy/Kconfig +1 -0
index 8f767877e7..0c4d63a01f 100644
@@ -307,5 +307,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 7a2b764492..6ac867350c 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 +13 -0
new file mode 100644
index 0000000000..5d78fde12e
@@ -0,0 +1,13 @@
+#
+# Phy drivers for Starfive platforms
+#
+
+menu "Starfive PHY driver"
+
+config PHY_STARFIVE_JH7110_USB2
+	bool "Starfive JH7110 USB 2.0 PHY driver"
+	select PHY
+	help
+	  Enable this to support the Starfive USB 2.0 PHY.
+
+endmenu
drivers/phy/starfive/Makefile new file +6 -0
new file mode 100644
index 0000000000..a405a75e34
@@ -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-usb2.c new file +135 -0

135 lines not on this page · raw message

Signature · 1 line
2.17.1
author maintainer
#5 lore raw

PATCH 3/7 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           |   6 +
 drivers/phy/starfive/Makefile          |   1 +
 drivers/phy/starfive/phy-jh7110-pcie.c | 211 +++++++++++++++++++++++++
 3 files changed, 218 insertions(+)
 create mode 100644 drivers/phy/starfive/phy-jh7110-pcie.c
drivers/phy/starfive/Kconfig +6 -0
index 5d78fde12e..eaebb2b47d 100644
@@ -4,6 +4,12 @@
 
 menu "Starfive PHY driver"
 
+config PHY_STARFIVE_JH7110_PCIE
+        bool "Starfive JH7110 PCIe 2.0 PHY driver"
+        select PHY
+        help
+          Enable this to support the Starfive PCIE 2.0/USB 3.0 PHY.
+
 config PHY_STARFIVE_JH7110_USB2
 	bool "Starfive JH7110 USB 2.0 PHY driver"
 	select PHY
drivers/phy/starfive/Makefile +1 -0
index a405a75e34..82f25aa21b 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 +211 -0

211 lines not on this page · raw message

Signature · 1 line
2.17.1
author maintainer
#7 lore raw

PATCH 4/7 usb: cdns: starfive: Add cdns USB driver

In reply to Minda Chen

Add cdns USB3 wrapper driver.

---
 drivers/usb/cdns3/Kconfig          |   7 ++
 drivers/usb/cdns3/Makefile         |   2 +
 drivers/usb/cdns3/cdns3-starfive.c | 184 +++++++++++++++++++++++++++++
 3 files changed, 193 insertions(+)
 create mode 100644 drivers/usb/cdns3/cdns3-starfive.c
drivers/usb/cdns3/Kconfig +7 -0
index 35b61497d9..f8f363982b 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 USB_CDNS3
+	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 18d7190755..03d1eadb2f 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 +184 -0

184 lines not on this page · raw message

Signature · 1 line
2.17.1
author maintainer
#9 lore raw

PATCH 5/7 configs: starfive: Add visionfive2 cadence USB configuration

In reply to Minda Chen

Add cadence USB confiuration.

---
 configs/starfive_visionfive2_defconfig | 9 +++++++++
 1 file changed, 9 insertions(+)
configs/starfive_visionfive2_defconfig +9 -0
index 3bbd1dbd67..444ddd508d 100644
@@ -68,6 +68,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
@@ -111,6 +112,8 @@ CONFIG_NVME_PCI=y
 CONFIG_DM_PCI_COMPAT=y
 CONFIG_PCI_REGION_MULTI_ENTRY=y
 CONFIG_PCIE_STARFIVE_JH7110=y
+CONFIG_PHY_STARFIVE_JH7110_PCIE=y
+CONFIG_PHY_STARFIVE_JH7110_USB2=y
 CONFIG_PINCTRL=y
 CONFIG_PINCONF=y
 CONFIG_SPL_PINCTRL=y
@@ -126,13 +129,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
#10 lore raw

PATCH 6/7 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                    | 52 +++++++++++++++++++
 2 files changed, 57 insertions(+)
arch/riscv/dts/jh7110-starfive-visionfive-2.dtsi +5 -0
index e11babc1cd..44785bbee3 100644
@@ -378,3 +378,8 @@
 		};
 	};
 };
+
+&usb_cdns3 {
+	dr_mode = "peripheral";
+	status = "okay";
+};
arch/riscv/dts/jh7110.dtsi +52 -0

58 lines not on this page · raw message

Signature · 1 line
2.17.1
author maintainer
#11 lore raw

PATCH 7/7 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 d7f638f9b4..1faf83f581 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
#2 lore raw

Re: [PATCH v1 1/7] usb: cdns3: Set USB PHY mode in cdns3_probe()

In reply to Minda Chen
Quoted 14 lines · Minda Chen

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

---
  drivers/usb/cdns3/core.c | 17 +++++++++++++++++
  1 file changed, 17 insertions(+)
drivers/usb/cdns3/core.c +0 -0
index 12a741c6ea..c1a61471f9 100644

drivers/usb/cdns3/core.c static int cdns3_probe(struct cdns3 *cdns) · line 324

Quoted 4 lines
drivers/usb/cdns3/core.c +1 -0
@@ -321,6 +321,7 @@ static int cdns3_probe(struct cdns3 *cdns)
  {
  	struct udevice *dev = cdns->dev;
  	int ret;
+	int mode = PHY_MODE_INVALID;

Please swap ret and mode to keep this list sorted.

Quoted 4 lines
drivers/usb/cdns3/core.c +0 -0
  	cdns->xhci_regs = dev_remap_addr_name(dev, "xhci");
  	if (!cdns->xhci_regs)
@@ -372,6 +373,22 @@ static int cdns3_probe(struct cdns3 *cdns)
  	if (ret)

drivers/usb/cdns3/core.c static int cdns3_probe(struct cdns3 *cdns) · line 383

Quoted 10 lines
drivers/usb/cdns3/core.c +8 -0
  		return ret;
 
+	if (cdns->dr_mode == USB_DR_MODE_HOST)
+		mode = PHY_MODE_USB_HOST;
+	else if (cdns->dr_mode == USB_DR_MODE_PERIPHERAL)
+		mode = PHY_MODE_USB_DEVICE;
+	else if (cdns->dr_mode == USB_DR_MODE_OTG)
+		mode = PHY_MODE_USB_OTG;
+
+	if (mode != PHY_MODE_INVALID) {

Better invert the condition this way to reduce indent:

if (mode == PHY_MODE_INVALID) {
dev_err(...report the error...);
return ret;
}

ret = generic_phy_set...

Quoted 11 lines
drivers/usb/cdns3/core.c +8 -0
+		ret = generic_phy_set_mode(&cdns->usb2_phy, mode, 0);
+		if (ret)
+			return ret;
+		ret = generic_phy_set_mode(&cdns->usb3_phy, mode, 0);
+		if (ret)
+			return ret;
+	}
+
  	dev_dbg(dev, "Cadence USB3 core: probe succeed\n");
 
  	return 0;
#4 lore raw

Re: [PATCH v1 2/7] phy: starfive: Add Starfive JH7110 USB 2.0 PHY driver

In reply to Minda Chen

On 5/4/24 5:03 PM, Minda Chen wrote:

[...]

drivers/phy/starfive/Makefile line 3

Quoted 9 lines
drivers/phy/starfive/Makefile new file +3 -0
new file mode 100644
index 0000000000..a405a75e34
@@ -0,0 +1,6 @@
+# SPDX-License-Identifier: GPL-2.0+
+#
+# Copyright (C) 2023 Starfive

2024 instead of 2023, please fix globally.

Quoted 8 lines
drivers/phy/starfive/Makefile new file +3 -0
+#
+
+obj-$(CONFIG_PHY_STARFIVE_JH7110_USB2)	+= phy-jh7110-usb2.o
drivers/phy/starfive/phy-jh7110-usb2.c new file +0 -0
new file mode 100644
index 0000000000..ffbd96d721

[...]

drivers/phy/starfive/phy-jh7110-usb2.c line 43

Quoted 12 lines
drivers/phy/starfive/phy-jh7110-usb2.c new file +12 -0
+static void usb2_set_ls_keepalive(struct jh7110_usb2_phy *phy, bool set)
+{
+	unsigned int val;
+
+	/* Host mode enable the LS speed keep-alive signal */
+	val = readl(phy->regs + USB_LS_KEEPALIVE_OFF);
+	if (set)
+		val |= USB_LS_KEEPALIVE_ENABLE;
+	else
+		val &= ~USB_LS_KEEPALIVE_ENABLE;
+
+	writel(val, phy->regs + USB_LS_KEEPALIVE_OFF);

This is clrsetbits_le32(), use it.

Quoted 8 lines
drivers/phy/starfive/phy-jh7110-usb2.c new file +8 -0
+}
+
+static int usb2_phy_set_mode(struct phy *_phy,
+			     enum phy_mode mode, int submode)
+{
+	struct udevice *dev = _phy->dev;
+	struct jh7110_usb2_phy *phy = dev_get_priv(dev);
+

drivers/phy/starfive/phy-jh7110-usb2.c line 61

Quoted 10 lines
drivers/phy/starfive/phy-jh7110-usb2.c new file +10 -0
+	switch (mode) {
+	case PHY_MODE_USB_HOST:
+	case PHY_MODE_USB_DEVICE:
+	case PHY_MODE_USB_OTG:
+		break;
+	default:
+		return -EINVAL;
+	}
+
+	if (mode != phy->mode) {

Reduce indent this way:

if (mode == phy->mode)
return 0;

... do mode switch stuff ...
return 0;

Quoted 5 lines
drivers/phy/starfive/phy-jh7110-usb2.c new file +5 -0
+		dev_dbg(dev, "Changing phy to %d\n", mode);
+		phy->mode = mode;
+		usb2_set_ls_keepalive(phy, (mode != PHY_MODE_USB_DEVICE));
+	}
+

drivers/phy/starfive/phy-jh7110-usb2.c line 76

Quoted 10 lines
drivers/phy/starfive/phy-jh7110-usb2.c new file +10 -0
+	return 0;
+}
+
+static int jh7110_usb2_phy_init(struct phy *_phy)
+{
+	struct udevice *dev = _phy->dev;
+	struct jh7110_usb2_phy *phy = dev_get_priv(dev);
+	int ret;
+
+	ret = clk_prepare_enable(phy->app_125m);

return clk_prepare_...(); is just fine

Quoted 18 lines
drivers/phy/starfive/phy-jh7110-usb2.c new file +18 -0
+	if (ret)
+		return ret;
+
+	return 0;
+}
+
+static int jh7110_usb2_phy_exit(struct phy *_phy)
+{
+	struct udevice *dev = _phy->dev;
+	struct jh7110_usb2_phy *phy = dev_get_priv(dev);
+
+	clk_disable_unprepare(phy->app_125m);
+
+	return 0;
+}
+
+struct phy_ops jh7110_usb2_phy_ops = {
+	.init     = jh7110_usb2_phy_init,

drivers/phy/starfive/phy-jh7110-usb2.c line 104

Quoted 10 lines
drivers/phy/starfive/phy-jh7110-usb2.c new file +10 -0
+	.exit     = jh7110_usb2_phy_exit,
+	.set_mode = usb2_phy_set_mode,
+};
+
+int jh7110_usb2_phy_probe(struct udevice *dev)
+{
+	struct jh7110_usb2_phy *phy = dev_get_priv(dev);
+
+	phy->regs = dev_read_addr_ptr(dev);
+

Drop extra newline.

Quoted 2 lines
drivers/phy/starfive/phy-jh7110-usb2.c new file +2 -0
+	if (!phy->regs)
+		return -EINVAL;

[...]

#6 lore raw

Re: [PATCH v1 3/7] phy: starfive: Add Starfive JH7110 PCIe 2.0 PHY driver

In reply to Minda Chen

On 5/4/24 5:03 PM, Minda Chen wrote:

Fix up the copyrights to year 2024 globally please.

[...]

Review

Quoted 2 lines
(quoted diff) +2 -0
+static int phy_usb3_mode_set(struct jh7110_pcie_phy *data)
+{

Can this phy_usb3_mode_set and phy_pcie_mode_set be unified into single function with parameter to select usb3/pcie mode instead ?

Quoted 21 lines
drivers/phy/starfive/phy-jh7110-pcie.c new file +21 -0
+	if (!data->stg_syscon || !data->sys_syscon) {
+		dev_err(data->phy->dev, "doesn't support usb3 mode\n");
+		return -EINVAL;
+	}
+
+	regmap_update_bits(data->stg_syscon, data->stg_pcie_mode,
+			   PCIE_PHY_MODE_MASK, PCIE_PHY_MODE);
+	regmap_update_bits(data->stg_syscon, data->stg_pcie_usb,
+			   PCIE_USB3_BUS_WIDTH_MASK, 0);
+	regmap_update_bits(data->stg_syscon, data->stg_pcie_usb,
+			   PCIE_USB3_PHY_ENABLE, PCIE_USB3_PHY_ENABLE);
+
+	/* Connect usb 3.0 phy mode */
+	regmap_update_bits(data->sys_syscon, data->sys_phy_connect,
+			   USB_PDRSTN_SPLIT, 0);
+
+	/* Configuare spread-spectrum mode: down-spread-spectrum */
+	writel(PCIE_USB3_PHY_ENABLE, data->regs + PCIE_USB3_PHY_PLL_CTL_OFF);
+
+	return 0;
+}

[...]

drivers/phy/starfive/phy-jh7110-pcie.c line 185

Quoted 7 lines
drivers/phy/starfive/phy-jh7110-pcie.c new file +7 -0
+int jh7110_pcie_phy_probe(struct udevice *dev)
+{
+	struct jh7110_pcie_phy *phy = dev_get_priv(dev);
+	int rc;
+
+	phy->regs = dev_read_addr_ptr(dev);
+

Drop extra newline here.

Quoted 2 lines
drivers/phy/starfive/phy-jh7110-pcie.c new file +2 -0
+	if (!phy->regs)
+		return -EINVAL;

[...]

#8 lore raw

Re: [PATCH v1 4/7] usb: cdns: starfive: Add cdns USB driver

In reply to Minda Chen

On 5/4/24 5:03 PM, Minda Chen wrote:

[...]

Quoted 6 lines
drivers/usb/cdns3/cdns3-starfive.c new file +6 -0
+static void cdns_mode_init(struct cdns_starfive *data, enum usb_dr_mode mode)
+{
+	regmap_update_bits(data->stg_syscon, data->stg_usb_mode,
+			   USB_MISC_CFG_MASK,
+			   USB_SUSPENDM_BYPS | USB_PLL_EN | USB_REFCLK_MODE);
+

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

Quoted 10 lines
drivers/usb/cdns3/cdns3-starfive.c new file +10 -0
+	switch (mode) {
+	case USB_DR_MODE_HOST:
+		regmap_update_bits(data->stg_syscon,
+				   data->stg_usb_mode,
+				   USB_STRAP_MASK,
+				   USB_STRAP_HOST);
+		regmap_update_bits(data->stg_syscon,
+				   data->stg_usb_mode,
+				   USB_SUSPENDM_MASK,
+				   USB_SUSPENDM_HOST);

Can you deduplicate thse regmap_update_bits at the end of this function ? Set a variable to USB_STRAP_HOST and another to USB_SUSPENDM_HOST here, set the same variables to USB_STRAP_DEVICE/0 below, and then call regmap_update_bits() with these variables at the end of this function once.

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

[...]

Reviewed-by on v1 7/7
#12 lore raw

Re: [PATCH v1 7/7] MAINTAINERS: Update Starfive visionfive2 maintain files.

In reply to Minda Chen
Quoted 12 lines · Minda Chen

Add USB related files to Starfive visionfive2 MAINTAINERS.

---
  board/starfive/visionfive2/MAINTAINERS | 2 ++
  1 file changed, 2 insertions(+)
board/starfive/visionfive2/MAINTAINERS +0 -0
index d7f638f9b4..1faf83f581 100644

board/starfive/visionfive2/MAINTAINERS F: board/starfive/visionfive2/ · line 10

Quoted 5 lines
board/starfive/visionfive2/MAINTAINERS +2 -0
@@ -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

Thanks !

author maintainer
#13 lore raw

Re: [PATCH v1 7/7] MAINTAINERS: Update Starfive visionfive2 maintain files.

Quoted 24 lines · Minda Chen

Review

Quoted 8 lines

Add USB related files to Starfive visionfive2 MAINTAINERS.

---
  board/starfive/visionfive2/MAINTAINERS | 2 ++
  1 file changed, 2 insertions(+)
(quoted diff) +0 -0

b/board/starfive/visionfive2/MAINTAINERS

board/starfive/visionfive2/MAINTAINERS F: board/starfive/visionfive2/ · line 10

Quoted 9 lines

index d7f638f9b4..1faf83f581 100644

board/starfive/visionfive2/MAINTAINERS +2 -0
@@ -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

Thanks !

Quoted 1 line

Thanks for reviewing the patch set! I will follow the comments.

#14 lore raw

Re: [PATCH v1 7/7] MAINTAINERS: Update Starfive visionfive2 maintain files.

Quoted 24 lines · Minda Chen
Quoted 24 lines · Minda Chen

Review

Quoted 8 lines

Add USB related files to Starfive visionfive2 MAINTAINERS.

---
   board/starfive/visionfive2/MAINTAINERS | 2 ++
   1 file changed, 2 insertions(+)
(quoted diff) +0 -0

b/board/starfive/visionfive2/MAINTAINERS

board/starfive/visionfive2/MAINTAINERS F: board/starfive/visionfive2/ · line 10

Quoted 9 lines

index d7f638f9b4..1faf83f581 100644

board/starfive/visionfive2/MAINTAINERS +2 -0
@@ -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

Thanks !

Quoted 3 lines
Quoted 1 line

Thanks for reviewing the patch set! I will follow the comments.

Thank you !

#15 lore raw
In reply to Minda Chen

Hi, there is a compile warning. I don't know why.

Quoted 44 lines · Minda Chen

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

The driver is almost the same with kernel driver.

patch1: Add set phy mode function in cdns3 core driver
which is used by Starfive.

patch2-3: USB and PCIe 2.0 (usb 3.0) PHY drivier
patch4: Cadence USB wrapper driver.
patch5-7 dts, config and maintainers update.

Minda Chen (7):
usb: cdns3: Set USB PHY mode in cdns3_probe()
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
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                    |  52 +++++
 board/starfive/visionfive2/MAINTAINERS        |   2 +
 configs/starfive_visionfive2_defconfig        |   9 +
 drivers/phy/Kconfig                           |   1 +
 drivers/phy/Makefile                          |   1 +
 drivers/phy/starfive/Kconfig                  |  19 ++
 drivers/phy/starfive/Makefile                 |   7 +
 drivers/phy/starfive/phy-jh7110-pcie.c        | 211 ++++++++++++++++++
 drivers/phy/starfive/phy-jh7110-usb2.c        | 135 +++++++++++
 drivers/usb/cdns3/Kconfig                     |   7 +
 drivers/usb/cdns3/Makefile                    |   2 +
 drivers/usb/cdns3/cdns3-starfive.c            | 184 +++++++++++++++
 drivers/usb/cdns3/core.c                      |  17 ++
 14 files changed, 652 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-usb2.c
 create mode 100644 drivers/usb/cdns3/cdns3-starfive.c
Quoted 4 lines

base-commit: 174ac987655c888017c82df1883c0c2ea0dc2495 --
2.17.1

The compile warning as follows:

In file included from /home/user/source/u-boot.git/drivers/usb/cdns3/gadget.c:70:
/home/user/source/u-boot.git/include/linux/bitmap.h: In function ‘bitmap_find_next_zero_area’:
/home/user/source/u-boot.git/include/linux/bitmap.h:170:17: warning:
implicit declaration of function ‘find_next_zero_bit’; did you mean ‘find_next_bit’? [-Wimplicit-function-declaration]

  170 |         index = find_next_zero_bit(map, size, start);
      |                 ^~~~~~~~~~~~~~~~~~
      |                 find_next_bit
  CC      drivers/usb/cdns3/ep0.o
In file included from
/home/user/source/u-boot.git/include/linux/usb/composite.h:26,
                 from /home/user/source/u-boot.git/drivers/usb/cdns3/ep0.c:19:

/home/user/source/u-boot.git/include/linux/bitmap.h: In function ‘bitmap_find_next_zero_area’:
/home/user/source/u-boot.git/include/linux/bitmap.h:170:17: warning:
implicit declaration of function ‘find_next_zero_bit’; did you mean ‘find_next_bit’? [-Wimplicit-function-declaration]

  170 |         index = find_next_zero_bit(map, size, start);
      |                 ^~~~~~~~~~~~~~~~~~
      |                 find_next_bit

Is this something missing in the patch series?

-E

author maintainer
#16 lore raw
Quoted 91 lines

-----邮件原件-----
发件人: E Shattow <[email protected]>
发送时间: 2024年5月20日 13:06
收件人: Minda Chen <[email protected]>
抄送: Marek Vasut <[email protected]>; Tom Rini <[email protected]>; Roger Quadros <[email protected]>; Neil Armstrong <[email protected]>; Alexey Romanov <[email protected]>; Sumit Garg <[email protected]>; Mark Kettenis <[email protected]>; Nishanth Menon <[email protected]>; Rick Chen <[email protected]>; Leo Yu-Chi Liang <[email protected]>; [email protected]; Heinrich Schuchardt <[email protected]>; Simon Glass <[email protected]>
主题: Re: [PATCH v1 0/7] Add Starfive JH7110 Cadence USB driver

Hi, there is a compile warning. I don't know why.

Quoted 22 lines · Minda Chen

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

The driver is almost the same with kernel driver.

patch1: Add set phy mode function in cdns3 core driver
which is used by Starfive.

patch2-3: USB and PCIe 2.0 (usb 3.0) PHY drivier
patch4: Cadence USB wrapper driver.
patch5-7 dts, config and maintainers update.

Minda Chen (7):
usb: cdns3: Set USB PHY mode in cdns3_probe()
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
configs: starfive: Add visionfive2 cadence USB configuration
dts: starfive: Add JH7110 Cadence USB dts node
MAINTAINERS: Update Starfive visionfive2 maintain files.

Quoted 9 lines
 .../dts/jh7110-starfive-visionfive-2.dtsi     |   5 +
 arch/riscv/dts/jh7110.dtsi                    |  52 +++++
 board/starfive/visionfive2/MAINTAINERS        |   2 +
 configs/starfive_visionfive2_defconfig        |   9 +
 drivers/phy/Kconfig                           |   1 +
 drivers/phy/Makefile                          |   1 +
 drivers/phy/starfive/Kconfig                  |  19 ++
 drivers/phy/starfive/Makefile                 |   7 +
 drivers/phy/starfive/phy-jh7110-pcie.c        | 211

++++++++++++++++++

Quoted 13 lines
 drivers/phy/starfive/phy-jh7110-usb2.c        | 135 +++++++++++
 drivers/usb/cdns3/Kconfig                     |   7 +
 drivers/usb/cdns3/Makefile                    |   2 +
 drivers/usb/cdns3/cdns3-starfive.c            | 184 +++++++++++++++
 drivers/usb/cdns3/core.c                      |  17 ++
 14 files changed, 652 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-usb2.c
 create mode 100644 drivers/usb/cdns3/cdns3-starfive.c
Quoted 4 lines

base-commit: 174ac987655c888017c82df1883c0c2ea0dc2495 --
2.17.1

The compile warning as follows:

In file included from /home/user/source/u-boot.git/drivers/usb/cdns3/gadget.c:70:
/home/user/source/u-boot.git/include/linux/bitmap.h: In function ‘bitmap_find_next_zero_area’:
/home/user/source/u-boot.git/include/linux/bitmap.h:170:17: warning:
implicit declaration of function ‘find_next_zero_bit’; did you mean ‘find_next_bit’? [-Wimplicit-function-declaration]

  170 |         index = find_next_zero_bit(map, size, start);
      |                 ^~~~~~~~~~~~~~~~~~
      |                 find_next_bit

CC drivers/usb/cdns3/ep0.o
In file included from /home/user/source/u-boot.git/include/linux/usb/composite.h:26,
from
/home/user/source/u-boot.git/drivers/usb/cdns3/ep0.c:19:
/home/user/source/u-boot.git/include/linux/bitmap.h: In function ‘bitmap_find_next_zero_area’:
/home/user/source/u-boot.git/include/linux/bitmap.h:170:17: warning:
implicit declaration of function ‘find_next_zero_bit’; did you mean ‘find_next_bit’? [-Wimplicit-function-declaration]

Quoted 8 lines
  170 |         index = find_next_zero_bit(map, size, start);
      |                 ^~~~~~~~~~~~~~~~~~
      |                 find_next_bit

Is this something missing in the patch series?

-E

I have not noticed this. I just check this it is risc-v code do not contain "find_next_zero_bit" macro define.

#17 lore raw

Minda, can you test USB Host function on VisionFive2? I guess that it is connected to the USB-C port. For the boards with JH7110 and not any VL805 USB controller this Cadence USB is the only way to have host USB. It is very much wanted to have host USB. Thanks! -E

Quoted 102 lines · Minda Chen
Quoted 92 lines

-----邮件原件-----
发件人: E Shattow <[email protected]>
发送时间: 2024年5月20日 13:06
收件人: Minda Chen <[email protected]>
抄送: Marek Vasut <[email protected]>; Tom Rini <[email protected]>; Roger Quadros <[email protected]>; Neil Armstrong <[email protected]>; Alexey Romanov <[email protected]>; Sumit Garg <[email protected]>; Mark Kettenis <[email protected]>; Nishanth Menon <[email protected]>; Rick Chen <[email protected]>; Leo Yu-Chi Liang <[email protected]>; [email protected]; Heinrich Schuchardt <[email protected]>; Simon Glass <[email protected]>
主题: Re: [PATCH v1 0/7] Add Starfive JH7110 Cadence USB driver

Hi, there is a compile warning. I don't know why.

Quoted 22 lines · Minda Chen

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

The driver is almost the same with kernel driver.

patch1: Add set phy mode function in cdns3 core driver
which is used by Starfive.

patch2-3: USB and PCIe 2.0 (usb 3.0) PHY drivier
patch4: Cadence USB wrapper driver.
patch5-7 dts, config and maintainers update.

Minda Chen (7):
usb: cdns3: Set USB PHY mode in cdns3_probe()
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
configs: starfive: Add visionfive2 cadence USB configuration
dts: starfive: Add JH7110 Cadence USB dts node
MAINTAINERS: Update Starfive visionfive2 maintain files.

Quoted 9 lines
 .../dts/jh7110-starfive-visionfive-2.dtsi     |   5 +
 arch/riscv/dts/jh7110.dtsi                    |  52 +++++
 board/starfive/visionfive2/MAINTAINERS        |   2 +
 configs/starfive_visionfive2_defconfig        |   9 +
 drivers/phy/Kconfig                           |   1 +
 drivers/phy/Makefile                          |   1 +
 drivers/phy/starfive/Kconfig                  |  19 ++
 drivers/phy/starfive/Makefile                 |   7 +
 drivers/phy/starfive/phy-jh7110-pcie.c        | 211

++++++++++++++++++

Quoted 13 lines
 drivers/phy/starfive/phy-jh7110-usb2.c        | 135 +++++++++++
 drivers/usb/cdns3/Kconfig                     |   7 +
 drivers/usb/cdns3/Makefile                    |   2 +
 drivers/usb/cdns3/cdns3-starfive.c            | 184 +++++++++++++++
 drivers/usb/cdns3/core.c                      |  17 ++
 14 files changed, 652 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-usb2.c
 create mode 100644 drivers/usb/cdns3/cdns3-starfive.c
Quoted 4 lines

base-commit: 174ac987655c888017c82df1883c0c2ea0dc2495 --
2.17.1

The compile warning as follows:

In file included from /home/user/source/u-boot.git/drivers/usb/cdns3/gadget.c:70:
/home/user/source/u-boot.git/include/linux/bitmap.h: In function ‘bitmap_find_next_zero_area’:
/home/user/source/u-boot.git/include/linux/bitmap.h:170:17: warning:
implicit declaration of function ‘find_next_zero_bit’; did you mean ‘find_next_bit’? [-Wimplicit-function-declaration]

  170 |         index = find_next_zero_bit(map, size, start);
      |                 ^~~~~~~~~~~~~~~~~~
      |                 find_next_bit

CC drivers/usb/cdns3/ep0.o
In file included from /home/user/source/u-boot.git/include/linux/usb/composite.h:26,
from
/home/user/source/u-boot.git/drivers/usb/cdns3/ep0.c:19:
/home/user/source/u-boot.git/include/linux/bitmap.h: In function ‘bitmap_find_next_zero_area’:
/home/user/source/u-boot.git/include/linux/bitmap.h:170:17: warning:
implicit declaration of function ‘find_next_zero_bit’; did you mean ‘find_next_bit’? [-Wimplicit-function-declaration]

Quoted 8 lines
  170 |         index = find_next_zero_bit(map, size, start);
      |                 ^~~~~~~~~~~~~~~~~~
      |                 find_next_bit

Is this something missing in the patch series?

-E

I have not noticed this. I just check this it is risc-v code do not contain "find_next_zero_bit" macro define.

author maintainer
#18 lore raw
Quoted 8 lines

Minda, can you test USB Host function on VisionFive2? I guess that it is connected to the USB-C port. For the boards with JH7110 and not any VL805 USB controller this Cadence USB is the only way to have host USB. It is very much wanted to have host USB. Thanks! -E

In VF2, PCIe0 connect with VL805 USB 3.0 host controller. Now PCIe driver have commit to Uboot upstream code. USB 3.0 can be used in uboot upstream code. Milk-v mars also connect VL805 and can use USB 3.0 host too.

You can use "pci e" command to active USB 3.0 host controller and then "usb reset" to scan usb devices. If you have any issue about this. Also reply it in this. Thanks.

Quoted 95 lines
Quoted 40 lines · Minda Chen
Quoted 40 lines

Hi, there is a compile warning. I don't know why.

Quoted 31 lines · Minda Chen

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

The driver is almost the same with kernel driver.

patch1: Add set phy mode function in cdns3 core driver
which is used by Starfive.

patch2-3: USB and PCIe 2.0 (usb 3.0) PHY drivier
patch4: Cadence USB wrapper driver.
patch5-7 dts, config and maintainers update.

Minda Chen (7):
usb: cdns3: Set USB PHY mode in cdns3_probe()
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
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                    |  52 +++++
 board/starfive/visionfive2/MAINTAINERS        |   2 +
 configs/starfive_visionfive2_defconfig        |   9 +
 drivers/phy/Kconfig                           |   1 +
 drivers/phy/Makefile                          |   1 +
 drivers/phy/starfive/Kconfig                  |  19 ++
 drivers/phy/starfive/Makefile                 |   7 +
 drivers/phy/starfive/phy-jh7110-pcie.c        | 211
Quoted 5 lines
Quoted 5 lines

++++++++++++++++++

Quoted 4 lines
 drivers/phy/starfive/phy-jh7110-usb2.c        | 135 +++++++++++
 drivers/usb/cdns3/Kconfig                     |   7 +
 drivers/usb/cdns3/Makefile                    |   2 +
 drivers/usb/cdns3/cdns3-starfive.c            | 184

+++++++++++++++

Quoted 41 lines
Quoted 41 lines
Quoted 9 lines
 drivers/usb/cdns3/core.c                      |  17 ++
 14 files changed, 652 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-usb2.c
 create mode 100644 drivers/usb/cdns3/cdns3-starfive.c
Quoted 4 lines

base-commit: 174ac987655c888017c82df1883c0c2ea0dc2495 --
2.17.1

The compile warning as follows:

In file included from /home/user/source/u-boot.git/drivers/usb/cdns3/gadget.c:70:
/home/user/source/u-boot.git/include/linux/bitmap.h: In function ‘bitmap_find_next_zero_area’:
/home/user/source/u-boot.git/include/linux/bitmap.h:170:17: warning:
implicit declaration of function ‘find_next_zero_bit’; did you mean ‘find_next_bit’? [-Wimplicit-function-declaration]

  170 |         index = find_next_zero_bit(map, size, start);
      |                 ^~~~~~~~~~~~~~~~~~
      |                 find_next_bit

CC drivers/usb/cdns3/ep0.o
In file included from /home/user/source/u-boot.git/include/linux/usb/composite.h:26,
from
/home/user/source/u-boot.git/drivers/usb/cdns3/ep0.c:19:
/home/user/source/u-boot.git/include/linux/bitmap.h: In function ‘bitmap_find_next_zero_area’:
/home/user/source/u-boot.git/include/linux/bitmap.h:170:17: warning:
implicit declaration of function ‘find_next_zero_bit’; did you mean ‘find_next_bit’? [-Wimplicit-function-declaration]

  170 |         index = find_next_zero_bit(map, size, start);
      |                 ^~~~~~~~~~~~~~~~~~
      |                 find_next_bit
Quoted 5 lines
Quoted 3 lines

Is this something missing in the patch series?

-E

I have not noticed this. I just check this it is risc-v code do not contain

"find_next_zero_bit" macro define.

#19 lore raw

Hi,

Quoted 10 lines · Minda Chen
Quoted 9 lines

Minda, can you test USB Host function on VisionFive2? I guess that it is connected to the USB-C port. For the boards with JH7110 and not any VL805 USB controller this Cadence USB is the only way to have host USB. It is very much wanted to have host USB. Thanks! -E

Quoted 3 lines

In VF2, PCIe0 connect with VL805 USB 3.0 host controller. Now PCIe driver have commit to Uboot upstream code. USB 3.0 can be used in uboot upstream code. Milk-v mars also connect VL805 and can use USB 3.0 host too.

No no I am asking about Cadence USB of JH7110 CPU. This VL805 is not the question, sorry that my question was not easy to understand before.

Quoted 3 lines

You can use "pci e" command to active USB 3.0 host controller and then "usb reset" to scan usb devices. If you have any issue about this. Also reply it in this. Thanks.

Can you show that Host USB is functioning on VF2 with the JH7110 CPU Cadence USB, not the VL805 controller?

This is needed so Milk-V Mars CM and Pine64 Star64 can have USB Host. There is no use of VL805 and we need JH7110 Cadence USB then.

Thanks!

-E

Quoted 96 lines
Quoted 96 lines
Quoted 40 lines · Minda Chen
Quoted 40 lines

Hi, there is a compile warning. I don't know why.

Quoted 31 lines · Minda Chen

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

The driver is almost the same with kernel driver.

patch1: Add set phy mode function in cdns3 core driver
which is used by Starfive.

patch2-3: USB and PCIe 2.0 (usb 3.0) PHY drivier
patch4: Cadence USB wrapper driver.
patch5-7 dts, config and maintainers update.

Minda Chen (7):
usb: cdns3: Set USB PHY mode in cdns3_probe()
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
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                    |  52 +++++
 board/starfive/visionfive2/MAINTAINERS        |   2 +
 configs/starfive_visionfive2_defconfig        |   9 +
 drivers/phy/Kconfig                           |   1 +
 drivers/phy/Makefile                          |   1 +
 drivers/phy/starfive/Kconfig                  |  19 ++
 drivers/phy/starfive/Makefile                 |   7 +
 drivers/phy/starfive/phy-jh7110-pcie.c        | 211
Quoted 5 lines
Quoted 5 lines

++++++++++++++++++

Quoted 4 lines
 drivers/phy/starfive/phy-jh7110-usb2.c        | 135 +++++++++++
 drivers/usb/cdns3/Kconfig                     |   7 +
 drivers/usb/cdns3/Makefile                    |   2 +
 drivers/usb/cdns3/cdns3-starfive.c            | 184

+++++++++++++++

Quoted 41 lines
Quoted 41 lines
Quoted 9 lines
 drivers/usb/cdns3/core.c                      |  17 ++
 14 files changed, 652 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-usb2.c
 create mode 100644 drivers/usb/cdns3/cdns3-starfive.c
Quoted 4 lines

base-commit: 174ac987655c888017c82df1883c0c2ea0dc2495 --
2.17.1

The compile warning as follows:

In file included from /home/user/source/u-boot.git/drivers/usb/cdns3/gadget.c:70:
/home/user/source/u-boot.git/include/linux/bitmap.h: In function ‘bitmap_find_next_zero_area’:
/home/user/source/u-boot.git/include/linux/bitmap.h:170:17: warning:
implicit declaration of function ‘find_next_zero_bit’; did you mean ‘find_next_bit’? [-Wimplicit-function-declaration]

  170 |         index = find_next_zero_bit(map, size, start);
      |                 ^~~~~~~~~~~~~~~~~~
      |                 find_next_bit

CC drivers/usb/cdns3/ep0.o
In file included from /home/user/source/u-boot.git/include/linux/usb/composite.h:26,
from
/home/user/source/u-boot.git/drivers/usb/cdns3/ep0.c:19:
/home/user/source/u-boot.git/include/linux/bitmap.h: In function ‘bitmap_find_next_zero_area’:
/home/user/source/u-boot.git/include/linux/bitmap.h:170:17: warning:
implicit declaration of function ‘find_next_zero_bit’; did you mean ‘find_next_bit’? [-Wimplicit-function-declaration]

  170 |         index = find_next_zero_bit(map, size, start);
      |                 ^~~~~~~~~~~~~~~~~~
      |                 find_next_bit
Quoted 5 lines
Quoted 3 lines

Is this something missing in the patch series?

-E

I have not noticed this. I just check this it is risc-v code do not contain

"find_next_zero_bit" macro define.

author maintainer
#20 lore raw
Quoted 27 lines

Hi,

Quoted 11 lines · Minda Chen
Quoted 10 lines

Minda, can you test USB Host function on VisionFive2? I guess that it is connected to the USB-C port. For the boards with JH7110 and not any
VL805 USB controller this Cadence USB is the only way to have host USB. It is very much wanted to have host USB. Thanks! -E

Quoted 2 lines

In VF2, PCIe0 connect with VL805 USB 3.0 host controller. Now PCIe driver have commit to Uboot upstream code. USB 3.0 can be used in uboot

upstream code.

Quoted 1 line

Milk-v mars also connect VL805 and can use USB 3.0 host too.

No no I am asking about Cadence USB of JH7110 CPU. This VL805 is not the question, sorry that my question was not easy to understand before.

Quoted 1 line
Quoted 7 lines
Quoted 2 lines

You can use "pci e" command to active USB 3.0 host controller and then "usb reset" to scan usb devices. If you have any issue about this. Also reply it

in this. Thanks.

Can you show that Host USB is functioning on VF2 with the JH7110 CPU Cadence USB, not the VL805 controller?

VF2 cadence USB is dr mode device.I cant test is with host.

Quoted 7 lines

This is needed so Milk-V Mars CM and Pine64 Star64 can have USB Host. There is no use of VL805 and we need JH7110 Cadence USB then.

Thanks!

-E

Okay. I will test cadence USB host in star64 board.

Quoted 98 lines
Quoted 98 lines
Quoted 98 lines
Quoted 40 lines · Minda Chen
Quoted 40 lines

Hi, there is a compile warning. I don't know why.

Quoted 31 lines · Minda Chen

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

The driver is almost the same with kernel driver.

patch1: Add set phy mode function in cdns3 core driver
which is used by Starfive.

patch2-3: USB and PCIe 2.0 (usb 3.0) PHY drivier
patch4: Cadence USB wrapper driver.
patch5-7 dts, config and maintainers update.

Minda Chen (7):
usb: cdns3: Set USB PHY mode in cdns3_probe()
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
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                    |  52 +++++
 board/starfive/visionfive2/MAINTAINERS        |   2 +
 configs/starfive_visionfive2_defconfig        |   9 +
 drivers/phy/Kconfig                           |   1 +
 drivers/phy/Makefile                          |   1 +
 drivers/phy/starfive/Kconfig                  |  19 ++
 drivers/phy/starfive/Makefile                 |   7 +
 drivers/phy/starfive/phy-jh7110-pcie.c        | 211
Quoted 5 lines
Quoted 5 lines

++++++++++++++++++

Quoted 4 lines
 drivers/phy/starfive/phy-jh7110-usb2.c        | 135 +++++++++++
 drivers/usb/cdns3/Kconfig                     |   7 +
 drivers/usb/cdns3/Makefile                    |   2 +
 drivers/usb/cdns3/cdns3-starfive.c            | 184

+++++++++++++++

Quoted 41 lines
Quoted 41 lines
Quoted 9 lines
 drivers/usb/cdns3/core.c                      |  17 ++
 14 files changed, 652 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-usb2.c
 create mode 100644 drivers/usb/cdns3/cdns3-starfive.c
Quoted 4 lines

base-commit: 174ac987655c888017c82df1883c0c2ea0dc2495 --
2.17.1

The compile warning as follows:

In file included from /home/user/source/u-boot.git/drivers/usb/cdns3/gadget.c:70:
/home/user/source/u-boot.git/include/linux/bitmap.h: In function ‘bitmap_find_next_zero_area’:
/home/user/source/u-boot.git/include/linux/bitmap.h:170:17: warning:
implicit declaration of function ‘find_next_zero_bit’; did you mean ‘find_next_bit’? [-Wimplicit-function-declaration]

  170 |         index = find_next_zero_bit(map, size, start);
      |                 ^~~~~~~~~~~~~~~~~~
      |                 find_next_bit

CC drivers/usb/cdns3/ep0.o
In file included from /home/user/source/u-boot.git/include/linux/usb/composite.h:26,
from
/home/user/source/u-boot.git/drivers/usb/cdns3/ep0.c:19:
/home/user/source/u-boot.git/include/linux/bitmap.h: In function ‘bitmap_find_next_zero_area’:
/home/user/source/u-boot.git/include/linux/bitmap.h:170:17: warning:
implicit declaration of function ‘find_next_zero_bit’; did you mean ‘find_next_bit’? [-Wimplicit-function-declaration]

  170 |         index = find_next_zero_bit(map, size, start);
      |                 ^~~~~~~~~~~~~~~~~~
      |                 find_next_bit
Quoted 6 lines
Quoted 3 lines

Is this something missing in the patch series?

-E

I have not noticed this. I just check this it is risc-v code do not contain

"find_next_zero_bit" macro define.