1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 2015 Marvell International Ltd.
5 * MVEBU USB HOST xHCI Controller
12 #include <power/regulator.h>
17 struct mvebu_xhci_plat {
22 * Contains pointers to register base addresses
23 * for the usb controller.
26 struct xhci_ctrl ctrl; /* Needs to come first in this struct! */
27 struct usb_plat usb_plat;
28 struct xhci_hccr *hcd;
32 * Dummy implementation that can be overwritten by a board
35 __weak int board_xhci_enable(fdt_addr_t base)
40 static int xhci_usb_probe(struct udevice *dev)
42 struct mvebu_xhci_plat *plat = dev_get_plat(dev);
43 struct mvebu_xhci *ctx = dev_get_priv(dev);
44 struct xhci_hcor *hcor;
46 struct udevice *regulator;
48 ctx->hcd = (struct xhci_hccr *)plat->hcd_base;
49 len = HC_LENGTH(xhci_readl(&ctx->hcd->cr_capbase));
50 hcor = (struct xhci_hcor *)((uintptr_t)ctx->hcd + len);
52 ret = device_get_supply_regulator(dev, "vbus-supply", ®ulator);
54 ret = regulator_set_enable(regulator, true);
56 printf("Failed to turn ON the VBUS regulator\n");
61 /* Enable USB xHCI (VBUS, reset etc) in board specific code */
62 board_xhci_enable(devfdt_get_addr_index(dev, 1));
64 return xhci_register(dev, ctx->hcd, hcor);
67 static int xhci_usb_of_to_plat(struct udevice *dev)
69 struct mvebu_xhci_plat *plat = dev_get_plat(dev);
72 * Get the base address for XHCI controller from the device node
74 plat->hcd_base = dev_read_addr(dev);
75 if (plat->hcd_base == FDT_ADDR_T_NONE) {
76 debug("Can't get the XHCI register base address\n");
83 static const struct udevice_id xhci_usb_ids[] = {
84 { .compatible = "marvell,armada3700-xhci" },
85 { .compatible = "marvell,armada-380-xhci" },
86 { .compatible = "marvell,armada-8k-xhci" },
90 U_BOOT_DRIVER(usb_xhci) = {
93 .of_match = xhci_usb_ids,
94 .of_to_plat = xhci_usb_of_to_plat,
95 .probe = xhci_usb_probe,
96 .remove = xhci_deregister,
98 .plat_auto = sizeof(struct mvebu_xhci_plat),
99 .priv_auto = sizeof(struct mvebu_xhci),
100 .flags = DM_FLAG_ALLOC_PRIV_DMA,