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>
lime2-spi
Marek Vasut 6 years ago committed by Marek Vasut
parent b43cdf9b3f
commit 1335e7745f
  1. 31
      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),

Loading…
Cancel
Save