2 * Copyright (C) 2014-2015 Masahiro Yamada <yamada.masahiro@socionext.com>
4 * SPDX-License-Identifier: GPL-2.0+
11 #include <mach/mio-regs.h>
15 DECLARE_GLOBAL_DATA_PTR;
17 #define FDT gd->fdt_blob
18 #define COMPAT "socionext,uniphier-ehci"
20 static int get_uniphier_ehci_base(int index, struct ehci_hccr **base)
24 for (offset = fdt_node_offset_by_compatible(FDT, 0, COMPAT);
26 offset = fdt_node_offset_by_compatible(FDT, offset, COMPAT)) {
28 *base = (struct ehci_hccr *)
29 fdtdec_get_addr(FDT, offset, "reg");
35 return -ENODEV; /* not found */
38 static void uniphier_ehci_reset(int index, int on)
42 tmp = readl(MIO_USB_RSTCTRL(index));
44 tmp &= ~MIO_USB_RSTCTRL_XRST;
46 tmp |= MIO_USB_RSTCTRL_XRST;
47 writel(tmp, MIO_USB_RSTCTRL(index));
50 int ehci_hcd_init(int index, enum usb_init_type init, struct ehci_hccr **hccr,
51 struct ehci_hcor **hcor)
57 uniphier_ehci_reset(index, 0);
59 ret = get_uniphier_ehci_base(index, &cr);
62 or = (void *)cr + HC_LENGTH(ehci_readl(&cr->cr_capbase));
70 int ehci_hcd_stop(int index)
72 uniphier_ehci_reset(index, 1);