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