blob: 20c102285bef85dcedf1b5ec83da1c73366a2bab [file] [log] [blame]
Benjamin Matthews130de7c2008-08-14 14:55:54 +08001/*
Robin Getz96f10502009-09-24 14:11:24 +00002 * Board Info File for the BlackStamp
Benjamin Matthews130de7c2008-08-14 14:55:54 +08003 *
Benjamin Matthews130de7c2008-08-14 14:55:54 +08004 * Copyright 2004-2008 Analog Devices Inc.
Robin Getz96f10502009-09-24 14:11:24 +00005 * 2008 Benjamin Matthews <bmat@lle.rochester.edu>
6 * 2005 National ICT Australia (NICTA)
7 * Aidan Williams <aidan@nicta.com.au>
Benjamin Matthews130de7c2008-08-14 14:55:54 +08008 *
9 * More info about the BlackStamp at:
10 * http://blackfin.uclinux.org/gf/project/blackstamp/
11 *
12 * Licensed under the GPL-2 or later.
13 */
14
15#include <linux/device.h>
16#include <linux/platform_device.h>
17#include <linux/mtd/mtd.h>
18#include <linux/mtd/partitions.h>
19#include <linux/mtd/physmap.h>
20#include <linux/spi/spi.h>
21#include <linux/spi/flash.h>
22#include <linux/irq.h>
23#include <linux/i2c.h>
24#include <asm/dma.h>
25#include <asm/bfin5xx_spi.h>
26#include <asm/portmux.h>
27#include <asm/dpmc.h>
David Howellsf3441942010-10-07 14:08:50 +010028#include <mach/fio_flag.h>
Benjamin Matthews130de7c2008-08-14 14:55:54 +080029
30/*
31 * Name the Board for the /proc/cpuinfo
32 */
33const char bfin_board_name[] = "BlackStamp";
34
35#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
36static struct platform_device rtc_device = {
37 .name = "rtc-bfin",
38 .id = -1,
39};
40#endif
41
42/*
43 * Driver needs to know address, irq and flag pin.
44 */
45#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
Michael Hennerich61f09b52009-07-24 08:48:31 +000046#include <linux/smc91x.h>
47
48static struct smc91x_platdata smc91x_info = {
49 .flags = SMC91X_USE_16BIT | SMC91X_NOWAIT,
50 .leda = RPC_LED_100_10,
51 .ledb = RPC_LED_TX_RX,
52};
53
Benjamin Matthews130de7c2008-08-14 14:55:54 +080054static struct resource smc91x_resources[] = {
55 {
56 .name = "smc91x-regs",
57 .start = 0x20300300,
58 .end = 0x20300300 + 16,
59 .flags = IORESOURCE_MEM,
60 }, {
61 .start = IRQ_PF3,
62 .end = IRQ_PF3,
63 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
64 },
65};
66
67static struct platform_device smc91x_device = {
68 .name = "smc91x",
69 .id = 0,
70 .num_resources = ARRAY_SIZE(smc91x_resources),
71 .resource = smc91x_resources,
Michael Hennerich61f09b52009-07-24 08:48:31 +000072 .dev = {
73 .platform_data = &smc91x_info,
74 },
Benjamin Matthews130de7c2008-08-14 14:55:54 +080075};
76#endif
77
78#if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE)
79static struct mtd_partition bfin_spi_flash_partitions[] = {
80 {
81 .name = "bootloader(spi)",
82 .size = 0x00040000,
83 .offset = 0,
84 .mask_flags = MTD_CAP_ROM
85 }, {
86 .name = "linux kernel(spi)",
87 .size = 0x180000,
88 .offset = MTDPART_OFS_APPEND,
89 }, {
90 .name = "file system(spi)",
91 .size = MTDPART_SIZ_FULL,
92 .offset = MTDPART_OFS_APPEND,
93 }
94};
95
96static struct flash_platform_data bfin_spi_flash_data = {
97 .name = "m25p80",
98 .parts = bfin_spi_flash_partitions,
99 .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
100 .type = "m25p64",
101};
102
103/* SPI flash chip (m25p64) */
104static struct bfin5xx_spi_chip spi_flash_chip_info = {
105 .enable_dma = 0, /* use dma transfer with this chip*/
106 .bits_per_word = 8,
107};
108#endif
109
Michael Hennerichf3f704d2009-03-06 00:27:57 +0800110#if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
111static struct bfin5xx_spi_chip mmc_spi_chip_info = {
112 .enable_dma = 0,
Benjamin Matthews130de7c2008-08-14 14:55:54 +0800113 .bits_per_word = 8,
114};
115#endif
116
117#if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
118static struct bfin5xx_spi_chip spidev_chip_info = {
119 .enable_dma = 0,
120 .bits_per_word = 8,
121};
122#endif
123
124static struct spi_board_info bfin_spi_board_info[] __initdata = {
125#if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE)
126 {
127 /* the modalias must be the same as spi device driver name */
128 .modalias = "m25p80", /* Name of spi_driver for this device */
129 .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */
130 .bus_num = 0, /* Framework bus number */
131 .chip_select = 2, /* Framework chip select. */
132 .platform_data = &bfin_spi_flash_data,
133 .controller_data = &spi_flash_chip_info,
134 .mode = SPI_MODE_3,
135 },
136#endif
137
Michael Hennerichf3f704d2009-03-06 00:27:57 +0800138#if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
Benjamin Matthews130de7c2008-08-14 14:55:54 +0800139 {
Michael Hennerichf3f704d2009-03-06 00:27:57 +0800140 .modalias = "mmc_spi",
Benjamin Matthews130de7c2008-08-14 14:55:54 +0800141 .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */
142 .bus_num = 0,
Michael Hennerichf3f704d2009-03-06 00:27:57 +0800143 .chip_select = 5,
144 .controller_data = &mmc_spi_chip_info,
Benjamin Matthews130de7c2008-08-14 14:55:54 +0800145 .mode = SPI_MODE_3,
146 },
147#endif
148
149#if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
150 {
151 .modalias = "spidev",
152 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
153 .bus_num = 0,
154 .chip_select = 7,
155 .controller_data = &spidev_chip_info,
156 },
157#endif
158};
159
160#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
161/* SPI (0) */
162static struct resource bfin_spi0_resource[] = {
163 [0] = {
164 .start = SPI0_REGBASE,
165 .end = SPI0_REGBASE + 0xFF,
166 .flags = IORESOURCE_MEM,
167 },
168 [1] = {
169 .start = CH_SPI,
170 .end = CH_SPI,
Yi Li53122692009-06-05 12:11:11 +0000171 .flags = IORESOURCE_DMA,
172 },
173 [2] = {
174 .start = IRQ_SPI,
175 .end = IRQ_SPI,
Benjamin Matthews130de7c2008-08-14 14:55:54 +0800176 .flags = IORESOURCE_IRQ,
177 }
178};
179
180/* SPI controller data */
181static struct bfin5xx_spi_master bfin_spi0_info = {
182 .num_chipselect = 8,
183 .enable_dma = 1, /* master has the ability to do dma transfer */
184 .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
185};
186
187static struct platform_device bfin_spi0_device = {
188 .name = "bfin-spi",
189 .id = 0, /* Bus number */
190 .num_resources = ARRAY_SIZE(bfin_spi0_resource),
191 .resource = bfin_spi0_resource,
192 .dev = {
193 .platform_data = &bfin_spi0_info, /* Passed to driver */
194 },
195};
196#endif /* spi master and devices */
197
198#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
Sonic Zhang6bd1fbe2009-09-09 10:46:19 +0000199#ifdef CONFIG_SERIAL_BFIN_UART0
200static struct resource bfin_uart0_resources[] = {
Benjamin Matthews130de7c2008-08-14 14:55:54 +0800201 {
Sonic Zhang6bd1fbe2009-09-09 10:46:19 +0000202 .start = BFIN_UART_THR,
203 .end = BFIN_UART_GCTL+2,
Benjamin Matthews130de7c2008-08-14 14:55:54 +0800204 .flags = IORESOURCE_MEM,
205 },
Sonic Zhang6bd1fbe2009-09-09 10:46:19 +0000206 {
207 .start = IRQ_UART0_RX,
208 .end = IRQ_UART0_RX + 1,
209 .flags = IORESOURCE_IRQ,
210 },
211 {
212 .start = IRQ_UART0_ERROR,
213 .end = IRQ_UART0_ERROR,
214 .flags = IORESOURCE_IRQ,
215 },
216 {
217 .start = CH_UART0_TX,
218 .end = CH_UART0_TX,
219 .flags = IORESOURCE_DMA,
220 },
221 {
222 .start = CH_UART0_RX,
223 .end = CH_UART0_RX,
224 .flags = IORESOURCE_DMA,
225 },
Benjamin Matthews130de7c2008-08-14 14:55:54 +0800226};
227
Sonic Zhang6bd1fbe2009-09-09 10:46:19 +0000228unsigned short bfin_uart0_peripherals[] = {
229 P_UART0_TX, P_UART0_RX, 0
Benjamin Matthews130de7c2008-08-14 14:55:54 +0800230};
Sonic Zhang6bd1fbe2009-09-09 10:46:19 +0000231
232static struct platform_device bfin_uart0_device = {
233 .name = "bfin-uart",
234 .id = 0,
235 .num_resources = ARRAY_SIZE(bfin_uart0_resources),
236 .resource = bfin_uart0_resources,
237 .dev = {
238 .platform_data = &bfin_uart0_peripherals, /* Passed to driver */
239 },
240};
241#endif
Benjamin Matthews130de7c2008-08-14 14:55:54 +0800242#endif
243
244#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
Benjamin Matthews130de7c2008-08-14 14:55:54 +0800245#ifdef CONFIG_BFIN_SIR0
Graf Yang42bd8bc2009-01-07 23:14:39 +0800246static struct resource bfin_sir0_resources[] = {
Benjamin Matthews130de7c2008-08-14 14:55:54 +0800247 {
248 .start = 0xFFC00400,
249 .end = 0xFFC004FF,
250 .flags = IORESOURCE_MEM,
251 },
Graf Yang42bd8bc2009-01-07 23:14:39 +0800252 {
253 .start = IRQ_UART0_RX,
254 .end = IRQ_UART0_RX+1,
255 .flags = IORESOURCE_IRQ,
256 },
257 {
258 .start = CH_UART0_RX,
259 .end = CH_UART0_RX+1,
260 .flags = IORESOURCE_DMA,
261 },
Benjamin Matthews130de7c2008-08-14 14:55:54 +0800262};
263
Graf Yang42bd8bc2009-01-07 23:14:39 +0800264static struct platform_device bfin_sir0_device = {
Benjamin Matthews130de7c2008-08-14 14:55:54 +0800265 .name = "bfin_sir",
266 .id = 0,
Graf Yang42bd8bc2009-01-07 23:14:39 +0800267 .num_resources = ARRAY_SIZE(bfin_sir0_resources),
268 .resource = bfin_sir0_resources,
Benjamin Matthews130de7c2008-08-14 14:55:54 +0800269};
270#endif
Graf Yang42bd8bc2009-01-07 23:14:39 +0800271#endif
Benjamin Matthews130de7c2008-08-14 14:55:54 +0800272
273#if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
Sonic Zhangdf5de262009-09-23 05:01:56 +0000274#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
275static struct resource bfin_sport0_uart_resources[] = {
276 {
277 .start = SPORT0_TCR1,
278 .end = SPORT0_MRCS3+4,
279 .flags = IORESOURCE_MEM,
280 },
281 {
282 .start = IRQ_SPORT0_RX,
283 .end = IRQ_SPORT0_RX+1,
284 .flags = IORESOURCE_IRQ,
285 },
286 {
287 .start = IRQ_SPORT0_ERROR,
288 .end = IRQ_SPORT0_ERROR,
289 .flags = IORESOURCE_IRQ,
290 },
291};
292
293unsigned short bfin_sport0_peripherals[] = {
294 P_SPORT0_TFS, P_SPORT0_DTPRI, P_SPORT0_TSCLK, P_SPORT0_RFS,
295 P_SPORT0_DRPRI, P_SPORT0_RSCLK, P_SPORT0_DRSEC, P_SPORT0_DTSEC, 0
296};
297
Benjamin Matthews130de7c2008-08-14 14:55:54 +0800298static struct platform_device bfin_sport0_uart_device = {
299 .name = "bfin-sport-uart",
300 .id = 0,
Sonic Zhangdf5de262009-09-23 05:01:56 +0000301 .num_resources = ARRAY_SIZE(bfin_sport0_uart_resources),
302 .resource = bfin_sport0_uart_resources,
303 .dev = {
304 .platform_data = &bfin_sport0_peripherals, /* Passed to driver */
305 },
306};
307#endif
308#ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
309static struct resource bfin_sport1_uart_resources[] = {
310 {
311 .start = SPORT1_TCR1,
312 .end = SPORT1_MRCS3+4,
313 .flags = IORESOURCE_MEM,
314 },
315 {
316 .start = IRQ_SPORT1_RX,
317 .end = IRQ_SPORT1_RX+1,
318 .flags = IORESOURCE_IRQ,
319 },
320 {
321 .start = IRQ_SPORT1_ERROR,
322 .end = IRQ_SPORT1_ERROR,
323 .flags = IORESOURCE_IRQ,
324 },
325};
326
327unsigned short bfin_sport1_peripherals[] = {
328 P_SPORT1_TFS, P_SPORT1_DTPRI, P_SPORT1_TSCLK, P_SPORT1_RFS,
329 P_SPORT1_DRPRI, P_SPORT1_RSCLK, P_SPORT1_DRSEC, P_SPORT1_DTSEC, 0
Benjamin Matthews130de7c2008-08-14 14:55:54 +0800330};
331
332static struct platform_device bfin_sport1_uart_device = {
333 .name = "bfin-sport-uart",
334 .id = 1,
Sonic Zhangdf5de262009-09-23 05:01:56 +0000335 .num_resources = ARRAY_SIZE(bfin_sport1_uart_resources),
336 .resource = bfin_sport1_uart_resources,
337 .dev = {
338 .platform_data = &bfin_sport1_peripherals, /* Passed to driver */
339 },
Benjamin Matthews130de7c2008-08-14 14:55:54 +0800340};
341#endif
Sonic Zhangdf5de262009-09-23 05:01:56 +0000342#endif
Benjamin Matthews130de7c2008-08-14 14:55:54 +0800343
344#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
345#include <linux/input.h>
346#include <linux/gpio_keys.h>
347
348static struct gpio_keys_button bfin_gpio_keys_table[] = {
349 {BTN_0, GPIO_PF4, 0, "gpio-keys: BTN0"},
350 {BTN_1, GPIO_PF5, 0, "gpio-keys: BTN1"},
351 {BTN_2, GPIO_PF6, 0, "gpio-keys: BTN2"},
352}; /* Mapped to the first three PF Test Points */
353
354static struct gpio_keys_platform_data bfin_gpio_keys_data = {
355 .buttons = bfin_gpio_keys_table,
356 .nbuttons = ARRAY_SIZE(bfin_gpio_keys_table),
357};
358
359static struct platform_device bfin_device_gpiokeys = {
360 .name = "gpio-keys",
361 .dev = {
362 .platform_data = &bfin_gpio_keys_data,
363 },
364};
365#endif
366
Benjamin Matthews130de7c2008-08-14 14:55:54 +0800367#if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
368#include <linux/i2c-gpio.h>
369
370static struct i2c_gpio_platform_data i2c_gpio_data = {
Mike Frysinger3d7dc882010-07-02 21:02:50 +0000371 .sda_pin = GPIO_PF8,
372 .scl_pin = GPIO_PF9,
Benjamin Matthews130de7c2008-08-14 14:55:54 +0800373 .sda_is_open_drain = 0,
374 .scl_is_open_drain = 0,
375 .udelay = 40,
376}; /* This hasn't actually been used these pins
377 * are (currently) free pins on the expansion connector */
378
379static struct platform_device i2c_gpio_device = {
380 .name = "i2c-gpio",
381 .id = 0,
382 .dev = {
383 .platform_data = &i2c_gpio_data,
384 },
385};
386#endif
387
Benjamin Matthews130de7c2008-08-14 14:55:54 +0800388static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
389};
Benjamin Matthews130de7c2008-08-14 14:55:54 +0800390
391static const unsigned int cclk_vlev_datasheet[] =
392{
393 VRPAIR(VLEV_085, 250000000),
394 VRPAIR(VLEV_090, 376000000),
395 VRPAIR(VLEV_095, 426000000),
396 VRPAIR(VLEV_100, 426000000),
397 VRPAIR(VLEV_105, 476000000),
398 VRPAIR(VLEV_110, 476000000),
399 VRPAIR(VLEV_115, 476000000),
400 VRPAIR(VLEV_120, 600000000),
401 VRPAIR(VLEV_125, 600000000),
402 VRPAIR(VLEV_130, 600000000),
403};
404
405static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
406 .tuple_tab = cclk_vlev_datasheet,
407 .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
408 .vr_settling_time = 25 /* us */,
409};
410
411static struct platform_device bfin_dpmc = {
412 .name = "bfin dpmc",
413 .dev = {
414 .platform_data = &bfin_dmpc_vreg_data,
415 },
416};
417
418static struct platform_device *stamp_devices[] __initdata = {
419
420 &bfin_dpmc,
421
422#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
423 &rtc_device,
424#endif
425
426#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
427 &smc91x_device,
428#endif
429
430
431#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
432 &bfin_spi0_device,
433#endif
434
435#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
Sonic Zhang6bd1fbe2009-09-09 10:46:19 +0000436#ifdef CONFIG_SERIAL_BFIN_UART0
437 &bfin_uart0_device,
438#endif
Benjamin Matthews130de7c2008-08-14 14:55:54 +0800439#endif
440
441#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
Graf Yang42bd8bc2009-01-07 23:14:39 +0800442#ifdef CONFIG_BFIN_SIR0
443 &bfin_sir0_device,
444#endif
Benjamin Matthews130de7c2008-08-14 14:55:54 +0800445#endif
446
447#if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
Sonic Zhangdf5de262009-09-23 05:01:56 +0000448#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
Benjamin Matthews130de7c2008-08-14 14:55:54 +0800449 &bfin_sport0_uart_device,
Sonic Zhangdf5de262009-09-23 05:01:56 +0000450#endif
451#ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
Benjamin Matthews130de7c2008-08-14 14:55:54 +0800452 &bfin_sport1_uart_device,
453#endif
Sonic Zhangdf5de262009-09-23 05:01:56 +0000454#endif
Benjamin Matthews130de7c2008-08-14 14:55:54 +0800455
456#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
457 &bfin_device_gpiokeys,
458#endif
459
460#if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
461 &i2c_gpio_device,
462#endif
Benjamin Matthews130de7c2008-08-14 14:55:54 +0800463};
464
465static int __init blackstamp_init(void)
466{
467 int ret;
468
469 printk(KERN_INFO "%s(): registering device resources\n", __func__);
470
Benjamin Matthews130de7c2008-08-14 14:55:54 +0800471 i2c_register_board_info(0, bfin_i2c_board_info,
472 ARRAY_SIZE(bfin_i2c_board_info));
Benjamin Matthews130de7c2008-08-14 14:55:54 +0800473
474 ret = platform_add_devices(stamp_devices, ARRAY_SIZE(stamp_devices));
475 if (ret < 0)
476 return ret;
477
478#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
479 /* setup BF533_STAMP CPLD to route AMS3 to Ethernet MAC */
480 bfin_write_FIO_DIR(bfin_read_FIO_DIR() | PF0);
481 bfin_write_FIO_FLAG_S(PF0);
482 SSYNC();
483#endif
484
485 spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
486 return 0;
487}
488
489arch_initcall(blackstamp_init);
Sonic Zhangc13ce9f2009-09-23 09:37:46 +0000490
491static struct platform_device *stamp_early_devices[] __initdata = {
492#if defined(CONFIG_SERIAL_BFIN_CONSOLE) || defined(CONFIG_EARLY_PRINTK)
493#ifdef CONFIG_SERIAL_BFIN_UART0
494 &bfin_uart0_device,
495#endif
496#endif
497
498#if defined(CONFIG_SERIAL_BFIN_SPORT_CONSOLE)
499#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
500 &bfin_sport0_uart_device,
501#endif
502#ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
503 &bfin_sport1_uart_device,
504#endif
505#endif
506};
507
508void __init native_machine_early_platform_add_devices(void)
509{
510 printk(KERN_INFO "register early platform devices\n");
511 early_platform_add_devices(stamp_early_devices,
512 ARRAY_SIZE(stamp_early_devices));
513}