Merge commit 'v2.6.27-rc7' into x86/microcode
[linux-2.6] / 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 <asm/dma.h>
39 #include <asm/bfin5xx_spi.h>
40 #include <asm/portmux.h>
41 #include <asm/dpmc.h>
42
43 /*
44  * Name the Board for the /proc/cpuinfo
45  */
46 const char bfin_board_name[] = "ADDS-BF561-EZKIT";
47
48 #define ISP1761_BASE       0x2C0F0000
49 #define ISP1761_IRQ        IRQ_PF10
50
51 #if defined(CONFIG_USB_ISP1760_HCD) || defined(CONFIG_USB_ISP1760_HCD_MODULE)
52 static struct resource bfin_isp1761_resources[] = {
53         {
54                 .name   = "isp1761-regs",
55                 .start  = ISP1761_BASE + 0x00000000,
56                 .end    = ISP1761_BASE + 0x000fffff,
57                 .flags  = IORESOURCE_MEM,
58         },
59         {
60                 .start  = ISP1761_IRQ,
61                 .end    = ISP1761_IRQ,
62                 .flags  = IORESOURCE_IRQ,
63         },
64 };
65
66 static struct platform_device bfin_isp1761_device = {
67         .name           = "isp1761",
68         .id             = 0,
69         .num_resources  = ARRAY_SIZE(bfin_isp1761_resources),
70         .resource       = bfin_isp1761_resources,
71 };
72
73 static struct platform_device *bfin_isp1761_devices[] = {
74         &bfin_isp1761_device,
75 };
76
77 int __init bfin_isp1761_init(void)
78 {
79         unsigned int num_devices = ARRAY_SIZE(bfin_isp1761_devices);
80
81         printk(KERN_INFO "%s(): registering device resources\n", __func__);
82         set_irq_type(ISP1761_IRQ, IRQF_TRIGGER_FALLING);
83
84         return platform_add_devices(bfin_isp1761_devices, num_devices);
85 }
86
87 void __exit bfin_isp1761_exit(void)
88 {
89         platform_device_unregister(&bfin_isp1761_device);
90 }
91
92 arch_initcall(bfin_isp1761_init);
93 #endif
94
95 #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
96 #include <linux/usb/isp1362.h>
97
98 static struct resource isp1362_hcd_resources[] = {
99         {
100                 .start = 0x2c060000,
101                 .end = 0x2c060000,
102                 .flags = IORESOURCE_MEM,
103         }, {
104                 .start = 0x2c060004,
105                 .end = 0x2c060004,
106                 .flags = IORESOURCE_MEM,
107         }, {
108                 .start = IRQ_PF8,
109                 .end = IRQ_PF8,
110                 .flags = IORESOURCE_IRQ,
111         },
112 };
113
114 static struct isp1362_platform_data isp1362_priv = {
115         .sel15Kres = 1,
116         .clknotstop = 0,
117         .oc_enable = 0,
118         .int_act_high = 0,
119         .int_edge_triggered = 0,
120         .remote_wakeup_connected = 0,
121         .no_power_switching = 1,
122         .power_switching_mode = 0,
123 };
124
125 static struct platform_device isp1362_hcd_device = {
126         .name = "isp1362-hcd",
127         .id = 0,
128         .dev = {
129                 .platform_data = &isp1362_priv,
130         },
131         .num_resources = ARRAY_SIZE(isp1362_hcd_resources),
132         .resource = isp1362_hcd_resources,
133 };
134 #endif
135
136 #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
137 static struct resource net2272_bfin_resources[] = {
138         {
139                 .start = 0x2C000000,
140                 .end = 0x2C000000 + 0x7F,
141                 .flags = IORESOURCE_MEM,
142         }, {
143                 .start = IRQ_PF10,
144                 .end = IRQ_PF10,
145                 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
146         },
147 };
148
149 static struct platform_device net2272_bfin_device = {
150         .name = "net2272",
151         .id = -1,
152         .num_resources = ARRAY_SIZE(net2272_bfin_resources),
153         .resource = net2272_bfin_resources,
154 };
155 #endif
156
157 /*
158  *  USB-LAN EzExtender board
159  *  Driver needs to know address, irq and flag pin.
160  */
161 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
162 static struct resource smc91x_resources[] = {
163         {
164                 .name = "smc91x-regs",
165                 .start = 0x2C010300,
166                 .end = 0x2C010300 + 16,
167                 .flags = IORESOURCE_MEM,
168         }, {
169
170                 .start = IRQ_PF9,
171                 .end = IRQ_PF9,
172                 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
173         },
174 };
175
176 static struct platform_device smc91x_device = {
177         .name = "smc91x",
178         .id = 0,
179         .num_resources = ARRAY_SIZE(smc91x_resources),
180         .resource = smc91x_resources,
181 };
182 #endif
183
184 #if defined(CONFIG_AX88180) || defined(CONFIG_AX88180_MODULE)
185 static struct resource ax88180_resources[] = {
186         [0] = {
187                 .start  = 0x2c000000,
188                 .end    = 0x2c000000 + 0x8000,
189                 .flags  = IORESOURCE_MEM,
190         },
191         [1] = {
192                 .start  = IRQ_PF10,
193                 .end    = IRQ_PF10,
194                 .flags  = (IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL),
195         },
196 };
197
198 static struct platform_device ax88180_device = {
199         .name           = "ax88180",
200         .id             = -1,
201         .num_resources  = ARRAY_SIZE(ax88180_resources),
202         .resource       = ax88180_resources,
203 };
204 #endif
205
206 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
207 static struct resource bfin_uart_resources[] = {
208         {
209                 .start = 0xFFC00400,
210                 .end = 0xFFC004FF,
211                 .flags = IORESOURCE_MEM,
212         },
213 };
214
215 static struct platform_device bfin_uart_device = {
216         .name = "bfin-uart",
217         .id = 1,
218         .num_resources = ARRAY_SIZE(bfin_uart_resources),
219         .resource = bfin_uart_resources,
220 };
221 #endif
222
223 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
224 static struct resource bfin_sir_resources[] = {
225 #ifdef CONFIG_BFIN_SIR0
226         {
227                 .start = 0xFFC00400,
228                 .end = 0xFFC004FF,
229                 .flags = IORESOURCE_MEM,
230         },
231 #endif
232 };
233
234 static struct platform_device bfin_sir_device = {
235         .name = "bfin_sir",
236         .id = 0,
237         .num_resources = ARRAY_SIZE(bfin_sir_resources),
238         .resource = bfin_sir_resources,
239 };
240 #endif
241
242 #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
243 static struct mtd_partition ezkit_partitions[] = {
244         {
245                 .name       = "bootloader(nor)",
246                 .size       = 0x40000,
247                 .offset     = 0,
248         }, {
249                 .name       = "linux kernel(nor)",
250                 .size       = 0x1C0000,
251                 .offset     = MTDPART_OFS_APPEND,
252         }, {
253                 .name       = "file system(nor)",
254                 .size       = MTDPART_SIZ_FULL,
255                 .offset     = MTDPART_OFS_APPEND,
256         }
257 };
258
259 static struct physmap_flash_data ezkit_flash_data = {
260         .width      = 2,
261         .parts      = ezkit_partitions,
262         .nr_parts   = ARRAY_SIZE(ezkit_partitions),
263 };
264
265 static struct resource ezkit_flash_resource = {
266         .start = 0x20000000,
267         .end   = 0x207fffff,
268         .flags = IORESOURCE_MEM,
269 };
270
271 static struct platform_device ezkit_flash_device = {
272         .name          = "physmap-flash",
273         .id            = 0,
274         .dev = {
275                 .platform_data = &ezkit_flash_data,
276         },
277         .num_resources = 1,
278         .resource      = &ezkit_flash_resource,
279 };
280 #endif
281
282 #if defined(CONFIG_SND_BLACKFIN_AD1836) \
283         || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
284 static struct bfin5xx_spi_chip ad1836_spi_chip_info = {
285         .enable_dma = 0,
286         .bits_per_word = 16,
287 };
288 #endif
289
290 #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
291 static struct bfin5xx_spi_chip spidev_chip_info = {
292         .enable_dma = 0,
293         .bits_per_word = 8,
294 };
295 #endif
296
297 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
298 /* SPI (0) */
299 static struct resource bfin_spi0_resource[] = {
300         [0] = {
301                 .start = SPI0_REGBASE,
302                 .end   = SPI0_REGBASE + 0xFF,
303                 .flags = IORESOURCE_MEM,
304         },
305         [1] = {
306                 .start = CH_SPI,
307                 .end   = CH_SPI,
308                 .flags = IORESOURCE_IRQ,
309         }
310 };
311
312 /* SPI controller data */
313 static struct bfin5xx_spi_master bfin_spi0_info = {
314         .num_chipselect = 8,
315         .enable_dma = 1,  /* master has the ability to do dma transfer */
316         .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
317 };
318
319 static struct platform_device bfin_spi0_device = {
320         .name = "bfin-spi",
321         .id = 0, /* Bus number */
322         .num_resources = ARRAY_SIZE(bfin_spi0_resource),
323         .resource = bfin_spi0_resource,
324         .dev = {
325                 .platform_data = &bfin_spi0_info, /* Passed to driver */
326         },
327 };
328 #endif
329
330 static struct spi_board_info bfin_spi_board_info[] __initdata = {
331 #if defined(CONFIG_SND_BLACKFIN_AD1836) \
332         || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
333         {
334                 .modalias = "ad1836-spi",
335                 .max_speed_hz = 3125000,     /* max spi clock (SCK) speed in HZ */
336                 .bus_num = 0,
337                 .chip_select = CONFIG_SND_BLACKFIN_SPI_PFBIT,
338                 .controller_data = &ad1836_spi_chip_info,
339         },
340 #endif
341 #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
342         {
343                 .modalias = "spidev",
344                 .max_speed_hz = 3125000,     /* max spi clock (SCK) speed in HZ */
345                 .bus_num = 0,
346                 .chip_select = 1,
347                 .controller_data = &spidev_chip_info,
348         },
349 #endif
350 };
351
352 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
353 #include <linux/input.h>
354 #include <linux/gpio_keys.h>
355
356 static struct gpio_keys_button bfin_gpio_keys_table[] = {
357         {BTN_0, GPIO_PF5, 1, "gpio-keys: BTN0"},
358         {BTN_1, GPIO_PF6, 1, "gpio-keys: BTN1"},
359         {BTN_2, GPIO_PF7, 1, "gpio-keys: BTN2"},
360         {BTN_3, GPIO_PF8, 1, "gpio-keys: BTN3"},
361 };
362
363 static struct gpio_keys_platform_data bfin_gpio_keys_data = {
364         .buttons        = bfin_gpio_keys_table,
365         .nbuttons       = ARRAY_SIZE(bfin_gpio_keys_table),
366 };
367
368 static struct platform_device bfin_device_gpiokeys = {
369         .name      = "gpio-keys",
370         .dev = {
371                 .platform_data = &bfin_gpio_keys_data,
372         },
373 };
374 #endif
375
376 static struct resource bfin_gpios_resources = {
377         .start = 0,
378         .end   = MAX_BLACKFIN_GPIOS - 1,
379         .flags = IORESOURCE_IRQ,
380 };
381
382 static struct platform_device bfin_gpios_device = {
383         .name = "simple-gpio",
384         .id = -1,
385         .num_resources = 1,
386         .resource = &bfin_gpios_resources,
387 };
388
389 #if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
390 #include <linux/i2c-gpio.h>
391
392 static struct i2c_gpio_platform_data i2c_gpio_data = {
393         .sda_pin                = 1,
394         .scl_pin                = 0,
395         .sda_is_open_drain      = 0,
396         .scl_is_open_drain      = 0,
397         .udelay                 = 40,
398 };
399
400 static struct platform_device i2c_gpio_device = {
401         .name           = "i2c-gpio",
402         .id             = 0,
403         .dev            = {
404                 .platform_data  = &i2c_gpio_data,
405         },
406 };
407 #endif
408
409 static const unsigned int cclk_vlev_datasheet[] =
410 {
411         VRPAIR(VLEV_085, 250000000),
412         VRPAIR(VLEV_090, 300000000),
413         VRPAIR(VLEV_095, 313000000),
414         VRPAIR(VLEV_100, 350000000),
415         VRPAIR(VLEV_105, 400000000),
416         VRPAIR(VLEV_110, 444000000),
417         VRPAIR(VLEV_115, 450000000),
418         VRPAIR(VLEV_120, 475000000),
419         VRPAIR(VLEV_125, 500000000),
420         VRPAIR(VLEV_130, 600000000),
421 };
422
423 static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
424         .tuple_tab = cclk_vlev_datasheet,
425         .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
426         .vr_settling_time = 25 /* us */,
427 };
428
429 static struct platform_device bfin_dpmc = {
430         .name = "bfin dpmc",
431         .dev = {
432                 .platform_data = &bfin_dmpc_vreg_data,
433         },
434 };
435
436 static struct platform_device *ezkit_devices[] __initdata = {
437
438         &bfin_dpmc,
439
440 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
441         &smc91x_device,
442 #endif
443
444 #if defined(CONFIG_AX88180) || defined(CONFIG_AX88180_MODULE)
445         &ax88180_device,
446 #endif
447
448 #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
449         &net2272_bfin_device,
450 #endif
451
452 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
453         &bfin_spi0_device,
454 #endif
455
456 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
457         &bfin_uart_device,
458 #endif
459
460 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
461         &bfin_sir_device,
462 #endif
463
464 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
465         &bfin_device_gpiokeys,
466 #endif
467
468 #if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
469         &i2c_gpio_device,
470 #endif
471
472 #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
473         &isp1362_hcd_device,
474 #endif
475
476         &bfin_gpios_device,
477
478 #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
479         &ezkit_flash_device,
480 #endif
481 };
482
483 static int __init ezkit_init(void)
484 {
485         int ret;
486
487         printk(KERN_INFO "%s(): registering device resources\n", __func__);
488
489         ret = platform_add_devices(ezkit_devices, ARRAY_SIZE(ezkit_devices));
490         if (ret < 0)
491                 return ret;
492
493 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
494         bfin_write_FIO0_DIR(bfin_read_FIO0_DIR() | (1 << 12));
495         SSYNC();
496 #endif
497
498         spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
499         return 0;
500 }
501
502 arch_initcall(ezkit_init);