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

Minda Chen minda.chen at starfivetech.com
Sat May 4 17:03:52 CEST 2024


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().

Signed-off-by: Minda Chen <minda.chen at starfivetech.com>
---
 drivers/usb/cdns3/core.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/drivers/usb/cdns3/core.c b/drivers/usb/cdns3/core.c
index 12a741c6ea..c1a61471f9 100644
--- a/drivers/usb/cdns3/core.c
+++ b/drivers/usb/cdns3/core.c
@@ -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;
-- 
2.17.1



More information about the U-Boot mailing list