2 * OMAP USB HOST xHCI Controller
5 * Texas Instruments, <www.ti.com>
7 * Author: Dan Murphy <dmurphy@ti.com>
9 * SPDX-License-Identifier: GPL-2.0+
14 #include <linux/errno.h>
15 #include <asm/omap_common.h>
16 #include <asm/arch/cpu.h>
17 #include <asm/arch/sys_proto.h>
19 #include <linux/compat.h>
20 #include <linux/usb/dwc3.h>
21 #include <linux/usb/xhci-omap.h>
25 /* Declare global data pointer */
26 DECLARE_GLOBAL_DATA_PTR;
28 static struct omap_xhci omap;
30 __weak int omap_xhci_board_usb_init(int index, enum usb_init_type init)
35 int board_usb_init(int index, enum usb_init_type init)
37 return omap_xhci_board_usb_init(index, init);
40 __weak int omap_xhci_board_usb_cleanup(int index, enum usb_init_type init)
45 int board_usb_cleanup(int index, enum usb_init_type init)
47 return omap_xhci_board_usb_cleanup(index, init);
50 static int omap_xhci_core_init(struct omap_xhci *omap)
55 omap_enable_phy(omap);
57 ret = dwc3_core_init(omap->dwc3_reg);
59 debug("%s:failed to initialize core\n", __func__);
63 /* We are hard-coding DWC3 core to Host Mode */
64 dwc3_set_mode(omap->dwc3_reg, DWC3_GCTL_PRTCAP_HOST);
69 static void omap_xhci_core_exit(struct omap_xhci *omap)
74 int xhci_hcd_init(int index, struct xhci_hccr **hccr, struct xhci_hcor **hcor)
76 struct omap_xhci *ctx = &omap;
79 ctx->hcd = (struct xhci_hccr *)OMAP_XHCI_BASE;
80 ctx->dwc3_reg = (struct dwc3 *)((char *)(ctx->hcd) + DWC3_REG_OFFSET);
81 ctx->usb3_phy = (struct omap_usb3_phy *)OMAP_OCP1_SCP_BASE;
82 ctx->otg_wrapper = (struct omap_dwc_wrapper *)OMAP_OTG_WRAPPER_BASE;
84 ret = board_usb_init(index, USB_INIT_HOST);
86 puts("Failed to initialize board for USB\n");
90 ret = omap_xhci_core_init(ctx);
92 puts("Failed to initialize xhci\n");
96 *hccr = (struct xhci_hccr *)(OMAP_XHCI_BASE);
97 *hcor = (struct xhci_hcor *)((uint32_t) *hccr
98 + HC_LENGTH(xhci_readl(&(*hccr)->cr_capbase)));
100 debug("omap-xhci: init hccr %x and hcor %x hc_length %d\n",
101 (uint32_t)*hccr, (uint32_t)*hcor,
102 (uint32_t)HC_LENGTH(xhci_readl(&(*hccr)->cr_capbase)));
107 void xhci_hcd_stop(int index)
109 struct omap_xhci *ctx = &omap;
111 omap_xhci_core_exit(ctx);
112 board_usb_cleanup(index, USB_INIT_HOST);