U-Boot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Minda Chen <minda.chen@starfivetech.com>
To: Marek Vasut <marex@denx.de>, Tom Rini <trini@konsulko.com>,
	Roger Quadros <rogerq@kernel.org>,
	Neil Armstrong <neil.armstrong@linaro.org>,
	Alexey Romanov <avromanov@salutedevices.com>,
	Sumit Garg <sumit.garg@linaro.org>,
	Mark Kettenis <kettenis@openbsd.org>, Nishanth Menon <nm@ti.com>,
	Rick Chen <rick@andestech.com>,
	Leo Yu-Chi Liang <ycliang@andestech.com>
Cc: u-boot@lists.denx.de, Heinrich Schuchardt <xypron.glpk@gmx.de>,
	Simon Glass <sjg@chromium.org>, E Shattow <lucent@gmail.com>,
	Minda Chen <minda.chen@starfivetech.com>
Subject: [PATCH v2 1/8] usb: cdns3: Set USB PHY mode in cdns3_core_init_role()
Date: Thu,  4 Jul 2024 13:50:07 +0800	[thread overview]
Message-ID: <20240704055014.55117-2-minda.chen@starfivetech.com> (raw)
In-Reply-To: <20240704055014.55117-1-minda.chen@starfivetech.com>

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@starfivetech.com>
---
 drivers/usb/cdns3/core.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/drivers/usb/cdns3/core.c b/drivers/usb/cdns3/core.c
index 12a741c6ea..1e863bed89 100644
--- a/drivers/usb/cdns3/core.c
+++ b/drivers/usb/cdns3/core.c
@@ -107,6 +107,7 @@ static int cdns3_core_init_role(struct cdns3 *cdns)
 {
 	struct udevice *dev = cdns->dev;
 	enum usb_dr_mode best_dr_mode;
+	int mode = PHY_MODE_INVALID;
 	enum usb_dr_mode dr_mode;
 	int ret = 0;
 
@@ -173,6 +174,30 @@ static int cdns3_core_init_role(struct cdns3 *cdns)
 
 	cdns->dr_mode = dr_mode;
 
+	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;
+	} else {
+		dev_err(dev, "Unknown dr mode %d\n", cdns->dr_mode);
+		ret = -EINVAL;
+		goto err;
+	}
+
+	ret = generic_phy_set_mode(&cdns->usb2_phy, mode, 0);
+	if (ret) {
+		dev_err(dev, "Set usb 2.0 PHY mode failed %d\n", ret);
+		goto err;
+	}
+
+	ret = generic_phy_set_mode(&cdns->usb3_phy, mode, 0);
+	if (ret) {
+		dev_err(dev, "Set usb 3.0 PHY mode failed %d\n", ret);
+		goto err;
+	}
+
 	ret = cdns3_drd_update_mode(cdns);
 	if (ret)
 		goto err;
-- 
2.17.1


  reply	other threads:[~2024-07-04  5:50 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-04  5:50 [PATCH v2 0/7] Add Starfive JH7110 Cadence USB driver Minda Chen
2024-07-04  5:50 ` Minda Chen [this message]
2024-07-04 13:30   ` [PATCH v2 1/8] usb: cdns3: Set USB PHY mode in cdns3_core_init_role() Roger Quadros
2024-07-05  8:23     ` Minda Chen
2024-07-04  5:50 ` [PATCH v2 2/8] phy: starfive: Add Starfive JH7110 USB 2.0 PHY driver Minda Chen
2024-07-04 13:34   ` Roger Quadros
2024-07-04  5:50 ` [PATCH v2 3/8] phy: starfive: Add Starfive JH7110 PCIe " Minda Chen
2024-07-04 14:06   ` Roger Quadros
2024-07-19  1:29     ` Minda Chen
2024-07-04 14:16   ` Roger Quadros
2024-07-04  5:50 ` [PATCH v2 4/8] usb: cdns: starfive: Add cdns USB driver Minda Chen
2024-07-04 14:17   ` Roger Quadros
2024-07-04  5:50 ` [PATCH v2 5/8] pinctrl: starfive: Setup USB default disable overcurrent pin Minda Chen
2024-07-04  5:50 ` [PATCH v2 6/8] configs: starfive: Add visionfive2 cadence USB configuration Minda Chen
2024-07-04  5:50 ` [PATCH v2 7/8] dts: starfive: Add JH7110 Cadence USB dts node Minda Chen
2024-07-04  5:50 ` [PATCH v2 8/8] MAINTAINERS: Update Starfive visionfive2 maintain files Minda Chen
2024-07-04 13:25 ` [PATCH v2 0/7] Add Starfive JH7110 Cadence USB driver Heinrich Schuchardt
2024-07-05  1:08   ` E Shattow
2024-07-05  5:33     ` 回复: " Minda Chen
2024-07-19  1:31   ` Minda Chen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240704055014.55117-2-minda.chen@starfivetech.com \
    --to=minda.chen@starfivetech.com \
    --cc=avromanov@salutedevices.com \
    --cc=kettenis@openbsd.org \
    --cc=lucent@gmail.com \
    --cc=marex@denx.de \
    --cc=neil.armstrong@linaro.org \
    --cc=nm@ti.com \
    --cc=rick@andestech.com \
    --cc=rogerq@kernel.org \
    --cc=sjg@chromium.org \
    --cc=sumit.garg@linaro.org \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    --cc=xypron.glpk@gmx.de \
    --cc=ycliang@andestech.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox