2 * Copyright (C) 2015 Marvell International Ltd.
4 * MVEBU USB HOST xHCI Controller
6 * SPDX-License-Identifier: GPL-2.0+
13 #include <power/regulator.h>
18 DECLARE_GLOBAL_DATA_PTR;
20 struct mvebu_xhci_platdata {
25 * Contains pointers to register base addresses
26 * for the usb controller.
29 struct xhci_ctrl ctrl; /* Needs to come first in this struct! */
30 struct usb_platdata usb_plat;
31 struct xhci_hccr *hcd;
35 * Dummy implementation that can be overwritten by a board
38 __weak int board_xhci_enable(void)
43 static int xhci_usb_probe(struct udevice *dev)
45 struct mvebu_xhci_platdata *plat = dev_get_platdata(dev);
46 struct mvebu_xhci *ctx = dev_get_priv(dev);
47 struct xhci_hcor *hcor;
49 struct udevice *regulator;
51 ctx->hcd = (struct xhci_hccr *)plat->hcd_base;
52 len = HC_LENGTH(xhci_readl(&ctx->hcd->cr_capbase));
53 hcor = (struct xhci_hcor *)((uintptr_t)ctx->hcd + len);
55 ret = device_get_supply_regulator(dev, "vbus-supply", ®ulator);
57 ret = regulator_set_enable(regulator, true);
59 printf("Failed to turn ON the VBUS regulator\n");
64 /* Enable USB xHCI (VBUS, reset etc) in board specific code */
67 return xhci_register(dev, ctx->hcd, hcor);
70 static int xhci_usb_ofdata_to_platdata(struct udevice *dev)
72 struct mvebu_xhci_platdata *plat = dev_get_platdata(dev);
75 * Get the base address for XHCI controller from the device node
77 plat->hcd_base = dev_get_addr(dev);
78 if (plat->hcd_base == FDT_ADDR_T_NONE) {
79 debug("Can't get the XHCI register base address\n");
86 static const struct udevice_id xhci_usb_ids[] = {
87 { .compatible = "marvell,armada3700-xhci" },
88 { .compatible = "marvell,armada-8k-xhci" },
92 U_BOOT_DRIVER(usb_xhci) = {
95 .of_match = xhci_usb_ids,
96 .ofdata_to_platdata = xhci_usb_ofdata_to_platdata,
97 .probe = xhci_usb_probe,
98 .remove = xhci_deregister,
100 .platdata_auto_alloc_size = sizeof(struct mvebu_xhci_platdata),
101 .priv_auto_alloc_size = sizeof(struct mvebu_xhci),
102 .flags = DM_FLAG_ALLOC_PRIV_DMA,