public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Ramon Fried <ramon.fried@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v1 08/13] ehci: msm: switch to generic PHY uclass
Date: Wed, 19 Sep 2018 21:28:16 +0300	[thread overview]
Message-ID: <20180919182821.19575-9-ramon.fried@gmail.com> (raw)
In-Reply-To: <20180919182821.19575-1-ramon.fried@gmail.com>

All the underlying USB PHY was handled in the ehci driver.
Use the generic phy API instead.

Signed-off-by: Ramon Fried <ramon.fried@gmail.com>
---

 drivers/usb/host/Kconfig    |  3 +--
 drivers/usb/host/ehci-msm.c | 52 +++++++------------------------------
 2 files changed, 10 insertions(+), 45 deletions(-)

diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index b4dd005651..a213c918bc 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -167,12 +167,11 @@ config USB_EHCI_MSM
 	bool "Support for Qualcomm on-chip EHCI USB controller"
 	depends on DM_USB
 	select USB_ULPI_VIEWPORT
+	select MSM8916_USB_PHY
 	default n
 	---help---
 	  Enables support for the on-chip EHCI controller on Qualcomm
 	  Snapdragon SoCs.
-	  This driver supports combination of Chipidea USB controller
-	  and Synapsys USB PHY in host mode only.
 
 config USB_EHCI_PCI
 	bool "Support for PCI-based EHCI USB controller"
diff --git a/drivers/usb/host/ehci-msm.c b/drivers/usb/host/ehci-msm.c
index e7fb76d6da..a27a5833dd 100644
--- a/drivers/usb/host/ehci-msm.c
+++ b/drivers/usb/host/ehci-msm.c
@@ -21,59 +21,19 @@
 #include <linux/compat.h>
 #include "ehci.h"
 
-/* PHY viewport regs */
-#define ULPI_MISC_A_READ         0x96
-#define ULPI_MISC_A_SET          0x97
-#define ULPI_MISC_A_CLEAR        0x98
-#define ULPI_MISC_A_VBUSVLDEXTSEL    (1 << 1)
-#define ULPI_MISC_A_VBUSVLDEXT       (1 << 0)
-
-#define GEN2_SESS_VLD_CTRL_EN (1 << 7)
-
-#define SESS_VLD_CTRL         (1 << 25)
-
 struct msm_ehci_priv {
 	struct ehci_ctrl ctrl; /* Needed by EHCI */
 	struct usb_ehci *ehci; /* Start of IP core*/
 	struct ulpi_viewport ulpi_vp; /* ULPI Viewport */
+	struct phy phy;
 };
 
