2 * Copyright (C) 2015 Panasonic Corporation
3 * Author: Masahiro Yamada <yamada.m@jp.panasonic.com>
5 * SPDX-License-Identifier: GPL-2.0+
14 static int get_uniphier_xhci_base(int index, struct xhci_hccr **base)
16 DECLARE_GLOBAL_DATA_PTR;
21 count = fdtdec_find_aliases_for_id(gd->fdt_blob, "usb",
22 COMPAT_PANASONIC_XHCI, node_list,
23 ARRAY_SIZE(node_list));
28 addr = fdtdec_get_addr(gd->fdt_blob, node_list[index], "reg");
29 if (addr == FDT_ADDR_T_NONE)
32 *base = (struct xhci_hccr *)addr;
37 #define USB3_RST_CTRL 0x00100040
38 #define IOMMU_RST_N (1 << 5)
39 #define LINK_RST_N (1 << 4)
41 static void uniphier_xhci_reset(void __iomem *base, int on)
45 tmp = readl(base + USB3_RST_CTRL);
48 tmp &= ~(IOMMU_RST_N | LINK_RST_N);
50 tmp |= IOMMU_RST_N | LINK_RST_N;
52 writel(tmp, base + USB3_RST_CTRL);
55 int xhci_hcd_init(int index, struct xhci_hccr **hccr, struct xhci_hcor **hcor)
61 ret = get_uniphier_xhci_base(index, &cr);
65 uniphier_xhci_reset(cr, 0);
67 or = (void *)cr + HC_LENGTH(xhci_readl(&cr->cr_capbase));
75 void xhci_hcd_stop(int index)
80 ret = get_uniphier_xhci_base(index, &cr);
84 uniphier_xhci_reset(cr, 1);