283be6340c688b548620f83a3d70bfb1a9ff619e
[safe/jmp/linux-2.6] / arch / blackfin / mach-bf548 / boards / cm_bf548.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/irq.h>
18 #include <linux/interrupt.h>
19 #include <linux/usb/musb.h>
20 #include <asm/bfin5xx_spi.h>
21 #include <asm/dma.h>
22 #include <asm/gpio.h>
23 #include <asm/nand.h>
24 #include <asm/portmux.h>
25 #include <asm/bfin_sdh.h>
26 #include <mach/bf54x_keys.h>
27 #include <asm/dpmc.h>
28 #include <linux/input.h>
29 #include <linux/spi/ad7877.h>
30
31 /*
32  * Name the Board for the /proc/cpuinfo
33  */
34 const char bfin_board_name[] = "Bluetechnix CM-BF548";
35
36 /*
37  *  Driver needs to know address, irq and flag pin.
38  */
39
40 #if defined(CONFIG_FB_BF54X_LQ043) || defined(CONFIG_FB_BF54X_LQ043_MODULE)
41
42 #include <mach/bf54x-lq043.h>
43
44 static struct bfin_bf54xfb_mach_info bf54x_lq043_data = {
45         .width =        480,
46         .height =       272,
47         .xres =         {480, 480, 480},
48         .yres =         {272, 272, 272},
49         .bpp =          {24, 24, 24},
50         .disp =         GPIO_PE3,
51 };
52
53 static struct resource bf54x_lq043_resources[] = {
54         {
55                 .start = IRQ_EPPI0_ERR,
56                 .end = IRQ_EPPI0_ERR,
57                 .flags = IORESOURCE_IRQ,
58         },
59 };
60
61 static struct platform_device bf54x_lq043_device = {
62         .name           = "bf54x-lq043",
63         .id             = -1,
64         .num_resources  = ARRAY_SIZE(bf54x_lq043_resources),
65         .resource       = bf54x_lq043_resources,
66         .dev            = {
67                 .platform_data = &bf54x_lq043_data,
68         },
69 };
70 #endif
71
72 #if defined(CONFIG_KEYBOARD_BFIN) || defined(CONFIG_KEYBOARD_BFIN_MODULE)
73 static unsigned int bf548_keymap[] = {
74         KEYVAL(0, 0, KEY_ENTER),
75         KEYVAL(0, 1, KEY_HELP),
76         KEYVAL(0, 2, KEY_0),
77         KEYVAL(0, 3, KEY_BACKSPACE),
78         KEYVAL(1, 0, KEY_TAB),
79         KEYVAL(1, 1, KEY_9),
80         KEYVAL(1, 2, KEY_8),
81         KEYVAL(1, 3, KEY_7),
82         KEYVAL(2, 0, KEY_DOWN),
83         KEYVAL(2, 1, KEY_6),
84         KEYVAL(2, 2, KEY_5),
85         KEYVAL(2, 3, KEY_4),
86         KEYVAL(3, 0, KEY_UP),
87         KEYVAL(3, 1, KEY_3),
88         KEYVAL(3, 2, KEY_2),
89         KEYVAL(3, 3, KEY_1),
90 };
91
92 static struct bfin_kpad_platform_data bf54x_kpad_data = {
93         .rows                   = 4,
94         .cols                   = 4,
95         .keymap                 = bf548_keymap,
96         .keymapsize             = ARRAY_SIZE(bf548_keymap),
97         .repeat                 = 0,
98         .debounce_time          = 5000, /* ns (5ms) */
99         .coldrive_time          = 1000, /* ns (1ms) */
100         .keyup_test_interval    = 50, /* ms (50ms) */
101 };
102
103 static struct resource bf54x_kpad_resources[] = {
104         {
105                 .start = IRQ_KEY,
106                 .end = IRQ_KEY,
107                 .flags = IORESOURCE_IRQ,
108         },
109 };
110
111 static struct platform_device bf54x_kpad_device = {
112         .name           = "bf54x-keys",
113         .id             = -1,
114         .num_resources  = ARRAY_SIZE(bf54x_kpad_resources),
115         .resource       = bf54x_kpad_resources,
116         .dev            = {
117                 .platform_data = &bf54x_kpad_data,
118         },
119 };
120 #endif
121
122 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
123 static struct platform_device rtc_device = {
124         .name = "rtc-bfin",
125         .id   = -1,
126 };
127 #endif
128
129 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
130 static struct resource bfin_uart_resources[] = {
131 #ifdef CONFIG_SERIAL_BFIN_UART0
132         {
133                 .start = 0xFFC00400,
134                 .end = 0xFFC004FF,
135                 .flags = IORESOURCE_MEM,
136         },
137 #endif
138 #ifdef CONFIG_SERIAL_BFIN_UART1
139         {
140                 .start = 0xFFC02000,
141                 .end = 0xFFC020FF,
142                 .flags = IORESOURCE_MEM,
143         },
144 #endif
145 #ifdef CONFIG_SERIAL_BFIN_UART2
146         {
147                 .start = 0xFFC02100,
148                 .end = 0xFFC021FF,
149                 .flags = IORESOURCE_MEM,
150         },
151 #endif
152 #ifdef CONFIG_SERIAL_BFIN_UART3
153         {
154                 .start = 0xFFC03100,
155                 .end = 0xFFC031FF,
156                 .flags = IORESOURCE_MEM,
157         },
158 #endif
159 };
160
161 static struct platform_device bfin_uart_device = {
162         .name = "bfin-uart",
163         .id = 1,
164         .num_resources = ARRAY_SIZE(bfin_uart_resources),
165         .resource = bfin_uart_resources,
166 };
167 #endif
168
169 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
170 #ifdef CONFIG_BFIN_SIR0
171 static struct resource bfin_sir0_resources[] = {
172         {
173                 .start = 0xFFC00400,
174                 .end = 0xFFC004FF,
175                 .flags = IORESOURCE_MEM,
176         },
177         {
178                 .start = IRQ_UART0_RX,
179                 .end = IRQ_UART0_RX+1,
180                 .flags = IORESOURCE_IRQ,
181         },
182         {
183                 .start = CH_UART0_RX,
184                 .end = CH_UART0_RX+1,
185                 .flags = IORESOURCE_DMA,
186         },
187 };
188 static struct platform_device bfin_sir0_device = {
189         .name = "bfin_sir",
190         .id = 0,
191         .num_resources = ARRAY_SIZE(bfin_sir0_resources),
192         .resource = bfin_sir0_resources,
193 };
194 #endif
195 #ifdef CONFIG_BFIN_SIR1
196 static struct resource bfin_sir1_resources[] = {
197         {
198                 .start = 0xFFC02000,
199                 .end = 0xFFC020FF,
200                 .flags = IORESOURCE_MEM,
201         },
202         {
203                 .start = IRQ_UART1_RX,
204                 .end = IRQ_UART1_RX+1,
205                 .flags = IORESOURCE_IRQ,
206         },
207         {
208                 .start = CH_UART1_RX,
209                 .end = CH_UART1_RX+1,
210                 .flags = IORESOURCE_DMA,
211         },
212 };
213 static struct platform_device bfin_sir1_device = {
214         .name = "bfin_sir",
215         .id = 1,
216         .num_resources = ARRAY_SIZE(bfin_sir1_resources),
217         .resource = bfin_sir1_resources,
218 };
219 #endif
220 #ifdef CONFIG_BFIN_SIR2
221 static struct resource bfin_sir2_resources[] = {
222         {
223                 .start = 0xFFC02100,
224                 .end = 0xFFC021FF,
225                 .flags = IORESOURCE_MEM,
226         },
227         {
228                 .start = IRQ_UART2_RX,
229                 .end = IRQ_UART2_RX+1,
230                 .flags = IORESOURCE_IRQ,
231         },
232         {
233                 .start = CH_UART2_RX,
234                 .end = CH_UART2_RX+1,
235                 .flags = IORESOURCE_DMA,
236         },
237 };
238 static struct platform_device bfin_sir2_device = {
239         .name = "bfin_sir",
240         .id = 2,
241         .num_resources = ARRAY_SIZE(bfin_sir2_resources),
242         .resource = bfin_sir2_resources,
243 };
244 #endif
245 #ifdef CONFIG_BFIN_SIR3
246 static struct resource bfin_sir3_resources[] = {
247         {
248                 .start = 0xFFC03100,
249                 .end = 0xFFC031FF,
250                 .flags = IORESOURCE_MEM,
251         },
252         {
253                 .start = IRQ_UART3_RX,
254                 .end = IRQ_UART3_RX+1,
255                 .flags = IORESOURCE_IRQ,
256         },
257         {
258                 .start = CH_UART3_RX,
259                 .end = CH_UART3_RX+1,
260                 .flags = IORESOURCE_DMA,
261         },
262 };
263 static struct platform_device bfin_sir3_device = {
264         .name = "bfin_sir",
265         .id = 3,
266         .num_resources = ARRAY_SIZE(bfin_sir3_resources),
267         .resource = bfin_sir3_resources,
268 };
269 #endif
270 #endif
271
272 #if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE)
273 #include <linux/smsc911x.h>
274
275 static struct resource smsc911x_resources[] = {
276         {
277                 .name = "smsc911x-memory",
278                 .start = 0x24000000,
279                 .end = 0x24000000 + 0xFF,
280                 .flags = IORESOURCE_MEM,
281         },
282         {
283                 .start = IRQ_PE6,
284                 .end = IRQ_PE6,
285                 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
286         },
287 };
288
289 static struct smsc911x_platform_config smsc911x_config = {
290         .flags = SMSC911X_USE_16BIT,
291         .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
292         .irq_type = SMSC911X_IRQ_TYPE_OPEN_DRAIN,
293         .phy_interface = PHY_INTERFACE_MODE_MII,
294 };
295
296 static struct platform_device smsc911x_device = {
297         .name = "smsc911x",
298         .id = 0,
299         .num_resources = ARRAY_SIZE(smsc911x_resources),
300         .resource = smsc911x_resources,
301         .dev = {
302                 .platform_data = &smsc911x_config,
303         },
304 };
305 #endif
306
307 #if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE)
308 static struct resource musb_resources[] = {
309         [0] = {
310                 .start  = 0xFFC03C00,
311                 .end    = 0xFFC040FF,
312                 .flags  = IORESOURCE_MEM,
313         },
314         [1] = { /* general IRQ */
315                 .start  = IRQ_USB_INT0,
316                 .end    = IRQ_USB_INT0,
317                 .flags  = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
318         },
319         [2] = { /* DMA IRQ */
320                 .start  = IRQ_USB_DMA,
321                 .end    = IRQ_USB_DMA,
322                 .flags  = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
323         },
324 };
325
326 static struct musb_hdrc_config musb_config = {
327         .multipoint     = 0,
328         .dyn_fifo       = 0,
329         .soft_con       = 1,
330         .dma            = 1,
331         .num_eps        = 8,
332         .dma_channels   = 8,
333         .gpio_vrsel     = GPIO_PH6,
334 };
335
336 static struct musb_hdrc_platform_data musb_plat = {
337 #if defined(CONFIG_USB_MUSB_OTG)
338         .mode           = MUSB_OTG,
339 #elif defined(CONFIG_USB_MUSB_HDRC_HCD)
340         .mode           = MUSB_HOST,
341 #elif defined(CONFIG_USB_GADGET_MUSB_HDRC)
342         .mode           = MUSB_PERIPHERAL,
343 #endif
344         .config         = &musb_config,
345 };
346
347 static u64 musb_dmamask = ~(u32)0;
348
349 static struct platform_device musb_device = {
350         .name           = "musb_hdrc",
351         .id             = 0,
352         .dev = {
353                 .dma_mask               = &musb_dmamask,
354                 .coherent_dma_mask      = 0xffffffff,
355                 .platform_data          = &musb_plat,
356         },
357         .num_resources  = ARRAY_SIZE(musb_resources),
358         .resource       = musb_resources,
359 };
360 #endif
361
362 static struct resource bfin_gpios_resources = {
363         .start = 0,
364         .end   = MAX_BLACKFIN_GPIOS - 1,
365         .flags = IORESOURCE_IRQ,
366 };
367
368 static struct platform_device bfin_gpios_device = {
369         .name = "simple-gpio",
370         .id = -1,
371         .num_resources = 1,
372         .resource = &bfin_gpios_resources,
373 };
374
375 #if defined(CONFIG_PATA_BF54X) || defined(CONFIG_PATA_BF54X_MODULE)
376 static struct resource bfin_atapi_resources[] = {
377         {
378                 .start = 0xFFC03800,
379                 .end = 0xFFC0386F,
380                 .flags = IORESOURCE_MEM,
381         },
382         {
383                 .start = IRQ_ATAPI_ERR,
384                 .end = IRQ_ATAPI_ERR,
385                 .flags = IORESOURCE_IRQ,
386         },
387 };
388
389 static struct platform_device bfin_atapi_device = {
390         .name = "pata-bf54x",
391         .id = -1,
392         .num_resources = ARRAY_SIZE(bfin_atapi_resources),
393         .resource = bfin_atapi_resources,
394 };
395 #endif
396
397 #if defined(CONFIG_MTD_NAND_BF5XX) || defined(CONFIG_MTD_NAND_BF5XX_MODULE)
398 static struct mtd_partition partition_info[] = {
399         {
400                 .name = "linux kernel(nand)",
401                 .offset = 0,
402                 .size = 4 * 1024 * 1024,
403         },
404         {
405                 .name = "file system(nand)",
406                 .offset = 4 * 1024 * 1024,
407                 .size = (256 - 4) * 1024 * 1024,
408         },
409 };
410
411 static struct bf5xx_nand_platform bf5xx_nand_platform = {
412         .page_size = NFC_PG_SIZE_256,
413         .data_width = NFC_NWIDTH_8,
414         .partitions = partition_info,
415         .nr_partitions = ARRAY_SIZE(partition_info),
416         .rd_dly = 3,
417         .wr_dly = 3,
418 };
419
420 static struct resource bf5xx_nand_resources[] = {
421         {
422                 .start = 0xFFC03B00,
423                 .end = 0xFFC03B4F,
424                 .flags = IORESOURCE_MEM,
425         },
426         {
427                 .start = CH_NFC,
428                 .end = CH_NFC,
429                 .flags = IORESOURCE_IRQ,
430         },
431 };
432
433 static struct platform_device bf5xx_nand_device = {
434         .name = "bf5xx-nand",
435         .id = 0,
436         .num_resources = ARRAY_SIZE(bf5xx_nand_resources),
437         .resource = bf5xx_nand_resources,
438         .dev = {
439                 .platform_data = &bf5xx_nand_platform,
440         },
441 };
442 #endif
443
444 #if defined(CONFIG_SDH_BFIN) || defined(CONFIG_SDH_BFIN_MODULE)
445 static struct bfin_sd_host bfin_sdh_data = {
446         .dma_chan = CH_SDH,
447         .irq_int0 = IRQ_SDH_MASK0,
448         .pin_req = {P_SD_D0, P_SD_D1, P_SD_D2, P_SD_D3, P_SD_CLK, P_SD_CMD, 0},
449 };
450
451 static struct platform_device bf54x_sdh_device = {
452         .name = "bfin-sdh",
453         .id = 0,
454         .dev = {
455                 .platform_data = &bfin_sdh_data,
456         },
457 };
458 #endif
459
460 #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
461 static struct mtd_partition para_partitions[] = {
462         {
463                 .name       = "bootloader(nor)",
464                 .size       = 0x40000,
465                 .offset     = 0,
466         }, {
467                 .name       = "linux kernel(nor)",
468                 .size       = 0x100000,
469                 .offset     = MTDPART_OFS_APPEND,
470         }, {
471                 .name       = "file system(nor)",
472                 .size       = MTDPART_SIZ_FULL,
473                 .offset     = MTDPART_OFS_APPEND,
474         }
475 };
476
477 static struct physmap_flash_data para_flash_data = {
478         .width      = 2,
479         .parts      = para_partitions,
480         .nr_parts   = ARRAY_SIZE(para_partitions),
481 };
482
483 static struct resource para_flash_resource = {
484         .start = 0x20000000,
485         .end   = 0x207fffff,
486         .flags = IORESOURCE_MEM,
487 };
488
489 static struct platform_device para_flash_device = {
490         .name          = "physmap-flash",
491         .id            = 0,
492         .dev = {
493                 .platform_data = &para_flash_data,
494         },
495         .num_resources = 1,
496         .resource      = &para_flash_resource,
497 };
498 #endif
499
500 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
501 /* all SPI peripherals info goes here */
502 #if defined(CONFIG_MTD_M25P80) \
503         || defined(CONFIG_MTD_M25P80_MODULE)
504 /* SPI flash chip (m25p16) */
505 static struct mtd_partition bfin_spi_flash_partitions[] = {
506         {
507                 .name = "bootloader(spi)",
508                 .size = 0x00040000,
509                 .offset = 0,
510                 .mask_flags = MTD_CAP_ROM
511         }, {
512                 .name = "linux kernel(spi)",
513                 .size = 0x1c0000,
514                 .offset = 0x40000
515         }
516 };
517
518 static struct flash_platform_data bfin_spi_flash_data = {
519         .name = "m25p80",
520         .parts = bfin_spi_flash_partitions,
521         .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
522         .type = "m25p16",
523 };
524
525 static struct bfin5xx_spi_chip spi_flash_chip_info = {
526         .enable_dma = 0,         /* use dma transfer with this chip*/
527         .bits_per_word = 8,
528 };
529 #endif
530
531 #if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
532 static struct bfin5xx_spi_chip spi_ad7877_chip_info = {
533         .enable_dma = 0,
534         .bits_per_word = 16,
535 };
536
537 static const struct ad7877_platform_data bfin_ad7877_ts_info = {
538         .model                  = 7877,
539         .vref_delay_usecs       = 50,   /* internal, no capacitor */
540         .x_plate_ohms           = 419,
541         .y_plate_ohms           = 486,
542         .pressure_max           = 1000,
543         .pressure_min           = 0,
544         .stopacq_polarity       = 1,
545         .first_conversion_delay = 3,
546         .acquisition_time       = 1,
547         .averaging              = 1,
548         .pen_down_acc_interval  = 1,
549 };
550 #endif
551
552 #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
553 static struct bfin5xx_spi_chip spidev_chip_info = {
554         .enable_dma = 0,
555         .bits_per_word = 8,
556 };
557 #endif
558
559 static struct spi_board_info bf54x_spi_board_info[] __initdata = {
560 #if defined(CONFIG_MTD_M25P80) \
561         || defined(CONFIG_MTD_M25P80_MODULE)
562         {
563                 /* the modalias must be the same as spi device driver name */
564                 .modalias = "m25p80", /* Name of spi_driver for this device */
565                 .max_speed_hz = 25000000,     /* max spi clock (SCK) speed in HZ */
566                 .bus_num = 0, /* Framework bus number */
567                 .chip_select = 1, /* SPI_SSEL1*/
568                 .platform_data = &bfin_spi_flash_data,
569                 .controller_data = &spi_flash_chip_info,
570                 .mode = SPI_MODE_3,
571         },
572 #endif
573 #if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
574 {
575         .modalias               = "ad7877",
576         .platform_data          = &bfin_ad7877_ts_info,
577         .irq                    = IRQ_PJ11,
578         .max_speed_hz           = 12500000,     /* max spi clock (SCK) speed in HZ */
579         .bus_num                = 0,
580         .chip_select            = 2,
581         .controller_data = &spi_ad7877_chip_info,
582 },
583 #endif
584 #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
585         {
586                 .modalias = "spidev",
587                 .max_speed_hz = 3125000,     /* max spi clock (SCK) speed in HZ */
588                 .bus_num = 0,
589                 .chip_select = 1,
590                 .controller_data = &spidev_chip_info,
591         },
592 #endif
593 };
594
595 /* SPI (0) */
596 static struct resource bfin_spi0_resource[] = {
597         [0] = {
598                 .start = SPI0_REGBASE,
599                 .end   = SPI0_REGBASE + 0xFF,
600                 .flags = IORESOURCE_MEM,
601         },
602         [1] = {
603                 .start = CH_SPI0,
604                 .end   = CH_SPI0,
605                 .flags = IORESOURCE_DMA,
606         },
607         [2] = {
608                 .start = IRQ_SPI0,
609                 .end   = IRQ_SPI0,
610                 .flags = IORESOURCE_IRQ,
611         }
612 };
613
614 /* SPI (1) */
615 static struct resource bfin_spi1_resource[] = {
616         [0] = {
617                 .start = SPI1_REGBASE,
618                 .end   = SPI1_REGBASE + 0xFF,
619                 .flags = IORESOURCE_MEM,
620         },
621         [1] = {
622                 .start = CH_SPI1,
623                 .end   = CH_SPI1,
624                 .flags = IORESOURCE_DMA,
625         },
626         [2] = {
627                 .start = IRQ_SPI1,
628                 .end   = IRQ_SPI1,
629                 .flags = IORESOURCE_IRQ,
630         }
631 };
632
633 /* SPI controller data */
634 static struct bfin5xx_spi_master bf54x_spi_master_info0 = {
635         .num_chipselect = 3,
636         .enable_dma = 1,  /* master has the ability to do dma transfer */
637         .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
638 };
639
640 static struct platform_device bf54x_spi_master0 = {
641         .name = "bfin-spi",
642         .id = 0, /* Bus number */
643         .num_resources = ARRAY_SIZE(bfin_spi0_resource),
644         .resource = bfin_spi0_resource,
645         .dev = {
646                 .platform_data = &bf54x_spi_master_info0, /* Passed to driver */
647                 },
648 };
649
650 static struct bfin5xx_spi_master bf54x_spi_master_info1 = {
651         .num_chipselect = 3,
652         .enable_dma = 1,  /* master has the ability to do dma transfer */
653         .pin_req = {P_SPI1_SCK, P_SPI1_MISO, P_SPI1_MOSI, 0},
654 };
655
656 static struct platform_device bf54x_spi_master1 = {
657         .name = "bfin-spi",
658         .id = 1, /* Bus number */
659         .num_resources = ARRAY_SIZE(bfin_spi1_resource),
660         .resource = bfin_spi1_resource,
661         .dev = {
662                 .platform_data = &bf54x_spi_master_info1, /* Passed to driver */
663                 },
664 };
665 #endif  /* spi master and devices */
666
667 #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
668 static struct resource bfin_twi0_resource[] = {
669         [0] = {
670                 .start = TWI0_REGBASE,
671                 .end   = TWI0_REGBASE + 0xFF,
672                 .flags = IORESOURCE_MEM,
673         },
674         [1] = {
675                 .start = IRQ_TWI0,
676                 .end   = IRQ_TWI0,
677                 .flags = IORESOURCE_IRQ,
678         },
679 };
680
681 static struct platform_device i2c_bfin_twi0_device = {
682         .name = "i2c-bfin-twi",
683         .id = 0,
684         .num_resources = ARRAY_SIZE(bfin_twi0_resource),
685         .resource = bfin_twi0_resource,
686 };
687
688 #if !defined(CONFIG_BF542)      /* The BF542 only has 1 TWI */
689 static struct resource bfin_twi1_resource[] = {
690         [0] = {
691                 .start = TWI1_REGBASE,
692                 .end   = TWI1_REGBASE + 0xFF,
693                 .flags = IORESOURCE_MEM,
694         },
695         [1] = {
696                 .start = IRQ_TWI1,
697                 .end   = IRQ_TWI1,
698                 .flags = IORESOURCE_IRQ,
699         },
700 };
701
702 static struct platform_device i2c_bfin_twi1_device = {
703         .name = "i2c-bfin-twi",
704         .id = 1,
705         .num_resources = ARRAY_SIZE(bfin_twi1_resource),
706         .resource = bfin_twi1_resource,
707 };
708 #endif
709 #endif
710
711 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
712 #include <linux/gpio_keys.h>
713
714 static struct gpio_keys_button bfin_gpio_keys_table[] = {
715         {BTN_0, GPIO_PH7, 1, "gpio-keys: BTN0"},
716 };
717
718 static struct gpio_keys_platform_data bfin_gpio_keys_data = {
719         .buttons        = bfin_gpio_keys_table,
720         .nbuttons       = ARRAY_SIZE(bfin_gpio_keys_table),
721 };
722
723 static struct platform_device bfin_device_gpiokeys = {
724         .name      = "gpio-keys",
725         .dev = {
726                 .platform_data = &bfin_gpio_keys_data,
727         },
728 };
729 #endif
730
731 static const unsigned int cclk_vlev_datasheet[] =
732 {
733 /*
734  * Internal VLEV BF54XSBBC1533
735  ****temporarily using these values until data sheet is updated
736  */
737         VRPAIR(VLEV_085, 150000000),
738         VRPAIR(VLEV_090, 250000000),
739         VRPAIR(VLEV_110, 276000000),
740         VRPAIR(VLEV_115, 301000000),
741         VRPAIR(VLEV_120, 525000000),
742         VRPAIR(VLEV_125, 550000000),
743         VRPAIR(VLEV_130, 600000000),
744 };
745
746 static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
747         .tuple_tab = cclk_vlev_datasheet,
748         .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
749         .vr_settling_time = 25 /* us */,
750 };
751
752 static struct platform_device bfin_dpmc = {
753         .name = "bfin dpmc",
754         .dev = {
755                 .platform_data = &bfin_dmpc_vreg_data,
756         },
757 };
758
759 static struct platform_device *cm_bf548_devices[] __initdata = {
760
761         &bfin_dpmc,
762
763 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
764         &rtc_device,
765 #endif
766
767 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
768         &bfin_uart_device,
769 #endif
770
771 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
772 #ifdef CONFIG_BFIN_SIR0
773         &bfin_sir0_device,
774 #endif
775 #ifdef CONFIG_BFIN_SIR1
776         &bfin_sir1_device,
777 #endif
778 #ifdef CONFIG_BFIN_SIR2
779         &bfin_sir2_device,
780 #endif
781 #ifdef CONFIG_BFIN_SIR3
782         &bfin_sir3_device,
783 #endif
784 #endif
785
786 #if defined(CONFIG_FB_BF54X_LQ043) || defined(CONFIG_FB_BF54X_LQ043_MODULE)
787         &bf54x_lq043_device,
788 #endif
789
790 #if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE)
791         &smsc911x_device,
792 #endif
793
794 #if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE)
795         &musb_device,
796 #endif
797
798 #if defined(CONFIG_PATA_BF54X) || defined(CONFIG_PATA_BF54X_MODULE)
799         &bfin_atapi_device,
800 #endif
801
802 #if defined(CONFIG_MTD_NAND_BF5XX) || defined(CONFIG_MTD_NAND_BF5XX_MODULE)
803         &bf5xx_nand_device,
804 #endif
805
806 #if defined(CONFIG_SDH_BFIN) || defined(CONFIG_SDH_BFIN_MODULE)
807         &bf54x_sdh_device,
808 #endif
809
810 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
811         &bf54x_spi_master0,
812         &bf54x_spi_master1,
813 #endif
814
815 #if defined(CONFIG_KEYBOARD_BFIN) || defined(CONFIG_KEYBOARD_BFIN_MODULE)
816         &bf54x_kpad_device,
817 #endif
818
819 #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
820         &i2c_bfin_twi0_device,
821 #if !defined(CONFIG_BF542)
822         &i2c_bfin_twi1_device,
823 #endif
824 #endif
825
826 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
827         &bfin_device_gpiokeys,
828 #endif
829
830 #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
831         &para_flash_device,
832 #endif
833
834         &bfin_gpios_device,
835 };
836
837 static int __init cm_bf548_init(void)
838 {
839         printk(KERN_INFO "%s(): registering device resources\n", __func__);
840         platform_add_devices(cm_bf548_devices, ARRAY_SIZE(cm_bf548_devices));
841
842 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
843         spi_register_board_info(bf54x_spi_board_info,
844                         ARRAY_SIZE(bf54x_spi_board_info));
845 #endif
846
847         return 0;
848 }
849
850 arch_initcall(cm_bf548_init);