2 * Copyright 2004-2009 Analog Devices Inc.
3 * 2005 National ICT Australia (NICTA)
4 * Aidan Williams <aidan@nicta.com.au>
6 * Licensed under the GPL-2 or later.
9 #include <linux/device.h>
10 #include <linux/platform_device.h>
11 #include <linux/mtd/mtd.h>
12 #include <linux/mtd/partitions.h>
13 #include <linux/mtd/physmap.h>
14 #include <linux/spi/spi.h>
15 #include <linux/spi/flash.h>
16 #include <linux/spi/mmc_spi.h>
17 #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
18 #include <linux/usb/isp1362.h>
20 #include <linux/irq.h>
21 #include <linux/i2c.h>
23 #include <asm/bfin5xx_spi.h>
24 #include <asm/reboot.h>
25 #include <asm/portmux.h>
29 * Name the Board for the /proc/cpuinfo
31 const char bfin_board_name[] = "ADI BF533-STAMP";
33 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
34 static struct platform_device rtc_device = {
41 * Driver needs to know address, irq and flag pin.
43 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
44 #include <linux/smc91x.h>
46 static struct smc91x_platdata smc91x_info = {
47 .flags = SMC91X_USE_16BIT | SMC91X_NOWAIT,
48 .leda = RPC_LED_100_10,
49 .ledb = RPC_LED_TX_RX,
52 static struct resource smc91x_resources[] = {
54 .name = "smc91x-regs",
56 .end = 0x20300300 + 16,
57 .flags = IORESOURCE_MEM,
61 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
65 static struct platform_device smc91x_device = {
68 .num_resources = ARRAY_SIZE(smc91x_resources),
69 .resource = smc91x_resources,
71 .platform_data = &smc91x_info,
76 #if defined(CONFIG_FB_BFIN_7393) || defined(CONFIG_FB_BFIN_7393_MODULE)
77 static struct platform_device bfin_fb_adv7393_device = {
78 .name = "bfin-adv7393",
82 #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
83 static struct resource net2272_bfin_resources[] = {
86 .end = 0x20300000 + 0x100,
87 .flags = IORESOURCE_MEM,
91 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
95 static struct platform_device net2272_bfin_device = {
98 .num_resources = ARRAY_SIZE(net2272_bfin_resources),
99 .resource = net2272_bfin_resources,
103 #if defined(CONFIG_MTD_BFIN_ASYNC) || defined(CONFIG_MTD_BFIN_ASYNC_MODULE)
104 static struct mtd_partition stamp_partitions[] = {
106 .name = "bootloader(nor)",
110 .name = "linux kernel(nor)",
112 .offset = MTDPART_OFS_APPEND,
114 .name = "file system(nor)",
115 .size = MTDPART_SIZ_FULL,
116 .offset = MTDPART_OFS_APPEND,
120 static struct physmap_flash_data stamp_flash_data = {
122 .parts = stamp_partitions,
123 .nr_parts = ARRAY_SIZE(stamp_partitions),
126 static struct resource stamp_flash_resource[] = {
131 .flags = IORESOURCE_MEM,
133 .start = 0x7BB07BB0, /* AMBCTL0 setting when accessing flash */
134 .end = 0x7BB07BB0, /* AMBCTL1 setting when accessing flash */
135 .flags = IORESOURCE_MEM,
138 .flags = IORESOURCE_IRQ,
142 static struct platform_device stamp_flash_device = {
143 .name = "bfin-async-flash",
146 .platform_data = &stamp_flash_data,
148 .num_resources = ARRAY_SIZE(stamp_flash_resource),
149 .resource = stamp_flash_resource,
153 #if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE)
154 static struct mtd_partition bfin_spi_flash_partitions[] = {
156 .name = "bootloader(spi)",
159 .mask_flags = MTD_CAP_ROM
161 .name = "linux kernel(spi)",
163 .offset = MTDPART_OFS_APPEND,
165 .name = "file system(spi)",
166 .size = MTDPART_SIZ_FULL,
167 .offset = MTDPART_OFS_APPEND,
171 static struct flash_platform_data bfin_spi_flash_data = {
173 .parts = bfin_spi_flash_partitions,
174 .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
178 /* SPI flash chip (m25p64) */
179 static struct bfin5xx_spi_chip spi_flash_chip_info = {
180 .enable_dma = 0, /* use dma transfer with this chip*/
185 #if defined(CONFIG_BFIN_SPI_ADC) || defined(CONFIG_BFIN_SPI_ADC_MODULE)
187 static struct bfin5xx_spi_chip spi_adc_chip_info = {
188 .enable_dma = 1, /* use dma transfer with this chip*/
193 #if defined(CONFIG_SND_BLACKFIN_AD1836) || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
194 static struct bfin5xx_spi_chip ad1836_spi_chip_info = {
200 #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
201 static struct bfin5xx_spi_chip spidev_chip_info = {
207 #if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
208 #define MMC_SPI_CARD_DETECT_INT IRQ_PF5
209 static int bfin_mmc_spi_init(struct device *dev,
210 irqreturn_t (*detect_int)(int, void *), void *data)
212 return request_irq(MMC_SPI_CARD_DETECT_INT, detect_int,
213 IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING,
214 "mmc-spi-detect", data);
217 static void bfin_mmc_spi_exit(struct device *dev, void *data)
219 free_irq(MMC_SPI_CARD_DETECT_INT, data);
222 static struct mmc_spi_platform_data bfin_mmc_spi_pdata = {
223 .init = bfin_mmc_spi_init,
224 .exit = bfin_mmc_spi_exit,
225 .detect_delay = 100, /* msecs */
228 static struct bfin5xx_spi_chip mmc_spi_chip_info = {
235 static struct spi_board_info bfin_spi_board_info[] __initdata = {
236 #if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE)
238 /* the modalias must be the same as spi device driver name */
239 .modalias = "m25p80", /* Name of spi_driver for this device */
240 .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
241 .bus_num = 0, /* Framework bus number */
242 .chip_select = 2, /* Framework chip select. On STAMP537 it is SPISSEL2*/
243 .platform_data = &bfin_spi_flash_data,
244 .controller_data = &spi_flash_chip_info,
249 #if defined(CONFIG_BFIN_SPI_ADC) || defined(CONFIG_BFIN_SPI_ADC_MODULE)
251 .modalias = "bfin_spi_adc", /* Name of spi_driver for this device */
252 .max_speed_hz = 6250000, /* max spi clock (SCK) speed in HZ */
253 .bus_num = 0, /* Framework bus number */
254 .chip_select = 1, /* Framework chip select. */
255 .platform_data = NULL, /* No spi_driver specific config */
256 .controller_data = &spi_adc_chip_info,
260 #if defined(CONFIG_SND_BLACKFIN_AD1836) || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
262 .modalias = "ad1836",
263 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
265 .chip_select = CONFIG_SND_BLACKFIN_SPI_PFBIT,
266 .controller_data = &ad1836_spi_chip_info,
270 #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
272 .modalias = "spidev",
273 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
276 .controller_data = &spidev_chip_info,
279 #if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
281 .modalias = "mmc_spi",
282 .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */
285 .platform_data = &bfin_mmc_spi_pdata,
286 .controller_data = &mmc_spi_chip_info,
292 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
294 static struct resource bfin_spi0_resource[] = {
296 .start = SPI0_REGBASE,
297 .end = SPI0_REGBASE + 0xFF,
298 .flags = IORESOURCE_MEM,
303 .flags = IORESOURCE_DMA,
308 .flags = IORESOURCE_IRQ,
312 /* SPI controller data */
313 static struct bfin5xx_spi_master bfin_spi0_info = {
315 .enable_dma = 1, /* master has the ability to do dma transfer */
316 .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
319 static struct platform_device bfin_spi0_device = {
321 .id = 0, /* Bus number */
322 .num_resources = ARRAY_SIZE(bfin_spi0_resource),
323 .resource = bfin_spi0_resource,
325 .platform_data = &bfin_spi0_info, /* Passed to driver */
328 #endif /* spi master and devices */
330 #if defined(CONFIG_FB_BF537_LQ035) || defined(CONFIG_FB_BF537_LQ035_MODULE)
331 static struct platform_device bfin_fb_device = {
336 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
337 static struct resource bfin_uart_resources[] = {
341 .flags = IORESOURCE_MEM,
345 static struct platform_device bfin_uart_device = {
348 .num_resources = ARRAY_SIZE(bfin_uart_resources),
349 .resource = bfin_uart_resources,
353 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
354 #ifdef CONFIG_BFIN_SIR0
355 static struct resource bfin_sir0_resources[] = {
359 .flags = IORESOURCE_MEM,
362 .start = IRQ_UART0_RX,
363 .end = IRQ_UART0_RX+1,
364 .flags = IORESOURCE_IRQ,
367 .start = CH_UART0_RX,
368 .end = CH_UART0_RX+1,
369 .flags = IORESOURCE_DMA,
373 static struct platform_device bfin_sir0_device = {
376 .num_resources = ARRAY_SIZE(bfin_sir0_resources),
377 .resource = bfin_sir0_resources,
382 #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
383 static struct platform_device bfin_sport0_uart_device = {
384 .name = "bfin-sport-uart",
388 static struct platform_device bfin_sport1_uart_device = {
389 .name = "bfin-sport-uart",
394 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
395 #include <linux/input.h>
396 #include <linux/gpio_keys.h>
398 static struct gpio_keys_button bfin_gpio_keys_table[] = {
399 {BTN_0, GPIO_PF5, 0, "gpio-keys: BTN0"},
400 {BTN_1, GPIO_PF6, 0, "gpio-keys: BTN1"},
401 {BTN_2, GPIO_PF8, 0, "gpio-keys: BTN2"},
404 static struct gpio_keys_platform_data bfin_gpio_keys_data = {
405 .buttons = bfin_gpio_keys_table,
406 .nbuttons = ARRAY_SIZE(bfin_gpio_keys_table),
409 static struct platform_device bfin_device_gpiokeys = {
412 .platform_data = &bfin_gpio_keys_data,
417 static struct resource bfin_gpios_resources = {
419 .end = MAX_BLACKFIN_GPIOS - 1,
420 .flags = IORESOURCE_IRQ,
423 static struct platform_device bfin_gpios_device = {
424 .name = "simple-gpio",
427 .resource = &bfin_gpios_resources,
430 #if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
431 #include <linux/i2c-gpio.h>
433 static struct i2c_gpio_platform_data i2c_gpio_data = {
436 .sda_is_open_drain = 0,
437 .scl_is_open_drain = 0,
441 static struct platform_device i2c_gpio_device = {
445 .platform_data = &i2c_gpio_data,
450 static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
451 #if defined(CONFIG_JOYSTICK_AD7142) || defined(CONFIG_JOYSTICK_AD7142_MODULE)
453 I2C_BOARD_INFO("ad7142_joystick", 0x2C),
457 #if defined(CONFIG_BFIN_TWI_LCD) || defined(CONFIG_BFIN_TWI_LCD_MODULE)
459 I2C_BOARD_INFO("pcf8574_lcd", 0x22),
462 #if defined(CONFIG_INPUT_PCF8574) || defined(CONFIG_INPUT_PCF8574_MODULE)
464 I2C_BOARD_INFO("pcf8574_keypad", 0x27),
470 static const unsigned int cclk_vlev_datasheet[] =
472 VRPAIR(VLEV_085, 250000000),
473 VRPAIR(VLEV_090, 376000000),
474 VRPAIR(VLEV_095, 426000000),
475 VRPAIR(VLEV_100, 426000000),
476 VRPAIR(VLEV_105, 476000000),
477 VRPAIR(VLEV_110, 476000000),
478 VRPAIR(VLEV_115, 476000000),
479 VRPAIR(VLEV_120, 600000000),
480 VRPAIR(VLEV_125, 600000000),
481 VRPAIR(VLEV_130, 600000000),
484 static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
485 .tuple_tab = cclk_vlev_datasheet,
486 .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
487 .vr_settling_time = 25 /* us */,
490 static struct platform_device bfin_dpmc = {
493 .platform_data = &bfin_dmpc_vreg_data,
497 static struct platform_device *stamp_devices[] __initdata = {
501 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
505 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
509 #if defined(CONFIG_FB_BFIN_7393) || defined(CONFIG_FB_BFIN_7393_MODULE)
510 &bfin_fb_adv7393_device,
513 #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
514 &net2272_bfin_device,
517 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
521 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
525 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
526 #ifdef CONFIG_BFIN_SIR0
531 #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
532 &bfin_sport0_uart_device,
533 &bfin_sport1_uart_device,
536 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
537 &bfin_device_gpiokeys,
540 #if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
546 #if defined(CONFIG_MTD_BFIN_ASYNC) || defined(CONFIG_MTD_BFIN_ASYNC_MODULE)
551 static int __init stamp_init(void)
555 printk(KERN_INFO "%s(): registering device resources\n", __func__);
557 i2c_register_board_info(0, bfin_i2c_board_info,
558 ARRAY_SIZE(bfin_i2c_board_info));
560 ret = platform_add_devices(stamp_devices, ARRAY_SIZE(stamp_devices));
564 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
565 /* setup BF533_STAMP CPLD to route AMS3 to Ethernet MAC */
566 bfin_write_FIO_DIR(bfin_read_FIO_DIR() | PF0);
567 bfin_write_FIO_FLAG_S(PF0);
571 spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
575 arch_initcall(stamp_init);
577 void native_machine_restart(char *cmd)
579 /* workaround pull up on cpld / flash pin not being strong enough */
580 bfin_write_FIO_INEN(~PF0);
581 bfin_write_FIO_DIR(PF0);
582 bfin_write_FIO_FLAG_C(PF0);