Path: blob/master/arch/blackfin/mach-bf561/boards/ezkit.c
10819 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/physmap.h>13#include <linux/spi/spi.h>14#include <linux/irq.h>15#include <linux/interrupt.h>16#include <linux/delay.h>17#include <asm/dma.h>18#include <asm/bfin5xx_spi.h>19#include <asm/portmux.h>20#include <asm/dpmc.h>2122/*23* Name the Board for the /proc/cpuinfo24*/25const char bfin_board_name[] = "ADI BF561-EZKIT";2627#if defined(CONFIG_USB_ISP1760_HCD) || defined(CONFIG_USB_ISP1760_HCD_MODULE)28#include <linux/usb/isp1760.h>29static struct resource bfin_isp1760_resources[] = {30[0] = {31.start = 0x2C0F0000,32.end = 0x203C0000 + 0xfffff,33.flags = IORESOURCE_MEM,34},35[1] = {36.start = IRQ_PF10,37.end = IRQ_PF10,38.flags = IORESOURCE_IRQ,39},40};4142static struct isp1760_platform_data isp1760_priv = {43.is_isp1761 = 0,44.bus_width_16 = 1,45.port1_otg = 0,46.analog_oc = 0,47.dack_polarity_high = 0,48.dreq_polarity_high = 0,49};5051static struct platform_device bfin_isp1760_device = {52.name = "isp1760",53.id = 0,54.dev = {55.platform_data = &isp1760_priv,56},57.num_resources = ARRAY_SIZE(bfin_isp1760_resources),58.resource = bfin_isp1760_resources,59};60#endif6162#if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)63#include <linux/usb/isp1362.h>6465static struct resource isp1362_hcd_resources[] = {66{67.start = 0x2c060000,68.end = 0x2c060000,69.flags = IORESOURCE_MEM,70}, {71.start = 0x2c060004,72.end = 0x2c060004,73.flags = IORESOURCE_MEM,74}, {75.start = IRQ_PF8,76.end = IRQ_PF8,77.flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWEDGE,78},79};8081static struct isp1362_platform_data isp1362_priv = {82.sel15Kres = 1,83.clknotstop = 0,84.oc_enable = 0,85.int_act_high = 0,86.int_edge_triggered = 0,87.remote_wakeup_connected = 0,88.no_power_switching = 1,89.power_switching_mode = 0,90};9192static struct platform_device isp1362_hcd_device = {93.name = "isp1362-hcd",94.id = 0,95.dev = {96.platform_data = &isp1362_priv,97},98.num_resources = ARRAY_SIZE(isp1362_hcd_resources),99.resource = isp1362_hcd_resources,100};101#endif102103#if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)104static struct resource net2272_bfin_resources[] = {105{106.start = 0x2C000000,107.end = 0x2C000000 + 0x7F,108.flags = IORESOURCE_MEM,109}, {110.start = IRQ_PF10,111.end = IRQ_PF10,112.flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,113},114};115116static struct platform_device net2272_bfin_device = {117.name = "net2272",118.id = -1,119.num_resources = ARRAY_SIZE(net2272_bfin_resources),120.resource = net2272_bfin_resources,121};122#endif123124/*125* USB-LAN EzExtender board126* Driver needs to know address, irq and flag pin.127*/128#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)129#include <linux/smc91x.h>130131static struct smc91x_platdata smc91x_info = {132.flags = SMC91X_USE_32BIT | SMC91X_NOWAIT,133.leda = RPC_LED_100_10,134.ledb = RPC_LED_TX_RX,135};136137static struct resource smc91x_resources[] = {138{139.name = "smc91x-regs",140.start = 0x2C010300,141.end = 0x2C010300 + 16,142.flags = IORESOURCE_MEM,143}, {144145.start = IRQ_PF9,146.end = IRQ_PF9,147.flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,148},149};150151static struct platform_device smc91x_device = {152.name = "smc91x",153.id = 0,154.num_resources = ARRAY_SIZE(smc91x_resources),155.resource = smc91x_resources,156.dev = {157.platform_data = &smc91x_info,158},159};160#endif161162#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)163#ifdef CONFIG_SERIAL_BFIN_UART0164static struct resource bfin_uart0_resources[] = {165{166.start = BFIN_UART_THR,167.end = BFIN_UART_GCTL+2,168.flags = IORESOURCE_MEM,169},170{171.start = IRQ_UART_RX,172.end = IRQ_UART_RX+1,173.flags = IORESOURCE_IRQ,174},175{176.start = IRQ_UART_ERROR,177.end = IRQ_UART_ERROR,178.flags = IORESOURCE_IRQ,179},180{181.start = CH_UART_TX,182.end = CH_UART_TX,183.flags = IORESOURCE_DMA,184},185{186.start = CH_UART_RX,187.end = CH_UART_RX,188.flags = IORESOURCE_DMA,189},190};191192static unsigned short bfin_uart0_peripherals[] = {193P_UART0_TX, P_UART0_RX, 0194};195196static struct platform_device bfin_uart0_device = {197.name = "bfin-uart",198.id = 0,199.num_resources = ARRAY_SIZE(bfin_uart0_resources),200.resource = bfin_uart0_resources,201.dev = {202.platform_data = &bfin_uart0_peripherals, /* Passed to driver */203},204};205#endif206#endif207208#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)209#ifdef CONFIG_BFIN_SIR0210static struct resource bfin_sir0_resources[] = {211{212.start = 0xFFC00400,213.end = 0xFFC004FF,214.flags = IORESOURCE_MEM,215},216{217.start = IRQ_UART0_RX,218.end = IRQ_UART0_RX+1,219.flags = IORESOURCE_IRQ,220},221{222.start = CH_UART0_RX,223.end = CH_UART0_RX+1,224.flags = IORESOURCE_DMA,225},226};227228static struct platform_device bfin_sir0_device = {229.name = "bfin_sir",230.id = 0,231.num_resources = ARRAY_SIZE(bfin_sir0_resources),232.resource = bfin_sir0_resources,233};234#endif235#endif236237#if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)238static struct mtd_partition ezkit_partitions[] = {239{240.name = "bootloader(nor)",241.size = 0x40000,242.offset = 0,243}, {244.name = "linux kernel(nor)",245.size = 0x1C0000,246.offset = MTDPART_OFS_APPEND,247}, {248.name = "file system(nor)",249.size = 0x800000 - 0x40000 - 0x1C0000 - 0x2000 * 8,250.offset = MTDPART_OFS_APPEND,251}, {252.name = "config(nor)",253.size = 0x2000 * 7,254.offset = MTDPART_OFS_APPEND,255}, {256.name = "u-boot env(nor)",257.size = 0x2000,258.offset = MTDPART_OFS_APPEND,259}260};261262static struct physmap_flash_data ezkit_flash_data = {263.width = 2,264.parts = ezkit_partitions,265.nr_parts = ARRAY_SIZE(ezkit_partitions),266};267268static struct resource ezkit_flash_resource = {269.start = 0x20000000,270.end = 0x207fffff,271.flags = IORESOURCE_MEM,272};273274static struct platform_device ezkit_flash_device = {275.name = "physmap-flash",276.id = 0,277.dev = {278.platform_data = &ezkit_flash_data,279},280.num_resources = 1,281.resource = &ezkit_flash_resource,282};283#endif284285#if defined(CONFIG_SND_BF5XX_SOC_AD183X) \286|| defined(CONFIG_SND_BF5XX_SOC_AD183X_MODULE)287static struct bfin5xx_spi_chip ad1836_spi_chip_info = {288.enable_dma = 0,289.bits_per_word = 16,290};291#endif292293#if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)294static struct bfin5xx_spi_chip spidev_chip_info = {295.enable_dma = 0,296.bits_per_word = 8,297};298#endif299300#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)301/* SPI (0) */302static struct resource bfin_spi0_resource[] = {303[0] = {304.start = SPI0_REGBASE,305.end = SPI0_REGBASE + 0xFF,306.flags = IORESOURCE_MEM,307},308[1] = {309.start = CH_SPI,310.end = CH_SPI,311.flags = IORESOURCE_DMA,312},313[2] = {314.start = IRQ_SPI,315.end = IRQ_SPI,316.flags = IORESOURCE_IRQ,317}318};319320/* SPI controller data */321static struct bfin5xx_spi_master bfin_spi0_info = {322.num_chipselect = 8,323.enable_dma = 1, /* master has the ability to do dma transfer */324.pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},325};326327static struct platform_device bfin_spi0_device = {328.name = "bfin-spi",329.id = 0, /* Bus number */330.num_resources = ARRAY_SIZE(bfin_spi0_resource),331.resource = bfin_spi0_resource,332.dev = {333.platform_data = &bfin_spi0_info, /* Passed to driver */334},335};336#endif337338static struct spi_board_info bfin_spi_board_info[] __initdata = {339#if defined(CONFIG_SND_BF5XX_SOC_AD183X) \340|| defined(CONFIG_SND_BF5XX_SOC_AD183X_MODULE)341{342.modalias = "ad183x",343.max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */344.bus_num = 0,345.chip_select = 4,346.platform_data = "ad1836", /* only includes chip name for the moment */347.controller_data = &ad1836_spi_chip_info,348.mode = SPI_MODE_3,349},350#endif351#if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)352{353.modalias = "spidev",354.max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */355.bus_num = 0,356.chip_select = 1,357.controller_data = &spidev_chip_info,358},359#endif360};361362#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)363#include <linux/input.h>364#include <linux/gpio_keys.h>365366static struct gpio_keys_button bfin_gpio_keys_table[] = {367{BTN_0, GPIO_PF5, 1, "gpio-keys: BTN0"},368{BTN_1, GPIO_PF6, 1, "gpio-keys: BTN1"},369{BTN_2, GPIO_PF7, 1, "gpio-keys: BTN2"},370{BTN_3, GPIO_PF8, 1, "gpio-keys: BTN3"},371};372373static struct gpio_keys_platform_data bfin_gpio_keys_data = {374.buttons = bfin_gpio_keys_table,375.nbuttons = ARRAY_SIZE(bfin_gpio_keys_table),376};377378static struct platform_device bfin_device_gpiokeys = {379.name = "gpio-keys",380.dev = {381.platform_data = &bfin_gpio_keys_data,382},383};384#endif385386#if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)387#include <linux/i2c-gpio.h>388389static struct i2c_gpio_platform_data i2c_gpio_data = {390.sda_pin = GPIO_PF1,391.scl_pin = GPIO_PF0,392.sda_is_open_drain = 0,393.scl_is_open_drain = 0,394.udelay = 40,395};396397static struct platform_device i2c_gpio_device = {398.name = "i2c-gpio",399.id = 0,400.dev = {401.platform_data = &i2c_gpio_data,402},403};404#endif405406static const unsigned int cclk_vlev_datasheet[] =407{408VRPAIR(VLEV_085, 250000000),409VRPAIR(VLEV_090, 300000000),410VRPAIR(VLEV_095, 313000000),411VRPAIR(VLEV_100, 350000000),412VRPAIR(VLEV_105, 400000000),413VRPAIR(VLEV_110, 444000000),414VRPAIR(VLEV_115, 450000000),415VRPAIR(VLEV_120, 475000000),416VRPAIR(VLEV_125, 500000000),417VRPAIR(VLEV_130, 600000000),418};419420static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {421.tuple_tab = cclk_vlev_datasheet,422.tabsize = ARRAY_SIZE(cclk_vlev_datasheet),423.vr_settling_time = 25 /* us */,424};425426static struct platform_device bfin_dpmc = {427.name = "bfin dpmc",428.dev = {429.platform_data = &bfin_dmpc_vreg_data,430},431};432433#if defined(CONFIG_SND_BF5XX_I2S) || defined(CONFIG_SND_BF5XX_I2S_MODULE)434static struct platform_device bfin_i2s = {435.name = "bfin-i2s",436.id = CONFIG_SND_BF5XX_SPORT_NUM,437/* TODO: add platform data here */438};439#endif440441#if defined(CONFIG_SND_BF5XX_TDM) || defined(CONFIG_SND_BF5XX_TDM_MODULE)442static struct platform_device bfin_tdm = {443.name = "bfin-tdm",444.id = CONFIG_SND_BF5XX_SPORT_NUM,445/* TODO: add platform data here */446};447#endif448449#if defined(CONFIG_SND_BF5XX_AC97) || defined(CONFIG_SND_BF5XX_AC97_MODULE)450static struct platform_device bfin_ac97 = {451.name = "bfin-ac97",452.id = CONFIG_SND_BF5XX_SPORT_NUM,453/* TODO: add platform data here */454};455#endif456457static struct platform_device *ezkit_devices[] __initdata = {458459&bfin_dpmc,460461#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)462&smc91x_device,463#endif464465#if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)466&net2272_bfin_device,467#endif468469#if defined(CONFIG_USB_ISP1760_HCD) || defined(CONFIG_USB_ISP1760_HCD_MODULE)470&bfin_isp1760_device,471#endif472473#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)474&bfin_spi0_device,475#endif476477#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)478#ifdef CONFIG_SERIAL_BFIN_UART0479&bfin_uart0_device,480#endif481#endif482483#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)484#ifdef CONFIG_BFIN_SIR0485&bfin_sir0_device,486#endif487#endif488489#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)490&bfin_device_gpiokeys,491#endif492493#if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)494&i2c_gpio_device,495#endif496497#if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)498&isp1362_hcd_device,499#endif500501#if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)502&ezkit_flash_device,503#endif504505#if defined(CONFIG_SND_BF5XX_I2S) || defined(CONFIG_SND_BF5XX_I2S_MODULE)506&bfin_i2s,507#endif508509#if defined(CONFIG_SND_BF5XX_TDM) || defined(CONFIG_SND_BF5XX_TDM_MODULE)510&bfin_tdm,511#endif512513#if defined(CONFIG_SND_BF5XX_AC97) || defined(CONFIG_SND_BF5XX_AC97_MODULE)514&bfin_ac97,515#endif516};517518static int __init ezkit_init(void)519{520int ret;521522printk(KERN_INFO "%s(): registering device resources\n", __func__);523524ret = platform_add_devices(ezkit_devices, ARRAY_SIZE(ezkit_devices));525if (ret < 0)526return ret;527528#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)529bfin_write_FIO0_DIR(bfin_read_FIO0_DIR() | (1 << 12));530SSYNC();531#endif532533#if defined(CONFIG_SND_BF5XX_SOC_AD183X) || defined(CONFIG_SND_BF5XX_SOC_AD183X_MODULE)534bfin_write_FIO0_DIR(bfin_read_FIO0_DIR() | (1 << 15));535bfin_write_FIO0_FLAG_S(1 << 15);536SSYNC();537/*538* This initialization lasts for approximately 4500 MCLKs.539* MCLK = 12.288MHz540*/541udelay(400);542#endif543544spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));545return 0;546}547548arch_initcall(ezkit_init);549550static struct platform_device *ezkit_early_devices[] __initdata = {551#if defined(CONFIG_SERIAL_BFIN_CONSOLE) || defined(CONFIG_EARLY_PRINTK)552#ifdef CONFIG_SERIAL_BFIN_UART0553&bfin_uart0_device,554#endif555#endif556};557558void __init native_machine_early_platform_add_devices(void)559{560printk(KERN_INFO "register early platform devices\n");561early_platform_add_devices(ezkit_early_devices,562ARRAY_SIZE(ezkit_early_devices));563}564565566