Path: blob/master/arch/blackfin/mach-bf533/boards/ezkit.c
15126 views
/*1* Copyright 2004-2009 Analog Devices Inc.2* 2005 National ICT Australia (NICTA)3* Aidan Williams <[email protected]>4*5* Licensed under the GPL-2 or later.6*/78#include <linux/device.h>9#include <linux/platform_device.h>10#include <linux/mtd/mtd.h>11#include <linux/mtd/partitions.h>12#include <linux/mtd/plat-ram.h>13#include <linux/mtd/physmap.h>14#include <linux/spi/spi.h>15#include <linux/spi/flash.h>16#if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)17#include <linux/usb/isp1362.h>18#endif19#include <linux/irq.h>20#include <linux/i2c.h>21#include <asm/dma.h>22#include <asm/bfin5xx_spi.h>23#include <asm/portmux.h>24#include <asm/dpmc.h>2526/*27* Name the Board for the /proc/cpuinfo28*/29const char bfin_board_name[] = "ADI BF533-EZKIT";3031#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)32static struct platform_device rtc_device = {33.name = "rtc-bfin",34.id = -1,35};36#endif3738/*39* USB-LAN EzExtender board40* Driver needs to know address, irq and flag pin.41*/42#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)43#include <linux/smc91x.h>4445static struct smc91x_platdata smc91x_info = {46.flags = SMC91X_USE_16BIT | SMC91X_NOWAIT,47.leda = RPC_LED_100_10,48.ledb = RPC_LED_TX_RX,49};5051static struct resource smc91x_resources[] = {52{53.name = "smc91x-regs",54.start = 0x20310300,55.end = 0x20310300 + 16,56.flags = IORESOURCE_MEM,57}, {58.start = IRQ_PF9,59.end = IRQ_PF9,60.flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,61},62};63static struct platform_device smc91x_device = {64.name = "smc91x",65.id = 0,66.num_resources = ARRAY_SIZE(smc91x_resources),67.resource = smc91x_resources,68.dev = {69.platform_data = &smc91x_info,70},71};72#endif7374#if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)75static struct mtd_partition ezkit_partitions_a[] = {76{77.name = "bootloader(nor a)",78.size = 0x40000,79.offset = 0,80}, {81.name = "linux kernel(nor a)",82.size = MTDPART_SIZ_FULL,83.offset = MTDPART_OFS_APPEND,84},85};8687static struct physmap_flash_data ezkit_flash_data_a = {88.width = 2,89.parts = ezkit_partitions_a,90.nr_parts = ARRAY_SIZE(ezkit_partitions_a),91};9293static struct resource ezkit_flash_resource_a = {94.start = 0x20000000,95.end = 0x200fffff,96.flags = IORESOURCE_MEM,97};9899static struct platform_device ezkit_flash_device_a = {100.name = "physmap-flash",101.id = 0,102.dev = {103.platform_data = &ezkit_flash_data_a,104},105.num_resources = 1,106.resource = &ezkit_flash_resource_a,107};108109static struct mtd_partition ezkit_partitions_b[] = {110{111.name = "file system(nor b)",112.size = MTDPART_SIZ_FULL,113.offset = MTDPART_OFS_APPEND,114},115};116117static struct physmap_flash_data ezkit_flash_data_b = {118.width = 2,119.parts = ezkit_partitions_b,120.nr_parts = ARRAY_SIZE(ezkit_partitions_b),121};122123static struct resource ezkit_flash_resource_b = {124.start = 0x20100000,125.end = 0x201fffff,126.flags = IORESOURCE_MEM,127};128129static struct platform_device ezkit_flash_device_b = {130.name = "physmap-flash",131.id = 4,132.dev = {133.platform_data = &ezkit_flash_data_b,134},135.num_resources = 1,136.resource = &ezkit_flash_resource_b,137};138#endif139140#if defined(CONFIG_MTD_PLATRAM) || defined(CONFIG_MTD_PLATRAM_MODULE)141static struct platdata_mtd_ram sram_data_a = {142.mapname = "Flash A SRAM",143.bankwidth = 2,144};145146static struct resource sram_resource_a = {147.start = 0x20240000,148.end = 0x2024ffff,149.flags = IORESOURCE_MEM,150};151152static struct platform_device sram_device_a = {153.name = "mtd-ram",154.id = 8,155.dev = {156.platform_data = &sram_data_a,157},158.num_resources = 1,159.resource = &sram_resource_a,160};161162static struct platdata_mtd_ram sram_data_b = {163.mapname = "Flash B SRAM",164.bankwidth = 2,165};166167static struct resource sram_resource_b = {168.start = 0x202c0000,169.end = 0x202cffff,170.flags = IORESOURCE_MEM,171};172173static struct platform_device sram_device_b = {174.name = "mtd-ram",175.id = 9,176.dev = {177.platform_data = &sram_data_b,178},179.num_resources = 1,180.resource = &sram_resource_b,181};182#endif183184#if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE)185static struct mtd_partition bfin_spi_flash_partitions[] = {186{187.name = "bootloader(spi)",188.size = 0x00020000,189.offset = 0,190.mask_flags = MTD_CAP_ROM191}, {192.name = "linux kernel(spi)",193.size = 0xe0000,194.offset = MTDPART_OFS_APPEND,195}, {196.name = "file system(spi)",197.size = MTDPART_SIZ_FULL,198.offset = MTDPART_OFS_APPEND,199}200};201202static struct flash_platform_data bfin_spi_flash_data = {203.name = "m25p80",204.parts = bfin_spi_flash_partitions,205.nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),206.type = "m25p64",207};208209/* SPI flash chip (m25p64) */210static struct bfin5xx_spi_chip spi_flash_chip_info = {211.enable_dma = 0, /* use dma transfer with this chip*/212.bits_per_word = 8,213};214#endif215216#if defined(CONFIG_BFIN_SPI_ADC) || defined(CONFIG_BFIN_SPI_ADC_MODULE)217/* SPI ADC chip */218static struct bfin5xx_spi_chip spi_adc_chip_info = {219.enable_dma = 1, /* use dma transfer with this chip*/220.bits_per_word = 16,221};222#endif223224#if defined(CONFIG_SND_BF5XX_SOC_AD183X) || defined(CONFIG_SND_BF5XX_SOC_AD183X_MODULE)225static struct bfin5xx_spi_chip ad1836_spi_chip_info = {226.enable_dma = 0,227.bits_per_word = 16,228};229#endif230231#if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)232static struct bfin5xx_spi_chip spidev_chip_info = {233.enable_dma = 0,234.bits_per_word = 8,235};236#endif237238static struct spi_board_info bfin_spi_board_info[] __initdata = {239#if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE)240{241/* the modalias must be the same as spi device driver name */242.modalias = "m25p80", /* Name of spi_driver for this device */243.max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */244.bus_num = 0, /* Framework bus number */245.chip_select = 2, /* Framework chip select. On STAMP537 it is SPISSEL2*/246.platform_data = &bfin_spi_flash_data,247.controller_data = &spi_flash_chip_info,248.mode = SPI_MODE_3,249},250#endif251252#if defined(CONFIG_BFIN_SPI_ADC) || defined(CONFIG_BFIN_SPI_ADC_MODULE)253{254.modalias = "bfin_spi_adc", /* Name of spi_driver for this device */255.max_speed_hz = 6250000, /* max spi clock (SCK) speed in HZ */256.bus_num = 0, /* Framework bus number */257.chip_select = 1, /* Framework chip select. */258.platform_data = NULL, /* No spi_driver specific config */259.controller_data = &spi_adc_chip_info,260},261#endif262263#if defined(CONFIG_SND_BF5XX_SOC_AD183X) || defined(CONFIG_SND_BF5XX_SOC_AD183X_MODULE)264{265.modalias = "ad183x",266.max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */267.bus_num = 0,268.chip_select = 4,269.controller_data = &ad1836_spi_chip_info,270},271#endif272#if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)273{274.modalias = "spidev",275.max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */276.bus_num = 0,277.chip_select = 1,278.controller_data = &spidev_chip_info,279},280#endif281};282283#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)284/* SPI (0) */285static struct resource bfin_spi0_resource[] = {286[0] = {287.start = SPI0_REGBASE,288.end = SPI0_REGBASE + 0xFF,289.flags = IORESOURCE_MEM,290},291[1] = {292.start = CH_SPI,293.end = CH_SPI,294.flags = IORESOURCE_DMA,295},296[2] = {297.start = IRQ_SPI,298.end = IRQ_SPI,299.flags = IORESOURCE_IRQ,300}301};302303/* SPI controller data */304static struct bfin5xx_spi_master bfin_spi0_info = {305.num_chipselect = 8,306.enable_dma = 1, /* master has the ability to do dma transfer */307.pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},308};309310static struct platform_device bfin_spi0_device = {311.name = "bfin-spi",312.id = 0, /* Bus number */313.num_resources = ARRAY_SIZE(bfin_spi0_resource),314.resource = bfin_spi0_resource,315.dev = {316.platform_data = &bfin_spi0_info, /* Passed to driver */317},318};319#endif /* spi master and devices */320321#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)322#ifdef CONFIG_SERIAL_BFIN_UART0323static struct resource bfin_uart0_resources[] = {324{325.start = BFIN_UART_THR,326.end = BFIN_UART_GCTL+2,327.flags = IORESOURCE_MEM,328},329{330.start = IRQ_UART0_RX,331.end = IRQ_UART0_RX + 1,332.flags = IORESOURCE_IRQ,333},334{335.start = IRQ_UART0_ERROR,336.end = IRQ_UART0_ERROR,337.flags = IORESOURCE_IRQ,338},339{340.start = CH_UART0_TX,341.end = CH_UART0_TX,342.flags = IORESOURCE_DMA,343},344{345.start = CH_UART0_RX,346.end = CH_UART0_RX,347.flags = IORESOURCE_DMA,348},349};350351static unsigned short bfin_uart0_peripherals[] = {352P_UART0_TX, P_UART0_RX, 0353};354355static struct platform_device bfin_uart0_device = {356.name = "bfin-uart",357.id = 0,358.num_resources = ARRAY_SIZE(bfin_uart0_resources),359.resource = bfin_uart0_resources,360.dev = {361.platform_data = &bfin_uart0_peripherals, /* Passed to driver */362},363};364#endif365#endif366367#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)368#ifdef CONFIG_BFIN_SIR0369static struct resource bfin_sir0_resources[] = {370{371.start = 0xFFC00400,372.end = 0xFFC004FF,373.flags = IORESOURCE_MEM,374},375{376.start = IRQ_UART0_RX,377.end = IRQ_UART0_RX+1,378.flags = IORESOURCE_IRQ,379},380{381.start = CH_UART0_RX,382.end = CH_UART0_RX+1,383.flags = IORESOURCE_DMA,384},385};386387static struct platform_device bfin_sir0_device = {388.name = "bfin_sir",389.id = 0,390.num_resources = ARRAY_SIZE(bfin_sir0_resources),391.resource = bfin_sir0_resources,392};393#endif394#endif395396#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)397#include <linux/input.h>398#include <linux/gpio_keys.h>399400static struct gpio_keys_button bfin_gpio_keys_table[] = {401{BTN_0, GPIO_PF7, 1, "gpio-keys: BTN0"},402{BTN_1, GPIO_PF8, 1, "gpio-keys: BTN1"},403{BTN_2, GPIO_PF9, 1, "gpio-keys: BTN2"},404{BTN_3, GPIO_PF10, 1, "gpio-keys: BTN3"},405};406407static struct gpio_keys_platform_data bfin_gpio_keys_data = {408.buttons = bfin_gpio_keys_table,409.nbuttons = ARRAY_SIZE(bfin_gpio_keys_table),410};411412static struct platform_device bfin_device_gpiokeys = {413.name = "gpio-keys",414.dev = {415.platform_data = &bfin_gpio_keys_data,416},417};418#endif419420#if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)421#include <linux/i2c-gpio.h>422423static struct i2c_gpio_platform_data i2c_gpio_data = {424.sda_pin = GPIO_PF1,425.scl_pin = GPIO_PF0,426.sda_is_open_drain = 0,427.scl_is_open_drain = 0,428.udelay = 40,429};430431static struct platform_device i2c_gpio_device = {432.name = "i2c-gpio",433.id = 0,434.dev = {435.platform_data = &i2c_gpio_data,436},437};438#endif439440static const unsigned int cclk_vlev_datasheet[] =441{442VRPAIR(VLEV_085, 250000000),443VRPAIR(VLEV_090, 376000000),444VRPAIR(VLEV_095, 426000000),445VRPAIR(VLEV_100, 426000000),446VRPAIR(VLEV_105, 476000000),447VRPAIR(VLEV_110, 476000000),448VRPAIR(VLEV_115, 476000000),449VRPAIR(VLEV_120, 600000000),450VRPAIR(VLEV_125, 600000000),451VRPAIR(VLEV_130, 600000000),452};453454static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {455.tuple_tab = cclk_vlev_datasheet,456.tabsize = ARRAY_SIZE(cclk_vlev_datasheet),457.vr_settling_time = 25 /* us */,458};459460static struct platform_device bfin_dpmc = {461.name = "bfin dpmc",462.dev = {463.platform_data = &bfin_dmpc_vreg_data,464},465};466467static struct i2c_board_info __initdata bfin_i2c_board_info[] = {468#if defined(CONFIG_FB_BFIN_7393) || defined(CONFIG_FB_BFIN_7393_MODULE)469{470I2C_BOARD_INFO("bfin-adv7393", 0x2B),471},472#endif473};474475#if defined(CONFIG_SND_BF5XX_I2S) || defined(CONFIG_SND_BF5XX_I2S_MODULE)476static struct platform_device bfin_i2s = {477.name = "bfin-i2s",478.id = CONFIG_SND_BF5XX_SPORT_NUM,479/* TODO: add platform data here */480};481#endif482483#if defined(CONFIG_SND_BF5XX_TDM) || defined(CONFIG_SND_BF5XX_TDM_MODULE)484static struct platform_device bfin_tdm = {485.name = "bfin-tdm",486.id = CONFIG_SND_BF5XX_SPORT_NUM,487/* TODO: add platform data here */488};489#endif490491#if defined(CONFIG_SND_BF5XX_AC97) || defined(CONFIG_SND_BF5XX_AC97_MODULE)492static struct platform_device bfin_ac97 = {493.name = "bfin-ac97",494.id = CONFIG_SND_BF5XX_SPORT_NUM,495/* TODO: add platform data here */496};497#endif498499static struct platform_device *ezkit_devices[] __initdata = {500501&bfin_dpmc,502503#if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)504&ezkit_flash_device_a,505&ezkit_flash_device_b,506#endif507508#if defined(CONFIG_MTD_PLATRAM) || defined(CONFIG_MTD_PLATRAM_MODULE)509&sram_device_a,510&sram_device_b,511#endif512513#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)514&smc91x_device,515#endif516517#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)518&bfin_spi0_device,519#endif520521#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)522&rtc_device,523#endif524525#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)526#ifdef CONFIG_SERIAL_BFIN_UART0527&bfin_uart0_device,528#endif529#endif530531#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)532#ifdef CONFIG_BFIN_SIR0533&bfin_sir0_device,534#endif535#endif536537#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)538&bfin_device_gpiokeys,539#endif540541#if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)542&i2c_gpio_device,543#endif544545#if defined(CONFIG_SND_BF5XX_I2S) || defined(CONFIG_SND_BF5XX_I2S_MODULE)546&bfin_i2s,547#endif548549#if defined(CONFIG_SND_BF5XX_TDM) || defined(CONFIG_SND_BF5XX_TDM_MODULE)550&bfin_tdm,551#endif552553#if defined(CONFIG_SND_BF5XX_AC97) || defined(CONFIG_SND_BF5XX_AC97_MODULE)554&bfin_ac97,555#endif556};557558static int __init ezkit_init(void)559{560printk(KERN_INFO "%s(): registering device resources\n", __func__);561platform_add_devices(ezkit_devices, ARRAY_SIZE(ezkit_devices));562spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));563i2c_register_board_info(0, bfin_i2c_board_info,564ARRAY_SIZE(bfin_i2c_board_info));565return 0;566}567568arch_initcall(ezkit_init);569570static struct platform_device *ezkit_early_devices[] __initdata = {571#if defined(CONFIG_SERIAL_BFIN_CONSOLE) || defined(CONFIG_EARLY_PRINTK)572#ifdef CONFIG_SERIAL_BFIN_UART0573&bfin_uart0_device,574#endif575#endif576};577578void __init native_machine_early_platform_add_devices(void)579{580printk(KERN_INFO "register early platform devices\n");581early_platform_add_devices(ezkit_early_devices,582ARRAY_SIZE(ezkit_early_devices));583}584585586