Path: blob/master/arch/blackfin/mach-bf537/boards/dnp5370.c
15112 views
/*1* This is the configuration for SSV Dil/NetPC DNP/5370 board.2*3* DIL module: http://www.dilnetpc.com/dnp0086.htm4* SK28 (starter kit): http://www.dilnetpc.com/dnp0088.htm5*6* Copyright 2010 3ality Digital Systems7* Copyright 2005 National ICT Australia (NICTA)8* Copyright 2004-2006 Analog Devices Inc.9*10* Licensed under the GPL-2 or later.11*/1213#include <linux/device.h>14#include <linux/kernel.h>15#include <linux/platform_device.h>16#include <linux/io.h>17#include <linux/mtd/mtd.h>18#include <linux/mtd/nand.h>19#include <linux/mtd/partitions.h>20#include <linux/mtd/plat-ram.h>21#include <linux/mtd/physmap.h>22#include <linux/spi/spi.h>23#include <linux/spi/flash.h>24#include <linux/irq.h>25#include <linux/interrupt.h>26#include <linux/i2c.h>27#include <linux/spi/mmc_spi.h>28#include <linux/phy.h>29#include <asm/dma.h>30#include <asm/bfin5xx_spi.h>31#include <asm/reboot.h>32#include <asm/portmux.h>33#include <asm/dpmc.h>3435/*36* Name the Board for the /proc/cpuinfo37*/38const char bfin_board_name[] = "DNP/5370";39#define FLASH_MAC 0x202f000040#define CONFIG_MTD_PHYSMAP_LEN 0x3000004142#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)43static struct platform_device rtc_device = {44.name = "rtc-bfin",45.id = -1,46};47#endif4849#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)50#include <linux/bfin_mac.h>51static const unsigned short bfin_mac_peripherals[] = P_RMII0;5253static struct bfin_phydev_platform_data bfin_phydev_data[] = {54{55.addr = 1,56.irq = PHY_POLL, /* IRQ_MAC_PHYINT */57},58};5960static struct bfin_mii_bus_platform_data bfin_mii_bus_data = {61.phydev_number = 1,62.phydev_data = bfin_phydev_data,63.phy_mode = PHY_INTERFACE_MODE_RMII,64.mac_peripherals = bfin_mac_peripherals,65};6667static struct platform_device bfin_mii_bus = {68.name = "bfin_mii_bus",69.dev = {70.platform_data = &bfin_mii_bus_data,71}72};7374static struct platform_device bfin_mac_device = {75.name = "bfin_mac",76.dev = {77.platform_data = &bfin_mii_bus,78}79};80#endif8182#if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)83static struct mtd_partition asmb_flash_partitions[] = {84{85.name = "bootloader(nor)",86.size = 0x30000,87.offset = 0,88}, {89.name = "linux kernel and rootfs(nor)",90.size = 0x300000 - 0x30000 - 0x10000,91.offset = MTDPART_OFS_APPEND,92}, {93.name = "MAC address(nor)",94.size = 0x10000,95.offset = MTDPART_OFS_APPEND,96.mask_flags = MTD_WRITEABLE,97}98};99100static struct physmap_flash_data asmb_flash_data = {101.width = 1,102.parts = asmb_flash_partitions,103.nr_parts = ARRAY_SIZE(asmb_flash_partitions),104};105106static struct resource asmb_flash_resource = {107.start = 0x20000000,108.end = 0x202fffff,109.flags = IORESOURCE_MEM,110};111112/* 4 MB NOR flash attached to async memory banks 0-2,113* therefore only 3 MB visible.114*/115static struct platform_device asmb_flash_device = {116.name = "physmap-flash",117.id = 0,118.dev = {119.platform_data = &asmb_flash_data,120},121.num_resources = 1,122.resource = &asmb_flash_resource,123};124#endif125126#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)127128#if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)129130static struct bfin5xx_spi_chip mmc_spi_chip_info = {131.enable_dma = 0, /* use no dma transfer with this chip*/132.bits_per_word = 8,133};134135#endif136137#if defined(CONFIG_MTD_DATAFLASH) || defined(CONFIG_MTD_DATAFLASH_MODULE)138/* This mapping is for at45db642 it has 1056 page size,139* partition size and offset should be page aligned140*/141static struct mtd_partition bfin_spi_dataflash_partitions[] = {142{143.name = "JFFS2 dataflash(nor)",144#ifdef CONFIG_MTD_PAGESIZE_1024145.offset = 0x40000,146.size = 0x7C0000,147#else148.offset = 0x0,149.size = 0x840000,150#endif151}152};153154static struct flash_platform_data bfin_spi_dataflash_data = {155.name = "mtd_dataflash",156.parts = bfin_spi_dataflash_partitions,157.nr_parts = ARRAY_SIZE(bfin_spi_dataflash_partitions),158.type = "mtd_dataflash",159};160161static struct bfin5xx_spi_chip spi_dataflash_chip_info = {162.enable_dma = 0, /* use no dma transfer with this chip*/163.bits_per_word = 8,164};165#endif166167static struct spi_board_info bfin_spi_board_info[] __initdata = {168/* SD/MMC card reader at SPI bus */169#if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)170{171.modalias = "mmc_spi",172.max_speed_hz = 20000000,173.bus_num = 0,174.chip_select = 1,175.controller_data = &mmc_spi_chip_info,176.mode = SPI_MODE_3,177},178#endif179180/* 8 Megabyte Atmel NOR flash chip at SPI bus */181#if defined(CONFIG_MTD_DATAFLASH) || defined(CONFIG_MTD_DATAFLASH_MODULE)182{183.modalias = "mtd_dataflash",184.max_speed_hz = 16700000,185.bus_num = 0,186.chip_select = 2,187.platform_data = &bfin_spi_dataflash_data,188.controller_data = &spi_dataflash_chip_info,189.mode = SPI_MODE_3, /* SPI_CPHA and SPI_CPOL */190},191#endif192};193194/* SPI controller data */195/* SPI (0) */196static struct resource bfin_spi0_resource[] = {197[0] = {198.start = SPI0_REGBASE,199.end = SPI0_REGBASE + 0xFF,200.flags = IORESOURCE_MEM,201},202[1] = {203.start = CH_SPI,204.end = CH_SPI,205.flags = IORESOURCE_DMA,206},207[2] = {208.start = IRQ_SPI,209.end = IRQ_SPI,210.flags = IORESOURCE_IRQ,211},212};213214static struct bfin5xx_spi_master spi_bfin_master_info = {215.num_chipselect = 8,216.enable_dma = 1, /* master has the ability to do dma transfer */217.pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},218};219220static struct platform_device spi_bfin_master_device = {221.name = "bfin-spi",222.id = 0, /* Bus number */223.num_resources = ARRAY_SIZE(bfin_spi0_resource),224.resource = bfin_spi0_resource,225.dev = {226.platform_data = &spi_bfin_master_info, /* Passed to driver */227},228};229#endif230231#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)232#ifdef CONFIG_SERIAL_BFIN_UART0233static struct resource bfin_uart0_resources[] = {234{235.start = UART0_THR,236.end = UART0_GCTL+2,237.flags = IORESOURCE_MEM,238},239{240.start = IRQ_UART0_RX,241.end = IRQ_UART0_RX+1,242.flags = IORESOURCE_IRQ,243},244{245.start = IRQ_UART0_ERROR,246.end = IRQ_UART0_ERROR,247.flags = IORESOURCE_IRQ,248},249{250.start = CH_UART0_TX,251.end = CH_UART0_TX,252.flags = IORESOURCE_DMA,253},254{255.start = CH_UART0_RX,256.end = CH_UART0_RX,257.flags = IORESOURCE_DMA,258},259};260261static unsigned short bfin_uart0_peripherals[] = {262P_UART0_TX, P_UART0_RX, 0263};264265static struct platform_device bfin_uart0_device = {266.name = "bfin-uart",267.id = 0,268.num_resources = ARRAY_SIZE(bfin_uart0_resources),269.resource = bfin_uart0_resources,270.dev = {271.platform_data = &bfin_uart0_peripherals, /* Passed to driver */272},273};274#endif275276#ifdef CONFIG_SERIAL_BFIN_UART1277static struct resource bfin_uart1_resources[] = {278{279.start = UART1_THR,280.end = UART1_GCTL+2,281.flags = IORESOURCE_MEM,282},283{284.start = IRQ_UART1_RX,285.end = IRQ_UART1_RX+1,286.flags = IORESOURCE_IRQ,287},288{289.start = IRQ_UART1_ERROR,290.end = IRQ_UART1_ERROR,291.flags = IORESOURCE_IRQ,292},293{294.start = CH_UART1_TX,295.end = CH_UART1_TX,296.flags = IORESOURCE_DMA,297},298{299.start = CH_UART1_RX,300.end = CH_UART1_RX,301.flags = IORESOURCE_DMA,302},303};304305static unsigned short bfin_uart1_peripherals[] = {306P_UART1_TX, P_UART1_RX, 0307};308309static struct platform_device bfin_uart1_device = {310.name = "bfin-uart",311.id = 1,312.num_resources = ARRAY_SIZE(bfin_uart1_resources),313.resource = bfin_uart1_resources,314.dev = {315.platform_data = &bfin_uart1_peripherals, /* Passed to driver */316},317};318#endif319#endif320321#if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)322static struct resource bfin_twi0_resource[] = {323[0] = {324.start = TWI0_REGBASE,325.end = TWI0_REGBASE + 0xff,326.flags = IORESOURCE_MEM,327},328[1] = {329.start = IRQ_TWI,330.end = IRQ_TWI,331.flags = IORESOURCE_IRQ,332},333};334335static struct platform_device i2c_bfin_twi_device = {336.name = "i2c-bfin-twi",337.id = 0,338.num_resources = ARRAY_SIZE(bfin_twi0_resource),339.resource = bfin_twi0_resource,340};341#endif342343static struct platform_device *dnp5370_devices[] __initdata = {344345#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)346#ifdef CONFIG_SERIAL_BFIN_UART0347&bfin_uart0_device,348#endif349#ifdef CONFIG_SERIAL_BFIN_UART1350&bfin_uart1_device,351#endif352#endif353354#if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)355&asmb_flash_device,356#endif357358#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)359&bfin_mii_bus,360&bfin_mac_device,361#endif362363#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)364&spi_bfin_master_device,365#endif366367#if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)368&i2c_bfin_twi_device,369#endif370371#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)372&rtc_device,373#endif374375};376377static int __init dnp5370_init(void)378{379printk(KERN_INFO "DNP/5370: registering device resources\n");380platform_add_devices(dnp5370_devices, ARRAY_SIZE(dnp5370_devices));381printk(KERN_INFO "DNP/5370: registering %zu SPI slave devices\n",382ARRAY_SIZE(bfin_spi_board_info));383spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));384printk(KERN_INFO "DNP/5370: MAC %pM\n", (void *)FLASH_MAC);385return 0;386}387arch_initcall(dnp5370_init);388389/*390* Currently the MAC address is saved in Flash by U-Boot391*/392void bfin_get_ether_addr(char *addr)393{394*(u32 *)(&(addr[0])) = bfin_read32(FLASH_MAC);395*(u16 *)(&(addr[4])) = bfin_read16(FLASH_MAC + 4);396}397EXPORT_SYMBOL(bfin_get_ether_addr);398399400