[U-Boot] [PATCH] usb: ehci: Add PHY support to ehci-pci

Marek Vasut marek.vasut at gmail.com
Wed Aug 8 12:41:30 UTC 2018


Add support for operating a PHY attached to ehci-pci. There are
systems where the EHCI controller is internally wired to a PCI
bus and has a PHY connected to it as well, ie. the R-Car Gen2.

Signed-off-by: Marek Vasut <marek.vasut+renesas at gmail.com>
---
 drivers/usb/host/ehci-pci.c | 32 ++++++++++++++++++++++++++++----
 1 file changed, 28 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/host/ehci-pci.c b/drivers/usb/host/ehci-pci.c
index a56e5bd144..fa0b88bafd 100644
--- a/drivers/usb/host/ehci-pci.c
+++ b/drivers/usb/host/ehci-pci.c
@@ -10,23 +10,30 @@
 #include <pci.h>
 #include <usb.h>
 #include <asm/io.h>
+#include <generic-phy.h>
 
 #include "ehci.h"
 
 /* Information about a USB port */
 struct ehci_pci_priv {
 	struct ehci_ctrl ehci;
+	struct phy phy;
 };
 
 #ifdef CONFIG_DM_USB
-
-static void ehci_pci_init(struct udevice *dev, struct ehci_hccr **ret_hccr,
+static int ehci_pci_init(struct udevice *dev, struct ehci_hccr **ret_hccr,
 			  struct ehci_hcor **ret_hcor)
 {
+	struct ehci_pci_priv *priv = dev_get_priv(dev);
 	struct ehci_hccr *hccr;
 	struct ehci_hcor *hcor;
+	int ret;
 	u32 cmd;
 
+	ret = ehci_setup_phy(dev, &priv->phy, 0);
+	if (ret)
+		return ret;
+
 	hccr = (struct ehci_hccr *)dm_pci_map_bar(dev,
 			PCI_BASE_ADDRESS_0, PCI_REGION_MEM);
 	hcor = (struct ehci_hcor *)((uintptr_t) hccr +
@@ -43,6 +50,8 @@ static void ehci_pci_init(struct udevice *dev, struct ehci_hccr **ret_hccr,
 	dm_pci_read_config32(dev, PCI_COMMAND, &cmd);
 	cmd |= PCI_COMMAND_MASTER;
 	dm_pci_write_config32(dev, PCI_COMMAND, cmd);
+
+	return 0;
 }
 
 #else
@@ -120,12 +129,27 @@ static int ehci_pci_probe(struct udevice *dev)
 {
 	struct ehci_hccr *hccr;
 	struct ehci_hcor *hcor;
+	int ret;
 
-	ehci_pci_init(dev, &hccr, &hcor);
+	ret = ehci_pci_init(dev, &hccr, &hcor);
+	if (ret)
+		return ret;
 
 	return ehci_register(dev, hccr, hcor, NULL, 0, USB_INIT_HOST);
 }
 
+static int ehci_pci_remove(struct udevice *dev)
+{
+	struct ehci_pci_priv *priv = dev_get_priv(dev);
+	int ret;
+
+	ret = ehci_deregister(dev);
+	if (ret)
+		return ret;
+
+	return ehci_shutdown_phy(dev, &priv->phy);
+}
+
 static const struct udevice_id ehci_pci_ids[] = {
 	{ .compatible = "ehci-pci" },
 	{ }
@@ -135,7 +159,7 @@ U_BOOT_DRIVER(ehci_pci) = {
 	.name	= "ehci_pci",
 	.id	= UCLASS_USB,
 	.probe = ehci_pci_probe,
-	.remove = ehci_deregister,
+	.remove = ehci_pci_remove,
 	.of_match = ehci_pci_ids,
 	.ops	= &ehci_usb_ops,
 	.platdata_auto_alloc_size = sizeof(struct usb_platdata),
-- 
2.16.2



More information about the U-Boot mailing list