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 struct mvebu_xhci_platdata {
23 * Contains pointers to register base addresses
24 * for the usb controller.
27 struct xhci_ctrl ctrl; /* Needs to come first in this struct! */
28 struct usb_platdata usb_plat;
29 struct xhci_hccr *hcd;
33 * Dummy implementation that can be overwritten by a board
36 __weak int board_xhci_enable(fdt_addr_t base)
41 static int xhci_usb_probe(struct udevice *dev)
43 struct mvebu_xhci_platdata *plat = dev_get_platdata(dev);
44 struct mvebu_xhci *ctx = dev_get_priv(dev);
45 struct xhci_hcor *hcor;
47 struct udevice *regulator;
49 ctx->hcd = (struct xhci_hccr *)plat->hcd_base;
50 len = HC_LENGTH(xhci_readl(&ctx->hcd->cr_capbase));
51 hcor = (struct xhci_hcor *)((uintptr_t)ctx->hcd + len);
53 ret = device_get_supply_regulator(dev, "vbus-supply", ®ulator);
55 ret = regulator_set_enable(regulator, true);
57 printf("Failed to turn ON the VBUS regulator\n");
62 /* Enable USB xHCI (VBUS, reset etc) in board specific code */
63 board_xhci_enable(devfdt_get_addr_index(dev, 1));
65 return xhci_register(dev, ctx->hcd, hcor);
68 static int xhci_usb_ofdata_to_platdata(struct udevice *dev)
70 struct mvebu_xhci_platdata *plat = dev_get_platdata(dev);
73 * Get the base address for XHCI controller from the device node
75 plat->hcd_base = devfdt_get_addr(dev);
76 if (plat->hcd_base == FDT_ADDR_T_NONE) {
77 debug("Can't get the XHCI register base address\n");
84 static const struct udevice_id xhci_usb_ids[] = {
85 { .compatible = "marvell,armada3700-xhci" },
86 { .compatible = "marvell,armada-380-xhci" },
87 { .compatible = "marvell,armada-8k-xhci" },
91 U_BOOT_DRIVER(usb_xhci) = {
94 .of_match = xhci_usb_ids,
95 .ofdata_to_platdata = xhci_usb_ofdata_to_platdata,
96 .probe = xhci_usb_probe,
97 .remove = xhci_deregister,
99 .platdata_auto_alloc_size = sizeof(struct mvebu_xhci_platdata),
100 .priv_auto_alloc_size = sizeof(struct mvebu_xhci),
101 .flags = DM_FLAG_ALLOC_PRIV_DMA,