2 * File: arch/blackfin/mach-bf533/blackstamp.c
3 * Based on: arch/blackfin/mach-bf533/stamp.c
4 * Author: Benjamin Matthews <bmat@lle.rochester.edu>
5 * Aidan Williams <aidan@nicta.com.au>
8 * Description: Board Info File for the BlackStamp
10 * Copyright 2005 National ICT Australia (NICTA)
11 * Copyright 2004-2008 Analog Devices Inc.
13 * Enter bugs at http://blackfin.uclinux.org/
15 * More info about the BlackStamp at:
16 * http://blackfin.uclinux.org/gf/project/blackstamp/
18 * Licensed under the GPL-2 or later.
21 #include <linux/device.h>
22 #include <linux/platform_device.h>
23 #include <linux/mtd/mtd.h>
24 #include <linux/mtd/partitions.h>
25 #include <linux/mtd/physmap.h>
26 #include <linux/spi/spi.h>
27 #include <linux/spi/flash.h>
28 #include <linux/irq.h>
29 #include <linux/i2c.h>
31 #include <asm/bfin5xx_spi.h>
32 #include <asm/portmux.h>
36 * Name the Board for the /proc/cpuinfo
38 const char bfin_board_name
[] = "BlackStamp";
40 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
41 static struct platform_device rtc_device
= {
48 * Driver needs to know address, irq and flag pin.
50 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
51 static struct resource smc91x_resources
[] = {
53 .name
= "smc91x-regs",
55 .end
= 0x20300300 + 16,
56 .flags
= IORESOURCE_MEM
,
60 .flags
= IORESOURCE_IRQ
| IORESOURCE_IRQ_HIGHLEVEL
,
64 static struct platform_device smc91x_device
= {
67 .num_resources
= ARRAY_SIZE(smc91x_resources
),
68 .resource
= smc91x_resources
,
72 #if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE)
73 static struct mtd_partition bfin_spi_flash_partitions
[] = {
75 .name
= "bootloader(spi)",
78 .mask_flags
= MTD_CAP_ROM
80 .name
= "linux kernel(spi)",
82 .offset
= MTDPART_OFS_APPEND
,
84 .name
= "file system(spi)",
85 .size
= MTDPART_SIZ_FULL
,
86 .offset
= MTDPART_OFS_APPEND
,
90 static struct flash_platform_data bfin_spi_flash_data
= {
92 .parts
= bfin_spi_flash_partitions
,
93 .nr_parts
= ARRAY_SIZE(bfin_spi_flash_partitions
),
97 /* SPI flash chip (m25p64) */
98 static struct bfin5xx_spi_chip spi_flash_chip_info
= {
99 .enable_dma
= 0, /* use dma transfer with this chip*/
104 #if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
105 static struct bfin5xx_spi_chip mmc_spi_chip_info
= {
111 #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
112 static struct bfin5xx_spi_chip spidev_chip_info
= {
118 static struct spi_board_info bfin_spi_board_info
[] __initdata
= {
119 #if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE)
121 /* the modalias must be the same as spi device driver name */
122 .modalias
= "m25p80", /* Name of spi_driver for this device */
123 .max_speed_hz
= 20000000, /* max spi clock (SCK) speed in HZ */
124 .bus_num
= 0, /* Framework bus number */
125 .chip_select
= 2, /* Framework chip select. */
126 .platform_data
= &bfin_spi_flash_data
,
127 .controller_data
= &spi_flash_chip_info
,
132 #if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
134 .modalias
= "mmc_spi",
135 .max_speed_hz
= 20000000, /* max spi clock (SCK) speed in HZ */
138 .controller_data
= &mmc_spi_chip_info
,
143 #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
145 .modalias
= "spidev",
146 .max_speed_hz
= 3125000, /* max spi clock (SCK) speed in HZ */
149 .controller_data
= &spidev_chip_info
,
154 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
156 static struct resource bfin_spi0_resource
[] = {
158 .start
= SPI0_REGBASE
,
159 .end
= SPI0_REGBASE
+ 0xFF,
160 .flags
= IORESOURCE_MEM
,
165 .flags
= IORESOURCE_DMA
,
170 .flags
= IORESOURCE_IRQ
,
174 /* SPI controller data */
175 static struct bfin5xx_spi_master bfin_spi0_info
= {
177 .enable_dma
= 1, /* master has the ability to do dma transfer */
178 .pin_req
= {P_SPI0_SCK
, P_SPI0_MISO
, P_SPI0_MOSI
, 0},
181 static struct platform_device bfin_spi0_device
= {
183 .id
= 0, /* Bus number */
184 .num_resources
= ARRAY_SIZE(bfin_spi0_resource
),
185 .resource
= bfin_spi0_resource
,
187 .platform_data
= &bfin_spi0_info
, /* Passed to driver */
190 #endif /* spi master and devices */
192 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
193 static struct resource bfin_uart_resources
[] = {
197 .flags
= IORESOURCE_MEM
,
201 static struct platform_device bfin_uart_device
= {
204 .num_resources
= ARRAY_SIZE(bfin_uart_resources
),
205 .resource
= bfin_uart_resources
,
209 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
210 #ifdef CONFIG_BFIN_SIR0
211 static struct resource bfin_sir0_resources
[] = {
215 .flags
= IORESOURCE_MEM
,
218 .start
= IRQ_UART0_RX
,
219 .end
= IRQ_UART0_RX
+1,
220 .flags
= IORESOURCE_IRQ
,
223 .start
= CH_UART0_RX
,
224 .end
= CH_UART0_RX
+1,
225 .flags
= IORESOURCE_DMA
,
229 static struct platform_device bfin_sir0_device
= {
232 .num_resources
= ARRAY_SIZE(bfin_sir0_resources
),
233 .resource
= bfin_sir0_resources
,
238 #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
239 static struct platform_device bfin_sport0_uart_device
= {
240 .name
= "bfin-sport-uart",
244 static struct platform_device bfin_sport1_uart_device
= {
245 .name
= "bfin-sport-uart",
250 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
251 #include <linux/input.h>
252 #include <linux/gpio_keys.h>
254 static struct gpio_keys_button bfin_gpio_keys_table
[] = {
255 {BTN_0
, GPIO_PF4
, 0, "gpio-keys: BTN0"},
256 {BTN_1
, GPIO_PF5
, 0, "gpio-keys: BTN1"},
257 {BTN_2
, GPIO_PF6
, 0, "gpio-keys: BTN2"},
258 }; /* Mapped to the first three PF Test Points */
260 static struct gpio_keys_platform_data bfin_gpio_keys_data
= {
261 .buttons
= bfin_gpio_keys_table
,
262 .nbuttons
= ARRAY_SIZE(bfin_gpio_keys_table
),
265 static struct platform_device bfin_device_gpiokeys
= {
268 .platform_data
= &bfin_gpio_keys_data
,
273 static struct resource bfin_gpios_resources
= {
275 .end
= MAX_BLACKFIN_GPIOS
- 1,
276 .flags
= IORESOURCE_IRQ
,
279 static struct platform_device bfin_gpios_device
= {
280 .name
= "simple-gpio",
283 .resource
= &bfin_gpios_resources
,
286 #if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
287 #include <linux/i2c-gpio.h>
289 static struct i2c_gpio_platform_data i2c_gpio_data
= {
292 .sda_is_open_drain
= 0,
293 .scl_is_open_drain
= 0,
295 }; /* This hasn't actually been used these pins
296 * are (currently) free pins on the expansion connector */
298 static struct platform_device i2c_gpio_device
= {
302 .platform_data
= &i2c_gpio_data
,
307 static struct i2c_board_info __initdata bfin_i2c_board_info
[] = {
310 static const unsigned int cclk_vlev_datasheet
[] =
312 VRPAIR(VLEV_085
, 250000000),
313 VRPAIR(VLEV_090
, 376000000),
314 VRPAIR(VLEV_095
, 426000000),
315 VRPAIR(VLEV_100
, 426000000),
316 VRPAIR(VLEV_105
, 476000000),
317 VRPAIR(VLEV_110
, 476000000),
318 VRPAIR(VLEV_115
, 476000000),
319 VRPAIR(VLEV_120
, 600000000),
320 VRPAIR(VLEV_125
, 600000000),
321 VRPAIR(VLEV_130
, 600000000),
324 static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data
= {
325 .tuple_tab
= cclk_vlev_datasheet
,
326 .tabsize
= ARRAY_SIZE(cclk_vlev_datasheet
),
327 .vr_settling_time
= 25 /* us */,
330 static struct platform_device bfin_dpmc
= {
333 .platform_data
= &bfin_dmpc_vreg_data
,
337 static struct platform_device
*stamp_devices
[] __initdata
= {
341 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
345 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
350 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
354 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
358 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
359 #ifdef CONFIG_BFIN_SIR0
364 #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
365 &bfin_sport0_uart_device
,
366 &bfin_sport1_uart_device
,
369 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
370 &bfin_device_gpiokeys
,
373 #if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
380 static int __init
blackstamp_init(void)
384 printk(KERN_INFO
"%s(): registering device resources\n", __func__
);
386 i2c_register_board_info(0, bfin_i2c_board_info
,
387 ARRAY_SIZE(bfin_i2c_board_info
));
389 ret
= platform_add_devices(stamp_devices
, ARRAY_SIZE(stamp_devices
));
393 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
394 /* setup BF533_STAMP CPLD to route AMS3 to Ethernet MAC */
395 bfin_write_FIO_DIR(bfin_read_FIO_DIR() | PF0
);
396 bfin_write_FIO_FLAG_S(PF0
);
400 spi_register_board_info(bfin_spi_board_info
, ARRAY_SIZE(bfin_spi_board_info
));
404 arch_initcall(blackstamp_init
);