diff options
author | Paul Mundt <lethal@linux-sh.org> | 2009-08-19 22:54:38 -0400 |
---|---|---|
committer | Paul Mundt <lethal@linux-sh.org> | 2009-08-19 22:54:38 -0400 |
commit | 65603789db56b915dd5e3ea0501a7773ecf4092d (patch) | |
tree | fbd367199986eb00e82a5c2e24b0e22d616b7690 /arch/sh/boards | |
parent | e638fab91e5d1c4db3a80957546c32ed4bd75086 (diff) | |
parent | f8f8c0797d73624d6e81dbb9c9e8f85005500ebc (diff) |
Merge branch 'sh/r8a66597-udc'
Diffstat (limited to 'arch/sh/boards')
-rw-r--r-- | arch/sh/boards/mach-kfr2r09/setup.c | 103 | ||||
-rw-r--r-- | arch/sh/boards/mach-se/7724/setup.c | 33 |
2 files changed, 136 insertions, 0 deletions
diff --git a/arch/sh/boards/mach-kfr2r09/setup.c b/arch/sh/boards/mach-kfr2r09/setup.c index bdb10c29ef18..1cbd6a3655c3 100644 --- a/arch/sh/boards/mach-kfr2r09/setup.c +++ b/arch/sh/boards/mach-kfr2r09/setup.c | |||
@@ -16,6 +16,8 @@ | |||
16 | #include <linux/clk.h> | 16 | #include <linux/clk.h> |
17 | #include <linux/gpio.h> | 17 | #include <linux/gpio.h> |
18 | #include <linux/input.h> | 18 | #include <linux/input.h> |
19 | #include <linux/i2c.h> | ||
20 | #include <linux/usb/r8a66597.h> | ||
19 | #include <video/sh_mobile_lcdc.h> | 21 | #include <video/sh_mobile_lcdc.h> |
20 | #include <asm/clock.h> | 22 | #include <asm/clock.h> |
21 | #include <asm/machvec.h> | 23 | #include <asm/machvec.h> |
@@ -175,6 +177,35 @@ static struct platform_device kfr2r09_sh_lcdc_device = { | |||
175 | }, | 177 | }, |
176 | }; | 178 | }; |
177 | 179 | ||
180 | static struct r8a66597_platdata kfr2r09_usb0_gadget_data = { | ||
181 | .on_chip = 1, | ||
182 | }; | ||
183 | |||
184 | static struct resource kfr2r09_usb0_gadget_resources[] = { | ||
185 | [0] = { | ||
186 | .start = 0x04d80000, | ||
187 | .end = 0x04d80123, | ||
188 | .flags = IORESOURCE_MEM, | ||
189 | }, | ||
190 | [1] = { | ||
191 | .start = 65, | ||
192 | .end = 65, | ||
193 | .flags = IORESOURCE_IRQ | IRQF_TRIGGER_LOW, | ||
194 | }, | ||
195 | }; | ||
196 | |||
197 | static struct platform_device kfr2r09_usb0_gadget_device = { | ||
198 | .name = "r8a66597_udc", | ||
199 | .id = 0, | ||
200 | .dev = { | ||
201 | .dma_mask = NULL, /* not use dma */ | ||
202 | .coherent_dma_mask = 0xffffffff, | ||
203 | .platform_data = &kfr2r09_usb0_gadget_data, | ||
204 | }, | ||
205 | .num_resources = ARRAY_SIZE(kfr2r09_usb0_gadget_resources), | ||
206 | .resource = kfr2r09_usb0_gadget_resources, | ||
207 | }; | ||
208 | |||
178 | static struct platform_device *kfr2r09_devices[] __initdata = { | 209 | static struct platform_device *kfr2r09_devices[] __initdata = { |
179 | &kfr2r09_nor_flash_device, | 210 | &kfr2r09_nor_flash_device, |
180 | &kfr2r09_nand_flash_device, | 211 | &kfr2r09_nand_flash_device, |
@@ -186,6 +217,74 @@ static struct platform_device *kfr2r09_devices[] __initdata = { | |||
186 | #define BSC_CS0WCR 0xfec10024 | 217 | #define BSC_CS0WCR 0xfec10024 |
187 | #define BSC_CS4BCR 0xfec10010 | 218 | #define BSC_CS4BCR 0xfec10010 |
188 | #define BSC_CS4WCR 0xfec10030 | 219 | #define BSC_CS4WCR 0xfec10030 |
220 | #define PORT_MSELCRB 0xa4050182 | ||
221 | |||
222 | static int kfr2r09_usb0_gadget_i2c_setup(void) | ||
223 | { | ||
224 | struct i2c_adapter *a; | ||
225 | struct i2c_msg msg; | ||
226 | unsigned char buf[2]; | ||
227 | int ret; | ||
228 | |||
229 | a = i2c_get_adapter(0); | ||
230 | if (!a) | ||
231 | return -ENODEV; | ||
232 | |||
233 | /* set bit 1 (the second bit) of chip at 0x09, register 0x13 */ | ||
234 | buf[0] = 0x13; | ||
235 | msg.addr = 0x09; | ||
236 | msg.buf = buf; | ||
237 | msg.len = 1; | ||
238 | msg.flags = 0; | ||
239 | ret = i2c_transfer(a, &msg, 1); | ||
240 | if (ret != 1) | ||
241 | return -ENODEV; | ||
242 | |||
243 | buf[0] = 0; | ||
244 | msg.addr = 0x09; | ||
245 | msg.buf = buf; | ||
246 | msg.len = 1; | ||
247 | msg.flags = I2C_M_RD; | ||
248 | ret = i2c_transfer(a, &msg, 1); | ||
249 | if (ret != 1) | ||
250 | return -ENODEV; | ||
251 | |||
252 | buf[1] = buf[0] | (1 << 1); | ||
253 | buf[0] = 0x13; | ||
254 | msg.addr = 0x09; | ||
255 | msg.buf = buf; | ||
256 | msg.len = 2; | ||
257 | msg.flags = 0; | ||
258 | ret = i2c_transfer(a, &msg, 1); | ||
259 | if (ret != 1) | ||
260 | return -ENODEV; | ||
261 | |||
262 | return 0; | ||
263 | } | ||
264 | |||
265 | static int kfr2r09_usb0_gadget_setup(void) | ||
266 | { | ||
267 | int plugged_in; | ||
268 | |||
269 | gpio_request(GPIO_PTN4, NULL); /* USB_DET */ | ||
270 | gpio_direction_input(GPIO_PTN4); | ||
271 | plugged_in = gpio_get_value(GPIO_PTN4); | ||
272 | if (!plugged_in) | ||
273 | return -ENODEV; /* no cable plugged in */ | ||
274 | |||
275 | if (kfr2r09_usb0_gadget_i2c_setup() != 0) | ||
276 | return -ENODEV; /* unable to configure using i2c */ | ||
277 | |||
278 | ctrl_outw((ctrl_inw(PORT_MSELCRB) & ~0xc000) | 0x8000, PORT_MSELCRB); | ||
279 | gpio_request(GPIO_FN_PDSTATUS, NULL); /* R-standby disables USB clock */ | ||
280 | gpio_request(GPIO_PTV6, NULL); /* USBCLK_ON */ | ||
281 | gpio_direction_output(GPIO_PTV6, 1); /* USBCLK_ON = H */ | ||
282 | msleep(20); /* wait 20ms to let the clock settle */ | ||
283 | clk_enable(clk_get(NULL, "usb0")); | ||
284 | ctrl_outw(0x0600, 0xa40501d4); | ||
285 | |||
286 | return 0; | ||
287 | } | ||
189 | 288 | ||
190 | static int __init kfr2r09_devices_setup(void) | 289 | static int __init kfr2r09_devices_setup(void) |
191 | { | 290 | { |
@@ -245,6 +344,10 @@ static int __init kfr2r09_devices_setup(void) | |||
245 | gpio_request(GPIO_PTU0, NULL); /* LEDSTDBY/ */ | 344 | gpio_request(GPIO_PTU0, NULL); /* LEDSTDBY/ */ |
246 | gpio_direction_output(GPIO_PTU0, 1); | 345 | gpio_direction_output(GPIO_PTU0, 1); |
247 | 346 | ||
347 | /* setup USB function */ | ||
348 | if (kfr2r09_usb0_gadget_setup() == 0) | ||
349 | platform_device_register(&kfr2r09_usb0_gadget_device); | ||
350 | |||
248 | return platform_add_devices(kfr2r09_devices, | 351 | return platform_add_devices(kfr2r09_devices, |
249 | ARRAY_SIZE(kfr2r09_devices)); | 352 | ARRAY_SIZE(kfr2r09_devices)); |
250 | } | 353 | } |
diff --git a/arch/sh/boards/mach-se/7724/setup.c b/arch/sh/boards/mach-se/7724/setup.c index c04e134474d8..e6bd09f2e14a 100644 --- a/arch/sh/boards/mach-se/7724/setup.c +++ b/arch/sh/boards/mach-se/7724/setup.c | |||
@@ -341,6 +341,35 @@ static struct platform_device sh7724_usb0_host_device = { | |||
341 | .resource = sh7724_usb0_host_resources, | 341 | .resource = sh7724_usb0_host_resources, |
342 | }; | 342 | }; |
343 | 343 | ||
344 | static struct r8a66597_platdata sh7724_usb1_gadget_data = { | ||
345 | .on_chip = 1, | ||
346 | }; | ||
347 | |||
348 | static struct resource sh7724_usb1_gadget_resources[] = { | ||
349 | [0] = { | ||
350 | .start = 0xa4d90000, | ||
351 | .end = 0xa4d90123, | ||
352 | .flags = IORESOURCE_MEM, | ||
353 | }, | ||
354 | [1] = { | ||
355 | .start = 66, | ||
356 | .end = 66, | ||
357 | .flags = IORESOURCE_IRQ | IRQF_TRIGGER_LOW, | ||
358 | }, | ||
359 | }; | ||
360 | |||
361 | static struct platform_device sh7724_usb1_gadget_device = { | ||
362 | .name = "r8a66597_udc", | ||
363 | .id = 1, /* USB1 */ | ||
364 | .dev = { | ||
365 | .dma_mask = NULL, /* not use dma */ | ||
366 | .coherent_dma_mask = 0xffffffff, | ||
367 | .platform_data = &sh7724_usb1_gadget_data, | ||
368 | }, | ||
369 | .num_resources = ARRAY_SIZE(sh7724_usb1_gadget_resources), | ||
370 | .resource = sh7724_usb1_gadget_resources, | ||
371 | }; | ||
372 | |||
344 | static struct platform_device *ms7724se_devices[] __initdata = { | 373 | static struct platform_device *ms7724se_devices[] __initdata = { |
345 | &heartbeat_device, | 374 | &heartbeat_device, |
346 | &smc91x_eth_device, | 375 | &smc91x_eth_device, |
@@ -351,6 +380,7 @@ static struct platform_device *ms7724se_devices[] __initdata = { | |||
351 | &keysc_device, | 380 | &keysc_device, |
352 | &sh_eth_device, | 381 | &sh_eth_device, |
353 | &sh7724_usb0_host_device, | 382 | &sh7724_usb0_host_device, |
383 | &sh7724_usb1_gadget_device, | ||
354 | }; | 384 | }; |
355 | 385 | ||
356 | #define EEPROM_OP 0xBA206000 | 386 | #define EEPROM_OP 0xBA206000 |
@@ -459,6 +489,9 @@ static int __init devices_setup(void) | |||
459 | /* enable USB0 port */ | 489 | /* enable USB0 port */ |
460 | ctrl_outw(0x0600, 0xa40501d4); | 490 | ctrl_outw(0x0600, 0xa40501d4); |
461 | 491 | ||
492 | /* enable USB1 port */ | ||
493 | ctrl_outw(0x0600, 0xa4050192); | ||
494 | |||
462 | /* enable IRQ 0,1,2 */ | 495 | /* enable IRQ 0,1,2 */ |
463 | gpio_request(GPIO_FN_INTC_IRQ0, NULL); | 496 | gpio_request(GPIO_FN_INTC_IRQ0, NULL); |
464 | gpio_request(GPIO_FN_INTC_IRQ1, NULL); | 497 | gpio_request(GPIO_FN_INTC_IRQ1, NULL); |