-static void setup_usb_phy(struct msm_ehci_priv *priv)
-{
-	/* Select and enable external configuration with USB PHY */
-	ulpi_write(&priv->ulpi_vp, (u8 *)ULPI_MISC_A_SET,
-		   ULPI_MISC_A_VBUSVLDEXTSEL | ULPI_MISC_A_VBUSVLDEXT);
-}
-
-static void reset_usb_phy(struct msm_ehci_priv *priv)
-{
-	/* Disable VBUS mimicing in the controller. */
-	ulpi_write(&priv->ulpi_vp, (u8 *)ULPI_MISC_A_CLEAR,
-		   ULPI_MISC_A_VBUSVLDEXTSEL | ULPI_MISC_A_VBUSVLDEXT);
-}
-
-
 static int msm_init_after_reset(struct ehci_ctrl *dev)
 {
 	struct msm_ehci_priv *p = container_of(dev, struct msm_ehci_priv, ctrl);
 	struct usb_ehci *ehci = p->ehci;
 
-	/* select ULPI phy */
-	writel(PORT_PTS_ULPI, &ehci->portsc);
-	setup_usb_phy(p);
-
-	/* Enable sess_vld */
-	setbits_le32(&ehci->genconfig2, GEN2_SESS_VLD_CTRL_EN);
-
-	/* Enable external vbus configuration in the LINK */
-	setbits_le32(&ehci->usbcmd, SESS_VLD_CTRL);
-
-	/* USB_OTG_HS_AHB_BURST */
-	writel(0x0, &ehci->sbuscfg);
-
-	/* USB_OTG_HS_AHB_MODE: HPROT_MODE */
-	/* Bus access related config. */
-	writel(0x08, &ehci->sbusmode);
+	generic_phy_reset(&p->phy);
 
 	/* set mode to host controller */
 	writel(CM_HOST, &ehci->usbmode);
@@ -97,6 +57,10 @@ static int ehci_usb_probe(struct udevice *dev)
 	hcor = (struct ehci_hcor *)((phys_addr_t)hccr +
 			HC_LENGTH(ehci_readl(&(hccr)->cr_capbase)));
 
+	ret = ehci_setup_phy(dev, &p->phy, 0);
+	if (ret)
+		return ret;
+
 	ret = board_usb_init(0, USB_INIT_HOST);
 	if (ret < 0)
 		return ret;
@@ -117,7 +81,9 @@ static int ehci_usb_remove(struct udevice *dev)
 	/* Stop controller. */
 	clrbits_le32(&ehci->usbcmd, CMD_RUN);
 
-	reset_usb_phy(p);
+	ret = ehci_shutdown_phy(dev, &p->phy);
+	if (ret)
+		return ret;
 
 	ret = board_usb_init(0, USB_INIT_DEVICE); /* Board specific hook */
 	if (ret < 0)
-- 
2.18.0

  parent reply	other threads:[~2018-09-19 18:28 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-19 18:28 [U-Boot] [PATCH v1 00/13] Introduce fastboot support for dragonboard410c Ramon Fried
2018-09-19 18:28 ` [U-Boot] [PATCH v1 01/13] ehci: Replace board_prepare_usb with board_usb_init Ramon Fried
2018-09-19 18:28 ` [U-Boot] [PATCH v1 02/13] ehci: msm: Add missing platdata Ramon Fried
2018-09-19 18:28 ` [U-Boot] [PATCH v1 03/13] dts: db410c: add alias for USB Ramon Fried
2018-09-19 19:28   ` Peter Robinson
2018-09-19 19:32     ` Ramon Fried
2018-09-19 20:03       ` Peter Robinson
2018-09-19 18:28 ` [U-Boot] [PATCH v1 04/13] db410c: serial# env using msm board serial Ramon Fried
2018-09-19 18:28 ` [U-Boot] [PATCH v1 05/13] phy: db410c: Add MSM USB PHY driver Ramon Fried
2018-09-19 18:28 ` [U-Boot] [PATCH v1 06/13] dts: db410c: Add bindings for MSM USB phy Ramon Fried
2018-09-19 18:28 ` [U-Boot] [PATCH v1 07/13] configs: db410c: Enable USB PHY Ramon Fried
2018-09-19 18:28 ` Ramon Fried [this message]
2018-09-19 18:28 ` [U-Boot] [PATCH v1 09/13] ehci: msm: use init_type in probe Ramon Fried
2018-09-19 18:28 ` [U-Boot] [PATCH v1 10/13] usb:ci_udc: Introduce init_after_reset phy function Ramon Fried
2018-09-19 18:28 ` [U-Boot] [PATCH v1 11/13] usb: ehci-msm: Add init_after_reset for CI_UDC Ramon Fried
2018-09-19 18:28 ` [U-Boot] [PATCH v1 12/13] DB410c: Enable fastboot support Ramon Fried
2018-09-19 18:28 ` [U-Boot] [PATCH v1 13/13] db410c: automatically launch fastboot Ramon Fried

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=20180919182821.19575-9-ramon.fried@gmail.com \
    --to=ramon.fried@gmail.com \
    --cc=u-boot@lists.denx.de \
    /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