include: replace linux/module.h with "struct module" wherever possible
[linux-2.6/next.git] / arch / blackfin / mach-bf533 / boards / ezkit.c
blobecd2801f050d9a9e0acde1e22fb6e6746edda3ba
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/plat-ram.h>
14 #include <linux/mtd/physmap.h>
15 #include <linux/spi/spi.h>
16 #include <linux/spi/flash.h>
17 #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
18 #include <linux/usb/isp1362.h>
19 #endif
20 #include <linux/irq.h>
21 #include <linux/i2c.h>
22 #include <asm/dma.h>
23 #include <asm/bfin5xx_spi.h>
24 #include <asm/portmux.h>
25 #include <asm/dpmc.h>
28 * Name the Board for the /proc/cpuinfo
30 const char bfin_board_name[] = "ADI BF533-EZKIT";
32 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
33 static struct platform_device rtc_device = {
34 .name = "rtc-bfin",
35 .id = -1,
37 #endif
40 * USB-LAN EzExtender board
41 * Driver needs to know address, irq and flag pin.
43 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
44 #include <linux/smc91x.h>
46 static struct smc91x_platdata smc91x_info = {
47 .flags = SMC91X_USE_16BIT | SMC91X_NOWAIT,
48 .leda = RPC_LED_100_10,
49 .ledb = RPC_LED_TX_RX,
52 static struct resource smc91x_resources[] = {
54 .name = "smc91x-regs",
55 .start = 0x20310300,
56 .end = 0x20310300 + 16,
57 .flags = IORESOURCE_MEM,
58 }, {
59 .start = IRQ_PF9,
60 .end = IRQ_PF9,
61 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
64 static struct platform_device smc91x_device = {
65 .name = "smc91x",
66 .id = 0,
67 .num_resources = ARRAY_SIZE(smc91x_resources),
68 .resource = smc91x_resources,
69 .dev = {
70 .platform_data = &smc91x_info,
73 #endif
75 #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
76 static struct mtd_partition ezkit_partitions_a[] = {
78 .name = "bootloader(nor a)",
79 .size = 0x40000,
80 .offset = 0,
81 }, {
82 .name = "linux kernel(nor a)",
83 .size = MTDPART_SIZ_FULL,
84 .offset = MTDPART_OFS_APPEND,
88 static struct physmap_flash_data ezkit_flash_data_a = {
89 .width = 2,
90 .parts = ezkit_partitions_a,
91 .nr_parts = ARRAY_SIZE(ezkit_partitions_a),
94 static struct resource ezkit_flash_resource_a = {
95 .start = 0x20000000,
96 .end = 0x200fffff,
97 .flags = IORESOURCE_MEM,
100 static struct platform_device ezkit_flash_device_a = {
101 .name = "physmap-flash",
102 .id = 0,
103 .dev = {
104 .platform_data = &ezkit_flash_data_a,
106 .num_resources = 1,
107 .resource = &ezkit_flash_resource_a,
110 static struct mtd_partition ezkit_partitions_b[] = {
112 .name = "file system(nor b)",
113 .size = MTDPART_SIZ_FULL,
114 .offset = MTDPART_OFS_APPEND,
118 static struct physmap_flash_data ezkit_flash_data_b = {
119 .width = 2,
120 .parts = ezkit_partitions_b,
121 .nr_parts = ARRAY_SIZE(ezkit_partitions_b),
124 static struct resource ezkit_flash_resource_b = {
125 .start = 0x20100000,
126 .end = 0x201fffff,
127 .flags = IORESOURCE_MEM,
130 static struct platform_device ezkit_flash_device_b = {
131 .name = "physmap-flash",
132 .id = 4,
133 .dev = {
134 .platform_data = &ezkit_flash_data_b,
136 .num_resources = 1,
137 .resource = &ezkit_flash_resource_b,
139 #endif
141 #if defined(CONFIG_MTD_PLATRAM) || defined(CONFIG_MTD_PLATRAM_MODULE)
142 static struct platdata_mtd_ram sram_data_a = {
143 .mapname = "Flash A SRAM",
144 .bankwidth = 2,
147 static struct resource sram_resource_a = {
148 .start = 0x20240000,
149 .end = 0x2024ffff,
150 .flags = IORESOURCE_MEM,
153 static struct platform_device sram_device_a = {
154 .name = "mtd-ram",
155 .id = 8,
156 .dev = {
157 .platform_data = &sram_data_a,
159 .num_resources = 1,
160 .resource = &sram_resource_a,
163 static struct platdata_mtd_ram sram_data_b = {
164 .mapname = "Flash B SRAM",
165 .bankwidth = 2,
168 static struct resource sram_resource_b = {
169 .start = 0x202c0000,
170 .end = 0x202cffff,
171 .flags = IORESOURCE_MEM,
174 static struct platform_device sram_device_b = {
175 .name = "mtd-ram",
176 .id = 9,
177 .dev = {
178 .platform_data = &sram_data_b,
180 .num_resources = 1,
181 .resource = &sram_resource_b,
183 #endif
185 #if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE)
186 static struct mtd_partition bfin_spi_flash_partitions[] = {
188 .name = "bootloader(spi)",
189 .size = 0x00020000,
190 .offset = 0,
191 .mask_flags = MTD_CAP_ROM
192 }, {
193 .name = "linux kernel(spi)",
194 .size = 0xe0000,
195 .offset = MTDPART_OFS_APPEND,
196 }, {
197 .name = "file system(spi)",
198 .size = MTDPART_SIZ_FULL,
199 .offset = MTDPART_OFS_APPEND,
203 static struct flash_platform_data bfin_spi_flash_data = {
204 .name = "m25p80",
205 .parts = bfin_spi_flash_partitions,
206 .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
207 .type = "m25p64",
210 /* SPI flash chip (m25p64) */
211 static struct bfin5xx_spi_chip spi_flash_chip_info = {
212 .enable_dma = 0, /* use dma transfer with this chip*/
214 #endif
216 static struct spi_board_info bfin_spi_board_info[] __initdata = {
217 #if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE)
219 /* the modalias must be the same as spi device driver name */
220 .modalias = "m25p80", /* Name of spi_driver for this device */
221 .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
222 .bus_num = 0, /* Framework bus number */
223 .chip_select = 2, /* Framework chip select. On STAMP537 it is SPISSEL2*/
224 .platform_data = &bfin_spi_flash_data,
225 .controller_data = &spi_flash_chip_info,
226 .mode = SPI_MODE_3,
228 #endif
230 #if defined(CONFIG_SND_BF5XX_SOC_AD183X) || defined(CONFIG_SND_BF5XX_SOC_AD183X_MODULE)
232 .modalias = "ad183x",
233 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
234 .bus_num = 0,
235 .chip_select = 4,
237 #endif
238 #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
240 .modalias = "spidev",
241 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
242 .bus_num = 0,
243 .chip_select = 1,
245 #endif
248 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
249 /* SPI (0) */
250 static struct resource bfin_spi0_resource[] = {
251 [0] = {
252 .start = SPI0_REGBASE,
253 .end = SPI0_REGBASE + 0xFF,
254 .flags = IORESOURCE_MEM,
256 [1] = {
257 .start = CH_SPI,
258 .end = CH_SPI,
259 .flags = IORESOURCE_DMA,
261 [2] = {
262 .start = IRQ_SPI,
263 .end = IRQ_SPI,
264 .flags = IORESOURCE_IRQ,
268 /* SPI controller data */
269 static struct bfin5xx_spi_master bfin_spi0_info = {
270 .num_chipselect = 8,
271 .enable_dma = 1, /* master has the ability to do dma transfer */
272 .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
275 static struct platform_device bfin_spi0_device = {
276 .name = "bfin-spi",
277 .id = 0, /* Bus number */
278 .num_resources = ARRAY_SIZE(bfin_spi0_resource),
279 .resource = bfin_spi0_resource,
280 .dev = {
281 .platform_data = &bfin_spi0_info, /* Passed to driver */
284 #endif /* spi master and devices */
286 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
287 #ifdef CONFIG_SERIAL_BFIN_UART0
288 static struct resource bfin_uart0_resources[] = {
290 .start = BFIN_UART_THR,
291 .end = BFIN_UART_GCTL+2,
292 .flags = IORESOURCE_MEM,
295 .start = IRQ_UART0_RX,
296 .end = IRQ_UART0_RX + 1,
297 .flags = IORESOURCE_IRQ,
300 .start = IRQ_UART0_ERROR,
301 .end = IRQ_UART0_ERROR,
302 .flags = IORESOURCE_IRQ,
305 .start = CH_UART0_TX,
306 .end = CH_UART0_TX,
307 .flags = IORESOURCE_DMA,
310 .start = CH_UART0_RX,
311 .end = CH_UART0_RX,
312 .flags = IORESOURCE_DMA,
316 static unsigned short bfin_uart0_peripherals[] = {
317 P_UART0_TX, P_UART0_RX, 0
320 static struct platform_device bfin_uart0_device = {
321 .name = "bfin-uart",
322 .id = 0,
323 .num_resources = ARRAY_SIZE(bfin_uart0_resources),
324 .resource = bfin_uart0_resources,
325 .dev = {
326 .platform_data = &bfin_uart0_peripherals, /* Passed to driver */
329 #endif
330 #endif
332 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
333 #ifdef CONFIG_BFIN_SIR0
334 static struct resource bfin_sir0_resources[] = {
336 .start = 0xFFC00400,
337 .end = 0xFFC004FF,
338 .flags = IORESOURCE_MEM,
341 .start = IRQ_UART0_RX,
342 .end = IRQ_UART0_RX+1,
343 .flags = IORESOURCE_IRQ,
346 .start = CH_UART0_RX,
347 .end = CH_UART0_RX+1,
348 .flags = IORESOURCE_DMA,
352 static struct platform_device bfin_sir0_device = {
353 .name = "bfin_sir",
354 .id = 0,
355 .num_resources = ARRAY_SIZE(bfin_sir0_resources),
356 .resource = bfin_sir0_resources,
358 #endif
359 #endif
361 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
362 #include <linux/input.h>
363 #include <linux/gpio_keys.h>
365 static struct gpio_keys_button bfin_gpio_keys_table[] = {
366 {BTN_0, GPIO_PF7, 1, "gpio-keys: BTN0"},
367 {BTN_1, GPIO_PF8, 1, "gpio-keys: BTN1"},
368 {BTN_2, GPIO_PF9, 1, "gpio-keys: BTN2"},
369 {BTN_3, GPIO_PF10, 1, "gpio-keys: BTN3"},
372 static struct gpio_keys_platform_data bfin_gpio_keys_data = {
373 .buttons = bfin_gpio_keys_table,
374 .nbuttons = ARRAY_SIZE(bfin_gpio_keys_table),
377 static struct platform_device bfin_device_gpiokeys = {
378 .name = "gpio-keys",
379 .dev = {
380 .platform_data = &bfin_gpio_keys_data,
383 #endif
385 #if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
386 #include <linux/i2c-gpio.h>
388 static struct i2c_gpio_platform_data i2c_gpio_data = {
389 .sda_pin = GPIO_PF1,
390 .scl_pin = GPIO_PF0,
391 .sda_is_open_drain = 0,
392 .scl_is_open_drain = 0,
393 .udelay = 40,
396 static struct platform_device i2c_gpio_device = {
397 .name = "i2c-gpio",
398 .id = 0,
399 .dev = {
400 .platform_data = &i2c_gpio_data,
403 #endif
405 static const unsigned int cclk_vlev_datasheet[] =
407 VRPAIR(VLEV_085, 250000000),
408 VRPAIR(VLEV_090, 376000000),
409 VRPAIR(VLEV_095, 426000000),
410 VRPAIR(VLEV_100, 426000000),
411 VRPAIR(VLEV_105, 476000000),
412 VRPAIR(VLEV_110, 476000000),
413 VRPAIR(VLEV_115, 476000000),
414 VRPAIR(VLEV_120, 600000000),
415 VRPAIR(VLEV_125, 600000000),
416 VRPAIR(VLEV_130, 600000000),
419 static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
420 .tuple_tab = cclk_vlev_datasheet,
421 .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
422 .vr_settling_time = 25 /* us */,
425 static struct platform_device bfin_dpmc = {
426 .name = "bfin dpmc",
427 .dev = {
428 .platform_data = &bfin_dmpc_vreg_data,
432 static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
433 #if defined(CONFIG_FB_BFIN_7393) || defined(CONFIG_FB_BFIN_7393_MODULE)
435 I2C_BOARD_INFO("bfin-adv7393", 0x2B),
437 #endif
440 #if defined(CONFIG_SND_BF5XX_I2S) || defined(CONFIG_SND_BF5XX_I2S_MODULE)
441 static struct platform_device bfin_i2s = {
442 .name = "bfin-i2s",
443 .id = CONFIG_SND_BF5XX_SPORT_NUM,
444 /* TODO: add platform data here */
446 #endif
448 #if defined(CONFIG_SND_BF5XX_TDM) || defined(CONFIG_SND_BF5XX_TDM_MODULE)
449 static struct platform_device bfin_tdm = {
450 .name = "bfin-tdm",
451 .id = CONFIG_SND_BF5XX_SPORT_NUM,
452 /* TODO: add platform data here */
454 #endif
456 #if defined(CONFIG_SND_BF5XX_AC97) || defined(CONFIG_SND_BF5XX_AC97_MODULE)
457 static struct platform_device bfin_ac97 = {
458 .name = "bfin-ac97",
459 .id = CONFIG_SND_BF5XX_SPORT_NUM,
460 /* TODO: add platform data here */
462 #endif
464 static struct platform_device *ezkit_devices[] __initdata = {
466 &bfin_dpmc,
468 #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
469 &ezkit_flash_device_a,
470 &ezkit_flash_device_b,
471 #endif
473 #if defined(CONFIG_MTD_PLATRAM) || defined(CONFIG_MTD_PLATRAM_MODULE)
474 &sram_device_a,
475 &sram_device_b,
476 #endif
478 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
479 &smc91x_device,
480 #endif
482 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
483 &bfin_spi0_device,
484 #endif
486 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
487 &rtc_device,
488 #endif
490 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
491 #ifdef CONFIG_SERIAL_BFIN_UART0
492 &bfin_uart0_device,
493 #endif
494 #endif
496 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
497 #ifdef CONFIG_BFIN_SIR0
498 &bfin_sir0_device,
499 #endif
500 #endif
502 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
503 &bfin_device_gpiokeys,
504 #endif
506 #if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
507 &i2c_gpio_device,
508 #endif
510 #if defined(CONFIG_SND_BF5XX_I2S) || defined(CONFIG_SND_BF5XX_I2S_MODULE)
511 &bfin_i2s,
512 #endif
514 #if defined(CONFIG_SND_BF5XX_TDM) || defined(CONFIG_SND_BF5XX_TDM_MODULE)
515 &bfin_tdm,
516 #endif
518 #if defined(CONFIG_SND_BF5XX_AC97) || defined(CONFIG_SND_BF5XX_AC97_MODULE)
519 &bfin_ac97,
520 #endif
523 static int __init ezkit_init(void)
525 printk(KERN_INFO "%s(): registering device resources\n", __func__);
526 platform_add_devices(ezkit_devices, ARRAY_SIZE(ezkit_devices));
527 spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
528 i2c_register_board_info(0, bfin_i2c_board_info,
529 ARRAY_SIZE(bfin_i2c_board_info));
530 return 0;
533 arch_initcall(ezkit_init);
535 static struct platform_device *ezkit_early_devices[] __initdata = {
536 #if defined(CONFIG_SERIAL_BFIN_CONSOLE) || defined(CONFIG_EARLY_PRINTK)
537 #ifdef CONFIG_SERIAL_BFIN_UART0
538 &bfin_uart0_device,
539 #endif
540 #endif
543 void __init native_machine_early_platform_add_devices(void)
545 printk(KERN_INFO "register early platform devices\n");
546 early_platform_add_devices(ezkit_early_devices,
547 ARRAY_SIZE(ezkit_early_devices));