2 * (C) Copyright 2014, Xilinx, Inc
4 * USB Low level initialization(Specific to zynq)
6 * SPDX-License-Identifier: GPL-2.0+
10 #include <asm/arch/hardware.h>
11 #include <asm/arch/sys_proto.h>
14 #include <usb/ehci-fsl.h>
19 #define ZYNQ_USB_USBCMD_RST 0x0000002
20 #define ZYNQ_USB_USBCMD_STOP 0x0000000
21 #define ZYNQ_USB_NUM_MIO 12
24 * Create the appropriate control structures to manage
25 * a new EHCI host controller.
27 int ehci_hcd_init(int index, enum usb_init_type init, struct ehci_hccr **hccr,
28 struct ehci_hcor **hcor)
30 struct usb_ehci *ehci;
31 struct ulpi_viewport ulpi_vp;
33 /* Used for writing the ULPI data address */
34 struct ulpi_regs *ulpi = (struct ulpi_regs *)0;
37 mio_usb = zynq_slcr_get_mio_pin_status("usb0");
38 if (mio_usb != ZYNQ_USB_NUM_MIO) {
39 printf("usb0 wrong num MIO: %d, Index %d\n", mio_usb,
43 ehci = (struct usb_ehci *)ZYNQ_USB_BASEADDR0;
45 mio_usb = zynq_slcr_get_mio_pin_status("usb1");
46 if (mio_usb != ZYNQ_USB_NUM_MIO) {
47 printf("usb1 wrong num MIO: %d, Index %d\n", mio_usb,
51 ehci = (struct usb_ehci *)ZYNQ_USB_BASEADDR1;
54 *hccr = (struct ehci_hccr *)((uint32_t)&ehci->caplength);
55 *hcor = (struct ehci_hcor *)((uint32_t) *hccr +
56 HC_LENGTH(ehci_readl(&(*hccr)->cr_capbase)));
58 ulpi_vp.viewport_addr = (u32)&ehci->ulpi_viewpoint;
61 ret = ulpi_init(&ulpi_vp);
63 puts("zynq ULPI viewport init failed\n");
68 ulpi_write(&ulpi_vp, &ulpi->otg_ctrl,
69 ULPI_OTG_DP_PULLDOWN | ULPI_OTG_DM_PULLDOWN |
71 ulpi_write(&ulpi_vp, &ulpi->function_ctrl,
72 ULPI_FC_FULL_SPEED | ULPI_FC_OPMODE_NORMAL |
74 ulpi_write(&ulpi_vp, &ulpi->iface_ctrl, 0);
77 ulpi_write(&ulpi_vp, &ulpi->otg_ctrl_set,
78 ULPI_OTG_DRVVBUS | ULPI_OTG_DRVVBUS_EXT);
84 * Destroy the appropriate control structures corresponding
85 * the the EHCI host controller.
87 int ehci_hcd_stop(int index)
89 struct usb_ehci *ehci;
92 ehci = (struct usb_ehci *)ZYNQ_USB_BASEADDR0;
94 ehci = (struct usb_ehci *)ZYNQ_USB_BASEADDR1;
97 writel(ZYNQ_USB_USBCMD_STOP, &ehci->usbcmd);
100 /* Initiate controller reset */
101 writel(ZYNQ_USB_USBCMD_RST, &ehci->usbcmd);