r8169: more phy init for the 8168
[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/spi/spi.h>
36 #include <linux/spi/flash.h>
37 #include <linux/irq.h>
38 #include <linux/interrupt.h>
39 #include <linux/usb/musb.h>
40 #include <asm/bfin5xx_spi.h>
41 #include <asm/cplb.h>
42 #include <asm/dma.h>
43 #include <asm/gpio.h>
44 #include <asm/nand.h>
45 #include <asm/mach/bf54x_keys.h>
46 #include <linux/input.h>
47 #include <linux/spi/ad7877.h>
48
49 /*
50  * Name the Board for the /proc/cpuinfo
51  */
52 char *bfin_board_name = "ADSP-BF548-EZKIT";
53
54 /*
55  *  Driver needs to know address, irq and flag pin.
56  */
57
58 #if defined(CONFIG_FB_BF54X_LQ043) || defined(CONFIG_FB_BF54X_LQ043_MODULE)
59
60 #include <asm/mach/bf54x-lq043.h>
61
62 static struct bfin_bf54xfb_mach_info bf54x_lq043_data = {
63         .width =        480,
64         .height =       272,
65         .xres =         {480, 480, 480},
66         .yres =         {272, 272, 272},
67         .bpp =          {24, 24, 24},
68         .disp =         GPIO_PE3,
69 };
70
71 static struct resource bf54x_lq043_resources[] = {
72         {
73                 .start = IRQ_EPPI0_ERR,
74                 .end = IRQ_EPPI0_ERR,
75                 .flags = IORESOURCE_IRQ,
76         },
77 };
78
79 static struct platform_device bf54x_lq043_device = {
80         .name           = "bf54x-lq043",
81         .id             = -1,
82         .num_resources  = ARRAY_SIZE(bf54x_lq043_resources),
83         .resource       = bf54x_lq043_resources,
84         .dev            = {
85                 .platform_data = &bf54x_lq043_data,
86         },
87 };
88 #endif
89
90 #if defined(CONFIG_KEYBOARD_BFIN) || defined(CONFIG_KEYBOARD_BFIN_MODULE)
91 static const unsigned int bf548_keymap[] = {
92         KEYVAL(0, 0, KEY_ENTER),
93         KEYVAL(0, 1, KEY_HELP),
94         KEYVAL(0, 2, KEY_0),
95         KEYVAL(0, 3, KEY_BACKSPACE),
96         KEYVAL(1, 0, KEY_TAB),
97         KEYVAL(1, 1, KEY_9),
98         KEYVAL(1, 2, KEY_8),
99         KEYVAL(1, 3, KEY_7),
100         KEYVAL(2, 0, KEY_DOWN),
101         KEYVAL(2, 1, KEY_6),
102         KEYVAL(2, 2, KEY_5),
103         KEYVAL(2, 3, KEY_4),
104         KEYVAL(3, 0, KEY_UP),
105         KEYVAL(3, 1, KEY_3),
106         KEYVAL(3, 2, KEY_2),
107         KEYVAL(3, 3, KEY_1),
108 };
109
110 static struct bfin_kpad_platform_data bf54x_kpad_data = {
111         .rows                   = 4,
112         .cols                   = 4,
113         .keymap                 = bf548_keymap,
114         .keymapsize             = ARRAY_SIZE(bf548_keymap),
115         .repeat                 = 0,
116         .debounce_time          = 5000, /* ns (5ms) */
117         .coldrive_time          = 1000, /* ns (1ms) */
118         .keyup_test_interval    = 50, /* ms (50ms) */
119 };
120
121 static struct resource bf54x_kpad_resources[] = {
122         {
123                 .start = IRQ_KEY,
124                 .end = IRQ_KEY,
125                 .flags = IORESOURCE_IRQ,
126         },
127 };
128
129 static struct platform_device bf54x_kpad_device = {
130         .name           = "bf54x-keys",
131         .id             = -1,
132         .num_resources  = ARRAY_SIZE(bf54x_kpad_resources),
133         .resource       = bf54x_kpad_resources,
134         .dev            = {
135                 .platform_data = &bf54x_kpad_data,
136         },
137 };
138 #endif
139
140 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
141 static struct platform_device rtc_device = {
142         .name = "rtc-bfin",
143         .id   = -1,
144 };
145 #endif
146
147 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
148 static struct resource bfin_uart_resources[] = {
149 #ifdef CONFIG_SERIAL_BFIN_UART0
150         {
151                 .start = 0xFFC00400,
152                 .end = 0xFFC004FF,
153                 .flags = IORESOURCE_MEM,
154         },
155 #endif
156 #ifdef CONFIG_SERIAL_BFIN_UART1
157         {
158                 .start = 0xFFC02000,
159                 .end = 0xFFC020FF,
160                 .flags = IORESOURCE_MEM,
161         },
162 #endif
163 #ifdef CONFIG_SERIAL_BFIN_UART2
164         {
165                 .start = 0xFFC02100,
166                 .end = 0xFFC021FF,
167                 .flags = IORESOURCE_MEM,
168         },
169 #endif
170 #ifdef CONFIG_SERIAL_BFIN_UART3
171         {
172                 .start = 0xFFC03100,
173                 .end = 0xFFC031FF,
174         },
175 #endif
176 };
177
178 static struct platform_device bfin_uart_device = {
179         .name = "bfin-uart",
180         .id = 1,
181         .num_resources = ARRAY_SIZE(bfin_uart_resources),
182         .resource = bfin_uart_resources,
183 };
184 #endif
185
186 #if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE)
187 static struct resource smsc911x_resources[] = {
188         {
189                 .name = "smsc911x-memory",
190                 .start = 0x24000000,
191                 .end = 0x24000000 + 0xFF,
192                 .flags = IORESOURCE_MEM,
193         },
194         {
195                 .start = IRQ_PE8,
196                 .end = IRQ_PE8,
197                 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
198         },
199 };
200 static struct platform_device smsc911x_device = {
201         .name = "smsc911x",
202         .id = 0,
203         .num_resources = ARRAY_SIZE(smsc911x_resources),
204         .resource = smsc911x_resources,
205 };
206 #endif
207
208 #if defined(CONFIG_USB_BF54x_HCD) || defined(CONFIG_USB_BF54x_HCD_MODULE)
209 static struct resource bf54x_hcd_resources[] = {
210         {
211                 .start = 0xFFC03C00,
212                 .end = 0xFFC040FF,
213                 .flags = IORESOURCE_MEM,
214         },
215 };
216
217 static struct platform_device bf54x_hcd = {
218         .name = "bf54x-hcd",
219         .id = 0,
220         .num_resources = ARRAY_SIZE(bf54x_hcd_resources),
221         .resource = bf54x_hcd_resources,
222 };
223 #endif
224
225 #if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE)
226 static struct resource musb_resources[] = {
227         [0] = {
228                 .start  = 0xFFC03C00,
229                 .end    = 0xFFC040FF,
230                 .flags  = IORESOURCE_MEM,
231         },
232         [1] = { /* general IRQ */
233                 .start  = IRQ_USB_INT0,
234                 .end    = IRQ_USB_INT0,
235                 .flags  = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
236         },
237         [2] = { /* DMA IRQ */
238                 .start  = IRQ_USB_DMA,
239                 .end    = IRQ_USB_DMA,
240                 .flags  = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
241         },
242 };
243
244 static struct musb_hdrc_platform_data musb_plat = {
245 #ifdef CONFIG_USB_MUSB_OTG
246         .mode           = MUSB_OTG,
247 #elif CONFIG_USB_MUSB_HDRC_HCD
248         .mode           = MUSB_HOST,
249 #elif CONFIG_USB_GADGET_MUSB_HDRC
250         .mode           = MUSB_PERIPHERAL,
251 #endif
252         .multipoint     = 1,
253 };
254
255 static u64 musb_dmamask = ~(u32)0;
256
257 static struct platform_device musb_device = {
258         .name           = "musb_hdrc",
259         .id             = 0,
260         .dev = {
261                 .dma_mask               = &musb_dmamask,
262                 .coherent_dma_mask      = 0xffffffff,
263                 .platform_data          = &musb_plat,
264         },
265         .num_resources  = ARRAY_SIZE(musb_resources),
266         .resource       = musb_resources,
267 };
268 #endif
269
270 #if defined(CONFIG_PATA_BF54X) || defined(CONFIG_PATA_BF54X_MODULE)
271 static struct resource bfin_atapi_resources[] = {
272         {
273                 .start = 0xFFC03800,
274                 .end = 0xFFC0386F,
275                 .flags = IORESOURCE_MEM,
276         },
277         {
278                 .start = IRQ_ATAPI_ERR,
279                 .end = IRQ_ATAPI_ERR,
280                 .flags = IORESOURCE_IRQ,
281         },
282 };
283
284 static struct platform_device bfin_atapi_device = {
285         .name = "pata-bf54x",
286         .id = -1,
287         .num_resources = ARRAY_SIZE(bfin_atapi_resources),
288         .resource = bfin_atapi_resources,
289 };
290 #endif
291
292 #if defined(CONFIG_MTD_NAND_BF5XX) || defined(CONFIG_MTD_NAND_BF5XX_MODULE)
293 static struct mtd_partition partition_info[] = {
294         {
295                 .name = "Linux Kernel",
296                 .offset = 0,
297                 .size = 4 * SIZE_1M,
298         },
299         {
300                 .name = "File System",
301                 .offset = 4 * SIZE_1M,
302                 .size = (256 - 4) * SIZE_1M,
303         },
304 };
305
306 static struct bf5xx_nand_platform bf5xx_nand_platform = {
307         .page_size = NFC_PG_SIZE_256,
308         .data_width = NFC_NWIDTH_8,
309         .partitions = partition_info,
310         .nr_partitions = ARRAY_SIZE(partition_info),
311         .rd_dly = 3,
312         .wr_dly = 3,
313 };
314
315 static struct resource bf5xx_nand_resources[] = {
316         {
317                 .start = 0xFFC03B00,
318                 .end = 0xFFC03B4F,
319                 .flags = IORESOURCE_MEM,
320         },
321         {
322                 .start = CH_NFC,
323                 .end = CH_NFC,
324                 .flags = IORESOURCE_IRQ,
325         },
326 };
327
328 static struct platform_device bf5xx_nand_device = {
329         .name = "bf5xx-nand",
330         .id = 0,
331         .num_resources = ARRAY_SIZE(bf5xx_nand_resources),
332         .resource = bf5xx_nand_resources,
333         .dev = {
334                 .platform_data = &bf5xx_nand_platform,
335         },
336 };
337 #endif
338
339 #if defined(CONFIG_SDH_BFIN) || defined(CONFIG_SDH_BFIN)
340 static struct platform_device bf54x_sdh_device = {
341         .name = "bfin-sdh",
342         .id = 0,
343 };
344 #endif
345
346 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
347 /* all SPI peripherals info goes here */
348 #if defined(CONFIG_MTD_M25P80) \
349         || defined(CONFIG_MTD_M25P80_MODULE)
350 /* SPI flash chip (m25p16) */
351 static struct mtd_partition bfin_spi_flash_partitions[] = {
352         {
353                 .name = "bootloader",
354                 .size = 0x00040000,
355                 .offset = 0,
356                 .mask_flags = MTD_CAP_ROM
357         }, {
358                 .name = "linux kernel",
359                 .size = 0x1c0000,
360                 .offset = 0x40000
361         }
362 };
363
364 static struct flash_platform_data bfin_spi_flash_data = {
365         .name = "m25p80",
366         .parts = bfin_spi_flash_partitions,
367         .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
368         .type = "m25p16",
369 };
370
371 static struct bfin5xx_spi_chip spi_flash_chip_info = {
372         .enable_dma = 0,         /* use dma transfer with this chip*/
373         .bits_per_word = 8,
374         .cs_change_per_word = 0,
375 };
376 #endif
377
378 #if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
379 static struct bfin5xx_spi_chip spi_ad7877_chip_info = {
380         .cs_change_per_word = 1,
381         .enable_dma = 0,
382         .bits_per_word = 16,
383 };
384
385 static const struct ad7877_platform_data bfin_ad7877_ts_info = {
386         .model                  = 7877,
387         .vref_delay_usecs       = 50,   /* internal, no capacitor */
388         .x_plate_ohms           = 419,
389         .y_plate_ohms           = 486,
390         .pressure_max           = 1000,
391         .pressure_min           = 0,
392         .stopacq_polarity       = 1,
393         .first_conversion_delay = 3,
394         .acquisition_time       = 1,
395         .averaging              = 1,
396         .pen_down_acc_interval  = 1,
397 };
398 #endif
399
400 static struct spi_board_info bf54x_spi_board_info[] __initdata = {
401 #if defined(CONFIG_MTD_M25P80) \
402         || defined(CONFIG_MTD_M25P80_MODULE)
403         {
404                 /* the modalias must be the same as spi device driver name */
405                 .modalias = "m25p80", /* Name of spi_driver for this device */
406                 .max_speed_hz = 25000000,     /* max spi clock (SCK) speed in HZ */
407                 .bus_num = 0, /* Framework bus number */
408                 .chip_select = 1, /* SPI_SSEL1*/
409                 .platform_data = &bfin_spi_flash_data,
410                 .controller_data = &spi_flash_chip_info,
411                 .mode = SPI_MODE_3,
412         },
413 #endif
414 #if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
415 {
416         .modalias               = "ad7877",
417         .platform_data          = &bfin_ad7877_ts_info,
418         .irq                    = IRQ_PJ11,
419         .max_speed_hz           = 12500000,     /* max spi clock (SCK) speed in HZ */
420         .bus_num                = 0,
421         .chip_select            = 2,
422         .controller_data = &spi_ad7877_chip_info,
423 },
424 #endif
425 };
426
427 /* SPI (0) */
428 static struct resource bfin_spi0_resource[] = {
429         [0] = {
430                 .start = SPI0_REGBASE,
431                 .end   = SPI0_REGBASE + 0xFF,
432                 .flags = IORESOURCE_MEM,
433         },
434         [1] = {
435                 .start = CH_SPI0,
436                 .end   = CH_SPI0,
437                 .flags = IORESOURCE_IRQ,
438         }
439 };
440
441 /* SPI (1) */
442 static struct resource bfin_spi1_resource[] = {
443         [0] = {
444                 .start = SPI1_REGBASE,
445                 .end   = SPI1_REGBASE + 0xFF,
446                 .flags = IORESOURCE_MEM,
447         },
448         [1] = {
449                 .start = CH_SPI1,
450                 .end   = CH_SPI1,
451                 .flags = IORESOURCE_IRQ,
452         }
453 };
454
455 /* SPI controller data */
456 static struct bfin5xx_spi_master bf54x_spi_master_info = {
457         .num_chipselect = 8,
458         .enable_dma = 1,  /* master has the ability to do dma transfer */
459 };
460
461 static struct platform_device bf54x_spi_master0 = {
462         .name = "bfin-spi",
463         .id = 0, /* Bus number */
464         .num_resources = ARRAY_SIZE(bfin_spi0_resource),
465         .resource = bfin_spi0_resource,
466         .dev = {
467                 .platform_data = &bf54x_spi_master_info, /* Passed to driver */
468                 },
469 };
470
471 static struct platform_device bf54x_spi_master1 = {
472         .name = "bfin-spi",
473         .id = 1, /* Bus number */
474         .num_resources = ARRAY_SIZE(bfin_spi1_resource),
475         .resource = bfin_spi1_resource,
476         .dev = {
477                 .platform_data = &bf54x_spi_master_info, /* Passed to driver */
478                 },
479 };
480 #endif  /* spi master and devices */
481
482 #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
483 static struct resource bfin_twi0_resource[] = {
484         [0] = {
485                 .start = TWI0_REGBASE,
486                 .end   = TWI0_REGBASE + 0xFF,
487                 .flags = IORESOURCE_MEM,
488         },
489         [1] = {
490                 .start = IRQ_TWI0,
491                 .end   = IRQ_TWI0,
492                 .flags = IORESOURCE_IRQ,
493         },
494 };
495
496 static struct platform_device i2c_bfin_twi0_device = {
497         .name = "i2c-bfin-twi",
498         .id = 0,
499         .num_resources = ARRAY_SIZE(bfin_twi0_resource),
500         .resource = bfin_twi0_resource,
501 };
502
503 static struct resource bfin_twi1_resource[] = {
504         [0] = {
505                 .start = TWI1_REGBASE,
506                 .end   = TWI1_REGBASE + 0xFF,
507                 .flags = IORESOURCE_MEM,
508         },
509         [1] = {
510                 .start = IRQ_TWI1,
511                 .end   = IRQ_TWI1,
512                 .flags = IORESOURCE_IRQ,
513         },
514 };
515
516 static struct platform_device i2c_bfin_twi1_device = {
517         .name = "i2c-bfin-twi",
518         .id = 1,
519         .num_resources = ARRAY_SIZE(bfin_twi1_resource),
520         .resource = bfin_twi1_resource,
521 };
522 #endif
523
524 static struct platform_device *ezkit_devices[] __initdata = {
525 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
526         &rtc_device,
527 #endif
528
529 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
530         &bfin_uart_device,
531 #endif
532
533 #if defined(CONFIG_FB_BF54X_LQ043) || defined(CONFIG_FB_BF54X_LQ043_MODULE)
534         &bf54x_lq043_device,
535 #endif
536
537 #if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE)
538         &smsc911x_device,
539 #endif
540
541 #if defined(CONFIG_USB_BF54x_HCD) || defined(CONFIG_USB_BF54x_HCD_MODULE)
542         &bf54x_hcd,
543 #endif
544
545 #if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE)
546         &musb_device,
547 #endif
548
549 #if defined(CONFIG_PATA_BF54X) || defined(CONFIG_PATA_BF54X_MODULE)
550         &bfin_atapi_device,
551 #endif
552
553 #if defined(CONFIG_MTD_NAND_BF5XX) || defined(CONFIG_MTD_NAND_BF5XX_MODULE)
554         &bf5xx_nand_device,
555 #endif
556
557 #if defined(CONFIG_SDH_BFIN) || defined(CONFIG_SDH_BFIN)
558         &bf54x_sdh_device,
559 #endif
560
561 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
562         &bf54x_spi_master0,
563 /*      &bf54x_spi_master1,*/
564 #endif
565
566 #if defined(CONFIG_KEYBOARD_BFIN) || defined(CONFIG_KEYBOARD_BFIN_MODULE)
567         &bf54x_kpad_device,
568 #endif
569
570 #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
571         &i2c_bfin_twi0_device,
572         &i2c_bfin_twi1_device,
573 #endif
574 };
575
576 static int __init stamp_init(void)
577 {
578         printk(KERN_INFO "%s(): registering device resources\n", __FUNCTION__);
579         platform_add_devices(ezkit_devices, ARRAY_SIZE(ezkit_devices));
580
581 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
582         spi_register_board_info(bf54x_spi_board_info,
583                         ARRAY_SIZE(bf54x_spi_board_info));
584 #endif
585
586         return 0;
587 }
588
589 arch_initcall(stamp_init);