1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (c) 2015, Google, Inc
16 static void xhci_pci_init(struct udevice *dev, struct xhci_hccr **ret_hccr,
17 struct xhci_hcor **ret_hcor)
19 struct xhci_hccr *hccr;
20 struct xhci_hcor *hcor;
23 hccr = (struct xhci_hccr *)dm_pci_map_bar(dev,
24 PCI_BASE_ADDRESS_0, PCI_REGION_MEM);
25 hcor = (struct xhci_hcor *)((uintptr_t) hccr +
26 HC_LENGTH(xhci_readl(&hccr->cr_capbase)));
28 debug("XHCI-PCI init hccr %p and hcor %p hc_length %d\n",
29 hccr, hcor, (u32)HC_LENGTH(xhci_readl(&hccr->cr_capbase)));
34 /* enable busmaster */
35 dm_pci_read_config32(dev, PCI_COMMAND, &cmd);
36 cmd |= PCI_COMMAND_MASTER;
37 dm_pci_write_config32(dev, PCI_COMMAND, cmd);
40 static int xhci_pci_probe(struct udevice *dev)
42 struct xhci_hccr *hccr;
43 struct xhci_hcor *hcor;
45 xhci_pci_init(dev, &hccr, &hcor);
47 return xhci_register(dev, hccr, hcor);
50 static const struct udevice_id xhci_pci_ids[] = {
51 { .compatible = "xhci-pci" },
55 U_BOOT_DRIVER(xhci_pci) = {
58 .probe = xhci_pci_probe,
59 .remove = xhci_deregister,
60 .of_match = xhci_pci_ids,
62 .plat_auto = sizeof(struct usb_plat),
63 .priv_auto = sizeof(struct xhci_ctrl),
64 .flags = DM_FLAG_ALLOC_PRIV_DMA,
67 static struct pci_device_id xhci_pci_supported[] = {
68 { PCI_DEVICE_CLASS(PCI_CLASS_SERIAL_USB_XHCI, ~0) },
72 U_BOOT_PCI_DEVICE(xhci_pci, xhci_pci_supported);