Blackfin: convert boards to use platform data with smc91x
[linux-2.6/linux-2.6-openrd.git] / arch / blackfin / mach-bf533 / boards / blackstamp.c
blob8208d67e2c9766cf3c496b41dd09bab7d99f2016
1 /*
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>
7 * Created: 2008
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>
30 #include <asm/dma.h>
31 #include <asm/bfin5xx_spi.h>
32 #include <asm/portmux.h>
33 #include <asm/dpmc.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 = {
42 .name = "rtc-bfin",
43 .id = -1,
45 #endif
48 * Driver needs to know address, irq and flag pin.
50 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
51 #include <linux/smc91x.h>
53 static struct smc91x_platdata smc91x_info = {
54 .flags = SMC91X_USE_16BIT | SMC91X_NOWAIT,
55 .leda = RPC_LED_100_10,
56 .ledb = RPC_LED_TX_RX,
59 static struct resource smc91x_resources[] = {
61 .name = "smc91x-regs",
62 .start = 0x20300300,
63 .end = 0x20300300 + 16,
64 .flags = IORESOURCE_MEM,
65 }, {
66 .start = IRQ_PF3,
67 .end = IRQ_PF3,
68 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
72 static struct platform_device smc91x_device = {
73 .name = "smc91x",
74 .id = 0,
75 .num_resources = ARRAY_SIZE(smc91x_resources),
76 .resource = smc91x_resources,
77 .dev = {
78 .platform_data = &smc91x_info,
81 #endif
83 #if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE)
84 static struct mtd_partition bfin_spi_flash_partitions[] = {
86 .name = "bootloader(spi)",
87 .size = 0x00040000,
88 .offset = 0,
89 .mask_flags = MTD_CAP_ROM
90 }, {
91 .name = "linux kernel(spi)",
92 .size = 0x180000,
93 .offset = MTDPART_OFS_APPEND,
94 }, {
95 .name = "file system(spi)",
96 .size = MTDPART_SIZ_FULL,
97 .offset = MTDPART_OFS_APPEND,
101 static struct flash_platform_data bfin_spi_flash_data = {
102 .name = "m25p80",
103 .parts = bfin_spi_flash_partitions,
104 .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
105 .type = "m25p64",
108 /* SPI flash chip (m25p64) */
109 static struct bfin5xx_spi_chip spi_flash_chip_info = {
110 .enable_dma = 0, /* use dma transfer with this chip*/
111 .bits_per_word = 8,
113 #endif
115 #if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
116 static struct bfin5xx_spi_chip mmc_spi_chip_info = {
117 .enable_dma = 0,
118 .bits_per_word = 8,
120 #endif
122 #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
123 static struct bfin5xx_spi_chip spidev_chip_info = {
124 .enable_dma = 0,
125 .bits_per_word = 8,
127 #endif
129 static struct spi_board_info bfin_spi_board_info[] __initdata = {
130 #if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE)
132 /* the modalias must be the same as spi device driver name */
133 .modalias = "m25p80", /* Name of spi_driver for this device */
134 .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */
135 .bus_num = 0, /* Framework bus number */
136 .chip_select = 2, /* Framework chip select. */
137 .platform_data = &bfin_spi_flash_data,
138 .controller_data = &spi_flash_chip_info,
139 .mode = SPI_MODE_3,
141 #endif
143 #if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
145 .modalias = "mmc_spi",
146 .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */
147 .bus_num = 0,
148 .chip_select = 5,
149 .controller_data = &mmc_spi_chip_info,
150 .mode = SPI_MODE_3,
152 #endif
154 #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
156 .modalias = "spidev",
157 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
158 .bus_num = 0,
159 .chip_select = 7,
160 .controller_data = &spidev_chip_info,
162 #endif
165 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
166 /* SPI (0) */
167 static struct resource bfin_spi0_resource[] = {
168 [0] = {
169 .start = SPI0_REGBASE,
170 .end = SPI0_REGBASE + 0xFF,
171 .flags = IORESOURCE_MEM,
173 [1] = {
174 .start = CH_SPI,
175 .end = CH_SPI,
176 .flags = IORESOURCE_DMA,
178 [2] = {
179 .start = IRQ_SPI,
180 .end = IRQ_SPI,
181 .flags = IORESOURCE_IRQ,
185 /* SPI controller data */
186 static struct bfin5xx_spi_master bfin_spi0_info = {
187 .num_chipselect = 8,
188 .enable_dma = 1, /* master has the ability to do dma transfer */
189 .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
192 static struct platform_device bfin_spi0_device = {
193 .name = "bfin-spi",
194 .id = 0, /* Bus number */
195 .num_resources = ARRAY_SIZE(bfin_spi0_resource),
196 .resource = bfin_spi0_resource,
197 .dev = {
198 .platform_data = &bfin_spi0_info, /* Passed to driver */
201 #endif /* spi master and devices */
203 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
204 static struct resource bfin_uart_resources[] = {
206 .start = 0xFFC00400,
207 .end = 0xFFC004FF,
208 .flags = IORESOURCE_MEM,
212 static struct platform_device bfin_uart_device = {
213 .name = "bfin-uart",
214 .id = 1,
215 .num_resources = ARRAY_SIZE(bfin_uart_resources),
216 .resource = bfin_uart_resources,
218 #endif
220 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
221 #ifdef CONFIG_BFIN_SIR0
222 static struct resource bfin_sir0_resources[] = {
224 .start = 0xFFC00400,
225 .end = 0xFFC004FF,
226 .flags = IORESOURCE_MEM,
229 .start = IRQ_UART0_RX,
230 .end = IRQ_UART0_RX+1,
231 .flags = IORESOURCE_IRQ,
234 .start = CH_UART0_RX,
235 .end = CH_UART0_RX+1,
236 .flags = IORESOURCE_DMA,
240 static struct platform_device bfin_sir0_device = {
241 .name = "bfin_sir",
242 .id = 0,
243 .num_resources = ARRAY_SIZE(bfin_sir0_resources),
244 .resource = bfin_sir0_resources,
246 #endif
247 #endif
249 #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
250 static struct platform_device bfin_sport0_uart_device = {
251 .name = "bfin-sport-uart",
252 .id = 0,
255 static struct platform_device bfin_sport1_uart_device = {
256 .name = "bfin-sport-uart",
257 .id = 1,
259 #endif
261 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
262 #include <linux/input.h>
263 #include <linux/gpio_keys.h>
265 static struct gpio_keys_button bfin_gpio_keys_table[] = {
266 {BTN_0, GPIO_PF4, 0, "gpio-keys: BTN0"},
267 {BTN_1, GPIO_PF5, 0, "gpio-keys: BTN1"},
268 {BTN_2, GPIO_PF6, 0, "gpio-keys: BTN2"},
269 }; /* Mapped to the first three PF Test Points */
271 static struct gpio_keys_platform_data bfin_gpio_keys_data = {
272 .buttons = bfin_gpio_keys_table,
273 .nbuttons = ARRAY_SIZE(bfin_gpio_keys_table),
276 static struct platform_device bfin_device_gpiokeys = {
277 .name = "gpio-keys",
278 .dev = {
279 .platform_data = &bfin_gpio_keys_data,
282 #endif
284 static struct resource bfin_gpios_resources = {
285 .start = 0,
286 .end = MAX_BLACKFIN_GPIOS - 1,
287 .flags = IORESOURCE_IRQ,
290 static struct platform_device bfin_gpios_device = {
291 .name = "simple-gpio",
292 .id = -1,
293 .num_resources = 1,
294 .resource = &bfin_gpios_resources,
297 #if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
298 #include <linux/i2c-gpio.h>
300 static struct i2c_gpio_platform_data i2c_gpio_data = {
301 .sda_pin = 8,
302 .scl_pin = 9,
303 .sda_is_open_drain = 0,
304 .scl_is_open_drain = 0,
305 .udelay = 40,
306 }; /* This hasn't actually been used these pins
307 * are (currently) free pins on the expansion connector */
309 static struct platform_device i2c_gpio_device = {
310 .name = "i2c-gpio",
311 .id = 0,
312 .dev = {
313 .platform_data = &i2c_gpio_data,
316 #endif
318 static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
321 static const unsigned int cclk_vlev_datasheet[] =
323 VRPAIR(VLEV_085, 250000000),
324 VRPAIR(VLEV_090, 376000000),
325 VRPAIR(VLEV_095, 426000000),
326 VRPAIR(VLEV_100, 426000000),
327 VRPAIR(VLEV_105, 476000000),
328 VRPAIR(VLEV_110, 476000000),
329 VRPAIR(VLEV_115, 476000000),
330 VRPAIR(VLEV_120, 600000000),
331 VRPAIR(VLEV_125, 600000000),
332 VRPAIR(VLEV_130, 600000000),
335 static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
336 .tuple_tab = cclk_vlev_datasheet,
337 .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
338 .vr_settling_time = 25 /* us */,
341 static struct platform_device bfin_dpmc = {
342 .name = "bfin dpmc",
343 .dev = {
344 .platform_data = &bfin_dmpc_vreg_data,
348 static struct platform_device *stamp_devices[] __initdata = {
350 &bfin_dpmc,
352 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
353 &rtc_device,
354 #endif
356 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
357 &smc91x_device,
358 #endif
361 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
362 &bfin_spi0_device,
363 #endif
365 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
366 &bfin_uart_device,
367 #endif
369 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
370 #ifdef CONFIG_BFIN_SIR0
371 &bfin_sir0_device,
372 #endif
373 #endif
375 #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
376 &bfin_sport0_uart_device,
377 &bfin_sport1_uart_device,
378 #endif
380 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
381 &bfin_device_gpiokeys,
382 #endif
384 #if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
385 &i2c_gpio_device,
386 #endif
388 &bfin_gpios_device,
391 static int __init blackstamp_init(void)
393 int ret;
395 printk(KERN_INFO "%s(): registering device resources\n", __func__);
397 i2c_register_board_info(0, bfin_i2c_board_info,
398 ARRAY_SIZE(bfin_i2c_board_info));
400 ret = platform_add_devices(stamp_devices, ARRAY_SIZE(stamp_devices));
401 if (ret < 0)
402 return ret;
404 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
405 /* setup BF533_STAMP CPLD to route AMS3 to Ethernet MAC */
406 bfin_write_FIO_DIR(bfin_read_FIO_DIR() | PF0);
407 bfin_write_FIO_FLAG_S(PF0);
408 SSYNC();
409 #endif
411 spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
412 return 0;
415 arch_initcall(blackstamp_init);