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>
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/physmap.h>
35 #include <linux/mtd/partitions.h>
36 #include <linux/spi/spi.h>
37 #include <linux/spi/flash.h>
38 #include <linux/irq.h>
39 #include <linux/interrupt.h>
40 #include <asm/bfin5xx_spi.h>
44 #include <asm/portmux.h>
46 #include <linux/input.h>
49 * Name the Board for the /proc/cpuinfo
51 const char bfin_board_name[] = "ADI BF538-EZKIT";
54 * Driver needs to know address, irq and flag pin.
58 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
59 static struct platform_device rtc_device = {
65 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
66 static struct resource bfin_uart_resources[] = {
67 #ifdef CONFIG_SERIAL_BFIN_UART0
71 .flags = IORESOURCE_MEM,
74 #ifdef CONFIG_SERIAL_BFIN_UART1
78 .flags = IORESOURCE_MEM,
81 #ifdef CONFIG_SERIAL_BFIN_UART2
85 .flags = IORESOURCE_MEM,
90 static struct platform_device bfin_uart_device = {
93 .num_resources = ARRAY_SIZE(bfin_uart_resources),
94 .resource = bfin_uart_resources,
98 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
99 #ifdef CONFIG_BFIN_SIR0
100 static struct resource bfin_sir0_resources[] = {
104 .flags = IORESOURCE_MEM,
107 .start = IRQ_UART0_RX,
108 .end = IRQ_UART0_RX+1,
109 .flags = IORESOURCE_IRQ,
112 .start = CH_UART0_RX,
113 .end = CH_UART0_RX+1,
114 .flags = IORESOURCE_DMA,
117 static struct platform_device bfin_sir0_device = {
120 .num_resources = ARRAY_SIZE(bfin_sir0_resources),
121 .resource = bfin_sir0_resources,
124 #ifdef CONFIG_BFIN_SIR1
125 static struct resource bfin_sir1_resources[] = {
129 .flags = IORESOURCE_MEM,
132 .start = IRQ_UART1_RX,
133 .end = IRQ_UART1_RX+1,
134 .flags = IORESOURCE_IRQ,
137 .start = CH_UART1_RX,
138 .end = CH_UART1_RX+1,
139 .flags = IORESOURCE_DMA,
142 static struct platform_device bfin_sir1_device = {
145 .num_resources = ARRAY_SIZE(bfin_sir1_resources),
146 .resource = bfin_sir1_resources,
149 #ifdef CONFIG_BFIN_SIR2
150 static struct resource bfin_sir2_resources[] = {
154 .flags = IORESOURCE_MEM,
157 .start = IRQ_UART2_RX,
158 .end = IRQ_UART2_RX+1,
159 .flags = IORESOURCE_IRQ,
162 .start = CH_UART2_RX,
163 .end = CH_UART2_RX+1,
164 .flags = IORESOURCE_DMA,
167 static struct platform_device bfin_sir2_device = {
170 .num_resources = ARRAY_SIZE(bfin_sir2_resources),
171 .resource = bfin_sir2_resources,
177 * USB-LAN EzExtender board
178 * Driver needs to know address, irq and flag pin.
180 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
181 #include <linux/smc91x.h>
183 static struct smc91x_platdata smc91x_info = {
184 .flags = SMC91X_USE_16BIT | SMC91X_NOWAIT,
185 .leda = RPC_LED_100_10,
186 .ledb = RPC_LED_TX_RX,
189 static struct resource smc91x_resources[] = {
191 .name = "smc91x-regs",
193 .end = 0x20310300 + 16,
194 .flags = IORESOURCE_MEM,
198 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
201 static struct platform_device smc91x_device = {
204 .num_resources = ARRAY_SIZE(smc91x_resources),
205 .resource = smc91x_resources,
207 .platform_data = &smc91x_info,
212 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
213 /* all SPI peripherals info goes here */
214 #if defined(CONFIG_MTD_M25P80) \
215 || defined(CONFIG_MTD_M25P80_MODULE)
216 /* SPI flash chip (m25p16) */
217 static struct mtd_partition bfin_spi_flash_partitions[] = {
219 .name = "bootloader(spi)",
222 .mask_flags = MTD_CAP_ROM
224 .name = "linux kernel(spi)",
230 static struct flash_platform_data bfin_spi_flash_data = {
232 .parts = bfin_spi_flash_partitions,
233 .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
237 static struct bfin5xx_spi_chip spi_flash_chip_info = {
238 .enable_dma = 0, /* use dma transfer with this chip*/
240 .cs_change_per_word = 0,
244 #if defined(CONFIG_TOUCHSCREEN_AD7879) || defined(CONFIG_TOUCHSCREEN_AD7879_MODULE)
245 #include <linux/spi/ad7879.h>
246 static const struct ad7879_platform_data bfin_ad7879_ts_info = {
247 .model = 7879, /* Model = AD7879 */
248 .x_plate_ohms = 620, /* 620 Ohm from the touch datasheet */
249 .pressure_max = 10000,
251 .first_conversion_delay = 3, /* wait 512us before do a first conversion */
252 .acquisition_time = 1, /* 4us acquisition time per sample */
253 .median = 2, /* do 8 measurements */
254 .averaging = 1, /* take the average of 4 middle samples */
255 .pen_down_acc_interval = 255, /* 9.4 ms */
256 .gpio_output = 1, /* configure AUX/VBAT/GPIO as GPIO output */
257 .gpio_default = 1, /* During initialization set GPIO = HIGH */
261 #if defined(CONFIG_TOUCHSCREEN_AD7879_SPI) || defined(CONFIG_TOUCHSCREEN_AD7879_SPI_MODULE)
262 static struct bfin5xx_spi_chip spi_ad7879_chip_info = {
268 #if defined(CONFIG_FB_BFIN_LQ035Q1) || defined(CONFIG_FB_BFIN_LQ035Q1_MODULE)
269 #include <asm/bfin-lq035q1.h>
271 static struct bfin_lq035q1fb_disp_info bfin_lq035q1_data = {
272 .mode = LQ035_NORM | LQ035_RGB | LQ035_RL | LQ035_TB,
273 .use_bl = 0, /* let something else control the LCD Blacklight */
277 static struct resource bfin_lq035q1_resources[] = {
279 .start = IRQ_PPI_ERROR,
280 .end = IRQ_PPI_ERROR,
281 .flags = IORESOURCE_IRQ,
285 static struct platform_device bfin_lq035q1_device = {
286 .name = "bfin-lq035q1",
288 .num_resources = ARRAY_SIZE(bfin_lq035q1_resources),
289 .resource = bfin_lq035q1_resources,
291 .platform_data = &bfin_lq035q1_data,
296 #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
297 static struct bfin5xx_spi_chip spidev_chip_info = {
303 #if defined(CONFIG_FB_BFIN_LQ035Q1) || defined(CONFIG_FB_BFIN_LQ035Q1_MODULE)
304 static struct bfin5xx_spi_chip lq035q1_spi_chip_info = {
310 static struct spi_board_info bf538_spi_board_info[] __initdata = {
311 #if defined(CONFIG_MTD_M25P80) \
312 || defined(CONFIG_MTD_M25P80_MODULE)
314 /* the modalias must be the same as spi device driver name */
315 .modalias = "m25p80", /* Name of spi_driver for this device */
316 .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
317 .bus_num = 0, /* Framework bus number */
318 .chip_select = 1, /* SPI_SSEL1*/
319 .platform_data = &bfin_spi_flash_data,
320 .controller_data = &spi_flash_chip_info,
324 #if defined(CONFIG_TOUCHSCREEN_AD7879_SPI) || defined(CONFIG_TOUCHSCREEN_AD7879_SPI_MODULE)
326 .modalias = "ad7879",
327 .platform_data = &bfin_ad7879_ts_info,
329 .max_speed_hz = 5000000, /* max spi clock (SCK) speed in HZ */
332 .controller_data = &spi_ad7879_chip_info,
333 .mode = SPI_CPHA | SPI_CPOL,
336 #if defined(CONFIG_FB_BFIN_LQ035Q1) || defined(CONFIG_FB_BFIN_LQ035Q1_MODULE)
338 .modalias = "bfin-lq035q1-spi",
339 .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */
342 .controller_data = &lq035q1_spi_chip_info,
343 .mode = SPI_CPHA | SPI_CPOL,
346 #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
348 .modalias = "spidev",
349 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
352 .controller_data = &spidev_chip_info,
358 static struct resource bfin_spi0_resource[] = {
360 .start = SPI0_REGBASE,
361 .end = SPI0_REGBASE + 0xFF,
362 .flags = IORESOURCE_MEM,
367 .flags = IORESOURCE_DMA,
372 .flags = IORESOURCE_IRQ,
377 static struct resource bfin_spi1_resource[] = {
379 .start = SPI1_REGBASE,
380 .end = SPI1_REGBASE + 0xFF,
381 .flags = IORESOURCE_MEM,
386 .flags = IORESOURCE_DMA,
391 .flags = IORESOURCE_IRQ,
396 static struct resource bfin_spi2_resource[] = {
398 .start = SPI2_REGBASE,
399 .end = SPI2_REGBASE + 0xFF,
400 .flags = IORESOURCE_MEM,
405 .flags = IORESOURCE_DMA,
410 .flags = IORESOURCE_IRQ,
414 /* SPI controller data */
415 static struct bfin5xx_spi_master bf538_spi_master_info0 = {
417 .enable_dma = 1, /* master has the ability to do dma transfer */
418 .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
421 static struct platform_device bf538_spi_master0 = {
423 .id = 0, /* Bus number */
424 .num_resources = ARRAY_SIZE(bfin_spi0_resource),
425 .resource = bfin_spi0_resource,
427 .platform_data = &bf538_spi_master_info0, /* Passed to driver */
431 static struct bfin5xx_spi_master bf538_spi_master_info1 = {
433 .enable_dma = 1, /* master has the ability to do dma transfer */
434 .pin_req = {P_SPI1_SCK, P_SPI1_MISO, P_SPI1_MOSI, 0},
437 static struct platform_device bf538_spi_master1 = {
439 .id = 1, /* Bus number */
440 .num_resources = ARRAY_SIZE(bfin_spi1_resource),
441 .resource = bfin_spi1_resource,
443 .platform_data = &bf538_spi_master_info1, /* Passed to driver */
447 static struct bfin5xx_spi_master bf538_spi_master_info2 = {
449 .enable_dma = 1, /* master has the ability to do dma transfer */
450 .pin_req = {P_SPI2_SCK, P_SPI2_MISO, P_SPI2_MOSI, 0},
453 static struct platform_device bf538_spi_master2 = {
455 .id = 2, /* Bus number */
456 .num_resources = ARRAY_SIZE(bfin_spi2_resource),
457 .resource = bfin_spi2_resource,
459 .platform_data = &bf538_spi_master_info2, /* Passed to driver */
463 #endif /* spi master and devices */
465 #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
466 static struct resource bfin_twi0_resource[] = {
468 .start = TWI0_REGBASE,
469 .end = TWI0_REGBASE + 0xFF,
470 .flags = IORESOURCE_MEM,
475 .flags = IORESOURCE_IRQ,
479 static struct platform_device i2c_bfin_twi0_device = {
480 .name = "i2c-bfin-twi",
482 .num_resources = ARRAY_SIZE(bfin_twi0_resource),
483 .resource = bfin_twi0_resource,
486 #if !defined(CONFIG_BF542) /* The BF542 only has 1 TWI */
487 static struct resource bfin_twi1_resource[] = {
489 .start = TWI1_REGBASE,
490 .end = TWI1_REGBASE + 0xFF,
491 .flags = IORESOURCE_MEM,
496 .flags = IORESOURCE_IRQ,
500 static struct platform_device i2c_bfin_twi1_device = {
501 .name = "i2c-bfin-twi",
503 .num_resources = ARRAY_SIZE(bfin_twi1_resource),
504 .resource = bfin_twi1_resource,
509 static struct resource bfin_gpios_resources = {
511 .end = MAX_BLACKFIN_GPIOS - 1,
512 .flags = IORESOURCE_IRQ,
515 static struct platform_device bfin_gpios_device = {
516 .name = "simple-gpio",
519 .resource = &bfin_gpios_resources,
522 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
523 #include <linux/gpio_keys.h>
525 static struct gpio_keys_button bfin_gpio_keys_table[] = {
526 {BTN_0, GPIO_PC7, 1, "gpio-keys: BTN0"},
529 static struct gpio_keys_platform_data bfin_gpio_keys_data = {
530 .buttons = bfin_gpio_keys_table,
531 .nbuttons = ARRAY_SIZE(bfin_gpio_keys_table),
534 static struct platform_device bfin_device_gpiokeys = {
537 .platform_data = &bfin_gpio_keys_data,
542 static const unsigned int cclk_vlev_datasheet[] =
545 * Internal VLEV BF538SBBC1533
546 ****temporarily using these values until data sheet is updated
548 VRPAIR(VLEV_100, 150000000),
549 VRPAIR(VLEV_100, 250000000),
550 VRPAIR(VLEV_110, 276000000),
551 VRPAIR(VLEV_115, 301000000),
552 VRPAIR(VLEV_120, 525000000),
553 VRPAIR(VLEV_125, 550000000),
554 VRPAIR(VLEV_130, 600000000),
557 static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
558 .tuple_tab = cclk_vlev_datasheet,
559 .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
560 .vr_settling_time = 25 /* us */,
563 static struct platform_device bfin_dpmc = {
566 .platform_data = &bfin_dmpc_vreg_data,
570 #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
571 static struct mtd_partition ezkit_partitions[] = {
573 .name = "bootloader(nor)",
577 .name = "linux kernel(nor)",
579 .offset = MTDPART_OFS_APPEND,
581 .name = "file system(nor)",
582 .size = MTDPART_SIZ_FULL,
583 .offset = MTDPART_OFS_APPEND,
587 static struct physmap_flash_data ezkit_flash_data = {
589 .parts = ezkit_partitions,
590 .nr_parts = ARRAY_SIZE(ezkit_partitions),
593 static struct resource ezkit_flash_resource = {
595 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
600 .flags = IORESOURCE_MEM,
603 static struct platform_device ezkit_flash_device = {
604 .name = "physmap-flash",
607 .platform_data = &ezkit_flash_data,
610 .resource = &ezkit_flash_resource,
614 static struct platform_device *cm_bf538_devices[] __initdata = {
618 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
622 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
626 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
632 #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
633 &i2c_bfin_twi0_device,
634 &i2c_bfin_twi1_device,
637 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
638 #ifdef CONFIG_BFIN_SIR0
641 #ifdef CONFIG_BFIN_SIR1
644 #ifdef CONFIG_BFIN_SIR2
649 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
653 #if defined(CONFIG_FB_BFIN_LQ035Q1) || defined(CONFIG_FB_BFIN_LQ035Q1_MODULE)
654 &bfin_lq035q1_device,
657 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
658 &bfin_device_gpiokeys,
663 #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
668 static int __init ezkit_init(void)
670 printk(KERN_INFO "%s(): registering device resources\n", __func__);
671 platform_add_devices(cm_bf538_devices, ARRAY_SIZE(cm_bf538_devices));
673 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
674 spi_register_board_info(bf538_spi_board_info,
675 ARRAY_SIZE(bf538_spi_board_info));
681 arch_initcall(ezkit_init);