Commit | Line | Data |
---|---|---|
b2441318 | 1 | // SPDX-License-Identifier: GPL-2.0 |
86cad160 DL |
2 | /* |
3 | * DA8xx USB | |
4 | */ | |
5411bad4 | 5 | #include <linux/clk-provider.h> |
0004b02a | 6 | #include <linux/delay.h> |
86cad160 DL |
7 | #include <linux/dma-mapping.h> |
8 | #include <linux/init.h> | |
0004b02a | 9 | #include <linux/mfd/da8xx-cfgchip.h> |
5411bad4 | 10 | #include <linux/mfd/syscon.h> |
9b504750 | 11 | #include <linux/phy/phy.h> |
5411bad4 | 12 | #include <linux/platform_data/clk-da8xx-cfgchip.h> |
bdec5a6b | 13 | #include <linux/platform_data/phy-da8xx-usb.h> |
86cad160 DL |
14 | #include <linux/platform_data/usb-davinci.h> |
15 | #include <linux/platform_device.h> | |
16 | #include <linux/usb/musb.h> | |
17 | ||
18 | #include <mach/common.h> | |
19 | #include <mach/cputype.h> | |
20 | #include <mach/da8xx.h> | |
544ca0b0 BG |
21 | |
22 | #include "irqs.h" | |
86cad160 DL |
23 | |
24 | #define DA8XX_USB0_BASE 0x01e00000 | |
25 | #define DA8XX_USB1_BASE 0x01e25000 | |
26 | ||
5411bad4 | 27 | #ifndef CONFIG_COMMON_CLK |
d1df1e01 | 28 | static struct clk *usb20_clk; |
5411bad4 | 29 | #endif |
d1df1e01 | 30 | |
3424a516 DL |
31 | static struct da8xx_usb_phy_platform_data da8xx_usb_phy_pdata; |
32 | ||
9b504750 DL |
33 | static struct platform_device da8xx_usb_phy = { |
34 | .name = "da8xx-usb-phy", | |
35 | .id = -1, | |
0004b02a DL |
36 | .dev = { |
37 | /* | |
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. | |
41 | */ | |
42 | .init_name = "da8xx-usb-phy", | |
3424a516 | 43 | .platform_data = &da8xx_usb_phy_pdata, |
0004b02a | 44 | }, |
9b504750 DL |
45 | }; |
46 | ||
47 | int __init da8xx_register_usb_phy(void) | |
48 | { | |
3424a516 | 49 | da8xx_usb_phy_pdata.cfgchip = da8xx_get_cfgchip(); |
bdec5a6b | 50 | |
9b504750 DL |
51 | return platform_device_register(&da8xx_usb_phy); |
52 | } | |
53 | ||
86cad160 DL |
54 | static struct musb_hdrc_config musb_config = { |
55 | .multipoint = true, | |
56 | .num_eps = 5, | |
57 | .ram_bits = 10, | |
58 | }; | |
59 | ||
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, | |
65 | }; | |
66 | ||
67 | static struct resource da8xx_usb20_resources[] = { | |
68 | { | |
69 | .start = DA8XX_USB0_BASE, | |
70 | .end = DA8XX_USB0_BASE + SZ_64K - 1, | |
71 | .flags = IORESOURCE_MEM, | |
72 | }, | |
73 | { | |
a98ca73e | 74 | .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_USB_INT), |
86cad160 DL |
75 | .flags = IORESOURCE_IRQ, |
76 | .name = "mc", | |
77 | }, | |
78 | }; | |
79 | ||
80 | static u64 usb_dmamask = DMA_BIT_MASK(32); | |
81 | ||
0004b02a | 82 | static struct platform_device da8xx_usb20_dev = { |
86cad160 DL |
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), | |
89 | }, | |
90 | .resource = da8xx_usb20_resources, | |
91 | .num_resources = ARRAY_SIZE(da8xx_usb20_resources), | |
92 | }; | |
93 | ||
94 | int __init da8xx_register_usb20(unsigned int mA, unsigned int potpgt) | |
95 | { | |
96 | usb_data.power = mA > 510 ? 255 : mA / 2; | |
97 | usb_data.potpgt = (potpgt + 1) / 2; | |
98 | ||
0004b02a | 99 | return platform_device_register(&da8xx_usb20_dev); |
86cad160 DL |
100 | } |
101 | ||
86cad160 DL |
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, | |
107 | }, | |
108 | [1] = { | |
a98ca73e BG |
109 | .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_IRQN), |
110 | .end = DAVINCI_INTC_IRQ(IRQ_DA8XX_IRQN), | |
86cad160 DL |
111 | .flags = IORESOURCE_IRQ, |
112 | }, | |
113 | }; | |
114 | ||
115 | static u64 da8xx_usb11_dma_mask = DMA_BIT_MASK(32); | |
116 | ||
117 | static struct platform_device da8xx_usb11_device = { | |
8439a1d7 AH |
118 | .name = "ohci-da8xx", |
119 | .id = -1, | |
86cad160 DL |
120 | .dev = { |
121 | .dma_mask = &da8xx_usb11_dma_mask, | |
122 | .coherent_dma_mask = DMA_BIT_MASK(32), | |
123 | }, | |
124 | .num_resources = ARRAY_SIZE(da8xx_usb11_resources), | |
125 | .resource = da8xx_usb11_resources, | |
126 | }; | |
127 | ||
128 | int __init da8xx_register_usb11(struct da8xx_ohci_root_hub *pdata) | |
129 | { | |
130 | da8xx_usb11_device.dev.platform_data = pdata; | |
131 | return platform_device_register(&da8xx_usb11_device); | |
132 | } | |
0004b02a | 133 | |
5411bad4 DL |
134 | static struct platform_device da8xx_usb_phy_clks_device = { |
135 | .name = "da830-usb-phy-clks", | |
136 | .id = -1, | |
137 | }; | |
138 | ||
139 | int __init da8xx_register_usb_phy_clocks(void) | |
140 | { | |
141 | struct da8xx_cfgchip_clk_platform_data pdata; | |
142 | ||
143 | pdata.cfgchip = da8xx_get_cfgchip(); | |
144 | da8xx_usb_phy_clks_device.dev.platform_data = &pdata; | |
145 | ||
146 | return platform_device_register(&da8xx_usb_phy_clks_device); | |
147 | } |