2 * Board Info File for the BlackStamp
4 * Copyright 2004-2008 Analog Devices Inc.
5 * 2008 Benjamin Matthews <bmat@lle.rochester.edu>
6 * 2005 National ICT Australia (NICTA)
7 * Aidan Williams <aidan@nicta.com.au>
9 * More info about the BlackStamp at:
10 * http://blackfin.uclinux.org/gf/project/blackstamp/
12 * Licensed under the GPL-2 or later.
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/gpio.h>
24 #include <linux/i2c.h>
26 #include <asm/bfin5xx_spi.h>
27 #include <asm/portmux.h>
31 * Name the Board for the /proc/cpuinfo
33 const char bfin_board_name
[] = "BlackStamp";
35 #if IS_ENABLED(CONFIG_RTC_DRV_BFIN)
36 static struct platform_device rtc_device
= {
43 * Driver needs to know address, irq and flag pin.
45 #if IS_ENABLED(CONFIG_SMC91X)
46 #include <linux/smc91x.h>
48 static struct smc91x_platdata smc91x_info
= {
49 .flags
= SMC91X_USE_16BIT
| SMC91X_NOWAIT
,
50 .leda
= RPC_LED_100_10
,
51 .ledb
= RPC_LED_TX_RX
,
54 static struct resource smc91x_resources
[] = {
56 .name
= "smc91x-regs",
58 .end
= 0x20300300 + 16,
59 .flags
= IORESOURCE_MEM
,
63 .flags
= IORESOURCE_IRQ
| IORESOURCE_IRQ_HIGHLEVEL
,
67 static struct platform_device smc91x_device
= {
70 .num_resources
= ARRAY_SIZE(smc91x_resources
),
71 .resource
= smc91x_resources
,
73 .platform_data
= &smc91x_info
,
78 #if IS_ENABLED(CONFIG_MTD_M25P80)
79 static struct mtd_partition bfin_spi_flash_partitions
[] = {
81 .name
= "bootloader(spi)",
84 .mask_flags
= MTD_CAP_ROM
86 .name
= "linux kernel(spi)",
88 .offset
= MTDPART_OFS_APPEND
,
90 .name
= "file system(spi)",
91 .size
= MTDPART_SIZ_FULL
,
92 .offset
= MTDPART_OFS_APPEND
,
96 static struct flash_platform_data bfin_spi_flash_data
= {
98 .parts
= bfin_spi_flash_partitions
,
99 .nr_parts
= ARRAY_SIZE(bfin_spi_flash_partitions
),
103 /* SPI flash chip (m25p64) */
104 static struct bfin5xx_spi_chip spi_flash_chip_info
= {
105 .enable_dma
= 0, /* use dma transfer with this chip*/
109 #if IS_ENABLED(CONFIG_MMC_SPI)
110 static struct bfin5xx_spi_chip mmc_spi_chip_info
= {
115 static struct spi_board_info bfin_spi_board_info
[] __initdata
= {
116 #if IS_ENABLED(CONFIG_MTD_M25P80)
118 /* the modalias must be the same as spi device driver name */
119 .modalias
= "m25p80", /* Name of spi_driver for this device */
120 .max_speed_hz
= 20000000, /* max spi clock (SCK) speed in HZ */
121 .bus_num
= 0, /* Framework bus number */
122 .chip_select
= 2, /* Framework chip select. */
123 .platform_data
= &bfin_spi_flash_data
,
124 .controller_data
= &spi_flash_chip_info
,
129 #if IS_ENABLED(CONFIG_MMC_SPI)
131 .modalias
= "mmc_spi",
132 .max_speed_hz
= 20000000, /* max spi clock (SCK) speed in HZ */
135 .controller_data
= &mmc_spi_chip_info
,
140 #if IS_ENABLED(CONFIG_SPI_SPIDEV)
142 .modalias
= "spidev",
143 .max_speed_hz
= 3125000, /* max spi clock (SCK) speed in HZ */
150 #if IS_ENABLED(CONFIG_SPI_BFIN5XX)
152 static struct resource bfin_spi0_resource
[] = {
154 .start
= SPI0_REGBASE
,
155 .end
= SPI0_REGBASE
+ 0xFF,
156 .flags
= IORESOURCE_MEM
,
161 .flags
= IORESOURCE_DMA
,
166 .flags
= IORESOURCE_IRQ
,
170 /* SPI controller data */
171 static struct bfin5xx_spi_master bfin_spi0_info
= {
173 .enable_dma
= 1, /* master has the ability to do dma transfer */
174 .pin_req
= {P_SPI0_SCK
, P_SPI0_MISO
, P_SPI0_MOSI
, 0},
177 static struct platform_device bfin_spi0_device
= {
179 .id
= 0, /* Bus number */
180 .num_resources
= ARRAY_SIZE(bfin_spi0_resource
),
181 .resource
= bfin_spi0_resource
,
183 .platform_data
= &bfin_spi0_info
, /* Passed to driver */
186 #endif /* spi master and devices */
188 #if IS_ENABLED(CONFIG_SERIAL_BFIN)
189 #ifdef CONFIG_SERIAL_BFIN_UART0
190 static struct resource bfin_uart0_resources
[] = {
192 .start
= BFIN_UART_THR
,
193 .end
= BFIN_UART_GCTL
+2,
194 .flags
= IORESOURCE_MEM
,
197 .start
= IRQ_UART0_TX
,
199 .flags
= IORESOURCE_IRQ
,
202 .start
= IRQ_UART0_RX
,
204 .flags
= IORESOURCE_IRQ
,
207 .start
= IRQ_UART0_ERROR
,
208 .end
= IRQ_UART0_ERROR
,
209 .flags
= IORESOURCE_IRQ
,
212 .start
= CH_UART0_TX
,
214 .flags
= IORESOURCE_DMA
,
217 .start
= CH_UART0_RX
,
219 .flags
= IORESOURCE_DMA
,
223 static unsigned short bfin_uart0_peripherals
[] = {
224 P_UART0_TX
, P_UART0_RX
, 0
227 static struct platform_device bfin_uart0_device
= {
230 .num_resources
= ARRAY_SIZE(bfin_uart0_resources
),
231 .resource
= bfin_uart0_resources
,
233 .platform_data
= &bfin_uart0_peripherals
, /* Passed to driver */
239 #if IS_ENABLED(CONFIG_BFIN_SIR)
240 #ifdef CONFIG_BFIN_SIR0
241 static struct resource bfin_sir0_resources
[] = {
245 .flags
= IORESOURCE_MEM
,
248 .start
= IRQ_UART0_RX
,
249 .end
= IRQ_UART0_RX
+1,
250 .flags
= IORESOURCE_IRQ
,
253 .start
= CH_UART0_RX
,
254 .end
= CH_UART0_RX
+1,
255 .flags
= IORESOURCE_DMA
,
259 static struct platform_device bfin_sir0_device
= {
262 .num_resources
= ARRAY_SIZE(bfin_sir0_resources
),
263 .resource
= bfin_sir0_resources
,
268 #if IS_ENABLED(CONFIG_SERIAL_BFIN_SPORT)
269 #ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
270 static struct resource bfin_sport0_uart_resources
[] = {
272 .start
= SPORT0_TCR1
,
273 .end
= SPORT0_MRCS3
+4,
274 .flags
= IORESOURCE_MEM
,
277 .start
= IRQ_SPORT0_RX
,
278 .end
= IRQ_SPORT0_RX
+1,
279 .flags
= IORESOURCE_IRQ
,
282 .start
= IRQ_SPORT0_ERROR
,
283 .end
= IRQ_SPORT0_ERROR
,
284 .flags
= IORESOURCE_IRQ
,
288 static unsigned short bfin_sport0_peripherals
[] = {
289 P_SPORT0_TFS
, P_SPORT0_DTPRI
, P_SPORT0_TSCLK
, P_SPORT0_RFS
,
290 P_SPORT0_DRPRI
, P_SPORT0_RSCLK
, 0
293 static struct platform_device bfin_sport0_uart_device
= {
294 .name
= "bfin-sport-uart",
296 .num_resources
= ARRAY_SIZE(bfin_sport0_uart_resources
),
297 .resource
= bfin_sport0_uart_resources
,
299 .platform_data
= &bfin_sport0_peripherals
, /* Passed to driver */
303 #ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
304 static struct resource bfin_sport1_uart_resources
[] = {
306 .start
= SPORT1_TCR1
,
307 .end
= SPORT1_MRCS3
+4,
308 .flags
= IORESOURCE_MEM
,
311 .start
= IRQ_SPORT1_RX
,
312 .end
= IRQ_SPORT1_RX
+1,
313 .flags
= IORESOURCE_IRQ
,
316 .start
= IRQ_SPORT1_ERROR
,
317 .end
= IRQ_SPORT1_ERROR
,
318 .flags
= IORESOURCE_IRQ
,
322 static unsigned short bfin_sport1_peripherals
[] = {
323 P_SPORT1_TFS
, P_SPORT1_DTPRI
, P_SPORT1_TSCLK
, P_SPORT1_RFS
,
324 P_SPORT1_DRPRI
, P_SPORT1_RSCLK
, 0
327 static struct platform_device bfin_sport1_uart_device
= {
328 .name
= "bfin-sport-uart",
330 .num_resources
= ARRAY_SIZE(bfin_sport1_uart_resources
),
331 .resource
= bfin_sport1_uart_resources
,
333 .platform_data
= &bfin_sport1_peripherals
, /* Passed to driver */
339 #if IS_ENABLED(CONFIG_KEYBOARD_GPIO)
340 #include <linux/input.h>
341 #include <linux/gpio_keys.h>
343 static struct gpio_keys_button bfin_gpio_keys_table
[] = {
344 {BTN_0
, GPIO_PF4
, 0, "gpio-keys: BTN0"},
345 {BTN_1
, GPIO_PF5
, 0, "gpio-keys: BTN1"},
346 {BTN_2
, GPIO_PF6
, 0, "gpio-keys: BTN2"},
347 }; /* Mapped to the first three PF Test Points */
349 static struct gpio_keys_platform_data bfin_gpio_keys_data
= {
350 .buttons
= bfin_gpio_keys_table
,
351 .nbuttons
= ARRAY_SIZE(bfin_gpio_keys_table
),
354 static struct platform_device bfin_device_gpiokeys
= {
357 .platform_data
= &bfin_gpio_keys_data
,
362 #if IS_ENABLED(CONFIG_I2C_GPIO)
363 #include <linux/i2c-gpio.h>
365 static struct i2c_gpio_platform_data i2c_gpio_data
= {
368 .sda_is_open_drain
= 0,
369 .scl_is_open_drain
= 0,
371 }; /* This hasn't actually been used these pins
372 * are (currently) free pins on the expansion connector */
374 static struct platform_device i2c_gpio_device
= {
378 .platform_data
= &i2c_gpio_data
,
383 static struct i2c_board_info __initdata bfin_i2c_board_info
[] = {
386 static const unsigned int cclk_vlev_datasheet
[] =
388 VRPAIR(VLEV_085
, 250000000),
389 VRPAIR(VLEV_090
, 376000000),
390 VRPAIR(VLEV_095
, 426000000),
391 VRPAIR(VLEV_100
, 426000000),
392 VRPAIR(VLEV_105
, 476000000),
393 VRPAIR(VLEV_110
, 476000000),
394 VRPAIR(VLEV_115
, 476000000),
395 VRPAIR(VLEV_120
, 600000000),
396 VRPAIR(VLEV_125
, 600000000),
397 VRPAIR(VLEV_130
, 600000000),
400 static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data
= {
401 .tuple_tab
= cclk_vlev_datasheet
,
402 .tabsize
= ARRAY_SIZE(cclk_vlev_datasheet
),
403 .vr_settling_time
= 25 /* us */,
406 static struct platform_device bfin_dpmc
= {
409 .platform_data
= &bfin_dmpc_vreg_data
,
413 static struct platform_device
*stamp_devices
[] __initdata
= {
417 #if IS_ENABLED(CONFIG_RTC_DRV_BFIN)
421 #if IS_ENABLED(CONFIG_SMC91X)
426 #if IS_ENABLED(CONFIG_SPI_BFIN5XX)
430 #if IS_ENABLED(CONFIG_SERIAL_BFIN)
431 #ifdef CONFIG_SERIAL_BFIN_UART0
436 #if IS_ENABLED(CONFIG_BFIN_SIR)
437 #ifdef CONFIG_BFIN_SIR0
442 #if IS_ENABLED(CONFIG_SERIAL_BFIN_SPORT)
443 #ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
444 &bfin_sport0_uart_device
,
446 #ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
447 &bfin_sport1_uart_device
,
451 #if IS_ENABLED(CONFIG_KEYBOARD_GPIO)
452 &bfin_device_gpiokeys
,
455 #if IS_ENABLED(CONFIG_I2C_GPIO)
460 static int __init
blackstamp_init(void)
464 printk(KERN_INFO
"%s(): registering device resources\n", __func__
);
466 i2c_register_board_info(0, bfin_i2c_board_info
,
467 ARRAY_SIZE(bfin_i2c_board_info
));
469 ret
= platform_add_devices(stamp_devices
, ARRAY_SIZE(stamp_devices
));
473 #if IS_ENABLED(CONFIG_SMC91X)
475 * setup BF533_STAMP CPLD to route AMS3 to Ethernet MAC.
476 * the bfin-async-map driver takes care of flipping between
477 * flash and ethernet when necessary.
479 ret
= gpio_request(GPIO_PF0
, "enet_cpld");
481 gpio_direction_output(GPIO_PF0
, 1);
486 spi_register_board_info(bfin_spi_board_info
, ARRAY_SIZE(bfin_spi_board_info
));
490 arch_initcall(blackstamp_init
);
492 static struct platform_device
*stamp_early_devices
[] __initdata
= {
493 #if defined(CONFIG_SERIAL_BFIN_CONSOLE) || defined(CONFIG_EARLY_PRINTK)
494 #ifdef CONFIG_SERIAL_BFIN_UART0
499 #if defined(CONFIG_SERIAL_BFIN_SPORT_CONSOLE)
500 #ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
501 &bfin_sport0_uart_device
,
503 #ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
504 &bfin_sport1_uart_device
,
509 void __init
native_machine_early_platform_add_devices(void)
511 printk(KERN_INFO
"register early platform devices\n");
512 early_platform_add_devices(stamp_early_devices
,
513 ARRAY_SIZE(stamp_early_devices
));