2 * Copyright 2004-2009 Analog Devices Inc.
3 * 2005 National ICT Australia (NICTA)
4 * Aidan Williams <aidan@nicta.com.au>
6 * Licensed under the GPL-2
9 #include <linux/device.h>
10 #include <linux/platform_device.h>
11 #include <linux/mtd/mtd.h>
12 #include <linux/mtd/physmap.h>
13 #include <linux/mtd/partitions.h>
14 #include <linux/spi/spi.h>
15 #include <linux/spi/flash.h>
16 #include <linux/irq.h>
17 #include <linux/interrupt.h>
18 #include <asm/bfin5xx_spi.h>
22 #include <asm/portmux.h>
24 #include <linux/input.h>
27 * Name the Board for the /proc/cpuinfo
29 const char bfin_board_name
[] = "ADI BF538-EZKIT";
32 * Driver needs to know address, irq and flag pin.
36 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
37 static struct platform_device rtc_device
= {
43 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
44 static struct resource bfin_uart_resources
[] = {
45 #ifdef CONFIG_SERIAL_BFIN_UART0
49 .flags
= IORESOURCE_MEM
,
52 #ifdef CONFIG_SERIAL_BFIN_UART1
56 .flags
= IORESOURCE_MEM
,
59 #ifdef CONFIG_SERIAL_BFIN_UART2
63 .flags
= IORESOURCE_MEM
,
68 static struct platform_device bfin_uart_device
= {
71 .num_resources
= ARRAY_SIZE(bfin_uart_resources
),
72 .resource
= bfin_uart_resources
,
76 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
77 #ifdef CONFIG_BFIN_SIR0
78 static struct resource bfin_sir0_resources
[] = {
82 .flags
= IORESOURCE_MEM
,
85 .start
= IRQ_UART0_RX
,
86 .end
= IRQ_UART0_RX
+1,
87 .flags
= IORESOURCE_IRQ
,
92 .flags
= IORESOURCE_DMA
,
95 static struct platform_device bfin_sir0_device
= {
98 .num_resources
= ARRAY_SIZE(bfin_sir0_resources
),
99 .resource
= bfin_sir0_resources
,
102 #ifdef CONFIG_BFIN_SIR1
103 static struct resource bfin_sir1_resources
[] = {
107 .flags
= IORESOURCE_MEM
,
110 .start
= IRQ_UART1_RX
,
111 .end
= IRQ_UART1_RX
+1,
112 .flags
= IORESOURCE_IRQ
,
115 .start
= CH_UART1_RX
,
116 .end
= CH_UART1_RX
+1,
117 .flags
= IORESOURCE_DMA
,
120 static struct platform_device bfin_sir1_device
= {
123 .num_resources
= ARRAY_SIZE(bfin_sir1_resources
),
124 .resource
= bfin_sir1_resources
,
127 #ifdef CONFIG_BFIN_SIR2
128 static struct resource bfin_sir2_resources
[] = {
132 .flags
= IORESOURCE_MEM
,
135 .start
= IRQ_UART2_RX
,
136 .end
= IRQ_UART2_RX
+1,
137 .flags
= IORESOURCE_IRQ
,
140 .start
= CH_UART2_RX
,
141 .end
= CH_UART2_RX
+1,
142 .flags
= IORESOURCE_DMA
,
145 static struct platform_device bfin_sir2_device
= {
148 .num_resources
= ARRAY_SIZE(bfin_sir2_resources
),
149 .resource
= bfin_sir2_resources
,
155 * USB-LAN EzExtender board
156 * Driver needs to know address, irq and flag pin.
158 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
159 #include <linux/smc91x.h>
161 static struct smc91x_platdata smc91x_info
= {
162 .flags
= SMC91X_USE_16BIT
| SMC91X_NOWAIT
,
163 .leda
= RPC_LED_100_10
,
164 .ledb
= RPC_LED_TX_RX
,
167 static struct resource smc91x_resources
[] = {
169 .name
= "smc91x-regs",
171 .end
= 0x20310300 + 16,
172 .flags
= IORESOURCE_MEM
,
176 .flags
= IORESOURCE_IRQ
| IORESOURCE_IRQ_HIGHLEVEL
,
179 static struct platform_device smc91x_device
= {
182 .num_resources
= ARRAY_SIZE(smc91x_resources
),
183 .resource
= smc91x_resources
,
185 .platform_data
= &smc91x_info
,
190 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
191 /* all SPI peripherals info goes here */
192 #if defined(CONFIG_MTD_M25P80) \
193 || defined(CONFIG_MTD_M25P80_MODULE)
194 /* SPI flash chip (m25p16) */
195 static struct mtd_partition bfin_spi_flash_partitions
[] = {
197 .name
= "bootloader(spi)",
200 .mask_flags
= MTD_CAP_ROM
202 .name
= "linux kernel(spi)",
208 static struct flash_platform_data bfin_spi_flash_data
= {
210 .parts
= bfin_spi_flash_partitions
,
211 .nr_parts
= ARRAY_SIZE(bfin_spi_flash_partitions
),
215 static struct bfin5xx_spi_chip spi_flash_chip_info
= {
216 .enable_dma
= 0, /* use dma transfer with this chip*/
221 #if defined(CONFIG_TOUCHSCREEN_AD7879) || defined(CONFIG_TOUCHSCREEN_AD7879_MODULE)
222 #include <linux/spi/ad7879.h>
223 static const struct ad7879_platform_data bfin_ad7879_ts_info
= {
224 .model
= 7879, /* Model = AD7879 */
225 .x_plate_ohms
= 620, /* 620 Ohm from the touch datasheet */
226 .pressure_max
= 10000,
228 .first_conversion_delay
= 3, /* wait 512us before do a first conversion */
229 .acquisition_time
= 1, /* 4us acquisition time per sample */
230 .median
= 2, /* do 8 measurements */
231 .averaging
= 1, /* take the average of 4 middle samples */
232 .pen_down_acc_interval
= 255, /* 9.4 ms */
233 .gpio_output
= 1, /* configure AUX/VBAT/GPIO as GPIO output */
234 .gpio_default
= 1, /* During initialization set GPIO = HIGH */
238 #if defined(CONFIG_TOUCHSCREEN_AD7879_SPI) || defined(CONFIG_TOUCHSCREEN_AD7879_SPI_MODULE)
239 static struct bfin5xx_spi_chip spi_ad7879_chip_info
= {
245 #if defined(CONFIG_FB_BFIN_LQ035Q1) || defined(CONFIG_FB_BFIN_LQ035Q1_MODULE)
246 #include <asm/bfin-lq035q1.h>
248 static struct bfin_lq035q1fb_disp_info bfin_lq035q1_data
= {
249 .mode
= LQ035_NORM
| LQ035_RGB
| LQ035_RL
| LQ035_TB
,
250 .use_bl
= 0, /* let something else control the LCD Blacklight */
254 static struct resource bfin_lq035q1_resources
[] = {
256 .start
= IRQ_PPI_ERROR
,
257 .end
= IRQ_PPI_ERROR
,
258 .flags
= IORESOURCE_IRQ
,
262 static struct platform_device bfin_lq035q1_device
= {
263 .name
= "bfin-lq035q1",
265 .num_resources
= ARRAY_SIZE(bfin_lq035q1_resources
),
266 .resource
= bfin_lq035q1_resources
,
268 .platform_data
= &bfin_lq035q1_data
,
273 #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
274 static struct bfin5xx_spi_chip spidev_chip_info
= {
280 #if defined(CONFIG_FB_BFIN_LQ035Q1) || defined(CONFIG_FB_BFIN_LQ035Q1_MODULE)
281 static struct bfin5xx_spi_chip lq035q1_spi_chip_info
= {
287 static struct spi_board_info bf538_spi_board_info
[] __initdata
= {
288 #if defined(CONFIG_MTD_M25P80) \
289 || defined(CONFIG_MTD_M25P80_MODULE)
291 /* the modalias must be the same as spi device driver name */
292 .modalias
= "m25p80", /* Name of spi_driver for this device */
293 .max_speed_hz
= 25000000, /* max spi clock (SCK) speed in HZ */
294 .bus_num
= 0, /* Framework bus number */
295 .chip_select
= 1, /* SPI_SSEL1*/
296 .platform_data
= &bfin_spi_flash_data
,
297 .controller_data
= &spi_flash_chip_info
,
301 #if defined(CONFIG_TOUCHSCREEN_AD7879_SPI) || defined(CONFIG_TOUCHSCREEN_AD7879_SPI_MODULE)
303 .modalias
= "ad7879",
304 .platform_data
= &bfin_ad7879_ts_info
,
306 .max_speed_hz
= 5000000, /* max spi clock (SCK) speed in HZ */
309 .controller_data
= &spi_ad7879_chip_info
,
310 .mode
= SPI_CPHA
| SPI_CPOL
,
313 #if defined(CONFIG_FB_BFIN_LQ035Q1) || defined(CONFIG_FB_BFIN_LQ035Q1_MODULE)
315 .modalias
= "bfin-lq035q1-spi",
316 .max_speed_hz
= 20000000, /* max spi clock (SCK) speed in HZ */
319 .controller_data
= &lq035q1_spi_chip_info
,
320 .mode
= SPI_CPHA
| SPI_CPOL
,
323 #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
325 .modalias
= "spidev",
326 .max_speed_hz
= 3125000, /* max spi clock (SCK) speed in HZ */
329 .controller_data
= &spidev_chip_info
,
335 static struct resource bfin_spi0_resource
[] = {
337 .start
= SPI0_REGBASE
,
338 .end
= SPI0_REGBASE
+ 0xFF,
339 .flags
= IORESOURCE_MEM
,
344 .flags
= IORESOURCE_DMA
,
349 .flags
= IORESOURCE_IRQ
,
354 static struct resource bfin_spi1_resource
[] = {
356 .start
= SPI1_REGBASE
,
357 .end
= SPI1_REGBASE
+ 0xFF,
358 .flags
= IORESOURCE_MEM
,
363 .flags
= IORESOURCE_DMA
,
368 .flags
= IORESOURCE_IRQ
,
373 static struct resource bfin_spi2_resource
[] = {
375 .start
= SPI2_REGBASE
,
376 .end
= SPI2_REGBASE
+ 0xFF,
377 .flags
= IORESOURCE_MEM
,
382 .flags
= IORESOURCE_DMA
,
387 .flags
= IORESOURCE_IRQ
,
391 /* SPI controller data */
392 static struct bfin5xx_spi_master bf538_spi_master_info0
= {
394 .enable_dma
= 1, /* master has the ability to do dma transfer */
395 .pin_req
= {P_SPI0_SCK
, P_SPI0_MISO
, P_SPI0_MOSI
, 0},
398 static struct platform_device bf538_spi_master0
= {
400 .id
= 0, /* Bus number */
401 .num_resources
= ARRAY_SIZE(bfin_spi0_resource
),
402 .resource
= bfin_spi0_resource
,
404 .platform_data
= &bf538_spi_master_info0
, /* Passed to driver */
408 static struct bfin5xx_spi_master bf538_spi_master_info1
= {
410 .enable_dma
= 1, /* master has the ability to do dma transfer */
411 .pin_req
= {P_SPI1_SCK
, P_SPI1_MISO
, P_SPI1_MOSI
, 0},
414 static struct platform_device bf538_spi_master1
= {
416 .id
= 1, /* Bus number */
417 .num_resources
= ARRAY_SIZE(bfin_spi1_resource
),
418 .resource
= bfin_spi1_resource
,
420 .platform_data
= &bf538_spi_master_info1
, /* Passed to driver */
424 static struct bfin5xx_spi_master bf538_spi_master_info2
= {
426 .enable_dma
= 1, /* master has the ability to do dma transfer */
427 .pin_req
= {P_SPI2_SCK
, P_SPI2_MISO
, P_SPI2_MOSI
, 0},
430 static struct platform_device bf538_spi_master2
= {
432 .id
= 2, /* Bus number */
433 .num_resources
= ARRAY_SIZE(bfin_spi2_resource
),
434 .resource
= bfin_spi2_resource
,
436 .platform_data
= &bf538_spi_master_info2
, /* Passed to driver */
440 #endif /* spi master and devices */
442 #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
443 static struct resource bfin_twi0_resource
[] = {
445 .start
= TWI0_REGBASE
,
446 .end
= TWI0_REGBASE
+ 0xFF,
447 .flags
= IORESOURCE_MEM
,
452 .flags
= IORESOURCE_IRQ
,
456 static struct platform_device i2c_bfin_twi0_device
= {
457 .name
= "i2c-bfin-twi",
459 .num_resources
= ARRAY_SIZE(bfin_twi0_resource
),
460 .resource
= bfin_twi0_resource
,
463 #if !defined(CONFIG_BF542) /* The BF542 only has 1 TWI */
464 static struct resource bfin_twi1_resource
[] = {
466 .start
= TWI1_REGBASE
,
467 .end
= TWI1_REGBASE
+ 0xFF,
468 .flags
= IORESOURCE_MEM
,
473 .flags
= IORESOURCE_IRQ
,
477 static struct platform_device i2c_bfin_twi1_device
= {
478 .name
= "i2c-bfin-twi",
480 .num_resources
= ARRAY_SIZE(bfin_twi1_resource
),
481 .resource
= bfin_twi1_resource
,
486 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
487 #include <linux/gpio_keys.h>
489 static struct gpio_keys_button bfin_gpio_keys_table
[] = {
490 {BTN_0
, GPIO_PC7
, 1, "gpio-keys: BTN0"},
493 static struct gpio_keys_platform_data bfin_gpio_keys_data
= {
494 .buttons
= bfin_gpio_keys_table
,
495 .nbuttons
= ARRAY_SIZE(bfin_gpio_keys_table
),
498 static struct platform_device bfin_device_gpiokeys
= {
501 .platform_data
= &bfin_gpio_keys_data
,
506 static const unsigned int cclk_vlev_datasheet
[] =
509 * Internal VLEV BF538SBBC1533
510 ****temporarily using these values until data sheet is updated
512 VRPAIR(VLEV_100
, 150000000),
513 VRPAIR(VLEV_100
, 250000000),
514 VRPAIR(VLEV_110
, 276000000),
515 VRPAIR(VLEV_115
, 301000000),
516 VRPAIR(VLEV_120
, 525000000),
517 VRPAIR(VLEV_125
, 550000000),
518 VRPAIR(VLEV_130
, 600000000),
521 static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data
= {
522 .tuple_tab
= cclk_vlev_datasheet
,
523 .tabsize
= ARRAY_SIZE(cclk_vlev_datasheet
),
524 .vr_settling_time
= 25 /* us */,
527 static struct platform_device bfin_dpmc
= {
530 .platform_data
= &bfin_dmpc_vreg_data
,
534 #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
535 static struct mtd_partition ezkit_partitions
[] = {
537 .name
= "bootloader(nor)",
541 .name
= "linux kernel(nor)",
543 .offset
= MTDPART_OFS_APPEND
,
545 .name
= "file system(nor)",
546 .size
= MTDPART_SIZ_FULL
,
547 .offset
= MTDPART_OFS_APPEND
,
551 static struct physmap_flash_data ezkit_flash_data
= {
553 .parts
= ezkit_partitions
,
554 .nr_parts
= ARRAY_SIZE(ezkit_partitions
),
557 static struct resource ezkit_flash_resource
= {
559 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
564 .flags
= IORESOURCE_MEM
,
567 static struct platform_device ezkit_flash_device
= {
568 .name
= "physmap-flash",
571 .platform_data
= &ezkit_flash_data
,
574 .resource
= &ezkit_flash_resource
,
578 static struct platform_device
*cm_bf538_devices
[] __initdata
= {
582 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
586 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
590 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
596 #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
597 &i2c_bfin_twi0_device
,
598 &i2c_bfin_twi1_device
,
601 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
602 #ifdef CONFIG_BFIN_SIR0
605 #ifdef CONFIG_BFIN_SIR1
608 #ifdef CONFIG_BFIN_SIR2
613 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
617 #if defined(CONFIG_FB_BFIN_LQ035Q1) || defined(CONFIG_FB_BFIN_LQ035Q1_MODULE)
618 &bfin_lq035q1_device
,
621 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
622 &bfin_device_gpiokeys
,
625 #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
630 static int __init
ezkit_init(void)
632 printk(KERN_INFO
"%s(): registering device resources\n", __func__
);
633 platform_add_devices(cm_bf538_devices
, ARRAY_SIZE(cm_bf538_devices
));
635 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
636 spi_register_board_info(bf538_spi_board_info
,
637 ARRAY_SIZE(bf538_spi_board_info
));
643 arch_initcall(ezkit_init
);