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