64816b08d13ce7948f76e1f0ba7b28dc9b78c7a6
[safe/jmp/linux-2.6] / arch / blackfin / mach-bf533 / boards / ezkit.c
1 /*
2  * Copyright 2004-2009 Analog Devices Inc.
3  *                2005 National ICT Australia (NICTA)
4  *                      Aidan Williams <aidan@nicta.com.au>
5  *
6  * Licensed under the GPL-2 or later.
7  */
8
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/spi/spi.h>
15 #include <linux/spi/flash.h>
16 #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
17 #include <linux/usb/isp1362.h>
18 #endif
19 #include <linux/irq.h>
20 #include <asm/dma.h>
21 #include <asm/bfin5xx_spi.h>
22 #include <asm/portmux.h>
23 #include <asm/dpmc.h>
24
25 /*
26  * Name the Board for the /proc/cpuinfo
27  */
28 const char bfin_board_name[] = "ADI BF533-EZKIT";
29
30 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
31 static struct platform_device rtc_device = {
32         .name = "rtc-bfin",
33         .id   = -1,
34 };
35 #endif
36
37 #if defined(CONFIG_FB_BFIN_7393) || defined(CONFIG_FB_BFIN_7393_MODULE)
38 static struct platform_device bfin_fb_adv7393_device = {
39         .name = "bfin-adv7393",
40 };
41 #endif
42
43 /*
44  *  USB-LAN EzExtender board
45  *  Driver needs to know address, irq and flag pin.
46  */
47 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
48 #include <linux/smc91x.h>
49
50 static struct smc91x_platdata smc91x_info = {
51         .flags = SMC91X_USE_16BIT | SMC91X_NOWAIT,
52         .leda = RPC_LED_100_10,
53         .ledb = RPC_LED_TX_RX,
54 };
55
56 static struct resource smc91x_resources[] = {
57         {
58                 .name = "smc91x-regs",
59                 .start = 0x20310300,
60                 .end = 0x20310300 + 16,
61                 .flags = IORESOURCE_MEM,
62         }, {
63                 .start = IRQ_PF9,
64                 .end = IRQ_PF9,
65                 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
66         },
67 };
68 static struct platform_device smc91x_device = {
69         .name = "smc91x",
70         .id = 0,
71         .num_resources = ARRAY_SIZE(smc91x_resources),
72         .resource = smc91x_resources,
73         .dev    = {
74                 .platform_data  = &smc91x_info,
75         },
76 };
77 #endif
78
79 #if defined(CONFIG_MTD_PSD4256G) || defined(CONFIG_MTD_PSD4256G_MODULE)
80 static const char *map_probes[] = {
81         "stm_flash",
82         NULL,
83 };
84
85 static struct platdata_mtd_ram stm_pri_data_a = {
86         .mapname    = "Flash A Primary",
87         .map_probes = map_probes,
88         .bankwidth  = 2,
89 };
90
91 static struct resource stm_pri_resource_a = {
92         .start = 0x20000000,
93         .end   = 0x200fffff,
94         .flags = IORESOURCE_MEM,
95 };
96
97 static struct platform_device stm_pri_device_a = {
98         .name          = "mtd-ram",
99         .id            = 0,
100         .dev = {
101                 .platform_data = &stm_pri_data_a,
102         },
103         .num_resources = 1,
104         .resource      = &stm_pri_resource_a,
105 };
106
107 static struct platdata_mtd_ram stm_pri_data_b = {
108         .mapname    = "Flash B Primary",
109         .map_probes = map_probes,
110         .bankwidth  = 2,
111 };
112
113 static struct resource stm_pri_resource_b = {
114         .start = 0x20100000,
115         .end   = 0x201fffff,
116         .flags = IORESOURCE_MEM,
117 };
118
119 static struct platform_device stm_pri_device_b = {
120         .name          = "mtd-ram",
121         .id            = 4,
122         .dev = {
123                 .platform_data = &stm_pri_data_b,
124         },
125         .num_resources = 1,
126         .resource      = &stm_pri_resource_b,
127 };
128 #endif
129
130 #if defined(CONFIG_MTD_PLATRAM) || defined(CONFIG_MTD_PLATRAM_MODULE)
131 static struct platdata_mtd_ram sram_data_a = {
132         .mapname   = "Flash A SRAM",
133         .bankwidth = 2,
134 };
135
136 static struct resource sram_resource_a = {
137         .start = 0x20240000,
138         .end   = 0x2024ffff,
139         .flags = IORESOURCE_MEM,
140 };
141
142 static struct platform_device sram_device_a = {
143         .name          = "mtd-ram",
144         .id            = 8,
145         .dev = {
146                 .platform_data = &sram_data_a,
147         },
148         .num_resources = 1,
149         .resource      = &sram_resource_a,
150 };
151
152 static struct platdata_mtd_ram sram_data_b = {
153         .mapname   = "Flash B SRAM",
154         .bankwidth = 2,
155 };
156
157 static struct resource sram_resource_b = {
158         .start = 0x202c0000,
159         .end   = 0x202cffff,
160         .flags = IORESOURCE_MEM,
161 };
162
163 static struct platform_device sram_device_b = {
164         .name          = "mtd-ram",
165         .id            = 9,
166         .dev = {
167                 .platform_data = &sram_data_b,
168         },
169         .num_resources = 1,
170         .resource      = &sram_resource_b,
171 };
172 #endif
173
174 #if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE)
175 static struct mtd_partition bfin_spi_flash_partitions[] = {
176         {
177                 .name = "bootloader(spi)",
178                 .size = 0x00020000,
179                 .offset = 0,
180                 .mask_flags = MTD_CAP_ROM
181         }, {
182                 .name = "linux kernel(spi)",
183                 .size = 0xe0000,
184                 .offset = MTDPART_OFS_APPEND,
185         }, {
186                 .name = "file system(spi)",
187                 .size = MTDPART_SIZ_FULL,
188                 .offset = MTDPART_OFS_APPEND,
189         }
190 };
191
192 static struct flash_platform_data bfin_spi_flash_data = {
193         .name = "m25p80",
194         .parts = bfin_spi_flash_partitions,
195         .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
196         .type = "m25p64",
197 };
198
199 /* SPI flash chip (m25p64) */
200 static struct bfin5xx_spi_chip spi_flash_chip_info = {
201         .enable_dma = 0,         /* use dma transfer with this chip*/
202         .bits_per_word = 8,
203 };
204 #endif
205
206 #if defined(CONFIG_BFIN_SPI_ADC) || defined(CONFIG_BFIN_SPI_ADC_MODULE)
207 /* SPI ADC chip */
208 static struct bfin5xx_spi_chip spi_adc_chip_info = {
209         .enable_dma = 1,         /* use dma transfer with this chip*/
210         .bits_per_word = 16,
211 };
212 #endif
213
214 #if defined(CONFIG_SND_BLACKFIN_AD1836) || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
215 static struct bfin5xx_spi_chip ad1836_spi_chip_info = {
216         .enable_dma = 0,
217         .bits_per_word = 16,
218 };
219 #endif
220
221 #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
222 static struct bfin5xx_spi_chip spidev_chip_info = {
223         .enable_dma = 0,
224         .bits_per_word = 8,
225 };
226 #endif
227
228 static struct spi_board_info bfin_spi_board_info[] __initdata = {
229 #if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE)
230         {
231                 /* the modalias must be the same as spi device driver name */
232                 .modalias = "m25p80", /* Name of spi_driver for this device */
233                 .max_speed_hz = 25000000,     /* max spi clock (SCK) speed in HZ */
234                 .bus_num = 0, /* Framework bus number */
235                 .chip_select = 2, /* Framework chip select. On STAMP537 it is SPISSEL2*/
236                 .platform_data = &bfin_spi_flash_data,
237                 .controller_data = &spi_flash_chip_info,
238                 .mode = SPI_MODE_3,
239         },
240 #endif
241
242 #if defined(CONFIG_BFIN_SPI_ADC) || defined(CONFIG_BFIN_SPI_ADC_MODULE)
243         {
244                 .modalias = "bfin_spi_adc", /* Name of spi_driver for this device */
245                 .max_speed_hz = 6250000,     /* max spi clock (SCK) speed in HZ */
246                 .bus_num = 0, /* Framework bus number */
247                 .chip_select = 1, /* Framework chip select. */
248                 .platform_data = NULL, /* No spi_driver specific config */
249                 .controller_data = &spi_adc_chip_info,
250         },
251 #endif
252
253 #if defined(CONFIG_SND_BLACKFIN_AD1836) || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
254         {
255                 .modalias = "ad1836",
256                 .max_speed_hz = 3125000,     /* max spi clock (SCK) speed in HZ */
257                 .bus_num = 0,
258                 .chip_select = CONFIG_SND_BLACKFIN_SPI_PFBIT,
259                 .controller_data = &ad1836_spi_chip_info,
260         },
261 #endif
262 #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
263         {
264                 .modalias = "spidev",
265                 .max_speed_hz = 3125000,     /* max spi clock (SCK) speed in HZ */
266                 .bus_num = 0,
267                 .chip_select = 1,
268                 .controller_data = &spidev_chip_info,
269         },
270 #endif
271 };
272
273 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
274 /* SPI (0) */
275 static struct resource bfin_spi0_resource[] = {
276         [0] = {
277                 .start = SPI0_REGBASE,
278                 .end   = SPI0_REGBASE + 0xFF,
279                 .flags = IORESOURCE_MEM,
280         },
281         [1] = {
282                 .start = CH_SPI,
283                 .end   = CH_SPI,
284                 .flags = IORESOURCE_DMA,
285         },
286         [2] = {
287                 .start = IRQ_SPI,
288                 .end   = IRQ_SPI,
289                 .flags = IORESOURCE_IRQ,
290         }
291 };
292
293 /* SPI controller data */
294 static struct bfin5xx_spi_master bfin_spi0_info = {
295         .num_chipselect = 8,
296         .enable_dma = 1,  /* master has the ability to do dma transfer */
297         .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
298 };
299
300 static struct platform_device bfin_spi0_device = {
301         .name = "bfin-spi",
302         .id = 0, /* Bus number */
303         .num_resources = ARRAY_SIZE(bfin_spi0_resource),
304         .resource = bfin_spi0_resource,
305         .dev = {
306                 .platform_data = &bfin_spi0_info, /* Passed to driver */
307         },
308 };
309 #endif  /* spi master and devices */
310
311 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
312 static struct resource bfin_uart_resources[] = {
313         {
314                 .start = 0xFFC00400,
315                 .end = 0xFFC004FF,
316                 .flags = IORESOURCE_MEM,
317         },
318 };
319
320 static struct platform_device bfin_uart_device = {
321         .name = "bfin-uart",
322         .id = 1,
323         .num_resources = ARRAY_SIZE(bfin_uart_resources),
324         .resource = bfin_uart_resources,
325 };
326 #endif
327
328 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
329 #ifdef CONFIG_BFIN_SIR0
330 static struct resource bfin_sir0_resources[] = {
331         {
332                 .start = 0xFFC00400,
333                 .end = 0xFFC004FF,
334                 .flags = IORESOURCE_MEM,
335         },
336         {
337                 .start = IRQ_UART0_RX,
338                 .end = IRQ_UART0_RX+1,
339                 .flags = IORESOURCE_IRQ,
340         },
341         {
342                 .start = CH_UART0_RX,
343                 .end = CH_UART0_RX+1,
344                 .flags = IORESOURCE_DMA,
345         },
346 };
347
348 static struct platform_device bfin_sir0_device = {
349         .name = "bfin_sir",
350         .id = 0,
351         .num_resources = ARRAY_SIZE(bfin_sir0_resources),
352         .resource = bfin_sir0_resources,
353 };
354 #endif
355 #endif
356
357 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
358 #include <linux/input.h>
359 #include <linux/gpio_keys.h>
360
361 static struct gpio_keys_button bfin_gpio_keys_table[] = {
362         {BTN_0, GPIO_PF7, 1, "gpio-keys: BTN0"},
363         {BTN_1, GPIO_PF8, 1, "gpio-keys: BTN1"},
364         {BTN_2, GPIO_PF9, 1, "gpio-keys: BTN2"},
365         {BTN_3, GPIO_PF10, 1, "gpio-keys: BTN3"},
366 };
367
368 static struct gpio_keys_platform_data bfin_gpio_keys_data = {
369         .buttons        = bfin_gpio_keys_table,
370         .nbuttons       = ARRAY_SIZE(bfin_gpio_keys_table),
371 };
372
373 static struct platform_device bfin_device_gpiokeys = {
374         .name      = "gpio-keys",
375         .dev = {
376                 .platform_data = &bfin_gpio_keys_data,
377         },
378 };
379 #endif
380
381 static struct resource bfin_gpios_resources = {
382         .start = 0,
383         .end   = MAX_BLACKFIN_GPIOS - 1,
384         .flags = IORESOURCE_IRQ,
385 };
386
387 static struct platform_device bfin_gpios_device = {
388         .name = "simple-gpio",
389         .id = -1,
390         .num_resources = 1,
391         .resource = &bfin_gpios_resources,
392 };
393
394 #if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
395 #include <linux/i2c-gpio.h>
396
397 static struct i2c_gpio_platform_data i2c_gpio_data = {
398         .sda_pin                = 1,
399         .scl_pin                = 0,
400         .sda_is_open_drain      = 0,
401         .scl_is_open_drain      = 0,
402         .udelay                 = 40,
403 };
404
405 static struct platform_device i2c_gpio_device = {
406         .name           = "i2c-gpio",
407         .id             = 0,
408         .dev            = {
409                 .platform_data  = &i2c_gpio_data,
410         },
411 };
412 #endif
413
414 static const unsigned int cclk_vlev_datasheet[] =
415 {
416         VRPAIR(VLEV_085, 250000000),
417         VRPAIR(VLEV_090, 376000000),
418         VRPAIR(VLEV_095, 426000000),
419         VRPAIR(VLEV_100, 426000000),
420         VRPAIR(VLEV_105, 476000000),
421         VRPAIR(VLEV_110, 476000000),
422         VRPAIR(VLEV_115, 476000000),
423         VRPAIR(VLEV_120, 600000000),
424         VRPAIR(VLEV_125, 600000000),
425         VRPAIR(VLEV_130, 600000000),
426 };
427
428 static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
429         .tuple_tab = cclk_vlev_datasheet,
430         .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
431         .vr_settling_time = 25 /* us */,
432 };
433
434 static struct platform_device bfin_dpmc = {
435         .name = "bfin dpmc",
436         .dev = {
437                 .platform_data = &bfin_dmpc_vreg_data,
438         },
439 };
440
441 static struct platform_device *ezkit_devices[] __initdata = {
442
443         &bfin_dpmc,
444
445 #if defined(CONFIG_MTD_PSD4256G) || defined(CONFIG_MTD_PSD4256G_MODULE)
446         &stm_pri_device_a,
447         &stm_pri_device_b,
448 #endif
449
450 #if defined(CONFIG_MTD_PLATRAM) || defined(CONFIG_MTD_PLATRAM_MODULE)
451         &sram_device_a,
452         &sram_device_b,
453 #endif
454
455 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
456         &smc91x_device,
457 #endif
458
459 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
460         &bfin_spi0_device,
461 #endif
462
463 #if defined(CONFIG_FB_BFIN_7393) || defined(CONFIG_FB_BFIN_7393_MODULE)
464         &bfin_fb_adv7393_device,
465 #endif
466
467 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
468         &rtc_device,
469 #endif
470
471 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
472         &bfin_uart_device,
473 #endif
474
475 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
476 #ifdef CONFIG_BFIN_SIR0
477         &bfin_sir0_device,
478 #endif
479 #endif
480
481 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
482         &bfin_device_gpiokeys,
483 #endif
484
485 #if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
486         &i2c_gpio_device,
487 #endif
488
489         &bfin_gpios_device,
490 };
491
492 static int __init ezkit_init(void)
493 {
494         printk(KERN_INFO "%s(): registering device resources\n", __func__);
495         platform_add_devices(ezkit_devices, ARRAY_SIZE(ezkit_devices));
496         spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
497         return 0;
498 }
499
500 arch_initcall(ezkit_init);