summaryrefslogtreecommitdiff
path: root/drivers/usb
diff options
context:
space:
mode:
authorMarek Vasut <marek.vasut+renesas@gmail.com>2018-08-07 12:27:10 +0200
committerMarek Vasut <marex@denx.de>2018-08-28 11:00:19 +0200
commit1335e7745f77f122cf4196b8da2aa2fc5edad475 (patch)
tree0bb9c4cefffce4ff951c03a89f5ad49286fd5bd7 /drivers/usb
parentb43cdf9b3fe246a8920d2b62ee41fc1722315ef0 (diff)
usb: ehci: Add PHY support to ehci-pci
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@gmail.com>
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/host/ehci-pci.c31
1 files changed, 27 insertions, 4 deletions
diff --git a/drivers/usb/host/ehci-pci.c b/drivers/usb/host/ehci-pci.c
index a56e5bd144..6150f3d888 100644
--- a/drivers/usb/host/ehci-pci.c
+++ b/drivers/usb/host/ehci-pci.c
@@ -16,17 +16,23 @@
/* 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 +49,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 +128,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 +158,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),