2 * Copyright (C) 2015 Marvell International Ltd.
4 * MVEBU USB HOST xHCI Controller
6 * SPDX-License-Identifier: GPL-2.0+
17 DECLARE_GLOBAL_DATA_PTR
;
19 struct mvebu_xhci_platdata
{
24 * Contains pointers to register base addresses
25 * for the usb controller.
28 struct xhci_ctrl ctrl
; /* Needs to come first in this struct! */
29 struct usb_platdata usb_plat
;
30 struct xhci_hccr
*hcd
;
34 * Dummy implementation that can be overwritten by a board
37 __weak
int board_xhci_enable(void)
42 static int xhci_usb_probe(struct udevice
*dev
)
44 struct mvebu_xhci_platdata
*plat
= dev_get_platdata(dev
);
45 struct mvebu_xhci
*ctx
= dev_get_priv(dev
);
46 struct xhci_hcor
*hcor
;
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 /* Enable USB xHCI (VBUS, reset etc) in board specific code */
56 return xhci_register(dev
, ctx
->hcd
, hcor
);
59 static int xhci_usb_remove(struct udevice
*dev
)
61 return xhci_deregister(dev
);
64 static int xhci_usb_ofdata_to_platdata(struct udevice
*dev
)
66 struct mvebu_xhci_platdata
*plat
= dev_get_platdata(dev
);
69 * Get the base address for XHCI controller from the device node
71 plat
->hcd_base
= dev_get_addr(dev
);
72 if (plat
->hcd_base
== FDT_ADDR_T_NONE
) {
73 debug("Can't get the XHCI register base address\n");
80 static const struct udevice_id xhci_usb_ids
[] = {
81 { .compatible
= "marvell,armada3700-xhci" },
82 { .compatible
= "marvell,armada-8k-xhci" },
86 U_BOOT_DRIVER(usb_xhci
) = {
89 .of_match
= xhci_usb_ids
,
90 .ofdata_to_platdata
= xhci_usb_ofdata_to_platdata
,
91 .probe
= xhci_usb_probe
,
92 .remove
= xhci_usb_remove
,
94 .platdata_auto_alloc_size
= sizeof(struct mvebu_xhci_platdata
),
95 .priv_auto_alloc_size
= sizeof(struct mvebu_xhci
),
96 .flags
= DM_FLAG_ALLOC_PRIV_DMA
,