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/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>
43 #include <asm/portmux.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
= {
64 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
65 static struct resource bfin_uart_resources
[] = {
66 #ifdef CONFIG_SERIAL_BFIN_UART0
70 .flags
= IORESOURCE_MEM
,
73 #ifdef CONFIG_SERIAL_BFIN_UART1
77 .flags
= IORESOURCE_MEM
,
80 #ifdef CONFIG_SERIAL_BFIN_UART2
84 .flags
= IORESOURCE_MEM
,
89 static struct platform_device bfin_uart_device
= {
92 .num_resources
= ARRAY_SIZE(bfin_uart_resources
),
93 .resource
= bfin_uart_resources
,
97 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
98 static struct resource bfin_sir_resources
[] = {
99 #ifdef CONFIG_BFIN_SIR0
103 .flags
= IORESOURCE_MEM
,
106 #ifdef CONFIG_BFIN_SIR1
110 .flags
= IORESOURCE_MEM
,
113 #ifdef CONFIG_BFIN_SIR2
117 .flags
= IORESOURCE_MEM
,
122 static struct platform_device bfin_sir_device
= {
125 .num_resources
= ARRAY_SIZE(bfin_sir_resources
),
126 .resource
= bfin_sir_resources
,
131 * USB-LAN EzExtender board
132 * Driver needs to know address, irq and flag pin.
134 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
135 static struct resource smc91x_resources
[] = {
137 .name
= "smc91x-regs",
139 .end
= 0x20310300 + 16,
140 .flags
= IORESOURCE_MEM
,
144 .flags
= IORESOURCE_IRQ
| IORESOURCE_IRQ_HIGHLEVEL
,
147 static struct platform_device smc91x_device
= {
150 .num_resources
= ARRAY_SIZE(smc91x_resources
),
151 .resource
= smc91x_resources
,
155 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
156 /* all SPI peripherals info goes here */
157 #if defined(CONFIG_MTD_M25P80) \
158 || defined(CONFIG_MTD_M25P80_MODULE)
159 /* SPI flash chip (m25p16) */
160 static struct mtd_partition bfin_spi_flash_partitions
[] = {
162 .name
= "bootloader(spi)",
165 .mask_flags
= MTD_CAP_ROM
167 .name
= "linux kernel(spi)",
173 static struct flash_platform_data bfin_spi_flash_data
= {
175 .parts
= bfin_spi_flash_partitions
,
176 .nr_parts
= ARRAY_SIZE(bfin_spi_flash_partitions
),
180 static struct bfin5xx_spi_chip spi_flash_chip_info
= {
181 .enable_dma
= 0, /* use dma transfer with this chip*/
183 .cs_change_per_word
= 0,
187 #if defined(CONFIG_TOUCHSCREEN_AD7879) || defined(CONFIG_TOUCHSCREEN_AD7879_MODULE)
188 #include <linux/spi/ad7879.h>
189 static const struct ad7879_platform_data bfin_ad7879_ts_info
= {
190 .model
= 7879, /* Model = AD7879 */
191 .x_plate_ohms
= 620, /* 620 Ohm from the touch datasheet */
192 .pressure_max
= 10000,
194 .first_conversion_delay
= 3, /* wait 512us before do a first conversion */
195 .acquisition_time
= 1, /* 4us acquisition time per sample */
196 .median
= 2, /* do 8 measurements */
197 .averaging
= 1, /* take the average of 4 middle samples */
198 .pen_down_acc_interval
= 255, /* 9.4 ms */
199 .gpio_output
= 1, /* configure AUX/VBAT/GPIO as GPIO output */
200 .gpio_default
= 1, /* During initialization set GPIO = HIGH */
204 #if defined(CONFIG_TOUCHSCREEN_AD7879_SPI) || defined(CONFIG_TOUCHSCREEN_AD7879_SPI_MODULE)
205 static struct bfin5xx_spi_chip spi_ad7879_chip_info
= {
211 #if defined(CONFIG_FB_BFIN_LQ035Q1) || defined(CONFIG_FB_BFIN_LQ035Q1_MODULE)
212 #include <asm/bfin-lq035q1.h>
214 static struct bfin_lq035q1fb_disp_info bfin_lq035q1_data
= {
215 .mode
= LQ035_NORM
| LQ035_RGB
| LQ035_RL
| LQ035_TB
,
216 .use_bl
= 0, /* let something else control the LCD Blacklight */
220 static struct resource bfin_lq035q1_resources
[] = {
222 .start
= IRQ_PPI_ERROR
,
223 .end
= IRQ_PPI_ERROR
,
224 .flags
= IORESOURCE_IRQ
,
228 static struct platform_device bfin_lq035q1_device
= {
229 .name
= "bfin-lq035q1",
231 .num_resources
= ARRAY_SIZE(bfin_lq035q1_resources
),
232 .resource
= bfin_lq035q1_resources
,
234 .platform_data
= &bfin_lq035q1_data
,
239 #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
240 static struct bfin5xx_spi_chip spidev_chip_info
= {
246 #if defined(CONFIG_FB_BFIN_LQ035Q1) || defined(CONFIG_FB_BFIN_LQ035Q1_MODULE)
247 static struct bfin5xx_spi_chip lq035q1_spi_chip_info
= {
253 static struct spi_board_info bf538_spi_board_info
[] __initdata
= {
254 #if defined(CONFIG_MTD_M25P80) \
255 || defined(CONFIG_MTD_M25P80_MODULE)
257 /* the modalias must be the same as spi device driver name */
258 .modalias
= "m25p80", /* Name of spi_driver for this device */
259 .max_speed_hz
= 25000000, /* max spi clock (SCK) speed in HZ */
260 .bus_num
= 0, /* Framework bus number */
261 .chip_select
= 1, /* SPI_SSEL1*/
262 .platform_data
= &bfin_spi_flash_data
,
263 .controller_data
= &spi_flash_chip_info
,
267 #if defined(CONFIG_TOUCHSCREEN_AD7879_SPI) || defined(CONFIG_TOUCHSCREEN_AD7879_SPI_MODULE)
269 .modalias
= "ad7879",
270 .platform_data
= &bfin_ad7879_ts_info
,
272 .max_speed_hz
= 5000000, /* max spi clock (SCK) speed in HZ */
275 .controller_data
= &spi_ad7879_chip_info
,
276 .mode
= SPI_CPHA
| SPI_CPOL
,
279 #if defined(CONFIG_FB_BFIN_LQ035Q1) || defined(CONFIG_FB_BFIN_LQ035Q1_MODULE)
281 .modalias
= "bfin-lq035q1-spi",
282 .max_speed_hz
= 20000000, /* max spi clock (SCK) speed in HZ */
285 .controller_data
= &lq035q1_spi_chip_info
,
286 .mode
= SPI_CPHA
| SPI_CPOL
,
289 #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
291 .modalias
= "spidev",
292 .max_speed_hz
= 3125000, /* max spi clock (SCK) speed in HZ */
295 .controller_data
= &spidev_chip_info
,
301 static struct resource bfin_spi0_resource
[] = {
303 .start
= SPI0_REGBASE
,
304 .end
= SPI0_REGBASE
+ 0xFF,
305 .flags
= IORESOURCE_MEM
,
310 .flags
= IORESOURCE_IRQ
,
315 static struct resource bfin_spi1_resource
[] = {
317 .start
= SPI1_REGBASE
,
318 .end
= SPI1_REGBASE
+ 0xFF,
319 .flags
= IORESOURCE_MEM
,
324 .flags
= IORESOURCE_IRQ
,
329 static struct resource bfin_spi2_resource
[] = {
331 .start
= SPI2_REGBASE
,
332 .end
= SPI2_REGBASE
+ 0xFF,
333 .flags
= IORESOURCE_MEM
,
338 .flags
= IORESOURCE_IRQ
,
342 /* SPI controller data */
343 static struct bfin5xx_spi_master bf538_spi_master_info0
= {
345 .enable_dma
= 1, /* master has the ability to do dma transfer */
346 .pin_req
= {P_SPI0_SCK
, P_SPI0_MISO
, P_SPI0_MOSI
, 0},
349 static struct platform_device bf538_spi_master0
= {
351 .id
= 0, /* Bus number */
352 .num_resources
= ARRAY_SIZE(bfin_spi0_resource
),
353 .resource
= bfin_spi0_resource
,
355 .platform_data
= &bf538_spi_master_info0
, /* Passed to driver */
359 static struct bfin5xx_spi_master bf538_spi_master_info1
= {
361 .enable_dma
= 1, /* master has the ability to do dma transfer */
362 .pin_req
= {P_SPI1_SCK
, P_SPI1_MISO
, P_SPI1_MOSI
, 0},
365 static struct platform_device bf538_spi_master1
= {
367 .id
= 1, /* Bus number */
368 .num_resources
= ARRAY_SIZE(bfin_spi1_resource
),
369 .resource
= bfin_spi1_resource
,
371 .platform_data
= &bf538_spi_master_info1
, /* Passed to driver */
375 static struct bfin5xx_spi_master bf538_spi_master_info2
= {
377 .enable_dma
= 1, /* master has the ability to do dma transfer */
378 .pin_req
= {P_SPI2_SCK
, P_SPI2_MISO
, P_SPI2_MOSI
, 0},
381 static struct platform_device bf538_spi_master2
= {
383 .id
= 2, /* Bus number */
384 .num_resources
= ARRAY_SIZE(bfin_spi2_resource
),
385 .resource
= bfin_spi2_resource
,
387 .platform_data
= &bf538_spi_master_info2
, /* Passed to driver */
391 #endif /* spi master and devices */
393 #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
394 static struct resource bfin_twi0_resource
[] = {
396 .start
= TWI0_REGBASE
,
397 .end
= TWI0_REGBASE
+ 0xFF,
398 .flags
= IORESOURCE_MEM
,
403 .flags
= IORESOURCE_IRQ
,
407 static struct platform_device i2c_bfin_twi0_device
= {
408 .name
= "i2c-bfin-twi",
410 .num_resources
= ARRAY_SIZE(bfin_twi0_resource
),
411 .resource
= bfin_twi0_resource
,
414 #if !defined(CONFIG_BF542) /* The BF542 only has 1 TWI */
415 static struct resource bfin_twi1_resource
[] = {
417 .start
= TWI1_REGBASE
,
418 .end
= TWI1_REGBASE
+ 0xFF,
419 .flags
= IORESOURCE_MEM
,
424 .flags
= IORESOURCE_IRQ
,
428 static struct platform_device i2c_bfin_twi1_device
= {
429 .name
= "i2c-bfin-twi",
431 .num_resources
= ARRAY_SIZE(bfin_twi1_resource
),
432 .resource
= bfin_twi1_resource
,
437 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
438 #include <linux/gpio_keys.h>
440 static struct gpio_keys_button bfin_gpio_keys_table
[] = {
441 {BTN_0
, GPIO_PC7
, 1, "gpio-keys: BTN0"},
444 static struct gpio_keys_platform_data bfin_gpio_keys_data
= {
445 .buttons
= bfin_gpio_keys_table
,
446 .nbuttons
= ARRAY_SIZE(bfin_gpio_keys_table
),
449 static struct platform_device bfin_device_gpiokeys
= {
452 .platform_data
= &bfin_gpio_keys_data
,
457 static const unsigned int cclk_vlev_datasheet
[] =
460 * Internal VLEV BF538SBBC1533
461 ****temporarily using these values until data sheet is updated
463 VRPAIR(VLEV_100
, 150000000),
464 VRPAIR(VLEV_100
, 250000000),
465 VRPAIR(VLEV_110
, 276000000),
466 VRPAIR(VLEV_115
, 301000000),
467 VRPAIR(VLEV_120
, 525000000),
468 VRPAIR(VLEV_125
, 550000000),
469 VRPAIR(VLEV_130
, 600000000),
472 static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data
= {
473 .tuple_tab
= cclk_vlev_datasheet
,
474 .tabsize
= ARRAY_SIZE(cclk_vlev_datasheet
),
475 .vr_settling_time
= 25 /* us */,
478 static struct platform_device bfin_dpmc
= {
481 .platform_data
= &bfin_dmpc_vreg_data
,
485 static struct platform_device
*cm_bf538_devices
[] __initdata
= {
489 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
493 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
497 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
503 #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
504 &i2c_bfin_twi0_device
,
505 &i2c_bfin_twi1_device
,
508 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
512 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
516 #if defined(CONFIG_FB_BFIN_LQ035Q1) || defined(CONFIG_FB_BFIN_LQ035Q1_MODULE)
517 &bfin_lq035q1_device
,
520 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
521 &bfin_device_gpiokeys
,
525 static int __init
ezkit_init(void)
527 printk(KERN_INFO
"%s(): registering device resources\n", __func__
);
528 platform_add_devices(cm_bf538_devices
, ARRAY_SIZE(cm_bf538_devices
));
530 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
531 spi_register_board_info(bf538_spi_board_info
,
532 ARRAY_SIZE(bf538_spi_board_info
));
538 arch_initcall(ezkit_init
);