2 * UniPhier Specific Glue Layer for DWC3
4 * Copyright (C) 2016-2017 Socionext Inc.
5 * Author: Masahiro Yamada <yamada.masahiro@socionext.com>
7 * SPDX-License-Identifier: GPL-2.0+
11 #include <linux/bitops.h>
12 #include <linux/errno.h>
14 #include <linux/sizes.h>
16 #define UNIPHIER_PRO4_DWC3_RESET 0x40
17 #define UNIPHIER_PRO4_DWC3_RESET_XIOMMU BIT(5)
18 #define UNIPHIER_PRO4_DWC3_RESET_XLINK BIT(4)
19 #define UNIPHIER_PRO4_DWC3_RESET_PHY_SS BIT(2)
21 #define UNIPHIER_PRO5_DWC3_RESET 0x00
22 #define UNIPHIER_PRO5_DWC3_RESET_PHY_S1 BIT(17)
23 #define UNIPHIER_PRO5_DWC3_RESET_PHY_S0 BIT(16)
24 #define UNIPHIER_PRO5_DWC3_RESET_XLINK BIT(15)
25 #define UNIPHIER_PRO5_DWC3_RESET_XIOMMU BIT(14)
27 #define UNIPHIER_PXS2_DWC3_RESET 0x00
28 #define UNIPHIER_PXS2_DWC3_RESET_XLINK BIT(15)
30 static int uniphier_pro4_dwc3_init(void __iomem *regs)
34 tmp = readl(regs + UNIPHIER_PRO4_DWC3_RESET);
35 tmp &= ~UNIPHIER_PRO4_DWC3_RESET_PHY_SS;
36 tmp |= UNIPHIER_PRO4_DWC3_RESET_XIOMMU | UNIPHIER_PRO4_DWC3_RESET_XLINK;
37 writel(tmp, regs + UNIPHIER_PRO4_DWC3_RESET);
42 static int uniphier_pro5_dwc3_init(void __iomem *regs)
46 tmp = readl(regs + UNIPHIER_PRO5_DWC3_RESET);
47 tmp &= ~(UNIPHIER_PRO5_DWC3_RESET_PHY_S1 |
48 UNIPHIER_PRO5_DWC3_RESET_PHY_S0);
49 tmp |= UNIPHIER_PRO5_DWC3_RESET_XLINK | UNIPHIER_PRO5_DWC3_RESET_XIOMMU;
50 writel(tmp, regs + UNIPHIER_PRO5_DWC3_RESET);
55 static int uniphier_pxs2_dwc3_init(void __iomem *regs)
59 tmp = readl(regs + UNIPHIER_PXS2_DWC3_RESET);
60 tmp |= UNIPHIER_PXS2_DWC3_RESET_XLINK;
61 writel(tmp, regs + UNIPHIER_PXS2_DWC3_RESET);
66 static int uniphier_dwc3_probe(struct udevice *dev)
70 int (*init)(void __iomem *regs);
73 base = devfdt_get_addr(dev);
74 if (base == FDT_ADDR_T_NONE)
77 regs = ioremap(base, SZ_32K);
81 init = (typeof(init))dev_get_driver_data(dev);
84 dev_err(dev, "failed to init glue layer\n");
91 static const struct udevice_id uniphier_dwc3_match[] = {
93 .compatible = "socionext,uniphier-pro4-dwc3",
94 .data = (ulong)uniphier_pro4_dwc3_init,
97 .compatible = "socionext,uniphier-pro5-dwc3",
98 .data = (ulong)uniphier_pro5_dwc3_init,
101 .compatible = "socionext,uniphier-pxs2-dwc3",
102 .data = (ulong)uniphier_pxs2_dwc3_init,
105 .compatible = "socionext,uniphier-ld20-dwc3",
106 .data = (ulong)uniphier_pxs2_dwc3_init,
109 .compatible = "socionext,uniphier-pxs3-dwc3",
110 .data = (ulong)uniphier_pxs2_dwc3_init,
115 U_BOOT_DRIVER(usb_xhci) = {
116 .name = "uniphier-dwc3",
117 .id = UCLASS_SIMPLE_BUS,
118 .of_match = uniphier_dwc3_match,
119 .probe = uniphier_dwc3_probe,