Path: blob/master/arch/blackfin/mach-bf537/boards/pnav10.c
15112 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/etherdevice.h>10#include <linux/platform_device.h>11#include <linux/mtd/mtd.h>12#include <linux/mtd/partitions.h>13#include <linux/spi/spi.h>14#include <linux/spi/flash.h>15#include <linux/irq.h>16#include <asm/dma.h>17#include <asm/bfin5xx_spi.h>18#include <asm/portmux.h>1920#include <linux/spi/ad7877.h>2122/*23* Name the Board for the /proc/cpuinfo24*/25const char bfin_board_name[] = "ADI PNAV-1.0";2627/*28* Driver needs to know address, irq and flag pin.29*/3031#if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE)32static struct resource bfin_pcmcia_cf_resources[] = {33{34.start = 0x20310000, /* IO PORT */35.end = 0x20312000,36.flags = IORESOURCE_MEM,37}, {38.start = 0x20311000, /* Attribute Memory */39.end = 0x20311FFF,40.flags = IORESOURCE_MEM,41}, {42.start = IRQ_PF4,43.end = IRQ_PF4,44.flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,45}, {46.start = 6, /* Card Detect PF6 */47.end = 6,48.flags = IORESOURCE_IRQ,49},50};5152static struct platform_device bfin_pcmcia_cf_device = {53.name = "bfin_cf_pcmcia",54.id = -1,55.num_resources = ARRAY_SIZE(bfin_pcmcia_cf_resources),56.resource = bfin_pcmcia_cf_resources,57};58#endif5960#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)61static struct platform_device rtc_device = {62.name = "rtc-bfin",63.id = -1,64};65#endif6667#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)68#include <linux/smc91x.h>6970static struct smc91x_platdata smc91x_info = {71.flags = SMC91X_USE_16BIT | SMC91X_NOWAIT,72.leda = RPC_LED_100_10,73.ledb = RPC_LED_TX_RX,74};7576static struct resource smc91x_resources[] = {77{78.name = "smc91x-regs",79.start = 0x20300300,80.end = 0x20300300 + 16,81.flags = IORESOURCE_MEM,82}, {8384.start = IRQ_PF7,85.end = IRQ_PF7,86.flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,87},88};89static struct platform_device smc91x_device = {90.name = "smc91x",91.id = 0,92.num_resources = ARRAY_SIZE(smc91x_resources),93.resource = smc91x_resources,94.dev = {95.platform_data = &smc91x_info,96},97};98#endif99100#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)101#include <linux/bfin_mac.h>102static const unsigned short bfin_mac_peripherals[] = P_RMII0;103104static struct bfin_phydev_platform_data bfin_phydev_data[] = {105{106.addr = 1,107.irq = IRQ_MAC_PHYINT,108},109};110111static struct bfin_mii_bus_platform_data bfin_mii_bus_data = {112.phydev_number = 1,113.phydev_data = bfin_phydev_data,114.phy_mode = PHY_INTERFACE_MODE_RMII,115.mac_peripherals = bfin_mac_peripherals,116};117118static struct platform_device bfin_mii_bus = {119.name = "bfin_mii_bus",120.dev = {121.platform_data = &bfin_mii_bus_data,122}123};124125static struct platform_device bfin_mac_device = {126.name = "bfin_mac",127.dev = {128.platform_data = &bfin_mii_bus,129}130};131#endif132133#if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)134static struct resource net2272_bfin_resources[] = {135{136.start = 0x20300000,137.end = 0x20300000 + 0x100,138.flags = IORESOURCE_MEM,139}, {140.start = IRQ_PF7,141.end = IRQ_PF7,142.flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,143},144};145146static struct platform_device net2272_bfin_device = {147.name = "net2272",148.id = -1,149.num_resources = ARRAY_SIZE(net2272_bfin_resources),150.resource = net2272_bfin_resources,151};152#endif153154#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)155/* all SPI peripherals info goes here */156157#if defined(CONFIG_MTD_M25P80) \158|| defined(CONFIG_MTD_M25P80_MODULE)159static struct mtd_partition bfin_spi_flash_partitions[] = {160{161.name = "bootloader(spi)",162.size = 0x00020000,163.offset = 0,164.mask_flags = MTD_CAP_ROM165}, {166.name = "linux kernel(spi)",167.size = 0xe0000,168.offset = 0x20000169}, {170.name = "file system(spi)",171.size = 0x700000,172.offset = 0x00100000,173}174};175176static struct flash_platform_data bfin_spi_flash_data = {177.name = "m25p80",178.parts = bfin_spi_flash_partitions,179.nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),180.type = "m25p64",181};182183/* SPI flash chip (m25p64) */184static struct bfin5xx_spi_chip spi_flash_chip_info = {185.enable_dma = 0, /* use dma transfer with this chip*/186.bits_per_word = 8,187};188#endif189190#if defined(CONFIG_BFIN_SPI_ADC) \191|| defined(CONFIG_BFIN_SPI_ADC_MODULE)192/* SPI ADC chip */193static struct bfin5xx_spi_chip spi_adc_chip_info = {194.enable_dma = 1, /* use dma transfer with this chip*/195.bits_per_word = 16,196};197#endif198199#if defined(CONFIG_SND_BF5XX_SOC_AD183X) \200|| defined(CONFIG_SND_BF5XX_SOC_AD183X_MODULE)201static struct bfin5xx_spi_chip ad1836_spi_chip_info = {202.enable_dma = 0,203.bits_per_word = 16,204};205#endif206207#if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)208static struct bfin5xx_spi_chip mmc_spi_chip_info = {209.enable_dma = 0,210.bits_per_word = 8,211};212#endif213214#if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)215static struct bfin5xx_spi_chip spi_ad7877_chip_info = {216.enable_dma = 0,217.bits_per_word = 16,218};219220static const struct ad7877_platform_data bfin_ad7877_ts_info = {221.model = 7877,222.vref_delay_usecs = 50, /* internal, no capacitor */223.x_plate_ohms = 419,224.y_plate_ohms = 486,225.pressure_max = 1000,226.pressure_min = 0,227.stopacq_polarity = 1,228.first_conversion_delay = 3,229.acquisition_time = 1,230.averaging = 1,231.pen_down_acc_interval = 1,232};233#endif234235static struct spi_board_info bfin_spi_board_info[] __initdata = {236#if defined(CONFIG_MTD_M25P80) \237|| defined(CONFIG_MTD_M25P80_MODULE)238{239/* the modalias must be the same as spi device driver name */240.modalias = "m25p80", /* Name of spi_driver for this device */241.max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */242.bus_num = 0, /* Framework bus number */243.chip_select = 1, /* Framework chip select. On STAMP537 it is SPISSEL1*/244.platform_data = &bfin_spi_flash_data,245.controller_data = &spi_flash_chip_info,246.mode = SPI_MODE_3,247},248#endif249250#if defined(CONFIG_BFIN_SPI_ADC) \251|| defined(CONFIG_BFIN_SPI_ADC_MODULE)252{253.modalias = "bfin_spi_adc", /* Name of spi_driver for this device */254.max_speed_hz = 6250000, /* max spi clock (SCK) speed in HZ */255.bus_num = 0, /* Framework bus number */256.chip_select = 1, /* Framework chip select. */257.platform_data = NULL, /* No spi_driver specific config */258.controller_data = &spi_adc_chip_info,259},260#endif261262#if defined(CONFIG_SND_BF5XX_SOC_AD183X) \263|| 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_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)273{274.modalias = "mmc_spi",275.max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */276.bus_num = 0,277.chip_select = 5,278.controller_data = &mmc_spi_chip_info,279.mode = SPI_MODE_3,280},281#endif282#if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)283{284.modalias = "ad7877",285.platform_data = &bfin_ad7877_ts_info,286.irq = IRQ_PF2,287.max_speed_hz = 12500000, /* max spi clock (SCK) speed in HZ */288.bus_num = 0,289.chip_select = 5,290.controller_data = &spi_ad7877_chip_info,291},292#endif293294};295296/* SPI (0) */297static struct resource bfin_spi0_resource[] = {298[0] = {299.start = SPI0_REGBASE,300.end = SPI0_REGBASE + 0xFF,301.flags = IORESOURCE_MEM,302},303[1] = {304.start = CH_SPI,305.end = CH_SPI,306.flags = IORESOURCE_DMA,307},308[2] = {309.start = IRQ_SPI,310.end = IRQ_SPI,311.flags = IORESOURCE_IRQ,312},313};314315/* SPI controller data */316static struct bfin5xx_spi_master bfin_spi0_info = {317.num_chipselect = 8,318.enable_dma = 1, /* master has the ability to do dma transfer */319.pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},320};321322static struct platform_device bfin_spi0_device = {323.name = "bfin-spi",324.id = 0, /* Bus number */325.num_resources = ARRAY_SIZE(bfin_spi0_resource),326.resource = bfin_spi0_resource,327.dev = {328.platform_data = &bfin_spi0_info, /* Passed to driver */329},330};331#endif /* spi master and devices */332333#if defined(CONFIG_FB_BF537_LQ035) || defined(CONFIG_FB_BF537_LQ035_MODULE)334static struct platform_device bfin_fb_device = {335.name = "bf537-lq035",336};337#endif338339#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)340#ifdef CONFIG_SERIAL_BFIN_UART0341static struct resource bfin_uart0_resources[] = {342{343.start = UART0_THR,344.end = UART0_GCTL+2,345.flags = IORESOURCE_MEM,346},347{348.start = IRQ_UART0_RX,349.end = IRQ_UART0_RX+1,350.flags = IORESOURCE_IRQ,351},352{353.start = IRQ_UART0_ERROR,354.end = IRQ_UART0_ERROR,355.flags = IORESOURCE_IRQ,356},357{358.start = CH_UART0_TX,359.end = CH_UART0_TX,360.flags = IORESOURCE_DMA,361},362{363.start = CH_UART0_RX,364.end = CH_UART0_RX,365.flags = IORESOURCE_DMA,366},367};368369static unsigned short bfin_uart0_peripherals[] = {370P_UART0_TX, P_UART0_RX, 0371};372373static struct platform_device bfin_uart0_device = {374.name = "bfin-uart",375.id = 0,376.num_resources = ARRAY_SIZE(bfin_uart0_resources),377.resource = bfin_uart0_resources,378.dev = {379.platform_data = &bfin_uart0_peripherals, /* Passed to driver */380},381};382#endif383#ifdef CONFIG_SERIAL_BFIN_UART1384static struct resource bfin_uart1_resources[] = {385{386.start = UART1_THR,387.end = UART1_GCTL+2,388.flags = IORESOURCE_MEM,389},390{391.start = IRQ_UART1_RX,392.end = IRQ_UART1_RX+1,393.flags = IORESOURCE_IRQ,394},395{396.start = IRQ_UART1_ERROR,397.end = IRQ_UART1_ERROR,398.flags = IORESOURCE_IRQ,399},400{401.start = CH_UART1_TX,402.end = CH_UART1_TX,403.flags = IORESOURCE_DMA,404},405{406.start = CH_UART1_RX,407.end = CH_UART1_RX,408.flags = IORESOURCE_DMA,409},410};411412static unsigned short bfin_uart1_peripherals[] = {413P_UART1_TX, P_UART1_RX, 0414};415416static struct platform_device bfin_uart1_device = {417.name = "bfin-uart",418.id = 1,419.num_resources = ARRAY_SIZE(bfin_uart1_resources),420.resource = bfin_uart1_resources,421.dev = {422.platform_data = &bfin_uart1_peripherals, /* Passed to driver */423},424};425#endif426#endif427428#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)429#ifdef CONFIG_BFIN_SIR0430static struct resource bfin_sir0_resources[] = {431{432.start = 0xFFC00400,433.end = 0xFFC004FF,434.flags = IORESOURCE_MEM,435},436{437.start = IRQ_UART0_RX,438.end = IRQ_UART0_RX+1,439.flags = IORESOURCE_IRQ,440},441{442.start = CH_UART0_RX,443.end = CH_UART0_RX+1,444.flags = IORESOURCE_DMA,445},446};447448static struct platform_device bfin_sir0_device = {449.name = "bfin_sir",450.id = 0,451.num_resources = ARRAY_SIZE(bfin_sir0_resources),452.resource = bfin_sir0_resources,453};454#endif455#ifdef CONFIG_BFIN_SIR1456static struct resource bfin_sir1_resources[] = {457{458.start = 0xFFC02000,459.end = 0xFFC020FF,460.flags = IORESOURCE_MEM,461},462{463.start = IRQ_UART1_RX,464.end = IRQ_UART1_RX+1,465.flags = IORESOURCE_IRQ,466},467{468.start = CH_UART1_RX,469.end = CH_UART1_RX+1,470.flags = IORESOURCE_DMA,471},472};473474static struct platform_device bfin_sir1_device = {475.name = "bfin_sir",476.id = 1,477.num_resources = ARRAY_SIZE(bfin_sir1_resources),478.resource = bfin_sir1_resources,479};480#endif481#endif482483static struct platform_device *stamp_devices[] __initdata = {484#if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE)485&bfin_pcmcia_cf_device,486#endif487488#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)489&rtc_device,490#endif491492#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)493&smc91x_device,494#endif495496#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)497&bfin_mii_bus,498&bfin_mac_device,499#endif500501#if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)502&net2272_bfin_device,503#endif504505#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)506&bfin_spi0_device,507#endif508509#if defined(CONFIG_FB_BF537_LQ035) || defined(CONFIG_FB_BF537_LQ035_MODULE)510&bfin_fb_device,511#endif512513#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)514#ifdef CONFIG_SERIAL_BFIN_UART0515&bfin_uart0_device,516#endif517#ifdef CONFIG_SERIAL_BFIN_UART1518&bfin_uart1_device,519#endif520#endif521522#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)523#ifdef CONFIG_BFIN_SIR0524&bfin_sir0_device,525#endif526#ifdef CONFIG_BFIN_SIR1527&bfin_sir1_device,528#endif529#endif530};531532static int __init pnav_init(void)533{534printk(KERN_INFO "%s(): registering device resources\n", __func__);535platform_add_devices(stamp_devices, ARRAY_SIZE(stamp_devices));536#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)537spi_register_board_info(bfin_spi_board_info,538ARRAY_SIZE(bfin_spi_board_info));539#endif540return 0;541}542543arch_initcall(pnav_init);544545static struct platform_device *stamp_early_devices[] __initdata = {546#if defined(CONFIG_SERIAL_BFIN_CONSOLE) || defined(CONFIG_EARLY_PRINTK)547#ifdef CONFIG_SERIAL_BFIN_UART0548&bfin_uart0_device,549#endif550#ifdef CONFIG_SERIAL_BFIN_UART1551&bfin_uart1_device,552#endif553#endif554};555556void __init native_machine_early_platform_add_devices(void)557{558printk(KERN_INFO "register early platform devices\n");559early_platform_add_devices(stamp_early_devices,560ARRAY_SIZE(stamp_early_devices));561}562563void bfin_get_ether_addr(char *addr)564{565random_ether_addr(addr);566printk(KERN_WARNING "%s:%s: Setting Ethernet MAC to a random one\n", __FILE__, __func__);567}568EXPORT_SYMBOL(bfin_get_ether_addr);569570571