diff options
Diffstat (limited to 'arch/arm/mach-shmobile/setup-r8a7778.c')
-rw-r--r-- | arch/arm/mach-shmobile/setup-r8a7778.c | 262 |
1 files changed, 251 insertions, 11 deletions
diff --git a/arch/arm/mach-shmobile/setup-r8a7778.c b/arch/arm/mach-shmobile/setup-r8a7778.c index 30b4a336308f..80c20392ad7c 100644 --- a/arch/arm/mach-shmobile/setup-r8a7778.c +++ b/arch/arm/mach-shmobile/setup-r8a7778.c | |||
@@ -24,11 +24,18 @@ | |||
24 | #include <linux/irqchip/arm-gic.h> | 24 | #include <linux/irqchip/arm-gic.h> |
25 | #include <linux/of.h> | 25 | #include <linux/of.h> |
26 | #include <linux/of_platform.h> | 26 | #include <linux/of_platform.h> |
27 | #include <linux/platform_data/gpio-rcar.h> | ||
27 | #include <linux/platform_data/irq-renesas-intc-irqpin.h> | 28 | #include <linux/platform_data/irq-renesas-intc-irqpin.h> |
28 | #include <linux/platform_device.h> | 29 | #include <linux/platform_device.h> |
29 | #include <linux/irqchip.h> | 30 | #include <linux/irqchip.h> |
30 | #include <linux/serial_sci.h> | 31 | #include <linux/serial_sci.h> |
31 | #include <linux/sh_timer.h> | 32 | #include <linux/sh_timer.h> |
33 | #include <linux/pm_runtime.h> | ||
34 | #include <linux/usb/phy.h> | ||
35 | #include <linux/usb/hcd.h> | ||
36 | #include <linux/usb/ehci_pdriver.h> | ||
37 | #include <linux/usb/ohci_pdriver.h> | ||
38 | #include <linux/dma-mapping.h> | ||
32 | #include <mach/irqs.h> | 39 | #include <mach/irqs.h> |
33 | #include <mach/r8a7778.h> | 40 | #include <mach/r8a7778.h> |
34 | #include <mach/common.h> | 41 | #include <mach/common.h> |
@@ -80,12 +87,6 @@ static struct sh_timer_config sh_tmu1_platform_data = { | |||
80 | .clocksource_rating = 200, | 87 | .clocksource_rating = 200, |
81 | }; | 88 | }; |
82 | 89 | ||
83 | /* Ether */ | ||
84 | static struct resource ether_resources[] = { | ||
85 | DEFINE_RES_MEM(0xfde00000, 0x400), | ||
86 | DEFINE_RES_IRQ(gic_iid(0x89)), | ||
87 | }; | ||
88 | |||
89 | #define r8a7778_register_tmu(idx) \ | 90 | #define r8a7778_register_tmu(idx) \ |
90 | platform_device_register_resndata( \ | 91 | platform_device_register_resndata( \ |
91 | &platform_bus, "sh_tmu", idx, \ | 92 | &platform_bus, "sh_tmu", idx, \ |
@@ -94,6 +95,244 @@ static struct resource ether_resources[] = { | |||
94 | &sh_tmu##idx##_platform_data, \ | 95 | &sh_tmu##idx##_platform_data, \ |
95 | sizeof(sh_tmu##idx##_platform_data)) | 96 | sizeof(sh_tmu##idx##_platform_data)) |
96 | 97 | ||
98 | /* USB PHY */ | ||
99 | static struct resource usb_phy_resources[] __initdata = { | ||
100 | DEFINE_RES_MEM(0xffe70800, 0x100), | ||
101 | DEFINE_RES_MEM(0xffe76000, 0x100), | ||
102 | }; | ||
103 | |||
104 | void __init r8a7778_add_usb_phy_device(struct rcar_phy_platform_data *pdata) | ||
105 | { | ||
106 | platform_device_register_resndata(&platform_bus, "rcar_usb_phy", -1, | ||
107 | usb_phy_resources, | ||
108 | ARRAY_SIZE(usb_phy_resources), | ||
109 | pdata, sizeof(*pdata)); | ||
110 | } | ||
111 | |||
112 | /* USB */ | ||
113 | static struct usb_phy *phy; | ||
114 | |||
115 | static int usb_power_on(struct platform_device *pdev) | ||
116 | { | ||
117 | if (IS_ERR(phy)) | ||
118 | return PTR_ERR(phy); | ||
119 | |||
120 | pm_runtime_enable(&pdev->dev); | ||
121 | pm_runtime_get_sync(&pdev->dev); | ||
122 | |||
123 | usb_phy_init(phy); | ||
124 | |||
125 | return 0; | ||
126 | } | ||
127 | |||
128 | static void usb_power_off(struct platform_device *pdev) | ||
129 | { | ||
130 | if (IS_ERR(phy)) | ||
131 | return; | ||
132 | |||
133 | usb_phy_shutdown(phy); | ||
134 | |||
135 | pm_runtime_put_sync(&pdev->dev); | ||
136 | pm_runtime_disable(&pdev->dev); | ||
137 | } | ||
138 | |||
139 | static int ehci_init_internal_buffer(struct usb_hcd *hcd) | ||
140 | { | ||
141 | /* | ||
142 | * Below are recommended values from the datasheet; | ||
143 | * see [USB :: Setting of EHCI Internal Buffer]. | ||
144 | */ | ||
145 | /* EHCI IP internal buffer setting */ | ||
146 | iowrite32(0x00ff0040, hcd->regs + 0x0094); | ||
147 | /* EHCI IP internal buffer enable */ | ||
148 | iowrite32(0x00000001, hcd->regs + 0x009C); | ||
149 | |||
150 | return 0; | ||
151 | } | ||
152 | |||
153 | static struct usb_ehci_pdata ehci_pdata __initdata = { | ||
154 | .power_on = usb_power_on, | ||
155 | .power_off = usb_power_off, | ||
156 | .power_suspend = usb_power_off, | ||
157 | .pre_setup = ehci_init_internal_buffer, | ||
158 | }; | ||
159 | |||
160 | static struct resource ehci_resources[] __initdata = { | ||
161 | DEFINE_RES_MEM(0xffe70000, 0x400), | ||
162 | DEFINE_RES_IRQ(gic_iid(0x4c)), | ||
163 | }; | ||
164 | |||
165 | static struct usb_ohci_pdata ohci_pdata __initdata = { | ||
166 | .power_on = usb_power_on, | ||
167 | .power_off = usb_power_off, | ||
168 | .power_suspend = usb_power_off, | ||
169 | }; | ||
170 | |||
171 | static struct resource ohci_resources[] __initdata = { | ||
172 | DEFINE_RES_MEM(0xffe70400, 0x400), | ||
173 | DEFINE_RES_IRQ(gic_iid(0x4c)), | ||
174 | }; | ||
175 | |||
176 | #define USB_PLATFORM_INFO(hci) \ | ||
177 | static struct platform_device_info hci##_info __initdata = { \ | ||
178 | .parent = &platform_bus, \ | ||
179 | .name = #hci "-platform", \ | ||
180 | .id = -1, \ | ||
181 | .res = hci##_resources, \ | ||
182 | .num_res = ARRAY_SIZE(hci##_resources), \ | ||
183 | .data = &hci##_pdata, \ | ||
184 | .size_data = sizeof(hci##_pdata), \ | ||
185 | .dma_mask = DMA_BIT_MASK(32), \ | ||
186 | } | ||
187 | |||
188 | USB_PLATFORM_INFO(ehci); | ||
189 | USB_PLATFORM_INFO(ohci); | ||
190 | |||
191 | /* Ether */ | ||
192 | static struct resource ether_resources[] = { | ||
193 | DEFINE_RES_MEM(0xfde00000, 0x400), | ||
194 | DEFINE_RES_IRQ(gic_iid(0x89)), | ||
195 | }; | ||
196 | |||
197 | void __init r8a7778_add_ether_device(struct sh_eth_plat_data *pdata) | ||
198 | { | ||
199 | platform_device_register_resndata(&platform_bus, "r8a777x-ether", -1, | ||
200 | ether_resources, | ||
201 | ARRAY_SIZE(ether_resources), | ||
202 | pdata, sizeof(*pdata)); | ||
203 | } | ||
204 | |||
205 | /* PFC/GPIO */ | ||
206 | static struct resource pfc_resources[] = { | ||
207 | DEFINE_RES_MEM(0xfffc0000, 0x118), | ||
208 | }; | ||
209 | |||
210 | #define R8A7778_GPIO(idx) \ | ||
211 | static struct resource r8a7778_gpio##idx##_resources[] = { \ | ||
212 | DEFINE_RES_MEM(0xffc40000 + 0x1000 * (idx), 0x30), \ | ||
213 | DEFINE_RES_IRQ(gic_iid(0x87)), \ | ||
214 | }; \ | ||
215 | \ | ||
216 | static struct gpio_rcar_config r8a7778_gpio##idx##_platform_data = { \ | ||
217 | .gpio_base = 32 * (idx), \ | ||
218 | .irq_base = GPIO_IRQ_BASE(idx), \ | ||
219 | .number_of_pins = 32, \ | ||
220 | .pctl_name = "pfc-r8a7778", \ | ||
221 | } | ||
222 | |||
223 | R8A7778_GPIO(0); | ||
224 | R8A7778_GPIO(1); | ||
225 | R8A7778_GPIO(2); | ||
226 | R8A7778_GPIO(3); | ||
227 | R8A7778_GPIO(4); | ||
228 | |||
229 | #define r8a7778_register_gpio(idx) \ | ||
230 | platform_device_register_resndata( \ | ||
231 | &platform_bus, "gpio_rcar", idx, \ | ||
232 | r8a7778_gpio##idx##_resources, \ | ||
233 | ARRAY_SIZE(r8a7778_gpio##idx##_resources), \ | ||
234 | &r8a7778_gpio##idx##_platform_data, \ | ||
235 | sizeof(r8a7778_gpio##idx##_platform_data)) | ||
236 | |||
237 | void __init r8a7778_pinmux_init(void) | ||
238 | { | ||
239 | platform_device_register_simple( | ||
240 | "pfc-r8a7778", -1, | ||
241 | pfc_resources, | ||
242 | ARRAY_SIZE(pfc_resources)); | ||
243 | |||
244 | r8a7778_register_gpio(0); | ||
245 | r8a7778_register_gpio(1); | ||
246 | r8a7778_register_gpio(2); | ||
247 | r8a7778_register_gpio(3); | ||
248 | r8a7778_register_gpio(4); | ||
249 | }; | ||
250 | |||
251 | /* SDHI */ | ||
252 | static struct resource sdhi_resources[] = { | ||
253 | /* SDHI0 */ | ||
254 | DEFINE_RES_MEM(0xFFE4C000, 0x100), | ||
255 | DEFINE_RES_IRQ(gic_iid(0x77)), | ||
256 | /* SDHI1 */ | ||
257 | DEFINE_RES_MEM(0xFFE4D000, 0x100), | ||
258 | DEFINE_RES_IRQ(gic_iid(0x78)), | ||
259 | /* SDHI2 */ | ||
260 | DEFINE_RES_MEM(0xFFE4F000, 0x100), | ||
261 | DEFINE_RES_IRQ(gic_iid(0x76)), | ||
262 | }; | ||
263 | |||
264 | void __init r8a7778_sdhi_init(int id, | ||
265 | struct sh_mobile_sdhi_info *info) | ||
266 | { | ||
267 | BUG_ON(id < 0 || id > 2); | ||
268 | |||
269 | platform_device_register_resndata( | ||
270 | &platform_bus, "sh_mobile_sdhi", id, | ||
271 | sdhi_resources + (2 * id), 2, | ||
272 | info, sizeof(*info)); | ||
273 | } | ||
274 | |||
275 | /* I2C */ | ||
276 | static struct resource i2c_resources[] __initdata = { | ||
277 | /* I2C0 */ | ||
278 | DEFINE_RES_MEM(0xffc70000, 0x1000), | ||
279 | DEFINE_RES_IRQ(gic_iid(0x63)), | ||
280 | /* I2C1 */ | ||
281 | DEFINE_RES_MEM(0xffc71000, 0x1000), | ||
282 | DEFINE_RES_IRQ(gic_iid(0x6e)), | ||
283 | /* I2C2 */ | ||
284 | DEFINE_RES_MEM(0xffc72000, 0x1000), | ||
285 | DEFINE_RES_IRQ(gic_iid(0x6c)), | ||
286 | /* I2C3 */ | ||
287 | DEFINE_RES_MEM(0xffc73000, 0x1000), | ||
288 | DEFINE_RES_IRQ(gic_iid(0x6d)), | ||
289 | }; | ||
290 | |||
291 | void __init r8a7778_add_i2c_device(int id) | ||
292 | { | ||
293 | BUG_ON(id < 0 || id > 3); | ||
294 | |||
295 | platform_device_register_simple( | ||
296 | "i2c-rcar", id, | ||
297 | i2c_resources + (2 * id), 2); | ||
298 | } | ||
299 | |||
300 | /* HSPI */ | ||
301 | static struct resource hspi_resources[] __initdata = { | ||
302 | /* HSPI0 */ | ||
303 | DEFINE_RES_MEM(0xfffc7000, 0x18), | ||
304 | DEFINE_RES_IRQ(gic_iid(0x5f)), | ||
305 | /* HSPI1 */ | ||
306 | DEFINE_RES_MEM(0xfffc8000, 0x18), | ||
307 | DEFINE_RES_IRQ(gic_iid(0x74)), | ||
308 | /* HSPI2 */ | ||
309 | DEFINE_RES_MEM(0xfffc6000, 0x18), | ||
310 | DEFINE_RES_IRQ(gic_iid(0x75)), | ||
311 | }; | ||
312 | |||
313 | void __init r8a7778_add_hspi_device(int id) | ||
314 | { | ||
315 | BUG_ON(id < 0 || id > 2); | ||
316 | |||
317 | platform_device_register_simple( | ||
318 | "sh-hspi", id, | ||
319 | hspi_resources + (2 * id), 2); | ||
320 | } | ||
321 | |||
322 | /* MMC */ | ||
323 | static struct resource mmc_resources[] __initdata = { | ||
324 | DEFINE_RES_MEM(0xffe4e000, 0x100), | ||
325 | DEFINE_RES_IRQ(gic_iid(0x5d)), | ||
326 | }; | ||
327 | |||
328 | void __init r8a7778_add_mmc_device(struct sh_mmcif_plat_data *info) | ||
329 | { | ||
330 | platform_device_register_resndata( | ||
331 | &platform_bus, "sh_mmcif", -1, | ||
332 | mmc_resources, ARRAY_SIZE(mmc_resources), | ||
333 | info, sizeof(*info)); | ||
334 | } | ||
335 | |||
97 | void __init r8a7778_add_standard_devices(void) | 336 | void __init r8a7778_add_standard_devices(void) |
98 | { | 337 | { |
99 | int i; | 338 | int i; |
@@ -118,12 +357,12 @@ void __init r8a7778_add_standard_devices(void) | |||
118 | r8a7778_register_tmu(1); | 357 | r8a7778_register_tmu(1); |
119 | } | 358 | } |
120 | 359 | ||
121 | void __init r8a7778_add_ether_device(struct sh_eth_plat_data *pdata) | 360 | void __init r8a7778_init_late(void) |
122 | { | 361 | { |
123 | platform_device_register_resndata(&platform_bus, "sh_eth", -1, | 362 | phy = usb_get_phy(USB_PHY_TYPE_USB2); |
124 | ether_resources, | 363 | |
125 | ARRAY_SIZE(ether_resources), | 364 | platform_device_register_full(&ehci_info); |
126 | pdata, sizeof(*pdata)); | 365 | platform_device_register_full(&ohci_info); |
127 | } | 366 | } |
128 | 367 | ||
129 | static struct renesas_intc_irqpin_config irqpin_platform_data = { | 368 | static struct renesas_intc_irqpin_config irqpin_platform_data = { |
@@ -239,6 +478,7 @@ DT_MACHINE_START(R8A7778_DT, "Generic R8A7778 (Flattened Device Tree)") | |||
239 | .init_machine = r8a7778_add_standard_devices_dt, | 478 | .init_machine = r8a7778_add_standard_devices_dt, |
240 | .init_time = shmobile_timer_init, | 479 | .init_time = shmobile_timer_init, |
241 | .dt_compat = r8a7778_compat_dt, | 480 | .dt_compat = r8a7778_compat_dt, |
481 | .init_late = r8a7778_init_late, | ||
242 | MACHINE_END | 482 | MACHINE_END |
243 | 483 | ||
244 | #endif /* CONFIG_USE_OF */ | 484 | #endif /* CONFIG_USE_OF */ |