cachepc-linux

Fork of AMDESE/linux with modifications for CachePC side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-linux
Log | Files | Refs | README | LICENSE | sfeed.txt

board-dm646x-evm.c (19742B)


      1/*
      2 * TI DaVinci DM646X EVM board
      3 *
      4 * Derived from: arch/arm/mach-davinci/board-evm.c
      5 * Copyright (C) 2006 Texas Instruments.
      6 *
      7 * (C) 2007-2008, MontaVista Software, Inc.
      8 *
      9 * This file is licensed under the terms of the GNU General Public License
     10 * version 2. This program is licensed "as is" without any warranty of any
     11 * kind, whether express or implied.
     12 *
     13 */
     14
     15/**************************************************************************
     16 * Included Files
     17 **************************************************************************/
     18
     19#include <linux/kernel.h>
     20#include <linux/init.h>
     21#include <linux/leds.h>
     22#include <linux/gpio.h>
     23#include <linux/platform_device.h>
     24#include <linux/i2c.h>
     25#include <linux/property.h>
     26#include <linux/platform_data/pcf857x.h>
     27#include <linux/platform_data/ti-aemif.h>
     28
     29#include <media/i2c/tvp514x.h>
     30#include <media/i2c/adv7343.h>
     31
     32#include <linux/mtd/mtd.h>
     33#include <linux/mtd/rawnand.h>
     34#include <linux/mtd/partitions.h>
     35#include <linux/nvmem-provider.h>
     36#include <linux/clk.h>
     37#include <linux/export.h>
     38#include <linux/platform_data/gpio-davinci.h>
     39#include <linux/platform_data/i2c-davinci.h>
     40#include <linux/platform_data/mtd-davinci.h>
     41#include <linux/platform_data/mtd-davinci-aemif.h>
     42
     43#include <asm/mach-types.h>
     44#include <asm/mach/arch.h>
     45
     46#include "common.h"
     47#include "serial.h"
     48#include "davinci.h"
     49#include "irqs.h"
     50
     51#define NAND_BLOCK_SIZE		SZ_128K
     52
     53/* Note: We are setting first partition as 'bootloader' constituting UBL, U-Boot
     54 * and U-Boot environment this avoids dependency on any particular combination
     55 * of UBL, U-Boot or flashing tools etc.
     56 */
     57static struct mtd_partition davinci_nand_partitions[] = {
     58	{
     59		/* UBL, U-Boot with environment */
     60		.name		= "bootloader",
     61		.offset		= MTDPART_OFS_APPEND,
     62		.size		= 16 * NAND_BLOCK_SIZE,
     63		.mask_flags	= MTD_WRITEABLE,	/* force read-only */
     64	}, {
     65		.name		= "kernel",
     66		.offset		= MTDPART_OFS_APPEND,
     67		.size		= SZ_4M,
     68		.mask_flags	= 0,
     69	}, {
     70		.name		= "filesystem",
     71		.offset		= MTDPART_OFS_APPEND,
     72		.size		= MTDPART_SIZ_FULL,
     73		.mask_flags	= 0,
     74	}
     75};
     76
     77static struct davinci_aemif_timing dm6467tevm_nandflash_timing = {
     78	.wsetup		= 29,
     79	.wstrobe	= 24,
     80	.whold		= 14,
     81	.rsetup		= 19,
     82	.rstrobe	= 33,
     83	.rhold		= 0,
     84	.ta		= 29,
     85};
     86
     87static struct davinci_nand_pdata davinci_nand_data = {
     88	.core_chipsel		= 0,
     89	.mask_cle 		= 0x80000,
     90	.mask_ale 		= 0x40000,
     91	.parts			= davinci_nand_partitions,
     92	.nr_parts		= ARRAY_SIZE(davinci_nand_partitions),
     93	.engine_type		= NAND_ECC_ENGINE_TYPE_ON_HOST,
     94	.ecc_bits		= 1,
     95	.options		= 0,
     96};
     97
     98static struct resource davinci_nand_resources[] = {
     99	{
    100		.start		= DM646X_ASYNC_EMIF_CS2_SPACE_BASE,
    101		.end		= DM646X_ASYNC_EMIF_CS2_SPACE_BASE + SZ_32M - 1,
    102		.flags		= IORESOURCE_MEM,
    103	}, {
    104		.start		= DM646X_ASYNC_EMIF_CONTROL_BASE,
    105		.end		= DM646X_ASYNC_EMIF_CONTROL_BASE + SZ_4K - 1,
    106		.flags		= IORESOURCE_MEM,
    107	},
    108};
    109
    110static struct platform_device davinci_aemif_devices[] = {
    111	{
    112		.name		= "davinci_nand",
    113		.id		= 0,
    114		.num_resources	= ARRAY_SIZE(davinci_nand_resources),
    115		.resource	= davinci_nand_resources,
    116		.dev		= {
    117			.platform_data	= &davinci_nand_data,
    118		},
    119	},
    120};
    121
    122static struct resource davinci_aemif_resources[] = {
    123	{
    124		.start	= DM646X_ASYNC_EMIF_CONTROL_BASE,
    125		.end	= DM646X_ASYNC_EMIF_CONTROL_BASE + SZ_4K - 1,
    126		.flags	= IORESOURCE_MEM,
    127	},
    128};
    129
    130static struct aemif_abus_data davinci_aemif_abus_data[] = {
    131	{
    132		.cs	= 1,
    133	},
    134};
    135
    136static struct aemif_platform_data davinci_aemif_pdata = {
    137	.abus_data		= davinci_aemif_abus_data,
    138	.num_abus_data		= ARRAY_SIZE(davinci_aemif_abus_data),
    139	.sub_devices		= davinci_aemif_devices,
    140	.num_sub_devices	= ARRAY_SIZE(davinci_aemif_devices),
    141};
    142
    143static struct platform_device davinci_aemif_device = {
    144	.name		= "ti-aemif",
    145	.id		= -1,
    146	.dev = {
    147		.platform_data	= &davinci_aemif_pdata,
    148	},
    149	.resource	= davinci_aemif_resources,
    150	.num_resources	= ARRAY_SIZE(davinci_aemif_resources),
    151};
    152
    153#define HAS_ATA		(IS_ENABLED(CONFIG_BLK_DEV_PALMCHIP_BK3710) || \
    154			 IS_ENABLED(CONFIG_PATA_BK3710))
    155
    156#ifdef CONFIG_I2C
    157/* CPLD Register 0 bits to control ATA */
    158#define DM646X_EVM_ATA_RST		BIT(0)
    159#define DM646X_EVM_ATA_PWD		BIT(1)
    160
    161/* CPLD Register 0 Client: used for I/O Control */
    162static int cpld_reg0_probe(struct i2c_client *client)
    163{
    164	if (HAS_ATA) {
    165		u8 data;
    166		struct i2c_msg msg[2] = {
    167			{
    168				.addr = client->addr,
    169				.flags = I2C_M_RD,
    170				.len = 1,
    171				.buf = &data,
    172			},
    173			{
    174				.addr = client->addr,
    175				.flags = 0,
    176				.len = 1,
    177				.buf = &data,
    178			},
    179		};
    180
    181		/* Clear ATA_RSTn and ATA_PWD bits to enable ATA operation. */
    182		i2c_transfer(client->adapter, msg, 1);
    183		data &= ~(DM646X_EVM_ATA_RST | DM646X_EVM_ATA_PWD);
    184		i2c_transfer(client->adapter, msg + 1, 1);
    185	}
    186
    187	return 0;
    188}
    189
    190static const struct i2c_device_id cpld_reg_ids[] = {
    191	{ "cpld_reg0", 0, },
    192	{ },
    193};
    194
    195static struct i2c_driver dm6467evm_cpld_driver = {
    196	.driver.name	= "cpld_reg0",
    197	.id_table	= cpld_reg_ids,
    198	.probe_new	= cpld_reg0_probe,
    199};
    200
    201/* LEDS */
    202
    203static struct gpio_led evm_leds[] = {
    204	{ .name = "DS1", .active_low = 1, },
    205	{ .name = "DS2", .active_low = 1, },
    206	{ .name = "DS3", .active_low = 1, },
    207	{ .name = "DS4", .active_low = 1, },
    208};
    209
    210static const struct gpio_led_platform_data evm_led_data = {
    211	.num_leds = ARRAY_SIZE(evm_leds),
    212	.leds     = evm_leds,
    213};
    214
    215static struct platform_device *evm_led_dev;
    216
    217static int evm_led_setup(struct i2c_client *client, int gpio,
    218			unsigned int ngpio, void *c)
    219{
    220	struct gpio_led *leds = evm_leds;
    221	int status;
    222
    223	while (ngpio--) {
    224		leds->gpio = gpio++;
    225		leds++;
    226	}
    227
    228	evm_led_dev = platform_device_alloc("leds-gpio", 0);
    229	platform_device_add_data(evm_led_dev, &evm_led_data,
    230				sizeof(evm_led_data));
    231
    232	evm_led_dev->dev.parent = &client->dev;
    233	status = platform_device_add(evm_led_dev);
    234	if (status < 0) {
    235		platform_device_put(evm_led_dev);
    236		evm_led_dev = NULL;
    237	}
    238	return status;
    239}
    240
    241static int evm_led_teardown(struct i2c_client *client, int gpio,
    242				unsigned ngpio, void *c)
    243{
    244	if (evm_led_dev) {
    245		platform_device_unregister(evm_led_dev);
    246		evm_led_dev = NULL;
    247	}
    248	return 0;
    249}
    250
    251static int evm_sw_gpio[4] = { -EINVAL, -EINVAL, -EINVAL, -EINVAL };
    252
    253static int evm_sw_setup(struct i2c_client *client, int gpio,
    254			unsigned ngpio, void *c)
    255{
    256	int status;
    257	int i;
    258	char label[10];
    259
    260	for (i = 0; i < 4; ++i) {
    261		snprintf(label, 10, "user_sw%d", i);
    262		status = gpio_request(gpio, label);
    263		if (status)
    264			goto out_free;
    265		evm_sw_gpio[i] = gpio++;
    266
    267		status = gpio_direction_input(evm_sw_gpio[i]);
    268		if (status)
    269			goto out_free;
    270
    271		status = gpio_export(evm_sw_gpio[i], 0);
    272		if (status)
    273			goto out_free;
    274	}
    275	return 0;
    276
    277out_free:
    278	for (i = 0; i < 4; ++i) {
    279		if (evm_sw_gpio[i] != -EINVAL) {
    280			gpio_free(evm_sw_gpio[i]);
    281			evm_sw_gpio[i] = -EINVAL;
    282		}
    283	}
    284	return status;
    285}
    286
    287static int evm_sw_teardown(struct i2c_client *client, int gpio,
    288			unsigned ngpio, void *c)
    289{
    290	int i;
    291
    292	for (i = 0; i < 4; ++i) {
    293		if (evm_sw_gpio[i] != -EINVAL) {
    294			gpio_unexport(evm_sw_gpio[i]);
    295			gpio_free(evm_sw_gpio[i]);
    296			evm_sw_gpio[i] = -EINVAL;
    297		}
    298	}
    299	return 0;
    300}
    301
    302static int evm_pcf_setup(struct i2c_client *client, int gpio,
    303			unsigned int ngpio, void *c)
    304{
    305	int status;
    306
    307	if (ngpio < 8)
    308		return -EINVAL;
    309
    310	status = evm_sw_setup(client, gpio, 4, c);
    311	if (status)
    312		return status;
    313
    314	return evm_led_setup(client, gpio+4, 4, c);
    315}
    316
    317static void evm_pcf_teardown(struct i2c_client *client, int gpio,
    318			unsigned int ngpio, void *c)
    319{
    320	BUG_ON(ngpio < 8);
    321
    322	evm_sw_teardown(client, gpio, 4, c);
    323	evm_led_teardown(client, gpio+4, 4, c);
    324}
    325
    326static struct pcf857x_platform_data pcf_data = {
    327	.gpio_base	= DAVINCI_N_GPIO+1,
    328	.setup		= evm_pcf_setup,
    329	.teardown	= evm_pcf_teardown,
    330};
    331
    332/* Most of this EEPROM is unused, but U-Boot uses some data:
    333 *  - 0x7f00, 6 bytes Ethernet Address
    334 *  - ... newer boards may have more
    335 */
    336
    337static struct nvmem_cell_info dm646x_evm_nvmem_cells[] = {
    338	{
    339		.name		= "macaddr",
    340		.offset		= 0x7f00,
    341		.bytes		= ETH_ALEN,
    342	}
    343};
    344
    345static struct nvmem_cell_table dm646x_evm_nvmem_cell_table = {
    346	.nvmem_name	= "1-00500",
    347	.cells		= dm646x_evm_nvmem_cells,
    348	.ncells		= ARRAY_SIZE(dm646x_evm_nvmem_cells),
    349};
    350
    351static struct nvmem_cell_lookup dm646x_evm_nvmem_cell_lookup = {
    352	.nvmem_name	= "1-00500",
    353	.cell_name	= "macaddr",
    354	.dev_id		= "davinci_emac.1",
    355	.con_id		= "mac-address",
    356};
    357
    358static const struct property_entry eeprom_properties[] = {
    359	PROPERTY_ENTRY_U32("pagesize", 64),
    360	{ }
    361};
    362
    363static const struct software_node eeprom_node = {
    364	.properties = eeprom_properties,
    365};
    366#endif
    367
    368static u8 dm646x_iis_serializer_direction[] = {
    369       TX_MODE, RX_MODE, INACTIVE_MODE, INACTIVE_MODE,
    370};
    371
    372static u8 dm646x_dit_serializer_direction[] = {
    373       TX_MODE,
    374};
    375
    376static struct snd_platform_data dm646x_evm_snd_data[] = {
    377	{
    378		.tx_dma_offset  = 0x400,
    379		.rx_dma_offset  = 0x400,
    380		.op_mode        = DAVINCI_MCASP_IIS_MODE,
    381		.num_serializer = ARRAY_SIZE(dm646x_iis_serializer_direction),
    382		.tdm_slots      = 2,
    383		.serial_dir     = dm646x_iis_serializer_direction,
    384		.asp_chan_q     = EVENTQ_0,
    385	},
    386	{
    387		.tx_dma_offset  = 0x400,
    388		.rx_dma_offset  = 0,
    389		.op_mode        = DAVINCI_MCASP_DIT_MODE,
    390		.num_serializer = ARRAY_SIZE(dm646x_dit_serializer_direction),
    391		.tdm_slots      = 32,
    392		.serial_dir     = dm646x_dit_serializer_direction,
    393		.asp_chan_q     = EVENTQ_0,
    394	},
    395};
    396
    397#ifdef CONFIG_I2C
    398static struct i2c_client *cpld_client;
    399
    400static int cpld_video_probe(struct i2c_client *client)
    401{
    402	cpld_client = client;
    403	return 0;
    404}
    405
    406static int cpld_video_remove(struct i2c_client *client)
    407{
    408	cpld_client = NULL;
    409	return 0;
    410}
    411
    412static const struct i2c_device_id cpld_video_id[] = {
    413	{ "cpld_video", 0 },
    414	{ }
    415};
    416
    417static struct i2c_driver cpld_video_driver = {
    418	.driver = {
    419		.name	= "cpld_video",
    420	},
    421	.probe_new	= cpld_video_probe,
    422	.remove		= cpld_video_remove,
    423	.id_table	= cpld_video_id,
    424};
    425
    426static void evm_init_cpld(void)
    427{
    428	i2c_add_driver(&cpld_video_driver);
    429}
    430
    431static struct i2c_board_info __initdata i2c_info[] =  {
    432	{
    433		I2C_BOARD_INFO("24c256", 0x50),
    434		.swnode = &eeprom_node,
    435	},
    436	{
    437		I2C_BOARD_INFO("pcf8574a", 0x38),
    438		.platform_data	= &pcf_data,
    439	},
    440	{
    441		I2C_BOARD_INFO("cpld_reg0", 0x3a),
    442	},
    443	{
    444		I2C_BOARD_INFO("tlv320aic33", 0x18),
    445	},
    446	{
    447		I2C_BOARD_INFO("cpld_video", 0x3b),
    448	},
    449};
    450
    451static struct davinci_i2c_platform_data i2c_pdata = {
    452	.bus_freq       = 100 /* kHz */,
    453	.bus_delay      = 0 /* usec */,
    454};
    455
    456#define VCH2CLK_MASK		(BIT_MASK(10) | BIT_MASK(9) | BIT_MASK(8))
    457#define VCH2CLK_SYSCLK8		(BIT(9))
    458#define VCH2CLK_AUXCLK		(BIT(9) | BIT(8))
    459#define VCH3CLK_MASK		(BIT_MASK(14) | BIT_MASK(13) | BIT_MASK(12))
    460#define VCH3CLK_SYSCLK8		(BIT(13))
    461#define VCH3CLK_AUXCLK		(BIT(14) | BIT(13))
    462
    463#define VIDCH2CLK		(BIT(10))
    464#define VIDCH3CLK		(BIT(11))
    465#define VIDCH1CLK		(BIT(4))
    466#define TVP7002_INPUT		(BIT(4))
    467#define TVP5147_INPUT		(~BIT(4))
    468#define VPIF_INPUT_ONE_CHANNEL	(BIT(5))
    469#define VPIF_INPUT_TWO_CHANNEL	(~BIT(5))
    470#define TVP5147_CH0		"tvp514x-0"
    471#define TVP5147_CH1		"tvp514x-1"
    472
    473/* spin lock for updating above registers */
    474static spinlock_t vpif_reg_lock;
    475
    476static int set_vpif_clock(int mux_mode, int hd)
    477{
    478	unsigned long flags;
    479	unsigned int value;
    480	int val = 0;
    481	int err = 0;
    482
    483	if (!cpld_client)
    484		return -ENXIO;
    485
    486	/* disable the clock */
    487	spin_lock_irqsave(&vpif_reg_lock, flags);
    488	value = __raw_readl(DAVINCI_SYSMOD_VIRT(SYSMOD_VSCLKDIS));
    489	value |= (VIDCH3CLK | VIDCH2CLK);
    490	__raw_writel(value, DAVINCI_SYSMOD_VIRT(SYSMOD_VSCLKDIS));
    491	spin_unlock_irqrestore(&vpif_reg_lock, flags);
    492
    493	val = i2c_smbus_read_byte(cpld_client);
    494	if (val < 0)
    495		return val;
    496
    497	if (mux_mode == 1)
    498		val &= ~0x40;
    499	else
    500		val |= 0x40;
    501
    502	err = i2c_smbus_write_byte(cpld_client, val);
    503	if (err)
    504		return err;
    505
    506	value = __raw_readl(DAVINCI_SYSMOD_VIRT(SYSMOD_VIDCLKCTL));
    507	value &= ~(VCH2CLK_MASK);
    508	value &= ~(VCH3CLK_MASK);
    509
    510	if (hd >= 1)
    511		value |= (VCH2CLK_SYSCLK8 | VCH3CLK_SYSCLK8);
    512	else
    513		value |= (VCH2CLK_AUXCLK | VCH3CLK_AUXCLK);
    514
    515	__raw_writel(value, DAVINCI_SYSMOD_VIRT(SYSMOD_VIDCLKCTL));
    516
    517	spin_lock_irqsave(&vpif_reg_lock, flags);
    518	value = __raw_readl(DAVINCI_SYSMOD_VIRT(SYSMOD_VSCLKDIS));
    519	/* enable the clock */
    520	value &= ~(VIDCH3CLK | VIDCH2CLK);
    521	__raw_writel(value, DAVINCI_SYSMOD_VIRT(SYSMOD_VSCLKDIS));
    522	spin_unlock_irqrestore(&vpif_reg_lock, flags);
    523
    524	return 0;
    525}
    526
    527static struct vpif_subdev_info dm646x_vpif_subdev[] = {
    528	{
    529		.name	= "adv7343",
    530		.board_info = {
    531			I2C_BOARD_INFO("adv7343", 0x2a),
    532		},
    533	},
    534	{
    535		.name	= "ths7303",
    536		.board_info = {
    537			I2C_BOARD_INFO("ths7303", 0x2c),
    538		},
    539	},
    540};
    541
    542static const struct vpif_output dm6467_ch0_outputs[] = {
    543	{
    544		.output = {
    545			.index = 0,
    546			.name = "Composite",
    547			.type = V4L2_OUTPUT_TYPE_ANALOG,
    548			.capabilities = V4L2_OUT_CAP_STD,
    549			.std = V4L2_STD_ALL,
    550		},
    551		.subdev_name = "adv7343",
    552		.output_route = ADV7343_COMPOSITE_ID,
    553	},
    554	{
    555		.output = {
    556			.index = 1,
    557			.name = "Component",
    558			.type = V4L2_OUTPUT_TYPE_ANALOG,
    559			.capabilities = V4L2_OUT_CAP_DV_TIMINGS,
    560		},
    561		.subdev_name = "adv7343",
    562		.output_route = ADV7343_COMPONENT_ID,
    563	},
    564	{
    565		.output = {
    566			.index = 2,
    567			.name = "S-Video",
    568			.type = V4L2_OUTPUT_TYPE_ANALOG,
    569			.capabilities = V4L2_OUT_CAP_STD,
    570			.std = V4L2_STD_ALL,
    571		},
    572		.subdev_name = "adv7343",
    573		.output_route = ADV7343_SVIDEO_ID,
    574	},
    575};
    576
    577static struct vpif_display_config dm646x_vpif_display_config = {
    578	.set_clock	= set_vpif_clock,
    579	.subdevinfo	= dm646x_vpif_subdev,
    580	.subdev_count	= ARRAY_SIZE(dm646x_vpif_subdev),
    581	.i2c_adapter_id = 1,
    582	.chan_config[0] = {
    583		.outputs = dm6467_ch0_outputs,
    584		.output_count = ARRAY_SIZE(dm6467_ch0_outputs),
    585	},
    586	.card_name	= "DM646x EVM Video Display",
    587};
    588
    589/**
    590 * setup_vpif_input_path()
    591 * @channel: channel id (0 - CH0, 1 - CH1)
    592 * @sub_dev_name: ptr sub device name
    593 *
    594 * This will set vpif input to capture data from tvp514x or
    595 * tvp7002.
    596 */
    597static int setup_vpif_input_path(int channel, const char *sub_dev_name)
    598{
    599	int err = 0;
    600	int val;
    601
    602	/* for channel 1, we don't do anything */
    603	if (channel != 0)
    604		return 0;
    605
    606	if (!cpld_client)
    607		return -ENXIO;
    608
    609	val = i2c_smbus_read_byte(cpld_client);
    610	if (val < 0)
    611		return val;
    612
    613	if (!strcmp(sub_dev_name, TVP5147_CH0) ||
    614	    !strcmp(sub_dev_name, TVP5147_CH1))
    615		val &= TVP5147_INPUT;
    616	else
    617		val |= TVP7002_INPUT;
    618
    619	err = i2c_smbus_write_byte(cpld_client, val);
    620	if (err)
    621		return err;
    622	return 0;
    623}
    624
    625/**
    626 * setup_vpif_input_channel_mode()
    627 * @mux_mode:  mux mode. 0 - 1 channel or (1) - 2 channel
    628 *
    629 * This will setup input mode to one channel (TVP7002) or 2 channel (TVP5147)
    630 */
    631static int setup_vpif_input_channel_mode(int mux_mode)
    632{
    633	unsigned long flags;
    634	int err = 0;
    635	int val;
    636	u32 value;
    637
    638	if (!cpld_client)
    639		return -ENXIO;
    640
    641	val = i2c_smbus_read_byte(cpld_client);
    642	if (val < 0)
    643		return val;
    644
    645	spin_lock_irqsave(&vpif_reg_lock, flags);
    646	value = __raw_readl(DAVINCI_SYSMOD_VIRT(SYSMOD_VIDCLKCTL));
    647	if (mux_mode) {
    648		val &= VPIF_INPUT_TWO_CHANNEL;
    649		value |= VIDCH1CLK;
    650	} else {
    651		val |= VPIF_INPUT_ONE_CHANNEL;
    652		value &= ~VIDCH1CLK;
    653	}
    654	__raw_writel(value, DAVINCI_SYSMOD_VIRT(SYSMOD_VIDCLKCTL));
    655	spin_unlock_irqrestore(&vpif_reg_lock, flags);
    656
    657	err = i2c_smbus_write_byte(cpld_client, val);
    658	if (err)
    659		return err;
    660
    661	return 0;
    662}
    663
    664static struct tvp514x_platform_data tvp5146_pdata = {
    665	.clk_polarity = 0,
    666	.hs_polarity = 1,
    667	.vs_polarity = 1
    668};
    669
    670#define TVP514X_STD_ALL (V4L2_STD_NTSC | V4L2_STD_PAL)
    671
    672static struct vpif_subdev_info vpif_capture_sdev_info[] = {
    673	{
    674		.name	= TVP5147_CH0,
    675		.board_info = {
    676			I2C_BOARD_INFO("tvp5146", 0x5d),
    677			.platform_data = &tvp5146_pdata,
    678		},
    679	},
    680	{
    681		.name	= TVP5147_CH1,
    682		.board_info = {
    683			I2C_BOARD_INFO("tvp5146", 0x5c),
    684			.platform_data = &tvp5146_pdata,
    685		},
    686	},
    687};
    688
    689static struct vpif_input dm6467_ch0_inputs[] = {
    690	{
    691		.input = {
    692			.index = 0,
    693			.name = "Composite",
    694			.type = V4L2_INPUT_TYPE_CAMERA,
    695			.capabilities = V4L2_IN_CAP_STD,
    696			.std = TVP514X_STD_ALL,
    697		},
    698		.subdev_name = TVP5147_CH0,
    699		.input_route = INPUT_CVBS_VI2B,
    700		.output_route = OUTPUT_10BIT_422_EMBEDDED_SYNC,
    701	},
    702};
    703
    704static struct vpif_input dm6467_ch1_inputs[] = {
    705       {
    706		.input = {
    707			.index = 0,
    708			.name = "S-Video",
    709			.type = V4L2_INPUT_TYPE_CAMERA,
    710			.capabilities = V4L2_IN_CAP_STD,
    711			.std = TVP514X_STD_ALL,
    712		},
    713		.subdev_name = TVP5147_CH1,
    714		.input_route = INPUT_SVIDEO_VI2C_VI1C,
    715		.output_route = OUTPUT_10BIT_422_EMBEDDED_SYNC,
    716	},
    717};
    718
    719static struct vpif_capture_config dm646x_vpif_capture_cfg = {
    720	.setup_input_path = setup_vpif_input_path,
    721	.setup_input_channel_mode = setup_vpif_input_channel_mode,
    722	.subdev_info = vpif_capture_sdev_info,
    723	.subdev_count = ARRAY_SIZE(vpif_capture_sdev_info),
    724	.i2c_adapter_id = 1,
    725	.chan_config[0] = {
    726		.inputs = dm6467_ch0_inputs,
    727		.input_count = ARRAY_SIZE(dm6467_ch0_inputs),
    728		.vpif_if = {
    729			.if_type = VPIF_IF_BT656,
    730			.hd_pol = 1,
    731			.vd_pol = 1,
    732			.fid_pol = 0,
    733		},
    734	},
    735	.chan_config[1] = {
    736		.inputs = dm6467_ch1_inputs,
    737		.input_count = ARRAY_SIZE(dm6467_ch1_inputs),
    738		.vpif_if = {
    739			.if_type = VPIF_IF_BT656,
    740			.hd_pol = 1,
    741			.vd_pol = 1,
    742			.fid_pol = 0,
    743		},
    744	},
    745	.card_name = "DM646x EVM Video Capture",
    746};
    747
    748static void __init evm_init_video(void)
    749{
    750	spin_lock_init(&vpif_reg_lock);
    751
    752	dm646x_setup_vpif(&dm646x_vpif_display_config,
    753			  &dm646x_vpif_capture_cfg);
    754}
    755
    756static void __init evm_init_i2c(void)
    757{
    758	davinci_init_i2c(&i2c_pdata);
    759	i2c_add_driver(&dm6467evm_cpld_driver);
    760	i2c_register_board_info(1, i2c_info, ARRAY_SIZE(i2c_info));
    761	evm_init_cpld();
    762	evm_init_video();
    763}
    764#endif
    765
    766#define DM646X_REF_FREQ			27000000
    767#define DM646X_AUX_FREQ			24000000
    768#define DM6467T_EVM_REF_FREQ		33000000
    769
    770static void __init davinci_map_io(void)
    771{
    772	dm646x_init();
    773}
    774
    775static void __init dm646x_evm_init_time(void)
    776{
    777	dm646x_init_time(DM646X_REF_FREQ, DM646X_AUX_FREQ);
    778}
    779
    780static void __init dm6467t_evm_init_time(void)
    781{
    782	dm646x_init_time(DM6467T_EVM_REF_FREQ, DM646X_AUX_FREQ);
    783}
    784
    785#define DM646X_EVM_PHY_ID		"davinci_mdio-0:01"
    786/*
    787 * The following EDMA channels/slots are not being used by drivers (for
    788 * example: Timer, GPIO, UART events etc) on dm646x, hence they are being
    789 * reserved for codecs on the DSP side.
    790 */
    791static const s16 dm646x_dma_rsv_chans[][2] = {
    792	/* (offset, number) */
    793	{ 0,  4},
    794	{13,  3},
    795	{24,  4},
    796	{30,  2},
    797	{54,  3},
    798	{-1, -1}
    799};
    800
    801static const s16 dm646x_dma_rsv_slots[][2] = {
    802	/* (offset, number) */
    803	{ 0,  4},
    804	{13,  3},
    805	{24,  4},
    806	{30,  2},
    807	{54,  3},
    808	{128, 384},
    809	{-1, -1}
    810};
    811
    812static struct edma_rsv_info dm646x_edma_rsv[] = {
    813	{
    814		.rsv_chans	= dm646x_dma_rsv_chans,
    815		.rsv_slots	= dm646x_dma_rsv_slots,
    816	},
    817};
    818
    819static __init void evm_init(void)
    820{
    821	int ret;
    822	struct davinci_soc_info *soc_info = &davinci_soc_info;
    823
    824	dm646x_register_clocks();
    825
    826	ret = dm646x_gpio_register();
    827	if (ret)
    828		pr_warn("%s: GPIO init failed: %d\n", __func__, ret);
    829
    830#ifdef CONFIG_I2C
    831	nvmem_add_cell_table(&dm646x_evm_nvmem_cell_table);
    832	nvmem_add_cell_lookups(&dm646x_evm_nvmem_cell_lookup, 1);
    833	evm_init_i2c();
    834#endif
    835
    836	davinci_serial_init(dm646x_serial_device);
    837	dm646x_init_mcasp0(&dm646x_evm_snd_data[0]);
    838	dm646x_init_mcasp1(&dm646x_evm_snd_data[1]);
    839
    840	if (machine_is_davinci_dm6467tevm())
    841		davinci_nand_data.timing = &dm6467tevm_nandflash_timing;
    842
    843	if (platform_device_register(&davinci_aemif_device))
    844		pr_warn("%s: Cannot register AEMIF device.\n", __func__);
    845
    846	dm646x_init_edma(dm646x_edma_rsv);
    847
    848	if (HAS_ATA)
    849		davinci_init_ide();
    850
    851	soc_info->emac_pdata->phy_id = DM646X_EVM_PHY_ID;
    852}
    853
    854MACHINE_START(DAVINCI_DM6467_EVM, "DaVinci DM646x EVM")
    855	.atag_offset  = 0x100,
    856	.map_io       = davinci_map_io,
    857	.init_irq     = dm646x_init_irq,
    858	.init_time	= dm646x_evm_init_time,
    859	.init_machine = evm_init,
    860	.init_late	= davinci_init_late,
    861	.dma_zone_size	= SZ_128M,
    862MACHINE_END
    863
    864MACHINE_START(DAVINCI_DM6467TEVM, "DaVinci DM6467T EVM")
    865	.atag_offset  = 0x100,
    866	.map_io       = davinci_map_io,
    867	.init_irq     = dm646x_init_irq,
    868	.init_time	= dm6467t_evm_init_time,
    869	.init_machine = evm_init,
    870	.init_late	= davinci_init_late,
    871	.dma_zone_size	= SZ_128M,
    872MACHINE_END
    873