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