]> git.sur5r.net Git - u-boot/blob - drivers/usb/host/xhci-mvebu.c
usb: xhci-mvebu: Add Armada 8K to compatiblity list
[u-boot] / drivers / usb / host / xhci-mvebu.c
1 /*
2  * Copyright (C) 2015 Marvell International Ltd.
3  *
4  * MVEBU USB HOST xHCI Controller
5  *
6  * SPDX-License-Identifier:     GPL-2.0+
7  */
8
9 #include <common.h>
10 #include <dm.h>
11 #include <fdtdec.h>
12 #include <usb.h>
13 #include <asm/gpio.h>
14
15 #include "xhci.h"
16
17 DECLARE_GLOBAL_DATA_PTR;
18
19 struct mvebu_xhci_platdata {
20         fdt_addr_t hcd_base;
21 };
22
23 /**
24  * Contains pointers to register base addresses
25  * for the usb controller.
26  */
27 struct mvebu_xhci {
28         struct xhci_ctrl ctrl;  /* Needs to come first in this struct! */
29         struct usb_platdata usb_plat;
30         struct xhci_hccr *hcd;
31 };
32
33 /*
34  * Dummy implementation that can be overwritten by a board
35  * specific function
36  */
37 __weak int board_xhci_enable(void)
38 {
39         return 0;
40 }
41
42 static int xhci_usb_probe(struct udevice *dev)
43 {
44         struct mvebu_xhci_platdata *plat = dev_get_platdata(dev);
45         struct mvebu_xhci *ctx = dev_get_priv(dev);
46         struct xhci_hcor *hcor;
47         int len;
48
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);
52
53         /* Enable USB xHCI (VBUS, reset etc) in board specific code */
54         board_xhci_enable();
55
56         return xhci_register(dev, ctx->hcd, hcor);
57 }
58
59 static int xhci_usb_remove(struct udevice *dev)
60 {
61         return xhci_deregister(dev);
62 }
63
64 static int xhci_usb_ofdata_to_platdata(struct udevice *dev)
65 {
66         struct mvebu_xhci_platdata *plat = dev_get_platdata(dev);
67
68         /*
69          * Get the base address for XHCI controller from the device node
70          */
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");
74                 return -ENXIO;
75         }
76
77         return 0;
78 }
79
80 static const struct udevice_id xhci_usb_ids[] = {
81         { .compatible = "marvell,armada3700-xhci" },
82         { .compatible = "marvell,armada-8k-xhci" },
83         { }
84 };
85
86 U_BOOT_DRIVER(usb_xhci) = {
87         .name   = "xhci_mvebu",
88         .id     = UCLASS_USB,
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,
93         .ops    = &xhci_usb_ops,
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,
97 };