| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314 | /* * TI DaVinci DM365 EVM board support * * Copyright (C) 2009 Texas Instruments Incorporated * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation version 2. * * This program is distributed "as is" WITHOUT ANY WARRANTY of any * kind, whether express or implied; without even the implied warranty * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU General Public License for more details. */#include <linux/kernel.h>#include <linux/init.h>#include <linux/err.h>#include <linux/i2c.h>#include <linux/io.h>#include <linux/clk.h>#include <linux/i2c/at24.h>#include <linux/leds.h>#include <linux/mtd/mtd.h>#include <linux/mtd/partitions.h>#include <linux/slab.h>#include <linux/mtd/nand.h>#include <linux/input.h>#include <linux/spi/spi.h>#include <linux/spi/eeprom.h>#include <asm/mach-types.h>#include <asm/mach/arch.h>#include <mach/mux.h>#include <mach/common.h>#include <linux/platform_data/i2c-davinci.h>#include <mach/serial.h>#include <linux/platform_data/mmc-davinci.h>#include <linux/platform_data/mtd-davinci.h>#include <linux/platform_data/keyscan-davinci.h>#include <media/tvp514x.h>#include "davinci.h"static inline int have_imager(void){	/* REVISIT when it's supported, trigger via Kconfig */	return 0;}static inline int have_tvp7002(void){	/* REVISIT when it's supported, trigger via Kconfig */	return 0;}#define DM365_EVM_PHY_ID		"davinci_mdio-0:01"/* * A MAX-II CPLD is used for various board control functions. */#define CPLD_OFFSET(a13a8,a2a1)		(((a13a8) << 10) + ((a2a1) << 3))#define CPLD_VERSION	CPLD_OFFSET(0,0)	/* r/o */#define CPLD_TEST	CPLD_OFFSET(0,1)#define CPLD_LEDS	CPLD_OFFSET(0,2)#define CPLD_MUX	CPLD_OFFSET(0,3)#define CPLD_SWITCH	CPLD_OFFSET(1,0)	/* r/o */#define CPLD_POWER	CPLD_OFFSET(1,1)#define CPLD_VIDEO	CPLD_OFFSET(1,2)#define CPLD_CARDSTAT	CPLD_OFFSET(1,3)	/* r/o */#define CPLD_DILC_OUT	CPLD_OFFSET(2,0)#define CPLD_DILC_IN	CPLD_OFFSET(2,1)	/* r/o */#define CPLD_IMG_DIR0	CPLD_OFFSET(2,2)#define CPLD_IMG_MUX0	CPLD_OFFSET(2,3)#define CPLD_IMG_MUX1	CPLD_OFFSET(3,0)#define CPLD_IMG_DIR1	CPLD_OFFSET(3,1)#define CPLD_IMG_MUX2	CPLD_OFFSET(3,2)#define CPLD_IMG_MUX3	CPLD_OFFSET(3,3)#define CPLD_IMG_DIR2	CPLD_OFFSET(4,0)#define CPLD_IMG_MUX4	CPLD_OFFSET(4,1)#define CPLD_IMG_MUX5	CPLD_OFFSET(4,2)#define CPLD_RESETS	CPLD_OFFSET(4,3)#define CPLD_CCD_DIR1	CPLD_OFFSET(0x3e,0)#define CPLD_CCD_IO1	CPLD_OFFSET(0x3e,1)#define CPLD_CCD_DIR2	CPLD_OFFSET(0x3e,2)#define CPLD_CCD_IO2	CPLD_OFFSET(0x3e,3)#define CPLD_CCD_DIR3	CPLD_OFFSET(0x3f,0)#define CPLD_CCD_IO3	CPLD_OFFSET(0x3f,1)static void __iomem *cpld;/* NOTE:  this is geared for the standard config, with a socketed * 2 GByte Micron NAND (MT29F16G08FAA) using 128KB sectors.  If you * swap chips with a different block size, partitioning will * need to be changed. This NAND chip MT29F16G08FAA is the default * NAND shipped with the Spectrum Digital DM365 EVM */#define NAND_BLOCK_SIZE		SZ_128Kstatic struct mtd_partition davinci_nand_partitions[] = {	{		/* UBL (a few copies) plus U-Boot */		.name		= "bootloader",		.offset		= 0,		.size		= 30 * NAND_BLOCK_SIZE,		.mask_flags	= MTD_WRITEABLE, /* force read-only */	}, {		/* U-Boot environment */		.name		= "params",		.offset		= MTDPART_OFS_APPEND,		.size		= 2 * NAND_BLOCK_SIZE,		.mask_flags	= 0,	}, {		.name		= "kernel",		.offset		= MTDPART_OFS_APPEND,		.size		= SZ_4M,		.mask_flags	= 0,	}, {		.name		= "filesystem1",		.offset		= MTDPART_OFS_APPEND,		.size		= SZ_512M,		.mask_flags	= 0,	}, {		.name		= "filesystem2",		.offset		= MTDPART_OFS_APPEND,		.size		= MTDPART_SIZ_FULL,		.mask_flags	= 0,	}	/* two blocks with bad block table (and mirror) at the end */};static struct davinci_nand_pdata davinci_nand_data = {	.mask_chipsel		= BIT(14),	.parts			= davinci_nand_partitions,	.nr_parts		= ARRAY_SIZE(davinci_nand_partitions),	.ecc_mode		= NAND_ECC_HW,	.bbt_options		= NAND_BBT_USE_FLASH,	.ecc_bits		= 4,};static struct resource davinci_nand_resources[] = {	{		.start		= DM365_ASYNC_EMIF_DATA_CE0_BASE,		.end		= DM365_ASYNC_EMIF_DATA_CE0_BASE + SZ_32M - 1,		.flags		= IORESOURCE_MEM,	}, {		.start		= DM365_ASYNC_EMIF_CONTROL_BASE,		.end		= DM365_ASYNC_EMIF_CONTROL_BASE + SZ_4K - 1,		.flags		= IORESOURCE_MEM,	},};static struct platform_device davinci_nand_device = {	.name			= "davinci_nand",	.id			= 0,	.num_resources		= ARRAY_SIZE(davinci_nand_resources),	.resource		= davinci_nand_resources,	.dev			= {		.platform_data	= &davinci_nand_data,	},};static struct at24_platform_data eeprom_info = {	.byte_len       = (256*1024) / 8,	.page_size      = 64,	.flags          = AT24_FLAG_ADDR16,	.setup          = davinci_get_mac_addr,	.context	= (void *)0x7f00,};static struct snd_platform_data dm365_evm_snd_data = {	.asp_chan_q = EVENTQ_3,};static struct i2c_board_info i2c_info[] = {	{		I2C_BOARD_INFO("24c256", 0x50),		.platform_data	= &eeprom_info,	},	{		I2C_BOARD_INFO("tlv320aic3x", 0x18),	},};static struct davinci_i2c_platform_data i2c_pdata = {	.bus_freq	= 400	/* kHz */,	.bus_delay	= 0	/* usec */,};static int dm365evm_keyscan_enable(struct device *dev){	return davinci_cfg_reg(DM365_KEYSCAN);}static unsigned short dm365evm_keymap[] = {	KEY_KP2,	KEY_LEFT,	KEY_EXIT,	KEY_DOWN,	KEY_ENTER,	KEY_UP,	KEY_KP1,	KEY_RIGHT,	KEY_MENU,	KEY_RECORD,	KEY_REWIND,	KEY_KPMINUS,	KEY_STOP,	KEY_FASTFORWARD,	KEY_KPPLUS,	KEY_PLAYPAUSE,	0};static struct davinci_ks_platform_data dm365evm_ks_data = {	.device_enable	= dm365evm_keyscan_enable,	.keymap		= dm365evm_keymap,	.keymapsize	= ARRAY_SIZE(dm365evm_keymap),	.rep		= 1,	/* Scan period = strobe + interval */	.strobe		= 0x5,	.interval	= 0x2,	.matrix_type	= DAVINCI_KEYSCAN_MATRIX_4X4,};static int cpld_mmc_get_cd(int module){	if (!cpld)		return -ENXIO;	/* low == card present */	return !(__raw_readb(cpld + CPLD_CARDSTAT) & BIT(module ? 4 : 0));}static int cpld_mmc_get_ro(int module){	if (!cpld)		return -ENXIO;	/* high == card's write protect switch active */	return !!(__raw_readb(cpld + CPLD_CARDSTAT) & BIT(module ? 5 : 1));}static struct davinci_mmc_config dm365evm_mmc_config = {	.get_cd		= cpld_mmc_get_cd,	.get_ro		= cpld_mmc_get_ro,	.wires		= 4,	.max_freq	= 50000000,	.caps		= MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED,	.version	= MMC_CTLR_VERSION_2,};static void dm365evm_emac_configure(void){	/*	 * EMAC pins are multiplexed with GPIO and UART	 * Further details are available at the DM365 ARM	 * Subsystem Users Guide(sprufg5.pdf) pages 125 - 127	 */	davinci_cfg_reg(DM365_EMAC_TX_EN);	davinci_cfg_reg(DM365_EMAC_TX_CLK);	davinci_cfg_reg(DM365_EMAC_COL);	davinci_cfg_reg(DM365_EMAC_TXD3);	davinci_cfg_reg(DM365_EMAC_TXD2);	davinci_cfg_reg(DM365_EMAC_TXD1);	davinci_cfg_reg(DM365_EMAC_TXD0);	davinci_cfg_reg(DM365_EMAC_RXD3);	davinci_cfg_reg(DM365_EMAC_RXD2);	davinci_cfg_reg(DM365_EMAC_RXD1);	davinci_cfg_reg(DM365_EMAC_RXD0);	davinci_cfg_reg(DM365_EMAC_RX_CLK);	davinci_cfg_reg(DM365_EMAC_RX_DV);	davinci_cfg_reg(DM365_EMAC_RX_ER);	davinci_cfg_reg(DM365_EMAC_CRS);	davinci_cfg_reg(DM365_EMAC_MDIO);	davinci_cfg_reg(DM365_EMAC_MDCLK);	/*	 * EMAC interrupts are multiplexed with GPIO interrupts	 * Details are available at the DM365 ARM	 * Subsystem Users Guide(sprufg5.pdf) pages 133 - 134	 */	davinci_cfg_reg(DM365_INT_EMAC_RXTHRESH);	davinci_cfg_reg(DM365_INT_EMAC_RXPULSE);	davinci_cfg_reg(DM365_INT_EMAC_TXPULSE);	davinci_cfg_reg(DM365_INT_EMAC_MISCPULSE);}static void dm365evm_mmc_configure(void){	/*	 * MMC/SD pins are multiplexed with GPIO and EMIF	 * Further details are available at the DM365 ARM	 * Subsystem Users Guide(sprufg5.pdf) pages 118, 128 - 131	 */	davinci_cfg_reg(DM365_SD1_CLK);	davinci_cfg_reg(DM365_SD1_CMD);	davinci_cfg_reg(DM365_SD1_DATA3);	davinci_cfg_reg(DM365_SD1_DATA2);	davinci_cfg_reg(DM365_SD1_DATA1);	davinci_cfg_reg(DM365_SD1_DATA0);}static struct tvp514x_platform_data tvp5146_pdata = {	.clk_polarity = 0,	.hs_polarity = 1,	.vs_polarity = 1};
 |