Merge branch 'next/fixes2' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/linux...
[pandora-kernel.git] / arch / blackfin / mach-bf537 / boards / pnav10.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/etherdevice.h>
11 #include <linux/platform_device.h>
12 #include <linux/mtd/mtd.h>
13 #include <linux/mtd/partitions.h>
14 #include <linux/spi/spi.h>
15 #include <linux/spi/flash.h>
16 #include <linux/irq.h>
17 #include <asm/dma.h>
18 #include <asm/bfin5xx_spi.h>
19 #include <asm/portmux.h>
20
21 #include <linux/spi/ad7877.h>
22
23 /*
24  * Name the Board for the /proc/cpuinfo
25  */
26 const char bfin_board_name[] = "ADI PNAV-1.0";
27
28 /*
29  *  Driver needs to know address, irq and flag pin.
30  */
31
32 #if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE)
33 static struct resource bfin_pcmcia_cf_resources[] = {
34         {
35                 .start = 0x20310000, /* IO PORT */
36                 .end = 0x20312000,
37                 .flags = IORESOURCE_MEM,
38         }, {
39                 .start = 0x20311000, /* Attribute Memory */
40                 .end = 0x20311FFF,
41                 .flags = IORESOURCE_MEM,
42         }, {
43                 .start = IRQ_PF4,
44                 .end = IRQ_PF4,
45                 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
46         }, {
47                 .start = 6, /* Card Detect PF6 */
48                 .end = 6,
49                 .flags = IORESOURCE_IRQ,
50         },
51 };
52
53 static struct platform_device bfin_pcmcia_cf_device = {
54         .name = "bfin_cf_pcmcia",
55         .id = -1,
56         .num_resources = ARRAY_SIZE(bfin_pcmcia_cf_resources),
57         .resource = bfin_pcmcia_cf_resources,
58 };
59 #endif
60
61 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
62 static struct platform_device rtc_device = {
63         .name = "rtc-bfin",
64         .id   = -1,
65 };
66 #endif
67
68 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
69 #include <linux/smc91x.h>
70
71 static struct smc91x_platdata smc91x_info = {
72         .flags = SMC91X_USE_16BIT | SMC91X_NOWAIT,
73         .leda = RPC_LED_100_10,
74         .ledb = RPC_LED_TX_RX,
75 };
76
77 static struct resource smc91x_resources[] = {
78         {
79                 .name = "smc91x-regs",
80                 .start = 0x20300300,
81                 .end = 0x20300300 + 16,
82                 .flags = IORESOURCE_MEM,
83         }, {
84
85                 .start = IRQ_PF7,
86                 .end = IRQ_PF7,
87                 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
88         },
89 };
90 static struct platform_device smc91x_device = {
91         .name = "smc91x",
92         .id = 0,
93         .num_resources = ARRAY_SIZE(smc91x_resources),
94         .resource = smc91x_resources,
95         .dev    = {
96                 .platform_data  = &smc91x_info,
97         },
98 };
99 #endif
100
101 #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
102 #include <linux/bfin_mac.h>
103 static const unsigned short bfin_mac_peripherals[] = P_RMII0;
104
105 static struct bfin_phydev_platform_data bfin_phydev_data[] = {
106         {
107                 .addr = 1,
108                 .irq = IRQ_MAC_PHYINT,
109         },
110 };
111
112 static struct bfin_mii_bus_platform_data bfin_mii_bus_data = {
113         .phydev_number = 1,
114         .phydev_data = bfin_phydev_data,
115         .phy_mode = PHY_INTERFACE_MODE_RMII,
116         .mac_peripherals = bfin_mac_peripherals,
117 };
118
119 static struct platform_device bfin_mii_bus = {
120         .name = "bfin_mii_bus",
121         .dev = {
122                 .platform_data = &bfin_mii_bus_data,
123         }
124 };
125
126 static struct platform_device bfin_mac_device = {
127         .name = "bfin_mac",
128         .dev = {
129                 .platform_data = &bfin_mii_bus,
130         }
131 };
132 #endif
133
134 #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
135 static struct resource net2272_bfin_resources[] = {
136         {
137                 .start = 0x20300000,
138                 .end = 0x20300000 + 0x100,
139                 .flags = IORESOURCE_MEM,
140         }, {
141                 .start = IRQ_PF7,
142                 .end = IRQ_PF7,
143                 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
144         },
145 };
146
147 static struct platform_device net2272_bfin_device = {
148         .name = "net2272",
149         .id = -1,
150         .num_resources = ARRAY_SIZE(net2272_bfin_resources),
151         .resource = net2272_bfin_resources,
152 };
153 #endif
154
155 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
156 /* all SPI peripherals info goes here */
157
158 #if defined(CONFIG_MTD_M25P80) \
159         || defined(CONFIG_MTD_M25P80_MODULE)
160 static struct mtd_partition bfin_spi_flash_partitions[] = {
161         {
162                 .name = "bootloader(spi)",
163                 .size = 0x00020000,
164                 .offset = 0,
165                 .mask_flags = MTD_CAP_ROM
166         }, {
167                 .name = "linux kernel(spi)",
168                 .size = 0xe0000,
169                 .offset = 0x20000
170         }, {
171                 .name = "file system(spi)",
172                 .size = 0x700000,
173                 .offset = 0x00100000,
174         }
175 };
176
177 static struct flash_platform_data bfin_spi_flash_data = {
178         .name = "m25p80",
179         .parts = bfin_spi_flash_partitions,
180         .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
181         .type = "m25p64",
182 };
183
184 /* SPI flash chip (m25p64) */
185 static struct bfin5xx_spi_chip spi_flash_chip_info = {
186         .enable_dma = 0,         /* use dma transfer with this chip*/
187 };
188 #endif
189
190 #if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
191 static struct bfin5xx_spi_chip mmc_spi_chip_info = {
192         .enable_dma = 0,
193 };
194 #endif
195
196 #if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
197 static const struct ad7877_platform_data bfin_ad7877_ts_info = {
198         .model                  = 7877,
199         .vref_delay_usecs       = 50,   /* internal, no capacitor */
200         .x_plate_ohms           = 419,
201         .y_plate_ohms           = 486,
202         .pressure_max           = 1000,
203         .pressure_min           = 0,
204         .stopacq_polarity       = 1,
205         .first_conversion_delay = 3,
206         .acquisition_time       = 1,
207         .averaging              = 1,
208         .pen_down_acc_interval  = 1,
209 };
210 #endif
211
212 static struct spi_board_info bfin_spi_board_info[] __initdata = {
213 #if defined(CONFIG_MTD_M25P80) \
214         || defined(CONFIG_MTD_M25P80_MODULE)
215         {
216                 /* the modalias must be the same as spi device driver name */
217                 .modalias = "m25p80", /* Name of spi_driver for this device */
218                 .max_speed_hz = 25000000,     /* max spi clock (SCK) speed in HZ */
219                 .bus_num = 0, /* Framework bus number */
220                 .chip_select = 1, /* Framework chip select. On STAMP537 it is SPISSEL1*/
221                 .platform_data = &bfin_spi_flash_data,
222                 .controller_data = &spi_flash_chip_info,
223                 .mode = SPI_MODE_3,
224         },
225 #endif
226
227 #if defined(CONFIG_SND_BF5XX_SOC_AD183X) \
228         || defined(CONFIG_SND_BF5XX_SOC_AD183X_MODULE)
229         {
230                 .modalias = "ad183x",
231                 .max_speed_hz = 3125000,     /* max spi clock (SCK) speed in HZ */
232                 .bus_num = 0,
233                 .chip_select = 4,
234         },
235 #endif
236 #if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
237         {
238                 .modalias = "mmc_spi",
239                 .max_speed_hz = 25000000,     /* max spi clock (SCK) speed in HZ */
240                 .bus_num = 0,
241                 .chip_select = 5,
242                 .controller_data = &mmc_spi_chip_info,
243                 .mode = SPI_MODE_3,
244         },
245 #endif
246 #if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
247 {
248         .modalias               = "ad7877",
249         .platform_data          = &bfin_ad7877_ts_info,
250         .irq                    = IRQ_PF2,
251         .max_speed_hz           = 12500000,     /* max spi clock (SCK) speed in HZ */
252         .bus_num                = 0,
253         .chip_select            = 5,
254 },
255 #endif
256
257 };
258
259 /* SPI (0) */
260 static struct resource bfin_spi0_resource[] = {
261         [0] = {
262                 .start = SPI0_REGBASE,
263                 .end   = SPI0_REGBASE + 0xFF,
264                 .flags = IORESOURCE_MEM,
265                 },
266         [1] = {
267                 .start = CH_SPI,
268                 .end   = CH_SPI,
269                 .flags = IORESOURCE_DMA,
270         },
271         [2] = {
272                 .start = IRQ_SPI,
273                 .end   = IRQ_SPI,
274                 .flags = IORESOURCE_IRQ,
275         },
276 };
277
278 /* SPI controller data */
279 static struct bfin5xx_spi_master bfin_spi0_info = {
280         .num_chipselect = 8,
281         .enable_dma = 1,  /* master has the ability to do dma transfer */
282         .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
283 };
284
285 static struct platform_device bfin_spi0_device = {
286         .name = "bfin-spi",
287         .id = 0, /* Bus number */
288         .num_resources = ARRAY_SIZE(bfin_spi0_resource),
289         .resource = bfin_spi0_resource,
290         .dev = {
291                 .platform_data = &bfin_spi0_info, /* Passed to driver */
292         },
293 };
294 #endif  /* spi master and devices */
295
296 #if defined(CONFIG_FB_BF537_LQ035) || defined(CONFIG_FB_BF537_LQ035_MODULE)
297 static struct platform_device bfin_fb_device = {
298         .name = "bf537-lq035",
299 };
300 #endif
301
302 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
303 #ifdef CONFIG_SERIAL_BFIN_UART0
304 static struct resource bfin_uart0_resources[] = {
305         {
306                 .start = UART0_THR,
307                 .end = UART0_GCTL+2,
308                 .flags = IORESOURCE_MEM,
309         },
310         {
311                 .start = IRQ_UART0_RX,
312                 .end = IRQ_UART0_RX+1,
313                 .flags = IORESOURCE_IRQ,
314         },
315         {
316                 .start = IRQ_UART0_ERROR,
317                 .end = IRQ_UART0_ERROR,
318                 .flags = IORESOURCE_IRQ,
319         },
320         {
321                 .start = CH_UART0_TX,
322                 .end = CH_UART0_TX,
323                 .flags = IORESOURCE_DMA,
324         },
325         {
326                 .start = CH_UART0_RX,
327                 .end = CH_UART0_RX,
328                 .flags = IORESOURCE_DMA,
329         },
330 };
331
332 static unsigned short bfin_uart0_peripherals[] = {
333         P_UART0_TX, P_UART0_RX, 0
334 };
335
336 static struct platform_device bfin_uart0_device = {
337         .name = "bfin-uart",
338         .id = 0,
339         .num_resources = ARRAY_SIZE(bfin_uart0_resources),
340         .resource = bfin_uart0_resources,
341         .dev = {
342                 .platform_data = &bfin_uart0_peripherals, /* Passed to driver */
343         },
344 };
345 #endif
346 #ifdef CONFIG_SERIAL_BFIN_UART1
347 static struct resource bfin_uart1_resources[] = {
348         {
349                 .start = UART1_THR,
350                 .end = UART1_GCTL+2,
351                 .flags = IORESOURCE_MEM,
352         },
353         {
354                 .start = IRQ_UART1_RX,
355                 .end = IRQ_UART1_RX+1,
356                 .flags = IORESOURCE_IRQ,
357         },
358         {
359                 .start = IRQ_UART1_ERROR,
360                 .end = IRQ_UART1_ERROR,
361                 .flags = IORESOURCE_IRQ,
362         },
363         {
364                 .start = CH_UART1_TX,
365                 .end = CH_UART1_TX,
366                 .flags = IORESOURCE_DMA,
367         },
368         {
369                 .start = CH_UART1_RX,
370                 .end = CH_UART1_RX,
371                 .flags = IORESOURCE_DMA,
372         },
373 };
374
375 static unsigned short bfin_uart1_peripherals[] = {
376         P_UART1_TX, P_UART1_RX, 0
377 };
378
379 static struct platform_device bfin_uart1_device = {
380         .name = "bfin-uart",
381         .id = 1,
382         .num_resources = ARRAY_SIZE(bfin_uart1_resources),
383         .resource = bfin_uart1_resources,
384         .dev = {
385                 .platform_data = &bfin_uart1_peripherals, /* Passed to driver */
386         },
387 };
388 #endif
389 #endif
390
391 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
392 #ifdef CONFIG_BFIN_SIR0
393 static struct resource bfin_sir0_resources[] = {
394         {
395                 .start = 0xFFC00400,
396                 .end = 0xFFC004FF,
397                 .flags = IORESOURCE_MEM,
398         },
399         {
400                 .start = IRQ_UART0_RX,
401                 .end = IRQ_UART0_RX+1,
402                 .flags = IORESOURCE_IRQ,
403         },
404         {
405                 .start = CH_UART0_RX,
406                 .end = CH_UART0_RX+1,
407                 .flags = IORESOURCE_DMA,
408         },
409 };
410
411 static struct platform_device bfin_sir0_device = {
412         .name = "bfin_sir",
413         .id = 0,
414         .num_resources = ARRAY_SIZE(bfin_sir0_resources),
415         .resource = bfin_sir0_resources,
416 };
417 #endif
418 #ifdef CONFIG_BFIN_SIR1
419 static struct resource bfin_sir1_resources[] = {
420         {
421                 .start = 0xFFC02000,
422                 .end = 0xFFC020FF,
423                 .flags = IORESOURCE_MEM,
424         },
425         {
426                 .start = IRQ_UART1_RX,
427                 .end = IRQ_UART1_RX+1,
428                 .flags = IORESOURCE_IRQ,
429         },
430         {
431                 .start = CH_UART1_RX,
432                 .end = CH_UART1_RX+1,
433                 .flags = IORESOURCE_DMA,
434         },
435 };
436
437 static struct platform_device bfin_sir1_device = {
438         .name = "bfin_sir",
439         .id = 1,
440         .num_resources = ARRAY_SIZE(bfin_sir1_resources),
441         .resource = bfin_sir1_resources,
442 };
443 #endif
444 #endif
445
446 static struct platform_device *stamp_devices[] __initdata = {
447 #if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE)
448         &bfin_pcmcia_cf_device,
449 #endif
450
451 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
452         &rtc_device,
453 #endif
454
455 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
456         &smc91x_device,
457 #endif
458
459 #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
460         &bfin_mii_bus,
461         &bfin_mac_device,
462 #endif
463
464 #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
465         &net2272_bfin_device,
466 #endif
467
468 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
469         &bfin_spi0_device,
470 #endif
471
472 #if defined(CONFIG_FB_BF537_LQ035) || defined(CONFIG_FB_BF537_LQ035_MODULE)
473         &bfin_fb_device,
474 #endif
475
476 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
477 #ifdef CONFIG_SERIAL_BFIN_UART0
478         &bfin_uart0_device,
479 #endif
480 #ifdef CONFIG_SERIAL_BFIN_UART1
481         &bfin_uart1_device,
482 #endif
483 #endif
484
485 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
486 #ifdef CONFIG_BFIN_SIR0
487         &bfin_sir0_device,
488 #endif
489 #ifdef CONFIG_BFIN_SIR1
490         &bfin_sir1_device,
491 #endif
492 #endif
493 };
494
495 static int __init pnav_init(void)
496 {
497         printk(KERN_INFO "%s(): registering device resources\n", __func__);
498         platform_add_devices(stamp_devices, ARRAY_SIZE(stamp_devices));
499 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
500         spi_register_board_info(bfin_spi_board_info,
501                                 ARRAY_SIZE(bfin_spi_board_info));
502 #endif
503         return 0;
504 }
505
506 arch_initcall(pnav_init);
507
508 static struct platform_device *stamp_early_devices[] __initdata = {
509 #if defined(CONFIG_SERIAL_BFIN_CONSOLE) || defined(CONFIG_EARLY_PRINTK)
510 #ifdef CONFIG_SERIAL_BFIN_UART0
511         &bfin_uart0_device,
512 #endif
513 #ifdef CONFIG_SERIAL_BFIN_UART1
514         &bfin_uart1_device,
515 #endif
516 #endif
517 };
518
519 void __init native_machine_early_platform_add_devices(void)
520 {
521         printk(KERN_INFO "register early platform devices\n");
522         early_platform_add_devices(stamp_early_devices,
523                 ARRAY_SIZE(stamp_early_devices));
524 }
525
526 void bfin_get_ether_addr(char *addr)
527 {
528         random_ether_addr(addr);
529         printk(KERN_WARNING "%s:%s: Setting Ethernet MAC to a random one\n", __FILE__, __func__);
530 }
531 EXPORT_SYMBOL(bfin_get_ether_addr);