Path: blob/master/arch/blackfin/mach-bf561/boards/acvilon.c
10819 views
/*1* File: arch/blackfin/mach-bf561/acvilon.c2* Based on: arch/blackfin/mach-bf561/ezkit.c3* Author:4*5* Created:6* Description:7*8* Modified:9* Copyright 2004-2006 Analog Devices Inc.10* Copyright 2009 CJSC "NII STT"11*12* Bugs:13*14* This program is free software; you can redistribute it and/or modify15* it under the terms of the GNU General Public License as published by16* the Free Software Foundation; either version 2 of the License, or17* (at your option) any later version.18*19* This program is distributed in the hope that it will be useful,20* but WITHOUT ANY WARRANTY; without even the implied warranty of21* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the22* GNU General Public License for more details.23*24* You should have received a copy of the GNU General Public License25* along with this program; if not, see the file COPYING, or write26* to the Free Software Foundation, Inc.,27* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA28*29*30* For more information about Acvilon BF561 SoM please31* go to http://www.niistt.ru/32*33*/3435#include <linux/device.h>36#include <linux/platform_device.h>37#include <linux/mtd/mtd.h>38#include <linux/mtd/partitions.h>39#include <linux/mtd/physmap.h>40#include <linux/mtd/nand.h>41#include <linux/mtd/plat-ram.h>42#include <linux/spi/spi.h>43#include <linux/spi/flash.h>44#include <linux/irq.h>45#include <linux/interrupt.h>46#include <linux/jiffies.h>47#include <linux/i2c-pca-platform.h>48#include <linux/delay.h>49#include <linux/io.h>50#include <asm/dma.h>51#include <asm/bfin5xx_spi.h>52#include <asm/portmux.h>53#include <asm/dpmc.h>54#include <asm/cacheflush.h>55#include <linux/i2c.h>5657/*58* Name the Board for the /proc/cpuinfo59*/60const char bfin_board_name[] = "Acvilon board";6162#if defined(CONFIG_USB_ISP1760_HCD) || defined(CONFIG_USB_ISP1760_HCD_MODULE)63#include <linux/usb/isp1760.h>64static struct resource bfin_isp1760_resources[] = {65[0] = {66.start = 0x20000000,67.end = 0x20000000 + 0x000fffff,68.flags = IORESOURCE_MEM,69},70[1] = {71.start = IRQ_PF15,72.end = IRQ_PF15,73.flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,74},75};7677static struct isp1760_platform_data isp1760_priv = {78.is_isp1761 = 0,79.port1_disable = 0,80.bus_width_16 = 1,81.port1_otg = 0,82.analog_oc = 0,83.dack_polarity_high = 0,84.dreq_polarity_high = 0,85};8687static struct platform_device bfin_isp1760_device = {88.name = "isp1760-hcd",89.id = 0,90.dev = {91.platform_data = &isp1760_priv,92},93.num_resources = ARRAY_SIZE(bfin_isp1760_resources),94.resource = bfin_isp1760_resources,95};96#endif9798static struct resource bfin_i2c_pca_resources[] = {99{100.name = "pca9564-regs",101.start = 0x2C000000,102.end = 0x2C000000 + 16,103.flags = IORESOURCE_MEM | IORESOURCE_MEM_32BIT,104}, {105106.start = IRQ_PF8,107.end = IRQ_PF8,108.flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,109},110};111112struct i2c_pca9564_pf_platform_data pca9564_platform_data = {113.gpio = -1,114.i2c_clock_speed = 330000,115.timeout = HZ,116};117118/* PCA9564 I2C Bus driver */119static struct platform_device bfin_i2c_pca_device = {120.name = "i2c-pca-platform",121.id = 0,122.num_resources = ARRAY_SIZE(bfin_i2c_pca_resources),123.resource = bfin_i2c_pca_resources,124.dev = {125.platform_data = &pca9564_platform_data,126}127};128129/* I2C devices fitted. */130static struct i2c_board_info acvilon_i2c_devs[] __initdata = {131{132I2C_BOARD_INFO("ds1339", 0x68),133},134{135I2C_BOARD_INFO("tcn75", 0x49),136},137};138139#if defined(CONFIG_MTD_PLATRAM) || defined(CONFIG_MTD_PLATRAM_MODULE)140static struct platdata_mtd_ram mtd_ram_data = {141.mapname = "rootfs(RAM)",142.bankwidth = 4,143};144145static struct resource mtd_ram_resource = {146.start = 0x4000000,147.end = 0x5ffffff,148.flags = IORESOURCE_MEM,149};150151static struct platform_device mtd_ram_device = {152.name = "mtd-ram",153.id = 0,154.dev = {155.platform_data = &mtd_ram_data,156},157.num_resources = 1,158.resource = &mtd_ram_resource,159};160#endif161162#if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE)163#include <linux/smsc911x.h>164static struct resource smsc911x_resources[] = {165{166.name = "smsc911x-memory",167.start = 0x28000000,168.end = 0x28000000 + 0xFF,169.flags = IORESOURCE_MEM,170},171{172.start = IRQ_PF7,173.end = IRQ_PF7,174.flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,175},176};177178static struct smsc911x_platform_config smsc911x_config = {179.flags = SMSC911X_USE_32BIT | SMSC911X_SAVE_MAC_ADDRESS,180.irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,181.irq_type = SMSC911X_IRQ_TYPE_OPEN_DRAIN,182.phy_interface = PHY_INTERFACE_MODE_MII,183};184185static struct platform_device smsc911x_device = {186.name = "smsc911x",187.id = 0,188.num_resources = ARRAY_SIZE(smsc911x_resources),189.resource = smsc911x_resources,190.dev = {191.platform_data = &smsc911x_config,192},193};194#endif195196#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_UART_RX,206.end = IRQ_UART_RX + 1,207.flags = IORESOURCE_IRQ,208},209{210.start = IRQ_UART_ERROR,211.end = IRQ_UART_ERROR,212.flags = IORESOURCE_IRQ,213},214{215.start = CH_UART_TX,216.end = CH_UART_TX,217.flags = IORESOURCE_DMA,218},219{220.start = CH_UART_RX,221.end = CH_UART_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/* Passed to driver */237.platform_data = &bfin_uart0_peripherals,238},239};240#endif241#endif242243#if defined(CONFIG_MTD_NAND_PLATFORM) || defined(CONFIG_MTD_NAND_PLATFORM_MODULE)244245const char *part_probes[] = { "cmdlinepart", NULL };246247static struct mtd_partition bfin_plat_nand_partitions[] = {248{249.name = "params(nand)",250.size = 32 * 1024 * 1024,251.offset = 0,252}, {253.name = "userfs(nand)",254.size = MTDPART_SIZ_FULL,255.offset = MTDPART_OFS_APPEND,256},257};258259#define BFIN_NAND_PLAT_CLE 2260#define BFIN_NAND_PLAT_ALE 3261262static void bfin_plat_nand_cmd_ctrl(struct mtd_info *mtd, int cmd,263unsigned int ctrl)264{265struct nand_chip *this = mtd->priv;266267if (cmd == NAND_CMD_NONE)268return;269270if (ctrl & NAND_CLE)271writeb(cmd, this->IO_ADDR_W + (1 << BFIN_NAND_PLAT_CLE));272else273writeb(cmd, this->IO_ADDR_W + (1 << BFIN_NAND_PLAT_ALE));274}275276#define BFIN_NAND_PLAT_READY GPIO_PF10277static int bfin_plat_nand_dev_ready(struct mtd_info *mtd)278{279return gpio_get_value(BFIN_NAND_PLAT_READY);280}281282static struct platform_nand_data bfin_plat_nand_data = {283.chip = {284.nr_chips = 1,285.chip_delay = 30,286.part_probe_types = part_probes,287.partitions = bfin_plat_nand_partitions,288.nr_partitions = ARRAY_SIZE(bfin_plat_nand_partitions),289},290.ctrl = {291.cmd_ctrl = bfin_plat_nand_cmd_ctrl,292.dev_ready = bfin_plat_nand_dev_ready,293},294};295296#define MAX(x, y) (x > y ? x : y)297static struct resource bfin_plat_nand_resources = {298.start = 0x24000000,299.end = 0x24000000 + (1 << MAX(BFIN_NAND_PLAT_CLE, BFIN_NAND_PLAT_ALE)),300.flags = IORESOURCE_MEM,301};302303static struct platform_device bfin_async_nand_device = {304.name = "gen_nand",305.id = -1,306.num_resources = 1,307.resource = &bfin_plat_nand_resources,308.dev = {309.platform_data = &bfin_plat_nand_data,310},311};312313static void bfin_plat_nand_init(void)314{315gpio_request(BFIN_NAND_PLAT_READY, "bfin_nand_plat");316}317#else318static void bfin_plat_nand_init(void)319{320}321#endif322323#if defined(CONFIG_MTD_DATAFLASH) || defined(CONFIG_MTD_DATAFLASH_MODULE)324static struct mtd_partition bfin_spi_dataflash_partitions[] = {325{326.name = "bootloader",327.size = 0x4200,328.offset = 0,329.mask_flags = MTD_CAP_ROM},330{331.name = "u-boot",332.size = 0x42000,333.offset = MTDPART_OFS_APPEND,334},335{336.name = "u-boot(params)",337.size = 0x4200,338.offset = MTDPART_OFS_APPEND,339},340{341.name = "kernel",342.size = 0x294000,343.offset = MTDPART_OFS_APPEND,344},345{346.name = "params",347.size = 0x42000,348.offset = MTDPART_OFS_APPEND,349},350{351.name = "rootfs",352.size = MTDPART_SIZ_FULL,353.offset = MTDPART_OFS_APPEND,354}355};356357static struct flash_platform_data bfin_spi_dataflash_data = {358.name = "SPI Dataflash",359.parts = bfin_spi_dataflash_partitions,360.nr_parts = ARRAY_SIZE(bfin_spi_dataflash_partitions),361};362363/* DataFlash chip */364static struct bfin5xx_spi_chip data_flash_chip_info = {365.enable_dma = 0, /* use dma transfer with this chip */366.bits_per_word = 8,367};368#endif369370#if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)371static struct bfin5xx_spi_chip spidev_chip_info = {372.enable_dma = 0,373.bits_per_word = 8,374};375#endif376377#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)378/* SPI (0) */379static struct resource bfin_spi0_resource[] = {380[0] = {381.start = SPI0_REGBASE,382.end = SPI0_REGBASE + 0xFF,383.flags = IORESOURCE_MEM,384},385[1] = {386.start = CH_SPI,387.end = CH_SPI,388.flags = IORESOURCE_DMA,389},390[2] = {391.start = IRQ_SPI,392.end = IRQ_SPI,393.flags = IORESOURCE_IRQ,394},395};396397/* SPI controller data */398static struct bfin5xx_spi_master bfin_spi0_info = {399.num_chipselect = 8,400.enable_dma = 1, /* master has the ability to do dma transfer */401.pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},402};403404static struct platform_device bfin_spi0_device = {405.name = "bfin-spi",406.id = 0, /* Bus number */407.num_resources = ARRAY_SIZE(bfin_spi0_resource),408.resource = bfin_spi0_resource,409.dev = {410.platform_data = &bfin_spi0_info, /* Passed to driver */411},412};413#endif414415static struct spi_board_info bfin_spi_board_info[] __initdata = {416#if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)417{418.modalias = "spidev",419.max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */420.bus_num = 0,421.chip_select = 3,422.controller_data = &spidev_chip_info,423},424#endif425#if defined(CONFIG_MTD_DATAFLASH) || defined(CONFIG_MTD_DATAFLASH_MODULE)426{ /* DataFlash chip */427.modalias = "mtd_dataflash",428.max_speed_hz = 33250000, /* max spi clock (SCK) speed in HZ */429.bus_num = 0, /* Framework bus number */430.chip_select = 2, /* Framework chip select */431.platform_data = &bfin_spi_dataflash_data,432.controller_data = &data_flash_chip_info,433.mode = SPI_MODE_3,434},435#endif436};437438static struct resource bfin_gpios_resources = {439.start = 31,440/* .end = MAX_BLACKFIN_GPIOS - 1, */441.end = 32,442.flags = IORESOURCE_IRQ,443};444445static struct platform_device bfin_gpios_device = {446.name = "simple-gpio",447.id = -1,448.num_resources = 1,449.resource = &bfin_gpios_resources,450};451452static const unsigned int cclk_vlev_datasheet[] = {453VRPAIR(VLEV_085, 250000000),454VRPAIR(VLEV_090, 300000000),455VRPAIR(VLEV_095, 313000000),456VRPAIR(VLEV_100, 350000000),457VRPAIR(VLEV_105, 400000000),458VRPAIR(VLEV_110, 444000000),459VRPAIR(VLEV_115, 450000000),460VRPAIR(VLEV_120, 475000000),461VRPAIR(VLEV_125, 500000000),462VRPAIR(VLEV_130, 600000000),463};464465static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {466.tuple_tab = cclk_vlev_datasheet,467.tabsize = ARRAY_SIZE(cclk_vlev_datasheet),468.vr_settling_time = 25 /* us */ ,469};470471static struct platform_device bfin_dpmc = {472.name = "bfin dpmc",473.dev = {474.platform_data = &bfin_dmpc_vreg_data,475},476};477478static struct platform_device *acvilon_devices[] __initdata = {479&bfin_dpmc,480481#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)482&bfin_spi0_device,483#endif484485#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)486#ifdef CONFIG_SERIAL_BFIN_UART0487&bfin_uart0_device,488#endif489#endif490491&bfin_gpios_device,492493#if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE)494&smsc911x_device,495#endif496497&bfin_i2c_pca_device,498499#if defined(CONFIG_MTD_NAND_PLATFORM) || defined(CONFIG_MTD_NAND_PLATFORM_MODULE)500&bfin_async_nand_device,501#endif502503#if defined(CONFIG_MTD_PLATRAM) || defined(CONFIG_MTD_PLATRAM_MODULE)504&mtd_ram_device,505#endif506507};508509static int __init acvilon_init(void)510{511int ret;512513printk(KERN_INFO "%s(): registering device resources\n", __func__);514515bfin_plat_nand_init();516ret =517platform_add_devices(acvilon_devices, ARRAY_SIZE(acvilon_devices));518if (ret < 0)519return ret;520521i2c_register_board_info(0, acvilon_i2c_devs,522ARRAY_SIZE(acvilon_i2c_devs));523524bfin_write_FIO0_FLAG_C(1 << 14);525msleep(5);526bfin_write_FIO0_FLAG_S(1 << 14);527528spi_register_board_info(bfin_spi_board_info,529ARRAY_SIZE(bfin_spi_board_info));530return 0;531}532533arch_initcall(acvilon_init);534535static struct platform_device *acvilon_early_devices[] __initdata = {536#if defined(CONFIG_SERIAL_BFIN_CONSOLE) || defined(CONFIG_EARLY_PRINTK)537#ifdef CONFIG_SERIAL_BFIN_UART0538&bfin_uart0_device,539#endif540#endif541};542543void __init native_machine_early_platform_add_devices(void)544{545printk(KERN_INFO "register early platform devices\n");546early_platform_add_devices(acvilon_early_devices,547ARRAY_SIZE(acvilon_early_devices));548}549550551