Path: blob/master/arch/blackfin/mach-bf533/boards/blackstamp.c
15126 views
/*1* Board Info File for the BlackStamp2*3* Copyright 2004-2008 Analog Devices Inc.4* 2008 Benjamin Matthews <[email protected]>5* 2005 National ICT Australia (NICTA)6* Aidan Williams <[email protected]>7*8* More info about the BlackStamp at:9* http://blackfin.uclinux.org/gf/project/blackstamp/10*11* Licensed under the GPL-2 or later.12*/1314#include <linux/device.h>15#include <linux/platform_device.h>16#include <linux/mtd/mtd.h>17#include <linux/mtd/partitions.h>18#include <linux/mtd/physmap.h>19#include <linux/spi/spi.h>20#include <linux/spi/flash.h>21#include <linux/irq.h>22#include <linux/i2c.h>23#include <asm/dma.h>24#include <asm/bfin5xx_spi.h>25#include <asm/portmux.h>26#include <asm/dpmc.h>2728/*29* Name the Board for the /proc/cpuinfo30*/31const char bfin_board_name[] = "BlackStamp";3233#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)34static struct platform_device rtc_device = {35.name = "rtc-bfin",36.id = -1,37};38#endif3940/*41* Driver needs to know address, irq and flag pin.42*/43#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)44#include <linux/smc91x.h>4546static struct smc91x_platdata smc91x_info = {47.flags = SMC91X_USE_16BIT | SMC91X_NOWAIT,48.leda = RPC_LED_100_10,49.ledb = RPC_LED_TX_RX,50};5152static struct resource smc91x_resources[] = {53{54.name = "smc91x-regs",55.start = 0x20300300,56.end = 0x20300300 + 16,57.flags = IORESOURCE_MEM,58}, {59.start = IRQ_PF3,60.end = IRQ_PF3,61.flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,62},63};6465static struct platform_device smc91x_device = {66.name = "smc91x",67.id = 0,68.num_resources = ARRAY_SIZE(smc91x_resources),69.resource = smc91x_resources,70.dev = {71.platform_data = &smc91x_info,72},73};74#endif7576#if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE)77static struct mtd_partition bfin_spi_flash_partitions[] = {78{79.name = "bootloader(spi)",80.size = 0x00040000,81.offset = 0,82.mask_flags = MTD_CAP_ROM83}, {84.name = "linux kernel(spi)",85.size = 0x180000,86.offset = MTDPART_OFS_APPEND,87}, {88.name = "file system(spi)",89.size = MTDPART_SIZ_FULL,90.offset = MTDPART_OFS_APPEND,91}92};9394static struct flash_platform_data bfin_spi_flash_data = {95.name = "m25p80",96.parts = bfin_spi_flash_partitions,97.nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),98.type = "m25p64",99};100101/* SPI flash chip (m25p64) */102static struct bfin5xx_spi_chip spi_flash_chip_info = {103.enable_dma = 0, /* use dma transfer with this chip*/104.bits_per_word = 8,105};106#endif107108#if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)109static struct bfin5xx_spi_chip mmc_spi_chip_info = {110.enable_dma = 0,111.bits_per_word = 8,112};113#endif114115#if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)116static struct bfin5xx_spi_chip spidev_chip_info = {117.enable_dma = 0,118.bits_per_word = 8,119};120#endif121122static struct spi_board_info bfin_spi_board_info[] __initdata = {123#if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE)124{125/* the modalias must be the same as spi device driver name */126.modalias = "m25p80", /* Name of spi_driver for this device */127.max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */128.bus_num = 0, /* Framework bus number */129.chip_select = 2, /* Framework chip select. */130.platform_data = &bfin_spi_flash_data,131.controller_data = &spi_flash_chip_info,132.mode = SPI_MODE_3,133},134#endif135136#if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)137{138.modalias = "mmc_spi",139.max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */140.bus_num = 0,141.chip_select = 5,142.controller_data = &mmc_spi_chip_info,143.mode = SPI_MODE_3,144},145#endif146147#if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)148{149.modalias = "spidev",150.max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */151.bus_num = 0,152.chip_select = 7,153.controller_data = &spidev_chip_info,154},155#endif156};157158#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)159/* SPI (0) */160static struct resource bfin_spi0_resource[] = {161[0] = {162.start = SPI0_REGBASE,163.end = SPI0_REGBASE + 0xFF,164.flags = IORESOURCE_MEM,165},166[1] = {167.start = CH_SPI,168.end = CH_SPI,169.flags = IORESOURCE_DMA,170},171[2] = {172.start = IRQ_SPI,173.end = IRQ_SPI,174.flags = IORESOURCE_IRQ,175}176};177178/* SPI controller data */179static struct bfin5xx_spi_master bfin_spi0_info = {180.num_chipselect = 8,181.enable_dma = 1, /* master has the ability to do dma transfer */182.pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},183};184185static struct platform_device bfin_spi0_device = {186.name = "bfin-spi",187.id = 0, /* Bus number */188.num_resources = ARRAY_SIZE(bfin_spi0_resource),189.resource = bfin_spi0_resource,190.dev = {191.platform_data = &bfin_spi0_info, /* Passed to driver */192},193};194#endif /* spi master and devices */195196#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)197#ifdef CONFIG_SERIAL_BFIN_UART0198static struct resource bfin_uart0_resources[] = {199{200.start = BFIN_UART_THR,201.end = BFIN_UART_GCTL+2,202.flags = IORESOURCE_MEM,203},204{205.start = IRQ_UART0_RX,206.end = IRQ_UART0_RX + 1,207.flags = IORESOURCE_IRQ,208},209{210.start = IRQ_UART0_ERROR,211.end = IRQ_UART0_ERROR,212.flags = IORESOURCE_IRQ,213},214{215.start = CH_UART0_TX,216.end = CH_UART0_TX,217.flags = IORESOURCE_DMA,218},219{220.start = CH_UART0_RX,221.end = CH_UART0_RX,222.flags = IORESOURCE_DMA,223},224};225226static unsigned short bfin_uart0_peripherals[] = {227P_UART0_TX, P_UART0_RX, 0228};229230static struct platform_device bfin_uart0_device = {231.name = "bfin-uart",232.id = 0,233.num_resources = ARRAY_SIZE(bfin_uart0_resources),234.resource = bfin_uart0_resources,235.dev = {236.platform_data = &bfin_uart0_peripherals, /* Passed to driver */237},238};239#endif240#endif241242#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)243#ifdef CONFIG_BFIN_SIR0244static struct resource bfin_sir0_resources[] = {245{246.start = 0xFFC00400,247.end = 0xFFC004FF,248.flags = IORESOURCE_MEM,249},250{251.start = IRQ_UART0_RX,252.end = IRQ_UART0_RX+1,253.flags = IORESOURCE_IRQ,254},255{256.start = CH_UART0_RX,257.end = CH_UART0_RX+1,258.flags = IORESOURCE_DMA,259},260};261262static struct platform_device bfin_sir0_device = {263.name = "bfin_sir",264.id = 0,265.num_resources = ARRAY_SIZE(bfin_sir0_resources),266.resource = bfin_sir0_resources,267};268#endif269#endif270271#if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)272#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART273static struct resource bfin_sport0_uart_resources[] = {274{275.start = SPORT0_TCR1,276.end = SPORT0_MRCS3+4,277.flags = IORESOURCE_MEM,278},279{280.start = IRQ_SPORT0_RX,281.end = IRQ_SPORT0_RX+1,282.flags = IORESOURCE_IRQ,283},284{285.start = IRQ_SPORT0_ERROR,286.end = IRQ_SPORT0_ERROR,287.flags = IORESOURCE_IRQ,288},289};290291static unsigned short bfin_sport0_peripherals[] = {292P_SPORT0_TFS, P_SPORT0_DTPRI, P_SPORT0_TSCLK, P_SPORT0_RFS,293P_SPORT0_DRPRI, P_SPORT0_RSCLK, 0294};295296static struct platform_device bfin_sport0_uart_device = {297.name = "bfin-sport-uart",298.id = 0,299.num_resources = ARRAY_SIZE(bfin_sport0_uart_resources),300.resource = bfin_sport0_uart_resources,301.dev = {302.platform_data = &bfin_sport0_peripherals, /* Passed to driver */303},304};305#endif306#ifdef CONFIG_SERIAL_BFIN_SPORT1_UART307static struct resource bfin_sport1_uart_resources[] = {308{309.start = SPORT1_TCR1,310.end = SPORT1_MRCS3+4,311.flags = IORESOURCE_MEM,312},313{314.start = IRQ_SPORT1_RX,315.end = IRQ_SPORT1_RX+1,316.flags = IORESOURCE_IRQ,317},318{319.start = IRQ_SPORT1_ERROR,320.end = IRQ_SPORT1_ERROR,321.flags = IORESOURCE_IRQ,322},323};324325static unsigned short bfin_sport1_peripherals[] = {326P_SPORT1_TFS, P_SPORT1_DTPRI, P_SPORT1_TSCLK, P_SPORT1_RFS,327P_SPORT1_DRPRI, P_SPORT1_RSCLK, 0328};329330static struct platform_device bfin_sport1_uart_device = {331.name = "bfin-sport-uart",332.id = 1,333.num_resources = ARRAY_SIZE(bfin_sport1_uart_resources),334.resource = bfin_sport1_uart_resources,335.dev = {336.platform_data = &bfin_sport1_peripherals, /* Passed to driver */337},338};339#endif340#endif341342#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)343#include <linux/input.h>344#include <linux/gpio_keys.h>345346static struct gpio_keys_button bfin_gpio_keys_table[] = {347{BTN_0, GPIO_PF4, 0, "gpio-keys: BTN0"},348{BTN_1, GPIO_PF5, 0, "gpio-keys: BTN1"},349{BTN_2, GPIO_PF6, 0, "gpio-keys: BTN2"},350}; /* Mapped to the first three PF Test Points */351352static struct gpio_keys_platform_data bfin_gpio_keys_data = {353.buttons = bfin_gpio_keys_table,354.nbuttons = ARRAY_SIZE(bfin_gpio_keys_table),355};356357static struct platform_device bfin_device_gpiokeys = {358.name = "gpio-keys",359.dev = {360.platform_data = &bfin_gpio_keys_data,361},362};363#endif364365#if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)366#include <linux/i2c-gpio.h>367368static struct i2c_gpio_platform_data i2c_gpio_data = {369.sda_pin = GPIO_PF8,370.scl_pin = GPIO_PF9,371.sda_is_open_drain = 0,372.scl_is_open_drain = 0,373.udelay = 40,374}; /* This hasn't actually been used these pins375* are (currently) free pins on the expansion connector */376377static struct platform_device i2c_gpio_device = {378.name = "i2c-gpio",379.id = 0,380.dev = {381.platform_data = &i2c_gpio_data,382},383};384#endif385386static struct i2c_board_info __initdata bfin_i2c_board_info[] = {387};388389static const unsigned int cclk_vlev_datasheet[] =390{391VRPAIR(VLEV_085, 250000000),392VRPAIR(VLEV_090, 376000000),393VRPAIR(VLEV_095, 426000000),394VRPAIR(VLEV_100, 426000000),395VRPAIR(VLEV_105, 476000000),396VRPAIR(VLEV_110, 476000000),397VRPAIR(VLEV_115, 476000000),398VRPAIR(VLEV_120, 600000000),399VRPAIR(VLEV_125, 600000000),400VRPAIR(VLEV_130, 600000000),401};402403static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {404.tuple_tab = cclk_vlev_datasheet,405.tabsize = ARRAY_SIZE(cclk_vlev_datasheet),406.vr_settling_time = 25 /* us */,407};408409static struct platform_device bfin_dpmc = {410.name = "bfin dpmc",411.dev = {412.platform_data = &bfin_dmpc_vreg_data,413},414};415416static struct platform_device *stamp_devices[] __initdata = {417418&bfin_dpmc,419420#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)421&rtc_device,422#endif423424#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)425&smc91x_device,426#endif427428429#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)430&bfin_spi0_device,431#endif432433#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)434#ifdef CONFIG_SERIAL_BFIN_UART0435&bfin_uart0_device,436#endif437#endif438439#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)440#ifdef CONFIG_BFIN_SIR0441&bfin_sir0_device,442#endif443#endif444445#if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)446#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART447&bfin_sport0_uart_device,448#endif449#ifdef CONFIG_SERIAL_BFIN_SPORT1_UART450&bfin_sport1_uart_device,451#endif452#endif453454#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)455&bfin_device_gpiokeys,456#endif457458#if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)459&i2c_gpio_device,460#endif461};462463static int __init blackstamp_init(void)464{465int ret;466467printk(KERN_INFO "%s(): registering device resources\n", __func__);468469i2c_register_board_info(0, bfin_i2c_board_info,470ARRAY_SIZE(bfin_i2c_board_info));471472ret = platform_add_devices(stamp_devices, ARRAY_SIZE(stamp_devices));473if (ret < 0)474return ret;475476#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)477/*478* setup BF533_STAMP CPLD to route AMS3 to Ethernet MAC.479* the bfin-async-map driver takes care of flipping between480* flash and ethernet when necessary.481*/482ret = gpio_request(GPIO_PF0, "enet_cpld");483if (!ret) {484gpio_direction_output(GPIO_PF0, 1);485gpio_free(GPIO_PF0);486}487#endif488489spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));490return 0;491}492493arch_initcall(blackstamp_init);494495static struct platform_device *stamp_early_devices[] __initdata = {496#if defined(CONFIG_SERIAL_BFIN_CONSOLE) || defined(CONFIG_EARLY_PRINTK)497#ifdef CONFIG_SERIAL_BFIN_UART0498&bfin_uart0_device,499#endif500#endif501502#if defined(CONFIG_SERIAL_BFIN_SPORT_CONSOLE)503#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART504&bfin_sport0_uart_device,505#endif506#ifdef CONFIG_SERIAL_BFIN_SPORT1_UART507&bfin_sport1_uart_device,508#endif509#endif510};511512void __init native_machine_early_platform_add_devices(void)513{514printk(KERN_INFO "register early platform devices\n");515early_platform_add_devices(stamp_early_devices,516ARRAY_SIZE(stamp_early_devices));517}518519520