Blackfin: bf537-stamp: add ADXL346 orientation sensing support
[linux-2.6.git] / arch / blackfin / mach-bf548 / boards / ezkit.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/platform_device.h>
11 #include <linux/mtd/mtd.h>
12 #include <linux/mtd/partitions.h>
13 #include <linux/mtd/physmap.h>
14 #include <linux/spi/spi.h>
15 #include <linux/spi/flash.h>
16 #include <linux/irq.h>
17 #include <linux/i2c.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/dpmc.h>
25 #include <asm/portmux.h>
26 #include <asm/bfin_sdh.h>
27 #include <mach/bf54x_keys.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[] = "ADI BF548-EZKIT";
35
36 /*
37  *  Driver needs to know address, irq and flag pin.
38  */
39
40 #if defined(CONFIG_USB_ISP1760_HCD) || defined(CONFIG_USB_ISP1760_HCD_MODULE)
41 #include <linux/usb/isp1760.h>
42 static struct resource bfin_isp1760_resources[] = {
43         [0] = {
44                 .start  = 0x2C0C0000,
45                 .end    = 0x2C0C0000 + 0xfffff,
46                 .flags  = IORESOURCE_MEM,
47         },
48         [1] = {
49                 .start  = IRQ_PG7,
50                 .end    = IRQ_PG7,
51                 .flags  = IORESOURCE_IRQ,
52         },
53 };
54
55 static struct isp1760_platform_data isp1760_priv = {
56         .is_isp1761 = 0,
57         .bus_width_16 = 1,
58         .port1_otg = 0,
59         .analog_oc = 0,
60         .dack_polarity_high = 0,
61         .dreq_polarity_high = 0,
62 };
63
64 static struct platform_device bfin_isp1760_device = {
65         .name           = "isp1760",
66         .id             = 0,
67         .dev = {
68                 .platform_data = &isp1760_priv,
69         },
70         .num_resources  = ARRAY_SIZE(bfin_isp1760_resources),
71         .resource       = bfin_isp1760_resources,
72 };
73 #endif
74
75 #if defined(CONFIG_FB_BF54X_LQ043) || defined(CONFIG_FB_BF54X_LQ043_MODULE)
76
77 #include <mach/bf54x-lq043.h>
78
79 static struct bfin_bf54xfb_mach_info bf54x_lq043_data = {
80         .width =        95,
81         .height =       54,
82         .xres =         {480, 480, 480},
83         .yres =         {272, 272, 272},
84         .bpp =          {24, 24, 24},
85         .disp =         GPIO_PE3,
86 };
87
88 static struct resource bf54x_lq043_resources[] = {
89         {
90                 .start = IRQ_EPPI0_ERR,
91                 .end = IRQ_EPPI0_ERR,
92                 .flags = IORESOURCE_IRQ,
93         },
94 };
95
96 static struct platform_device bf54x_lq043_device = {
97         .name           = "bf54x-lq043",
98         .id             = -1,
99         .num_resources  = ARRAY_SIZE(bf54x_lq043_resources),
100         .resource       = bf54x_lq043_resources,
101         .dev            = {
102                 .platform_data = &bf54x_lq043_data,
103         },
104 };
105 #endif
106
107 #if defined(CONFIG_KEYBOARD_BFIN) || defined(CONFIG_KEYBOARD_BFIN_MODULE)
108 static const unsigned int bf548_keymap[] = {
109         KEYVAL(0, 0, KEY_ENTER),
110         KEYVAL(0, 1, KEY_HELP),
111         KEYVAL(0, 2, KEY_0),
112         KEYVAL(0, 3, KEY_BACKSPACE),
113         KEYVAL(1, 0, KEY_TAB),
114         KEYVAL(1, 1, KEY_9),
115         KEYVAL(1, 2, KEY_8),
116         KEYVAL(1, 3, KEY_7),
117         KEYVAL(2, 0, KEY_DOWN),
118         KEYVAL(2, 1, KEY_6),
119         KEYVAL(2, 2, KEY_5),
120         KEYVAL(2, 3, KEY_4),
121         KEYVAL(3, 0, KEY_UP),
122         KEYVAL(3, 1, KEY_3),
123         KEYVAL(3, 2, KEY_2),
124         KEYVAL(3, 3, KEY_1),
125 };
126
127 static struct bfin_kpad_platform_data bf54x_kpad_data = {
128         .rows                   = 4,
129         .cols                   = 4,
130         .keymap                 = bf548_keymap,
131         .keymapsize             = ARRAY_SIZE(bf548_keymap),
132         .repeat                 = 0,
133         .debounce_time          = 5000, /* ns (5ms) */
134         .coldrive_time          = 1000, /* ns (1ms) */
135         .keyup_test_interval    = 50, /* ms (50ms) */
136 };
137
138 static struct resource bf54x_kpad_resources[] = {
139         {
140                 .start = IRQ_KEY,
141                 .end = IRQ_KEY,
142                 .flags = IORESOURCE_IRQ,
143         },
144 };
145
146 static struct platform_device bf54x_kpad_device = {
147         .name           = "bf54x-keys",
148         .id             = -1,
149         .num_resources  = ARRAY_SIZE(bf54x_kpad_resources),
150         .resource       = bf54x_kpad_resources,
151         .dev            = {
152                 .platform_data = &bf54x_kpad_data,
153         },
154 };
155 #endif
156
157 #if defined(CONFIG_INPUT_BFIN_ROTARY) || defined(CONFIG_INPUT_BFIN_ROTARY_MODULE)
158 #include <asm/bfin_rotary.h>
159
160 static struct bfin_rotary_platform_data bfin_rotary_data = {
161         /*.rotary_up_key     = KEY_UP,*/
162         /*.rotary_down_key   = KEY_DOWN,*/
163         .rotary_rel_code   = REL_WHEEL,
164         .rotary_button_key = KEY_ENTER,
165         .debounce          = 10,        /* 0..17 */
166         .mode              = ROT_QUAD_ENC | ROT_DEBE,
167 };
168
169 static struct resource bfin_rotary_resources[] = {
170         {
171                 .start = IRQ_CNT,
172                 .end = IRQ_CNT,
173                 .flags = IORESOURCE_IRQ,
174         },
175 };
176
177 static struct platform_device bfin_rotary_device = {
178         .name           = "bfin-rotary",
179         .id             = -1,
180         .num_resources  = ARRAY_SIZE(bfin_rotary_resources),
181         .resource       = bfin_rotary_resources,
182         .dev            = {
183                 .platform_data = &bfin_rotary_data,
184         },
185 };
186 #endif
187
188 #if defined(CONFIG_INPUT_ADXL34X) || defined(CONFIG_INPUT_ADXL34X_MODULE)
189 #include <linux/input/adxl34x.h>
190 static const struct adxl34x_platform_data adxl34x_info = {
191         .x_axis_offset = 0,
192         .y_axis_offset = 0,
193         .z_axis_offset = 0,
194         .tap_threshold = 0x31,
195         .tap_duration = 0x10,
196         .tap_latency = 0x60,
197         .tap_window = 0xF0,
198         .tap_axis_control = ADXL_TAP_X_EN | ADXL_TAP_Y_EN | ADXL_TAP_Z_EN,
199         .act_axis_control = 0xFF,
200         .activity_threshold = 5,
201         .inactivity_threshold = 3,
202         .inactivity_time = 4,
203         .free_fall_threshold = 0x7,
204         .free_fall_time = 0x20,
205         .data_rate = 0x8,
206         .data_range = ADXL_FULL_RES,
207
208         .ev_type = EV_ABS,
209         .ev_code_x = ABS_X,             /* EV_REL */
210         .ev_code_y = ABS_Y,             /* EV_REL */
211         .ev_code_z = ABS_Z,             /* EV_REL */
212
213         .ev_code_tap = {BTN_TOUCH, BTN_TOUCH, BTN_TOUCH}, /* EV_KEY x,y,z */
214
215 /*      .ev_code_ff = KEY_F,*/          /* EV_KEY */
216 /*      .ev_code_act_inactivity = KEY_A,*/      /* EV_KEY */
217         .power_mode = ADXL_AUTO_SLEEP | ADXL_LINK,
218         .fifo_mode = ADXL_FIFO_STREAM,
219         .orientation_enable = ADXL_EN_ORIENTATION_3D,
220         .deadzone_angle = ADXL_DEADZONE_ANGLE_10p8,
221         .divisor_length = ADXL_LP_FILTER_DIVISOR_16,
222         /* EV_KEY {+Z, +Y, +X, -X, -Y, -Z} */
223         .ev_codes_orient_3d = {BTN_Z, BTN_Y, BTN_X, BTN_A, BTN_B, BTN_C},
224 };
225 #endif
226
227 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
228 static struct platform_device rtc_device = {
229         .name = "rtc-bfin",
230         .id   = -1,
231 };
232 #endif
233
234 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
235 static struct resource bfin_uart_resources[] = {
236 #ifdef CONFIG_SERIAL_BFIN_UART0
237         {
238                 .start = 0xFFC00400,
239                 .end = 0xFFC004FF,
240                 .flags = IORESOURCE_MEM,
241         },
242 #endif
243 #ifdef CONFIG_SERIAL_BFIN_UART1
244         {
245                 .start = 0xFFC02000,
246                 .end = 0xFFC020FF,
247                 .flags = IORESOURCE_MEM,
248         },
249 #endif
250 #ifdef CONFIG_SERIAL_BFIN_UART2
251         {
252                 .start = 0xFFC02100,
253                 .end = 0xFFC021FF,
254                 .flags = IORESOURCE_MEM,
255         },
256 #endif
257 #ifdef CONFIG_SERIAL_BFIN_UART3
258         {
259                 .start = 0xFFC03100,
260                 .end = 0xFFC031FF,
261                 .flags = IORESOURCE_MEM,
262         },
263 #endif
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 static struct platform_device bfin_sir0_device = {
294         .name = "bfin_sir",
295         .id = 0,
296         .num_resources = ARRAY_SIZE(bfin_sir0_resources),
297         .resource = bfin_sir0_resources,
298 };
299 #endif
300 #ifdef CONFIG_BFIN_SIR1
301 static struct resource bfin_sir1_resources[] = {
302         {
303                 .start = 0xFFC02000,
304                 .end = 0xFFC020FF,
305                 .flags = IORESOURCE_MEM,
306         },
307         {
308                 .start = IRQ_UART1_RX,
309                 .end = IRQ_UART1_RX+1,
310                 .flags = IORESOURCE_IRQ,
311         },
312         {
313                 .start = CH_UART1_RX,
314                 .end = CH_UART1_RX+1,
315                 .flags = IORESOURCE_DMA,
316         },
317 };
318 static struct platform_device bfin_sir1_device = {
319         .name = "bfin_sir",
320         .id = 1,
321         .num_resources = ARRAY_SIZE(bfin_sir1_resources),
322         .resource = bfin_sir1_resources,
323 };
324 #endif
325 #ifdef CONFIG_BFIN_SIR2
326 static struct resource bfin_sir2_resources[] = {
327         {
328                 .start = 0xFFC02100,
329                 .end = 0xFFC021FF,
330                 .flags = IORESOURCE_MEM,
331         },
332         {
333                 .start = IRQ_UART2_RX,
334                 .end = IRQ_UART2_RX+1,
335                 .flags = IORESOURCE_IRQ,
336         },
337         {
338                 .start = CH_UART2_RX,
339                 .end = CH_UART2_RX+1,
340                 .flags = IORESOURCE_DMA,
341         },
342 };
343 static struct platform_device bfin_sir2_device = {
344         .name = "bfin_sir",
345         .id = 2,
346         .num_resources = ARRAY_SIZE(bfin_sir2_resources),
347         .resource = bfin_sir2_resources,
348 };
349 #endif
350 #ifdef CONFIG_BFIN_SIR3
351 static struct resource bfin_sir3_resources[] = {
352         {
353                 .start = 0xFFC03100,
354                 .end = 0xFFC031FF,
355                 .flags = IORESOURCE_MEM,
356         },
357         {
358                 .start = IRQ_UART3_RX,
359                 .end = IRQ_UART3_RX+1,
360                 .flags = IORESOURCE_IRQ,
361         },
362         {
363                 .start = CH_UART3_RX,
364                 .end = CH_UART3_RX+1,
365                 .flags = IORESOURCE_DMA,
366         },
367 };
368 static struct platform_device bfin_sir3_device = {
369         .name = "bfin_sir",
370         .id = 3,
371         .num_resources = ARRAY_SIZE(bfin_sir3_resources),
372         .resource = bfin_sir3_resources,
373 };
374 #endif
375 #endif
376
377 #if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE)
378 #include <linux/smsc911x.h>
379
380 static struct resource smsc911x_resources[] = {
381         {
382                 .name = "smsc911x-memory",
383                 .start = 0x24000000,
384                 .end = 0x24000000 + 0xFF,
385                 .flags = IORESOURCE_MEM,
386         },
387         {
388                 .start = IRQ_PE8,
389                 .end = IRQ_PE8,
390                 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
391         },
392 };
393
394 static struct smsc911x_platform_config smsc911x_config = {
395         .flags = SMSC911X_USE_32BIT,
396         .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
397         .irq_type = SMSC911X_IRQ_TYPE_OPEN_DRAIN,
398         .phy_interface = PHY_INTERFACE_MODE_MII,
399 };
400
401 static struct platform_device smsc911x_device = {
402         .name = "smsc911x",
403         .id = 0,
404         .num_resources = ARRAY_SIZE(smsc911x_resources),
405         .resource = smsc911x_resources,
406         .dev = {
407                 .platform_data = &smsc911x_config,
408         },
409 };
410 #endif
411
412 #if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE)
413 static struct resource musb_resources[] = {
414         [0] = {
415                 .start  = 0xFFC03C00,
416                 .end    = 0xFFC040FF,
417                 .flags  = IORESOURCE_MEM,
418         },
419         [1] = { /* general IRQ */
420                 .start  = IRQ_USB_INT0,
421                 .end    = IRQ_USB_INT0,
422                 .flags  = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
423         },
424         [2] = { /* DMA IRQ */
425                 .start  = IRQ_USB_DMA,
426                 .end    = IRQ_USB_DMA,
427                 .flags  = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
428         },
429 };
430
431 static struct musb_hdrc_config musb_config = {
432         .multipoint     = 0,
433         .dyn_fifo       = 0,
434         .soft_con       = 1,
435         .dma            = 1,
436         .num_eps        = 8,
437         .dma_channels   = 8,
438         .gpio_vrsel     = GPIO_PE7,
439 };
440
441 static struct musb_hdrc_platform_data musb_plat = {
442 #if defined(CONFIG_USB_MUSB_OTG)
443         .mode           = MUSB_OTG,
444 #elif defined(CONFIG_USB_MUSB_HDRC_HCD)
445         .mode           = MUSB_HOST,
446 #elif defined(CONFIG_USB_GADGET_MUSB_HDRC)
447         .mode           = MUSB_PERIPHERAL,
448 #endif
449         .config         = &musb_config,
450 };
451
452 static u64 musb_dmamask = ~(u32)0;
453
454 static struct platform_device musb_device = {
455         .name           = "musb_hdrc",
456         .id             = 0,
457         .dev = {
458                 .dma_mask               = &musb_dmamask,
459                 .coherent_dma_mask      = 0xffffffff,
460                 .platform_data          = &musb_plat,
461         },
462         .num_resources  = ARRAY_SIZE(musb_resources),
463         .resource       = musb_resources,
464 };
465 #endif
466
467 #if defined(CONFIG_PATA_BF54X) || defined(CONFIG_PATA_BF54X_MODULE)
468 static struct resource bfin_atapi_resources[] = {
469         {
470                 .start = 0xFFC03800,
471                 .end = 0xFFC0386F,
472                 .flags = IORESOURCE_MEM,
473         },
474         {
475                 .start = IRQ_ATAPI_ERR,
476                 .end = IRQ_ATAPI_ERR,
477                 .flags = IORESOURCE_IRQ,
478         },
479 };
480
481 static struct platform_device bfin_atapi_device = {
482         .name = "pata-bf54x",
483         .id = -1,
484         .num_resources = ARRAY_SIZE(bfin_atapi_resources),
485         .resource = bfin_atapi_resources,
486 };
487 #endif
488
489 #if defined(CONFIG_MTD_NAND_BF5XX) || defined(CONFIG_MTD_NAND_BF5XX_MODULE)
490 static struct mtd_partition partition_info[] = {
491         {
492                 .name = "linux kernel(nand)",
493                 .offset = 0,
494                 .size = 4 * 1024 * 1024,
495         },
496         {
497                 .name = "file system(nand)",
498                 .offset = MTDPART_OFS_APPEND,
499                 .size = MTDPART_SIZ_FULL,
500         },
501 };
502
503 static struct bf5xx_nand_platform bf5xx_nand_platform = {
504         .page_size = NFC_PG_SIZE_256,
505         .data_width = NFC_NWIDTH_8,
506         .partitions = partition_info,
507         .nr_partitions = ARRAY_SIZE(partition_info),
508         .rd_dly = 3,
509         .wr_dly = 3,
510 };
511
512 static struct resource bf5xx_nand_resources[] = {
513         {
514                 .start = 0xFFC03B00,
515                 .end = 0xFFC03B4F,
516                 .flags = IORESOURCE_MEM,
517         },
518         {
519                 .start = CH_NFC,
520                 .end = CH_NFC,
521                 .flags = IORESOURCE_IRQ,
522         },
523 };
524
525 static struct platform_device bf5xx_nand_device = {
526         .name = "bf5xx-nand",
527         .id = 0,
528         .num_resources = ARRAY_SIZE(bf5xx_nand_resources),
529         .resource = bf5xx_nand_resources,
530         .dev = {
531                 .platform_data = &bf5xx_nand_platform,
532         },
533 };
534 #endif
535
536 #if defined(CONFIG_SDH_BFIN) || defined(CONFIG_SDH_BFIN_MODULE)
537
538 static struct bfin_sd_host bfin_sdh_data = {
539         .dma_chan = CH_SDH,
540         .irq_int0 = IRQ_SDH_MASK0,
541         .pin_req = {P_SD_D0, P_SD_D1, P_SD_D2, P_SD_D3, P_SD_CLK, P_SD_CMD, 0},
542 };
543
544 static struct platform_device bf54x_sdh_device = {
545         .name = "bfin-sdh",
546         .id = 0,
547         .dev = {
548                 .platform_data = &bfin_sdh_data,
549         },
550 };
551 #endif
552
553 #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
554 static struct mtd_partition ezkit_partitions[] = {
555         {
556                 .name       = "bootloader(nor)",
557                 .size       = 0x40000,
558                 .offset     = 0,
559         }, {
560                 .name       = "linux kernel(nor)",
561                 .size       = 0x400000,
562                 .offset     = MTDPART_OFS_APPEND,
563         }, {
564                 .name       = "file system(nor)",
565                 .size       = MTDPART_SIZ_FULL,
566                 .offset     = MTDPART_OFS_APPEND,
567         }
568 };
569
570 static struct physmap_flash_data ezkit_flash_data = {
571         .width      = 2,
572         .parts      = ezkit_partitions,
573         .nr_parts   = ARRAY_SIZE(ezkit_partitions),
574 };
575
576 static struct resource ezkit_flash_resource = {
577         .start = 0x20000000,
578         .end   = 0x21ffffff,
579         .flags = IORESOURCE_MEM,
580 };
581
582 static struct platform_device ezkit_flash_device = {
583         .name          = "physmap-flash",
584         .id            = 0,
585         .dev = {
586                 .platform_data = &ezkit_flash_data,
587         },
588         .num_resources = 1,
589         .resource      = &ezkit_flash_resource,
590 };
591 #endif
592
593 #if defined(CONFIG_MTD_M25P80) \
594         || defined(CONFIG_MTD_M25P80_MODULE)
595 /* SPI flash chip (m25p16) */
596 static struct mtd_partition bfin_spi_flash_partitions[] = {
597         {
598                 .name = "bootloader(spi)",
599                 .size = 0x00040000,
600                 .offset = 0,
601                 .mask_flags = MTD_CAP_ROM
602         }, {
603                 .name = "linux kernel(spi)",
604                 .size = MTDPART_SIZ_FULL,
605                 .offset = MTDPART_OFS_APPEND,
606         }
607 };
608
609 static struct flash_platform_data bfin_spi_flash_data = {
610         .name = "m25p80",
611         .parts = bfin_spi_flash_partitions,
612         .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
613         .type = "m25p16",
614 };
615
616 static struct bfin5xx_spi_chip spi_flash_chip_info = {
617         .enable_dma = 0,         /* use dma transfer with this chip*/
618         .bits_per_word = 8,
619 };
620 #endif
621
622 #if defined(CONFIG_SND_BLACKFIN_AD1836) \
623         || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
624 static struct bfin5xx_spi_chip ad1836_spi_chip_info = {
625         .enable_dma = 0,
626         .bits_per_word = 16,
627 };
628 #endif
629
630 #if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
631 static struct bfin5xx_spi_chip spi_ad7877_chip_info = {
632         .enable_dma = 0,
633         .bits_per_word = 16,
634 };
635
636 static const struct ad7877_platform_data bfin_ad7877_ts_info = {
637         .model                  = 7877,
638         .vref_delay_usecs       = 50,   /* internal, no capacitor */
639         .x_plate_ohms           = 419,
640         .y_plate_ohms           = 486,
641         .pressure_max           = 1000,
642         .pressure_min           = 0,
643         .stopacq_polarity       = 1,
644         .first_conversion_delay = 3,
645         .acquisition_time       = 1,
646         .averaging              = 1,
647         .pen_down_acc_interval  = 1,
648 };
649 #endif
650
651 #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
652 static struct bfin5xx_spi_chip spidev_chip_info = {
653         .enable_dma = 0,
654         .bits_per_word = 8,
655 };
656 #endif
657
658 #if defined(CONFIG_INPUT_ADXL34X_SPI) || defined(CONFIG_INPUT_ADXL34X_SPI_MODULE)
659 static struct bfin5xx_spi_chip spi_adxl34x_chip_info = {
660         .enable_dma = 0,         /* use dma transfer with this chip*/
661         .bits_per_word = 8,
662 };
663 #endif
664
665 static struct spi_board_info bfin_spi_board_info[] __initdata = {
666 #if defined(CONFIG_MTD_M25P80) \
667         || defined(CONFIG_MTD_M25P80_MODULE)
668         {
669                 /* the modalias must be the same as spi device driver name */
670                 .modalias = "m25p80", /* Name of spi_driver for this device */
671                 .max_speed_hz = 25000000,     /* max spi clock (SCK) speed in HZ */
672                 .bus_num = 0, /* Framework bus number */
673                 .chip_select = 1, /* SPI_SSEL1*/
674                 .platform_data = &bfin_spi_flash_data,
675                 .controller_data = &spi_flash_chip_info,
676                 .mode = SPI_MODE_3,
677         },
678 #endif
679 #if defined(CONFIG_SND_BLACKFIN_AD1836) \
680         || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
681         {
682                 .modalias = "ad1836",
683                 .max_speed_hz = 3125000,     /* max spi clock (SCK) speed in HZ */
684                 .bus_num = 1,
685                 .chip_select = CONFIG_SND_BLACKFIN_SPI_PFBIT,
686                 .controller_data = &ad1836_spi_chip_info,
687         },
688 #endif
689 #if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
690         {
691                 .modalias               = "ad7877",
692                 .platform_data          = &bfin_ad7877_ts_info,
693                 .irq                    = IRQ_PB4,      /* old boards (<=Rev 1.3) use IRQ_PJ11 */
694                 .max_speed_hz           = 12500000,     /* max spi clock (SCK) speed in HZ */
695                 .bus_num                = 0,
696                 .chip_select            = 2,
697                 .controller_data = &spi_ad7877_chip_info,
698         },
699 #endif
700 #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
701         {
702                 .modalias = "spidev",
703                 .max_speed_hz = 3125000,     /* max spi clock (SCK) speed in HZ */
704                 .bus_num = 0,
705                 .chip_select = 1,
706                 .controller_data = &spidev_chip_info,
707         },
708 #endif
709 #if defined(CONFIG_INPUT_ADXL34X_SPI) || defined(CONFIG_INPUT_ADXL34X_SPI_MODULE)
710         {
711                 .modalias               = "adxl34x",
712                 .platform_data          = &adxl34x_info,
713                 .irq                    = IRQ_PC5,
714                 .max_speed_hz           = 5000000,     /* max spi clock (SCK) speed in HZ */
715                 .bus_num                = 1,
716                 .chip_select            = 2,
717                 .controller_data = &spi_adxl34x_chip_info,
718                 .mode = SPI_MODE_3,
719         },
720 #endif
721 };
722 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
723 /* SPI (0) */
724 static struct resource bfin_spi0_resource[] = {
725         [0] = {
726                 .start = SPI0_REGBASE,
727                 .end   = SPI0_REGBASE + 0xFF,
728                 .flags = IORESOURCE_MEM,
729         },
730         [1] = {
731                 .start = CH_SPI0,
732                 .end   = CH_SPI0,
733                 .flags = IORESOURCE_DMA,
734         },
735         [2] = {
736                 .start = IRQ_SPI0,
737                 .end   = IRQ_SPI0,
738                 .flags = IORESOURCE_IRQ,
739         }
740 };
741
742 /* SPI (1) */
743 static struct resource bfin_spi1_resource[] = {
744         [0] = {
745                 .start = SPI1_REGBASE,
746                 .end   = SPI1_REGBASE + 0xFF,
747                 .flags = IORESOURCE_MEM,
748         },
749         [1] = {
750                 .start = CH_SPI1,
751                 .end   = CH_SPI1,
752                 .flags = IORESOURCE_DMA,
753         },
754         [2] = {
755                 .start = IRQ_SPI1,
756                 .end   = IRQ_SPI1,
757                 .flags = IORESOURCE_IRQ,
758         }
759 };
760
761 /* SPI controller data */
762 static struct bfin5xx_spi_master bf54x_spi_master_info0 = {
763         .num_chipselect = 3,
764         .enable_dma = 1,  /* master has the ability to do dma transfer */
765         .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
766 };
767
768 static struct platform_device bf54x_spi_master0 = {
769         .name = "bfin-spi",
770         .id = 0, /* Bus number */
771         .num_resources = ARRAY_SIZE(bfin_spi0_resource),
772         .resource = bfin_spi0_resource,
773         .dev = {
774                 .platform_data = &bf54x_spi_master_info0, /* Passed to driver */
775                 },
776 };
777
778 static struct bfin5xx_spi_master bf54x_spi_master_info1 = {
779         .num_chipselect = 3,
780         .enable_dma = 1,  /* master has the ability to do dma transfer */
781         .pin_req = {P_SPI1_SCK, P_SPI1_MISO, P_SPI1_MOSI, 0},
782 };
783
784 static struct platform_device bf54x_spi_master1 = {
785         .name = "bfin-spi",
786         .id = 1, /* Bus number */
787         .num_resources = ARRAY_SIZE(bfin_spi1_resource),
788         .resource = bfin_spi1_resource,
789         .dev = {
790                 .platform_data = &bf54x_spi_master_info1, /* Passed to driver */
791                 },
792 };
793 #endif  /* spi master and devices */
794
795 #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
796 static struct resource bfin_twi0_resource[] = {
797         [0] = {
798                 .start = TWI0_REGBASE,
799                 .end   = TWI0_REGBASE + 0xFF,
800                 .flags = IORESOURCE_MEM,
801         },
802         [1] = {
803                 .start = IRQ_TWI0,
804                 .end   = IRQ_TWI0,
805                 .flags = IORESOURCE_IRQ,
806         },
807 };
808
809 static struct platform_device i2c_bfin_twi0_device = {
810         .name = "i2c-bfin-twi",
811         .id = 0,
812         .num_resources = ARRAY_SIZE(bfin_twi0_resource),
813         .resource = bfin_twi0_resource,
814 };
815
816 #if !defined(CONFIG_BF542)      /* The BF542 only has 1 TWI */
817 static struct resource bfin_twi1_resource[] = {
818         [0] = {
819                 .start = TWI1_REGBASE,
820                 .end   = TWI1_REGBASE + 0xFF,
821                 .flags = IORESOURCE_MEM,
822         },
823         [1] = {
824                 .start = IRQ_TWI1,
825                 .end   = IRQ_TWI1,
826                 .flags = IORESOURCE_IRQ,
827         },
828 };
829
830 static struct platform_device i2c_bfin_twi1_device = {
831         .name = "i2c-bfin-twi",
832         .id = 1,
833         .num_resources = ARRAY_SIZE(bfin_twi1_resource),
834         .resource = bfin_twi1_resource,
835 };
836 #endif
837 #endif
838
839 static struct i2c_board_info __initdata bfin_i2c_board_info0[] = {
840 };
841
842 #if !defined(CONFIG_BF542)      /* The BF542 only has 1 TWI */
843 static struct i2c_board_info __initdata bfin_i2c_board_info1[] = {
844 #if defined(CONFIG_BFIN_TWI_LCD) || defined(CONFIG_BFIN_TWI_LCD_MODULE)
845         {
846                 I2C_BOARD_INFO("pcf8574_lcd", 0x22),
847         },
848 #endif
849 #if defined(CONFIG_INPUT_PCF8574) || defined(CONFIG_INPUT_PCF8574_MODULE)
850         {
851                 I2C_BOARD_INFO("pcf8574_keypad", 0x27),
852                 .irq = 212,
853         },
854 #endif
855 #if defined(CONFIG_INPUT_ADXL34X_I2C) || defined(CONFIG_INPUT_ADXL34X_I2C_MODULE)
856         {
857                 I2C_BOARD_INFO("adxl34x", 0x53),
858                 .irq = IRQ_PC5,
859                 .platform_data = (void *)&adxl34x_info,
860         },
861 #endif
862 };
863 #endif
864
865 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
866 #include <linux/gpio_keys.h>
867
868 static struct gpio_keys_button bfin_gpio_keys_table[] = {
869         {BTN_0, GPIO_PB8, 1, "gpio-keys: BTN0"},
870         {BTN_1, GPIO_PB9, 1, "gpio-keys: BTN1"},
871         {BTN_2, GPIO_PB10, 1, "gpio-keys: BTN2"},
872         {BTN_3, GPIO_PB11, 1, "gpio-keys: BTN3"},
873 };
874
875 static struct gpio_keys_platform_data bfin_gpio_keys_data = {
876         .buttons        = bfin_gpio_keys_table,
877         .nbuttons       = ARRAY_SIZE(bfin_gpio_keys_table),
878 };
879
880 static struct platform_device bfin_device_gpiokeys = {
881         .name      = "gpio-keys",
882         .dev = {
883                 .platform_data = &bfin_gpio_keys_data,
884         },
885 };
886 #endif
887
888 static const unsigned int cclk_vlev_datasheet[] =
889 {
890 /*
891  * Internal VLEV BF54XSBBC1533
892  ****temporarily using these values until data sheet is updated
893  */
894         VRPAIR(VLEV_085, 150000000),
895         VRPAIR(VLEV_090, 250000000),
896         VRPAIR(VLEV_110, 276000000),
897         VRPAIR(VLEV_115, 301000000),
898         VRPAIR(VLEV_120, 525000000),
899         VRPAIR(VLEV_125, 550000000),
900         VRPAIR(VLEV_130, 600000000),
901 };
902
903 static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
904         .tuple_tab = cclk_vlev_datasheet,
905         .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
906         .vr_settling_time = 25 /* us */,
907 };
908
909 static struct platform_device bfin_dpmc = {
910         .name = "bfin dpmc",
911         .dev = {
912                 .platform_data = &bfin_dmpc_vreg_data,
913         },
914 };
915
916 static struct platform_device *ezkit_devices[] __initdata = {
917
918         &bfin_dpmc,
919
920 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
921         &rtc_device,
922 #endif
923
924 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
925         &bfin_uart_device,
926 #endif
927
928 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
929 #ifdef CONFIG_BFIN_SIR0
930         &bfin_sir0_device,
931 #endif
932 #ifdef CONFIG_BFIN_SIR1
933         &bfin_sir1_device,
934 #endif
935 #ifdef CONFIG_BFIN_SIR2
936         &bfin_sir2_device,
937 #endif
938 #ifdef CONFIG_BFIN_SIR3
939         &bfin_sir3_device,
940 #endif
941 #endif
942
943 #if defined(CONFIG_FB_BF54X_LQ043) || defined(CONFIG_FB_BF54X_LQ043_MODULE)
944         &bf54x_lq043_device,
945 #endif
946
947 #if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE)
948         &smsc911x_device,
949 #endif
950
951 #if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE)
952         &musb_device,
953 #endif
954
955 #if defined(CONFIG_USB_ISP1760_HCD) || defined(CONFIG_USB_ISP1760_HCD_MODULE)
956         &bfin_isp1760_device,
957 #endif
958
959 #if defined(CONFIG_PATA_BF54X) || defined(CONFIG_PATA_BF54X_MODULE)
960         &bfin_atapi_device,
961 #endif
962
963 #if defined(CONFIG_MTD_NAND_BF5XX) || defined(CONFIG_MTD_NAND_BF5XX_MODULE)
964         &bf5xx_nand_device,
965 #endif
966
967 #if defined(CONFIG_SDH_BFIN) || defined(CONFIG_SDH_BFIN_MODULE)
968         &bf54x_sdh_device,
969 #endif
970
971 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
972         &bf54x_spi_master0,
973         &bf54x_spi_master1,
974 #endif
975
976 #if defined(CONFIG_KEYBOARD_BFIN) || defined(CONFIG_KEYBOARD_BFIN_MODULE)
977         &bf54x_kpad_device,
978 #endif
979
980 #if defined(CONFIG_INPUT_BFIN_ROTARY) || defined(CONFIG_INPUT_BFIN_ROTARY_MODULE)
981         &bfin_rotary_device,
982 #endif
983
984 #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
985         &i2c_bfin_twi0_device,
986 #if !defined(CONFIG_BF542)
987         &i2c_bfin_twi1_device,
988 #endif
989 #endif
990
991 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
992         &bfin_device_gpiokeys,
993 #endif
994
995 #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
996         &ezkit_flash_device,
997 #endif
998 };
999
1000 static int __init ezkit_init(void)
1001 {
1002         printk(KERN_INFO "%s(): registering device resources\n", __func__);
1003
1004         i2c_register_board_info(0, bfin_i2c_board_info0,
1005                                 ARRAY_SIZE(bfin_i2c_board_info0));
1006 #if !defined(CONFIG_BF542)      /* The BF542 only has 1 TWI */
1007         i2c_register_board_info(1, bfin_i2c_board_info1,
1008                                 ARRAY_SIZE(bfin_i2c_board_info1));
1009 #endif
1010
1011         platform_add_devices(ezkit_devices, ARRAY_SIZE(ezkit_devices));
1012
1013         spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
1014
1015         return 0;
1016 }
1017
1018 arch_initcall(ezkit_init);