Merge branch 'core/topology' of git://git.kernel.org/pub/scm/linux/kernel/git/tip...
[sfrench/cifs-2.6.git] / arch / blackfin / mach-bf561 / boards / ezkit.c
1 /*
2  * File:         arch/blackfin/mach-bf561/ezkit.c
3  * Based on:
4  * Author:
5  *
6  * Created:
7  * Description:
8  *
9  * Modified:
10  *               Copyright 2004-2006 Analog Devices Inc.
11  *
12  * Bugs:         Enter bugs at http://blackfin.uclinux.org/
13  *
14  * This program is free software; you can redistribute it and/or modify
15  * it under the terms of the GNU General Public License as published by
16  * the Free Software Foundation; either version 2 of the License, or
17  * (at your option) any later version.
18  *
19  * This program is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22  * GNU General Public License for more details.
23  *
24  * You should have received a copy of the GNU General Public License
25  * along with this program; if not, see the file COPYING, or write
26  * to the Free Software Foundation, Inc.,
27  * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
28  */
29
30 #include <linux/device.h>
31 #include <linux/platform_device.h>
32 #include <linux/mtd/mtd.h>
33 #include <linux/mtd/partitions.h>
34 #include <linux/mtd/physmap.h>
35 #include <linux/spi/spi.h>
36 #include <linux/irq.h>
37 #include <linux/interrupt.h>
38 #include <linux/ata_platform.h>
39 #include <asm/dma.h>
40 #include <asm/bfin5xx_spi.h>
41 #include <asm/portmux.h>
42 #include <asm/dpmc.h>
43
44 /*
45  * Name the Board for the /proc/cpuinfo
46  */
47 const char bfin_board_name[] = "ADDS-BF561-EZKIT";
48
49 #define ISP1761_BASE       0x2C0F0000
50 #define ISP1761_IRQ        IRQ_PF10
51
52 #if defined(CONFIG_USB_ISP1760_HCD) || defined(CONFIG_USB_ISP1760_HCD_MODULE)
53 static struct resource bfin_isp1761_resources[] = {
54         {
55                 .name   = "isp1761-regs",
56                 .start  = ISP1761_BASE + 0x00000000,
57                 .end    = ISP1761_BASE + 0x000fffff,
58                 .flags  = IORESOURCE_MEM,
59         },
60         {
61                 .start  = ISP1761_IRQ,
62                 .end    = ISP1761_IRQ,
63                 .flags  = IORESOURCE_IRQ,
64         },
65 };
66
67 static struct platform_device bfin_isp1761_device = {
68         .name           = "isp1761",
69         .id             = 0,
70         .num_resources  = ARRAY_SIZE(bfin_isp1761_resources),
71         .resource       = bfin_isp1761_resources,
72 };
73
74 static struct platform_device *bfin_isp1761_devices[] = {
75         &bfin_isp1761_device,
76 };
77
78 int __init bfin_isp1761_init(void)
79 {
80         unsigned int num_devices = ARRAY_SIZE(bfin_isp1761_devices);
81
82         printk(KERN_INFO "%s(): registering device resources\n", __func__);
83         set_irq_type(ISP1761_IRQ, IRQF_TRIGGER_FALLING);
84
85         return platform_add_devices(bfin_isp1761_devices, num_devices);
86 }
87
88 void __exit bfin_isp1761_exit(void)
89 {
90         platform_device_unregister(&bfin_isp1761_device);
91 }
92
93 arch_initcall(bfin_isp1761_init);
94 #endif
95
96 #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
97 #include <linux/usb/isp1362.h>
98
99 static struct resource isp1362_hcd_resources[] = {
100         {
101                 .start = 0x2c060000,
102                 .end = 0x2c060000,
103                 .flags = IORESOURCE_MEM,
104         }, {
105                 .start = 0x2c060004,
106                 .end = 0x2c060004,
107                 .flags = IORESOURCE_MEM,
108         }, {
109                 .start = IRQ_PF8,
110                 .end = IRQ_PF8,
111                 .flags = IORESOURCE_IRQ,
112         },
113 };
114
115 static struct isp1362_platform_data isp1362_priv = {
116         .sel15Kres = 1,
117         .clknotstop = 0,
118         .oc_enable = 0,
119         .int_act_high = 0,
120         .int_edge_triggered = 0,
121         .remote_wakeup_connected = 0,
122         .no_power_switching = 1,
123         .power_switching_mode = 0,
124 };
125
126 static struct platform_device isp1362_hcd_device = {
127         .name = "isp1362-hcd",
128         .id = 0,
129         .dev = {
130                 .platform_data = &isp1362_priv,
131         },
132         .num_resources = ARRAY_SIZE(isp1362_hcd_resources),
133         .resource = isp1362_hcd_resources,
134 };
135 #endif
136
137 #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
138 static struct resource net2272_bfin_resources[] = {
139         {
140                 .start = 0x2C000000,
141                 .end = 0x2C000000 + 0x7F,
142                 .flags = IORESOURCE_MEM,
143         }, {
144                 .start = IRQ_PF10,
145                 .end = IRQ_PF10,
146                 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
147         },
148 };
149
150 static struct platform_device net2272_bfin_device = {
151         .name = "net2272",
152         .id = -1,
153         .num_resources = ARRAY_SIZE(net2272_bfin_resources),
154         .resource = net2272_bfin_resources,
155 };
156 #endif
157
158 /*
159  *  USB-LAN EzExtender board
160  *  Driver needs to know address, irq and flag pin.
161  */
162 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
163 static struct resource smc91x_resources[] = {
164         {
165                 .name = "smc91x-regs",
166                 .start = 0x2C010300,
167                 .end = 0x2C010300 + 16,
168                 .flags = IORESOURCE_MEM,
169         }, {
170
171                 .start = IRQ_PF9,
172                 .end = IRQ_PF9,
173                 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
174         },
175 };
176
177 static struct platform_device smc91x_device = {
178         .name = "smc91x",
179         .id = 0,
180         .num_resources = ARRAY_SIZE(smc91x_resources),
181         .resource = smc91x_resources,
182 };
183 #endif
184
185 #if defined(CONFIG_AX88180) || defined(CONFIG_AX88180_MODULE)
186 static struct resource ax88180_resources[] = {
187         [0] = {
188                 .start  = 0x2c000000,
189                 .end    = 0x2c000000 + 0x8000,
190                 .flags  = IORESOURCE_MEM,
191         },
192         [1] = {
193                 .start  = IRQ_PF10,
194                 .end    = IRQ_PF10,
195                 .flags  = (IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL),
196         },
197 };
198
199 static struct platform_device ax88180_device = {
200         .name           = "ax88180",
201         .id             = -1,
202         .num_resources  = ARRAY_SIZE(ax88180_resources),
203         .resource       = ax88180_resources,
204 };
205 #endif
206
207 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
208 static struct resource bfin_uart_resources[] = {
209         {
210                 .start = 0xFFC00400,
211                 .end = 0xFFC004FF,
212                 .flags = IORESOURCE_MEM,
213         },
214 };
215
216 static struct platform_device bfin_uart_device = {
217         .name = "bfin-uart",
218         .id = 1,
219         .num_resources = ARRAY_SIZE(bfin_uart_resources),
220         .resource = bfin_uart_resources,
221 };
222 #endif
223
224 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
225 static struct resource bfin_sir_resources[] = {
226 #ifdef CONFIG_BFIN_SIR0
227         {
228                 .start = 0xFFC00400,
229                 .end = 0xFFC004FF,
230                 .flags = IORESOURCE_MEM,
231         },
232 #endif
233 };
234
235 static struct platform_device bfin_sir_device = {
236         .name = "bfin_sir",
237         .id = 0,
238         .num_resources = ARRAY_SIZE(bfin_sir_resources),
239         .resource = bfin_sir_resources,
240 };
241 #endif
242
243 #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
244 static struct mtd_partition ezkit_partitions[] = {
245         {
246                 .name       = "Bootloader",
247                 .size       = 0x40000,
248                 .offset     = 0,
249         }, {
250                 .name       = "Kernel",
251                 .size       = 0x1C0000,
252                 .offset     = MTDPART_OFS_APPEND,
253         }, {
254                 .name       = "RootFS",
255                 .size       = MTDPART_SIZ_FULL,
256                 .offset     = MTDPART_OFS_APPEND,
257         }
258 };
259
260 static struct physmap_flash_data ezkit_flash_data = {
261         .width      = 2,
262         .parts      = ezkit_partitions,
263         .nr_parts   = ARRAY_SIZE(ezkit_partitions),
264 };
265
266 static struct resource ezkit_flash_resource = {
267         .start = 0x20000000,
268         .end   = 0x207fffff,
269         .flags = IORESOURCE_MEM,
270 };
271
272 static struct platform_device ezkit_flash_device = {
273         .name          = "physmap-flash",
274         .id            = 0,
275         .dev = {
276                 .platform_data = &ezkit_flash_data,
277         },
278         .num_resources = 1,
279         .resource      = &ezkit_flash_resource,
280 };
281 #endif
282
283 #if defined(CONFIG_SND_BLACKFIN_AD1836) \
284         || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
285 static struct bfin5xx_spi_chip ad1836_spi_chip_info = {
286         .enable_dma = 0,
287         .bits_per_word = 16,
288 };
289 #endif
290
291 #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
292 static struct bfin5xx_spi_chip spidev_chip_info = {
293         .enable_dma = 0,
294         .bits_per_word = 8,
295 };
296 #endif
297
298 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
299 /* SPI (0) */
300 static struct resource bfin_spi0_resource[] = {
301         [0] = {
302                 .start = SPI0_REGBASE,
303                 .end   = SPI0_REGBASE + 0xFF,
304                 .flags = IORESOURCE_MEM,
305         },
306         [1] = {
307                 .start = CH_SPI,
308                 .end   = CH_SPI,
309                 .flags = IORESOURCE_IRQ,
310         }
311 };
312
313 /* SPI controller data */
314 static struct bfin5xx_spi_master bfin_spi0_info = {
315         .num_chipselect = 8,
316         .enable_dma = 1,  /* master has the ability to do dma transfer */
317         .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
318 };
319
320 static struct platform_device bfin_spi0_device = {
321         .name = "bfin-spi",
322         .id = 0, /* Bus number */
323         .num_resources = ARRAY_SIZE(bfin_spi0_resource),
324         .resource = bfin_spi0_resource,
325         .dev = {
326                 .platform_data = &bfin_spi0_info, /* Passed to driver */
327         },
328 };
329 #endif
330
331 static struct spi_board_info bfin_spi_board_info[] __initdata = {
332 #if defined(CONFIG_SND_BLACKFIN_AD1836) \
333         || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
334         {
335                 .modalias = "ad1836-spi",
336                 .max_speed_hz = 3125000,     /* max spi clock (SCK) speed in HZ */
337                 .bus_num = 0,
338                 .chip_select = CONFIG_SND_BLACKFIN_SPI_PFBIT,
339                 .controller_data = &ad1836_spi_chip_info,
340         },
341 #endif
342 #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
343         {
344                 .modalias = "spidev",
345                 .max_speed_hz = 3125000,     /* max spi clock (SCK) speed in HZ */
346                 .bus_num = 0,
347                 .chip_select = 1,
348                 .controller_data = &spidev_chip_info,
349         },
350 #endif
351 };
352
353 #if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
354 #define PATA_INT        55
355
356 static struct pata_platform_info bfin_pata_platform_data = {
357         .ioport_shift = 1,
358         .irq_type = IRQF_TRIGGER_HIGH | IRQF_DISABLED,
359 };
360
361 static struct resource bfin_pata_resources[] = {
362         {
363                 .start = 0x20314020,
364                 .end = 0x2031403F,
365                 .flags = IORESOURCE_MEM,
366         },
367         {
368                 .start = 0x2031401C,
369                 .end = 0x2031401F,
370                 .flags = IORESOURCE_MEM,
371         },
372         {
373                 .start = PATA_INT,
374                 .end = PATA_INT,
375                 .flags = IORESOURCE_IRQ,
376         },
377 };
378
379 static struct platform_device bfin_pata_device = {
380         .name = "pata_platform",
381         .id = -1,
382         .num_resources = ARRAY_SIZE(bfin_pata_resources),
383         .resource = bfin_pata_resources,
384         .dev = {
385                 .platform_data = &bfin_pata_platform_data,
386         }
387 };
388 #endif
389
390 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
391 #include <linux/input.h>
392 #include <linux/gpio_keys.h>
393
394 static struct gpio_keys_button bfin_gpio_keys_table[] = {
395         {BTN_0, GPIO_PF5, 1, "gpio-keys: BTN0"},
396         {BTN_1, GPIO_PF6, 1, "gpio-keys: BTN1"},
397         {BTN_2, GPIO_PF7, 1, "gpio-keys: BTN2"},
398         {BTN_3, GPIO_PF8, 1, "gpio-keys: BTN3"},
399 };
400
401 static struct gpio_keys_platform_data bfin_gpio_keys_data = {
402         .buttons        = bfin_gpio_keys_table,
403         .nbuttons       = ARRAY_SIZE(bfin_gpio_keys_table),
404 };
405
406 static struct platform_device bfin_device_gpiokeys = {
407         .name      = "gpio-keys",
408         .dev = {
409                 .platform_data = &bfin_gpio_keys_data,
410         },
411 };
412 #endif
413
414 static struct resource bfin_gpios_resources = {
415         .start = 0,
416         .end   = MAX_BLACKFIN_GPIOS - 1,
417         .flags = IORESOURCE_IRQ,
418 };
419
420 static struct platform_device bfin_gpios_device = {
421         .name = "simple-gpio",
422         .id = -1,
423         .num_resources = 1,
424         .resource = &bfin_gpios_resources,
425 };
426
427 #if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
428 #include <linux/i2c-gpio.h>
429
430 static struct i2c_gpio_platform_data i2c_gpio_data = {
431         .sda_pin                = 1,
432         .scl_pin                = 0,
433         .sda_is_open_drain      = 0,
434         .scl_is_open_drain      = 0,
435         .udelay                 = 40,
436 };
437
438 static struct platform_device i2c_gpio_device = {
439         .name           = "i2c-gpio",
440         .id             = 0,
441         .dev            = {
442                 .platform_data  = &i2c_gpio_data,
443         },
444 };
445 #endif
446
447 static const unsigned int cclk_vlev_datasheet[] =
448 {
449         VRPAIR(VLEV_085, 250000000),
450         VRPAIR(VLEV_090, 300000000),
451         VRPAIR(VLEV_095, 313000000),
452         VRPAIR(VLEV_100, 350000000),
453         VRPAIR(VLEV_105, 400000000),
454         VRPAIR(VLEV_110, 444000000),
455         VRPAIR(VLEV_115, 450000000),
456         VRPAIR(VLEV_120, 475000000),
457         VRPAIR(VLEV_125, 500000000),
458         VRPAIR(VLEV_130, 600000000),
459 };
460
461 static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
462         .tuple_tab = cclk_vlev_datasheet,
463         .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
464         .vr_settling_time = 25 /* us */,
465 };
466
467 static struct platform_device bfin_dpmc = {
468         .name = "bfin dpmc",
469         .dev = {
470                 .platform_data = &bfin_dmpc_vreg_data,
471         },
472 };
473
474 static struct platform_device *ezkit_devices[] __initdata = {
475
476         &bfin_dpmc,
477
478 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
479         &smc91x_device,
480 #endif
481
482 #if defined(CONFIG_AX88180) || defined(CONFIG_AX88180_MODULE)
483         &ax88180_device,
484 #endif
485
486 #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
487         &net2272_bfin_device,
488 #endif
489
490 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
491         &bfin_spi0_device,
492 #endif
493
494 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
495         &bfin_uart_device,
496 #endif
497
498 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
499         &bfin_sir_device,
500 #endif
501
502 #if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
503         &bfin_pata_device,
504 #endif
505
506 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
507         &bfin_device_gpiokeys,
508 #endif
509
510 #if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
511         &i2c_gpio_device,
512 #endif
513
514 #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
515         &isp1362_hcd_device,
516 #endif
517
518         &bfin_gpios_device,
519
520 #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
521         &ezkit_flash_device,
522 #endif
523 };
524
525 static int __init ezkit_init(void)
526 {
527         int ret;
528
529         printk(KERN_INFO "%s(): registering device resources\n", __func__);
530
531         ret = platform_add_devices(ezkit_devices, ARRAY_SIZE(ezkit_devices));
532         if (ret < 0)
533                 return ret;
534
535 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
536         bfin_write_FIO0_DIR(bfin_read_FIO0_DIR() | (1 << 12));
537         SSYNC();
538 #endif
539
540         spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
541
542 #if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
543         irq_desc[PATA_INT].status |= IRQ_NOAUTOEN;
544 #endif
545         return 0;
546 }
547
548 arch_initcall(ezkit_init);