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