2 * Copyright (c) 2007-2008, Juniper Networks, Inc.
5 * SPDX-License-Identifier: GPL-2.0
17 /* Information about a USB port */
18 struct ehci_pci_priv {
19 struct ehci_ctrl ehci;
24 static void ehci_pci_init(struct udevice *dev, struct ehci_hccr **ret_hccr,
25 struct ehci_hcor **ret_hcor)
27 struct ehci_hccr *hccr;
28 struct ehci_hcor *hcor;
31 hccr = (struct ehci_hccr *)dm_pci_map_bar(dev,
32 PCI_BASE_ADDRESS_0, PCI_REGION_MEM);
33 hcor = (struct ehci_hcor *)((uintptr_t) hccr +
34 HC_LENGTH(ehci_readl(&hccr->cr_capbase)));
36 debug("EHCI-PCI init hccr %#lx and hcor %#lx hc_length %d\n",
37 (ulong)hccr, (ulong)hcor,
38 (u32)HC_LENGTH(ehci_readl(&hccr->cr_capbase)));
43 /* enable busmaster */
44 dm_pci_read_config32(dev, PCI_COMMAND, &cmd);
45 cmd |= PCI_COMMAND_MASTER;
46 dm_pci_write_config32(dev, PCI_COMMAND, cmd);
51 #ifdef CONFIG_PCI_EHCI_DEVICE
52 static struct pci_device_id ehci_pci_ids[] = {
53 /* Please add supported PCI EHCI controller ids here */
54 {0x1033, 0x00E0}, /* NEC */
55 {0x10B9, 0x5239}, /* ULI1575 PCI EHCI module ids */
56 {0x12D8, 0x400F}, /* Pericom */
61 static void ehci_pci_legacy_init(pci_dev_t pdev, struct ehci_hccr **ret_hccr,
62 struct ehci_hcor **ret_hcor)
64 struct ehci_hccr *hccr;
65 struct ehci_hcor *hcor;
68 hccr = (struct ehci_hccr *)pci_map_bar(pdev,
69 PCI_BASE_ADDRESS_0, PCI_REGION_MEM);
70 hcor = (struct ehci_hcor *)((uintptr_t) hccr +
71 HC_LENGTH(ehci_readl(&hccr->cr_capbase)));
73 debug("EHCI-PCI init hccr 0x%x and hcor 0x%x hc_length %d\n",
75 (u32)HC_LENGTH(ehci_readl(&hccr->cr_capbase)));
80 /* enable busmaster */
81 pci_read_config_dword(pdev, PCI_COMMAND, &cmd);
82 cmd |= PCI_COMMAND_MASTER;
83 pci_write_config_dword(pdev, PCI_COMMAND, cmd);
87 * Create the appropriate control structures to manage
88 * a new EHCI host controller.
90 int ehci_hcd_init(int index, enum usb_init_type init,
91 struct ehci_hccr **ret_hccr, struct ehci_hcor **ret_hcor)
95 #ifdef CONFIG_PCI_EHCI_DEVICE
96 pdev = pci_find_devices(ehci_pci_ids, CONFIG_PCI_EHCI_DEVICE);
98 pdev = pci_find_class(PCI_CLASS_SERIAL_USB_EHCI, index);
101 printf("EHCI host controller not found\n");
104 ehci_pci_legacy_init(pdev, ret_hccr, ret_hcor);
110 * Destroy the appropriate control structures corresponding
111 * the the EHCI host controller.
113 int ehci_hcd_stop(int index)
117 #endif /* nCONFIG_DM_USB */
120 static int ehci_pci_probe(struct udevice *dev)
122 struct ehci_hccr *hccr;
123 struct ehci_hcor *hcor;
125 ehci_pci_init(dev, &hccr, &hcor);
127 return ehci_register(dev, hccr, hcor, NULL, 0, USB_INIT_HOST);
130 static const struct udevice_id ehci_pci_ids[] = {
131 { .compatible = "ehci-pci" },
135 U_BOOT_DRIVER(ehci_pci) = {
138 .probe = ehci_pci_probe,
139 .remove = ehci_deregister,
140 .of_match = ehci_pci_ids,
141 .ops = &ehci_usb_ops,
142 .platdata_auto_alloc_size = sizeof(struct usb_platdata),
143 .priv_auto_alloc_size = sizeof(struct ehci_pci_priv),
144 .flags = DM_FLAG_ALLOC_PRIV_DMA,
147 static struct pci_device_id ehci_pci_supported[] = {
148 { PCI_DEVICE_CLASS(PCI_CLASS_SERIAL_USB_EHCI, ~0) },
152 U_BOOT_PCI_DEVICE(ehci_pci, ehci_pci_supported);
154 #endif /* CONFIG_DM_USB */