Merge branch 'master' of /home/cbou/linux-2.6
[pandora-kernel.git] / arch / blackfin / mach-bf537 / boards / cm_bf537.c
1 /*
2  * File:         arch/blackfin/mach-bf537/boards/cm_bf537.c
3  * Based on:     arch/blackfin/mach-bf533/boards/ezkit.c
4  * Author:       Aidan Williams <aidan@nicta.com.au>
5  *
6  * Created:      2005
7  * Description:  Board description file
8  *
9  * Modified:
10  *               Copyright 2005 National ICT Australia (NICTA)
11  *               Copyright 2004-2006 Analog Devices Inc.
12  *
13  * Bugs:         Enter bugs at http://blackfin.uclinux.org/
14  *
15  * This program is free software; you can redistribute it and/or modify
16  * it under the terms of the GNU General Public License as published by
17  * the Free Software Foundation; either version 2 of the License, or
18  * (at your option) any later version.
19  *
20  * This program is distributed in the hope that it will be useful,
21  * but WITHOUT ANY WARRANTY; without even the implied warranty of
22  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23  * GNU General Public License for more details.
24  *
25  * You should have received a copy of the GNU General Public License
26  * along with this program; if not, see the file COPYING, or write
27  * to the Free Software Foundation, Inc.,
28  * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
29  */
30
31 #include <linux/device.h>
32 #include <linux/etherdevice.h>
33 #include <linux/platform_device.h>
34 #include <linux/mtd/mtd.h>
35 #include <linux/mtd/partitions.h>
36 #include <linux/spi/spi.h>
37 #include <linux/spi/flash.h>
38 #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
39 #include <linux/usb/isp1362.h>
40 #endif
41 #include <linux/ata_platform.h>
42 #include <linux/irq.h>
43 #include <asm/dma.h>
44 #include <asm/bfin5xx_spi.h>
45 #include <asm/portmux.h>
46 #include <asm/dpmc.h>
47
48 /*
49  * Name the Board for the /proc/cpuinfo
50  */
51 const char bfin_board_name[] = "Bluetechnix CM BF537";
52
53 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
54 /* all SPI peripherals info goes here */
55
56 #if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE)
57 static struct mtd_partition bfin_spi_flash_partitions[] = {
58         {
59                 .name = "bootloader",
60                 .size = 0x00020000,
61                 .offset = 0,
62                 .mask_flags = MTD_CAP_ROM
63         }, {
64                 .name = "kernel",
65                 .size = 0xe0000,
66                 .offset = 0x20000
67         }, {
68                 .name = "file system",
69                 .size = 0x700000,
70                 .offset = 0x00100000,
71         }
72 };
73
74 static struct flash_platform_data bfin_spi_flash_data = {
75         .name = "m25p80",
76         .parts = bfin_spi_flash_partitions,
77         .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
78         .type = "m25p64",
79 };
80
81 /* SPI flash chip (m25p64) */
82 static struct bfin5xx_spi_chip spi_flash_chip_info = {
83         .enable_dma = 0,         /* use dma transfer with this chip*/
84         .bits_per_word = 8,
85 };
86 #endif
87
88 #if defined(CONFIG_SPI_ADC_BF533) || defined(CONFIG_SPI_ADC_BF533_MODULE)
89 /* SPI ADC chip */
90 static struct bfin5xx_spi_chip spi_adc_chip_info = {
91         .enable_dma = 1,         /* use dma transfer with this chip*/
92         .bits_per_word = 16,
93 };
94 #endif
95
96 #if defined(CONFIG_SND_BLACKFIN_AD1836) || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
97 static struct bfin5xx_spi_chip ad1836_spi_chip_info = {
98         .enable_dma = 0,
99         .bits_per_word = 16,
100 };
101 #endif
102
103 #if defined(CONFIG_AD9960) || defined(CONFIG_AD9960_MODULE)
104 static struct bfin5xx_spi_chip ad9960_spi_chip_info = {
105         .enable_dma = 0,
106         .bits_per_word = 16,
107 };
108 #endif
109
110 #if defined(CONFIG_SPI_MMC) || defined(CONFIG_SPI_MMC_MODULE)
111 static struct bfin5xx_spi_chip spi_mmc_chip_info = {
112         .enable_dma = 1,
113         .bits_per_word = 8,
114 };
115 #endif
116
117 static struct spi_board_info bfin_spi_board_info[] __initdata = {
118 #if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE)
119         {
120                 /* the modalias must be the same as spi device driver name */
121                 .modalias = "m25p80", /* Name of spi_driver for this device */
122                 .max_speed_hz = 25000000,     /* max spi clock (SCK) speed in HZ */
123                 .bus_num = 0, /* Framework bus number */
124                 .chip_select = 1, /* Framework chip select. On STAMP537 it is SPISSEL1*/
125                 .platform_data = &bfin_spi_flash_data,
126                 .controller_data = &spi_flash_chip_info,
127                 .mode = SPI_MODE_3,
128         },
129 #endif
130
131 #if defined(CONFIG_SPI_ADC_BF533) || defined(CONFIG_SPI_ADC_BF533_MODULE)
132         {
133                 .modalias = "bfin_spi_adc", /* Name of spi_driver for this device */
134                 .max_speed_hz = 6250000,     /* max spi clock (SCK) speed in HZ */
135                 .bus_num = 0, /* Framework bus number */
136                 .chip_select = 1, /* Framework chip select. */
137                 .platform_data = NULL, /* No spi_driver specific config */
138                 .controller_data = &spi_adc_chip_info,
139         },
140 #endif
141
142 #if defined(CONFIG_SND_BLACKFIN_AD1836) || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
143         {
144                 .modalias = "ad1836-spi",
145                 .max_speed_hz = 3125000,     /* max spi clock (SCK) speed in HZ */
146                 .bus_num = 0,
147                 .chip_select = CONFIG_SND_BLACKFIN_SPI_PFBIT,
148                 .controller_data = &ad1836_spi_chip_info,
149         },
150 #endif
151
152 #if defined(CONFIG_AD9960) || defined(CONFIG_AD9960_MODULE)
153         {
154                 .modalias = "ad9960-spi",
155                 .max_speed_hz = 10000000,     /* max spi clock (SCK) speed in HZ */
156                 .bus_num = 0,
157                 .chip_select = 1,
158                 .controller_data = &ad9960_spi_chip_info,
159         },
160 #endif
161
162 #if defined(CONFIG_SPI_MMC) || defined(CONFIG_SPI_MMC_MODULE)
163         {
164                 .modalias = "spi_mmc_dummy",
165                 .max_speed_hz = 25000000,     /* max spi clock (SCK) speed in HZ */
166                 .bus_num = 0,
167                 .chip_select = 7,
168                 .platform_data = NULL,
169                 .controller_data = &spi_mmc_chip_info,
170                 .mode = SPI_MODE_3,
171         },
172         {
173                 .modalias = "spi_mmc",
174                 .max_speed_hz = 25000000,     /* max spi clock (SCK) speed in HZ */
175                 .bus_num = 0,
176                 .chip_select = CONFIG_SPI_MMC_CS_CHAN,
177                 .platform_data = NULL,
178                 .controller_data = &spi_mmc_chip_info,
179                 .mode = SPI_MODE_3,
180         },
181 #endif
182 };
183
184 /* SPI (0) */
185 static struct resource bfin_spi0_resource[] = {
186         [0] = {
187                 .start = SPI0_REGBASE,
188                 .end   = SPI0_REGBASE + 0xFF,
189                 .flags = IORESOURCE_MEM,
190                 },
191         [1] = {
192                 .start = CH_SPI,
193                 .end   = CH_SPI,
194                 .flags = IORESOURCE_IRQ,
195         }
196 };
197
198 /* SPI controller data */
199 static struct bfin5xx_spi_master bfin_spi0_info = {
200         .num_chipselect = 8,
201         .enable_dma = 1,  /* master has the ability to do dma transfer */
202         .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
203 };
204
205 static struct platform_device bfin_spi0_device = {
206         .name = "bfin-spi",
207         .id = 0, /* Bus number */
208         .num_resources = ARRAY_SIZE(bfin_spi0_resource),
209         .resource = bfin_spi0_resource,
210         .dev = {
211                 .platform_data = &bfin_spi0_info, /* Passed to driver */
212         },
213 };
214 #endif  /* spi master and devices */
215
216 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
217 static struct platform_device rtc_device = {
218         .name = "rtc-bfin",
219         .id   = -1,
220 };
221 #endif
222
223 #if defined(CONFIG_FB_HITACHI_TX09) || defined(CONFIG_FB_HITACHI_TX09_MODULE)
224 static struct platform_device hitachi_fb_device = {
225         .name = "hitachi-tx09",
226 };
227 #endif
228
229 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
230 static struct resource smc91x_resources[] = {
231         {
232                 .start = 0x20200300,
233                 .end = 0x20200300 + 16,
234                 .flags = IORESOURCE_MEM,
235         }, {
236                 .start = IRQ_PF14,
237                 .end = IRQ_PF14,
238                 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
239                 },
240 };
241
242 static struct platform_device smc91x_device = {
243         .name = "smc91x",
244         .id = 0,
245         .num_resources = ARRAY_SIZE(smc91x_resources),
246         .resource = smc91x_resources,
247 };
248 #endif
249
250 #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
251 static struct resource isp1362_hcd_resources[] = {
252         {
253                 .start = 0x20308000,
254                 .end = 0x20308000,
255                 .flags = IORESOURCE_MEM,
256         }, {
257                 .start = 0x20308004,
258                 .end = 0x20308004,
259                 .flags = IORESOURCE_MEM,
260         }, {
261                 .start = IRQ_PG15,
262                 .end = IRQ_PG15,
263                 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
264         },
265 };
266
267 static struct isp1362_platform_data isp1362_priv = {
268         .sel15Kres = 1,
269         .clknotstop = 0,
270         .oc_enable = 0,
271         .int_act_high = 0,
272         .int_edge_triggered = 0,
273         .remote_wakeup_connected = 0,
274         .no_power_switching = 1,
275         .power_switching_mode = 0,
276 };
277
278 static struct platform_device isp1362_hcd_device = {
279         .name = "isp1362-hcd",
280         .id = 0,
281         .dev = {
282                 .platform_data = &isp1362_priv,
283         },
284         .num_resources = ARRAY_SIZE(isp1362_hcd_resources),
285         .resource = isp1362_hcd_resources,
286 };
287 #endif
288
289 #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
290 static struct resource net2272_bfin_resources[] = {
291         {
292                 .start = 0x20200000,
293                 .end = 0x20200000 + 0x100,
294                 .flags = IORESOURCE_MEM,
295         }, {
296                 .start = IRQ_PH14,
297                 .end = IRQ_PH14,
298                 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
299         },
300 };
301
302 static struct platform_device net2272_bfin_device = {
303         .name = "net2272",
304         .id = -1,
305         .num_resources = ARRAY_SIZE(net2272_bfin_resources),
306         .resource = net2272_bfin_resources,
307 };
308 #endif
309
310 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
311 static struct resource bfin_uart_resources[] = {
312         {
313                 .start = 0xFFC00400,
314                 .end = 0xFFC004FF,
315                 .flags = IORESOURCE_MEM,
316         }, {
317                 .start = 0xFFC02000,
318                 .end = 0xFFC020FF,
319                 .flags = IORESOURCE_MEM,
320         },
321 };
322
323 static struct platform_device bfin_uart_device = {
324         .name = "bfin-uart",
325         .id = 1,
326         .num_resources = ARRAY_SIZE(bfin_uart_resources),
327         .resource = bfin_uart_resources,
328 };
329 #endif
330
331 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
332 static struct resource bfin_sir_resources[] = {
333 #ifdef CONFIG_BFIN_SIR0
334         {
335                 .start = 0xFFC00400,
336                 .end = 0xFFC004FF,
337                 .flags = IORESOURCE_MEM,
338         },
339 #endif
340 #ifdef CONFIG_BFIN_SIR1
341         {
342                 .start = 0xFFC02000,
343                 .end = 0xFFC020FF,
344                 .flags = IORESOURCE_MEM,
345         },
346 #endif
347 };
348
349 static struct platform_device bfin_sir_device = {
350         .name = "bfin_sir",
351         .id = 0,
352         .num_resources = ARRAY_SIZE(bfin_sir_resources),
353         .resource = bfin_sir_resources,
354 };
355 #endif
356
357 #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
358 static struct resource bfin_twi0_resource[] = {
359         [0] = {
360                 .start = TWI0_REGBASE,
361                 .end   = TWI0_REGBASE,
362                 .flags = IORESOURCE_MEM,
363         },
364         [1] = {
365                 .start = IRQ_TWI,
366                 .end   = IRQ_TWI,
367                 .flags = IORESOURCE_IRQ,
368         },
369 };
370
371 static struct platform_device i2c_bfin_twi_device = {
372         .name = "i2c-bfin-twi",
373         .id = 0,
374         .num_resources = ARRAY_SIZE(bfin_twi0_resource),
375         .resource = bfin_twi0_resource,
376 };
377 #endif
378
379 #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
380 static struct platform_device bfin_sport0_uart_device = {
381         .name = "bfin-sport-uart",
382         .id = 0,
383 };
384
385 static struct platform_device bfin_sport1_uart_device = {
386         .name = "bfin-sport-uart",
387         .id = 1,
388 };
389 #endif
390
391 #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
392 static struct platform_device bfin_mac_device = {
393         .name = "bfin_mac",
394 };
395 #endif
396
397 #if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
398 #define PATA_INT        64
399
400 static struct pata_platform_info bfin_pata_platform_data = {
401         .ioport_shift = 2,
402         .irq_type = IRQF_TRIGGER_HIGH | IRQF_DISABLED,
403 };
404
405 static struct resource bfin_pata_resources[] = {
406         {
407                 .start = 0x2030C000,
408                 .end = 0x2030C01F,
409                 .flags = IORESOURCE_MEM,
410         },
411         {
412                 .start = 0x2030D018,
413                 .end = 0x2030D01B,
414                 .flags = IORESOURCE_MEM,
415         },
416         {
417                 .start = PATA_INT,
418                 .end = PATA_INT,
419                 .flags = IORESOURCE_IRQ,
420         },
421 };
422
423 static struct platform_device bfin_pata_device = {
424         .name = "pata_platform",
425         .id = -1,
426         .num_resources = ARRAY_SIZE(bfin_pata_resources),
427         .resource = bfin_pata_resources,
428         .dev = {
429                 .platform_data = &bfin_pata_platform_data,
430         }
431 };
432 #endif
433
434 static const unsigned int cclk_vlev_datasheet[] =
435 {
436         VRPAIR(VLEV_085, 250000000),
437         VRPAIR(VLEV_090, 376000000),
438         VRPAIR(VLEV_095, 426000000),
439         VRPAIR(VLEV_100, 426000000),
440         VRPAIR(VLEV_105, 476000000),
441         VRPAIR(VLEV_110, 476000000),
442         VRPAIR(VLEV_115, 476000000),
443         VRPAIR(VLEV_120, 500000000),
444         VRPAIR(VLEV_125, 533000000),
445         VRPAIR(VLEV_130, 600000000),
446 };
447
448 static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
449         .tuple_tab = cclk_vlev_datasheet,
450         .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
451         .vr_settling_time = 25 /* us */,
452 };
453
454 static struct platform_device bfin_dpmc = {
455         .name = "bfin dpmc",
456         .dev = {
457                 .platform_data = &bfin_dmpc_vreg_data,
458         },
459 };
460
461 static struct platform_device *cm_bf537_devices[] __initdata = {
462
463         &bfin_dpmc,
464
465 #if defined(CONFIG_FB_HITACHI_TX09) || defined(CONFIG_FB_HITACHI_TX09_MODULE)
466         &hitachi_fb_device,
467 #endif
468
469 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
470         &rtc_device,
471 #endif
472
473 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
474         &bfin_uart_device,
475 #endif
476
477 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
478         &bfin_sir_device,
479 #endif
480
481 #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
482         &i2c_bfin_twi_device,
483 #endif
484
485 #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
486         &bfin_sport0_uart_device,
487         &bfin_sport1_uart_device,
488 #endif
489
490 #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
491         &isp1362_hcd_device,
492 #endif
493
494 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
495         &smc91x_device,
496 #endif
497
498 #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
499         &bfin_mac_device,
500 #endif
501
502 #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
503         &net2272_bfin_device,
504 #endif
505
506 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
507         &bfin_spi0_device,
508 #endif
509
510 #if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
511         &bfin_pata_device,
512 #endif
513 };
514
515 static int __init cm_bf537_init(void)
516 {
517         printk(KERN_INFO "%s(): registering device resources\n", __func__);
518         platform_add_devices(cm_bf537_devices, ARRAY_SIZE(cm_bf537_devices));
519 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
520         spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
521 #endif
522
523 #if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
524         irq_desc[PATA_INT].status |= IRQ_NOAUTOEN;
525 #endif
526         return 0;
527 }
528
529 arch_initcall(cm_bf537_init);
530
531 void bfin_get_ether_addr(char *addr)
532 {
533         random_ether_addr(addr);
534         printk(KERN_WARNING "%s:%s: Setting Ethernet MAC to a random one\n", __FILE__, __func__);
535 }
536 EXPORT_SYMBOL(bfin_get_ether_addr);