Blackfin: convert boards to use platform data with smc91x
[linux-2.6/linux-2.6-openrd.git] / arch / blackfin / mach-bf538 / boards / ezkit.c
blob42297fad46b921c7a6419a6a913ba768c54ca672
1 /*
2 * File: arch/blackfin/mach-bf538/boards/ezkit.c
3 * Based on: arch/blackfin/mach-bf537/boards/ezkit.c
4 * Author: Aidan Williams <aidan@nicta.com.au>
6 * Created:
7 * Description:
9 * Modified:
10 * Copyright 2005 National ICT Australia (NICTA)
11 * Copyright 2004-2008 Analog Devices Inc.
13 * Bugs: Enter bugs at http://blackfin.uclinux.org/
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.
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.
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
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 <asm/bfin5xx_spi.h>
40 #include <asm/dma.h>
41 #include <asm/gpio.h>
42 #include <asm/nand.h>
43 #include <asm/portmux.h>
44 #include <asm/dpmc.h>
45 #include <linux/input.h>
48 * Name the Board for the /proc/cpuinfo
50 const char bfin_board_name[] = "ADI BF538-EZKIT";
53 * Driver needs to know address, irq and flag pin.
57 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
58 static struct platform_device rtc_device = {
59 .name = "rtc-bfin",
60 .id = -1,
62 #endif
64 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
65 static struct resource bfin_uart_resources[] = {
66 #ifdef CONFIG_SERIAL_BFIN_UART0
68 .start = 0xFFC00400,
69 .end = 0xFFC004FF,
70 .flags = IORESOURCE_MEM,
72 #endif
73 #ifdef CONFIG_SERIAL_BFIN_UART1
75 .start = 0xFFC02000,
76 .end = 0xFFC020FF,
77 .flags = IORESOURCE_MEM,
79 #endif
80 #ifdef CONFIG_SERIAL_BFIN_UART2
82 .start = 0xFFC02100,
83 .end = 0xFFC021FF,
84 .flags = IORESOURCE_MEM,
86 #endif
89 static struct platform_device bfin_uart_device = {
90 .name = "bfin-uart",
91 .id = 1,
92 .num_resources = ARRAY_SIZE(bfin_uart_resources),
93 .resource = bfin_uart_resources,
95 #endif
97 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
98 #ifdef CONFIG_BFIN_SIR0
99 static struct resource bfin_sir0_resources[] = {
101 .start = 0xFFC00400,
102 .end = 0xFFC004FF,
103 .flags = IORESOURCE_MEM,
106 .start = IRQ_UART0_RX,
107 .end = IRQ_UART0_RX+1,
108 .flags = IORESOURCE_IRQ,
111 .start = CH_UART0_RX,
112 .end = CH_UART0_RX+1,
113 .flags = IORESOURCE_DMA,
116 static struct platform_device bfin_sir0_device = {
117 .name = "bfin_sir",
118 .id = 0,
119 .num_resources = ARRAY_SIZE(bfin_sir0_resources),
120 .resource = bfin_sir0_resources,
122 #endif
123 #ifdef CONFIG_BFIN_SIR1
124 static struct resource bfin_sir1_resources[] = {
126 .start = 0xFFC02000,
127 .end = 0xFFC020FF,
128 .flags = IORESOURCE_MEM,
131 .start = IRQ_UART1_RX,
132 .end = IRQ_UART1_RX+1,
133 .flags = IORESOURCE_IRQ,
136 .start = CH_UART1_RX,
137 .end = CH_UART1_RX+1,
138 .flags = IORESOURCE_DMA,
141 static struct platform_device bfin_sir1_device = {
142 .name = "bfin_sir",
143 .id = 1,
144 .num_resources = ARRAY_SIZE(bfin_sir1_resources),
145 .resource = bfin_sir1_resources,
147 #endif
148 #ifdef CONFIG_BFIN_SIR2
149 static struct resource bfin_sir2_resources[] = {
151 .start = 0xFFC02100,
152 .end = 0xFFC021FF,
153 .flags = IORESOURCE_MEM,
156 .start = IRQ_UART2_RX,
157 .end = IRQ_UART2_RX+1,
158 .flags = IORESOURCE_IRQ,
161 .start = CH_UART2_RX,
162 .end = CH_UART2_RX+1,
163 .flags = IORESOURCE_DMA,
166 static struct platform_device bfin_sir2_device = {
167 .name = "bfin_sir",
168 .id = 2,
169 .num_resources = ARRAY_SIZE(bfin_sir2_resources),
170 .resource = bfin_sir2_resources,
172 #endif
173 #endif
176 * USB-LAN EzExtender board
177 * Driver needs to know address, irq and flag pin.
179 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
180 #include <linux/smc91x.h>
182 static struct smc91x_platdata smc91x_info = {
183 .flags = SMC91X_USE_16BIT | SMC91X_NOWAIT,
184 .leda = RPC_LED_100_10,
185 .ledb = RPC_LED_TX_RX,
188 static struct resource smc91x_resources[] = {
190 .name = "smc91x-regs",
191 .start = 0x20310300,
192 .end = 0x20310300 + 16,
193 .flags = IORESOURCE_MEM,
194 }, {
195 .start = IRQ_PF0,
196 .end = IRQ_PF0,
197 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
200 static struct platform_device smc91x_device = {
201 .name = "smc91x",
202 .id = 0,
203 .num_resources = ARRAY_SIZE(smc91x_resources),
204 .resource = smc91x_resources,
205 .dev = {
206 .platform_data = &smc91x_info,
209 #endif
211 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
212 /* all SPI peripherals info goes here */
213 #if defined(CONFIG_MTD_M25P80) \
214 || defined(CONFIG_MTD_M25P80_MODULE)
215 /* SPI flash chip (m25p16) */
216 static struct mtd_partition bfin_spi_flash_partitions[] = {
218 .name = "bootloader(spi)",
219 .size = 0x00040000,
220 .offset = 0,
221 .mask_flags = MTD_CAP_ROM
222 }, {
223 .name = "linux kernel(spi)",
224 .size = 0x1c0000,
225 .offset = 0x40000
229 static struct flash_platform_data bfin_spi_flash_data = {
230 .name = "m25p80",
231 .parts = bfin_spi_flash_partitions,
232 .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
233 .type = "m25p16",
236 static struct bfin5xx_spi_chip spi_flash_chip_info = {
237 .enable_dma = 0, /* use dma transfer with this chip*/
238 .bits_per_word = 8,
239 .cs_change_per_word = 0,
241 #endif
243 #if defined(CONFIG_TOUCHSCREEN_AD7879) || defined(CONFIG_TOUCHSCREEN_AD7879_MODULE)
244 #include <linux/spi/ad7879.h>
245 static const struct ad7879_platform_data bfin_ad7879_ts_info = {
246 .model = 7879, /* Model = AD7879 */
247 .x_plate_ohms = 620, /* 620 Ohm from the touch datasheet */
248 .pressure_max = 10000,
249 .pressure_min = 0,
250 .first_conversion_delay = 3, /* wait 512us before do a first conversion */
251 .acquisition_time = 1, /* 4us acquisition time per sample */
252 .median = 2, /* do 8 measurements */
253 .averaging = 1, /* take the average of 4 middle samples */
254 .pen_down_acc_interval = 255, /* 9.4 ms */
255 .gpio_output = 1, /* configure AUX/VBAT/GPIO as GPIO output */
256 .gpio_default = 1, /* During initialization set GPIO = HIGH */
258 #endif
260 #if defined(CONFIG_TOUCHSCREEN_AD7879_SPI) || defined(CONFIG_TOUCHSCREEN_AD7879_SPI_MODULE)
261 static struct bfin5xx_spi_chip spi_ad7879_chip_info = {
262 .enable_dma = 0,
263 .bits_per_word = 16,
265 #endif
267 #if defined(CONFIG_FB_BFIN_LQ035Q1) || defined(CONFIG_FB_BFIN_LQ035Q1_MODULE)
268 #include <asm/bfin-lq035q1.h>
270 static struct bfin_lq035q1fb_disp_info bfin_lq035q1_data = {
271 .mode = LQ035_NORM | LQ035_RGB | LQ035_RL | LQ035_TB,
272 .use_bl = 0, /* let something else control the LCD Blacklight */
273 .gpio_bl = GPIO_PF7,
276 static struct resource bfin_lq035q1_resources[] = {
278 .start = IRQ_PPI_ERROR,
279 .end = IRQ_PPI_ERROR,
280 .flags = IORESOURCE_IRQ,
284 static struct platform_device bfin_lq035q1_device = {
285 .name = "bfin-lq035q1",
286 .id = -1,
287 .num_resources = ARRAY_SIZE(bfin_lq035q1_resources),
288 .resource = bfin_lq035q1_resources,
289 .dev = {
290 .platform_data = &bfin_lq035q1_data,
293 #endif
295 #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
296 static struct bfin5xx_spi_chip spidev_chip_info = {
297 .enable_dma = 0,
298 .bits_per_word = 8,
300 #endif
302 #if defined(CONFIG_FB_BFIN_LQ035Q1) || defined(CONFIG_FB_BFIN_LQ035Q1_MODULE)
303 static struct bfin5xx_spi_chip lq035q1_spi_chip_info = {
304 .enable_dma = 0,
305 .bits_per_word = 8,
307 #endif
309 static struct spi_board_info bf538_spi_board_info[] __initdata = {
310 #if defined(CONFIG_MTD_M25P80) \
311 || defined(CONFIG_MTD_M25P80_MODULE)
313 /* the modalias must be the same as spi device driver name */
314 .modalias = "m25p80", /* Name of spi_driver for this device */
315 .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
316 .bus_num = 0, /* Framework bus number */
317 .chip_select = 1, /* SPI_SSEL1*/
318 .platform_data = &bfin_spi_flash_data,
319 .controller_data = &spi_flash_chip_info,
320 .mode = SPI_MODE_3,
322 #endif
323 #if defined(CONFIG_TOUCHSCREEN_AD7879_SPI) || defined(CONFIG_TOUCHSCREEN_AD7879_SPI_MODULE)
325 .modalias = "ad7879",
326 .platform_data = &bfin_ad7879_ts_info,
327 .irq = IRQ_PF3,
328 .max_speed_hz = 5000000, /* max spi clock (SCK) speed in HZ */
329 .bus_num = 0,
330 .chip_select = 1,
331 .controller_data = &spi_ad7879_chip_info,
332 .mode = SPI_CPHA | SPI_CPOL,
334 #endif
335 #if defined(CONFIG_FB_BFIN_LQ035Q1) || defined(CONFIG_FB_BFIN_LQ035Q1_MODULE)
337 .modalias = "bfin-lq035q1-spi",
338 .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */
339 .bus_num = 0,
340 .chip_select = 2,
341 .controller_data = &lq035q1_spi_chip_info,
342 .mode = SPI_CPHA | SPI_CPOL,
344 #endif
345 #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
347 .modalias = "spidev",
348 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
349 .bus_num = 0,
350 .chip_select = 1,
351 .controller_data = &spidev_chip_info,
353 #endif
356 /* SPI (0) */
357 static struct resource bfin_spi0_resource[] = {
358 [0] = {
359 .start = SPI0_REGBASE,
360 .end = SPI0_REGBASE + 0xFF,
361 .flags = IORESOURCE_MEM,
363 [1] = {
364 .start = CH_SPI0,
365 .end = CH_SPI0,
366 .flags = IORESOURCE_DMA,
368 [2] = {
369 .start = IRQ_SPI0,
370 .end = IRQ_SPI0,
371 .flags = IORESOURCE_IRQ,
375 /* SPI (1) */
376 static struct resource bfin_spi1_resource[] = {
377 [0] = {
378 .start = SPI1_REGBASE,
379 .end = SPI1_REGBASE + 0xFF,
380 .flags = IORESOURCE_MEM,
382 [1] = {
383 .start = CH_SPI1,
384 .end = CH_SPI1,
385 .flags = IORESOURCE_DMA,
387 [2] = {
388 .start = IRQ_SPI1,
389 .end = IRQ_SPI1,
390 .flags = IORESOURCE_IRQ,
394 /* SPI (2) */
395 static struct resource bfin_spi2_resource[] = {
396 [0] = {
397 .start = SPI2_REGBASE,
398 .end = SPI2_REGBASE + 0xFF,
399 .flags = IORESOURCE_MEM,
401 [1] = {
402 .start = CH_SPI2,
403 .end = CH_SPI2,
404 .flags = IORESOURCE_IRQ,
408 /* SPI controller data */
409 static struct bfin5xx_spi_master bf538_spi_master_info0 = {
410 .num_chipselect = 8,
411 .enable_dma = 1, /* master has the ability to do dma transfer */
412 .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
415 static struct platform_device bf538_spi_master0 = {
416 .name = "bfin-spi",
417 .id = 0, /* Bus number */
418 .num_resources = ARRAY_SIZE(bfin_spi0_resource),
419 .resource = bfin_spi0_resource,
420 .dev = {
421 .platform_data = &bf538_spi_master_info0, /* Passed to driver */
425 static struct bfin5xx_spi_master bf538_spi_master_info1 = {
426 .num_chipselect = 8,
427 .enable_dma = 1, /* master has the ability to do dma transfer */
428 .pin_req = {P_SPI1_SCK, P_SPI1_MISO, P_SPI1_MOSI, 0},
431 static struct platform_device bf538_spi_master1 = {
432 .name = "bfin-spi",
433 .id = 1, /* Bus number */
434 .num_resources = ARRAY_SIZE(bfin_spi1_resource),
435 .resource = bfin_spi1_resource,
436 .dev = {
437 .platform_data = &bf538_spi_master_info1, /* Passed to driver */
441 static struct bfin5xx_spi_master bf538_spi_master_info2 = {
442 .num_chipselect = 8,
443 .enable_dma = 1, /* master has the ability to do dma transfer */
444 .pin_req = {P_SPI2_SCK, P_SPI2_MISO, P_SPI2_MOSI, 0},
447 static struct platform_device bf538_spi_master2 = {
448 .name = "bfin-spi",
449 .id = 2, /* Bus number */
450 .num_resources = ARRAY_SIZE(bfin_spi2_resource),
451 .resource = bfin_spi2_resource,
452 .dev = {
453 .platform_data = &bf538_spi_master_info2, /* Passed to driver */
457 #endif /* spi master and devices */
459 #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
460 static struct resource bfin_twi0_resource[] = {
461 [0] = {
462 .start = TWI0_REGBASE,
463 .end = TWI0_REGBASE + 0xFF,
464 .flags = IORESOURCE_MEM,
466 [1] = {
467 .start = IRQ_TWI0,
468 .end = IRQ_TWI0,
469 .flags = IORESOURCE_IRQ,
473 static struct platform_device i2c_bfin_twi0_device = {
474 .name = "i2c-bfin-twi",
475 .id = 0,
476 .num_resources = ARRAY_SIZE(bfin_twi0_resource),
477 .resource = bfin_twi0_resource,
480 #if !defined(CONFIG_BF542) /* The BF542 only has 1 TWI */
481 static struct resource bfin_twi1_resource[] = {
482 [0] = {
483 .start = TWI1_REGBASE,
484 .end = TWI1_REGBASE + 0xFF,
485 .flags = IORESOURCE_MEM,
487 [1] = {
488 .start = IRQ_TWI1,
489 .end = IRQ_TWI1,
490 .flags = IORESOURCE_IRQ,
494 static struct platform_device i2c_bfin_twi1_device = {
495 .name = "i2c-bfin-twi",
496 .id = 1,
497 .num_resources = ARRAY_SIZE(bfin_twi1_resource),
498 .resource = bfin_twi1_resource,
500 #endif
501 #endif
503 static struct resource bfin_gpios_resources = {
504 .start = 0,
505 .end = MAX_BLACKFIN_GPIOS - 1,
506 .flags = IORESOURCE_IRQ,
509 static struct platform_device bfin_gpios_device = {
510 .name = "simple-gpio",
511 .id = -1,
512 .num_resources = 1,
513 .resource = &bfin_gpios_resources,
516 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
517 #include <linux/gpio_keys.h>
519 static struct gpio_keys_button bfin_gpio_keys_table[] = {
520 {BTN_0, GPIO_PC7, 1, "gpio-keys: BTN0"},
523 static struct gpio_keys_platform_data bfin_gpio_keys_data = {
524 .buttons = bfin_gpio_keys_table,
525 .nbuttons = ARRAY_SIZE(bfin_gpio_keys_table),
528 static struct platform_device bfin_device_gpiokeys = {
529 .name = "gpio-keys",
530 .dev = {
531 .platform_data = &bfin_gpio_keys_data,
534 #endif
536 static const unsigned int cclk_vlev_datasheet[] =
539 * Internal VLEV BF538SBBC1533
540 ****temporarily using these values until data sheet is updated
542 VRPAIR(VLEV_100, 150000000),
543 VRPAIR(VLEV_100, 250000000),
544 VRPAIR(VLEV_110, 276000000),
545 VRPAIR(VLEV_115, 301000000),
546 VRPAIR(VLEV_120, 525000000),
547 VRPAIR(VLEV_125, 550000000),
548 VRPAIR(VLEV_130, 600000000),
551 static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
552 .tuple_tab = cclk_vlev_datasheet,
553 .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
554 .vr_settling_time = 25 /* us */,
557 static struct platform_device bfin_dpmc = {
558 .name = "bfin dpmc",
559 .dev = {
560 .platform_data = &bfin_dmpc_vreg_data,
564 static struct platform_device *cm_bf538_devices[] __initdata = {
566 &bfin_dpmc,
568 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
569 &rtc_device,
570 #endif
572 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
573 &bfin_uart_device,
574 #endif
576 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
577 &bf538_spi_master0,
578 &bf538_spi_master1,
579 &bf538_spi_master2,
580 #endif
582 #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
583 &i2c_bfin_twi0_device,
584 &i2c_bfin_twi1_device,
585 #endif
587 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
588 #ifdef CONFIG_BFIN_SIR0
589 &bfin_sir0_device,
590 #endif
591 #ifdef CONFIG_BFIN_SIR1
592 &bfin_sir1_device,
593 #endif
594 #ifdef CONFIG_BFIN_SIR2
595 &bfin_sir2_device,
596 #endif
597 #endif
599 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
600 &smc91x_device,
601 #endif
603 #if defined(CONFIG_FB_BFIN_LQ035Q1) || defined(CONFIG_FB_BFIN_LQ035Q1_MODULE)
604 &bfin_lq035q1_device,
605 #endif
607 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
608 &bfin_device_gpiokeys,
609 #endif
611 &bfin_gpios_device,
614 static int __init ezkit_init(void)
616 printk(KERN_INFO "%s(): registering device resources\n", __func__);
617 platform_add_devices(cm_bf538_devices, ARRAY_SIZE(cm_bf538_devices));
619 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
620 spi_register_board_info(bf538_spi_board_info,
621 ARRAY_SIZE(bf538_spi_board_info));
622 #endif
624 return 0;
627 arch_initcall(ezkit_init);