Add linux-next specific files for 20110831
[linux-2.6/next.git] / arch / blackfin / mach-bf561 / boards / ezkit.c
blob27f22ed381d99767b0bda919964fed021f7d3cb5
1 /*
2 * Copyright 2004-2009 Analog Devices Inc.
3 * 2005 National ICT Australia (NICTA)
4 * Aidan Williams <aidan@nicta.com.au>
6 * Licensed under the GPL-2 or later.
7 */
9 #include <linux/device.h>
10 #include <linux/platform_device.h>
11 #include <linux/mtd/mtd.h>
12 #include <linux/mtd/partitions.h>
13 #include <linux/mtd/physmap.h>
14 #include <linux/spi/spi.h>
15 #include <linux/irq.h>
16 #include <linux/interrupt.h>
17 #include <linux/delay.h>
18 #include <asm/dma.h>
19 #include <asm/bfin5xx_spi.h>
20 #include <asm/portmux.h>
21 #include <asm/dpmc.h>
24 * Name the Board for the /proc/cpuinfo
26 const char bfin_board_name[] = "ADI BF561-EZKIT";
28 #if defined(CONFIG_USB_ISP1760_HCD) || defined(CONFIG_USB_ISP1760_HCD_MODULE)
29 #include <linux/usb/isp1760.h>
30 static struct resource bfin_isp1760_resources[] = {
31 [0] = {
32 .start = 0x2C0F0000,
33 .end = 0x203C0000 + 0xfffff,
34 .flags = IORESOURCE_MEM,
36 [1] = {
37 .start = IRQ_PF10,
38 .end = IRQ_PF10,
39 .flags = IORESOURCE_IRQ,
43 static struct isp1760_platform_data isp1760_priv = {
44 .is_isp1761 = 0,
45 .bus_width_16 = 1,
46 .port1_otg = 0,
47 .analog_oc = 0,
48 .dack_polarity_high = 0,
49 .dreq_polarity_high = 0,
52 static struct platform_device bfin_isp1760_device = {
53 .name = "isp1760",
54 .id = 0,
55 .dev = {
56 .platform_data = &isp1760_priv,
58 .num_resources = ARRAY_SIZE(bfin_isp1760_resources),
59 .resource = bfin_isp1760_resources,
61 #endif
63 #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
64 #include <linux/usb/isp1362.h>
66 static struct resource isp1362_hcd_resources[] = {
68 .start = 0x2c060000,
69 .end = 0x2c060000,
70 .flags = IORESOURCE_MEM,
71 }, {
72 .start = 0x2c060004,
73 .end = 0x2c060004,
74 .flags = IORESOURCE_MEM,
75 }, {
76 .start = IRQ_PF8,
77 .end = IRQ_PF8,
78 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWEDGE,
82 static struct isp1362_platform_data isp1362_priv = {
83 .sel15Kres = 1,
84 .clknotstop = 0,
85 .oc_enable = 0,
86 .int_act_high = 0,
87 .int_edge_triggered = 0,
88 .remote_wakeup_connected = 0,
89 .no_power_switching = 1,
90 .power_switching_mode = 0,
93 static struct platform_device isp1362_hcd_device = {
94 .name = "isp1362-hcd",
95 .id = 0,
96 .dev = {
97 .platform_data = &isp1362_priv,
99 .num_resources = ARRAY_SIZE(isp1362_hcd_resources),
100 .resource = isp1362_hcd_resources,
102 #endif
104 #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
105 static struct resource net2272_bfin_resources[] = {
107 .start = 0x2C000000,
108 .end = 0x2C000000 + 0x7F,
109 .flags = IORESOURCE_MEM,
110 }, {
111 .start = 1,
112 .flags = IORESOURCE_BUS,
113 }, {
114 .start = IRQ_PF10,
115 .end = IRQ_PF10,
116 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
120 static struct platform_device net2272_bfin_device = {
121 .name = "net2272",
122 .id = -1,
123 .num_resources = ARRAY_SIZE(net2272_bfin_resources),
124 .resource = net2272_bfin_resources,
126 #endif
129 * USB-LAN EzExtender board
130 * Driver needs to know address, irq and flag pin.
132 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
133 #include <linux/smc91x.h>
135 static struct smc91x_platdata smc91x_info = {
136 .flags = SMC91X_USE_32BIT | SMC91X_NOWAIT,
137 .leda = RPC_LED_100_10,
138 .ledb = RPC_LED_TX_RX,
141 static struct resource smc91x_resources[] = {
143 .name = "smc91x-regs",
144 .start = 0x2C010300,
145 .end = 0x2C010300 + 16,
146 .flags = IORESOURCE_MEM,
147 }, {
149 .start = IRQ_PF9,
150 .end = IRQ_PF9,
151 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
155 static struct platform_device smc91x_device = {
156 .name = "smc91x",
157 .id = 0,
158 .num_resources = ARRAY_SIZE(smc91x_resources),
159 .resource = smc91x_resources,
160 .dev = {
161 .platform_data = &smc91x_info,
164 #endif
166 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
167 #ifdef CONFIG_SERIAL_BFIN_UART0
168 static struct resource bfin_uart0_resources[] = {
170 .start = BFIN_UART_THR,
171 .end = BFIN_UART_GCTL+2,
172 .flags = IORESOURCE_MEM,
175 .start = IRQ_UART_TX,
176 .end = IRQ_UART_TX,
177 .flags = IORESOURCE_IRQ,
180 .start = IRQ_UART_RX,
181 .end = IRQ_UART_RX,
182 .flags = IORESOURCE_IRQ,
185 .start = IRQ_UART_ERROR,
186 .end = IRQ_UART_ERROR,
187 .flags = IORESOURCE_IRQ,
190 .start = CH_UART_TX,
191 .end = CH_UART_TX,
192 .flags = IORESOURCE_DMA,
195 .start = CH_UART_RX,
196 .end = CH_UART_RX,
197 .flags = IORESOURCE_DMA,
201 static unsigned short bfin_uart0_peripherals[] = {
202 P_UART0_TX, P_UART0_RX, 0
205 static struct platform_device bfin_uart0_device = {
206 .name = "bfin-uart",
207 .id = 0,
208 .num_resources = ARRAY_SIZE(bfin_uart0_resources),
209 .resource = bfin_uart0_resources,
210 .dev = {
211 .platform_data = &bfin_uart0_peripherals, /* Passed to driver */
214 #endif
215 #endif
217 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
218 #ifdef CONFIG_BFIN_SIR0
219 static struct resource bfin_sir0_resources[] = {
221 .start = 0xFFC00400,
222 .end = 0xFFC004FF,
223 .flags = IORESOURCE_MEM,
226 .start = IRQ_UART0_RX,
227 .end = IRQ_UART0_RX+1,
228 .flags = IORESOURCE_IRQ,
231 .start = CH_UART0_RX,
232 .end = CH_UART0_RX+1,
233 .flags = IORESOURCE_DMA,
237 static struct platform_device bfin_sir0_device = {
238 .name = "bfin_sir",
239 .id = 0,
240 .num_resources = ARRAY_SIZE(bfin_sir0_resources),
241 .resource = bfin_sir0_resources,
243 #endif
244 #endif
246 #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
247 static struct mtd_partition ezkit_partitions[] = {
249 .name = "bootloader(nor)",
250 .size = 0x40000,
251 .offset = 0,
252 }, {
253 .name = "linux kernel(nor)",
254 .size = 0x1C0000,
255 .offset = MTDPART_OFS_APPEND,
256 }, {
257 .name = "file system(nor)",
258 .size = 0x800000 - 0x40000 - 0x1C0000 - 0x2000 * 8,
259 .offset = MTDPART_OFS_APPEND,
260 }, {
261 .name = "config(nor)",
262 .size = 0x2000 * 7,
263 .offset = MTDPART_OFS_APPEND,
264 }, {
265 .name = "u-boot env(nor)",
266 .size = 0x2000,
267 .offset = MTDPART_OFS_APPEND,
271 static struct physmap_flash_data ezkit_flash_data = {
272 .width = 2,
273 .parts = ezkit_partitions,
274 .nr_parts = ARRAY_SIZE(ezkit_partitions),
277 static struct resource ezkit_flash_resource = {
278 .start = 0x20000000,
279 .end = 0x207fffff,
280 .flags = IORESOURCE_MEM,
283 static struct platform_device ezkit_flash_device = {
284 .name = "physmap-flash",
285 .id = 0,
286 .dev = {
287 .platform_data = &ezkit_flash_data,
289 .num_resources = 1,
290 .resource = &ezkit_flash_resource,
292 #endif
294 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
295 /* SPI (0) */
296 static struct resource bfin_spi0_resource[] = {
297 [0] = {
298 .start = SPI0_REGBASE,
299 .end = SPI0_REGBASE + 0xFF,
300 .flags = IORESOURCE_MEM,
302 [1] = {
303 .start = CH_SPI,
304 .end = CH_SPI,
305 .flags = IORESOURCE_DMA,
307 [2] = {
308 .start = IRQ_SPI,
309 .end = IRQ_SPI,
310 .flags = IORESOURCE_IRQ,
314 /* SPI controller data */
315 static struct bfin5xx_spi_master bfin_spi0_info = {
316 .num_chipselect = 8,
317 .enable_dma = 1, /* master has the ability to do dma transfer */
318 .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
321 static struct platform_device bfin_spi0_device = {
322 .name = "bfin-spi",
323 .id = 0, /* Bus number */
324 .num_resources = ARRAY_SIZE(bfin_spi0_resource),
325 .resource = bfin_spi0_resource,
326 .dev = {
327 .platform_data = &bfin_spi0_info, /* Passed to driver */
330 #endif
332 static struct spi_board_info bfin_spi_board_info[] __initdata = {
333 #if defined(CONFIG_SND_BF5XX_SOC_AD183X) \
334 || defined(CONFIG_SND_BF5XX_SOC_AD183X_MODULE)
336 .modalias = "ad183x",
337 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
338 .bus_num = 0,
339 .chip_select = 4,
340 .platform_data = "ad1836", /* only includes chip name for the moment */
341 .mode = SPI_MODE_3,
343 #endif
344 #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
346 .modalias = "spidev",
347 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
348 .bus_num = 0,
349 .chip_select = 1,
351 #endif
354 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
355 #include <linux/input.h>
356 #include <linux/gpio_keys.h>
358 static struct gpio_keys_button bfin_gpio_keys_table[] = {
359 {BTN_0, GPIO_PF5, 1, "gpio-keys: BTN0"},
360 {BTN_1, GPIO_PF6, 1, "gpio-keys: BTN1"},
361 {BTN_2, GPIO_PF7, 1, "gpio-keys: BTN2"},
362 {BTN_3, GPIO_PF8, 1, "gpio-keys: BTN3"},
365 static struct gpio_keys_platform_data bfin_gpio_keys_data = {
366 .buttons = bfin_gpio_keys_table,
367 .nbuttons = ARRAY_SIZE(bfin_gpio_keys_table),
370 static struct platform_device bfin_device_gpiokeys = {
371 .name = "gpio-keys",
372 .dev = {
373 .platform_data = &bfin_gpio_keys_data,
376 #endif
378 #if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
379 #include <linux/i2c-gpio.h>
381 static struct i2c_gpio_platform_data i2c_gpio_data = {
382 .sda_pin = GPIO_PF1,
383 .scl_pin = GPIO_PF0,
384 .sda_is_open_drain = 0,
385 .scl_is_open_drain = 0,
386 .udelay = 40,
389 static struct platform_device i2c_gpio_device = {
390 .name = "i2c-gpio",
391 .id = 0,
392 .dev = {
393 .platform_data = &i2c_gpio_data,
396 #endif
398 static const unsigned int cclk_vlev_datasheet[] =
400 VRPAIR(VLEV_085, 250000000),
401 VRPAIR(VLEV_090, 300000000),
402 VRPAIR(VLEV_095, 313000000),
403 VRPAIR(VLEV_100, 350000000),
404 VRPAIR(VLEV_105, 400000000),
405 VRPAIR(VLEV_110, 444000000),
406 VRPAIR(VLEV_115, 450000000),
407 VRPAIR(VLEV_120, 475000000),
408 VRPAIR(VLEV_125, 500000000),
409 VRPAIR(VLEV_130, 600000000),
412 static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
413 .tuple_tab = cclk_vlev_datasheet,
414 .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
415 .vr_settling_time = 25 /* us */,
418 static struct platform_device bfin_dpmc = {
419 .name = "bfin dpmc",
420 .dev = {
421 .platform_data = &bfin_dmpc_vreg_data,
425 #if defined(CONFIG_SND_BF5XX_I2S) || defined(CONFIG_SND_BF5XX_I2S_MODULE)
426 static struct platform_device bfin_i2s = {
427 .name = "bfin-i2s",
428 .id = CONFIG_SND_BF5XX_SPORT_NUM,
429 /* TODO: add platform data here */
431 #endif
433 #if defined(CONFIG_SND_BF5XX_TDM) || defined(CONFIG_SND_BF5XX_TDM_MODULE)
434 static struct platform_device bfin_tdm = {
435 .name = "bfin-tdm",
436 .id = CONFIG_SND_BF5XX_SPORT_NUM,
437 /* TODO: add platform data here */
439 #endif
441 #if defined(CONFIG_SND_BF5XX_AC97) || defined(CONFIG_SND_BF5XX_AC97_MODULE)
442 static struct platform_device bfin_ac97 = {
443 .name = "bfin-ac97",
444 .id = CONFIG_SND_BF5XX_SPORT_NUM,
445 /* TODO: add platform data here */
447 #endif
449 static struct platform_device *ezkit_devices[] __initdata = {
451 &bfin_dpmc,
453 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
454 &smc91x_device,
455 #endif
457 #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
458 &net2272_bfin_device,
459 #endif
461 #if defined(CONFIG_USB_ISP1760_HCD) || defined(CONFIG_USB_ISP1760_HCD_MODULE)
462 &bfin_isp1760_device,
463 #endif
465 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
466 &bfin_spi0_device,
467 #endif
469 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
470 #ifdef CONFIG_SERIAL_BFIN_UART0
471 &bfin_uart0_device,
472 #endif
473 #endif
475 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
476 #ifdef CONFIG_BFIN_SIR0
477 &bfin_sir0_device,
478 #endif
479 #endif
481 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
482 &bfin_device_gpiokeys,
483 #endif
485 #if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
486 &i2c_gpio_device,
487 #endif
489 #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
490 &isp1362_hcd_device,
491 #endif
493 #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
494 &ezkit_flash_device,
495 #endif
497 #if defined(CONFIG_SND_BF5XX_I2S) || defined(CONFIG_SND_BF5XX_I2S_MODULE)
498 &bfin_i2s,
499 #endif
501 #if defined(CONFIG_SND_BF5XX_TDM) || defined(CONFIG_SND_BF5XX_TDM_MODULE)
502 &bfin_tdm,
503 #endif
505 #if defined(CONFIG_SND_BF5XX_AC97) || defined(CONFIG_SND_BF5XX_AC97_MODULE)
506 &bfin_ac97,
507 #endif
510 static int __init net2272_init(void)
512 #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
513 int ret;
515 ret = gpio_request(GPIO_PF11, "net2272");
516 if (ret)
517 return ret;
519 /* Reset the USB chip */
520 gpio_direction_output(GPIO_PF11, 0);
521 mdelay(2);
522 gpio_set_value(GPIO_PF11, 1);
523 #endif
525 return 0;
528 static int __init ezkit_init(void)
530 int ret;
532 printk(KERN_INFO "%s(): registering device resources\n", __func__);
534 ret = platform_add_devices(ezkit_devices, ARRAY_SIZE(ezkit_devices));
535 if (ret < 0)
536 return ret;
538 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
539 bfin_write_FIO0_DIR(bfin_read_FIO0_DIR() | (1 << 12));
540 SSYNC();
541 #endif
543 #if defined(CONFIG_SND_BF5XX_SOC_AD183X) || defined(CONFIG_SND_BF5XX_SOC_AD183X_MODULE)
544 bfin_write_FIO0_DIR(bfin_read_FIO0_DIR() | (1 << 15));
545 bfin_write_FIO0_FLAG_S(1 << 15);
546 SSYNC();
548 * This initialization lasts for approximately 4500 MCLKs.
549 * MCLK = 12.288MHz
551 udelay(400);
552 #endif
554 if (net2272_init())
555 pr_warning("unable to configure net2272; it probably won't work\n");
557 spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
558 return 0;
561 arch_initcall(ezkit_init);
563 static struct platform_device *ezkit_early_devices[] __initdata = {
564 #if defined(CONFIG_SERIAL_BFIN_CONSOLE) || defined(CONFIG_EARLY_PRINTK)
565 #ifdef CONFIG_SERIAL_BFIN_UART0
566 &bfin_uart0_device,
567 #endif
568 #endif
571 void __init native_machine_early_platform_add_devices(void)
573 printk(KERN_INFO "register early platform devices\n");
574 early_platform_add_devices(ezkit_early_devices,
575 ARRAY_SIZE(ezkit_early_devices));