2 * Copyright (C) 2015 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>
15 static int get_uniphier_xhci_base(int index, struct xhci_hccr **base)
17 DECLARE_GLOBAL_DATA_PTR;
22 count = fdtdec_find_aliases_for_id(gd->fdt_blob, "usb",
23 COMPAT_SOCIONEXT_XHCI, node_list,
24 ARRAY_SIZE(node_list));
29 addr = fdtdec_get_addr(gd->fdt_blob, node_list[index], "reg");
30 if (addr == FDT_ADDR_T_NONE)
33 *base = (struct xhci_hccr *)addr;
38 #define USB3_RST_CTRL 0x00100040
39 #define IOMMU_RST_N (1 << 5)
40 #define LINK_RST_N (1 << 4)
42 static void uniphier_xhci_reset(void __iomem *base, int on)
46 tmp = readl(base + USB3_RST_CTRL);
49 tmp &= ~(IOMMU_RST_N | LINK_RST_N);
51 tmp |= IOMMU_RST_N | LINK_RST_N;
53 writel(tmp, base + USB3_RST_CTRL);
56 int xhci_hcd_init(int index, struct xhci_hccr **hccr, struct xhci_hcor **hcor)
62 ret = get_uniphier_xhci_base(index, &cr);
66 uniphier_xhci_reset(cr, 0);
68 or = (void *)cr + HC_LENGTH(xhci_readl(&cr->cr_capbase));
76 void xhci_hcd_stop(int index)
81 ret = get_uniphier_xhci_base(index, &cr);
85 uniphier_xhci_reset(cr, 1);