2 * Copyright (C) 2014 Panasonic Corporation
3 * Copyright (C) 2015 Socionext Inc.
4 * Author: Masahiro Yamada <yamada.masahiro@socionext.com>
6 * SPDX-License-Identifier: GPL-2.0+
10 #include <linux/err.h>
13 #include <mach/mio-regs.h>
17 DECLARE_GLOBAL_DATA_PTR;
19 #define FDT gd->fdt_blob
20 #define COMPAT "socionext,uniphier-ehci"
22 static int get_uniphier_ehci_base(int index, struct ehci_hccr **base)
26 for (offset = fdt_node_offset_by_compatible(FDT, 0, COMPAT);
28 offset = fdt_node_offset_by_compatible(FDT, offset, COMPAT)) {
30 *base = (struct ehci_hccr *)
31 fdtdec_get_addr(FDT, offset, "reg");
37 return -ENODEV; /* not found */
40 static void uniphier_ehci_reset(int index, int on)
44 tmp = readl(MIO_USB_RSTCTRL(index));
46 tmp &= ~MIO_USB_RSTCTRL_XRST;
48 tmp |= MIO_USB_RSTCTRL_XRST;
49 writel(tmp, MIO_USB_RSTCTRL(index));
52 int ehci_hcd_init(int index, enum usb_init_type init, struct ehci_hccr **hccr,
53 struct ehci_hcor **hcor)
59 uniphier_ehci_reset(index, 0);
61 ret = get_uniphier_ehci_base(index, &cr);
64 or = (void *)cr + HC_LENGTH(ehci_readl(&cr->cr_capbase));
72 int ehci_hcd_stop(int index)
74 uniphier_ehci_reset(index, 1);