Linux 5.6.13
[linux/fpc-iii.git] / arch / arm / mach-davinci / usb-da8xx.c
blob25f21ee86f1ab7a709bb5258fd598d91127f3bcd
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3 * DA8xx USB
4 */
5 #include <linux/clk-provider.h>
6 #include <linux/delay.h>
7 #include <linux/dma-mapping.h>
8 #include <linux/init.h>
9 #include <linux/mfd/da8xx-cfgchip.h>
10 #include <linux/mfd/syscon.h>
11 #include <linux/phy/phy.h>
12 #include <linux/platform_data/clk-da8xx-cfgchip.h>
13 #include <linux/platform_data/phy-da8xx-usb.h>
14 #include <linux/platform_data/usb-davinci.h>
15 #include <linux/platform_device.h>
16 #include <linux/usb/musb.h>
18 #include <mach/common.h>
19 #include <mach/cputype.h>
20 #include <mach/da8xx.h>
22 #include "irqs.h"
24 #define DA8XX_USB0_BASE 0x01e00000
25 #define DA8XX_USB1_BASE 0x01e25000
27 #ifndef CONFIG_COMMON_CLK
28 static struct clk *usb20_clk;
29 #endif
31 static struct da8xx_usb_phy_platform_data da8xx_usb_phy_pdata;
33 static struct platform_device da8xx_usb_phy = {
34 .name = "da8xx-usb-phy",
35 .id = -1,
36 .dev = {
38 * Setting init_name so that clock lookup will work in
39 * da8xx_register_usb11_phy_clk() even if this device is not
40 * registered yet.
42 .init_name = "da8xx-usb-phy",
43 .platform_data = &da8xx_usb_phy_pdata,
47 int __init da8xx_register_usb_phy(void)
49 da8xx_usb_phy_pdata.cfgchip = da8xx_get_cfgchip();
51 return platform_device_register(&da8xx_usb_phy);
54 static struct musb_hdrc_config musb_config = {
55 .multipoint = true,
56 .num_eps = 5,
57 .ram_bits = 10,
60 static struct musb_hdrc_platform_data usb_data = {
61 /* OTG requires a Mini-AB connector */
62 .mode = MUSB_OTG,
63 .clock = "usb20",
64 .config = &musb_config,
67 static struct resource da8xx_usb20_resources[] = {
69 .start = DA8XX_USB0_BASE,
70 .end = DA8XX_USB0_BASE + SZ_64K - 1,
71 .flags = IORESOURCE_MEM,
74 .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_USB_INT),
75 .flags = IORESOURCE_IRQ,
76 .name = "mc",
80 static u64 usb_dmamask = DMA_BIT_MASK(32);
82 static struct platform_device da8xx_usb20_dev = {
83 .name = "musb-da8xx",
84 .id = -1,
85 .dev = {
86 .platform_data = &usb_data,
87 .dma_mask = &usb_dmamask,
88 .coherent_dma_mask = DMA_BIT_MASK(32),
90 .resource = da8xx_usb20_resources,
91 .num_resources = ARRAY_SIZE(da8xx_usb20_resources),
94 int __init da8xx_register_usb20(unsigned int mA, unsigned int potpgt)
96 usb_data.power = mA > 510 ? 255 : mA / 2;
97 usb_data.potpgt = (potpgt + 1) / 2;
99 return platform_device_register(&da8xx_usb20_dev);
102 static struct resource da8xx_usb11_resources[] = {
103 [0] = {
104 .start = DA8XX_USB1_BASE,
105 .end = DA8XX_USB1_BASE + SZ_4K - 1,
106 .flags = IORESOURCE_MEM,
108 [1] = {
109 .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_IRQN),
110 .end = DAVINCI_INTC_IRQ(IRQ_DA8XX_IRQN),
111 .flags = IORESOURCE_IRQ,
115 static u64 da8xx_usb11_dma_mask = DMA_BIT_MASK(32);
117 static struct platform_device da8xx_usb11_device = {
118 .name = "ohci-da8xx",
119 .id = -1,
120 .dev = {
121 .dma_mask = &da8xx_usb11_dma_mask,
122 .coherent_dma_mask = DMA_BIT_MASK(32),
124 .num_resources = ARRAY_SIZE(da8xx_usb11_resources),
125 .resource = da8xx_usb11_resources,
128 int __init da8xx_register_usb11(struct da8xx_ohci_root_hub *pdata)
130 da8xx_usb11_device.dev.platform_data = pdata;
131 return platform_device_register(&da8xx_usb11_device);
134 static struct platform_device da8xx_usb_phy_clks_device = {
135 .name = "da830-usb-phy-clks",
136 .id = -1,
139 int __init da8xx_register_usb_phy_clocks(void)
141 struct da8xx_cfgchip_clk_platform_data pdata;
143 pdata.cfgchip = da8xx_get_cfgchip();
144 da8xx_usb_phy_clks_device.dev.platform_data = &pdata;
146 return platform_device_register(&da8xx_usb_phy_clks_device);