Path: blob/master/arch/arm/mach-davinci/board-dm355-leopard.c
10699 views
/*1* DM355 leopard board support2*3* Based on board-dm355-evm.c4*5* This file is licensed under the terms of the GNU General Public6* License version 2. This program is licensed "as is" without any7* warranty of any kind, whether express or implied.8*/9#include <linux/kernel.h>10#include <linux/init.h>11#include <linux/err.h>12#include <linux/platform_device.h>13#include <linux/mtd/mtd.h>14#include <linux/mtd/partitions.h>15#include <linux/mtd/nand.h>16#include <linux/i2c.h>17#include <linux/gpio.h>18#include <linux/clk.h>19#include <linux/spi/spi.h>20#include <linux/spi/eeprom.h>2122#include <asm/mach-types.h>23#include <asm/mach/arch.h>2425#include <mach/dm355.h>26#include <mach/i2c.h>27#include <mach/serial.h>28#include <mach/nand.h>29#include <mach/mmc.h>30#include <mach/usb.h>3132/* NOTE: this is geared for the standard config, with a socketed33* 2 GByte Micron NAND (MT29F16G08FAA) using 128KB sectors. If you34* swap chips, maybe with a different block size, partitioning may35* need to be changed.36*/37#define NAND_BLOCK_SIZE SZ_128K3839static struct mtd_partition davinci_nand_partitions[] = {40{41/* UBL (a few copies) plus U-Boot */42.name = "bootloader",43.offset = 0,44.size = 15 * NAND_BLOCK_SIZE,45.mask_flags = MTD_WRITEABLE, /* force read-only */46}, {47/* U-Boot environment */48.name = "params",49.offset = MTDPART_OFS_APPEND,50.size = 1 * NAND_BLOCK_SIZE,51.mask_flags = 0,52}, {53.name = "kernel",54.offset = MTDPART_OFS_APPEND,55.size = SZ_4M,56.mask_flags = 0,57}, {58.name = "filesystem1",59.offset = MTDPART_OFS_APPEND,60.size = SZ_512M,61.mask_flags = 0,62}, {63.name = "filesystem2",64.offset = MTDPART_OFS_APPEND,65.size = MTDPART_SIZ_FULL,66.mask_flags = 0,67}68/* two blocks with bad block table (and mirror) at the end */69};7071static struct davinci_nand_pdata davinci_nand_data = {72.mask_chipsel = BIT(14),73.parts = davinci_nand_partitions,74.nr_parts = ARRAY_SIZE(davinci_nand_partitions),75.ecc_mode = NAND_ECC_HW_SYNDROME,76.options = NAND_USE_FLASH_BBT,77};7879static struct resource davinci_nand_resources[] = {80{81.start = DM355_ASYNC_EMIF_DATA_CE0_BASE,82.end = DM355_ASYNC_EMIF_DATA_CE0_BASE + SZ_32M - 1,83.flags = IORESOURCE_MEM,84}, {85.start = DM355_ASYNC_EMIF_CONTROL_BASE,86.end = DM355_ASYNC_EMIF_CONTROL_BASE + SZ_4K - 1,87.flags = IORESOURCE_MEM,88},89};9091static struct platform_device davinci_nand_device = {92.name = "davinci_nand",93.id = 0,9495.num_resources = ARRAY_SIZE(davinci_nand_resources),96.resource = davinci_nand_resources,9798.dev = {99.platform_data = &davinci_nand_data,100},101};102103static struct davinci_i2c_platform_data i2c_pdata = {104.bus_freq = 400 /* kHz */,105.bus_delay = 0 /* usec */,106};107108static int leopard_mmc_gpio = -EINVAL;109110static void dm355leopard_mmcsd_gpios(unsigned gpio)111{112gpio_request(gpio + 0, "mmc0_ro");113gpio_request(gpio + 1, "mmc0_cd");114gpio_request(gpio + 2, "mmc1_ro");115gpio_request(gpio + 3, "mmc1_cd");116117/* we "know" these are input-only so we don't118* need to call gpio_direction_input()119*/120121leopard_mmc_gpio = gpio;122}123124static struct i2c_board_info dm355leopard_i2c_info[] = {125{ I2C_BOARD_INFO("dm355leopard_msp", 0x25),126.platform_data = dm355leopard_mmcsd_gpios,127/* plus irq */ },128/* { I2C_BOARD_INFO("tlv320aic3x", 0x1b), }, */129/* { I2C_BOARD_INFO("tvp5146", 0x5d), }, */130};131132static void __init leopard_init_i2c(void)133{134davinci_init_i2c(&i2c_pdata);135136gpio_request(5, "dm355leopard_msp");137gpio_direction_input(5);138dm355leopard_i2c_info[0].irq = gpio_to_irq(5);139140i2c_register_board_info(1, dm355leopard_i2c_info,141ARRAY_SIZE(dm355leopard_i2c_info));142}143144static struct resource dm355leopard_dm9000_rsrc[] = {145{146/* addr */147.start = 0x04000000,148.end = 0x04000001,149.flags = IORESOURCE_MEM,150}, {151/* data */152.start = 0x04000016,153.end = 0x04000017,154.flags = IORESOURCE_MEM,155}, {156.flags = IORESOURCE_IRQ157| IORESOURCE_IRQ_HIGHEDGE /* rising (active high) */,158},159};160161static struct platform_device dm355leopard_dm9000 = {162.name = "dm9000",163.id = -1,164.resource = dm355leopard_dm9000_rsrc,165.num_resources = ARRAY_SIZE(dm355leopard_dm9000_rsrc),166};167168static struct platform_device *davinci_leopard_devices[] __initdata = {169&dm355leopard_dm9000,170&davinci_nand_device,171};172173static struct davinci_uart_config uart_config __initdata = {174.enabled_uarts = (1 << 0),175};176177static void __init dm355_leopard_map_io(void)178{179dm355_init();180}181182static int dm355leopard_mmc_get_cd(int module)183{184if (!gpio_is_valid(leopard_mmc_gpio))185return -ENXIO;186/* low == card present */187return !gpio_get_value_cansleep(leopard_mmc_gpio + 2 * module + 1);188}189190static int dm355leopard_mmc_get_ro(int module)191{192if (!gpio_is_valid(leopard_mmc_gpio))193return -ENXIO;194/* high == card's write protect switch active */195return gpio_get_value_cansleep(leopard_mmc_gpio + 2 * module + 0);196}197198static struct davinci_mmc_config dm355leopard_mmc_config = {199.get_cd = dm355leopard_mmc_get_cd,200.get_ro = dm355leopard_mmc_get_ro,201.wires = 4,202.max_freq = 50000000,203.caps = MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED,204};205206/* Don't connect anything to J10 unless you're only using USB host207* mode *and* have to do so with some kind of gender-bender. If208* you have proper Mini-B or Mini-A cables (or Mini-A adapters)209* the ID pin won't need any help.210*/211#ifdef CONFIG_USB_MUSB_PERIPHERAL212#define USB_ID_VALUE 0 /* ID pulled high; *should* float */213#else214#define USB_ID_VALUE 1 /* ID pulled low */215#endif216217static struct spi_eeprom at25640a = {218.byte_len = SZ_64K / 8,219.name = "at25640a",220.page_size = 32,221.flags = EE_ADDR2,222};223224static struct spi_board_info dm355_leopard_spi_info[] __initconst = {225{226.modalias = "at25",227.platform_data = &at25640a,228.max_speed_hz = 10 * 1000 * 1000, /* at 3v3 */229.bus_num = 0,230.chip_select = 0,231.mode = SPI_MODE_0,232},233};234235static __init void dm355_leopard_init(void)236{237struct clk *aemif;238239gpio_request(9, "dm9000");240gpio_direction_input(9);241dm355leopard_dm9000_rsrc[2].start = gpio_to_irq(9);242243aemif = clk_get(&dm355leopard_dm9000.dev, "aemif");244if (IS_ERR(aemif))245WARN("%s: unable to get AEMIF clock\n", __func__);246else247clk_enable(aemif);248249platform_add_devices(davinci_leopard_devices,250ARRAY_SIZE(davinci_leopard_devices));251leopard_init_i2c();252davinci_serial_init(&uart_config);253254/* NOTE: NAND flash timings set by the UBL are slower than255* needed by MT29F16G08FAA chips ... EMIF.A1CR is 0x40400204256* but could be 0x0400008c for about 25% faster page reads.257*/258259gpio_request(2, "usb_id_toggle");260gpio_direction_output(2, USB_ID_VALUE);261/* irlml6401 switches over 1A in under 8 msec */262davinci_setup_usb(1000, 8);263264davinci_setup_mmc(0, &dm355leopard_mmc_config);265davinci_setup_mmc(1, &dm355leopard_mmc_config);266267dm355_init_spi0(BIT(0), dm355_leopard_spi_info,268ARRAY_SIZE(dm355_leopard_spi_info));269}270271MACHINE_START(DM355_LEOPARD, "DaVinci DM355 leopard")272.boot_params = (0x80000100),273.map_io = dm355_leopard_map_io,274.init_irq = davinci_irq_init,275.timer = &davinci_timer,276.init_machine = dm355_leopard_init,277MACHINE_END278279280