All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2/2] TVP514x V4L int device driver support
@ 2008-11-21 15:22 ` hvaibhav
  2008-11-21 16:16   ` Hans Verkuil
                     ` (3 more replies)
  0 siblings, 4 replies; 263+ messages in thread
From: hvaibhav @ 2008-11-21 15:22 UTC (permalink / raw)
  To: video4linux-list; +Cc: linux-omap, davinci-linux-open-source-bounces

From: Vaibhav Hiremath <hvaibhav@ti.com>

Added new V4L2 slave driver for TVP514x.

The Driver interface has been tested on OMAP3EVM board
with TI daughter card (TVP5146). Soon the patch for Daughter card will
be posted on community.

Signed-off-by: Brijesh Jadav <brijesh.j@ti.com>
		Hardik Shah <hardik.shah@ti.com>
		Manjunath Hadli <mrh@ti.com>
		R Sivaraj <sivaraj@ti.com>
		Vaibhav Hiremath <hvaibhav@ti.com>
		Karicheri Muralidharan <m-karicheri2@ti.com>
---
 drivers/media/video/Kconfig   |   11 +
 drivers/media/video/Makefile  |    1 +
 drivers/media/video/tvp514x.c | 1331 +++++++++++++++++++++++++++++++++++++++++
 include/media/tvp514x.h       |  406 +++++++++++++
 4 files changed, 1749 insertions(+), 0 deletions(-)
 create mode 100644 drivers/media/video/tvp514x.c
 create mode 100644 include/media/tvp514x.h

diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig
index 47102c2..377d14e 100644
--- a/drivers/media/video/Kconfig
+++ b/drivers/media/video/Kconfig
@@ -361,6 +361,17 @@ config VIDEO_SAA7191
 	  To compile this driver as a module, choose M here: the
 	  module will be called saa7191.

+config VIDEO_TVP514X
+	tristate "Texas Instruments TVP5146/47 video decoder"
+	depends on VIDEO_V4L2 && I2C
+	---help---
+	  This is a Video4Linux2 sensor-level driver for the TI TVP5146/47
+	  decoder. It is currently working with the TI OMAP3 camera
+	  controller.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called tvp514x.
+
 config VIDEO_TVP5150
 	tristate "Texas Instruments TVP5150 video decoder"
 	depends on VIDEO_V4L2 && I2C
diff --git a/drivers/media/video/Makefile b/drivers/media/video/Makefile
index 16962f3..cdbbf38 100644
--- a/drivers/media/video/Makefile
+++ b/drivers/media/video/Makefile
@@ -66,6 +66,7 @@ obj-$(CONFIG_VIDEO_CX88) += cx88/
 obj-$(CONFIG_VIDEO_EM28XX) += em28xx/
 obj-$(CONFIG_VIDEO_USBVISION) += usbvision/
 obj-$(CONFIG_VIDEO_TVP5150) += tvp5150.o
+obj-$(CONFIG_VIDEO_TVP514X) += tvp514x.o
 obj-$(CONFIG_VIDEO_PVRUSB2) += pvrusb2/
 obj-$(CONFIG_VIDEO_MSP3400) += msp3400.o
 obj-$(CONFIG_VIDEO_CS5345) += cs5345.o
diff --git a/drivers/media/video/tvp514x.c b/drivers/media/video/tvp514x.c
new file mode 100644
index 0000000..b68ddf5
--- /dev/null
+++ b/drivers/media/video/tvp514x.c
@@ -0,0 +1,1331 @@
+/*
+ * drivers/media/video/tvp514x.c
+ *
+ * TI TVP5146/47 decoder driver
+ *
+ * Copyright (C) 2008 Texas Instruments Inc
+ *
+ * Contributors:
+ *     Brijesh R Jadav <brijesh.j@ti.com>
+ *     Hardik Shah <hardik.shah@ti.com>
+ *     Manjunath Hadli <mrh@ti.com>
+ *     Sivaraj R <sivaraj@ti.com>
+ *     Vaibhav Hiremath <hvaibhav@ti.com>
+ *
+ * This package is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#include <linux/i2c.h>
+#include <linux/delay.h>
+#include <linux/videodev2.h>
+#include <media/v4l2-int-device.h>
+#include <media/tvp514x.h>
+
+#define MODULE_NAME	TVP514X_MODULE_NAME
+
+/* Debug functions */
+#ifdef CONFIG_VIDEO_ADV_DEBUG
+
+#define dump_reg(client, reg, val)					\
+	do {								\
+		tvp514x_read_reg(client, reg, &val);			\
+		dev_dbg(&(client)->dev, "Reg(0x%.2X): 0x%.2X\n", reg, val); \
+	} while (0)
+
+#endif				/* #ifdef CONFIG_VIDEO_ADV_DEBUG */
+
+/* List of image formats supported by TVP5146/47 decoder
+ * Currently we are using 8 bit mode only, but can be
+ * extended to 10/20 bit mode.
+ */
+static const struct v4l2_fmtdesc tvp514x_fmt_list[] = {
+	{
+	 .index = 0,
+	 .type = V4L2_BUF_TYPE_VIDEO_CAPTURE,
+	 .flags = 0,
+	 .description = "8-bit UYVY 4:2:2 Format",
+	 .pixelformat = V4L2_PIX_FMT_UYVY,
+	 }
+};
+
+#define TVP514X_NUM_FORMATS		ARRAY_SIZE(tvp514x_fmt_list)
+
+/*
+ * Supported standards - These must be ordered according to enum tvp514x_std
+ * order.
+ * Currently supports two standards only, need to add support for rest of the
+ * modes, like SECAM, etc...
+ */
+static struct tvp514x_std_info tvp514x_std_list[] = {
+	{
+	 .width = NTSC_NUM_ACTIVE_PIXELS,
+	 .height = NTSC_NUM_ACTIVE_LINES,
+	 .video_std = VIDEO_STD_NTSC_MJ_BIT,
+	 .standard = {
+		      .index = 0,
+		      .id = V4L2_STD_NTSC,
+		      .name = "NTSC",
+		      .frameperiod = {1001, 30000},
+		      .framelines = 525}
+	 },
+	{
+	 .width = PAL_NUM_ACTIVE_PIXELS,
+	 .height = PAL_NUM_ACTIVE_LINES,
+	 .video_std = VIDEO_STD_PAL_BDGHIN_BIT,
+	 .standard = {
+		      .index = 1,
+		      .id = V4L2_STD_PAL,
+		      .name = "PAL",
+		      .frameperiod = {1, 25},
+		      .framelines = 625}
+	 }
+};
+
+#define TVP514X_NUM_STANDARDS		ARRAY_SIZE(tvp514x_std_list)
+
+/* Supported controls */
+static const struct tvp514x_ctrl_info tvp514x_ctrl_list[] = {
+	{
+	 .reg_address = REG_BRIGHTNESS,
+	 .query_ctrl = {
+			.id = V4L2_CID_BRIGHTNESS,
+			.name = "BRIGHTNESS",
+			.type = V4L2_CTRL_TYPE_INTEGER,
+			.minimum = 0,
+			.maximum = 255,
+			.step = 1,
+			.default_value = 128}
+	 },
+	{
+	 .reg_address = REG_CONTRAST,
+	 .query_ctrl = {
+			.id = V4L2_CID_CONTRAST,
+			.name = "CONTRAST",
+			.type = V4L2_CTRL_TYPE_INTEGER,
+			.minimum = 0,
+			.maximum = 255,
+			.step = 1,
+			.default_value = 128}
+	 },
+	{
+	 .reg_address = REG_SATURATION,
+	 .query_ctrl = {
+			.id = V4L2_CID_SATURATION,
+			.name = "SATURATION",
+			.type = V4L2_CTRL_TYPE_INTEGER,
+			.minimum = 0,
+			.maximum = 255,
+			.step = 1,
+			.default_value = 128}
+	 },
+	{
+	 .reg_address = REG_HUE,
+	 .query_ctrl = {
+			.id = V4L2_CID_HUE,
+			.name = "HUE",
+			.type = V4L2_CTRL_TYPE_INTEGER,
+			.minimum = -180,
+			.maximum = 180,
+			.step = 180,
+			.default_value = 0}
+	 },
+	{
+	 .reg_address = REG_AFE_GAIN_CTRL,
+	 .query_ctrl = {
+			.id = V4L2_CID_AUTOGAIN,
+			.name = "Automatic Gain Control",
+			.type = V4L2_CTRL_TYPE_BOOLEAN,
+			.minimum = 0,
+			.maximum = 1,
+			.step = 1,
+			.default_value = 1}
+	 }
+};
+
+#define TVP514X_NUM_CONTROLS		ARRAY_SIZE(tvp514x_ctrl_list)
+
+/*
+ * Read a value from a register in an TVP5146/47 decoder device.
+ * The value is returned in 'val'.
+ * Returns zero if successful, or non-zero otherwise.
+ */
+static int tvp514x_read_reg(struct i2c_client *client, u8 reg, u8 *val)
+{
+	int err;
+	struct i2c_msg msg[2];
+	u8 data;
+
+	if (!client->adapter)
+		return -ENODEV;
+
+	/* [MSG1] fill the register address data */
+	data = reg;
+	msg[0].addr = client->addr;
+	msg[0].len = 1;
+	msg[0].flags = 0;
+	msg[0].buf = &data;
+
+	/* [MSG2] fill the data rx buffer */
+	msg[1].addr = client->addr;
+	msg[1].len = 1;		/* only 1 byte */
+	msg[1].flags = I2C_M_RD;	/* Read the register values */
+	msg[1].buf = val;
+	err = i2c_transfer(client->adapter, msg, 2);
+	if (err >= 0)
+		return 0;
+
+	dev_err(&client->dev,
+		"read from device 0x%.2x, offset 0x%.2x error %d\n",
+		client->addr, reg, err);
+
+	return err;
+}
+
+/*
+ * Write a value to a register in an TVP5146/47 decoder device.
+ * Returns zero if successful, or non-zero otherwise.
+ */
+static int tvp514x_write_reg(struct i2c_client *client, u8 reg, u8 val)
+{
+	int err;
+	int retry = 0;
+	struct i2c_msg msg[1];
+	u8 data[2];
+
+	if (!client->adapter)
+		return -ENODEV;
+
+again:
+	data[0] = reg;		/* Register offset */
+	data[1] = val;		/* Register value */
+	msg->addr = client->addr;
+	msg->len = 2;
+	msg->flags = 0;		/* write operation */
+	msg->buf = data;
+
+	err = i2c_transfer(client->adapter, msg, 1);
+	if (err >= 0)
+		return 0;
+
+	dev_err(&client->dev,
+		"wrote 0x%.2x to offset 0x%.2x error %d\n", val, reg, err);
+	if (retry <= I2C_RETRY_COUNT) {
+		dev_info(&client->dev, "retry ... %d\n", retry);
+		retry++;
+		schedule_timeout(msecs_to_jiffies(20));
+		goto again;
+	}
+	return err;
+}
+
+/*
+ * tvp514x_write_regs : Initializes a list of TVP5146/47 registers
+ *		if token is TOK_TERM, then entire write operation terminates
+ *		if token is TOK_DELAY, then a delay of 'val' msec is introduced
+ *		if token is TOK_SKIP, then the register write is skipped
+ *		if token is TOK_WRITE, then the register write is performed
+ *
+ * reglist - list of registers to be written
+ * Returns zero if successful, or non-zero otherwise.
+ */
+static int tvp514x_write_regs(struct i2c_client *client,
+			      const struct tvp514x_reg reglist[])
+{
+	int err;
+	const struct tvp514x_reg *next = reglist;
+
+	for (; next->token != TOK_TERM; next++) {
+		if (next->token == TOK_DELAY) {
+			schedule_timeout(msecs_to_jiffies(next->val));
+			continue;
+		}
+
+		if (next->token == TOK_SKIP)
+			continue;
+
+		err = tvp514x_write_reg(client, next->reg, (u8) next->val);
+		if (err) {
+			dev_err(&client->dev, "write failed. Err[%d]\n",
+				err);
+			return err;
+		}
+	}
+	return 0;
+}
+
+/*
+ * tvp514x_get_current_std:
+ * Returns the current standard detected by TVP5146/47
+ */
+static enum tvp514x_std tvp514x_get_current_std(struct tvp514x_decoder
+						*decoder)
+{
+	u8 std, std_status;
+
+	if (tvp514x_read_reg(decoder->client, REG_VIDEO_STD, &std))
+		return STD_INVALID;
+
+	if ((std & VIDEO_STD_MASK) == VIDEO_STD_AUTO_SWITCH_BIT) {
+		/* use the standard status register */
+		if (tvp514x_read_reg(decoder->client, REG_VIDEO_STD_STATUS,
+				     &std_status))
+			return STD_INVALID;
+	} else
+		std_status = std;	/* use the standard register itself */
+
+	switch (std_status & VIDEO_STD_MASK) {
+	case VIDEO_STD_NTSC_MJ_BIT:
+		return STD_NTSC_MJ;
+		break;
+
+	case VIDEO_STD_PAL_BDGHIN_BIT:
+		return STD_PAL_BDGHIN;
+		break;
+
+	default:
+		return STD_INVALID;
+		break;
+	}
+
+	return STD_INVALID;
+}
+
+#ifdef CONFIG_VIDEO_ADV_DEBUG
+/*
+ * TVP5146/47 register dump function
+ */
+void tvp514x_reg_dump(struct tvp514x_decoder *decoder)
+{
+	u8 value;
+
+	dump_reg(decoder->client, REG_INPUT_SEL, value);
+	dump_reg(decoder->client, REG_AFE_GAIN_CTRL, value);
+	dump_reg(decoder->client, REG_VIDEO_STD, value);
+	dump_reg(decoder->client, REG_OPERATION_MODE, value);
+	dump_reg(decoder->client, REG_COLOR_KILLER, value);
+	dump_reg(decoder->client, REG_LUMA_CONTROL1, value);
+	dump_reg(decoder->client, REG_LUMA_CONTROL2, value);
+	dump_reg(decoder->client, REG_LUMA_CONTROL3, value);
+	dump_reg(decoder->client, REG_BRIGHTNESS, value);
+	dump_reg(decoder->client, REG_CONTRAST, value);
+	dump_reg(decoder->client, REG_SATURATION, value);
+	dump_reg(decoder->client, REG_HUE, value);
+	dump_reg(decoder->client, REG_CHROMA_CONTROL1, value);
+	dump_reg(decoder->client, REG_CHROMA_CONTROL2, value);
+	dump_reg(decoder->client, REG_COMP_PR_SATURATION, value);
+	dump_reg(decoder->client, REG_COMP_Y_CONTRAST, value);
+	dump_reg(decoder->client, REG_COMP_PB_SATURATION, value);
+	dump_reg(decoder->client, REG_COMP_Y_BRIGHTNESS, value);
+	dump_reg(decoder->client, REG_AVID_START_PIXEL_LSB, value);
+	dump_reg(decoder->client, REG_AVID_START_PIXEL_MSB, value);
+	dump_reg(decoder->client, REG_AVID_STOP_PIXEL_LSB, value);
+	dump_reg(decoder->client, REG_AVID_STOP_PIXEL_MSB, value);
+	dump_reg(decoder->client, REG_HSYNC_START_PIXEL_LSB, value);
+	dump_reg(decoder->client, REG_HSYNC_START_PIXEL_MSB, value);
+	dump_reg(decoder->client, REG_HSYNC_STOP_PIXEL_LSB, value);
+	dump_reg(decoder->client, REG_HSYNC_STOP_PIXEL_MSB, value);
+	dump_reg(decoder->client, REG_VSYNC_START_LINE_LSB, value);
+	dump_reg(decoder->client, REG_VSYNC_START_LINE_MSB, value);
+	dump_reg(decoder->client, REG_VSYNC_STOP_LINE_LSB, value);
+	dump_reg(decoder->client, REG_VSYNC_STOP_LINE_MSB, value);
+	dump_reg(decoder->client, REG_VBLK_START_LINE_LSB, value);
+	dump_reg(decoder->client, REG_VBLK_START_LINE_MSB, value);
+	dump_reg(decoder->client, REG_VBLK_STOP_LINE_LSB, value);
+	dump_reg(decoder->client, REG_VBLK_STOP_LINE_MSB, value);
+	dump_reg(decoder->client, REG_SYNC_CONTROL, value);
+	dump_reg(decoder->client, REG_OUTPUT_FORMATTER1, value);
+	dump_reg(decoder->client, REG_OUTPUT_FORMATTER2, value);
+	dump_reg(decoder->client, REG_OUTPUT_FORMATTER3, value);
+	dump_reg(decoder->client, REG_OUTPUT_FORMATTER4, value);
+	dump_reg(decoder->client, REG_OUTPUT_FORMATTER5, value);
+	dump_reg(decoder->client, REG_OUTPUT_FORMATTER6, value);
+	dump_reg(decoder->client, REG_CLEAR_LOST_LOCK, value);
+}
+#endif		/* #ifdef CONFIG_VIDEO_ADV_DEBUG */
+
+/*
+ * Configure the TVP5146/47 with the current register settings
+ * Returns zero if successful, or non-zero otherwise.
+ */
+static int tvp514x_configure(struct tvp514x_decoder *decoder)
+{
+	int err;
+
+	/* common register initialization */
+	err =
+	    tvp514x_write_regs(decoder->client, decoder->pdata->reg_list);
+	if (err)
+		return err;
+
+#ifdef CONFIG_VIDEO_ADV_DEBUG
+	tvp514x_reg_dump(decoder);
+#endif
+
+	return 0;
+}
+
+/*
+ * Detect if an tvp514x is present, and if so which revision.
+ * A device is considered to be detected if the chip ID (LSB and MSB)
+ * registers match the expected values.
+ * Any value of the rom version register is accepted.
+ * Returns ENODEV error number if no device is detected, or zero
+ * if a device is detected.
+ */
+static int tvp514x_detect(struct tvp514x_decoder *decoder)
+{
+	u8 chip_id_msb, chip_id_lsb, rom_ver;
+
+	if (tvp514x_read_reg
+	    (decoder->client, REG_CHIP_ID_MSB, &chip_id_msb))
+		return -ENODEV;
+	if (tvp514x_read_reg
+	    (decoder->client, REG_CHIP_ID_LSB, &chip_id_lsb))
+		return -ENODEV;
+	if (tvp514x_read_reg(decoder->client, REG_ROM_VERSION, &rom_ver))
+		return -ENODEV;
+
+	dev_info(&decoder->client->dev,
+		 "chip id detected msb:0x%x lsb:0x%x rom version:0x%x\n",
+		 chip_id_msb, chip_id_lsb, rom_ver);
+	if ((chip_id_msb != TVP514X_CHIP_ID_MSB)
+		|| ((chip_id_lsb != TVP5146_CHIP_ID_LSB)
+		&& (chip_id_lsb != TVP5147_CHIP_ID_LSB))) {
+		/* We didn't read the values we expected, so this must not be
+		 * an TVP5146/47.
+		 */
+		dev_err(&decoder->client->dev,
+			"chip id mismatch msb:0x%x lsb:0x%x\n",
+			chip_id_msb, chip_id_lsb);
+		return -ENODEV;
+	}
+
+	decoder->ver = rom_ver;
+	decoder->state = STATE_DETECTED;
+
+	return 0;
+}
+
+/*
+ * Following are decoder interface functions implemented by
+ * TVP5146/47 decoder driver.
+ */
+
+/**
+ * ioctl_querystd - V4L2 decoder interface handler for VIDIOC_QUERYSTD ioctl
+ * @s: pointer to standard V4L2 device structure
+ * @std_id: standard V4L2 std_id ioctl enum
+ *
+ * Returns the current standard detected by TVP5146/47. If no active input is
+ * detected, returns -EINVAL
+ */
+static int ioctl_querystd(struct v4l2_int_device *s, v4l2_std_id *std_id)
+{
+	struct tvp514x_decoder *decoder = s->priv;
+	enum tvp514x_std current_std;
+	u8 sync_lock_status, lock_mask;
+
+	if (std_id == NULL)
+		return -EINVAL;
+
+	/* get the current standard */
+	current_std = tvp514x_get_current_std(decoder);
+	if (current_std == STD_INVALID)
+		return -EINVAL;
+
+	/* check whether signal is locked */
+	if (tvp514x_read_reg
+	    (decoder->client, REG_STATUS1, &sync_lock_status))
+		return -EINVAL;
+
+	lock_mask =
+	    decoder->pdata->input_list[decoder->inputidx].lock_mask;
+	if (lock_mask != (sync_lock_status & lock_mask))
+		return -EINVAL;	/* No input detected */
+
+	decoder->current_std = current_std;
+	*std_id = decoder->std_list[current_std].standard.id;
+
+	return 0;
+}
+
+/**
+ * ioctl_s_std - V4L2 decoder interface handler for VIDIOC_S_STD ioctl
+ * @s: pointer to standard V4L2 device structure
+ * @std_id: standard V4L2 v4l2_std_id ioctl enum
+ *
+ * If std_id is supported, sets the requested standard. Otherwise, returns
+ * -EINVAL
+ */
+static int ioctl_s_std(struct v4l2_int_device *s, v4l2_std_id *std_id)
+{
+	struct tvp514x_decoder *decoder = s->priv;
+	int err, i;
+
+	if (std_id == NULL)
+		return -EINVAL;
+
+	for (i = 0; i < decoder->num_stds; i++)
+		if (*std_id & decoder->std_list[i].standard.id)
+			break;
+
+	if (i == decoder->num_stds)
+		return -EINVAL;
+
+	err = tvp514x_write_reg(decoder->client, REG_VIDEO_STD,
+				decoder->std_list[i].video_std);
+	if (err)
+		return err;
+
+	decoder->current_std = i;
+	decoder->pdata->reg_list[REG_VIDEO_STD].val =
+	    decoder->std_list[i].video_std;
+
+	return 0;
+}
+
+/**
+ * ioctl_enum_input - V4L2 decoder interface handler for VIDIOC_ENUMINPUT ioctl
+ * @s: pointer to standard V4L2 device structure
+ * @input: standard V4L2 VIDIOC_ENUMINPUT ioctl structure
+ *
+ * If index is valid, returns the description of the input. Otherwise, returns
+ * -EINVAL if any error occurs
+ */
+static int
+ioctl_enum_input(struct v4l2_int_device *s, struct v4l2_input *input)
+{
+	struct tvp514x_decoder *decoder = s->priv;
+	int index;
+
+	if (input == NULL)
+		return -EINVAL;
+
+	index = input->index;
+	if ((index >= decoder->pdata->num_inputs) || (index < 0))
+		return -EINVAL;	/* Index out of bound */
+
+	memcpy(input, &decoder->pdata->input_list[index].input,
+		sizeof(struct v4l2_input));
+
+	return 0;
+}
+
+/**
+ * ioctl_s_input - V4L2 decoder interface handler for VIDIOC_S_INPUT ioctl
+ * @s: pointer to standard V4L2 device structure
+ * @index: number of the input
+ *
+ * If index is valid, selects the requested input. Otherwise, returns -EINVAL if
+ * the input is not supported or there is no active signal present in the
+ * selected input.
+ */
+static int ioctl_s_input(struct v4l2_int_device *s, int index)
+{
+	struct tvp514x_decoder *decoder = s->priv;
+	u8 input_sel;
+	int err;
+	enum tvp514x_std current_std = STD_INVALID;
+	u8 sync_lock_status, lock_mask;
+	int try_count = LOCK_RETRY_COUNT;
+
+	if ((index >= decoder->pdata->num_inputs) || (index < 0))
+		return -EINVAL;	/* Index out of bound */
+
+	/* Get the register value to be written to select the requested input */
+	input_sel = decoder->pdata->input_list[index].input_sel;
+	err = tvp514x_write_reg(decoder->client, REG_INPUT_SEL, input_sel);
+	if (err)
+		return err;
+
+	decoder->inputidx = index;
+	decoder->pdata->reg_list[REG_INPUT_SEL].val = input_sel;
+
+	/* Clear status */
+	msleep(LOCK_RETRY_DELAY);
+	err =
+	    tvp514x_write_reg(decoder->client, REG_CLEAR_LOST_LOCK, 0x01);
+	if (err)
+		return err;
+
+	while (try_count-- > 0) {
+		/* Allow decoder to sync up with new input */
+		msleep(LOCK_RETRY_DELAY);
+
+		/* get the current standard for future reference */
+		current_std = tvp514x_get_current_std(decoder);
+		if (current_std == STD_INVALID)
+			continue;
+
+		if (tvp514x_read_reg(decoder->client, REG_STATUS1,
+					&sync_lock_status))
+			return -EINVAL;
+
+		lock_mask =
+		    decoder->pdata->input_list[decoder->inputidx].
+		    lock_mask;
+		if (lock_mask == (sync_lock_status & lock_mask))
+			break;	/* Input detected */
+	}
+
+	if ((current_std == STD_INVALID) || (try_count < 0))
+		return -EINVAL;
+
+	decoder->current_std = current_std;
+
+	return 0;
+}
+
+/**
+ * ioctl_g_input - V4L2 decoder interface handler for VIDIOC_G_INPUT ioctl
+ * @s: pointer to standard V4L2 device structure
+ * @index: returns the current selected input
+ *
+ * Returns the current selected input. Returns -EINVAL if any error occurs
+ */
+static int ioctl_g_input(struct v4l2_int_device *s, int *index)
+{
+	struct tvp514x_decoder *decoder = s->priv;
+	int err = -EINVAL, i, inputidx;
+
+	if (index == NULL)
+		return -EINVAL;
+
+	/* Search through the input list for active inputs */
+	inputidx = decoder->inputidx;
+	for (i = 0; i < decoder->pdata->num_inputs; i++) {
+		inputidx++;	/* Move to next input */
+		if (inputidx >= decoder->pdata->num_inputs)
+			inputidx = 0;	/* fall back to first input */
+
+		err = ioctl_s_input(s, inputidx);
+		if (!err) {
+			/* Active input found - select it and return success */
+			*index = inputidx;
+			return 0;
+		}
+	}
+
+	return err;
+}
+
+/**
+ * ioctl_queryctrl - V4L2 decoder interface handler for VIDIOC_QUERYCTRL ioctl
+ * @s: pointer to standard V4L2 device structure
+ * @qc: standard V4L2 VIDIOC_QUERYCTRL ioctl structure
+ *
+ * If the requested control is supported, returns the control information
+ * from the ctrl_list[] array. Otherwise, returns -EINVAL if the
+ * control is not supported.
+ */
+static int
+ioctl_queryctrl(struct v4l2_int_device *s, struct v4l2_queryctrl *qctrl)
+{
+	struct tvp514x_decoder *decoder = s->priv;
+	int id, index;
+	const struct tvp514x_ctrl_info *control = NULL;
+
+	if (qctrl == NULL)
+		return -EINVAL;
+
+	id = qctrl->id;
+	memset(qctrl, 0, sizeof(struct v4l2_queryctrl));
+	qctrl->id = id;
+
+	for (index = 0; index < decoder->num_ctrls; index++) {
+		control = &decoder->ctrl_list[index];
+		if (control->query_ctrl.id == qctrl->id)
+			break;	/* Match found */
+	}
+	if (index == decoder->num_ctrls)
+		return -EINVAL;	/* Index out of bound */
+
+	memcpy(qctrl, &control->query_ctrl, sizeof(struct v4l2_queryctrl));
+
+	return 0;
+}
+
+/**
+ * ioctl_g_ctrl - V4L2 decoder interface handler for VIDIOC_G_CTRL ioctl
+ * @s: pointer to standard V4L2 device structure
+ * @vc: standard V4L2 VIDIOC_G_CTRL ioctl structure
+ *
+ * If the requested control is supported, returns the control's current
+ * value from the decoder. Otherwise, returns -EINVAL if the control is not
+ * supported.
+ */
+static int
+ioctl_g_ctrl(struct v4l2_int_device *s, struct v4l2_control *ctrl)
+{
+	struct tvp514x_decoder *decoder = s->priv;
+	int err, index;
+	u8 val;
+	int value;
+	const struct tvp514x_ctrl_info *control = NULL;
+
+	if (ctrl == NULL)
+		return -EINVAL;
+
+	for (index = 0; index < decoder->num_ctrls; index++) {
+		control = &decoder->ctrl_list[index];
+		if (control->query_ctrl.id == ctrl->id)
+			break;	/* Match found */
+	}
+	if (index == decoder->num_ctrls)
+		return -EINVAL;	/* Index out of bound */
+
+	err =
+	    tvp514x_read_reg(decoder->client, control->reg_address, &val);
+	if (err < 0)
+		return err;
+
+	/* cross check */
+	if (val != decoder->pdata->reg_list[control->reg_address].val)
+		return -EINVAL;	/* Driver & TVP5146/47 setting mismatch */
+
+	value = val;
+	if (V4L2_CID_AUTOGAIN == ctrl->id) {
+		if ((value & 0x3) == 3)
+			value = 1;
+		else
+			value = 0;
+	}
+
+	if (V4L2_CID_HUE == ctrl->id) {
+		if (value == 0x7F)
+			value = 180;
+		else if (value == 0x80)
+			value = -180;
+		else
+			value = 0;
+	}
+
+	ctrl->value = value;
+
+	return err;
+}
+
+/**
+ * ioctl_s_ctrl - V4L2 decoder interface handler for VIDIOC_S_CTRL ioctl
+ * @s: pointer to standard V4L2 device structure
+ * @vc: standard V4L2 VIDIOC_S_CTRL ioctl structure
+ *
+ * If the requested control is supported, sets the control's current
+ * value in HW. Otherwise, returns -EINVAL if the control is not supported.
+ */
+static int
+ioctl_s_ctrl(struct v4l2_int_device *s, struct v4l2_control *ctrl)
+{
+	struct tvp514x_decoder *decoder = s->priv;
+	int err, value, index;
+	const struct tvp514x_ctrl_info *control = NULL;
+
+	if (ctrl == NULL)
+		return -EINVAL;
+
+	value = (__s32) ctrl->value;
+	for (index = 0; index < decoder->num_ctrls; index++) {
+		control = &decoder->ctrl_list[index];
+		if (control->query_ctrl.id == ctrl->id)
+			break;	/* Match found */
+	}
+	if (index == decoder->num_ctrls)
+		return -EINVAL;	/* Index out of bound */
+
+	if (V4L2_CID_AUTOGAIN == ctrl->id) {
+		if (value == 1)
+			value = 0x0F;
+		else if (value == 0)
+			value = 0x0C;
+		else
+			return -ERANGE;
+	} else if (V4L2_CID_HUE == ctrl->id) {
+		if (value == 180)
+			value = 0x7F;
+		else if (value == -180)
+			value = 0x80;
+		else if (value == 0)
+			value = 0;
+		else
+			return -ERANGE;
+	} else {
+		if ((value < control->query_ctrl.minimum)
+			|| (value > control->query_ctrl.maximum))
+			return -ERANGE;
+	}
+
+	err =
+	    tvp514x_write_reg(decoder->client, control->reg_address,
+				value);
+	if (err < 0)
+		return err;
+
+	decoder->pdata->reg_list[control->reg_address].val = value;
+	return err;
+}
+
+/**
+ * ioctl_enum_fmt_cap - Implement the CAPTURE buffer VIDIOC_ENUM_FMT ioctl
+ * @s: pointer to standard V4L2 device structure
+ * @fmt: standard V4L2 VIDIOC_ENUM_FMT ioctl structure
+ *
+ * Implement the VIDIOC_ENUM_FMT ioctl to enumerate supported formats
+ */
+static int
+ioctl_enum_fmt_cap(struct v4l2_int_device *s, struct v4l2_fmtdesc *fmt)
+{
+	struct tvp514x_decoder *decoder = s->priv;
+	int index;
+
+	if (fmt == NULL)
+		return -EINVAL;
+
+	index = fmt->index;
+	if ((index >= decoder->num_fmts) || (index < 0))
+		return -EINVAL;	/* Index out of bound */
+
+	if (fmt->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
+		return -EINVAL;	/* only capture is supported */
+
+	memcpy(fmt, &decoder->fmt_list[index],
+		sizeof(struct v4l2_fmtdesc));
+
+	return 0;
+}
+
+/**
+ * ioctl_try_fmt_cap - Implement the CAPTURE buffer VIDIOC_TRY_FMT ioctl
+ * @s: pointer to standard V4L2 device structure
+ * @f: pointer to standard V4L2 VIDIOC_TRY_FMT ioctl structure
+ *
+ * Implement the VIDIOC_TRY_FMT ioctl for the CAPTURE buffer type. This
+ * ioctl is used to negotiate the image capture size and pixel format
+ * without actually making it take effect.
+ */
+static int
+ioctl_try_fmt_cap(struct v4l2_int_device *s, struct v4l2_format *f)
+{
+	struct tvp514x_decoder *decoder = s->priv;
+	int ifmt;
+	struct v4l2_pix_format *pix;
+	enum tvp514x_std current_std;
+
+	if (f == NULL)
+		return -EINVAL;
+
+	if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
+		f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+
+	pix = &f->fmt.pix;
+
+	/* Calculate height and width based on current standard */
+	current_std = tvp514x_get_current_std(decoder);
+	if (current_std == STD_INVALID)
+		return -EINVAL;
+
+	decoder->current_std = current_std;
+	pix->width = decoder->std_list[current_std].width;
+	pix->height = decoder->std_list[current_std].height;
+
+	for (ifmt = 0; ifmt < decoder->num_fmts; ifmt++) {
+		if (pix->pixelformat ==
+			decoder->fmt_list[ifmt].pixelformat)
+			break;
+	}
+	if (ifmt == decoder->num_fmts)
+		ifmt = 0;	/* None of the format matched, select default */
+	pix->pixelformat = decoder->fmt_list[ifmt].pixelformat;
+
+	pix->field = V4L2_FIELD_INTERLACED;
+	pix->bytesperline = pix->width * 2;
+	pix->sizeimage = pix->bytesperline * pix->height;
+	pix->colorspace = V4L2_COLORSPACE_SMPTE170M;
+	pix->priv = 0;
+
+	return 0;
+}
+
+/**
+ * ioctl_s_fmt_cap - V4L2 decoder interface handler for VIDIOC_S_FMT ioctl
+ * @s: pointer to standard V4L2 device structure
+ * @f: pointer to standard V4L2 VIDIOC_S_FMT ioctl structure
+ *
+ * If the requested format is supported, configures the HW to use that
+ * format, returns error code if format not supported or HW can't be
+ * correctly configured.
+ */
+static int
+ioctl_s_fmt_cap(struct v4l2_int_device *s, struct v4l2_format *f)
+{
+	struct tvp514x_decoder *decoder = s->priv;
+	struct v4l2_pix_format *pix;
+	int rval;
+
+	if (f == NULL)
+		return -EINVAL;
+
+	if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
+		return -EINVAL;	/* only capture is supported */
+
+	pix = &f->fmt.pix;
+	rval = ioctl_try_fmt_cap(s, f);
+	if (rval)
+		return rval;
+	else
+		decoder->pix = *pix;
+
+	return rval;
+}
+
+/**
+ * ioctl_g_fmt_cap - V4L2 decoder interface handler for ioctl_g_fmt_cap
+ * @s: pointer to standard V4L2 device structure
+ * @f: pointer to standard V4L2 v4l2_format structure
+ *
+ * Returns the decoder's current pixel format in the v4l2_format
+ * parameter.
+ */
+static int
+ioctl_g_fmt_cap(struct v4l2_int_device *s, struct v4l2_format *f)
+{
+	struct tvp514x_decoder *decoder = s->priv;
+
+	if (f == NULL)
+		return -EINVAL;
+
+	if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
+		return -EINVAL;	/* only capture is supported */
+
+	f->fmt.pix = decoder->pix;
+
+	return 0;
+}
+
+/**
+ * ioctl_g_parm - V4L2 decoder interface handler for VIDIOC_G_PARM ioctl
+ * @s: pointer to standard V4L2 device structure
+ * @a: pointer to standard V4L2 VIDIOC_G_PARM ioctl structure
+ *
+ * Returns the decoder's video CAPTURE parameters.
+ */
+static int
+ioctl_g_parm(struct v4l2_int_device *s, struct v4l2_streamparm *a)
+{
+	struct tvp514x_decoder *decoder = s->priv;
+	struct v4l2_captureparm *cparm;
+	enum tvp514x_std current_std;
+
+	if (a == NULL)
+		return -EINVAL;
+
+	if (a->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
+		return -EINVAL;	/* only capture is supported */
+
+	memset(a, 0, sizeof(*a));
+	a->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+
+	/* get the current standard */
+	current_std = tvp514x_get_current_std(decoder);
+	decoder->current_std = current_std;
+
+	cparm = &a->parm.capture;
+	cparm->capability = V4L2_CAP_TIMEPERFRAME;
+	cparm->timeperframe
+	    = decoder->std_list[current_std].standard.frameperiod;
+
+	return 0;
+}
+
+/**
+ * ioctl_s_parm - V4L2 decoder interface handler for VIDIOC_S_PARM ioctl
+ * @s: pointer to standard V4L2 device structure
+ * @a: pointer to standard V4L2 VIDIOC_S_PARM ioctl structure
+ *
+ * Configures the decoder to use the input parameters, if possible. If
+ * not possible, returns the appropriate error code.
+ */
+static int
+ioctl_s_parm(struct v4l2_int_device *s, struct v4l2_streamparm *a)
+{
+	struct tvp514x_decoder *decoder = s->priv;
+	struct v4l2_fract *timeperframe;
+	enum tvp514x_std current_std;
+
+	if (a == NULL)
+		return -EINVAL;
+
+	if (a->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
+		return -EINVAL;	/* only capture is supported */
+
+	timeperframe = &a->parm.capture.timeperframe;
+
+	/* get the current standard */
+	current_std = tvp514x_get_current_std(decoder);
+	decoder->current_std = current_std;
+
+	*timeperframe =
+	    decoder->std_list[current_std].standard.frameperiod;
+
+	return 0;
+}
+
+/**
+ * ioctl_g_ifparm - V4L2 decoder interface handler for vidioc_int_g_ifparm_num
+ * @s: pointer to standard V4L2 device structure
+ * @p: pointer to standard V4L2 vidioc_int_g_ifparm_num ioctl structure
+ *
+ * Gets slave interface parameters.
+ * Calculates the required xclk value to support the requested
+ * clock parameters in p. This value is returned in the p
+ * parameter.
+ */
+static int ioctl_g_ifparm(struct v4l2_int_device *s, struct v4l2_ifparm *p)
+{
+	struct tvp514x_decoder *decoder = s->priv;
+	int rval;
+
+	if (p == NULL)
+		return -EINVAL;
+
+	if (NULL == decoder->pdata->ifparm)
+		return -EINVAL;
+
+	rval = decoder->pdata->ifparm(p);
+	if (rval) {
+		dev_err(&decoder->client->dev, "error. Err[%d]\n", rval);
+		return rval;
+	}
+
+	p->u.bt656.clock_curr = TVP514X_XCLK_BT656;
+
+	return 0;
+}
+
+/**
+ * ioctl_g_priv - V4L2 decoder interface handler for vidioc_int_g_priv_num
+ * @s: pointer to standard V4L2 device structure
+ * @p: void pointer to hold decoder's private data address
+ *
+ * Returns device's (decoder's) private data area address in p parameter
+ */
+static int ioctl_g_priv(struct v4l2_int_device *s, void *p)
+{
+	struct tvp514x_decoder *decoder = s->priv;
+
+	if (NULL == decoder->pdata->priv_data_set)
+		return -EINVAL;
+
+	return decoder->pdata->priv_data_set(p);
+}
+
+/**
+ * ioctl_s_power - V4L2 decoder interface handler for vidioc_int_s_power_num
+ * @s: pointer to standard V4L2 device structure
+ * @on: power state to which device is to be set
+ *
+ * Sets devices power state to requrested state, if possible.
+ */
+static int ioctl_s_power(struct v4l2_int_device *s, enum v4l2_power on)
+{
+	struct tvp514x_decoder *decoder = s->priv;
+	int err = 0;
+
+	switch (on) {
+	case V4L2_POWER_OFF:
+		/* Power Down Sequence */
+		err =
+		    tvp514x_write_reg(decoder->client, REG_OPERATION_MODE,
+					0x01);
+		/* Disable mux for TVP5146/47 decoder data path */
+		if (decoder->pdata->power_set)
+			err |= decoder->pdata->power_set(on);
+		break;
+
+	case V4L2_POWER_STANDBY:
+		if (decoder->pdata->power_set)
+			err = decoder->pdata->power_set(on);
+		break;
+
+	case V4L2_POWER_ON:
+		/* Enable mux for TVP5146/47 decoder data path */
+		if (decoder->pdata->power_set)
+			err = decoder->pdata->power_set(on);
+
+		/* Power Up Sequence */
+		err |=
+		    tvp514x_write_reg(decoder->client, REG_OPERATION_MODE,
+					0x01);
+		err |=
+		    tvp514x_write_reg(decoder->client, REG_OPERATION_MODE,
+					0x00);
+
+		/* Detect the sensor is not already detected */
+		if (decoder->state == STATE_NOT_DETECTED) {
+			err |= tvp514x_detect(decoder);
+			if (err < 0) {
+				dev_err(&decoder->client->dev,
+					"Unable to detect decoder\n");
+				return err;
+			}
+			dev_info(&decoder->client->dev,
+				 "chip version 0x%.2x detected\n",
+				 decoder->ver);
+		}
+		break;
+
+	default:
+		return -ENODEV;
+		break;
+	}
+
+	return err;
+}
+
+/**
+ * ioctl_init - V4L2 decoder interface handler for VIDIOC_INT_INIT
+ * @s: pointer to standard V4L2 device structure
+ *
+ * Initialize the decoder device (calls tvp514x_configure())
+ */
+static int ioctl_init(struct v4l2_int_device *s)
+{
+	struct tvp514x_decoder *decoder = s->priv;
+
+	/* Set default standard to auto */
+	decoder->pdata->reg_list[REG_VIDEO_STD].val =
+	    VIDEO_STD_AUTO_SWITCH_BIT;
+
+	return tvp514x_configure(decoder);
+}
+
+/**
+ * ioctl_dev_exit - V4L2 decoder interface handler for vidioc_int_dev_exit_num
+ * @s: pointer to standard V4L2 device structure
+ *
+ * Delinitialise the dev. at slave detach. The complement of ioctl_dev_init.
+ */
+static int ioctl_dev_exit(struct v4l2_int_device *s)
+{
+	return 0;
+}
+
+/**
+ * ioctl_dev_init - V4L2 decoder interface handler for vidioc_int_dev_init_num
+ * @s: pointer to standard V4L2 device structure
+ *
+ * Initialise the device when slave attaches to the master. Returns 0 if
+ * TVP5146/47 device could be found, otherwise returns appropriate error.
+ */
+static int ioctl_dev_init(struct v4l2_int_device *s)
+{
+	struct tvp514x_decoder *decoder = s->priv;
+	int err;
+
+	err = tvp514x_detect(decoder);
+	if (err < 0) {
+		dev_err(&decoder->client->dev,
+			"Unable to detect decoder\n");
+		return err;
+	}
+
+	dev_info(&decoder->client->dev,
+		 "chip version 0x%.2x detected\n", decoder->ver);
+
+	return 0;
+}
+
+static struct v4l2_int_ioctl_desc tvp514x_ioctl_desc[] = {
+	{vidioc_int_dev_init_num, (v4l2_int_ioctl_func*) ioctl_dev_init},
+	{vidioc_int_dev_exit_num, (v4l2_int_ioctl_func*) ioctl_dev_exit},
+	{vidioc_int_s_power_num, (v4l2_int_ioctl_func*) ioctl_s_power},
+	{vidioc_int_g_priv_num, (v4l2_int_ioctl_func*) ioctl_g_priv},
+	{vidioc_int_g_ifparm_num, (v4l2_int_ioctl_func*) ioctl_g_ifparm},
+	{vidioc_int_init_num, (v4l2_int_ioctl_func*) ioctl_init},
+	{vidioc_int_enum_fmt_cap_num,
+	 (v4l2_int_ioctl_func *) ioctl_enum_fmt_cap},
+	{vidioc_int_try_fmt_cap_num,
+	 (v4l2_int_ioctl_func *) ioctl_try_fmt_cap},
+	{vidioc_int_g_fmt_cap_num,
+	 (v4l2_int_ioctl_func *) ioctl_g_fmt_cap},
+	{vidioc_int_s_fmt_cap_num,
+	 (v4l2_int_ioctl_func *) ioctl_s_fmt_cap},
+	{vidioc_int_g_parm_num, (v4l2_int_ioctl_func *) ioctl_g_parm},
+	{vidioc_int_s_parm_num, (v4l2_int_ioctl_func *) ioctl_s_parm},
+	{vidioc_int_queryctrl_num,
+	 (v4l2_int_ioctl_func *) ioctl_queryctrl},
+	{vidioc_int_g_ctrl_num, (v4l2_int_ioctl_func *) ioctl_g_ctrl},
+	{vidioc_int_s_ctrl_num, (v4l2_int_ioctl_func *) ioctl_s_ctrl},
+	{vidioc_int_querystd_num, (v4l2_int_ioctl_func *) ioctl_querystd},
+	{vidioc_int_s_std_num, (v4l2_int_ioctl_func *) ioctl_s_std},
+	{vidioc_int_enum_input_num,
+	 (v4l2_int_ioctl_func *) ioctl_enum_input},
+	{vidioc_int_g_input_num, (v4l2_int_ioctl_func *) ioctl_g_input},
+	{vidioc_int_s_input_num, (v4l2_int_ioctl_func *) ioctl_s_input},
+};
+
+static struct v4l2_int_slave tvp514x_slave = {
+	.ioctls = tvp514x_ioctl_desc,
+	.num_ioctls = ARRAY_SIZE(tvp514x_ioctl_desc),
+};
+
+static struct tvp514x_decoder tvp514x_dev = {
+	.state = STATE_NOT_DETECTED,
+
+	.num_fmts = TVP514X_NUM_FORMATS,
+	.fmt_list = tvp514x_fmt_list,
+
+	.pix = {		/* Default to NTSC 8-bit YUV 422 */
+		.width = NTSC_NUM_ACTIVE_PIXELS,
+		.height = NTSC_NUM_ACTIVE_LINES,
+		.pixelformat = V4L2_PIX_FMT_UYVY,
+		.field = V4L2_FIELD_INTERLACED,
+		.bytesperline = NTSC_NUM_ACTIVE_PIXELS * 2,
+		.sizeimage =
+		NTSC_NUM_ACTIVE_PIXELS * 2 * NTSC_NUM_ACTIVE_LINES,
+		.colorspace = V4L2_COLORSPACE_SMPTE170M,
+		},
+
+	.current_std = STD_NTSC_MJ,
+	.num_stds = TVP514X_NUM_STANDARDS,
+	.std_list = tvp514x_std_list,
+
+	.num_ctrls = TVP514X_NUM_CONTROLS,
+	.ctrl_list = tvp514x_ctrl_list,
+
+	.inputidx = 0,		/* Composite selected */
+};
+
+static struct v4l2_int_device tvp514x_int_device = {
+	.module = THIS_MODULE,
+	.name = MODULE_NAME,
+	.priv = &tvp514x_dev,
+	.type = v4l2_int_type_slave,
+	.u = {
+	      .slave = &tvp514x_slave,
+	      },
+};
+
+/**
+ * tvp514x_probe - decoder driver i2c probe handler
+ * @client: i2c driver client device structure
+ *
+ * Register decoder as an i2c client device and V4L2
+ * device.
+ */
+static int
+tvp514x_probe(struct i2c_client *client, const struct i2c_device_id *id)
+{
+	struct tvp514x_decoder *decoder = &tvp514x_dev;
+	int err;
+
+	if (i2c_get_clientdata(client))
+		return -EBUSY;
+
+	decoder->pdata = client->dev.platform_data;
+	if (!decoder->pdata) {
+		dev_err(&client->dev, "No platform data\n!!");
+		return -ENODEV;
+	}
+
+	/* Attach to Master */
+	strcpy(tvp514x_int_device.u.slave->attach_to, decoder->pdata->master);
+	decoder->v4l2_int_device = &tvp514x_int_device;
+	decoder->client = client;
+	i2c_set_clientdata(client, decoder);
+
+	/* Register with V4L2 layer as slave device */
+	err = v4l2_int_device_register(decoder->v4l2_int_device);
+	if (err) {
+		i2c_set_clientdata(client, NULL);
+		dev_err(&client->dev,
+			"Unable to register to v4l2. Err[%d]\n", err);
+
+	} else
+		dev_info(&client->dev, "Registered to v4l2 master %s!!\n",
+				decoder->pdata->master);
+
+	return 0;
+}
+
+/**
+ * tvp514x_remove - decoder driver i2c remove handler
+ * @client: i2c driver client device structure
+ *
+ * Unregister decoder as an i2c client device and V4L2
+ * device. Complement of tvp514x_probe().
+ */
+static int __exit tvp514x_remove(struct i2c_client *client)
+{
+	struct tvp514x_decoder *decoder = i2c_get_clientdata(client);
+
+	if (!client->adapter)
+		return -ENODEV;	/* our client isn't attached */
+
+	v4l2_int_device_unregister(decoder->v4l2_int_device);
+	i2c_set_clientdata(client, NULL);
+
+	return 0;
+}
+
+static const struct i2c_device_id tvp514x_id[] = {
+	{MODULE_NAME, 0},
+	{},
+};
+
+MODULE_DEVICE_TABLE(i2c, tvp514x_id);
+
+static struct i2c_driver tvp514x_i2c_driver = {
+	.driver = {
+		   .name = MODULE_NAME,
+		   .owner = THIS_MODULE,
+		   },
+	.probe = tvp514x_probe,
+	.remove = __exit_p(tvp514x_remove),
+	.id_table = tvp514x_id,
+};
+
+/**
+ * tvp514x_init
+ *
+ * Module init function
+ */
+static int __init tvp514x_init(void)
+{
+	int err;
+
+	err = i2c_add_driver(&tvp514x_i2c_driver);
+	if (err) {
+		printk(KERN_ERR "Failed to register " MODULE_NAME ".\n");
+		return err;
+	}
+	return 0;
+}
+
+/**
+ * tvp514x_cleanup
+ *
+ * Module exit function
+ */
+static void __exit tvp514x_cleanup(void)
+{
+	i2c_del_driver(&tvp514x_i2c_driver);
+}
+
+late_initcall(tvp514x_init);
+module_exit(tvp514x_cleanup);
+
+MODULE_AUTHOR("Texas Instruments");
+MODULE_DESCRIPTION("TVP514x linux decoder driver");
+MODULE_LICENSE("GPL");
diff --git a/include/media/tvp514x.h b/include/media/tvp514x.h
new file mode 100644
index 0000000..4433b96
--- /dev/null
+++ b/include/media/tvp514x.h
@@ -0,0 +1,406 @@
+/*
+ * drivers/media/video/tvp514x.h
+ *
+ * Copyright (C) 2008 Texas Instruments Inc
+ *
+ * This package is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#ifndef _TVP514X_H
+#define _TVP514X_H
+
+/*
+ * TVP5146/47 registers
+ */
+#define REG_INPUT_SEL			(0x00)
+#define REG_AFE_GAIN_CTRL		(0x01)
+#define REG_VIDEO_STD			(0x02)
+#define REG_OPERATION_MODE		(0x03)
+#define REG_AUTOSWITCH_MASK		(0x04)
+
+#define REG_COLOR_KILLER		(0x05)
+#define REG_LUMA_CONTROL1		(0x06)
+#define REG_LUMA_CONTROL2		(0x07)
+#define REG_LUMA_CONTROL3		(0x08)
+
+#define REG_BRIGHTNESS			(0x09)
+#define REG_CONTRAST			(0x0A)
+#define REG_SATURATION			(0x0B)
+#define REG_HUE				(0x0C)
+
+#define REG_CHROMA_CONTROL1		(0x0D)
+#define REG_CHROMA_CONTROL2		(0x0E)
+
+/* 0x0F Reserved */
+
+#define REG_COMP_PR_SATURATION		(0x10)
+#define REG_COMP_Y_CONTRAST		(0x11)
+#define REG_COMP_PB_SATURATION		(0x12)
+
+/* 0x13 Reserved */
+
+#define REG_COMP_Y_BRIGHTNESS		(0x14)
+
+/* 0x15 Reserved */
+
+#define REG_AVID_START_PIXEL_LSB	(0x16)
+#define REG_AVID_START_PIXEL_MSB	(0x17)
+#define REG_AVID_STOP_PIXEL_LSB		(0x18)
+#define REG_AVID_STOP_PIXEL_MSB		(0x19)
+
+#define REG_HSYNC_START_PIXEL_LSB	(0x1A)
+#define REG_HSYNC_START_PIXEL_MSB	(0x1B)
+#define REG_HSYNC_STOP_PIXEL_LSB	(0x1C)
+#define REG_HSYNC_STOP_PIXEL_MSB	(0x1D)
+
+#define REG_VSYNC_START_LINE_LSB	(0x1E)
+#define REG_VSYNC_START_LINE_MSB	(0x1F)
+#define REG_VSYNC_STOP_LINE_LSB		(0x20)
+#define REG_VSYNC_STOP_LINE_MSB		(0x21)
+
+#define REG_VBLK_START_LINE_LSB		(0x22)
+#define REG_VBLK_START_LINE_MSB		(0x23)
+#define REG_VBLK_STOP_LINE_LSB		(0x24)
+#define REG_VBLK_STOP_LINE_MSB		(0x25)
+
+/* 0x26 - 0x27 Reserved */
+
+#define REG_FAST_SWTICH_CONTROL		(0x28)
+
+/* 0x29 Reserved */
+
+#define REG_FAST_SWTICH_SCART_DELAY	(0x2A)
+
+/* 0x2B Reserved */
+
+#define REG_SCART_DELAY			(0x2C)
+#define REG_CTI_DELAY			(0x2D)
+#define REG_CTI_CONTROL			(0x2E)
+
+/* 0x2F - 0x31 Reserved */
+
+#define REG_SYNC_CONTROL		(0x32)
+#define REG_OUTPUT_FORMATTER1		(0x33)
+#define REG_OUTPUT_FORMATTER2		(0x34)
+#define REG_OUTPUT_FORMATTER3		(0x35)
+#define REG_OUTPUT_FORMATTER4		(0x36)
+#define REG_OUTPUT_FORMATTER5		(0x37)
+#define REG_OUTPUT_FORMATTER6		(0x38)
+#define REG_CLEAR_LOST_LOCK		(0x39)
+
+#define REG_STATUS1			(0x3A)
+#define REG_STATUS2			(0x3B)
+
+#define REG_AGC_GAIN_STATUS_LSB		(0x3C)
+#define REG_AGC_GAIN_STATUS_MSB		(0x3D)
+
+/* 0x3E Reserved */
+
+#define REG_VIDEO_STD_STATUS		(0x3F)
+#define REG_GPIO_INPUT1			(0x40)
+#define REG_GPIO_INPUT2			(0x41)
+
+/* 0x42 - 0x45 Reserved */
+
+#define REG_AFE_COARSE_GAIN_CH1		(0x46)
+#define REG_AFE_COARSE_GAIN_CH2		(0x47)
+#define REG_AFE_COARSE_GAIN_CH3		(0x48)
+#define REG_AFE_COARSE_GAIN_CH4		(0x49)
+
+#define REG_AFE_FINE_GAIN_PB_B_LSB	(0x4A)
+#define REG_AFE_FINE_GAIN_PB_B_MSB	(0x4B)
+#define REG_AFE_FINE_GAIN_Y_G_CHROMA_LSB	(0x4C)
+#define REG_AFE_FINE_GAIN_Y_G_CHROMA_MSB	(0x4D)
+#define REG_AFE_FINE_GAIN_PR_R_LSB	(0x4E)
+#define REG_AFE_FINE_GAIN_PR_R_MSB	(0x4F)
+#define REG_AFE_FINE_GAIN_CVBS_LUMA_LSB	(0x50)
+#define REG_AFE_FINE_GAIN_CVBS_LUMA_MSB	(0x51)
+
+/* 0x52 - 0x68 Reserved */
+
+#define REG_FBIT_VBIT_CONTROL1		(0x69)
+
+/* 0x6A - 0x6B Reserved */
+
+#define REG_BACKEND_AGC_CONTROL		(0x6C)
+
+/* 0x6D - 0x6E Reserved */
+
+#define REG_AGC_DECREMENT_SPEED_CONTROL	(0x6F)
+#define REG_ROM_VERSION			(0x70)
+
+/* 0x71 - 0x73 Reserved */
+
+#define REG_AGC_WHITE_PEAK_PROCESSING	(0x74)
+#define REG_FBIT_VBIT_CONTROL2		(0x75)
+#define REG_VCR_TRICK_MODE_CONTROL	(0x76)
+#define REG_HORIZONTAL_SHAKE_INCREMENT	(0x77)
+#define REG_AGC_INCREMENT_SPEED		(0x78)
+#define REG_AGC_INCREMENT_DELAY		(0x79)
+
+/* 0x7A - 0x7F Reserved */
+
+#define REG_CHIP_ID_MSB			(0x80)
+#define REG_CHIP_ID_LSB			(0x81)
+
+/* 0x82 Reserved */
+
+#define REG_CPLL_SPEED_CONTROL		(0x83)
+
+/* 0x84 - 0x96 Reserved */
+
+#define REG_STATUS_REQUEST		(0x97)
+
+/* 0x98 - 0x99 Reserved */
+
+#define REG_VERTICAL_LINE_COUNT_LSB	(0x9A)
+#define REG_VERTICAL_LINE_COUNT_MSB	(0x9B)
+
+/* 0x9C - 0x9D Reserved */
+
+#define REG_AGC_DECREMENT_DELAY		(0x9E)
+
+/* 0x9F - 0xB0 Reserved */
+
+#define REG_VDP_TTX_FILTER_1_MASK1	(0xB1)
+#define REG_VDP_TTX_FILTER_1_MASK2	(0xB2)
+#define REG_VDP_TTX_FILTER_1_MASK3	(0xB3)
+#define REG_VDP_TTX_FILTER_1_MASK4	(0xB4)
+#define REG_VDP_TTX_FILTER_1_MASK5	(0xB5)
+#define REG_VDP_TTX_FILTER_2_MASK1	(0xB6)
+#define REG_VDP_TTX_FILTER_2_MASK2	(0xB7)
+#define REG_VDP_TTX_FILTER_2_MASK3	(0xB8)
+#define REG_VDP_TTX_FILTER_2_MASK4	(0xB9)
+#define REG_VDP_TTX_FILTER_2_MASK5	(0xBA)
+#define REG_VDP_TTX_FILTER_CONTROL	(0xBB)
+#define REG_VDP_FIFO_WORD_COUNT		(0xBC)
+#define REG_VDP_FIFO_INTERRUPT_THRLD	(0xBD)
+
+/* 0xBE Reserved */
+
+#define REG_VDP_FIFO_RESET		(0xBF)
+#define REG_VDP_FIFO_OUTPUT_CONTROL	(0xC0)
+#define REG_VDP_LINE_NUMBER_INTERRUPT	(0xC1)
+#define REG_VDP_PIXEL_ALIGNMENT_LSB	(0xC2)
+#define REG_VDP_PIXEL_ALIGNMENT_MSB	(0xC3)
+
+/* 0xC4 - 0xD5 Reserved */
+
+#define REG_VDP_LINE_START		(0xD6)
+#define REG_VDP_LINE_STOP		(0xD7)
+#define REG_VDP_GLOBAL_LINE_MODE	(0xD8)
+#define REG_VDP_FULL_FIELD_ENABLE	(0xD9)
+#define REG_VDP_FULL_FIELD_MODE		(0xDA)
+
+/* 0xDB - 0xDF Reserved */
+
+#define REG_VBUS_DATA_ACCESS_NO_VBUS_ADDR_INCR	(0xE0)
+#define REG_VBUS_DATA_ACCESS_VBUS_ADDR_INCR	(0xE1)
+#define REG_FIFO_READ_DATA			(0xE2)
+
+/* 0xE3 - 0xE7 Reserved */
+
+#define REG_VBUS_ADDRESS_ACCESS1	(0xE8)
+#define REG_VBUS_ADDRESS_ACCESS2	(0xE9)
+#define REG_VBUS_ADDRESS_ACCESS3	(0xEA)
+
+/* 0xEB - 0xEF Reserved */
+
+#define REG_INTERRUPT_RAW_STATUS0	(0xF0)
+#define REG_INTERRUPT_RAW_STATUS1	(0xF1)
+#define REG_INTERRUPT_STATUS0		(0xF2)
+#define REG_INTERRUPT_STATUS1		(0xF3)
+#define REG_INTERRUPT_MASK0		(0xF4)
+#define REG_INTERRUPT_MASK1		(0xF5)
+#define REG_INTERRUPT_CLEAR0		(0xF6)
+#define REG_INTERRUPT_CLEAR1		(0xF7)
+
+/* 0xF8 - 0xFF Reserved */
+
+/*
+ * Mask and bit definitions of TVP5146/47 registers
+ */
+/* The ID values we are looking for */
+#define TVP514X_CHIP_ID_MSB		(0x51)
+#define TVP5146_CHIP_ID_LSB		(0x46)
+#define TVP5147_CHIP_ID_LSB		(0x47)
+
+#define VIDEO_STD_MASK			(0x07)
+#define VIDEO_STD_AUTO_SWITCH_BIT	(0x00)
+#define VIDEO_STD_NTSC_MJ_BIT		(0x01)
+#define VIDEO_STD_PAL_BDGHIN_BIT	(0x02)
+#define VIDEO_STD_PAL_M_BIT		(0x03)
+#define VIDEO_STD_PAL_COMBINATION_N_BIT	(0x04)
+#define VIDEO_STD_NTSC_4_43_BIT		(0x05)
+#define VIDEO_STD_SECAM_BIT		(0x06)
+#define VIDEO_STD_PAL_60_BIT		(0x07)
+
+/*
+ * Other macros
+ */
+#define TVP514X_MODULE_NAME		"tvp514x"
+#define TVP514X_I2C_DELAY		(3)
+#define I2C_RETRY_COUNT			(5)
+#define LOCK_RETRY_COUNT		(3)
+#define LOCK_RETRY_DELAY		(200)
+
+#define TOK_WRITE			(0)	/* token for write operation */
+#define TOK_TERM			(1)	/* terminating token */
+#define TOK_DELAY			(2)	/* delay token for reg list */
+#define TOK_SKIP			(3)	/* token to skip a register */
+
+#define TVP514X_XCLK_BT656		(27000000)
+
+/* Number of pixels and number of lines per frame for different standards */
+#define NTSC_NUM_ACTIVE_PIXELS		(720)
+#define NTSC_NUM_ACTIVE_LINES		(480)
+#define PAL_NUM_ACTIVE_PIXELS		(720)
+#define PAL_NUM_ACTIVE_LINES		(576)
+
+/**
+ * enum tvp514x_std - enum for supported standards
+ */
+enum tvp514x_std {
+	STD_NTSC_MJ = 0,
+	STD_PAL_BDGHIN,
+	STD_INVALID
+};
+
+/**
+ * enum tvp514x_state - enum for different decoder states
+ */
+enum tvp514x_state {
+	STATE_NOT_DETECTED,
+	STATE_DETECTED
+};
+
+/**
+ * struct tvp514x_reg - Structure for TVP5146/47 register initialization values
+ * @token - Token: TOK_WRITE, TOK_TERM etc..
+ * @reg - Register offset
+ * @val - Register Value for TOK_WRITE or delay in ms for TOK_DELAY
+ */
+struct tvp514x_reg {
+	u8 token;
+	u8 reg;
+	u32 val;
+};
+
+/**
+ * struct tvp514x_std_info - Structure to store standard informations
+ * @width: Line width in pixels
+ * @height:Number of active lines
+ * @video_std: Value to write in REG_VIDEO_STD register
+ * @standard: v4l2 standard structure information
+ */
+struct tvp514x_std_info {
+	unsigned long width;
+	unsigned long height;
+	u8 video_std;
+	struct v4l2_standard standard;
+};
+
+/**
+ * struct tvp514x_ctrl_info - Information regarding supported controls
+ * @reg_address: Register offset of control register
+ * @query_ctrl: v4l2 query control information
+ */
+struct tvp514x_ctrl_info {
+	u8 reg_address;
+	struct v4l2_queryctrl query_ctrl;
+};
+
+/**
+ * struct tvp514x_input_info - Information regarding supported inputs
+ * @input_sel: Input select register
+ * @lock_mask: lock mask - depends on Svideo/CVBS
+ * @input: v4l2 input information
+ */
+struct tvp514x_input_info {
+	u8 input_sel;
+	u8 lock_mask;
+	struct v4l2_input input;
+};
+
+/**
+ * struct tvp514x_platform_data - Platform data values and access functions
+ * @power_set: Power state access function, zero is off, non-zero is on.
+ * @ifparm: Interface parameters access function
+ * @priv_data_set: Device private data (pointer) access function
+ * @reg_list: The board dependent driver should fill the default value for
+ *            required registers depending on board layout. The TVP5146/47
+ *            driver will update this register list for the registers
+ *            whose values should be maintained across open()/close() like
+ *            setting brightness as defined in V4L2.
+ *            The register list should be in the same order as defined in
+ *            TVP5146/47 datasheet including reserved registers. As of now
+ *            the driver expects the size of this list to be a minimum of
+ *            57 + 1 (upto regsiter REG_CLEAR_LOST_LOCK).
+ *            The last member should be of the list should be
+ *            {TOK_TERM, 0, 0} to indicate the end of register list.
+ * @num_inputs: Number of input connection in board
+ * @input_list: Input information list for num_inputs
+ */
+struct tvp514x_platform_data {
+	char *master;
+	int (*power_set) (enum v4l2_power on);
+	int (*ifparm) (struct v4l2_ifparm *p);
+	int (*priv_data_set) (void *);
+
+	struct tvp514x_reg *reg_list;
+
+	int num_inputs;
+	const struct tvp514x_input_info *input_list;
+};
+
+/**
+ * struct tvp514x_decoded - TVP5146/47 decoder object
+ * @v4l2_int_device: Slave handle
+ * @pdata: Board specific
+ * @client: I2C client data
+ * @ver: Chip version
+ * @state: TVP5146/47 decoder state - detected or not-detected
+ * @pix: Current pixel format
+ * @num_fmts: Number of formats
+ * @fmt_list: Format list
+ * @current_std: Current standard
+ * @num_stds: Number of standards
+ * @std_list: Standards list
+ * @num_ctrls: Number of controls
+ * @ctrl_list: Control list
+ */
+struct tvp514x_decoder {
+	struct v4l2_int_device *v4l2_int_device;
+	const struct tvp514x_platform_data *pdata;
+	struct i2c_client *client;
+
+	int ver;
+	enum tvp514x_state state;
+
+	struct v4l2_pix_format pix;
+	int num_fmts;
+	const struct v4l2_fmtdesc *fmt_list;
+
+	enum tvp514x_std current_std;
+	int num_stds;
+	struct tvp514x_std_info *std_list;
+
+	int num_ctrls;
+	const struct tvp514x_ctrl_info *ctrl_list;
+
+	int inputidx;
+};
+
+#endif				/* ifndef _TVP514X_H */
--
1.5.6

--
video4linux-list mailing list
Unsubscribe mailto:video4linux-list-request@redhat.com?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list

^ permalink raw reply related	[flat|nested] 263+ messages in thread

* Re: [PATCH 2/2] TVP514x V4L int device driver support
  2008-11-21 15:22 ` [PATCH 2/2] TVP514x V4L int device driver support hvaibhav
@ 2008-11-21 16:16   ` Hans Verkuil
  2008-11-21 18:12     ` Trilok Soni
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 263+ messages in thread
From: Hans Verkuil @ 2008-11-21 16:16 UTC (permalink / raw)
  To: video4linux-list; +Cc: linux-omap, davinci-linux-open-source-bounces

On Friday 21 November 2008 16:22:03 hvaibhav@ti.com wrote:
> From: Vaibhav Hiremath <hvaibhav@ti.com>
>
> Added new V4L2 slave driver for TVP514x.
>
> The Driver interface has been tested on OMAP3EVM board
> with TI daughter card (TVP5146). Soon the patch for Daughter card
> will be posted on community.
>
> Signed-off-by: Brijesh Jadav <brijesh.j@ti.com>
> 		Hardik Shah <hardik.shah@ti.com>
> 		Manjunath Hadli <mrh@ti.com>
> 		R Sivaraj <sivaraj@ti.com>
> 		Vaibhav Hiremath <hvaibhav@ti.com>
> 		Karicheri Muralidharan <m-karicheri2@ti.com>
> ---
>  drivers/media/video/Kconfig   |   11 +
>  drivers/media/video/Makefile  |    1 +
>  drivers/media/video/tvp514x.c | 1331
> +++++++++++++++++++++++++++++++++++++++++ include/media/tvp514x.h    
>   |  406 +++++++++++++
>  4 files changed, 1749 insertions(+), 0 deletions(-)
>  create mode 100644 drivers/media/video/tvp514x.c
>  create mode 100644 include/media/tvp514x.h
>

I'll review this today or tomorrow.

Regards,

	Hans

--
video4linux-list mailing list
Unsubscribe mailto:video4linux-list-request@redhat.com?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list

^ permalink raw reply	[flat|nested] 263+ messages in thread

* Re: [PATCH 2/2] TVP514x V4L int device driver support
  2008-11-21 15:22 ` [PATCH 2/2] TVP514x V4L int device driver support hvaibhav
@ 2008-11-21 18:12     ` Trilok Soni
  2008-11-21 18:12     ` Trilok Soni
                       ` (2 subsequent siblings)
  3 siblings, 0 replies; 263+ messages in thread
From: Trilok Soni @ 2008-11-21 18:12 UTC (permalink / raw)
  To: hvaibhav; +Cc: video4linux-list, linux-omap, davinci-linux-open-source-bounces

Hi Vaibhav,

On Fri, Nov 21, 2008 at 8:52 PM,  <hvaibhav@ti.com> wrote:
> From: Vaibhav Hiremath <hvaibhav@ti.com>
>
> Added new V4L2 slave driver for TVP514x.
>
> The Driver interface has been tested on OMAP3EVM board
> with TI daughter card (TVP5146). Soon the patch for Daughter card will
> be posted on community.

You may want to add some of the TVP5146 video decoder capabilities in
commit text. Useful for someone who just sees this chip for first
time.

>
> Signed-off-by: Brijesh Jadav <brijesh.j@ti.com>
>                Hardik Shah <hardik.shah@ti.com>
>                Manjunath Hadli <mrh@ti.com>
>                R Sivaraj <sivaraj@ti.com>
>                Vaibhav Hiremath <hvaibhav@ti.com>
>                Karicheri Muralidharan <m-karicheri2@ti.com>

I suggested to change this in another email.

> +
> +#include <linux/i2c.h>
> +#include <linux/delay.h>
> +#include <linux/videodev2.h>
> +#include <media/v4l2-int-device.h>

Convention is is to put empty line between  #include <linux/xxx.h> and
first #include <nonlinux/xxx.h> which is #include
<media/v4l2-int-device.h>

> +#include <media/tvp514x.h>
> +

> +
> +/* List of image formats supported by TVP5146/47 decoder
> + * Currently we are using 8 bit mode only, but can be
> + * extended to 10/20 bit mode.
> + */
> +static const struct v4l2_fmtdesc tvp514x_fmt_list[] = {
> +       {
> +        .index = 0,
> +        .type = V4L2_BUF_TYPE_VIDEO_CAPTURE,
> +        .flags = 0,
> +        .description = "8-bit UYVY 4:2:2 Format",
> +        .pixelformat = V4L2_PIX_FMT_UYVY,
> +        }

Good to add "," after the last element.

> +static struct tvp514x_std_info tvp514x_std_list[] = {
> +       {
> +        .width = NTSC_NUM_ACTIVE_PIXELS,
> +        .height = NTSC_NUM_ACTIVE_LINES,
> +        .video_std = VIDEO_STD_NTSC_MJ_BIT,
> +        .standard = {
> +                     .index = 0,
> +                     .id = V4L2_STD_NTSC,
> +                     .name = "NTSC",
> +                     .frameperiod = {1001, 30000},
> +                     .framelines = 525}

"{" after 525 looks weird.

> +        },
> +       {

You can put "{" with "}" to save one line . Like this

"}, {"

You may want to make similar changes at other places in the patch.

> +static enum tvp514x_std tvp514x_get_current_std(struct tvp514x_decoder
> +                                               *decoder)
> +{
> +       u8 std, std_status;
> +
> +       if (tvp514x_read_reg(decoder->client, REG_VIDEO_STD, &std))
> +               return STD_INVALID;
> +
> +       if ((std & VIDEO_STD_MASK) == VIDEO_STD_AUTO_SWITCH_BIT) {
> +               /* use the standard status register */
> +               if (tvp514x_read_reg(decoder->client, REG_VIDEO_STD_STATUS,
> +                                    &std_status))
> +                       return STD_INVALID;
> +       } else
> +               std_status = std;       /* use the standard register itself */
> +
> +       switch (std_status & VIDEO_STD_MASK) {
> +       case VIDEO_STD_NTSC_MJ_BIT:
> +               return STD_NTSC_MJ;
> +               break;

No need of " break" here.

> +
> +       case VIDEO_STD_PAL_BDGHIN_BIT:
> +               return STD_PAL_BDGHIN;
> +               break;

Ditto.

> +
> +       default:
> +               return STD_INVALID;
> +               break;

Tritto?

> +       }
> +
> +       return STD_INVALID;
> +}
> +

> +
> +static int
> +tvp514x_probe(struct i2c_client *client, const struct i2c_device_id *id)
> +{

Mark this as __init please.

-- 
---Trilok Soni
http://triloksoni.wordpress.com
http://www.linkedin.com/in/triloksoni

--
video4linux-list mailing list
Unsubscribe mailto:video4linux-list-request@redhat.com?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list

^ permalink raw reply	[flat|nested] 263+ messages in thread

* Re: [PATCH 2/2] TVP514x V4L int device driver support
@ 2008-11-21 18:12     ` Trilok Soni
  0 siblings, 0 replies; 263+ messages in thread
From: Trilok Soni @ 2008-11-21 18:12 UTC (permalink / raw)
  To: hvaibhav; +Cc: video4linux-list, linux-omap, davinci-linux-open-source-bounces

Hi Vaibhav,

On Fri, Nov 21, 2008 at 8:52 PM,  <hvaibhav@ti.com> wrote:
> From: Vaibhav Hiremath <hvaibhav@ti.com>
>
> Added new V4L2 slave driver for TVP514x.
>
> The Driver interface has been tested on OMAP3EVM board
> with TI daughter card (TVP5146). Soon the patch for Daughter card will
> be posted on community.

You may want to add some of the TVP5146 video decoder capabilities in
commit text. Useful for someone who just sees this chip for first
time.

>
> Signed-off-by: Brijesh Jadav <brijesh.j@ti.com>
>                Hardik Shah <hardik.shah@ti.com>
>                Manjunath Hadli <mrh@ti.com>
>                R Sivaraj <sivaraj@ti.com>
>                Vaibhav Hiremath <hvaibhav@ti.com>
>                Karicheri Muralidharan <m-karicheri2@ti.com>

I suggested to change this in another email.

> +
> +#include <linux/i2c.h>
> +#include <linux/delay.h>
> +#include <linux/videodev2.h>
> +#include <media/v4l2-int-device.h>

Convention is is to put empty line between  #include <linux/xxx.h> and
first #include <nonlinux/xxx.h> which is #include
<media/v4l2-int-device.h>

> +#include <media/tvp514x.h>
> +

> +
> +/* List of image formats supported by TVP5146/47 decoder
> + * Currently we are using 8 bit mode only, but can be
> + * extended to 10/20 bit mode.
> + */
> +static const struct v4l2_fmtdesc tvp514x_fmt_list[] = {
> +       {
> +        .index = 0,
> +        .type = V4L2_BUF_TYPE_VIDEO_CAPTURE,
> +        .flags = 0,
> +        .description = "8-bit UYVY 4:2:2 Format",
> +        .pixelformat = V4L2_PIX_FMT_UYVY,
> +        }

Good to add "," after the last element.

> +static struct tvp514x_std_info tvp514x_std_list[] = {
> +       {
> +        .width = NTSC_NUM_ACTIVE_PIXELS,
> +        .height = NTSC_NUM_ACTIVE_LINES,
> +        .video_std = VIDEO_STD_NTSC_MJ_BIT,
> +        .standard = {
> +                     .index = 0,
> +                     .id = V4L2_STD_NTSC,
> +                     .name = "NTSC",
> +                     .frameperiod = {1001, 30000},
> +                     .framelines = 525}

"{" after 525 looks weird.

> +        },
> +       {

You can put "{" with "}" to save one line . Like this

"}, {"

You may want to make similar changes at other places in the patch.

> +static enum tvp514x_std tvp514x_get_current_std(struct tvp514x_decoder
> +                                               *decoder)
> +{
> +       u8 std, std_status;
> +
> +       if (tvp514x_read_reg(decoder->client, REG_VIDEO_STD, &std))
> +               return STD_INVALID;
> +
> +       if ((std & VIDEO_STD_MASK) == VIDEO_STD_AUTO_SWITCH_BIT) {
> +               /* use the standard status register */
> +               if (tvp514x_read_reg(decoder->client, REG_VIDEO_STD_STATUS,
> +                                    &std_status))
> +                       return STD_INVALID;
> +       } else
> +               std_status = std;       /* use the standard register itself */
> +
> +       switch (std_status & VIDEO_STD_MASK) {
> +       case VIDEO_STD_NTSC_MJ_BIT:
> +               return STD_NTSC_MJ;
> +               break;

No need of " break" here.

> +
> +       case VIDEO_STD_PAL_BDGHIN_BIT:
> +               return STD_PAL_BDGHIN;
> +               break;

Ditto.

> +
> +       default:
> +               return STD_INVALID;
> +               break;

Tritto?

> +       }
> +
> +       return STD_INVALID;
> +}
> +

> +
> +static int
> +tvp514x_probe(struct i2c_client *client, const struct i2c_device_id *id)
> +{

Mark this as __init please.

-- 
---Trilok Soni
http://triloksoni.wordpress.com
http://www.linkedin.com/in/triloksoni

^ permalink raw reply	[flat|nested] 263+ messages in thread

* RE: [PATCH 2/2] TVP514x V4L int device driver support
  2008-11-21 18:12     ` Trilok Soni
@ 2008-11-21 19:07       ` Hiremath, Vaibhav
  -1 siblings, 0 replies; 263+ messages in thread
From: Hiremath, Vaibhav @ 2008-11-21 19:07 UTC (permalink / raw)
  To: Trilok Soni
  Cc: video4linux-list, linux-omap, davinci-linux-open-source-bounces



Thanks,
Vaibhav Hiremath

> -----Original Message-----
> From: Trilok Soni [mailto:soni.trilok@gmail.com]
> Sent: Friday, November 21, 2008 11:43 PM
> To: Hiremath, Vaibhav
> Cc: video4linux-list@redhat.com; linux-omap@vger.kernel.org;
> davinci-linux-open-source-bounces@linux.davincidsp.com
> Subject: Re: [PATCH 2/2] TVP514x V4L int device driver support
> 
> Hi Vaibhav,
> 
> On Fri, Nov 21, 2008 at 8:52 PM,  <hvaibhav@ti.com> wrote:
> > From: Vaibhav Hiremath <hvaibhav@ti.com>
> >
> > Added new V4L2 slave driver for TVP514x.
> >
> > The Driver interface has been tested on OMAP3EVM board
> > with TI daughter card (TVP5146). Soon the patch for Daughter card
> will
> > be posted on community.
> 
> You may want to add some of the TVP5146 video decoder capabilities
> in
> commit text. Useful for someone who just sees this chip for first
> time.
> 
[Hiremath, Vaibhav] Will take care next time.
> >
> > Signed-off-by: Brijesh Jadav <brijesh.j@ti.com>
> >                Hardik Shah <hardik.shah@ti.com>
> >                Manjunath Hadli <mrh@ti.com>
> >                R Sivaraj <sivaraj@ti.com>
> >                Vaibhav Hiremath <hvaibhav@ti.com>
> >                Karicheri Muralidharan <m-karicheri2@ti.com>
> 
> I suggested to change this in another email.
> 
[Hiremath, Vaibhav] Point taken.
> > +
> > +#include <linux/i2c.h>
> > +#include <linux/delay.h>
> > +#include <linux/videodev2.h>
> > +#include <media/v4l2-int-device.h>
> 
> Convention is is to put empty line between  #include <linux/xxx.h>
> and
> first #include <nonlinux/xxx.h> which is #include
> <media/v4l2-int-device.h>
> 
[Hiremath, Vaibhav] I had referred to the other driver files under media/video/ (e.g. tvp5150) which doesn't follow this. Not sure about actual convention, but it looks like line break is expected between standard include (linux or non-linux) and local include.
E.g.
include <linux/xxx.h>
include <media/yyy.h>

Include "zzz.h"


> > +#include <media/tvp514x.h>
> > +
> 
> > +
> > +/* List of image formats supported by TVP5146/47 decoder
> > + * Currently we are using 8 bit mode only, but can be
> > + * extended to 10/20 bit mode.
> > + */
> > +static const struct v4l2_fmtdesc tvp514x_fmt_list[] = {
> > +       {
> > +        .index = 0,
> > +        .type = V4L2_BUF_TYPE_VIDEO_CAPTURE,
> > +        .flags = 0,
> > +        .description = "8-bit UYVY 4:2:2 Format",
> > +        .pixelformat = V4L2_PIX_FMT_UYVY,
> > +        }
> 
> Good to add "," after the last element.
> 
> > +static struct tvp514x_std_info tvp514x_std_list[] = {
> > +       {
> > +        .width = NTSC_NUM_ACTIVE_PIXELS,
> > +        .height = NTSC_NUM_ACTIVE_LINES,
> > +        .video_std = VIDEO_STD_NTSC_MJ_BIT,
> > +        .standard = {
> > +                     .index = 0,
> > +                     .id = V4L2_STD_NTSC,
> > +                     .name = "NTSC",
> > +                     .frameperiod = {1001, 30000},
> > +                     .framelines = 525}
> 
> "{" after 525 looks weird.
> 
> > +        },
> > +       {
> 
> You can put "{" with "}" to save one line . Like this
> 
> "}, {"
> 
[Hiremath, Vaibhav] Point taken.

> You may want to make similar changes at other places in the patch.
> 
> > +static enum tvp514x_std tvp514x_get_current_std(struct
> tvp514x_decoder
> > +                                               *decoder)
> > +{
> > +       u8 std, std_status;
> > +
> > +       if (tvp514x_read_reg(decoder->client, REG_VIDEO_STD,
> &std))
> > +               return STD_INVALID;
> > +
> > +       if ((std & VIDEO_STD_MASK) == VIDEO_STD_AUTO_SWITCH_BIT) {
> > +               /* use the standard status register */
> > +               if (tvp514x_read_reg(decoder->client,
> REG_VIDEO_STD_STATUS,
> > +                                    &std_status))
> > +                       return STD_INVALID;
> > +       } else
> > +               std_status = std;       /* use the standard
> register itself */
> > +
> > +       switch (std_status & VIDEO_STD_MASK) {
> > +       case VIDEO_STD_NTSC_MJ_BIT:
> > +               return STD_NTSC_MJ;
> > +               break;
> 
> No need of " break" here.
> 
[Hiremath, Vaibhav] Point taken.

> > +
> > +       case VIDEO_STD_PAL_BDGHIN_BIT:
> > +               return STD_PAL_BDGHIN;
> > +               break;
> 
> Ditto.
> 
> > +
> > +       default:
> > +               return STD_INVALID;
> > +               break;
> 
> Tritto?
> 
> > +       }
> > +
> > +       return STD_INVALID;
> > +}
> > +
> 
> > +
> > +static int
> > +tvp514x_probe(struct i2c_client *client, const struct
> i2c_device_id *id)
> > +{
> 
> Mark this as __init please.
> 
[Hiremath, Vaibhav] Again valid point. I will update the patch with review comments and post it again. Please let me know if there are any more comments.

> --
> ---Trilok Soni
> http://triloksoni.wordpress.com
> http://www.linkedin.com/in/triloksoni


--
video4linux-list mailing list
Unsubscribe mailto:video4linux-list-request@redhat.com?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list

^ permalink raw reply	[flat|nested] 263+ messages in thread

* RE: [PATCH 2/2] TVP514x V4L int device driver support
@ 2008-11-21 19:07       ` Hiremath, Vaibhav
  0 siblings, 0 replies; 263+ messages in thread
From: Hiremath, Vaibhav @ 2008-11-21 19:07 UTC (permalink / raw)
  To: Trilok Soni
  Cc: video4linux-list, linux-omap, davinci-linux-open-source-bounces



Thanks,
Vaibhav Hiremath

> -----Original Message-----
> From: Trilok Soni [mailto:soni.trilok@gmail.com]
> Sent: Friday, November 21, 2008 11:43 PM
> To: Hiremath, Vaibhav
> Cc: video4linux-list@redhat.com; linux-omap@vger.kernel.org;
> davinci-linux-open-source-bounces@linux.davincidsp.com
> Subject: Re: [PATCH 2/2] TVP514x V4L int device driver support
> 
> Hi Vaibhav,
> 
> On Fri, Nov 21, 2008 at 8:52 PM,  <hvaibhav@ti.com> wrote:
> > From: Vaibhav Hiremath <hvaibhav@ti.com>
> >
> > Added new V4L2 slave driver for TVP514x.
> >
> > The Driver interface has been tested on OMAP3EVM board
> > with TI daughter card (TVP5146). Soon the patch for Daughter card
> will
> > be posted on community.
> 
> You may want to add some of the TVP5146 video decoder capabilities
> in
> commit text. Useful for someone who just sees this chip for first
> time.
> 
[Hiremath, Vaibhav] Will take care next time.
> >
> > Signed-off-by: Brijesh Jadav <brijesh.j@ti.com>
> >                Hardik Shah <hardik.shah@ti.com>
> >                Manjunath Hadli <mrh@ti.com>
> >                R Sivaraj <sivaraj@ti.com>
> >                Vaibhav Hiremath <hvaibhav@ti.com>
> >                Karicheri Muralidharan <m-karicheri2@ti.com>
> 
> I suggested to change this in another email.
> 
[Hiremath, Vaibhav] Point taken.
> > +
> > +#include <linux/i2c.h>
> > +#include <linux/delay.h>
> > +#include <linux/videodev2.h>
> > +#include <media/v4l2-int-device.h>
> 
> Convention is is to put empty line between  #include <linux/xxx.h>
> and
> first #include <nonlinux/xxx.h> which is #include
> <media/v4l2-int-device.h>
> 
[Hiremath, Vaibhav] I had referred to the other driver files under media/video/ (e.g. tvp5150) which doesn't follow this. Not sure about actual convention, but it looks like line break is expected between standard include (linux or non-linux) and local include.
E.g.
include <linux/xxx.h>
include <media/yyy.h>

Include "zzz.h"


> > +#include <media/tvp514x.h>
> > +
> 
> > +
> > +/* List of image formats supported by TVP5146/47 decoder
> > + * Currently we are using 8 bit mode only, but can be
> > + * extended to 10/20 bit mode.
> > + */
> > +static const struct v4l2_fmtdesc tvp514x_fmt_list[] = {
> > +       {
> > +        .index = 0,
> > +        .type = V4L2_BUF_TYPE_VIDEO_CAPTURE,
> > +        .flags = 0,
> > +        .description = "8-bit UYVY 4:2:2 Format",
> > +        .pixelformat = V4L2_PIX_FMT_UYVY,
> > +        }
> 
> Good to add "," after the last element.
> 
> > +static struct tvp514x_std_info tvp514x_std_list[] = {
> > +       {
> > +        .width = NTSC_NUM_ACTIVE_PIXELS,
> > +        .height = NTSC_NUM_ACTIVE_LINES,
> > +        .video_std = VIDEO_STD_NTSC_MJ_BIT,
> > +        .standard = {
> > +                     .index = 0,
> > +                     .id = V4L2_STD_NTSC,
> > +                     .name = "NTSC",
> > +                     .frameperiod = {1001, 30000},
> > +                     .framelines = 525}
> 
> "{" after 525 looks weird.
> 
> > +        },
> > +       {
> 
> You can put "{" with "}" to save one line . Like this
> 
> "}, {"
> 
[Hiremath, Vaibhav] Point taken.

> You may want to make similar changes at other places in the patch.
> 
> > +static enum tvp514x_std tvp514x_get_current_std(struct
> tvp514x_decoder
> > +                                               *decoder)
> > +{
> > +       u8 std, std_status;
> > +
> > +       if (tvp514x_read_reg(decoder->client, REG_VIDEO_STD,
> &std))
> > +               return STD_INVALID;
> > +
> > +       if ((std & VIDEO_STD_MASK) == VIDEO_STD_AUTO_SWITCH_BIT) {
> > +               /* use the standard status register */
> > +               if (tvp514x_read_reg(decoder->client,
> REG_VIDEO_STD_STATUS,
> > +                                    &std_status))
> > +                       return STD_INVALID;
> > +       } else
> > +               std_status = std;       /* use the standard
> register itself */
> > +
> > +       switch (std_status & VIDEO_STD_MASK) {
> > +       case VIDEO_STD_NTSC_MJ_BIT:
> > +               return STD_NTSC_MJ;
> > +               break;
> 
> No need of " break" here.
> 
[Hiremath, Vaibhav] Point taken.

> > +
> > +       case VIDEO_STD_PAL_BDGHIN_BIT:
> > +               return STD_PAL_BDGHIN;
> > +               break;
> 
> Ditto.
> 
> > +
> > +       default:
> > +               return STD_INVALID;
> > +               break;
> 
> Tritto?
> 
> > +       }
> > +
> > +       return STD_INVALID;
> > +}
> > +
> 
> > +
> > +static int
> > +tvp514x_probe(struct i2c_client *client, const struct
> i2c_device_id *id)
> > +{
> 
> Mark this as __init please.
> 
[Hiremath, Vaibhav] Again valid point. I will update the patch with review comments and post it again. Please let me know if there are any more comments.

> --
> ---Trilok Soni
> http://triloksoni.wordpress.com
> http://www.linkedin.com/in/triloksoni


^ permalink raw reply	[flat|nested] 263+ messages in thread

* Re: [PATCH 2/2] TVP514x V4L int device driver support
  2008-11-21 18:12     ` Trilok Soni
  (?)
  (?)
@ 2008-11-21 19:11     ` David Brownell
  -1 siblings, 0 replies; 263+ messages in thread
From: David Brownell @ 2008-11-21 19:11 UTC (permalink / raw)
  To: Trilok Soni
  Cc: hvaibhav, video4linux-list, linux-omap,
	davinci-linux-open-source-bounces

On Friday 21 November 2008, Trilok Soni wrote:
> > +
> > +static int
> > +tvp514x_probe(struct i2c_client *client, const struct i2c_device_id *id)
> > +{
> 
> Mark this as __init please.

No, don't.  It's for an I2C device ... which means it needs
to stay hotpluggable.

There are *very* few places it's correct to mark probe()
methods as __init, or even __devinit, and this isn't one
of those exceptions.

- Dave

^ permalink raw reply	[flat|nested] 263+ messages in thread

* Re: [PATCH 2/2] TVP514x V4L int device driver support
  2008-11-21 15:22 ` [PATCH 2/2] TVP514x V4L int device driver support hvaibhav
  2008-11-21 16:16   ` Hans Verkuil
  2008-11-21 18:12     ` Trilok Soni
@ 2008-11-23 22:00   ` Hans Verkuil
  2008-11-23 22:04     ` Koen Kooi
  2008-11-24  6:16       ` Trilok Soni
  2008-11-24 10:06   ` David Brownell
  3 siblings, 2 replies; 263+ messages in thread
From: Hans Verkuil @ 2008-11-23 22:00 UTC (permalink / raw)
  To: video4linux-list; +Cc: linux-omap, davinci-linux-open-source-bounces

Hi Vaibhav,

Here is my review as promised (although a day late). It's a mix of 
smaller and larger issues:

1) CONFIG_VIDEO_ADV_DEBUG is meant to enable the ability to set/get 
registers through the VIDIOC_DBG_G/S_REGISTER ioctls. For general 
debugging you should use a debug module option (see e.g. saa7115.c).

2) Please use the media/v4l2-i2c-drv.h or media/v4l2-i2c-drv-legacy.h 
header to hide some of the i2c complexity (again, see e.g. saa7115.c). 
The i2c API tends to change a lot (and some changes are upcoming) so 
using this header will mean that i2c driver changes will be minimal in 
the future. In addition it will ensure that this driver can be compiled 
with older kernels as well once it is part of the v4l-dvb repository.

3) Remember that the use of v4l2-int-device.h must be temporary only. It 
will make it impossible to use this driver with any other platform but 
omap. I had hoped to release my generic v4l2 subdevice support today 
which should replace v4l2-int-device.h in time, but I hit a bug that 
needs to be resolved first. I hope to fix it during the next week so 
that I can finally make it available for use asap.

4) This is the really big problem I have with this driver: it relies on 
the bridge driver to do the initialization of the registers. This is 
very much the wrong approach. It would require all bridge drivers that 
are going to use this chip to program the chips registers. That's not 
the way to do it. The tvp514x driver should do this and the bridge 
driver should only pass high-level config data (such as with 
input/output pins are being used). Again, see saa7115, cx25840, etc. 
This approach means that all the relevant programming is inside the 
chip's driver and that bridge drivers can easily replace one chip for 
another since except for a little bit of initialization (usually 
routing, clock frequencies) there is otherwise no difference between 
using one chip or another.

Remember that this is not a driver for use with omap, this is a generic 
i2c driver for this chip. omap just happens to be the only bridge 
driver using it right now, but that can easily change.

Yes, it makes it harder to write an i2c driver, but experience has shown 
us that the advantages regarding reuse far outweigh this initial cost.

Regards,

	Hans

On Friday 21 November 2008 16:22:03 hvaibhav@ti.com wrote:
> From: Vaibhav Hiremath <hvaibhav@ti.com>
>
> Added new V4L2 slave driver for TVP514x.
>
> The Driver interface has been tested on OMAP3EVM board
> with TI daughter card (TVP5146). Soon the patch for Daughter card
> will be posted on community.
>
> Signed-off-by: Brijesh Jadav <brijesh.j@ti.com>
> 		Hardik Shah <hardik.shah@ti.com>
> 		Manjunath Hadli <mrh@ti.com>
> 		R Sivaraj <sivaraj@ti.com>
> 		Vaibhav Hiremath <hvaibhav@ti.com>
> 		Karicheri Muralidharan <m-karicheri2@ti.com>
> ---
>  drivers/media/video/Kconfig   |   11 +
>  drivers/media/video/Makefile  |    1 +
>  drivers/media/video/tvp514x.c | 1331
> +++++++++++++++++++++++++++++++++++++++++ include/media/tvp514x.h    
>   |  406 +++++++++++++
>  4 files changed, 1749 insertions(+), 0 deletions(-)
>  create mode 100644 drivers/media/video/tvp514x.c
>  create mode 100644 include/media/tvp514x.h
>
> diff --git a/drivers/media/video/Kconfig
> b/drivers/media/video/Kconfig index 47102c2..377d14e 100644
> --- a/drivers/media/video/Kconfig
> +++ b/drivers/media/video/Kconfig
> @@ -361,6 +361,17 @@ config VIDEO_SAA7191
>  	  To compile this driver as a module, choose M here: the
>  	  module will be called saa7191.
>
> +config VIDEO_TVP514X
> +	tristate "Texas Instruments TVP5146/47 video decoder"
> +	depends on VIDEO_V4L2 && I2C
> +	---help---
> +	  This is a Video4Linux2 sensor-level driver for the TI TVP5146/47
> +	  decoder. It is currently working with the TI OMAP3 camera
> +	  controller.
> +
> +	  To compile this driver as a module, choose M here: the
> +	  module will be called tvp514x.
> +
>  config VIDEO_TVP5150
>  	tristate "Texas Instruments TVP5150 video decoder"
>  	depends on VIDEO_V4L2 && I2C
> diff --git a/drivers/media/video/Makefile
> b/drivers/media/video/Makefile index 16962f3..cdbbf38 100644
> --- a/drivers/media/video/Makefile
> +++ b/drivers/media/video/Makefile
> @@ -66,6 +66,7 @@ obj-$(CONFIG_VIDEO_CX88) += cx88/
>  obj-$(CONFIG_VIDEO_EM28XX) += em28xx/
>  obj-$(CONFIG_VIDEO_USBVISION) += usbvision/
>  obj-$(CONFIG_VIDEO_TVP5150) += tvp5150.o
> +obj-$(CONFIG_VIDEO_TVP514X) += tvp514x.o
>  obj-$(CONFIG_VIDEO_PVRUSB2) += pvrusb2/
>  obj-$(CONFIG_VIDEO_MSP3400) += msp3400.o
>  obj-$(CONFIG_VIDEO_CS5345) += cs5345.o
> diff --git a/drivers/media/video/tvp514x.c
> b/drivers/media/video/tvp514x.c new file mode 100644
> index 0000000..b68ddf5
> --- /dev/null
> +++ b/drivers/media/video/tvp514x.c
> @@ -0,0 +1,1331 @@
> +/*
> + * drivers/media/video/tvp514x.c
> + *
> + * TI TVP5146/47 decoder driver
> + *
> + * Copyright (C) 2008 Texas Instruments Inc
> + *
> + * Contributors:
> + *     Brijesh R Jadav <brijesh.j@ti.com>
> + *     Hardik Shah <hardik.shah@ti.com>
> + *     Manjunath Hadli <mrh@ti.com>
> + *     Sivaraj R <sivaraj@ti.com>
> + *     Vaibhav Hiremath <hvaibhav@ti.com>
> + *
> + * This package is free software; you can redistribute it and/or
> modify + * it under the terms of the GNU General Public License
> version 2 as + * published by the Free Software Foundation.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program; if not, write to the Free Software
> + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
> + *
> + */
> +
> +#include <linux/i2c.h>
> +#include <linux/delay.h>
> +#include <linux/videodev2.h>
> +#include <media/v4l2-int-device.h>
> +#include <media/tvp514x.h>
> +
> +#define MODULE_NAME	TVP514X_MODULE_NAME
> +
> +/* Debug functions */
> +#ifdef CONFIG_VIDEO_ADV_DEBUG
> +
> +#define dump_reg(client, reg, val)					\
> +	do {								\
> +		tvp514x_read_reg(client, reg, &val);			\
> +		dev_dbg(&(client)->dev, "Reg(0x%.2X): 0x%.2X\n", reg, val); \
> +	} while (0)
> +
> +#endif				/* #ifdef CONFIG_VIDEO_ADV_DEBUG */
> +
> +/* List of image formats supported by TVP5146/47 decoder
> + * Currently we are using 8 bit mode only, but can be
> + * extended to 10/20 bit mode.
> + */
> +static const struct v4l2_fmtdesc tvp514x_fmt_list[] = {
> +	{
> +	 .index = 0,
> +	 .type = V4L2_BUF_TYPE_VIDEO_CAPTURE,
> +	 .flags = 0,
> +	 .description = "8-bit UYVY 4:2:2 Format",
> +	 .pixelformat = V4L2_PIX_FMT_UYVY,
> +	 }
> +};
> +
> +#define TVP514X_NUM_FORMATS		ARRAY_SIZE(tvp514x_fmt_list)
> +
> +/*
> + * Supported standards - These must be ordered according to enum
> tvp514x_std + * order.
> + * Currently supports two standards only, need to add support for
> rest of the + * modes, like SECAM, etc...
> + */
> +static struct tvp514x_std_info tvp514x_std_list[] = {
> +	{
> +	 .width = NTSC_NUM_ACTIVE_PIXELS,
> +	 .height = NTSC_NUM_ACTIVE_LINES,
> +	 .video_std = VIDEO_STD_NTSC_MJ_BIT,
> +	 .standard = {
> +		      .index = 0,
> +		      .id = V4L2_STD_NTSC,
> +		      .name = "NTSC",
> +		      .frameperiod = {1001, 30000},
> +		      .framelines = 525}
> +	 },
> +	{
> +	 .width = PAL_NUM_ACTIVE_PIXELS,
> +	 .height = PAL_NUM_ACTIVE_LINES,
> +	 .video_std = VIDEO_STD_PAL_BDGHIN_BIT,
> +	 .standard = {
> +		      .index = 1,
> +		      .id = V4L2_STD_PAL,
> +		      .name = "PAL",
> +		      .frameperiod = {1, 25},
> +		      .framelines = 625}
> +	 }
> +};
> +
> +#define TVP514X_NUM_STANDARDS		ARRAY_SIZE(tvp514x_std_list)
> +
> +/* Supported controls */
> +static const struct tvp514x_ctrl_info tvp514x_ctrl_list[] = {
> +	{
> +	 .reg_address = REG_BRIGHTNESS,
> +	 .query_ctrl = {
> +			.id = V4L2_CID_BRIGHTNESS,
> +			.name = "BRIGHTNESS",
> +			.type = V4L2_CTRL_TYPE_INTEGER,
> +			.minimum = 0,
> +			.maximum = 255,
> +			.step = 1,
> +			.default_value = 128}
> +	 },
> +	{
> +	 .reg_address = REG_CONTRAST,
> +	 .query_ctrl = {
> +			.id = V4L2_CID_CONTRAST,
> +			.name = "CONTRAST",
> +			.type = V4L2_CTRL_TYPE_INTEGER,
> +			.minimum = 0,
> +			.maximum = 255,
> +			.step = 1,
> +			.default_value = 128}
> +	 },
> +	{
> +	 .reg_address = REG_SATURATION,
> +	 .query_ctrl = {
> +			.id = V4L2_CID_SATURATION,
> +			.name = "SATURATION",
> +			.type = V4L2_CTRL_TYPE_INTEGER,
> +			.minimum = 0,
> +			.maximum = 255,
> +			.step = 1,
> +			.default_value = 128}
> +	 },
> +	{
> +	 .reg_address = REG_HUE,
> +	 .query_ctrl = {
> +			.id = V4L2_CID_HUE,
> +			.name = "HUE",
> +			.type = V4L2_CTRL_TYPE_INTEGER,
> +			.minimum = -180,
> +			.maximum = 180,
> +			.step = 180,
> +			.default_value = 0}
> +	 },
> +	{
> +	 .reg_address = REG_AFE_GAIN_CTRL,
> +	 .query_ctrl = {
> +			.id = V4L2_CID_AUTOGAIN,
> +			.name = "Automatic Gain Control",
> +			.type = V4L2_CTRL_TYPE_BOOLEAN,
> +			.minimum = 0,
> +			.maximum = 1,
> +			.step = 1,
> +			.default_value = 1}
> +	 }
> +};
> +
> +#define TVP514X_NUM_CONTROLS		ARRAY_SIZE(tvp514x_ctrl_list)
> +
> +/*
> + * Read a value from a register in an TVP5146/47 decoder device.
> + * The value is returned in 'val'.
> + * Returns zero if successful, or non-zero otherwise.
> + */
> +static int tvp514x_read_reg(struct i2c_client *client, u8 reg, u8
> *val) +{
> +	int err;
> +	struct i2c_msg msg[2];
> +	u8 data;
> +
> +	if (!client->adapter)
> +		return -ENODEV;
> +
> +	/* [MSG1] fill the register address data */
> +	data = reg;
> +	msg[0].addr = client->addr;
> +	msg[0].len = 1;
> +	msg[0].flags = 0;
> +	msg[0].buf = &data;
> +
> +	/* [MSG2] fill the data rx buffer */
> +	msg[1].addr = client->addr;
> +	msg[1].len = 1;		/* only 1 byte */
> +	msg[1].flags = I2C_M_RD;	/* Read the register values */
> +	msg[1].buf = val;
> +	err = i2c_transfer(client->adapter, msg, 2);
> +	if (err >= 0)
> +		return 0;
> +
> +	dev_err(&client->dev,
> +		"read from device 0x%.2x, offset 0x%.2x error %d\n",
> +		client->addr, reg, err);
> +
> +	return err;
> +}
> +
> +/*
> + * Write a value to a register in an TVP5146/47 decoder device.
> + * Returns zero if successful, or non-zero otherwise.
> + */
> +static int tvp514x_write_reg(struct i2c_client *client, u8 reg, u8
> val) +{
> +	int err;
> +	int retry = 0;
> +	struct i2c_msg msg[1];
> +	u8 data[2];
> +
> +	if (!client->adapter)
> +		return -ENODEV;
> +
> +again:
> +	data[0] = reg;		/* Register offset */
> +	data[1] = val;		/* Register value */
> +	msg->addr = client->addr;
> +	msg->len = 2;
> +	msg->flags = 0;		/* write operation */
> +	msg->buf = data;
> +
> +	err = i2c_transfer(client->adapter, msg, 1);
> +	if (err >= 0)
> +		return 0;
> +
> +	dev_err(&client->dev,
> +		"wrote 0x%.2x to offset 0x%.2x error %d\n", val, reg, err);
> +	if (retry <= I2C_RETRY_COUNT) {
> +		dev_info(&client->dev, "retry ... %d\n", retry);
> +		retry++;
> +		schedule_timeout(msecs_to_jiffies(20));
> +		goto again;
> +	}
> +	return err;
> +}
> +
> +/*
> + * tvp514x_write_regs : Initializes a list of TVP5146/47 registers
> + *		if token is TOK_TERM, then entire write operation terminates
> + *		if token is TOK_DELAY, then a delay of 'val' msec is introduced
> + *		if token is TOK_SKIP, then the register write is skipped
> + *		if token is TOK_WRITE, then the register write is performed
> + *
> + * reglist - list of registers to be written
> + * Returns zero if successful, or non-zero otherwise.
> + */
> +static int tvp514x_write_regs(struct i2c_client *client,
> +			      const struct tvp514x_reg reglist[])
> +{
> +	int err;
> +	const struct tvp514x_reg *next = reglist;
> +
> +	for (; next->token != TOK_TERM; next++) {
> +		if (next->token == TOK_DELAY) {
> +			schedule_timeout(msecs_to_jiffies(next->val));
> +			continue;
> +		}
> +
> +		if (next->token == TOK_SKIP)
> +			continue;
> +
> +		err = tvp514x_write_reg(client, next->reg, (u8) next->val);
> +		if (err) {
> +			dev_err(&client->dev, "write failed. Err[%d]\n",
> +				err);
> +			return err;
> +		}
> +	}
> +	return 0;
> +}
> +
> +/*
> + * tvp514x_get_current_std:
> + * Returns the current standard detected by TVP5146/47
> + */
> +static enum tvp514x_std tvp514x_get_current_std(struct
> tvp514x_decoder +						*decoder)
> +{
> +	u8 std, std_status;
> +
> +	if (tvp514x_read_reg(decoder->client, REG_VIDEO_STD, &std))
> +		return STD_INVALID;
> +
> +	if ((std & VIDEO_STD_MASK) == VIDEO_STD_AUTO_SWITCH_BIT) {
> +		/* use the standard status register */
> +		if (tvp514x_read_reg(decoder->client, REG_VIDEO_STD_STATUS,
> +				     &std_status))
> +			return STD_INVALID;
> +	} else
> +		std_status = std;	/* use the standard register itself */
> +
> +	switch (std_status & VIDEO_STD_MASK) {
> +	case VIDEO_STD_NTSC_MJ_BIT:
> +		return STD_NTSC_MJ;
> +		break;
> +
> +	case VIDEO_STD_PAL_BDGHIN_BIT:
> +		return STD_PAL_BDGHIN;
> +		break;
> +
> +	default:
> +		return STD_INVALID;
> +		break;
> +	}
> +
> +	return STD_INVALID;
> +}
> +
> +#ifdef CONFIG_VIDEO_ADV_DEBUG
> +/*
> + * TVP5146/47 register dump function
> + */
> +void tvp514x_reg_dump(struct tvp514x_decoder *decoder)
> +{
> +	u8 value;
> +
> +	dump_reg(decoder->client, REG_INPUT_SEL, value);
> +	dump_reg(decoder->client, REG_AFE_GAIN_CTRL, value);
> +	dump_reg(decoder->client, REG_VIDEO_STD, value);
> +	dump_reg(decoder->client, REG_OPERATION_MODE, value);
> +	dump_reg(decoder->client, REG_COLOR_KILLER, value);
> +	dump_reg(decoder->client, REG_LUMA_CONTROL1, value);
> +	dump_reg(decoder->client, REG_LUMA_CONTROL2, value);
> +	dump_reg(decoder->client, REG_LUMA_CONTROL3, value);
> +	dump_reg(decoder->client, REG_BRIGHTNESS, value);
> +	dump_reg(decoder->client, REG_CONTRAST, value);
> +	dump_reg(decoder->client, REG_SATURATION, value);
> +	dump_reg(decoder->client, REG_HUE, value);
> +	dump_reg(decoder->client, REG_CHROMA_CONTROL1, value);
> +	dump_reg(decoder->client, REG_CHROMA_CONTROL2, value);
> +	dump_reg(decoder->client, REG_COMP_PR_SATURATION, value);
> +	dump_reg(decoder->client, REG_COMP_Y_CONTRAST, value);
> +	dump_reg(decoder->client, REG_COMP_PB_SATURATION, value);
> +	dump_reg(decoder->client, REG_COMP_Y_BRIGHTNESS, value);
> +	dump_reg(decoder->client, REG_AVID_START_PIXEL_LSB, value);
> +	dump_reg(decoder->client, REG_AVID_START_PIXEL_MSB, value);
> +	dump_reg(decoder->client, REG_AVID_STOP_PIXEL_LSB, value);
> +	dump_reg(decoder->client, REG_AVID_STOP_PIXEL_MSB, value);
> +	dump_reg(decoder->client, REG_HSYNC_START_PIXEL_LSB, value);
> +	dump_reg(decoder->client, REG_HSYNC_START_PIXEL_MSB, value);
> +	dump_reg(decoder->client, REG_HSYNC_STOP_PIXEL_LSB, value);
> +	dump_reg(decoder->client, REG_HSYNC_STOP_PIXEL_MSB, value);
> +	dump_reg(decoder->client, REG_VSYNC_START_LINE_LSB, value);
> +	dump_reg(decoder->client, REG_VSYNC_START_LINE_MSB, value);
> +	dump_reg(decoder->client, REG_VSYNC_STOP_LINE_LSB, value);
> +	dump_reg(decoder->client, REG_VSYNC_STOP_LINE_MSB, value);
> +	dump_reg(decoder->client, REG_VBLK_START_LINE_LSB, value);
> +	dump_reg(decoder->client, REG_VBLK_START_LINE_MSB, value);
> +	dump_reg(decoder->client, REG_VBLK_STOP_LINE_LSB, value);
> +	dump_reg(decoder->client, REG_VBLK_STOP_LINE_MSB, value);
> +	dump_reg(decoder->client, REG_SYNC_CONTROL, value);
> +	dump_reg(decoder->client, REG_OUTPUT_FORMATTER1, value);
> +	dump_reg(decoder->client, REG_OUTPUT_FORMATTER2, value);
> +	dump_reg(decoder->client, REG_OUTPUT_FORMATTER3, value);
> +	dump_reg(decoder->client, REG_OUTPUT_FORMATTER4, value);
> +	dump_reg(decoder->client, REG_OUTPUT_FORMATTER5, value);
> +	dump_reg(decoder->client, REG_OUTPUT_FORMATTER6, value);
> +	dump_reg(decoder->client, REG_CLEAR_LOST_LOCK, value);
> +}
> +#endif		/* #ifdef CONFIG_VIDEO_ADV_DEBUG */
> +
> +/*
> + * Configure the TVP5146/47 with the current register settings
> + * Returns zero if successful, or non-zero otherwise.
> + */
> +static int tvp514x_configure(struct tvp514x_decoder *decoder)
> +{
> +	int err;
> +
> +	/* common register initialization */
> +	err =
> +	    tvp514x_write_regs(decoder->client, decoder->pdata->reg_list);
> +	if (err)
> +		return err;
> +
> +#ifdef CONFIG_VIDEO_ADV_DEBUG
> +	tvp514x_reg_dump(decoder);
> +#endif
> +
> +	return 0;
> +}
> +
> +/*
> + * Detect if an tvp514x is present, and if so which revision.
> + * A device is considered to be detected if the chip ID (LSB and
> MSB) + * registers match the expected values.
> + * Any value of the rom version register is accepted.
> + * Returns ENODEV error number if no device is detected, or zero
> + * if a device is detected.
> + */
> +static int tvp514x_detect(struct tvp514x_decoder *decoder)
> +{
> +	u8 chip_id_msb, chip_id_lsb, rom_ver;
> +
> +	if (tvp514x_read_reg
> +	    (decoder->client, REG_CHIP_ID_MSB, &chip_id_msb))
> +		return -ENODEV;
> +	if (tvp514x_read_reg
> +	    (decoder->client, REG_CHIP_ID_LSB, &chip_id_lsb))
> +		return -ENODEV;
> +	if (tvp514x_read_reg(decoder->client, REG_ROM_VERSION, &rom_ver))
> +		return -ENODEV;
> +
> +	dev_info(&decoder->client->dev,
> +		 "chip id detected msb:0x%x lsb:0x%x rom version:0x%x\n",
> +		 chip_id_msb, chip_id_lsb, rom_ver);
> +	if ((chip_id_msb != TVP514X_CHIP_ID_MSB)
> +		|| ((chip_id_lsb != TVP5146_CHIP_ID_LSB)
> +		&& (chip_id_lsb != TVP5147_CHIP_ID_LSB))) {
> +		/* We didn't read the values we expected, so this must not be
> +		 * an TVP5146/47.
> +		 */
> +		dev_err(&decoder->client->dev,
> +			"chip id mismatch msb:0x%x lsb:0x%x\n",
> +			chip_id_msb, chip_id_lsb);
> +		return -ENODEV;
> +	}
> +
> +	decoder->ver = rom_ver;
> +	decoder->state = STATE_DETECTED;
> +
> +	return 0;
> +}
> +
> +/*
> + * Following are decoder interface functions implemented by
> + * TVP5146/47 decoder driver.
> + */
> +
> +/**
> + * ioctl_querystd - V4L2 decoder interface handler for
> VIDIOC_QUERYSTD ioctl + * @s: pointer to standard V4L2 device
> structure
> + * @std_id: standard V4L2 std_id ioctl enum
> + *
> + * Returns the current standard detected by TVP5146/47. If no active
> input is + * detected, returns -EINVAL
> + */
> +static int ioctl_querystd(struct v4l2_int_device *s, v4l2_std_id
> *std_id) +{
> +	struct tvp514x_decoder *decoder = s->priv;
> +	enum tvp514x_std current_std;
> +	u8 sync_lock_status, lock_mask;
> +
> +	if (std_id == NULL)
> +		return -EINVAL;
> +
> +	/* get the current standard */
> +	current_std = tvp514x_get_current_std(decoder);
> +	if (current_std == STD_INVALID)
> +		return -EINVAL;
> +
> +	/* check whether signal is locked */
> +	if (tvp514x_read_reg
> +	    (decoder->client, REG_STATUS1, &sync_lock_status))
> +		return -EINVAL;
> +
> +	lock_mask =
> +	    decoder->pdata->input_list[decoder->inputidx].lock_mask;
> +	if (lock_mask != (sync_lock_status & lock_mask))
> +		return -EINVAL;	/* No input detected */
> +
> +	decoder->current_std = current_std;
> +	*std_id = decoder->std_list[current_std].standard.id;
> +
> +	return 0;
> +}
> +
> +/**
> + * ioctl_s_std - V4L2 decoder interface handler for VIDIOC_S_STD
> ioctl + * @s: pointer to standard V4L2 device structure
> + * @std_id: standard V4L2 v4l2_std_id ioctl enum
> + *
> + * If std_id is supported, sets the requested standard. Otherwise,
> returns + * -EINVAL
> + */
> +static int ioctl_s_std(struct v4l2_int_device *s, v4l2_std_id
> *std_id) +{
> +	struct tvp514x_decoder *decoder = s->priv;
> +	int err, i;
> +
> +	if (std_id == NULL)
> +		return -EINVAL;
> +
> +	for (i = 0; i < decoder->num_stds; i++)
> +		if (*std_id & decoder->std_list[i].standard.id)
> +			break;
> +
> +	if (i == decoder->num_stds)
> +		return -EINVAL;
> +
> +	err = tvp514x_write_reg(decoder->client, REG_VIDEO_STD,
> +				decoder->std_list[i].video_std);
> +	if (err)
> +		return err;
> +
> +	decoder->current_std = i;
> +	decoder->pdata->reg_list[REG_VIDEO_STD].val =
> +	    decoder->std_list[i].video_std;
> +
> +	return 0;
> +}
> +
> +/**
> + * ioctl_enum_input - V4L2 decoder interface handler for
> VIDIOC_ENUMINPUT ioctl + * @s: pointer to standard V4L2 device
> structure
> + * @input: standard V4L2 VIDIOC_ENUMINPUT ioctl structure
> + *
> + * If index is valid, returns the description of the input.
> Otherwise, returns + * -EINVAL if any error occurs
> + */
> +static int
> +ioctl_enum_input(struct v4l2_int_device *s, struct v4l2_input
> *input) +{
> +	struct tvp514x_decoder *decoder = s->priv;
> +	int index;
> +
> +	if (input == NULL)
> +		return -EINVAL;
> +
> +	index = input->index;
> +	if ((index >= decoder->pdata->num_inputs) || (index < 0))
> +		return -EINVAL;	/* Index out of bound */
> +
> +	memcpy(input, &decoder->pdata->input_list[index].input,
> +		sizeof(struct v4l2_input));
> +
> +	return 0;
> +}
> +
> +/**
> + * ioctl_s_input - V4L2 decoder interface handler for VIDIOC_S_INPUT
> ioctl + * @s: pointer to standard V4L2 device structure
> + * @index: number of the input
> + *
> + * If index is valid, selects the requested input. Otherwise,
> returns -EINVAL if + * the input is not supported or there is no
> active signal present in the + * selected input.
> + */
> +static int ioctl_s_input(struct v4l2_int_device *s, int index)
> +{
> +	struct tvp514x_decoder *decoder = s->priv;
> +	u8 input_sel;
> +	int err;
> +	enum tvp514x_std current_std = STD_INVALID;
> +	u8 sync_lock_status, lock_mask;
> +	int try_count = LOCK_RETRY_COUNT;
> +
> +	if ((index >= decoder->pdata->num_inputs) || (index < 0))
> +		return -EINVAL;	/* Index out of bound */
> +
> +	/* Get the register value to be written to select the requested
> input */ +	input_sel = decoder->pdata->input_list[index].input_sel;
> +	err = tvp514x_write_reg(decoder->client, REG_INPUT_SEL, input_sel);
> +	if (err)
> +		return err;
> +
> +	decoder->inputidx = index;
> +	decoder->pdata->reg_list[REG_INPUT_SEL].val = input_sel;
> +
> +	/* Clear status */
> +	msleep(LOCK_RETRY_DELAY);
> +	err =
> +	    tvp514x_write_reg(decoder->client, REG_CLEAR_LOST_LOCK, 0x01);
> +	if (err)
> +		return err;
> +
> +	while (try_count-- > 0) {
> +		/* Allow decoder to sync up with new input */
> +		msleep(LOCK_RETRY_DELAY);
> +
> +		/* get the current standard for future reference */
> +		current_std = tvp514x_get_current_std(decoder);
> +		if (current_std == STD_INVALID)
> +			continue;
> +
> +		if (tvp514x_read_reg(decoder->client, REG_STATUS1,
> +					&sync_lock_status))
> +			return -EINVAL;
> +
> +		lock_mask =
> +		    decoder->pdata->input_list[decoder->inputidx].
> +		    lock_mask;
> +		if (lock_mask == (sync_lock_status & lock_mask))
> +			break;	/* Input detected */
> +	}
> +
> +	if ((current_std == STD_INVALID) || (try_count < 0))
> +		return -EINVAL;
> +
> +	decoder->current_std = current_std;
> +
> +	return 0;
> +}
> +
> +/**
> + * ioctl_g_input - V4L2 decoder interface handler for VIDIOC_G_INPUT
> ioctl + * @s: pointer to standard V4L2 device structure
> + * @index: returns the current selected input
> + *
> + * Returns the current selected input. Returns -EINVAL if any error
> occurs + */
> +static int ioctl_g_input(struct v4l2_int_device *s, int *index)
> +{
> +	struct tvp514x_decoder *decoder = s->priv;
> +	int err = -EINVAL, i, inputidx;
> +
> +	if (index == NULL)
> +		return -EINVAL;
> +
> +	/* Search through the input list for active inputs */
> +	inputidx = decoder->inputidx;
> +	for (i = 0; i < decoder->pdata->num_inputs; i++) {
> +		inputidx++;	/* Move to next input */
> +		if (inputidx >= decoder->pdata->num_inputs)
> +			inputidx = 0;	/* fall back to first input */
> +
> +		err = ioctl_s_input(s, inputidx);
> +		if (!err) {
> +			/* Active input found - select it and return success */
> +			*index = inputidx;
> +			return 0;
> +		}
> +	}
> +
> +	return err;
> +}
> +
> +/**
> + * ioctl_queryctrl - V4L2 decoder interface handler for
> VIDIOC_QUERYCTRL ioctl + * @s: pointer to standard V4L2 device
> structure
> + * @qc: standard V4L2 VIDIOC_QUERYCTRL ioctl structure
> + *
> + * If the requested control is supported, returns the control
> information + * from the ctrl_list[] array. Otherwise, returns
> -EINVAL if the + * control is not supported.
> + */
> +static int
> +ioctl_queryctrl(struct v4l2_int_device *s, struct v4l2_queryctrl
> *qctrl) +{
> +	struct tvp514x_decoder *decoder = s->priv;
> +	int id, index;
> +	const struct tvp514x_ctrl_info *control = NULL;
> +
> +	if (qctrl == NULL)
> +		return -EINVAL;
> +
> +	id = qctrl->id;
> +	memset(qctrl, 0, sizeof(struct v4l2_queryctrl));
> +	qctrl->id = id;
> +
> +	for (index = 0; index < decoder->num_ctrls; index++) {
> +		control = &decoder->ctrl_list[index];
> +		if (control->query_ctrl.id == qctrl->id)
> +			break;	/* Match found */
> +	}
> +	if (index == decoder->num_ctrls)
> +		return -EINVAL;	/* Index out of bound */
> +
> +	memcpy(qctrl, &control->query_ctrl, sizeof(struct v4l2_queryctrl));
> +
> +	return 0;
> +}
> +
> +/**
> + * ioctl_g_ctrl - V4L2 decoder interface handler for VIDIOC_G_CTRL
> ioctl + * @s: pointer to standard V4L2 device structure
> + * @vc: standard V4L2 VIDIOC_G_CTRL ioctl structure
> + *
> + * If the requested control is supported, returns the control's
> current + * value from the decoder. Otherwise, returns -EINVAL if the
> control is not + * supported.
> + */
> +static int
> +ioctl_g_ctrl(struct v4l2_int_device *s, struct v4l2_control *ctrl)
> +{
> +	struct tvp514x_decoder *decoder = s->priv;
> +	int err, index;
> +	u8 val;
> +	int value;
> +	const struct tvp514x_ctrl_info *control = NULL;
> +
> +	if (ctrl == NULL)
> +		return -EINVAL;
> +
> +	for (index = 0; index < decoder->num_ctrls; index++) {
> +		control = &decoder->ctrl_list[index];
> +		if (control->query_ctrl.id == ctrl->id)
> +			break;	/* Match found */
> +	}
> +	if (index == decoder->num_ctrls)
> +		return -EINVAL;	/* Index out of bound */
> +
> +	err =
> +	    tvp514x_read_reg(decoder->client, control->reg_address, &val);
> +	if (err < 0)
> +		return err;
> +
> +	/* cross check */
> +	if (val != decoder->pdata->reg_list[control->reg_address].val)
> +		return -EINVAL;	/* Driver & TVP5146/47 setting mismatch */
> +
> +	value = val;
> +	if (V4L2_CID_AUTOGAIN == ctrl->id) {
> +		if ((value & 0x3) == 3)
> +			value = 1;
> +		else
> +			value = 0;
> +	}
> +
> +	if (V4L2_CID_HUE == ctrl->id) {
> +		if (value == 0x7F)
> +			value = 180;
> +		else if (value == 0x80)
> +			value = -180;
> +		else
> +			value = 0;
> +	}
> +
> +	ctrl->value = value;
> +
> +	return err;
> +}
> +
> +/**
> + * ioctl_s_ctrl - V4L2 decoder interface handler for VIDIOC_S_CTRL
> ioctl + * @s: pointer to standard V4L2 device structure
> + * @vc: standard V4L2 VIDIOC_S_CTRL ioctl structure
> + *
> + * If the requested control is supported, sets the control's current
> + * value in HW. Otherwise, returns -EINVAL if the control is not
> supported. + */
> +static int
> +ioctl_s_ctrl(struct v4l2_int_device *s, struct v4l2_control *ctrl)
> +{
> +	struct tvp514x_decoder *decoder = s->priv;
> +	int err, value, index;
> +	const struct tvp514x_ctrl_info *control = NULL;
> +
> +	if (ctrl == NULL)
> +		return -EINVAL;
> +
> +	value = (__s32) ctrl->value;
> +	for (index = 0; index < decoder->num_ctrls; index++) {
> +		control = &decoder->ctrl_list[index];
> +		if (control->query_ctrl.id == ctrl->id)
> +			break;	/* Match found */
> +	}
> +	if (index == decoder->num_ctrls)
> +		return -EINVAL;	/* Index out of bound */
> +
> +	if (V4L2_CID_AUTOGAIN == ctrl->id) {
> +		if (value == 1)
> +			value = 0x0F;
> +		else if (value == 0)
> +			value = 0x0C;
> +		else
> +			return -ERANGE;
> +	} else if (V4L2_CID_HUE == ctrl->id) {
> +		if (value == 180)
> +			value = 0x7F;
> +		else if (value == -180)
> +			value = 0x80;
> +		else if (value == 0)
> +			value = 0;
> +		else
> +			return -ERANGE;
> +	} else {
> +		if ((value < control->query_ctrl.minimum)
> +			|| (value > control->query_ctrl.maximum))
> +			return -ERANGE;
> +	}
> +
> +	err =
> +	    tvp514x_write_reg(decoder->client, control->reg_address,
> +				value);
> +	if (err < 0)
> +		return err;
> +
> +	decoder->pdata->reg_list[control->reg_address].val = value;
> +	return err;
> +}
> +
> +/**
> + * ioctl_enum_fmt_cap - Implement the CAPTURE buffer VIDIOC_ENUM_FMT
> ioctl + * @s: pointer to standard V4L2 device structure
> + * @fmt: standard V4L2 VIDIOC_ENUM_FMT ioctl structure
> + *
> + * Implement the VIDIOC_ENUM_FMT ioctl to enumerate supported
> formats + */
> +static int
> +ioctl_enum_fmt_cap(struct v4l2_int_device *s, struct v4l2_fmtdesc
> *fmt) +{
> +	struct tvp514x_decoder *decoder = s->priv;
> +	int index;
> +
> +	if (fmt == NULL)
> +		return -EINVAL;
> +
> +	index = fmt->index;
> +	if ((index >= decoder->num_fmts) || (index < 0))
> +		return -EINVAL;	/* Index out of bound */
> +
> +	if (fmt->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
> +		return -EINVAL;	/* only capture is supported */
> +
> +	memcpy(fmt, &decoder->fmt_list[index],
> +		sizeof(struct v4l2_fmtdesc));
> +
> +	return 0;
> +}
> +
> +/**
> + * ioctl_try_fmt_cap - Implement the CAPTURE buffer VIDIOC_TRY_FMT
> ioctl + * @s: pointer to standard V4L2 device structure
> + * @f: pointer to standard V4L2 VIDIOC_TRY_FMT ioctl structure
> + *
> + * Implement the VIDIOC_TRY_FMT ioctl for the CAPTURE buffer type.
> This + * ioctl is used to negotiate the image capture size and pixel
> format + * without actually making it take effect.
> + */
> +static int
> +ioctl_try_fmt_cap(struct v4l2_int_device *s, struct v4l2_format *f)
> +{
> +	struct tvp514x_decoder *decoder = s->priv;
> +	int ifmt;
> +	struct v4l2_pix_format *pix;
> +	enum tvp514x_std current_std;
> +
> +	if (f == NULL)
> +		return -EINVAL;
> +
> +	if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
> +		f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
> +
> +	pix = &f->fmt.pix;
> +
> +	/* Calculate height and width based on current standard */
> +	current_std = tvp514x_get_current_std(decoder);
> +	if (current_std == STD_INVALID)
> +		return -EINVAL;
> +
> +	decoder->current_std = current_std;
> +	pix->width = decoder->std_list[current_std].width;
> +	pix->height = decoder->std_list[current_std].height;
> +
> +	for (ifmt = 0; ifmt < decoder->num_fmts; ifmt++) {
> +		if (pix->pixelformat ==
> +			decoder->fmt_list[ifmt].pixelformat)
> +			break;
> +	}
> +	if (ifmt == decoder->num_fmts)
> +		ifmt = 0;	/* None of the format matched, select default */
> +	pix->pixelformat = decoder->fmt_list[ifmt].pixelformat;
> +
> +	pix->field = V4L2_FIELD_INTERLACED;
> +	pix->bytesperline = pix->width * 2;
> +	pix->sizeimage = pix->bytesperline * pix->height;
> +	pix->colorspace = V4L2_COLORSPACE_SMPTE170M;
> +	pix->priv = 0;
> +
> +	return 0;
> +}
> +
> +/**
> + * ioctl_s_fmt_cap - V4L2 decoder interface handler for VIDIOC_S_FMT
> ioctl + * @s: pointer to standard V4L2 device structure
> + * @f: pointer to standard V4L2 VIDIOC_S_FMT ioctl structure
> + *
> + * If the requested format is supported, configures the HW to use
> that + * format, returns error code if format not supported or HW
> can't be + * correctly configured.
> + */
> +static int
> +ioctl_s_fmt_cap(struct v4l2_int_device *s, struct v4l2_format *f)
> +{
> +	struct tvp514x_decoder *decoder = s->priv;
> +	struct v4l2_pix_format *pix;
> +	int rval;
> +
> +	if (f == NULL)
> +		return -EINVAL;
> +
> +	if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
> +		return -EINVAL;	/* only capture is supported */
> +
> +	pix = &f->fmt.pix;
> +	rval = ioctl_try_fmt_cap(s, f);
> +	if (rval)
> +		return rval;
> +	else
> +		decoder->pix = *pix;
> +
> +	return rval;
> +}
> +
> +/**
> + * ioctl_g_fmt_cap - V4L2 decoder interface handler for
> ioctl_g_fmt_cap + * @s: pointer to standard V4L2 device structure
> + * @f: pointer to standard V4L2 v4l2_format structure
> + *
> + * Returns the decoder's current pixel format in the v4l2_format
> + * parameter.
> + */
> +static int
> +ioctl_g_fmt_cap(struct v4l2_int_device *s, struct v4l2_format *f)
> +{
> +	struct tvp514x_decoder *decoder = s->priv;
> +
> +	if (f == NULL)
> +		return -EINVAL;
> +
> +	if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
> +		return -EINVAL;	/* only capture is supported */
> +
> +	f->fmt.pix = decoder->pix;
> +
> +	return 0;
> +}
> +
> +/**
> + * ioctl_g_parm - V4L2 decoder interface handler for VIDIOC_G_PARM
> ioctl + * @s: pointer to standard V4L2 device structure
> + * @a: pointer to standard V4L2 VIDIOC_G_PARM ioctl structure
> + *
> + * Returns the decoder's video CAPTURE parameters.
> + */
> +static int
> +ioctl_g_parm(struct v4l2_int_device *s, struct v4l2_streamparm *a)
> +{
> +	struct tvp514x_decoder *decoder = s->priv;
> +	struct v4l2_captureparm *cparm;
> +	enum tvp514x_std current_std;
> +
> +	if (a == NULL)
> +		return -EINVAL;
> +
> +	if (a->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
> +		return -EINVAL;	/* only capture is supported */
> +
> +	memset(a, 0, sizeof(*a));
> +	a->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
> +
> +	/* get the current standard */
> +	current_std = tvp514x_get_current_std(decoder);
> +	decoder->current_std = current_std;
> +
> +	cparm = &a->parm.capture;
> +	cparm->capability = V4L2_CAP_TIMEPERFRAME;
> +	cparm->timeperframe
> +	    = decoder->std_list[current_std].standard.frameperiod;
> +
> +	return 0;
> +}
> +
> +/**
> + * ioctl_s_parm - V4L2 decoder interface handler for VIDIOC_S_PARM
> ioctl + * @s: pointer to standard V4L2 device structure
> + * @a: pointer to standard V4L2 VIDIOC_S_PARM ioctl structure
> + *
> + * Configures the decoder to use the input parameters, if possible.
> If + * not possible, returns the appropriate error code.
> + */
> +static int
> +ioctl_s_parm(struct v4l2_int_device *s, struct v4l2_streamparm *a)
> +{
> +	struct tvp514x_decoder *decoder = s->priv;
> +	struct v4l2_fract *timeperframe;
> +	enum tvp514x_std current_std;
> +
> +	if (a == NULL)
> +		return -EINVAL;
> +
> +	if (a->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
> +		return -EINVAL;	/* only capture is supported */
> +
> +	timeperframe = &a->parm.capture.timeperframe;
> +
> +	/* get the current standard */
> +	current_std = tvp514x_get_current_std(decoder);
> +	decoder->current_std = current_std;
> +
> +	*timeperframe =
> +	    decoder->std_list[current_std].standard.frameperiod;
> +
> +	return 0;
> +}
> +
> +/**
> + * ioctl_g_ifparm - V4L2 decoder interface handler for
> vidioc_int_g_ifparm_num + * @s: pointer to standard V4L2 device
> structure
> + * @p: pointer to standard V4L2 vidioc_int_g_ifparm_num ioctl
> structure + *
> + * Gets slave interface parameters.
> + * Calculates the required xclk value to support the requested
> + * clock parameters in p. This value is returned in the p
> + * parameter.
> + */
> +static int ioctl_g_ifparm(struct v4l2_int_device *s, struct
> v4l2_ifparm *p) +{
> +	struct tvp514x_decoder *decoder = s->priv;
> +	int rval;
> +
> +	if (p == NULL)
> +		return -EINVAL;
> +
> +	if (NULL == decoder->pdata->ifparm)
> +		return -EINVAL;
> +
> +	rval = decoder->pdata->ifparm(p);
> +	if (rval) {
> +		dev_err(&decoder->client->dev, "error. Err[%d]\n", rval);
> +		return rval;
> +	}
> +
> +	p->u.bt656.clock_curr = TVP514X_XCLK_BT656;
> +
> +	return 0;
> +}
> +
> +/**
> + * ioctl_g_priv - V4L2 decoder interface handler for
> vidioc_int_g_priv_num + * @s: pointer to standard V4L2 device
> structure
> + * @p: void pointer to hold decoder's private data address
> + *
> + * Returns device's (decoder's) private data area address in p
> parameter + */
> +static int ioctl_g_priv(struct v4l2_int_device *s, void *p)
> +{
> +	struct tvp514x_decoder *decoder = s->priv;
> +
> +	if (NULL == decoder->pdata->priv_data_set)
> +		return -EINVAL;
> +
> +	return decoder->pdata->priv_data_set(p);
> +}
> +
> +/**
> + * ioctl_s_power - V4L2 decoder interface handler for
> vidioc_int_s_power_num + * @s: pointer to standard V4L2 device
> structure
> + * @on: power state to which device is to be set
> + *
> + * Sets devices power state to requrested state, if possible.
> + */
> +static int ioctl_s_power(struct v4l2_int_device *s, enum v4l2_power
> on) +{
> +	struct tvp514x_decoder *decoder = s->priv;
> +	int err = 0;
> +
> +	switch (on) {
> +	case V4L2_POWER_OFF:
> +		/* Power Down Sequence */
> +		err =
> +		    tvp514x_write_reg(decoder->client, REG_OPERATION_MODE,
> +					0x01);
> +		/* Disable mux for TVP5146/47 decoder data path */
> +		if (decoder->pdata->power_set)
> +			err |= decoder->pdata->power_set(on);
> +		break;
> +
> +	case V4L2_POWER_STANDBY:
> +		if (decoder->pdata->power_set)
> +			err = decoder->pdata->power_set(on);
> +		break;
> +
> +	case V4L2_POWER_ON:
> +		/* Enable mux for TVP5146/47 decoder data path */
> +		if (decoder->pdata->power_set)
> +			err = decoder->pdata->power_set(on);
> +
> +		/* Power Up Sequence */
> +		err |=
> +		    tvp514x_write_reg(decoder->client, REG_OPERATION_MODE,
> +					0x01);
> +		err |=
> +		    tvp514x_write_reg(decoder->client, REG_OPERATION_MODE,
> +					0x00);
> +
> +		/* Detect the sensor is not already detected */
> +		if (decoder->state == STATE_NOT_DETECTED) {
> +			err |= tvp514x_detect(decoder);
> +			if (err < 0) {
> +				dev_err(&decoder->client->dev,
> +					"Unable to detect decoder\n");
> +				return err;
> +			}
> +			dev_info(&decoder->client->dev,
> +				 "chip version 0x%.2x detected\n",
> +				 decoder->ver);
> +		}
> +		break;
> +
> +	default:
> +		return -ENODEV;
> +		break;
> +	}
> +
> +	return err;
> +}
> +
> +/**
> + * ioctl_init - V4L2 decoder interface handler for VIDIOC_INT_INIT
> + * @s: pointer to standard V4L2 device structure
> + *
> + * Initialize the decoder device (calls tvp514x_configure())
> + */
> +static int ioctl_init(struct v4l2_int_device *s)
> +{
> +	struct tvp514x_decoder *decoder = s->priv;
> +
> +	/* Set default standard to auto */
> +	decoder->pdata->reg_list[REG_VIDEO_STD].val =
> +	    VIDEO_STD_AUTO_SWITCH_BIT;
> +
> +	return tvp514x_configure(decoder);
> +}
> +
> +/**
> + * ioctl_dev_exit - V4L2 decoder interface handler for
> vidioc_int_dev_exit_num + * @s: pointer to standard V4L2 device
> structure
> + *
> + * Delinitialise the dev. at slave detach. The complement of
> ioctl_dev_init. + */
> +static int ioctl_dev_exit(struct v4l2_int_device *s)
> +{
> +	return 0;
> +}
> +
> +/**
> + * ioctl_dev_init - V4L2 decoder interface handler for
> vidioc_int_dev_init_num + * @s: pointer to standard V4L2 device
> structure
> + *
> + * Initialise the device when slave attaches to the master. Returns
> 0 if + * TVP5146/47 device could be found, otherwise returns
> appropriate error. + */
> +static int ioctl_dev_init(struct v4l2_int_device *s)
> +{
> +	struct tvp514x_decoder *decoder = s->priv;
> +	int err;
> +
> +	err = tvp514x_detect(decoder);
> +	if (err < 0) {
> +		dev_err(&decoder->client->dev,
> +			"Unable to detect decoder\n");
> +		return err;
> +	}
> +
> +	dev_info(&decoder->client->dev,
> +		 "chip version 0x%.2x detected\n", decoder->ver);
> +
> +	return 0;
> +}
> +
> +static struct v4l2_int_ioctl_desc tvp514x_ioctl_desc[] = {
> +	{vidioc_int_dev_init_num, (v4l2_int_ioctl_func*) ioctl_dev_init},
> +	{vidioc_int_dev_exit_num, (v4l2_int_ioctl_func*) ioctl_dev_exit},
> +	{vidioc_int_s_power_num, (v4l2_int_ioctl_func*) ioctl_s_power},
> +	{vidioc_int_g_priv_num, (v4l2_int_ioctl_func*) ioctl_g_priv},
> +	{vidioc_int_g_ifparm_num, (v4l2_int_ioctl_func*) ioctl_g_ifparm},
> +	{vidioc_int_init_num, (v4l2_int_ioctl_func*) ioctl_init},
> +	{vidioc_int_enum_fmt_cap_num,
> +	 (v4l2_int_ioctl_func *) ioctl_enum_fmt_cap},
> +	{vidioc_int_try_fmt_cap_num,
> +	 (v4l2_int_ioctl_func *) ioctl_try_fmt_cap},
> +	{vidioc_int_g_fmt_cap_num,
> +	 (v4l2_int_ioctl_func *) ioctl_g_fmt_cap},
> +	{vidioc_int_s_fmt_cap_num,
> +	 (v4l2_int_ioctl_func *) ioctl_s_fmt_cap},
> +	{vidioc_int_g_parm_num, (v4l2_int_ioctl_func *) ioctl_g_parm},
> +	{vidioc_int_s_parm_num, (v4l2_int_ioctl_func *) ioctl_s_parm},
> +	{vidioc_int_queryctrl_num,
> +	 (v4l2_int_ioctl_func *) ioctl_queryctrl},
> +	{vidioc_int_g_ctrl_num, (v4l2_int_ioctl_func *) ioctl_g_ctrl},
> +	{vidioc_int_s_ctrl_num, (v4l2_int_ioctl_func *) ioctl_s_ctrl},
> +	{vidioc_int_querystd_num, (v4l2_int_ioctl_func *) ioctl_querystd},
> +	{vidioc_int_s_std_num, (v4l2_int_ioctl_func *) ioctl_s_std},
> +	{vidioc_int_enum_input_num,
> +	 (v4l2_int_ioctl_func *) ioctl_enum_input},
> +	{vidioc_int_g_input_num, (v4l2_int_ioctl_func *) ioctl_g_input},
> +	{vidioc_int_s_input_num, (v4l2_int_ioctl_func *) ioctl_s_input},
> +};
> +
> +static struct v4l2_int_slave tvp514x_slave = {
> +	.ioctls = tvp514x_ioctl_desc,
> +	.num_ioctls = ARRAY_SIZE(tvp514x_ioctl_desc),
> +};
> +
> +static struct tvp514x_decoder tvp514x_dev = {
> +	.state = STATE_NOT_DETECTED,
> +
> +	.num_fmts = TVP514X_NUM_FORMATS,
> +	.fmt_list = tvp514x_fmt_list,
> +
> +	.pix = {		/* Default to NTSC 8-bit YUV 422 */
> +		.width = NTSC_NUM_ACTIVE_PIXELS,
> +		.height = NTSC_NUM_ACTIVE_LINES,
> +		.pixelformat = V4L2_PIX_FMT_UYVY,
> +		.field = V4L2_FIELD_INTERLACED,
> +		.bytesperline = NTSC_NUM_ACTIVE_PIXELS * 2,
> +		.sizeimage =
> +		NTSC_NUM_ACTIVE_PIXELS * 2 * NTSC_NUM_ACTIVE_LINES,
> +		.colorspace = V4L2_COLORSPACE_SMPTE170M,
> +		},
> +
> +	.current_std = STD_NTSC_MJ,
> +	.num_stds = TVP514X_NUM_STANDARDS,
> +	.std_list = tvp514x_std_list,
> +
> +	.num_ctrls = TVP514X_NUM_CONTROLS,
> +	.ctrl_list = tvp514x_ctrl_list,
> +
> +	.inputidx = 0,		/* Composite selected */
> +};
> +
> +static struct v4l2_int_device tvp514x_int_device = {
> +	.module = THIS_MODULE,
> +	.name = MODULE_NAME,
> +	.priv = &tvp514x_dev,
> +	.type = v4l2_int_type_slave,
> +	.u = {
> +	      .slave = &tvp514x_slave,
> +	      },
> +};
> +
> +/**
> + * tvp514x_probe - decoder driver i2c probe handler
> + * @client: i2c driver client device structure
> + *
> + * Register decoder as an i2c client device and V4L2
> + * device.
> + */
> +static int
> +tvp514x_probe(struct i2c_client *client, const struct i2c_device_id
> *id) +{
> +	struct tvp514x_decoder *decoder = &tvp514x_dev;
> +	int err;
> +
> +	if (i2c_get_clientdata(client))
> +		return -EBUSY;
> +
> +	decoder->pdata = client->dev.platform_data;
> +	if (!decoder->pdata) {
> +		dev_err(&client->dev, "No platform data\n!!");
> +		return -ENODEV;
> +	}
> +
> +	/* Attach to Master */
> +	strcpy(tvp514x_int_device.u.slave->attach_to,
> decoder->pdata->master); +	decoder->v4l2_int_device =
> &tvp514x_int_device;
> +	decoder->client = client;
> +	i2c_set_clientdata(client, decoder);
> +
> +	/* Register with V4L2 layer as slave device */
> +	err = v4l2_int_device_register(decoder->v4l2_int_device);
> +	if (err) {
> +		i2c_set_clientdata(client, NULL);
> +		dev_err(&client->dev,
> +			"Unable to register to v4l2. Err[%d]\n", err);
> +
> +	} else
> +		dev_info(&client->dev, "Registered to v4l2 master %s!!\n",
> +				decoder->pdata->master);
> +
> +	return 0;
> +}
> +
> +/**
> + * tvp514x_remove - decoder driver i2c remove handler
> + * @client: i2c driver client device structure
> + *
> + * Unregister decoder as an i2c client device and V4L2
> + * device. Complement of tvp514x_probe().
> + */
> +static int __exit tvp514x_remove(struct i2c_client *client)
> +{
> +	struct tvp514x_decoder *decoder = i2c_get_clientdata(client);
> +
> +	if (!client->adapter)
> +		return -ENODEV;	/* our client isn't attached */
> +
> +	v4l2_int_device_unregister(decoder->v4l2_int_device);
> +	i2c_set_clientdata(client, NULL);
> +
> +	return 0;
> +}
> +
> +static const struct i2c_device_id tvp514x_id[] = {
> +	{MODULE_NAME, 0},
> +	{},
> +};
> +
> +MODULE_DEVICE_TABLE(i2c, tvp514x_id);
> +
> +static struct i2c_driver tvp514x_i2c_driver = {
> +	.driver = {
> +		   .name = MODULE_NAME,
> +		   .owner = THIS_MODULE,
> +		   },
> +	.probe = tvp514x_probe,
> +	.remove = __exit_p(tvp514x_remove),
> +	.id_table = tvp514x_id,
> +};
> +
> +/**
> + * tvp514x_init
> + *
> + * Module init function
> + */
> +static int __init tvp514x_init(void)
> +{
> +	int err;
> +
> +	err = i2c_add_driver(&tvp514x_i2c_driver);
> +	if (err) {
> +		printk(KERN_ERR "Failed to register " MODULE_NAME ".\n");
> +		return err;
> +	}
> +	return 0;
> +}
> +
> +/**
> + * tvp514x_cleanup
> + *
> + * Module exit function
> + */
> +static void __exit tvp514x_cleanup(void)
> +{
> +	i2c_del_driver(&tvp514x_i2c_driver);
> +}
> +
> +late_initcall(tvp514x_init);
> +module_exit(tvp514x_cleanup);
> +
> +MODULE_AUTHOR("Texas Instruments");
> +MODULE_DESCRIPTION("TVP514x linux decoder driver");
> +MODULE_LICENSE("GPL");
> diff --git a/include/media/tvp514x.h b/include/media/tvp514x.h
> new file mode 100644
> index 0000000..4433b96
> --- /dev/null
> +++ b/include/media/tvp514x.h
> @@ -0,0 +1,406 @@
> +/*
> + * drivers/media/video/tvp514x.h
> + *
> + * Copyright (C) 2008 Texas Instruments Inc
> + *
> + * This package is free software; you can redistribute it and/or
> modify + * it under the terms of the GNU General Public License
> version 2 as + * published by the Free Software Foundation.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program; if not, write to the Free Software
> + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
> + *
> + */
> +
> +#ifndef _TVP514X_H
> +#define _TVP514X_H
> +
> +/*
> + * TVP5146/47 registers
> + */
> +#define REG_INPUT_SEL			(0x00)
> +#define REG_AFE_GAIN_CTRL		(0x01)
> +#define REG_VIDEO_STD			(0x02)
> +#define REG_OPERATION_MODE		(0x03)
> +#define REG_AUTOSWITCH_MASK		(0x04)
> +
> +#define REG_COLOR_KILLER		(0x05)
> +#define REG_LUMA_CONTROL1		(0x06)
> +#define REG_LUMA_CONTROL2		(0x07)
> +#define REG_LUMA_CONTROL3		(0x08)
> +
> +#define REG_BRIGHTNESS			(0x09)
> +#define REG_CONTRAST			(0x0A)
> +#define REG_SATURATION			(0x0B)
> +#define REG_HUE				(0x0C)
> +
> +#define REG_CHROMA_CONTROL1		(0x0D)
> +#define REG_CHROMA_CONTROL2		(0x0E)
> +
> +/* 0x0F Reserved */
> +
> +#define REG_COMP_PR_SATURATION		(0x10)
> +#define REG_COMP_Y_CONTRAST		(0x11)
> +#define REG_COMP_PB_SATURATION		(0x12)
> +
> +/* 0x13 Reserved */
> +
> +#define REG_COMP_Y_BRIGHTNESS		(0x14)
> +
> +/* 0x15 Reserved */
> +
> +#define REG_AVID_START_PIXEL_LSB	(0x16)
> +#define REG_AVID_START_PIXEL_MSB	(0x17)
> +#define REG_AVID_STOP_PIXEL_LSB		(0x18)
> +#define REG_AVID_STOP_PIXEL_MSB		(0x19)
> +
> +#define REG_HSYNC_START_PIXEL_LSB	(0x1A)
> +#define REG_HSYNC_START_PIXEL_MSB	(0x1B)
> +#define REG_HSYNC_STOP_PIXEL_LSB	(0x1C)
> +#define REG_HSYNC_STOP_PIXEL_MSB	(0x1D)
> +
> +#define REG_VSYNC_START_LINE_LSB	(0x1E)
> +#define REG_VSYNC_START_LINE_MSB	(0x1F)
> +#define REG_VSYNC_STOP_LINE_LSB		(0x20)
> +#define REG_VSYNC_STOP_LINE_MSB		(0x21)
> +
> +#define REG_VBLK_START_LINE_LSB		(0x22)
> +#define REG_VBLK_START_LINE_MSB		(0x23)
> +#define REG_VBLK_STOP_LINE_LSB		(0x24)
> +#define REG_VBLK_STOP_LINE_MSB		(0x25)
> +
> +/* 0x26 - 0x27 Reserved */
> +
> +#define REG_FAST_SWTICH_CONTROL		(0x28)
> +
> +/* 0x29 Reserved */
> +
> +#define REG_FAST_SWTICH_SCART_DELAY	(0x2A)
> +
> +/* 0x2B Reserved */
> +
> +#define REG_SCART_DELAY			(0x2C)
> +#define REG_CTI_DELAY			(0x2D)
> +#define REG_CTI_CONTROL			(0x2E)
> +
> +/* 0x2F - 0x31 Reserved */
> +
> +#define REG_SYNC_CONTROL		(0x32)
> +#define REG_OUTPUT_FORMATTER1		(0x33)
> +#define REG_OUTPUT_FORMATTER2		(0x34)
> +#define REG_OUTPUT_FORMATTER3		(0x35)
> +#define REG_OUTPUT_FORMATTER4		(0x36)
> +#define REG_OUTPUT_FORMATTER5		(0x37)
> +#define REG_OUTPUT_FORMATTER6		(0x38)
> +#define REG_CLEAR_LOST_LOCK		(0x39)
> +
> +#define REG_STATUS1			(0x3A)
> +#define REG_STATUS2			(0x3B)
> +
> +#define REG_AGC_GAIN_STATUS_LSB		(0x3C)
> +#define REG_AGC_GAIN_STATUS_MSB		(0x3D)
> +
> +/* 0x3E Reserved */
> +
> +#define REG_VIDEO_STD_STATUS		(0x3F)
> +#define REG_GPIO_INPUT1			(0x40)
> +#define REG_GPIO_INPUT2			(0x41)
> +
> +/* 0x42 - 0x45 Reserved */
> +
> +#define REG_AFE_COARSE_GAIN_CH1		(0x46)
> +#define REG_AFE_COARSE_GAIN_CH2		(0x47)
> +#define REG_AFE_COARSE_GAIN_CH3		(0x48)
> +#define REG_AFE_COARSE_GAIN_CH4		(0x49)
> +
> +#define REG_AFE_FINE_GAIN_PB_B_LSB	(0x4A)
> +#define REG_AFE_FINE_GAIN_PB_B_MSB	(0x4B)
> +#define REG_AFE_FINE_GAIN_Y_G_CHROMA_LSB	(0x4C)
> +#define REG_AFE_FINE_GAIN_Y_G_CHROMA_MSB	(0x4D)
> +#define REG_AFE_FINE_GAIN_PR_R_LSB	(0x4E)
> +#define REG_AFE_FINE_GAIN_PR_R_MSB	(0x4F)
> +#define REG_AFE_FINE_GAIN_CVBS_LUMA_LSB	(0x50)
> +#define REG_AFE_FINE_GAIN_CVBS_LUMA_MSB	(0x51)
> +
> +/* 0x52 - 0x68 Reserved */
> +
> +#define REG_FBIT_VBIT_CONTROL1		(0x69)
> +
> +/* 0x6A - 0x6B Reserved */
> +
> +#define REG_BACKEND_AGC_CONTROL		(0x6C)
> +
> +/* 0x6D - 0x6E Reserved */
> +
> +#define REG_AGC_DECREMENT_SPEED_CONTROL	(0x6F)
> +#define REG_ROM_VERSION			(0x70)
> +
> +/* 0x71 - 0x73 Reserved */
> +
> +#define REG_AGC_WHITE_PEAK_PROCESSING	(0x74)
> +#define REG_FBIT_VBIT_CONTROL2		(0x75)
> +#define REG_VCR_TRICK_MODE_CONTROL	(0x76)
> +#define REG_HORIZONTAL_SHAKE_INCREMENT	(0x77)
> +#define REG_AGC_INCREMENT_SPEED		(0x78)
> +#define REG_AGC_INCREMENT_DELAY		(0x79)
> +
> +/* 0x7A - 0x7F Reserved */
> +
> +#define REG_CHIP_ID_MSB			(0x80)
> +#define REG_CHIP_ID_LSB			(0x81)
> +
> +/* 0x82 Reserved */
> +
> +#define REG_CPLL_SPEED_CONTROL		(0x83)
> +
> +/* 0x84 - 0x96 Reserved */
> +
> +#define REG_STATUS_REQUEST		(0x97)
> +
> +/* 0x98 - 0x99 Reserved */
> +
> +#define REG_VERTICAL_LINE_COUNT_LSB	(0x9A)
> +#define REG_VERTICAL_LINE_COUNT_MSB	(0x9B)
> +
> +/* 0x9C - 0x9D Reserved */
> +
> +#define REG_AGC_DECREMENT_DELAY		(0x9E)
> +
> +/* 0x9F - 0xB0 Reserved */
> +
> +#define REG_VDP_TTX_FILTER_1_MASK1	(0xB1)
> +#define REG_VDP_TTX_FILTER_1_MASK2	(0xB2)
> +#define REG_VDP_TTX_FILTER_1_MASK3	(0xB3)
> +#define REG_VDP_TTX_FILTER_1_MASK4	(0xB4)
> +#define REG_VDP_TTX_FILTER_1_MASK5	(0xB5)
> +#define REG_VDP_TTX_FILTER_2_MASK1	(0xB6)
> +#define REG_VDP_TTX_FILTER_2_MASK2	(0xB7)
> +#define REG_VDP_TTX_FILTER_2_MASK3	(0xB8)
> +#define REG_VDP_TTX_FILTER_2_MASK4	(0xB9)
> +#define REG_VDP_TTX_FILTER_2_MASK5	(0xBA)
> +#define REG_VDP_TTX_FILTER_CONTROL	(0xBB)
> +#define REG_VDP_FIFO_WORD_COUNT		(0xBC)
> +#define REG_VDP_FIFO_INTERRUPT_THRLD	(0xBD)
> +
> +/* 0xBE Reserved */
> +
> +#define REG_VDP_FIFO_RESET		(0xBF)
> +#define REG_VDP_FIFO_OUTPUT_CONTROL	(0xC0)
> +#define REG_VDP_LINE_NUMBER_INTERRUPT	(0xC1)
> +#define REG_VDP_PIXEL_ALIGNMENT_LSB	(0xC2)
> +#define REG_VDP_PIXEL_ALIGNMENT_MSB	(0xC3)
> +
> +/* 0xC4 - 0xD5 Reserved */
> +
> +#define REG_VDP_LINE_START		(0xD6)
> +#define REG_VDP_LINE_STOP		(0xD7)
> +#define REG_VDP_GLOBAL_LINE_MODE	(0xD8)
> +#define REG_VDP_FULL_FIELD_ENABLE	(0xD9)
> +#define REG_VDP_FULL_FIELD_MODE		(0xDA)
> +
> +/* 0xDB - 0xDF Reserved */
> +
> +#define REG_VBUS_DATA_ACCESS_NO_VBUS_ADDR_INCR	(0xE0)
> +#define REG_VBUS_DATA_ACCESS_VBUS_ADDR_INCR	(0xE1)
> +#define REG_FIFO_READ_DATA			(0xE2)
> +
> +/* 0xE3 - 0xE7 Reserved */
> +
> +#define REG_VBUS_ADDRESS_ACCESS1	(0xE8)
> +#define REG_VBUS_ADDRESS_ACCESS2	(0xE9)
> +#define REG_VBUS_ADDRESS_ACCESS3	(0xEA)
> +
> +/* 0xEB - 0xEF Reserved */
> +
> +#define REG_INTERRUPT_RAW_STATUS0	(0xF0)
> +#define REG_INTERRUPT_RAW_STATUS1	(0xF1)
> +#define REG_INTERRUPT_STATUS0		(0xF2)
> +#define REG_INTERRUPT_STATUS1		(0xF3)
> +#define REG_INTERRUPT_MASK0		(0xF4)
> +#define REG_INTERRUPT_MASK1		(0xF5)
> +#define REG_INTERRUPT_CLEAR0		(0xF6)
> +#define REG_INTERRUPT_CLEAR1		(0xF7)
> +
> +/* 0xF8 - 0xFF Reserved */
> +
> +/*
> + * Mask and bit definitions of TVP5146/47 registers
> + */
> +/* The ID values we are looking for */
> +#define TVP514X_CHIP_ID_MSB		(0x51)
> +#define TVP5146_CHIP_ID_LSB		(0x46)
> +#define TVP5147_CHIP_ID_LSB		(0x47)
> +
> +#define VIDEO_STD_MASK			(0x07)
> +#define VIDEO_STD_AUTO_SWITCH_BIT	(0x00)
> +#define VIDEO_STD_NTSC_MJ_BIT		(0x01)
> +#define VIDEO_STD_PAL_BDGHIN_BIT	(0x02)
> +#define VIDEO_STD_PAL_M_BIT		(0x03)
> +#define VIDEO_STD_PAL_COMBINATION_N_BIT	(0x04)
> +#define VIDEO_STD_NTSC_4_43_BIT		(0x05)
> +#define VIDEO_STD_SECAM_BIT		(0x06)
> +#define VIDEO_STD_PAL_60_BIT		(0x07)
> +
> +/*
> + * Other macros
> + */
> +#define TVP514X_MODULE_NAME		"tvp514x"
> +#define TVP514X_I2C_DELAY		(3)
> +#define I2C_RETRY_COUNT			(5)
> +#define LOCK_RETRY_COUNT		(3)
> +#define LOCK_RETRY_DELAY		(200)
> +
> +#define TOK_WRITE			(0)	/* token for write operation */
> +#define TOK_TERM			(1)	/* terminating token */
> +#define TOK_DELAY			(2)	/* delay token for reg list */
> +#define TOK_SKIP			(3)	/* token to skip a register */
> +
> +#define TVP514X_XCLK_BT656		(27000000)
> +
> +/* Number of pixels and number of lines per frame for different
> standards */ +#define NTSC_NUM_ACTIVE_PIXELS		(720)
> +#define NTSC_NUM_ACTIVE_LINES		(480)
> +#define PAL_NUM_ACTIVE_PIXELS		(720)
> +#define PAL_NUM_ACTIVE_LINES		(576)
> +
> +/**
> + * enum tvp514x_std - enum for supported standards
> + */
> +enum tvp514x_std {
> +	STD_NTSC_MJ = 0,
> +	STD_PAL_BDGHIN,
> +	STD_INVALID
> +};
> +
> +/**
> + * enum tvp514x_state - enum for different decoder states
> + */
> +enum tvp514x_state {
> +	STATE_NOT_DETECTED,
> +	STATE_DETECTED
> +};
> +
> +/**
> + * struct tvp514x_reg - Structure for TVP5146/47 register
> initialization values + * @token - Token: TOK_WRITE, TOK_TERM etc..
> + * @reg - Register offset
> + * @val - Register Value for TOK_WRITE or delay in ms for TOK_DELAY
> + */
> +struct tvp514x_reg {
> +	u8 token;
> +	u8 reg;
> +	u32 val;
> +};
> +
> +/**
> + * struct tvp514x_std_info - Structure to store standard
> informations + * @width: Line width in pixels
> + * @height:Number of active lines
> + * @video_std: Value to write in REG_VIDEO_STD register
> + * @standard: v4l2 standard structure information
> + */
> +struct tvp514x_std_info {
> +	unsigned long width;
> +	unsigned long height;
> +	u8 video_std;
> +	struct v4l2_standard standard;
> +};
> +
> +/**
> + * struct tvp514x_ctrl_info - Information regarding supported
> controls + * @reg_address: Register offset of control register
> + * @query_ctrl: v4l2 query control information
> + */
> +struct tvp514x_ctrl_info {
> +	u8 reg_address;
> +	struct v4l2_queryctrl query_ctrl;
> +};
> +
> +/**
> + * struct tvp514x_input_info - Information regarding supported
> inputs + * @input_sel: Input select register
> + * @lock_mask: lock mask - depends on Svideo/CVBS
> + * @input: v4l2 input information
> + */
> +struct tvp514x_input_info {
> +	u8 input_sel;
> +	u8 lock_mask;
> +	struct v4l2_input input;
> +};
> +
> +/**
> + * struct tvp514x_platform_data - Platform data values and access
> functions + * @power_set: Power state access function, zero is off,
> non-zero is on. + * @ifparm: Interface parameters access function
> + * @priv_data_set: Device private data (pointer) access function
> + * @reg_list: The board dependent driver should fill the default
> value for + *            required registers depending on board
> layout. The TVP5146/47 + *            driver will update this
> register list for the registers + *            whose values should be
> maintained across open()/close() like + *            setting
> brightness as defined in V4L2.
> + *            The register list should be in the same order as
> defined in + *            TVP5146/47 datasheet including reserved
> registers. As of now + *            the driver expects the size of
> this list to be a minimum of + *            57 + 1 (upto regsiter
> REG_CLEAR_LOST_LOCK).
> + *            The last member should be of the list should be
> + *            {TOK_TERM, 0, 0} to indicate the end of register list.
> + * @num_inputs: Number of input connection in board
> + * @input_list: Input information list for num_inputs
> + */
> +struct tvp514x_platform_data {
> +	char *master;
> +	int (*power_set) (enum v4l2_power on);
> +	int (*ifparm) (struct v4l2_ifparm *p);
> +	int (*priv_data_set) (void *);
> +
> +	struct tvp514x_reg *reg_list;
> +
> +	int num_inputs;
> +	const struct tvp514x_input_info *input_list;
> +};
> +
> +/**
> + * struct tvp514x_decoded - TVP5146/47 decoder object
> + * @v4l2_int_device: Slave handle
> + * @pdata: Board specific
> + * @client: I2C client data
> + * @ver: Chip version
> + * @state: TVP5146/47 decoder state - detected or not-detected
> + * @pix: Current pixel format
> + * @num_fmts: Number of formats
> + * @fmt_list: Format list
> + * @current_std: Current standard
> + * @num_stds: Number of standards
> + * @std_list: Standards list
> + * @num_ctrls: Number of controls
> + * @ctrl_list: Control list
> + */
> +struct tvp514x_decoder {
> +	struct v4l2_int_device *v4l2_int_device;
> +	const struct tvp514x_platform_data *pdata;
> +	struct i2c_client *client;
> +
> +	int ver;
> +	enum tvp514x_state state;
> +
> +	struct v4l2_pix_format pix;
> +	int num_fmts;
> +	const struct v4l2_fmtdesc *fmt_list;
> +
> +	enum tvp514x_std current_std;
> +	int num_stds;
> +	struct tvp514x_std_info *std_list;
> +
> +	int num_ctrls;
> +	const struct tvp514x_ctrl_info *ctrl_list;
> +
> +	int inputidx;
> +};
> +
> +#endif				/* ifndef _TVP514X_H */
> --
> 1.5.6
>
> --
> video4linux-list mailing list
> Unsubscribe
> mailto:video4linux-list-request@redhat.com?subject=unsubscribe
> https://www.redhat.com/mailman/listinfo/video4linux-list


--
video4linux-list mailing list
Unsubscribe mailto:video4linux-list-request@redhat.com?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list

^ permalink raw reply	[flat|nested] 263+ messages in thread

* Re: [PATCH 2/2] TVP514x V4L int device driver support
  2008-11-23 22:00   ` Hans Verkuil
@ 2008-11-23 22:04     ` Koen Kooi
  2008-11-24  6:16       ` Trilok Soni
  1 sibling, 0 replies; 263+ messages in thread
From: Koen Kooi @ 2008-11-23 22:04 UTC (permalink / raw)
  To: Hans Verkuil
  Cc: video4linux-list, hvaibhav, linux-omap,
	davinci-linux-open-source-bounces

[-- Attachment #1: Type: text/plain, Size: 535 bytes --]


Op 23 nov 2008, om 23:00 heeft Hans Verkuil het volgende geschreven:

> Remember that this is not a driver for use with omap, this is a  
> generic
> i2c driver for this chip. omap just happens to be the only bridge
> driver using it right now, but that can easily change.
>
> Yes, it makes it harder to write an i2c driver, but experience has  
> shown
> us that the advantages regarding reuse far outweigh this initial cost.

And google suggests that this chip is is used on dm35x and davinci  
platforms as well :)

regards,

Koen

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 186 bytes --]

^ permalink raw reply	[flat|nested] 263+ messages in thread

* Re: [PATCH 2/2] TVP514x V4L int device driver support
  2008-11-23 22:00   ` Hans Verkuil
@ 2008-11-24  6:16       ` Trilok Soni
  2008-11-24  6:16       ` Trilok Soni
  1 sibling, 0 replies; 263+ messages in thread
From: Trilok Soni @ 2008-11-24  6:16 UTC (permalink / raw)
  To: Hans Verkuil
  Cc: video4linux-list, linux-omap, davinci-linux-open-source-bounces

Hi Hans,

On Mon, Nov 24, 2008 at 3:30 AM, Hans Verkuil <hverkuil@xs4all.nl> wrote:
> Hi Vaibhav,
>
> Here is my review as promised (although a day late). It's a mix of
> smaller and larger issues:
>
> 1) CONFIG_VIDEO_ADV_DEBUG is meant to enable the ability to set/get
> registers through the VIDIOC_DBG_G/S_REGISTER ioctls. For general
> debugging you should use a debug module option (see e.g. saa7115.c).

Local dprintk with log levels is fine, as far as it not misused.

>
> 2) Please use the media/v4l2-i2c-drv.h or media/v4l2-i2c-drv-legacy.h
> header to hide some of the i2c complexity (again, see e.g. saa7115.c).
> The i2c API tends to change a lot (and some changes are upcoming) so
> using this header will mean that i2c driver changes will be minimal in
> the future. In addition it will ensure that this driver can be compiled
> with older kernels as well once it is part of the v4l-dvb repository.

I don't agree with having support to compile with older kernels. Even
though I2C APIs change as lot it is for good, and creating
abstractions doesn't help as saa7xxx is family of chips where I don't
see the case here. Once this driver is mainlined if someone does i2c
subsystem change which breaks this driver from building then he/she
has to make changes to all the code affecting it.

I am not in favour of adding support to compile with older kernels.

>
> 3) Remember that the use of v4l2-int-device.h must be temporary only. It
> will make it impossible to use this driver with any other platform but
> omap. I had hoped to release my generic v4l2 subdevice support today
> which should replace v4l2-int-device.h in time, but I hit a bug that
> needs to be resolved first. I hope to fix it during the next week so
> that I can finally make it available for use asap.

Better step would be to have single camera-sensor framework or merge
with soc-camera framework. Two frameworks doesn't help anyone, but
creates more confusion for new developers.

-- 
---Trilok Soni
http://triloksoni.wordpress.com
http://www.linkedin.com/in/triloksoni

--
video4linux-list mailing list
Unsubscribe mailto:video4linux-list-request@redhat.com?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list

^ permalink raw reply	[flat|nested] 263+ messages in thread

* Re: [PATCH 2/2] TVP514x V4L int device driver support
@ 2008-11-24  6:16       ` Trilok Soni
  0 siblings, 0 replies; 263+ messages in thread
From: Trilok Soni @ 2008-11-24  6:16 UTC (permalink / raw)
  To: Hans Verkuil
  Cc: video4linux-list, linux-omap, davinci-linux-open-source-bounces

Hi Hans,

On Mon, Nov 24, 2008 at 3:30 AM, Hans Verkuil <hverkuil@xs4all.nl> wrote:
> Hi Vaibhav,
>
> Here is my review as promised (although a day late). It's a mix of
> smaller and larger issues:
>
> 1) CONFIG_VIDEO_ADV_DEBUG is meant to enable the ability to set/get
> registers through the VIDIOC_DBG_G/S_REGISTER ioctls. For general
> debugging you should use a debug module option (see e.g. saa7115.c).

Local dprintk with log levels is fine, as far as it not misused.

>
> 2) Please use the media/v4l2-i2c-drv.h or media/v4l2-i2c-drv-legacy.h
> header to hide some of the i2c complexity (again, see e.g. saa7115.c).
> The i2c API tends to change a lot (and some changes are upcoming) so
> using this header will mean that i2c driver changes will be minimal in
> the future. In addition it will ensure that this driver can be compiled
> with older kernels as well once it is part of the v4l-dvb repository.

I don't agree with having support to compile with older kernels. Even
though I2C APIs change as lot it is for good, and creating
abstractions doesn't help as saa7xxx is family of chips where I don't
see the case here. Once this driver is mainlined if someone does i2c
subsystem change which breaks this driver from building then he/she
has to make changes to all the code affecting it.

I am not in favour of adding support to compile with older kernels.

>
> 3) Remember that the use of v4l2-int-device.h must be temporary only. It
> will make it impossible to use this driver with any other platform but
> omap. I had hoped to release my generic v4l2 subdevice support today
> which should replace v4l2-int-device.h in time, but I hit a bug that
> needs to be resolved first. I hope to fix it during the next week so
> that I can finally make it available for use asap.

Better step would be to have single camera-sensor framework or merge
with soc-camera framework. Two frameworks doesn't help anyone, but
creates more confusion for new developers.

-- 
---Trilok Soni
http://triloksoni.wordpress.com
http://www.linkedin.com/in/triloksoni

^ permalink raw reply	[flat|nested] 263+ messages in thread

* Re: [PATCH 2/2] TVP514x V4L int device driver support
  2008-11-24  6:16       ` Trilok Soni
  (?)
@ 2008-11-24  6:32       ` David Brownell
  2008-11-24  7:53         ` Hans Verkuil
  -1 siblings, 1 reply; 263+ messages in thread
From: David Brownell @ 2008-11-24  6:32 UTC (permalink / raw)
  To: Trilok Soni, Hans Verkuil
  Cc: video4linux-list, linux-omap, davinci-linux-open-source-bounces

On Sunday 23 November 2008, Trilok Soni wrote:
> > 2) Please use the media/v4l2-i2c-drv.h or media/v4l2-i2c-drv-legacy.h
> > header to hide some of the i2c complexity (again, see e.g. saa7115.c).
> > The i2c API tends to change a lot (and some changes are upcoming) so

What "changes" do you mean?  Since this is not a legacy-style
driver (yay!), the upcoming changes won't affect it at all.


> > using this header will mean that i2c driver changes will be minimal in
> > the future. In addition it will ensure that this driver can be compiled
> > with older kernels as well once it is part of the v4l-dvb repository.
> 
> I don't agree with having support to compile with older kernels.

Right.  Folk wanting legacy tvp5146 and tvp5140 support could
try to use the legacy drivers from the DaVinci tree.


> Even though I2C APIs change as lot it is for good, and creating
> abstractions doesn't help as saa7xxx is family of chips where I don't
> see the case here. Once this driver is mainlined if someone does i2c
> subsystem change which breaks this driver from building then he/she
> has to make changes to all the code affecting it.

And AFAIK no such change is anticipated.  The conversion from
legacy style I2C drivers to "new style" driver-model friendly
drivers is progressing fairly well, so that legacy support can
be completely removed.


> I am not in favour of adding support to compile with older kernels.

My two cents:  I'm not in favor either.  In fact that's the
general policy for mainline drivers, and I'm surprised to hear
any maintainer suggest it be added.

- Dave

^ permalink raw reply	[flat|nested] 263+ messages in thread

* Re: [PATCH 2/2] TVP514x V4L int device driver support
  2008-11-24  6:32       ` David Brownell
@ 2008-11-24  7:53         ` Hans Verkuil
  2008-11-24  8:53             ` Hiremath, Vaibhav
  0 siblings, 1 reply; 263+ messages in thread
From: Hans Verkuil @ 2008-11-24  7:53 UTC (permalink / raw)
  To: David Brownell
  Cc: video4linux-list, linux-omap, davinci-linux-open-source-bounces

On Monday 24 November 2008 07:32:31 David Brownell wrote:
> On Sunday 23 November 2008, Trilok Soni wrote:
> > > 2) Please use the media/v4l2-i2c-drv.h or
> > > media/v4l2-i2c-drv-legacy.h header to hide some of the i2c
> > > complexity (again, see e.g. saa7115.c). The i2c API tends to
> > > change a lot (and some changes are upcoming) so
>
> What "changes" do you mean?  Since this is not a legacy-style
> driver (yay!), the upcoming changes won't affect it at all.

Oops, sorry. I thought it was a legacy driver, but it isn't. There are 
changes upcoming for legacy drivers, but not for new-style drivers.

> > > using this header will mean that i2c driver changes will be
> > > minimal in the future. In addition it will ensure that this
> > > driver can be compiled with older kernels as well once it is part
> > > of the v4l-dvb repository.
> >
> > I don't agree with having support to compile with older kernels.
>
> Right.  Folk wanting legacy tvp5146 and tvp5140 support could
> try to use the legacy drivers from the DaVinci tree.

The v4l-dvb mercurial tree at www.linuxtv.org/hg which is the main 
v4l-dvb repository can support kernels >= 2.6.16. Before new stuff is 
merged with the git kernel all the compatibility stuff for old kernels 
is stripped out, so you don't see it in the actual kernel code. Using 
the media/v4l2-i2c-drv.h header makes it much easier to support these 
older kernels and it actually reduces the code size as well. Most v4l 
i2c drivers are already converted or will be converted soon. It's a v4l 
thing.

> > Even though I2C APIs change as lot it is for good, and creating
> > abstractions doesn't help as saa7xxx is family of chips where I
> > don't see the case here. Once this driver is mainlined if someone
> > does i2c subsystem change which breaks this driver from building
> > then he/she has to make changes to all the code affecting it.
>
> And AFAIK no such change is anticipated.  The conversion from
> legacy style I2C drivers to "new style" driver-model friendly
> drivers is progressing fairly well, so that legacy support can
> be completely removed.
>
> > I am not in favour of adding support to compile with older kernels.
>
> My two cents:  I'm not in favor either.  In fact that's the
> general policy for mainline drivers, and I'm surprised to hear
> any maintainer suggest it be added.

Again, it's specific to v4l drivers. You don't have to do it, but it 
makes it consistent with the other v4l i2c drivers and when the driver 
is in the v4l-dvb repository you get support for older kernels for 
free.

Whether it is good or bad that the v4l-dvb repo works this way is a 
completely different discussion.

Regards,

	Hans

--
video4linux-list mailing list
Unsubscribe mailto:video4linux-list-request@redhat.com?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list

^ permalink raw reply	[flat|nested] 263+ messages in thread

* Re: [PATCH 2/2] TVP514x V4L int device driver support
  2008-11-24  6:16       ` Trilok Soni
@ 2008-11-24  8:04         ` Hans Verkuil
  -1 siblings, 0 replies; 263+ messages in thread
From: Hans Verkuil @ 2008-11-24  8:04 UTC (permalink / raw)
  To: Trilok Soni
  Cc: video4linux-list, linux-omap, davinci-linux-open-source-bounces

On Monday 24 November 2008 07:16:12 Trilok Soni wrote:
> Hi Hans,
>
> On Mon, Nov 24, 2008 at 3:30 AM, Hans Verkuil <hverkuil@xs4all.nl> 
wrote:
> > Hi Vaibhav,
> >
> > Here is my review as promised (although a day late). It's a mix of
> > smaller and larger issues:
> >
> > 1) CONFIG_VIDEO_ADV_DEBUG is meant to enable the ability to set/get
> > registers through the VIDIOC_DBG_G/S_REGISTER ioctls. For general
> > debugging you should use a debug module option (see e.g.
> > saa7115.c).
>
> Local dprintk with log levels is fine, as far as it not misused.
>
> > 2) Please use the media/v4l2-i2c-drv.h or
> > media/v4l2-i2c-drv-legacy.h header to hide some of the i2c
> > complexity (again, see e.g. saa7115.c). The i2c API tends to change
> > a lot (and some changes are upcoming) so using this header will
> > mean that i2c driver changes will be minimal in the future. In
> > addition it will ensure that this driver can be compiled with older
> > kernels as well once it is part of the v4l-dvb repository.
>
> I don't agree with having support to compile with older kernels. Even
> though I2C APIs change as lot it is for good, and creating
> abstractions doesn't help as saa7xxx is family of chips where I don't
> see the case here. Once this driver is mainlined if someone does i2c
> subsystem change which breaks this driver from building then he/she
> has to make changes to all the code affecting it.
>
> I am not in favour of adding support to compile with older kernels.
>
> > 3) Remember that the use of v4l2-int-device.h must be temporary
> > only. It will make it impossible to use this driver with any other
> > platform but omap. I had hoped to release my generic v4l2 subdevice
> > support today which should replace v4l2-int-device.h in time, but I
> > hit a bug that needs to be resolved first. I hope to fix it during
> > the next week so that I can finally make it available for use asap.
>
> Better step would be to have single camera-sensor framework or merge
> with soc-camera framework. Two frameworks doesn't help anyone, but
> creates more confusion for new developers.

The v4l2-int-device.h stuff should never have been added. Ditto for 
parts of the soc-camera framework that duplicates v4l2-int-device.h. My 
new v4l2_subdev support will replace the three methods of using i2c 
devices (or similar) that are currently in use. It's exactly to reduce 
the confusion that I'm working on this.

It's been discussed before on the v4l mailinglist and the relevant 
developers are aware of this. It's almost finished, just need to track 
down a single remaining oops.

Regards,

	Hans

--
video4linux-list mailing list
Unsubscribe mailto:video4linux-list-request@redhat.com?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list

^ permalink raw reply	[flat|nested] 263+ messages in thread

* Re: [PATCH 2/2] TVP514x V4L int device driver support
@ 2008-11-24  8:04         ` Hans Verkuil
  0 siblings, 0 replies; 263+ messages in thread
From: Hans Verkuil @ 2008-11-24  8:04 UTC (permalink / raw)
  To: Trilok Soni
  Cc: video4linux-list, linux-omap, davinci-linux-open-source-bounces

On Monday 24 November 2008 07:16:12 Trilok Soni wrote:
> Hi Hans,
>
> On Mon, Nov 24, 2008 at 3:30 AM, Hans Verkuil <hverkuil@xs4all.nl> 
wrote:
> > Hi Vaibhav,
> >
> > Here is my review as promised (although a day late). It's a mix of
> > smaller and larger issues:
> >
> > 1) CONFIG_VIDEO_ADV_DEBUG is meant to enable the ability to set/get
> > registers through the VIDIOC_DBG_G/S_REGISTER ioctls. For general
> > debugging you should use a debug module option (see e.g.
> > saa7115.c).
>
> Local dprintk with log levels is fine, as far as it not misused.
>
> > 2) Please use the media/v4l2-i2c-drv.h or
> > media/v4l2-i2c-drv-legacy.h header to hide some of the i2c
> > complexity (again, see e.g. saa7115.c). The i2c API tends to change
> > a lot (and some changes are upcoming) so using this header will
> > mean that i2c driver changes will be minimal in the future. In
> > addition it will ensure that this driver can be compiled with older
> > kernels as well once it is part of the v4l-dvb repository.
>
> I don't agree with having support to compile with older kernels. Even
> though I2C APIs change as lot it is for good, and creating
> abstractions doesn't help as saa7xxx is family of chips where I don't
> see the case here. Once this driver is mainlined if someone does i2c
> subsystem change which breaks this driver from building then he/she
> has to make changes to all the code affecting it.
>
> I am not in favour of adding support to compile with older kernels.
>
> > 3) Remember that the use of v4l2-int-device.h must be temporary
> > only. It will make it impossible to use this driver with any other
> > platform but omap. I had hoped to release my generic v4l2 subdevice
> > support today which should replace v4l2-int-device.h in time, but I
> > hit a bug that needs to be resolved first. I hope to fix it during
> > the next week so that I can finally make it available for use asap.
>
> Better step would be to have single camera-sensor framework or merge
> with soc-camera framework. Two frameworks doesn't help anyone, but
> creates more confusion for new developers.

The v4l2-int-device.h stuff should never have been added. Ditto for 
parts of the soc-camera framework that duplicates v4l2-int-device.h. My 
new v4l2_subdev support will replace the three methods of using i2c 
devices (or similar) that are currently in use. It's exactly to reduce 
the confusion that I'm working on this.

It's been discussed before on the v4l mailinglist and the relevant 
developers are aware of this. It's almost finished, just need to track 
down a single remaining oops.

Regards,

	Hans

^ permalink raw reply	[flat|nested] 263+ messages in thread

* Re: [PATCH 2/2] TVP514x V4L int device driver support
  2008-11-24  8:04         ` Hans Verkuil
@ 2008-11-24  8:43           ` Trilok Soni
  -1 siblings, 0 replies; 263+ messages in thread
From: Trilok Soni @ 2008-11-24  8:43 UTC (permalink / raw)
  To: Hans Verkuil; +Cc: video4linux-list, linux-omap, davinci-linux-open-source

Hi Hans,

>
> The v4l2-int-device.h stuff should never have been added. Ditto for
> parts of the soc-camera framework that duplicates v4l2-int-device.h. My
> new v4l2_subdev support will replace the three methods of using i2c
> devices (or similar) that are currently in use. It's exactly to reduce
> the confusion that I'm working on this.
>
> It's been discussed before on the v4l mailinglist and the relevant
> developers are aware of this. It's almost finished, just need to track
> down a single remaining oops.

Right, I will wait for your updates.

I am planning to send omap24xxcam and ov9640 drivers (now deleted)
available from linux-omap tree after syncing them with latest
linux-2.6.x tree, and the whole driver and the sensor is written using
v4l2-int-device framework. I am going to send it anyway, so that it
can have some review comments.

-- 
---Trilok Soni
http://triloksoni.wordpress.com
http://www.linkedin.com/in/triloksoni

--
video4linux-list mailing list
Unsubscribe mailto:video4linux-list-request@redhat.com?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list

^ permalink raw reply	[flat|nested] 263+ messages in thread

* Re: [PATCH 2/2] TVP514x V4L int device driver support
@ 2008-11-24  8:43           ` Trilok Soni
  0 siblings, 0 replies; 263+ messages in thread
From: Trilok Soni @ 2008-11-24  8:43 UTC (permalink / raw)
  To: Hans Verkuil; +Cc: video4linux-list, linux-omap, davinci-linux-open-source

Hi Hans,

>
> The v4l2-int-device.h stuff should never have been added. Ditto for
> parts of the soc-camera framework that duplicates v4l2-int-device.h. My
> new v4l2_subdev support will replace the three methods of using i2c
> devices (or similar) that are currently in use. It's exactly to reduce
> the confusion that I'm working on this.
>
> It's been discussed before on the v4l mailinglist and the relevant
> developers are aware of this. It's almost finished, just need to track
> down a single remaining oops.

Right, I will wait for your updates.

I am planning to send omap24xxcam and ov9640 drivers (now deleted)
available from linux-omap tree after syncing them with latest
linux-2.6.x tree, and the whole driver and the sensor is written using
v4l2-int-device framework. I am going to send it anyway, so that it
can have some review comments.

-- 
---Trilok Soni
http://triloksoni.wordpress.com
http://www.linkedin.com/in/triloksoni

^ permalink raw reply	[flat|nested] 263+ messages in thread

* RE: [PATCH 2/2] TVP514x V4L int device driver support
  2008-11-24  7:53         ` Hans Verkuil
@ 2008-11-24  8:53             ` Hiremath, Vaibhav
  0 siblings, 0 replies; 263+ messages in thread
From: Hiremath, Vaibhav @ 2008-11-24  8:53 UTC (permalink / raw)
  To: Hans Verkuil, David Brownell
  Cc: video4linux-list, linux-omap, davinci-linux-open-source-bounces



Thanks,
Vaibhav Hiremath

> -----Original Message-----
> From: video4linux-list-bounces@redhat.com [mailto:video4linux-list-
> bounces@redhat.com] On Behalf Of Hans Verkuil
> Sent: Monday, November 24, 2008 1:24 PM
> To: David Brownell
> Cc: video4linux-list@redhat.com; linux-omap@vger.kernel.org;
> davinci-linux-open-source-bounces@linux.davincidsp.com
> Subject: Re: [PATCH 2/2] TVP514x V4L int device driver support
> 
> On Monday 24 November 2008 07:32:31 David Brownell wrote:
> > On Sunday 23 November 2008, Trilok Soni wrote:
> > > > 2) Please use the media/v4l2-i2c-drv.h or
> > > > media/v4l2-i2c-drv-legacy.h header to hide some of the i2c
> > > > complexity (again, see e.g. saa7115.c). The i2c API tends to
> > > > change a lot (and some changes are upcoming) so
> >
> > What "changes" do you mean?  Since this is not a legacy-style
> > driver (yay!), the upcoming changes won't affect it at all.
> 
> Oops, sorry. I thought it was a legacy driver, but it isn't. There
> are
> changes upcoming for legacy drivers, but not for new-style drivers.
> 
> > > > using this header will mean that i2c driver changes will be
> > > > minimal in the future. In addition it will ensure that this
> > > > driver can be compiled with older kernels as well once it is
> part
> > > > of the v4l-dvb repository.
> > >
> > > I don't agree with having support to compile with older kernels.
> >
> > Right.  Folk wanting legacy tvp5146 and tvp5140 support could
> > try to use the legacy drivers from the DaVinci tree.
> 
> The v4l-dvb mercurial tree at www.linuxtv.org/hg which is the main
> v4l-dvb repository can support kernels >= 2.6.16. Before new stuff
> is
> merged with the git kernel all the compatibility stuff for old
> kernels
> is stripped out, so you don't see it in the actual kernel code.
> Using
> the media/v4l2-i2c-drv.h header makes it much easier to support
> these
> older kernels and it actually reduces the code size as well. Most
> v4l
> i2c drivers are already converted or will be converted soon. It's a
> v4l
> thing.
> 
> > > Even though I2C APIs change as lot it is for good, and creating
> > > abstractions doesn't help as saa7xxx is family of chips where I
> > > don't see the case here. Once this driver is mainlined if
> someone
> > > does i2c subsystem change which breaks this driver from building
> > > then he/she has to make changes to all the code affecting it.
> >
> > And AFAIK no such change is anticipated.  The conversion from
> > legacy style I2C drivers to "new style" driver-model friendly
> > drivers is progressing fairly well, so that legacy support can
> > be completely removed.
> >
> > > I am not in favour of adding support to compile with older
> kernels.
> >
> > My two cents:  I'm not in favor either.  In fact that's the
> > general policy for mainline drivers, and I'm surprised to hear
> > any maintainer suggest it be added.
> 
> Again, it's specific to v4l drivers. You don't have to do it, but it
> makes it consistent with the other v4l i2c drivers and when the
> driver
> is in the v4l-dvb repository you get support for older kernels for
> free.
> 
[Hiremath, Vaibhav] Again only to maintain consistency, supporting legacy wrapper is not good practice (In my opinion). Why can't we have new driver coming with new interface and old drivers still can have legacy wrappers? 

> Whether it is good or bad that the v4l-dvb repo works this way is a
> completely different discussion.
> 
> Regards,
> 
> 	Hans
> 
> --
> video4linux-list mailing list
> Unsubscribe mailto:video4linux-list-
> request@redhat.com?subject=unsubscribe
> https://www.redhat.com/mailman/listinfo/video4linux-list


--
video4linux-list mailing list
Unsubscribe mailto:video4linux-list-request@redhat.com?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list

^ permalink raw reply	[flat|nested] 263+ messages in thread

* RE: [PATCH 2/2] TVP514x V4L int device driver support
@ 2008-11-24  8:53             ` Hiremath, Vaibhav
  0 siblings, 0 replies; 263+ messages in thread
From: Hiremath, Vaibhav @ 2008-11-24  8:53 UTC (permalink / raw)
  To: Hans Verkuil, David Brownell
  Cc: video4linux-list, linux-omap, davinci-linux-open-source-bounces



Thanks,
Vaibhav Hiremath

> -----Original Message-----
> From: video4linux-list-bounces@redhat.com [mailto:video4linux-list-
> bounces@redhat.com] On Behalf Of Hans Verkuil
> Sent: Monday, November 24, 2008 1:24 PM
> To: David Brownell
> Cc: video4linux-list@redhat.com; linux-omap@vger.kernel.org;
> davinci-linux-open-source-bounces@linux.davincidsp.com
> Subject: Re: [PATCH 2/2] TVP514x V4L int device driver support
> 
> On Monday 24 November 2008 07:32:31 David Brownell wrote:
> > On Sunday 23 November 2008, Trilok Soni wrote:
> > > > 2) Please use the media/v4l2-i2c-drv.h or
> > > > media/v4l2-i2c-drv-legacy.h header to hide some of the i2c
> > > > complexity (again, see e.g. saa7115.c). The i2c API tends to
> > > > change a lot (and some changes are upcoming) so
> >
> > What "changes" do you mean?  Since this is not a legacy-style
> > driver (yay!), the upcoming changes won't affect it at all.
> 
> Oops, sorry. I thought it was a legacy driver, but it isn't. There
> are
> changes upcoming for legacy drivers, but not for new-style drivers.
> 
> > > > using this header will mean that i2c driver changes will be
> > > > minimal in the future. In addition it will ensure that this
> > > > driver can be compiled with older kernels as well once it is
> part
> > > > of the v4l-dvb repository.
> > >
> > > I don't agree with having support to compile with older kernels.
> >
> > Right.  Folk wanting legacy tvp5146 and tvp5140 support could
> > try to use the legacy drivers from the DaVinci tree.
> 
> The v4l-dvb mercurial tree at www.linuxtv.org/hg which is the main
> v4l-dvb repository can support kernels >= 2.6.16. Before new stuff
> is
> merged with the git kernel all the compatibility stuff for old
> kernels
> is stripped out, so you don't see it in the actual kernel code.
> Using
> the media/v4l2-i2c-drv.h header makes it much easier to support
> these
> older kernels and it actually reduces the code size as well. Most
> v4l
> i2c drivers are already converted or will be converted soon. It's a
> v4l
> thing.
> 
> > > Even though I2C APIs change as lot it is for good, and creating
> > > abstractions doesn't help as saa7xxx is family of chips where I
> > > don't see the case here. Once this driver is mainlined if
> someone
> > > does i2c subsystem change which breaks this driver from building
> > > then he/she has to make changes to all the code affecting it.
> >
> > And AFAIK no such change is anticipated.  The conversion from
> > legacy style I2C drivers to "new style" driver-model friendly
> > drivers is progressing fairly well, so that legacy support can
> > be completely removed.
> >
> > > I am not in favour of adding support to compile with older
> kernels.
> >
> > My two cents:  I'm not in favor either.  In fact that's the
> > general policy for mainline drivers, and I'm surprised to hear
> > any maintainer suggest it be added.
> 
> Again, it's specific to v4l drivers. You don't have to do it, but it
> makes it consistent with the other v4l i2c drivers and when the
> driver
> is in the v4l-dvb repository you get support for older kernels for
> free.
> 
[Hiremath, Vaibhav] Again only to maintain consistency, supporting legacy wrapper is not good practice (In my opinion). Why can't we have new driver coming with new interface and old drivers still can have legacy wrappers? 

> Whether it is good or bad that the v4l-dvb repo works this way is a
> completely different discussion.
> 
> Regards,
> 
> 	Hans
> 
> --
> video4linux-list mailing list
> Unsubscribe mailto:video4linux-list-
> request@redhat.com?subject=unsubscribe
> https://www.redhat.com/mailman/listinfo/video4linux-list


^ permalink raw reply	[flat|nested] 263+ messages in thread

* RE: [PATCH 2/2] TVP514x V4L int device driver support
  2008-11-24  8:43           ` Trilok Soni
@ 2008-11-24  8:59             ` Hiremath, Vaibhav
  -1 siblings, 0 replies; 263+ messages in thread
From: Hiremath, Vaibhav @ 2008-11-24  8:59 UTC (permalink / raw)
  To: Trilok Soni, Hans Verkuil
  Cc: video4linux-list, linux-omap, davinci-linux-open-source

Hans,

Thanks,
Vaibhav Hiremath

> -----Original Message-----
> From: linux-omap-owner@vger.kernel.org [mailto:linux-omap-
> owner@vger.kernel.org] On Behalf Of Trilok Soni
> Sent: Monday, November 24, 2008 2:13 PM
> To: Hans Verkuil
> Cc: video4linux-list@redhat.com; linux-omap@vger.kernel.org;
> davinci-linux-open-source@linux.davincidsp.com
> Subject: Re: [PATCH 2/2] TVP514x V4L int device driver support
> 
> Hi Hans,
> 
> >
> > The v4l2-int-device.h stuff should never have been added. Ditto
> for
> > parts of the soc-camera framework that duplicates v4l2-int-
> device.h. My
> > new v4l2_subdev support will replace the three methods of using
> i2c
> > devices (or similar) that are currently in use. It's exactly to
> reduce
> > the confusion that I'm working on this.
> >
> > It's been discussed before on the v4l mailinglist and the relevant
> > developers are aware of this. It's almost finished, just need to
> track
> > down a single remaining oops.
> 
> Right, I will wait for your updates.
> 
> I am planning to send omap24xxcam and ov9640 drivers (now deleted)
> available from linux-omap tree after syncing them with latest
> linux-2.6.x tree, and the whole driver and the sensor is written
> using
> v4l2-int-device framework. I am going to send it anyway, so that it
> can have some review comments.
> 
[Hiremath, Vaibhav] Is your current development accessible through linuxtv.org? Can you share it with us, so that we can have a look into it? Which driver you are migrating to new interface (which I can refer to as a sample)?
Again I would like to know, how are we handling current drivers (soc-camera and v4l2-int)?

> --
> ---Trilok Soni
> http://triloksoni.wordpress.com
> http://www.linkedin.com/in/triloksoni
> --
> To unsubscribe from this list: send the line "unsubscribe linux-
> omap" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


--
video4linux-list mailing list
Unsubscribe mailto:video4linux-list-request@redhat.com?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list

^ permalink raw reply	[flat|nested] 263+ messages in thread

* RE: [PATCH 2/2] TVP514x V4L int device driver support
@ 2008-11-24  8:59             ` Hiremath, Vaibhav
  0 siblings, 0 replies; 263+ messages in thread
From: Hiremath, Vaibhav @ 2008-11-24  8:59 UTC (permalink / raw)
  To: Trilok Soni, Hans Verkuil
  Cc: video4linux-list, linux-omap, davinci-linux-open-source

Hans,

Thanks,
Vaibhav Hiremath

> -----Original Message-----
> From: linux-omap-owner@vger.kernel.org [mailto:linux-omap-
> owner@vger.kernel.org] On Behalf Of Trilok Soni
> Sent: Monday, November 24, 2008 2:13 PM
> To: Hans Verkuil
> Cc: video4linux-list@redhat.com; linux-omap@vger.kernel.org;
> davinci-linux-open-source@linux.davincidsp.com
> Subject: Re: [PATCH 2/2] TVP514x V4L int device driver support
> 
> Hi Hans,
> 
> >
> > The v4l2-int-device.h stuff should never have been added. Ditto
> for
> > parts of the soc-camera framework that duplicates v4l2-int-
> device.h. My
> > new v4l2_subdev support will replace the three methods of using
> i2c
> > devices (or similar) that are currently in use. It's exactly to
> reduce
> > the confusion that I'm working on this.
> >
> > It's been discussed before on the v4l mailinglist and the relevant
> > developers are aware of this. It's almost finished, just need to
> track
> > down a single remaining oops.
> 
> Right, I will wait for your updates.
> 
> I am planning to send omap24xxcam and ov9640 drivers (now deleted)
> available from linux-omap tree after syncing them with latest
> linux-2.6.x tree, and the whole driver and the sensor is written
> using
> v4l2-int-device framework. I am going to send it anyway, so that it
> can have some review comments.
> 
[Hiremath, Vaibhav] Is your current development accessible through linuxtv.org? Can you share it with us, so that we can have a look into it? Which driver you are migrating to new interface (which I can refer to as a sample)?
Again I would like to know, how are we handling current drivers (soc-camera and v4l2-int)?

> --
> ---Trilok Soni
> http://triloksoni.wordpress.com
> http://www.linkedin.com/in/triloksoni
> --
> To unsubscribe from this list: send the line "unsubscribe linux-
> omap" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


^ permalink raw reply	[flat|nested] 263+ messages in thread

* Re: [PATCH 2/2] TVP514x V4L int device driver support
  2008-11-21 15:22 ` [PATCH 2/2] TVP514x V4L int device driver support hvaibhav
                     ` (2 preceding siblings ...)
  2008-11-23 22:00   ` Hans Verkuil
@ 2008-11-24 10:06   ` David Brownell
  3 siblings, 0 replies; 263+ messages in thread
From: David Brownell @ 2008-11-24 10:06 UTC (permalink / raw)
  To: hvaibhav
  Cc: video4linux-list, linux-omap, davinci-linux-open-source-bounces,
	Brijesh Jadav

On Friday 21 November 2008, hvaibhav@ti.com wrote:
> +static const struct i2c_device_id tvp514x_id[] = {
> +       {MODULE_NAME, 0},
> +       {},
> +};

Don't do that.  Instead:

	{ "tvp5146", 0 },
	{ "tvp5147", 0 },

and so on.  Maybe pass a flag there to help determine which
chip reset/init message sequence to use.  (Which, hmm, I did
not see in this code, although the data sheets are clear
that the '46 needs 12 writes and the '47 needs 18 ...)  Or
tell if the extra '46 registers are available, etc.


> +late_initcall(tvp514x_init);

Why is this "late" instead of normal module_init()?
It's unusual for I2C...

- Dave
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [PATCH 1/2] Add Input/Output related ioctl support
@ 2008-11-26 17:04 ` hvaibhav
  2008-11-26 17:15     ` Hans Verkuil
  0 siblings, 1 reply; 263+ messages in thread
From: hvaibhav @ 2008-11-26 17:04 UTC (permalink / raw)
  To: video4linux-list
  Cc: davinci-linux-open-source-bounces, Karicheri Muralidharan, linux-omap

From: Vaibhav Hiremath <hvaibhav@ti.com>

Note - Resending again with TVP driver for completeness.

Added ioctl support for query std, set std, enum input,
get input, set input, enum output, get output and set output.

For sensor kind of slave drivers v4l2-int-device.h provides
necessary ioctl support, but the ioctls required to interface
with decoders and encoders are missing. Most of the decoders
and encoders supports multiple inputs and outputs, like
S-Video or Composite.

With these ioctl''s user can select the specific input/output.

Signed-off-by: Brijesh Jadav <brijesh.j@ti.com>
Signed-off-by: Hardik Shah <hardik.shah@ti.com>
Signed-off-by: Manjunath Hadli <mrh@ti.com>
Signed-off-by: R Sivaraj <sivaraj@ti.com>
Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
Signed-off-by: Karicheri Muralidharan <m-karicheri2@ti.com>
---
 include/media/v4l2-int-device.h |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/include/media/v4l2-int-device.h b/include/media/v4l2-int-device.h
index 9c2df41..2325b2a 100644
--- a/include/media/v4l2-int-device.h
+++ b/include/media/v4l2-int-device.h
@@ -102,6 +102,7 @@ enum v4l2_power {
 	V4L2_POWER_OFF = 0,
 	V4L2_POWER_ON,
 	V4L2_POWER_STANDBY,
+	V4L2_POWER_RESUME,
 };

 /* Slave interface type. */
@@ -183,6 +184,14 @@ enum v4l2_int_ioctl_num {
 	vidioc_int_s_crop_num,
 	vidioc_int_g_parm_num,
 	vidioc_int_s_parm_num,
+	vidioc_int_querystd_num,
+	vidioc_int_s_std_num,
+	vidioc_int_enum_input_num,
+	vidioc_int_g_input_num,
+	vidioc_int_s_input_num,
+	vidioc_int_enumoutput_num,
+	vidioc_int_g_output_num,
+	vidioc_int_s_output_num,

 	/*
 	 *
@@ -284,6 +293,14 @@ V4L2_INT_WRAPPER_1(g_crop, struct v4l2_crop, *);
 V4L2_INT_WRAPPER_1(s_crop, struct v4l2_crop, *);
 V4L2_INT_WRAPPER_1(g_parm, struct v4l2_streamparm, *);
 V4L2_INT_WRAPPER_1(s_parm, struct v4l2_streamparm, *);
+V4L2_INT_WRAPPER_1(querystd, v4l2_std_id, *);
+V4L2_INT_WRAPPER_1(s_std, v4l2_std_id, *);
+V4L2_INT_WRAPPER_1(enum_input, struct v4l2_input, *);
+V4L2_INT_WRAPPER_1(g_input, int, *);
+V4L2_INT_WRAPPER_1(s_input, int, );
+V4L2_INT_WRAPPER_1(enumoutput, struct v4l2_output, *);
+V4L2_INT_WRAPPER_1(g_output, int, *);
+V4L2_INT_WRAPPER_1(s_output, int, );

 V4L2_INT_WRAPPER_0(dev_init);
 V4L2_INT_WRAPPER_0(dev_exit);
--
1.5.6

--
video4linux-list mailing list
Unsubscribe mailto:video4linux-list-request@redhat.com?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list

^ permalink raw reply related	[flat|nested] 263+ messages in thread

* [PATCH 2/2] TVP514x Driver with Review comments fixed
@ 2008-11-26 17:05   ` hvaibhav
  0 siblings, 0 replies; 263+ messages in thread
From: hvaibhav @ 2008-11-26 17:05 UTC (permalink / raw)
  To: video4linux-list
  Cc: davinci-linux-open-source-bounces, Karicheri Muralidharan, linux-omap

From: Vaibhav Hiremath <hvaibhav@ti.com>

I have fixed most of the review comments received so far.
Here are the details:

FIXES
    Wrong use of CONFIG_VIDEO_ADV_DEBUG option:
        Implemented module parameter based approach for debugging.

    Bridge driver and access to TVP registers:
        The bridge driver will now provide only neccessary information
        depending on platform/board/interface. In case of TVP5146, we do
        require clk_polarity, input, number of input, HS/VS polarity, etc..
        which is interface dependent.
        All register access and values are limited to TVP driver.

    V4L2-int framework:
        The new sub-device framework is a new development and will take its
        own time to mature and stabilize. The implementation is rightly
        placed in a different branch for the same reason.

        I beleive till this time, we should move ahead with current framework.
	This patch provides base for V4L2-int capture-master driver and patch
	for the same will be posted in couple of weeks. we are in the process
	of code clean-up.

	It would be good if we can get this patch into the current codebase
	till the 'sub-device' framework stabilizes. The migration can be
	planned immediately.

    i2c table:
        Specified the name of chip.

    Code cleanup:
        Multiple changes as suggested.

PENDING (TO DO)

    I2C Legacy framework support:
        Still no change for Legacy support (Hans agreed on this).
        Can be added while we move to sub-device framework.

    New sub-device framework support:
        Will be taken up immediately.

Signed-off-by: Brijesh Jadav <brijesh.j@ti.com>
Signed-off-by: Hardik Shah <hardik.shah@ti.com>
Signed-off-by: Manjunath Hadli <mrh@ti.com>
Signed-off-by: R Sivaraj <sivaraj@ti.com>
Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
Signed-off-by: Karicheri Muralidharan <m-karicheri2@ti.com>
---
 drivers/media/video/Kconfig   |   11 +
 drivers/media/video/Makefile  |    1 +
 drivers/media/video/tvp514x.c | 1551 +++++++++++++++++++++++++++++++++++++++++
 include/media/tvp514x.h       |  461 ++++++++++++
 4 files changed, 2024 insertions(+), 0 deletions(-)
 create mode 100644 drivers/media/video/tvp514x.c
 create mode 100644 include/media/tvp514x.h

diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig
index 47102c2..2e5dc3e 100644
--- a/drivers/media/video/Kconfig
+++ b/drivers/media/video/Kconfig
@@ -361,6 +361,17 @@ config VIDEO_SAA7191
 	  To compile this driver as a module, choose M here: the
 	  module will be called saa7191.

+config VIDEO_TVP514X
+	tristate "Texas Instruments TVP514x video decoder"
+	depends on VIDEO_V4L2 && I2C
+	---help---
+	  This is a Video4Linux2 sensor-level driver for the TI TVP5146/47
+	  decoder. It is currently working with the TI OMAP3 camera
+	  controller.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called tvp514x.
+
 config VIDEO_TVP5150
 	tristate "Texas Instruments TVP5150 video decoder"
 	depends on VIDEO_V4L2 && I2C
diff --git a/drivers/media/video/Makefile b/drivers/media/video/Makefile
index 16962f3..cdbbf38 100644
--- a/drivers/media/video/Makefile
+++ b/drivers/media/video/Makefile
@@ -66,6 +66,7 @@ obj-$(CONFIG_VIDEO_CX88) += cx88/
 obj-$(CONFIG_VIDEO_EM28XX) += em28xx/
 obj-$(CONFIG_VIDEO_USBVISION) += usbvision/
 obj-$(CONFIG_VIDEO_TVP5150) += tvp5150.o
+obj-$(CONFIG_VIDEO_TVP514X) += tvp514x.o
 obj-$(CONFIG_VIDEO_PVRUSB2) += pvrusb2/
 obj-$(CONFIG_VIDEO_MSP3400) += msp3400.o
 obj-$(CONFIG_VIDEO_CS5345) += cs5345.o
diff --git a/drivers/media/video/tvp514x.c b/drivers/media/video/tvp514x.c
new file mode 100644
index 0000000..187a063
--- /dev/null
+++ b/drivers/media/video/tvp514x.c
@@ -0,0 +1,1551 @@
+/*
+ * drivers/media/video/tvp514x.c
+ *
+ * TI TVP5146/47 decoder driver
+ *
+ * Copyright (C) 2008 Texas Instruments Inc
+ *
+ * Contributors:
+ *     Brijesh R Jadav <brijesh.j@ti.com>
+ *     Hardik Shah <hardik.shah@ti.com>
+ *     Manjunath Hadli <mrh@ti.com>
+ *     Sivaraj R <sivaraj@ti.com>
+ *     Vaibhav Hiremath <hvaibhav@ti.com>
+ *
+ * This package is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#include <linux/i2c.h>
+#include <linux/delay.h>
+#include <linux/videodev2.h>
+#include <media/v4l2-int-device.h>
+#include <media/tvp514x.h>
+
+#define MODULE_NAME	TVP514X_MODULE_NAME
+
+/* Debug functions */
+#ifdef TVP514X_DEBUG
+static unsigned short debug = 3;
+module_param(debug, ushort, 0644);
+MODULE_PARM_DESC(debug,
+		"\n<n> Debugging information level, from 0 to 3:"
+		"\n0 = none (use carefully)"
+		"\n1 = critical errors"
+		"\n2 = significant informations"
+		"\n3 = more verbose messages"
+		"\nLevel 3 is useful for testing only, when only "
+		"one device is used."
+		"\nDefault value is "__MODULE_STRING(2)"."
+		"\n");
+
+#define DBG(dev, level, fmt, args...)                                    \
+	do {                                                             \
+		if (debug >= (level)) {                                  \
+			if ((level) == 1)                                \
+				dev_err(dev, fmt "\n", ## args);         \
+			else if ((level) == 2)                           \
+				dev_info(dev, fmt "\n", ## args);        \
+			else if ((level) >= 3)                           \
+				dev_info(dev, "[%s:%s:%d] " fmt "\n",    \
+				__FILE__, __func__, __LINE__ , ## args); \
+		}                                                        \
+	} while (0)
+
+#define dump_reg(client, reg, val)					\
+	do {								\
+		tvp514x_read_reg(client, reg, &val);			\
+		dev_dbg(&(client)->dev, "Reg(0x%.2X): 0x%.2X\n", reg, val); \
+	} while (0)
+
+#else
+#define DBG(dev, level, fmt, args...) do {; } while (0)
+#endif				/* #ifdef TVP514X_DEBUG */
+
+/* TVP514x default register values */
+static struct tvp514x_reg tvp514x_reg_list[] = {
+	{TOK_WRITE, REG_INPUT_SEL, 0x05},	/* Composite selected */
+	{TOK_WRITE, REG_AFE_GAIN_CTRL, 0x0F},
+	{TOK_WRITE, REG_VIDEO_STD, 0x00},	/* Auto mode */
+	{TOK_WRITE, REG_OPERATION_MODE, 0x00},
+	{TOK_SKIP, REG_AUTOSWITCH_MASK, 0x3F},
+	{TOK_WRITE, REG_COLOR_KILLER, 0x10},
+	{TOK_WRITE, REG_LUMA_CONTROL1, 0x00},
+	{TOK_WRITE, REG_LUMA_CONTROL2, 0x00},
+	{TOK_WRITE, REG_LUMA_CONTROL3, 0x02},
+	{TOK_WRITE, REG_BRIGHTNESS, 0x80},
+	{TOK_WRITE, REG_CONTRAST, 0x80},
+	{TOK_WRITE, REG_SATURATION, 0x80},
+	{TOK_WRITE, REG_HUE, 0x00},
+	{TOK_WRITE, REG_CHROMA_CONTROL1, 0x00},
+	{TOK_WRITE, REG_CHROMA_CONTROL2, 0x0E},
+	{TOK_SKIP, 0x0F, 0x00},	/* Reserved */
+	{TOK_WRITE, REG_COMP_PR_SATURATION, 0x80},
+	{TOK_WRITE, REG_COMP_Y_CONTRAST, 0x80},
+	{TOK_WRITE, REG_COMP_PB_SATURATION, 0x80},
+	{TOK_SKIP, 0x13, 0x00},	/* Reserved */
+	{TOK_WRITE, REG_COMP_Y_BRIGHTNESS, 0x80},
+	{TOK_SKIP, 0x15, 0x00},	/* Reserved */
+	{TOK_SKIP, REG_AVID_START_PIXEL_LSB, 0x55},	/* NTSC timing */
+	{TOK_SKIP, REG_AVID_START_PIXEL_MSB, 0x00},
+	{TOK_SKIP, REG_AVID_STOP_PIXEL_LSB, 0x25},
+	{TOK_SKIP, REG_AVID_STOP_PIXEL_MSB, 0x03},
+	{TOK_SKIP, REG_HSYNC_START_PIXEL_LSB, 0x00},	/* NTSC timing */
+	{TOK_SKIP, REG_HSYNC_START_PIXEL_MSB, 0x00},
+	{TOK_SKIP, REG_HSYNC_STOP_PIXEL_LSB, 0x40},
+	{TOK_SKIP, REG_HSYNC_STOP_PIXEL_MSB, 0x00},
+	{TOK_SKIP, REG_VSYNC_START_LINE_LSB, 0x04},	/* NTSC timing */
+	{TOK_SKIP, REG_VSYNC_START_LINE_MSB, 0x00},
+	{TOK_SKIP, REG_VSYNC_STOP_LINE_LSB, 0x07},
+	{TOK_SKIP, REG_VSYNC_STOP_LINE_MSB, 0x00},
+	{TOK_SKIP, REG_VBLK_START_LINE_LSB, 0x01},	/* NTSC timing */
+	{TOK_SKIP, REG_VBLK_START_LINE_MSB, 0x00},
+	{TOK_SKIP, REG_VBLK_STOP_LINE_LSB, 0x15},
+	{TOK_SKIP, REG_VBLK_STOP_LINE_MSB, 0x00},
+	{TOK_SKIP, 0x26, 0x00},	/* Reserved */
+	{TOK_SKIP, 0x27, 0x00},	/* Reserved */
+	{TOK_SKIP, REG_FAST_SWTICH_CONTROL, 0xCC},
+	{TOK_SKIP, 0x29, 0x00},	/* Reserved */
+	{TOK_SKIP, REG_FAST_SWTICH_SCART_DELAY, 0x00},
+	{TOK_SKIP, 0x2B, 0x00},	/* Reserved */
+	{TOK_SKIP, REG_SCART_DELAY, 0x00},
+	{TOK_SKIP, REG_CTI_DELAY, 0x00},
+	{TOK_SKIP, REG_CTI_CONTROL, 0x00},
+	{TOK_SKIP, 0x2F, 0x00},	/* Reserved */
+	{TOK_SKIP, 0x30, 0x00},	/* Reserved */
+	{TOK_SKIP, 0x31, 0x00},	/* Reserved */
+	{TOK_WRITE, REG_SYNC_CONTROL, 0x00},	/* HS, VS active high */
+	{TOK_WRITE, REG_OUTPUT_FORMATTER1, 0x00},	/* 10-bit BT.656 */
+	{TOK_WRITE, REG_OUTPUT_FORMATTER2, 0x11},	/* Enable clk & data */
+	{TOK_WRITE, REG_OUTPUT_FORMATTER3, 0xEE},	/* Enable AVID & FLD */
+	{TOK_WRITE, REG_OUTPUT_FORMATTER4, 0xAF},	/* Enable VS & HS */
+	{TOK_WRITE, REG_OUTPUT_FORMATTER5, 0xFF},
+	{TOK_WRITE, REG_OUTPUT_FORMATTER6, 0xFF},
+	{TOK_WRITE, REG_CLEAR_LOST_LOCK, 0x01},	/* Clear status */
+	{TOK_TERM, 0, 0},
+};
+
+/* List of image formats supported by TVP5146/47 decoder
+ * Currently we are using 8 bit mode only, but can be
+ * extended to 10/20 bit mode.
+ */
+static const struct v4l2_fmtdesc tvp514x_fmt_list[] = {
+	{
+	 .index = 0,
+	 .type = V4L2_BUF_TYPE_VIDEO_CAPTURE,
+	 .flags = 0,
+	 .description = "8-bit UYVY 4:2:2 Format",
+	 .pixelformat = V4L2_PIX_FMT_UYVY,
+	},
+};
+
+#define TVP514X_NUM_FORMATS		ARRAY_SIZE(tvp514x_fmt_list)
+
+/*
+ * Supported standards - These must be ordered according to enum tvp514x_std
+ * order.
+ * Currently supports two standards only, need to add support for rest of the
+ * modes, like SECAM, etc...
+ */
+static struct tvp514x_std_info tvp514x_std_list[] = {
+	{
+	 .width = NTSC_NUM_ACTIVE_PIXELS,
+	 .height = NTSC_NUM_ACTIVE_LINES,
+	 .video_std = VIDEO_STD_NTSC_MJ_BIT,
+	 .standard = {
+		      .index = 0,
+		      .id = V4L2_STD_NTSC,
+		      .name = "NTSC",
+		      .frameperiod = {1001, 30000},
+		      .framelines = 525
+		     },
+	}, {
+	 .width = PAL_NUM_ACTIVE_PIXELS,
+	 .height = PAL_NUM_ACTIVE_LINES,
+	 .video_std = VIDEO_STD_PAL_BDGHIN_BIT,
+	 .standard = {
+		      .index = 1,
+		      .id = V4L2_STD_PAL,
+		      .name = "PAL",
+		      .frameperiod = {1, 25},
+		      .framelines = 625
+		     },
+	},
+};
+
+#define TVP514X_NUM_STANDARDS		ARRAY_SIZE(tvp514x_std_list)
+
+/* Supported controls */
+static const struct tvp514x_ctrl_info tvp514x_ctrl_list[] = {
+	{
+	 .reg_address = REG_BRIGHTNESS,
+	 .query_ctrl = {
+			.id = V4L2_CID_BRIGHTNESS,
+			.name = "BRIGHTNESS",
+			.type = V4L2_CTRL_TYPE_INTEGER,
+			.minimum = 0,
+			.maximum = 255,
+			.step = 1,
+			.default_value = 128
+			},
+	}, {
+	 .reg_address = REG_CONTRAST,
+	 .query_ctrl = {
+			.id = V4L2_CID_CONTRAST,
+			.name = "CONTRAST",
+			.type = V4L2_CTRL_TYPE_INTEGER,
+			.minimum = 0,
+			.maximum = 255,
+			.step = 1,
+			.default_value = 128
+			},
+	}, {
+	 .reg_address = REG_SATURATION,
+	 .query_ctrl = {
+			.id = V4L2_CID_SATURATION,
+			.name = "SATURATION",
+			.type = V4L2_CTRL_TYPE_INTEGER,
+			.minimum = 0,
+			.maximum = 255,
+			.step = 1,
+			.default_value = 128
+			},
+	}, {
+	 .reg_address = REG_HUE,
+	 .query_ctrl = {
+			.id = V4L2_CID_HUE,
+			.name = "HUE",
+			.type = V4L2_CTRL_TYPE_INTEGER,
+			.minimum = -180,
+			.maximum = 180,
+			.step = 180,
+			.default_value = 0
+			},
+	}, {
+	 .reg_address = REG_AFE_GAIN_CTRL,
+	 .query_ctrl = {
+			.id = V4L2_CID_AUTOGAIN,
+			.name = "Automatic Gain Control",
+			.type = V4L2_CTRL_TYPE_BOOLEAN,
+			.minimum = 0,
+			.maximum = 1,
+			.step = 1,
+			.default_value = 1
+			},
+	 },
+};
+
+#define TVP514X_NUM_CONTROLS		ARRAY_SIZE(tvp514x_ctrl_list)
+
+/*
+ * Read a value from a register in an TVP5146/47 decoder device.
+ * The value is returned in 'val'.
+ * Returns zero if successful, or non-zero otherwise.
+ */
+static int tvp514x_read_reg(struct i2c_client *client, u8 reg, u8 *val)
+{
+	int err;
+	struct i2c_msg msg[2];
+	u8 data;
+
+	if (!client->adapter)
+		return -ENODEV;
+
+	/* [MSG1] fill the register address data */
+	data = reg;
+	msg[0].addr = client->addr;
+	msg[0].len = 1;
+	msg[0].flags = 0;
+	msg[0].buf = &data;
+
+	/* [MSG2] fill the data rx buffer */
+	msg[1].addr = client->addr;
+	msg[1].len = 1;		/* only 1 byte */
+	msg[1].flags = I2C_M_RD;	/* Read the register values */
+	msg[1].buf = val;
+	err = i2c_transfer(client->adapter, msg, 2);
+	if (err >= 0)
+		return 0;
+
+	DBG(&client->dev, 1,
+		"read from device 0x%.2x, offset 0x%.2x error %d\n",
+		client->addr, reg, err);
+
+	return err;
+}
+
+/*
+ * Write a value to a register in an TVP5146/47 decoder device.
+ * Returns zero if successful, or non-zero otherwise.
+ */
+static int tvp514x_write_reg(struct i2c_client *client, u8 reg, u8 val)
+{
+	int err;
+	int retry = 0;
+	struct i2c_msg msg[1];
+	u8 data[2];
+
+	if (!client->adapter)
+		return -ENODEV;
+
+again:
+	data[0] = reg;		/* Register offset */
+	data[1] = val;		/* Register value */
+	msg->addr = client->addr;
+	msg->len = 2;
+	msg->flags = 0;		/* write operation */
+	msg->buf = data;
+
+	err = i2c_transfer(client->adapter, msg, 1);
+	if (err >= 0)
+		return 0;
+
+	DBG(&client->dev, 1,
+		"wrote 0x%.2x to offset 0x%.2x error %d\n", val, reg, err);
+	if (retry <= I2C_RETRY_COUNT) {
+		DBG(&client->dev, 2, "retry ... %d\n", retry);
+		retry++;
+		schedule_timeout(msecs_to_jiffies(20));
+		goto again;
+	}
+	return err;
+}
+
+/*
+ * tvp514x_write_regs : Initializes a list of TVP5146/47 registers
+ *		if token is TOK_TERM, then entire write operation terminates
+ *		if token is TOK_DELAY, then a delay of 'val' msec is introduced
+ *		if token is TOK_SKIP, then the register write is skipped
+ *		if token is TOK_WRITE, then the register write is performed
+ *
+ * reglist - list of registers to be written
+ * Returns zero if successful, or non-zero otherwise.
+ */
+static int tvp514x_write_regs(struct i2c_client *client,
+			      const struct tvp514x_reg reglist[])
+{
+	int err;
+	const struct tvp514x_reg *next = reglist;
+
+	for (; next->token != TOK_TERM; next++) {
+		if (next->token == TOK_DELAY) {
+			schedule_timeout(msecs_to_jiffies(next->val));
+			continue;
+		}
+
+		if (next->token == TOK_SKIP)
+			continue;
+
+		err = tvp514x_write_reg(client, next->reg, (u8) next->val);
+		if (err) {
+			DBG(&client->dev, 1, "write failed. Err[%d]\n",
+				err);
+			return err;
+		}
+	}
+	return 0;
+}
+
+/*
+ * tvp514x_get_current_std:
+ * Returns the current standard detected by TVP5146/47
+ */
+static enum tvp514x_std tvp514x_get_current_std(struct tvp514x_decoder
+						*decoder)
+{
+	u8 std, std_status;
+
+	if (tvp514x_read_reg(decoder->client, REG_VIDEO_STD, &std))
+		return STD_INVALID;
+
+	if ((std & VIDEO_STD_MASK) == VIDEO_STD_AUTO_SWITCH_BIT) {
+		/* use the standard status register */
+		if (tvp514x_read_reg(decoder->client, REG_VIDEO_STD_STATUS,
+				     &std_status))
+			return STD_INVALID;
+	} else
+		std_status = std;	/* use the standard register itself */
+
+	switch (std_status & VIDEO_STD_MASK) {
+	case VIDEO_STD_NTSC_MJ_BIT:
+		return STD_NTSC_MJ;
+
+	case VIDEO_STD_PAL_BDGHIN_BIT:
+		return STD_PAL_BDGHIN;
+
+	default:
+		return STD_INVALID;
+	}
+
+	return STD_INVALID;
+}
+
+#ifdef TVP514X_DEBUG
+/*
+ * TVP5146/47 register dump function
+ */
+void tvp514x_reg_dump(struct tvp514x_decoder *decoder)
+{
+	u8 value;
+
+	dump_reg(decoder->client, REG_INPUT_SEL, value);
+	dump_reg(decoder->client, REG_AFE_GAIN_CTRL, value);
+	dump_reg(decoder->client, REG_VIDEO_STD, value);
+	dump_reg(decoder->client, REG_OPERATION_MODE, value);
+	dump_reg(decoder->client, REG_COLOR_KILLER, value);
+	dump_reg(decoder->client, REG_LUMA_CONTROL1, value);
+	dump_reg(decoder->client, REG_LUMA_CONTROL2, value);
+	dump_reg(decoder->client, REG_LUMA_CONTROL3, value);
+	dump_reg(decoder->client, REG_BRIGHTNESS, value);
+	dump_reg(decoder->client, REG_CONTRAST, value);
+	dump_reg(decoder->client, REG_SATURATION, value);
+	dump_reg(decoder->client, REG_HUE, value);
+	dump_reg(decoder->client, REG_CHROMA_CONTROL1, value);
+	dump_reg(decoder->client, REG_CHROMA_CONTROL2, value);
+	dump_reg(decoder->client, REG_COMP_PR_SATURATION, value);
+	dump_reg(decoder->client, REG_COMP_Y_CONTRAST, value);
+	dump_reg(decoder->client, REG_COMP_PB_SATURATION, value);
+	dump_reg(decoder->client, REG_COMP_Y_BRIGHTNESS, value);
+	dump_reg(decoder->client, REG_AVID_START_PIXEL_LSB, value);
+	dump_reg(decoder->client, REG_AVID_START_PIXEL_MSB, value);
+	dump_reg(decoder->client, REG_AVID_STOP_PIXEL_LSB, value);
+	dump_reg(decoder->client, REG_AVID_STOP_PIXEL_MSB, value);
+	dump_reg(decoder->client, REG_HSYNC_START_PIXEL_LSB, value);
+	dump_reg(decoder->client, REG_HSYNC_START_PIXEL_MSB, value);
+	dump_reg(decoder->client, REG_HSYNC_STOP_PIXEL_LSB, value);
+	dump_reg(decoder->client, REG_HSYNC_STOP_PIXEL_MSB, value);
+	dump_reg(decoder->client, REG_VSYNC_START_LINE_LSB, value);
+	dump_reg(decoder->client, REG_VSYNC_START_LINE_MSB, value);
+	dump_reg(decoder->client, REG_VSYNC_STOP_LINE_LSB, value);
+	dump_reg(decoder->client, REG_VSYNC_STOP_LINE_MSB, value);
+	dump_reg(decoder->client, REG_VBLK_START_LINE_LSB, value);
+	dump_reg(decoder->client, REG_VBLK_START_LINE_MSB, value);
+	dump_reg(decoder->client, REG_VBLK_STOP_LINE_LSB, value);
+	dump_reg(decoder->client, REG_VBLK_STOP_LINE_MSB, value);
+	dump_reg(decoder->client, REG_SYNC_CONTROL, value);
+	dump_reg(decoder->client, REG_OUTPUT_FORMATTER1, value);
+	dump_reg(decoder->client, REG_OUTPUT_FORMATTER2, value);
+	dump_reg(decoder->client, REG_OUTPUT_FORMATTER3, value);
+	dump_reg(decoder->client, REG_OUTPUT_FORMATTER4, value);
+	dump_reg(decoder->client, REG_OUTPUT_FORMATTER5, value);
+	dump_reg(decoder->client, REG_OUTPUT_FORMATTER6, value);
+	dump_reg(decoder->client, REG_CLEAR_LOST_LOCK, value);
+}
+#endif
+
+/*
+ * Configure the TVP5146/47 with the current register settings
+ * Returns zero if successful, or non-zero otherwise.
+ */
+static int tvp514x_configure(struct tvp514x_decoder *decoder)
+{
+	int err;
+
+	/* common register initialization */
+	err =
+	    tvp514x_write_regs(decoder->client, tvp514x_reg_list);
+	if (err)
+		return err;
+
+#ifdef TVP514X_DEBUG
+	tvp514x_reg_dump(decoder);
+#endif
+
+	return 0;
+}
+
+/*
+ * Detect if an tvp514x is present, and if so which revision.
+ * A device is considered to be detected if the chip ID (LSB and MSB)
+ * registers match the expected values.
+ * Any value of the rom version register is accepted.
+ * Returns ENODEV error number if no device is detected, or zero
+ * if a device is detected.
+ */
+static int tvp514x_detect(struct tvp514x_decoder *decoder)
+{
+	u8 chip_id_msb, chip_id_lsb, rom_ver;
+
+	if (tvp514x_read_reg
+	    (decoder->client, REG_CHIP_ID_MSB, &chip_id_msb))
+		return -ENODEV;
+	if (tvp514x_read_reg
+	    (decoder->client, REG_CHIP_ID_LSB, &chip_id_lsb))
+		return -ENODEV;
+	if (tvp514x_read_reg(decoder->client, REG_ROM_VERSION, &rom_ver))
+		return -ENODEV;
+
+	DBG(&decoder->client->dev, 2,
+		 "chip id detected msb:0x%x lsb:0x%x rom version:0x%x\n",
+		 chip_id_msb, chip_id_lsb, rom_ver);
+	if ((chip_id_msb != TVP514X_CHIP_ID_MSB)
+		|| ((chip_id_lsb != TVP5146_CHIP_ID_LSB)
+		&& (chip_id_lsb != TVP5147_CHIP_ID_LSB))) {
+		/* We didn't read the values we expected, so this must not be
+		 * an TVP5146/47.
+		 */
+		DBG(&decoder->client->dev, 1,
+			"chip id mismatch msb:0x%x lsb:0x%x\n",
+			chip_id_msb, chip_id_lsb);
+		return -ENODEV;
+	}
+
+	decoder->ver = rom_ver;
+	decoder->state = STATE_DETECTED;
+
+	return 0;
+}
+
+/*
+ * following are decoder interface functions implemented by
+ * TVP5146/47 decoder driver.
+ */
+
+/**
+ * ioctl_querystd - V4L2 decoder interface handler for VIDIOC_QUERYSTD ioctl
+ * @s: pointer to standard V4L2 device structure
+ * @std_id: standard V4L2 std_id ioctl enum
+ *
+ * Returns the current standard detected by TVP5146/47. If no active input is
+ * detected, returns -EINVAL
+ */
+static int ioctl_querystd(struct v4l2_int_device *s, v4l2_std_id *std_id)
+{
+	struct tvp514x_decoder *decoder = s->priv;
+	enum tvp514x_std current_std;
+	enum tvp514x_input input_sel;
+	u8 sync_lock_status, lock_mask;
+
+	if (std_id == NULL)
+		return -EINVAL;
+
+	/* get the current standard */
+	current_std = tvp514x_get_current_std(decoder);
+	if (current_std == STD_INVALID)
+		return -EINVAL;
+
+	/* check whether signal is locked */
+	if (tvp514x_read_reg
+	    (decoder->client, REG_STATUS1, &sync_lock_status))
+		return -EINVAL;
+
+	input_sel = decoder->pdata->input_list[decoder->inputidx].input_sel;
+
+	switch (input_sel) {
+	case INPUT_CVBS_VI1A:
+	case INPUT_CVBS_VI1B:
+	case INPUT_CVBS_VI1C:
+	case INPUT_CVBS_VI2A:
+	case INPUT_CVBS_VI2B:
+	case INPUT_CVBS_VI2C:
+	case INPUT_CVBS_VI3A:
+	case INPUT_CVBS_VI3B:
+	case INPUT_CVBS_VI3C:
+	case INPUT_CVBS_VI4A:
+		lock_mask = STATUS_CLR_SUBCAR_LOCK_BIT |
+			STATUS_HORZ_SYNC_LOCK_BIT |
+			STATUS_VIRT_SYNC_LOCK_BIT;
+		break;
+
+	case INPUT_SVIDEO_VI2A_VI1A:
+	case INPUT_SVIDEO_VI2B_VI1B:
+	case INPUT_SVIDEO_VI2C_VI1C:
+	case INPUT_SVIDEO_VI2A_VI3A:
+	case INPUT_SVIDEO_VI2B_VI3B:
+	case INPUT_SVIDEO_VI2C_VI3C:
+	case INPUT_SVIDEO_VI4A_VI1A:
+	case INPUT_SVIDEO_VI4A_VI1B:
+	case INPUT_SVIDEO_VI4A_VI1C:
+	case INPUT_SVIDEO_VI4A_VI3A:
+	case INPUT_SVIDEO_VI4A_VI3B:
+	case INPUT_SVIDEO_VI4A_VI3C:
+		lock_mask = STATUS_HORZ_SYNC_LOCK_BIT |
+			STATUS_VIRT_SYNC_LOCK_BIT;
+		break;
+		/*Need to add other interfaces*/
+	default:
+		return -EINVAL;
+	}
+
+	if (lock_mask != (sync_lock_status & lock_mask))
+		return -EINVAL;	/* No input detected */
+
+	decoder->current_std = current_std;
+	*std_id = decoder->std_list[current_std].standard.id;
+
+	DBG(&decoder->client->dev, 3,
+			"Current STD: %s",
+			decoder->std_list[current_std].standard.name);
+	return 0;
+}
+
+/**
+ * ioctl_s_std - V4L2 decoder interface handler for VIDIOC_S_STD ioctl
+ * @s: pointer to standard V4L2 device structure
+ * @std_id: standard V4L2 v4l2_std_id ioctl enum
+ *
+ * If std_id is supported, sets the requested standard. Otherwise, returns
+ * -EINVAL
+ */
+static int ioctl_s_std(struct v4l2_int_device *s, v4l2_std_id *std_id)
+{
+	struct tvp514x_decoder *decoder = s->priv;
+	int err, i;
+
+	if (std_id == NULL)
+		return -EINVAL;
+
+	for (i = 0; i < decoder->num_stds; i++)
+		if (*std_id & decoder->std_list[i].standard.id)
+			break;
+
+	if (i == decoder->num_stds)
+		return -EINVAL;
+
+	err = tvp514x_write_reg(decoder->client, REG_VIDEO_STD,
+				decoder->std_list[i].video_std);
+	if (err)
+		return err;
+
+	decoder->current_std = i;
+	tvp514x_reg_list[REG_VIDEO_STD].val =
+	    decoder->std_list[i].video_std;
+
+	DBG(&decoder->client->dev, 3,
+			"Standard set to: %s",
+			decoder->std_list[i].standard.name);
+	return 0;
+}
+
+/**
+ * ioctl_enum_input - V4L2 decoder interface handler for VIDIOC_ENUMINPUT ioctl
+ * @s: pointer to standard V4L2 device structure
+ * @input: standard V4L2 VIDIOC_ENUMINPUT ioctl structure
+ *
+ * If index is valid, returns the description of the input. Otherwise, returns
+ * -EINVAL if any error occurs
+ */
+static int
+ioctl_enum_input(struct v4l2_int_device *s, struct v4l2_input *input)
+{
+	struct tvp514x_decoder *decoder = s->priv;
+	int index;
+
+	if (input == NULL)
+		return -EINVAL;
+
+	index = input->index;
+	if ((index >= decoder->pdata->num_inputs) || (index < 0))
+		return -EINVAL;	/* Index out of bound */
+
+	memcpy(input, &decoder->pdata->input_list[index].input,
+		sizeof(struct v4l2_input));
+
+	DBG(&decoder->client->dev, 3,
+			"Current input is: index - %d (%s)",
+			decoder->pdata->input_list[index].input.index,
+			decoder->pdata->input_list[index].input.name);
+	return 0;
+}
+
+/**
+ * ioctl_s_input - V4L2 decoder interface handler for VIDIOC_S_INPUT ioctl
+ * @s: pointer to standard V4L2 device structure
+ * @index: number of the input
+ *
+ * If index is valid, selects the requested input. Otherwise, returns -EINVAL if
+ * the input is not supported or there is no active signal present in the
+ * selected input.
+ */
+static int ioctl_s_input(struct v4l2_int_device *s, int index)
+{
+	struct tvp514x_decoder *decoder = s->priv;
+	int err;
+	enum tvp514x_input input_sel;
+	enum tvp514x_std current_std = STD_INVALID;
+	u8 sync_lock_status, lock_mask;
+	int try_count = LOCK_RETRY_COUNT;
+
+	if ((index >= decoder->pdata->num_inputs) || (index < 0))
+		return -EINVAL;	/* Index out of bound */
+
+	/* Get the register value to be written to select the requested input */
+	input_sel = decoder->pdata->input_list[index].input_sel;
+	err = tvp514x_write_reg(decoder->client, REG_INPUT_SEL, input_sel);
+	if (err)
+		return err;
+
+	decoder->inputidx = index;
+	tvp514x_reg_list[REG_INPUT_SEL].val = input_sel;
+
+	/* Clear status */
+	msleep(LOCK_RETRY_DELAY);
+	err =
+	    tvp514x_write_reg(decoder->client, REG_CLEAR_LOST_LOCK, 0x01);
+	if (err)
+		return err;
+
+	switch (input_sel) {
+	case INPUT_CVBS_VI1A:
+	case INPUT_CVBS_VI1B:
+	case INPUT_CVBS_VI1C:
+	case INPUT_CVBS_VI2A:
+	case INPUT_CVBS_VI2B:
+	case INPUT_CVBS_VI2C:
+	case INPUT_CVBS_VI3A:
+	case INPUT_CVBS_VI3B:
+	case INPUT_CVBS_VI3C:
+	case INPUT_CVBS_VI4A:
+		lock_mask = STATUS_CLR_SUBCAR_LOCK_BIT |
+			STATUS_HORZ_SYNC_LOCK_BIT |
+			STATUS_VIRT_SYNC_LOCK_BIT;
+		break;
+
+	case INPUT_SVIDEO_VI2A_VI1A:
+	case INPUT_SVIDEO_VI2B_VI1B:
+	case INPUT_SVIDEO_VI2C_VI1C:
+	case INPUT_SVIDEO_VI2A_VI3A:
+	case INPUT_SVIDEO_VI2B_VI3B:
+	case INPUT_SVIDEO_VI2C_VI3C:
+	case INPUT_SVIDEO_VI4A_VI1A:
+	case INPUT_SVIDEO_VI4A_VI1B:
+	case INPUT_SVIDEO_VI4A_VI1C:
+	case INPUT_SVIDEO_VI4A_VI3A:
+	case INPUT_SVIDEO_VI4A_VI3B:
+	case INPUT_SVIDEO_VI4A_VI3C:
+		lock_mask = STATUS_HORZ_SYNC_LOCK_BIT |
+			STATUS_VIRT_SYNC_LOCK_BIT;
+		break;
+	/*Need to add other interfaces*/
+	default:
+		return -EINVAL;
+	}
+
+	while (try_count-- > 0) {
+		/* Allow decoder to sync up with new input */
+		msleep(LOCK_RETRY_DELAY);
+
+		/* get the current standard for future reference */
+		current_std = tvp514x_get_current_std(decoder);
+		if (current_std == STD_INVALID)
+			continue;
+
+		if (tvp514x_read_reg(decoder->client, REG_STATUS1,
+					&sync_lock_status))
+			return -EINVAL;
+
+		if (lock_mask == (sync_lock_status & lock_mask))
+			break;	/* Input detected */
+	}
+
+	if ((current_std == STD_INVALID) || (try_count < 0))
+		return -EINVAL;
+
+	decoder->current_std = current_std;
+
+	DBG(&decoder->client->dev, 3,
+			"Input set to: index - %d (%s)",
+			decoder->pdata->input_list[index].input.index,
+			decoder->pdata->input_list[index].input.name);
+	return 0;
+}
+
+/**
+ * ioctl_g_input - V4L2 decoder interface handler for VIDIOC_G_INPUT ioctl
+ * @s: pointer to standard V4L2 device structure
+ * @index: returns the current selected input
+ *
+ * Returns the current selected input. Returns -EINVAL if any error occurs
+ */
+static int ioctl_g_input(struct v4l2_int_device *s, int *index)
+{
+	struct tvp514x_decoder *decoder = s->priv;
+	int err = -EINVAL, i, inputidx;
+
+	if (index == NULL)
+		return -EINVAL;
+
+	/* Search through the input list for active inputs */
+	inputidx = decoder->inputidx;
+	for (i = 0; i < decoder->pdata->num_inputs; i++) {
+		inputidx++;	/* Move to next input */
+		if (inputidx >= decoder->pdata->num_inputs)
+			inputidx = 0;	/* fall back to first input */
+
+		err = ioctl_s_input(s, inputidx);
+		if (!err) {
+			/* Active input found - select it and return success */
+			*index = inputidx;
+			return 0;
+		}
+	}
+
+	return err;
+}
+
+/**
+ * ioctl_queryctrl - V4L2 decoder interface handler for VIDIOC_QUERYCTRL ioctl
+ * @s: pointer to standard V4L2 device structure
+ * @qc: standard V4L2 VIDIOC_QUERYCTRL ioctl structure
+ *
+ * If the requested control is supported, returns the control information
+ * from the ctrl_list[] array. Otherwise, returns -EINVAL if the
+ * control is not supported.
+ */
+static int
+ioctl_queryctrl(struct v4l2_int_device *s, struct v4l2_queryctrl *qctrl)
+{
+	struct tvp514x_decoder *decoder = s->priv;
+	int id, index;
+	const struct tvp514x_ctrl_info *control = NULL;
+
+	if (qctrl == NULL)
+		return -EINVAL;
+
+	id = qctrl->id;
+	memset(qctrl, 0, sizeof(struct v4l2_queryctrl));
+	qctrl->id = id;
+
+	for (index = 0; index < decoder->num_ctrls; index++) {
+		control = &decoder->ctrl_list[index];
+		if (control->query_ctrl.id == qctrl->id)
+			break;	/* Match found */
+	}
+	if (index == decoder->num_ctrls)
+		return -EINVAL;	/* Index out of bound */
+
+	memcpy(qctrl, &control->query_ctrl, sizeof(struct v4l2_queryctrl));
+
+	DBG(&decoder->client->dev, 3,
+			"Query Cotrol: %s : Min - %d, Max - %d, Def - %d",
+			control->query_ctrl.name,
+			control->query_ctrl.minimum,
+			control->query_ctrl.maximum,
+			control->query_ctrl.default_value);
+	return 0;
+}
+
+/**
+ * ioctl_g_ctrl - V4L2 decoder interface handler for VIDIOC_G_CTRL ioctl
+ * @s: pointer to standard V4L2 device structure
+ * @vc: standard V4L2 VIDIOC_G_CTRL ioctl structure
+ *
+ * If the requested control is supported, returns the control's current
+ * value from the decoder. Otherwise, returns -EINVAL if the control is not
+ * supported.
+ */
+static int
+ioctl_g_ctrl(struct v4l2_int_device *s, struct v4l2_control *ctrl)
+{
+	struct tvp514x_decoder *decoder = s->priv;
+	int err, index;
+	u8 val;
+	int value;
+	const struct tvp514x_ctrl_info *control = NULL;
+
+	if (ctrl == NULL)
+		return -EINVAL;
+
+	for (index = 0; index < decoder->num_ctrls; index++) {
+		control = &decoder->ctrl_list[index];
+		if (control->query_ctrl.id == ctrl->id)
+			break;	/* Match found */
+	}
+	if (index == decoder->num_ctrls)
+		return -EINVAL;	/* Index out of bound */
+
+	err =
+	    tvp514x_read_reg(decoder->client, control->reg_address, &val);
+	if (err < 0)
+		return err;
+
+	/* cross check */
+	if (val != tvp514x_reg_list[control->reg_address].val)
+		return -EINVAL;	/* Driver & TVP5146/47 setting mismatch */
+
+	value = val;
+	if (V4L2_CID_AUTOGAIN == ctrl->id) {
+		if ((value & 0x3) == 3)
+			value = 1;
+		else
+			value = 0;
+	}
+
+	if (V4L2_CID_HUE == ctrl->id) {
+		if (value == 0x7F)
+			value = 180;
+		else if (value == 0x80)
+			value = -180;
+		else
+			value = 0;
+	}
+
+	ctrl->value = value;
+
+	DBG(&decoder->client->dev, 3,
+			"Get Cotrol: %s - %d",
+			control->query_ctrl.name, value);
+	return err;
+}
+
+/**
+ * ioctl_s_ctrl - V4L2 decoder interface handler for VIDIOC_S_CTRL ioctl
+ * @s: pointer to standard V4L2 device structure
+ * @vc: standard V4L2 VIDIOC_S_CTRL ioctl structure
+ *
+ * If the requested control is supported, sets the control's current
+ * value in HW. Otherwise, returns -EINVAL if the control is not supported.
+ */
+static int
+ioctl_s_ctrl(struct v4l2_int_device *s, struct v4l2_control *ctrl)
+{
+	struct tvp514x_decoder *decoder = s->priv;
+	int err, value, index;
+	const struct tvp514x_ctrl_info *control = NULL;
+
+	if (ctrl == NULL)
+		return -EINVAL;
+
+	value = (__s32) ctrl->value;
+	for (index = 0; index < decoder->num_ctrls; index++) {
+		control = &decoder->ctrl_list[index];
+		if (control->query_ctrl.id == ctrl->id)
+			break;	/* Match found */
+	}
+	if (index == decoder->num_ctrls)
+		return -EINVAL;	/* Index out of bound */
+
+	if (V4L2_CID_AUTOGAIN == ctrl->id) {
+		if (value == 1)
+			value = 0x0F;
+		else if (value == 0)
+			value = 0x0C;
+		else
+			return -ERANGE;
+	} else if (V4L2_CID_HUE == ctrl->id) {
+		if (value == 180)
+			value = 0x7F;
+		else if (value == -180)
+			value = 0x80;
+		else if (value == 0)
+			value = 0;
+		else
+			return -ERANGE;
+	} else {
+		if ((value < control->query_ctrl.minimum)
+			|| (value > control->query_ctrl.maximum))
+			return -ERANGE;
+	}
+
+	err =
+	    tvp514x_write_reg(decoder->client, control->reg_address,
+				value);
+	if (err < 0)
+		return err;
+
+	tvp514x_reg_list[control->reg_address].val = value;
+
+	DBG(&decoder->client->dev, 3,
+			"Set Cotrol: %s - %d",
+			control->query_ctrl.name, value);
+	return err;
+}
+
+/**
+ * ioctl_enum_fmt_cap - Implement the CAPTURE buffer VIDIOC_ENUM_FMT ioctl
+ * @s: pointer to standard V4L2 device structure
+ * @fmt: standard V4L2 VIDIOC_ENUM_FMT ioctl structure
+ *
+ * Implement the VIDIOC_ENUM_FMT ioctl to enumerate supported formats
+ */
+static int
+ioctl_enum_fmt_cap(struct v4l2_int_device *s, struct v4l2_fmtdesc *fmt)
+{
+	struct tvp514x_decoder *decoder = s->priv;
+	int index;
+
+	if (fmt == NULL)
+		return -EINVAL;
+
+	index = fmt->index;
+	if ((index >= decoder->num_fmts) || (index < 0))
+		return -EINVAL;	/* Index out of bound */
+
+	if (fmt->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
+		return -EINVAL;	/* only capture is supported */
+
+	memcpy(fmt, &decoder->fmt_list[index],
+		sizeof(struct v4l2_fmtdesc));
+
+	DBG(&decoder->client->dev, 3,
+			"Current FMT: index - %d (%s)",
+			decoder->fmt_list[index].index,
+			decoder->fmt_list[index].description);
+	return 0;
+}
+
+/**
+ * ioctl_try_fmt_cap - Implement the CAPTURE buffer VIDIOC_TRY_FMT ioctl
+ * @s: pointer to standard V4L2 device structure
+ * @f: pointer to standard V4L2 VIDIOC_TRY_FMT ioctl structure
+ *
+ * Implement the VIDIOC_TRY_FMT ioctl for the CAPTURE buffer type. This
+ * ioctl is used to negotiate the image capture size and pixel format
+ * without actually making it take effect.
+ */
+static int
+ioctl_try_fmt_cap(struct v4l2_int_device *s, struct v4l2_format *f)
+{
+	struct tvp514x_decoder *decoder = s->priv;
+	int ifmt;
+	struct v4l2_pix_format *pix;
+	enum tvp514x_std current_std;
+
+	if (f == NULL)
+		return -EINVAL;
+
+	if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
+		f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+
+	pix = &f->fmt.pix;
+
+	/* Calculate height and width based on current standard */
+	current_std = tvp514x_get_current_std(decoder);
+	if (current_std == STD_INVALID)
+		return -EINVAL;
+
+	decoder->current_std = current_std;
+	pix->width = decoder->std_list[current_std].width;
+	pix->height = decoder->std_list[current_std].height;
+
+	for (ifmt = 0; ifmt < decoder->num_fmts; ifmt++) {
+		if (pix->pixelformat ==
+			decoder->fmt_list[ifmt].pixelformat)
+			break;
+	}
+	if (ifmt == decoder->num_fmts)
+		ifmt = 0;	/* None of the format matched, select default */
+	pix->pixelformat = decoder->fmt_list[ifmt].pixelformat;
+
+	pix->field = V4L2_FIELD_INTERLACED;
+	pix->bytesperline = pix->width * 2;
+	pix->sizeimage = pix->bytesperline * pix->height;
+	pix->colorspace = V4L2_COLORSPACE_SMPTE170M;
+	pix->priv = 0;
+
+	DBG(&decoder->client->dev, 3,
+			"Try FMT: pixelformat - %s, bytesperline - %d"
+			"Width - %d, Height - %d",
+			decoder->fmt_list[ifmt].description, pix->bytesperline,
+			pix->width, pix->height);
+	return 0;
+}
+
+/**
+ * ioctl_s_fmt_cap - V4L2 decoder interface handler for VIDIOC_S_FMT ioctl
+ * @s: pointer to standard V4L2 device structure
+ * @f: pointer to standard V4L2 VIDIOC_S_FMT ioctl structure
+ *
+ * If the requested format is supported, configures the HW to use that
+ * format, returns error code if format not supported or HW can't be
+ * correctly configured.
+ */
+static int
+ioctl_s_fmt_cap(struct v4l2_int_device *s, struct v4l2_format *f)
+{
+	struct tvp514x_decoder *decoder = s->priv;
+	struct v4l2_pix_format *pix;
+	int rval;
+
+	if (f == NULL)
+		return -EINVAL;
+
+	if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
+		return -EINVAL;	/* only capture is supported */
+
+	pix = &f->fmt.pix;
+	rval = ioctl_try_fmt_cap(s, f);
+	if (rval)
+		return rval;
+	else
+		decoder->pix = *pix;
+
+	return rval;
+}
+
+/**
+ * ioctl_g_fmt_cap - V4L2 decoder interface handler for ioctl_g_fmt_cap
+ * @s: pointer to standard V4L2 device structure
+ * @f: pointer to standard V4L2 v4l2_format structure
+ *
+ * Returns the decoder's current pixel format in the v4l2_format
+ * parameter.
+ */
+static int
+ioctl_g_fmt_cap(struct v4l2_int_device *s, struct v4l2_format *f)
+{
+	struct tvp514x_decoder *decoder = s->priv;
+
+	if (f == NULL)
+		return -EINVAL;
+
+	if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
+		return -EINVAL;	/* only capture is supported */
+
+	f->fmt.pix = decoder->pix;
+
+	DBG(&decoder->client->dev, 3,
+			"Current FMT: bytesperline - %d"
+			"Width - %d, Height - %d",
+			decoder->pix.bytesperline,
+			decoder->pix.width, decoder->pix.height);
+	return 0;
+}
+
+/**
+ * ioctl_g_parm - V4L2 decoder interface handler for VIDIOC_G_PARM ioctl
+ * @s: pointer to standard V4L2 device structure
+ * @a: pointer to standard V4L2 VIDIOC_G_PARM ioctl structure
+ *
+ * Returns the decoder's video CAPTURE parameters.
+ */
+static int
+ioctl_g_parm(struct v4l2_int_device *s, struct v4l2_streamparm *a)
+{
+	struct tvp514x_decoder *decoder = s->priv;
+	struct v4l2_captureparm *cparm;
+	enum tvp514x_std current_std;
+
+	if (a == NULL)
+		return -EINVAL;
+
+	if (a->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
+		return -EINVAL;	/* only capture is supported */
+
+	memset(a, 0, sizeof(*a));
+	a->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+
+	/* get the current standard */
+	current_std = tvp514x_get_current_std(decoder);
+	decoder->current_std = current_std;
+
+	cparm = &a->parm.capture;
+	cparm->capability = V4L2_CAP_TIMEPERFRAME;
+	cparm->timeperframe
+	    = decoder->std_list[current_std].standard.frameperiod;
+
+	return 0;
+}
+
+/**
+ * ioctl_s_parm - V4L2 decoder interface handler for VIDIOC_S_PARM ioctl
+ * @s: pointer to standard V4L2 device structure
+ * @a: pointer to standard V4L2 VIDIOC_S_PARM ioctl structure
+ *
+ * Configures the decoder to use the input parameters, if possible. If
+ * not possible, returns the appropriate error code.
+ */
+static int
+ioctl_s_parm(struct v4l2_int_device *s, struct v4l2_streamparm *a)
+{
+	struct tvp514x_decoder *decoder = s->priv;
+	struct v4l2_fract *timeperframe;
+	enum tvp514x_std current_std;
+
+	if (a == NULL)
+		return -EINVAL;
+
+	if (a->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
+		return -EINVAL;	/* only capture is supported */
+
+	timeperframe = &a->parm.capture.timeperframe;
+
+	/* get the current standard */
+	current_std = tvp514x_get_current_std(decoder);
+	decoder->current_std = current_std;
+
+	*timeperframe =
+	    decoder->std_list[current_std].standard.frameperiod;
+
+	return 0;
+}
+
+/**
+ * ioctl_g_ifparm - V4L2 decoder interface handler for vidioc_int_g_ifparm_num
+ * @s: pointer to standard V4L2 device structure
+ * @p: pointer to standard V4L2 vidioc_int_g_ifparm_num ioctl structure
+ *
+ * Gets slave interface parameters.
+ * Calculates the required xclk value to support the requested
+ * clock parameters in p. This value is returned in the p
+ * parameter.
+ */
+static int ioctl_g_ifparm(struct v4l2_int_device *s, struct v4l2_ifparm *p)
+{
+	struct tvp514x_decoder *decoder = s->priv;
+	int rval;
+
+	if (p == NULL)
+		return -EINVAL;
+
+	if (NULL == decoder->pdata->ifparm)
+		return -EINVAL;
+
+	rval = decoder->pdata->ifparm(p);
+	if (rval) {
+		DBG(&decoder->client->dev, 1, "error. Err[%d]\n", rval);
+		return rval;
+	}
+
+	p->u.bt656.clock_curr = TVP514X_XCLK_BT656;
+
+	return 0;
+}
+
+/**
+ * ioctl_g_priv - V4L2 decoder interface handler for vidioc_int_g_priv_num
+ * @s: pointer to standard V4L2 device structure
+ * @p: void pointer to hold decoder's private data address
+ *
+ * Returns device's (decoder's) private data area address in p parameter
+ */
+static int ioctl_g_priv(struct v4l2_int_device *s, void *p)
+{
+	struct tvp514x_decoder *decoder = s->priv;
+
+	if (NULL == decoder->pdata->priv_data_set)
+		return -EINVAL;
+
+	return decoder->pdata->priv_data_set(p);
+}
+
+/**
+ * ioctl_s_power - V4L2 decoder interface handler for vidioc_int_s_power_num
+ * @s: pointer to standard V4L2 device structure
+ * @on: power state to which device is to be set
+ *
+ * Sets devices power state to requrested state, if possible.
+ */
+static int ioctl_s_power(struct v4l2_int_device *s, enum v4l2_power on)
+{
+	struct tvp514x_decoder *decoder = s->priv;
+	int err = 0;
+
+	switch (on) {
+	case V4L2_POWER_OFF:
+		/* Power Down Sequence */
+		err =
+		    tvp514x_write_reg(decoder->client, REG_OPERATION_MODE,
+					0x01);
+		/* Disable mux for TVP5146/47 decoder data path */
+		if (decoder->pdata->power_set)
+			err |= decoder->pdata->power_set(on);
+		break;
+
+	case V4L2_POWER_STANDBY:
+		if (decoder->pdata->power_set)
+			err = decoder->pdata->power_set(on);
+		break;
+
+	case V4L2_POWER_ON:
+		/* Enable mux for TVP5146/47 decoder data path */
+		if (decoder->pdata->power_set)
+			err = decoder->pdata->power_set(on);
+
+		/* Power Up Sequence */
+		err |=
+		    tvp514x_write_reg(decoder->client, REG_OPERATION_MODE,
+					0x01);
+		err |=
+		    tvp514x_write_reg(decoder->client, REG_OPERATION_MODE,
+					0x00);
+
+		/* Detect the sensor is not already detected */
+		if (decoder->state == STATE_NOT_DETECTED) {
+			err |= tvp514x_detect(decoder);
+			if (err < 0) {
+				DBG(&decoder->client->dev, 1,
+					"Unable to detect decoder\n");
+				return err;
+			}
+			DBG(&decoder->client->dev, 2,
+				 "chip version 0x%.2x detected\n",
+				 decoder->ver);
+		}
+		break;
+
+	case V4L2_POWER_RESUME:
+		if (decoder->pdata->power_set)
+			err = decoder->pdata->power_set(on);
+		if (decoder->state == STATE_DETECTED)
+			err |= tvp514x_configure(decoder);
+		break;
+
+	default:
+		err = -ENODEV;
+		break;
+	}
+
+	return err;
+}
+
+/**
+ * ioctl_init - V4L2 decoder interface handler for VIDIOC_INT_INIT
+ * @s: pointer to standard V4L2 device structure
+ *
+ * Initialize the decoder device (calls tvp514x_configure())
+ */
+static int ioctl_init(struct v4l2_int_device *s)
+{
+	struct tvp514x_decoder *decoder = s->priv;
+
+	/* Set default standard to auto */
+	tvp514x_reg_list[REG_VIDEO_STD].val =
+	    VIDEO_STD_AUTO_SWITCH_BIT;
+
+	return tvp514x_configure(decoder);
+}
+
+/**
+ * ioctl_dev_exit - V4L2 decoder interface handler for vidioc_int_dev_exit_num
+ * @s: pointer to standard V4L2 device structure
+ *
+ * Delinitialise the dev. at slave detach. The complement of ioctl_dev_init.
+ */
+static int ioctl_dev_exit(struct v4l2_int_device *s)
+{
+	return 0;
+}
+
+/**
+ * ioctl_dev_init - V4L2 decoder interface handler for vidioc_int_dev_init_num
+ * @s: pointer to standard V4L2 device structure
+ *
+ * Initialise the device when slave attaches to the master. Returns 0 if
+ * TVP5146/47 device could be found, otherwise returns appropriate error.
+ */
+static int ioctl_dev_init(struct v4l2_int_device *s)
+{
+	struct tvp514x_decoder *decoder = s->priv;
+	int err;
+
+	err = tvp514x_detect(decoder);
+	if (err < 0) {
+		DBG(&decoder->client->dev, 1,
+			"Unable to detect decoder\n");
+		return err;
+	}
+
+	DBG(&decoder->client->dev, 2,
+		 "chip version 0x%.2x detected\n", decoder->ver);
+
+	return 0;
+}
+
+static struct v4l2_int_ioctl_desc tvp514x_ioctl_desc[] = {
+	{vidioc_int_dev_init_num, (v4l2_int_ioctl_func*) ioctl_dev_init},
+	{vidioc_int_dev_exit_num, (v4l2_int_ioctl_func*) ioctl_dev_exit},
+	{vidioc_int_s_power_num, (v4l2_int_ioctl_func*) ioctl_s_power},
+	{vidioc_int_g_priv_num, (v4l2_int_ioctl_func*) ioctl_g_priv},
+	{vidioc_int_g_ifparm_num, (v4l2_int_ioctl_func*) ioctl_g_ifparm},
+	{vidioc_int_init_num, (v4l2_int_ioctl_func*) ioctl_init},
+	{vidioc_int_enum_fmt_cap_num,
+	 (v4l2_int_ioctl_func *) ioctl_enum_fmt_cap},
+	{vidioc_int_try_fmt_cap_num,
+	 (v4l2_int_ioctl_func *) ioctl_try_fmt_cap},
+	{vidioc_int_g_fmt_cap_num,
+	 (v4l2_int_ioctl_func *) ioctl_g_fmt_cap},
+	{vidioc_int_s_fmt_cap_num,
+	 (v4l2_int_ioctl_func *) ioctl_s_fmt_cap},
+	{vidioc_int_g_parm_num, (v4l2_int_ioctl_func *) ioctl_g_parm},
+	{vidioc_int_s_parm_num, (v4l2_int_ioctl_func *) ioctl_s_parm},
+	{vidioc_int_queryctrl_num,
+	 (v4l2_int_ioctl_func *) ioctl_queryctrl},
+	{vidioc_int_g_ctrl_num, (v4l2_int_ioctl_func *) ioctl_g_ctrl},
+	{vidioc_int_s_ctrl_num, (v4l2_int_ioctl_func *) ioctl_s_ctrl},
+	{vidioc_int_querystd_num, (v4l2_int_ioctl_func *) ioctl_querystd},
+	{vidioc_int_s_std_num, (v4l2_int_ioctl_func *) ioctl_s_std},
+	{vidioc_int_enum_input_num,
+	 (v4l2_int_ioctl_func *) ioctl_enum_input},
+	{vidioc_int_g_input_num, (v4l2_int_ioctl_func *) ioctl_g_input},
+	{vidioc_int_s_input_num, (v4l2_int_ioctl_func *) ioctl_s_input},
+};
+
+static struct v4l2_int_slave tvp514x_slave = {
+	.ioctls = tvp514x_ioctl_desc,
+	.num_ioctls = ARRAY_SIZE(tvp514x_ioctl_desc),
+};
+
+static struct tvp514x_decoder tvp514x_dev = {
+	.state = STATE_NOT_DETECTED,
+
+	.num_fmts = TVP514X_NUM_FORMATS,
+	.fmt_list = tvp514x_fmt_list,
+
+	.pix = {		/* Default to NTSC 8-bit YUV 422 */
+		.width = NTSC_NUM_ACTIVE_PIXELS,
+		.height = NTSC_NUM_ACTIVE_LINES,
+		.pixelformat = V4L2_PIX_FMT_UYVY,
+		.field = V4L2_FIELD_INTERLACED,
+		.bytesperline = NTSC_NUM_ACTIVE_PIXELS * 2,
+		.sizeimage =
+		NTSC_NUM_ACTIVE_PIXELS * 2 * NTSC_NUM_ACTIVE_LINES,
+		.colorspace = V4L2_COLORSPACE_SMPTE170M,
+		},
+
+	.current_std = STD_NTSC_MJ,
+	.num_stds = TVP514X_NUM_STANDARDS,
+	.std_list = tvp514x_std_list,
+
+	.num_ctrls = TVP514X_NUM_CONTROLS,
+	.ctrl_list = tvp514x_ctrl_list,
+
+};
+
+static struct v4l2_int_device tvp514x_int_device = {
+	.module = THIS_MODULE,
+	.name = MODULE_NAME,
+	.priv = &tvp514x_dev,
+	.type = v4l2_int_type_slave,
+	.u = {
+	      .slave = &tvp514x_slave,
+	      },
+};
+
+/**
+ * tvp514x_probe - decoder driver i2c probe handler
+ * @client: i2c driver client device structure
+ *
+ * Register decoder as an i2c client device and V4L2
+ * device.
+ */
+static int
+tvp514x_probe(struct i2c_client *client, const struct i2c_device_id *id)
+{
+	struct tvp514x_decoder *decoder = &tvp514x_dev;
+	int err;
+
+	if (i2c_get_clientdata(client))
+		return -EBUSY;
+
+	decoder->pdata = client->dev.platform_data;
+	if (!decoder->pdata) {
+		DBG(&client->dev, 1, "No platform data\n!!");
+		return -ENODEV;
+	}
+	/*
+	 * Fetch platform specific data, and configure the
+	 * tvp514x_reg_list[] accordingly. Since this is one
+	 * time configuration, no need to preserve.
+	 */
+	decoder->inputidx = decoder->pdata->default_input;
+	tvp514x_reg_list[REG_OUTPUT_FORMATTER2].val |=
+			(decoder->pdata->clk_polarity << 1);
+	tvp514x_reg_list[REG_OUTPUT_FORMATTER1].val |=
+			decoder->pdata->fmt;
+	tvp514x_reg_list[REG_SYNC_CONTROL].val |=
+			((decoder->pdata->hs_polarity << 2) |
+			(decoder->pdata->vs_polarity << 3));
+
+	/* Attach to Master */
+	strcpy(tvp514x_int_device.u.slave->attach_to, decoder->pdata->master);
+	decoder->v4l2_int_device = &tvp514x_int_device;
+	decoder->client = client;
+	i2c_set_clientdata(client, decoder);
+
+	/* Register with V4L2 layer as slave device */
+	err = v4l2_int_device_register(decoder->v4l2_int_device);
+	if (err) {
+		i2c_set_clientdata(client, NULL);
+		DBG(&client->dev, 1,
+			"Unable to register to v4l2. Err[%d]\n", err);
+
+	} else
+		DBG(&client->dev, 3, "Registered to v4l2 master %s!!\n",
+				decoder->pdata->master);
+
+	return 0;
+}
+
+/**
+ * tvp514x_remove - decoder driver i2c remove handler
+ * @client: i2c driver client device structure
+ *
+ * Unregister decoder as an i2c client device and V4L2
+ * device. Complement of tvp514x_probe().
+ */
+static int __exit tvp514x_remove(struct i2c_client *client)
+{
+	struct tvp514x_decoder *decoder = i2c_get_clientdata(client);
+
+	if (!client->adapter)
+		return -ENODEV;	/* our client isn't attached */
+
+	v4l2_int_device_unregister(decoder->v4l2_int_device);
+	i2c_set_clientdata(client, NULL);
+
+	return 0;
+}
+
+static const struct i2c_device_id tvp514x_id[] = {
+	{"tvp5146", 0},
+	{"tvp5147", 0},
+	{},
+};
+
+MODULE_DEVICE_TABLE(i2c, tvp514x_id);
+
+static struct i2c_driver tvp514x_i2c_driver = {
+	.driver = {
+		   .name = MODULE_NAME,
+		   .owner = THIS_MODULE,
+		   },
+	.probe = tvp514x_probe,
+	.remove = __exit_p(tvp514x_remove),
+	.id_table = tvp514x_id,
+};
+
+/**
+ * tvp514x_init
+ *
+ * Module init function
+ */
+static int __init tvp514x_init(void)
+{
+	int err;
+
+	err = i2c_add_driver(&tvp514x_i2c_driver);
+	if (err) {
+		printk(KERN_ERR "Failed to register " MODULE_NAME ".\n");
+		return err;
+	}
+	return 0;
+}
+
+/**
+ * tvp514x_cleanup
+ *
+ * Module exit function
+ */
+static void __exit tvp514x_cleanup(void)
+{
+	i2c_del_driver(&tvp514x_i2c_driver);
+}
+
+module_init(tvp514x_init);
+module_exit(tvp514x_cleanup);
+
+MODULE_AUTHOR("Texas Instruments");
+MODULE_DESCRIPTION("TVP514X linux decoder driver");
+MODULE_LICENSE("GPL");
diff --git a/include/media/tvp514x.h b/include/media/tvp514x.h
new file mode 100644
index 0000000..5a4e2d5
--- /dev/null
+++ b/include/media/tvp514x.h
@@ -0,0 +1,461 @@
+/*
+ * drivers/media/video/tvp514x.h
+ *
+ * Copyright (C) 2008 Texas Instruments Inc
+ *
+ * This package is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#ifndef _TVP514X_H
+#define _TVP514X_H
+
+/*
+ * TVP5146/47 registers
+ */
+#define REG_INPUT_SEL			(0x00)
+#define REG_AFE_GAIN_CTRL		(0x01)
+#define REG_VIDEO_STD			(0x02)
+#define REG_OPERATION_MODE		(0x03)
+#define REG_AUTOSWITCH_MASK		(0x04)
+
+#define REG_COLOR_KILLER		(0x05)
+#define REG_LUMA_CONTROL1		(0x06)
+#define REG_LUMA_CONTROL2		(0x07)
+#define REG_LUMA_CONTROL3		(0x08)
+
+#define REG_BRIGHTNESS			(0x09)
+#define REG_CONTRAST			(0x0A)
+#define REG_SATURATION			(0x0B)
+#define REG_HUE				(0x0C)
+
+#define REG_CHROMA_CONTROL1		(0x0D)
+#define REG_CHROMA_CONTROL2		(0x0E)
+
+/* 0x0F Reserved */
+
+#define REG_COMP_PR_SATURATION		(0x10)
+#define REG_COMP_Y_CONTRAST		(0x11)
+#define REG_COMP_PB_SATURATION		(0x12)
+
+/* 0x13 Reserved */
+
+#define REG_COMP_Y_BRIGHTNESS		(0x14)
+
+/* 0x15 Reserved */
+
+#define REG_AVID_START_PIXEL_LSB	(0x16)
+#define REG_AVID_START_PIXEL_MSB	(0x17)
+#define REG_AVID_STOP_PIXEL_LSB		(0x18)
+#define REG_AVID_STOP_PIXEL_MSB		(0x19)
+
+#define REG_HSYNC_START_PIXEL_LSB	(0x1A)
+#define REG_HSYNC_START_PIXEL_MSB	(0x1B)
+#define REG_HSYNC_STOP_PIXEL_LSB	(0x1C)
+#define REG_HSYNC_STOP_PIXEL_MSB	(0x1D)
+
+#define REG_VSYNC_START_LINE_LSB	(0x1E)
+#define REG_VSYNC_START_LINE_MSB	(0x1F)
+#define REG_VSYNC_STOP_LINE_LSB		(0x20)
+#define REG_VSYNC_STOP_LINE_MSB		(0x21)
+
+#define REG_VBLK_START_LINE_LSB		(0x22)
+#define REG_VBLK_START_LINE_MSB		(0x23)
+#define REG_VBLK_STOP_LINE_LSB		(0x24)
+#define REG_VBLK_STOP_LINE_MSB		(0x25)
+
+/* 0x26 - 0x27 Reserved */
+
+#define REG_FAST_SWTICH_CONTROL		(0x28)
+
+/* 0x29 Reserved */
+
+#define REG_FAST_SWTICH_SCART_DELAY	(0x2A)
+
+/* 0x2B Reserved */
+
+#define REG_SCART_DELAY			(0x2C)
+#define REG_CTI_DELAY			(0x2D)
+#define REG_CTI_CONTROL			(0x2E)
+
+/* 0x2F - 0x31 Reserved */
+
+#define REG_SYNC_CONTROL		(0x32)
+#define REG_OUTPUT_FORMATTER1		(0x33)
+#define REG_OUTPUT_FORMATTER2		(0x34)
+#define REG_OUTPUT_FORMATTER3		(0x35)
+#define REG_OUTPUT_FORMATTER4		(0x36)
+#define REG_OUTPUT_FORMATTER5		(0x37)
+#define REG_OUTPUT_FORMATTER6		(0x38)
+#define REG_CLEAR_LOST_LOCK		(0x39)
+
+#define REG_STATUS1			(0x3A)
+#define REG_STATUS2			(0x3B)
+
+#define REG_AGC_GAIN_STATUS_LSB		(0x3C)
+#define REG_AGC_GAIN_STATUS_MSB		(0x3D)
+
+/* 0x3E Reserved */
+
+#define REG_VIDEO_STD_STATUS		(0x3F)
+#define REG_GPIO_INPUT1			(0x40)
+#define REG_GPIO_INPUT2			(0x41)
+
+/* 0x42 - 0x45 Reserved */
+
+#define REG_AFE_COARSE_GAIN_CH1		(0x46)
+#define REG_AFE_COARSE_GAIN_CH2		(0x47)
+#define REG_AFE_COARSE_GAIN_CH3		(0x48)
+#define REG_AFE_COARSE_GAIN_CH4		(0x49)
+
+#define REG_AFE_FINE_GAIN_PB_B_LSB	(0x4A)
+#define REG_AFE_FINE_GAIN_PB_B_MSB	(0x4B)
+#define REG_AFE_FINE_GAIN_Y_G_CHROMA_LSB	(0x4C)
+#define REG_AFE_FINE_GAIN_Y_G_CHROMA_MSB	(0x4D)
+#define REG_AFE_FINE_GAIN_PR_R_LSB	(0x4E)
+#define REG_AFE_FINE_GAIN_PR_R_MSB	(0x4F)
+#define REG_AFE_FINE_GAIN_CVBS_LUMA_LSB	(0x50)
+#define REG_AFE_FINE_GAIN_CVBS_LUMA_MSB	(0x51)
+
+/* 0x52 - 0x68 Reserved */
+
+#define REG_FBIT_VBIT_CONTROL1		(0x69)
+
+/* 0x6A - 0x6B Reserved */
+
+#define REG_BACKEND_AGC_CONTROL		(0x6C)
+
+/* 0x6D - 0x6E Reserved */
+
+#define REG_AGC_DECREMENT_SPEED_CONTROL	(0x6F)
+#define REG_ROM_VERSION			(0x70)
+
+/* 0x71 - 0x73 Reserved */
+
+#define REG_AGC_WHITE_PEAK_PROCESSING	(0x74)
+#define REG_FBIT_VBIT_CONTROL2		(0x75)
+#define REG_VCR_TRICK_MODE_CONTROL	(0x76)
+#define REG_HORIZONTAL_SHAKE_INCREMENT	(0x77)
+#define REG_AGC_INCREMENT_SPEED		(0x78)
+#define REG_AGC_INCREMENT_DELAY		(0x79)
+
+/* 0x7A - 0x7F Reserved */
+
+#define REG_CHIP_ID_MSB			(0x80)
+#define REG_CHIP_ID_LSB			(0x81)
+
+/* 0x82 Reserved */
+
+#define REG_CPLL_SPEED_CONTROL		(0x83)
+
+/* 0x84 - 0x96 Reserved */
+
+#define REG_STATUS_REQUEST		(0x97)
+
+/* 0x98 - 0x99 Reserved */
+
+#define REG_VERTICAL_LINE_COUNT_LSB	(0x9A)
+#define REG_VERTICAL_LINE_COUNT_MSB	(0x9B)
+
+/* 0x9C - 0x9D Reserved */
+
+#define REG_AGC_DECREMENT_DELAY		(0x9E)
+
+/* 0x9F - 0xB0 Reserved */
+
+#define REG_VDP_TTX_FILTER_1_MASK1	(0xB1)
+#define REG_VDP_TTX_FILTER_1_MASK2	(0xB2)
+#define REG_VDP_TTX_FILTER_1_MASK3	(0xB3)
+#define REG_VDP_TTX_FILTER_1_MASK4	(0xB4)
+#define REG_VDP_TTX_FILTER_1_MASK5	(0xB5)
+#define REG_VDP_TTX_FILTER_2_MASK1	(0xB6)
+#define REG_VDP_TTX_FILTER_2_MASK2	(0xB7)
+#define REG_VDP_TTX_FILTER_2_MASK3	(0xB8)
+#define REG_VDP_TTX_FILTER_2_MASK4	(0xB9)
+#define REG_VDP_TTX_FILTER_2_MASK5	(0xBA)
+#define REG_VDP_TTX_FILTER_CONTROL	(0xBB)
+#define REG_VDP_FIFO_WORD_COUNT		(0xBC)
+#define REG_VDP_FIFO_INTERRUPT_THRLD	(0xBD)
+
+/* 0xBE Reserved */
+
+#define REG_VDP_FIFO_RESET		(0xBF)
+#define REG_VDP_FIFO_OUTPUT_CONTROL	(0xC0)
+#define REG_VDP_LINE_NUMBER_INTERRUPT	(0xC1)
+#define REG_VDP_PIXEL_ALIGNMENT_LSB	(0xC2)
+#define REG_VDP_PIXEL_ALIGNMENT_MSB	(0xC3)
+
+/* 0xC4 - 0xD5 Reserved */
+
+#define REG_VDP_LINE_START		(0xD6)
+#define REG_VDP_LINE_STOP		(0xD7)
+#define REG_VDP_GLOBAL_LINE_MODE	(0xD8)
+#define REG_VDP_FULL_FIELD_ENABLE	(0xD9)
+#define REG_VDP_FULL_FIELD_MODE		(0xDA)
+
+/* 0xDB - 0xDF Reserved */
+
+#define REG_VBUS_DATA_ACCESS_NO_VBUS_ADDR_INCR	(0xE0)
+#define REG_VBUS_DATA_ACCESS_VBUS_ADDR_INCR	(0xE1)
+#define REG_FIFO_READ_DATA			(0xE2)
+
+/* 0xE3 - 0xE7 Reserved */
+
+#define REG_VBUS_ADDRESS_ACCESS1	(0xE8)
+#define REG_VBUS_ADDRESS_ACCESS2	(0xE9)
+#define REG_VBUS_ADDRESS_ACCESS3	(0xEA)
+
+/* 0xEB - 0xEF Reserved */
+
+#define REG_INTERRUPT_RAW_STATUS0	(0xF0)
+#define REG_INTERRUPT_RAW_STATUS1	(0xF1)
+#define REG_INTERRUPT_STATUS0		(0xF2)
+#define REG_INTERRUPT_STATUS1		(0xF3)
+#define REG_INTERRUPT_MASK0		(0xF4)
+#define REG_INTERRUPT_MASK1		(0xF5)
+#define REG_INTERRUPT_CLEAR0		(0xF6)
+#define REG_INTERRUPT_CLEAR1		(0xF7)
+
+/* 0xF8 - 0xFF Reserved */
+
+/*
+ * Mask and bit definitions of TVP5146/47 registers
+ */
+/* The ID values we are looking for */
+#define TVP514X_CHIP_ID_MSB		(0x51)
+#define TVP5146_CHIP_ID_LSB		(0x46)
+#define TVP5147_CHIP_ID_LSB		(0x47)
+
+#define VIDEO_STD_MASK			(0x07)
+#define VIDEO_STD_AUTO_SWITCH_BIT	(0x00)
+#define VIDEO_STD_NTSC_MJ_BIT		(0x01)
+#define VIDEO_STD_PAL_BDGHIN_BIT	(0x02)
+#define VIDEO_STD_PAL_M_BIT		(0x03)
+#define VIDEO_STD_PAL_COMBINATION_N_BIT	(0x04)
+#define VIDEO_STD_NTSC_4_43_BIT		(0x05)
+#define VIDEO_STD_SECAM_BIT		(0x06)
+#define VIDEO_STD_PAL_60_BIT		(0x07)
+
+/*
+ * Status bit
+ */
+#define STATUS_TV_VCR_BIT		(1<<0)
+#define STATUS_HORZ_SYNC_LOCK_BIT	(1<<1)
+#define STATUS_VIRT_SYNC_LOCK_BIT	(1<<2)
+#define STATUS_CLR_SUBCAR_LOCK_BIT	(1<<3)
+#define STATUS_LOST_LOCK_DETECT_BIT	(1<<4)
+#define STATUS_FEILD_RATE_BIT		(1<<5)
+#define STATUS_LINE_ALTERNATING_BIT	(1<<6)
+#define STATUS_PEAK_WHITE_DETECT_BIT	(1<<7)
+/*
+ * Other macros
+ */
+#define TVP514X_MODULE_NAME		"tvp514x"
+#define TVP514X_I2C_DELAY		(3)
+#define I2C_RETRY_COUNT			(5)
+#define LOCK_RETRY_COUNT		(3)
+#define LOCK_RETRY_DELAY		(200)
+
+#define TOK_WRITE			(0)	/* token for write operation */
+#define TOK_TERM			(1)	/* terminating token */
+#define TOK_DELAY			(2)	/* delay token for reg list */
+#define TOK_SKIP			(3)	/* token to skip a register */
+
+#define TVP514X_XCLK_BT656		(27000000)
+
+/* Number of pixels and number of lines per frame for different standards */
+#define NTSC_NUM_ACTIVE_PIXELS		(720)
+#define NTSC_NUM_ACTIVE_LINES		(480)
+#define PAL_NUM_ACTIVE_PIXELS		(720)
+#define PAL_NUM_ACTIVE_LINES		(576)
+
+/**
+ * enum tvp514x_std - enum for supported standards
+ */
+enum tvp514x_std {
+	STD_NTSC_MJ = 0,
+	STD_PAL_BDGHIN,
+	STD_INVALID
+};
+
+/**
+ * enum tvp514x_state - enum for different decoder states
+ */
+enum tvp514x_state {
+	STATE_NOT_DETECTED,
+	STATE_DETECTED
+};
+
+enum tvp514x_input {
+	/*
+	 * CVBS input selection
+	 */
+	INPUT_CVBS_VI1A = 0x0,
+	INPUT_CVBS_VI1B,
+	INPUT_CVBS_VI1C,
+	INPUT_CVBS_VI2A = 0x04,
+	INPUT_CVBS_VI2B,
+	INPUT_CVBS_VI2C,
+	INPUT_CVBS_VI3A = 0x08,
+	INPUT_CVBS_VI3B,
+	INPUT_CVBS_VI3C,
+	INPUT_CVBS_VI4A = 0x0C,
+	/*
+	 * S-Video input selection
+	 */
+	INPUT_SVIDEO_VI2A_VI1A = 0x44,
+	INPUT_SVIDEO_VI2B_VI1B,
+	INPUT_SVIDEO_VI2C_VI1C,
+	INPUT_SVIDEO_VI2A_VI3A = 0x54,
+	INPUT_SVIDEO_VI2B_VI3B,
+	INPUT_SVIDEO_VI2C_VI3C,
+	INPUT_SVIDEO_VI4A_VI1A = 0x4C,
+	INPUT_SVIDEO_VI4A_VI1B,
+	INPUT_SVIDEO_VI4A_VI1C,
+	INPUT_SVIDEO_VI4A_VI3A = 0x5C,
+	INPUT_SVIDEO_VI4A_VI3B,
+	INPUT_SVIDEO_VI4A_VI3C
+
+	/* Need to add entries for
+	 * RGB, YPbPr and SCART.
+	 */
+};
+
+enum tvp514x_output_fmt {
+	OUTPUT_10BIT_422_EMBEDDED_SYNC = 0,
+	OUTPUT_20BIT_422_SEPERATE_SYNC,
+	OUTPUT_10BIT_422_SEPERATE_SYNC = 3,
+	OUTPUT_INVALID
+};
+/**
+ * struct tvp514x_reg - Structure for TVP5146/47 register initialization values
+ * @token - Token: TOK_WRITE, TOK_TERM etc..
+ * @reg - Register offset
+ * @val - Register Value for TOK_WRITE or delay in ms for TOK_DELAY
+ */
+struct tvp514x_reg {
+	u8 token;
+	u8 reg;
+	u32 val;
+};
+
+/**
+ * struct tvp514x_std_info - Structure to store standard informations
+ * @width: Line width in pixels
+ * @height:Number of active lines
+ * @video_std: Value to write in REG_VIDEO_STD register
+ * @standard: v4l2 standard structure information
+ */
+struct tvp514x_std_info {
+	unsigned long width;
+	unsigned long height;
+	u8 video_std;
+	struct v4l2_standard standard;
+};
+
+/**
+ * struct tvp514x_ctrl_info - Information regarding supported controls
+ * @reg_address: Register offset of control register
+ * @query_ctrl: v4l2 query control information
+ */
+struct tvp514x_ctrl_info {
+	u8 reg_address;
+	struct v4l2_queryctrl query_ctrl;
+};
+
+/**
+ * struct tvp514x_input_info - Information regarding supported inputs
+ * @input_sel: Input select register
+ * @lock_mask: lock mask - depends on Svideo/CVBS
+ * @input: v4l2 input information
+ */
+struct tvp514x_input_info {
+	enum tvp514x_input input_sel;
+	struct v4l2_input input;
+};
+
+/**
+ * struct tvp514x_platform_data - Platform data values and access functions
+ * @power_set: Power state access function, zero is off, non-zero is on.
+ * @ifparm: Interface parameters access function
+ * @priv_data_set: Device private data (pointer) access function
+ * @reg_list: The board dependent driver should fill the default value for
+ *            required registers depending on board layout. The TVP5146/47
+ *            driver will update this register list for the registers
+ *            whose values should be maintained across open()/close() like
+ *            setting brightness as defined in V4L2.
+ *            The register list should be in the same order as defined in
+ *            TVP5146/47 datasheet including reserved registers. As of now
+ *            the driver expects the size of this list to be a minimum of
+ *            57 + 1 (upto regsiter REG_CLEAR_LOST_LOCK).
+ *            The last member should be of the list should be
+ *            {TOK_TERM, 0, 0} to indicate the end of register list.
+ * @num_inputs: Number of input connection in board
+ * @input_list: Input information list for num_inputs
+ */
+struct tvp514x_platform_data {
+	char *master;
+	int (*power_set) (enum v4l2_power on);
+	int (*ifparm) (struct v4l2_ifparm *p);
+	int (*priv_data_set) (void *);
+	/* Input params */
+	int num_inputs;
+	const struct tvp514x_input_info *input_list;
+	int default_input;
+	/* Interface control params */
+	enum tvp514x_output_fmt fmt;
+	bool clk_polarity;
+	bool hs_polarity;
+	bool vs_polarity;
+};
+
+/**
+ * struct tvp514x_decoded - TVP5146/47 decoder object
+ * @v4l2_int_device: Slave handle
+ * @pdata: Board specific
+ * @client: I2C client data
+ * @ver: Chip version
+ * @state: TVP5146/47 decoder state - detected or not-detected
+ * @pix: Current pixel format
+ * @num_fmts: Number of formats
+ * @fmt_list: Format list
+ * @current_std: Current standard
+ * @num_stds: Number of standards
+ * @std_list: Standards list
+ * @num_ctrls: Number of controls
+ * @ctrl_list: Control list
+ */
+struct tvp514x_decoder {
+	struct v4l2_int_device *v4l2_int_device;
+	const struct tvp514x_platform_data *pdata;
+	struct i2c_client *client;
+
+	int ver;
+	enum tvp514x_state state;
+
+	struct v4l2_pix_format pix;
+	int num_fmts;
+	const struct v4l2_fmtdesc *fmt_list;
+
+	enum tvp514x_std current_std;
+	int num_stds;
+	struct tvp514x_std_info *std_list;
+
+	int num_ctrls;
+	const struct tvp514x_ctrl_info *ctrl_list;
+
+	int inputidx;
+};
+
+#endif				/* ifndef _TVP514X_H */
--
1.5.6

--
video4linux-list mailing list
Unsubscribe mailto:video4linux-list-request@redhat.com?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list

^ permalink raw reply related	[flat|nested] 263+ messages in thread

* [PATCH 2/2] TVP514x Driver with Review comments fixed
@ 2008-11-26 17:05   ` hvaibhav
  0 siblings, 0 replies; 263+ messages in thread
From: hvaibhav @ 2008-11-26 17:05 UTC (permalink / raw)
  To: video4linux-list
  Cc: linux-omap, davinci-linux-open-source-bounces, Vaibhav Hiremath,
	Brijesh Jadav, Hardik Shah, Manjunath Hadli, R Sivaraj,
	Karicheri Muralidharan

From: Vaibhav Hiremath <hvaibhav@ti.com>

I have fixed most of the review comments received so far.
Here are the details:

FIXES
    Wrong use of CONFIG_VIDEO_ADV_DEBUG option:
        Implemented module parameter based approach for debugging.

    Bridge driver and access to TVP registers:
        The bridge driver will now provide only neccessary information
        depending on platform/board/interface. In case of TVP5146, we do
        require clk_polarity, input, number of input, HS/VS polarity, etc..
        which is interface dependent.
        All register access and values are limited to TVP driver.

    V4L2-int framework:
        The new sub-device framework is a new development and will take its
        own time to mature and stabilize. The implementation is rightly
        placed in a different branch for the same reason.

        I beleive till this time, we should move ahead with current framework.
	This patch provides base for V4L2-int capture-master driver and patch
	for the same will be posted in couple of weeks. we are in the process
	of code clean-up.

	It would be good if we can get this patch into the current codebase
	till the 'sub-device' framework stabilizes. The migration can be
	planned immediately.

    i2c table:
        Specified the name of chip.

    Code cleanup:
        Multiple changes as suggested.

PENDING (TO DO)

    I2C Legacy framework support:
        Still no change for Legacy support (Hans agreed on this).
        Can be added while we move to sub-device framework.

    New sub-device framework support:
        Will be taken up immediately.

Signed-off-by: Brijesh Jadav <brijesh.j@ti.com>
Signed-off-by: Hardik Shah <hardik.shah@ti.com>
Signed-off-by: Manjunath Hadli <mrh@ti.com>
Signed-off-by: R Sivaraj <sivaraj@ti.com>
Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
Signed-off-by: Karicheri Muralidharan <m-karicheri2@ti.com>
---
 drivers/media/video/Kconfig   |   11 +
 drivers/media/video/Makefile  |    1 +
 drivers/media/video/tvp514x.c | 1551 +++++++++++++++++++++++++++++++++++++++++
 include/media/tvp514x.h       |  461 ++++++++++++
 4 files changed, 2024 insertions(+), 0 deletions(-)
 create mode 100644 drivers/media/video/tvp514x.c
 create mode 100644 include/media/tvp514x.h

diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig
index 47102c2..2e5dc3e 100644
--- a/drivers/media/video/Kconfig
+++ b/drivers/media/video/Kconfig
@@ -361,6 +361,17 @@ config VIDEO_SAA7191
 	  To compile this driver as a module, choose M here: the
 	  module will be called saa7191.

+config VIDEO_TVP514X
+	tristate "Texas Instruments TVP514x video decoder"
+	depends on VIDEO_V4L2 && I2C
+	---help---
+	  This is a Video4Linux2 sensor-level driver for the TI TVP5146/47
+	  decoder. It is currently working with the TI OMAP3 camera
+	  controller.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called tvp514x.
+
 config VIDEO_TVP5150
 	tristate "Texas Instruments TVP5150 video decoder"
 	depends on VIDEO_V4L2 && I2C
diff --git a/drivers/media/video/Makefile b/drivers/media/video/Makefile
index 16962f3..cdbbf38 100644
--- a/drivers/media/video/Makefile
+++ b/drivers/media/video/Makefile
@@ -66,6 +66,7 @@ obj-$(CONFIG_VIDEO_CX88) += cx88/
 obj-$(CONFIG_VIDEO_EM28XX) += em28xx/
 obj-$(CONFIG_VIDEO_USBVISION) += usbvision/
 obj-$(CONFIG_VIDEO_TVP5150) += tvp5150.o
+obj-$(CONFIG_VIDEO_TVP514X) += tvp514x.o
 obj-$(CONFIG_VIDEO_PVRUSB2) += pvrusb2/
 obj-$(CONFIG_VIDEO_MSP3400) += msp3400.o
 obj-$(CONFIG_VIDEO_CS5345) += cs5345.o
diff --git a/drivers/media/video/tvp514x.c b/drivers/media/video/tvp514x.c
new file mode 100644
index 0000000..187a063
--- /dev/null
+++ b/drivers/media/video/tvp514x.c
@@ -0,0 +1,1551 @@
+/*
+ * drivers/media/video/tvp514x.c
+ *
+ * TI TVP5146/47 decoder driver
+ *
+ * Copyright (C) 2008 Texas Instruments Inc
+ *
+ * Contributors:
+ *     Brijesh R Jadav <brijesh.j@ti.com>
+ *     Hardik Shah <hardik.shah@ti.com>
+ *     Manjunath Hadli <mrh@ti.com>
+ *     Sivaraj R <sivaraj@ti.com>
+ *     Vaibhav Hiremath <hvaibhav@ti.com>
+ *
+ * This package is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#include <linux/i2c.h>
+#include <linux/delay.h>
+#include <linux/videodev2.h>
+#include <media/v4l2-int-device.h>
+#include <media/tvp514x.h>
+
+#define MODULE_NAME	TVP514X_MODULE_NAME
+
+/* Debug functions */
+#ifdef TVP514X_DEBUG
+static unsigned short debug = 3;
+module_param(debug, ushort, 0644);
+MODULE_PARM_DESC(debug,
+		"\n<n> Debugging information level, from 0 to 3:"
+		"\n0 = none (use carefully)"
+		"\n1 = critical errors"
+		"\n2 = significant informations"
+		"\n3 = more verbose messages"
+		"\nLevel 3 is useful for testing only, when only "
+		"one device is used."
+		"\nDefault value is "__MODULE_STRING(2)"."
+		"\n");
+
+#define DBG(dev, level, fmt, args...)                                    \
+	do {                                                             \
+		if (debug >= (level)) {                                  \
+			if ((level) == 1)                                \
+				dev_err(dev, fmt "\n", ## args);         \
+			else if ((level) == 2)                           \
+				dev_info(dev, fmt "\n", ## args);        \
+			else if ((level) >= 3)                           \
+				dev_info(dev, "[%s:%s:%d] " fmt "\n",    \
+				__FILE__, __func__, __LINE__ , ## args); \
+		}                                                        \
+	} while (0)
+
+#define dump_reg(client, reg, val)					\
+	do {								\
+		tvp514x_read_reg(client, reg, &val);			\
+		dev_dbg(&(client)->dev, "Reg(0x%.2X): 0x%.2X\n", reg, val); \
+	} while (0)
+
+#else
+#define DBG(dev, level, fmt, args...) do {; } while (0)
+#endif				/* #ifdef TVP514X_DEBUG */
+
+/* TVP514x default register values */
+static struct tvp514x_reg tvp514x_reg_list[] = {
+	{TOK_WRITE, REG_INPUT_SEL, 0x05},	/* Composite selected */
+	{TOK_WRITE, REG_AFE_GAIN_CTRL, 0x0F},
+	{TOK_WRITE, REG_VIDEO_STD, 0x00},	/* Auto mode */
+	{TOK_WRITE, REG_OPERATION_MODE, 0x00},
+	{TOK_SKIP, REG_AUTOSWITCH_MASK, 0x3F},
+	{TOK_WRITE, REG_COLOR_KILLER, 0x10},
+	{TOK_WRITE, REG_LUMA_CONTROL1, 0x00},
+	{TOK_WRITE, REG_LUMA_CONTROL2, 0x00},
+	{TOK_WRITE, REG_LUMA_CONTROL3, 0x02},
+	{TOK_WRITE, REG_BRIGHTNESS, 0x80},
+	{TOK_WRITE, REG_CONTRAST, 0x80},
+	{TOK_WRITE, REG_SATURATION, 0x80},
+	{TOK_WRITE, REG_HUE, 0x00},
+	{TOK_WRITE, REG_CHROMA_CONTROL1, 0x00},
+	{TOK_WRITE, REG_CHROMA_CONTROL2, 0x0E},
+	{TOK_SKIP, 0x0F, 0x00},	/* Reserved */
+	{TOK_WRITE, REG_COMP_PR_SATURATION, 0x80},
+	{TOK_WRITE, REG_COMP_Y_CONTRAST, 0x80},
+	{TOK_WRITE, REG_COMP_PB_SATURATION, 0x80},
+	{TOK_SKIP, 0x13, 0x00},	/* Reserved */
+	{TOK_WRITE, REG_COMP_Y_BRIGHTNESS, 0x80},
+	{TOK_SKIP, 0x15, 0x00},	/* Reserved */
+	{TOK_SKIP, REG_AVID_START_PIXEL_LSB, 0x55},	/* NTSC timing */
+	{TOK_SKIP, REG_AVID_START_PIXEL_MSB, 0x00},
+	{TOK_SKIP, REG_AVID_STOP_PIXEL_LSB, 0x25},
+	{TOK_SKIP, REG_AVID_STOP_PIXEL_MSB, 0x03},
+	{TOK_SKIP, REG_HSYNC_START_PIXEL_LSB, 0x00},	/* NTSC timing */
+	{TOK_SKIP, REG_HSYNC_START_PIXEL_MSB, 0x00},
+	{TOK_SKIP, REG_HSYNC_STOP_PIXEL_LSB, 0x40},
+	{TOK_SKIP, REG_HSYNC_STOP_PIXEL_MSB, 0x00},
+	{TOK_SKIP, REG_VSYNC_START_LINE_LSB, 0x04},	/* NTSC timing */
+	{TOK_SKIP, REG_VSYNC_START_LINE_MSB, 0x00},
+	{TOK_SKIP, REG_VSYNC_STOP_LINE_LSB, 0x07},
+	{TOK_SKIP, REG_VSYNC_STOP_LINE_MSB, 0x00},
+	{TOK_SKIP, REG_VBLK_START_LINE_LSB, 0x01},	/* NTSC timing */
+	{TOK_SKIP, REG_VBLK_START_LINE_MSB, 0x00},
+	{TOK_SKIP, REG_VBLK_STOP_LINE_LSB, 0x15},
+	{TOK_SKIP, REG_VBLK_STOP_LINE_MSB, 0x00},
+	{TOK_SKIP, 0x26, 0x00},	/* Reserved */
+	{TOK_SKIP, 0x27, 0x00},	/* Reserved */
+	{TOK_SKIP, REG_FAST_SWTICH_CONTROL, 0xCC},
+	{TOK_SKIP, 0x29, 0x00},	/* Reserved */
+	{TOK_SKIP, REG_FAST_SWTICH_SCART_DELAY, 0x00},
+	{TOK_SKIP, 0x2B, 0x00},	/* Reserved */
+	{TOK_SKIP, REG_SCART_DELAY, 0x00},
+	{TOK_SKIP, REG_CTI_DELAY, 0x00},
+	{TOK_SKIP, REG_CTI_CONTROL, 0x00},
+	{TOK_SKIP, 0x2F, 0x00},	/* Reserved */
+	{TOK_SKIP, 0x30, 0x00},	/* Reserved */
+	{TOK_SKIP, 0x31, 0x00},	/* Reserved */
+	{TOK_WRITE, REG_SYNC_CONTROL, 0x00},	/* HS, VS active high */
+	{TOK_WRITE, REG_OUTPUT_FORMATTER1, 0x00},	/* 10-bit BT.656 */
+	{TOK_WRITE, REG_OUTPUT_FORMATTER2, 0x11},	/* Enable clk & data */
+	{TOK_WRITE, REG_OUTPUT_FORMATTER3, 0xEE},	/* Enable AVID & FLD */
+	{TOK_WRITE, REG_OUTPUT_FORMATTER4, 0xAF},	/* Enable VS & HS */
+	{TOK_WRITE, REG_OUTPUT_FORMATTER5, 0xFF},
+	{TOK_WRITE, REG_OUTPUT_FORMATTER6, 0xFF},
+	{TOK_WRITE, REG_CLEAR_LOST_LOCK, 0x01},	/* Clear status */
+	{TOK_TERM, 0, 0},
+};
+
+/* List of image formats supported by TVP5146/47 decoder
+ * Currently we are using 8 bit mode only, but can be
+ * extended to 10/20 bit mode.
+ */
+static const struct v4l2_fmtdesc tvp514x_fmt_list[] = {
+	{
+	 .index = 0,
+	 .type = V4L2_BUF_TYPE_VIDEO_CAPTURE,
+	 .flags = 0,
+	 .description = "8-bit UYVY 4:2:2 Format",
+	 .pixelformat = V4L2_PIX_FMT_UYVY,
+	},
+};
+
+#define TVP514X_NUM_FORMATS		ARRAY_SIZE(tvp514x_fmt_list)
+
+/*
+ * Supported standards - These must be ordered according to enum tvp514x_std
+ * order.
+ * Currently supports two standards only, need to add support for rest of the
+ * modes, like SECAM, etc...
+ */
+static struct tvp514x_std_info tvp514x_std_list[] = {
+	{
+	 .width = NTSC_NUM_ACTIVE_PIXELS,
+	 .height = NTSC_NUM_ACTIVE_LINES,
+	 .video_std = VIDEO_STD_NTSC_MJ_BIT,
+	 .standard = {
+		      .index = 0,
+		      .id = V4L2_STD_NTSC,
+		      .name = "NTSC",
+		      .frameperiod = {1001, 30000},
+		      .framelines = 525
+		     },
+	}, {
+	 .width = PAL_NUM_ACTIVE_PIXELS,
+	 .height = PAL_NUM_ACTIVE_LINES,
+	 .video_std = VIDEO_STD_PAL_BDGHIN_BIT,
+	 .standard = {
+		      .index = 1,
+		      .id = V4L2_STD_PAL,
+		      .name = "PAL",
+		      .frameperiod = {1, 25},
+		      .framelines = 625
+		     },
+	},
+};
+
+#define TVP514X_NUM_STANDARDS		ARRAY_SIZE(tvp514x_std_list)
+
+/* Supported controls */
+static const struct tvp514x_ctrl_info tvp514x_ctrl_list[] = {
+	{
+	 .reg_address = REG_BRIGHTNESS,
+	 .query_ctrl = {
+			.id = V4L2_CID_BRIGHTNESS,
+			.name = "BRIGHTNESS",
+			.type = V4L2_CTRL_TYPE_INTEGER,
+			.minimum = 0,
+			.maximum = 255,
+			.step = 1,
+			.default_value = 128
+			},
+	}, {
+	 .reg_address = REG_CONTRAST,
+	 .query_ctrl = {
+			.id = V4L2_CID_CONTRAST,
+			.name = "CONTRAST",
+			.type = V4L2_CTRL_TYPE_INTEGER,
+			.minimum = 0,
+			.maximum = 255,
+			.step = 1,
+			.default_value = 128
+			},
+	}, {
+	 .reg_address = REG_SATURATION,
+	 .query_ctrl = {
+			.id = V4L2_CID_SATURATION,
+			.name = "SATURATION",
+			.type = V4L2_CTRL_TYPE_INTEGER,
+			.minimum = 0,
+			.maximum = 255,
+			.step = 1,
+			.default_value = 128
+			},
+	}, {
+	 .reg_address = REG_HUE,
+	 .query_ctrl = {
+			.id = V4L2_CID_HUE,
+			.name = "HUE",
+			.type = V4L2_CTRL_TYPE_INTEGER,
+			.minimum = -180,
+			.maximum = 180,
+			.step = 180,
+			.default_value = 0
+			},
+	}, {
+	 .reg_address = REG_AFE_GAIN_CTRL,
+	 .query_ctrl = {
+			.id = V4L2_CID_AUTOGAIN,
+			.name = "Automatic Gain Control",
+			.type = V4L2_CTRL_TYPE_BOOLEAN,
+			.minimum = 0,
+			.maximum = 1,
+			.step = 1,
+			.default_value = 1
+			},
+	 },
+};
+
+#define TVP514X_NUM_CONTROLS		ARRAY_SIZE(tvp514x_ctrl_list)
+
+/*
+ * Read a value from a register in an TVP5146/47 decoder device.
+ * The value is returned in 'val'.
+ * Returns zero if successful, or non-zero otherwise.
+ */
+static int tvp514x_read_reg(struct i2c_client *client, u8 reg, u8 *val)
+{
+	int err;
+	struct i2c_msg msg[2];
+	u8 data;
+
+	if (!client->adapter)
+		return -ENODEV;
+
+	/* [MSG1] fill the register address data */
+	data = reg;
+	msg[0].addr = client->addr;
+	msg[0].len = 1;
+	msg[0].flags = 0;
+	msg[0].buf = &data;
+
+	/* [MSG2] fill the data rx buffer */
+	msg[1].addr = client->addr;
+	msg[1].len = 1;		/* only 1 byte */
+	msg[1].flags = I2C_M_RD;	/* Read the register values */
+	msg[1].buf = val;
+	err = i2c_transfer(client->adapter, msg, 2);
+	if (err >= 0)
+		return 0;
+
+	DBG(&client->dev, 1,
+		"read from device 0x%.2x, offset 0x%.2x error %d\n",
+		client->addr, reg, err);
+
+	return err;
+}
+
+/*
+ * Write a value to a register in an TVP5146/47 decoder device.
+ * Returns zero if successful, or non-zero otherwise.
+ */
+static int tvp514x_write_reg(struct i2c_client *client, u8 reg, u8 val)
+{
+	int err;
+	int retry = 0;
+	struct i2c_msg msg[1];
+	u8 data[2];
+
+	if (!client->adapter)
+		return -ENODEV;
+
+again:
+	data[0] = reg;		/* Register offset */
+	data[1] = val;		/* Register value */
+	msg->addr = client->addr;
+	msg->len = 2;
+	msg->flags = 0;		/* write operation */
+	msg->buf = data;
+
+	err = i2c_transfer(client->adapter, msg, 1);
+	if (err >= 0)
+		return 0;
+
+	DBG(&client->dev, 1,
+		"wrote 0x%.2x to offset 0x%.2x error %d\n", val, reg, err);
+	if (retry <= I2C_RETRY_COUNT) {
+		DBG(&client->dev, 2, "retry ... %d\n", retry);
+		retry++;
+		schedule_timeout(msecs_to_jiffies(20));
+		goto again;
+	}
+	return err;
+}
+
+/*
+ * tvp514x_write_regs : Initializes a list of TVP5146/47 registers
+ *		if token is TOK_TERM, then entire write operation terminates
+ *		if token is TOK_DELAY, then a delay of 'val' msec is introduced
+ *		if token is TOK_SKIP, then the register write is skipped
+ *		if token is TOK_WRITE, then the register write is performed
+ *
+ * reglist - list of registers to be written
+ * Returns zero if successful, or non-zero otherwise.
+ */
+static int tvp514x_write_regs(struct i2c_client *client,
+			      const struct tvp514x_reg reglist[])
+{
+	int err;
+	const struct tvp514x_reg *next = reglist;
+
+	for (; next->token != TOK_TERM; next++) {
+		if (next->token == TOK_DELAY) {
+			schedule_timeout(msecs_to_jiffies(next->val));
+			continue;
+		}
+
+		if (next->token == TOK_SKIP)
+			continue;
+
+		err = tvp514x_write_reg(client, next->reg, (u8) next->val);
+		if (err) {
+			DBG(&client->dev, 1, "write failed. Err[%d]\n",
+				err);
+			return err;
+		}
+	}
+	return 0;
+}
+
+/*
+ * tvp514x_get_current_std:
+ * Returns the current standard detected by TVP5146/47
+ */
+static enum tvp514x_std tvp514x_get_current_std(struct tvp514x_decoder
+						*decoder)
+{
+	u8 std, std_status;
+
+	if (tvp514x_read_reg(decoder->client, REG_VIDEO_STD, &std))
+		return STD_INVALID;
+
+	if ((std & VIDEO_STD_MASK) == VIDEO_STD_AUTO_SWITCH_BIT) {
+		/* use the standard status register */
+		if (tvp514x_read_reg(decoder->client, REG_VIDEO_STD_STATUS,
+				     &std_status))
+			return STD_INVALID;
+	} else
+		std_status = std;	/* use the standard register itself */
+
+	switch (std_status & VIDEO_STD_MASK) {
+	case VIDEO_STD_NTSC_MJ_BIT:
+		return STD_NTSC_MJ;
+
+	case VIDEO_STD_PAL_BDGHIN_BIT:
+		return STD_PAL_BDGHIN;
+
+	default:
+		return STD_INVALID;
+	}
+
+	return STD_INVALID;
+}
+
+#ifdef TVP514X_DEBUG
+/*
+ * TVP5146/47 register dump function
+ */
+void tvp514x_reg_dump(struct tvp514x_decoder *decoder)
+{
+	u8 value;
+
+	dump_reg(decoder->client, REG_INPUT_SEL, value);
+	dump_reg(decoder->client, REG_AFE_GAIN_CTRL, value);
+	dump_reg(decoder->client, REG_VIDEO_STD, value);
+	dump_reg(decoder->client, REG_OPERATION_MODE, value);
+	dump_reg(decoder->client, REG_COLOR_KILLER, value);
+	dump_reg(decoder->client, REG_LUMA_CONTROL1, value);
+	dump_reg(decoder->client, REG_LUMA_CONTROL2, value);
+	dump_reg(decoder->client, REG_LUMA_CONTROL3, value);
+	dump_reg(decoder->client, REG_BRIGHTNESS, value);
+	dump_reg(decoder->client, REG_CONTRAST, value);
+	dump_reg(decoder->client, REG_SATURATION, value);
+	dump_reg(decoder->client, REG_HUE, value);
+	dump_reg(decoder->client, REG_CHROMA_CONTROL1, value);
+	dump_reg(decoder->client, REG_CHROMA_CONTROL2, value);
+	dump_reg(decoder->client, REG_COMP_PR_SATURATION, value);
+	dump_reg(decoder->client, REG_COMP_Y_CONTRAST, value);
+	dump_reg(decoder->client, REG_COMP_PB_SATURATION, value);
+	dump_reg(decoder->client, REG_COMP_Y_BRIGHTNESS, value);
+	dump_reg(decoder->client, REG_AVID_START_PIXEL_LSB, value);
+	dump_reg(decoder->client, REG_AVID_START_PIXEL_MSB, value);
+	dump_reg(decoder->client, REG_AVID_STOP_PIXEL_LSB, value);
+	dump_reg(decoder->client, REG_AVID_STOP_PIXEL_MSB, value);
+	dump_reg(decoder->client, REG_HSYNC_START_PIXEL_LSB, value);
+	dump_reg(decoder->client, REG_HSYNC_START_PIXEL_MSB, value);
+	dump_reg(decoder->client, REG_HSYNC_STOP_PIXEL_LSB, value);
+	dump_reg(decoder->client, REG_HSYNC_STOP_PIXEL_MSB, value);
+	dump_reg(decoder->client, REG_VSYNC_START_LINE_LSB, value);
+	dump_reg(decoder->client, REG_VSYNC_START_LINE_MSB, value);
+	dump_reg(decoder->client, REG_VSYNC_STOP_LINE_LSB, value);
+	dump_reg(decoder->client, REG_VSYNC_STOP_LINE_MSB, value);
+	dump_reg(decoder->client, REG_VBLK_START_LINE_LSB, value);
+	dump_reg(decoder->client, REG_VBLK_START_LINE_MSB, value);
+	dump_reg(decoder->client, REG_VBLK_STOP_LINE_LSB, value);
+	dump_reg(decoder->client, REG_VBLK_STOP_LINE_MSB, value);
+	dump_reg(decoder->client, REG_SYNC_CONTROL, value);
+	dump_reg(decoder->client, REG_OUTPUT_FORMATTER1, value);
+	dump_reg(decoder->client, REG_OUTPUT_FORMATTER2, value);
+	dump_reg(decoder->client, REG_OUTPUT_FORMATTER3, value);
+	dump_reg(decoder->client, REG_OUTPUT_FORMATTER4, value);
+	dump_reg(decoder->client, REG_OUTPUT_FORMATTER5, value);
+	dump_reg(decoder->client, REG_OUTPUT_FORMATTER6, value);
+	dump_reg(decoder->client, REG_CLEAR_LOST_LOCK, value);
+}
+#endif
+
+/*
+ * Configure the TVP5146/47 with the current register settings
+ * Returns zero if successful, or non-zero otherwise.
+ */
+static int tvp514x_configure(struct tvp514x_decoder *decoder)
+{
+	int err;
+
+	/* common register initialization */
+	err =
+	    tvp514x_write_regs(decoder->client, tvp514x_reg_list);
+	if (err)
+		return err;
+
+#ifdef TVP514X_DEBUG
+	tvp514x_reg_dump(decoder);
+#endif
+
+	return 0;
+}
+
+/*
+ * Detect if an tvp514x is present, and if so which revision.
+ * A device is considered to be detected if the chip ID (LSB and MSB)
+ * registers match the expected values.
+ * Any value of the rom version register is accepted.
+ * Returns ENODEV error number if no device is detected, or zero
+ * if a device is detected.
+ */
+static int tvp514x_detect(struct tvp514x_decoder *decoder)
+{
+	u8 chip_id_msb, chip_id_lsb, rom_ver;
+
+	if (tvp514x_read_reg
+	    (decoder->client, REG_CHIP_ID_MSB, &chip_id_msb))
+		return -ENODEV;
+	if (tvp514x_read_reg
+	    (decoder->client, REG_CHIP_ID_LSB, &chip_id_lsb))
+		return -ENODEV;
+	if (tvp514x_read_reg(decoder->client, REG_ROM_VERSION, &rom_ver))
+		return -ENODEV;
+
+	DBG(&decoder->client->dev, 2,
+		 "chip id detected msb:0x%x lsb:0x%x rom version:0x%x\n",
+		 chip_id_msb, chip_id_lsb, rom_ver);
+	if ((chip_id_msb != TVP514X_CHIP_ID_MSB)
+		|| ((chip_id_lsb != TVP5146_CHIP_ID_LSB)
+		&& (chip_id_lsb != TVP5147_CHIP_ID_LSB))) {
+		/* We didn't read the values we expected, so this must not be
+		 * an TVP5146/47.
+		 */
+		DBG(&decoder->client->dev, 1,
+			"chip id mismatch msb:0x%x lsb:0x%x\n",
+			chip_id_msb, chip_id_lsb);
+		return -ENODEV;
+	}
+
+	decoder->ver = rom_ver;
+	decoder->state = STATE_DETECTED;
+
+	return 0;
+}
+
+/*
+ * following are decoder interface functions implemented by
+ * TVP5146/47 decoder driver.
+ */
+
+/**
+ * ioctl_querystd - V4L2 decoder interface handler for VIDIOC_QUERYSTD ioctl
+ * @s: pointer to standard V4L2 device structure
+ * @std_id: standard V4L2 std_id ioctl enum
+ *
+ * Returns the current standard detected by TVP5146/47. If no active input is
+ * detected, returns -EINVAL
+ */
+static int ioctl_querystd(struct v4l2_int_device *s, v4l2_std_id *std_id)
+{
+	struct tvp514x_decoder *decoder = s->priv;
+	enum tvp514x_std current_std;
+	enum tvp514x_input input_sel;
+	u8 sync_lock_status, lock_mask;
+
+	if (std_id == NULL)
+		return -EINVAL;
+
+	/* get the current standard */
+	current_std = tvp514x_get_current_std(decoder);
+	if (current_std == STD_INVALID)
+		return -EINVAL;
+
+	/* check whether signal is locked */
+	if (tvp514x_read_reg
+	    (decoder->client, REG_STATUS1, &sync_lock_status))
+		return -EINVAL;
+
+	input_sel = decoder->pdata->input_list[decoder->inputidx].input_sel;
+
+	switch (input_sel) {
+	case INPUT_CVBS_VI1A:
+	case INPUT_CVBS_VI1B:
+	case INPUT_CVBS_VI1C:
+	case INPUT_CVBS_VI2A:
+	case INPUT_CVBS_VI2B:
+	case INPUT_CVBS_VI2C:
+	case INPUT_CVBS_VI3A:
+	case INPUT_CVBS_VI3B:
+	case INPUT_CVBS_VI3C:
+	case INPUT_CVBS_VI4A:
+		lock_mask = STATUS_CLR_SUBCAR_LOCK_BIT |
+			STATUS_HORZ_SYNC_LOCK_BIT |
+			STATUS_VIRT_SYNC_LOCK_BIT;
+		break;
+
+	case INPUT_SVIDEO_VI2A_VI1A:
+	case INPUT_SVIDEO_VI2B_VI1B:
+	case INPUT_SVIDEO_VI2C_VI1C:
+	case INPUT_SVIDEO_VI2A_VI3A:
+	case INPUT_SVIDEO_VI2B_VI3B:
+	case INPUT_SVIDEO_VI2C_VI3C:
+	case INPUT_SVIDEO_VI4A_VI1A:
+	case INPUT_SVIDEO_VI4A_VI1B:
+	case INPUT_SVIDEO_VI4A_VI1C:
+	case INPUT_SVIDEO_VI4A_VI3A:
+	case INPUT_SVIDEO_VI4A_VI3B:
+	case INPUT_SVIDEO_VI4A_VI3C:
+		lock_mask = STATUS_HORZ_SYNC_LOCK_BIT |
+			STATUS_VIRT_SYNC_LOCK_BIT;
+		break;
+		/*Need to add other interfaces*/
+	default:
+		return -EINVAL;
+	}
+
+	if (lock_mask != (sync_lock_status & lock_mask))
+		return -EINVAL;	/* No input detected */
+
+	decoder->current_std = current_std;
+	*std_id = decoder->std_list[current_std].standard.id;
+
+	DBG(&decoder->client->dev, 3,
+			"Current STD: %s",
+			decoder->std_list[current_std].standard.name);
+	return 0;
+}
+
+/**
+ * ioctl_s_std - V4L2 decoder interface handler for VIDIOC_S_STD ioctl
+ * @s: pointer to standard V4L2 device structure
+ * @std_id: standard V4L2 v4l2_std_id ioctl enum
+ *
+ * If std_id is supported, sets the requested standard. Otherwise, returns
+ * -EINVAL
+ */
+static int ioctl_s_std(struct v4l2_int_device *s, v4l2_std_id *std_id)
+{
+	struct tvp514x_decoder *decoder = s->priv;
+	int err, i;
+
+	if (std_id == NULL)
+		return -EINVAL;
+
+	for (i = 0; i < decoder->num_stds; i++)
+		if (*std_id & decoder->std_list[i].standard.id)
+			break;
+
+	if (i == decoder->num_stds)
+		return -EINVAL;
+
+	err = tvp514x_write_reg(decoder->client, REG_VIDEO_STD,
+				decoder->std_list[i].video_std);
+	if (err)
+		return err;
+
+	decoder->current_std = i;
+	tvp514x_reg_list[REG_VIDEO_STD].val =
+	    decoder->std_list[i].video_std;
+
+	DBG(&decoder->client->dev, 3,
+			"Standard set to: %s",
+			decoder->std_list[i].standard.name);
+	return 0;
+}
+
+/**
+ * ioctl_enum_input - V4L2 decoder interface handler for VIDIOC_ENUMINPUT ioctl
+ * @s: pointer to standard V4L2 device structure
+ * @input: standard V4L2 VIDIOC_ENUMINPUT ioctl structure
+ *
+ * If index is valid, returns the description of the input. Otherwise, returns
+ * -EINVAL if any error occurs
+ */
+static int
+ioctl_enum_input(struct v4l2_int_device *s, struct v4l2_input *input)
+{
+	struct tvp514x_decoder *decoder = s->priv;
+	int index;
+
+	if (input == NULL)
+		return -EINVAL;
+
+	index = input->index;
+	if ((index >= decoder->pdata->num_inputs) || (index < 0))
+		return -EINVAL;	/* Index out of bound */
+
+	memcpy(input, &decoder->pdata->input_list[index].input,
+		sizeof(struct v4l2_input));
+
+	DBG(&decoder->client->dev, 3,
+			"Current input is: index - %d (%s)",
+			decoder->pdata->input_list[index].input.index,
+			decoder->pdata->input_list[index].input.name);
+	return 0;
+}
+
+/**
+ * ioctl_s_input - V4L2 decoder interface handler for VIDIOC_S_INPUT ioctl
+ * @s: pointer to standard V4L2 device structure
+ * @index: number of the input
+ *
+ * If index is valid, selects the requested input. Otherwise, returns -EINVAL if
+ * the input is not supported or there is no active signal present in the
+ * selected input.
+ */
+static int ioctl_s_input(struct v4l2_int_device *s, int index)
+{
+	struct tvp514x_decoder *decoder = s->priv;
+	int err;
+	enum tvp514x_input input_sel;
+	enum tvp514x_std current_std = STD_INVALID;
+	u8 sync_lock_status, lock_mask;
+	int try_count = LOCK_RETRY_COUNT;
+
+	if ((index >= decoder->pdata->num_inputs) || (index < 0))
+		return -EINVAL;	/* Index out of bound */
+
+	/* Get the register value to be written to select the requested input */
+	input_sel = decoder->pdata->input_list[index].input_sel;
+	err = tvp514x_write_reg(decoder->client, REG_INPUT_SEL, input_sel);
+	if (err)
+		return err;
+
+	decoder->inputidx = index;
+	tvp514x_reg_list[REG_INPUT_SEL].val = input_sel;
+
+	/* Clear status */
+	msleep(LOCK_RETRY_DELAY);
+	err =
+	    tvp514x_write_reg(decoder->client, REG_CLEAR_LOST_LOCK, 0x01);
+	if (err)
+		return err;
+
+	switch (input_sel) {
+	case INPUT_CVBS_VI1A:
+	case INPUT_CVBS_VI1B:
+	case INPUT_CVBS_VI1C:
+	case INPUT_CVBS_VI2A:
+	case INPUT_CVBS_VI2B:
+	case INPUT_CVBS_VI2C:
+	case INPUT_CVBS_VI3A:
+	case INPUT_CVBS_VI3B:
+	case INPUT_CVBS_VI3C:
+	case INPUT_CVBS_VI4A:
+		lock_mask = STATUS_CLR_SUBCAR_LOCK_BIT |
+			STATUS_HORZ_SYNC_LOCK_BIT |
+			STATUS_VIRT_SYNC_LOCK_BIT;
+		break;
+
+	case INPUT_SVIDEO_VI2A_VI1A:
+	case INPUT_SVIDEO_VI2B_VI1B:
+	case INPUT_SVIDEO_VI2C_VI1C:
+	case INPUT_SVIDEO_VI2A_VI3A:
+	case INPUT_SVIDEO_VI2B_VI3B:
+	case INPUT_SVIDEO_VI2C_VI3C:
+	case INPUT_SVIDEO_VI4A_VI1A:
+	case INPUT_SVIDEO_VI4A_VI1B:
+	case INPUT_SVIDEO_VI4A_VI1C:
+	case INPUT_SVIDEO_VI4A_VI3A:
+	case INPUT_SVIDEO_VI4A_VI3B:
+	case INPUT_SVIDEO_VI4A_VI3C:
+		lock_mask = STATUS_HORZ_SYNC_LOCK_BIT |
+			STATUS_VIRT_SYNC_LOCK_BIT;
+		break;
+	/*Need to add other interfaces*/
+	default:
+		return -EINVAL;
+	}
+
+	while (try_count-- > 0) {
+		/* Allow decoder to sync up with new input */
+		msleep(LOCK_RETRY_DELAY);
+
+		/* get the current standard for future reference */
+		current_std = tvp514x_get_current_std(decoder);
+		if (current_std == STD_INVALID)
+			continue;
+
+		if (tvp514x_read_reg(decoder->client, REG_STATUS1,
+					&sync_lock_status))
+			return -EINVAL;
+
+		if (lock_mask == (sync_lock_status & lock_mask))
+			break;	/* Input detected */
+	}
+
+	if ((current_std == STD_INVALID) || (try_count < 0))
+		return -EINVAL;
+
+	decoder->current_std = current_std;
+
+	DBG(&decoder->client->dev, 3,
+			"Input set to: index - %d (%s)",
+			decoder->pdata->input_list[index].input.index,
+			decoder->pdata->input_list[index].input.name);
+	return 0;
+}
+
+/**
+ * ioctl_g_input - V4L2 decoder interface handler for VIDIOC_G_INPUT ioctl
+ * @s: pointer to standard V4L2 device structure
+ * @index: returns the current selected input
+ *
+ * Returns the current selected input. Returns -EINVAL if any error occurs
+ */
+static int ioctl_g_input(struct v4l2_int_device *s, int *index)
+{
+	struct tvp514x_decoder *decoder = s->priv;
+	int err = -EINVAL, i, inputidx;
+
+	if (index == NULL)
+		return -EINVAL;
+
+	/* Search through the input list for active inputs */
+	inputidx = decoder->inputidx;
+	for (i = 0; i < decoder->pdata->num_inputs; i++) {
+		inputidx++;	/* Move to next input */
+		if (inputidx >= decoder->pdata->num_inputs)
+			inputidx = 0;	/* fall back to first input */
+
+		err = ioctl_s_input(s, inputidx);
+		if (!err) {
+			/* Active input found - select it and return success */
+			*index = inputidx;
+			return 0;
+		}
+	}
+
+	return err;
+}
+
+/**
+ * ioctl_queryctrl - V4L2 decoder interface handler for VIDIOC_QUERYCTRL ioctl
+ * @s: pointer to standard V4L2 device structure
+ * @qc: standard V4L2 VIDIOC_QUERYCTRL ioctl structure
+ *
+ * If the requested control is supported, returns the control information
+ * from the ctrl_list[] array. Otherwise, returns -EINVAL if the
+ * control is not supported.
+ */
+static int
+ioctl_queryctrl(struct v4l2_int_device *s, struct v4l2_queryctrl *qctrl)
+{
+	struct tvp514x_decoder *decoder = s->priv;
+	int id, index;
+	const struct tvp514x_ctrl_info *control = NULL;
+
+	if (qctrl == NULL)
+		return -EINVAL;
+
+	id = qctrl->id;
+	memset(qctrl, 0, sizeof(struct v4l2_queryctrl));
+	qctrl->id = id;
+
+	for (index = 0; index < decoder->num_ctrls; index++) {
+		control = &decoder->ctrl_list[index];
+		if (control->query_ctrl.id == qctrl->id)
+			break;	/* Match found */
+	}
+	if (index == decoder->num_ctrls)
+		return -EINVAL;	/* Index out of bound */
+
+	memcpy(qctrl, &control->query_ctrl, sizeof(struct v4l2_queryctrl));
+
+	DBG(&decoder->client->dev, 3,
+			"Query Cotrol: %s : Min - %d, Max - %d, Def - %d",
+			control->query_ctrl.name,
+			control->query_ctrl.minimum,
+			control->query_ctrl.maximum,
+			control->query_ctrl.default_value);
+	return 0;
+}
+
+/**
+ * ioctl_g_ctrl - V4L2 decoder interface handler for VIDIOC_G_CTRL ioctl
+ * @s: pointer to standard V4L2 device structure
+ * @vc: standard V4L2 VIDIOC_G_CTRL ioctl structure
+ *
+ * If the requested control is supported, returns the control's current
+ * value from the decoder. Otherwise, returns -EINVAL if the control is not
+ * supported.
+ */
+static int
+ioctl_g_ctrl(struct v4l2_int_device *s, struct v4l2_control *ctrl)
+{
+	struct tvp514x_decoder *decoder = s->priv;
+	int err, index;
+	u8 val;
+	int value;
+	const struct tvp514x_ctrl_info *control = NULL;
+
+	if (ctrl == NULL)
+		return -EINVAL;
+
+	for (index = 0; index < decoder->num_ctrls; index++) {
+		control = &decoder->ctrl_list[index];
+		if (control->query_ctrl.id == ctrl->id)
+			break;	/* Match found */
+	}
+	if (index == decoder->num_ctrls)
+		return -EINVAL;	/* Index out of bound */
+
+	err =
+	    tvp514x_read_reg(decoder->client, control->reg_address, &val);
+	if (err < 0)
+		return err;
+
+	/* cross check */
+	if (val != tvp514x_reg_list[control->reg_address].val)
+		return -EINVAL;	/* Driver & TVP5146/47 setting mismatch */
+
+	value = val;
+	if (V4L2_CID_AUTOGAIN == ctrl->id) {
+		if ((value & 0x3) == 3)
+			value = 1;
+		else
+			value = 0;
+	}
+
+	if (V4L2_CID_HUE == ctrl->id) {
+		if (value == 0x7F)
+			value = 180;
+		else if (value == 0x80)
+			value = -180;
+		else
+			value = 0;
+	}
+
+	ctrl->value = value;
+
+	DBG(&decoder->client->dev, 3,
+			"Get Cotrol: %s - %d",
+			control->query_ctrl.name, value);
+	return err;
+}
+
+/**
+ * ioctl_s_ctrl - V4L2 decoder interface handler for VIDIOC_S_CTRL ioctl
+ * @s: pointer to standard V4L2 device structure
+ * @vc: standard V4L2 VIDIOC_S_CTRL ioctl structure
+ *
+ * If the requested control is supported, sets the control's current
+ * value in HW. Otherwise, returns -EINVAL if the control is not supported.
+ */
+static int
+ioctl_s_ctrl(struct v4l2_int_device *s, struct v4l2_control *ctrl)
+{
+	struct tvp514x_decoder *decoder = s->priv;
+	int err, value, index;
+	const struct tvp514x_ctrl_info *control = NULL;
+
+	if (ctrl == NULL)
+		return -EINVAL;
+
+	value = (__s32) ctrl->value;
+	for (index = 0; index < decoder->num_ctrls; index++) {
+		control = &decoder->ctrl_list[index];
+		if (control->query_ctrl.id == ctrl->id)
+			break;	/* Match found */
+	}
+	if (index == decoder->num_ctrls)
+		return -EINVAL;	/* Index out of bound */
+
+	if (V4L2_CID_AUTOGAIN == ctrl->id) {
+		if (value == 1)
+			value = 0x0F;
+		else if (value == 0)
+			value = 0x0C;
+		else
+			return -ERANGE;
+	} else if (V4L2_CID_HUE == ctrl->id) {
+		if (value == 180)
+			value = 0x7F;
+		else if (value == -180)
+			value = 0x80;
+		else if (value == 0)
+			value = 0;
+		else
+			return -ERANGE;
+	} else {
+		if ((value < control->query_ctrl.minimum)
+			|| (value > control->query_ctrl.maximum))
+			return -ERANGE;
+	}
+
+	err =
+	    tvp514x_write_reg(decoder->client, control->reg_address,
+				value);
+	if (err < 0)
+		return err;
+
+	tvp514x_reg_list[control->reg_address].val = value;
+
+	DBG(&decoder->client->dev, 3,
+			"Set Cotrol: %s - %d",
+			control->query_ctrl.name, value);
+	return err;
+}
+
+/**
+ * ioctl_enum_fmt_cap - Implement the CAPTURE buffer VIDIOC_ENUM_FMT ioctl
+ * @s: pointer to standard V4L2 device structure
+ * @fmt: standard V4L2 VIDIOC_ENUM_FMT ioctl structure
+ *
+ * Implement the VIDIOC_ENUM_FMT ioctl to enumerate supported formats
+ */
+static int
+ioctl_enum_fmt_cap(struct v4l2_int_device *s, struct v4l2_fmtdesc *fmt)
+{
+	struct tvp514x_decoder *decoder = s->priv;
+	int index;
+
+	if (fmt == NULL)
+		return -EINVAL;
+
+	index = fmt->index;
+	if ((index >= decoder->num_fmts) || (index < 0))
+		return -EINVAL;	/* Index out of bound */
+
+	if (fmt->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
+		return -EINVAL;	/* only capture is supported */
+
+	memcpy(fmt, &decoder->fmt_list[index],
+		sizeof(struct v4l2_fmtdesc));
+
+	DBG(&decoder->client->dev, 3,
+			"Current FMT: index - %d (%s)",
+			decoder->fmt_list[index].index,
+			decoder->fmt_list[index].description);
+	return 0;
+}
+
+/**
+ * ioctl_try_fmt_cap - Implement the CAPTURE buffer VIDIOC_TRY_FMT ioctl
+ * @s: pointer to standard V4L2 device structure
+ * @f: pointer to standard V4L2 VIDIOC_TRY_FMT ioctl structure
+ *
+ * Implement the VIDIOC_TRY_FMT ioctl for the CAPTURE buffer type. This
+ * ioctl is used to negotiate the image capture size and pixel format
+ * without actually making it take effect.
+ */
+static int
+ioctl_try_fmt_cap(struct v4l2_int_device *s, struct v4l2_format *f)
+{
+	struct tvp514x_decoder *decoder = s->priv;
+	int ifmt;
+	struct v4l2_pix_format *pix;
+	enum tvp514x_std current_std;
+
+	if (f == NULL)
+		return -EINVAL;
+
+	if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
+		f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+
+	pix = &f->fmt.pix;
+
+	/* Calculate height and width based on current standard */
+	current_std = tvp514x_get_current_std(decoder);
+	if (current_std == STD_INVALID)
+		return -EINVAL;
+
+	decoder->current_std = current_std;
+	pix->width = decoder->std_list[current_std].width;
+	pix->height = decoder->std_list[current_std].height;
+
+	for (ifmt = 0; ifmt < decoder->num_fmts; ifmt++) {
+		if (pix->pixelformat ==
+			decoder->fmt_list[ifmt].pixelformat)
+			break;
+	}
+	if (ifmt == decoder->num_fmts)
+		ifmt = 0;	/* None of the format matched, select default */
+	pix->pixelformat = decoder->fmt_list[ifmt].pixelformat;
+
+	pix->field = V4L2_FIELD_INTERLACED;
+	pix->bytesperline = pix->width * 2;
+	pix->sizeimage = pix->bytesperline * pix->height;
+	pix->colorspace = V4L2_COLORSPACE_SMPTE170M;
+	pix->priv = 0;
+
+	DBG(&decoder->client->dev, 3,
+			"Try FMT: pixelformat - %s, bytesperline - %d"
+			"Width - %d, Height - %d",
+			decoder->fmt_list[ifmt].description, pix->bytesperline,
+			pix->width, pix->height);
+	return 0;
+}
+
+/**
+ * ioctl_s_fmt_cap - V4L2 decoder interface handler for VIDIOC_S_FMT ioctl
+ * @s: pointer to standard V4L2 device structure
+ * @f: pointer to standard V4L2 VIDIOC_S_FMT ioctl structure
+ *
+ * If the requested format is supported, configures the HW to use that
+ * format, returns error code if format not supported or HW can't be
+ * correctly configured.
+ */
+static int
+ioctl_s_fmt_cap(struct v4l2_int_device *s, struct v4l2_format *f)
+{
+	struct tvp514x_decoder *decoder = s->priv;
+	struct v4l2_pix_format *pix;
+	int rval;
+
+	if (f == NULL)
+		return -EINVAL;
+
+	if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
+		return -EINVAL;	/* only capture is supported */
+
+	pix = &f->fmt.pix;
+	rval = ioctl_try_fmt_cap(s, f);
+	if (rval)
+		return rval;
+	else
+		decoder->pix = *pix;
+
+	return rval;
+}
+
+/**
+ * ioctl_g_fmt_cap - V4L2 decoder interface handler for ioctl_g_fmt_cap
+ * @s: pointer to standard V4L2 device structure
+ * @f: pointer to standard V4L2 v4l2_format structure
+ *
+ * Returns the decoder's current pixel format in the v4l2_format
+ * parameter.
+ */
+static int
+ioctl_g_fmt_cap(struct v4l2_int_device *s, struct v4l2_format *f)
+{
+	struct tvp514x_decoder *decoder = s->priv;
+
+	if (f == NULL)
+		return -EINVAL;
+
+	if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
+		return -EINVAL;	/* only capture is supported */
+
+	f->fmt.pix = decoder->pix;
+
+	DBG(&decoder->client->dev, 3,
+			"Current FMT: bytesperline - %d"
+			"Width - %d, Height - %d",
+			decoder->pix.bytesperline,
+			decoder->pix.width, decoder->pix.height);
+	return 0;
+}
+
+/**
+ * ioctl_g_parm - V4L2 decoder interface handler for VIDIOC_G_PARM ioctl
+ * @s: pointer to standard V4L2 device structure
+ * @a: pointer to standard V4L2 VIDIOC_G_PARM ioctl structure
+ *
+ * Returns the decoder's video CAPTURE parameters.
+ */
+static int
+ioctl_g_parm(struct v4l2_int_device *s, struct v4l2_streamparm *a)
+{
+	struct tvp514x_decoder *decoder = s->priv;
+	struct v4l2_captureparm *cparm;
+	enum tvp514x_std current_std;
+
+	if (a == NULL)
+		return -EINVAL;
+
+	if (a->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
+		return -EINVAL;	/* only capture is supported */
+
+	memset(a, 0, sizeof(*a));
+	a->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+
+	/* get the current standard */
+	current_std = tvp514x_get_current_std(decoder);
+	decoder->current_std = current_std;
+
+	cparm = &a->parm.capture;
+	cparm->capability = V4L2_CAP_TIMEPERFRAME;
+	cparm->timeperframe
+	    = decoder->std_list[current_std].standard.frameperiod;
+
+	return 0;
+}
+
+/**
+ * ioctl_s_parm - V4L2 decoder interface handler for VIDIOC_S_PARM ioctl
+ * @s: pointer to standard V4L2 device structure
+ * @a: pointer to standard V4L2 VIDIOC_S_PARM ioctl structure
+ *
+ * Configures the decoder to use the input parameters, if possible. If
+ * not possible, returns the appropriate error code.
+ */
+static int
+ioctl_s_parm(struct v4l2_int_device *s, struct v4l2_streamparm *a)
+{
+	struct tvp514x_decoder *decoder = s->priv;
+	struct v4l2_fract *timeperframe;
+	enum tvp514x_std current_std;
+
+	if (a == NULL)
+		return -EINVAL;
+
+	if (a->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
+		return -EINVAL;	/* only capture is supported */
+
+	timeperframe = &a->parm.capture.timeperframe;
+
+	/* get the current standard */
+	current_std = tvp514x_get_current_std(decoder);
+	decoder->current_std = current_std;
+
+	*timeperframe =
+	    decoder->std_list[current_std].standard.frameperiod;
+
+	return 0;
+}
+
+/**
+ * ioctl_g_ifparm - V4L2 decoder interface handler for vidioc_int_g_ifparm_num
+ * @s: pointer to standard V4L2 device structure
+ * @p: pointer to standard V4L2 vidioc_int_g_ifparm_num ioctl structure
+ *
+ * Gets slave interface parameters.
+ * Calculates the required xclk value to support the requested
+ * clock parameters in p. This value is returned in the p
+ * parameter.
+ */
+static int ioctl_g_ifparm(struct v4l2_int_device *s, struct v4l2_ifparm *p)
+{
+	struct tvp514x_decoder *decoder = s->priv;
+	int rval;
+
+	if (p == NULL)
+		return -EINVAL;
+
+	if (NULL == decoder->pdata->ifparm)
+		return -EINVAL;
+
+	rval = decoder->pdata->ifparm(p);
+	if (rval) {
+		DBG(&decoder->client->dev, 1, "error. Err[%d]\n", rval);
+		return rval;
+	}
+
+	p->u.bt656.clock_curr = TVP514X_XCLK_BT656;
+
+	return 0;
+}
+
+/**
+ * ioctl_g_priv - V4L2 decoder interface handler for vidioc_int_g_priv_num
+ * @s: pointer to standard V4L2 device structure
+ * @p: void pointer to hold decoder's private data address
+ *
+ * Returns device's (decoder's) private data area address in p parameter
+ */
+static int ioctl_g_priv(struct v4l2_int_device *s, void *p)
+{
+	struct tvp514x_decoder *decoder = s->priv;
+
+	if (NULL == decoder->pdata->priv_data_set)
+		return -EINVAL;
+
+	return decoder->pdata->priv_data_set(p);
+}
+
+/**
+ * ioctl_s_power - V4L2 decoder interface handler for vidioc_int_s_power_num
+ * @s: pointer to standard V4L2 device structure
+ * @on: power state to which device is to be set
+ *
+ * Sets devices power state to requrested state, if possible.
+ */
+static int ioctl_s_power(struct v4l2_int_device *s, enum v4l2_power on)
+{
+	struct tvp514x_decoder *decoder = s->priv;
+	int err = 0;
+
+	switch (on) {
+	case V4L2_POWER_OFF:
+		/* Power Down Sequence */
+		err =
+		    tvp514x_write_reg(decoder->client, REG_OPERATION_MODE,
+					0x01);
+		/* Disable mux for TVP5146/47 decoder data path */
+		if (decoder->pdata->power_set)
+			err |= decoder->pdata->power_set(on);
+		break;
+
+	case V4L2_POWER_STANDBY:
+		if (decoder->pdata->power_set)
+			err = decoder->pdata->power_set(on);
+		break;
+
+	case V4L2_POWER_ON:
+		/* Enable mux for TVP5146/47 decoder data path */
+		if (decoder->pdata->power_set)
+			err = decoder->pdata->power_set(on);
+
+		/* Power Up Sequence */
+		err |=
+		    tvp514x_write_reg(decoder->client, REG_OPERATION_MODE,
+					0x01);
+		err |=
+		    tvp514x_write_reg(decoder->client, REG_OPERATION_MODE,
+					0x00);
+
+		/* Detect the sensor is not already detected */
+		if (decoder->state == STATE_NOT_DETECTED) {
+			err |= tvp514x_detect(decoder);
+			if (err < 0) {
+				DBG(&decoder->client->dev, 1,
+					"Unable to detect decoder\n");
+				return err;
+			}
+			DBG(&decoder->client->dev, 2,
+				 "chip version 0x%.2x detected\n",
+				 decoder->ver);
+		}
+		break;
+
+	case V4L2_POWER_RESUME:
+		if (decoder->pdata->power_set)
+			err = decoder->pdata->power_set(on);
+		if (decoder->state == STATE_DETECTED)
+			err |= tvp514x_configure(decoder);
+		break;
+
+	default:
+		err = -ENODEV;
+		break;
+	}
+
+	return err;
+}
+
+/**
+ * ioctl_init - V4L2 decoder interface handler for VIDIOC_INT_INIT
+ * @s: pointer to standard V4L2 device structure
+ *
+ * Initialize the decoder device (calls tvp514x_configure())
+ */
+static int ioctl_init(struct v4l2_int_device *s)
+{
+	struct tvp514x_decoder *decoder = s->priv;
+
+	/* Set default standard to auto */
+	tvp514x_reg_list[REG_VIDEO_STD].val =
+	    VIDEO_STD_AUTO_SWITCH_BIT;
+
+	return tvp514x_configure(decoder);
+}
+
+/**
+ * ioctl_dev_exit - V4L2 decoder interface handler for vidioc_int_dev_exit_num
+ * @s: pointer to standard V4L2 device structure
+ *
+ * Delinitialise the dev. at slave detach. The complement of ioctl_dev_init.
+ */
+static int ioctl_dev_exit(struct v4l2_int_device *s)
+{
+	return 0;
+}
+
+/**
+ * ioctl_dev_init - V4L2 decoder interface handler for vidioc_int_dev_init_num
+ * @s: pointer to standard V4L2 device structure
+ *
+ * Initialise the device when slave attaches to the master. Returns 0 if
+ * TVP5146/47 device could be found, otherwise returns appropriate error.
+ */
+static int ioctl_dev_init(struct v4l2_int_device *s)
+{
+	struct tvp514x_decoder *decoder = s->priv;
+	int err;
+
+	err = tvp514x_detect(decoder);
+	if (err < 0) {
+		DBG(&decoder->client->dev, 1,
+			"Unable to detect decoder\n");
+		return err;
+	}
+
+	DBG(&decoder->client->dev, 2,
+		 "chip version 0x%.2x detected\n", decoder->ver);
+
+	return 0;
+}
+
+static struct v4l2_int_ioctl_desc tvp514x_ioctl_desc[] = {
+	{vidioc_int_dev_init_num, (v4l2_int_ioctl_func*) ioctl_dev_init},
+	{vidioc_int_dev_exit_num, (v4l2_int_ioctl_func*) ioctl_dev_exit},
+	{vidioc_int_s_power_num, (v4l2_int_ioctl_func*) ioctl_s_power},
+	{vidioc_int_g_priv_num, (v4l2_int_ioctl_func*) ioctl_g_priv},
+	{vidioc_int_g_ifparm_num, (v4l2_int_ioctl_func*) ioctl_g_ifparm},
+	{vidioc_int_init_num, (v4l2_int_ioctl_func*) ioctl_init},
+	{vidioc_int_enum_fmt_cap_num,
+	 (v4l2_int_ioctl_func *) ioctl_enum_fmt_cap},
+	{vidioc_int_try_fmt_cap_num,
+	 (v4l2_int_ioctl_func *) ioctl_try_fmt_cap},
+	{vidioc_int_g_fmt_cap_num,
+	 (v4l2_int_ioctl_func *) ioctl_g_fmt_cap},
+	{vidioc_int_s_fmt_cap_num,
+	 (v4l2_int_ioctl_func *) ioctl_s_fmt_cap},
+	{vidioc_int_g_parm_num, (v4l2_int_ioctl_func *) ioctl_g_parm},
+	{vidioc_int_s_parm_num, (v4l2_int_ioctl_func *) ioctl_s_parm},
+	{vidioc_int_queryctrl_num,
+	 (v4l2_int_ioctl_func *) ioctl_queryctrl},
+	{vidioc_int_g_ctrl_num, (v4l2_int_ioctl_func *) ioctl_g_ctrl},
+	{vidioc_int_s_ctrl_num, (v4l2_int_ioctl_func *) ioctl_s_ctrl},
+	{vidioc_int_querystd_num, (v4l2_int_ioctl_func *) ioctl_querystd},
+	{vidioc_int_s_std_num, (v4l2_int_ioctl_func *) ioctl_s_std},
+	{vidioc_int_enum_input_num,
+	 (v4l2_int_ioctl_func *) ioctl_enum_input},
+	{vidioc_int_g_input_num, (v4l2_int_ioctl_func *) ioctl_g_input},
+	{vidioc_int_s_input_num, (v4l2_int_ioctl_func *) ioctl_s_input},
+};
+
+static struct v4l2_int_slave tvp514x_slave = {
+	.ioctls = tvp514x_ioctl_desc,
+	.num_ioctls = ARRAY_SIZE(tvp514x_ioctl_desc),
+};
+
+static struct tvp514x_decoder tvp514x_dev = {
+	.state = STATE_NOT_DETECTED,
+
+	.num_fmts = TVP514X_NUM_FORMATS,
+	.fmt_list = tvp514x_fmt_list,
+
+	.pix = {		/* Default to NTSC 8-bit YUV 422 */
+		.width = NTSC_NUM_ACTIVE_PIXELS,
+		.height = NTSC_NUM_ACTIVE_LINES,
+		.pixelformat = V4L2_PIX_FMT_UYVY,
+		.field = V4L2_FIELD_INTERLACED,
+		.bytesperline = NTSC_NUM_ACTIVE_PIXELS * 2,
+		.sizeimage =
+		NTSC_NUM_ACTIVE_PIXELS * 2 * NTSC_NUM_ACTIVE_LINES,
+		.colorspace = V4L2_COLORSPACE_SMPTE170M,
+		},
+
+	.current_std = STD_NTSC_MJ,
+	.num_stds = TVP514X_NUM_STANDARDS,
+	.std_list = tvp514x_std_list,
+
+	.num_ctrls = TVP514X_NUM_CONTROLS,
+	.ctrl_list = tvp514x_ctrl_list,
+
+};
+
+static struct v4l2_int_device tvp514x_int_device = {
+	.module = THIS_MODULE,
+	.name = MODULE_NAME,
+	.priv = &tvp514x_dev,
+	.type = v4l2_int_type_slave,
+	.u = {
+	      .slave = &tvp514x_slave,
+	      },
+};
+
+/**
+ * tvp514x_probe - decoder driver i2c probe handler
+ * @client: i2c driver client device structure
+ *
+ * Register decoder as an i2c client device and V4L2
+ * device.
+ */
+static int
+tvp514x_probe(struct i2c_client *client, const struct i2c_device_id *id)
+{
+	struct tvp514x_decoder *decoder = &tvp514x_dev;
+	int err;
+
+	if (i2c_get_clientdata(client))
+		return -EBUSY;
+
+	decoder->pdata = client->dev.platform_data;
+	if (!decoder->pdata) {
+		DBG(&client->dev, 1, "No platform data\n!!");
+		return -ENODEV;
+	}
+	/*
+	 * Fetch platform specific data, and configure the
+	 * tvp514x_reg_list[] accordingly. Since this is one
+	 * time configuration, no need to preserve.
+	 */
+	decoder->inputidx = decoder->pdata->default_input;
+	tvp514x_reg_list[REG_OUTPUT_FORMATTER2].val |=
+			(decoder->pdata->clk_polarity << 1);
+	tvp514x_reg_list[REG_OUTPUT_FORMATTER1].val |=
+			decoder->pdata->fmt;
+	tvp514x_reg_list[REG_SYNC_CONTROL].val |=
+			((decoder->pdata->hs_polarity << 2) |
+			(decoder->pdata->vs_polarity << 3));
+
+	/* Attach to Master */
+	strcpy(tvp514x_int_device.u.slave->attach_to, decoder->pdata->master);
+	decoder->v4l2_int_device = &tvp514x_int_device;
+	decoder->client = client;
+	i2c_set_clientdata(client, decoder);
+
+	/* Register with V4L2 layer as slave device */
+	err = v4l2_int_device_register(decoder->v4l2_int_device);
+	if (err) {
+		i2c_set_clientdata(client, NULL);
+		DBG(&client->dev, 1,
+			"Unable to register to v4l2. Err[%d]\n", err);
+
+	} else
+		DBG(&client->dev, 3, "Registered to v4l2 master %s!!\n",
+				decoder->pdata->master);
+
+	return 0;
+}
+
+/**
+ * tvp514x_remove - decoder driver i2c remove handler
+ * @client: i2c driver client device structure
+ *
+ * Unregister decoder as an i2c client device and V4L2
+ * device. Complement of tvp514x_probe().
+ */
+static int __exit tvp514x_remove(struct i2c_client *client)
+{
+	struct tvp514x_decoder *decoder = i2c_get_clientdata(client);
+
+	if (!client->adapter)
+		return -ENODEV;	/* our client isn't attached */
+
+	v4l2_int_device_unregister(decoder->v4l2_int_device);
+	i2c_set_clientdata(client, NULL);
+
+	return 0;
+}
+
+static const struct i2c_device_id tvp514x_id[] = {
+	{"tvp5146", 0},
+	{"tvp5147", 0},
+	{},
+};
+
+MODULE_DEVICE_TABLE(i2c, tvp514x_id);
+
+static struct i2c_driver tvp514x_i2c_driver = {
+	.driver = {
+		   .name = MODULE_NAME,
+		   .owner = THIS_MODULE,
+		   },
+	.probe = tvp514x_probe,
+	.remove = __exit_p(tvp514x_remove),
+	.id_table = tvp514x_id,
+};
+
+/**
+ * tvp514x_init
+ *
+ * Module init function
+ */
+static int __init tvp514x_init(void)
+{
+	int err;
+
+	err = i2c_add_driver(&tvp514x_i2c_driver);
+	if (err) {
+		printk(KERN_ERR "Failed to register " MODULE_NAME ".\n");
+		return err;
+	}
+	return 0;
+}
+
+/**
+ * tvp514x_cleanup
+ *
+ * Module exit function
+ */
+static void __exit tvp514x_cleanup(void)
+{
+	i2c_del_driver(&tvp514x_i2c_driver);
+}
+
+module_init(tvp514x_init);
+module_exit(tvp514x_cleanup);
+
+MODULE_AUTHOR("Texas Instruments");
+MODULE_DESCRIPTION("TVP514X linux decoder driver");
+MODULE_LICENSE("GPL");
diff --git a/include/media/tvp514x.h b/include/media/tvp514x.h
new file mode 100644
index 0000000..5a4e2d5
--- /dev/null
+++ b/include/media/tvp514x.h
@@ -0,0 +1,461 @@
+/*
+ * drivers/media/video/tvp514x.h
+ *
+ * Copyright (C) 2008 Texas Instruments Inc
+ *
+ * This package is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#ifndef _TVP514X_H
+#define _TVP514X_H
+
+/*
+ * TVP5146/47 registers
+ */
+#define REG_INPUT_SEL			(0x00)
+#define REG_AFE_GAIN_CTRL		(0x01)
+#define REG_VIDEO_STD			(0x02)
+#define REG_OPERATION_MODE		(0x03)
+#define REG_AUTOSWITCH_MASK		(0x04)
+
+#define REG_COLOR_KILLER		(0x05)
+#define REG_LUMA_CONTROL1		(0x06)
+#define REG_LUMA_CONTROL2		(0x07)
+#define REG_LUMA_CONTROL3		(0x08)
+
+#define REG_BRIGHTNESS			(0x09)
+#define REG_CONTRAST			(0x0A)
+#define REG_SATURATION			(0x0B)
+#define REG_HUE				(0x0C)
+
+#define REG_CHROMA_CONTROL1		(0x0D)
+#define REG_CHROMA_CONTROL2		(0x0E)
+
+/* 0x0F Reserved */
+
+#define REG_COMP_PR_SATURATION		(0x10)
+#define REG_COMP_Y_CONTRAST		(0x11)
+#define REG_COMP_PB_SATURATION		(0x12)
+
+/* 0x13 Reserved */
+
+#define REG_COMP_Y_BRIGHTNESS		(0x14)
+
+/* 0x15 Reserved */
+
+#define REG_AVID_START_PIXEL_LSB	(0x16)
+#define REG_AVID_START_PIXEL_MSB	(0x17)
+#define REG_AVID_STOP_PIXEL_LSB		(0x18)
+#define REG_AVID_STOP_PIXEL_MSB		(0x19)
+
+#define REG_HSYNC_START_PIXEL_LSB	(0x1A)
+#define REG_HSYNC_START_PIXEL_MSB	(0x1B)
+#define REG_HSYNC_STOP_PIXEL_LSB	(0x1C)
+#define REG_HSYNC_STOP_PIXEL_MSB	(0x1D)
+
+#define REG_VSYNC_START_LINE_LSB	(0x1E)
+#define REG_VSYNC_START_LINE_MSB	(0x1F)
+#define REG_VSYNC_STOP_LINE_LSB		(0x20)
+#define REG_VSYNC_STOP_LINE_MSB		(0x21)
+
+#define REG_VBLK_START_LINE_LSB		(0x22)
+#define REG_VBLK_START_LINE_MSB		(0x23)
+#define REG_VBLK_STOP_LINE_LSB		(0x24)
+#define REG_VBLK_STOP_LINE_MSB		(0x25)
+
+/* 0x26 - 0x27 Reserved */
+
+#define REG_FAST_SWTICH_CONTROL		(0x28)
+
+/* 0x29 Reserved */
+
+#define REG_FAST_SWTICH_SCART_DELAY	(0x2A)
+
+/* 0x2B Reserved */
+
+#define REG_SCART_DELAY			(0x2C)
+#define REG_CTI_DELAY			(0x2D)
+#define REG_CTI_CONTROL			(0x2E)
+
+/* 0x2F - 0x31 Reserved */
+
+#define REG_SYNC_CONTROL		(0x32)
+#define REG_OUTPUT_FORMATTER1		(0x33)
+#define REG_OUTPUT_FORMATTER2		(0x34)
+#define REG_OUTPUT_FORMATTER3		(0x35)
+#define REG_OUTPUT_FORMATTER4		(0x36)
+#define REG_OUTPUT_FORMATTER5		(0x37)
+#define REG_OUTPUT_FORMATTER6		(0x38)
+#define REG_CLEAR_LOST_LOCK		(0x39)
+
+#define REG_STATUS1			(0x3A)
+#define REG_STATUS2			(0x3B)
+
+#define REG_AGC_GAIN_STATUS_LSB		(0x3C)
+#define REG_AGC_GAIN_STATUS_MSB		(0x3D)
+
+/* 0x3E Reserved */
+
+#define REG_VIDEO_STD_STATUS		(0x3F)
+#define REG_GPIO_INPUT1			(0x40)
+#define REG_GPIO_INPUT2			(0x41)
+
+/* 0x42 - 0x45 Reserved */
+
+#define REG_AFE_COARSE_GAIN_CH1		(0x46)
+#define REG_AFE_COARSE_GAIN_CH2		(0x47)
+#define REG_AFE_COARSE_GAIN_CH3		(0x48)
+#define REG_AFE_COARSE_GAIN_CH4		(0x49)
+
+#define REG_AFE_FINE_GAIN_PB_B_LSB	(0x4A)
+#define REG_AFE_FINE_GAIN_PB_B_MSB	(0x4B)
+#define REG_AFE_FINE_GAIN_Y_G_CHROMA_LSB	(0x4C)
+#define REG_AFE_FINE_GAIN_Y_G_CHROMA_MSB	(0x4D)
+#define REG_AFE_FINE_GAIN_PR_R_LSB	(0x4E)
+#define REG_AFE_FINE_GAIN_PR_R_MSB	(0x4F)
+#define REG_AFE_FINE_GAIN_CVBS_LUMA_LSB	(0x50)
+#define REG_AFE_FINE_GAIN_CVBS_LUMA_MSB	(0x51)
+
+/* 0x52 - 0x68 Reserved */
+
+#define REG_FBIT_VBIT_CONTROL1		(0x69)
+
+/* 0x6A - 0x6B Reserved */
+
+#define REG_BACKEND_AGC_CONTROL		(0x6C)
+
+/* 0x6D - 0x6E Reserved */
+
+#define REG_AGC_DECREMENT_SPEED_CONTROL	(0x6F)
+#define REG_ROM_VERSION			(0x70)
+
+/* 0x71 - 0x73 Reserved */
+
+#define REG_AGC_WHITE_PEAK_PROCESSING	(0x74)
+#define REG_FBIT_VBIT_CONTROL2		(0x75)
+#define REG_VCR_TRICK_MODE_CONTROL	(0x76)
+#define REG_HORIZONTAL_SHAKE_INCREMENT	(0x77)
+#define REG_AGC_INCREMENT_SPEED		(0x78)
+#define REG_AGC_INCREMENT_DELAY		(0x79)
+
+/* 0x7A - 0x7F Reserved */
+
+#define REG_CHIP_ID_MSB			(0x80)
+#define REG_CHIP_ID_LSB			(0x81)
+
+/* 0x82 Reserved */
+
+#define REG_CPLL_SPEED_CONTROL		(0x83)
+
+/* 0x84 - 0x96 Reserved */
+
+#define REG_STATUS_REQUEST		(0x97)
+
+/* 0x98 - 0x99 Reserved */
+
+#define REG_VERTICAL_LINE_COUNT_LSB	(0x9A)
+#define REG_VERTICAL_LINE_COUNT_MSB	(0x9B)
+
+/* 0x9C - 0x9D Reserved */
+
+#define REG_AGC_DECREMENT_DELAY		(0x9E)
+
+/* 0x9F - 0xB0 Reserved */
+
+#define REG_VDP_TTX_FILTER_1_MASK1	(0xB1)
+#define REG_VDP_TTX_FILTER_1_MASK2	(0xB2)
+#define REG_VDP_TTX_FILTER_1_MASK3	(0xB3)
+#define REG_VDP_TTX_FILTER_1_MASK4	(0xB4)
+#define REG_VDP_TTX_FILTER_1_MASK5	(0xB5)
+#define REG_VDP_TTX_FILTER_2_MASK1	(0xB6)
+#define REG_VDP_TTX_FILTER_2_MASK2	(0xB7)
+#define REG_VDP_TTX_FILTER_2_MASK3	(0xB8)
+#define REG_VDP_TTX_FILTER_2_MASK4	(0xB9)
+#define REG_VDP_TTX_FILTER_2_MASK5	(0xBA)
+#define REG_VDP_TTX_FILTER_CONTROL	(0xBB)
+#define REG_VDP_FIFO_WORD_COUNT		(0xBC)
+#define REG_VDP_FIFO_INTERRUPT_THRLD	(0xBD)
+
+/* 0xBE Reserved */
+
+#define REG_VDP_FIFO_RESET		(0xBF)
+#define REG_VDP_FIFO_OUTPUT_CONTROL	(0xC0)
+#define REG_VDP_LINE_NUMBER_INTERRUPT	(0xC1)
+#define REG_VDP_PIXEL_ALIGNMENT_LSB	(0xC2)
+#define REG_VDP_PIXEL_ALIGNMENT_MSB	(0xC3)
+
+/* 0xC4 - 0xD5 Reserved */
+
+#define REG_VDP_LINE_START		(0xD6)
+#define REG_VDP_LINE_STOP		(0xD7)
+#define REG_VDP_GLOBAL_LINE_MODE	(0xD8)
+#define REG_VDP_FULL_FIELD_ENABLE	(0xD9)
+#define REG_VDP_FULL_FIELD_MODE		(0xDA)
+
+/* 0xDB - 0xDF Reserved */
+
+#define REG_VBUS_DATA_ACCESS_NO_VBUS_ADDR_INCR	(0xE0)
+#define REG_VBUS_DATA_ACCESS_VBUS_ADDR_INCR	(0xE1)
+#define REG_FIFO_READ_DATA			(0xE2)
+
+/* 0xE3 - 0xE7 Reserved */
+
+#define REG_VBUS_ADDRESS_ACCESS1	(0xE8)
+#define REG_VBUS_ADDRESS_ACCESS2	(0xE9)
+#define REG_VBUS_ADDRESS_ACCESS3	(0xEA)
+
+/* 0xEB - 0xEF Reserved */
+
+#define REG_INTERRUPT_RAW_STATUS0	(0xF0)
+#define REG_INTERRUPT_RAW_STATUS1	(0xF1)
+#define REG_INTERRUPT_STATUS0		(0xF2)
+#define REG_INTERRUPT_STATUS1		(0xF3)
+#define REG_INTERRUPT_MASK0		(0xF4)
+#define REG_INTERRUPT_MASK1		(0xF5)
+#define REG_INTERRUPT_CLEAR0		(0xF6)
+#define REG_INTERRUPT_CLEAR1		(0xF7)
+
+/* 0xF8 - 0xFF Reserved */
+
+/*
+ * Mask and bit definitions of TVP5146/47 registers
+ */
+/* The ID values we are looking for */
+#define TVP514X_CHIP_ID_MSB		(0x51)
+#define TVP5146_CHIP_ID_LSB		(0x46)
+#define TVP5147_CHIP_ID_LSB		(0x47)
+
+#define VIDEO_STD_MASK			(0x07)
+#define VIDEO_STD_AUTO_SWITCH_BIT	(0x00)
+#define VIDEO_STD_NTSC_MJ_BIT		(0x01)
+#define VIDEO_STD_PAL_BDGHIN_BIT	(0x02)
+#define VIDEO_STD_PAL_M_BIT		(0x03)
+#define VIDEO_STD_PAL_COMBINATION_N_BIT	(0x04)
+#define VIDEO_STD_NTSC_4_43_BIT		(0x05)
+#define VIDEO_STD_SECAM_BIT		(0x06)
+#define VIDEO_STD_PAL_60_BIT		(0x07)
+
+/*
+ * Status bit
+ */
+#define STATUS_TV_VCR_BIT		(1<<0)
+#define STATUS_HORZ_SYNC_LOCK_BIT	(1<<1)
+#define STATUS_VIRT_SYNC_LOCK_BIT	(1<<2)
+#define STATUS_CLR_SUBCAR_LOCK_BIT	(1<<3)
+#define STATUS_LOST_LOCK_DETECT_BIT	(1<<4)
+#define STATUS_FEILD_RATE_BIT		(1<<5)
+#define STATUS_LINE_ALTERNATING_BIT	(1<<6)
+#define STATUS_PEAK_WHITE_DETECT_BIT	(1<<7)
+/*
+ * Other macros
+ */
+#define TVP514X_MODULE_NAME		"tvp514x"
+#define TVP514X_I2C_DELAY		(3)
+#define I2C_RETRY_COUNT			(5)
+#define LOCK_RETRY_COUNT		(3)
+#define LOCK_RETRY_DELAY		(200)
+
+#define TOK_WRITE			(0)	/* token for write operation */
+#define TOK_TERM			(1)	/* terminating token */
+#define TOK_DELAY			(2)	/* delay token for reg list */
+#define TOK_SKIP			(3)	/* token to skip a register */
+
+#define TVP514X_XCLK_BT656		(27000000)
+
+/* Number of pixels and number of lines per frame for different standards */
+#define NTSC_NUM_ACTIVE_PIXELS		(720)
+#define NTSC_NUM_ACTIVE_LINES		(480)
+#define PAL_NUM_ACTIVE_PIXELS		(720)
+#define PAL_NUM_ACTIVE_LINES		(576)
+
+/**
+ * enum tvp514x_std - enum for supported standards
+ */
+enum tvp514x_std {
+	STD_NTSC_MJ = 0,
+	STD_PAL_BDGHIN,
+	STD_INVALID
+};
+
+/**
+ * enum tvp514x_state - enum for different decoder states
+ */
+enum tvp514x_state {
+	STATE_NOT_DETECTED,
+	STATE_DETECTED
+};
+
+enum tvp514x_input {
+	/*
+	 * CVBS input selection
+	 */
+	INPUT_CVBS_VI1A = 0x0,
+	INPUT_CVBS_VI1B,
+	INPUT_CVBS_VI1C,
+	INPUT_CVBS_VI2A = 0x04,
+	INPUT_CVBS_VI2B,
+	INPUT_CVBS_VI2C,
+	INPUT_CVBS_VI3A = 0x08,
+	INPUT_CVBS_VI3B,
+	INPUT_CVBS_VI3C,
+	INPUT_CVBS_VI4A = 0x0C,
+	/*
+	 * S-Video input selection
+	 */
+	INPUT_SVIDEO_VI2A_VI1A = 0x44,
+	INPUT_SVIDEO_VI2B_VI1B,
+	INPUT_SVIDEO_VI2C_VI1C,
+	INPUT_SVIDEO_VI2A_VI3A = 0x54,
+	INPUT_SVIDEO_VI2B_VI3B,
+	INPUT_SVIDEO_VI2C_VI3C,
+	INPUT_SVIDEO_VI4A_VI1A = 0x4C,
+	INPUT_SVIDEO_VI4A_VI1B,
+	INPUT_SVIDEO_VI4A_VI1C,
+	INPUT_SVIDEO_VI4A_VI3A = 0x5C,
+	INPUT_SVIDEO_VI4A_VI3B,
+	INPUT_SVIDEO_VI4A_VI3C
+
+	/* Need to add entries for
+	 * RGB, YPbPr and SCART.
+	 */
+};
+
+enum tvp514x_output_fmt {
+	OUTPUT_10BIT_422_EMBEDDED_SYNC = 0,
+	OUTPUT_20BIT_422_SEPERATE_SYNC,
+	OUTPUT_10BIT_422_SEPERATE_SYNC = 3,
+	OUTPUT_INVALID
+};
+/**
+ * struct tvp514x_reg - Structure for TVP5146/47 register initialization values
+ * @token - Token: TOK_WRITE, TOK_TERM etc..
+ * @reg - Register offset
+ * @val - Register Value for TOK_WRITE or delay in ms for TOK_DELAY
+ */
+struct tvp514x_reg {
+	u8 token;
+	u8 reg;
+	u32 val;
+};
+
+/**
+ * struct tvp514x_std_info - Structure to store standard informations
+ * @width: Line width in pixels
+ * @height:Number of active lines
+ * @video_std: Value to write in REG_VIDEO_STD register
+ * @standard: v4l2 standard structure information
+ */
+struct tvp514x_std_info {
+	unsigned long width;
+	unsigned long height;
+	u8 video_std;
+	struct v4l2_standard standard;
+};
+
+/**
+ * struct tvp514x_ctrl_info - Information regarding supported controls
+ * @reg_address: Register offset of control register
+ * @query_ctrl: v4l2 query control information
+ */
+struct tvp514x_ctrl_info {
+	u8 reg_address;
+	struct v4l2_queryctrl query_ctrl;
+};
+
+/**
+ * struct tvp514x_input_info - Information regarding supported inputs
+ * @input_sel: Input select register
+ * @lock_mask: lock mask - depends on Svideo/CVBS
+ * @input: v4l2 input information
+ */
+struct tvp514x_input_info {
+	enum tvp514x_input input_sel;
+	struct v4l2_input input;
+};
+
+/**
+ * struct tvp514x_platform_data - Platform data values and access functions
+ * @power_set: Power state access function, zero is off, non-zero is on.
+ * @ifparm: Interface parameters access function
+ * @priv_data_set: Device private data (pointer) access function
+ * @reg_list: The board dependent driver should fill the default value for
+ *            required registers depending on board layout. The TVP5146/47
+ *            driver will update this register list for the registers
+ *            whose values should be maintained across open()/close() like
+ *            setting brightness as defined in V4L2.
+ *            The register list should be in the same order as defined in
+ *            TVP5146/47 datasheet including reserved registers. As of now
+ *            the driver expects the size of this list to be a minimum of
+ *            57 + 1 (upto regsiter REG_CLEAR_LOST_LOCK).
+ *            The last member should be of the list should be
+ *            {TOK_TERM, 0, 0} to indicate the end of register list.
+ * @num_inputs: Number of input connection in board
+ * @input_list: Input information list for num_inputs
+ */
+struct tvp514x_platform_data {
+	char *master;
+	int (*power_set) (enum v4l2_power on);
+	int (*ifparm) (struct v4l2_ifparm *p);
+	int (*priv_data_set) (void *);
+	/* Input params */
+	int num_inputs;
+	const struct tvp514x_input_info *input_list;
+	int default_input;
+	/* Interface control params */
+	enum tvp514x_output_fmt fmt;
+	bool clk_polarity;
+	bool hs_polarity;
+	bool vs_polarity;
+};
+
+/**
+ * struct tvp514x_decoded - TVP5146/47 decoder object
+ * @v4l2_int_device: Slave handle
+ * @pdata: Board specific
+ * @client: I2C client data
+ * @ver: Chip version
+ * @state: TVP5146/47 decoder state - detected or not-detected
+ * @pix: Current pixel format
+ * @num_fmts: Number of formats
+ * @fmt_list: Format list
+ * @current_std: Current standard
+ * @num_stds: Number of standards
+ * @std_list: Standards list
+ * @num_ctrls: Number of controls
+ * @ctrl_list: Control list
+ */
+struct tvp514x_decoder {
+	struct v4l2_int_device *v4l2_int_device;
+	const struct tvp514x_platform_data *pdata;
+	struct i2c_client *client;
+
+	int ver;
+	enum tvp514x_state state;
+
+	struct v4l2_pix_format pix;
+	int num_fmts;
+	const struct v4l2_fmtdesc *fmt_list;
+
+	enum tvp514x_std current_std;
+	int num_stds;
+	struct tvp514x_std_info *std_list;
+
+	int num_ctrls;
+	const struct tvp514x_ctrl_info *ctrl_list;
+
+	int inputidx;
+};
+
+#endif				/* ifndef _TVP514X_H */
--
1.5.6


^ permalink raw reply related	[flat|nested] 263+ messages in thread

* Re: [PATCH 1/2] Add Input/Output related ioctl support
  2008-11-26 17:04 ` [PATCH 1/2] Add Input/Output related ioctl support hvaibhav
@ 2008-11-26 17:15     ` Hans Verkuil
  0 siblings, 0 replies; 263+ messages in thread
From: Hans Verkuil @ 2008-11-26 17:15 UTC (permalink / raw)
  To: video4linux-list
  Cc: linux-omap, Karicheri Muralidharan, davinci-linux-open-source-bounces

On Wednesday 26 November 2008 18:04:39 hvaibhav@ti.com wrote:
> From: Vaibhav Hiremath <hvaibhav@ti.com>
>
> Note - Resending again with TVP driver for completeness.
>
> Added ioctl support for query std, set std, enum input,
> get input, set input, enum output, get output and set output.
>
> For sensor kind of slave drivers v4l2-int-device.h provides
> necessary ioctl support, but the ioctls required to interface
> with decoders and encoders are missing. Most of the decoders
> and encoders supports multiple inputs and outputs, like
> S-Video or Composite.
>
> With these ioctl''s user can select the specific input/output.
>
> Signed-off-by: Brijesh Jadav <brijesh.j@ti.com>
> Signed-off-by: Hardik Shah <hardik.shah@ti.com>
> Signed-off-by: Manjunath Hadli <mrh@ti.com>
> Signed-off-by: R Sivaraj <sivaraj@ti.com>
> Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
> Signed-off-by: Karicheri Muralidharan <m-karicheri2@ti.com>
> ---
>  include/media/v4l2-int-device.h |   17 +++++++++++++++++
>  1 files changed, 17 insertions(+), 0 deletions(-)
>
> diff --git a/include/media/v4l2-int-device.h
> b/include/media/v4l2-int-device.h index 9c2df41..2325b2a 100644
> --- a/include/media/v4l2-int-device.h
> +++ b/include/media/v4l2-int-device.h
> @@ -102,6 +102,7 @@ enum v4l2_power {
>  	V4L2_POWER_OFF = 0,
>  	V4L2_POWER_ON,
>  	V4L2_POWER_STANDBY,
> +	V4L2_POWER_RESUME,
>  };

Why is POWER_RESUME added? In an earlier discussion with Sakari Ailus it 
was decided not to add this (see the video4linux thread with 
subject "[PATCH 4/6] V4L: Int if: Define new power state changes").

It also wasn't in your original patch.

Regards,

	Hans

>
>  /* Slave interface type. */
> @@ -183,6 +184,14 @@ enum v4l2_int_ioctl_num {
>  	vidioc_int_s_crop_num,
>  	vidioc_int_g_parm_num,
>  	vidioc_int_s_parm_num,
> +	vidioc_int_querystd_num,
> +	vidioc_int_s_std_num,
> +	vidioc_int_enum_input_num,
> +	vidioc_int_g_input_num,
> +	vidioc_int_s_input_num,
> +	vidioc_int_enumoutput_num,
> +	vidioc_int_g_output_num,
> +	vidioc_int_s_output_num,
>
>  	/*
>  	 *
> @@ -284,6 +293,14 @@ V4L2_INT_WRAPPER_1(g_crop, struct v4l2_crop, *);
>  V4L2_INT_WRAPPER_1(s_crop, struct v4l2_crop, *);
>  V4L2_INT_WRAPPER_1(g_parm, struct v4l2_streamparm, *);
>  V4L2_INT_WRAPPER_1(s_parm, struct v4l2_streamparm, *);
> +V4L2_INT_WRAPPER_1(querystd, v4l2_std_id, *);
> +V4L2_INT_WRAPPER_1(s_std, v4l2_std_id, *);
> +V4L2_INT_WRAPPER_1(enum_input, struct v4l2_input, *);
> +V4L2_INT_WRAPPER_1(g_input, int, *);
> +V4L2_INT_WRAPPER_1(s_input, int, );
> +V4L2_INT_WRAPPER_1(enumoutput, struct v4l2_output, *);
> +V4L2_INT_WRAPPER_1(g_output, int, *);
> +V4L2_INT_WRAPPER_1(s_output, int, );
>
>  V4L2_INT_WRAPPER_0(dev_init);
>  V4L2_INT_WRAPPER_0(dev_exit);
> --
> 1.5.6
>
> --
> video4linux-list mailing list
> Unsubscribe
> mailto:video4linux-list-request@redhat.com?subject=unsubscribe
> https://www.redhat.com/mailman/listinfo/video4linux-list


--
video4linux-list mailing list
Unsubscribe mailto:video4linux-list-request@redhat.com?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list

^ permalink raw reply	[flat|nested] 263+ messages in thread

* Re: [PATCH 1/2] Add Input/Output related ioctl support
@ 2008-11-26 17:15     ` Hans Verkuil
  0 siblings, 0 replies; 263+ messages in thread
From: Hans Verkuil @ 2008-11-26 17:15 UTC (permalink / raw)
  To: video4linux-list
  Cc: hvaibhav, davinci-linux-open-source-bounces,
	Karicheri Muralidharan, linux-omap

On Wednesday 26 November 2008 18:04:39 hvaibhav@ti.com wrote:
> From: Vaibhav Hiremath <hvaibhav@ti.com>
>
> Note - Resending again with TVP driver for completeness.
>
> Added ioctl support for query std, set std, enum input,
> get input, set input, enum output, get output and set output.
>
> For sensor kind of slave drivers v4l2-int-device.h provides
> necessary ioctl support, but the ioctls required to interface
> with decoders and encoders are missing. Most of the decoders
> and encoders supports multiple inputs and outputs, like
> S-Video or Composite.
>
> With these ioctl''s user can select the specific input/output.
>
> Signed-off-by: Brijesh Jadav <brijesh.j@ti.com>
> Signed-off-by: Hardik Shah <hardik.shah@ti.com>
> Signed-off-by: Manjunath Hadli <mrh@ti.com>
> Signed-off-by: R Sivaraj <sivaraj@ti.com>
> Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
> Signed-off-by: Karicheri Muralidharan <m-karicheri2@ti.com>
> ---
>  include/media/v4l2-int-device.h |   17 +++++++++++++++++
>  1 files changed, 17 insertions(+), 0 deletions(-)
>
> diff --git a/include/media/v4l2-int-device.h
> b/include/media/v4l2-int-device.h index 9c2df41..2325b2a 100644
> --- a/include/media/v4l2-int-device.h
> +++ b/include/media/v4l2-int-device.h
> @@ -102,6 +102,7 @@ enum v4l2_power {
>  	V4L2_POWER_OFF = 0,
>  	V4L2_POWER_ON,
>  	V4L2_POWER_STANDBY,
> +	V4L2_POWER_RESUME,
>  };

Why is POWER_RESUME added? In an earlier discussion with Sakari Ailus it 
was decided not to add this (see the video4linux thread with 
subject "[PATCH 4/6] V4L: Int if: Define new power state changes").

It also wasn't in your original patch.

Regards,

	Hans

>
>  /* Slave interface type. */
> @@ -183,6 +184,14 @@ enum v4l2_int_ioctl_num {
>  	vidioc_int_s_crop_num,
>  	vidioc_int_g_parm_num,
>  	vidioc_int_s_parm_num,
> +	vidioc_int_querystd_num,
> +	vidioc_int_s_std_num,
> +	vidioc_int_enum_input_num,
> +	vidioc_int_g_input_num,
> +	vidioc_int_s_input_num,
> +	vidioc_int_enumoutput_num,
> +	vidioc_int_g_output_num,
> +	vidioc_int_s_output_num,
>
>  	/*
>  	 *
> @@ -284,6 +293,14 @@ V4L2_INT_WRAPPER_1(g_crop, struct v4l2_crop, *);
>  V4L2_INT_WRAPPER_1(s_crop, struct v4l2_crop, *);
>  V4L2_INT_WRAPPER_1(g_parm, struct v4l2_streamparm, *);
>  V4L2_INT_WRAPPER_1(s_parm, struct v4l2_streamparm, *);
> +V4L2_INT_WRAPPER_1(querystd, v4l2_std_id, *);
> +V4L2_INT_WRAPPER_1(s_std, v4l2_std_id, *);
> +V4L2_INT_WRAPPER_1(enum_input, struct v4l2_input, *);
> +V4L2_INT_WRAPPER_1(g_input, int, *);
> +V4L2_INT_WRAPPER_1(s_input, int, );
> +V4L2_INT_WRAPPER_1(enumoutput, struct v4l2_output, *);
> +V4L2_INT_WRAPPER_1(g_output, int, *);
> +V4L2_INT_WRAPPER_1(s_output, int, );
>
>  V4L2_INT_WRAPPER_0(dev_init);
>  V4L2_INT_WRAPPER_0(dev_exit);
> --
> 1.5.6
>
> --
> video4linux-list mailing list
> Unsubscribe
> mailto:video4linux-list-request@redhat.com?subject=unsubscribe
> https://www.redhat.com/mailman/listinfo/video4linux-list



^ permalink raw reply	[flat|nested] 263+ messages in thread

* Re: [PATCH 2/2] TVP514x Driver with Review comments fixed
  2008-11-26 17:05   ` hvaibhav
  (?)
@ 2008-11-26 17:48   ` Hans Verkuil
  -1 siblings, 0 replies; 263+ messages in thread
From: Hans Verkuil @ 2008-11-26 17:48 UTC (permalink / raw)
  To: video4linux-list
  Cc: linux-omap, Karicheri Muralidharan, davinci-linux-open-source-bounces

Hi Vaibhav,

See below for my comments.

On Wednesday 26 November 2008 18:05:01 hvaibhav@ti.com wrote:
> From: Vaibhav Hiremath <hvaibhav@ti.com>
>
> I have fixed most of the review comments received so far.
> Here are the details:
>
> FIXES
>     Wrong use of CONFIG_VIDEO_ADV_DEBUG option:
>         Implemented module parameter based approach for debugging.
>
>     Bridge driver and access to TVP registers:
>         The bridge driver will now provide only neccessary
> information depending on platform/board/interface. In case of
> TVP5146, we do require clk_polarity, input, number of input, HS/VS
> polarity, etc.. which is interface dependent.
>         All register access and values are limited to TVP driver.
>
>     V4L2-int framework:
>         The new sub-device framework is a new development and will
> take its own time to mature and stabilize. The implementation is
> rightly placed in a different branch for the same reason.
>
>         I beleive till this time, we should move ahead with current
> framework. This patch provides base for V4L2-int capture-master
> driver and patch for the same will be posted in couple of weeks. we
> are in the process of code clean-up.
>
> 	It would be good if we can get this patch into the current codebase
> 	till the 'sub-device' framework stabilizes. The migration can be
> 	planned immediately.

I've no problem with this.

>     i2c table:
>         Specified the name of chip.
>
>     Code cleanup:
>         Multiple changes as suggested.
>
> PENDING (TO DO)
>
>     I2C Legacy framework support:
>         Still no change for Legacy support (Hans agreed on this).
>         Can be added while we move to sub-device framework.
>
>     New sub-device framework support:
>         Will be taken up immediately.
>
> Signed-off-by: Brijesh Jadav <brijesh.j@ti.com>
> Signed-off-by: Hardik Shah <hardik.shah@ti.com>
> Signed-off-by: Manjunath Hadli <mrh@ti.com>
> Signed-off-by: R Sivaraj <sivaraj@ti.com>
> Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
> Signed-off-by: Karicheri Muralidharan <m-karicheri2@ti.com>
> ---
>  drivers/media/video/Kconfig   |   11 +
>  drivers/media/video/Makefile  |    1 +
>  drivers/media/video/tvp514x.c | 1551
> +++++++++++++++++++++++++++++++++++++++++ include/media/tvp514x.h    
>   |  461 ++++++++++++
>  4 files changed, 2024 insertions(+), 0 deletions(-)
>  create mode 100644 drivers/media/video/tvp514x.c
>  create mode 100644 include/media/tvp514x.h
>
> diff --git a/drivers/media/video/Kconfig
> b/drivers/media/video/Kconfig index 47102c2..2e5dc3e 100644
> --- a/drivers/media/video/Kconfig
> +++ b/drivers/media/video/Kconfig
> @@ -361,6 +361,17 @@ config VIDEO_SAA7191
>  	  To compile this driver as a module, choose M here: the
>  	  module will be called saa7191.
>
> +config VIDEO_TVP514X
> +	tristate "Texas Instruments TVP514x video decoder"
> +	depends on VIDEO_V4L2 && I2C
> +	---help---
> +	  This is a Video4Linux2 sensor-level driver for the TI TVP5146/47
> +	  decoder. It is currently working with the TI OMAP3 camera
> +	  controller.
> +
> +	  To compile this driver as a module, choose M here: the
> +	  module will be called tvp514x.
> +
>  config VIDEO_TVP5150
>  	tristate "Texas Instruments TVP5150 video decoder"
>  	depends on VIDEO_V4L2 && I2C
> diff --git a/drivers/media/video/Makefile
> b/drivers/media/video/Makefile index 16962f3..cdbbf38 100644
> --- a/drivers/media/video/Makefile
> +++ b/drivers/media/video/Makefile
> @@ -66,6 +66,7 @@ obj-$(CONFIG_VIDEO_CX88) += cx88/
>  obj-$(CONFIG_VIDEO_EM28XX) += em28xx/
>  obj-$(CONFIG_VIDEO_USBVISION) += usbvision/
>  obj-$(CONFIG_VIDEO_TVP5150) += tvp5150.o
> +obj-$(CONFIG_VIDEO_TVP514X) += tvp514x.o
>  obj-$(CONFIG_VIDEO_PVRUSB2) += pvrusb2/
>  obj-$(CONFIG_VIDEO_MSP3400) += msp3400.o
>  obj-$(CONFIG_VIDEO_CS5345) += cs5345.o
> diff --git a/drivers/media/video/tvp514x.c
> b/drivers/media/video/tvp514x.c new file mode 100644
> index 0000000..187a063
> --- /dev/null
> +++ b/drivers/media/video/tvp514x.c
> @@ -0,0 +1,1551 @@
> +/*
> + * drivers/media/video/tvp514x.c
> + *
> + * TI TVP5146/47 decoder driver
> + *
> + * Copyright (C) 2008 Texas Instruments Inc
> + *
> + * Contributors:
> + *     Brijesh R Jadav <brijesh.j@ti.com>
> + *     Hardik Shah <hardik.shah@ti.com>
> + *     Manjunath Hadli <mrh@ti.com>
> + *     Sivaraj R <sivaraj@ti.com>
> + *     Vaibhav Hiremath <hvaibhav@ti.com>
> + *
> + * This package is free software; you can redistribute it and/or
> modify + * it under the terms of the GNU General Public License
> version 2 as + * published by the Free Software Foundation.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program; if not, write to the Free Software
> + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
> + *
> + */
> +
> +#include <linux/i2c.h>
> +#include <linux/delay.h>
> +#include <linux/videodev2.h>
> +#include <media/v4l2-int-device.h>
> +#include <media/tvp514x.h>
> +
> +#define MODULE_NAME	TVP514X_MODULE_NAME
> +
> +/* Debug functions */
> +#ifdef TVP514X_DEBUG

There is no need to put this under an #ifdef. I would also recommend 
having just one debug level. Usually errors and 'significant info' 
messages are always printed. Debugging messages are printed only when 
debug == 1. Some drivers have a debug level 2 to enable very frequently 
occuring messages. The default debug level is usually 0 since you never 
want debugging messages in a module.

> +static unsigned short debug = 3;
> +module_param(debug, ushort, 0644);
> +MODULE_PARM_DESC(debug,
> +		"\n<n> Debugging information level, from 0 to 3:"
> +		"\n0 = none (use carefully)"
> +		"\n1 = critical errors"
> +		"\n2 = significant informations"
> +		"\n3 = more verbose messages"
> +		"\nLevel 3 is useful for testing only, when only "
> +		"one device is used."
> +		"\nDefault value is "__MODULE_STRING(2)"."
> +		"\n");
> +
> +#define DBG(dev, level, fmt, args...)                               
>     \ +	do {                                                         
>    \ +		if (debug >= (level)) {                                  \
> +			if ((level) == 1)                                \
> +				dev_err(dev, fmt "\n", ## args);         \
> +			else if ((level) == 2)                           \
> +				dev_info(dev, fmt "\n", ## args);        \
> +			else if ((level) >= 3)                           \
> +				dev_info(dev, "[%s:%s:%d] " fmt "\n",    \
> +				__FILE__, __func__, __LINE__ , ## args); \
> +		}                                                        \
> +	} while (0)

Please use the v4l_* macros from v4l2-common.h. They are used in most 
other i2c drivers as well.

> +
> +#define dump_reg(client, reg, val)					\
> +	do {								\
> +		tvp514x_read_reg(client, reg, &val);			\
> +		dev_dbg(&(client)->dev, "Reg(0x%.2X): 0x%.2X\n", reg, val); \
> +	} while (0)
> +
> +#else
> +#define DBG(dev, level, fmt, args...) do {; } while (0)
> +#endif				/* #ifdef TVP514X_DEBUG */
> +
> +/* TVP514x default register values */
> +static struct tvp514x_reg tvp514x_reg_list[] = {
> +	{TOK_WRITE, REG_INPUT_SEL, 0x05},	/* Composite selected */
> +	{TOK_WRITE, REG_AFE_GAIN_CTRL, 0x0F},
> +	{TOK_WRITE, REG_VIDEO_STD, 0x00},	/* Auto mode */
> +	{TOK_WRITE, REG_OPERATION_MODE, 0x00},
> +	{TOK_SKIP, REG_AUTOSWITCH_MASK, 0x3F},
> +	{TOK_WRITE, REG_COLOR_KILLER, 0x10},
> +	{TOK_WRITE, REG_LUMA_CONTROL1, 0x00},
> +	{TOK_WRITE, REG_LUMA_CONTROL2, 0x00},
> +	{TOK_WRITE, REG_LUMA_CONTROL3, 0x02},
> +	{TOK_WRITE, REG_BRIGHTNESS, 0x80},
> +	{TOK_WRITE, REG_CONTRAST, 0x80},
> +	{TOK_WRITE, REG_SATURATION, 0x80},
> +	{TOK_WRITE, REG_HUE, 0x00},
> +	{TOK_WRITE, REG_CHROMA_CONTROL1, 0x00},
> +	{TOK_WRITE, REG_CHROMA_CONTROL2, 0x0E},
> +	{TOK_SKIP, 0x0F, 0x00},	/* Reserved */
> +	{TOK_WRITE, REG_COMP_PR_SATURATION, 0x80},
> +	{TOK_WRITE, REG_COMP_Y_CONTRAST, 0x80},
> +	{TOK_WRITE, REG_COMP_PB_SATURATION, 0x80},
> +	{TOK_SKIP, 0x13, 0x00},	/* Reserved */
> +	{TOK_WRITE, REG_COMP_Y_BRIGHTNESS, 0x80},
> +	{TOK_SKIP, 0x15, 0x00},	/* Reserved */
> +	{TOK_SKIP, REG_AVID_START_PIXEL_LSB, 0x55},	/* NTSC timing */
> +	{TOK_SKIP, REG_AVID_START_PIXEL_MSB, 0x00},
> +	{TOK_SKIP, REG_AVID_STOP_PIXEL_LSB, 0x25},
> +	{TOK_SKIP, REG_AVID_STOP_PIXEL_MSB, 0x03},
> +	{TOK_SKIP, REG_HSYNC_START_PIXEL_LSB, 0x00},	/* NTSC timing */
> +	{TOK_SKIP, REG_HSYNC_START_PIXEL_MSB, 0x00},
> +	{TOK_SKIP, REG_HSYNC_STOP_PIXEL_LSB, 0x40},
> +	{TOK_SKIP, REG_HSYNC_STOP_PIXEL_MSB, 0x00},
> +	{TOK_SKIP, REG_VSYNC_START_LINE_LSB, 0x04},	/* NTSC timing */
> +	{TOK_SKIP, REG_VSYNC_START_LINE_MSB, 0x00},
> +	{TOK_SKIP, REG_VSYNC_STOP_LINE_LSB, 0x07},
> +	{TOK_SKIP, REG_VSYNC_STOP_LINE_MSB, 0x00},
> +	{TOK_SKIP, REG_VBLK_START_LINE_LSB, 0x01},	/* NTSC timing */
> +	{TOK_SKIP, REG_VBLK_START_LINE_MSB, 0x00},
> +	{TOK_SKIP, REG_VBLK_STOP_LINE_LSB, 0x15},
> +	{TOK_SKIP, REG_VBLK_STOP_LINE_MSB, 0x00},
> +	{TOK_SKIP, 0x26, 0x00},	/* Reserved */
> +	{TOK_SKIP, 0x27, 0x00},	/* Reserved */
> +	{TOK_SKIP, REG_FAST_SWTICH_CONTROL, 0xCC},
> +	{TOK_SKIP, 0x29, 0x00},	/* Reserved */
> +	{TOK_SKIP, REG_FAST_SWTICH_SCART_DELAY, 0x00},
> +	{TOK_SKIP, 0x2B, 0x00},	/* Reserved */
> +	{TOK_SKIP, REG_SCART_DELAY, 0x00},
> +	{TOK_SKIP, REG_CTI_DELAY, 0x00},
> +	{TOK_SKIP, REG_CTI_CONTROL, 0x00},
> +	{TOK_SKIP, 0x2F, 0x00},	/* Reserved */
> +	{TOK_SKIP, 0x30, 0x00},	/* Reserved */
> +	{TOK_SKIP, 0x31, 0x00},	/* Reserved */
> +	{TOK_WRITE, REG_SYNC_CONTROL, 0x00},	/* HS, VS active high */
> +	{TOK_WRITE, REG_OUTPUT_FORMATTER1, 0x00},	/* 10-bit BT.656 */
> +	{TOK_WRITE, REG_OUTPUT_FORMATTER2, 0x11},	/* Enable clk & data */
> +	{TOK_WRITE, REG_OUTPUT_FORMATTER3, 0xEE},	/* Enable AVID & FLD */
> +	{TOK_WRITE, REG_OUTPUT_FORMATTER4, 0xAF},	/* Enable VS & HS */
> +	{TOK_WRITE, REG_OUTPUT_FORMATTER5, 0xFF},
> +	{TOK_WRITE, REG_OUTPUT_FORMATTER6, 0xFF},
> +	{TOK_WRITE, REG_CLEAR_LOST_LOCK, 0x01},	/* Clear status */
> +	{TOK_TERM, 0, 0},
> +};
> +
> +/* List of image formats supported by TVP5146/47 decoder
> + * Currently we are using 8 bit mode only, but can be
> + * extended to 10/20 bit mode.
> + */
> +static const struct v4l2_fmtdesc tvp514x_fmt_list[] = {
> +	{
> +	 .index = 0,
> +	 .type = V4L2_BUF_TYPE_VIDEO_CAPTURE,
> +	 .flags = 0,
> +	 .description = "8-bit UYVY 4:2:2 Format",
> +	 .pixelformat = V4L2_PIX_FMT_UYVY,
> +	},
> +};
> +
> +#define TVP514X_NUM_FORMATS		ARRAY_SIZE(tvp514x_fmt_list)
> +
> +/*
> + * Supported standards - These must be ordered according to enum
> tvp514x_std + * order.
> + * Currently supports two standards only, need to add support for
> rest of the + * modes, like SECAM, etc...
> + */
> +static struct tvp514x_std_info tvp514x_std_list[] = {
> +	{
> +	 .width = NTSC_NUM_ACTIVE_PIXELS,
> +	 .height = NTSC_NUM_ACTIVE_LINES,
> +	 .video_std = VIDEO_STD_NTSC_MJ_BIT,
> +	 .standard = {
> +		      .index = 0,
> +		      .id = V4L2_STD_NTSC,
> +		      .name = "NTSC",
> +		      .frameperiod = {1001, 30000},
> +		      .framelines = 525
> +		     },
> +	}, {
> +	 .width = PAL_NUM_ACTIVE_PIXELS,
> +	 .height = PAL_NUM_ACTIVE_LINES,
> +	 .video_std = VIDEO_STD_PAL_BDGHIN_BIT,
> +	 .standard = {
> +		      .index = 1,
> +		      .id = V4L2_STD_PAL,
> +		      .name = "PAL",
> +		      .frameperiod = {1, 25},
> +		      .framelines = 625
> +		     },
> +	},
> +};
> +
> +#define TVP514X_NUM_STANDARDS		ARRAY_SIZE(tvp514x_std_list)
> +
> +/* Supported controls */
> +static const struct tvp514x_ctrl_info tvp514x_ctrl_list[] = {
> +	{
> +	 .reg_address = REG_BRIGHTNESS,
> +	 .query_ctrl = {
> +			.id = V4L2_CID_BRIGHTNESS,
> +			.name = "BRIGHTNESS",
> +			.type = V4L2_CTRL_TYPE_INTEGER,
> +			.minimum = 0,
> +			.maximum = 255,
> +			.step = 1,
> +			.default_value = 128
> +			},
> +	}, {
> +	 .reg_address = REG_CONTRAST,
> +	 .query_ctrl = {
> +			.id = V4L2_CID_CONTRAST,
> +			.name = "CONTRAST",
> +			.type = V4L2_CTRL_TYPE_INTEGER,
> +			.minimum = 0,
> +			.maximum = 255,
> +			.step = 1,
> +			.default_value = 128
> +			},
> +	}, {
> +	 .reg_address = REG_SATURATION,
> +	 .query_ctrl = {
> +			.id = V4L2_CID_SATURATION,
> +			.name = "SATURATION",
> +			.type = V4L2_CTRL_TYPE_INTEGER,
> +			.minimum = 0,
> +			.maximum = 255,
> +			.step = 1,
> +			.default_value = 128
> +			},
> +	}, {
> +	 .reg_address = REG_HUE,
> +	 .query_ctrl = {
> +			.id = V4L2_CID_HUE,
> +			.name = "HUE",
> +			.type = V4L2_CTRL_TYPE_INTEGER,
> +			.minimum = -180,
> +			.maximum = 180,
> +			.step = 180,
> +			.default_value = 0
> +			},
> +	}, {
> +	 .reg_address = REG_AFE_GAIN_CTRL,
> +	 .query_ctrl = {
> +			.id = V4L2_CID_AUTOGAIN,
> +			.name = "Automatic Gain Control",
> +			.type = V4L2_CTRL_TYPE_BOOLEAN,
> +			.minimum = 0,
> +			.maximum = 1,
> +			.step = 1,
> +			.default_value = 1
> +			},
> +	 },
> +};
> +
> +#define TVP514X_NUM_CONTROLS		ARRAY_SIZE(tvp514x_ctrl_list)
> +
> +/*
> + * Read a value from a register in an TVP5146/47 decoder device.
> + * The value is returned in 'val'.
> + * Returns zero if successful, or non-zero otherwise.
> + */
> +static int tvp514x_read_reg(struct i2c_client *client, u8 reg, u8
> *val) +{
> +	int err;
> +	struct i2c_msg msg[2];
> +	u8 data;
> +
> +	if (!client->adapter)
> +		return -ENODEV;
> +
> +	/* [MSG1] fill the register address data */
> +	data = reg;
> +	msg[0].addr = client->addr;
> +	msg[0].len = 1;
> +	msg[0].flags = 0;
> +	msg[0].buf = &data;
> +
> +	/* [MSG2] fill the data rx buffer */
> +	msg[1].addr = client->addr;
> +	msg[1].len = 1;		/* only 1 byte */
> +	msg[1].flags = I2C_M_RD;	/* Read the register values */
> +	msg[1].buf = val;
> +	err = i2c_transfer(client->adapter, msg, 2);
> +	if (err >= 0)
> +		return 0;
> +
> +	DBG(&client->dev, 1,
> +		"read from device 0x%.2x, offset 0x%.2x error %d\n",
> +		client->addr, reg, err);
> +
> +	return err;
> +}
> +
> +/*
> + * Write a value to a register in an TVP5146/47 decoder device.
> + * Returns zero if successful, or non-zero otherwise.
> + */
> +static int tvp514x_write_reg(struct i2c_client *client, u8 reg, u8
> val) +{
> +	int err;
> +	int retry = 0;
> +	struct i2c_msg msg[1];
> +	u8 data[2];
> +
> +	if (!client->adapter)
> +		return -ENODEV;
> +
> +again:
> +	data[0] = reg;		/* Register offset */
> +	data[1] = val;		/* Register value */
> +	msg->addr = client->addr;
> +	msg->len = 2;
> +	msg->flags = 0;		/* write operation */
> +	msg->buf = data;
> +
> +	err = i2c_transfer(client->adapter, msg, 1);
> +	if (err >= 0)
> +		return 0;
> +
> +	DBG(&client->dev, 1,
> +		"wrote 0x%.2x to offset 0x%.2x error %d\n", val, reg, err);
> +	if (retry <= I2C_RETRY_COUNT) {
> +		DBG(&client->dev, 2, "retry ... %d\n", retry);
> +		retry++;
> +		schedule_timeout(msecs_to_jiffies(20));
> +		goto again;
> +	}
> +	return err;
> +}
> +
> +/*
> + * tvp514x_write_regs : Initializes a list of TVP5146/47 registers
> + *		if token is TOK_TERM, then entire write operation terminates
> + *		if token is TOK_DELAY, then a delay of 'val' msec is introduced
> + *		if token is TOK_SKIP, then the register write is skipped
> + *		if token is TOK_WRITE, then the register write is performed
> + *
> + * reglist - list of registers to be written
> + * Returns zero if successful, or non-zero otherwise.
> + */
> +static int tvp514x_write_regs(struct i2c_client *client,
> +			      const struct tvp514x_reg reglist[])
> +{
> +	int err;
> +	const struct tvp514x_reg *next = reglist;
> +
> +	for (; next->token != TOK_TERM; next++) {
> +		if (next->token == TOK_DELAY) {
> +			schedule_timeout(msecs_to_jiffies(next->val));
> +			continue;
> +		}
> +
> +		if (next->token == TOK_SKIP)
> +			continue;
> +
> +		err = tvp514x_write_reg(client, next->reg, (u8) next->val);
> +		if (err) {
> +			DBG(&client->dev, 1, "write failed. Err[%d]\n",
> +				err);
> +			return err;
> +		}
> +	}
> +	return 0;
> +}
> +
> +/*
> + * tvp514x_get_current_std:
> + * Returns the current standard detected by TVP5146/47
> + */
> +static enum tvp514x_std tvp514x_get_current_std(struct
> tvp514x_decoder +						*decoder)
> +{
> +	u8 std, std_status;
> +
> +	if (tvp514x_read_reg(decoder->client, REG_VIDEO_STD, &std))
> +		return STD_INVALID;
> +
> +	if ((std & VIDEO_STD_MASK) == VIDEO_STD_AUTO_SWITCH_BIT) {
> +		/* use the standard status register */
> +		if (tvp514x_read_reg(decoder->client, REG_VIDEO_STD_STATUS,
> +				     &std_status))
> +			return STD_INVALID;
> +	} else
> +		std_status = std;	/* use the standard register itself */
> +
> +	switch (std_status & VIDEO_STD_MASK) {
> +	case VIDEO_STD_NTSC_MJ_BIT:
> +		return STD_NTSC_MJ;
> +
> +	case VIDEO_STD_PAL_BDGHIN_BIT:
> +		return STD_PAL_BDGHIN;
> +
> +	default:
> +		return STD_INVALID;
> +	}
> +
> +	return STD_INVALID;
> +}
> +
> +#ifdef TVP514X_DEBUG
> +/*
> + * TVP5146/47 register dump function
> + */
> +void tvp514x_reg_dump(struct tvp514x_decoder *decoder)
> +{
> +	u8 value;
> +
> +	dump_reg(decoder->client, REG_INPUT_SEL, value);
> +	dump_reg(decoder->client, REG_AFE_GAIN_CTRL, value);
> +	dump_reg(decoder->client, REG_VIDEO_STD, value);
> +	dump_reg(decoder->client, REG_OPERATION_MODE, value);
> +	dump_reg(decoder->client, REG_COLOR_KILLER, value);
> +	dump_reg(decoder->client, REG_LUMA_CONTROL1, value);
> +	dump_reg(decoder->client, REG_LUMA_CONTROL2, value);
> +	dump_reg(decoder->client, REG_LUMA_CONTROL3, value);
> +	dump_reg(decoder->client, REG_BRIGHTNESS, value);
> +	dump_reg(decoder->client, REG_CONTRAST, value);
> +	dump_reg(decoder->client, REG_SATURATION, value);
> +	dump_reg(decoder->client, REG_HUE, value);
> +	dump_reg(decoder->client, REG_CHROMA_CONTROL1, value);
> +	dump_reg(decoder->client, REG_CHROMA_CONTROL2, value);
> +	dump_reg(decoder->client, REG_COMP_PR_SATURATION, value);
> +	dump_reg(decoder->client, REG_COMP_Y_CONTRAST, value);
> +	dump_reg(decoder->client, REG_COMP_PB_SATURATION, value);
> +	dump_reg(decoder->client, REG_COMP_Y_BRIGHTNESS, value);
> +	dump_reg(decoder->client, REG_AVID_START_PIXEL_LSB, value);
> +	dump_reg(decoder->client, REG_AVID_START_PIXEL_MSB, value);
> +	dump_reg(decoder->client, REG_AVID_STOP_PIXEL_LSB, value);
> +	dump_reg(decoder->client, REG_AVID_STOP_PIXEL_MSB, value);
> +	dump_reg(decoder->client, REG_HSYNC_START_PIXEL_LSB, value);
> +	dump_reg(decoder->client, REG_HSYNC_START_PIXEL_MSB, value);
> +	dump_reg(decoder->client, REG_HSYNC_STOP_PIXEL_LSB, value);
> +	dump_reg(decoder->client, REG_HSYNC_STOP_PIXEL_MSB, value);
> +	dump_reg(decoder->client, REG_VSYNC_START_LINE_LSB, value);
> +	dump_reg(decoder->client, REG_VSYNC_START_LINE_MSB, value);
> +	dump_reg(decoder->client, REG_VSYNC_STOP_LINE_LSB, value);
> +	dump_reg(decoder->client, REG_VSYNC_STOP_LINE_MSB, value);
> +	dump_reg(decoder->client, REG_VBLK_START_LINE_LSB, value);
> +	dump_reg(decoder->client, REG_VBLK_START_LINE_MSB, value);
> +	dump_reg(decoder->client, REG_VBLK_STOP_LINE_LSB, value);
> +	dump_reg(decoder->client, REG_VBLK_STOP_LINE_MSB, value);
> +	dump_reg(decoder->client, REG_SYNC_CONTROL, value);
> +	dump_reg(decoder->client, REG_OUTPUT_FORMATTER1, value);
> +	dump_reg(decoder->client, REG_OUTPUT_FORMATTER2, value);
> +	dump_reg(decoder->client, REG_OUTPUT_FORMATTER3, value);
> +	dump_reg(decoder->client, REG_OUTPUT_FORMATTER4, value);
> +	dump_reg(decoder->client, REG_OUTPUT_FORMATTER5, value);
> +	dump_reg(decoder->client, REG_OUTPUT_FORMATTER6, value);
> +	dump_reg(decoder->client, REG_CLEAR_LOST_LOCK, value);
> +}
> +#endif
> +
> +/*
> + * Configure the TVP5146/47 with the current register settings
> + * Returns zero if successful, or non-zero otherwise.
> + */
> +static int tvp514x_configure(struct tvp514x_decoder *decoder)
> +{
> +	int err;
> +
> +	/* common register initialization */
> +	err =
> +	    tvp514x_write_regs(decoder->client, tvp514x_reg_list);
> +	if (err)
> +		return err;
> +
> +#ifdef TVP514X_DEBUG
> +	tvp514x_reg_dump(decoder);
> +#endif
> +
> +	return 0;
> +}
> +
> +/*
> + * Detect if an tvp514x is present, and if so which revision.
> + * A device is considered to be detected if the chip ID (LSB and
> MSB) + * registers match the expected values.
> + * Any value of the rom version register is accepted.
> + * Returns ENODEV error number if no device is detected, or zero
> + * if a device is detected.
> + */
> +static int tvp514x_detect(struct tvp514x_decoder *decoder)
> +{
> +	u8 chip_id_msb, chip_id_lsb, rom_ver;
> +
> +	if (tvp514x_read_reg
> +	    (decoder->client, REG_CHIP_ID_MSB, &chip_id_msb))
> +		return -ENODEV;
> +	if (tvp514x_read_reg
> +	    (decoder->client, REG_CHIP_ID_LSB, &chip_id_lsb))
> +		return -ENODEV;
> +	if (tvp514x_read_reg(decoder->client, REG_ROM_VERSION, &rom_ver))
> +		return -ENODEV;
> +
> +	DBG(&decoder->client->dev, 2,
> +		 "chip id detected msb:0x%x lsb:0x%x rom version:0x%x\n",
> +		 chip_id_msb, chip_id_lsb, rom_ver);
> +	if ((chip_id_msb != TVP514X_CHIP_ID_MSB)
> +		|| ((chip_id_lsb != TVP5146_CHIP_ID_LSB)
> +		&& (chip_id_lsb != TVP5147_CHIP_ID_LSB))) {
> +		/* We didn't read the values we expected, so this must not be
> +		 * an TVP5146/47.
> +		 */
> +		DBG(&decoder->client->dev, 1,
> +			"chip id mismatch msb:0x%x lsb:0x%x\n",
> +			chip_id_msb, chip_id_lsb);
> +		return -ENODEV;
> +	}
> +
> +	decoder->ver = rom_ver;
> +	decoder->state = STATE_DETECTED;

Please add a line like this:

        v4l_info(client, "%s found @ 0x%x (%s)\n", client->name,
                        client->addr << 1, client->adapter->name);

It is good to log that the driver has detected a chip and on which 
adapter and address. The v4l_info above is the standard text that is 
printed.

> +
> +	return 0;
> +}
> +
> +/*
> + * following are decoder interface functions implemented by
> + * TVP5146/47 decoder driver.
> + */
> +
> +/**
> + * ioctl_querystd - V4L2 decoder interface handler for
> VIDIOC_QUERYSTD ioctl + * @s: pointer to standard V4L2 device
> structure
> + * @std_id: standard V4L2 std_id ioctl enum
> + *
> + * Returns the current standard detected by TVP5146/47. If no active
> input is + * detected, returns -EINVAL
> + */
> +static int ioctl_querystd(struct v4l2_int_device *s, v4l2_std_id
> *std_id) +{
> +	struct tvp514x_decoder *decoder = s->priv;
> +	enum tvp514x_std current_std;
> +	enum tvp514x_input input_sel;
> +	u8 sync_lock_status, lock_mask;
> +
> +	if (std_id == NULL)
> +		return -EINVAL;
> +
> +	/* get the current standard */
> +	current_std = tvp514x_get_current_std(decoder);
> +	if (current_std == STD_INVALID)
> +		return -EINVAL;
> +
> +	/* check whether signal is locked */
> +	if (tvp514x_read_reg
> +	    (decoder->client, REG_STATUS1, &sync_lock_status))
> +		return -EINVAL;
> +
> +	input_sel =
> decoder->pdata->input_list[decoder->inputidx].input_sel; +
> +	switch (input_sel) {
> +	case INPUT_CVBS_VI1A:
> +	case INPUT_CVBS_VI1B:
> +	case INPUT_CVBS_VI1C:
> +	case INPUT_CVBS_VI2A:
> +	case INPUT_CVBS_VI2B:
> +	case INPUT_CVBS_VI2C:
> +	case INPUT_CVBS_VI3A:
> +	case INPUT_CVBS_VI3B:
> +	case INPUT_CVBS_VI3C:
> +	case INPUT_CVBS_VI4A:
> +		lock_mask = STATUS_CLR_SUBCAR_LOCK_BIT |
> +			STATUS_HORZ_SYNC_LOCK_BIT |
> +			STATUS_VIRT_SYNC_LOCK_BIT;
> +		break;
> +
> +	case INPUT_SVIDEO_VI2A_VI1A:
> +	case INPUT_SVIDEO_VI2B_VI1B:
> +	case INPUT_SVIDEO_VI2C_VI1C:
> +	case INPUT_SVIDEO_VI2A_VI3A:
> +	case INPUT_SVIDEO_VI2B_VI3B:
> +	case INPUT_SVIDEO_VI2C_VI3C:
> +	case INPUT_SVIDEO_VI4A_VI1A:
> +	case INPUT_SVIDEO_VI4A_VI1B:
> +	case INPUT_SVIDEO_VI4A_VI1C:
> +	case INPUT_SVIDEO_VI4A_VI3A:
> +	case INPUT_SVIDEO_VI4A_VI3B:
> +	case INPUT_SVIDEO_VI4A_VI3C:
> +		lock_mask = STATUS_HORZ_SYNC_LOCK_BIT |
> +			STATUS_VIRT_SYNC_LOCK_BIT;
> +		break;
> +		/*Need to add other interfaces*/
> +	default:
> +		return -EINVAL;
> +	}
> +
> +	if (lock_mask != (sync_lock_status & lock_mask))
> +		return -EINVAL;	/* No input detected */
> +
> +	decoder->current_std = current_std;
> +	*std_id = decoder->std_list[current_std].standard.id;
> +
> +	DBG(&decoder->client->dev, 3,
> +			"Current STD: %s",
> +			decoder->std_list[current_std].standard.name);
> +	return 0;
> +}
> +
> +/**
> + * ioctl_s_std - V4L2 decoder interface handler for VIDIOC_S_STD
> ioctl + * @s: pointer to standard V4L2 device structure
> + * @std_id: standard V4L2 v4l2_std_id ioctl enum
> + *
> + * If std_id is supported, sets the requested standard. Otherwise,
> returns + * -EINVAL
> + */
> +static int ioctl_s_std(struct v4l2_int_device *s, v4l2_std_id
> *std_id) +{
> +	struct tvp514x_decoder *decoder = s->priv;
> +	int err, i;
> +
> +	if (std_id == NULL)
> +		return -EINVAL;
> +
> +	for (i = 0; i < decoder->num_stds; i++)
> +		if (*std_id & decoder->std_list[i].standard.id)
> +			break;
> +
> +	if (i == decoder->num_stds)
> +		return -EINVAL;
> +
> +	err = tvp514x_write_reg(decoder->client, REG_VIDEO_STD,
> +				decoder->std_list[i].video_std);
> +	if (err)
> +		return err;
> +
> +	decoder->current_std = i;
> +	tvp514x_reg_list[REG_VIDEO_STD].val =
> +	    decoder->std_list[i].video_std;
> +
> +	DBG(&decoder->client->dev, 3,
> +			"Standard set to: %s",
> +			decoder->std_list[i].standard.name);
> +	return 0;
> +}
> +
> +/**
> + * ioctl_enum_input - V4L2 decoder interface handler for
> VIDIOC_ENUMINPUT ioctl + * @s: pointer to standard V4L2 device
> structure
> + * @input: standard V4L2 VIDIOC_ENUMINPUT ioctl structure
> + *
> + * If index is valid, returns the description of the input.
> Otherwise, returns + * -EINVAL if any error occurs
> + */
> +static int
> +ioctl_enum_input(struct v4l2_int_device *s, struct v4l2_input
> *input) +{
> +	struct tvp514x_decoder *decoder = s->priv;
> +	int index;
> +
> +	if (input == NULL)
> +		return -EINVAL;
> +
> +	index = input->index;
> +	if ((index >= decoder->pdata->num_inputs) || (index < 0))
> +		return -EINVAL;	/* Index out of bound */
> +
> +	memcpy(input, &decoder->pdata->input_list[index].input,
> +		sizeof(struct v4l2_input));
> +
> +	DBG(&decoder->client->dev, 3,
> +			"Current input is: index - %d (%s)",
> +			decoder->pdata->input_list[index].input.index,
> +			decoder->pdata->input_list[index].input.name);
> +	return 0;
> +}
> +
> +/**
> + * ioctl_s_input - V4L2 decoder interface handler for VIDIOC_S_INPUT
> ioctl + * @s: pointer to standard V4L2 device structure
> + * @index: number of the input
> + *
> + * If index is valid, selects the requested input. Otherwise,
> returns -EINVAL if + * the input is not supported or there is no
> active signal present in the + * selected input.
> + */

What sort of input are we talking about here? The VIDIOC_S_INPUT ioctl 
deals with user-visible inputs (e.g. S-Video, HDMI, DVI, etc). That is 
quite different from the inputs on the chip-level. An input there 
corresponds to a pin. The VIDIOC_INT_S_VIDEO_ROUTING ioctl exists for 
that purpose. Mixing these two will leads to very hard to maintain code 
(really, I had to fix a bunch of drivers in the past that did it all 
wrong).

If the s_input function is meant for chip inputs, then I strongly 
recommend that it is renamed (ioctl_s_routing or ioctl_s_input_pins) to 
prevent this confusion.

> +static int ioctl_s_input(struct v4l2_int_device *s, int index)
> +{
> +	struct tvp514x_decoder *decoder = s->priv;
> +	int err;
> +	enum tvp514x_input input_sel;
> +	enum tvp514x_std current_std = STD_INVALID;
> +	u8 sync_lock_status, lock_mask;
> +	int try_count = LOCK_RETRY_COUNT;
> +
> +	if ((index >= decoder->pdata->num_inputs) || (index < 0))
> +		return -EINVAL;	/* Index out of bound */
> +
> +	/* Get the register value to be written to select the requested
> input */ +	input_sel = decoder->pdata->input_list[index].input_sel;
> +	err = tvp514x_write_reg(decoder->client, REG_INPUT_SEL, input_sel);
> +	if (err)
> +		return err;
> +
> +	decoder->inputidx = index;
> +	tvp514x_reg_list[REG_INPUT_SEL].val = input_sel;
> +
> +	/* Clear status */
> +	msleep(LOCK_RETRY_DELAY);
> +	err =
> +	    tvp514x_write_reg(decoder->client, REG_CLEAR_LOST_LOCK, 0x01);
> +	if (err)
> +		return err;
> +
> +	switch (input_sel) {
> +	case INPUT_CVBS_VI1A:
> +	case INPUT_CVBS_VI1B:
> +	case INPUT_CVBS_VI1C:
> +	case INPUT_CVBS_VI2A:
> +	case INPUT_CVBS_VI2B:
> +	case INPUT_CVBS_VI2C:
> +	case INPUT_CVBS_VI3A:
> +	case INPUT_CVBS_VI3B:
> +	case INPUT_CVBS_VI3C:
> +	case INPUT_CVBS_VI4A:
> +		lock_mask = STATUS_CLR_SUBCAR_LOCK_BIT |
> +			STATUS_HORZ_SYNC_LOCK_BIT |
> +			STATUS_VIRT_SYNC_LOCK_BIT;
> +		break;
> +
> +	case INPUT_SVIDEO_VI2A_VI1A:
> +	case INPUT_SVIDEO_VI2B_VI1B:
> +	case INPUT_SVIDEO_VI2C_VI1C:
> +	case INPUT_SVIDEO_VI2A_VI3A:
> +	case INPUT_SVIDEO_VI2B_VI3B:
> +	case INPUT_SVIDEO_VI2C_VI3C:
> +	case INPUT_SVIDEO_VI4A_VI1A:
> +	case INPUT_SVIDEO_VI4A_VI1B:
> +	case INPUT_SVIDEO_VI4A_VI1C:
> +	case INPUT_SVIDEO_VI4A_VI3A:
> +	case INPUT_SVIDEO_VI4A_VI3B:
> +	case INPUT_SVIDEO_VI4A_VI3C:
> +		lock_mask = STATUS_HORZ_SYNC_LOCK_BIT |
> +			STATUS_VIRT_SYNC_LOCK_BIT;
> +		break;
> +	/*Need to add other interfaces*/
> +	default:
> +		return -EINVAL;
> +	}
> +
> +	while (try_count-- > 0) {
> +		/* Allow decoder to sync up with new input */
> +		msleep(LOCK_RETRY_DELAY);
> +
> +		/* get the current standard for future reference */
> +		current_std = tvp514x_get_current_std(decoder);
> +		if (current_std == STD_INVALID)
> +			continue;
> +
> +		if (tvp514x_read_reg(decoder->client, REG_STATUS1,
> +					&sync_lock_status))
> +			return -EINVAL;
> +
> +		if (lock_mask == (sync_lock_status & lock_mask))
> +			break;	/* Input detected */
> +	}
> +
> +	if ((current_std == STD_INVALID) || (try_count < 0))
> +		return -EINVAL;
> +
> +	decoder->current_std = current_std;
> +
> +	DBG(&decoder->client->dev, 3,
> +			"Input set to: index - %d (%s)",
> +			decoder->pdata->input_list[index].input.index,
> +			decoder->pdata->input_list[index].input.name);
> +	return 0;
> +}
> +
> +/**
> + * ioctl_g_input - V4L2 decoder interface handler for VIDIOC_G_INPUT
> ioctl + * @s: pointer to standard V4L2 device structure
> + * @index: returns the current selected input
> + *
> + * Returns the current selected input. Returns -EINVAL if any error
> occurs + */
> +static int ioctl_g_input(struct v4l2_int_device *s, int *index)
> +{
> +	struct tvp514x_decoder *decoder = s->priv;
> +	int err = -EINVAL, i, inputidx;
> +
> +	if (index == NULL)
> +		return -EINVAL;
> +
> +	/* Search through the input list for active inputs */
> +	inputidx = decoder->inputidx;
> +	for (i = 0; i < decoder->pdata->num_inputs; i++) {
> +		inputidx++;	/* Move to next input */
> +		if (inputidx >= decoder->pdata->num_inputs)
> +			inputidx = 0;	/* fall back to first input */
> +
> +		err = ioctl_s_input(s, inputidx);
> +		if (!err) {
> +			/* Active input found - select it and return success */
> +			*index = inputidx;
> +			return 0;
> +		}
> +	}
> +
> +	return err;
> +}
> +
> +/**
> + * ioctl_queryctrl - V4L2 decoder interface handler for
> VIDIOC_QUERYCTRL ioctl + * @s: pointer to standard V4L2 device
> structure
> + * @qc: standard V4L2 VIDIOC_QUERYCTRL ioctl structure
> + *
> + * If the requested control is supported, returns the control
> information + * from the ctrl_list[] array. Otherwise, returns
> -EINVAL if the + * control is not supported.
> + */
> +static int
> +ioctl_queryctrl(struct v4l2_int_device *s, struct v4l2_queryctrl
> *qctrl) +{
> +	struct tvp514x_decoder *decoder = s->priv;
> +	int id, index;
> +	const struct tvp514x_ctrl_info *control = NULL;
> +
> +	if (qctrl == NULL)
> +		return -EINVAL;
> +
> +	id = qctrl->id;
> +	memset(qctrl, 0, sizeof(struct v4l2_queryctrl));
> +	qctrl->id = id;
> +
> +	for (index = 0; index < decoder->num_ctrls; index++) {
> +		control = &decoder->ctrl_list[index];
> +		if (control->query_ctrl.id == qctrl->id)
> +			break;	/* Match found */
> +	}
> +	if (index == decoder->num_ctrls)
> +		return -EINVAL;	/* Index out of bound */
> +
> +	memcpy(qctrl, &control->query_ctrl, sizeof(struct v4l2_queryctrl));
> +
> +	DBG(&decoder->client->dev, 3,
> +			"Query Cotrol: %s : Min - %d, Max - %d, Def - %d",

Typo: 'Cotrol' instead of 'Control'. Happens multiple times in the 
source.

> +			control->query_ctrl.name,
> +			control->query_ctrl.minimum,
> +			control->query_ctrl.maximum,
> +			control->query_ctrl.default_value);
> +	return 0;
> +}
> +
> +/**
> + * ioctl_g_ctrl - V4L2 decoder interface handler for VIDIOC_G_CTRL
> ioctl + * @s: pointer to standard V4L2 device structure
> + * @vc: standard V4L2 VIDIOC_G_CTRL ioctl structure
> + *
> + * If the requested control is supported, returns the control's
> current + * value from the decoder. Otherwise, returns -EINVAL if the
> control is not + * supported.
> + */
> +static int
> +ioctl_g_ctrl(struct v4l2_int_device *s, struct v4l2_control *ctrl)
> +{
> +	struct tvp514x_decoder *decoder = s->priv;
> +	int err, index;
> +	u8 val;
> +	int value;
> +	const struct tvp514x_ctrl_info *control = NULL;
> +
> +	if (ctrl == NULL)
> +		return -EINVAL;
> +
> +	for (index = 0; index < decoder->num_ctrls; index++) {
> +		control = &decoder->ctrl_list[index];
> +		if (control->query_ctrl.id == ctrl->id)
> +			break;	/* Match found */
> +	}
> +	if (index == decoder->num_ctrls)
> +		return -EINVAL;	/* Index out of bound */
> +
> +	err =
> +	    tvp514x_read_reg(decoder->client, control->reg_address, &val);
> +	if (err < 0)
> +		return err;
> +
> +	/* cross check */
> +	if (val != tvp514x_reg_list[control->reg_address].val)
> +		return -EINVAL;	/* Driver & TVP5146/47 setting mismatch */
> +
> +	value = val;
> +	if (V4L2_CID_AUTOGAIN == ctrl->id) {
> +		if ((value & 0x3) == 3)
> +			value = 1;
> +		else
> +			value = 0;
> +	}
> +
> +	if (V4L2_CID_HUE == ctrl->id) {
> +		if (value == 0x7F)
> +			value = 180;
> +		else if (value == 0x80)
> +			value = -180;
> +		else
> +			value = 0;
> +	}
> +
> +	ctrl->value = value;
> +
> +	DBG(&decoder->client->dev, 3,
> +			"Get Cotrol: %s - %d",
> +			control->query_ctrl.name, value);
> +	return err;
> +}
> +
> +/**
> + * ioctl_s_ctrl - V4L2 decoder interface handler for VIDIOC_S_CTRL
> ioctl + * @s: pointer to standard V4L2 device structure
> + * @vc: standard V4L2 VIDIOC_S_CTRL ioctl structure
> + *
> + * If the requested control is supported, sets the control's current
> + * value in HW. Otherwise, returns -EINVAL if the control is not
> supported. + */
> +static int
> +ioctl_s_ctrl(struct v4l2_int_device *s, struct v4l2_control *ctrl)
> +{
> +	struct tvp514x_decoder *decoder = s->priv;
> +	int err, value, index;
> +	const struct tvp514x_ctrl_info *control = NULL;
> +
> +	if (ctrl == NULL)
> +		return -EINVAL;
> +
> +	value = (__s32) ctrl->value;
> +	for (index = 0; index < decoder->num_ctrls; index++) {
> +		control = &decoder->ctrl_list[index];
> +		if (control->query_ctrl.id == ctrl->id)
> +			break;	/* Match found */
> +	}
> +	if (index == decoder->num_ctrls)
> +		return -EINVAL;	/* Index out of bound */
> +
> +	if (V4L2_CID_AUTOGAIN == ctrl->id) {
> +		if (value == 1)
> +			value = 0x0F;
> +		else if (value == 0)
> +			value = 0x0C;
> +		else
> +			return -ERANGE;
> +	} else if (V4L2_CID_HUE == ctrl->id) {
> +		if (value == 180)
> +			value = 0x7F;
> +		else if (value == -180)
> +			value = 0x80;
> +		else if (value == 0)
> +			value = 0;
> +		else
> +			return -ERANGE;
> +	} else {
> +		if ((value < control->query_ctrl.minimum)
> +			|| (value > control->query_ctrl.maximum))
> +			return -ERANGE;
> +	}
> +
> +	err =
> +	    tvp514x_write_reg(decoder->client, control->reg_address,
> +				value);
> +	if (err < 0)
> +		return err;
> +
> +	tvp514x_reg_list[control->reg_address].val = value;
> +
> +	DBG(&decoder->client->dev, 3,
> +			"Set Cotrol: %s - %d",
> +			control->query_ctrl.name, value);
> +	return err;
> +}
> +
> +/**
> + * ioctl_enum_fmt_cap - Implement the CAPTURE buffer VIDIOC_ENUM_FMT
> ioctl + * @s: pointer to standard V4L2 device structure
> + * @fmt: standard V4L2 VIDIOC_ENUM_FMT ioctl structure
> + *
> + * Implement the VIDIOC_ENUM_FMT ioctl to enumerate supported
> formats + */
> +static int
> +ioctl_enum_fmt_cap(struct v4l2_int_device *s, struct v4l2_fmtdesc
> *fmt) +{
> +	struct tvp514x_decoder *decoder = s->priv;
> +	int index;
> +
> +	if (fmt == NULL)
> +		return -EINVAL;
> +
> +	index = fmt->index;
> +	if ((index >= decoder->num_fmts) || (index < 0))
> +		return -EINVAL;	/* Index out of bound */
> +
> +	if (fmt->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
> +		return -EINVAL;	/* only capture is supported */
> +
> +	memcpy(fmt, &decoder->fmt_list[index],
> +		sizeof(struct v4l2_fmtdesc));
> +
> +	DBG(&decoder->client->dev, 3,
> +			"Current FMT: index - %d (%s)",
> +			decoder->fmt_list[index].index,
> +			decoder->fmt_list[index].description);
> +	return 0;
> +}
> +
> +/**
> + * ioctl_try_fmt_cap - Implement the CAPTURE buffer VIDIOC_TRY_FMT
> ioctl + * @s: pointer to standard V4L2 device structure
> + * @f: pointer to standard V4L2 VIDIOC_TRY_FMT ioctl structure
> + *
> + * Implement the VIDIOC_TRY_FMT ioctl for the CAPTURE buffer type.
> This + * ioctl is used to negotiate the image capture size and pixel
> format + * without actually making it take effect.
> + */
> +static int
> +ioctl_try_fmt_cap(struct v4l2_int_device *s, struct v4l2_format *f)
> +{
> +	struct tvp514x_decoder *decoder = s->priv;
> +	int ifmt;
> +	struct v4l2_pix_format *pix;
> +	enum tvp514x_std current_std;
> +
> +	if (f == NULL)
> +		return -EINVAL;
> +
> +	if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
> +		f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
> +
> +	pix = &f->fmt.pix;
> +
> +	/* Calculate height and width based on current standard */
> +	current_std = tvp514x_get_current_std(decoder);
> +	if (current_std == STD_INVALID)
> +		return -EINVAL;
> +
> +	decoder->current_std = current_std;
> +	pix->width = decoder->std_list[current_std].width;
> +	pix->height = decoder->std_list[current_std].height;
> +
> +	for (ifmt = 0; ifmt < decoder->num_fmts; ifmt++) {
> +		if (pix->pixelformat ==
> +			decoder->fmt_list[ifmt].pixelformat)
> +			break;
> +	}
> +	if (ifmt == decoder->num_fmts)
> +		ifmt = 0;	/* None of the format matched, select default */
> +	pix->pixelformat = decoder->fmt_list[ifmt].pixelformat;
> +
> +	pix->field = V4L2_FIELD_INTERLACED;
> +	pix->bytesperline = pix->width * 2;
> +	pix->sizeimage = pix->bytesperline * pix->height;
> +	pix->colorspace = V4L2_COLORSPACE_SMPTE170M;
> +	pix->priv = 0;
> +
> +	DBG(&decoder->client->dev, 3,
> +			"Try FMT: pixelformat - %s, bytesperline - %d"
> +			"Width - %d, Height - %d",
> +			decoder->fmt_list[ifmt].description, pix->bytesperline,
> +			pix->width, pix->height);
> +	return 0;
> +}
> +
> +/**
> + * ioctl_s_fmt_cap - V4L2 decoder interface handler for VIDIOC_S_FMT
> ioctl + * @s: pointer to standard V4L2 device structure
> + * @f: pointer to standard V4L2 VIDIOC_S_FMT ioctl structure
> + *
> + * If the requested format is supported, configures the HW to use
> that + * format, returns error code if format not supported or HW
> can't be + * correctly configured.
> + */
> +static int
> +ioctl_s_fmt_cap(struct v4l2_int_device *s, struct v4l2_format *f)
> +{
> +	struct tvp514x_decoder *decoder = s->priv;
> +	struct v4l2_pix_format *pix;
> +	int rval;
> +
> +	if (f == NULL)
> +		return -EINVAL;
> +
> +	if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
> +		return -EINVAL;	/* only capture is supported */
> +
> +	pix = &f->fmt.pix;
> +	rval = ioctl_try_fmt_cap(s, f);
> +	if (rval)
> +		return rval;
> +	else
> +		decoder->pix = *pix;
> +
> +	return rval;
> +}
> +
> +/**
> + * ioctl_g_fmt_cap - V4L2 decoder interface handler for
> ioctl_g_fmt_cap + * @s: pointer to standard V4L2 device structure
> + * @f: pointer to standard V4L2 v4l2_format structure
> + *
> + * Returns the decoder's current pixel format in the v4l2_format
> + * parameter.
> + */
> +static int
> +ioctl_g_fmt_cap(struct v4l2_int_device *s, struct v4l2_format *f)
> +{
> +	struct tvp514x_decoder *decoder = s->priv;
> +
> +	if (f == NULL)
> +		return -EINVAL;
> +
> +	if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
> +		return -EINVAL;	/* only capture is supported */
> +
> +	f->fmt.pix = decoder->pix;
> +
> +	DBG(&decoder->client->dev, 3,
> +			"Current FMT: bytesperline - %d"
> +			"Width - %d, Height - %d",
> +			decoder->pix.bytesperline,
> +			decoder->pix.width, decoder->pix.height);
> +	return 0;
> +}
> +
> +/**
> + * ioctl_g_parm - V4L2 decoder interface handler for VIDIOC_G_PARM
> ioctl + * @s: pointer to standard V4L2 device structure
> + * @a: pointer to standard V4L2 VIDIOC_G_PARM ioctl structure
> + *
> + * Returns the decoder's video CAPTURE parameters.
> + */
> +static int
> +ioctl_g_parm(struct v4l2_int_device *s, struct v4l2_streamparm *a)
> +{
> +	struct tvp514x_decoder *decoder = s->priv;
> +	struct v4l2_captureparm *cparm;
> +	enum tvp514x_std current_std;
> +
> +	if (a == NULL)
> +		return -EINVAL;
> +
> +	if (a->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
> +		return -EINVAL;	/* only capture is supported */
> +
> +	memset(a, 0, sizeof(*a));
> +	a->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
> +
> +	/* get the current standard */
> +	current_std = tvp514x_get_current_std(decoder);
> +	decoder->current_std = current_std;
> +
> +	cparm = &a->parm.capture;
> +	cparm->capability = V4L2_CAP_TIMEPERFRAME;
> +	cparm->timeperframe
> +	    = decoder->std_list[current_std].standard.frameperiod;
> +
> +	return 0;
> +}
> +
> +/**
> + * ioctl_s_parm - V4L2 decoder interface handler for VIDIOC_S_PARM
> ioctl + * @s: pointer to standard V4L2 device structure
> + * @a: pointer to standard V4L2 VIDIOC_S_PARM ioctl structure
> + *
> + * Configures the decoder to use the input parameters, if possible.
> If + * not possible, returns the appropriate error code.
> + */
> +static int
> +ioctl_s_parm(struct v4l2_int_device *s, struct v4l2_streamparm *a)
> +{
> +	struct tvp514x_decoder *decoder = s->priv;
> +	struct v4l2_fract *timeperframe;
> +	enum tvp514x_std current_std;
> +
> +	if (a == NULL)
> +		return -EINVAL;
> +
> +	if (a->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
> +		return -EINVAL;	/* only capture is supported */
> +
> +	timeperframe = &a->parm.capture.timeperframe;
> +
> +	/* get the current standard */
> +	current_std = tvp514x_get_current_std(decoder);
> +	decoder->current_std = current_std;
> +
> +	*timeperframe =
> +	    decoder->std_list[current_std].standard.frameperiod;
> +
> +	return 0;
> +}
> +
> +/**
> + * ioctl_g_ifparm - V4L2 decoder interface handler for
> vidioc_int_g_ifparm_num + * @s: pointer to standard V4L2 device
> structure
> + * @p: pointer to standard V4L2 vidioc_int_g_ifparm_num ioctl
> structure + *
> + * Gets slave interface parameters.
> + * Calculates the required xclk value to support the requested
> + * clock parameters in p. This value is returned in the p
> + * parameter.
> + */
> +static int ioctl_g_ifparm(struct v4l2_int_device *s, struct
> v4l2_ifparm *p) +{
> +	struct tvp514x_decoder *decoder = s->priv;
> +	int rval;
> +
> +	if (p == NULL)
> +		return -EINVAL;
> +
> +	if (NULL == decoder->pdata->ifparm)
> +		return -EINVAL;
> +
> +	rval = decoder->pdata->ifparm(p);
> +	if (rval) {
> +		DBG(&decoder->client->dev, 1, "error. Err[%d]\n", rval);
> +		return rval;
> +	}
> +
> +	p->u.bt656.clock_curr = TVP514X_XCLK_BT656;
> +
> +	return 0;
> +}
> +
> +/**
> + * ioctl_g_priv - V4L2 decoder interface handler for
> vidioc_int_g_priv_num + * @s: pointer to standard V4L2 device
> structure
> + * @p: void pointer to hold decoder's private data address
> + *
> + * Returns device's (decoder's) private data area address in p
> parameter + */
> +static int ioctl_g_priv(struct v4l2_int_device *s, void *p)
> +{
> +	struct tvp514x_decoder *decoder = s->priv;
> +
> +	if (NULL == decoder->pdata->priv_data_set)
> +		return -EINVAL;
> +
> +	return decoder->pdata->priv_data_set(p);
> +}
> +
> +/**
> + * ioctl_s_power - V4L2 decoder interface handler for
> vidioc_int_s_power_num + * @s: pointer to standard V4L2 device
> structure
> + * @on: power state to which device is to be set
> + *
> + * Sets devices power state to requrested state, if possible.
> + */
> +static int ioctl_s_power(struct v4l2_int_device *s, enum v4l2_power
> on) +{
> +	struct tvp514x_decoder *decoder = s->priv;
> +	int err = 0;
> +
> +	switch (on) {
> +	case V4L2_POWER_OFF:
> +		/* Power Down Sequence */
> +		err =
> +		    tvp514x_write_reg(decoder->client, REG_OPERATION_MODE,
> +					0x01);
> +		/* Disable mux for TVP5146/47 decoder data path */
> +		if (decoder->pdata->power_set)
> +			err |= decoder->pdata->power_set(on);
> +		break;
> +
> +	case V4L2_POWER_STANDBY:
> +		if (decoder->pdata->power_set)
> +			err = decoder->pdata->power_set(on);
> +		break;
> +
> +	case V4L2_POWER_ON:
> +		/* Enable mux for TVP5146/47 decoder data path */
> +		if (decoder->pdata->power_set)
> +			err = decoder->pdata->power_set(on);
> +
> +		/* Power Up Sequence */
> +		err |=
> +		    tvp514x_write_reg(decoder->client, REG_OPERATION_MODE,
> +					0x01);
> +		err |=
> +		    tvp514x_write_reg(decoder->client, REG_OPERATION_MODE,
> +					0x00);
> +
> +		/* Detect the sensor is not already detected */
> +		if (decoder->state == STATE_NOT_DETECTED) {
> +			err |= tvp514x_detect(decoder);
> +			if (err < 0) {
> +				DBG(&decoder->client->dev, 1,
> +					"Unable to detect decoder\n");
> +				return err;
> +			}
> +			DBG(&decoder->client->dev, 2,
> +				 "chip version 0x%.2x detected\n",
> +				 decoder->ver);
> +		}
> +		break;
> +
> +	case V4L2_POWER_RESUME:
> +		if (decoder->pdata->power_set)
> +			err = decoder->pdata->power_set(on);
> +		if (decoder->state == STATE_DETECTED)
> +			err |= tvp514x_configure(decoder);
> +		break;
> +
> +	default:
> +		err = -ENODEV;
> +		break;
> +	}
> +
> +	return err;
> +}
> +
> +/**
> + * ioctl_init - V4L2 decoder interface handler for VIDIOC_INT_INIT
> + * @s: pointer to standard V4L2 device structure
> + *
> + * Initialize the decoder device (calls tvp514x_configure())
> + */
> +static int ioctl_init(struct v4l2_int_device *s)
> +{
> +	struct tvp514x_decoder *decoder = s->priv;
> +
> +	/* Set default standard to auto */
> +	tvp514x_reg_list[REG_VIDEO_STD].val =
> +	    VIDEO_STD_AUTO_SWITCH_BIT;
> +
> +	return tvp514x_configure(decoder);
> +}
> +
> +/**
> + * ioctl_dev_exit - V4L2 decoder interface handler for
> vidioc_int_dev_exit_num + * @s: pointer to standard V4L2 device
> structure
> + *
> + * Delinitialise the dev. at slave detach. The complement of
> ioctl_dev_init. + */
> +static int ioctl_dev_exit(struct v4l2_int_device *s)
> +{
> +	return 0;
> +}
> +
> +/**
> + * ioctl_dev_init - V4L2 decoder interface handler for
> vidioc_int_dev_init_num + * @s: pointer to standard V4L2 device
> structure
> + *
> + * Initialise the device when slave attaches to the master. Returns
> 0 if + * TVP5146/47 device could be found, otherwise returns
> appropriate error. + */
> +static int ioctl_dev_init(struct v4l2_int_device *s)
> +{
> +	struct tvp514x_decoder *decoder = s->priv;
> +	int err;
> +
> +	err = tvp514x_detect(decoder);
> +	if (err < 0) {
> +		DBG(&decoder->client->dev, 1,
> +			"Unable to detect decoder\n");
> +		return err;
> +	}
> +
> +	DBG(&decoder->client->dev, 2,
> +		 "chip version 0x%.2x detected\n", decoder->ver);
> +
> +	return 0;
> +}
> +
> +static struct v4l2_int_ioctl_desc tvp514x_ioctl_desc[] = {
> +	{vidioc_int_dev_init_num, (v4l2_int_ioctl_func*) ioctl_dev_init},
> +	{vidioc_int_dev_exit_num, (v4l2_int_ioctl_func*) ioctl_dev_exit},
> +	{vidioc_int_s_power_num, (v4l2_int_ioctl_func*) ioctl_s_power},
> +	{vidioc_int_g_priv_num, (v4l2_int_ioctl_func*) ioctl_g_priv},
> +	{vidioc_int_g_ifparm_num, (v4l2_int_ioctl_func*) ioctl_g_ifparm},
> +	{vidioc_int_init_num, (v4l2_int_ioctl_func*) ioctl_init},
> +	{vidioc_int_enum_fmt_cap_num,
> +	 (v4l2_int_ioctl_func *) ioctl_enum_fmt_cap},
> +	{vidioc_int_try_fmt_cap_num,
> +	 (v4l2_int_ioctl_func *) ioctl_try_fmt_cap},
> +	{vidioc_int_g_fmt_cap_num,
> +	 (v4l2_int_ioctl_func *) ioctl_g_fmt_cap},
> +	{vidioc_int_s_fmt_cap_num,
> +	 (v4l2_int_ioctl_func *) ioctl_s_fmt_cap},
> +	{vidioc_int_g_parm_num, (v4l2_int_ioctl_func *) ioctl_g_parm},
> +	{vidioc_int_s_parm_num, (v4l2_int_ioctl_func *) ioctl_s_parm},
> +	{vidioc_int_queryctrl_num,
> +	 (v4l2_int_ioctl_func *) ioctl_queryctrl},
> +	{vidioc_int_g_ctrl_num, (v4l2_int_ioctl_func *) ioctl_g_ctrl},
> +	{vidioc_int_s_ctrl_num, (v4l2_int_ioctl_func *) ioctl_s_ctrl},
> +	{vidioc_int_querystd_num, (v4l2_int_ioctl_func *) ioctl_querystd},
> +	{vidioc_int_s_std_num, (v4l2_int_ioctl_func *) ioctl_s_std},
> +	{vidioc_int_enum_input_num,
> +	 (v4l2_int_ioctl_func *) ioctl_enum_input},
> +	{vidioc_int_g_input_num, (v4l2_int_ioctl_func *) ioctl_g_input},
> +	{vidioc_int_s_input_num, (v4l2_int_ioctl_func *) ioctl_s_input},
> +};
> +
> +static struct v4l2_int_slave tvp514x_slave = {
> +	.ioctls = tvp514x_ioctl_desc,
> +	.num_ioctls = ARRAY_SIZE(tvp514x_ioctl_desc),
> +};
> +
> +static struct tvp514x_decoder tvp514x_dev = {
> +	.state = STATE_NOT_DETECTED,
> +
> +	.num_fmts = TVP514X_NUM_FORMATS,
> +	.fmt_list = tvp514x_fmt_list,
> +
> +	.pix = {		/* Default to NTSC 8-bit YUV 422 */
> +		.width = NTSC_NUM_ACTIVE_PIXELS,
> +		.height = NTSC_NUM_ACTIVE_LINES,
> +		.pixelformat = V4L2_PIX_FMT_UYVY,
> +		.field = V4L2_FIELD_INTERLACED,
> +		.bytesperline = NTSC_NUM_ACTIVE_PIXELS * 2,
> +		.sizeimage =
> +		NTSC_NUM_ACTIVE_PIXELS * 2 * NTSC_NUM_ACTIVE_LINES,
> +		.colorspace = V4L2_COLORSPACE_SMPTE170M,
> +		},
> +
> +	.current_std = STD_NTSC_MJ,
> +	.num_stds = TVP514X_NUM_STANDARDS,
> +	.std_list = tvp514x_std_list,
> +
> +	.num_ctrls = TVP514X_NUM_CONTROLS,
> +	.ctrl_list = tvp514x_ctrl_list,
> +
> +};
> +
> +static struct v4l2_int_device tvp514x_int_device = {
> +	.module = THIS_MODULE,
> +	.name = MODULE_NAME,
> +	.priv = &tvp514x_dev,
> +	.type = v4l2_int_type_slave,
> +	.u = {
> +	      .slave = &tvp514x_slave,
> +	      },
> +};
> +
> +/**
> + * tvp514x_probe - decoder driver i2c probe handler
> + * @client: i2c driver client device structure
> + *
> + * Register decoder as an i2c client device and V4L2
> + * device.
> + */
> +static int
> +tvp514x_probe(struct i2c_client *client, const struct i2c_device_id
> *id) +{
> +	struct tvp514x_decoder *decoder = &tvp514x_dev;
> +	int err;
> +
> +	if (i2c_get_clientdata(client))
> +		return -EBUSY;
> +
> +	decoder->pdata = client->dev.platform_data;
> +	if (!decoder->pdata) {
> +		DBG(&client->dev, 1, "No platform data\n!!");
> +		return -ENODEV;
> +	}
> +	/*
> +	 * Fetch platform specific data, and configure the
> +	 * tvp514x_reg_list[] accordingly. Since this is one
> +	 * time configuration, no need to preserve.
> +	 */
> +	decoder->inputidx = decoder->pdata->default_input;
> +	tvp514x_reg_list[REG_OUTPUT_FORMATTER2].val |=
> +			(decoder->pdata->clk_polarity << 1);
> +	tvp514x_reg_list[REG_OUTPUT_FORMATTER1].val |=
> +			decoder->pdata->fmt;
> +	tvp514x_reg_list[REG_SYNC_CONTROL].val |=
> +			((decoder->pdata->hs_polarity << 2) |
> +			(decoder->pdata->vs_polarity << 3));
> +
> +	/* Attach to Master */
> +	strcpy(tvp514x_int_device.u.slave->attach_to,
> decoder->pdata->master); +	decoder->v4l2_int_device =
> &tvp514x_int_device;
> +	decoder->client = client;
> +	i2c_set_clientdata(client, decoder);
> +
> +	/* Register with V4L2 layer as slave device */
> +	err = v4l2_int_device_register(decoder->v4l2_int_device);
> +	if (err) {
> +		i2c_set_clientdata(client, NULL);
> +		DBG(&client->dev, 1,
> +			"Unable to register to v4l2. Err[%d]\n", err);
> +
> +	} else
> +		DBG(&client->dev, 3, "Registered to v4l2 master %s!!\n",
> +				decoder->pdata->master);
> +
> +	return 0;
> +}
> +
> +/**
> + * tvp514x_remove - decoder driver i2c remove handler
> + * @client: i2c driver client device structure
> + *
> + * Unregister decoder as an i2c client device and V4L2
> + * device. Complement of tvp514x_probe().
> + */
> +static int __exit tvp514x_remove(struct i2c_client *client)
> +{
> +	struct tvp514x_decoder *decoder = i2c_get_clientdata(client);
> +
> +	if (!client->adapter)
> +		return -ENODEV;	/* our client isn't attached */
> +
> +	v4l2_int_device_unregister(decoder->v4l2_int_device);
> +	i2c_set_clientdata(client, NULL);
> +
> +	return 0;
> +}
> +
> +static const struct i2c_device_id tvp514x_id[] = {
> +	{"tvp5146", 0},
> +	{"tvp5147", 0},
> +	{},
> +};
> +
> +MODULE_DEVICE_TABLE(i2c, tvp514x_id);
> +
> +static struct i2c_driver tvp514x_i2c_driver = {
> +	.driver = {
> +		   .name = MODULE_NAME,
> +		   .owner = THIS_MODULE,
> +		   },
> +	.probe = tvp514x_probe,
> +	.remove = __exit_p(tvp514x_remove),
> +	.id_table = tvp514x_id,
> +};
> +
> +/**
> + * tvp514x_init
> + *
> + * Module init function
> + */
> +static int __init tvp514x_init(void)
> +{
> +	int err;
> +
> +	err = i2c_add_driver(&tvp514x_i2c_driver);
> +	if (err) {
> +		printk(KERN_ERR "Failed to register " MODULE_NAME ".\n");
> +		return err;
> +	}
> +	return 0;
> +}
> +
> +/**
> + * tvp514x_cleanup
> + *
> + * Module exit function
> + */
> +static void __exit tvp514x_cleanup(void)
> +{
> +	i2c_del_driver(&tvp514x_i2c_driver);
> +}
> +
> +module_init(tvp514x_init);
> +module_exit(tvp514x_cleanup);
> +
> +MODULE_AUTHOR("Texas Instruments");
> +MODULE_DESCRIPTION("TVP514X linux decoder driver");
> +MODULE_LICENSE("GPL");
> diff --git a/include/media/tvp514x.h b/include/media/tvp514x.h
> new file mode 100644
> index 0000000..5a4e2d5
> --- /dev/null
> +++ b/include/media/tvp514x.h

I strongly recommend splitting this header up into two parts: all the 
register defines etc. should go to a driver/media/video/tvp514x_regs.h 
leaving only the parts that host drivers will typically use in this 
header.

Basically split it into a public header (this one) and a private one 
that's in the same directory as the source.

Regards,

	Hans

> @@ -0,0 +1,461 @@
> +/*
> + * drivers/media/video/tvp514x.h
> + *
> + * Copyright (C) 2008 Texas Instruments Inc
> + *
> + * This package is free software; you can redistribute it and/or
> modify + * it under the terms of the GNU General Public License
> version 2 as + * published by the Free Software Foundation.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program; if not, write to the Free Software
> + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
> + *
> + */
> +
> +#ifndef _TVP514X_H
> +#define _TVP514X_H
> +
> +/*
> + * TVP5146/47 registers
> + */
> +#define REG_INPUT_SEL			(0x00)
> +#define REG_AFE_GAIN_CTRL		(0x01)
> +#define REG_VIDEO_STD			(0x02)
> +#define REG_OPERATION_MODE		(0x03)
> +#define REG_AUTOSWITCH_MASK		(0x04)
> +
> +#define REG_COLOR_KILLER		(0x05)
> +#define REG_LUMA_CONTROL1		(0x06)
> +#define REG_LUMA_CONTROL2		(0x07)
> +#define REG_LUMA_CONTROL3		(0x08)
> +
> +#define REG_BRIGHTNESS			(0x09)
> +#define REG_CONTRAST			(0x0A)
> +#define REG_SATURATION			(0x0B)
> +#define REG_HUE				(0x0C)
> +
> +#define REG_CHROMA_CONTROL1		(0x0D)
> +#define REG_CHROMA_CONTROL2		(0x0E)
> +
> +/* 0x0F Reserved */
> +
> +#define REG_COMP_PR_SATURATION		(0x10)
> +#define REG_COMP_Y_CONTRAST		(0x11)
> +#define REG_COMP_PB_SATURATION		(0x12)
> +
> +/* 0x13 Reserved */
> +
> +#define REG_COMP_Y_BRIGHTNESS		(0x14)
> +
> +/* 0x15 Reserved */
> +
> +#define REG_AVID_START_PIXEL_LSB	(0x16)
> +#define REG_AVID_START_PIXEL_MSB	(0x17)
> +#define REG_AVID_STOP_PIXEL_LSB		(0x18)
> +#define REG_AVID_STOP_PIXEL_MSB		(0x19)
> +
> +#define REG_HSYNC_START_PIXEL_LSB	(0x1A)
> +#define REG_HSYNC_START_PIXEL_MSB	(0x1B)
> +#define REG_HSYNC_STOP_PIXEL_LSB	(0x1C)
> +#define REG_HSYNC_STOP_PIXEL_MSB	(0x1D)
> +
> +#define REG_VSYNC_START_LINE_LSB	(0x1E)
> +#define REG_VSYNC_START_LINE_MSB	(0x1F)
> +#define REG_VSYNC_STOP_LINE_LSB		(0x20)
> +#define REG_VSYNC_STOP_LINE_MSB		(0x21)
> +
> +#define REG_VBLK_START_LINE_LSB		(0x22)
> +#define REG_VBLK_START_LINE_MSB		(0x23)
> +#define REG_VBLK_STOP_LINE_LSB		(0x24)
> +#define REG_VBLK_STOP_LINE_MSB		(0x25)
> +
> +/* 0x26 - 0x27 Reserved */
> +
> +#define REG_FAST_SWTICH_CONTROL		(0x28)
> +
> +/* 0x29 Reserved */
> +
> +#define REG_FAST_SWTICH_SCART_DELAY	(0x2A)
> +
> +/* 0x2B Reserved */
> +
> +#define REG_SCART_DELAY			(0x2C)
> +#define REG_CTI_DELAY			(0x2D)
> +#define REG_CTI_CONTROL			(0x2E)
> +
> +/* 0x2F - 0x31 Reserved */
> +
> +#define REG_SYNC_CONTROL		(0x32)
> +#define REG_OUTPUT_FORMATTER1		(0x33)
> +#define REG_OUTPUT_FORMATTER2		(0x34)
> +#define REG_OUTPUT_FORMATTER3		(0x35)
> +#define REG_OUTPUT_FORMATTER4		(0x36)
> +#define REG_OUTPUT_FORMATTER5		(0x37)
> +#define REG_OUTPUT_FORMATTER6		(0x38)
> +#define REG_CLEAR_LOST_LOCK		(0x39)
> +
> +#define REG_STATUS1			(0x3A)
> +#define REG_STATUS2			(0x3B)
> +
> +#define REG_AGC_GAIN_STATUS_LSB		(0x3C)
> +#define REG_AGC_GAIN_STATUS_MSB		(0x3D)
> +
> +/* 0x3E Reserved */
> +
> +#define REG_VIDEO_STD_STATUS		(0x3F)
> +#define REG_GPIO_INPUT1			(0x40)
> +#define REG_GPIO_INPUT2			(0x41)
> +
> +/* 0x42 - 0x45 Reserved */
> +
> +#define REG_AFE_COARSE_GAIN_CH1		(0x46)
> +#define REG_AFE_COARSE_GAIN_CH2		(0x47)
> +#define REG_AFE_COARSE_GAIN_CH3		(0x48)
> +#define REG_AFE_COARSE_GAIN_CH4		(0x49)
> +
> +#define REG_AFE_FINE_GAIN_PB_B_LSB	(0x4A)
> +#define REG_AFE_FINE_GAIN_PB_B_MSB	(0x4B)
> +#define REG_AFE_FINE_GAIN_Y_G_CHROMA_LSB	(0x4C)
> +#define REG_AFE_FINE_GAIN_Y_G_CHROMA_MSB	(0x4D)
> +#define REG_AFE_FINE_GAIN_PR_R_LSB	(0x4E)
> +#define REG_AFE_FINE_GAIN_PR_R_MSB	(0x4F)
> +#define REG_AFE_FINE_GAIN_CVBS_LUMA_LSB	(0x50)
> +#define REG_AFE_FINE_GAIN_CVBS_LUMA_MSB	(0x51)
> +
> +/* 0x52 - 0x68 Reserved */
> +
> +#define REG_FBIT_VBIT_CONTROL1		(0x69)
> +
> +/* 0x6A - 0x6B Reserved */
> +
> +#define REG_BACKEND_AGC_CONTROL		(0x6C)
> +
> +/* 0x6D - 0x6E Reserved */
> +
> +#define REG_AGC_DECREMENT_SPEED_CONTROL	(0x6F)
> +#define REG_ROM_VERSION			(0x70)
> +
> +/* 0x71 - 0x73 Reserved */
> +
> +#define REG_AGC_WHITE_PEAK_PROCESSING	(0x74)
> +#define REG_FBIT_VBIT_CONTROL2		(0x75)
> +#define REG_VCR_TRICK_MODE_CONTROL	(0x76)
> +#define REG_HORIZONTAL_SHAKE_INCREMENT	(0x77)
> +#define REG_AGC_INCREMENT_SPEED		(0x78)
> +#define REG_AGC_INCREMENT_DELAY		(0x79)
> +
> +/* 0x7A - 0x7F Reserved */
> +
> +#define REG_CHIP_ID_MSB			(0x80)
> +#define REG_CHIP_ID_LSB			(0x81)
> +
> +/* 0x82 Reserved */
> +
> +#define REG_CPLL_SPEED_CONTROL		(0x83)
> +
> +/* 0x84 - 0x96 Reserved */
> +
> +#define REG_STATUS_REQUEST		(0x97)
> +
> +/* 0x98 - 0x99 Reserved */
> +
> +#define REG_VERTICAL_LINE_COUNT_LSB	(0x9A)
> +#define REG_VERTICAL_LINE_COUNT_MSB	(0x9B)
> +
> +/* 0x9C - 0x9D Reserved */
> +
> +#define REG_AGC_DECREMENT_DELAY		(0x9E)
> +
> +/* 0x9F - 0xB0 Reserved */
> +
> +#define REG_VDP_TTX_FILTER_1_MASK1	(0xB1)
> +#define REG_VDP_TTX_FILTER_1_MASK2	(0xB2)
> +#define REG_VDP_TTX_FILTER_1_MASK3	(0xB3)
> +#define REG_VDP_TTX_FILTER_1_MASK4	(0xB4)
> +#define REG_VDP_TTX_FILTER_1_MASK5	(0xB5)
> +#define REG_VDP_TTX_FILTER_2_MASK1	(0xB6)
> +#define REG_VDP_TTX_FILTER_2_MASK2	(0xB7)
> +#define REG_VDP_TTX_FILTER_2_MASK3	(0xB8)
> +#define REG_VDP_TTX_FILTER_2_MASK4	(0xB9)
> +#define REG_VDP_TTX_FILTER_2_MASK5	(0xBA)
> +#define REG_VDP_TTX_FILTER_CONTROL	(0xBB)
> +#define REG_VDP_FIFO_WORD_COUNT		(0xBC)
> +#define REG_VDP_FIFO_INTERRUPT_THRLD	(0xBD)
> +
> +/* 0xBE Reserved */
> +
> +#define REG_VDP_FIFO_RESET		(0xBF)
> +#define REG_VDP_FIFO_OUTPUT_CONTROL	(0xC0)
> +#define REG_VDP_LINE_NUMBER_INTERRUPT	(0xC1)
> +#define REG_VDP_PIXEL_ALIGNMENT_LSB	(0xC2)
> +#define REG_VDP_PIXEL_ALIGNMENT_MSB	(0xC3)
> +
> +/* 0xC4 - 0xD5 Reserved */
> +
> +#define REG_VDP_LINE_START		(0xD6)
> +#define REG_VDP_LINE_STOP		(0xD7)
> +#define REG_VDP_GLOBAL_LINE_MODE	(0xD8)
> +#define REG_VDP_FULL_FIELD_ENABLE	(0xD9)
> +#define REG_VDP_FULL_FIELD_MODE		(0xDA)
> +
> +/* 0xDB - 0xDF Reserved */
> +
> +#define REG_VBUS_DATA_ACCESS_NO_VBUS_ADDR_INCR	(0xE0)
> +#define REG_VBUS_DATA_ACCESS_VBUS_ADDR_INCR	(0xE1)
> +#define REG_FIFO_READ_DATA			(0xE2)
> +
> +/* 0xE3 - 0xE7 Reserved */
> +
> +#define REG_VBUS_ADDRESS_ACCESS1	(0xE8)
> +#define REG_VBUS_ADDRESS_ACCESS2	(0xE9)
> +#define REG_VBUS_ADDRESS_ACCESS3	(0xEA)
> +
> +/* 0xEB - 0xEF Reserved */
> +
> +#define REG_INTERRUPT_RAW_STATUS0	(0xF0)
> +#define REG_INTERRUPT_RAW_STATUS1	(0xF1)
> +#define REG_INTERRUPT_STATUS0		(0xF2)
> +#define REG_INTERRUPT_STATUS1		(0xF3)
> +#define REG_INTERRUPT_MASK0		(0xF4)
> +#define REG_INTERRUPT_MASK1		(0xF5)
> +#define REG_INTERRUPT_CLEAR0		(0xF6)
> +#define REG_INTERRUPT_CLEAR1		(0xF7)
> +
> +/* 0xF8 - 0xFF Reserved */
> +
> +/*
> + * Mask and bit definitions of TVP5146/47 registers
> + */
> +/* The ID values we are looking for */
> +#define TVP514X_CHIP_ID_MSB		(0x51)
> +#define TVP5146_CHIP_ID_LSB		(0x46)
> +#define TVP5147_CHIP_ID_LSB		(0x47)
> +
> +#define VIDEO_STD_MASK			(0x07)
> +#define VIDEO_STD_AUTO_SWITCH_BIT	(0x00)
> +#define VIDEO_STD_NTSC_MJ_BIT		(0x01)
> +#define VIDEO_STD_PAL_BDGHIN_BIT	(0x02)
> +#define VIDEO_STD_PAL_M_BIT		(0x03)
> +#define VIDEO_STD_PAL_COMBINATION_N_BIT	(0x04)
> +#define VIDEO_STD_NTSC_4_43_BIT		(0x05)
> +#define VIDEO_STD_SECAM_BIT		(0x06)
> +#define VIDEO_STD_PAL_60_BIT		(0x07)
> +
> +/*
> + * Status bit
> + */
> +#define STATUS_TV_VCR_BIT		(1<<0)
> +#define STATUS_HORZ_SYNC_LOCK_BIT	(1<<1)
> +#define STATUS_VIRT_SYNC_LOCK_BIT	(1<<2)
> +#define STATUS_CLR_SUBCAR_LOCK_BIT	(1<<3)
> +#define STATUS_LOST_LOCK_DETECT_BIT	(1<<4)
> +#define STATUS_FEILD_RATE_BIT		(1<<5)
> +#define STATUS_LINE_ALTERNATING_BIT	(1<<6)
> +#define STATUS_PEAK_WHITE_DETECT_BIT	(1<<7)
> +/*
> + * Other macros
> + */
> +#define TVP514X_MODULE_NAME		"tvp514x"
> +#define TVP514X_I2C_DELAY		(3)
> +#define I2C_RETRY_COUNT			(5)
> +#define LOCK_RETRY_COUNT		(3)
> +#define LOCK_RETRY_DELAY		(200)
> +
> +#define TOK_WRITE			(0)	/* token for write operation */
> +#define TOK_TERM			(1)	/* terminating token */
> +#define TOK_DELAY			(2)	/* delay token for reg list */
> +#define TOK_SKIP			(3)	/* token to skip a register */
> +
> +#define TVP514X_XCLK_BT656		(27000000)
> +
> +/* Number of pixels and number of lines per frame for different
> standards */ +#define NTSC_NUM_ACTIVE_PIXELS		(720)
> +#define NTSC_NUM_ACTIVE_LINES		(480)
> +#define PAL_NUM_ACTIVE_PIXELS		(720)
> +#define PAL_NUM_ACTIVE_LINES		(576)
> +
> +/**
> + * enum tvp514x_std - enum for supported standards
> + */
> +enum tvp514x_std {
> +	STD_NTSC_MJ = 0,
> +	STD_PAL_BDGHIN,
> +	STD_INVALID
> +};
> +
> +/**
> + * enum tvp514x_state - enum for different decoder states
> + */
> +enum tvp514x_state {
> +	STATE_NOT_DETECTED,
> +	STATE_DETECTED
> +};
> +
> +enum tvp514x_input {
> +	/*
> +	 * CVBS input selection
> +	 */
> +	INPUT_CVBS_VI1A = 0x0,
> +	INPUT_CVBS_VI1B,
> +	INPUT_CVBS_VI1C,
> +	INPUT_CVBS_VI2A = 0x04,
> +	INPUT_CVBS_VI2B,
> +	INPUT_CVBS_VI2C,
> +	INPUT_CVBS_VI3A = 0x08,
> +	INPUT_CVBS_VI3B,
> +	INPUT_CVBS_VI3C,
> +	INPUT_CVBS_VI4A = 0x0C,
> +	/*
> +	 * S-Video input selection
> +	 */
> +	INPUT_SVIDEO_VI2A_VI1A = 0x44,
> +	INPUT_SVIDEO_VI2B_VI1B,
> +	INPUT_SVIDEO_VI2C_VI1C,
> +	INPUT_SVIDEO_VI2A_VI3A = 0x54,
> +	INPUT_SVIDEO_VI2B_VI3B,
> +	INPUT_SVIDEO_VI2C_VI3C,
> +	INPUT_SVIDEO_VI4A_VI1A = 0x4C,
> +	INPUT_SVIDEO_VI4A_VI1B,
> +	INPUT_SVIDEO_VI4A_VI1C,
> +	INPUT_SVIDEO_VI4A_VI3A = 0x5C,
> +	INPUT_SVIDEO_VI4A_VI3B,
> +	INPUT_SVIDEO_VI4A_VI3C
> +
> +	/* Need to add entries for
> +	 * RGB, YPbPr and SCART.
> +	 */
> +};
> +
> +enum tvp514x_output_fmt {
> +	OUTPUT_10BIT_422_EMBEDDED_SYNC = 0,
> +	OUTPUT_20BIT_422_SEPERATE_SYNC,
> +	OUTPUT_10BIT_422_SEPERATE_SYNC = 3,
> +	OUTPUT_INVALID
> +};
> +/**
> + * struct tvp514x_reg - Structure for TVP5146/47 register
> initialization values + * @token - Token: TOK_WRITE, TOK_TERM etc..
> + * @reg - Register offset
> + * @val - Register Value for TOK_WRITE or delay in ms for TOK_DELAY
> + */
> +struct tvp514x_reg {
> +	u8 token;
> +	u8 reg;
> +	u32 val;
> +};
> +
> +/**
> + * struct tvp514x_std_info - Structure to store standard
> informations + * @width: Line width in pixels
> + * @height:Number of active lines
> + * @video_std: Value to write in REG_VIDEO_STD register
> + * @standard: v4l2 standard structure information
> + */
> +struct tvp514x_std_info {
> +	unsigned long width;
> +	unsigned long height;
> +	u8 video_std;
> +	struct v4l2_standard standard;
> +};
> +
> +/**
> + * struct tvp514x_ctrl_info - Information regarding supported
> controls + * @reg_address: Register offset of control register
> + * @query_ctrl: v4l2 query control information
> + */
> +struct tvp514x_ctrl_info {
> +	u8 reg_address;
> +	struct v4l2_queryctrl query_ctrl;
> +};
> +
> +/**
> + * struct tvp514x_input_info - Information regarding supported
> inputs + * @input_sel: Input select register
> + * @lock_mask: lock mask - depends on Svideo/CVBS
> + * @input: v4l2 input information
> + */
> +struct tvp514x_input_info {
> +	enum tvp514x_input input_sel;
> +	struct v4l2_input input;
> +};
> +
> +/**
> + * struct tvp514x_platform_data - Platform data values and access
> functions + * @power_set: Power state access function, zero is off,
> non-zero is on. + * @ifparm: Interface parameters access function
> + * @priv_data_set: Device private data (pointer) access function
> + * @reg_list: The board dependent driver should fill the default
> value for + *            required registers depending on board
> layout. The TVP5146/47 + *            driver will update this
> register list for the registers + *            whose values should be
> maintained across open()/close() like + *            setting
> brightness as defined in V4L2.
> + *            The register list should be in the same order as
> defined in + *            TVP5146/47 datasheet including reserved
> registers. As of now + *            the driver expects the size of
> this list to be a minimum of + *            57 + 1 (upto regsiter
> REG_CLEAR_LOST_LOCK).
> + *            The last member should be of the list should be
> + *            {TOK_TERM, 0, 0} to indicate the end of register list.
> + * @num_inputs: Number of input connection in board
> + * @input_list: Input information list for num_inputs
> + */
> +struct tvp514x_platform_data {
> +	char *master;
> +	int (*power_set) (enum v4l2_power on);
> +	int (*ifparm) (struct v4l2_ifparm *p);
> +	int (*priv_data_set) (void *);
> +	/* Input params */
> +	int num_inputs;
> +	const struct tvp514x_input_info *input_list;
> +	int default_input;
> +	/* Interface control params */
> +	enum tvp514x_output_fmt fmt;
> +	bool clk_polarity;
> +	bool hs_polarity;
> +	bool vs_polarity;
> +};
> +
> +/**
> + * struct tvp514x_decoded - TVP5146/47 decoder object
> + * @v4l2_int_device: Slave handle
> + * @pdata: Board specific
> + * @client: I2C client data
> + * @ver: Chip version
> + * @state: TVP5146/47 decoder state - detected or not-detected
> + * @pix: Current pixel format
> + * @num_fmts: Number of formats
> + * @fmt_list: Format list
> + * @current_std: Current standard
> + * @num_stds: Number of standards
> + * @std_list: Standards list
> + * @num_ctrls: Number of controls
> + * @ctrl_list: Control list
> + */
> +struct tvp514x_decoder {
> +	struct v4l2_int_device *v4l2_int_device;
> +	const struct tvp514x_platform_data *pdata;
> +	struct i2c_client *client;
> +
> +	int ver;
> +	enum tvp514x_state state;
> +
> +	struct v4l2_pix_format pix;
> +	int num_fmts;
> +	const struct v4l2_fmtdesc *fmt_list;
> +
> +	enum tvp514x_std current_std;
> +	int num_stds;
> +	struct tvp514x_std_info *std_list;
> +
> +	int num_ctrls;
> +	const struct tvp514x_ctrl_info *ctrl_list;
> +
> +	int inputidx;
> +};
> +
> +#endif				/* ifndef _TVP514X_H */
> --
> 1.5.6
>
> --
> video4linux-list mailing list
> Unsubscribe
> mailto:video4linux-list-request@redhat.com?subject=unsubscribe
> https://www.redhat.com/mailman/listinfo/video4linux-list


--
video4linux-list mailing list
Unsubscribe mailto:video4linux-list-request@redhat.com?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [PATCH 2/2] TVP514x Driver with Review comments fixed [V4]
@ 2008-12-02 15:35   ` hvaibhav
  0 siblings, 0 replies; 263+ messages in thread
From: hvaibhav @ 2008-12-02 15:35 UTC (permalink / raw)
  To: video4linux-list
  Cc: davinci-linux-open-source-bounces, Karicheri Muralidharan, linux-omap

From: Vaibhav Hiremath <hvaibhav@ti.com>

I have fixed all the review commentsreceived so far.
Here are the details -

FIXSES:
    Make use of i2c_smbus_read/write_byte API:
        Probe function now checks for SMBUS capability,
	and read/write functions make use of the above API.

    Error check for I2C Read/Write:
        Added error condition check for both read and write
	API.
	This has been added for completeness.

    input set/get ioctl:
        As we do have support for set and get routing ioctl,
	instead of adding new ioctl used them.

    enum_ioctl:
        After discussing with Hans verkuil, came to conclusion
	that as of now just remove support for enum_ioctl from
	decoder, since this has to handle at master driver level.

TODO LIST:
    OMAP Master capture driver:
        This should be completely aligned with the current
	discussion.

    Migration to sub_device framework:
        Immediately after all the above task, migrate both
	Master and slave driver to sub_device framework.

Signed-off-by: Brijesh Jadav <brijesh.j@ti.com>
Signed-off-by: Hardik Shah <hardik.shah@ti.com>
Signed-off-by: Manjunath Hadli <mrh@ti.com>
Signed-off-by: R Sivaraj <sivaraj@ti.com>
Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
Signed-off-by: Karicheri Muralidharan <m-karicheri2@ti.com>
---
 drivers/media/video/Kconfig        |   11 +
 drivers/media/video/Makefile       |    1 +
 drivers/media/video/tvp514x.c      | 1521 ++++++++++++++++++++++++++++++++++++
 drivers/media/video/tvp514x_regs.h |  292 +++++++
 include/media/tvp514x.h            |  232 ++++++
 5 files changed, 2057 insertions(+), 0 deletions(-)
 create mode 100755 drivers/media/video/tvp514x.c
 create mode 100755 drivers/media/video/tvp514x_regs.h
 create mode 100755 include/media/tvp514x.h

diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig
index 47102c2..2e5dc3e 100644
--- a/drivers/media/video/Kconfig
+++ b/drivers/media/video/Kconfig
@@ -361,6 +361,17 @@ config VIDEO_SAA7191
 	  To compile this driver as a module, choose M here: the
 	  module will be called saa7191.

+config VIDEO_TVP514X
+	tristate "Texas Instruments TVP514x video decoder"
+	depends on VIDEO_V4L2 && I2C
+	---help---
+	  This is a Video4Linux2 sensor-level driver for the TI TVP5146/47
+	  decoder. It is currently working with the TI OMAP3 camera
+	  controller.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called tvp514x.
+
 config VIDEO_TVP5150
 	tristate "Texas Instruments TVP5150 video decoder"
 	depends on VIDEO_V4L2 && I2C
diff --git a/drivers/media/video/Makefile b/drivers/media/video/Makefile
index 16962f3..cdbbf38 100644
--- a/drivers/media/video/Makefile
+++ b/drivers/media/video/Makefile
@@ -66,6 +66,7 @@ obj-$(CONFIG_VIDEO_CX88) += cx88/
 obj-$(CONFIG_VIDEO_EM28XX) += em28xx/
 obj-$(CONFIG_VIDEO_USBVISION) += usbvision/
 obj-$(CONFIG_VIDEO_TVP5150) += tvp5150.o
+obj-$(CONFIG_VIDEO_TVP514X) += tvp514x.o
 obj-$(CONFIG_VIDEO_PVRUSB2) += pvrusb2/
 obj-$(CONFIG_VIDEO_MSP3400) += msp3400.o
 obj-$(CONFIG_VIDEO_CS5345) += cs5345.o
diff --git a/drivers/media/video/tvp514x.c b/drivers/media/video/tvp514x.c
new file mode 100755
index 0000000..c0834e4
--- /dev/null
+++ b/drivers/media/video/tvp514x.c
@@ -0,0 +1,1521 @@
+/*
+ * drivers/media/video/tvp514x.c
+ *
+ * TI TVP5146/47 decoder driver
+ *
+ * Copyright (C) 2008 Texas Instruments Inc
+ * Author: Vaibhav Hiremath <hvaibhav@ti.com>
+ *
+ * Contributors:
+ *     Sivaraj R <sivaraj@ti.com>
+ *     Brijesh R Jadav <brijesh.j@ti.com>
+ *     Hardik Shah <hardik.shah@ti.com>
+ *     Manjunath Hadli <mrh@ti.com>
+ *     Karicheri Muralidharan <m-karicheri2@ti.com>
+ *
+ * This package is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#include <linux/i2c.h>
+#include <linux/delay.h>
+#include <linux/videodev2.h>
+#include <media/v4l2-int-device.h>
+#include <media/tvp514x.h>
+
+#include "tvp514x_regs.h"
+
+#define MODULE_NAME	TVP514X_MODULE_NAME
+
+/* Debug functions */
+static int debug;
+module_param(debug, bool, 0644);
+MODULE_PARM_DESC(debug, "Debug level (0-1)");
+
+#define dump_reg(client, reg, val)				\
+	do {							\
+		val = tvp514x_read_reg(client, reg);		\
+		v4l_info(client, "Reg(0x%.2X): 0x%.2X\n", reg, val); \
+	} while (0)
+
+
+/* TVP514x default register values */
+static struct tvp514x_reg tvp514x_reg_list[] = {
+	{TOK_WRITE, REG_INPUT_SEL, 0x05},	/* Composite selected */
+	{TOK_WRITE, REG_AFE_GAIN_CTRL, 0x0F},
+	{TOK_WRITE, REG_VIDEO_STD, 0x00},	/* Auto mode */
+	{TOK_WRITE, REG_OPERATION_MODE, 0x00},
+	{TOK_SKIP, REG_AUTOSWITCH_MASK, 0x3F},
+	{TOK_WRITE, REG_COLOR_KILLER, 0x10},
+	{TOK_WRITE, REG_LUMA_CONTROL1, 0x00},
+	{TOK_WRITE, REG_LUMA_CONTROL2, 0x00},
+	{TOK_WRITE, REG_LUMA_CONTROL3, 0x02},
+	{TOK_WRITE, REG_BRIGHTNESS, 0x80},
+	{TOK_WRITE, REG_CONTRAST, 0x80},
+	{TOK_WRITE, REG_SATURATION, 0x80},
+	{TOK_WRITE, REG_HUE, 0x00},
+	{TOK_WRITE, REG_CHROMA_CONTROL1, 0x00},
+	{TOK_WRITE, REG_CHROMA_CONTROL2, 0x0E},
+	{TOK_SKIP, 0x0F, 0x00},	/* Reserved */
+	{TOK_WRITE, REG_COMP_PR_SATURATION, 0x80},
+	{TOK_WRITE, REG_COMP_Y_CONTRAST, 0x80},
+	{TOK_WRITE, REG_COMP_PB_SATURATION, 0x80},
+	{TOK_SKIP, 0x13, 0x00},	/* Reserved */
+	{TOK_WRITE, REG_COMP_Y_BRIGHTNESS, 0x80},
+	{TOK_SKIP, 0x15, 0x00},	/* Reserved */
+	{TOK_SKIP, REG_AVID_START_PIXEL_LSB, 0x55},	/* NTSC timing */
+	{TOK_SKIP, REG_AVID_START_PIXEL_MSB, 0x00},
+	{TOK_SKIP, REG_AVID_STOP_PIXEL_LSB, 0x25},
+	{TOK_SKIP, REG_AVID_STOP_PIXEL_MSB, 0x03},
+	{TOK_SKIP, REG_HSYNC_START_PIXEL_LSB, 0x00},	/* NTSC timing */
+	{TOK_SKIP, REG_HSYNC_START_PIXEL_MSB, 0x00},
+	{TOK_SKIP, REG_HSYNC_STOP_PIXEL_LSB, 0x40},
+	{TOK_SKIP, REG_HSYNC_STOP_PIXEL_MSB, 0x00},
+	{TOK_SKIP, REG_VSYNC_START_LINE_LSB, 0x04},	/* NTSC timing */
+	{TOK_SKIP, REG_VSYNC_START_LINE_MSB, 0x00},
+	{TOK_SKIP, REG_VSYNC_STOP_LINE_LSB, 0x07},
+	{TOK_SKIP, REG_VSYNC_STOP_LINE_MSB, 0x00},
+	{TOK_SKIP, REG_VBLK_START_LINE_LSB, 0x01},	/* NTSC timing */
+	{TOK_SKIP, REG_VBLK_START_LINE_MSB, 0x00},
+	{TOK_SKIP, REG_VBLK_STOP_LINE_LSB, 0x15},
+	{TOK_SKIP, REG_VBLK_STOP_LINE_MSB, 0x00},
+	{TOK_SKIP, 0x26, 0x00},	/* Reserved */
+	{TOK_SKIP, 0x27, 0x00},	/* Reserved */
+	{TOK_SKIP, REG_FAST_SWTICH_CONTROL, 0xCC},
+	{TOK_SKIP, 0x29, 0x00},	/* Reserved */
+	{TOK_SKIP, REG_FAST_SWTICH_SCART_DELAY, 0x00},
+	{TOK_SKIP, 0x2B, 0x00},	/* Reserved */
+	{TOK_SKIP, REG_SCART_DELAY, 0x00},
+	{TOK_SKIP, REG_CTI_DELAY, 0x00},
+	{TOK_SKIP, REG_CTI_CONTROL, 0x00},
+	{TOK_SKIP, 0x2F, 0x00},	/* Reserved */
+	{TOK_SKIP, 0x30, 0x00},	/* Reserved */
+	{TOK_SKIP, 0x31, 0x00},	/* Reserved */
+	{TOK_WRITE, REG_SYNC_CONTROL, 0x00},	/* HS, VS active high */
+	{TOK_WRITE, REG_OUTPUT_FORMATTER1, 0x00},	/* 10-bit BT.656 */
+	{TOK_WRITE, REG_OUTPUT_FORMATTER2, 0x11},	/* Enable clk & data */
+	{TOK_WRITE, REG_OUTPUT_FORMATTER3, 0xEE},	/* Enable AVID & FLD */
+	{TOK_WRITE, REG_OUTPUT_FORMATTER4, 0xAF},	/* Enable VS & HS */
+	{TOK_WRITE, REG_OUTPUT_FORMATTER5, 0xFF},
+	{TOK_WRITE, REG_OUTPUT_FORMATTER6, 0xFF},
+	{TOK_WRITE, REG_CLEAR_LOST_LOCK, 0x01},	/* Clear status */
+	{TOK_TERM, 0, 0},
+};
+
+/* List of image formats supported by TVP5146/47 decoder
+ * Currently we are using 8 bit mode only, but can be
+ * extended to 10/20 bit mode.
+ */
+static const struct v4l2_fmtdesc tvp514x_fmt_list[] = {
+	{
+	 .index = 0,
+	 .type = V4L2_BUF_TYPE_VIDEO_CAPTURE,
+	 .flags = 0,
+	 .description = "8-bit UYVY 4:2:2 Format",
+	 .pixelformat = V4L2_PIX_FMT_UYVY,
+	},
+};
+
+#define TVP514X_NUM_FORMATS		ARRAY_SIZE(tvp514x_fmt_list)
+
+/*
+ * Supported standards -
+ *
+ * Currently supports two standards only, need to add support for rest of the
+ * modes, like SECAM, etc...
+ */
+static struct tvp514x_std_info tvp514x_std_list[] = {
+	/* Standard: STD_NTSC_MJ */
+	[STD_NTSC_MJ] = {
+	 .width = NTSC_NUM_ACTIVE_PIXELS,
+	 .height = NTSC_NUM_ACTIVE_LINES,
+	 .video_std = VIDEO_STD_NTSC_MJ_BIT,
+	 .standard = {
+		      .index = 0,
+		      .id = V4L2_STD_NTSC,
+		      .name = "NTSC",
+		      .frameperiod = {1001, 30000},
+		      .framelines = 525
+		     },
+	/* Standard: STD_PAL_BDGHIN */
+	},
+	[STD_PAL_BDGHIN] = {
+	 .width = PAL_NUM_ACTIVE_PIXELS,
+	 .height = PAL_NUM_ACTIVE_LINES,
+	 .video_std = VIDEO_STD_PAL_BDGHIN_BIT,
+	 .standard = {
+		      .index = 1,
+		      .id = V4L2_STD_PAL,
+		      .name = "PAL",
+		      .frameperiod = {1, 25},
+		      .framelines = 625
+		     },
+	},
+	/* Standard: need to add for additional standard */
+};
+
+#define TVP514X_NUM_STANDARDS		ARRAY_SIZE(tvp514x_std_list)
+
+/* Supported controls */
+static const struct tvp514x_ctrl_info tvp514x_ctrl_list[] = {
+	{
+	 .reg_address = REG_BRIGHTNESS,
+	 .query_ctrl = {
+			.id = V4L2_CID_BRIGHTNESS,
+			.name = "BRIGHTNESS",
+			.type = V4L2_CTRL_TYPE_INTEGER,
+			.minimum = 0,
+			.maximum = 255,
+			.step = 1,
+			.default_value = 128
+			},
+	}, {
+	 .reg_address = REG_CONTRAST,
+	 .query_ctrl = {
+			.id = V4L2_CID_CONTRAST,
+			.name = "CONTRAST",
+			.type = V4L2_CTRL_TYPE_INTEGER,
+			.minimum = 0,
+			.maximum = 255,
+			.step = 1,
+			.default_value = 128
+			},
+	}, {
+	 .reg_address = REG_SATURATION,
+	 .query_ctrl = {
+			.id = V4L2_CID_SATURATION,
+			.name = "SATURATION",
+			.type = V4L2_CTRL_TYPE_INTEGER,
+			.minimum = 0,
+			.maximum = 255,
+			.step = 1,
+			.default_value = 128
+			},
+	}, {
+	 .reg_address = REG_HUE,
+	 .query_ctrl = {
+			.id = V4L2_CID_HUE,
+			.name = "HUE",
+			.type = V4L2_CTRL_TYPE_INTEGER,
+			.minimum = -180,
+			.maximum = 180,
+			.step = 180,
+			.default_value = 0
+			},
+	}, {
+	 .reg_address = REG_AFE_GAIN_CTRL,
+	 .query_ctrl = {
+			.id = V4L2_CID_AUTOGAIN,
+			.name = "Automatic Gain Control",
+			.type = V4L2_CTRL_TYPE_BOOLEAN,
+			.minimum = 0,
+			.maximum = 1,
+			.step = 1,
+			.default_value = 1
+			},
+	 },
+};
+
+#define TVP514X_NUM_CONTROLS		ARRAY_SIZE(tvp514x_ctrl_list)
+
+/*
+ * Read a value from a register in an TVP5146/47 decoder device.
+ * Returns value read if successful, or non-zero (-1) otherwise.
+ */
+static int tvp514x_read_reg(struct i2c_client *client, u8 reg)
+{
+	int err;
+	int retry = 0;
+read_again:
+
+	err = i2c_smbus_read_byte_data(client, reg);
+	if (err == -1) {
+		if (retry <= I2C_RETRY_COUNT) {
+			v4l_warn(client, "Read: retry ... %d\n", retry);
+			retry++;
+			msleep_interruptible(10);
+			goto read_again;
+		}
+	}
+
+	return err;
+}
+
+/*
+ * Write a value to a register in an TVP5146/47 decoder device.
+ * Returns zero if successful, or non-zero otherwise.
+ */
+static int tvp514x_write_reg(struct i2c_client *client, u8 reg, u8 val)
+{
+	int err;
+	int retry = 0;
+write_again:
+
+	err = i2c_smbus_write_byte_data(client, reg, val);
+	if (err) {
+		if (retry <= I2C_RETRY_COUNT) {
+			v4l_warn(client, "Write: retry ... %d\n", retry);
+			retry++;
+			msleep_interruptible(10);
+			goto write_again;
+		}
+	}
+
+	return err;
+}
+
+/*
+ * tvp514x_write_regs : Initializes a list of TVP5146/47 registers
+ *		if token is TOK_TERM, then entire write operation terminates
+ *		if token is TOK_DELAY, then a delay of 'val' msec is introduced
+ *		if token is TOK_SKIP, then the register write is skipped
+ *		if token is TOK_WRITE, then the register write is performed
+ *
+ * reglist - list of registers to be written
+ * Returns zero if successful, or non-zero otherwise.
+ */
+static int tvp514x_write_regs(struct i2c_client *client,
+			      const struct tvp514x_reg reglist[])
+{
+	int err;
+	const struct tvp514x_reg *next = reglist;
+
+	for (; next->token != TOK_TERM; next++) {
+		if (next->token == TOK_DELAY) {
+			msleep(next->val);
+			continue;
+		}
+
+		if (next->token == TOK_SKIP)
+			continue;
+
+		err = tvp514x_write_reg(client, next->reg, (u8) next->val);
+		if (err) {
+			v4l_err(client, "Write failed. Err[%d]\n", err);
+			return err;
+		}
+	}
+	return 0;
+}
+
+/*
+ * tvp514x_get_current_std:
+ * Returns the current standard detected by TVP5146/47
+ */
+static enum tvp514x_std tvp514x_get_current_std(struct tvp514x_decoder
+						*decoder)
+{
+	u8 std, std_status;
+
+	std = tvp514x_read_reg(decoder->client, REG_VIDEO_STD);
+	if ((std & VIDEO_STD_MASK) == VIDEO_STD_AUTO_SWITCH_BIT) {
+		/* use the standard status register */
+		std_status = tvp514x_read_reg(decoder->client,
+				REG_VIDEO_STD_STATUS);
+	} else
+		std_status = std;	/* use the standard register itself */
+
+	switch (std_status & VIDEO_STD_MASK) {
+	case VIDEO_STD_NTSC_MJ_BIT:
+		return STD_NTSC_MJ;
+
+	case VIDEO_STD_PAL_BDGHIN_BIT:
+		return STD_PAL_BDGHIN;
+
+	default:
+		return STD_INVALID;
+	}
+
+	return STD_INVALID;
+}
+
+/*
+ * TVP5146/47 register dump function
+ */
+void tvp514x_reg_dump(struct tvp514x_decoder *decoder)
+{
+	u8 value;
+
+	dump_reg(decoder->client, REG_INPUT_SEL, value);
+	dump_reg(decoder->client, REG_AFE_GAIN_CTRL, value);
+	dump_reg(decoder->client, REG_VIDEO_STD, value);
+	dump_reg(decoder->client, REG_OPERATION_MODE, value);
+	dump_reg(decoder->client, REG_COLOR_KILLER, value);
+	dump_reg(decoder->client, REG_LUMA_CONTROL1, value);
+	dump_reg(decoder->client, REG_LUMA_CONTROL2, value);
+	dump_reg(decoder->client, REG_LUMA_CONTROL3, value);
+	dump_reg(decoder->client, REG_BRIGHTNESS, value);
+	dump_reg(decoder->client, REG_CONTRAST, value);
+	dump_reg(decoder->client, REG_SATURATION, value);
+	dump_reg(decoder->client, REG_HUE, value);
+	dump_reg(decoder->client, REG_CHROMA_CONTROL1, value);
+	dump_reg(decoder->client, REG_CHROMA_CONTROL2, value);
+	dump_reg(decoder->client, REG_COMP_PR_SATURATION, value);
+	dump_reg(decoder->client, REG_COMP_Y_CONTRAST, value);
+	dump_reg(decoder->client, REG_COMP_PB_SATURATION, value);
+	dump_reg(decoder->client, REG_COMP_Y_BRIGHTNESS, value);
+	dump_reg(decoder->client, REG_AVID_START_PIXEL_LSB, value);
+	dump_reg(decoder->client, REG_AVID_START_PIXEL_MSB, value);
+	dump_reg(decoder->client, REG_AVID_STOP_PIXEL_LSB, value);
+	dump_reg(decoder->client, REG_AVID_STOP_PIXEL_MSB, value);
+	dump_reg(decoder->client, REG_HSYNC_START_PIXEL_LSB, value);
+	dump_reg(decoder->client, REG_HSYNC_START_PIXEL_MSB, value);
+	dump_reg(decoder->client, REG_HSYNC_STOP_PIXEL_LSB, value);
+	dump_reg(decoder->client, REG_HSYNC_STOP_PIXEL_MSB, value);
+	dump_reg(decoder->client, REG_VSYNC_START_LINE_LSB, value);
+	dump_reg(decoder->client, REG_VSYNC_START_LINE_MSB, value);
+	dump_reg(decoder->client, REG_VSYNC_STOP_LINE_LSB, value);
+	dump_reg(decoder->client, REG_VSYNC_STOP_LINE_MSB, value);
+	dump_reg(decoder->client, REG_VBLK_START_LINE_LSB, value);
+	dump_reg(decoder->client, REG_VBLK_START_LINE_MSB, value);
+	dump_reg(decoder->client, REG_VBLK_STOP_LINE_LSB, value);
+	dump_reg(decoder->client, REG_VBLK_STOP_LINE_MSB, value);
+	dump_reg(decoder->client, REG_SYNC_CONTROL, value);
+	dump_reg(decoder->client, REG_OUTPUT_FORMATTER1, value);
+	dump_reg(decoder->client, REG_OUTPUT_FORMATTER2, value);
+	dump_reg(decoder->client, REG_OUTPUT_FORMATTER3, value);
+	dump_reg(decoder->client, REG_OUTPUT_FORMATTER4, value);
+	dump_reg(decoder->client, REG_OUTPUT_FORMATTER5, value);
+	dump_reg(decoder->client, REG_OUTPUT_FORMATTER6, value);
+	dump_reg(decoder->client, REG_CLEAR_LOST_LOCK, value);
+}
+
+/*
+ * Configure the TVP5146/47 with the current register settings
+ * Returns zero if successful, or non-zero otherwise.
+ */
+static int tvp514x_configure(struct tvp514x_decoder *decoder)
+{
+	int err;
+
+	/* common register initialization */
+	err =
+	    tvp514x_write_regs(decoder->client, tvp514x_reg_list);
+	if (err)
+		return err;
+
+	if (debug)
+		tvp514x_reg_dump(decoder);
+
+	return 0;
+}
+
+/*
+ * Detect if an tvp514x is present, and if so which revision.
+ * A device is considered to be detected if the chip ID (LSB and MSB)
+ * registers match the expected values.
+ * Any value of the rom version register is accepted.
+ * Returns ENODEV error number if no device is detected, or zero
+ * if a device is detected.
+ */
+static int tvp514x_detect(struct tvp514x_decoder *decoder)
+{
+	u8 chip_id_msb, chip_id_lsb, rom_ver;
+
+	chip_id_msb = tvp514x_read_reg(decoder->client, REG_CHIP_ID_MSB);
+	chip_id_lsb = tvp514x_read_reg(decoder->client, REG_CHIP_ID_LSB);
+	rom_ver = tvp514x_read_reg(decoder->client, REG_ROM_VERSION);
+
+	v4l_dbg(1, debug, decoder->client,
+		 "chip id detected msb:0x%x lsb:0x%x rom version:0x%x\n",
+		 chip_id_msb, chip_id_lsb, rom_ver);
+	if ((chip_id_msb != TVP514X_CHIP_ID_MSB)
+		|| ((chip_id_lsb != TVP5146_CHIP_ID_LSB)
+		&& (chip_id_lsb != TVP5147_CHIP_ID_LSB))) {
+		/* We didn't read the values we expected, so this must not be
+		 * an TVP5146/47.
+		 */
+		v4l_err(decoder->client,
+			"chip id mismatch msb:0x%x lsb:0x%x\n",
+			chip_id_msb, chip_id_lsb);
+		return -ENODEV;
+	}
+
+	decoder->ver = rom_ver;
+	decoder->state = STATE_DETECTED;
+
+	v4l_info(decoder->client,
+			"\n%s found at 0x%x (%s)\n", decoder->client->name,
+			decoder->client->addr << 1,
+			decoder->client->adapter->name);
+	return 0;
+}
+
+/*
+ * Following are decoder interface functions implemented by
+ * TVP5146/47 decoder driver.
+ */
+
+/**
+ * ioctl_querystd - V4L2 decoder interface handler for VIDIOC_QUERYSTD ioctl
+ * @s: pointer to standard V4L2 device structure
+ * @std_id: standard V4L2 std_id ioctl enum
+ *
+ * Returns the current standard detected by TVP5146/47. If no active input is
+ * detected, returns -EINVAL
+ */
+static int ioctl_querystd(struct v4l2_int_device *s, v4l2_std_id *std_id)
+{
+	struct tvp514x_decoder *decoder = s->priv;
+	enum tvp514x_std current_std;
+	enum tvp514x_input input_sel;
+	u8 sync_lock_status, lock_mask;
+
+	if (std_id == NULL)
+		return -EINVAL;
+
+	/* get the current standard */
+	current_std = tvp514x_get_current_std(decoder);
+	if (current_std == STD_INVALID)
+		return -EINVAL;
+
+	input_sel = decoder->pdata->input_list[decoder->inputidx].input_sel;
+
+	switch (input_sel) {
+	case INPUT_CVBS_VI1A:
+	case INPUT_CVBS_VI1B:
+	case INPUT_CVBS_VI1C:
+	case INPUT_CVBS_VI2A:
+	case INPUT_CVBS_VI2B:
+	case INPUT_CVBS_VI2C:
+	case INPUT_CVBS_VI3A:
+	case INPUT_CVBS_VI3B:
+	case INPUT_CVBS_VI3C:
+	case INPUT_CVBS_VI4A:
+		lock_mask = STATUS_CLR_SUBCAR_LOCK_BIT |
+			STATUS_HORZ_SYNC_LOCK_BIT |
+			STATUS_VIRT_SYNC_LOCK_BIT;
+		break;
+
+	case INPUT_SVIDEO_VI2A_VI1A:
+	case INPUT_SVIDEO_VI2B_VI1B:
+	case INPUT_SVIDEO_VI2C_VI1C:
+	case INPUT_SVIDEO_VI2A_VI3A:
+	case INPUT_SVIDEO_VI2B_VI3B:
+	case INPUT_SVIDEO_VI2C_VI3C:
+	case INPUT_SVIDEO_VI4A_VI1A:
+	case INPUT_SVIDEO_VI4A_VI1B:
+	case INPUT_SVIDEO_VI4A_VI1C:
+	case INPUT_SVIDEO_VI4A_VI3A:
+	case INPUT_SVIDEO_VI4A_VI3B:
+	case INPUT_SVIDEO_VI4A_VI3C:
+		lock_mask = STATUS_HORZ_SYNC_LOCK_BIT |
+			STATUS_VIRT_SYNC_LOCK_BIT;
+		break;
+		/*Need to add other interfaces*/
+	default:
+		return -EINVAL;
+	}
+	/* check whether signal is locked */
+	sync_lock_status = tvp514x_read_reg(decoder->client, REG_STATUS1);
+	if (lock_mask != (sync_lock_status & lock_mask))
+		return -EINVAL;	/* No input detected */
+
+	decoder->current_std = current_std;
+	*std_id = decoder->std_list[current_std].standard.id;
+
+	v4l_dbg(1, debug, decoder->client, "Current STD: %s",
+			decoder->std_list[current_std].standard.name);
+	return 0;
+}
+
+/**
+ * ioctl_s_std - V4L2 decoder interface handler for VIDIOC_S_STD ioctl
+ * @s: pointer to standard V4L2 device structure
+ * @std_id: standard V4L2 v4l2_std_id ioctl enum
+ *
+ * If std_id is supported, sets the requested standard. Otherwise, returns
+ * -EINVAL
+ */
+static int ioctl_s_std(struct v4l2_int_device *s, v4l2_std_id *std_id)
+{
+	struct tvp514x_decoder *decoder = s->priv;
+	int err, i;
+
+	if (std_id == NULL)
+		return -EINVAL;
+
+	for (i = 0; i < decoder->num_stds; i++)
+		if (*std_id & decoder->std_list[i].standard.id)
+			break;
+
+	if ((i == decoder->num_stds) || (i == STD_INVALID))
+		return -EINVAL;
+
+	err = tvp514x_write_reg(decoder->client, REG_VIDEO_STD,
+				decoder->std_list[i].video_std);
+	if (err)
+		return err;
+
+	decoder->current_std = i;
+	tvp514x_reg_list[REG_VIDEO_STD].val = decoder->std_list[i].video_std;
+
+	v4l_dbg(1, debug, decoder->client, "Standard set to: %s",
+			decoder->std_list[i].standard.name);
+	return 0;
+}
+
+/**
+ * ioctl_s_routing - V4L2 decoder interface handler for VIDIOC_S_INPUT ioctl
+ * @s: pointer to standard V4L2 device structure
+ * @index: number of the input
+ *
+ * If index is valid, selects the requested input. Otherwise, returns -EINVAL if
+ * the input is not supported or there is no active signal present in the
+ * selected input.
+ */
+static int ioctl_s_routing(struct v4l2_int_device *s, int index)
+{
+	struct tvp514x_decoder *decoder = s->priv;
+	int err;
+	enum tvp514x_input input_sel;
+	enum tvp514x_std current_std = STD_INVALID;
+	u8 sync_lock_status, lock_mask;
+	int try_count = LOCK_RETRY_COUNT;
+
+	if ((index >= decoder->pdata->num_inputs) || (index < 0))
+		return -EINVAL;	/* Index out of bound */
+
+	/* Get the register value to be written to select the requested input */
+	input_sel = decoder->pdata->input_list[index].input_sel;
+	err = tvp514x_write_reg(decoder->client, REG_INPUT_SEL, input_sel);
+	if (err)
+		return err;
+
+	decoder->inputidx = index;
+	tvp514x_reg_list[REG_INPUT_SEL].val = input_sel;
+
+	/* Clear status */
+	msleep(LOCK_RETRY_DELAY);
+	err =
+	    tvp514x_write_reg(decoder->client, REG_CLEAR_LOST_LOCK, 0x01);
+	if (err)
+		return err;
+
+	switch (input_sel) {
+	case INPUT_CVBS_VI1A:
+	case INPUT_CVBS_VI1B:
+	case INPUT_CVBS_VI1C:
+	case INPUT_CVBS_VI2A:
+	case INPUT_CVBS_VI2B:
+	case INPUT_CVBS_VI2C:
+	case INPUT_CVBS_VI3A:
+	case INPUT_CVBS_VI3B:
+	case INPUT_CVBS_VI3C:
+	case INPUT_CVBS_VI4A:
+		lock_mask = STATUS_CLR_SUBCAR_LOCK_BIT |
+			STATUS_HORZ_SYNC_LOCK_BIT |
+			STATUS_VIRT_SYNC_LOCK_BIT;
+		break;
+
+	case INPUT_SVIDEO_VI2A_VI1A:
+	case INPUT_SVIDEO_VI2B_VI1B:
+	case INPUT_SVIDEO_VI2C_VI1C:
+	case INPUT_SVIDEO_VI2A_VI3A:
+	case INPUT_SVIDEO_VI2B_VI3B:
+	case INPUT_SVIDEO_VI2C_VI3C:
+	case INPUT_SVIDEO_VI4A_VI1A:
+	case INPUT_SVIDEO_VI4A_VI1B:
+	case INPUT_SVIDEO_VI4A_VI1C:
+	case INPUT_SVIDEO_VI4A_VI3A:
+	case INPUT_SVIDEO_VI4A_VI3B:
+	case INPUT_SVIDEO_VI4A_VI3C:
+		lock_mask = STATUS_HORZ_SYNC_LOCK_BIT |
+			STATUS_VIRT_SYNC_LOCK_BIT;
+		break;
+	/*Need to add other interfaces*/
+	default:
+		return -EINVAL;
+	}
+
+	while (try_count-- > 0) {
+		/* Allow decoder to sync up with new input */
+		msleep(LOCK_RETRY_DELAY);
+
+		/* get the current standard for future reference */
+		current_std = tvp514x_get_current_std(decoder);
+		if (current_std == STD_INVALID)
+			continue;
+
+		sync_lock_status = tvp514x_read_reg(decoder->client,
+				REG_STATUS1);
+		if (lock_mask == (sync_lock_status & lock_mask))
+			break;	/* Input detected */
+	}
+
+	if ((current_std == STD_INVALID) || (try_count < 0))
+		return -EINVAL;
+
+	decoder->current_std = current_std;
+
+	v4l_dbg(1, debug, decoder->client,
+			"Input set to: index - %d (%s)",
+			decoder->pdata->input_list[index].input.index,
+			decoder->pdata->input_list[index].input.name);
+	return 0;
+}
+
+/**
+ * ioctl_g_routing - V4L2 decoder interface handler for VIDIOC_G_INPUT ioctl
+ * @s: pointer to standard V4L2 device structure
+ * @index: returns the current selected input
+ *
+ * Returns the current selected input. Returns -EINVAL if any error occurs
+ */
+static int ioctl_g_routing(struct v4l2_int_device *s, int *index)
+{
+	struct tvp514x_decoder *decoder = s->priv;
+	int err = -EINVAL, i, inputidx;
+
+	if (index == NULL)
+		return err;
+
+	/* Search through the input list for active inputs */
+	inputidx = decoder->inputidx;
+	for (i = 0; i < decoder->pdata->num_inputs; i++) {
+		inputidx++;	/* Move to next input */
+		if (inputidx >= decoder->pdata->num_inputs)
+			inputidx = 0;	/* fall back to first input */
+
+		err = ioctl_s_routing(s, inputidx);
+		if (!err) {
+			/* Active input found - select it and return success */
+			*index = inputidx;
+			return 0;
+		}
+	}
+
+	return err;
+}
+
+/**
+ * ioctl_queryctrl - V4L2 decoder interface handler for VIDIOC_QUERYCTRL ioctl
+ * @s: pointer to standard V4L2 device structure
+ * @qc: standard V4L2 VIDIOC_QUERYCTRL ioctl structure
+ *
+ * If the requested control is supported, returns the control information
+ * from the ctrl_list[] array. Otherwise, returns -EINVAL if the
+ * control is not supported.
+ */
+static int
+ioctl_queryctrl(struct v4l2_int_device *s, struct v4l2_queryctrl *qctrl)
+{
+	struct tvp514x_decoder *decoder = s->priv;
+	int id, index;
+	const struct tvp514x_ctrl_info *control = NULL;
+
+	if (qctrl == NULL)
+		return -EINVAL;
+
+	id = qctrl->id;
+	memset(qctrl, 0, sizeof(struct v4l2_queryctrl));
+	qctrl->id = id;
+
+	for (index = 0; index < decoder->num_ctrls; index++) {
+		control = &decoder->ctrl_list[index];
+		if (control->query_ctrl.id == qctrl->id)
+			break;	/* Match found */
+	}
+	if (index == decoder->num_ctrls)
+		return -EINVAL;	/* Index out of bound */
+
+	memcpy(qctrl, &control->query_ctrl, sizeof(struct v4l2_queryctrl));
+
+	v4l_dbg(1, debug, decoder->client,
+			"Query Control: %s : Min - %d, Max - %d, Def - %d",
+			control->query_ctrl.name,
+			control->query_ctrl.minimum,
+			control->query_ctrl.maximum,
+			control->query_ctrl.default_value);
+	return 0;
+}
+
+/**
+ * ioctl_g_ctrl - V4L2 decoder interface handler for VIDIOC_G_CTRL ioctl
+ * @s: pointer to standard V4L2 device structure
+ * @vc: standard V4L2 VIDIOC_G_CTRL ioctl structure
+ *
+ * If the requested control is supported, returns the control's current
+ * value from the decoder. Otherwise, returns -EINVAL if the control is not
+ * supported.
+ */
+static int
+ioctl_g_ctrl(struct v4l2_int_device *s, struct v4l2_control *ctrl)
+{
+	struct tvp514x_decoder *decoder = s->priv;
+	int index, value;
+	const struct tvp514x_ctrl_info *control = NULL;
+
+	if (ctrl == NULL)
+		return -EINVAL;
+
+	for (index = 0; index < decoder->num_ctrls; index++) {
+		control = &decoder->ctrl_list[index];
+		if (control->query_ctrl.id == ctrl->id)
+			break;	/* Match found */
+	}
+	if (index == decoder->num_ctrls)
+		return -EINVAL;	/* Index out of bound */
+
+	value =
+	    tvp514x_read_reg(decoder->client, control->reg_address);
+
+	/* cross check */
+	if (value != tvp514x_reg_list[control->reg_address].val)
+		return -EINVAL;	/* Driver & TVP5146/47 setting mismatch */
+
+	if (V4L2_CID_AUTOGAIN == ctrl->id) {
+		if ((value & 0x3) == 3)
+			value = 1;
+		else
+			value = 0;
+	}
+
+	if (V4L2_CID_HUE == ctrl->id) {
+		if (value == 0x7F)
+			value = 180;
+		else if (value == 0x80)
+			value = -180;
+		else
+			value = 0;
+	}
+
+	ctrl->value = value;
+
+	v4l_dbg(1, debug, decoder->client,
+			"Get Cotrol: %s - %d",
+			control->query_ctrl.name, value);
+	return 0;
+}
+
+/**
+ * ioctl_s_ctrl - V4L2 decoder interface handler for VIDIOC_S_CTRL ioctl
+ * @s: pointer to standard V4L2 device structure
+ * @vc: standard V4L2 VIDIOC_S_CTRL ioctl structure
+ *
+ * If the requested control is supported, sets the control's current
+ * value in HW. Otherwise, returns -EINVAL if the control is not supported.
+ */
+static int
+ioctl_s_ctrl(struct v4l2_int_device *s, struct v4l2_control *ctrl)
+{
+	struct tvp514x_decoder *decoder = s->priv;
+	int err, value, index;
+	const struct tvp514x_ctrl_info *control = NULL;
+
+	if (ctrl == NULL)
+		return -EINVAL;
+
+	value = (__s32) ctrl->value;
+	for (index = 0; index < decoder->num_ctrls; index++) {
+		control = &decoder->ctrl_list[index];
+		if (control->query_ctrl.id == ctrl->id)
+			break;	/* Match found */
+	}
+	if (index == decoder->num_ctrls)
+		return -EINVAL;	/* Index out of bound */
+
+	if (V4L2_CID_AUTOGAIN == ctrl->id) {
+		if (value == 1)
+			value = 0x0F;
+		else if (value == 0)
+			value = 0x0C;
+		else
+			return -ERANGE;
+	} else if (V4L2_CID_HUE == ctrl->id) {
+		if (value == 180)
+			value = 0x7F;
+		else if (value == -180)
+			value = 0x80;
+		else if (value == 0)
+			value = 0;
+		else
+			return -ERANGE;
+	} else {
+		if ((value < control->query_ctrl.minimum)
+			|| (value > control->query_ctrl.maximum))
+			return -ERANGE;
+	}
+
+	err =
+	    tvp514x_write_reg(decoder->client, control->reg_address,
+				value);
+	if (err)
+		return err;
+
+	tvp514x_reg_list[control->reg_address].val = value;
+
+	v4l_dbg(1, debug, decoder->client,
+			"Set Cotrol: %s - %d",
+			control->query_ctrl.name, value);
+	return err;
+}
+
+/**
+ * ioctl_enum_fmt_cap - Implement the CAPTURE buffer VIDIOC_ENUM_FMT ioctl
+ * @s: pointer to standard V4L2 device structure
+ * @fmt: standard V4L2 VIDIOC_ENUM_FMT ioctl structure
+ *
+ * Implement the VIDIOC_ENUM_FMT ioctl to enumerate supported formats
+ */
+static int
+ioctl_enum_fmt_cap(struct v4l2_int_device *s, struct v4l2_fmtdesc *fmt)
+{
+	struct tvp514x_decoder *decoder = s->priv;
+	int index;
+
+	if (fmt == NULL)
+		return -EINVAL;
+
+	index = fmt->index;
+	if ((index >= decoder->num_fmts) || (index < 0))
+		return -EINVAL;	/* Index out of bound */
+
+	if (fmt->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
+		return -EINVAL;	/* only capture is supported */
+
+	memcpy(fmt, &decoder->fmt_list[index],
+		sizeof(struct v4l2_fmtdesc));
+
+	v4l_dbg(1, debug, decoder->client,
+			"Current FMT: index - %d (%s)",
+			decoder->fmt_list[index].index,
+			decoder->fmt_list[index].description);
+	return 0;
+}
+
+/**
+ * ioctl_try_fmt_cap - Implement the CAPTURE buffer VIDIOC_TRY_FMT ioctl
+ * @s: pointer to standard V4L2 device structure
+ * @f: pointer to standard V4L2 VIDIOC_TRY_FMT ioctl structure
+ *
+ * Implement the VIDIOC_TRY_FMT ioctl for the CAPTURE buffer type. This
+ * ioctl is used to negotiate the image capture size and pixel format
+ * without actually making it take effect.
+ */
+static int
+ioctl_try_fmt_cap(struct v4l2_int_device *s, struct v4l2_format *f)
+{
+	struct tvp514x_decoder *decoder = s->priv;
+	int ifmt;
+	struct v4l2_pix_format *pix;
+	enum tvp514x_std current_std;
+
+	if (f == NULL)
+		return -EINVAL;
+
+	if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
+		f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+
+	pix = &f->fmt.pix;
+
+	/* Calculate height and width based on current standard */
+	current_std = tvp514x_get_current_std(decoder);
+	if (current_std == STD_INVALID)
+		return -EINVAL;
+
+	decoder->current_std = current_std;
+	pix->width = decoder->std_list[current_std].width;
+	pix->height = decoder->std_list[current_std].height;
+
+	for (ifmt = 0; ifmt < decoder->num_fmts; ifmt++) {
+		if (pix->pixelformat ==
+			decoder->fmt_list[ifmt].pixelformat)
+			break;
+	}
+	if (ifmt == decoder->num_fmts)
+		ifmt = 0;	/* None of the format matched, select default */
+	pix->pixelformat = decoder->fmt_list[ifmt].pixelformat;
+
+	pix->field = V4L2_FIELD_INTERLACED;
+	pix->bytesperline = pix->width * 2;
+	pix->sizeimage = pix->bytesperline * pix->height;
+	pix->colorspace = V4L2_COLORSPACE_SMPTE170M;
+	pix->priv = 0;
+
+	v4l_dbg(1, debug, decoder->client,
+			"Try FMT: pixelformat - %s, bytesperline - %d"
+			"Width - %d, Height - %d",
+			decoder->fmt_list[ifmt].description, pix->bytesperline,
+			pix->width, pix->height);
+	return 0;
+}
+
+/**
+ * ioctl_s_fmt_cap - V4L2 decoder interface handler for VIDIOC_S_FMT ioctl
+ * @s: pointer to standard V4L2 device structure
+ * @f: pointer to standard V4L2 VIDIOC_S_FMT ioctl structure
+ *
+ * If the requested format is supported, configures the HW to use that
+ * format, returns error code if format not supported or HW can't be
+ * correctly configured.
+ */
+static int
+ioctl_s_fmt_cap(struct v4l2_int_device *s, struct v4l2_format *f)
+{
+	struct tvp514x_decoder *decoder = s->priv;
+	struct v4l2_pix_format *pix;
+	int rval;
+
+	if (f == NULL)
+		return -EINVAL;
+
+	if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
+		return -EINVAL;	/* only capture is supported */
+
+	pix = &f->fmt.pix;
+	rval = ioctl_try_fmt_cap(s, f);
+	if (rval)
+		return rval;
+	else
+		decoder->pix = *pix;
+
+	return rval;
+}
+
+/**
+ * ioctl_g_fmt_cap - V4L2 decoder interface handler for ioctl_g_fmt_cap
+ * @s: pointer to standard V4L2 device structure
+ * @f: pointer to standard V4L2 v4l2_format structure
+ *
+ * Returns the decoder's current pixel format in the v4l2_format
+ * parameter.
+ */
+static int
+ioctl_g_fmt_cap(struct v4l2_int_device *s, struct v4l2_format *f)
+{
+	struct tvp514x_decoder *decoder = s->priv;
+
+	if (f == NULL)
+		return -EINVAL;
+
+	if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
+		return -EINVAL;	/* only capture is supported */
+
+	f->fmt.pix = decoder->pix;
+
+	v4l_dbg(1, debug, decoder->client,
+			"Current FMT: bytesperline - %d"
+			"Width - %d, Height - %d",
+			decoder->pix.bytesperline,
+			decoder->pix.width, decoder->pix.height);
+	return 0;
+}
+
+/**
+ * ioctl_g_parm - V4L2 decoder interface handler for VIDIOC_G_PARM ioctl
+ * @s: pointer to standard V4L2 device structure
+ * @a: pointer to standard V4L2 VIDIOC_G_PARM ioctl structure
+ *
+ * Returns the decoder's video CAPTURE parameters.
+ */
+static int
+ioctl_g_parm(struct v4l2_int_device *s, struct v4l2_streamparm *a)
+{
+	struct tvp514x_decoder *decoder = s->priv;
+	struct v4l2_captureparm *cparm;
+	enum tvp514x_std current_std;
+
+	if (a == NULL)
+		return -EINVAL;
+
+	if (a->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
+		return -EINVAL;	/* only capture is supported */
+
+	memset(a, 0, sizeof(*a));
+	a->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+
+	/* get the current standard */
+	current_std = tvp514x_get_current_std(decoder);
+	if (current_std == STD_INVALID)
+		return -EINVAL;
+
+	decoder->current_std = current_std;
+
+	cparm = &a->parm.capture;
+	cparm->capability = V4L2_CAP_TIMEPERFRAME;
+	cparm->timeperframe =
+		decoder->std_list[current_std].standard.frameperiod;
+
+	return 0;
+}
+
+/**
+ * ioctl_s_parm - V4L2 decoder interface handler for VIDIOC_S_PARM ioctl
+ * @s: pointer to standard V4L2 device structure
+ * @a: pointer to standard V4L2 VIDIOC_S_PARM ioctl structure
+ *
+ * Configures the decoder to use the input parameters, if possible. If
+ * not possible, returns the appropriate error code.
+ */
+static int
+ioctl_s_parm(struct v4l2_int_device *s, struct v4l2_streamparm *a)
+{
+	struct tvp514x_decoder *decoder = s->priv;
+	struct v4l2_fract *timeperframe;
+	enum tvp514x_std current_std;
+
+	if (a == NULL)
+		return -EINVAL;
+
+	if (a->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
+		return -EINVAL;	/* only capture is supported */
+
+	timeperframe = &a->parm.capture.timeperframe;
+
+	/* get the current standard */
+	current_std = tvp514x_get_current_std(decoder);
+	if (current_std == STD_INVALID)
+		return -EINVAL;
+
+	decoder->current_std = current_std;
+
+	*timeperframe =
+	    decoder->std_list[current_std].standard.frameperiod;
+
+	return 0;
+}
+
+/**
+ * ioctl_g_ifparm - V4L2 decoder interface handler for vidioc_int_g_ifparm_num
+ * @s: pointer to standard V4L2 device structure
+ * @p: pointer to standard V4L2 vidioc_int_g_ifparm_num ioctl structure
+ *
+ * Gets slave interface parameters.
+ * Calculates the required xclk value to support the requested
+ * clock parameters in p. This value is returned in the p
+ * parameter.
+ */
+static int ioctl_g_ifparm(struct v4l2_int_device *s, struct v4l2_ifparm *p)
+{
+	struct tvp514x_decoder *decoder = s->priv;
+	int rval;
+
+	if (p == NULL)
+		return -EINVAL;
+
+	if (NULL == decoder->pdata->ifparm)
+		return -EINVAL;
+
+	rval = decoder->pdata->ifparm(p);
+	if (rval) {
+		v4l_err(decoder->client, "g_ifparm.Err[%d]\n", rval);
+		return rval;
+	}
+
+	p->u.bt656.clock_curr = TVP514X_XCLK_BT656;
+
+	return 0;
+}
+
+/**
+ * ioctl_g_priv - V4L2 decoder interface handler for vidioc_int_g_priv_num
+ * @s: pointer to standard V4L2 device structure
+ * @p: void pointer to hold decoder's private data address
+ *
+ * Returns device's (decoder's) private data area address in p parameter
+ */
+static int ioctl_g_priv(struct v4l2_int_device *s, void *p)
+{
+	struct tvp514x_decoder *decoder = s->priv;
+
+	if (NULL == decoder->pdata->priv_data_set)
+		return -EINVAL;
+
+	return decoder->pdata->priv_data_set(p);
+}
+
+/**
+ * ioctl_s_power - V4L2 decoder interface handler for vidioc_int_s_power_num
+ * @s: pointer to standard V4L2 device structure
+ * @on: power state to which device is to be set
+ *
+ * Sets devices power state to requrested state, if possible.
+ */
+static int ioctl_s_power(struct v4l2_int_device *s, enum v4l2_power on)
+{
+	struct tvp514x_decoder *decoder = s->priv;
+	int err = 0;
+
+	switch (on) {
+	case V4L2_POWER_OFF:
+		/* Power Down Sequence */
+		err =
+		    tvp514x_write_reg(decoder->client, REG_OPERATION_MODE,
+					0x01);
+		/* Disable mux for TVP5146/47 decoder data path */
+		if (decoder->pdata->power_set)
+			err |= decoder->pdata->power_set(on);
+		decoder->state = STATE_NOT_DETECTED;
+		break;
+
+	case V4L2_POWER_STANDBY:
+		if (decoder->pdata->power_set)
+			err = decoder->pdata->power_set(on);
+		break;
+
+	case V4L2_POWER_ON:
+		/* Enable mux for TVP5146/47 decoder data path */
+		if ((decoder->pdata->power_set) &&
+				(decoder->state == STATE_NOT_DETECTED)) {
+			int i;
+			struct tvp514x_init_seq *int_seq =
+				(struct tvp514x_init_seq *)
+				decoder->id->driver_data;
+
+			err = decoder->pdata->power_set(on);
+
+			/* Power Up Sequence */
+			for (i = 0; i < int_seq->no_regs; i++) {
+				err |= tvp514x_write_reg(decoder->client,
+						int_seq->init_reg_seq[i].reg,
+						int_seq->init_reg_seq[i].val);
+			}
+			/* Detect the sensor is not already detected */
+			err |= tvp514x_detect(decoder);
+			if (err) {
+				v4l_err(decoder->client,
+						"Unable to detect decoder\n");
+				return err;
+			}
+		}
+		err |= tvp514x_configure(decoder);
+		break;
+
+	default:
+		err = -ENODEV;
+		break;
+	}
+
+	return err;
+}
+
+/**
+ * ioctl_init - V4L2 decoder interface handler for VIDIOC_INT_INIT
+ * @s: pointer to standard V4L2 device structure
+ *
+ * Initialize the decoder device (calls tvp514x_configure())
+ */
+static int ioctl_init(struct v4l2_int_device *s)
+{
+	struct tvp514x_decoder *decoder = s->priv;
+
+	/* Set default standard to auto */
+	tvp514x_reg_list[REG_VIDEO_STD].val =
+	    VIDEO_STD_AUTO_SWITCH_BIT;
+
+	return tvp514x_configure(decoder);
+}
+
+/**
+ * ioctl_dev_exit - V4L2 decoder interface handler for vidioc_int_dev_exit_num
+ * @s: pointer to standard V4L2 device structure
+ *
+ * Delinitialise the dev. at slave detach. The complement of ioctl_dev_init.
+ */
+static int ioctl_dev_exit(struct v4l2_int_device *s)
+{
+	return 0;
+}
+
+/**
+ * ioctl_dev_init - V4L2 decoder interface handler for vidioc_int_dev_init_num
+ * @s: pointer to standard V4L2 device structure
+ *
+ * Initialise the device when slave attaches to the master. Returns 0 if
+ * TVP5146/47 device could be found, otherwise returns appropriate error.
+ */
+static int ioctl_dev_init(struct v4l2_int_device *s)
+{
+	struct tvp514x_decoder *decoder = s->priv;
+	int err;
+
+	err = tvp514x_detect(decoder);
+	if (err < 0) {
+		v4l_err(decoder->client,
+			"Unable to detect decoder\n");
+		return err;
+	}
+
+	v4l_info(decoder->client,
+		 "chip version 0x%.2x detected\n", decoder->ver);
+
+	return 0;
+}
+
+static struct v4l2_int_ioctl_desc tvp514x_ioctl_desc[] = {
+	{vidioc_int_dev_init_num, (v4l2_int_ioctl_func*) ioctl_dev_init},
+	{vidioc_int_dev_exit_num, (v4l2_int_ioctl_func*) ioctl_dev_exit},
+	{vidioc_int_s_power_num, (v4l2_int_ioctl_func*) ioctl_s_power},
+	{vidioc_int_g_priv_num, (v4l2_int_ioctl_func*) ioctl_g_priv},
+	{vidioc_int_g_ifparm_num, (v4l2_int_ioctl_func*) ioctl_g_ifparm},
+	{vidioc_int_init_num, (v4l2_int_ioctl_func*) ioctl_init},
+	{vidioc_int_enum_fmt_cap_num,
+	 (v4l2_int_ioctl_func *) ioctl_enum_fmt_cap},
+	{vidioc_int_try_fmt_cap_num,
+	 (v4l2_int_ioctl_func *) ioctl_try_fmt_cap},
+	{vidioc_int_g_fmt_cap_num,
+	 (v4l2_int_ioctl_func *) ioctl_g_fmt_cap},
+	{vidioc_int_s_fmt_cap_num,
+	 (v4l2_int_ioctl_func *) ioctl_s_fmt_cap},
+	{vidioc_int_g_parm_num, (v4l2_int_ioctl_func *) ioctl_g_parm},
+	{vidioc_int_s_parm_num, (v4l2_int_ioctl_func *) ioctl_s_parm},
+	{vidioc_int_queryctrl_num,
+	 (v4l2_int_ioctl_func *) ioctl_queryctrl},
+	{vidioc_int_g_ctrl_num, (v4l2_int_ioctl_func *) ioctl_g_ctrl},
+	{vidioc_int_s_ctrl_num, (v4l2_int_ioctl_func *) ioctl_s_ctrl},
+	{vidioc_int_querystd_num, (v4l2_int_ioctl_func *) ioctl_querystd},
+	{vidioc_int_s_std_num, (v4l2_int_ioctl_func *) ioctl_s_std},
+	{vidioc_int_g_video_routing_num,
+		(v4l2_int_ioctl_func *) ioctl_g_routing},
+	{vidioc_int_s_video_routing_num,
+		(v4l2_int_ioctl_func *) ioctl_s_routing},
+};
+
+static struct v4l2_int_slave tvp514x_slave = {
+	.ioctls = tvp514x_ioctl_desc,
+	.num_ioctls = ARRAY_SIZE(tvp514x_ioctl_desc),
+};
+
+static struct tvp514x_decoder tvp514x_dev = {
+	.state = STATE_NOT_DETECTED,
+
+	.num_fmts = TVP514X_NUM_FORMATS,
+	.fmt_list = tvp514x_fmt_list,
+
+	.pix = {		/* Default to NTSC 8-bit YUV 422 */
+		.width = NTSC_NUM_ACTIVE_PIXELS,
+		.height = NTSC_NUM_ACTIVE_LINES,
+		.pixelformat = V4L2_PIX_FMT_UYVY,
+		.field = V4L2_FIELD_INTERLACED,
+		.bytesperline = NTSC_NUM_ACTIVE_PIXELS * 2,
+		.sizeimage =
+		NTSC_NUM_ACTIVE_PIXELS * 2 * NTSC_NUM_ACTIVE_LINES,
+		.colorspace = V4L2_COLORSPACE_SMPTE170M,
+		},
+
+	.current_std = STD_NTSC_MJ,
+	.num_stds = TVP514X_NUM_STANDARDS,
+	.std_list = tvp514x_std_list,
+
+	.num_ctrls = TVP514X_NUM_CONTROLS,
+	.ctrl_list = tvp514x_ctrl_list,
+
+};
+
+static struct v4l2_int_device tvp514x_int_device = {
+	.module = THIS_MODULE,
+	.name = MODULE_NAME,
+	.priv = &tvp514x_dev,
+	.type = v4l2_int_type_slave,
+	.u = {
+	      .slave = &tvp514x_slave,
+	      },
+};
+
+/**
+ * tvp514x_probe - decoder driver i2c probe handler
+ * @client: i2c driver client device structure
+ *
+ * Register decoder as an i2c client device and V4L2
+ * device.
+ */
+static int
+tvp514x_probe(struct i2c_client *client, const struct i2c_device_id *id)
+{
+	struct tvp514x_decoder *decoder = &tvp514x_dev;
+	int err;
+
+	/* Check if the adapter supports the needed features */
+	if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA))
+		return -EIO;
+
+	decoder->pdata = client->dev.platform_data;
+	if (!decoder->pdata) {
+		v4l_err(client, "No platform data\n!!");
+		return -ENODEV;
+	}
+	/*
+	 * Fetch platform specific data, and configure the
+	 * tvp514x_reg_list[] accordingly. Since this is one
+	 * time configuration, no need to preserve.
+	 */
+	decoder->inputidx = decoder->pdata->default_input;
+	tvp514x_reg_list[REG_OUTPUT_FORMATTER2].val |=
+			(decoder->pdata->clk_polarity << 1);
+	tvp514x_reg_list[REG_OUTPUT_FORMATTER1].val |=
+			decoder->pdata->fmt;
+	tvp514x_reg_list[REG_SYNC_CONTROL].val |=
+			((decoder->pdata->hs_polarity << 2) |
+			(decoder->pdata->vs_polarity << 3));
+	/*
+	 * Save the id data, required for power up sequence
+	 */
+	decoder->id = (struct i2c_device_id *)id;
+	/* Attach to Master */
+	strcpy(tvp514x_int_device.u.slave->attach_to, decoder->pdata->master);
+	decoder->v4l2_int_device = &tvp514x_int_device;
+	decoder->client = client;
+	i2c_set_clientdata(client, decoder);
+
+	/* Register with V4L2 layer as slave device */
+	err = v4l2_int_device_register(decoder->v4l2_int_device);
+	if (err) {
+		i2c_set_clientdata(client, NULL);
+		v4l_err(client,
+			"Unable to register to v4l2. Err[%d]\n", err);
+
+	} else
+		v4l_info(client, "Registered to v4l2 master %s!!\n",
+				decoder->pdata->master);
+
+	return 0;
+}
+
+/**
+ * tvp514x_remove - decoder driver i2c remove handler
+ * @client: i2c driver client device structure
+ *
+ * Unregister decoder as an i2c client device and V4L2
+ * device. Complement of tvp514x_probe().
+ */
+static int __exit tvp514x_remove(struct i2c_client *client)
+{
+	struct tvp514x_decoder *decoder = i2c_get_clientdata(client);
+
+	if (!client->adapter)
+		return -ENODEV;	/* our client isn't attached */
+
+	v4l2_int_device_unregister(decoder->v4l2_int_device);
+	i2c_set_clientdata(client, NULL);
+
+	return 0;
+}
+/*
+ * TVP5146 Init/Power on Sequence
+ */
+static struct tvp514x_reg tvp5146_init_reg_seq[] = {
+	{TOK_WRITE, REG_VBUS_ADDRESS_ACCESS1, 0x02},
+	{TOK_WRITE, REG_VBUS_ADDRESS_ACCESS2, 0x00},
+	{TOK_WRITE, REG_VBUS_ADDRESS_ACCESS3, 0x80},
+	{TOK_WRITE, REG_VBUS_DATA_ACCESS_NO_VBUS_ADDR_INCR, 0x01},
+	{TOK_WRITE, REG_VBUS_ADDRESS_ACCESS1, 0x60},
+	{TOK_WRITE, REG_VBUS_ADDRESS_ACCESS2, 0x00},
+	{TOK_WRITE, REG_VBUS_ADDRESS_ACCESS3, 0xB0},
+	{TOK_WRITE, REG_VBUS_DATA_ACCESS_NO_VBUS_ADDR_INCR, 0x01},
+	{TOK_WRITE, REG_VBUS_DATA_ACCESS_NO_VBUS_ADDR_INCR, 0x00},
+	{TOK_WRITE, REG_OPERATION_MODE, 0x01},
+	{TOK_WRITE, REG_OPERATION_MODE, 0x00},
+};
+static struct tvp514x_init_seq tvp5146_init = {
+	.no_regs = ARRAY_SIZE(tvp5146_init_reg_seq),
+	.init_reg_seq = tvp5146_init_reg_seq,
+};
+/*
+ * TVP5147 Init/Power on Sequence
+ */
+static struct tvp514x_reg tvp5147_init_reg_seq[] =	{
+	{TOK_WRITE, REG_VBUS_ADDRESS_ACCESS1, 0x02},
+	{TOK_WRITE, REG_VBUS_ADDRESS_ACCESS2, 0x00},
+	{TOK_WRITE, REG_VBUS_ADDRESS_ACCESS3, 0x80},
+	{TOK_WRITE, REG_VBUS_DATA_ACCESS_NO_VBUS_ADDR_INCR, 0x01},
+	{TOK_WRITE, REG_VBUS_ADDRESS_ACCESS1, 0x60},
+	{TOK_WRITE, REG_VBUS_ADDRESS_ACCESS2, 0x00},
+	{TOK_WRITE, REG_VBUS_ADDRESS_ACCESS3, 0xB0},
+	{TOK_WRITE, REG_VBUS_DATA_ACCESS_NO_VBUS_ADDR_INCR, 0x01},
+	{TOK_WRITE, REG_VBUS_ADDRESS_ACCESS1, 0x16},
+	{TOK_WRITE, REG_VBUS_ADDRESS_ACCESS2, 0x00},
+	{TOK_WRITE, REG_VBUS_ADDRESS_ACCESS3, 0xA0},
+	{TOK_WRITE, REG_VBUS_DATA_ACCESS_NO_VBUS_ADDR_INCR, 0x16},
+	{TOK_WRITE, REG_VBUS_ADDRESS_ACCESS1, 0x60},
+	{TOK_WRITE, REG_VBUS_ADDRESS_ACCESS2, 0x00},
+	{TOK_WRITE, REG_VBUS_ADDRESS_ACCESS3, 0xB0},
+	{TOK_WRITE, REG_VBUS_DATA_ACCESS_NO_VBUS_ADDR_INCR, 0x00},
+	{TOK_WRITE, REG_OPERATION_MODE, 0x01},
+	{TOK_WRITE, REG_OPERATION_MODE, 0x00},
+};
+static struct tvp514x_init_seq tvp5147_init = {
+	.no_regs = ARRAY_SIZE(tvp5147_init_reg_seq),
+	.init_reg_seq = tvp5147_init_reg_seq,
+};
+/*
+ * TVP5146M2/TVP5147M1 Init/Power on Sequence
+ */
+static struct tvp514x_reg tvp514xm_init_reg_seq[] = {
+	{TOK_WRITE, REG_OPERATION_MODE, 0x01},
+	{TOK_WRITE, REG_OPERATION_MODE, 0x00},
+};
+static struct tvp514x_init_seq tvp514xm_init = {
+	.no_regs = ARRAY_SIZE(tvp514xm_init_reg_seq),
+	.init_reg_seq = tvp514xm_init_reg_seq,
+};
+/*
+ * I2C Device Table -
+ *
+ * name - Name of the actual device/chip.
+ * driver_data - Driver data
+ */
+static const struct i2c_device_id tvp514x_id[] = {
+	{"tvp5146", (unsigned int)&tvp5146_init},
+	{"tvp5146m2", (unsigned int)&tvp514xm_init},
+	{"tvp5147", (unsigned int)&tvp5147_init},
+	{"tvp5147m1", (unsigned int)&tvp514xm_init},
+	{},
+};
+
+MODULE_DEVICE_TABLE(i2c, tvp514x_id);
+
+static struct i2c_driver tvp514x_i2c_driver = {
+	.driver = {
+		   .name = MODULE_NAME,
+		   .owner = THIS_MODULE,
+		   },
+	.probe = tvp514x_probe,
+	.remove = __exit_p(tvp514x_remove),
+	.id_table = tvp514x_id,
+};
+
+/**
+ * tvp514x_init
+ *
+ * Module init function
+ */
+static int __init tvp514x_init(void)
+{
+	int err;
+
+	err = i2c_add_driver(&tvp514x_i2c_driver);
+	if (err) {
+		printk(KERN_ERR "Failed to register " MODULE_NAME ".\n");
+		return err;
+	}
+	return 0;
+}
+
+/**
+ * tvp514x_cleanup
+ *
+ * Module exit function
+ */
+static void __exit tvp514x_cleanup(void)
+{
+	i2c_del_driver(&tvp514x_i2c_driver);
+}
+
+module_init(tvp514x_init);
+module_exit(tvp514x_cleanup);
+
+MODULE_AUTHOR("Texas Instruments");
+MODULE_DESCRIPTION("TVP514X linux decoder driver");
+MODULE_LICENSE("GPL");
diff --git a/drivers/media/video/tvp514x_regs.h b/drivers/media/video/tvp514x_regs.h
new file mode 100755
index 0000000..003a3c1
--- /dev/null
+++ b/drivers/media/video/tvp514x_regs.h
@@ -0,0 +1,292 @@
+/*
+ * drivers/media/video/tvp514x_regs.h
+ *
+ * Copyright (C) 2008 Texas Instruments Inc
+ * Author: Vaibhav Hiremath <hvaibhav@ti.com>
+ *
+ * Contributors:
+ *     Sivaraj R <sivaraj@ti.com>
+ *     Brijesh R Jadav <brijesh.j@ti.com>
+ *     Hardik Shah <hardik.shah@ti.com>
+ *     Manjunath Hadli <mrh@ti.com>
+ *     Karicheri Muralidharan <m-karicheri2@ti.com>
+ *
+ * This package is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#ifndef _TVP514X_REGS_H
+#define _TVP514X_REGS_H
+
+/*
+ * TVP5146/47 registers
+ */
+#define REG_INPUT_SEL			(0x00)
+#define REG_AFE_GAIN_CTRL		(0x01)
+#define REG_VIDEO_STD			(0x02)
+#define REG_OPERATION_MODE		(0x03)
+#define REG_AUTOSWITCH_MASK		(0x04)
+
+#define REG_COLOR_KILLER		(0x05)
+#define REG_LUMA_CONTROL1		(0x06)
+#define REG_LUMA_CONTROL2		(0x07)
+#define REG_LUMA_CONTROL3		(0x08)
+
+#define REG_BRIGHTNESS			(0x09)
+#define REG_CONTRAST			(0x0A)
+#define REG_SATURATION			(0x0B)
+#define REG_HUE				(0x0C)
+
+#define REG_CHROMA_CONTROL1		(0x0D)
+#define REG_CHROMA_CONTROL2		(0x0E)
+
+/* 0x0F Reserved */
+
+#define REG_COMP_PR_SATURATION		(0x10)
+#define REG_COMP_Y_CONTRAST		(0x11)
+#define REG_COMP_PB_SATURATION		(0x12)
+
+/* 0x13 Reserved */
+
+#define REG_COMP_Y_BRIGHTNESS		(0x14)
+
+/* 0x15 Reserved */
+
+#define REG_AVID_START_PIXEL_LSB	(0x16)
+#define REG_AVID_START_PIXEL_MSB	(0x17)
+#define REG_AVID_STOP_PIXEL_LSB		(0x18)
+#define REG_AVID_STOP_PIXEL_MSB		(0x19)
+
+#define REG_HSYNC_START_PIXEL_LSB	(0x1A)
+#define REG_HSYNC_START_PIXEL_MSB	(0x1B)
+#define REG_HSYNC_STOP_PIXEL_LSB	(0x1C)
+#define REG_HSYNC_STOP_PIXEL_MSB	(0x1D)
+
+#define REG_VSYNC_START_LINE_LSB	(0x1E)
+#define REG_VSYNC_START_LINE_MSB	(0x1F)
+#define REG_VSYNC_STOP_LINE_LSB		(0x20)
+#define REG_VSYNC_STOP_LINE_MSB		(0x21)
+
+#define REG_VBLK_START_LINE_LSB		(0x22)
+#define REG_VBLK_START_LINE_MSB		(0x23)
+#define REG_VBLK_STOP_LINE_LSB		(0x24)
+#define REG_VBLK_STOP_LINE_MSB		(0x25)
+
+/* 0x26 - 0x27 Reserved */
+
+#define REG_FAST_SWTICH_CONTROL		(0x28)
+
+/* 0x29 Reserved */
+
+#define REG_FAST_SWTICH_SCART_DELAY	(0x2A)
+
+/* 0x2B Reserved */
+
+#define REG_SCART_DELAY			(0x2C)
+#define REG_CTI_DELAY			(0x2D)
+#define REG_CTI_CONTROL			(0x2E)
+
+/* 0x2F - 0x31 Reserved */
+
+#define REG_SYNC_CONTROL		(0x32)
+#define REG_OUTPUT_FORMATTER1		(0x33)
+#define REG_OUTPUT_FORMATTER2		(0x34)
+#define REG_OUTPUT_FORMATTER3		(0x35)
+#define REG_OUTPUT_FORMATTER4		(0x36)
+#define REG_OUTPUT_FORMATTER5		(0x37)
+#define REG_OUTPUT_FORMATTER6		(0x38)
+#define REG_CLEAR_LOST_LOCK		(0x39)
+
+#define REG_STATUS1			(0x3A)
+#define REG_STATUS2			(0x3B)
+
+#define REG_AGC_GAIN_STATUS_LSB		(0x3C)
+#define REG_AGC_GAIN_STATUS_MSB		(0x3D)
+
+/* 0x3E Reserved */
+
+#define REG_VIDEO_STD_STATUS		(0x3F)
+#define REG_GPIO_INPUT1			(0x40)
+#define REG_GPIO_INPUT2			(0x41)
+
+/* 0x42 - 0x45 Reserved */
+
+#define REG_AFE_COARSE_GAIN_CH1		(0x46)
+#define REG_AFE_COARSE_GAIN_CH2		(0x47)
+#define REG_AFE_COARSE_GAIN_CH3		(0x48)
+#define REG_AFE_COARSE_GAIN_CH4		(0x49)
+
+#define REG_AFE_FINE_GAIN_PB_B_LSB	(0x4A)
+#define REG_AFE_FINE_GAIN_PB_B_MSB	(0x4B)
+#define REG_AFE_FINE_GAIN_Y_G_CHROMA_LSB	(0x4C)
+#define REG_AFE_FINE_GAIN_Y_G_CHROMA_MSB	(0x4D)
+#define REG_AFE_FINE_GAIN_PR_R_LSB	(0x4E)
+#define REG_AFE_FINE_GAIN_PR_R_MSB	(0x4F)
+#define REG_AFE_FINE_GAIN_CVBS_LUMA_LSB	(0x50)
+#define REG_AFE_FINE_GAIN_CVBS_LUMA_MSB	(0x51)
+
+/* 0x52 - 0x68 Reserved */
+
+#define REG_FBIT_VBIT_CONTROL1		(0x69)
+
+/* 0x6A - 0x6B Reserved */
+
+#define REG_BACKEND_AGC_CONTROL		(0x6C)
+
+/* 0x6D - 0x6E Reserved */
+
+#define REG_AGC_DECREMENT_SPEED_CONTROL	(0x6F)
+#define REG_ROM_VERSION			(0x70)
+
+/* 0x71 - 0x73 Reserved */
+
+#define REG_AGC_WHITE_PEAK_PROCESSING	(0x74)
+#define REG_FBIT_VBIT_CONTROL2		(0x75)
+#define REG_VCR_TRICK_MODE_CONTROL	(0x76)
+#define REG_HORIZONTAL_SHAKE_INCREMENT	(0x77)
+#define REG_AGC_INCREMENT_SPEED		(0x78)
+#define REG_AGC_INCREMENT_DELAY		(0x79)
+
+/* 0x7A - 0x7F Reserved */
+
+#define REG_CHIP_ID_MSB			(0x80)
+#define REG_CHIP_ID_LSB			(0x81)
+
+/* 0x82 Reserved */
+
+#define REG_CPLL_SPEED_CONTROL		(0x83)
+
+/* 0x84 - 0x96 Reserved */
+
+#define REG_STATUS_REQUEST		(0x97)
+
+/* 0x98 - 0x99 Reserved */
+
+#define REG_VERTICAL_LINE_COUNT_LSB	(0x9A)
+#define REG_VERTICAL_LINE_COUNT_MSB	(0x9B)
+
+/* 0x9C - 0x9D Reserved */
+
+#define REG_AGC_DECREMENT_DELAY		(0x9E)
+
+/* 0x9F - 0xB0 Reserved */
+
+#define REG_VDP_TTX_FILTER_1_MASK1	(0xB1)
+#define REG_VDP_TTX_FILTER_1_MASK2	(0xB2)
+#define REG_VDP_TTX_FILTER_1_MASK3	(0xB3)
+#define REG_VDP_TTX_FILTER_1_MASK4	(0xB4)
+#define REG_VDP_TTX_FILTER_1_MASK5	(0xB5)
+#define REG_VDP_TTX_FILTER_2_MASK1	(0xB6)
+#define REG_VDP_TTX_FILTER_2_MASK2	(0xB7)
+#define REG_VDP_TTX_FILTER_2_MASK3	(0xB8)
+#define REG_VDP_TTX_FILTER_2_MASK4	(0xB9)
+#define REG_VDP_TTX_FILTER_2_MASK5	(0xBA)
+#define REG_VDP_TTX_FILTER_CONTROL	(0xBB)
+#define REG_VDP_FIFO_WORD_COUNT		(0xBC)
+#define REG_VDP_FIFO_INTERRUPT_THRLD	(0xBD)
+
+/* 0xBE Reserved */
+
+#define REG_VDP_FIFO_RESET		(0xBF)
+#define REG_VDP_FIFO_OUTPUT_CONTROL	(0xC0)
+#define REG_VDP_LINE_NUMBER_INTERRUPT	(0xC1)
+#define REG_VDP_PIXEL_ALIGNMENT_LSB	(0xC2)
+#define REG_VDP_PIXEL_ALIGNMENT_MSB	(0xC3)
+
+/* 0xC4 - 0xD5 Reserved */
+
+#define REG_VDP_LINE_START		(0xD6)
+#define REG_VDP_LINE_STOP		(0xD7)
+#define REG_VDP_GLOBAL_LINE_MODE	(0xD8)
+#define REG_VDP_FULL_FIELD_ENABLE	(0xD9)
+#define REG_VDP_FULL_FIELD_MODE		(0xDA)
+
+/* 0xDB - 0xDF Reserved */
+
+#define REG_VBUS_DATA_ACCESS_NO_VBUS_ADDR_INCR	(0xE0)
+#define REG_VBUS_DATA_ACCESS_VBUS_ADDR_INCR	(0xE1)
+#define REG_FIFO_READ_DATA			(0xE2)
+
+/* 0xE3 - 0xE7 Reserved */
+
+#define REG_VBUS_ADDRESS_ACCESS1	(0xE8)
+#define REG_VBUS_ADDRESS_ACCESS2	(0xE9)
+#define REG_VBUS_ADDRESS_ACCESS3	(0xEA)
+
+/* 0xEB - 0xEF Reserved */
+
+#define REG_INTERRUPT_RAW_STATUS0	(0xF0)
+#define REG_INTERRUPT_RAW_STATUS1	(0xF1)
+#define REG_INTERRUPT_STATUS0		(0xF2)
+#define REG_INTERRUPT_STATUS1		(0xF3)
+#define REG_INTERRUPT_MASK0		(0xF4)
+#define REG_INTERRUPT_MASK1		(0xF5)
+#define REG_INTERRUPT_CLEAR0		(0xF6)
+#define REG_INTERRUPT_CLEAR1		(0xF7)
+
+/* 0xF8 - 0xFF Reserved */
+
+/*
+ * Mask and bit definitions of TVP5146/47 registers
+ */
+/* The ID values we are looking for */
+#define TVP514X_CHIP_ID_MSB		(0x51)
+#define TVP5146_CHIP_ID_LSB		(0x46)
+#define TVP5147_CHIP_ID_LSB		(0x47)
+
+#define VIDEO_STD_MASK			(0x07)
+#define VIDEO_STD_AUTO_SWITCH_BIT	(0x00)
+#define VIDEO_STD_NTSC_MJ_BIT		(0x01)
+#define VIDEO_STD_PAL_BDGHIN_BIT	(0x02)
+#define VIDEO_STD_PAL_M_BIT		(0x03)
+#define VIDEO_STD_PAL_COMBINATION_N_BIT	(0x04)
+#define VIDEO_STD_NTSC_4_43_BIT		(0x05)
+#define VIDEO_STD_SECAM_BIT		(0x06)
+#define VIDEO_STD_PAL_60_BIT		(0x07)
+
+/*
+ * Status bit
+ */
+#define STATUS_TV_VCR_BIT		(1<<0)
+#define STATUS_HORZ_SYNC_LOCK_BIT	(1<<1)
+#define STATUS_VIRT_SYNC_LOCK_BIT	(1<<2)
+#define STATUS_CLR_SUBCAR_LOCK_BIT	(1<<3)
+#define STATUS_LOST_LOCK_DETECT_BIT	(1<<4)
+#define STATUS_FEILD_RATE_BIT		(1<<5)
+#define STATUS_LINE_ALTERNATING_BIT	(1<<6)
+#define STATUS_PEAK_WHITE_DETECT_BIT	(1<<7)
+
+/**
+ * struct tvp514x_reg - Structure for TVP5146/47 register initialization values
+ * @token - Token: TOK_WRITE, TOK_TERM etc..
+ * @reg - Register offset
+ * @val - Register Value for TOK_WRITE or delay in ms for TOK_DELAY
+ */
+struct tvp514x_reg {
+	u8 token;
+	u8 reg;
+	u32 val;
+};
+
+/**
+ * struct tvp514x_init_seq - Structure for TVP5146/47/46M2/47M1 power up
+ *		Sequence.
+ * @ no_regs - Number of registers to write for power up sequence.
+ * @ init_reg_seq - Array of registers and respective value to write.
+ */
+struct tvp514x_init_seq {
+	unsigned int no_regs;
+	struct tvp514x_reg *init_reg_seq;
+};
+#endif				/* ifndef _TVP514X_REGS_H */
diff --git a/include/media/tvp514x.h b/include/media/tvp514x.h
new file mode 100755
index 0000000..2fee5e7
--- /dev/null
+++ b/include/media/tvp514x.h
@@ -0,0 +1,232 @@
+/*
+ * drivers/media/video/tvp514x.h
+ *
+ * Copyright (C) 2008 Texas Instruments Inc
+ * Author: Vaibhav Hiremath <hvaibhav@ti.com>
+ *
+ * Contributors:
+ *     Sivaraj R <sivaraj@ti.com>
+ *     Brijesh R Jadav <brijesh.j@ti.com>
+ *     Hardik Shah <hardik.shah@ti.com>
+ *     Manjunath Hadli <mrh@ti.com>
+ *     Karicheri Muralidharan <m-karicheri2@ti.com>
+ *
+ * This package is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#ifndef _TVP514X_H
+#define _TVP514X_H
+
+/*
+ * Other macros
+ */
+#define TVP514X_MODULE_NAME		"tvp514x"
+#define TVP514X_I2C_DELAY		(3)
+#define I2C_RETRY_COUNT			(5)
+#define LOCK_RETRY_COUNT		(5)
+#define LOCK_RETRY_DELAY		(200)
+
+#define TOK_WRITE			(0)	/* token for write operation */
+#define TOK_TERM			(1)	/* terminating token */
+#define TOK_DELAY			(2)	/* delay token for reg list */
+#define TOK_SKIP			(3)	/* token to skip a register */
+
+#define TVP514X_XCLK_BT656		(27000000)
+
+/* Number of pixels and number of lines per frame for different standards */
+#define NTSC_NUM_ACTIVE_PIXELS		(720)
+#define NTSC_NUM_ACTIVE_LINES		(480)
+#define PAL_NUM_ACTIVE_PIXELS		(720)
+#define PAL_NUM_ACTIVE_LINES		(576)
+
+/**
+ * enum tvp514x_std - enum for supported standards
+ */
+enum tvp514x_std {
+	STD_NTSC_MJ = 0,
+	STD_PAL_BDGHIN,
+	STD_INVALID
+};
+
+/**
+ * enum tvp514x_state - enum for different decoder states
+ */
+enum tvp514x_state {
+	STATE_NOT_DETECTED,
+	STATE_DETECTED
+};
+
+/**
+ * enum tvp514x_input - enum for different decoder input pin
+ *		configuration.
+ */
+enum tvp514x_input {
+	/*
+	 * CVBS input selection
+	 */
+	INPUT_CVBS_VI1A = 0x0,
+	INPUT_CVBS_VI1B,
+	INPUT_CVBS_VI1C,
+	INPUT_CVBS_VI2A = 0x04,
+	INPUT_CVBS_VI2B,
+	INPUT_CVBS_VI2C,
+	INPUT_CVBS_VI3A = 0x08,
+	INPUT_CVBS_VI3B,
+	INPUT_CVBS_VI3C,
+	INPUT_CVBS_VI4A = 0x0C,
+	/*
+	 * S-Video input selection
+	 */
+	INPUT_SVIDEO_VI2A_VI1A = 0x44,
+	INPUT_SVIDEO_VI2B_VI1B,
+	INPUT_SVIDEO_VI2C_VI1C,
+	INPUT_SVIDEO_VI2A_VI3A = 0x54,
+	INPUT_SVIDEO_VI2B_VI3B,
+	INPUT_SVIDEO_VI2C_VI3C,
+	INPUT_SVIDEO_VI4A_VI1A = 0x4C,
+	INPUT_SVIDEO_VI4A_VI1B,
+	INPUT_SVIDEO_VI4A_VI1C,
+	INPUT_SVIDEO_VI4A_VI3A = 0x5C,
+	INPUT_SVIDEO_VI4A_VI3B,
+	INPUT_SVIDEO_VI4A_VI3C
+
+	/* Need to add entries for
+	 * RGB, YPbPr and SCART.
+	 */
+};
+
+/**
+ * enum tvp514x_output_fmt - enum for output format
+ *			supported.
+ */
+enum tvp514x_output_fmt {
+	OUTPUT_10BIT_422_EMBEDDED_SYNC = 0,
+	OUTPUT_20BIT_422_SEPERATE_SYNC,
+	OUTPUT_10BIT_422_SEPERATE_SYNC = 3,
+	OUTPUT_INVALID
+};
+
+/**
+ * struct tvp514x_std_info - Structure to store standard informations
+ * @width: Line width in pixels
+ * @height:Number of active lines
+ * @video_std: Value to write in REG_VIDEO_STD register
+ * @standard: v4l2 standard structure information
+ */
+struct tvp514x_std_info {
+	unsigned long width;
+	unsigned long height;
+	u8 video_std;
+	struct v4l2_standard standard;
+};
+
+/**
+ * struct tvp514x_ctrl_info - Information regarding supported controls
+ * @reg_address: Register offset of control register
+ * @query_ctrl: v4l2 query control information
+ */
+struct tvp514x_ctrl_info {
+	u8 reg_address;
+	struct v4l2_queryctrl query_ctrl;
+};
+
+/**
+ * struct tvp514x_input_info - Information regarding supported inputs
+ * @input_sel: Input select register
+ * @lock_mask: lock mask - depends on Svideo/CVBS
+ * @input: v4l2 input information
+ */
+struct tvp514x_input_info {
+	enum tvp514x_input input_sel;
+	struct v4l2_input input;
+};
+
+/**
+ * struct tvp514x_platform_data - Platform data values and access functions
+ * @power_set: Power state access function, zero is off, non-zero is on.
+ * @ifparm: Interface parameters access function
+ * @priv_data_set: Device private data (pointer) access function
+ * @reg_list: The board dependent driver should fill the default value for
+ *            required registers depending on board layout. The TVP5146/47
+ *            driver will update this register list for the registers
+ *            whose values should be maintained across open()/close() like
+ *            setting brightness as defined in V4L2.
+ *            The register list should be in the same order as defined in
+ *            TVP5146/47 datasheet including reserved registers. As of now
+ *            the driver expects the size of this list to be a minimum of
+ *            57 + 1 (upto regsiter REG_CLEAR_LOST_LOCK).
+ *            The last member should be of the list should be
+ *            {TOK_TERM, 0, 0} to indicate the end of register list.
+ * @num_inputs: Number of input connection in board
+ * @input_list: Input information list for num_inputs
+ */
+struct tvp514x_platform_data {
+	char *master;
+	int (*power_set) (enum v4l2_power on);
+	int (*ifparm) (struct v4l2_ifparm *p);
+	int (*priv_data_set) (void *);
+	/* Input params */
+	int num_inputs;
+	const struct tvp514x_input_info *input_list;
+	int default_input;
+	/* Interface control params */
+	enum tvp514x_output_fmt fmt;
+	bool clk_polarity;
+	bool hs_polarity;
+	bool vs_polarity;
+};
+
+/**
+ * struct tvp514x_decoded - TVP5146/47 decoder object
+ * @v4l2_int_device: Slave handle
+ * @pdata: Board specific
+ * @client: I2C client data
+ * @id: Entry from I2C table
+ * @ver: Chip version
+ * @state: TVP5146/47 decoder state - detected or not-detected
+ * @pix: Current pixel format
+ * @num_fmts: Number of formats
+ * @fmt_list: Format list
+ * @current_std: Current standard
+ * @num_stds: Number of standards
+ * @std_list: Standards list
+ * @num_ctrls: Number of controls
+ * @ctrl_list: Control list
+ */
+struct tvp514x_decoder {
+	struct v4l2_int_device *v4l2_int_device;
+	const struct tvp514x_platform_data *pdata;
+	struct i2c_client *client;
+
+	struct i2c_device_id *id;
+
+	int ver;
+	enum tvp514x_state state;
+
+	struct v4l2_pix_format pix;
+	int num_fmts;
+	const struct v4l2_fmtdesc *fmt_list;
+
+	enum tvp514x_std current_std;
+	int num_stds;
+	struct tvp514x_std_info *std_list;
+
+	int num_ctrls;
+	const struct tvp514x_ctrl_info *ctrl_list;
+
+	int inputidx;
+};
+
+#endif				/* ifndef _TVP514X_H */
--
1.5.6

--
video4linux-list mailing list
Unsubscribe mailto:video4linux-list-request@redhat.com?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list

^ permalink raw reply related	[flat|nested] 263+ messages in thread

* [PATCH 2/2] TVP514x Driver with Review comments fixed [V4]
@ 2008-12-02 15:35   ` hvaibhav
  0 siblings, 0 replies; 263+ messages in thread
From: hvaibhav @ 2008-12-02 15:35 UTC (permalink / raw)
  To: video4linux-list
  Cc: linux-omap, davinci-linux-open-source-bounces, Vaibhav Hiremath,
	Brijesh Jadav, Hardik Shah, Manjunath Hadli, R Sivaraj,
	Karicheri Muralidharan

From: Vaibhav Hiremath <hvaibhav@ti.com>

I have fixed all the review commentsreceived so far.
Here are the details -

FIXSES:
    Make use of i2c_smbus_read/write_byte API:
        Probe function now checks for SMBUS capability,
	and read/write functions make use of the above API.

    Error check for I2C Read/Write:
        Added error condition check for both read and write
	API.
	This has been added for completeness.

    input set/get ioctl:
        As we do have support for set and get routing ioctl,
	instead of adding new ioctl used them.

    enum_ioctl:
        After discussing with Hans verkuil, came to conclusion
	that as of now just remove support for enum_ioctl from
	decoder, since this has to handle at master driver level.

TODO LIST:
    OMAP Master capture driver:
        This should be completely aligned with the current
	discussion.

    Migration to sub_device framework:
        Immediately after all the above task, migrate both
	Master and slave driver to sub_device framework.

Signed-off-by: Brijesh Jadav <brijesh.j@ti.com>
Signed-off-by: Hardik Shah <hardik.shah@ti.com>
Signed-off-by: Manjunath Hadli <mrh@ti.com>
Signed-off-by: R Sivaraj <sivaraj@ti.com>
Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
Signed-off-by: Karicheri Muralidharan <m-karicheri2@ti.com>
---
 drivers/media/video/Kconfig        |   11 +
 drivers/media/video/Makefile       |    1 +
 drivers/media/video/tvp514x.c      | 1521 ++++++++++++++++++++++++++++++++++++
 drivers/media/video/tvp514x_regs.h |  292 +++++++
 include/media/tvp514x.h            |  232 ++++++
 5 files changed, 2057 insertions(+), 0 deletions(-)
 create mode 100755 drivers/media/video/tvp514x.c
 create mode 100755 drivers/media/video/tvp514x_regs.h
 create mode 100755 include/media/tvp514x.h

diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig
index 47102c2..2e5dc3e 100644
--- a/drivers/media/video/Kconfig
+++ b/drivers/media/video/Kconfig
@@ -361,6 +361,17 @@ config VIDEO_SAA7191
 	  To compile this driver as a module, choose M here: the
 	  module will be called saa7191.

+config VIDEO_TVP514X
+	tristate "Texas Instruments TVP514x video decoder"
+	depends on VIDEO_V4L2 && I2C
+	---help---
+	  This is a Video4Linux2 sensor-level driver for the TI TVP5146/47
+	  decoder. It is currently working with the TI OMAP3 camera
+	  controller.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called tvp514x.
+
 config VIDEO_TVP5150
 	tristate "Texas Instruments TVP5150 video decoder"
 	depends on VIDEO_V4L2 && I2C
diff --git a/drivers/media/video/Makefile b/drivers/media/video/Makefile
index 16962f3..cdbbf38 100644
--- a/drivers/media/video/Makefile
+++ b/drivers/media/video/Makefile
@@ -66,6 +66,7 @@ obj-$(CONFIG_VIDEO_CX88) += cx88/
 obj-$(CONFIG_VIDEO_EM28XX) += em28xx/
 obj-$(CONFIG_VIDEO_USBVISION) += usbvision/
 obj-$(CONFIG_VIDEO_TVP5150) += tvp5150.o
+obj-$(CONFIG_VIDEO_TVP514X) += tvp514x.o
 obj-$(CONFIG_VIDEO_PVRUSB2) += pvrusb2/
 obj-$(CONFIG_VIDEO_MSP3400) += msp3400.o
 obj-$(CONFIG_VIDEO_CS5345) += cs5345.o
diff --git a/drivers/media/video/tvp514x.c b/drivers/media/video/tvp514x.c
new file mode 100755
index 0000000..c0834e4
--- /dev/null
+++ b/drivers/media/video/tvp514x.c
@@ -0,0 +1,1521 @@
+/*
+ * drivers/media/video/tvp514x.c
+ *
+ * TI TVP5146/47 decoder driver
+ *
+ * Copyright (C) 2008 Texas Instruments Inc
+ * Author: Vaibhav Hiremath <hvaibhav@ti.com>
+ *
+ * Contributors:
+ *     Sivaraj R <sivaraj@ti.com>
+ *     Brijesh R Jadav <brijesh.j@ti.com>
+ *     Hardik Shah <hardik.shah@ti.com>
+ *     Manjunath Hadli <mrh@ti.com>
+ *     Karicheri Muralidharan <m-karicheri2@ti.com>
+ *
+ * This package is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#include <linux/i2c.h>
+#include <linux/delay.h>
+#include <linux/videodev2.h>
+#include <media/v4l2-int-device.h>
+#include <media/tvp514x.h>
+
+#include "tvp514x_regs.h"
+
+#define MODULE_NAME	TVP514X_MODULE_NAME
+
+/* Debug functions */
+static int debug;
+module_param(debug, bool, 0644);
+MODULE_PARM_DESC(debug, "Debug level (0-1)");
+
+#define dump_reg(client, reg, val)				\
+	do {							\
+		val = tvp514x_read_reg(client, reg);		\
+		v4l_info(client, "Reg(0x%.2X): 0x%.2X\n", reg, val); \
+	} while (0)
+
+
+/* TVP514x default register values */
+static struct tvp514x_reg tvp514x_reg_list[] = {
+	{TOK_WRITE, REG_INPUT_SEL, 0x05},	/* Composite selected */
+	{TOK_WRITE, REG_AFE_GAIN_CTRL, 0x0F},
+	{TOK_WRITE, REG_VIDEO_STD, 0x00},	/* Auto mode */
+	{TOK_WRITE, REG_OPERATION_MODE, 0x00},
+	{TOK_SKIP, REG_AUTOSWITCH_MASK, 0x3F},
+	{TOK_WRITE, REG_COLOR_KILLER, 0x10},
+	{TOK_WRITE, REG_LUMA_CONTROL1, 0x00},
+	{TOK_WRITE, REG_LUMA_CONTROL2, 0x00},
+	{TOK_WRITE, REG_LUMA_CONTROL3, 0x02},
+	{TOK_WRITE, REG_BRIGHTNESS, 0x80},
+	{TOK_WRITE, REG_CONTRAST, 0x80},
+	{TOK_WRITE, REG_SATURATION, 0x80},
+	{TOK_WRITE, REG_HUE, 0x00},
+	{TOK_WRITE, REG_CHROMA_CONTROL1, 0x00},
+	{TOK_WRITE, REG_CHROMA_CONTROL2, 0x0E},
+	{TOK_SKIP, 0x0F, 0x00},	/* Reserved */
+	{TOK_WRITE, REG_COMP_PR_SATURATION, 0x80},
+	{TOK_WRITE, REG_COMP_Y_CONTRAST, 0x80},
+	{TOK_WRITE, REG_COMP_PB_SATURATION, 0x80},
+	{TOK_SKIP, 0x13, 0x00},	/* Reserved */
+	{TOK_WRITE, REG_COMP_Y_BRIGHTNESS, 0x80},
+	{TOK_SKIP, 0x15, 0x00},	/* Reserved */
+	{TOK_SKIP, REG_AVID_START_PIXEL_LSB, 0x55},	/* NTSC timing */
+	{TOK_SKIP, REG_AVID_START_PIXEL_MSB, 0x00},
+	{TOK_SKIP, REG_AVID_STOP_PIXEL_LSB, 0x25},
+	{TOK_SKIP, REG_AVID_STOP_PIXEL_MSB, 0x03},
+	{TOK_SKIP, REG_HSYNC_START_PIXEL_LSB, 0x00},	/* NTSC timing */
+	{TOK_SKIP, REG_HSYNC_START_PIXEL_MSB, 0x00},
+	{TOK_SKIP, REG_HSYNC_STOP_PIXEL_LSB, 0x40},
+	{TOK_SKIP, REG_HSYNC_STOP_PIXEL_MSB, 0x00},
+	{TOK_SKIP, REG_VSYNC_START_LINE_LSB, 0x04},	/* NTSC timing */
+	{TOK_SKIP, REG_VSYNC_START_LINE_MSB, 0x00},
+	{TOK_SKIP, REG_VSYNC_STOP_LINE_LSB, 0x07},
+	{TOK_SKIP, REG_VSYNC_STOP_LINE_MSB, 0x00},
+	{TOK_SKIP, REG_VBLK_START_LINE_LSB, 0x01},	/* NTSC timing */
+	{TOK_SKIP, REG_VBLK_START_LINE_MSB, 0x00},
+	{TOK_SKIP, REG_VBLK_STOP_LINE_LSB, 0x15},
+	{TOK_SKIP, REG_VBLK_STOP_LINE_MSB, 0x00},
+	{TOK_SKIP, 0x26, 0x00},	/* Reserved */
+	{TOK_SKIP, 0x27, 0x00},	/* Reserved */
+	{TOK_SKIP, REG_FAST_SWTICH_CONTROL, 0xCC},
+	{TOK_SKIP, 0x29, 0x00},	/* Reserved */
+	{TOK_SKIP, REG_FAST_SWTICH_SCART_DELAY, 0x00},
+	{TOK_SKIP, 0x2B, 0x00},	/* Reserved */
+	{TOK_SKIP, REG_SCART_DELAY, 0x00},
+	{TOK_SKIP, REG_CTI_DELAY, 0x00},
+	{TOK_SKIP, REG_CTI_CONTROL, 0x00},
+	{TOK_SKIP, 0x2F, 0x00},	/* Reserved */
+	{TOK_SKIP, 0x30, 0x00},	/* Reserved */
+	{TOK_SKIP, 0x31, 0x00},	/* Reserved */
+	{TOK_WRITE, REG_SYNC_CONTROL, 0x00},	/* HS, VS active high */
+	{TOK_WRITE, REG_OUTPUT_FORMATTER1, 0x00},	/* 10-bit BT.656 */
+	{TOK_WRITE, REG_OUTPUT_FORMATTER2, 0x11},	/* Enable clk & data */
+	{TOK_WRITE, REG_OUTPUT_FORMATTER3, 0xEE},	/* Enable AVID & FLD */
+	{TOK_WRITE, REG_OUTPUT_FORMATTER4, 0xAF},	/* Enable VS & HS */
+	{TOK_WRITE, REG_OUTPUT_FORMATTER5, 0xFF},
+	{TOK_WRITE, REG_OUTPUT_FORMATTER6, 0xFF},
+	{TOK_WRITE, REG_CLEAR_LOST_LOCK, 0x01},	/* Clear status */
+	{TOK_TERM, 0, 0},
+};
+
+/* List of image formats supported by TVP5146/47 decoder
+ * Currently we are using 8 bit mode only, but can be
+ * extended to 10/20 bit mode.
+ */
+static const struct v4l2_fmtdesc tvp514x_fmt_list[] = {
+	{
+	 .index = 0,
+	 .type = V4L2_BUF_TYPE_VIDEO_CAPTURE,
+	 .flags = 0,
+	 .description = "8-bit UYVY 4:2:2 Format",
+	 .pixelformat = V4L2_PIX_FMT_UYVY,
+	},
+};
+
+#define TVP514X_NUM_FORMATS		ARRAY_SIZE(tvp514x_fmt_list)
+
+/*
+ * Supported standards -
+ *
+ * Currently supports two standards only, need to add support for rest of the
+ * modes, like SECAM, etc...
+ */
+static struct tvp514x_std_info tvp514x_std_list[] = {
+	/* Standard: STD_NTSC_MJ */
+	[STD_NTSC_MJ] = {
+	 .width = NTSC_NUM_ACTIVE_PIXELS,
+	 .height = NTSC_NUM_ACTIVE_LINES,
+	 .video_std = VIDEO_STD_NTSC_MJ_BIT,
+	 .standard = {
+		      .index = 0,
+		      .id = V4L2_STD_NTSC,
+		      .name = "NTSC",
+		      .frameperiod = {1001, 30000},
+		      .framelines = 525
+		     },
+	/* Standard: STD_PAL_BDGHIN */
+	},
+	[STD_PAL_BDGHIN] = {
+	 .width = PAL_NUM_ACTIVE_PIXELS,
+	 .height = PAL_NUM_ACTIVE_LINES,
+	 .video_std = VIDEO_STD_PAL_BDGHIN_BIT,
+	 .standard = {
+		      .index = 1,
+		      .id = V4L2_STD_PAL,
+		      .name = "PAL",
+		      .frameperiod = {1, 25},
+		      .framelines = 625
+		     },
+	},
+	/* Standard: need to add for additional standard */
+};
+
+#define TVP514X_NUM_STANDARDS		ARRAY_SIZE(tvp514x_std_list)
+
+/* Supported controls */
+static const struct tvp514x_ctrl_info tvp514x_ctrl_list[] = {
+	{
+	 .reg_address = REG_BRIGHTNESS,
+	 .query_ctrl = {
+			.id = V4L2_CID_BRIGHTNESS,
+			.name = "BRIGHTNESS",
+			.type = V4L2_CTRL_TYPE_INTEGER,
+			.minimum = 0,
+			.maximum = 255,
+			.step = 1,
+			.default_value = 128
+			},
+	}, {
+	 .reg_address = REG_CONTRAST,
+	 .query_ctrl = {
+			.id = V4L2_CID_CONTRAST,
+			.name = "CONTRAST",
+			.type = V4L2_CTRL_TYPE_INTEGER,
+			.minimum = 0,
+			.maximum = 255,
+			.step = 1,
+			.default_value = 128
+			},
+	}, {
+	 .reg_address = REG_SATURATION,
+	 .query_ctrl = {
+			.id = V4L2_CID_SATURATION,
+			.name = "SATURATION",
+			.type = V4L2_CTRL_TYPE_INTEGER,
+			.minimum = 0,
+			.maximum = 255,
+			.step = 1,
+			.default_value = 128
+			},
+	}, {
+	 .reg_address = REG_HUE,
+	 .query_ctrl = {
+			.id = V4L2_CID_HUE,
+			.name = "HUE",
+			.type = V4L2_CTRL_TYPE_INTEGER,
+			.minimum = -180,
+			.maximum = 180,
+			.step = 180,
+			.default_value = 0
+			},
+	}, {
+	 .reg_address = REG_AFE_GAIN_CTRL,
+	 .query_ctrl = {
+			.id = V4L2_CID_AUTOGAIN,
+			.name = "Automatic Gain Control",
+			.type = V4L2_CTRL_TYPE_BOOLEAN,
+			.minimum = 0,
+			.maximum = 1,
+			.step = 1,
+			.default_value = 1
+			},
+	 },
+};
+
+#define TVP514X_NUM_CONTROLS		ARRAY_SIZE(tvp514x_ctrl_list)
+
+/*
+ * Read a value from a register in an TVP5146/47 decoder device.
+ * Returns value read if successful, or non-zero (-1) otherwise.
+ */
+static int tvp514x_read_reg(struct i2c_client *client, u8 reg)
+{
+	int err;
+	int retry = 0;
+read_again:
+
+	err = i2c_smbus_read_byte_data(client, reg);
+	if (err == -1) {
+		if (retry <= I2C_RETRY_COUNT) {
+			v4l_warn(client, "Read: retry ... %d\n", retry);
+			retry++;
+			msleep_interruptible(10);
+			goto read_again;
+		}
+	}
+
+	return err;
+}
+
+/*
+ * Write a value to a register in an TVP5146/47 decoder device.
+ * Returns zero if successful, or non-zero otherwise.
+ */
+static int tvp514x_write_reg(struct i2c_client *client, u8 reg, u8 val)
+{
+	int err;
+	int retry = 0;
+write_again:
+
+	err = i2c_smbus_write_byte_data(client, reg, val);
+	if (err) {
+		if (retry <= I2C_RETRY_COUNT) {
+			v4l_warn(client, "Write: retry ... %d\n", retry);
+			retry++;
+			msleep_interruptible(10);
+			goto write_again;
+		}
+	}
+
+	return err;
+}
+
+/*
+ * tvp514x_write_regs : Initializes a list of TVP5146/47 registers
+ *		if token is TOK_TERM, then entire write operation terminates
+ *		if token is TOK_DELAY, then a delay of 'val' msec is introduced
+ *		if token is TOK_SKIP, then the register write is skipped
+ *		if token is TOK_WRITE, then the register write is performed
+ *
+ * reglist - list of registers to be written
+ * Returns zero if successful, or non-zero otherwise.
+ */
+static int tvp514x_write_regs(struct i2c_client *client,
+			      const struct tvp514x_reg reglist[])
+{
+	int err;
+	const struct tvp514x_reg *next = reglist;
+
+	for (; next->token != TOK_TERM; next++) {
+		if (next->token == TOK_DELAY) {
+			msleep(next->val);
+			continue;
+		}
+
+		if (next->token == TOK_SKIP)
+			continue;
+
+		err = tvp514x_write_reg(client, next->reg, (u8) next->val);
+		if (err) {
+			v4l_err(client, "Write failed. Err[%d]\n", err);
+			return err;
+		}
+	}
+	return 0;
+}
+
+/*
+ * tvp514x_get_current_std:
+ * Returns the current standard detected by TVP5146/47
+ */
+static enum tvp514x_std tvp514x_get_current_std(struct tvp514x_decoder
+						*decoder)
+{
+	u8 std, std_status;
+
+	std = tvp514x_read_reg(decoder->client, REG_VIDEO_STD);
+	if ((std & VIDEO_STD_MASK) == VIDEO_STD_AUTO_SWITCH_BIT) {
+		/* use the standard status register */
+		std_status = tvp514x_read_reg(decoder->client,
+				REG_VIDEO_STD_STATUS);
+	} else
+		std_status = std;	/* use the standard register itself */
+
+	switch (std_status & VIDEO_STD_MASK) {
+	case VIDEO_STD_NTSC_MJ_BIT:
+		return STD_NTSC_MJ;
+
+	case VIDEO_STD_PAL_BDGHIN_BIT:
+		return STD_PAL_BDGHIN;
+
+	default:
+		return STD_INVALID;
+	}
+
+	return STD_INVALID;
+}
+
+/*
+ * TVP5146/47 register dump function
+ */
+void tvp514x_reg_dump(struct tvp514x_decoder *decoder)
+{
+	u8 value;
+
+	dump_reg(decoder->client, REG_INPUT_SEL, value);
+	dump_reg(decoder->client, REG_AFE_GAIN_CTRL, value);
+	dump_reg(decoder->client, REG_VIDEO_STD, value);
+	dump_reg(decoder->client, REG_OPERATION_MODE, value);
+	dump_reg(decoder->client, REG_COLOR_KILLER, value);
+	dump_reg(decoder->client, REG_LUMA_CONTROL1, value);
+	dump_reg(decoder->client, REG_LUMA_CONTROL2, value);
+	dump_reg(decoder->client, REG_LUMA_CONTROL3, value);
+	dump_reg(decoder->client, REG_BRIGHTNESS, value);
+	dump_reg(decoder->client, REG_CONTRAST, value);
+	dump_reg(decoder->client, REG_SATURATION, value);
+	dump_reg(decoder->client, REG_HUE, value);
+	dump_reg(decoder->client, REG_CHROMA_CONTROL1, value);
+	dump_reg(decoder->client, REG_CHROMA_CONTROL2, value);
+	dump_reg(decoder->client, REG_COMP_PR_SATURATION, value);
+	dump_reg(decoder->client, REG_COMP_Y_CONTRAST, value);
+	dump_reg(decoder->client, REG_COMP_PB_SATURATION, value);
+	dump_reg(decoder->client, REG_COMP_Y_BRIGHTNESS, value);
+	dump_reg(decoder->client, REG_AVID_START_PIXEL_LSB, value);
+	dump_reg(decoder->client, REG_AVID_START_PIXEL_MSB, value);
+	dump_reg(decoder->client, REG_AVID_STOP_PIXEL_LSB, value);
+	dump_reg(decoder->client, REG_AVID_STOP_PIXEL_MSB, value);
+	dump_reg(decoder->client, REG_HSYNC_START_PIXEL_LSB, value);
+	dump_reg(decoder->client, REG_HSYNC_START_PIXEL_MSB, value);
+	dump_reg(decoder->client, REG_HSYNC_STOP_PIXEL_LSB, value);
+	dump_reg(decoder->client, REG_HSYNC_STOP_PIXEL_MSB, value);
+	dump_reg(decoder->client, REG_VSYNC_START_LINE_LSB, value);
+	dump_reg(decoder->client, REG_VSYNC_START_LINE_MSB, value);
+	dump_reg(decoder->client, REG_VSYNC_STOP_LINE_LSB, value);
+	dump_reg(decoder->client, REG_VSYNC_STOP_LINE_MSB, value);
+	dump_reg(decoder->client, REG_VBLK_START_LINE_LSB, value);
+	dump_reg(decoder->client, REG_VBLK_START_LINE_MSB, value);
+	dump_reg(decoder->client, REG_VBLK_STOP_LINE_LSB, value);
+	dump_reg(decoder->client, REG_VBLK_STOP_LINE_MSB, value);
+	dump_reg(decoder->client, REG_SYNC_CONTROL, value);
+	dump_reg(decoder->client, REG_OUTPUT_FORMATTER1, value);
+	dump_reg(decoder->client, REG_OUTPUT_FORMATTER2, value);
+	dump_reg(decoder->client, REG_OUTPUT_FORMATTER3, value);
+	dump_reg(decoder->client, REG_OUTPUT_FORMATTER4, value);
+	dump_reg(decoder->client, REG_OUTPUT_FORMATTER5, value);
+	dump_reg(decoder->client, REG_OUTPUT_FORMATTER6, value);
+	dump_reg(decoder->client, REG_CLEAR_LOST_LOCK, value);
+}
+
+/*
+ * Configure the TVP5146/47 with the current register settings
+ * Returns zero if successful, or non-zero otherwise.
+ */
+static int tvp514x_configure(struct tvp514x_decoder *decoder)
+{
+	int err;
+
+	/* common register initialization */
+	err =
+	    tvp514x_write_regs(decoder->client, tvp514x_reg_list);
+	if (err)
+		return err;
+
+	if (debug)
+		tvp514x_reg_dump(decoder);
+
+	return 0;
+}
+
+/*
+ * Detect if an tvp514x is present, and if so which revision.
+ * A device is considered to be detected if the chip ID (LSB and MSB)
+ * registers match the expected values.
+ * Any value of the rom version register is accepted.
+ * Returns ENODEV error number if no device is detected, or zero
+ * if a device is detected.
+ */
+static int tvp514x_detect(struct tvp514x_decoder *decoder)
+{
+	u8 chip_id_msb, chip_id_lsb, rom_ver;
+
+	chip_id_msb = tvp514x_read_reg(decoder->client, REG_CHIP_ID_MSB);
+	chip_id_lsb = tvp514x_read_reg(decoder->client, REG_CHIP_ID_LSB);
+	rom_ver = tvp514x_read_reg(decoder->client, REG_ROM_VERSION);
+
+	v4l_dbg(1, debug, decoder->client,
+		 "chip id detected msb:0x%x lsb:0x%x rom version:0x%x\n",
+		 chip_id_msb, chip_id_lsb, rom_ver);
+	if ((chip_id_msb != TVP514X_CHIP_ID_MSB)
+		|| ((chip_id_lsb != TVP5146_CHIP_ID_LSB)
+		&& (chip_id_lsb != TVP5147_CHIP_ID_LSB))) {
+		/* We didn't read the values we expected, so this must not be
+		 * an TVP5146/47.
+		 */
+		v4l_err(decoder->client,
+			"chip id mismatch msb:0x%x lsb:0x%x\n",
+			chip_id_msb, chip_id_lsb);
+		return -ENODEV;
+	}
+
+	decoder->ver = rom_ver;
+	decoder->state = STATE_DETECTED;
+
+	v4l_info(decoder->client,
+			"\n%s found at 0x%x (%s)\n", decoder->client->name,
+			decoder->client->addr << 1,
+			decoder->client->adapter->name);
+	return 0;
+}
+
+/*
+ * Following are decoder interface functions implemented by
+ * TVP5146/47 decoder driver.
+ */
+
+/**
+ * ioctl_querystd - V4L2 decoder interface handler for VIDIOC_QUERYSTD ioctl
+ * @s: pointer to standard V4L2 device structure
+ * @std_id: standard V4L2 std_id ioctl enum
+ *
+ * Returns the current standard detected by TVP5146/47. If no active input is
+ * detected, returns -EINVAL
+ */
+static int ioctl_querystd(struct v4l2_int_device *s, v4l2_std_id *std_id)
+{
+	struct tvp514x_decoder *decoder = s->priv;
+	enum tvp514x_std current_std;
+	enum tvp514x_input input_sel;
+	u8 sync_lock_status, lock_mask;
+
+	if (std_id == NULL)
+		return -EINVAL;
+
+	/* get the current standard */
+	current_std = tvp514x_get_current_std(decoder);
+	if (current_std == STD_INVALID)
+		return -EINVAL;
+
+	input_sel = decoder->pdata->input_list[decoder->inputidx].input_sel;
+
+	switch (input_sel) {
+	case INPUT_CVBS_VI1A:
+	case INPUT_CVBS_VI1B:
+	case INPUT_CVBS_VI1C:
+	case INPUT_CVBS_VI2A:
+	case INPUT_CVBS_VI2B:
+	case INPUT_CVBS_VI2C:
+	case INPUT_CVBS_VI3A:
+	case INPUT_CVBS_VI3B:
+	case INPUT_CVBS_VI3C:
+	case INPUT_CVBS_VI4A:
+		lock_mask = STATUS_CLR_SUBCAR_LOCK_BIT |
+			STATUS_HORZ_SYNC_LOCK_BIT |
+			STATUS_VIRT_SYNC_LOCK_BIT;
+		break;
+
+	case INPUT_SVIDEO_VI2A_VI1A:
+	case INPUT_SVIDEO_VI2B_VI1B:
+	case INPUT_SVIDEO_VI2C_VI1C:
+	case INPUT_SVIDEO_VI2A_VI3A:
+	case INPUT_SVIDEO_VI2B_VI3B:
+	case INPUT_SVIDEO_VI2C_VI3C:
+	case INPUT_SVIDEO_VI4A_VI1A:
+	case INPUT_SVIDEO_VI4A_VI1B:
+	case INPUT_SVIDEO_VI4A_VI1C:
+	case INPUT_SVIDEO_VI4A_VI3A:
+	case INPUT_SVIDEO_VI4A_VI3B:
+	case INPUT_SVIDEO_VI4A_VI3C:
+		lock_mask = STATUS_HORZ_SYNC_LOCK_BIT |
+			STATUS_VIRT_SYNC_LOCK_BIT;
+		break;
+		/*Need to add other interfaces*/
+	default:
+		return -EINVAL;
+	}
+	/* check whether signal is locked */
+	sync_lock_status = tvp514x_read_reg(decoder->client, REG_STATUS1);
+	if (lock_mask != (sync_lock_status & lock_mask))
+		return -EINVAL;	/* No input detected */
+
+	decoder->current_std = current_std;
+	*std_id = decoder->std_list[current_std].standard.id;
+
+	v4l_dbg(1, debug, decoder->client, "Current STD: %s",
+			decoder->std_list[current_std].standard.name);
+	return 0;
+}
+
+/**
+ * ioctl_s_std - V4L2 decoder interface handler for VIDIOC_S_STD ioctl
+ * @s: pointer to standard V4L2 device structure
+ * @std_id: standard V4L2 v4l2_std_id ioctl enum
+ *
+ * If std_id is supported, sets the requested standard. Otherwise, returns
+ * -EINVAL
+ */
+static int ioctl_s_std(struct v4l2_int_device *s, v4l2_std_id *std_id)
+{
+	struct tvp514x_decoder *decoder = s->priv;
+	int err, i;
+
+	if (std_id == NULL)
+		return -EINVAL;
+
+	for (i = 0; i < decoder->num_stds; i++)
+		if (*std_id & decoder->std_list[i].standard.id)
+			break;
+
+	if ((i == decoder->num_stds) || (i == STD_INVALID))
+		return -EINVAL;
+
+	err = tvp514x_write_reg(decoder->client, REG_VIDEO_STD,
+				decoder->std_list[i].video_std);
+	if (err)
+		return err;
+
+	decoder->current_std = i;
+	tvp514x_reg_list[REG_VIDEO_STD].val = decoder->std_list[i].video_std;
+
+	v4l_dbg(1, debug, decoder->client, "Standard set to: %s",
+			decoder->std_list[i].standard.name);
+	return 0;
+}
+
+/**
+ * ioctl_s_routing - V4L2 decoder interface handler for VIDIOC_S_INPUT ioctl
+ * @s: pointer to standard V4L2 device structure
+ * @index: number of the input
+ *
+ * If index is valid, selects the requested input. Otherwise, returns -EINVAL if
+ * the input is not supported or there is no active signal present in the
+ * selected input.
+ */
+static int ioctl_s_routing(struct v4l2_int_device *s, int index)
+{
+	struct tvp514x_decoder *decoder = s->priv;
+	int err;
+	enum tvp514x_input input_sel;
+	enum tvp514x_std current_std = STD_INVALID;
+	u8 sync_lock_status, lock_mask;
+	int try_count = LOCK_RETRY_COUNT;
+
+	if ((index >= decoder->pdata->num_inputs) || (index < 0))
+		return -EINVAL;	/* Index out of bound */
+
+	/* Get the register value to be written to select the requested input */
+	input_sel = decoder->pdata->input_list[index].input_sel;
+	err = tvp514x_write_reg(decoder->client, REG_INPUT_SEL, input_sel);
+	if (err)
+		return err;
+
+	decoder->inputidx = index;
+	tvp514x_reg_list[REG_INPUT_SEL].val = input_sel;
+
+	/* Clear status */
+	msleep(LOCK_RETRY_DELAY);
+	err =
+	    tvp514x_write_reg(decoder->client, REG_CLEAR_LOST_LOCK, 0x01);
+	if (err)
+		return err;
+
+	switch (input_sel) {
+	case INPUT_CVBS_VI1A:
+	case INPUT_CVBS_VI1B:
+	case INPUT_CVBS_VI1C:
+	case INPUT_CVBS_VI2A:
+	case INPUT_CVBS_VI2B:
+	case INPUT_CVBS_VI2C:
+	case INPUT_CVBS_VI3A:
+	case INPUT_CVBS_VI3B:
+	case INPUT_CVBS_VI3C:
+	case INPUT_CVBS_VI4A:
+		lock_mask = STATUS_CLR_SUBCAR_LOCK_BIT |
+			STATUS_HORZ_SYNC_LOCK_BIT |
+			STATUS_VIRT_SYNC_LOCK_BIT;
+		break;
+
+	case INPUT_SVIDEO_VI2A_VI1A:
+	case INPUT_SVIDEO_VI2B_VI1B:
+	case INPUT_SVIDEO_VI2C_VI1C:
+	case INPUT_SVIDEO_VI2A_VI3A:
+	case INPUT_SVIDEO_VI2B_VI3B:
+	case INPUT_SVIDEO_VI2C_VI3C:
+	case INPUT_SVIDEO_VI4A_VI1A:
+	case INPUT_SVIDEO_VI4A_VI1B:
+	case INPUT_SVIDEO_VI4A_VI1C:
+	case INPUT_SVIDEO_VI4A_VI3A:
+	case INPUT_SVIDEO_VI4A_VI3B:
+	case INPUT_SVIDEO_VI4A_VI3C:
+		lock_mask = STATUS_HORZ_SYNC_LOCK_BIT |
+			STATUS_VIRT_SYNC_LOCK_BIT;
+		break;
+	/*Need to add other interfaces*/
+	default:
+		return -EINVAL;
+	}
+
+	while (try_count-- > 0) {
+		/* Allow decoder to sync up with new input */
+		msleep(LOCK_RETRY_DELAY);
+
+		/* get the current standard for future reference */
+		current_std = tvp514x_get_current_std(decoder);
+		if (current_std == STD_INVALID)
+			continue;
+
+		sync_lock_status = tvp514x_read_reg(decoder->client,
+				REG_STATUS1);
+		if (lock_mask == (sync_lock_status & lock_mask))
+			break;	/* Input detected */
+	}
+
+	if ((current_std == STD_INVALID) || (try_count < 0))
+		return -EINVAL;
+
+	decoder->current_std = current_std;
+
+	v4l_dbg(1, debug, decoder->client,
+			"Input set to: index - %d (%s)",
+			decoder->pdata->input_list[index].input.index,
+			decoder->pdata->input_list[index].input.name);
+	return 0;
+}
+
+/**
+ * ioctl_g_routing - V4L2 decoder interface handler for VIDIOC_G_INPUT ioctl
+ * @s: pointer to standard V4L2 device structure
+ * @index: returns the current selected input
+ *
+ * Returns the current selected input. Returns -EINVAL if any error occurs
+ */
+static int ioctl_g_routing(struct v4l2_int_device *s, int *index)
+{
+	struct tvp514x_decoder *decoder = s->priv;
+	int err = -EINVAL, i, inputidx;
+
+	if (index == NULL)
+		return err;
+
+	/* Search through the input list for active inputs */
+	inputidx = decoder->inputidx;
+	for (i = 0; i < decoder->pdata->num_inputs; i++) {
+		inputidx++;	/* Move to next input */
+		if (inputidx >= decoder->pdata->num_inputs)
+			inputidx = 0;	/* fall back to first input */
+
+		err = ioctl_s_routing(s, inputidx);
+		if (!err) {
+			/* Active input found - select it and return success */
+			*index = inputidx;
+			return 0;
+		}
+	}
+
+	return err;
+}
+
+/**
+ * ioctl_queryctrl - V4L2 decoder interface handler for VIDIOC_QUERYCTRL ioctl
+ * @s: pointer to standard V4L2 device structure
+ * @qc: standard V4L2 VIDIOC_QUERYCTRL ioctl structure
+ *
+ * If the requested control is supported, returns the control information
+ * from the ctrl_list[] array. Otherwise, returns -EINVAL if the
+ * control is not supported.
+ */
+static int
+ioctl_queryctrl(struct v4l2_int_device *s, struct v4l2_queryctrl *qctrl)
+{
+	struct tvp514x_decoder *decoder = s->priv;
+	int id, index;
+	const struct tvp514x_ctrl_info *control = NULL;
+
+	if (qctrl == NULL)
+		return -EINVAL;
+
+	id = qctrl->id;
+	memset(qctrl, 0, sizeof(struct v4l2_queryctrl));
+	qctrl->id = id;
+
+	for (index = 0; index < decoder->num_ctrls; index++) {
+		control = &decoder->ctrl_list[index];
+		if (control->query_ctrl.id == qctrl->id)
+			break;	/* Match found */
+	}
+	if (index == decoder->num_ctrls)
+		return -EINVAL;	/* Index out of bound */
+
+	memcpy(qctrl, &control->query_ctrl, sizeof(struct v4l2_queryctrl));
+
+	v4l_dbg(1, debug, decoder->client,
+			"Query Control: %s : Min - %d, Max - %d, Def - %d",
+			control->query_ctrl.name,
+			control->query_ctrl.minimum,
+			control->query_ctrl.maximum,
+			control->query_ctrl.default_value);
+	return 0;
+}
+
+/**
+ * ioctl_g_ctrl - V4L2 decoder interface handler for VIDIOC_G_CTRL ioctl
+ * @s: pointer to standard V4L2 device structure
+ * @vc: standard V4L2 VIDIOC_G_CTRL ioctl structure
+ *
+ * If the requested control is supported, returns the control's current
+ * value from the decoder. Otherwise, returns -EINVAL if the control is not
+ * supported.
+ */
+static int
+ioctl_g_ctrl(struct v4l2_int_device *s, struct v4l2_control *ctrl)
+{
+	struct tvp514x_decoder *decoder = s->priv;
+	int index, value;
+	const struct tvp514x_ctrl_info *control = NULL;
+
+	if (ctrl == NULL)
+		return -EINVAL;
+
+	for (index = 0; index < decoder->num_ctrls; index++) {
+		control = &decoder->ctrl_list[index];
+		if (control->query_ctrl.id == ctrl->id)
+			break;	/* Match found */
+	}
+	if (index == decoder->num_ctrls)
+		return -EINVAL;	/* Index out of bound */
+
+	value =
+	    tvp514x_read_reg(decoder->client, control->reg_address);
+
+	/* cross check */
+	if (value != tvp514x_reg_list[control->reg_address].val)
+		return -EINVAL;	/* Driver & TVP5146/47 setting mismatch */
+
+	if (V4L2_CID_AUTOGAIN == ctrl->id) {
+		if ((value & 0x3) == 3)
+			value = 1;
+		else
+			value = 0;
+	}
+
+	if (V4L2_CID_HUE == ctrl->id) {
+		if (value == 0x7F)
+			value = 180;
+		else if (value == 0x80)
+			value = -180;
+		else
+			value = 0;
+	}
+
+	ctrl->value = value;
+
+	v4l_dbg(1, debug, decoder->client,
+			"Get Cotrol: %s - %d",
+			control->query_ctrl.name, value);
+	return 0;
+}
+
+/**
+ * ioctl_s_ctrl - V4L2 decoder interface handler for VIDIOC_S_CTRL ioctl
+ * @s: pointer to standard V4L2 device structure
+ * @vc: standard V4L2 VIDIOC_S_CTRL ioctl structure
+ *
+ * If the requested control is supported, sets the control's current
+ * value in HW. Otherwise, returns -EINVAL if the control is not supported.
+ */
+static int
+ioctl_s_ctrl(struct v4l2_int_device *s, struct v4l2_control *ctrl)
+{
+	struct tvp514x_decoder *decoder = s->priv;
+	int err, value, index;
+	const struct tvp514x_ctrl_info *control = NULL;
+
+	if (ctrl == NULL)
+		return -EINVAL;
+
+	value = (__s32) ctrl->value;
+	for (index = 0; index < decoder->num_ctrls; index++) {
+		control = &decoder->ctrl_list[index];
+		if (control->query_ctrl.id == ctrl->id)
+			break;	/* Match found */
+	}
+	if (index == decoder->num_ctrls)
+		return -EINVAL;	/* Index out of bound */
+
+	if (V4L2_CID_AUTOGAIN == ctrl->id) {
+		if (value == 1)
+			value = 0x0F;
+		else if (value == 0)
+			value = 0x0C;
+		else
+			return -ERANGE;
+	} else if (V4L2_CID_HUE == ctrl->id) {
+		if (value == 180)
+			value = 0x7F;
+		else if (value == -180)
+			value = 0x80;
+		else if (value == 0)
+			value = 0;
+		else
+			return -ERANGE;
+	} else {
+		if ((value < control->query_ctrl.minimum)
+			|| (value > control->query_ctrl.maximum))
+			return -ERANGE;
+	}
+
+	err =
+	    tvp514x_write_reg(decoder->client, control->reg_address,
+				value);
+	if (err)
+		return err;
+
+	tvp514x_reg_list[control->reg_address].val = value;
+
+	v4l_dbg(1, debug, decoder->client,
+			"Set Cotrol: %s - %d",
+			control->query_ctrl.name, value);
+	return err;
+}
+
+/**
+ * ioctl_enum_fmt_cap - Implement the CAPTURE buffer VIDIOC_ENUM_FMT ioctl
+ * @s: pointer to standard V4L2 device structure
+ * @fmt: standard V4L2 VIDIOC_ENUM_FMT ioctl structure
+ *
+ * Implement the VIDIOC_ENUM_FMT ioctl to enumerate supported formats
+ */
+static int
+ioctl_enum_fmt_cap(struct v4l2_int_device *s, struct v4l2_fmtdesc *fmt)
+{
+	struct tvp514x_decoder *decoder = s->priv;
+	int index;
+
+	if (fmt == NULL)
+		return -EINVAL;
+
+	index = fmt->index;
+	if ((index >= decoder->num_fmts) || (index < 0))
+		return -EINVAL;	/* Index out of bound */
+
+	if (fmt->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
+		return -EINVAL;	/* only capture is supported */
+
+	memcpy(fmt, &decoder->fmt_list[index],
+		sizeof(struct v4l2_fmtdesc));
+
+	v4l_dbg(1, debug, decoder->client,
+			"Current FMT: index - %d (%s)",
+			decoder->fmt_list[index].index,
+			decoder->fmt_list[index].description);
+	return 0;
+}
+
+/**
+ * ioctl_try_fmt_cap - Implement the CAPTURE buffer VIDIOC_TRY_FMT ioctl
+ * @s: pointer to standard V4L2 device structure
+ * @f: pointer to standard V4L2 VIDIOC_TRY_FMT ioctl structure
+ *
+ * Implement the VIDIOC_TRY_FMT ioctl for the CAPTURE buffer type. This
+ * ioctl is used to negotiate the image capture size and pixel format
+ * without actually making it take effect.
+ */
+static int
+ioctl_try_fmt_cap(struct v4l2_int_device *s, struct v4l2_format *f)
+{
+	struct tvp514x_decoder *decoder = s->priv;
+	int ifmt;
+	struct v4l2_pix_format *pix;
+	enum tvp514x_std current_std;
+
+	if (f == NULL)
+		return -EINVAL;
+
+	if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
+		f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+
+	pix = &f->fmt.pix;
+
+	/* Calculate height and width based on current standard */
+	current_std = tvp514x_get_current_std(decoder);
+	if (current_std == STD_INVALID)
+		return -EINVAL;
+
+	decoder->current_std = current_std;
+	pix->width = decoder->std_list[current_std].width;
+	pix->height = decoder->std_list[current_std].height;
+
+	for (ifmt = 0; ifmt < decoder->num_fmts; ifmt++) {
+		if (pix->pixelformat ==
+			decoder->fmt_list[ifmt].pixelformat)
+			break;
+	}
+	if (ifmt == decoder->num_fmts)
+		ifmt = 0;	/* None of the format matched, select default */
+	pix->pixelformat = decoder->fmt_list[ifmt].pixelformat;
+
+	pix->field = V4L2_FIELD_INTERLACED;
+	pix->bytesperline = pix->width * 2;
+	pix->sizeimage = pix->bytesperline * pix->height;
+	pix->colorspace = V4L2_COLORSPACE_SMPTE170M;
+	pix->priv = 0;
+
+	v4l_dbg(1, debug, decoder->client,
+			"Try FMT: pixelformat - %s, bytesperline - %d"
+			"Width - %d, Height - %d",
+			decoder->fmt_list[ifmt].description, pix->bytesperline,
+			pix->width, pix->height);
+	return 0;
+}
+
+/**
+ * ioctl_s_fmt_cap - V4L2 decoder interface handler for VIDIOC_S_FMT ioctl
+ * @s: pointer to standard V4L2 device structure
+ * @f: pointer to standard V4L2 VIDIOC_S_FMT ioctl structure
+ *
+ * If the requested format is supported, configures the HW to use that
+ * format, returns error code if format not supported or HW can't be
+ * correctly configured.
+ */
+static int
+ioctl_s_fmt_cap(struct v4l2_int_device *s, struct v4l2_format *f)
+{
+	struct tvp514x_decoder *decoder = s->priv;
+	struct v4l2_pix_format *pix;
+	int rval;
+
+	if (f == NULL)
+		return -EINVAL;
+
+	if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
+		return -EINVAL;	/* only capture is supported */
+
+	pix = &f->fmt.pix;
+	rval = ioctl_try_fmt_cap(s, f);
+	if (rval)
+		return rval;
+	else
+		decoder->pix = *pix;
+
+	return rval;
+}
+
+/**
+ * ioctl_g_fmt_cap - V4L2 decoder interface handler for ioctl_g_fmt_cap
+ * @s: pointer to standard V4L2 device structure
+ * @f: pointer to standard V4L2 v4l2_format structure
+ *
+ * Returns the decoder's current pixel format in the v4l2_format
+ * parameter.
+ */
+static int
+ioctl_g_fmt_cap(struct v4l2_int_device *s, struct v4l2_format *f)
+{
+	struct tvp514x_decoder *decoder = s->priv;
+
+	if (f == NULL)
+		return -EINVAL;
+
+	if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
+		return -EINVAL;	/* only capture is supported */
+
+	f->fmt.pix = decoder->pix;
+
+	v4l_dbg(1, debug, decoder->client,
+			"Current FMT: bytesperline - %d"
+			"Width - %d, Height - %d",
+			decoder->pix.bytesperline,
+			decoder->pix.width, decoder->pix.height);
+	return 0;
+}
+
+/**
+ * ioctl_g_parm - V4L2 decoder interface handler for VIDIOC_G_PARM ioctl
+ * @s: pointer to standard V4L2 device structure
+ * @a: pointer to standard V4L2 VIDIOC_G_PARM ioctl structure
+ *
+ * Returns the decoder's video CAPTURE parameters.
+ */
+static int
+ioctl_g_parm(struct v4l2_int_device *s, struct v4l2_streamparm *a)
+{
+	struct tvp514x_decoder *decoder = s->priv;
+	struct v4l2_captureparm *cparm;
+	enum tvp514x_std current_std;
+
+	if (a == NULL)
+		return -EINVAL;
+
+	if (a->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
+		return -EINVAL;	/* only capture is supported */
+
+	memset(a, 0, sizeof(*a));
+	a->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+
+	/* get the current standard */
+	current_std = tvp514x_get_current_std(decoder);
+	if (current_std == STD_INVALID)
+		return -EINVAL;
+
+	decoder->current_std = current_std;
+
+	cparm = &a->parm.capture;
+	cparm->capability = V4L2_CAP_TIMEPERFRAME;
+	cparm->timeperframe =
+		decoder->std_list[current_std].standard.frameperiod;
+
+	return 0;
+}
+
+/**
+ * ioctl_s_parm - V4L2 decoder interface handler for VIDIOC_S_PARM ioctl
+ * @s: pointer to standard V4L2 device structure
+ * @a: pointer to standard V4L2 VIDIOC_S_PARM ioctl structure
+ *
+ * Configures the decoder to use the input parameters, if possible. If
+ * not possible, returns the appropriate error code.
+ */
+static int
+ioctl_s_parm(struct v4l2_int_device *s, struct v4l2_streamparm *a)
+{
+	struct tvp514x_decoder *decoder = s->priv;
+	struct v4l2_fract *timeperframe;
+	enum tvp514x_std current_std;
+
+	if (a == NULL)
+		return -EINVAL;
+
+	if (a->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
+		return -EINVAL;	/* only capture is supported */
+
+	timeperframe = &a->parm.capture.timeperframe;
+
+	/* get the current standard */
+	current_std = tvp514x_get_current_std(decoder);
+	if (current_std == STD_INVALID)
+		return -EINVAL;
+
+	decoder->current_std = current_std;
+
+	*timeperframe =
+	    decoder->std_list[current_std].standard.frameperiod;
+
+	return 0;
+}
+
+/**
+ * ioctl_g_ifparm - V4L2 decoder interface handler for vidioc_int_g_ifparm_num
+ * @s: pointer to standard V4L2 device structure
+ * @p: pointer to standard V4L2 vidioc_int_g_ifparm_num ioctl structure
+ *
+ * Gets slave interface parameters.
+ * Calculates the required xclk value to support the requested
+ * clock parameters in p. This value is returned in the p
+ * parameter.
+ */
+static int ioctl_g_ifparm(struct v4l2_int_device *s, struct v4l2_ifparm *p)
+{
+	struct tvp514x_decoder *decoder = s->priv;
+	int rval;
+
+	if (p == NULL)
+		return -EINVAL;
+
+	if (NULL == decoder->pdata->ifparm)
+		return -EINVAL;
+
+	rval = decoder->pdata->ifparm(p);
+	if (rval) {
+		v4l_err(decoder->client, "g_ifparm.Err[%d]\n", rval);
+		return rval;
+	}
+
+	p->u.bt656.clock_curr = TVP514X_XCLK_BT656;
+
+	return 0;
+}
+
+/**
+ * ioctl_g_priv - V4L2 decoder interface handler for vidioc_int_g_priv_num
+ * @s: pointer to standard V4L2 device structure
+ * @p: void pointer to hold decoder's private data address
+ *
+ * Returns device's (decoder's) private data area address in p parameter
+ */
+static int ioctl_g_priv(struct v4l2_int_device *s, void *p)
+{
+	struct tvp514x_decoder *decoder = s->priv;
+
+	if (NULL == decoder->pdata->priv_data_set)
+		return -EINVAL;
+
+	return decoder->pdata->priv_data_set(p);
+}
+
+/**
+ * ioctl_s_power - V4L2 decoder interface handler for vidioc_int_s_power_num
+ * @s: pointer to standard V4L2 device structure
+ * @on: power state to which device is to be set
+ *
+ * Sets devices power state to requrested state, if possible.
+ */
+static int ioctl_s_power(struct v4l2_int_device *s, enum v4l2_power on)
+{
+	struct tvp514x_decoder *decoder = s->priv;
+	int err = 0;
+
+	switch (on) {
+	case V4L2_POWER_OFF:
+		/* Power Down Sequence */
+		err =
+		    tvp514x_write_reg(decoder->client, REG_OPERATION_MODE,
+					0x01);
+		/* Disable mux for TVP5146/47 decoder data path */
+		if (decoder->pdata->power_set)
+			err |= decoder->pdata->power_set(on);
+		decoder->state = STATE_NOT_DETECTED;
+		break;
+
+	case V4L2_POWER_STANDBY:
+		if (decoder->pdata->power_set)
+			err = decoder->pdata->power_set(on);
+		break;
+
+	case V4L2_POWER_ON:
+		/* Enable mux for TVP5146/47 decoder data path */
+		if ((decoder->pdata->power_set) &&
+				(decoder->state == STATE_NOT_DETECTED)) {
+			int i;
+			struct tvp514x_init_seq *int_seq =
+				(struct tvp514x_init_seq *)
+				decoder->id->driver_data;
+
+			err = decoder->pdata->power_set(on);
+
+			/* Power Up Sequence */
+			for (i = 0; i < int_seq->no_regs; i++) {
+				err |= tvp514x_write_reg(decoder->client,
+						int_seq->init_reg_seq[i].reg,
+						int_seq->init_reg_seq[i].val);
+			}
+			/* Detect the sensor is not already detected */
+			err |= tvp514x_detect(decoder);
+			if (err) {
+				v4l_err(decoder->client,
+						"Unable to detect decoder\n");
+				return err;
+			}
+		}
+		err |= tvp514x_configure(decoder);
+		break;
+
+	default:
+		err = -ENODEV;
+		break;
+	}
+
+	return err;
+}
+
+/**
+ * ioctl_init - V4L2 decoder interface handler for VIDIOC_INT_INIT
+ * @s: pointer to standard V4L2 device structure
+ *
+ * Initialize the decoder device (calls tvp514x_configure())
+ */
+static int ioctl_init(struct v4l2_int_device *s)
+{
+	struct tvp514x_decoder *decoder = s->priv;
+
+	/* Set default standard to auto */
+	tvp514x_reg_list[REG_VIDEO_STD].val =
+	    VIDEO_STD_AUTO_SWITCH_BIT;
+
+	return tvp514x_configure(decoder);
+}
+
+/**
+ * ioctl_dev_exit - V4L2 decoder interface handler for vidioc_int_dev_exit_num
+ * @s: pointer to standard V4L2 device structure
+ *
+ * Delinitialise the dev. at slave detach. The complement of ioctl_dev_init.
+ */
+static int ioctl_dev_exit(struct v4l2_int_device *s)
+{
+	return 0;
+}
+
+/**
+ * ioctl_dev_init - V4L2 decoder interface handler for vidioc_int_dev_init_num
+ * @s: pointer to standard V4L2 device structure
+ *
+ * Initialise the device when slave attaches to the master. Returns 0 if
+ * TVP5146/47 device could be found, otherwise returns appropriate error.
+ */
+static int ioctl_dev_init(struct v4l2_int_device *s)
+{
+	struct tvp514x_decoder *decoder = s->priv;
+	int err;
+
+	err = tvp514x_detect(decoder);
+	if (err < 0) {
+		v4l_err(decoder->client,
+			"Unable to detect decoder\n");
+		return err;
+	}
+
+	v4l_info(decoder->client,
+		 "chip version 0x%.2x detected\n", decoder->ver);
+
+	return 0;
+}
+
+static struct v4l2_int_ioctl_desc tvp514x_ioctl_desc[] = {
+	{vidioc_int_dev_init_num, (v4l2_int_ioctl_func*) ioctl_dev_init},
+	{vidioc_int_dev_exit_num, (v4l2_int_ioctl_func*) ioctl_dev_exit},
+	{vidioc_int_s_power_num, (v4l2_int_ioctl_func*) ioctl_s_power},
+	{vidioc_int_g_priv_num, (v4l2_int_ioctl_func*) ioctl_g_priv},
+	{vidioc_int_g_ifparm_num, (v4l2_int_ioctl_func*) ioctl_g_ifparm},
+	{vidioc_int_init_num, (v4l2_int_ioctl_func*) ioctl_init},
+	{vidioc_int_enum_fmt_cap_num,
+	 (v4l2_int_ioctl_func *) ioctl_enum_fmt_cap},
+	{vidioc_int_try_fmt_cap_num,
+	 (v4l2_int_ioctl_func *) ioctl_try_fmt_cap},
+	{vidioc_int_g_fmt_cap_num,
+	 (v4l2_int_ioctl_func *) ioctl_g_fmt_cap},
+	{vidioc_int_s_fmt_cap_num,
+	 (v4l2_int_ioctl_func *) ioctl_s_fmt_cap},
+	{vidioc_int_g_parm_num, (v4l2_int_ioctl_func *) ioctl_g_parm},
+	{vidioc_int_s_parm_num, (v4l2_int_ioctl_func *) ioctl_s_parm},
+	{vidioc_int_queryctrl_num,
+	 (v4l2_int_ioctl_func *) ioctl_queryctrl},
+	{vidioc_int_g_ctrl_num, (v4l2_int_ioctl_func *) ioctl_g_ctrl},
+	{vidioc_int_s_ctrl_num, (v4l2_int_ioctl_func *) ioctl_s_ctrl},
+	{vidioc_int_querystd_num, (v4l2_int_ioctl_func *) ioctl_querystd},
+	{vidioc_int_s_std_num, (v4l2_int_ioctl_func *) ioctl_s_std},
+	{vidioc_int_g_video_routing_num,
+		(v4l2_int_ioctl_func *) ioctl_g_routing},
+	{vidioc_int_s_video_routing_num,
+		(v4l2_int_ioctl_func *) ioctl_s_routing},
+};
+
+static struct v4l2_int_slave tvp514x_slave = {
+	.ioctls = tvp514x_ioctl_desc,
+	.num_ioctls = ARRAY_SIZE(tvp514x_ioctl_desc),
+};
+
+static struct tvp514x_decoder tvp514x_dev = {
+	.state = STATE_NOT_DETECTED,
+
+	.num_fmts = TVP514X_NUM_FORMATS,
+	.fmt_list = tvp514x_fmt_list,
+
+	.pix = {		/* Default to NTSC 8-bit YUV 422 */
+		.width = NTSC_NUM_ACTIVE_PIXELS,
+		.height = NTSC_NUM_ACTIVE_LINES,
+		.pixelformat = V4L2_PIX_FMT_UYVY,
+		.field = V4L2_FIELD_INTERLACED,
+		.bytesperline = NTSC_NUM_ACTIVE_PIXELS * 2,
+		.sizeimage =
+		NTSC_NUM_ACTIVE_PIXELS * 2 * NTSC_NUM_ACTIVE_LINES,
+		.colorspace = V4L2_COLORSPACE_SMPTE170M,
+		},
+
+	.current_std = STD_NTSC_MJ,
+	.num_stds = TVP514X_NUM_STANDARDS,
+	.std_list = tvp514x_std_list,
+
+	.num_ctrls = TVP514X_NUM_CONTROLS,
+	.ctrl_list = tvp514x_ctrl_list,
+
+};
+
+static struct v4l2_int_device tvp514x_int_device = {
+	.module = THIS_MODULE,
+	.name = MODULE_NAME,
+	.priv = &tvp514x_dev,
+	.type = v4l2_int_type_slave,
+	.u = {
+	      .slave = &tvp514x_slave,
+	      },
+};
+
+/**
+ * tvp514x_probe - decoder driver i2c probe handler
+ * @client: i2c driver client device structure
+ *
+ * Register decoder as an i2c client device and V4L2
+ * device.
+ */
+static int
+tvp514x_probe(struct i2c_client *client, const struct i2c_device_id *id)
+{
+	struct tvp514x_decoder *decoder = &tvp514x_dev;
+	int err;
+
+	/* Check if the adapter supports the needed features */
+	if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA))
+		return -EIO;
+
+	decoder->pdata = client->dev.platform_data;
+	if (!decoder->pdata) {
+		v4l_err(client, "No platform data\n!!");
+		return -ENODEV;
+	}
+	/*
+	 * Fetch platform specific data, and configure the
+	 * tvp514x_reg_list[] accordingly. Since this is one
+	 * time configuration, no need to preserve.
+	 */
+	decoder->inputidx = decoder->pdata->default_input;
+	tvp514x_reg_list[REG_OUTPUT_FORMATTER2].val |=
+			(decoder->pdata->clk_polarity << 1);
+	tvp514x_reg_list[REG_OUTPUT_FORMATTER1].val |=
+			decoder->pdata->fmt;
+	tvp514x_reg_list[REG_SYNC_CONTROL].val |=
+			((decoder->pdata->hs_polarity << 2) |
+			(decoder->pdata->vs_polarity << 3));
+	/*
+	 * Save the id data, required for power up sequence
+	 */
+	decoder->id = (struct i2c_device_id *)id;
+	/* Attach to Master */
+	strcpy(tvp514x_int_device.u.slave->attach_to, decoder->pdata->master);
+	decoder->v4l2_int_device = &tvp514x_int_device;
+	decoder->client = client;
+	i2c_set_clientdata(client, decoder);
+
+	/* Register with V4L2 layer as slave device */
+	err = v4l2_int_device_register(decoder->v4l2_int_device);
+	if (err) {
+		i2c_set_clientdata(client, NULL);
+		v4l_err(client,
+			"Unable to register to v4l2. Err[%d]\n", err);
+
+	} else
+		v4l_info(client, "Registered to v4l2 master %s!!\n",
+				decoder->pdata->master);
+
+	return 0;
+}
+
+/**
+ * tvp514x_remove - decoder driver i2c remove handler
+ * @client: i2c driver client device structure
+ *
+ * Unregister decoder as an i2c client device and V4L2
+ * device. Complement of tvp514x_probe().
+ */
+static int __exit tvp514x_remove(struct i2c_client *client)
+{
+	struct tvp514x_decoder *decoder = i2c_get_clientdata(client);
+
+	if (!client->adapter)
+		return -ENODEV;	/* our client isn't attached */
+
+	v4l2_int_device_unregister(decoder->v4l2_int_device);
+	i2c_set_clientdata(client, NULL);
+
+	return 0;
+}
+/*
+ * TVP5146 Init/Power on Sequence
+ */
+static struct tvp514x_reg tvp5146_init_reg_seq[] = {
+	{TOK_WRITE, REG_VBUS_ADDRESS_ACCESS1, 0x02},
+	{TOK_WRITE, REG_VBUS_ADDRESS_ACCESS2, 0x00},
+	{TOK_WRITE, REG_VBUS_ADDRESS_ACCESS3, 0x80},
+	{TOK_WRITE, REG_VBUS_DATA_ACCESS_NO_VBUS_ADDR_INCR, 0x01},
+	{TOK_WRITE, REG_VBUS_ADDRESS_ACCESS1, 0x60},
+	{TOK_WRITE, REG_VBUS_ADDRESS_ACCESS2, 0x00},
+	{TOK_WRITE, REG_VBUS_ADDRESS_ACCESS3, 0xB0},
+	{TOK_WRITE, REG_VBUS_DATA_ACCESS_NO_VBUS_ADDR_INCR, 0x01},
+	{TOK_WRITE, REG_VBUS_DATA_ACCESS_NO_VBUS_ADDR_INCR, 0x00},
+	{TOK_WRITE, REG_OPERATION_MODE, 0x01},
+	{TOK_WRITE, REG_OPERATION_MODE, 0x00},
+};
+static struct tvp514x_init_seq tvp5146_init = {
+	.no_regs = ARRAY_SIZE(tvp5146_init_reg_seq),
+	.init_reg_seq = tvp5146_init_reg_seq,
+};
+/*
+ * TVP5147 Init/Power on Sequence
+ */
+static struct tvp514x_reg tvp5147_init_reg_seq[] =	{
+	{TOK_WRITE, REG_VBUS_ADDRESS_ACCESS1, 0x02},
+	{TOK_WRITE, REG_VBUS_ADDRESS_ACCESS2, 0x00},
+	{TOK_WRITE, REG_VBUS_ADDRESS_ACCESS3, 0x80},
+	{TOK_WRITE, REG_VBUS_DATA_ACCESS_NO_VBUS_ADDR_INCR, 0x01},
+	{TOK_WRITE, REG_VBUS_ADDRESS_ACCESS1, 0x60},
+	{TOK_WRITE, REG_VBUS_ADDRESS_ACCESS2, 0x00},
+	{TOK_WRITE, REG_VBUS_ADDRESS_ACCESS3, 0xB0},
+	{TOK_WRITE, REG_VBUS_DATA_ACCESS_NO_VBUS_ADDR_INCR, 0x01},
+	{TOK_WRITE, REG_VBUS_ADDRESS_ACCESS1, 0x16},
+	{TOK_WRITE, REG_VBUS_ADDRESS_ACCESS2, 0x00},
+	{TOK_WRITE, REG_VBUS_ADDRESS_ACCESS3, 0xA0},
+	{TOK_WRITE, REG_VBUS_DATA_ACCESS_NO_VBUS_ADDR_INCR, 0x16},
+	{TOK_WRITE, REG_VBUS_ADDRESS_ACCESS1, 0x60},
+	{TOK_WRITE, REG_VBUS_ADDRESS_ACCESS2, 0x00},
+	{TOK_WRITE, REG_VBUS_ADDRESS_ACCESS3, 0xB0},
+	{TOK_WRITE, REG_VBUS_DATA_ACCESS_NO_VBUS_ADDR_INCR, 0x00},
+	{TOK_WRITE, REG_OPERATION_MODE, 0x01},
+	{TOK_WRITE, REG_OPERATION_MODE, 0x00},
+};
+static struct tvp514x_init_seq tvp5147_init = {
+	.no_regs = ARRAY_SIZE(tvp5147_init_reg_seq),
+	.init_reg_seq = tvp5147_init_reg_seq,
+};
+/*
+ * TVP5146M2/TVP5147M1 Init/Power on Sequence
+ */
+static struct tvp514x_reg tvp514xm_init_reg_seq[] = {
+	{TOK_WRITE, REG_OPERATION_MODE, 0x01},
+	{TOK_WRITE, REG_OPERATION_MODE, 0x00},
+};
+static struct tvp514x_init_seq tvp514xm_init = {
+	.no_regs = ARRAY_SIZE(tvp514xm_init_reg_seq),
+	.init_reg_seq = tvp514xm_init_reg_seq,
+};
+/*
+ * I2C Device Table -
+ *
+ * name - Name of the actual device/chip.
+ * driver_data - Driver data
+ */
+static const struct i2c_device_id tvp514x_id[] = {
+	{"tvp5146", (unsigned int)&tvp5146_init},
+	{"tvp5146m2", (unsigned int)&tvp514xm_init},
+	{"tvp5147", (unsigned int)&tvp5147_init},
+	{"tvp5147m1", (unsigned int)&tvp514xm_init},
+	{},
+};
+
+MODULE_DEVICE_TABLE(i2c, tvp514x_id);
+
+static struct i2c_driver tvp514x_i2c_driver = {
+	.driver = {
+		   .name = MODULE_NAME,
+		   .owner = THIS_MODULE,
+		   },
+	.probe = tvp514x_probe,
+	.remove = __exit_p(tvp514x_remove),
+	.id_table = tvp514x_id,
+};
+
+/**
+ * tvp514x_init
+ *
+ * Module init function
+ */
+static int __init tvp514x_init(void)
+{
+	int err;
+
+	err = i2c_add_driver(&tvp514x_i2c_driver);
+	if (err) {
+		printk(KERN_ERR "Failed to register " MODULE_NAME ".\n");
+		return err;
+	}
+	return 0;
+}
+
+/**
+ * tvp514x_cleanup
+ *
+ * Module exit function
+ */
+static void __exit tvp514x_cleanup(void)
+{
+	i2c_del_driver(&tvp514x_i2c_driver);
+}
+
+module_init(tvp514x_init);
+module_exit(tvp514x_cleanup);
+
+MODULE_AUTHOR("Texas Instruments");
+MODULE_DESCRIPTION("TVP514X linux decoder driver");
+MODULE_LICENSE("GPL");
diff --git a/drivers/media/video/tvp514x_regs.h b/drivers/media/video/tvp514x_regs.h
new file mode 100755
index 0000000..003a3c1
--- /dev/null
+++ b/drivers/media/video/tvp514x_regs.h
@@ -0,0 +1,292 @@
+/*
+ * drivers/media/video/tvp514x_regs.h
+ *
+ * Copyright (C) 2008 Texas Instruments Inc
+ * Author: Vaibhav Hiremath <hvaibhav@ti.com>
+ *
+ * Contributors:
+ *     Sivaraj R <sivaraj@ti.com>
+ *     Brijesh R Jadav <brijesh.j@ti.com>
+ *     Hardik Shah <hardik.shah@ti.com>
+ *     Manjunath Hadli <mrh@ti.com>
+ *     Karicheri Muralidharan <m-karicheri2@ti.com>
+ *
+ * This package is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#ifndef _TVP514X_REGS_H
+#define _TVP514X_REGS_H
+
+/*
+ * TVP5146/47 registers
+ */
+#define REG_INPUT_SEL			(0x00)
+#define REG_AFE_GAIN_CTRL		(0x01)
+#define REG_VIDEO_STD			(0x02)
+#define REG_OPERATION_MODE		(0x03)
+#define REG_AUTOSWITCH_MASK		(0x04)
+
+#define REG_COLOR_KILLER		(0x05)
+#define REG_LUMA_CONTROL1		(0x06)
+#define REG_LUMA_CONTROL2		(0x07)
+#define REG_LUMA_CONTROL3		(0x08)
+
+#define REG_BRIGHTNESS			(0x09)
+#define REG_CONTRAST			(0x0A)
+#define REG_SATURATION			(0x0B)
+#define REG_HUE				(0x0C)
+
+#define REG_CHROMA_CONTROL1		(0x0D)
+#define REG_CHROMA_CONTROL2		(0x0E)
+
+/* 0x0F Reserved */
+
+#define REG_COMP_PR_SATURATION		(0x10)
+#define REG_COMP_Y_CONTRAST		(0x11)
+#define REG_COMP_PB_SATURATION		(0x12)
+
+/* 0x13 Reserved */
+
+#define REG_COMP_Y_BRIGHTNESS		(0x14)
+
+/* 0x15 Reserved */
+
+#define REG_AVID_START_PIXEL_LSB	(0x16)
+#define REG_AVID_START_PIXEL_MSB	(0x17)
+#define REG_AVID_STOP_PIXEL_LSB		(0x18)
+#define REG_AVID_STOP_PIXEL_MSB		(0x19)
+
+#define REG_HSYNC_START_PIXEL_LSB	(0x1A)
+#define REG_HSYNC_START_PIXEL_MSB	(0x1B)
+#define REG_HSYNC_STOP_PIXEL_LSB	(0x1C)
+#define REG_HSYNC_STOP_PIXEL_MSB	(0x1D)
+
+#define REG_VSYNC_START_LINE_LSB	(0x1E)
+#define REG_VSYNC_START_LINE_MSB	(0x1F)
+#define REG_VSYNC_STOP_LINE_LSB		(0x20)
+#define REG_VSYNC_STOP_LINE_MSB		(0x21)
+
+#define REG_VBLK_START_LINE_LSB		(0x22)
+#define REG_VBLK_START_LINE_MSB		(0x23)
+#define REG_VBLK_STOP_LINE_LSB		(0x24)
+#define REG_VBLK_STOP_LINE_MSB		(0x25)
+
+/* 0x26 - 0x27 Reserved */
+
+#define REG_FAST_SWTICH_CONTROL		(0x28)
+
+/* 0x29 Reserved */
+
+#define REG_FAST_SWTICH_SCART_DELAY	(0x2A)
+
+/* 0x2B Reserved */
+
+#define REG_SCART_DELAY			(0x2C)
+#define REG_CTI_DELAY			(0x2D)
+#define REG_CTI_CONTROL			(0x2E)
+
+/* 0x2F - 0x31 Reserved */
+
+#define REG_SYNC_CONTROL		(0x32)
+#define REG_OUTPUT_FORMATTER1		(0x33)
+#define REG_OUTPUT_FORMATTER2		(0x34)
+#define REG_OUTPUT_FORMATTER3		(0x35)
+#define REG_OUTPUT_FORMATTER4		(0x36)
+#define REG_OUTPUT_FORMATTER5		(0x37)
+#define REG_OUTPUT_FORMATTER6		(0x38)
+#define REG_CLEAR_LOST_LOCK		(0x39)
+
+#define REG_STATUS1			(0x3A)
+#define REG_STATUS2			(0x3B)
+
+#define REG_AGC_GAIN_STATUS_LSB		(0x3C)
+#define REG_AGC_GAIN_STATUS_MSB		(0x3D)
+
+/* 0x3E Reserved */
+
+#define REG_VIDEO_STD_STATUS		(0x3F)
+#define REG_GPIO_INPUT1			(0x40)
+#define REG_GPIO_INPUT2			(0x41)
+
+/* 0x42 - 0x45 Reserved */
+
+#define REG_AFE_COARSE_GAIN_CH1		(0x46)
+#define REG_AFE_COARSE_GAIN_CH2		(0x47)
+#define REG_AFE_COARSE_GAIN_CH3		(0x48)
+#define REG_AFE_COARSE_GAIN_CH4		(0x49)
+
+#define REG_AFE_FINE_GAIN_PB_B_LSB	(0x4A)
+#define REG_AFE_FINE_GAIN_PB_B_MSB	(0x4B)
+#define REG_AFE_FINE_GAIN_Y_G_CHROMA_LSB	(0x4C)
+#define REG_AFE_FINE_GAIN_Y_G_CHROMA_MSB	(0x4D)
+#define REG_AFE_FINE_GAIN_PR_R_LSB	(0x4E)
+#define REG_AFE_FINE_GAIN_PR_R_MSB	(0x4F)
+#define REG_AFE_FINE_GAIN_CVBS_LUMA_LSB	(0x50)
+#define REG_AFE_FINE_GAIN_CVBS_LUMA_MSB	(0x51)
+
+/* 0x52 - 0x68 Reserved */
+
+#define REG_FBIT_VBIT_CONTROL1		(0x69)
+
+/* 0x6A - 0x6B Reserved */
+
+#define REG_BACKEND_AGC_CONTROL		(0x6C)
+
+/* 0x6D - 0x6E Reserved */
+
+#define REG_AGC_DECREMENT_SPEED_CONTROL	(0x6F)
+#define REG_ROM_VERSION			(0x70)
+
+/* 0x71 - 0x73 Reserved */
+
+#define REG_AGC_WHITE_PEAK_PROCESSING	(0x74)
+#define REG_FBIT_VBIT_CONTROL2		(0x75)
+#define REG_VCR_TRICK_MODE_CONTROL	(0x76)
+#define REG_HORIZONTAL_SHAKE_INCREMENT	(0x77)
+#define REG_AGC_INCREMENT_SPEED		(0x78)
+#define REG_AGC_INCREMENT_DELAY		(0x79)
+
+/* 0x7A - 0x7F Reserved */
+
+#define REG_CHIP_ID_MSB			(0x80)
+#define REG_CHIP_ID_LSB			(0x81)
+
+/* 0x82 Reserved */
+
+#define REG_CPLL_SPEED_CONTROL		(0x83)
+
+/* 0x84 - 0x96 Reserved */
+
+#define REG_STATUS_REQUEST		(0x97)
+
+/* 0x98 - 0x99 Reserved */
+
+#define REG_VERTICAL_LINE_COUNT_LSB	(0x9A)
+#define REG_VERTICAL_LINE_COUNT_MSB	(0x9B)
+
+/* 0x9C - 0x9D Reserved */
+
+#define REG_AGC_DECREMENT_DELAY		(0x9E)
+
+/* 0x9F - 0xB0 Reserved */
+
+#define REG_VDP_TTX_FILTER_1_MASK1	(0xB1)
+#define REG_VDP_TTX_FILTER_1_MASK2	(0xB2)
+#define REG_VDP_TTX_FILTER_1_MASK3	(0xB3)
+#define REG_VDP_TTX_FILTER_1_MASK4	(0xB4)
+#define REG_VDP_TTX_FILTER_1_MASK5	(0xB5)
+#define REG_VDP_TTX_FILTER_2_MASK1	(0xB6)
+#define REG_VDP_TTX_FILTER_2_MASK2	(0xB7)
+#define REG_VDP_TTX_FILTER_2_MASK3	(0xB8)
+#define REG_VDP_TTX_FILTER_2_MASK4	(0xB9)
+#define REG_VDP_TTX_FILTER_2_MASK5	(0xBA)
+#define REG_VDP_TTX_FILTER_CONTROL	(0xBB)
+#define REG_VDP_FIFO_WORD_COUNT		(0xBC)
+#define REG_VDP_FIFO_INTERRUPT_THRLD	(0xBD)
+
+/* 0xBE Reserved */
+
+#define REG_VDP_FIFO_RESET		(0xBF)
+#define REG_VDP_FIFO_OUTPUT_CONTROL	(0xC0)
+#define REG_VDP_LINE_NUMBER_INTERRUPT	(0xC1)
+#define REG_VDP_PIXEL_ALIGNMENT_LSB	(0xC2)
+#define REG_VDP_PIXEL_ALIGNMENT_MSB	(0xC3)
+
+/* 0xC4 - 0xD5 Reserved */
+
+#define REG_VDP_LINE_START		(0xD6)
+#define REG_VDP_LINE_STOP		(0xD7)
+#define REG_VDP_GLOBAL_LINE_MODE	(0xD8)
+#define REG_VDP_FULL_FIELD_ENABLE	(0xD9)
+#define REG_VDP_FULL_FIELD_MODE		(0xDA)
+
+/* 0xDB - 0xDF Reserved */
+
+#define REG_VBUS_DATA_ACCESS_NO_VBUS_ADDR_INCR	(0xE0)
+#define REG_VBUS_DATA_ACCESS_VBUS_ADDR_INCR	(0xE1)
+#define REG_FIFO_READ_DATA			(0xE2)
+
+/* 0xE3 - 0xE7 Reserved */
+
+#define REG_VBUS_ADDRESS_ACCESS1	(0xE8)
+#define REG_VBUS_ADDRESS_ACCESS2	(0xE9)
+#define REG_VBUS_ADDRESS_ACCESS3	(0xEA)
+
+/* 0xEB - 0xEF Reserved */
+
+#define REG_INTERRUPT_RAW_STATUS0	(0xF0)
+#define REG_INTERRUPT_RAW_STATUS1	(0xF1)
+#define REG_INTERRUPT_STATUS0		(0xF2)
+#define REG_INTERRUPT_STATUS1		(0xF3)
+#define REG_INTERRUPT_MASK0		(0xF4)
+#define REG_INTERRUPT_MASK1		(0xF5)
+#define REG_INTERRUPT_CLEAR0		(0xF6)
+#define REG_INTERRUPT_CLEAR1		(0xF7)
+
+/* 0xF8 - 0xFF Reserved */
+
+/*
+ * Mask and bit definitions of TVP5146/47 registers
+ */
+/* The ID values we are looking for */
+#define TVP514X_CHIP_ID_MSB		(0x51)
+#define TVP5146_CHIP_ID_LSB		(0x46)
+#define TVP5147_CHIP_ID_LSB		(0x47)
+
+#define VIDEO_STD_MASK			(0x07)
+#define VIDEO_STD_AUTO_SWITCH_BIT	(0x00)
+#define VIDEO_STD_NTSC_MJ_BIT		(0x01)
+#define VIDEO_STD_PAL_BDGHIN_BIT	(0x02)
+#define VIDEO_STD_PAL_M_BIT		(0x03)
+#define VIDEO_STD_PAL_COMBINATION_N_BIT	(0x04)
+#define VIDEO_STD_NTSC_4_43_BIT		(0x05)
+#define VIDEO_STD_SECAM_BIT		(0x06)
+#define VIDEO_STD_PAL_60_BIT		(0x07)
+
+/*
+ * Status bit
+ */
+#define STATUS_TV_VCR_BIT		(1<<0)
+#define STATUS_HORZ_SYNC_LOCK_BIT	(1<<1)
+#define STATUS_VIRT_SYNC_LOCK_BIT	(1<<2)
+#define STATUS_CLR_SUBCAR_LOCK_BIT	(1<<3)
+#define STATUS_LOST_LOCK_DETECT_BIT	(1<<4)
+#define STATUS_FEILD_RATE_BIT		(1<<5)
+#define STATUS_LINE_ALTERNATING_BIT	(1<<6)
+#define STATUS_PEAK_WHITE_DETECT_BIT	(1<<7)
+
+/**
+ * struct tvp514x_reg - Structure for TVP5146/47 register initialization values
+ * @token - Token: TOK_WRITE, TOK_TERM etc..
+ * @reg - Register offset
+ * @val - Register Value for TOK_WRITE or delay in ms for TOK_DELAY
+ */
+struct tvp514x_reg {
+	u8 token;
+	u8 reg;
+	u32 val;
+};
+
+/**
+ * struct tvp514x_init_seq - Structure for TVP5146/47/46M2/47M1 power up
+ *		Sequence.
+ * @ no_regs - Number of registers to write for power up sequence.
+ * @ init_reg_seq - Array of registers and respective value to write.
+ */
+struct tvp514x_init_seq {
+	unsigned int no_regs;
+	struct tvp514x_reg *init_reg_seq;
+};
+#endif				/* ifndef _TVP514X_REGS_H */
diff --git a/include/media/tvp514x.h b/include/media/tvp514x.h
new file mode 100755
index 0000000..2fee5e7
--- /dev/null
+++ b/include/media/tvp514x.h
@@ -0,0 +1,232 @@
+/*
+ * drivers/media/video/tvp514x.h
+ *
+ * Copyright (C) 2008 Texas Instruments Inc
+ * Author: Vaibhav Hiremath <hvaibhav@ti.com>
+ *
+ * Contributors:
+ *     Sivaraj R <sivaraj@ti.com>
+ *     Brijesh R Jadav <brijesh.j@ti.com>
+ *     Hardik Shah <hardik.shah@ti.com>
+ *     Manjunath Hadli <mrh@ti.com>
+ *     Karicheri Muralidharan <m-karicheri2@ti.com>
+ *
+ * This package is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#ifndef _TVP514X_H
+#define _TVP514X_H
+
+/*
+ * Other macros
+ */
+#define TVP514X_MODULE_NAME		"tvp514x"
+#define TVP514X_I2C_DELAY		(3)
+#define I2C_RETRY_COUNT			(5)
+#define LOCK_RETRY_COUNT		(5)
+#define LOCK_RETRY_DELAY		(200)
+
+#define TOK_WRITE			(0)	/* token for write operation */
+#define TOK_TERM			(1)	/* terminating token */
+#define TOK_DELAY			(2)	/* delay token for reg list */
+#define TOK_SKIP			(3)	/* token to skip a register */
+
+#define TVP514X_XCLK_BT656		(27000000)
+
+/* Number of pixels and number of lines per frame for different standards */
+#define NTSC_NUM_ACTIVE_PIXELS		(720)
+#define NTSC_NUM_ACTIVE_LINES		(480)
+#define PAL_NUM_ACTIVE_PIXELS		(720)
+#define PAL_NUM_ACTIVE_LINES		(576)
+
+/**
+ * enum tvp514x_std - enum for supported standards
+ */
+enum tvp514x_std {
+	STD_NTSC_MJ = 0,
+	STD_PAL_BDGHIN,
+	STD_INVALID
+};
+
+/**
+ * enum tvp514x_state - enum for different decoder states
+ */
+enum tvp514x_state {
+	STATE_NOT_DETECTED,
+	STATE_DETECTED
+};
+
+/**
+ * enum tvp514x_input - enum for different decoder input pin
+ *		configuration.
+ */
+enum tvp514x_input {
+	/*
+	 * CVBS input selection
+	 */
+	INPUT_CVBS_VI1A = 0x0,
+	INPUT_CVBS_VI1B,
+	INPUT_CVBS_VI1C,
+	INPUT_CVBS_VI2A = 0x04,
+	INPUT_CVBS_VI2B,
+	INPUT_CVBS_VI2C,
+	INPUT_CVBS_VI3A = 0x08,
+	INPUT_CVBS_VI3B,
+	INPUT_CVBS_VI3C,
+	INPUT_CVBS_VI4A = 0x0C,
+	/*
+	 * S-Video input selection
+	 */
+	INPUT_SVIDEO_VI2A_VI1A = 0x44,
+	INPUT_SVIDEO_VI2B_VI1B,
+	INPUT_SVIDEO_VI2C_VI1C,
+	INPUT_SVIDEO_VI2A_VI3A = 0x54,
+	INPUT_SVIDEO_VI2B_VI3B,
+	INPUT_SVIDEO_VI2C_VI3C,
+	INPUT_SVIDEO_VI4A_VI1A = 0x4C,
+	INPUT_SVIDEO_VI4A_VI1B,
+	INPUT_SVIDEO_VI4A_VI1C,
+	INPUT_SVIDEO_VI4A_VI3A = 0x5C,
+	INPUT_SVIDEO_VI4A_VI3B,
+	INPUT_SVIDEO_VI4A_VI3C
+
+	/* Need to add entries for
+	 * RGB, YPbPr and SCART.
+	 */
+};
+
+/**
+ * enum tvp514x_output_fmt - enum for output format
+ *			supported.
+ */
+enum tvp514x_output_fmt {
+	OUTPUT_10BIT_422_EMBEDDED_SYNC = 0,
+	OUTPUT_20BIT_422_SEPERATE_SYNC,
+	OUTPUT_10BIT_422_SEPERATE_SYNC = 3,
+	OUTPUT_INVALID
+};
+
+/**
+ * struct tvp514x_std_info - Structure to store standard informations
+ * @width: Line width in pixels
+ * @height:Number of active lines
+ * @video_std: Value to write in REG_VIDEO_STD register
+ * @standard: v4l2 standard structure information
+ */
+struct tvp514x_std_info {
+	unsigned long width;
+	unsigned long height;
+	u8 video_std;
+	struct v4l2_standard standard;
+};
+
+/**
+ * struct tvp514x_ctrl_info - Information regarding supported controls
+ * @reg_address: Register offset of control register
+ * @query_ctrl: v4l2 query control information
+ */
+struct tvp514x_ctrl_info {
+	u8 reg_address;
+	struct v4l2_queryctrl query_ctrl;
+};
+
+/**
+ * struct tvp514x_input_info - Information regarding supported inputs
+ * @input_sel: Input select register
+ * @lock_mask: lock mask - depends on Svideo/CVBS
+ * @input: v4l2 input information
+ */
+struct tvp514x_input_info {
+	enum tvp514x_input input_sel;
+	struct v4l2_input input;
+};
+
+/**
+ * struct tvp514x_platform_data - Platform data values and access functions
+ * @power_set: Power state access function, zero is off, non-zero is on.
+ * @ifparm: Interface parameters access function
+ * @priv_data_set: Device private data (pointer) access function
+ * @reg_list: The board dependent driver should fill the default value for
+ *            required registers depending on board layout. The TVP5146/47
+ *            driver will update this register list for the registers
+ *            whose values should be maintained across open()/close() like
+ *            setting brightness as defined in V4L2.
+ *            The register list should be in the same order as defined in
+ *            TVP5146/47 datasheet including reserved registers. As of now
+ *            the driver expects the size of this list to be a minimum of
+ *            57 + 1 (upto regsiter REG_CLEAR_LOST_LOCK).
+ *            The last member should be of the list should be
+ *            {TOK_TERM, 0, 0} to indicate the end of register list.
+ * @num_inputs: Number of input connection in board
+ * @input_list: Input information list for num_inputs
+ */
+struct tvp514x_platform_data {
+	char *master;
+	int (*power_set) (enum v4l2_power on);
+	int (*ifparm) (struct v4l2_ifparm *p);
+	int (*priv_data_set) (void *);
+	/* Input params */
+	int num_inputs;
+	const struct tvp514x_input_info *input_list;
+	int default_input;
+	/* Interface control params */
+	enum tvp514x_output_fmt fmt;
+	bool clk_polarity;
+	bool hs_polarity;
+	bool vs_polarity;
+};
+
+/**
+ * struct tvp514x_decoded - TVP5146/47 decoder object
+ * @v4l2_int_device: Slave handle
+ * @pdata: Board specific
+ * @client: I2C client data
+ * @id: Entry from I2C table
+ * @ver: Chip version
+ * @state: TVP5146/47 decoder state - detected or not-detected
+ * @pix: Current pixel format
+ * @num_fmts: Number of formats
+ * @fmt_list: Format list
+ * @current_std: Current standard
+ * @num_stds: Number of standards
+ * @std_list: Standards list
+ * @num_ctrls: Number of controls
+ * @ctrl_list: Control list
+ */
+struct tvp514x_decoder {
+	struct v4l2_int_device *v4l2_int_device;
+	const struct tvp514x_platform_data *pdata;
+	struct i2c_client *client;
+
+	struct i2c_device_id *id;
+
+	int ver;
+	enum tvp514x_state state;
+
+	struct v4l2_pix_format pix;
+	int num_fmts;
+	const struct v4l2_fmtdesc *fmt_list;
+
+	enum tvp514x_std current_std;
+	int num_stds;
+	struct tvp514x_std_info *std_list;
+
+	int num_ctrls;
+	const struct tvp514x_ctrl_info *ctrl_list;
+
+	int inputidx;
+};
+
+#endif				/* ifndef _TVP514X_H */
--
1.5.6


^ permalink raw reply related	[flat|nested] 263+ messages in thread

* Re: [PATCH 2/2] TVP514x Driver with Review comments fixed [V4]
  2008-12-02 15:35   ` hvaibhav
  (?)
@ 2008-12-02 17:20   ` Hans Verkuil
  2008-12-03  3:58       ` Hiremath, Vaibhav
  2008-12-03 13:43     ` V4L2 PIXEL buffer conversion Jonathan Lafontaine
  -1 siblings, 2 replies; 263+ messages in thread
From: Hans Verkuil @ 2008-12-02 17:20 UTC (permalink / raw)
  To: video4linux-list
  Cc: linux-omap, Karicheri Muralidharan, davinci-linux-open-source-bounces

Hi Vaibhav,

I'm sorry, but this is still wrong. You basically renamed s_input with 
s_routing while still using the list with user inputs from the platform 
data. 

These three fields in struct tvp514x_platform_data should be removed as 
they do not belong here:

> +	/* Input params */
> +	int num_inputs;
> +	const struct tvp514x_input_info *input_list;
> +	int default_input;

This is all high-level stuff that does not belong in an i2c driver. It's 
the master driver that has to translate the input as specified by the 
user to a pin of the tvp514x (like INPUT_CVBS_VI1A).

Also, ioctl_g_routing() can be removed as I have yet to see a master 
driver that is interested in obtaining this information. Besides, that 
function looks very strange because it is calling ioctl_s_routing. A 
get function that sets something?!?

Eventually the whole tvp514x_platform_data will have to be removed. 
Everything that's in there should be passed to the i2c driver using 
v4l2_subdev ops. But that's something for the future.

I'm available in the #v4l IRC channel tomorrow for further discussions 
on this.

BTW1, struct tvp514x_decoder shouldn't be in include/media/tvp514x.h. 
It's internal to the driver (at least, I sincerely hope so), so it can 
be moved to either the source or the tvp514x_regs.h header.

BTW2, I'm not going to make it a blocking issue, but those callback 
functions in tvp514x_platform_data are horrible. The priv_data_set 
callback is the clearest example of what's wrong with this design: a 
master driver calls ioctl_g_priv in tvp whose only action is to call 
priv_data_set in the platform code! The master driver shouldn't have to 
go through the i2c driver for that! The only reason a low level v4l i2c 
driver would ever make a call to higher level code is for 
notifications.

Regards,

	Hans

On Tuesday 02 December 2008 16:35:42 hvaibhav@ti.com wrote:
> From: Vaibhav Hiremath <hvaibhav@ti.com>
>
> I have fixed all the review commentsreceived so far.
> Here are the details -
>
> FIXSES:
>     Make use of i2c_smbus_read/write_byte API:
>         Probe function now checks for SMBUS capability,
> 	and read/write functions make use of the above API.
>
>     Error check for I2C Read/Write:
>         Added error condition check for both read and write
> 	API.
> 	This has been added for completeness.
>
>     input set/get ioctl:
>         As we do have support for set and get routing ioctl,
> 	instead of adding new ioctl used them.
>
>     enum_ioctl:
>         After discussing with Hans verkuil, came to conclusion
> 	that as of now just remove support for enum_ioctl from
> 	decoder, since this has to handle at master driver level.
>
> TODO LIST:
>     OMAP Master capture driver:
>         This should be completely aligned with the current
> 	discussion.
>
>     Migration to sub_device framework:
>         Immediately after all the above task, migrate both
> 	Master and slave driver to sub_device framework.
>
> Signed-off-by: Brijesh Jadav <brijesh.j@ti.com>
> Signed-off-by: Hardik Shah <hardik.shah@ti.com>
> Signed-off-by: Manjunath Hadli <mrh@ti.com>
> Signed-off-by: R Sivaraj <sivaraj@ti.com>
> Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
> Signed-off-by: Karicheri Muralidharan <m-karicheri2@ti.com>
> ---
>  drivers/media/video/Kconfig        |   11 +
>  drivers/media/video/Makefile       |    1 +
>  drivers/media/video/tvp514x.c      | 1521
> ++++++++++++++++++++++++++++++++++++
> drivers/media/video/tvp514x_regs.h |  292 +++++++
>  include/media/tvp514x.h            |  232 ++++++
>  5 files changed, 2057 insertions(+), 0 deletions(-)
>  create mode 100755 drivers/media/video/tvp514x.c
>  create mode 100755 drivers/media/video/tvp514x_regs.h
>  create mode 100755 include/media/tvp514x.h
>
> diff --git a/drivers/media/video/Kconfig
> b/drivers/media/video/Kconfig index 47102c2..2e5dc3e 100644
> --- a/drivers/media/video/Kconfig
> +++ b/drivers/media/video/Kconfig
> @@ -361,6 +361,17 @@ config VIDEO_SAA7191
>  	  To compile this driver as a module, choose M here: the
>  	  module will be called saa7191.
>
> +config VIDEO_TVP514X
> +	tristate "Texas Instruments TVP514x video decoder"
> +	depends on VIDEO_V4L2 && I2C
> +	---help---
> +	  This is a Video4Linux2 sensor-level driver for the TI TVP5146/47
> +	  decoder. It is currently working with the TI OMAP3 camera
> +	  controller.
> +
> +	  To compile this driver as a module, choose M here: the
> +	  module will be called tvp514x.
> +
>  config VIDEO_TVP5150
>  	tristate "Texas Instruments TVP5150 video decoder"
>  	depends on VIDEO_V4L2 && I2C
> diff --git a/drivers/media/video/Makefile
> b/drivers/media/video/Makefile index 16962f3..cdbbf38 100644
> --- a/drivers/media/video/Makefile
> +++ b/drivers/media/video/Makefile
> @@ -66,6 +66,7 @@ obj-$(CONFIG_VIDEO_CX88) += cx88/
>  obj-$(CONFIG_VIDEO_EM28XX) += em28xx/
>  obj-$(CONFIG_VIDEO_USBVISION) += usbvision/
>  obj-$(CONFIG_VIDEO_TVP5150) += tvp5150.o
> +obj-$(CONFIG_VIDEO_TVP514X) += tvp514x.o
>  obj-$(CONFIG_VIDEO_PVRUSB2) += pvrusb2/
>  obj-$(CONFIG_VIDEO_MSP3400) += msp3400.o
>  obj-$(CONFIG_VIDEO_CS5345) += cs5345.o
> diff --git a/drivers/media/video/tvp514x.c
> b/drivers/media/video/tvp514x.c new file mode 100755
> index 0000000..c0834e4
> --- /dev/null
> +++ b/drivers/media/video/tvp514x.c
> @@ -0,0 +1,1521 @@
> +/*
> + * drivers/media/video/tvp514x.c
> + *
> + * TI TVP5146/47 decoder driver
> + *
> + * Copyright (C) 2008 Texas Instruments Inc
> + * Author: Vaibhav Hiremath <hvaibhav@ti.com>
> + *
> + * Contributors:
> + *     Sivaraj R <sivaraj@ti.com>
> + *     Brijesh R Jadav <brijesh.j@ti.com>
> + *     Hardik Shah <hardik.shah@ti.com>
> + *     Manjunath Hadli <mrh@ti.com>
> + *     Karicheri Muralidharan <m-karicheri2@ti.com>
> + *
> + * This package is free software; you can redistribute it and/or
> modify + * it under the terms of the GNU General Public License
> version 2 as + * published by the Free Software Foundation.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program; if not, write to the Free Software
> + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
> + *
> + */
> +
> +#include <linux/i2c.h>
> +#include <linux/delay.h>
> +#include <linux/videodev2.h>
> +#include <media/v4l2-int-device.h>
> +#include <media/tvp514x.h>
> +
> +#include "tvp514x_regs.h"
> +
> +#define MODULE_NAME	TVP514X_MODULE_NAME
> +
> +/* Debug functions */
> +static int debug;
> +module_param(debug, bool, 0644);
> +MODULE_PARM_DESC(debug, "Debug level (0-1)");
> +
> +#define dump_reg(client, reg, val)				\
> +	do {							\
> +		val = tvp514x_read_reg(client, reg);		\
> +		v4l_info(client, "Reg(0x%.2X): 0x%.2X\n", reg, val); \
> +	} while (0)
> +
> +
> +/* TVP514x default register values */
> +static struct tvp514x_reg tvp514x_reg_list[] = {
> +	{TOK_WRITE, REG_INPUT_SEL, 0x05},	/* Composite selected */
> +	{TOK_WRITE, REG_AFE_GAIN_CTRL, 0x0F},
> +	{TOK_WRITE, REG_VIDEO_STD, 0x00},	/* Auto mode */
> +	{TOK_WRITE, REG_OPERATION_MODE, 0x00},
> +	{TOK_SKIP, REG_AUTOSWITCH_MASK, 0x3F},
> +	{TOK_WRITE, REG_COLOR_KILLER, 0x10},
> +	{TOK_WRITE, REG_LUMA_CONTROL1, 0x00},
> +	{TOK_WRITE, REG_LUMA_CONTROL2, 0x00},
> +	{TOK_WRITE, REG_LUMA_CONTROL3, 0x02},
> +	{TOK_WRITE, REG_BRIGHTNESS, 0x80},
> +	{TOK_WRITE, REG_CONTRAST, 0x80},
> +	{TOK_WRITE, REG_SATURATION, 0x80},
> +	{TOK_WRITE, REG_HUE, 0x00},
> +	{TOK_WRITE, REG_CHROMA_CONTROL1, 0x00},
> +	{TOK_WRITE, REG_CHROMA_CONTROL2, 0x0E},
> +	{TOK_SKIP, 0x0F, 0x00},	/* Reserved */
> +	{TOK_WRITE, REG_COMP_PR_SATURATION, 0x80},
> +	{TOK_WRITE, REG_COMP_Y_CONTRAST, 0x80},
> +	{TOK_WRITE, REG_COMP_PB_SATURATION, 0x80},
> +	{TOK_SKIP, 0x13, 0x00},	/* Reserved */
> +	{TOK_WRITE, REG_COMP_Y_BRIGHTNESS, 0x80},
> +	{TOK_SKIP, 0x15, 0x00},	/* Reserved */
> +	{TOK_SKIP, REG_AVID_START_PIXEL_LSB, 0x55},	/* NTSC timing */
> +	{TOK_SKIP, REG_AVID_START_PIXEL_MSB, 0x00},
> +	{TOK_SKIP, REG_AVID_STOP_PIXEL_LSB, 0x25},
> +	{TOK_SKIP, REG_AVID_STOP_PIXEL_MSB, 0x03},
> +	{TOK_SKIP, REG_HSYNC_START_PIXEL_LSB, 0x00},	/* NTSC timing */
> +	{TOK_SKIP, REG_HSYNC_START_PIXEL_MSB, 0x00},
> +	{TOK_SKIP, REG_HSYNC_STOP_PIXEL_LSB, 0x40},
> +	{TOK_SKIP, REG_HSYNC_STOP_PIXEL_MSB, 0x00},
> +	{TOK_SKIP, REG_VSYNC_START_LINE_LSB, 0x04},	/* NTSC timing */
> +	{TOK_SKIP, REG_VSYNC_START_LINE_MSB, 0x00},
> +	{TOK_SKIP, REG_VSYNC_STOP_LINE_LSB, 0x07},
> +	{TOK_SKIP, REG_VSYNC_STOP_LINE_MSB, 0x00},
> +	{TOK_SKIP, REG_VBLK_START_LINE_LSB, 0x01},	/* NTSC timing */
> +	{TOK_SKIP, REG_VBLK_START_LINE_MSB, 0x00},
> +	{TOK_SKIP, REG_VBLK_STOP_LINE_LSB, 0x15},
> +	{TOK_SKIP, REG_VBLK_STOP_LINE_MSB, 0x00},
> +	{TOK_SKIP, 0x26, 0x00},	/* Reserved */
> +	{TOK_SKIP, 0x27, 0x00},	/* Reserved */
> +	{TOK_SKIP, REG_FAST_SWTICH_CONTROL, 0xCC},
> +	{TOK_SKIP, 0x29, 0x00},	/* Reserved */
> +	{TOK_SKIP, REG_FAST_SWTICH_SCART_DELAY, 0x00},
> +	{TOK_SKIP, 0x2B, 0x00},	/* Reserved */
> +	{TOK_SKIP, REG_SCART_DELAY, 0x00},
> +	{TOK_SKIP, REG_CTI_DELAY, 0x00},
> +	{TOK_SKIP, REG_CTI_CONTROL, 0x00},
> +	{TOK_SKIP, 0x2F, 0x00},	/* Reserved */
> +	{TOK_SKIP, 0x30, 0x00},	/* Reserved */
> +	{TOK_SKIP, 0x31, 0x00},	/* Reserved */
> +	{TOK_WRITE, REG_SYNC_CONTROL, 0x00},	/* HS, VS active high */
> +	{TOK_WRITE, REG_OUTPUT_FORMATTER1, 0x00},	/* 10-bit BT.656 */
> +	{TOK_WRITE, REG_OUTPUT_FORMATTER2, 0x11},	/* Enable clk & data */
> +	{TOK_WRITE, REG_OUTPUT_FORMATTER3, 0xEE},	/* Enable AVID & FLD */
> +	{TOK_WRITE, REG_OUTPUT_FORMATTER4, 0xAF},	/* Enable VS & HS */
> +	{TOK_WRITE, REG_OUTPUT_FORMATTER5, 0xFF},
> +	{TOK_WRITE, REG_OUTPUT_FORMATTER6, 0xFF},
> +	{TOK_WRITE, REG_CLEAR_LOST_LOCK, 0x01},	/* Clear status */
> +	{TOK_TERM, 0, 0},
> +};
> +
> +/* List of image formats supported by TVP5146/47 decoder
> + * Currently we are using 8 bit mode only, but can be
> + * extended to 10/20 bit mode.
> + */
> +static const struct v4l2_fmtdesc tvp514x_fmt_list[] = {
> +	{
> +	 .index = 0,
> +	 .type = V4L2_BUF_TYPE_VIDEO_CAPTURE,
> +	 .flags = 0,
> +	 .description = "8-bit UYVY 4:2:2 Format",
> +	 .pixelformat = V4L2_PIX_FMT_UYVY,
> +	},
> +};
> +
> +#define TVP514X_NUM_FORMATS		ARRAY_SIZE(tvp514x_fmt_list)
> +
> +/*
> + * Supported standards -
> + *
> + * Currently supports two standards only, need to add support for
> rest of the + * modes, like SECAM, etc...
> + */
> +static struct tvp514x_std_info tvp514x_std_list[] = {
> +	/* Standard: STD_NTSC_MJ */
> +	[STD_NTSC_MJ] = {
> +	 .width = NTSC_NUM_ACTIVE_PIXELS,
> +	 .height = NTSC_NUM_ACTIVE_LINES,
> +	 .video_std = VIDEO_STD_NTSC_MJ_BIT,
> +	 .standard = {
> +		      .index = 0,
> +		      .id = V4L2_STD_NTSC,
> +		      .name = "NTSC",
> +		      .frameperiod = {1001, 30000},
> +		      .framelines = 525
> +		     },
> +	/* Standard: STD_PAL_BDGHIN */
> +	},
> +	[STD_PAL_BDGHIN] = {
> +	 .width = PAL_NUM_ACTIVE_PIXELS,
> +	 .height = PAL_NUM_ACTIVE_LINES,
> +	 .video_std = VIDEO_STD_PAL_BDGHIN_BIT,
> +	 .standard = {
> +		      .index = 1,
> +		      .id = V4L2_STD_PAL,
> +		      .name = "PAL",
> +		      .frameperiod = {1, 25},
> +		      .framelines = 625
> +		     },
> +	},
> +	/* Standard: need to add for additional standard */
> +};
> +
> +#define TVP514X_NUM_STANDARDS		ARRAY_SIZE(tvp514x_std_list)
> +
> +/* Supported controls */
> +static const struct tvp514x_ctrl_info tvp514x_ctrl_list[] = {
> +	{
> +	 .reg_address = REG_BRIGHTNESS,
> +	 .query_ctrl = {
> +			.id = V4L2_CID_BRIGHTNESS,
> +			.name = "BRIGHTNESS",
> +			.type = V4L2_CTRL_TYPE_INTEGER,
> +			.minimum = 0,
> +			.maximum = 255,
> +			.step = 1,
> +			.default_value = 128
> +			},
> +	}, {
> +	 .reg_address = REG_CONTRAST,
> +	 .query_ctrl = {
> +			.id = V4L2_CID_CONTRAST,
> +			.name = "CONTRAST",
> +			.type = V4L2_CTRL_TYPE_INTEGER,
> +			.minimum = 0,
> +			.maximum = 255,
> +			.step = 1,
> +			.default_value = 128
> +			},
> +	}, {
> +	 .reg_address = REG_SATURATION,
> +	 .query_ctrl = {
> +			.id = V4L2_CID_SATURATION,
> +			.name = "SATURATION",
> +			.type = V4L2_CTRL_TYPE_INTEGER,
> +			.minimum = 0,
> +			.maximum = 255,
> +			.step = 1,
> +			.default_value = 128
> +			},
> +	}, {
> +	 .reg_address = REG_HUE,
> +	 .query_ctrl = {
> +			.id = V4L2_CID_HUE,
> +			.name = "HUE",
> +			.type = V4L2_CTRL_TYPE_INTEGER,
> +			.minimum = -180,
> +			.maximum = 180,
> +			.step = 180,
> +			.default_value = 0
> +			},
> +	}, {
> +	 .reg_address = REG_AFE_GAIN_CTRL,
> +	 .query_ctrl = {
> +			.id = V4L2_CID_AUTOGAIN,
> +			.name = "Automatic Gain Control",
> +			.type = V4L2_CTRL_TYPE_BOOLEAN,
> +			.minimum = 0,
> +			.maximum = 1,
> +			.step = 1,
> +			.default_value = 1
> +			},
> +	 },
> +};
> +
> +#define TVP514X_NUM_CONTROLS		ARRAY_SIZE(tvp514x_ctrl_list)
> +
> +/*
> + * Read a value from a register in an TVP5146/47 decoder device.
> + * Returns value read if successful, or non-zero (-1) otherwise.
> + */
> +static int tvp514x_read_reg(struct i2c_client *client, u8 reg)
> +{
> +	int err;
> +	int retry = 0;
> +read_again:
> +
> +	err = i2c_smbus_read_byte_data(client, reg);
> +	if (err == -1) {
> +		if (retry <= I2C_RETRY_COUNT) {
> +			v4l_warn(client, "Read: retry ... %d\n", retry);
> +			retry++;
> +			msleep_interruptible(10);
> +			goto read_again;
> +		}
> +	}
> +
> +	return err;
> +}
> +
> +/*
> + * Write a value to a register in an TVP5146/47 decoder device.
> + * Returns zero if successful, or non-zero otherwise.
> + */
> +static int tvp514x_write_reg(struct i2c_client *client, u8 reg, u8
> val) +{
> +	int err;
> +	int retry = 0;
> +write_again:
> +
> +	err = i2c_smbus_write_byte_data(client, reg, val);
> +	if (err) {
> +		if (retry <= I2C_RETRY_COUNT) {
> +			v4l_warn(client, "Write: retry ... %d\n", retry);
> +			retry++;
> +			msleep_interruptible(10);
> +			goto write_again;
> +		}
> +	}
> +
> +	return err;
> +}
> +
> +/*
> + * tvp514x_write_regs : Initializes a list of TVP5146/47 registers
> + *		if token is TOK_TERM, then entire write operation terminates
> + *		if token is TOK_DELAY, then a delay of 'val' msec is introduced
> + *		if token is TOK_SKIP, then the register write is skipped
> + *		if token is TOK_WRITE, then the register write is performed
> + *
> + * reglist - list of registers to be written
> + * Returns zero if successful, or non-zero otherwise.
> + */
> +static int tvp514x_write_regs(struct i2c_client *client,
> +			      const struct tvp514x_reg reglist[])
> +{
> +	int err;
> +	const struct tvp514x_reg *next = reglist;
> +
> +	for (; next->token != TOK_TERM; next++) {
> +		if (next->token == TOK_DELAY) {
> +			msleep(next->val);
> +			continue;
> +		}
> +
> +		if (next->token == TOK_SKIP)
> +			continue;
> +
> +		err = tvp514x_write_reg(client, next->reg, (u8) next->val);
> +		if (err) {
> +			v4l_err(client, "Write failed. Err[%d]\n", err);
> +			return err;
> +		}
> +	}
> +	return 0;
> +}
> +
> +/*
> + * tvp514x_get_current_std:
> + * Returns the current standard detected by TVP5146/47
> + */
> +static enum tvp514x_std tvp514x_get_current_std(struct
> tvp514x_decoder +						*decoder)
> +{
> +	u8 std, std_status;
> +
> +	std = tvp514x_read_reg(decoder->client, REG_VIDEO_STD);
> +	if ((std & VIDEO_STD_MASK) == VIDEO_STD_AUTO_SWITCH_BIT) {
> +		/* use the standard status register */
> +		std_status = tvp514x_read_reg(decoder->client,
> +				REG_VIDEO_STD_STATUS);
> +	} else
> +		std_status = std;	/* use the standard register itself */
> +
> +	switch (std_status & VIDEO_STD_MASK) {
> +	case VIDEO_STD_NTSC_MJ_BIT:
> +		return STD_NTSC_MJ;
> +
> +	case VIDEO_STD_PAL_BDGHIN_BIT:
> +		return STD_PAL_BDGHIN;
> +
> +	default:
> +		return STD_INVALID;
> +	}
> +
> +	return STD_INVALID;
> +}
> +
> +/*
> + * TVP5146/47 register dump function
> + */
> +void tvp514x_reg_dump(struct tvp514x_decoder *decoder)
> +{
> +	u8 value;
> +
> +	dump_reg(decoder->client, REG_INPUT_SEL, value);
> +	dump_reg(decoder->client, REG_AFE_GAIN_CTRL, value);
> +	dump_reg(decoder->client, REG_VIDEO_STD, value);
> +	dump_reg(decoder->client, REG_OPERATION_MODE, value);
> +	dump_reg(decoder->client, REG_COLOR_KILLER, value);
> +	dump_reg(decoder->client, REG_LUMA_CONTROL1, value);
> +	dump_reg(decoder->client, REG_LUMA_CONTROL2, value);
> +	dump_reg(decoder->client, REG_LUMA_CONTROL3, value);
> +	dump_reg(decoder->client, REG_BRIGHTNESS, value);
> +	dump_reg(decoder->client, REG_CONTRAST, value);
> +	dump_reg(decoder->client, REG_SATURATION, value);
> +	dump_reg(decoder->client, REG_HUE, value);
> +	dump_reg(decoder->client, REG_CHROMA_CONTROL1, value);
> +	dump_reg(decoder->client, REG_CHROMA_CONTROL2, value);
> +	dump_reg(decoder->client, REG_COMP_PR_SATURATION, value);
> +	dump_reg(decoder->client, REG_COMP_Y_CONTRAST, value);
> +	dump_reg(decoder->client, REG_COMP_PB_SATURATION, value);
> +	dump_reg(decoder->client, REG_COMP_Y_BRIGHTNESS, value);
> +	dump_reg(decoder->client, REG_AVID_START_PIXEL_LSB, value);
> +	dump_reg(decoder->client, REG_AVID_START_PIXEL_MSB, value);
> +	dump_reg(decoder->client, REG_AVID_STOP_PIXEL_LSB, value);
> +	dump_reg(decoder->client, REG_AVID_STOP_PIXEL_MSB, value);
> +	dump_reg(decoder->client, REG_HSYNC_START_PIXEL_LSB, value);
> +	dump_reg(decoder->client, REG_HSYNC_START_PIXEL_MSB, value);
> +	dump_reg(decoder->client, REG_HSYNC_STOP_PIXEL_LSB, value);
> +	dump_reg(decoder->client, REG_HSYNC_STOP_PIXEL_MSB, value);
> +	dump_reg(decoder->client, REG_VSYNC_START_LINE_LSB, value);
> +	dump_reg(decoder->client, REG_VSYNC_START_LINE_MSB, value);
> +	dump_reg(decoder->client, REG_VSYNC_STOP_LINE_LSB, value);
> +	dump_reg(decoder->client, REG_VSYNC_STOP_LINE_MSB, value);
> +	dump_reg(decoder->client, REG_VBLK_START_LINE_LSB, value);
> +	dump_reg(decoder->client, REG_VBLK_START_LINE_MSB, value);
> +	dump_reg(decoder->client, REG_VBLK_STOP_LINE_LSB, value);
> +	dump_reg(decoder->client, REG_VBLK_STOP_LINE_MSB, value);
> +	dump_reg(decoder->client, REG_SYNC_CONTROL, value);
> +	dump_reg(decoder->client, REG_OUTPUT_FORMATTER1, value);
> +	dump_reg(decoder->client, REG_OUTPUT_FORMATTER2, value);
> +	dump_reg(decoder->client, REG_OUTPUT_FORMATTER3, value);
> +	dump_reg(decoder->client, REG_OUTPUT_FORMATTER4, value);
> +	dump_reg(decoder->client, REG_OUTPUT_FORMATTER5, value);
> +	dump_reg(decoder->client, REG_OUTPUT_FORMATTER6, value);
> +	dump_reg(decoder->client, REG_CLEAR_LOST_LOCK, value);
> +}
> +
> +/*
> + * Configure the TVP5146/47 with the current register settings
> + * Returns zero if successful, or non-zero otherwise.
> + */
> +static int tvp514x_configure(struct tvp514x_decoder *decoder)
> +{
> +	int err;
> +
> +	/* common register initialization */
> +	err =
> +	    tvp514x_write_regs(decoder->client, tvp514x_reg_list);
> +	if (err)
> +		return err;
> +
> +	if (debug)
> +		tvp514x_reg_dump(decoder);
> +
> +	return 0;
> +}
> +
> +/*
> + * Detect if an tvp514x is present, and if so which revision.
> + * A device is considered to be detected if the chip ID (LSB and
> MSB) + * registers match the expected values.
> + * Any value of the rom version register is accepted.
> + * Returns ENODEV error number if no device is detected, or zero
> + * if a device is detected.
> + */
> +static int tvp514x_detect(struct tvp514x_decoder *decoder)
> +{
> +	u8 chip_id_msb, chip_id_lsb, rom_ver;
> +
> +	chip_id_msb = tvp514x_read_reg(decoder->client, REG_CHIP_ID_MSB);
> +	chip_id_lsb = tvp514x_read_reg(decoder->client, REG_CHIP_ID_LSB);
> +	rom_ver = tvp514x_read_reg(decoder->client, REG_ROM_VERSION);
> +
> +	v4l_dbg(1, debug, decoder->client,
> +		 "chip id detected msb:0x%x lsb:0x%x rom version:0x%x\n",
> +		 chip_id_msb, chip_id_lsb, rom_ver);
> +	if ((chip_id_msb != TVP514X_CHIP_ID_MSB)
> +		|| ((chip_id_lsb != TVP5146_CHIP_ID_LSB)
> +		&& (chip_id_lsb != TVP5147_CHIP_ID_LSB))) {
> +		/* We didn't read the values we expected, so this must not be
> +		 * an TVP5146/47.
> +		 */
> +		v4l_err(decoder->client,
> +			"chip id mismatch msb:0x%x lsb:0x%x\n",
> +			chip_id_msb, chip_id_lsb);
> +		return -ENODEV;
> +	}
> +
> +	decoder->ver = rom_ver;
> +	decoder->state = STATE_DETECTED;
> +
> +	v4l_info(decoder->client,
> +			"\n%s found at 0x%x (%s)\n", decoder->client->name,
> +			decoder->client->addr << 1,
> +			decoder->client->adapter->name);
> +	return 0;
> +}
> +
> +/*
> + * Following are decoder interface functions implemented by
> + * TVP5146/47 decoder driver.
> + */
> +
> +/**
> + * ioctl_querystd - V4L2 decoder interface handler for
> VIDIOC_QUERYSTD ioctl + * @s: pointer to standard V4L2 device
> structure
> + * @std_id: standard V4L2 std_id ioctl enum
> + *
> + * Returns the current standard detected by TVP5146/47. If no active
> input is + * detected, returns -EINVAL
> + */
> +static int ioctl_querystd(struct v4l2_int_device *s, v4l2_std_id
> *std_id) +{
> +	struct tvp514x_decoder *decoder = s->priv;
> +	enum tvp514x_std current_std;
> +	enum tvp514x_input input_sel;
> +	u8 sync_lock_status, lock_mask;
> +
> +	if (std_id == NULL)
> +		return -EINVAL;
> +
> +	/* get the current standard */
> +	current_std = tvp514x_get_current_std(decoder);
> +	if (current_std == STD_INVALID)
> +		return -EINVAL;
> +
> +	input_sel =
> decoder->pdata->input_list[decoder->inputidx].input_sel; +
> +	switch (input_sel) {
> +	case INPUT_CVBS_VI1A:
> +	case INPUT_CVBS_VI1B:
> +	case INPUT_CVBS_VI1C:
> +	case INPUT_CVBS_VI2A:
> +	case INPUT_CVBS_VI2B:
> +	case INPUT_CVBS_VI2C:
> +	case INPUT_CVBS_VI3A:
> +	case INPUT_CVBS_VI3B:
> +	case INPUT_CVBS_VI3C:
> +	case INPUT_CVBS_VI4A:
> +		lock_mask = STATUS_CLR_SUBCAR_LOCK_BIT |
> +			STATUS_HORZ_SYNC_LOCK_BIT |
> +			STATUS_VIRT_SYNC_LOCK_BIT;
> +		break;
> +
> +	case INPUT_SVIDEO_VI2A_VI1A:
> +	case INPUT_SVIDEO_VI2B_VI1B:
> +	case INPUT_SVIDEO_VI2C_VI1C:
> +	case INPUT_SVIDEO_VI2A_VI3A:
> +	case INPUT_SVIDEO_VI2B_VI3B:
> +	case INPUT_SVIDEO_VI2C_VI3C:
> +	case INPUT_SVIDEO_VI4A_VI1A:
> +	case INPUT_SVIDEO_VI4A_VI1B:
> +	case INPUT_SVIDEO_VI4A_VI1C:
> +	case INPUT_SVIDEO_VI4A_VI3A:
> +	case INPUT_SVIDEO_VI4A_VI3B:
> +	case INPUT_SVIDEO_VI4A_VI3C:
> +		lock_mask = STATUS_HORZ_SYNC_LOCK_BIT |
> +			STATUS_VIRT_SYNC_LOCK_BIT;
> +		break;
> +		/*Need to add other interfaces*/
> +	default:
> +		return -EINVAL;
> +	}
> +	/* check whether signal is locked */
> +	sync_lock_status = tvp514x_read_reg(decoder->client, REG_STATUS1);
> +	if (lock_mask != (sync_lock_status & lock_mask))
> +		return -EINVAL;	/* No input detected */
> +
> +	decoder->current_std = current_std;
> +	*std_id = decoder->std_list[current_std].standard.id;
> +
> +	v4l_dbg(1, debug, decoder->client, "Current STD: %s",
> +			decoder->std_list[current_std].standard.name);
> +	return 0;
> +}
> +
> +/**
> + * ioctl_s_std - V4L2 decoder interface handler for VIDIOC_S_STD
> ioctl + * @s: pointer to standard V4L2 device structure
> + * @std_id: standard V4L2 v4l2_std_id ioctl enum
> + *
> + * If std_id is supported, sets the requested standard. Otherwise,
> returns + * -EINVAL
> + */
> +static int ioctl_s_std(struct v4l2_int_device *s, v4l2_std_id
> *std_id) +{
> +	struct tvp514x_decoder *decoder = s->priv;
> +	int err, i;
> +
> +	if (std_id == NULL)
> +		return -EINVAL;
> +
> +	for (i = 0; i < decoder->num_stds; i++)
> +		if (*std_id & decoder->std_list[i].standard.id)
> +			break;
> +
> +	if ((i == decoder->num_stds) || (i == STD_INVALID))
> +		return -EINVAL;
> +
> +	err = tvp514x_write_reg(decoder->client, REG_VIDEO_STD,
> +				decoder->std_list[i].video_std);
> +	if (err)
> +		return err;
> +
> +	decoder->current_std = i;
> +	tvp514x_reg_list[REG_VIDEO_STD].val =
> decoder->std_list[i].video_std; +
> +	v4l_dbg(1, debug, decoder->client, "Standard set to: %s",
> +			decoder->std_list[i].standard.name);
> +	return 0;
> +}
> +
> +/**
> + * ioctl_s_routing - V4L2 decoder interface handler for
> VIDIOC_S_INPUT ioctl + * @s: pointer to standard V4L2 device
> structure
> + * @index: number of the input
> + *
> + * If index is valid, selects the requested input. Otherwise,
> returns -EINVAL if + * the input is not supported or there is no
> active signal present in the + * selected input.
> + */
> +static int ioctl_s_routing(struct v4l2_int_device *s, int index)
> +{
> +	struct tvp514x_decoder *decoder = s->priv;
> +	int err;
> +	enum tvp514x_input input_sel;
> +	enum tvp514x_std current_std = STD_INVALID;
> +	u8 sync_lock_status, lock_mask;
> +	int try_count = LOCK_RETRY_COUNT;
> +
> +	if ((index >= decoder->pdata->num_inputs) || (index < 0))
> +		return -EINVAL;	/* Index out of bound */
> +
> +	/* Get the register value to be written to select the requested
> input */ +	input_sel = decoder->pdata->input_list[index].input_sel;
> +	err = tvp514x_write_reg(decoder->client, REG_INPUT_SEL, input_sel);
> +	if (err)
> +		return err;
> +
> +	decoder->inputidx = index;
> +	tvp514x_reg_list[REG_INPUT_SEL].val = input_sel;
> +
> +	/* Clear status */
> +	msleep(LOCK_RETRY_DELAY);
> +	err =
> +	    tvp514x_write_reg(decoder->client, REG_CLEAR_LOST_LOCK, 0x01);
> +	if (err)
> +		return err;
> +
> +	switch (input_sel) {
> +	case INPUT_CVBS_VI1A:
> +	case INPUT_CVBS_VI1B:
> +	case INPUT_CVBS_VI1C:
> +	case INPUT_CVBS_VI2A:
> +	case INPUT_CVBS_VI2B:
> +	case INPUT_CVBS_VI2C:
> +	case INPUT_CVBS_VI3A:
> +	case INPUT_CVBS_VI3B:
> +	case INPUT_CVBS_VI3C:
> +	case INPUT_CVBS_VI4A:
> +		lock_mask = STATUS_CLR_SUBCAR_LOCK_BIT |
> +			STATUS_HORZ_SYNC_LOCK_BIT |
> +			STATUS_VIRT_SYNC_LOCK_BIT;
> +		break;
> +
> +	case INPUT_SVIDEO_VI2A_VI1A:
> +	case INPUT_SVIDEO_VI2B_VI1B:
> +	case INPUT_SVIDEO_VI2C_VI1C:
> +	case INPUT_SVIDEO_VI2A_VI3A:
> +	case INPUT_SVIDEO_VI2B_VI3B:
> +	case INPUT_SVIDEO_VI2C_VI3C:
> +	case INPUT_SVIDEO_VI4A_VI1A:
> +	case INPUT_SVIDEO_VI4A_VI1B:
> +	case INPUT_SVIDEO_VI4A_VI1C:
> +	case INPUT_SVIDEO_VI4A_VI3A:
> +	case INPUT_SVIDEO_VI4A_VI3B:
> +	case INPUT_SVIDEO_VI4A_VI3C:
> +		lock_mask = STATUS_HORZ_SYNC_LOCK_BIT |
> +			STATUS_VIRT_SYNC_LOCK_BIT;
> +		break;
> +	/*Need to add other interfaces*/
> +	default:
> +		return -EINVAL;
> +	}
> +
> +	while (try_count-- > 0) {
> +		/* Allow decoder to sync up with new input */
> +		msleep(LOCK_RETRY_DELAY);
> +
> +		/* get the current standard for future reference */
> +		current_std = tvp514x_get_current_std(decoder);
> +		if (current_std == STD_INVALID)
> +			continue;
> +
> +		sync_lock_status = tvp514x_read_reg(decoder->client,
> +				REG_STATUS1);
> +		if (lock_mask == (sync_lock_status & lock_mask))
> +			break;	/* Input detected */
> +	}
> +
> +	if ((current_std == STD_INVALID) || (try_count < 0))
> +		return -EINVAL;
> +
> +	decoder->current_std = current_std;
> +
> +	v4l_dbg(1, debug, decoder->client,
> +			"Input set to: index - %d (%s)",
> +			decoder->pdata->input_list[index].input.index,
> +			decoder->pdata->input_list[index].input.name);
> +	return 0;
> +}
> +
> +/**
> + * ioctl_g_routing - V4L2 decoder interface handler for
> VIDIOC_G_INPUT ioctl + * @s: pointer to standard V4L2 device
> structure
> + * @index: returns the current selected input
> + *
> + * Returns the current selected input. Returns -EINVAL if any error
> occurs + */
> +static int ioctl_g_routing(struct v4l2_int_device *s, int *index)
> +{
> +	struct tvp514x_decoder *decoder = s->priv;
> +	int err = -EINVAL, i, inputidx;
> +
> +	if (index == NULL)
> +		return err;
> +
> +	/* Search through the input list for active inputs */
> +	inputidx = decoder->inputidx;
> +	for (i = 0; i < decoder->pdata->num_inputs; i++) {
> +		inputidx++;	/* Move to next input */
> +		if (inputidx >= decoder->pdata->num_inputs)
> +			inputidx = 0;	/* fall back to first input */
> +
> +		err = ioctl_s_routing(s, inputidx);
> +		if (!err) {
> +			/* Active input found - select it and return success */
> +			*index = inputidx;
> +			return 0;
> +		}
> +	}
> +
> +	return err;
> +}
> +
> +/**
> + * ioctl_queryctrl - V4L2 decoder interface handler for
> VIDIOC_QUERYCTRL ioctl + * @s: pointer to standard V4L2 device
> structure
> + * @qc: standard V4L2 VIDIOC_QUERYCTRL ioctl structure
> + *
> + * If the requested control is supported, returns the control
> information + * from the ctrl_list[] array. Otherwise, returns
> -EINVAL if the + * control is not supported.
> + */
> +static int
> +ioctl_queryctrl(struct v4l2_int_device *s, struct v4l2_queryctrl
> *qctrl) +{
> +	struct tvp514x_decoder *decoder = s->priv;
> +	int id, index;
> +	const struct tvp514x_ctrl_info *control = NULL;
> +
> +	if (qctrl == NULL)
> +		return -EINVAL;
> +
> +	id = qctrl->id;
> +	memset(qctrl, 0, sizeof(struct v4l2_queryctrl));
> +	qctrl->id = id;
> +
> +	for (index = 0; index < decoder->num_ctrls; index++) {
> +		control = &decoder->ctrl_list[index];
> +		if (control->query_ctrl.id == qctrl->id)
> +			break;	/* Match found */
> +	}
> +	if (index == decoder->num_ctrls)
> +		return -EINVAL;	/* Index out of bound */
> +
> +	memcpy(qctrl, &control->query_ctrl, sizeof(struct v4l2_queryctrl));
> +
> +	v4l_dbg(1, debug, decoder->client,
> +			"Query Control: %s : Min - %d, Max - %d, Def - %d",
> +			control->query_ctrl.name,
> +			control->query_ctrl.minimum,
> +			control->query_ctrl.maximum,
> +			control->query_ctrl.default_value);
> +	return 0;
> +}
> +
> +/**
> + * ioctl_g_ctrl - V4L2 decoder interface handler for VIDIOC_G_CTRL
> ioctl + * @s: pointer to standard V4L2 device structure
> + * @vc: standard V4L2 VIDIOC_G_CTRL ioctl structure
> + *
> + * If the requested control is supported, returns the control's
> current + * value from the decoder. Otherwise, returns -EINVAL if the
> control is not + * supported.
> + */
> +static int
> +ioctl_g_ctrl(struct v4l2_int_device *s, struct v4l2_control *ctrl)
> +{
> +	struct tvp514x_decoder *decoder = s->priv;
> +	int index, value;
> +	const struct tvp514x_ctrl_info *control = NULL;
> +
> +	if (ctrl == NULL)
> +		return -EINVAL;
> +
> +	for (index = 0; index < decoder->num_ctrls; index++) {
> +		control = &decoder->ctrl_list[index];
> +		if (control->query_ctrl.id == ctrl->id)
> +			break;	/* Match found */
> +	}
> +	if (index == decoder->num_ctrls)
> +		return -EINVAL;	/* Index out of bound */
> +
> +	value =
> +	    tvp514x_read_reg(decoder->client, control->reg_address);
> +
> +	/* cross check */
> +	if (value != tvp514x_reg_list[control->reg_address].val)
> +		return -EINVAL;	/* Driver & TVP5146/47 setting mismatch */
> +
> +	if (V4L2_CID_AUTOGAIN == ctrl->id) {
> +		if ((value & 0x3) == 3)
> +			value = 1;
> +		else
> +			value = 0;
> +	}
> +
> +	if (V4L2_CID_HUE == ctrl->id) {
> +		if (value == 0x7F)
> +			value = 180;
> +		else if (value == 0x80)
> +			value = -180;
> +		else
> +			value = 0;
> +	}
> +
> +	ctrl->value = value;
> +
> +	v4l_dbg(1, debug, decoder->client,
> +			"Get Cotrol: %s - %d",
> +			control->query_ctrl.name, value);
> +	return 0;
> +}
> +
> +/**
> + * ioctl_s_ctrl - V4L2 decoder interface handler for VIDIOC_S_CTRL
> ioctl + * @s: pointer to standard V4L2 device structure
> + * @vc: standard V4L2 VIDIOC_S_CTRL ioctl structure
> + *
> + * If the requested control is supported, sets the control's current
> + * value in HW. Otherwise, returns -EINVAL if the control is not
> supported. + */
> +static int
> +ioctl_s_ctrl(struct v4l2_int_device *s, struct v4l2_control *ctrl)
> +{
> +	struct tvp514x_decoder *decoder = s->priv;
> +	int err, value, index;
> +	const struct tvp514x_ctrl_info *control = NULL;
> +
> +	if (ctrl == NULL)
> +		return -EINVAL;
> +
> +	value = (__s32) ctrl->value;
> +	for (index = 0; index < decoder->num_ctrls; index++) {
> +		control = &decoder->ctrl_list[index];
> +		if (control->query_ctrl.id == ctrl->id)
> +			break;	/* Match found */
> +	}
> +	if (index == decoder->num_ctrls)
> +		return -EINVAL;	/* Index out of bound */
> +
> +	if (V4L2_CID_AUTOGAIN == ctrl->id) {
> +		if (value == 1)
> +			value = 0x0F;
> +		else if (value == 0)
> +			value = 0x0C;
> +		else
> +			return -ERANGE;
> +	} else if (V4L2_CID_HUE == ctrl->id) {
> +		if (value == 180)
> +			value = 0x7F;
> +		else if (value == -180)
> +			value = 0x80;
> +		else if (value == 0)
> +			value = 0;
> +		else
> +			return -ERANGE;
> +	} else {
> +		if ((value < control->query_ctrl.minimum)
> +			|| (value > control->query_ctrl.maximum))
> +			return -ERANGE;
> +	}
> +
> +	err =
> +	    tvp514x_write_reg(decoder->client, control->reg_address,
> +				value);
> +	if (err)
> +		return err;
> +
> +	tvp514x_reg_list[control->reg_address].val = value;
> +
> +	v4l_dbg(1, debug, decoder->client,
> +			"Set Cotrol: %s - %d",
> +			control->query_ctrl.name, value);
> +	return err;
> +}
> +
> +/**
> + * ioctl_enum_fmt_cap - Implement the CAPTURE buffer VIDIOC_ENUM_FMT
> ioctl + * @s: pointer to standard V4L2 device structure
> + * @fmt: standard V4L2 VIDIOC_ENUM_FMT ioctl structure
> + *
> + * Implement the VIDIOC_ENUM_FMT ioctl to enumerate supported
> formats + */
> +static int
> +ioctl_enum_fmt_cap(struct v4l2_int_device *s, struct v4l2_fmtdesc
> *fmt) +{
> +	struct tvp514x_decoder *decoder = s->priv;
> +	int index;
> +
> +	if (fmt == NULL)
> +		return -EINVAL;
> +
> +	index = fmt->index;
> +	if ((index >= decoder->num_fmts) || (index < 0))
> +		return -EINVAL;	/* Index out of bound */
> +
> +	if (fmt->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
> +		return -EINVAL;	/* only capture is supported */
> +
> +	memcpy(fmt, &decoder->fmt_list[index],
> +		sizeof(struct v4l2_fmtdesc));
> +
> +	v4l_dbg(1, debug, decoder->client,
> +			"Current FMT: index - %d (%s)",
> +			decoder->fmt_list[index].index,
> +			decoder->fmt_list[index].description);
> +	return 0;
> +}
> +
> +/**
> + * ioctl_try_fmt_cap - Implement the CAPTURE buffer VIDIOC_TRY_FMT
> ioctl + * @s: pointer to standard V4L2 device structure
> + * @f: pointer to standard V4L2 VIDIOC_TRY_FMT ioctl structure
> + *
> + * Implement the VIDIOC_TRY_FMT ioctl for the CAPTURE buffer type.
> This + * ioctl is used to negotiate the image capture size and pixel
> format + * without actually making it take effect.
> + */
> +static int
> +ioctl_try_fmt_cap(struct v4l2_int_device *s, struct v4l2_format *f)
> +{
> +	struct tvp514x_decoder *decoder = s->priv;
> +	int ifmt;
> +	struct v4l2_pix_format *pix;
> +	enum tvp514x_std current_std;
> +
> +	if (f == NULL)
> +		return -EINVAL;
> +
> +	if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
> +		f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
> +
> +	pix = &f->fmt.pix;
> +
> +	/* Calculate height and width based on current standard */
> +	current_std = tvp514x_get_current_std(decoder);
> +	if (current_std == STD_INVALID)
> +		return -EINVAL;
> +
> +	decoder->current_std = current_std;
> +	pix->width = decoder->std_list[current_std].width;
> +	pix->height = decoder->std_list[current_std].height;
> +
> +	for (ifmt = 0; ifmt < decoder->num_fmts; ifmt++) {
> +		if (pix->pixelformat ==
> +			decoder->fmt_list[ifmt].pixelformat)
> +			break;
> +	}
> +	if (ifmt == decoder->num_fmts)
> +		ifmt = 0;	/* None of the format matched, select default */
> +	pix->pixelformat = decoder->fmt_list[ifmt].pixelformat;
> +
> +	pix->field = V4L2_FIELD_INTERLACED;
> +	pix->bytesperline = pix->width * 2;
> +	pix->sizeimage = pix->bytesperline * pix->height;
> +	pix->colorspace = V4L2_COLORSPACE_SMPTE170M;
> +	pix->priv = 0;
> +
> +	v4l_dbg(1, debug, decoder->client,
> +			"Try FMT: pixelformat - %s, bytesperline - %d"
> +			"Width - %d, Height - %d",
> +			decoder->fmt_list[ifmt].description, pix->bytesperline,
> +			pix->width, pix->height);
> +	return 0;
> +}
> +
> +/**
> + * ioctl_s_fmt_cap - V4L2 decoder interface handler for VIDIOC_S_FMT
> ioctl + * @s: pointer to standard V4L2 device structure
> + * @f: pointer to standard V4L2 VIDIOC_S_FMT ioctl structure
> + *
> + * If the requested format is supported, configures the HW to use
> that + * format, returns error code if format not supported or HW
> can't be + * correctly configured.
> + */
> +static int
> +ioctl_s_fmt_cap(struct v4l2_int_device *s, struct v4l2_format *f)
> +{
> +	struct tvp514x_decoder *decoder = s->priv;
> +	struct v4l2_pix_format *pix;
> +	int rval;
> +
> +	if (f == NULL)
> +		return -EINVAL;
> +
> +	if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
> +		return -EINVAL;	/* only capture is supported */
> +
> +	pix = &f->fmt.pix;
> +	rval = ioctl_try_fmt_cap(s, f);
> +	if (rval)
> +		return rval;
> +	else
> +		decoder->pix = *pix;
> +
> +	return rval;
> +}
> +
> +/**
> + * ioctl_g_fmt_cap - V4L2 decoder interface handler for
> ioctl_g_fmt_cap + * @s: pointer to standard V4L2 device structure
> + * @f: pointer to standard V4L2 v4l2_format structure
> + *
> + * Returns the decoder's current pixel format in the v4l2_format
> + * parameter.
> + */
> +static int
> +ioctl_g_fmt_cap(struct v4l2_int_device *s, struct v4l2_format *f)
> +{
> +	struct tvp514x_decoder *decoder = s->priv;
> +
> +	if (f == NULL)
> +		return -EINVAL;
> +
> +	if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
> +		return -EINVAL;	/* only capture is supported */
> +
> +	f->fmt.pix = decoder->pix;
> +
> +	v4l_dbg(1, debug, decoder->client,
> +			"Current FMT: bytesperline - %d"
> +			"Width - %d, Height - %d",
> +			decoder->pix.bytesperline,
> +			decoder->pix.width, decoder->pix.height);
> +	return 0;
> +}
> +
> +/**
> + * ioctl_g_parm - V4L2 decoder interface handler for VIDIOC_G_PARM
> ioctl + * @s: pointer to standard V4L2 device structure
> + * @a: pointer to standard V4L2 VIDIOC_G_PARM ioctl structure
> + *
> + * Returns the decoder's video CAPTURE parameters.
> + */
> +static int
> +ioctl_g_parm(struct v4l2_int_device *s, struct v4l2_streamparm *a)
> +{
> +	struct tvp514x_decoder *decoder = s->priv;
> +	struct v4l2_captureparm *cparm;
> +	enum tvp514x_std current_std;
> +
> +	if (a == NULL)
> +		return -EINVAL;
> +
> +	if (a->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
> +		return -EINVAL;	/* only capture is supported */
> +
> +	memset(a, 0, sizeof(*a));
> +	a->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
> +
> +	/* get the current standard */
> +	current_std = tvp514x_get_current_std(decoder);
> +	if (current_std == STD_INVALID)
> +		return -EINVAL;
> +
> +	decoder->current_std = current_std;
> +
> +	cparm = &a->parm.capture;
> +	cparm->capability = V4L2_CAP_TIMEPERFRAME;
> +	cparm->timeperframe =
> +		decoder->std_list[current_std].standard.frameperiod;
> +
> +	return 0;
> +}
> +
> +/**
> + * ioctl_s_parm - V4L2 decoder interface handler for VIDIOC_S_PARM
> ioctl + * @s: pointer to standard V4L2 device structure
> + * @a: pointer to standard V4L2 VIDIOC_S_PARM ioctl structure
> + *
> + * Configures the decoder to use the input parameters, if possible.
> If + * not possible, returns the appropriate error code.
> + */
> +static int
> +ioctl_s_parm(struct v4l2_int_device *s, struct v4l2_streamparm *a)
> +{
> +	struct tvp514x_decoder *decoder = s->priv;
> +	struct v4l2_fract *timeperframe;
> +	enum tvp514x_std current_std;
> +
> +	if (a == NULL)
> +		return -EINVAL;
> +
> +	if (a->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
> +		return -EINVAL;	/* only capture is supported */
> +
> +	timeperframe = &a->parm.capture.timeperframe;
> +
> +	/* get the current standard */
> +	current_std = tvp514x_get_current_std(decoder);
> +	if (current_std == STD_INVALID)
> +		return -EINVAL;
> +
> +	decoder->current_std = current_std;
> +
> +	*timeperframe =
> +	    decoder->std_list[current_std].standard.frameperiod;
> +
> +	return 0;
> +}
> +
> +/**
> + * ioctl_g_ifparm - V4L2 decoder interface handler for
> vidioc_int_g_ifparm_num + * @s: pointer to standard V4L2 device
> structure
> + * @p: pointer to standard V4L2 vidioc_int_g_ifparm_num ioctl
> structure + *
> + * Gets slave interface parameters.
> + * Calculates the required xclk value to support the requested
> + * clock parameters in p. This value is returned in the p
> + * parameter.
> + */
> +static int ioctl_g_ifparm(struct v4l2_int_device *s, struct
> v4l2_ifparm *p) +{
> +	struct tvp514x_decoder *decoder = s->priv;
> +	int rval;
> +
> +	if (p == NULL)
> +		return -EINVAL;
> +
> +	if (NULL == decoder->pdata->ifparm)
> +		return -EINVAL;
> +
> +	rval = decoder->pdata->ifparm(p);
> +	if (rval) {
> +		v4l_err(decoder->client, "g_ifparm.Err[%d]\n", rval);
> +		return rval;
> +	}
> +
> +	p->u.bt656.clock_curr = TVP514X_XCLK_BT656;
> +
> +	return 0;
> +}
> +
> +/**
> + * ioctl_g_priv - V4L2 decoder interface handler for
> vidioc_int_g_priv_num + * @s: pointer to standard V4L2 device
> structure
> + * @p: void pointer to hold decoder's private data address
> + *
> + * Returns device's (decoder's) private data area address in p
> parameter + */
> +static int ioctl_g_priv(struct v4l2_int_device *s, void *p)
> +{
> +	struct tvp514x_decoder *decoder = s->priv;
> +
> +	if (NULL == decoder->pdata->priv_data_set)
> +		return -EINVAL;
> +
> +	return decoder->pdata->priv_data_set(p);
> +}
> +
> +/**
> + * ioctl_s_power - V4L2 decoder interface handler for
> vidioc_int_s_power_num + * @s: pointer to standard V4L2 device
> structure
> + * @on: power state to which device is to be set
> + *
> + * Sets devices power state to requrested state, if possible.
> + */
> +static int ioctl_s_power(struct v4l2_int_device *s, enum v4l2_power
> on) +{
> +	struct tvp514x_decoder *decoder = s->priv;
> +	int err = 0;
> +
> +	switch (on) {
> +	case V4L2_POWER_OFF:
> +		/* Power Down Sequence */
> +		err =
> +		    tvp514x_write_reg(decoder->client, REG_OPERATION_MODE,
> +					0x01);
> +		/* Disable mux for TVP5146/47 decoder data path */
> +		if (decoder->pdata->power_set)
> +			err |= decoder->pdata->power_set(on);
> +		decoder->state = STATE_NOT_DETECTED;
> +		break;
> +
> +	case V4L2_POWER_STANDBY:
> +		if (decoder->pdata->power_set)
> +			err = decoder->pdata->power_set(on);
> +		break;
> +
> +	case V4L2_POWER_ON:
> +		/* Enable mux for TVP5146/47 decoder data path */
> +		if ((decoder->pdata->power_set) &&
> +				(decoder->state == STATE_NOT_DETECTED)) {
> +			int i;
> +			struct tvp514x_init_seq *int_seq =
> +				(struct tvp514x_init_seq *)
> +				decoder->id->driver_data;
> +
> +			err = decoder->pdata->power_set(on);
> +
> +			/* Power Up Sequence */
> +			for (i = 0; i < int_seq->no_regs; i++) {
> +				err |= tvp514x_write_reg(decoder->client,
> +						int_seq->init_reg_seq[i].reg,
> +						int_seq->init_reg_seq[i].val);
> +			}
> +			/* Detect the sensor is not already detected */
> +			err |= tvp514x_detect(decoder);
> +			if (err) {
> +				v4l_err(decoder->client,
> +						"Unable to detect decoder\n");
> +				return err;
> +			}
> +		}
> +		err |= tvp514x_configure(decoder);
> +		break;
> +
> +	default:
> +		err = -ENODEV;
> +		break;
> +	}
> +
> +	return err;
> +}
> +
> +/**
> + * ioctl_init - V4L2 decoder interface handler for VIDIOC_INT_INIT
> + * @s: pointer to standard V4L2 device structure
> + *
> + * Initialize the decoder device (calls tvp514x_configure())
> + */
> +static int ioctl_init(struct v4l2_int_device *s)
> +{
> +	struct tvp514x_decoder *decoder = s->priv;
> +
> +	/* Set default standard to auto */
> +	tvp514x_reg_list[REG_VIDEO_STD].val =
> +	    VIDEO_STD_AUTO_SWITCH_BIT;
> +
> +	return tvp514x_configure(decoder);
> +}
> +
> +/**
> + * ioctl_dev_exit - V4L2 decoder interface handler for
> vidioc_int_dev_exit_num + * @s: pointer to standard V4L2 device
> structure
> + *
> + * Delinitialise the dev. at slave detach. The complement of
> ioctl_dev_init. + */
> +static int ioctl_dev_exit(struct v4l2_int_device *s)
> +{
> +	return 0;
> +}
> +
> +/**
> + * ioctl_dev_init - V4L2 decoder interface handler for
> vidioc_int_dev_init_num + * @s: pointer to standard V4L2 device
> structure
> + *
> + * Initialise the device when slave attaches to the master. Returns
> 0 if + * TVP5146/47 device could be found, otherwise returns
> appropriate error. + */
> +static int ioctl_dev_init(struct v4l2_int_device *s)
> +{
> +	struct tvp514x_decoder *decoder = s->priv;
> +	int err;
> +
> +	err = tvp514x_detect(decoder);
> +	if (err < 0) {
> +		v4l_err(decoder->client,
> +			"Unable to detect decoder\n");
> +		return err;
> +	}
> +
> +	v4l_info(decoder->client,
> +		 "chip version 0x%.2x detected\n", decoder->ver);
> +
> +	return 0;
> +}
> +
> +static struct v4l2_int_ioctl_desc tvp514x_ioctl_desc[] = {
> +	{vidioc_int_dev_init_num, (v4l2_int_ioctl_func*) ioctl_dev_init},
> +	{vidioc_int_dev_exit_num, (v4l2_int_ioctl_func*) ioctl_dev_exit},
> +	{vidioc_int_s_power_num, (v4l2_int_ioctl_func*) ioctl_s_power},
> +	{vidioc_int_g_priv_num, (v4l2_int_ioctl_func*) ioctl_g_priv},
> +	{vidioc_int_g_ifparm_num, (v4l2_int_ioctl_func*) ioctl_g_ifparm},
> +	{vidioc_int_init_num, (v4l2_int_ioctl_func*) ioctl_init},
> +	{vidioc_int_enum_fmt_cap_num,
> +	 (v4l2_int_ioctl_func *) ioctl_enum_fmt_cap},
> +	{vidioc_int_try_fmt_cap_num,
> +	 (v4l2_int_ioctl_func *) ioctl_try_fmt_cap},
> +	{vidioc_int_g_fmt_cap_num,
> +	 (v4l2_int_ioctl_func *) ioctl_g_fmt_cap},
> +	{vidioc_int_s_fmt_cap_num,
> +	 (v4l2_int_ioctl_func *) ioctl_s_fmt_cap},
> +	{vidioc_int_g_parm_num, (v4l2_int_ioctl_func *) ioctl_g_parm},
> +	{vidioc_int_s_parm_num, (v4l2_int_ioctl_func *) ioctl_s_parm},
> +	{vidioc_int_queryctrl_num,
> +	 (v4l2_int_ioctl_func *) ioctl_queryctrl},
> +	{vidioc_int_g_ctrl_num, (v4l2_int_ioctl_func *) ioctl_g_ctrl},
> +	{vidioc_int_s_ctrl_num, (v4l2_int_ioctl_func *) ioctl_s_ctrl},
> +	{vidioc_int_querystd_num, (v4l2_int_ioctl_func *) ioctl_querystd},
> +	{vidioc_int_s_std_num, (v4l2_int_ioctl_func *) ioctl_s_std},
> +	{vidioc_int_g_video_routing_num,
> +		(v4l2_int_ioctl_func *) ioctl_g_routing},
> +	{vidioc_int_s_video_routing_num,
> +		(v4l2_int_ioctl_func *) ioctl_s_routing},
> +};
> +
> +static struct v4l2_int_slave tvp514x_slave = {
> +	.ioctls = tvp514x_ioctl_desc,
> +	.num_ioctls = ARRAY_SIZE(tvp514x_ioctl_desc),
> +};
> +
> +static struct tvp514x_decoder tvp514x_dev = {
> +	.state = STATE_NOT_DETECTED,
> +
> +	.num_fmts = TVP514X_NUM_FORMATS,
> +	.fmt_list = tvp514x_fmt_list,
> +
> +	.pix = {		/* Default to NTSC 8-bit YUV 422 */
> +		.width = NTSC_NUM_ACTIVE_PIXELS,
> +		.height = NTSC_NUM_ACTIVE_LINES,
> +		.pixelformat = V4L2_PIX_FMT_UYVY,
> +		.field = V4L2_FIELD_INTERLACED,
> +		.bytesperline = NTSC_NUM_ACTIVE_PIXELS * 2,
> +		.sizeimage =
> +		NTSC_NUM_ACTIVE_PIXELS * 2 * NTSC_NUM_ACTIVE_LINES,
> +		.colorspace = V4L2_COLORSPACE_SMPTE170M,
> +		},
> +
> +	.current_std = STD_NTSC_MJ,
> +	.num_stds = TVP514X_NUM_STANDARDS,
> +	.std_list = tvp514x_std_list,
> +
> +	.num_ctrls = TVP514X_NUM_CONTROLS,
> +	.ctrl_list = tvp514x_ctrl_list,
> +
> +};
> +
> +static struct v4l2_int_device tvp514x_int_device = {
> +	.module = THIS_MODULE,
> +	.name = MODULE_NAME,
> +	.priv = &tvp514x_dev,
> +	.type = v4l2_int_type_slave,
> +	.u = {
> +	      .slave = &tvp514x_slave,
> +	      },
> +};
> +
> +/**
> + * tvp514x_probe - decoder driver i2c probe handler
> + * @client: i2c driver client device structure
> + *
> + * Register decoder as an i2c client device and V4L2
> + * device.
> + */
> +static int
> +tvp514x_probe(struct i2c_client *client, const struct i2c_device_id
> *id) +{
> +	struct tvp514x_decoder *decoder = &tvp514x_dev;
> +	int err;
> +
> +	/* Check if the adapter supports the needed features */
> +	if (!i2c_check_functionality(client->adapter,
> I2C_FUNC_SMBUS_BYTE_DATA)) +		return -EIO;
> +
> +	decoder->pdata = client->dev.platform_data;
> +	if (!decoder->pdata) {
> +		v4l_err(client, "No platform data\n!!");
> +		return -ENODEV;
> +	}
> +	/*
> +	 * Fetch platform specific data, and configure the
> +	 * tvp514x_reg_list[] accordingly. Since this is one
> +	 * time configuration, no need to preserve.
> +	 */
> +	decoder->inputidx = decoder->pdata->default_input;
> +	tvp514x_reg_list[REG_OUTPUT_FORMATTER2].val |=
> +			(decoder->pdata->clk_polarity << 1);
> +	tvp514x_reg_list[REG_OUTPUT_FORMATTER1].val |=
> +			decoder->pdata->fmt;
> +	tvp514x_reg_list[REG_SYNC_CONTROL].val |=
> +			((decoder->pdata->hs_polarity << 2) |
> +			(decoder->pdata->vs_polarity << 3));
> +	/*
> +	 * Save the id data, required for power up sequence
> +	 */
> +	decoder->id = (struct i2c_device_id *)id;
> +	/* Attach to Master */
> +	strcpy(tvp514x_int_device.u.slave->attach_to,
> decoder->pdata->master); +	decoder->v4l2_int_device =
> &tvp514x_int_device;
> +	decoder->client = client;
> +	i2c_set_clientdata(client, decoder);
> +
> +	/* Register with V4L2 layer as slave device */
> +	err = v4l2_int_device_register(decoder->v4l2_int_device);
> +	if (err) {
> +		i2c_set_clientdata(client, NULL);
> +		v4l_err(client,
> +			"Unable to register to v4l2. Err[%d]\n", err);
> +
> +	} else
> +		v4l_info(client, "Registered to v4l2 master %s!!\n",
> +				decoder->pdata->master);
> +
> +	return 0;
> +}
> +
> +/**
> + * tvp514x_remove - decoder driver i2c remove handler
> + * @client: i2c driver client device structure
> + *
> + * Unregister decoder as an i2c client device and V4L2
> + * device. Complement of tvp514x_probe().
> + */
> +static int __exit tvp514x_remove(struct i2c_client *client)
> +{
> +	struct tvp514x_decoder *decoder = i2c_get_clientdata(client);
> +
> +	if (!client->adapter)
> +		return -ENODEV;	/* our client isn't attached */
> +
> +	v4l2_int_device_unregister(decoder->v4l2_int_device);
> +	i2c_set_clientdata(client, NULL);
> +
> +	return 0;
> +}
> +/*
> + * TVP5146 Init/Power on Sequence
> + */
> +static struct tvp514x_reg tvp5146_init_reg_seq[] = {
> +	{TOK_WRITE, REG_VBUS_ADDRESS_ACCESS1, 0x02},
> +	{TOK_WRITE, REG_VBUS_ADDRESS_ACCESS2, 0x00},
> +	{TOK_WRITE, REG_VBUS_ADDRESS_ACCESS3, 0x80},
> +	{TOK_WRITE, REG_VBUS_DATA_ACCESS_NO_VBUS_ADDR_INCR, 0x01},
> +	{TOK_WRITE, REG_VBUS_ADDRESS_ACCESS1, 0x60},
> +	{TOK_WRITE, REG_VBUS_ADDRESS_ACCESS2, 0x00},
> +	{TOK_WRITE, REG_VBUS_ADDRESS_ACCESS3, 0xB0},
> +	{TOK_WRITE, REG_VBUS_DATA_ACCESS_NO_VBUS_ADDR_INCR, 0x01},
> +	{TOK_WRITE, REG_VBUS_DATA_ACCESS_NO_VBUS_ADDR_INCR, 0x00},
> +	{TOK_WRITE, REG_OPERATION_MODE, 0x01},
> +	{TOK_WRITE, REG_OPERATION_MODE, 0x00},
> +};
> +static struct tvp514x_init_seq tvp5146_init = {
> +	.no_regs = ARRAY_SIZE(tvp5146_init_reg_seq),
> +	.init_reg_seq = tvp5146_init_reg_seq,
> +};
> +/*
> + * TVP5147 Init/Power on Sequence
> + */
> +static struct tvp514x_reg tvp5147_init_reg_seq[] =	{
> +	{TOK_WRITE, REG_VBUS_ADDRESS_ACCESS1, 0x02},
> +	{TOK_WRITE, REG_VBUS_ADDRESS_ACCESS2, 0x00},
> +	{TOK_WRITE, REG_VBUS_ADDRESS_ACCESS3, 0x80},
> +	{TOK_WRITE, REG_VBUS_DATA_ACCESS_NO_VBUS_ADDR_INCR, 0x01},
> +	{TOK_WRITE, REG_VBUS_ADDRESS_ACCESS1, 0x60},
> +	{TOK_WRITE, REG_VBUS_ADDRESS_ACCESS2, 0x00},
> +	{TOK_WRITE, REG_VBUS_ADDRESS_ACCESS3, 0xB0},
> +	{TOK_WRITE, REG_VBUS_DATA_ACCESS_NO_VBUS_ADDR_INCR, 0x01},
> +	{TOK_WRITE, REG_VBUS_ADDRESS_ACCESS1, 0x16},
> +	{TOK_WRITE, REG_VBUS_ADDRESS_ACCESS2, 0x00},
> +	{TOK_WRITE, REG_VBUS_ADDRESS_ACCESS3, 0xA0},
> +	{TOK_WRITE, REG_VBUS_DATA_ACCESS_NO_VBUS_ADDR_INCR, 0x16},
> +	{TOK_WRITE, REG_VBUS_ADDRESS_ACCESS1, 0x60},
> +	{TOK_WRITE, REG_VBUS_ADDRESS_ACCESS2, 0x00},
> +	{TOK_WRITE, REG_VBUS_ADDRESS_ACCESS3, 0xB0},
> +	{TOK_WRITE, REG_VBUS_DATA_ACCESS_NO_VBUS_ADDR_INCR, 0x00},
> +	{TOK_WRITE, REG_OPERATION_MODE, 0x01},
> +	{TOK_WRITE, REG_OPERATION_MODE, 0x00},
> +};
> +static struct tvp514x_init_seq tvp5147_init = {
> +	.no_regs = ARRAY_SIZE(tvp5147_init_reg_seq),
> +	.init_reg_seq = tvp5147_init_reg_seq,
> +};
> +/*
> + * TVP5146M2/TVP5147M1 Init/Power on Sequence
> + */
> +static struct tvp514x_reg tvp514xm_init_reg_seq[] = {
> +	{TOK_WRITE, REG_OPERATION_MODE, 0x01},
> +	{TOK_WRITE, REG_OPERATION_MODE, 0x00},
> +};
> +static struct tvp514x_init_seq tvp514xm_init = {
> +	.no_regs = ARRAY_SIZE(tvp514xm_init_reg_seq),
> +	.init_reg_seq = tvp514xm_init_reg_seq,
> +};
> +/*
> + * I2C Device Table -
> + *
> + * name - Name of the actual device/chip.
> + * driver_data - Driver data
> + */
> +static const struct i2c_device_id tvp514x_id[] = {
> +	{"tvp5146", (unsigned int)&tvp5146_init},
> +	{"tvp5146m2", (unsigned int)&tvp514xm_init},
> +	{"tvp5147", (unsigned int)&tvp5147_init},
> +	{"tvp5147m1", (unsigned int)&tvp514xm_init},
> +	{},
> +};
> +
> +MODULE_DEVICE_TABLE(i2c, tvp514x_id);
> +
> +static struct i2c_driver tvp514x_i2c_driver = {
> +	.driver = {
> +		   .name = MODULE_NAME,
> +		   .owner = THIS_MODULE,
> +		   },
> +	.probe = tvp514x_probe,
> +	.remove = __exit_p(tvp514x_remove),
> +	.id_table = tvp514x_id,
> +};
> +
> +/**
> + * tvp514x_init
> + *
> + * Module init function
> + */
> +static int __init tvp514x_init(void)
> +{
> +	int err;
> +
> +	err = i2c_add_driver(&tvp514x_i2c_driver);
> +	if (err) {
> +		printk(KERN_ERR "Failed to register " MODULE_NAME ".\n");
> +		return err;
> +	}
> +	return 0;
> +}
> +
> +/**
> + * tvp514x_cleanup
> + *
> + * Module exit function
> + */
> +static void __exit tvp514x_cleanup(void)
> +{
> +	i2c_del_driver(&tvp514x_i2c_driver);
> +}
> +
> +module_init(tvp514x_init);
> +module_exit(tvp514x_cleanup);
> +
> +MODULE_AUTHOR("Texas Instruments");
> +MODULE_DESCRIPTION("TVP514X linux decoder driver");
> +MODULE_LICENSE("GPL");
> diff --git a/drivers/media/video/tvp514x_regs.h
> b/drivers/media/video/tvp514x_regs.h new file mode 100755
> index 0000000..003a3c1
> --- /dev/null
> +++ b/drivers/media/video/tvp514x_regs.h
> @@ -0,0 +1,292 @@
> +/*
> + * drivers/media/video/tvp514x_regs.h
> + *
> + * Copyright (C) 2008 Texas Instruments Inc
> + * Author: Vaibhav Hiremath <hvaibhav@ti.com>
> + *
> + * Contributors:
> + *     Sivaraj R <sivaraj@ti.com>
> + *     Brijesh R Jadav <brijesh.j@ti.com>
> + *     Hardik Shah <hardik.shah@ti.com>
> + *     Manjunath Hadli <mrh@ti.com>
> + *     Karicheri Muralidharan <m-karicheri2@ti.com>
> + *
> + * This package is free software; you can redistribute it and/or
> modify + * it under the terms of the GNU General Public License
> version 2 as + * published by the Free Software Foundation.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program; if not, write to the Free Software
> + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
> + *
> + */
> +
> +#ifndef _TVP514X_REGS_H
> +#define _TVP514X_REGS_H
> +
> +/*
> + * TVP5146/47 registers
> + */
> +#define REG_INPUT_SEL			(0x00)
> +#define REG_AFE_GAIN_CTRL		(0x01)
> +#define REG_VIDEO_STD			(0x02)
> +#define REG_OPERATION_MODE		(0x03)
> +#define REG_AUTOSWITCH_MASK		(0x04)
> +
> +#define REG_COLOR_KILLER		(0x05)
> +#define REG_LUMA_CONTROL1		(0x06)
> +#define REG_LUMA_CONTROL2		(0x07)
> +#define REG_LUMA_CONTROL3		(0x08)
> +
> +#define REG_BRIGHTNESS			(0x09)
> +#define REG_CONTRAST			(0x0A)
> +#define REG_SATURATION			(0x0B)
> +#define REG_HUE				(0x0C)
> +
> +#define REG_CHROMA_CONTROL1		(0x0D)
> +#define REG_CHROMA_CONTROL2		(0x0E)
> +
> +/* 0x0F Reserved */
> +
> +#define REG_COMP_PR_SATURATION		(0x10)
> +#define REG_COMP_Y_CONTRAST		(0x11)
> +#define REG_COMP_PB_SATURATION		(0x12)
> +
> +/* 0x13 Reserved */
> +
> +#define REG_COMP_Y_BRIGHTNESS		(0x14)
> +
> +/* 0x15 Reserved */
> +
> +#define REG_AVID_START_PIXEL_LSB	(0x16)
> +#define REG_AVID_START_PIXEL_MSB	(0x17)
> +#define REG_AVID_STOP_PIXEL_LSB		(0x18)
> +#define REG_AVID_STOP_PIXEL_MSB		(0x19)
> +
> +#define REG_HSYNC_START_PIXEL_LSB	(0x1A)
> +#define REG_HSYNC_START_PIXEL_MSB	(0x1B)
> +#define REG_HSYNC_STOP_PIXEL_LSB	(0x1C)
> +#define REG_HSYNC_STOP_PIXEL_MSB	(0x1D)
> +
> +#define REG_VSYNC_START_LINE_LSB	(0x1E)
> +#define REG_VSYNC_START_LINE_MSB	(0x1F)
> +#define REG_VSYNC_STOP_LINE_LSB		(0x20)
> +#define REG_VSYNC_STOP_LINE_MSB		(0x21)
> +
> +#define REG_VBLK_START_LINE_LSB		(0x22)
> +#define REG_VBLK_START_LINE_MSB		(0x23)
> +#define REG_VBLK_STOP_LINE_LSB		(0x24)
> +#define REG_VBLK_STOP_LINE_MSB		(0x25)
> +
> +/* 0x26 - 0x27 Reserved */
> +
> +#define REG_FAST_SWTICH_CONTROL		(0x28)
> +
> +/* 0x29 Reserved */
> +
> +#define REG_FAST_SWTICH_SCART_DELAY	(0x2A)
> +
> +/* 0x2B Reserved */
> +
> +#define REG_SCART_DELAY			(0x2C)
> +#define REG_CTI_DELAY			(0x2D)
> +#define REG_CTI_CONTROL			(0x2E)
> +
> +/* 0x2F - 0x31 Reserved */
> +
> +#define REG_SYNC_CONTROL		(0x32)
> +#define REG_OUTPUT_FORMATTER1		(0x33)
> +#define REG_OUTPUT_FORMATTER2		(0x34)
> +#define REG_OUTPUT_FORMATTER3		(0x35)
> +#define REG_OUTPUT_FORMATTER4		(0x36)
> +#define REG_OUTPUT_FORMATTER5		(0x37)
> +#define REG_OUTPUT_FORMATTER6		(0x38)
> +#define REG_CLEAR_LOST_LOCK		(0x39)
> +
> +#define REG_STATUS1			(0x3A)
> +#define REG_STATUS2			(0x3B)
> +
> +#define REG_AGC_GAIN_STATUS_LSB		(0x3C)
> +#define REG_AGC_GAIN_STATUS_MSB		(0x3D)
> +
> +/* 0x3E Reserved */
> +
> +#define REG_VIDEO_STD_STATUS		(0x3F)
> +#define REG_GPIO_INPUT1			(0x40)
> +#define REG_GPIO_INPUT2			(0x41)
> +
> +/* 0x42 - 0x45 Reserved */
> +
> +#define REG_AFE_COARSE_GAIN_CH1		(0x46)
> +#define REG_AFE_COARSE_GAIN_CH2		(0x47)
> +#define REG_AFE_COARSE_GAIN_CH3		(0x48)
> +#define REG_AFE_COARSE_GAIN_CH4		(0x49)
> +
> +#define REG_AFE_FINE_GAIN_PB_B_LSB	(0x4A)
> +#define REG_AFE_FINE_GAIN_PB_B_MSB	(0x4B)
> +#define REG_AFE_FINE_GAIN_Y_G_CHROMA_LSB	(0x4C)
> +#define REG_AFE_FINE_GAIN_Y_G_CHROMA_MSB	(0x4D)
> +#define REG_AFE_FINE_GAIN_PR_R_LSB	(0x4E)
> +#define REG_AFE_FINE_GAIN_PR_R_MSB	(0x4F)
> +#define REG_AFE_FINE_GAIN_CVBS_LUMA_LSB	(0x50)
> +#define REG_AFE_FINE_GAIN_CVBS_LUMA_MSB	(0x51)
> +
> +/* 0x52 - 0x68 Reserved */
> +
> +#define REG_FBIT_VBIT_CONTROL1		(0x69)
> +
> +/* 0x6A - 0x6B Reserved */
> +
> +#define REG_BACKEND_AGC_CONTROL		(0x6C)
> +
> +/* 0x6D - 0x6E Reserved */
> +
> +#define REG_AGC_DECREMENT_SPEED_CONTROL	(0x6F)
> +#define REG_ROM_VERSION			(0x70)
> +
> +/* 0x71 - 0x73 Reserved */
> +
> +#define REG_AGC_WHITE_PEAK_PROCESSING	(0x74)
> +#define REG_FBIT_VBIT_CONTROL2		(0x75)
> +#define REG_VCR_TRICK_MODE_CONTROL	(0x76)
> +#define REG_HORIZONTAL_SHAKE_INCREMENT	(0x77)
> +#define REG_AGC_INCREMENT_SPEED		(0x78)
> +#define REG_AGC_INCREMENT_DELAY		(0x79)
> +
> +/* 0x7A - 0x7F Reserved */
> +
> +#define REG_CHIP_ID_MSB			(0x80)
> +#define REG_CHIP_ID_LSB			(0x81)
> +
> +/* 0x82 Reserved */
> +
> +#define REG_CPLL_SPEED_CONTROL		(0x83)
> +
> +/* 0x84 - 0x96 Reserved */
> +
> +#define REG_STATUS_REQUEST		(0x97)
> +
> +/* 0x98 - 0x99 Reserved */
> +
> +#define REG_VERTICAL_LINE_COUNT_LSB	(0x9A)
> +#define REG_VERTICAL_LINE_COUNT_MSB	(0x9B)
> +
> +/* 0x9C - 0x9D Reserved */
> +
> +#define REG_AGC_DECREMENT_DELAY		(0x9E)
> +
> +/* 0x9F - 0xB0 Reserved */
> +
> +#define REG_VDP_TTX_FILTER_1_MASK1	(0xB1)
> +#define REG_VDP_TTX_FILTER_1_MASK2	(0xB2)
> +#define REG_VDP_TTX_FILTER_1_MASK3	(0xB3)
> +#define REG_VDP_TTX_FILTER_1_MASK4	(0xB4)
> +#define REG_VDP_TTX_FILTER_1_MASK5	(0xB5)
> +#define REG_VDP_TTX_FILTER_2_MASK1	(0xB6)
> +#define REG_VDP_TTX_FILTER_2_MASK2	(0xB7)
> +#define REG_VDP_TTX_FILTER_2_MASK3	(0xB8)
> +#define REG_VDP_TTX_FILTER_2_MASK4	(0xB9)
> +#define REG_VDP_TTX_FILTER_2_MASK5	(0xBA)
> +#define REG_VDP_TTX_FILTER_CONTROL	(0xBB)
> +#define REG_VDP_FIFO_WORD_COUNT		(0xBC)
> +#define REG_VDP_FIFO_INTERRUPT_THRLD	(0xBD)
> +
> +/* 0xBE Reserved */
> +
> +#define REG_VDP_FIFO_RESET		(0xBF)
> +#define REG_VDP_FIFO_OUTPUT_CONTROL	(0xC0)
> +#define REG_VDP_LINE_NUMBER_INTERRUPT	(0xC1)
> +#define REG_VDP_PIXEL_ALIGNMENT_LSB	(0xC2)
> +#define REG_VDP_PIXEL_ALIGNMENT_MSB	(0xC3)
> +
> +/* 0xC4 - 0xD5 Reserved */
> +
> +#define REG_VDP_LINE_START		(0xD6)
> +#define REG_VDP_LINE_STOP		(0xD7)
> +#define REG_VDP_GLOBAL_LINE_MODE	(0xD8)
> +#define REG_VDP_FULL_FIELD_ENABLE	(0xD9)
> +#define REG_VDP_FULL_FIELD_MODE		(0xDA)
> +
> +/* 0xDB - 0xDF Reserved */
> +
> +#define REG_VBUS_DATA_ACCESS_NO_VBUS_ADDR_INCR	(0xE0)
> +#define REG_VBUS_DATA_ACCESS_VBUS_ADDR_INCR	(0xE1)
> +#define REG_FIFO_READ_DATA			(0xE2)
> +
> +/* 0xE3 - 0xE7 Reserved */
> +
> +#define REG_VBUS_ADDRESS_ACCESS1	(0xE8)
> +#define REG_VBUS_ADDRESS_ACCESS2	(0xE9)
> +#define REG_VBUS_ADDRESS_ACCESS3	(0xEA)
> +
> +/* 0xEB - 0xEF Reserved */
> +
> +#define REG_INTERRUPT_RAW_STATUS0	(0xF0)
> +#define REG_INTERRUPT_RAW_STATUS1	(0xF1)
> +#define REG_INTERRUPT_STATUS0		(0xF2)
> +#define REG_INTERRUPT_STATUS1		(0xF3)
> +#define REG_INTERRUPT_MASK0		(0xF4)
> +#define REG_INTERRUPT_MASK1		(0xF5)
> +#define REG_INTERRUPT_CLEAR0		(0xF6)
> +#define REG_INTERRUPT_CLEAR1		(0xF7)
> +
> +/* 0xF8 - 0xFF Reserved */
> +
> +/*
> + * Mask and bit definitions of TVP5146/47 registers
> + */
> +/* The ID values we are looking for */
> +#define TVP514X_CHIP_ID_MSB		(0x51)
> +#define TVP5146_CHIP_ID_LSB		(0x46)
> +#define TVP5147_CHIP_ID_LSB		(0x47)
> +
> +#define VIDEO_STD_MASK			(0x07)
> +#define VIDEO_STD_AUTO_SWITCH_BIT	(0x00)
> +#define VIDEO_STD_NTSC_MJ_BIT		(0x01)
> +#define VIDEO_STD_PAL_BDGHIN_BIT	(0x02)
> +#define VIDEO_STD_PAL_M_BIT		(0x03)
> +#define VIDEO_STD_PAL_COMBINATION_N_BIT	(0x04)
> +#define VIDEO_STD_NTSC_4_43_BIT		(0x05)
> +#define VIDEO_STD_SECAM_BIT		(0x06)
> +#define VIDEO_STD_PAL_60_BIT		(0x07)
> +
> +/*
> + * Status bit
> + */
> +#define STATUS_TV_VCR_BIT		(1<<0)
> +#define STATUS_HORZ_SYNC_LOCK_BIT	(1<<1)
> +#define STATUS_VIRT_SYNC_LOCK_BIT	(1<<2)
> +#define STATUS_CLR_SUBCAR_LOCK_BIT	(1<<3)
> +#define STATUS_LOST_LOCK_DETECT_BIT	(1<<4)
> +#define STATUS_FEILD_RATE_BIT		(1<<5)
> +#define STATUS_LINE_ALTERNATING_BIT	(1<<6)
> +#define STATUS_PEAK_WHITE_DETECT_BIT	(1<<7)
> +
> +/**
> + * struct tvp514x_reg - Structure for TVP5146/47 register
> initialization values + * @token - Token: TOK_WRITE, TOK_TERM etc..
> + * @reg - Register offset
> + * @val - Register Value for TOK_WRITE or delay in ms for TOK_DELAY
> + */
> +struct tvp514x_reg {
> +	u8 token;
> +	u8 reg;
> +	u32 val;
> +};
> +
> +/**
> + * struct tvp514x_init_seq - Structure for TVP5146/47/46M2/47M1
> power up + *		Sequence.
> + * @ no_regs - Number of registers to write for power up sequence.
> + * @ init_reg_seq - Array of registers and respective value to
> write. + */
> +struct tvp514x_init_seq {
> +	unsigned int no_regs;
> +	struct tvp514x_reg *init_reg_seq;
> +};
> +#endif				/* ifndef _TVP514X_REGS_H */
> diff --git a/include/media/tvp514x.h b/include/media/tvp514x.h
> new file mode 100755
> index 0000000..2fee5e7
> --- /dev/null
> +++ b/include/media/tvp514x.h
> @@ -0,0 +1,232 @@
> +/*
> + * drivers/media/video/tvp514x.h
> + *
> + * Copyright (C) 2008 Texas Instruments Inc
> + * Author: Vaibhav Hiremath <hvaibhav@ti.com>
> + *
> + * Contributors:
> + *     Sivaraj R <sivaraj@ti.com>
> + *     Brijesh R Jadav <brijesh.j@ti.com>
> + *     Hardik Shah <hardik.shah@ti.com>
> + *     Manjunath Hadli <mrh@ti.com>
> + *     Karicheri Muralidharan <m-karicheri2@ti.com>
> + *
> + * This package is free software; you can redistribute it and/or
> modify + * it under the terms of the GNU General Public License
> version 2 as + * published by the Free Software Foundation.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program; if not, write to the Free Software
> + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
> + *
> + */
> +
> +#ifndef _TVP514X_H
> +#define _TVP514X_H
> +
> +/*
> + * Other macros
> + */
> +#define TVP514X_MODULE_NAME		"tvp514x"
> +#define TVP514X_I2C_DELAY		(3)
> +#define I2C_RETRY_COUNT			(5)
> +#define LOCK_RETRY_COUNT		(5)
> +#define LOCK_RETRY_DELAY		(200)
> +
> +#define TOK_WRITE			(0)	/* token for write operation */
> +#define TOK_TERM			(1)	/* terminating token */
> +#define TOK_DELAY			(2)	/* delay token for reg list */
> +#define TOK_SKIP			(3)	/* token to skip a register */
> +
> +#define TVP514X_XCLK_BT656		(27000000)
> +
> +/* Number of pixels and number of lines per frame for different
> standards */ +#define NTSC_NUM_ACTIVE_PIXELS		(720)
> +#define NTSC_NUM_ACTIVE_LINES		(480)
> +#define PAL_NUM_ACTIVE_PIXELS		(720)
> +#define PAL_NUM_ACTIVE_LINES		(576)
> +
> +/**
> + * enum tvp514x_std - enum for supported standards
> + */
> +enum tvp514x_std {
> +	STD_NTSC_MJ = 0,
> +	STD_PAL_BDGHIN,
> +	STD_INVALID
> +};
> +
> +/**
> + * enum tvp514x_state - enum for different decoder states
> + */
> +enum tvp514x_state {
> +	STATE_NOT_DETECTED,
> +	STATE_DETECTED
> +};
> +
> +/**
> + * enum tvp514x_input - enum for different decoder input pin
> + *		configuration.
> + */
> +enum tvp514x_input {
> +	/*
> +	 * CVBS input selection
> +	 */
> +	INPUT_CVBS_VI1A = 0x0,
> +	INPUT_CVBS_VI1B,
> +	INPUT_CVBS_VI1C,
> +	INPUT_CVBS_VI2A = 0x04,
> +	INPUT_CVBS_VI2B,
> +	INPUT_CVBS_VI2C,
> +	INPUT_CVBS_VI3A = 0x08,
> +	INPUT_CVBS_VI3B,
> +	INPUT_CVBS_VI3C,
> +	INPUT_CVBS_VI4A = 0x0C,
> +	/*
> +	 * S-Video input selection
> +	 */
> +	INPUT_SVIDEO_VI2A_VI1A = 0x44,
> +	INPUT_SVIDEO_VI2B_VI1B,
> +	INPUT_SVIDEO_VI2C_VI1C,
> +	INPUT_SVIDEO_VI2A_VI3A = 0x54,
> +	INPUT_SVIDEO_VI2B_VI3B,
> +	INPUT_SVIDEO_VI2C_VI3C,
> +	INPUT_SVIDEO_VI4A_VI1A = 0x4C,
> +	INPUT_SVIDEO_VI4A_VI1B,
> +	INPUT_SVIDEO_VI4A_VI1C,
> +	INPUT_SVIDEO_VI4A_VI3A = 0x5C,
> +	INPUT_SVIDEO_VI4A_VI3B,
> +	INPUT_SVIDEO_VI4A_VI3C
> +
> +	/* Need to add entries for
> +	 * RGB, YPbPr and SCART.
> +	 */
> +};
> +
> +/**
> + * enum tvp514x_output_fmt - enum for output format
> + *			supported.
> + */
> +enum tvp514x_output_fmt {
> +	OUTPUT_10BIT_422_EMBEDDED_SYNC = 0,
> +	OUTPUT_20BIT_422_SEPERATE_SYNC,
> +	OUTPUT_10BIT_422_SEPERATE_SYNC = 3,
> +	OUTPUT_INVALID
> +};
> +
> +/**
> + * struct tvp514x_std_info - Structure to store standard
> informations + * @width: Line width in pixels
> + * @height:Number of active lines
> + * @video_std: Value to write in REG_VIDEO_STD register
> + * @standard: v4l2 standard structure information
> + */
> +struct tvp514x_std_info {
> +	unsigned long width;
> +	unsigned long height;
> +	u8 video_std;
> +	struct v4l2_standard standard;
> +};
> +
> +/**
> + * struct tvp514x_ctrl_info - Information regarding supported
> controls + * @reg_address: Register offset of control register
> + * @query_ctrl: v4l2 query control information
> + */
> +struct tvp514x_ctrl_info {
> +	u8 reg_address;
> +	struct v4l2_queryctrl query_ctrl;
> +};
> +
> +/**
> + * struct tvp514x_input_info - Information regarding supported
> inputs + * @input_sel: Input select register
> + * @lock_mask: lock mask - depends on Svideo/CVBS
> + * @input: v4l2 input information
> + */
> +struct tvp514x_input_info {
> +	enum tvp514x_input input_sel;
> +	struct v4l2_input input;
> +};
> +
> +/**
> + * struct tvp514x_platform_data - Platform data values and access
> functions + * @power_set: Power state access function, zero is off,
> non-zero is on. + * @ifparm: Interface parameters access function
> + * @priv_data_set: Device private data (pointer) access function
> + * @reg_list: The board dependent driver should fill the default
> value for + *            required registers depending on board
> layout. The TVP5146/47 + *            driver will update this
> register list for the registers + *            whose values should be
> maintained across open()/close() like + *            setting
> brightness as defined in V4L2.
> + *            The register list should be in the same order as
> defined in + *            TVP5146/47 datasheet including reserved
> registers. As of now + *            the driver expects the size of
> this list to be a minimum of + *            57 + 1 (upto regsiter
> REG_CLEAR_LOST_LOCK).
> + *            The last member should be of the list should be
> + *            {TOK_TERM, 0, 0} to indicate the end of register list.
> + * @num_inputs: Number of input connection in board
> + * @input_list: Input information list for num_inputs
> + */
> +struct tvp514x_platform_data {
> +	char *master;
> +	int (*power_set) (enum v4l2_power on);
> +	int (*ifparm) (struct v4l2_ifparm *p);
> +	int (*priv_data_set) (void *);
> +	/* Input params */
> +	int num_inputs;
> +	const struct tvp514x_input_info *input_list;
> +	int default_input;
> +	/* Interface control params */
> +	enum tvp514x_output_fmt fmt;
> +	bool clk_polarity;
> +	bool hs_polarity;
> +	bool vs_polarity;
> +};
> +
> +/**
> + * struct tvp514x_decoded - TVP5146/47 decoder object
> + * @v4l2_int_device: Slave handle
> + * @pdata: Board specific
> + * @client: I2C client data
> + * @id: Entry from I2C table
> + * @ver: Chip version
> + * @state: TVP5146/47 decoder state - detected or not-detected
> + * @pix: Current pixel format
> + * @num_fmts: Number of formats
> + * @fmt_list: Format list
> + * @current_std: Current standard
> + * @num_stds: Number of standards
> + * @std_list: Standards list
> + * @num_ctrls: Number of controls
> + * @ctrl_list: Control list
> + */
> +struct tvp514x_decoder {
> +	struct v4l2_int_device *v4l2_int_device;
> +	const struct tvp514x_platform_data *pdata;
> +	struct i2c_client *client;
> +
> +	struct i2c_device_id *id;
> +
> +	int ver;
> +	enum tvp514x_state state;
> +
> +	struct v4l2_pix_format pix;
> +	int num_fmts;
> +	const struct v4l2_fmtdesc *fmt_list;
> +
> +	enum tvp514x_std current_std;
> +	int num_stds;
> +	struct tvp514x_std_info *std_list;
> +
> +	int num_ctrls;
> +	const struct tvp514x_ctrl_info *ctrl_list;
> +
> +	int inputidx;
> +};
> +
> +#endif				/* ifndef _TVP514X_H */
> --
> 1.5.6
>
> --
> video4linux-list mailing list
> Unsubscribe
> mailto:video4linux-list-request@redhat.com?subject=unsubscribe
> https://www.redhat.com/mailman/listinfo/video4linux-list



-- 
Hans Verkuil - video4linux developer - sponsored by TANDBERG

--
video4linux-list mailing list
Unsubscribe mailto:video4linux-list-request@redhat.com?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list

^ permalink raw reply	[flat|nested] 263+ messages in thread

* Re: [PATCH 2/2] TVP514x Driver with Review comments fixed [V4]
  2008-12-02 15:35   ` hvaibhav
  (?)
  (?)
@ 2008-12-02 19:29   ` David Brownell
  -1 siblings, 0 replies; 263+ messages in thread
From: David Brownell @ 2008-12-02 19:29 UTC (permalink / raw)
  To: hvaibhav
  Cc: video4linux-list, linux-omap, davinci-linux-open-source-bounces,
	Brijesh Jadav, Hardik Shah, Manjunath Hadli, R Sivaraj,
	Karicheri Muralidharan

On Tuesday 02 December 2008, hvaibhav@ti.com wrote:
> +static int __init tvp514x_init(void)
> +{
> +       int err;
> +
> +       err = i2c_add_driver(&tvp514x_i2c_driver);
> +       if (err) {
> +               printk(KERN_ERR "Failed to register " MODULE_NAME ".\n");
> +               return err;
> +       }
> +       return 0;
> +}

Just do the normal

	return i2c_add_driver(...);



--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 263+ messages in thread

* Re: [PATCH 2/2] TVP514x Driver with Review comments fixed [V4]
  2008-12-02 15:35   ` hvaibhav
                     ` (2 preceding siblings ...)
  (?)
@ 2008-12-02 19:44   ` David Brownell
  -1 siblings, 0 replies; 263+ messages in thread
From: David Brownell @ 2008-12-02 19:44 UTC (permalink / raw)
  To: hvaibhav
  Cc: video4linux-list, linux-omap, davinci-linux-open-source-bounces,
	Brijesh Jadav, Hardik Shah, Manjunath Hadli, R Sivaraj,
	Karicheri Muralidharan

Yep, nice to see an I2C driver that actually tries to cope
with errors when reading/writing registers.  :)

I expect that I'll have some more comments later.


On Tuesday 02 December 2008, hvaibhav@ti.com wrote:
> +void tvp514x_reg_dump(struct tvp514x_decoder *decoder)

"static void" ... there probably shouldn't be any symbols
exported from this driver, except the ones handling module
init (which are in a section that's removed ASAP).


> +/*
> + * TVP5146 Init/Power on Sequence
> + */
> +static struct tvp514x_reg tvp5146_init_reg_seq[] = {
> +       {TOK_WRITE, REG_VBUS_ADDRESS_ACCESS1, 0x02},
> +       {TOK_WRITE, REG_VBUS_ADDRESS_ACCESS2, 0x00},
> +       {TOK_WRITE, REG_VBUS_ADDRESS_ACCESS3, 0x80},
> +       {TOK_WRITE, REG_VBUS_DATA_ACCESS_NO_VBUS_ADDR_INCR, 0x01},
> +       ...
> +};
> +static struct tvp514x_init_seq tvp5146_init = {
> +       .no_regs = ARRAY_SIZE(tvp5146_init_reg_seq),
> +       .init_reg_seq = tvp5146_init_reg_seq,
> +};

I suggest making all of those be "static const", along
with their friends  :)


> +       {"tvp5146", (unsigned int)&tvp5146_init},

As I noted earlier, best if this were "unsigned long".

I'm surprised you're only using the driver_data to hold
a pointer to a tvp514x_init_seq structure.  That would
be the natural place to store other chip-specific
data ... like whatever is needed to ensure that this
driver never tries to access a '46-specific register
on a '47 chip.

- Dave
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 263+ messages in thread

* RE: [PATCH 2/2] TVP514x Driver with Review comments fixed [V4]
  2008-12-02 17:20   ` Hans Verkuil
@ 2008-12-03  3:58       ` Hiremath, Vaibhav
  2008-12-03 13:43     ` V4L2 PIXEL buffer conversion Jonathan Lafontaine
  1 sibling, 0 replies; 263+ messages in thread
From: Hiremath, Vaibhav @ 2008-12-03  3:58 UTC (permalink / raw)
  To: Hans Verkuil, video4linux-list
  Cc: linux-omap, Karicheri, Muralidharan, davinci-linux-open-source-bounces



Thanks,
Vaibhav Hiremath

> -----Original Message-----
> From: Hans Verkuil [mailto:hverkuil@xs4all.nl]
> Sent: Tuesday, December 02, 2008 10:50 PM
> To: video4linux-list@redhat.com
> Cc: Hiremath, Vaibhav; davinci-linux-open-source-
> bounces@linux.davincidsp.com; Karicheri, Muralidharan; linux-
> omap@vger.kernel.org
> Subject: Re: [PATCH 2/2] TVP514x Driver with Review comments fixed
> [V4]
>
> Hi Vaibhav,
>
> I'm sorry, but this is still wrong. You basically renamed s_input
> with
> s_routing while still using the list with user inputs from the
> platform
> data.
>
> These three fields in struct tvp514x_platform_data should be removed
> as
> they do not belong here:
>
> > +   /* Input params */
> > +   int num_inputs;
> > +   const struct tvp514x_input_info *input_list;
> > +   int default_input;
>
> This is all high-level stuff that does not belong in an i2c driver.
> It's
> the master driver that has to translate the input as specified by
> the
> user to a pin of the tvp514x (like INPUT_CVBS_VI1A).
>
> Also, ioctl_g_routing() can be removed as I have yet to see a master
> driver that is interested in obtaining this information. Besides,
> that
> function looks very strange because it is calling ioctl_s_routing. A
> get function that sets something?!?
>
> Eventually the whole tvp514x_platform_data will have to be removed.
> Everything that's in there should be passed to the i2c driver using
> v4l2_subdev ops. But that's something for the future.
>
[Hiremath, Vaibhav] Definitely, as you mentioned eventually the platform data dependency from TVP driver will be removed. But I will have to start with master driver to do it, since now platform data will go to master driver which will maintain list or table at his level.

I think yesterday on chat I had mentioned clearly that, simultaneously I will have to start with master driver which will automatically address your all comments, like -

        - g_routing: Since this will get handled at master level no need to support at slave or TVP level.
        - s_routing: The input params will change to v4l2_routing, and argument will come directly from master. Master will now include "tvp514x.h" file to pass appropriate routing data.
        - tvp514x_platform_data: Again, the data related to input will go to master.

Since it would take good amount of change and time, I thought to get reviewed first and while submitting master driver anyway I will have to change.

I believe once master driver becomes slave aware (including tvp514x.h); all issues automatically will get addressed.

Probably I missed to mention all these points in the patch, which lead to confusion.

Hope this clears.

> I'm available in the #v4l IRC channel tomorrow for further
> discussions
> on this.
>
> BTW1, struct tvp514x_decoder shouldn't be in
> include/media/tvp514x.h.
> It's internal to the driver (at least, I sincerely hope so), so it
> can
> be moved to either the source or the tvp514x_regs.h header.
>
> BTW2, I'm not going to make it a blocking issue, but those callback
> functions in tvp514x_platform_data are horrible. The priv_data_set
> callback is the clearest example of what's wrong with this design: a
> master driver calls ioctl_g_priv in tvp whose only action is to call
> priv_data_set in the platform code! The master driver shouldn't have
> to
> go through the i2c driver for that! The only reason a low level v4l
> i2c
> driver would ever make a call to higher level code is for
> notifications.
>
> Regards,
>
>       Hans
>
> On Tuesday 02 December 2008 16:35:42 hvaibhav@ti.com wrote:
> > From: Vaibhav Hiremath <hvaibhav@ti.com>
> >
> > I have fixed all the review commentsreceived so far.
> > Here are the details -
> >
> > FIXSES:
> >     Make use of i2c_smbus_read/write_byte API:
> >         Probe function now checks for SMBUS capability,
> >     and read/write functions make use of the above API.
> >
> >     Error check for I2C Read/Write:
> >         Added error condition check for both read and write
> >     API.
> >     This has been added for completeness.
> >
> >     input set/get ioctl:
> >         As we do have support for set and get routing ioctl,
> >     instead of adding new ioctl used them.
> >
> >     enum_ioctl:
> >         After discussing with Hans verkuil, came to conclusion
> >     that as of now just remove support for enum_ioctl from
> >     decoder, since this has to handle at master driver level.
> >
> > TODO LIST:
> >     OMAP Master capture driver:
> >         This should be completely aligned with the current
> >     discussion.
> >
> >     Migration to sub_device framework:
> >         Immediately after all the above task, migrate both
> >     Master and slave driver to sub_device framework.
> >
> > Signed-off-by: Brijesh Jadav <brijesh.j@ti.com>
> > Signed-off-by: Hardik Shah <hardik.shah@ti.com>
> > Signed-off-by: Manjunath Hadli <mrh@ti.com>
> > Signed-off-by: R Sivaraj <sivaraj@ti.com>
> > Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
> > Signed-off-by: Karicheri Muralidharan <m-karicheri2@ti.com>
> > ---
> >  drivers/media/video/Kconfig        |   11 +
> >  drivers/media/video/Makefile       |    1 +
> >  drivers/media/video/tvp514x.c      | 1521
> > ++++++++++++++++++++++++++++++++++++
> > drivers/media/video/tvp514x_regs.h |  292 +++++++
> >  include/media/tvp514x.h            |  232 ++++++
> >  5 files changed, 2057 insertions(+), 0 deletions(-)
> >  create mode 100755 drivers/media/video/tvp514x.c
> >  create mode 100755 drivers/media/video/tvp514x_regs.h
> >  create mode 100755 include/media/tvp514x.h
> >
> > diff --git a/drivers/media/video/Kconfig
> > b/drivers/media/video/Kconfig index 47102c2..2e5dc3e 100644
> > --- a/drivers/media/video/Kconfig
> > +++ b/drivers/media/video/Kconfig
> > @@ -361,6 +361,17 @@ config VIDEO_SAA7191
> >       To compile this driver as a module, choose M here: the
> >       module will be called saa7191.
> >
> > +config VIDEO_TVP514X
> > +   tristate "Texas Instruments TVP514x video decoder"
> > +   depends on VIDEO_V4L2 && I2C
> > +   ---help---
> > +     This is a Video4Linux2 sensor-level driver for the TI
> TVP5146/47
> > +     decoder. It is currently working with the TI OMAP3 camera
> > +     controller.
> > +
> > +     To compile this driver as a module, choose M here: the
> > +     module will be called tvp514x.
> > +
> >  config VIDEO_TVP5150
> >     tristate "Texas Instruments TVP5150 video decoder"
> >     depends on VIDEO_V4L2 && I2C
> > diff --git a/drivers/media/video/Makefile
> > b/drivers/media/video/Makefile index 16962f3..cdbbf38 100644
> > --- a/drivers/media/video/Makefile
> > +++ b/drivers/media/video/Makefile
> > @@ -66,6 +66,7 @@ obj-$(CONFIG_VIDEO_CX88) += cx88/
> >  obj-$(CONFIG_VIDEO_EM28XX) += em28xx/
> >  obj-$(CONFIG_VIDEO_USBVISION) += usbvision/
> >  obj-$(CONFIG_VIDEO_TVP5150) += tvp5150.o
> > +obj-$(CONFIG_VIDEO_TVP514X) += tvp514x.o
> >  obj-$(CONFIG_VIDEO_PVRUSB2) += pvrusb2/
> >  obj-$(CONFIG_VIDEO_MSP3400) += msp3400.o
> >  obj-$(CONFIG_VIDEO_CS5345) += cs5345.o
> > diff --git a/drivers/media/video/tvp514x.c
> > b/drivers/media/video/tvp514x.c new file mode 100755
> > index 0000000..c0834e4
> > --- /dev/null
> > +++ b/drivers/media/video/tvp514x.c
> > @@ -0,0 +1,1521 @@
> > +/*
> > + * drivers/media/video/tvp514x.c
> > + *
> > + * TI TVP5146/47 decoder driver
> > + *
> > + * Copyright (C) 2008 Texas Instruments Inc
> > + * Author: Vaibhav Hiremath <hvaibhav@ti.com>
> > + *
> > + * Contributors:
> > + *     Sivaraj R <sivaraj@ti.com>
> > + *     Brijesh R Jadav <brijesh.j@ti.com>
> > + *     Hardik Shah <hardik.shah@ti.com>
> > + *     Manjunath Hadli <mrh@ti.com>
> > + *     Karicheri Muralidharan <m-karicheri2@ti.com>
> > + *
> > + * This package is free software; you can redistribute it and/or
> > modify + * it under the terms of the GNU General Public License
> > version 2 as + * published by the Free Software Foundation.
> > + *
> > + * This program is distributed in the hope that it will be
> useful,
> > + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> > + * GNU General Public License for more details.
> > + *
> > + * You should have received a copy of the GNU General Public
> License
> > + * along with this program; if not, write to the Free Software
> > + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
> > + *
> > + */
> > +
> > +#include <linux/i2c.h>
> > +#include <linux/delay.h>
> > +#include <linux/videodev2.h>
> > +#include <media/v4l2-int-device.h>
> > +#include <media/tvp514x.h>
> > +
> > +#include "tvp514x_regs.h"
> > +
> > +#define MODULE_NAME        TVP514X_MODULE_NAME
> > +
> > +/* Debug functions */
> > +static int debug;
> > +module_param(debug, bool, 0644);
> > +MODULE_PARM_DESC(debug, "Debug level (0-1)");
> > +
> > +#define dump_reg(client, reg, val)                         \
> > +   do {                                                    \
> > +           val = tvp514x_read_reg(client, reg);            \
> > +           v4l_info(client, "Reg(0x%.2X): 0x%.2X\n", reg, val); \
> > +   } while (0)
> > +
> > +
> > +/* TVP514x default register values */
> > +static struct tvp514x_reg tvp514x_reg_list[] = {
> > +   {TOK_WRITE, REG_INPUT_SEL, 0x05},       /* Composite selected */
> > +   {TOK_WRITE, REG_AFE_GAIN_CTRL, 0x0F},
> > +   {TOK_WRITE, REG_VIDEO_STD, 0x00},       /* Auto mode */
> > +   {TOK_WRITE, REG_OPERATION_MODE, 0x00},
> > +   {TOK_SKIP, REG_AUTOSWITCH_MASK, 0x3F},
> > +   {TOK_WRITE, REG_COLOR_KILLER, 0x10},
> > +   {TOK_WRITE, REG_LUMA_CONTROL1, 0x00},
> > +   {TOK_WRITE, REG_LUMA_CONTROL2, 0x00},
> > +   {TOK_WRITE, REG_LUMA_CONTROL3, 0x02},
> > +   {TOK_WRITE, REG_BRIGHTNESS, 0x80},
> > +   {TOK_WRITE, REG_CONTRAST, 0x80},
> > +   {TOK_WRITE, REG_SATURATION, 0x80},
> > +   {TOK_WRITE, REG_HUE, 0x00},
> > +   {TOK_WRITE, REG_CHROMA_CONTROL1, 0x00},
> > +   {TOK_WRITE, REG_CHROMA_CONTROL2, 0x0E},
> > +   {TOK_SKIP, 0x0F, 0x00}, /* Reserved */
> > +   {TOK_WRITE, REG_COMP_PR_SATURATION, 0x80},
> > +   {TOK_WRITE, REG_COMP_Y_CONTRAST, 0x80},
> > +   {TOK_WRITE, REG_COMP_PB_SATURATION, 0x80},
> > +   {TOK_SKIP, 0x13, 0x00}, /* Reserved */
> > +   {TOK_WRITE, REG_COMP_Y_BRIGHTNESS, 0x80},
> > +   {TOK_SKIP, 0x15, 0x00}, /* Reserved */
> > +   {TOK_SKIP, REG_AVID_START_PIXEL_LSB, 0x55},     /* NTSC timing
> */
> > +   {TOK_SKIP, REG_AVID_START_PIXEL_MSB, 0x00},
> > +   {TOK_SKIP, REG_AVID_STOP_PIXEL_LSB, 0x25},
> > +   {TOK_SKIP, REG_AVID_STOP_PIXEL_MSB, 0x03},
> > +   {TOK_SKIP, REG_HSYNC_START_PIXEL_LSB, 0x00},    /* NTSC timing
> */
> > +   {TOK_SKIP, REG_HSYNC_START_PIXEL_MSB, 0x00},
> > +   {TOK_SKIP, REG_HSYNC_STOP_PIXEL_LSB, 0x40},
> > +   {TOK_SKIP, REG_HSYNC_STOP_PIXEL_MSB, 0x00},
> > +   {TOK_SKIP, REG_VSYNC_START_LINE_LSB, 0x04},     /* NTSC timing
> */
> > +   {TOK_SKIP, REG_VSYNC_START_LINE_MSB, 0x00},
> > +   {TOK_SKIP, REG_VSYNC_STOP_LINE_LSB, 0x07},
> > +   {TOK_SKIP, REG_VSYNC_STOP_LINE_MSB, 0x00},
> > +   {TOK_SKIP, REG_VBLK_START_LINE_LSB, 0x01},      /* NTSC timing
> */
> > +   {TOK_SKIP, REG_VBLK_START_LINE_MSB, 0x00},
> > +   {TOK_SKIP, REG_VBLK_STOP_LINE_LSB, 0x15},
> > +   {TOK_SKIP, REG_VBLK_STOP_LINE_MSB, 0x00},
> > +   {TOK_SKIP, 0x26, 0x00}, /* Reserved */
> > +   {TOK_SKIP, 0x27, 0x00}, /* Reserved */
> > +   {TOK_SKIP, REG_FAST_SWTICH_CONTROL, 0xCC},
> > +   {TOK_SKIP, 0x29, 0x00}, /* Reserved */
> > +   {TOK_SKIP, REG_FAST_SWTICH_SCART_DELAY, 0x00},
> > +   {TOK_SKIP, 0x2B, 0x00}, /* Reserved */
> > +   {TOK_SKIP, REG_SCART_DELAY, 0x00},
> > +   {TOK_SKIP, REG_CTI_DELAY, 0x00},
> > +   {TOK_SKIP, REG_CTI_CONTROL, 0x00},
> > +   {TOK_SKIP, 0x2F, 0x00}, /* Reserved */
> > +   {TOK_SKIP, 0x30, 0x00}, /* Reserved */
> > +   {TOK_SKIP, 0x31, 0x00}, /* Reserved */
> > +   {TOK_WRITE, REG_SYNC_CONTROL, 0x00},    /* HS, VS active
> high */
> > +   {TOK_WRITE, REG_OUTPUT_FORMATTER1, 0x00},       /* 10-bit BT.656 */
> > +   {TOK_WRITE, REG_OUTPUT_FORMATTER2, 0x11},       /* Enable clk & data
> */
> > +   {TOK_WRITE, REG_OUTPUT_FORMATTER3, 0xEE},       /* Enable AVID & FLD
> */
> > +   {TOK_WRITE, REG_OUTPUT_FORMATTER4, 0xAF},       /* Enable VS & HS */
> > +   {TOK_WRITE, REG_OUTPUT_FORMATTER5, 0xFF},
> > +   {TOK_WRITE, REG_OUTPUT_FORMATTER6, 0xFF},
> > +   {TOK_WRITE, REG_CLEAR_LOST_LOCK, 0x01}, /* Clear status */
> > +   {TOK_TERM, 0, 0},
> > +};
> > +
> > +/* List of image formats supported by TVP5146/47 decoder
> > + * Currently we are using 8 bit mode only, but can be
> > + * extended to 10/20 bit mode.
> > + */
> > +static const struct v4l2_fmtdesc tvp514x_fmt_list[] = {
> > +   {
> > +    .index = 0,
> > +    .type = V4L2_BUF_TYPE_VIDEO_CAPTURE,
> > +    .flags = 0,
> > +    .description = "8-bit UYVY 4:2:2 Format",
> > +    .pixelformat = V4L2_PIX_FMT_UYVY,
> > +   },
> > +};
> > +
> > +#define TVP514X_NUM_FORMATS
>       ARRAY_SIZE(tvp514x_fmt_list)
> > +
> > +/*
> > + * Supported standards -
> > + *
> > + * Currently supports two standards only, need to add support for
> > rest of the + * modes, like SECAM, etc...
> > + */
> > +static struct tvp514x_std_info tvp514x_std_list[] = {
> > +   /* Standard: STD_NTSC_MJ */
> > +   [STD_NTSC_MJ] = {
> > +    .width = NTSC_NUM_ACTIVE_PIXELS,
> > +    .height = NTSC_NUM_ACTIVE_LINES,
> > +    .video_std = VIDEO_STD_NTSC_MJ_BIT,
> > +    .standard = {
> > +                 .index = 0,
> > +                 .id = V4L2_STD_NTSC,
> > +                 .name = "NTSC",
> > +                 .frameperiod = {1001, 30000},
> > +                 .framelines = 525
> > +                },
> > +   /* Standard: STD_PAL_BDGHIN */
> > +   },
> > +   [STD_PAL_BDGHIN] = {
> > +    .width = PAL_NUM_ACTIVE_PIXELS,
> > +    .height = PAL_NUM_ACTIVE_LINES,
> > +    .video_std = VIDEO_STD_PAL_BDGHIN_BIT,
> > +    .standard = {
> > +                 .index = 1,
> > +                 .id = V4L2_STD_PAL,
> > +                 .name = "PAL",
> > +                 .frameperiod = {1, 25},
> > +                 .framelines = 625
> > +                },
> > +   },
> > +   /* Standard: need to add for additional standard */
> > +};
> > +
> > +#define TVP514X_NUM_STANDARDS
>       ARRAY_SIZE(tvp514x_std_list)
> > +
> > +/* Supported controls */
> > +static const struct tvp514x_ctrl_info tvp514x_ctrl_list[] = {
> > +   {
> > +    .reg_address = REG_BRIGHTNESS,
> > +    .query_ctrl = {
> > +                   .id = V4L2_CID_BRIGHTNESS,
> > +                   .name = "BRIGHTNESS",
> > +                   .type = V4L2_CTRL_TYPE_INTEGER,
> > +                   .minimum = 0,
> > +                   .maximum = 255,
> > +                   .step = 1,
> > +                   .default_value = 128
> > +                   },
> > +   }, {
> > +    .reg_address = REG_CONTRAST,
> > +    .query_ctrl = {
> > +                   .id = V4L2_CID_CONTRAST,
> > +                   .name = "CONTRAST",
> > +                   .type = V4L2_CTRL_TYPE_INTEGER,
> > +                   .minimum = 0,
> > +                   .maximum = 255,
> > +                   .step = 1,
> > +                   .default_value = 128
> > +                   },
> > +   }, {
> > +    .reg_address = REG_SATURATION,
> > +    .query_ctrl = {
> > +                   .id = V4L2_CID_SATURATION,
> > +                   .name = "SATURATION",
> > +                   .type = V4L2_CTRL_TYPE_INTEGER,
> > +                   .minimum = 0,
> > +                   .maximum = 255,
> > +                   .step = 1,
> > +                   .default_value = 128
> > +                   },
> > +   }, {
> > +    .reg_address = REG_HUE,
> > +    .query_ctrl = {
> > +                   .id = V4L2_CID_HUE,
> > +                   .name = "HUE",
> > +                   .type = V4L2_CTRL_TYPE_INTEGER,
> > +                   .minimum = -180,
> > +                   .maximum = 180,
> > +                   .step = 180,
> > +                   .default_value = 0
> > +                   },
> > +   }, {
> > +    .reg_address = REG_AFE_GAIN_CTRL,
> > +    .query_ctrl = {
> > +                   .id = V4L2_CID_AUTOGAIN,
> > +                   .name = "Automatic Gain Control",
> > +                   .type = V4L2_CTRL_TYPE_BOOLEAN,
> > +                   .minimum = 0,
> > +                   .maximum = 1,
> > +                   .step = 1,
> > +                   .default_value = 1
> > +                   },
> > +    },
> > +};
> > +
> > +#define TVP514X_NUM_CONTROLS
>       ARRAY_SIZE(tvp514x_ctrl_list)
> > +
> > +/*
> > + * Read a value from a register in an TVP5146/47 decoder device.
> > + * Returns value read if successful, or non-zero (-1) otherwise.
> > + */
> > +static int tvp514x_read_reg(struct i2c_client *client, u8 reg)
> > +{
> > +   int err;
> > +   int retry = 0;
> > +read_again:
> > +
> > +   err = i2c_smbus_read_byte_data(client, reg);
> > +   if (err == -1) {
> > +           if (retry <= I2C_RETRY_COUNT) {
> > +                   v4l_warn(client, "Read: retry ... %d\n", retry);
> > +                   retry++;
> > +                   msleep_interruptible(10);
> > +                   goto read_again;
> > +           }
> > +   }
> > +
> > +   return err;
> > +}
> > +
> > +/*
> > + * Write a value to a register in an TVP5146/47 decoder device.
> > + * Returns zero if successful, or non-zero otherwise.
> > + */
> > +static int tvp514x_write_reg(struct i2c_client *client, u8 reg,
> u8
> > val) +{
> > +   int err;
> > +   int retry = 0;
> > +write_again:
> > +
> > +   err = i2c_smbus_write_byte_data(client, reg, val);
> > +   if (err) {
> > +           if (retry <= I2C_RETRY_COUNT) {
> > +                   v4l_warn(client, "Write: retry ... %d\n", retry);
> > +                   retry++;
> > +                   msleep_interruptible(10);
> > +                   goto write_again;
> > +           }
> > +   }
> > +
> > +   return err;
> > +}
> > +
> > +/*
> > + * tvp514x_write_regs : Initializes a list of TVP5146/47
> registers
> > + *         if token is TOK_TERM, then entire write operation
> terminates
> > + *         if token is TOK_DELAY, then a delay of 'val' msec is
> introduced
> > + *         if token is TOK_SKIP, then the register write is skipped
> > + *         if token is TOK_WRITE, then the register write is
> performed
> > + *
> > + * reglist - list of registers to be written
> > + * Returns zero if successful, or non-zero otherwise.
> > + */
> > +static int tvp514x_write_regs(struct i2c_client *client,
> > +                         const struct tvp514x_reg reglist[])
> > +{
> > +   int err;
> > +   const struct tvp514x_reg *next = reglist;
> > +
> > +   for (; next->token != TOK_TERM; next++) {
> > +           if (next->token == TOK_DELAY) {
> > +                   msleep(next->val);
> > +                   continue;
> > +           }
> > +
> > +           if (next->token == TOK_SKIP)
> > +                   continue;
> > +
> > +           err = tvp514x_write_reg(client, next->reg, (u8) next-
> >val);
> > +           if (err) {
> > +                   v4l_err(client, "Write failed. Err[%d]\n", err);
> > +                   return err;
> > +           }
> > +   }
> > +   return 0;
> > +}
> > +
> > +/*
> > + * tvp514x_get_current_std:
> > + * Returns the current standard detected by TVP5146/47
> > + */
> > +static enum tvp514x_std tvp514x_get_current_std(struct
> > tvp514x_decoder +                                           *decoder)
> > +{
> > +   u8 std, std_status;
> > +
> > +   std = tvp514x_read_reg(decoder->client, REG_VIDEO_STD);
> > +   if ((std & VIDEO_STD_MASK) == VIDEO_STD_AUTO_SWITCH_BIT) {
> > +           /* use the standard status register */
> > +           std_status = tvp514x_read_reg(decoder->client,
> > +                           REG_VIDEO_STD_STATUS);
> > +   } else
> > +           std_status = std;       /* use the standard register itself */
> > +
> > +   switch (std_status & VIDEO_STD_MASK) {
> > +   case VIDEO_STD_NTSC_MJ_BIT:
> > +           return STD_NTSC_MJ;
> > +
> > +   case VIDEO_STD_PAL_BDGHIN_BIT:
> > +           return STD_PAL_BDGHIN;
> > +
> > +   default:
> > +           return STD_INVALID;
> > +   }
> > +
> > +   return STD_INVALID;
> > +}
> > +
> > +/*
> > + * TVP5146/47 register dump function
> > + */
> > +void tvp514x_reg_dump(struct tvp514x_decoder *decoder)
> > +{
> > +   u8 value;
> > +
> > +   dump_reg(decoder->client, REG_INPUT_SEL, value);
> > +   dump_reg(decoder->client, REG_AFE_GAIN_CTRL, value);
> > +   dump_reg(decoder->client, REG_VIDEO_STD, value);
> > +   dump_reg(decoder->client, REG_OPERATION_MODE, value);
> > +   dump_reg(decoder->client, REG_COLOR_KILLER, value);
> > +   dump_reg(decoder->client, REG_LUMA_CONTROL1, value);
> > +   dump_reg(decoder->client, REG_LUMA_CONTROL2, value);
> > +   dump_reg(decoder->client, REG_LUMA_CONTROL3, value);
> > +   dump_reg(decoder->client, REG_BRIGHTNESS, value);
> > +   dump_reg(decoder->client, REG_CONTRAST, value);
> > +   dump_reg(decoder->client, REG_SATURATION, value);
> > +   dump_reg(decoder->client, REG_HUE, value);
> > +   dump_reg(decoder->client, REG_CHROMA_CONTROL1, value);
> > +   dump_reg(decoder->client, REG_CHROMA_CONTROL2, value);
> > +   dump_reg(decoder->client, REG_COMP_PR_SATURATION, value);
> > +   dump_reg(decoder->client, REG_COMP_Y_CONTRAST, value);
> > +   dump_reg(decoder->client, REG_COMP_PB_SATURATION, value);
> > +   dump_reg(decoder->client, REG_COMP_Y_BRIGHTNESS, value);
> > +   dump_reg(decoder->client, REG_AVID_START_PIXEL_LSB, value);
> > +   dump_reg(decoder->client, REG_AVID_START_PIXEL_MSB, value);
> > +   dump_reg(decoder->client, REG_AVID_STOP_PIXEL_LSB, value);
> > +   dump_reg(decoder->client, REG_AVID_STOP_PIXEL_MSB, value);
> > +   dump_reg(decoder->client, REG_HSYNC_START_PIXEL_LSB, value);
> > +   dump_reg(decoder->client, REG_HSYNC_START_PIXEL_MSB, value);
> > +   dump_reg(decoder->client, REG_HSYNC_STOP_PIXEL_LSB, value);
> > +   dump_reg(decoder->client, REG_HSYNC_STOP_PIXEL_MSB, value);
> > +   dump_reg(decoder->client, REG_VSYNC_START_LINE_LSB, value);
> > +   dump_reg(decoder->client, REG_VSYNC_START_LINE_MSB, value);
> > +   dump_reg(decoder->client, REG_VSYNC_STOP_LINE_LSB, value);
> > +   dump_reg(decoder->client, REG_VSYNC_STOP_LINE_MSB, value);
> > +   dump_reg(decoder->client, REG_VBLK_START_LINE_LSB, value);
> > +   dump_reg(decoder->client, REG_VBLK_START_LINE_MSB, value);
> > +   dump_reg(decoder->client, REG_VBLK_STOP_LINE_LSB, value);
> > +   dump_reg(decoder->client, REG_VBLK_STOP_LINE_MSB, value);
> > +   dump_reg(decoder->client, REG_SYNC_CONTROL, value);
> > +   dump_reg(decoder->client, REG_OUTPUT_FORMATTER1, value);
> > +   dump_reg(decoder->client, REG_OUTPUT_FORMATTER2, value);
> > +   dump_reg(decoder->client, REG_OUTPUT_FORMATTER3, value);
> > +   dump_reg(decoder->client, REG_OUTPUT_FORMATTER4, value);
> > +   dump_reg(decoder->client, REG_OUTPUT_FORMATTER5, value);
> > +   dump_reg(decoder->client, REG_OUTPUT_FORMATTER6, value);
> > +   dump_reg(decoder->client, REG_CLEAR_LOST_LOCK, value);
> > +}
> > +
> > +/*
> > + * Configure the TVP5146/47 with the current register settings
> > + * Returns zero if successful, or non-zero otherwise.
> > + */
> > +static int tvp514x_configure(struct tvp514x_decoder *decoder)
> > +{
> > +   int err;
> > +
> > +   /* common register initialization */
> > +   err =
> > +       tvp514x_write_regs(decoder->client, tvp514x_reg_list);
> > +   if (err)
> > +           return err;
> > +
> > +   if (debug)
> > +           tvp514x_reg_dump(decoder);
> > +
> > +   return 0;
> > +}
> > +
> > +/*
> > + * Detect if an tvp514x is present, and if so which revision.
> > + * A device is considered to be detected if the chip ID (LSB and
> > MSB) + * registers match the expected values.
> > + * Any value of the rom version register is accepted.
> > + * Returns ENODEV error number if no device is detected, or zero
> > + * if a device is detected.
> > + */
> > +static int tvp514x_detect(struct tvp514x_decoder *decoder)
> > +{
> > +   u8 chip_id_msb, chip_id_lsb, rom_ver;
> > +
> > +   chip_id_msb = tvp514x_read_reg(decoder->client,
> REG_CHIP_ID_MSB);
> > +   chip_id_lsb = tvp514x_read_reg(decoder->client,
> REG_CHIP_ID_LSB);
> > +   rom_ver = tvp514x_read_reg(decoder->client, REG_ROM_VERSION);
> > +
> > +   v4l_dbg(1, debug, decoder->client,
> > +            "chip id detected msb:0x%x lsb:0x%x rom
> version:0x%x\n",
> > +            chip_id_msb, chip_id_lsb, rom_ver);
> > +   if ((chip_id_msb != TVP514X_CHIP_ID_MSB)
> > +           || ((chip_id_lsb != TVP5146_CHIP_ID_LSB)
> > +           && (chip_id_lsb != TVP5147_CHIP_ID_LSB))) {
> > +           /* We didn't read the values we expected, so this must
> not be
> > +            * an TVP5146/47.
> > +            */
> > +           v4l_err(decoder->client,
> > +                   "chip id mismatch msb:0x%x lsb:0x%x\n",
> > +                   chip_id_msb, chip_id_lsb);
> > +           return -ENODEV;
> > +   }
> > +
> > +   decoder->ver = rom_ver;
> > +   decoder->state = STATE_DETECTED;
> > +
> > +   v4l_info(decoder->client,
> > +                   "\n%s found at 0x%x (%s)\n", decoder->client-
> >name,
> > +                   decoder->client->addr << 1,
> > +                   decoder->client->adapter->name);
> > +   return 0;
> > +}
> > +
> > +/*
> > + * Following are decoder interface functions implemented by
> > + * TVP5146/47 decoder driver.
> > + */
> > +
> > +/**
> > + * ioctl_querystd - V4L2 decoder interface handler for
> > VIDIOC_QUERYSTD ioctl + * @s: pointer to standard V4L2 device
> > structure
> > + * @std_id: standard V4L2 std_id ioctl enum
> > + *
> > + * Returns the current standard detected by TVP5146/47. If no
> active
> > input is + * detected, returns -EINVAL
> > + */
> > +static int ioctl_querystd(struct v4l2_int_device *s, v4l2_std_id
> > *std_id) +{
> > +   struct tvp514x_decoder *decoder = s->priv;
> > +   enum tvp514x_std current_std;
> > +   enum tvp514x_input input_sel;
> > +   u8 sync_lock_status, lock_mask;
> > +
> > +   if (std_id == NULL)
> > +           return -EINVAL;
> > +
> > +   /* get the current standard */
> > +   current_std = tvp514x_get_current_std(decoder);
> > +   if (current_std == STD_INVALID)
> > +           return -EINVAL;
> > +
> > +   input_sel =
> > decoder->pdata->input_list[decoder->inputidx].input_sel; +
> > +   switch (input_sel) {
> > +   case INPUT_CVBS_VI1A:
> > +   case INPUT_CVBS_VI1B:
> > +   case INPUT_CVBS_VI1C:
> > +   case INPUT_CVBS_VI2A:
> > +   case INPUT_CVBS_VI2B:
> > +   case INPUT_CVBS_VI2C:
> > +   case INPUT_CVBS_VI3A:
> > +   case INPUT_CVBS_VI3B:
> > +   case INPUT_CVBS_VI3C:
> > +   case INPUT_CVBS_VI4A:
> > +           lock_mask = STATUS_CLR_SUBCAR_LOCK_BIT |
> > +                   STATUS_HORZ_SYNC_LOCK_BIT |
> > +                   STATUS_VIRT_SYNC_LOCK_BIT;
> > +           break;
> > +
> > +   case INPUT_SVIDEO_VI2A_VI1A:
> > +   case INPUT_SVIDEO_VI2B_VI1B:
> > +   case INPUT_SVIDEO_VI2C_VI1C:
> > +   case INPUT_SVIDEO_VI2A_VI3A:
> > +   case INPUT_SVIDEO_VI2B_VI3B:
> > +   case INPUT_SVIDEO_VI2C_VI3C:
> > +   case INPUT_SVIDEO_VI4A_VI1A:
> > +   case INPUT_SVIDEO_VI4A_VI1B:
> > +   case INPUT_SVIDEO_VI4A_VI1C:
> > +   case INPUT_SVIDEO_VI4A_VI3A:
> > +   case INPUT_SVIDEO_VI4A_VI3B:
> > +   case INPUT_SVIDEO_VI4A_VI3C:
> > +           lock_mask = STATUS_HORZ_SYNC_LOCK_BIT |
> > +                   STATUS_VIRT_SYNC_LOCK_BIT;
> > +           break;
> > +           /*Need to add other interfaces*/
> > +   default:
> > +           return -EINVAL;
> > +   }
> > +   /* check whether signal is locked */
> > +   sync_lock_status = tvp514x_read_reg(decoder->client,
> REG_STATUS1);
> > +   if (lock_mask != (sync_lock_status & lock_mask))
> > +           return -EINVAL; /* No input detected */
> > +
> > +   decoder->current_std = current_std;
> > +   *std_id = decoder->std_list[current_std].standard.id;
> > +
> > +   v4l_dbg(1, debug, decoder->client, "Current STD: %s",
> > +                   decoder->std_list[current_std].standard.name);
> > +   return 0;
> > +}
> > +
> > +/**
> > + * ioctl_s_std - V4L2 decoder interface handler for VIDIOC_S_STD
> > ioctl + * @s: pointer to standard V4L2 device structure
> > + * @std_id: standard V4L2 v4l2_std_id ioctl enum
> > + *
> > + * If std_id is supported, sets the requested standard.
> Otherwise,
> > returns + * -EINVAL
> > + */
> > +static int ioctl_s_std(struct v4l2_int_device *s, v4l2_std_id
> > *std_id) +{
> > +   struct tvp514x_decoder *decoder = s->priv;
> > +   int err, i;
> > +
> > +   if (std_id == NULL)
> > +           return -EINVAL;
> > +
> > +   for (i = 0; i < decoder->num_stds; i++)
> > +           if (*std_id & decoder->std_list[i].standard.id)
> > +                   break;
> > +
> > +   if ((i == decoder->num_stds) || (i == STD_INVALID))
> > +           return -EINVAL;
> > +
> > +   err = tvp514x_write_reg(decoder->client, REG_VIDEO_STD,
> > +                           decoder->std_list[i].video_std);
> > +   if (err)
> > +           return err;
> > +
> > +   decoder->current_std = i;
> > +   tvp514x_reg_list[REG_VIDEO_STD].val =
> > decoder->std_list[i].video_std; +
> > +   v4l_dbg(1, debug, decoder->client, "Standard set to: %s",
> > +                   decoder->std_list[i].standard.name);
> > +   return 0;
> > +}
> > +
> > +/**
> > + * ioctl_s_routing - V4L2 decoder interface handler for
> > VIDIOC_S_INPUT ioctl + * @s: pointer to standard V4L2 device
> > structure
> > + * @index: number of the input
> > + *
> > + * If index is valid, selects the requested input. Otherwise,
> > returns -EINVAL if + * the input is not supported or there is no
> > active signal present in the + * selected input.
> > + */
> > +static int ioctl_s_routing(struct v4l2_int_device *s, int index)
> > +{
> > +   struct tvp514x_decoder *decoder = s->priv;
> > +   int err;
> > +   enum tvp514x_input input_sel;
> > +   enum tvp514x_std current_std = STD_INVALID;
> > +   u8 sync_lock_status, lock_mask;
> > +   int try_count = LOCK_RETRY_COUNT;
> > +
> > +   if ((index >= decoder->pdata->num_inputs) || (index < 0))
> > +           return -EINVAL; /* Index out of bound */
> > +
> > +   /* Get the register value to be written to select the
> requested
> > input */ +  input_sel = decoder->pdata-
> >input_list[index].input_sel;
> > +   err = tvp514x_write_reg(decoder->client, REG_INPUT_SEL,
> input_sel);
> > +   if (err)
> > +           return err;
> > +
> > +   decoder->inputidx = index;
> > +   tvp514x_reg_list[REG_INPUT_SEL].val = input_sel;
> > +
> > +   /* Clear status */
> > +   msleep(LOCK_RETRY_DELAY);
> > +   err =
> > +       tvp514x_write_reg(decoder->client, REG_CLEAR_LOST_LOCK,
> 0x01);
> > +   if (err)
> > +           return err;
> > +
> > +   switch (input_sel) {
> > +   case INPUT_CVBS_VI1A:
> > +   case INPUT_CVBS_VI1B:
> > +   case INPUT_CVBS_VI1C:
> > +   case INPUT_CVBS_VI2A:
> > +   case INPUT_CVBS_VI2B:
> > +   case INPUT_CVBS_VI2C:
> > +   case INPUT_CVBS_VI3A:
> > +   case INPUT_CVBS_VI3B:
> > +   case INPUT_CVBS_VI3C:
> > +   case INPUT_CVBS_VI4A:
> > +           lock_mask = STATUS_CLR_SUBCAR_LOCK_BIT |
> > +                   STATUS_HORZ_SYNC_LOCK_BIT |
> > +                   STATUS_VIRT_SYNC_LOCK_BIT;
> > +           break;
> > +
> > +   case INPUT_SVIDEO_VI2A_VI1A:
> > +   case INPUT_SVIDEO_VI2B_VI1B:
> > +   case INPUT_SVIDEO_VI2C_VI1C:
> > +   case INPUT_SVIDEO_VI2A_VI3A:
> > +   case INPUT_SVIDEO_VI2B_VI3B:
> > +   case INPUT_SVIDEO_VI2C_VI3C:
> > +   case INPUT_SVIDEO_VI4A_VI1A:
> > +   case INPUT_SVIDEO_VI4A_VI1B:
> > +   case INPUT_SVIDEO_VI4A_VI1C:
> > +   case INPUT_SVIDEO_VI4A_VI3A:
> > +   case INPUT_SVIDEO_VI4A_VI3B:
> > +   case INPUT_SVIDEO_VI4A_VI3C:
> > +           lock_mask = STATUS_HORZ_SYNC_LOCK_BIT |
> > +                   STATUS_VIRT_SYNC_LOCK_BIT;
> > +           break;
> > +   /*Need to add other interfaces*/
> > +   default:
> > +           return -EINVAL;
> > +   }
> > +
> > +   while (try_count-- > 0) {
> > +           /* Allow decoder to sync up with new input */
> > +           msleep(LOCK_RETRY_DELAY);
> > +
> > +           /* get the current standard for future reference */
> > +           current_std = tvp514x_get_current_std(decoder);
> > +           if (current_std == STD_INVALID)
> > +                   continue;
> > +
> > +           sync_lock_status = tvp514x_read_reg(decoder->client,
> > +                           REG_STATUS1);
> > +           if (lock_mask == (sync_lock_status & lock_mask))
> > +                   break;  /* Input detected */
> > +   }
> > +
> > +   if ((current_std == STD_INVALID) || (try_count < 0))
> > +           return -EINVAL;
> > +
> > +   decoder->current_std = current_std;
> > +
> > +   v4l_dbg(1, debug, decoder->client,
> > +                   "Input set to: index - %d (%s)",
> > +                   decoder->pdata->input_list[index].input.index,
> > +                   decoder->pdata->input_list[index].input.name);
> > +   return 0;
> > +}
> > +
> > +/**
> > + * ioctl_g_routing - V4L2 decoder interface handler for
> > VIDIOC_G_INPUT ioctl + * @s: pointer to standard V4L2 device
> > structure
> > + * @index: returns the current selected input
> > + *
> > + * Returns the current selected input. Returns -EINVAL if any
> error
> > occurs + */
> > +static int ioctl_g_routing(struct v4l2_int_device *s, int *index)
> > +{
> > +   struct tvp514x_decoder *decoder = s->priv;
> > +   int err = -EINVAL, i, inputidx;
> > +
> > +   if (index == NULL)
> > +           return err;
> > +
> > +   /* Search through the input list for active inputs */
> > +   inputidx = decoder->inputidx;
> > +   for (i = 0; i < decoder->pdata->num_inputs; i++) {
> > +           inputidx++;     /* Move to next input */
> > +           if (inputidx >= decoder->pdata->num_inputs)
> > +                   inputidx = 0;   /* fall back to first input */
> > +
> > +           err = ioctl_s_routing(s, inputidx);
> > +           if (!err) {
> > +                   /* Active input found - select it and return
> success */
> > +                   *index = inputidx;
> > +                   return 0;
> > +           }
> > +   }
> > +
> > +   return err;
> > +}
> > +
> > +/**
> > + * ioctl_queryctrl - V4L2 decoder interface handler for
> > VIDIOC_QUERYCTRL ioctl + * @s: pointer to standard V4L2 device
> > structure
> > + * @qc: standard V4L2 VIDIOC_QUERYCTRL ioctl structure
> > + *
> > + * If the requested control is supported, returns the control
> > information + * from the ctrl_list[] array. Otherwise, returns
> > -EINVAL if the + * control is not supported.
> > + */
> > +static int
> > +ioctl_queryctrl(struct v4l2_int_device *s, struct v4l2_queryctrl
> > *qctrl) +{
> > +   struct tvp514x_decoder *decoder = s->priv;
> > +   int id, index;
> > +   const struct tvp514x_ctrl_info *control = NULL;
> > +
> > +   if (qctrl == NULL)
> > +           return -EINVAL;
> > +
> > +   id = qctrl->id;
> > +   memset(qctrl, 0, sizeof(struct v4l2_queryctrl));
> > +   qctrl->id = id;
> > +
> > +   for (index = 0; index < decoder->num_ctrls; index++) {
> > +           control = &decoder->ctrl_list[index];
> > +           if (control->query_ctrl.id == qctrl->id)
> > +                   break;  /* Match found */
> > +   }
> > +   if (index == decoder->num_ctrls)
> > +           return -EINVAL; /* Index out of bound */
> > +
> > +   memcpy(qctrl, &control->query_ctrl, sizeof(struct
> v4l2_queryctrl));
> > +
> > +   v4l_dbg(1, debug, decoder->client,
> > +                   "Query Control: %s : Min - %d, Max - %d, Def -
> %d",
> > +                   control->query_ctrl.name,
> > +                   control->query_ctrl.minimum,
> > +                   control->query_ctrl.maximum,
> > +                   control->query_ctrl.default_value);
> > +   return 0;
> > +}
> > +
> > +/**
> > + * ioctl_g_ctrl - V4L2 decoder interface handler for
> VIDIOC_G_CTRL
> > ioctl + * @s: pointer to standard V4L2 device structure
> > + * @vc: standard V4L2 VIDIOC_G_CTRL ioctl structure
> > + *
> > + * If the requested control is supported, returns the control's
> > current + * value from the decoder. Otherwise, returns -EINVAL if
> the
> > control is not + * supported.
> > + */
> > +static int
> > +ioctl_g_ctrl(struct v4l2_int_device *s, struct v4l2_control
> *ctrl)
> > +{
> > +   struct tvp514x_decoder *decoder = s->priv;
> > +   int index, value;
> > +   const struct tvp514x_ctrl_info *control = NULL;
> > +
> > +   if (ctrl == NULL)
> > +           return -EINVAL;
> > +
> > +   for (index = 0; index < decoder->num_ctrls; index++) {
> > +           control = &decoder->ctrl_list[index];
> > +           if (control->query_ctrl.id == ctrl->id)
> > +                   break;  /* Match found */
> > +   }
> > +   if (index == decoder->num_ctrls)
> > +           return -EINVAL; /* Index out of bound */
> > +
> > +   value =
> > +       tvp514x_read_reg(decoder->client, control->reg_address);
> > +
> > +   /* cross check */
> > +   if (value != tvp514x_reg_list[control->reg_address].val)
> > +           return -EINVAL; /* Driver & TVP5146/47 setting
> mismatch */
> > +
> > +   if (V4L2_CID_AUTOGAIN == ctrl->id) {
> > +           if ((value & 0x3) == 3)
> > +                   value = 1;
> > +           else
> > +                   value = 0;
> > +   }
> > +
> > +   if (V4L2_CID_HUE == ctrl->id) {
> > +           if (value == 0x7F)
> > +                   value = 180;
> > +           else if (value == 0x80)
> > +                   value = -180;
> > +           else
> > +                   value = 0;
> > +   }
> > +
> > +   ctrl->value = value;
> > +
> > +   v4l_dbg(1, debug, decoder->client,
> > +                   "Get Cotrol: %s - %d",
> > +                   control->query_ctrl.name, value);
> > +   return 0;
> > +}
> > +
> > +/**
> > + * ioctl_s_ctrl - V4L2 decoder interface handler for
> VIDIOC_S_CTRL
> > ioctl + * @s: pointer to standard V4L2 device structure
> > + * @vc: standard V4L2 VIDIOC_S_CTRL ioctl structure
> > + *
> > + * If the requested control is supported, sets the control's
> current
> > + * value in HW. Otherwise, returns -EINVAL if the control is not
> > supported. + */
> > +static int
> > +ioctl_s_ctrl(struct v4l2_int_device *s, struct v4l2_control
> *ctrl)
> > +{
> > +   struct tvp514x_decoder *decoder = s->priv;
> > +   int err, value, index;
> > +   const struct tvp514x_ctrl_info *control = NULL;
> > +
> > +   if (ctrl == NULL)
> > +           return -EINVAL;
> > +
> > +   value = (__s32) ctrl->value;
> > +   for (index = 0; index < decoder->num_ctrls; index++) {
> > +           control = &decoder->ctrl_list[index];
> > +           if (control->query_ctrl.id == ctrl->id)
> > +                   break;  /* Match found */
> > +   }
> > +   if (index == decoder->num_ctrls)
> > +           return -EINVAL; /* Index out of bound */
> > +
> > +   if (V4L2_CID_AUTOGAIN == ctrl->id) {
> > +           if (value == 1)
> > +                   value = 0x0F;
> > +           else if (value == 0)
> > +                   value = 0x0C;
> > +           else
> > +                   return -ERANGE;
> > +   } else if (V4L2_CID_HUE == ctrl->id) {
> > +           if (value == 180)
> > +                   value = 0x7F;
> > +           else if (value == -180)
> > +                   value = 0x80;
> > +           else if (value == 0)
> > +                   value = 0;
> > +           else
> > +                   return -ERANGE;
> > +   } else {
> > +           if ((value < control->query_ctrl.minimum)
> > +                   || (value > control->query_ctrl.maximum))
> > +                   return -ERANGE;
> > +   }
> > +
> > +   err =
> > +       tvp514x_write_reg(decoder->client, control->reg_address,
> > +                           value);
> > +   if (err)
> > +           return err;
> > +
> > +   tvp514x_reg_list[control->reg_address].val = value;
> > +
> > +   v4l_dbg(1, debug, decoder->client,
> > +                   "Set Cotrol: %s - %d",
> > +                   control->query_ctrl.name, value);
> > +   return err;
> > +}
> > +
> > +/**
> > + * ioctl_enum_fmt_cap - Implement the CAPTURE buffer
> VIDIOC_ENUM_FMT
> > ioctl + * @s: pointer to standard V4L2 device structure
> > + * @fmt: standard V4L2 VIDIOC_ENUM_FMT ioctl structure
> > + *
> > + * Implement the VIDIOC_ENUM_FMT ioctl to enumerate supported
> > formats + */
> > +static int
> > +ioctl_enum_fmt_cap(struct v4l2_int_device *s, struct v4l2_fmtdesc
> > *fmt) +{
> > +   struct tvp514x_decoder *decoder = s->priv;
> > +   int index;
> > +
> > +   if (fmt == NULL)
> > +           return -EINVAL;
> > +
> > +   index = fmt->index;
> > +   if ((index >= decoder->num_fmts) || (index < 0))
> > +           return -EINVAL; /* Index out of bound */
> > +
> > +   if (fmt->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
> > +           return -EINVAL; /* only capture is supported */
> > +
> > +   memcpy(fmt, &decoder->fmt_list[index],
> > +           sizeof(struct v4l2_fmtdesc));
> > +
> > +   v4l_dbg(1, debug, decoder->client,
> > +                   "Current FMT: index - %d (%s)",
> > +                   decoder->fmt_list[index].index,
> > +                   decoder->fmt_list[index].description);
> > +   return 0;
> > +}
> > +
> > +/**
> > + * ioctl_try_fmt_cap - Implement the CAPTURE buffer
> VIDIOC_TRY_FMT
> > ioctl + * @s: pointer to standard V4L2 device structure
> > + * @f: pointer to standard V4L2 VIDIOC_TRY_FMT ioctl structure
> > + *
> > + * Implement the VIDIOC_TRY_FMT ioctl for the CAPTURE buffer
> type.
> > This + * ioctl is used to negotiate the image capture size and
> pixel
> > format + * without actually making it take effect.
> > + */
> > +static int
> > +ioctl_try_fmt_cap(struct v4l2_int_device *s, struct v4l2_format
> *f)
> > +{
> > +   struct tvp514x_decoder *decoder = s->priv;
> > +   int ifmt;
> > +   struct v4l2_pix_format *pix;
> > +   enum tvp514x_std current_std;
> > +
> > +   if (f == NULL)
> > +           return -EINVAL;
> > +
> > +   if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
> > +           f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
> > +
> > +   pix = &f->fmt.pix;
> > +
> > +   /* Calculate height and width based on current standard */
> > +   current_std = tvp514x_get_current_std(decoder);
> > +   if (current_std == STD_INVALID)
> > +           return -EINVAL;
> > +
> > +   decoder->current_std = current_std;
> > +   pix->width = decoder->std_list[current_std].width;
> > +   pix->height = decoder->std_list[current_std].height;
> > +
> > +   for (ifmt = 0; ifmt < decoder->num_fmts; ifmt++) {
> > +           if (pix->pixelformat ==
> > +                   decoder->fmt_list[ifmt].pixelformat)
> > +                   break;
> > +   }
> > +   if (ifmt == decoder->num_fmts)
> > +           ifmt = 0;       /* None of the format matched, select
> default */
> > +   pix->pixelformat = decoder->fmt_list[ifmt].pixelformat;
> > +
> > +   pix->field = V4L2_FIELD_INTERLACED;
> > +   pix->bytesperline = pix->width * 2;
> > +   pix->sizeimage = pix->bytesperline * pix->height;
> > +   pix->colorspace = V4L2_COLORSPACE_SMPTE170M;
> > +   pix->priv = 0;
> > +
> > +   v4l_dbg(1, debug, decoder->client,
> > +                   "Try FMT: pixelformat - %s, bytesperline - %d"
> > +                   "Width - %d, Height - %d",
> > +                   decoder->fmt_list[ifmt].description, pix-
> >bytesperline,
> > +                   pix->width, pix->height);
> > +   return 0;
> > +}
> > +
> > +/**
> > + * ioctl_s_fmt_cap - V4L2 decoder interface handler for
> VIDIOC_S_FMT
> > ioctl + * @s: pointer to standard V4L2 device structure
> > + * @f: pointer to standard V4L2 VIDIOC_S_FMT ioctl structure
> > + *
> > + * If the requested format is supported, configures the HW to use
> > that + * format, returns error code if format not supported or HW
> > can't be + * correctly configured.
> > + */
> > +static int
> > +ioctl_s_fmt_cap(struct v4l2_int_device *s, struct v4l2_format *f)
> > +{
> > +   struct tvp514x_decoder *decoder = s->priv;
> > +   struct v4l2_pix_format *pix;
> > +   int rval;
> > +
> > +   if (f == NULL)
> > +           return -EINVAL;
> > +
> > +   if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
> > +           return -EINVAL; /* only capture is supported */
> > +
> > +   pix = &f->fmt.pix;
> > +   rval = ioctl_try_fmt_cap(s, f);
> > +   if (rval)
> > +           return rval;
> > +   else
> > +           decoder->pix = *pix;
> > +
> > +   return rval;
> > +}
> > +
> > +/**
> > + * ioctl_g_fmt_cap - V4L2 decoder interface handler for
> > ioctl_g_fmt_cap + * @s: pointer to standard V4L2 device structure
> > + * @f: pointer to standard V4L2 v4l2_format structure
> > + *
> > + * Returns the decoder's current pixel format in the v4l2_format
> > + * parameter.
> > + */
> > +static int
> > +ioctl_g_fmt_cap(struct v4l2_int_device *s, struct v4l2_format *f)
> > +{
> > +   struct tvp514x_decoder *decoder = s->priv;
> > +
> > +   if (f == NULL)
> > +           return -EINVAL;
> > +
> > +   if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
> > +           return -EINVAL; /* only capture is supported */
> > +
> > +   f->fmt.pix = decoder->pix;
> > +
> > +   v4l_dbg(1, debug, decoder->client,
> > +                   "Current FMT: bytesperline - %d"
> > +                   "Width - %d, Height - %d",
> > +                   decoder->pix.bytesperline,
> > +                   decoder->pix.width, decoder->pix.height);
> > +   return 0;
> > +}
> > +
> > +/**
> > + * ioctl_g_parm - V4L2 decoder interface handler for
> VIDIOC_G_PARM
> > ioctl + * @s: pointer to standard V4L2 device structure
> > + * @a: pointer to standard V4L2 VIDIOC_G_PARM ioctl structure
> > + *
> > + * Returns the decoder's video CAPTURE parameters.
> > + */
> > +static int
> > +ioctl_g_parm(struct v4l2_int_device *s, struct v4l2_streamparm
> *a)
> > +{
> > +   struct tvp514x_decoder *decoder = s->priv;
> > +   struct v4l2_captureparm *cparm;
> > +   enum tvp514x_std current_std;
> > +
> > +   if (a == NULL)
> > +           return -EINVAL;
> > +
> > +   if (a->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
> > +           return -EINVAL; /* only capture is supported */
> > +
> > +   memset(a, 0, sizeof(*a));
> > +   a->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
> > +
> > +   /* get the current standard */
> > +   current_std = tvp514x_get_current_std(decoder);
> > +   if (current_std == STD_INVALID)
> > +           return -EINVAL;
> > +
> > +   decoder->current_std = current_std;
> > +
> > +   cparm = &a->parm.capture;
> > +   cparm->capability = V4L2_CAP_TIMEPERFRAME;
> > +   cparm->timeperframe =
> > +           decoder->std_list[current_std].standard.frameperiod;
> > +
> > +   return 0;
> > +}
> > +
> > +/**
> > + * ioctl_s_parm - V4L2 decoder interface handler for
> VIDIOC_S_PARM
> > ioctl + * @s: pointer to standard V4L2 device structure
> > + * @a: pointer to standard V4L2 VIDIOC_S_PARM ioctl structure
> > + *
> > + * Configures the decoder to use the input parameters, if
> possible.
> > If + * not possible, returns the appropriate error code.
> > + */
> > +static int
> > +ioctl_s_parm(struct v4l2_int_device *s, struct v4l2_streamparm
> *a)
> > +{
> > +   struct tvp514x_decoder *decoder = s->priv;
> > +   struct v4l2_fract *timeperframe;
> > +   enum tvp514x_std current_std;
> > +
> > +   if (a == NULL)
> > +           return -EINVAL;
> > +
> > +   if (a->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
> > +           return -EINVAL; /* only capture is supported */
> > +
> > +   timeperframe = &a->parm.capture.timeperframe;
> > +
> > +   /* get the current standard */
> > +   current_std = tvp514x_get_current_std(decoder);
> > +   if (current_std == STD_INVALID)
> > +           return -EINVAL;
> > +
> > +   decoder->current_std = current_std;
> > +
> > +   *timeperframe =
> > +       decoder->std_list[current_std].standard.frameperiod;
> > +
> > +   return 0;
> > +}
> > +
> > +/**
> > + * ioctl_g_ifparm - V4L2 decoder interface handler for
> > vidioc_int_g_ifparm_num + * @s: pointer to standard V4L2 device
> > structure
> > + * @p: pointer to standard V4L2 vidioc_int_g_ifparm_num ioctl
> > structure + *
> > + * Gets slave interface parameters.
> > + * Calculates the required xclk value to support the requested
> > + * clock parameters in p. This value is returned in the p
> > + * parameter.
> > + */
> > +static int ioctl_g_ifparm(struct v4l2_int_device *s, struct
> > v4l2_ifparm *p) +{
> > +   struct tvp514x_decoder *decoder = s->priv;
> > +   int rval;
> > +
> > +   if (p == NULL)
> > +           return -EINVAL;
> > +
> > +   if (NULL == decoder->pdata->ifparm)
> > +           return -EINVAL;
> > +
> > +   rval = decoder->pdata->ifparm(p);
> > +   if (rval) {
> > +           v4l_err(decoder->client, "g_ifparm.Err[%d]\n", rval);
> > +           return rval;
> > +   }
> > +
> > +   p->u.bt656.clock_curr = TVP514X_XCLK_BT656;
> > +
> > +   return 0;
> > +}
> > +
> > +/**
> > + * ioctl_g_priv - V4L2 decoder interface handler for
> > vidioc_int_g_priv_num + * @s: pointer to standard V4L2 device
> > structure
> > + * @p: void pointer to hold decoder's private data address
> > + *
> > + * Returns device's (decoder's) private data area address in p
> > parameter + */
> > +static int ioctl_g_priv(struct v4l2_int_device *s, void *p)
> > +{
> > +   struct tvp514x_decoder *decoder = s->priv;
> > +
> > +   if (NULL == decoder->pdata->priv_data_set)
> > +           return -EINVAL;
> > +
> > +   return decoder->pdata->priv_data_set(p);
> > +}
> > +
> > +/**
> > + * ioctl_s_power - V4L2 decoder interface handler for
> > vidioc_int_s_power_num + * @s: pointer to standard V4L2 device
> > structure
> > + * @on: power state to which device is to be set
> > + *
> > + * Sets devices power state to requrested state, if possible.
> > + */
> > +static int ioctl_s_power(struct v4l2_int_device *s, enum
> v4l2_power
> > on) +{
> > +   struct tvp514x_decoder *decoder = s->priv;
> > +   int err = 0;
> > +
> > +   switch (on) {
> > +   case V4L2_POWER_OFF:
> > +           /* Power Down Sequence */
> > +           err =
> > +               tvp514x_write_reg(decoder->client,
> REG_OPERATION_MODE,
> > +                                   0x01);
> > +           /* Disable mux for TVP5146/47 decoder data path */
> > +           if (decoder->pdata->power_set)
> > +                   err |= decoder->pdata->power_set(on);
> > +           decoder->state = STATE_NOT_DETECTED;
> > +           break;
> > +
> > +   case V4L2_POWER_STANDBY:
> > +           if (decoder->pdata->power_set)
> > +                   err = decoder->pdata->power_set(on);
> > +           break;
> > +
> > +   case V4L2_POWER_ON:
> > +           /* Enable mux for TVP5146/47 decoder data path */
> > +           if ((decoder->pdata->power_set) &&
> > +                           (decoder->state == STATE_NOT_DETECTED)) {
> > +                   int i;
> > +                   struct tvp514x_init_seq *int_seq =
> > +                           (struct tvp514x_init_seq *)
> > +                           decoder->id->driver_data;
> > +
> > +                   err = decoder->pdata->power_set(on);
> > +
> > +                   /* Power Up Sequence */
> > +                   for (i = 0; i < int_seq->no_regs; i++) {
> > +                           err |= tvp514x_write_reg(decoder->client,
> > +                                           int_seq->init_reg_seq[i].reg,
> > +                                           int_seq->init_reg_seq[i].val);
> > +                   }
> > +                   /* Detect the sensor is not already detected */
> > +                   err |= tvp514x_detect(decoder);
> > +                   if (err) {
> > +                           v4l_err(decoder->client,
> > +                                           "Unable to detect decoder\n");
> > +                           return err;
> > +                   }
> > +           }
> > +           err |= tvp514x_configure(decoder);
> > +           break;
> > +
> > +   default:
> > +           err = -ENODEV;
> > +           break;
> > +   }
> > +
> > +   return err;
> > +}
> > +
> > +/**
> > + * ioctl_init - V4L2 decoder interface handler for
> VIDIOC_INT_INIT
> > + * @s: pointer to standard V4L2 device structure
> > + *
> > + * Initialize the decoder device (calls tvp514x_configure())
> > + */
> > +static int ioctl_init(struct v4l2_int_device *s)
> > +{
> > +   struct tvp514x_decoder *decoder = s->priv;
> > +
> > +   /* Set default standard to auto */
> > +   tvp514x_reg_list[REG_VIDEO_STD].val =
> > +       VIDEO_STD_AUTO_SWITCH_BIT;
> > +
> > +   return tvp514x_configure(decoder);
> > +}
> > +
> > +/**
> > + * ioctl_dev_exit - V4L2 decoder interface handler for
> > vidioc_int_dev_exit_num + * @s: pointer to standard V4L2 device
> > structure
> > + *
> > + * Delinitialise the dev. at slave detach. The complement of
> > ioctl_dev_init. + */
> > +static int ioctl_dev_exit(struct v4l2_int_device *s)
> > +{
> > +   return 0;
> > +}
> > +
> > +/**
> > + * ioctl_dev_init - V4L2 decoder interface handler for
> > vidioc_int_dev_init_num + * @s: pointer to standard V4L2 device
> > structure
> > + *
> > + * Initialise the device when slave attaches to the master.
> Returns
> > 0 if + * TVP5146/47 device could be found, otherwise returns
> > appropriate error. + */
> > +static int ioctl_dev_init(struct v4l2_int_device *s)
> > +{
> > +   struct tvp514x_decoder *decoder = s->priv;
> > +   int err;
> > +
> > +   err = tvp514x_detect(decoder);
> > +   if (err < 0) {
> > +           v4l_err(decoder->client,
> > +                   "Unable to detect decoder\n");
> > +           return err;
> > +   }
> > +
> > +   v4l_info(decoder->client,
> > +            "chip version 0x%.2x detected\n", decoder->ver);
> > +
> > +   return 0;
> > +}
> > +
> > +static struct v4l2_int_ioctl_desc tvp514x_ioctl_desc[] = {
> > +   {vidioc_int_dev_init_num, (v4l2_int_ioctl_func*)
> ioctl_dev_init},
> > +   {vidioc_int_dev_exit_num, (v4l2_int_ioctl_func*)
> ioctl_dev_exit},
> > +   {vidioc_int_s_power_num, (v4l2_int_ioctl_func*)
> ioctl_s_power},
> > +   {vidioc_int_g_priv_num, (v4l2_int_ioctl_func*) ioctl_g_priv},
> > +   {vidioc_int_g_ifparm_num, (v4l2_int_ioctl_func*)
> ioctl_g_ifparm},
> > +   {vidioc_int_init_num, (v4l2_int_ioctl_func*) ioctl_init},
> > +   {vidioc_int_enum_fmt_cap_num,
> > +    (v4l2_int_ioctl_func *) ioctl_enum_fmt_cap},
> > +   {vidioc_int_try_fmt_cap_num,
> > +    (v4l2_int_ioctl_func *) ioctl_try_fmt_cap},
> > +   {vidioc_int_g_fmt_cap_num,
> > +    (v4l2_int_ioctl_func *) ioctl_g_fmt_cap},
> > +   {vidioc_int_s_fmt_cap_num,
> > +    (v4l2_int_ioctl_func *) ioctl_s_fmt_cap},
> > +   {vidioc_int_g_parm_num, (v4l2_int_ioctl_func *) ioctl_g_parm},
> > +   {vidioc_int_s_parm_num, (v4l2_int_ioctl_func *) ioctl_s_parm},
> > +   {vidioc_int_queryctrl_num,
> > +    (v4l2_int_ioctl_func *) ioctl_queryctrl},
> > +   {vidioc_int_g_ctrl_num, (v4l2_int_ioctl_func *) ioctl_g_ctrl},
> > +   {vidioc_int_s_ctrl_num, (v4l2_int_ioctl_func *) ioctl_s_ctrl},
> > +   {vidioc_int_querystd_num, (v4l2_int_ioctl_func *)
> ioctl_querystd},
> > +   {vidioc_int_s_std_num, (v4l2_int_ioctl_func *) ioctl_s_std},
> > +   {vidioc_int_g_video_routing_num,
> > +           (v4l2_int_ioctl_func *) ioctl_g_routing},
> > +   {vidioc_int_s_video_routing_num,
> > +           (v4l2_int_ioctl_func *) ioctl_s_routing},
> > +};
> > +
> > +static struct v4l2_int_slave tvp514x_slave = {
> > +   .ioctls = tvp514x_ioctl_desc,
> > +   .num_ioctls = ARRAY_SIZE(tvp514x_ioctl_desc),
> > +};
> > +
> > +static struct tvp514x_decoder tvp514x_dev = {
> > +   .state = STATE_NOT_DETECTED,
> > +
> > +   .num_fmts = TVP514X_NUM_FORMATS,
> > +   .fmt_list = tvp514x_fmt_list,
> > +
> > +   .pix = {                /* Default to NTSC 8-bit YUV 422 */
> > +           .width = NTSC_NUM_ACTIVE_PIXELS,
> > +           .height = NTSC_NUM_ACTIVE_LINES,
> > +           .pixelformat = V4L2_PIX_FMT_UYVY,
> > +           .field = V4L2_FIELD_INTERLACED,
> > +           .bytesperline = NTSC_NUM_ACTIVE_PIXELS * 2,
> > +           .sizeimage =
> > +           NTSC_NUM_ACTIVE_PIXELS * 2 * NTSC_NUM_ACTIVE_LINES,
> > +           .colorspace = V4L2_COLORSPACE_SMPTE170M,
> > +           },
> > +
> > +   .current_std = STD_NTSC_MJ,
> > +   .num_stds = TVP514X_NUM_STANDARDS,
> > +   .std_list = tvp514x_std_list,
> > +
> > +   .num_ctrls = TVP514X_NUM_CONTROLS,
> > +   .ctrl_list = tvp514x_ctrl_list,
> > +
> > +};
> > +
> > +static struct v4l2_int_device tvp514x_int_device = {
> > +   .module = THIS_MODULE,
> > +   .name = MODULE_NAME,
> > +   .priv = &tvp514x_dev,
> > +   .type = v4l2_int_type_slave,
> > +   .u = {
> > +         .slave = &tvp514x_slave,
> > +         },
> > +};
> > +
> > +/**
> > + * tvp514x_probe - decoder driver i2c probe handler
> > + * @client: i2c driver client device structure
> > + *
> > + * Register decoder as an i2c client device and V4L2
> > + * device.
> > + */
> > +static int
> > +tvp514x_probe(struct i2c_client *client, const struct
> i2c_device_id
> > *id) +{
> > +   struct tvp514x_decoder *decoder = &tvp514x_dev;
> > +   int err;
> > +
> > +   /* Check if the adapter supports the needed features */
> > +   if (!i2c_check_functionality(client->adapter,
> > I2C_FUNC_SMBUS_BYTE_DATA)) +                return -EIO;
> > +
> > +   decoder->pdata = client->dev.platform_data;
> > +   if (!decoder->pdata) {
> > +           v4l_err(client, "No platform data\n!!");
> > +           return -ENODEV;
> > +   }
> > +   /*
> > +    * Fetch platform specific data, and configure the
> > +    * tvp514x_reg_list[] accordingly. Since this is one
> > +    * time configuration, no need to preserve.
> > +    */
> > +   decoder->inputidx = decoder->pdata->default_input;
> > +   tvp514x_reg_list[REG_OUTPUT_FORMATTER2].val |=
> > +                   (decoder->pdata->clk_polarity << 1);
> > +   tvp514x_reg_list[REG_OUTPUT_FORMATTER1].val |=
> > +                   decoder->pdata->fmt;
> > +   tvp514x_reg_list[REG_SYNC_CONTROL].val |=
> > +                   ((decoder->pdata->hs_polarity << 2) |
> > +                   (decoder->pdata->vs_polarity << 3));
> > +   /*
> > +    * Save the id data, required for power up sequence
> > +    */
> > +   decoder->id = (struct i2c_device_id *)id;
> > +   /* Attach to Master */
> > +   strcpy(tvp514x_int_device.u.slave->attach_to,
> > decoder->pdata->master); +  decoder->v4l2_int_device =
> > &tvp514x_int_device;
> > +   decoder->client = client;
> > +   i2c_set_clientdata(client, decoder);
> > +
> > +   /* Register with V4L2 layer as slave device */
> > +   err = v4l2_int_device_register(decoder->v4l2_int_device);
> > +   if (err) {
> > +           i2c_set_clientdata(client, NULL);
> > +           v4l_err(client,
> > +                   "Unable to register to v4l2. Err[%d]\n", err);
> > +
> > +   } else
> > +           v4l_info(client, "Registered to v4l2 master %s!!\n",
> > +                           decoder->pdata->master);
> > +
> > +   return 0;
> > +}
> > +
> > +/**
> > + * tvp514x_remove - decoder driver i2c remove handler
> > + * @client: i2c driver client device structure
> > + *
> > + * Unregister decoder as an i2c client device and V4L2
> > + * device. Complement of tvp514x_probe().
> > + */
> > +static int __exit tvp514x_remove(struct i2c_client *client)
> > +{
> > +   struct tvp514x_decoder *decoder = i2c_get_clientdata(client);
> > +
> > +   if (!client->adapter)
> > +           return -ENODEV; /* our client isn't attached */
> > +
> > +   v4l2_int_device_unregister(decoder->v4l2_int_device);
> > +   i2c_set_clientdata(client, NULL);
> > +
> > +   return 0;
> > +}
> > +/*
> > + * TVP5146 Init/Power on Sequence
> > + */
> > +static struct tvp514x_reg tvp5146_init_reg_seq[] = {
> > +   {TOK_WRITE, REG_VBUS_ADDRESS_ACCESS1, 0x02},
> > +   {TOK_WRITE, REG_VBUS_ADDRESS_ACCESS2, 0x00},
> > +   {TOK_WRITE, REG_VBUS_ADDRESS_ACCESS3, 0x80},
> > +   {TOK_WRITE, REG_VBUS_DATA_ACCESS_NO_VBUS_ADDR_INCR, 0x01},
> > +   {TOK_WRITE, REG_VBUS_ADDRESS_ACCESS1, 0x60},
> > +   {TOK_WRITE, REG_VBUS_ADDRESS_ACCESS2, 0x00},
> > +   {TOK_WRITE, REG_VBUS_ADDRESS_ACCESS3, 0xB0},
> > +   {TOK_WRITE, REG_VBUS_DATA_ACCESS_NO_VBUS_ADDR_INCR, 0x01},
> > +   {TOK_WRITE, REG_VBUS_DATA_ACCESS_NO_VBUS_ADDR_INCR, 0x00},
> > +   {TOK_WRITE, REG_OPERATION_MODE, 0x01},
> > +   {TOK_WRITE, REG_OPERATION_MODE, 0x00},
> > +};
> > +static struct tvp514x_init_seq tvp5146_init = {
> > +   .no_regs = ARRAY_SIZE(tvp5146_init_reg_seq),
> > +   .init_reg_seq = tvp5146_init_reg_seq,
> > +};
> > +/*
> > + * TVP5147 Init/Power on Sequence
> > + */
> > +static struct tvp514x_reg tvp5147_init_reg_seq[] = {
> > +   {TOK_WRITE, REG_VBUS_ADDRESS_ACCESS1, 0x02},
> > +   {TOK_WRITE, REG_VBUS_ADDRESS_ACCESS2, 0x00},
> > +   {TOK_WRITE, REG_VBUS_ADDRESS_ACCESS3, 0x80},
> > +   {TOK_WRITE, REG_VBUS_DATA_ACCESS_NO_VBUS_ADDR_INCR, 0x01},
> > +   {TOK_WRITE, REG_VBUS_ADDRESS_ACCESS1, 0x60},
> > +   {TOK_WRITE, REG_VBUS_ADDRESS_ACCESS2, 0x00},
> > +   {TOK_WRITE, REG_VBUS_ADDRESS_ACCESS3, 0xB0},
> > +   {TOK_WRITE, REG_VBUS_DATA_ACCESS_NO_VBUS_ADDR_INCR, 0x01},
> > +   {TOK_WRITE, REG_VBUS_ADDRESS_ACCESS1, 0x16},
> > +   {TOK_WRITE, REG_VBUS_ADDRESS_ACCESS2, 0x00},
> > +   {TOK_WRITE, REG_VBUS_ADDRESS_ACCESS3, 0xA0},
> > +   {TOK_WRITE, REG_VBUS_DATA_ACCESS_NO_VBUS_ADDR_INCR, 0x16},
> > +   {TOK_WRITE, REG_VBUS_ADDRESS_ACCESS1, 0x60},
> > +   {TOK_WRITE, REG_VBUS_ADDRESS_ACCESS2, 0x00},
> > +   {TOK_WRITE, REG_VBUS_ADDRESS_ACCESS3, 0xB0},
> > +   {TOK_WRITE, REG_VBUS_DATA_ACCESS_NO_VBUS_ADDR_INCR, 0x00},
> > +   {TOK_WRITE, REG_OPERATION_MODE, 0x01},
> > +   {TOK_WRITE, REG_OPERATION_MODE, 0x00},
> > +};
> > +static struct tvp514x_init_seq tvp5147_init = {
> > +   .no_regs = ARRAY_SIZE(tvp5147_init_reg_seq),
> > +   .init_reg_seq = tvp5147_init_reg_seq,
> > +};
> > +/*
> > + * TVP5146M2/TVP5147M1 Init/Power on Sequence
> > + */
> > +static struct tvp514x_reg tvp514xm_init_reg_seq[] = {
> > +   {TOK_WRITE, REG_OPERATION_MODE, 0x01},
> > +   {TOK_WRITE, REG_OPERATION_MODE, 0x00},
> > +};
> > +static struct tvp514x_init_seq tvp514xm_init = {
> > +   .no_regs = ARRAY_SIZE(tvp514xm_init_reg_seq),
> > +   .init_reg_seq = tvp514xm_init_reg_seq,
> > +};
> > +/*
> > + * I2C Device Table -
> > + *
> > + * name - Name of the actual device/chip.
> > + * driver_data - Driver data
> > + */
> > +static const struct i2c_device_id tvp514x_id[] = {
> > +   {"tvp5146", (unsigned int)&tvp5146_init},
> > +   {"tvp5146m2", (unsigned int)&tvp514xm_init},
> > +   {"tvp5147", (unsigned int)&tvp5147_init},
> > +   {"tvp5147m1", (unsigned int)&tvp514xm_init},
> > +   {},
> > +};
> > +
> > +MODULE_DEVICE_TABLE(i2c, tvp514x_id);
> > +
> > +static struct i2c_driver tvp514x_i2c_driver = {
> > +   .driver = {
> > +              .name = MODULE_NAME,
> > +              .owner = THIS_MODULE,
> > +              },
> > +   .probe = tvp514x_probe,
> > +   .remove = __exit_p(tvp514x_remove),
> > +   .id_table = tvp514x_id,
> > +};
> > +
> > +/**
> > + * tvp514x_init
> > + *
> > + * Module init function
> > + */
> > +static int __init tvp514x_init(void)
> > +{
> > +   int err;
> > +
> > +   err = i2c_add_driver(&tvp514x_i2c_driver);
> > +   if (err) {
> > +           printk(KERN_ERR "Failed to register " MODULE_NAME
> ".\n");
> > +           return err;
> > +   }
> > +   return 0;
> > +}
> > +
> > +/**
> > + * tvp514x_cleanup
> > + *
> > + * Module exit function
> > + */
> > +static void __exit tvp514x_cleanup(void)
> > +{
> > +   i2c_del_driver(&tvp514x_i2c_driver);
> > +}
> > +
> > +module_init(tvp514x_init);
> > +module_exit(tvp514x_cleanup);
> > +
> > +MODULE_AUTHOR("Texas Instruments");
> > +MODULE_DESCRIPTION("TVP514X linux decoder driver");
> > +MODULE_LICENSE("GPL");
> > diff --git a/drivers/media/video/tvp514x_regs.h
> > b/drivers/media/video/tvp514x_regs.h new file mode 100755
> > index 0000000..003a3c1
> > --- /dev/null
> > +++ b/drivers/media/video/tvp514x_regs.h
> > @@ -0,0 +1,292 @@
> > +/*
> > + * drivers/media/video/tvp514x_regs.h
> > + *
> > + * Copyright (C) 2008 Texas Instruments Inc
> > + * Author: Vaibhav Hiremath <hvaibhav@ti.com>
> > + *
> > + * Contributors:
> > + *     Sivaraj R <sivaraj@ti.com>
> > + *     Brijesh R Jadav <brijesh.j@ti.com>
> > + *     Hardik Shah <hardik.shah@ti.com>
> > + *     Manjunath Hadli <mrh@ti.com>
> > + *     Karicheri Muralidharan <m-karicheri2@ti.com>
> > + *
> > + * This package is free software; you can redistribute it and/or
> > modify + * it under the terms of the GNU General Public License
> > version 2 as + * published by the Free Software Foundation.
> > + *
> > + * This program is distributed in the hope that it will be
> useful,
> > + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> > + * GNU General Public License for more details.
> > + *
> > + * You should have received a copy of the GNU General Public
> License
> > + * along with this program; if not, write to the Free Software
> > + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
> > + *
> > + */
> > +
> > +#ifndef _TVP514X_REGS_H
> > +#define _TVP514X_REGS_H
> > +
> > +/*
> > + * TVP5146/47 registers
> > + */
> > +#define REG_INPUT_SEL                      (0x00)
> > +#define REG_AFE_GAIN_CTRL          (0x01)
> > +#define REG_VIDEO_STD                      (0x02)
> > +#define REG_OPERATION_MODE         (0x03)
> > +#define REG_AUTOSWITCH_MASK                (0x04)
> > +
> > +#define REG_COLOR_KILLER           (0x05)
> > +#define REG_LUMA_CONTROL1          (0x06)
> > +#define REG_LUMA_CONTROL2          (0x07)
> > +#define REG_LUMA_CONTROL3          (0x08)
> > +
> > +#define REG_BRIGHTNESS                     (0x09)
> > +#define REG_CONTRAST                       (0x0A)
> > +#define REG_SATURATION                     (0x0B)
> > +#define REG_HUE                            (0x0C)
> > +
> > +#define REG_CHROMA_CONTROL1                (0x0D)
> > +#define REG_CHROMA_CONTROL2                (0x0E)
> > +
> > +/* 0x0F Reserved */
> > +
> > +#define REG_COMP_PR_SATURATION             (0x10)
> > +#define REG_COMP_Y_CONTRAST                (0x11)
> > +#define REG_COMP_PB_SATURATION             (0x12)
> > +
> > +/* 0x13 Reserved */
> > +
> > +#define REG_COMP_Y_BRIGHTNESS              (0x14)
> > +
> > +/* 0x15 Reserved */
> > +
> > +#define REG_AVID_START_PIXEL_LSB   (0x16)
> > +#define REG_AVID_START_PIXEL_MSB   (0x17)
> > +#define REG_AVID_STOP_PIXEL_LSB            (0x18)
> > +#define REG_AVID_STOP_PIXEL_MSB            (0x19)
> > +
> > +#define REG_HSYNC_START_PIXEL_LSB  (0x1A)
> > +#define REG_HSYNC_START_PIXEL_MSB  (0x1B)
> > +#define REG_HSYNC_STOP_PIXEL_LSB   (0x1C)
> > +#define REG_HSYNC_STOP_PIXEL_MSB   (0x1D)
> > +
> > +#define REG_VSYNC_START_LINE_LSB   (0x1E)
> > +#define REG_VSYNC_START_LINE_MSB   (0x1F)
> > +#define REG_VSYNC_STOP_LINE_LSB            (0x20)
> > +#define REG_VSYNC_STOP_LINE_MSB            (0x21)
> > +
> > +#define REG_VBLK_START_LINE_LSB            (0x22)
> > +#define REG_VBLK_START_LINE_MSB            (0x23)
> > +#define REG_VBLK_STOP_LINE_LSB             (0x24)
> > +#define REG_VBLK_STOP_LINE_MSB             (0x25)
> > +
> > +/* 0x26 - 0x27 Reserved */
> > +
> > +#define REG_FAST_SWTICH_CONTROL            (0x28)
> > +
> > +/* 0x29 Reserved */
> > +
> > +#define REG_FAST_SWTICH_SCART_DELAY        (0x2A)
> > +
> > +/* 0x2B Reserved */
> > +
> > +#define REG_SCART_DELAY                    (0x2C)
> > +#define REG_CTI_DELAY                      (0x2D)
> > +#define REG_CTI_CONTROL                    (0x2E)
> > +
> > +/* 0x2F - 0x31 Reserved */
> > +
> > +#define REG_SYNC_CONTROL           (0x32)
> > +#define REG_OUTPUT_FORMATTER1              (0x33)
> > +#define REG_OUTPUT_FORMATTER2              (0x34)
> > +#define REG_OUTPUT_FORMATTER3              (0x35)
> > +#define REG_OUTPUT_FORMATTER4              (0x36)
> > +#define REG_OUTPUT_FORMATTER5              (0x37)
> > +#define REG_OUTPUT_FORMATTER6              (0x38)
> > +#define REG_CLEAR_LOST_LOCK                (0x39)
> > +
> > +#define REG_STATUS1                        (0x3A)
> > +#define REG_STATUS2                        (0x3B)
> > +
> > +#define REG_AGC_GAIN_STATUS_LSB            (0x3C)
> > +#define REG_AGC_GAIN_STATUS_MSB            (0x3D)
> > +
> > +/* 0x3E Reserved */
> > +
> > +#define REG_VIDEO_STD_STATUS               (0x3F)
> > +#define REG_GPIO_INPUT1                    (0x40)
> > +#define REG_GPIO_INPUT2                    (0x41)
> > +
> > +/* 0x42 - 0x45 Reserved */
> > +
> > +#define REG_AFE_COARSE_GAIN_CH1            (0x46)
> > +#define REG_AFE_COARSE_GAIN_CH2            (0x47)
> > +#define REG_AFE_COARSE_GAIN_CH3            (0x48)
> > +#define REG_AFE_COARSE_GAIN_CH4            (0x49)
> > +
> > +#define REG_AFE_FINE_GAIN_PB_B_LSB (0x4A)
> > +#define REG_AFE_FINE_GAIN_PB_B_MSB (0x4B)
> > +#define REG_AFE_FINE_GAIN_Y_G_CHROMA_LSB   (0x4C)
> > +#define REG_AFE_FINE_GAIN_Y_G_CHROMA_MSB   (0x4D)
> > +#define REG_AFE_FINE_GAIN_PR_R_LSB (0x4E)
> > +#define REG_AFE_FINE_GAIN_PR_R_MSB (0x4F)
> > +#define REG_AFE_FINE_GAIN_CVBS_LUMA_LSB    (0x50)
> > +#define REG_AFE_FINE_GAIN_CVBS_LUMA_MSB    (0x51)
> > +
> > +/* 0x52 - 0x68 Reserved */
> > +
> > +#define REG_FBIT_VBIT_CONTROL1             (0x69)
> > +
> > +/* 0x6A - 0x6B Reserved */
> > +
> > +#define REG_BACKEND_AGC_CONTROL            (0x6C)
> > +
> > +/* 0x6D - 0x6E Reserved */
> > +
> > +#define REG_AGC_DECREMENT_SPEED_CONTROL    (0x6F)
> > +#define REG_ROM_VERSION                    (0x70)
> > +
> > +/* 0x71 - 0x73 Reserved */
> > +
> > +#define REG_AGC_WHITE_PEAK_PROCESSING      (0x74)
> > +#define REG_FBIT_VBIT_CONTROL2             (0x75)
> > +#define REG_VCR_TRICK_MODE_CONTROL (0x76)
> > +#define REG_HORIZONTAL_SHAKE_INCREMENT     (0x77)
> > +#define REG_AGC_INCREMENT_SPEED            (0x78)
> > +#define REG_AGC_INCREMENT_DELAY            (0x79)
> > +
> > +/* 0x7A - 0x7F Reserved */
> > +
> > +#define REG_CHIP_ID_MSB                    (0x80)
> > +#define REG_CHIP_ID_LSB                    (0x81)
> > +
> > +/* 0x82 Reserved */
> > +
> > +#define REG_CPLL_SPEED_CONTROL             (0x83)
> > +
> > +/* 0x84 - 0x96 Reserved */
> > +
> > +#define REG_STATUS_REQUEST         (0x97)
> > +
> > +/* 0x98 - 0x99 Reserved */
> > +
> > +#define REG_VERTICAL_LINE_COUNT_LSB        (0x9A)
> > +#define REG_VERTICAL_LINE_COUNT_MSB        (0x9B)
> > +
> > +/* 0x9C - 0x9D Reserved */
> > +
> > +#define REG_AGC_DECREMENT_DELAY            (0x9E)
> > +
> > +/* 0x9F - 0xB0 Reserved */
> > +
> > +#define REG_VDP_TTX_FILTER_1_MASK1 (0xB1)
> > +#define REG_VDP_TTX_FILTER_1_MASK2 (0xB2)
> > +#define REG_VDP_TTX_FILTER_1_MASK3 (0xB3)
> > +#define REG_VDP_TTX_FILTER_1_MASK4 (0xB4)
> > +#define REG_VDP_TTX_FILTER_1_MASK5 (0xB5)
> > +#define REG_VDP_TTX_FILTER_2_MASK1 (0xB6)
> > +#define REG_VDP_TTX_FILTER_2_MASK2 (0xB7)
> > +#define REG_VDP_TTX_FILTER_2_MASK3 (0xB8)
> > +#define REG_VDP_TTX_FILTER_2_MASK4 (0xB9)
> > +#define REG_VDP_TTX_FILTER_2_MASK5 (0xBA)
> > +#define REG_VDP_TTX_FILTER_CONTROL (0xBB)
> > +#define REG_VDP_FIFO_WORD_COUNT            (0xBC)
> > +#define REG_VDP_FIFO_INTERRUPT_THRLD       (0xBD)
> > +
> > +/* 0xBE Reserved */
> > +
> > +#define REG_VDP_FIFO_RESET         (0xBF)
> > +#define REG_VDP_FIFO_OUTPUT_CONTROL        (0xC0)
> > +#define REG_VDP_LINE_NUMBER_INTERRUPT      (0xC1)
> > +#define REG_VDP_PIXEL_ALIGNMENT_LSB        (0xC2)
> > +#define REG_VDP_PIXEL_ALIGNMENT_MSB        (0xC3)
> > +
> > +/* 0xC4 - 0xD5 Reserved */
> > +
> > +#define REG_VDP_LINE_START         (0xD6)
> > +#define REG_VDP_LINE_STOP          (0xD7)
> > +#define REG_VDP_GLOBAL_LINE_MODE   (0xD8)
> > +#define REG_VDP_FULL_FIELD_ENABLE  (0xD9)
> > +#define REG_VDP_FULL_FIELD_MODE            (0xDA)
> > +
> > +/* 0xDB - 0xDF Reserved */
> > +
> > +#define REG_VBUS_DATA_ACCESS_NO_VBUS_ADDR_INCR     (0xE0)
> > +#define REG_VBUS_DATA_ACCESS_VBUS_ADDR_INCR        (0xE1)
> > +#define REG_FIFO_READ_DATA                 (0xE2)
> > +
> > +/* 0xE3 - 0xE7 Reserved */
> > +
> > +#define REG_VBUS_ADDRESS_ACCESS1   (0xE8)
> > +#define REG_VBUS_ADDRESS_ACCESS2   (0xE9)
> > +#define REG_VBUS_ADDRESS_ACCESS3   (0xEA)
> > +
> > +/* 0xEB - 0xEF Reserved */
> > +
> > +#define REG_INTERRUPT_RAW_STATUS0  (0xF0)
> > +#define REG_INTERRUPT_RAW_STATUS1  (0xF1)
> > +#define REG_INTERRUPT_STATUS0              (0xF2)
> > +#define REG_INTERRUPT_STATUS1              (0xF3)
> > +#define REG_INTERRUPT_MASK0                (0xF4)
> > +#define REG_INTERRUPT_MASK1                (0xF5)
> > +#define REG_INTERRUPT_CLEAR0               (0xF6)
> > +#define REG_INTERRUPT_CLEAR1               (0xF7)
> > +
> > +/* 0xF8 - 0xFF Reserved */
> > +
> > +/*
> > + * Mask and bit definitions of TVP5146/47 registers
> > + */
> > +/* The ID values we are looking for */
> > +#define TVP514X_CHIP_ID_MSB                (0x51)
> > +#define TVP5146_CHIP_ID_LSB                (0x46)
> > +#define TVP5147_CHIP_ID_LSB                (0x47)
> > +
> > +#define VIDEO_STD_MASK                     (0x07)
> > +#define VIDEO_STD_AUTO_SWITCH_BIT  (0x00)
> > +#define VIDEO_STD_NTSC_MJ_BIT              (0x01)
> > +#define VIDEO_STD_PAL_BDGHIN_BIT   (0x02)
> > +#define VIDEO_STD_PAL_M_BIT                (0x03)
> > +#define VIDEO_STD_PAL_COMBINATION_N_BIT    (0x04)
> > +#define VIDEO_STD_NTSC_4_43_BIT            (0x05)
> > +#define VIDEO_STD_SECAM_BIT                (0x06)
> > +#define VIDEO_STD_PAL_60_BIT               (0x07)
> > +
> > +/*
> > + * Status bit
> > + */
> > +#define STATUS_TV_VCR_BIT          (1<<0)
> > +#define STATUS_HORZ_SYNC_LOCK_BIT  (1<<1)
> > +#define STATUS_VIRT_SYNC_LOCK_BIT  (1<<2)
> > +#define STATUS_CLR_SUBCAR_LOCK_BIT (1<<3)
> > +#define STATUS_LOST_LOCK_DETECT_BIT        (1<<4)
> > +#define STATUS_FEILD_RATE_BIT              (1<<5)
> > +#define STATUS_LINE_ALTERNATING_BIT        (1<<6)
> > +#define STATUS_PEAK_WHITE_DETECT_BIT       (1<<7)
> > +
> > +/**
> > + * struct tvp514x_reg - Structure for TVP5146/47 register
> > initialization values + * @token - Token: TOK_WRITE, TOK_TERM
> etc..
> > + * @reg - Register offset
> > + * @val - Register Value for TOK_WRITE or delay in ms for
> TOK_DELAY
> > + */
> > +struct tvp514x_reg {
> > +   u8 token;
> > +   u8 reg;
> > +   u32 val;
> > +};
> > +
> > +/**
> > + * struct tvp514x_init_seq - Structure for TVP5146/47/46M2/47M1
> > power up + *                Sequence.
> > + * @ no_regs - Number of registers to write for power up
> sequence.
> > + * @ init_reg_seq - Array of registers and respective value to
> > write. + */
> > +struct tvp514x_init_seq {
> > +   unsigned int no_regs;
> > +   struct tvp514x_reg *init_reg_seq;
> > +};
> > +#endif                             /* ifndef _TVP514X_REGS_H */
> > diff --git a/include/media/tvp514x.h b/include/media/tvp514x.h
> > new file mode 100755
> > index 0000000..2fee5e7
> > --- /dev/null
> > +++ b/include/media/tvp514x.h
> > @@ -0,0 +1,232 @@
> > +/*
> > + * drivers/media/video/tvp514x.h
> > + *
> > + * Copyright (C) 2008 Texas Instruments Inc
> > + * Author: Vaibhav Hiremath <hvaibhav@ti.com>
> > + *
> > + * Contributors:
> > + *     Sivaraj R <sivaraj@ti.com>
> > + *     Brijesh R Jadav <brijesh.j@ti.com>
> > + *     Hardik Shah <hardik.shah@ti.com>
> > + *     Manjunath Hadli <mrh@ti.com>
> > + *     Karicheri Muralidharan <m-karicheri2@ti.com>
> > + *
> > + * This package is free software; you can redistribute it and/or
> > modify + * it under the terms of the GNU General Public License
> > version 2 as + * published by the Free Software Foundation.
> > + *
> > + * This program is distributed in the hope that it will be
> useful,
> > + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> > + * GNU General Public License for more details.
> > + *
> > + * You should have received a copy of the GNU General Public
> License
> > + * along with this program; if not, write to the Free Software
> > + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
> > + *
> > + */
> > +
> > +#ifndef _TVP514X_H
> > +#define _TVP514X_H
> > +
> > +/*
> > + * Other macros
> > + */
> > +#define TVP514X_MODULE_NAME                "tvp514x"
> > +#define TVP514X_I2C_DELAY          (3)
> > +#define I2C_RETRY_COUNT                    (5)
> > +#define LOCK_RETRY_COUNT           (5)
> > +#define LOCK_RETRY_DELAY           (200)
> > +
> > +#define TOK_WRITE                  (0)     /* token for write
> operation */
> > +#define TOK_TERM                   (1)     /* terminating token */
> > +#define TOK_DELAY                  (2)     /* delay token for reg
> list */
> > +#define TOK_SKIP                   (3)     /* token to skip a
> register */
> > +
> > +#define TVP514X_XCLK_BT656         (27000000)
> > +
> > +/* Number of pixels and number of lines per frame for different
> > standards */ +#define NTSC_NUM_ACTIVE_PIXELS                (720)
> > +#define NTSC_NUM_ACTIVE_LINES              (480)
> > +#define PAL_NUM_ACTIVE_PIXELS              (720)
> > +#define PAL_NUM_ACTIVE_LINES               (576)
> > +
> > +/**
> > + * enum tvp514x_std - enum for supported standards
> > + */
> > +enum tvp514x_std {
> > +   STD_NTSC_MJ = 0,
> > +   STD_PAL_BDGHIN,
> > +   STD_INVALID
> > +};
> > +
> > +/**
> > + * enum tvp514x_state - enum for different decoder states
> > + */
> > +enum tvp514x_state {
> > +   STATE_NOT_DETECTED,
> > +   STATE_DETECTED
> > +};
> > +
> > +/**
> > + * enum tvp514x_input - enum for different decoder input pin
> > + *         configuration.
> > + */
> > +enum tvp514x_input {
> > +   /*
> > +    * CVBS input selection
> > +    */
> > +   INPUT_CVBS_VI1A = 0x0,
> > +   INPUT_CVBS_VI1B,
> > +   INPUT_CVBS_VI1C,
> > +   INPUT_CVBS_VI2A = 0x04,
> > +   INPUT_CVBS_VI2B,
> > +   INPUT_CVBS_VI2C,
> > +   INPUT_CVBS_VI3A = 0x08,
> > +   INPUT_CVBS_VI3B,
> > +   INPUT_CVBS_VI3C,
> > +   INPUT_CVBS_VI4A = 0x0C,
> > +   /*
> > +    * S-Video input selection
> > +    */
> > +   INPUT_SVIDEO_VI2A_VI1A = 0x44,
> > +   INPUT_SVIDEO_VI2B_VI1B,
> > +   INPUT_SVIDEO_VI2C_VI1C,
> > +   INPUT_SVIDEO_VI2A_VI3A = 0x54,
> > +   INPUT_SVIDEO_VI2B_VI3B,
> > +   INPUT_SVIDEO_VI2C_VI3C,
> > +   INPUT_SVIDEO_VI4A_VI1A = 0x4C,
> > +   INPUT_SVIDEO_VI4A_VI1B,
> > +   INPUT_SVIDEO_VI4A_VI1C,
> > +   INPUT_SVIDEO_VI4A_VI3A = 0x5C,
> > +   INPUT_SVIDEO_VI4A_VI3B,
> > +   INPUT_SVIDEO_VI4A_VI3C
> > +
> > +   /* Need to add entries for
> > +    * RGB, YPbPr and SCART.
> > +    */
> > +};
> > +
> > +/**
> > + * enum tvp514x_output_fmt - enum for output format
> > + *                 supported.
> > + */
> > +enum tvp514x_output_fmt {
> > +   OUTPUT_10BIT_422_EMBEDDED_SYNC = 0,
> > +   OUTPUT_20BIT_422_SEPERATE_SYNC,
> > +   OUTPUT_10BIT_422_SEPERATE_SYNC = 3,
> > +   OUTPUT_INVALID
> > +};
> > +
> > +/**
> > + * struct tvp514x_std_info - Structure to store standard
> > informations + * @width: Line width in pixels
> > + * @height:Number of active lines
> > + * @video_std: Value to write in REG_VIDEO_STD register
> > + * @standard: v4l2 standard structure information
> > + */
> > +struct tvp514x_std_info {
> > +   unsigned long width;
> > +   unsigned long height;
> > +   u8 video_std;
> > +   struct v4l2_standard standard;
> > +};
> > +
> > +/**
> > + * struct tvp514x_ctrl_info - Information regarding supported
> > controls + * @reg_address: Register offset of control register
> > + * @query_ctrl: v4l2 query control information
> > + */
> > +struct tvp514x_ctrl_info {
> > +   u8 reg_address;
> > +   struct v4l2_queryctrl query_ctrl;
> > +};
> > +
> > +/**
> > + * struct tvp514x_input_info - Information regarding supported
> > inputs + * @input_sel: Input select register
> > + * @lock_mask: lock mask - depends on Svideo/CVBS
> > + * @input: v4l2 input information
> > + */
> > +struct tvp514x_input_info {
> > +   enum tvp514x_input input_sel;
> > +   struct v4l2_input input;
> > +};
> > +
> > +/**
> > + * struct tvp514x_platform_data - Platform data values and access
> > functions + * @power_set: Power state access function, zero is
> off,
> > non-zero is on. + * @ifparm: Interface parameters access function
> > + * @priv_data_set: Device private data (pointer) access function
> > + * @reg_list: The board dependent driver should fill the default
> > value for + *            required registers depending on board
> > layout. The TVP5146/47 + *            driver will update this
> > register list for the registers + *            whose values should
> be
> > maintained across open()/close() like + *            setting
> > brightness as defined in V4L2.
> > + *            The register list should be in the same order as
> > defined in + *            TVP5146/47 datasheet including reserved
> > registers. As of now + *            the driver expects the size of
> > this list to be a minimum of + *            57 + 1 (upto regsiter
> > REG_CLEAR_LOST_LOCK).
> > + *            The last member should be of the list should be
> > + *            {TOK_TERM, 0, 0} to indicate the end of register
> list.
> > + * @num_inputs: Number of input connection in board
> > + * @input_list: Input information list for num_inputs
> > + */
> > +struct tvp514x_platform_data {
> > +   char *master;
> > +   int (*power_set) (enum v4l2_power on);
> > +   int (*ifparm) (struct v4l2_ifparm *p);
> > +   int (*priv_data_set) (void *);
> > +   /* Input params */
> > +   int num_inputs;
> > +   const struct tvp514x_input_info *input_list;
> > +   int default_input;
> > +   /* Interface control params */
> > +   enum tvp514x_output_fmt fmt;
> > +   bool clk_polarity;
> > +   bool hs_polarity;
> > +   bool vs_polarity;
> > +};
> > +
> > +/**
> > + * struct tvp514x_decoded - TVP5146/47 decoder object
> > + * @v4l2_int_device: Slave handle
> > + * @pdata: Board specific
> > + * @client: I2C client data
> > + * @id: Entry from I2C table
> > + * @ver: Chip version
> > + * @state: TVP5146/47 decoder state - detected or not-detected
> > + * @pix: Current pixel format
> > + * @num_fmts: Number of formats
> > + * @fmt_list: Format list
> > + * @current_std: Current standard
> > + * @num_stds: Number of standards
> > + * @std_list: Standards list
> > + * @num_ctrls: Number of controls
> > + * @ctrl_list: Control list
> > + */
> > +struct tvp514x_decoder {
> > +   struct v4l2_int_device *v4l2_int_device;
> > +   const struct tvp514x_platform_data *pdata;
> > +   struct i2c_client *client;
> > +
> > +   struct i2c_device_id *id;
> > +
> > +   int ver;
> > +   enum tvp514x_state state;
> > +
> > +   struct v4l2_pix_format pix;
> > +   int num_fmts;
> > +   const struct v4l2_fmtdesc *fmt_list;
> > +
> > +   enum tvp514x_std current_std;
> > +   int num_stds;
> > +   struct tvp514x_std_info *std_list;
> > +
> > +   int num_ctrls;
> > +   const struct tvp514x_ctrl_info *ctrl_list;
> > +
> > +   int inputidx;
> > +};
> > +
> > +#endif                             /* ifndef _TVP514X_H */
> > --
> > 1.5.6
> >
> > --
> > video4linux-list mailing list
> > Unsubscribe
> > mailto:video4linux-list-request@redhat.com?subject=unsubscribe
> > https://www.redhat.com/mailman/listinfo/video4linux-list
>
>
>
> --
> Hans Verkuil - video4linux developer - sponsored by TANDBERG


--
video4linux-list mailing list
Unsubscribe mailto:video4linux-list-request@redhat.com?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list

^ permalink raw reply	[flat|nested] 263+ messages in thread

* RE: [PATCH 2/2] TVP514x Driver with Review comments fixed [V4]
@ 2008-12-03  3:58       ` Hiremath, Vaibhav
  0 siblings, 0 replies; 263+ messages in thread
From: Hiremath, Vaibhav @ 2008-12-03  3:58 UTC (permalink / raw)
  To: Hans Verkuil, video4linux-list
  Cc: davinci-linux-open-source-bounces, Karicheri, Muralidharan, linux-omap



Thanks,
Vaibhav Hiremath

> -----Original Message-----
> From: Hans Verkuil [mailto:hverkuil@xs4all.nl]
> Sent: Tuesday, December 02, 2008 10:50 PM
> To: video4linux-list@redhat.com
> Cc: Hiremath, Vaibhav; davinci-linux-open-source-
> bounces@linux.davincidsp.com; Karicheri, Muralidharan; linux-
> omap@vger.kernel.org
> Subject: Re: [PATCH 2/2] TVP514x Driver with Review comments fixed
> [V4]
>
> Hi Vaibhav,
>
> I'm sorry, but this is still wrong. You basically renamed s_input
> with
> s_routing while still using the list with user inputs from the
> platform
> data.
>
> These three fields in struct tvp514x_platform_data should be removed
> as
> they do not belong here:
>
> > +   /* Input params */
> > +   int num_inputs;
> > +   const struct tvp514x_input_info *input_list;
> > +   int default_input;
>
> This is all high-level stuff that does not belong in an i2c driver.
> It's
> the master driver that has to translate the input as specified by
> the
> user to a pin of the tvp514x (like INPUT_CVBS_VI1A).
>
> Also, ioctl_g_routing() can be removed as I have yet to see a master
> driver that is interested in obtaining this information. Besides,
> that
> function looks very strange because it is calling ioctl_s_routing. A
> get function that sets something?!?
>
> Eventually the whole tvp514x_platform_data will have to be removed.
> Everything that's in there should be passed to the i2c driver using
> v4l2_subdev ops. But that's something for the future.
>
[Hiremath, Vaibhav] Definitely, as you mentioned eventually the platform data dependency from TVP driver will be removed. But I will have to start with master driver to do it, since now platform data will go to master driver which will maintain list or table at his level.

I think yesterday on chat I had mentioned clearly that, simultaneously I will have to start with master driver which will automatically address your all comments, like -

        - g_routing: Since this will get handled at master level no need to support at slave or TVP level.
        - s_routing: The input params will change to v4l2_routing, and argument will come directly from master. Master will now include "tvp514x.h" file to pass appropriate routing data.
        - tvp514x_platform_data: Again, the data related to input will go to master.

Since it would take good amount of change and time, I thought to get reviewed first and while submitting master driver anyway I will have to change.

I believe once master driver becomes slave aware (including tvp514x.h); all issues automatically will get addressed.

Probably I missed to mention all these points in the patch, which lead to confusion.

Hope this clears.

> I'm available in the #v4l IRC channel tomorrow for further
> discussions
> on this.
>
> BTW1, struct tvp514x_decoder shouldn't be in
> include/media/tvp514x.h.
> It's internal to the driver (at least, I sincerely hope so), so it
> can
> be moved to either the source or the tvp514x_regs.h header.
>
> BTW2, I'm not going to make it a blocking issue, but those callback
> functions in tvp514x_platform_data are horrible. The priv_data_set
> callback is the clearest example of what's wrong with this design: a
> master driver calls ioctl_g_priv in tvp whose only action is to call
> priv_data_set in the platform code! The master driver shouldn't have
> to
> go through the i2c driver for that! The only reason a low level v4l
> i2c
> driver would ever make a call to higher level code is for
> notifications.
>
> Regards,
>
>       Hans
>
> On Tuesday 02 December 2008 16:35:42 hvaibhav@ti.com wrote:
> > From: Vaibhav Hiremath <hvaibhav@ti.com>
> >
> > I have fixed all the review commentsreceived so far.
> > Here are the details -
> >
> > FIXSES:
> >     Make use of i2c_smbus_read/write_byte API:
> >         Probe function now checks for SMBUS capability,
> >     and read/write functions make use of the above API.
> >
> >     Error check for I2C Read/Write:
> >         Added error condition check for both read and write
> >     API.
> >     This has been added for completeness.
> >
> >     input set/get ioctl:
> >         As we do have support for set and get routing ioctl,
> >     instead of adding new ioctl used them.
> >
> >     enum_ioctl:
> >         After discussing with Hans verkuil, came to conclusion
> >     that as of now just remove support for enum_ioctl from
> >     decoder, since this has to handle at master driver level.
> >
> > TODO LIST:
> >     OMAP Master capture driver:
> >         This should be completely aligned with the current
> >     discussion.
> >
> >     Migration to sub_device framework:
> >         Immediately after all the above task, migrate both
> >     Master and slave driver to sub_device framework.
> >
> > Signed-off-by: Brijesh Jadav <brijesh.j@ti.com>
> > Signed-off-by: Hardik Shah <hardik.shah@ti.com>
> > Signed-off-by: Manjunath Hadli <mrh@ti.com>
> > Signed-off-by: R Sivaraj <sivaraj@ti.com>
> > Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
> > Signed-off-by: Karicheri Muralidharan <m-karicheri2@ti.com>
> > ---
> >  drivers/media/video/Kconfig        |   11 +
> >  drivers/media/video/Makefile       |    1 +
> >  drivers/media/video/tvp514x.c      | 1521
> > ++++++++++++++++++++++++++++++++++++
> > drivers/media/video/tvp514x_regs.h |  292 +++++++
> >  include/media/tvp514x.h            |  232 ++++++
> >  5 files changed, 2057 insertions(+), 0 deletions(-)
> >  create mode 100755 drivers/media/video/tvp514x.c
> >  create mode 100755 drivers/media/video/tvp514x_regs.h
> >  create mode 100755 include/media/tvp514x.h
> >
> > diff --git a/drivers/media/video/Kconfig
> > b/drivers/media/video/Kconfig index 47102c2..2e5dc3e 100644
> > --- a/drivers/media/video/Kconfig
> > +++ b/drivers/media/video/Kconfig
> > @@ -361,6 +361,17 @@ config VIDEO_SAA7191
> >       To compile this driver as a module, choose M here: the
> >       module will be called saa7191.
> >
> > +config VIDEO_TVP514X
> > +   tristate "Texas Instruments TVP514x video decoder"
> > +   depends on VIDEO_V4L2 && I2C
> > +   ---help---
> > +     This is a Video4Linux2 sensor-level driver for the TI
> TVP5146/47
> > +     decoder. It is currently working with the TI OMAP3 camera
> > +     controller.
> > +
> > +     To compile this driver as a module, choose M here: the
> > +     module will be called tvp514x.
> > +
> >  config VIDEO_TVP5150
> >     tristate "Texas Instruments TVP5150 video decoder"
> >     depends on VIDEO_V4L2 && I2C
> > diff --git a/drivers/media/video/Makefile
> > b/drivers/media/video/Makefile index 16962f3..cdbbf38 100644
> > --- a/drivers/media/video/Makefile
> > +++ b/drivers/media/video/Makefile
> > @@ -66,6 +66,7 @@ obj-$(CONFIG_VIDEO_CX88) += cx88/
> >  obj-$(CONFIG_VIDEO_EM28XX) += em28xx/
> >  obj-$(CONFIG_VIDEO_USBVISION) += usbvision/
> >  obj-$(CONFIG_VIDEO_TVP5150) += tvp5150.o
> > +obj-$(CONFIG_VIDEO_TVP514X) += tvp514x.o
> >  obj-$(CONFIG_VIDEO_PVRUSB2) += pvrusb2/
> >  obj-$(CONFIG_VIDEO_MSP3400) += msp3400.o
> >  obj-$(CONFIG_VIDEO_CS5345) += cs5345.o
> > diff --git a/drivers/media/video/tvp514x.c
> > b/drivers/media/video/tvp514x.c new file mode 100755
> > index 0000000..c0834e4
> > --- /dev/null
> > +++ b/drivers/media/video/tvp514x.c
> > @@ -0,0 +1,1521 @@
> > +/*
> > + * drivers/media/video/tvp514x.c
> > + *
> > + * TI TVP5146/47 decoder driver
> > + *
> > + * Copyright (C) 2008 Texas Instruments Inc
> > + * Author: Vaibhav Hiremath <hvaibhav@ti.com>
> > + *
> > + * Contributors:
> > + *     Sivaraj R <sivaraj@ti.com>
> > + *     Brijesh R Jadav <brijesh.j@ti.com>
> > + *     Hardik Shah <hardik.shah@ti.com>
> > + *     Manjunath Hadli <mrh@ti.com>
> > + *     Karicheri Muralidharan <m-karicheri2@ti.com>
> > + *
> > + * This package is free software; you can redistribute it and/or
> > modify + * it under the terms of the GNU General Public License
> > version 2 as + * published by the Free Software Foundation.
> > + *
> > + * This program is distributed in the hope that it will be
> useful,
> > + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> > + * GNU General Public License for more details.
> > + *
> > + * You should have received a copy of the GNU General Public
> License
> > + * along with this program; if not, write to the Free Software
> > + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
> > + *
> > + */
> > +
> > +#include <linux/i2c.h>
> > +#include <linux/delay.h>
> > +#include <linux/videodev2.h>
> > +#include <media/v4l2-int-device.h>
> > +#include <media/tvp514x.h>
> > +
> > +#include "tvp514x_regs.h"
> > +
> > +#define MODULE_NAME        TVP514X_MODULE_NAME
> > +
> > +/* Debug functions */
> > +static int debug;
> > +module_param(debug, bool, 0644);
> > +MODULE_PARM_DESC(debug, "Debug level (0-1)");
> > +
> > +#define dump_reg(client, reg, val)                         \
> > +   do {                                                    \
> > +           val = tvp514x_read_reg(client, reg);            \
> > +           v4l_info(client, "Reg(0x%.2X): 0x%.2X\n", reg, val); \
> > +   } while (0)
> > +
> > +
> > +/* TVP514x default register values */
> > +static struct tvp514x_reg tvp514x_reg_list[] = {
> > +   {TOK_WRITE, REG_INPUT_SEL, 0x05},       /* Composite selected */
> > +   {TOK_WRITE, REG_AFE_GAIN_CTRL, 0x0F},
> > +   {TOK_WRITE, REG_VIDEO_STD, 0x00},       /* Auto mode */
> > +   {TOK_WRITE, REG_OPERATION_MODE, 0x00},
> > +   {TOK_SKIP, REG_AUTOSWITCH_MASK, 0x3F},
> > +   {TOK_WRITE, REG_COLOR_KILLER, 0x10},
> > +   {TOK_WRITE, REG_LUMA_CONTROL1, 0x00},
> > +   {TOK_WRITE, REG_LUMA_CONTROL2, 0x00},
> > +   {TOK_WRITE, REG_LUMA_CONTROL3, 0x02},
> > +   {TOK_WRITE, REG_BRIGHTNESS, 0x80},
> > +   {TOK_WRITE, REG_CONTRAST, 0x80},
> > +   {TOK_WRITE, REG_SATURATION, 0x80},
> > +   {TOK_WRITE, REG_HUE, 0x00},
> > +   {TOK_WRITE, REG_CHROMA_CONTROL1, 0x00},
> > +   {TOK_WRITE, REG_CHROMA_CONTROL2, 0x0E},
> > +   {TOK_SKIP, 0x0F, 0x00}, /* Reserved */
> > +   {TOK_WRITE, REG_COMP_PR_SATURATION, 0x80},
> > +   {TOK_WRITE, REG_COMP_Y_CONTRAST, 0x80},
> > +   {TOK_WRITE, REG_COMP_PB_SATURATION, 0x80},
> > +   {TOK_SKIP, 0x13, 0x00}, /* Reserved */
> > +   {TOK_WRITE, REG_COMP_Y_BRIGHTNESS, 0x80},
> > +   {TOK_SKIP, 0x15, 0x00}, /* Reserved */
> > +   {TOK_SKIP, REG_AVID_START_PIXEL_LSB, 0x55},     /* NTSC timing
> */
> > +   {TOK_SKIP, REG_AVID_START_PIXEL_MSB, 0x00},
> > +   {TOK_SKIP, REG_AVID_STOP_PIXEL_LSB, 0x25},
> > +   {TOK_SKIP, REG_AVID_STOP_PIXEL_MSB, 0x03},
> > +   {TOK_SKIP, REG_HSYNC_START_PIXEL_LSB, 0x00},    /* NTSC timing
> */
> > +   {TOK_SKIP, REG_HSYNC_START_PIXEL_MSB, 0x00},
> > +   {TOK_SKIP, REG_HSYNC_STOP_PIXEL_LSB, 0x40},
> > +   {TOK_SKIP, REG_HSYNC_STOP_PIXEL_MSB, 0x00},
> > +   {TOK_SKIP, REG_VSYNC_START_LINE_LSB, 0x04},     /* NTSC timing
> */
> > +   {TOK_SKIP, REG_VSYNC_START_LINE_MSB, 0x00},
> > +   {TOK_SKIP, REG_VSYNC_STOP_LINE_LSB, 0x07},
> > +   {TOK_SKIP, REG_VSYNC_STOP_LINE_MSB, 0x00},
> > +   {TOK_SKIP, REG_VBLK_START_LINE_LSB, 0x01},      /* NTSC timing
> */
> > +   {TOK_SKIP, REG_VBLK_START_LINE_MSB, 0x00},
> > +   {TOK_SKIP, REG_VBLK_STOP_LINE_LSB, 0x15},
> > +   {TOK_SKIP, REG_VBLK_STOP_LINE_MSB, 0x00},
> > +   {TOK_SKIP, 0x26, 0x00}, /* Reserved */
> > +   {TOK_SKIP, 0x27, 0x00}, /* Reserved */
> > +   {TOK_SKIP, REG_FAST_SWTICH_CONTROL, 0xCC},
> > +   {TOK_SKIP, 0x29, 0x00}, /* Reserved */
> > +   {TOK_SKIP, REG_FAST_SWTICH_SCART_DELAY, 0x00},
> > +   {TOK_SKIP, 0x2B, 0x00}, /* Reserved */
> > +   {TOK_SKIP, REG_SCART_DELAY, 0x00},
> > +   {TOK_SKIP, REG_CTI_DELAY, 0x00},
> > +   {TOK_SKIP, REG_CTI_CONTROL, 0x00},
> > +   {TOK_SKIP, 0x2F, 0x00}, /* Reserved */
> > +   {TOK_SKIP, 0x30, 0x00}, /* Reserved */
> > +   {TOK_SKIP, 0x31, 0x00}, /* Reserved */
> > +   {TOK_WRITE, REG_SYNC_CONTROL, 0x00},    /* HS, VS active
> high */
> > +   {TOK_WRITE, REG_OUTPUT_FORMATTER1, 0x00},       /* 10-bit BT.656 */
> > +   {TOK_WRITE, REG_OUTPUT_FORMATTER2, 0x11},       /* Enable clk & data
> */
> > +   {TOK_WRITE, REG_OUTPUT_FORMATTER3, 0xEE},       /* Enable AVID & FLD
> */
> > +   {TOK_WRITE, REG_OUTPUT_FORMATTER4, 0xAF},       /* Enable VS & HS */
> > +   {TOK_WRITE, REG_OUTPUT_FORMATTER5, 0xFF},
> > +   {TOK_WRITE, REG_OUTPUT_FORMATTER6, 0xFF},
> > +   {TOK_WRITE, REG_CLEAR_LOST_LOCK, 0x01}, /* Clear status */
> > +   {TOK_TERM, 0, 0},
> > +};
> > +
> > +/* List of image formats supported by TVP5146/47 decoder
> > + * Currently we are using 8 bit mode only, but can be
> > + * extended to 10/20 bit mode.
> > + */
> > +static const struct v4l2_fmtdesc tvp514x_fmt_list[] = {
> > +   {
> > +    .index = 0,
> > +    .type = V4L2_BUF_TYPE_VIDEO_CAPTURE,
> > +    .flags = 0,
> > +    .description = "8-bit UYVY 4:2:2 Format",
> > +    .pixelformat = V4L2_PIX_FMT_UYVY,
> > +   },
> > +};
> > +
> > +#define TVP514X_NUM_FORMATS
>       ARRAY_SIZE(tvp514x_fmt_list)
> > +
> > +/*
> > + * Supported standards -
> > + *
> > + * Currently supports two standards only, need to add support for
> > rest of the + * modes, like SECAM, etc...
> > + */
> > +static struct tvp514x_std_info tvp514x_std_list[] = {
> > +   /* Standard: STD_NTSC_MJ */
> > +   [STD_NTSC_MJ] = {
> > +    .width = NTSC_NUM_ACTIVE_PIXELS,
> > +    .height = NTSC_NUM_ACTIVE_LINES,
> > +    .video_std = VIDEO_STD_NTSC_MJ_BIT,
> > +    .standard = {
> > +                 .index = 0,
> > +                 .id = V4L2_STD_NTSC,
> > +                 .name = "NTSC",
> > +                 .frameperiod = {1001, 30000},
> > +                 .framelines = 525
> > +                },
> > +   /* Standard: STD_PAL_BDGHIN */
> > +   },
> > +   [STD_PAL_BDGHIN] = {
> > +    .width = PAL_NUM_ACTIVE_PIXELS,
> > +    .height = PAL_NUM_ACTIVE_LINES,
> > +    .video_std = VIDEO_STD_PAL_BDGHIN_BIT,
> > +    .standard = {
> > +                 .index = 1,
> > +                 .id = V4L2_STD_PAL,
> > +                 .name = "PAL",
> > +                 .frameperiod = {1, 25},
> > +                 .framelines = 625
> > +                },
> > +   },
> > +   /* Standard: need to add for additional standard */
> > +};
> > +
> > +#define TVP514X_NUM_STANDARDS
>       ARRAY_SIZE(tvp514x_std_list)
> > +
> > +/* Supported controls */
> > +static const struct tvp514x_ctrl_info tvp514x_ctrl_list[] = {
> > +   {
> > +    .reg_address = REG_BRIGHTNESS,
> > +    .query_ctrl = {
> > +                   .id = V4L2_CID_BRIGHTNESS,
> > +                   .name = "BRIGHTNESS",
> > +                   .type = V4L2_CTRL_TYPE_INTEGER,
> > +                   .minimum = 0,
> > +                   .maximum = 255,
> > +                   .step = 1,
> > +                   .default_value = 128
> > +                   },
> > +   }, {
> > +    .reg_address = REG_CONTRAST,
> > +    .query_ctrl = {
> > +                   .id = V4L2_CID_CONTRAST,
> > +                   .name = "CONTRAST",
> > +                   .type = V4L2_CTRL_TYPE_INTEGER,
> > +                   .minimum = 0,
> > +                   .maximum = 255,
> > +                   .step = 1,
> > +                   .default_value = 128
> > +                   },
> > +   }, {
> > +    .reg_address = REG_SATURATION,
> > +    .query_ctrl = {
> > +                   .id = V4L2_CID_SATURATION,
> > +                   .name = "SATURATION",
> > +                   .type = V4L2_CTRL_TYPE_INTEGER,
> > +                   .minimum = 0,
> > +                   .maximum = 255,
> > +                   .step = 1,
> > +                   .default_value = 128
> > +                   },
> > +   }, {
> > +    .reg_address = REG_HUE,
> > +    .query_ctrl = {
> > +                   .id = V4L2_CID_HUE,
> > +                   .name = "HUE",
> > +                   .type = V4L2_CTRL_TYPE_INTEGER,
> > +                   .minimum = -180,
> > +                   .maximum = 180,
> > +                   .step = 180,
> > +                   .default_value = 0
> > +                   },
> > +   }, {
> > +    .reg_address = REG_AFE_GAIN_CTRL,
> > +    .query_ctrl = {
> > +                   .id = V4L2_CID_AUTOGAIN,
> > +                   .name = "Automatic Gain Control",
> > +                   .type = V4L2_CTRL_TYPE_BOOLEAN,
> > +                   .minimum = 0,
> > +                   .maximum = 1,
> > +                   .step = 1,
> > +                   .default_value = 1
> > +                   },
> > +    },
> > +};
> > +
> > +#define TVP514X_NUM_CONTROLS
>       ARRAY_SIZE(tvp514x_ctrl_list)
> > +
> > +/*
> > + * Read a value from a register in an TVP5146/47 decoder device.
> > + * Returns value read if successful, or non-zero (-1) otherwise.
> > + */
> > +static int tvp514x_read_reg(struct i2c_client *client, u8 reg)
> > +{
> > +   int err;
> > +   int retry = 0;
> > +read_again:
> > +
> > +   err = i2c_smbus_read_byte_data(client, reg);
> > +   if (err == -1) {
> > +           if (retry <= I2C_RETRY_COUNT) {
> > +                   v4l_warn(client, "Read: retry ... %d\n", retry);
> > +                   retry++;
> > +                   msleep_interruptible(10);
> > +                   goto read_again;
> > +           }
> > +   }
> > +
> > +   return err;
> > +}
> > +
> > +/*
> > + * Write a value to a register in an TVP5146/47 decoder device.
> > + * Returns zero if successful, or non-zero otherwise.
> > + */
> > +static int tvp514x_write_reg(struct i2c_client *client, u8 reg,
> u8
> > val) +{
> > +   int err;
> > +   int retry = 0;
> > +write_again:
> > +
> > +   err = i2c_smbus_write_byte_data(client, reg, val);
> > +   if (err) {
> > +           if (retry <= I2C_RETRY_COUNT) {
> > +                   v4l_warn(client, "Write: retry ... %d\n", retry);
> > +                   retry++;
> > +                   msleep_interruptible(10);
> > +                   goto write_again;
> > +           }
> > +   }
> > +
> > +   return err;
> > +}
> > +
> > +/*
> > + * tvp514x_write_regs : Initializes a list of TVP5146/47
> registers
> > + *         if token is TOK_TERM, then entire write operation
> terminates
> > + *         if token is TOK_DELAY, then a delay of 'val' msec is
> introduced
> > + *         if token is TOK_SKIP, then the register write is skipped
> > + *         if token is TOK_WRITE, then the register write is
> performed
> > + *
> > + * reglist - list of registers to be written
> > + * Returns zero if successful, or non-zero otherwise.
> > + */
> > +static int tvp514x_write_regs(struct i2c_client *client,
> > +                         const struct tvp514x_reg reglist[])
> > +{
> > +   int err;
> > +   const struct tvp514x_reg *next = reglist;
> > +
> > +   for (; next->token != TOK_TERM; next++) {
> > +           if (next->token == TOK_DELAY) {
> > +                   msleep(next->val);
> > +                   continue;
> > +           }
> > +
> > +           if (next->token == TOK_SKIP)
> > +                   continue;
> > +
> > +           err = tvp514x_write_reg(client, next->reg, (u8) next-
> >val);
> > +           if (err) {
> > +                   v4l_err(client, "Write failed. Err[%d]\n", err);
> > +                   return err;
> > +           }
> > +   }
> > +   return 0;
> > +}
> > +
> > +/*
> > + * tvp514x_get_current_std:
> > + * Returns the current standard detected by TVP5146/47
> > + */
> > +static enum tvp514x_std tvp514x_get_current_std(struct
> > tvp514x_decoder +                                           *decoder)
> > +{
> > +   u8 std, std_status;
> > +
> > +   std = tvp514x_read_reg(decoder->client, REG_VIDEO_STD);
> > +   if ((std & VIDEO_STD_MASK) == VIDEO_STD_AUTO_SWITCH_BIT) {
> > +           /* use the standard status register */
> > +           std_status = tvp514x_read_reg(decoder->client,
> > +                           REG_VIDEO_STD_STATUS);
> > +   } else
> > +           std_status = std;       /* use the standard register itself */
> > +
> > +   switch (std_status & VIDEO_STD_MASK) {
> > +   case VIDEO_STD_NTSC_MJ_BIT:
> > +           return STD_NTSC_MJ;
> > +
> > +   case VIDEO_STD_PAL_BDGHIN_BIT:
> > +           return STD_PAL_BDGHIN;
> > +
> > +   default:
> > +           return STD_INVALID;
> > +   }
> > +
> > +   return STD_INVALID;
> > +}
> > +
> > +/*
> > + * TVP5146/47 register dump function
> > + */
> > +void tvp514x_reg_dump(struct tvp514x_decoder *decoder)
> > +{
> > +   u8 value;
> > +
> > +   dump_reg(decoder->client, REG_INPUT_SEL, value);
> > +   dump_reg(decoder->client, REG_AFE_GAIN_CTRL, value);
> > +   dump_reg(decoder->client, REG_VIDEO_STD, value);
> > +   dump_reg(decoder->client, REG_OPERATION_MODE, value);
> > +   dump_reg(decoder->client, REG_COLOR_KILLER, value);
> > +   dump_reg(decoder->client, REG_LUMA_CONTROL1, value);
> > +   dump_reg(decoder->client, REG_LUMA_CONTROL2, value);
> > +   dump_reg(decoder->client, REG_LUMA_CONTROL3, value);
> > +   dump_reg(decoder->client, REG_BRIGHTNESS, value);
> > +   dump_reg(decoder->client, REG_CONTRAST, value);
> > +   dump_reg(decoder->client, REG_SATURATION, value);
> > +   dump_reg(decoder->client, REG_HUE, value);
> > +   dump_reg(decoder->client, REG_CHROMA_CONTROL1, value);
> > +   dump_reg(decoder->client, REG_CHROMA_CONTROL2, value);
> > +   dump_reg(decoder->client, REG_COMP_PR_SATURATION, value);
> > +   dump_reg(decoder->client, REG_COMP_Y_CONTRAST, value);
> > +   dump_reg(decoder->client, REG_COMP_PB_SATURATION, value);
> > +   dump_reg(decoder->client, REG_COMP_Y_BRIGHTNESS, value);
> > +   dump_reg(decoder->client, REG_AVID_START_PIXEL_LSB, value);
> > +   dump_reg(decoder->client, REG_AVID_START_PIXEL_MSB, value);
> > +   dump_reg(decoder->client, REG_AVID_STOP_PIXEL_LSB, value);
> > +   dump_reg(decoder->client, REG_AVID_STOP_PIXEL_MSB, value);
> > +   dump_reg(decoder->client, REG_HSYNC_START_PIXEL_LSB, value);
> > +   dump_reg(decoder->client, REG_HSYNC_START_PIXEL_MSB, value);
> > +   dump_reg(decoder->client, REG_HSYNC_STOP_PIXEL_LSB, value);
> > +   dump_reg(decoder->client, REG_HSYNC_STOP_PIXEL_MSB, value);
> > +   dump_reg(decoder->client, REG_VSYNC_START_LINE_LSB, value);
> > +   dump_reg(decoder->client, REG_VSYNC_START_LINE_MSB, value);
> > +   dump_reg(decoder->client, REG_VSYNC_STOP_LINE_LSB, value);
> > +   dump_reg(decoder->client, REG_VSYNC_STOP_LINE_MSB, value);
> > +   dump_reg(decoder->client, REG_VBLK_START_LINE_LSB, value);
> > +   dump_reg(decoder->client, REG_VBLK_START_LINE_MSB, value);
> > +   dump_reg(decoder->client, REG_VBLK_STOP_LINE_LSB, value);
> > +   dump_reg(decoder->client, REG_VBLK_STOP_LINE_MSB, value);
> > +   dump_reg(decoder->client, REG_SYNC_CONTROL, value);
> > +   dump_reg(decoder->client, REG_OUTPUT_FORMATTER1, value);
> > +   dump_reg(decoder->client, REG_OUTPUT_FORMATTER2, value);
> > +   dump_reg(decoder->client, REG_OUTPUT_FORMATTER3, value);
> > +   dump_reg(decoder->client, REG_OUTPUT_FORMATTER4, value);
> > +   dump_reg(decoder->client, REG_OUTPUT_FORMATTER5, value);
> > +   dump_reg(decoder->client, REG_OUTPUT_FORMATTER6, value);
> > +   dump_reg(decoder->client, REG_CLEAR_LOST_LOCK, value);
> > +}
> > +
> > +/*
> > + * Configure the TVP5146/47 with the current register settings
> > + * Returns zero if successful, or non-zero otherwise.
> > + */
> > +static int tvp514x_configure(struct tvp514x_decoder *decoder)
> > +{
> > +   int err;
> > +
> > +   /* common register initialization */
> > +   err =
> > +       tvp514x_write_regs(decoder->client, tvp514x_reg_list);
> > +   if (err)
> > +           return err;
> > +
> > +   if (debug)
> > +           tvp514x_reg_dump(decoder);
> > +
> > +   return 0;
> > +}
> > +
> > +/*
> > + * Detect if an tvp514x is present, and if so which revision.
> > + * A device is considered to be detected if the chip ID (LSB and
> > MSB) + * registers match the expected values.
> > + * Any value of the rom version register is accepted.
> > + * Returns ENODEV error number if no device is detected, or zero
> > + * if a device is detected.
> > + */
> > +static int tvp514x_detect(struct tvp514x_decoder *decoder)
> > +{
> > +   u8 chip_id_msb, chip_id_lsb, rom_ver;
> > +
> > +   chip_id_msb = tvp514x_read_reg(decoder->client,
> REG_CHIP_ID_MSB);
> > +   chip_id_lsb = tvp514x_read_reg(decoder->client,
> REG_CHIP_ID_LSB);
> > +   rom_ver = tvp514x_read_reg(decoder->client, REG_ROM_VERSION);
> > +
> > +   v4l_dbg(1, debug, decoder->client,
> > +            "chip id detected msb:0x%x lsb:0x%x rom
> version:0x%x\n",
> > +            chip_id_msb, chip_id_lsb, rom_ver);
> > +   if ((chip_id_msb != TVP514X_CHIP_ID_MSB)
> > +           || ((chip_id_lsb != TVP5146_CHIP_ID_LSB)
> > +           && (chip_id_lsb != TVP5147_CHIP_ID_LSB))) {
> > +           /* We didn't read the values we expected, so this must
> not be
> > +            * an TVP5146/47.
> > +            */
> > +           v4l_err(decoder->client,
> > +                   "chip id mismatch msb:0x%x lsb:0x%x\n",
> > +                   chip_id_msb, chip_id_lsb);
> > +           return -ENODEV;
> > +   }
> > +
> > +   decoder->ver = rom_ver;
> > +   decoder->state = STATE_DETECTED;
> > +
> > +   v4l_info(decoder->client,
> > +                   "\n%s found at 0x%x (%s)\n", decoder->client-
> >name,
> > +                   decoder->client->addr << 1,
> > +                   decoder->client->adapter->name);
> > +   return 0;
> > +}
> > +
> > +/*
> > + * Following are decoder interface functions implemented by
> > + * TVP5146/47 decoder driver.
> > + */
> > +
> > +/**
> > + * ioctl_querystd - V4L2 decoder interface handler for
> > VIDIOC_QUERYSTD ioctl + * @s: pointer to standard V4L2 device
> > structure
> > + * @std_id: standard V4L2 std_id ioctl enum
> > + *
> > + * Returns the current standard detected by TVP5146/47. If no
> active
> > input is + * detected, returns -EINVAL
> > + */
> > +static int ioctl_querystd(struct v4l2_int_device *s, v4l2_std_id
> > *std_id) +{
> > +   struct tvp514x_decoder *decoder = s->priv;
> > +   enum tvp514x_std current_std;
> > +   enum tvp514x_input input_sel;
> > +   u8 sync_lock_status, lock_mask;
> > +
> > +   if (std_id == NULL)
> > +           return -EINVAL;
> > +
> > +   /* get the current standard */
> > +   current_std = tvp514x_get_current_std(decoder);
> > +   if (current_std == STD_INVALID)
> > +           return -EINVAL;
> > +
> > +   input_sel =
> > decoder->pdata->input_list[decoder->inputidx].input_sel; +
> > +   switch (input_sel) {
> > +   case INPUT_CVBS_VI1A:
> > +   case INPUT_CVBS_VI1B:
> > +   case INPUT_CVBS_VI1C:
> > +   case INPUT_CVBS_VI2A:
> > +   case INPUT_CVBS_VI2B:
> > +   case INPUT_CVBS_VI2C:
> > +   case INPUT_CVBS_VI3A:
> > +   case INPUT_CVBS_VI3B:
> > +   case INPUT_CVBS_VI3C:
> > +   case INPUT_CVBS_VI4A:
> > +           lock_mask = STATUS_CLR_SUBCAR_LOCK_BIT |
> > +                   STATUS_HORZ_SYNC_LOCK_BIT |
> > +                   STATUS_VIRT_SYNC_LOCK_BIT;
> > +           break;
> > +
> > +   case INPUT_SVIDEO_VI2A_VI1A:
> > +   case INPUT_SVIDEO_VI2B_VI1B:
> > +   case INPUT_SVIDEO_VI2C_VI1C:
> > +   case INPUT_SVIDEO_VI2A_VI3A:
> > +   case INPUT_SVIDEO_VI2B_VI3B:
> > +   case INPUT_SVIDEO_VI2C_VI3C:
> > +   case INPUT_SVIDEO_VI4A_VI1A:
> > +   case INPUT_SVIDEO_VI4A_VI1B:
> > +   case INPUT_SVIDEO_VI4A_VI1C:
> > +   case INPUT_SVIDEO_VI4A_VI3A:
> > +   case INPUT_SVIDEO_VI4A_VI3B:
> > +   case INPUT_SVIDEO_VI4A_VI3C:
> > +           lock_mask = STATUS_HORZ_SYNC_LOCK_BIT |
> > +                   STATUS_VIRT_SYNC_LOCK_BIT;
> > +           break;
> > +           /*Need to add other interfaces*/
> > +   default:
> > +           return -EINVAL;
> > +   }
> > +   /* check whether signal is locked */
> > +   sync_lock_status = tvp514x_read_reg(decoder->client,
> REG_STATUS1);
> > +   if (lock_mask != (sync_lock_status & lock_mask))
> > +           return -EINVAL; /* No input detected */
> > +
> > +   decoder->current_std = current_std;
> > +   *std_id = decoder->std_list[current_std].standard.id;
> > +
> > +   v4l_dbg(1, debug, decoder->client, "Current STD: %s",
> > +                   decoder->std_list[current_std].standard.name);
> > +   return 0;
> > +}
> > +
> > +/**
> > + * ioctl_s_std - V4L2 decoder interface handler for VIDIOC_S_STD
> > ioctl + * @s: pointer to standard V4L2 device structure
> > + * @std_id: standard V4L2 v4l2_std_id ioctl enum
> > + *
> > + * If std_id is supported, sets the requested standard.
> Otherwise,
> > returns + * -EINVAL
> > + */
> > +static int ioctl_s_std(struct v4l2_int_device *s, v4l2_std_id
> > *std_id) +{
> > +   struct tvp514x_decoder *decoder = s->priv;
> > +   int err, i;
> > +
> > +   if (std_id == NULL)
> > +           return -EINVAL;
> > +
> > +   for (i = 0; i < decoder->num_stds; i++)
> > +           if (*std_id & decoder->std_list[i].standard.id)
> > +                   break;
> > +
> > +   if ((i == decoder->num_stds) || (i == STD_INVALID))
> > +           return -EINVAL;
> > +
> > +   err = tvp514x_write_reg(decoder->client, REG_VIDEO_STD,
> > +                           decoder->std_list[i].video_std);
> > +   if (err)
> > +           return err;
> > +
> > +   decoder->current_std = i;
> > +   tvp514x_reg_list[REG_VIDEO_STD].val =
> > decoder->std_list[i].video_std; +
> > +   v4l_dbg(1, debug, decoder->client, "Standard set to: %s",
> > +                   decoder->std_list[i].standard.name);
> > +   return 0;
> > +}
> > +
> > +/**
> > + * ioctl_s_routing - V4L2 decoder interface handler for
> > VIDIOC_S_INPUT ioctl + * @s: pointer to standard V4L2 device
> > structure
> > + * @index: number of the input
> > + *
> > + * If index is valid, selects the requested input. Otherwise,
> > returns -EINVAL if + * the input is not supported or there is no
> > active signal present in the + * selected input.
> > + */
> > +static int ioctl_s_routing(struct v4l2_int_device *s, int index)
> > +{
> > +   struct tvp514x_decoder *decoder = s->priv;
> > +   int err;
> > +   enum tvp514x_input input_sel;
> > +   enum tvp514x_std current_std = STD_INVALID;
> > +   u8 sync_lock_status, lock_mask;
> > +   int try_count = LOCK_RETRY_COUNT;
> > +
> > +   if ((index >= decoder->pdata->num_inputs) || (index < 0))
> > +           return -EINVAL; /* Index out of bound */
> > +
> > +   /* Get the register value to be written to select the
> requested
> > input */ +  input_sel = decoder->pdata-
> >input_list[index].input_sel;
> > +   err = tvp514x_write_reg(decoder->client, REG_INPUT_SEL,
> input_sel);
> > +   if (err)
> > +           return err;
> > +
> > +   decoder->inputidx = index;
> > +   tvp514x_reg_list[REG_INPUT_SEL].val = input_sel;
> > +
> > +   /* Clear status */
> > +   msleep(LOCK_RETRY_DELAY);
> > +   err =
> > +       tvp514x_write_reg(decoder->client, REG_CLEAR_LOST_LOCK,
> 0x01);
> > +   if (err)
> > +           return err;
> > +
> > +   switch (input_sel) {
> > +   case INPUT_CVBS_VI1A:
> > +   case INPUT_CVBS_VI1B:
> > +   case INPUT_CVBS_VI1C:
> > +   case INPUT_CVBS_VI2A:
> > +   case INPUT_CVBS_VI2B:
> > +   case INPUT_CVBS_VI2C:
> > +   case INPUT_CVBS_VI3A:
> > +   case INPUT_CVBS_VI3B:
> > +   case INPUT_CVBS_VI3C:
> > +   case INPUT_CVBS_VI4A:
> > +           lock_mask = STATUS_CLR_SUBCAR_LOCK_BIT |
> > +                   STATUS_HORZ_SYNC_LOCK_BIT |
> > +                   STATUS_VIRT_SYNC_LOCK_BIT;
> > +           break;
> > +
> > +   case INPUT_SVIDEO_VI2A_VI1A:
> > +   case INPUT_SVIDEO_VI2B_VI1B:
> > +   case INPUT_SVIDEO_VI2C_VI1C:
> > +   case INPUT_SVIDEO_VI2A_VI3A:
> > +   case INPUT_SVIDEO_VI2B_VI3B:
> > +   case INPUT_SVIDEO_VI2C_VI3C:
> > +   case INPUT_SVIDEO_VI4A_VI1A:
> > +   case INPUT_SVIDEO_VI4A_VI1B:
> > +   case INPUT_SVIDEO_VI4A_VI1C:
> > +   case INPUT_SVIDEO_VI4A_VI3A:
> > +   case INPUT_SVIDEO_VI4A_VI3B:
> > +   case INPUT_SVIDEO_VI4A_VI3C:
> > +           lock_mask = STATUS_HORZ_SYNC_LOCK_BIT |
> > +                   STATUS_VIRT_SYNC_LOCK_BIT;
> > +           break;
> > +   /*Need to add other interfaces*/
> > +   default:
> > +           return -EINVAL;
> > +   }
> > +
> > +   while (try_count-- > 0) {
> > +           /* Allow decoder to sync up with new input */
> > +           msleep(LOCK_RETRY_DELAY);
> > +
> > +           /* get the current standard for future reference */
> > +           current_std = tvp514x_get_current_std(decoder);
> > +           if (current_std == STD_INVALID)
> > +                   continue;
> > +
> > +           sync_lock_status = tvp514x_read_reg(decoder->client,
> > +                           REG_STATUS1);
> > +           if (lock_mask == (sync_lock_status & lock_mask))
> > +                   break;  /* Input detected */
> > +   }
> > +
> > +   if ((current_std == STD_INVALID) || (try_count < 0))
> > +           return -EINVAL;
> > +
> > +   decoder->current_std = current_std;
> > +
> > +   v4l_dbg(1, debug, decoder->client,
> > +                   "Input set to: index - %d (%s)",
> > +                   decoder->pdata->input_list[index].input.index,
> > +                   decoder->pdata->input_list[index].input.name);
> > +   return 0;
> > +}
> > +
> > +/**
> > + * ioctl_g_routing - V4L2 decoder interface handler for
> > VIDIOC_G_INPUT ioctl + * @s: pointer to standard V4L2 device
> > structure
> > + * @index: returns the current selected input
> > + *
> > + * Returns the current selected input. Returns -EINVAL if any
> error
> > occurs + */
> > +static int ioctl_g_routing(struct v4l2_int_device *s, int *index)
> > +{
> > +   struct tvp514x_decoder *decoder = s->priv;
> > +   int err = -EINVAL, i, inputidx;
> > +
> > +   if (index == NULL)
> > +           return err;
> > +
> > +   /* Search through the input list for active inputs */
> > +   inputidx = decoder->inputidx;
> > +   for (i = 0; i < decoder->pdata->num_inputs; i++) {
> > +           inputidx++;     /* Move to next input */
> > +           if (inputidx >= decoder->pdata->num_inputs)
> > +                   inputidx = 0;   /* fall back to first input */
> > +
> > +           err = ioctl_s_routing(s, inputidx);
> > +           if (!err) {
> > +                   /* Active input found - select it and return
> success */
> > +                   *index = inputidx;
> > +                   return 0;
> > +           }
> > +   }
> > +
> > +   return err;
> > +}
> > +
> > +/**
> > + * ioctl_queryctrl - V4L2 decoder interface handler for
> > VIDIOC_QUERYCTRL ioctl + * @s: pointer to standard V4L2 device
> > structure
> > + * @qc: standard V4L2 VIDIOC_QUERYCTRL ioctl structure
> > + *
> > + * If the requested control is supported, returns the control
> > information + * from the ctrl_list[] array. Otherwise, returns
> > -EINVAL if the + * control is not supported.
> > + */
> > +static int
> > +ioctl_queryctrl(struct v4l2_int_device *s, struct v4l2_queryctrl
> > *qctrl) +{
> > +   struct tvp514x_decoder *decoder = s->priv;
> > +   int id, index;
> > +   const struct tvp514x_ctrl_info *control = NULL;
> > +
> > +   if (qctrl == NULL)
> > +           return -EINVAL;
> > +
> > +   id = qctrl->id;
> > +   memset(qctrl, 0, sizeof(struct v4l2_queryctrl));
> > +   qctrl->id = id;
> > +
> > +   for (index = 0; index < decoder->num_ctrls; index++) {
> > +           control = &decoder->ctrl_list[index];
> > +           if (control->query_ctrl.id == qctrl->id)
> > +                   break;  /* Match found */
> > +   }
> > +   if (index == decoder->num_ctrls)
> > +           return -EINVAL; /* Index out of bound */
> > +
> > +   memcpy(qctrl, &control->query_ctrl, sizeof(struct
> v4l2_queryctrl));
> > +
> > +   v4l_dbg(1, debug, decoder->client,
> > +                   "Query Control: %s : Min - %d, Max - %d, Def -
> %d",
> > +                   control->query_ctrl.name,
> > +                   control->query_ctrl.minimum,
> > +                   control->query_ctrl.maximum,
> > +                   control->query_ctrl.default_value);
> > +   return 0;
> > +}
> > +
> > +/**
> > + * ioctl_g_ctrl - V4L2 decoder interface handler for
> VIDIOC_G_CTRL
> > ioctl + * @s: pointer to standard V4L2 device structure
> > + * @vc: standard V4L2 VIDIOC_G_CTRL ioctl structure
> > + *
> > + * If the requested control is supported, returns the control's
> > current + * value from the decoder. Otherwise, returns -EINVAL if
> the
> > control is not + * supported.
> > + */
> > +static int
> > +ioctl_g_ctrl(struct v4l2_int_device *s, struct v4l2_control
> *ctrl)
> > +{
> > +   struct tvp514x_decoder *decoder = s->priv;
> > +   int index, value;
> > +   const struct tvp514x_ctrl_info *control = NULL;
> > +
> > +   if (ctrl == NULL)
> > +           return -EINVAL;
> > +
> > +   for (index = 0; index < decoder->num_ctrls; index++) {
> > +           control = &decoder->ctrl_list[index];
> > +           if (control->query_ctrl.id == ctrl->id)
> > +                   break;  /* Match found */
> > +   }
> > +   if (index == decoder->num_ctrls)
> > +           return -EINVAL; /* Index out of bound */
> > +
> > +   value =
> > +       tvp514x_read_reg(decoder->client, control->reg_address);
> > +
> > +   /* cross check */
> > +   if (value != tvp514x_reg_list[control->reg_address].val)
> > +           return -EINVAL; /* Driver & TVP5146/47 setting
> mismatch */
> > +
> > +   if (V4L2_CID_AUTOGAIN == ctrl->id) {
> > +           if ((value & 0x3) == 3)
> > +                   value = 1;
> > +           else
> > +                   value = 0;
> > +   }
> > +
> > +   if (V4L2_CID_HUE == ctrl->id) {
> > +           if (value == 0x7F)
> > +                   value = 180;
> > +           else if (value == 0x80)
> > +                   value = -180;
> > +           else
> > +                   value = 0;
> > +   }
> > +
> > +   ctrl->value = value;
> > +
> > +   v4l_dbg(1, debug, decoder->client,
> > +                   "Get Cotrol: %s - %d",
> > +                   control->query_ctrl.name, value);
> > +   return 0;
> > +}
> > +
> > +/**
> > + * ioctl_s_ctrl - V4L2 decoder interface handler for
> VIDIOC_S_CTRL
> > ioctl + * @s: pointer to standard V4L2 device structure
> > + * @vc: standard V4L2 VIDIOC_S_CTRL ioctl structure
> > + *
> > + * If the requested control is supported, sets the control's
> current
> > + * value in HW. Otherwise, returns -EINVAL if the control is not
> > supported. + */
> > +static int
> > +ioctl_s_ctrl(struct v4l2_int_device *s, struct v4l2_control
> *ctrl)
> > +{
> > +   struct tvp514x_decoder *decoder = s->priv;
> > +   int err, value, index;
> > +   const struct tvp514x_ctrl_info *control = NULL;
> > +
> > +   if (ctrl == NULL)
> > +           return -EINVAL;
> > +
> > +   value = (__s32) ctrl->value;
> > +   for (index = 0; index < decoder->num_ctrls; index++) {
> > +           control = &decoder->ctrl_list[index];
> > +           if (control->query_ctrl.id == ctrl->id)
> > +                   break;  /* Match found */
> > +   }
> > +   if (index == decoder->num_ctrls)
> > +           return -EINVAL; /* Index out of bound */
> > +
> > +   if (V4L2_CID_AUTOGAIN == ctrl->id) {
> > +           if (value == 1)
> > +                   value = 0x0F;
> > +           else if (value == 0)
> > +                   value = 0x0C;
> > +           else
> > +                   return -ERANGE;
> > +   } else if (V4L2_CID_HUE == ctrl->id) {
> > +           if (value == 180)
> > +                   value = 0x7F;
> > +           else if (value == -180)
> > +                   value = 0x80;
> > +           else if (value == 0)
> > +                   value = 0;
> > +           else
> > +                   return -ERANGE;
> > +   } else {
> > +           if ((value < control->query_ctrl.minimum)
> > +                   || (value > control->query_ctrl.maximum))
> > +                   return -ERANGE;
> > +   }
> > +
> > +   err =
> > +       tvp514x_write_reg(decoder->client, control->reg_address,
> > +                           value);
> > +   if (err)
> > +           return err;
> > +
> > +   tvp514x_reg_list[control->reg_address].val = value;
> > +
> > +   v4l_dbg(1, debug, decoder->client,
> > +                   "Set Cotrol: %s - %d",
> > +                   control->query_ctrl.name, value);
> > +   return err;
> > +}
> > +
> > +/**
> > + * ioctl_enum_fmt_cap - Implement the CAPTURE buffer
> VIDIOC_ENUM_FMT
> > ioctl + * @s: pointer to standard V4L2 device structure
> > + * @fmt: standard V4L2 VIDIOC_ENUM_FMT ioctl structure
> > + *
> > + * Implement the VIDIOC_ENUM_FMT ioctl to enumerate supported
> > formats + */
> > +static int
> > +ioctl_enum_fmt_cap(struct v4l2_int_device *s, struct v4l2_fmtdesc
> > *fmt) +{
> > +   struct tvp514x_decoder *decoder = s->priv;
> > +   int index;
> > +
> > +   if (fmt == NULL)
> > +           return -EINVAL;
> > +
> > +   index = fmt->index;
> > +   if ((index >= decoder->num_fmts) || (index < 0))
> > +           return -EINVAL; /* Index out of bound */
> > +
> > +   if (fmt->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
> > +           return -EINVAL; /* only capture is supported */
> > +
> > +   memcpy(fmt, &decoder->fmt_list[index],
> > +           sizeof(struct v4l2_fmtdesc));
> > +
> > +   v4l_dbg(1, debug, decoder->client,
> > +                   "Current FMT: index - %d (%s)",
> > +                   decoder->fmt_list[index].index,
> > +                   decoder->fmt_list[index].description);
> > +   return 0;
> > +}
> > +
> > +/**
> > + * ioctl_try_fmt_cap - Implement the CAPTURE buffer
> VIDIOC_TRY_FMT
> > ioctl + * @s: pointer to standard V4L2 device structure
> > + * @f: pointer to standard V4L2 VIDIOC_TRY_FMT ioctl structure
> > + *
> > + * Implement the VIDIOC_TRY_FMT ioctl for the CAPTURE buffer
> type.
> > This + * ioctl is used to negotiate the image capture size and
> pixel
> > format + * without actually making it take effect.
> > + */
> > +static int
> > +ioctl_try_fmt_cap(struct v4l2_int_device *s, struct v4l2_format
> *f)
> > +{
> > +   struct tvp514x_decoder *decoder = s->priv;
> > +   int ifmt;
> > +   struct v4l2_pix_format *pix;
> > +   enum tvp514x_std current_std;
> > +
> > +   if (f == NULL)
> > +           return -EINVAL;
> > +
> > +   if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
> > +           f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
> > +
> > +   pix = &f->fmt.pix;
> > +
> > +   /* Calculate height and width based on current standard */
> > +   current_std = tvp514x_get_current_std(decoder);
> > +   if (current_std == STD_INVALID)
> > +           return -EINVAL;
> > +
> > +   decoder->current_std = current_std;
> > +   pix->width = decoder->std_list[current_std].width;
> > +   pix->height = decoder->std_list[current_std].height;
> > +
> > +   for (ifmt = 0; ifmt < decoder->num_fmts; ifmt++) {
> > +           if (pix->pixelformat ==
> > +                   decoder->fmt_list[ifmt].pixelformat)
> > +                   break;
> > +   }
> > +   if (ifmt == decoder->num_fmts)
> > +           ifmt = 0;       /* None of the format matched, select
> default */
> > +   pix->pixelformat = decoder->fmt_list[ifmt].pixelformat;
> > +
> > +   pix->field = V4L2_FIELD_INTERLACED;
> > +   pix->bytesperline = pix->width * 2;
> > +   pix->sizeimage = pix->bytesperline * pix->height;
> > +   pix->colorspace = V4L2_COLORSPACE_SMPTE170M;
> > +   pix->priv = 0;
> > +
> > +   v4l_dbg(1, debug, decoder->client,
> > +                   "Try FMT: pixelformat - %s, bytesperline - %d"
> > +                   "Width - %d, Height - %d",
> > +                   decoder->fmt_list[ifmt].description, pix-
> >bytesperline,
> > +                   pix->width, pix->height);
> > +   return 0;
> > +}
> > +
> > +/**
> > + * ioctl_s_fmt_cap - V4L2 decoder interface handler for
> VIDIOC_S_FMT
> > ioctl + * @s: pointer to standard V4L2 device structure
> > + * @f: pointer to standard V4L2 VIDIOC_S_FMT ioctl structure
> > + *
> > + * If the requested format is supported, configures the HW to use
> > that + * format, returns error code if format not supported or HW
> > can't be + * correctly configured.
> > + */
> > +static int
> > +ioctl_s_fmt_cap(struct v4l2_int_device *s, struct v4l2_format *f)
> > +{
> > +   struct tvp514x_decoder *decoder = s->priv;
> > +   struct v4l2_pix_format *pix;
> > +   int rval;
> > +
> > +   if (f == NULL)
> > +           return -EINVAL;
> > +
> > +   if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
> > +           return -EINVAL; /* only capture is supported */
> > +
> > +   pix = &f->fmt.pix;
> > +   rval = ioctl_try_fmt_cap(s, f);
> > +   if (rval)
> > +           return rval;
> > +   else
> > +           decoder->pix = *pix;
> > +
> > +   return rval;
> > +}
> > +
> > +/**
> > + * ioctl_g_fmt_cap - V4L2 decoder interface handler for
> > ioctl_g_fmt_cap + * @s: pointer to standard V4L2 device structure
> > + * @f: pointer to standard V4L2 v4l2_format structure
> > + *
> > + * Returns the decoder's current pixel format in the v4l2_format
> > + * parameter.
> > + */
> > +static int
> > +ioctl_g_fmt_cap(struct v4l2_int_device *s, struct v4l2_format *f)
> > +{
> > +   struct tvp514x_decoder *decoder = s->priv;
> > +
> > +   if (f == NULL)
> > +           return -EINVAL;
> > +
> > +   if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
> > +           return -EINVAL; /* only capture is supported */
> > +
> > +   f->fmt.pix = decoder->pix;
> > +
> > +   v4l_dbg(1, debug, decoder->client,
> > +                   "Current FMT: bytesperline - %d"
> > +                   "Width - %d, Height - %d",
> > +                   decoder->pix.bytesperline,
> > +                   decoder->pix.width, decoder->pix.height);
> > +   return 0;
> > +}
> > +
> > +/**
> > + * ioctl_g_parm - V4L2 decoder interface handler for
> VIDIOC_G_PARM
> > ioctl + * @s: pointer to standard V4L2 device structure
> > + * @a: pointer to standard V4L2 VIDIOC_G_PARM ioctl structure
> > + *
> > + * Returns the decoder's video CAPTURE parameters.
> > + */
> > +static int
> > +ioctl_g_parm(struct v4l2_int_device *s, struct v4l2_streamparm
> *a)
> > +{
> > +   struct tvp514x_decoder *decoder = s->priv;
> > +   struct v4l2_captureparm *cparm;
> > +   enum tvp514x_std current_std;
> > +
> > +   if (a == NULL)
> > +           return -EINVAL;
> > +
> > +   if (a->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
> > +           return -EINVAL; /* only capture is supported */
> > +
> > +   memset(a, 0, sizeof(*a));
> > +   a->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
> > +
> > +   /* get the current standard */
> > +   current_std = tvp514x_get_current_std(decoder);
> > +   if (current_std == STD_INVALID)
> > +           return -EINVAL;
> > +
> > +   decoder->current_std = current_std;
> > +
> > +   cparm = &a->parm.capture;
> > +   cparm->capability = V4L2_CAP_TIMEPERFRAME;
> > +   cparm->timeperframe =
> > +           decoder->std_list[current_std].standard.frameperiod;
> > +
> > +   return 0;
> > +}
> > +
> > +/**
> > + * ioctl_s_parm - V4L2 decoder interface handler for
> VIDIOC_S_PARM
> > ioctl + * @s: pointer to standard V4L2 device structure
> > + * @a: pointer to standard V4L2 VIDIOC_S_PARM ioctl structure
> > + *
> > + * Configures the decoder to use the input parameters, if
> possible.
> > If + * not possible, returns the appropriate error code.
> > + */
> > +static int
> > +ioctl_s_parm(struct v4l2_int_device *s, struct v4l2_streamparm
> *a)
> > +{
> > +   struct tvp514x_decoder *decoder = s->priv;
> > +   struct v4l2_fract *timeperframe;
> > +   enum tvp514x_std current_std;
> > +
> > +   if (a == NULL)
> > +           return -EINVAL;
> > +
> > +   if (a->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
> > +           return -EINVAL; /* only capture is supported */
> > +
> > +   timeperframe = &a->parm.capture.timeperframe;
> > +
> > +   /* get the current standard */
> > +   current_std = tvp514x_get_current_std(decoder);
> > +   if (current_std == STD_INVALID)
> > +           return -EINVAL;
> > +
> > +   decoder->current_std = current_std;
> > +
> > +   *timeperframe =
> > +       decoder->std_list[current_std].standard.frameperiod;
> > +
> > +   return 0;
> > +}
> > +
> > +/**
> > + * ioctl_g_ifparm - V4L2 decoder interface handler for
> > vidioc_int_g_ifparm_num + * @s: pointer to standard V4L2 device
> > structure
> > + * @p: pointer to standard V4L2 vidioc_int_g_ifparm_num ioctl
> > structure + *
> > + * Gets slave interface parameters.
> > + * Calculates the required xclk value to support the requested
> > + * clock parameters in p. This value is returned in the p
> > + * parameter.
> > + */
> > +static int ioctl_g_ifparm(struct v4l2_int_device *s, struct
> > v4l2_ifparm *p) +{
> > +   struct tvp514x_decoder *decoder = s->priv;
> > +   int rval;
> > +
> > +   if (p == NULL)
> > +           return -EINVAL;
> > +
> > +   if (NULL == decoder->pdata->ifparm)
> > +           return -EINVAL;
> > +
> > +   rval = decoder->pdata->ifparm(p);
> > +   if (rval) {
> > +           v4l_err(decoder->client, "g_ifparm.Err[%d]\n", rval);
> > +           return rval;
> > +   }
> > +
> > +   p->u.bt656.clock_curr = TVP514X_XCLK_BT656;
> > +
> > +   return 0;
> > +}
> > +
> > +/**
> > + * ioctl_g_priv - V4L2 decoder interface handler for
> > vidioc_int_g_priv_num + * @s: pointer to standard V4L2 device
> > structure
> > + * @p: void pointer to hold decoder's private data address
> > + *
> > + * Returns device's (decoder's) private data area address in p
> > parameter + */
> > +static int ioctl_g_priv(struct v4l2_int_device *s, void *p)
> > +{
> > +   struct tvp514x_decoder *decoder = s->priv;
> > +
> > +   if (NULL == decoder->pdata->priv_data_set)
> > +           return -EINVAL;
> > +
> > +   return decoder->pdata->priv_data_set(p);
> > +}
> > +
> > +/**
> > + * ioctl_s_power - V4L2 decoder interface handler for
> > vidioc_int_s_power_num + * @s: pointer to standard V4L2 device
> > structure
> > + * @on: power state to which device is to be set
> > + *
> > + * Sets devices power state to requrested state, if possible.
> > + */
> > +static int ioctl_s_power(struct v4l2_int_device *s, enum
> v4l2_power
> > on) +{
> > +   struct tvp514x_decoder *decoder = s->priv;
> > +   int err = 0;
> > +
> > +   switch (on) {
> > +   case V4L2_POWER_OFF:
> > +           /* Power Down Sequence */
> > +           err =
> > +               tvp514x_write_reg(decoder->client,
> REG_OPERATION_MODE,
> > +                                   0x01);
> > +           /* Disable mux for TVP5146/47 decoder data path */
> > +           if (decoder->pdata->power_set)
> > +                   err |= decoder->pdata->power_set(on);
> > +           decoder->state = STATE_NOT_DETECTED;
> > +           break;
> > +
> > +   case V4L2_POWER_STANDBY:
> > +           if (decoder->pdata->power_set)
> > +                   err = decoder->pdata->power_set(on);
> > +           break;
> > +
> > +   case V4L2_POWER_ON:
> > +           /* Enable mux for TVP5146/47 decoder data path */
> > +           if ((decoder->pdata->power_set) &&
> > +                           (decoder->state == STATE_NOT_DETECTED)) {
> > +                   int i;
> > +                   struct tvp514x_init_seq *int_seq =
> > +                           (struct tvp514x_init_seq *)
> > +                           decoder->id->driver_data;
> > +
> > +                   err = decoder->pdata->power_set(on);
> > +
> > +                   /* Power Up Sequence */
> > +                   for (i = 0; i < int_seq->no_regs; i++) {
> > +                           err |= tvp514x_write_reg(decoder->client,
> > +                                           int_seq->init_reg_seq[i].reg,
> > +                                           int_seq->init_reg_seq[i].val);
> > +                   }
> > +                   /* Detect the sensor is not already detected */
> > +                   err |= tvp514x_detect(decoder);
> > +                   if (err) {
> > +                           v4l_err(decoder->client,
> > +                                           "Unable to detect decoder\n");
> > +                           return err;
> > +                   }
> > +           }
> > +           err |= tvp514x_configure(decoder);
> > +           break;
> > +
> > +   default:
> > +           err = -ENODEV;
> > +           break;
> > +   }
> > +
> > +   return err;
> > +}
> > +
> > +/**
> > + * ioctl_init - V4L2 decoder interface handler for
> VIDIOC_INT_INIT
> > + * @s: pointer to standard V4L2 device structure
> > + *
> > + * Initialize the decoder device (calls tvp514x_configure())
> > + */
> > +static int ioctl_init(struct v4l2_int_device *s)
> > +{
> > +   struct tvp514x_decoder *decoder = s->priv;
> > +
> > +   /* Set default standard to auto */
> > +   tvp514x_reg_list[REG_VIDEO_STD].val =
> > +       VIDEO_STD_AUTO_SWITCH_BIT;
> > +
> > +   return tvp514x_configure(decoder);
> > +}
> > +
> > +/**
> > + * ioctl_dev_exit - V4L2 decoder interface handler for
> > vidioc_int_dev_exit_num + * @s: pointer to standard V4L2 device
> > structure
> > + *
> > + * Delinitialise the dev. at slave detach. The complement of
> > ioctl_dev_init. + */
> > +static int ioctl_dev_exit(struct v4l2_int_device *s)
> > +{
> > +   return 0;
> > +}
> > +
> > +/**
> > + * ioctl_dev_init - V4L2 decoder interface handler for
> > vidioc_int_dev_init_num + * @s: pointer to standard V4L2 device
> > structure
> > + *
> > + * Initialise the device when slave attaches to the master.
> Returns
> > 0 if + * TVP5146/47 device could be found, otherwise returns
> > appropriate error. + */
> > +static int ioctl_dev_init(struct v4l2_int_device *s)
> > +{
> > +   struct tvp514x_decoder *decoder = s->priv;
> > +   int err;
> > +
> > +   err = tvp514x_detect(decoder);
> > +   if (err < 0) {
> > +           v4l_err(decoder->client,
> > +                   "Unable to detect decoder\n");
> > +           return err;
> > +   }
> > +
> > +   v4l_info(decoder->client,
> > +            "chip version 0x%.2x detected\n", decoder->ver);
> > +
> > +   return 0;
> > +}
> > +
> > +static struct v4l2_int_ioctl_desc tvp514x_ioctl_desc[] = {
> > +   {vidioc_int_dev_init_num, (v4l2_int_ioctl_func*)
> ioctl_dev_init},
> > +   {vidioc_int_dev_exit_num, (v4l2_int_ioctl_func*)
> ioctl_dev_exit},
> > +   {vidioc_int_s_power_num, (v4l2_int_ioctl_func*)
> ioctl_s_power},
> > +   {vidioc_int_g_priv_num, (v4l2_int_ioctl_func*) ioctl_g_priv},
> > +   {vidioc_int_g_ifparm_num, (v4l2_int_ioctl_func*)
> ioctl_g_ifparm},
> > +   {vidioc_int_init_num, (v4l2_int_ioctl_func*) ioctl_init},
> > +   {vidioc_int_enum_fmt_cap_num,
> > +    (v4l2_int_ioctl_func *) ioctl_enum_fmt_cap},
> > +   {vidioc_int_try_fmt_cap_num,
> > +    (v4l2_int_ioctl_func *) ioctl_try_fmt_cap},
> > +   {vidioc_int_g_fmt_cap_num,
> > +    (v4l2_int_ioctl_func *) ioctl_g_fmt_cap},
> > +   {vidioc_int_s_fmt_cap_num,
> > +    (v4l2_int_ioctl_func *) ioctl_s_fmt_cap},
> > +   {vidioc_int_g_parm_num, (v4l2_int_ioctl_func *) ioctl_g_parm},
> > +   {vidioc_int_s_parm_num, (v4l2_int_ioctl_func *) ioctl_s_parm},
> > +   {vidioc_int_queryctrl_num,
> > +    (v4l2_int_ioctl_func *) ioctl_queryctrl},
> > +   {vidioc_int_g_ctrl_num, (v4l2_int_ioctl_func *) ioctl_g_ctrl},
> > +   {vidioc_int_s_ctrl_num, (v4l2_int_ioctl_func *) ioctl_s_ctrl},
> > +   {vidioc_int_querystd_num, (v4l2_int_ioctl_func *)
> ioctl_querystd},
> > +   {vidioc_int_s_std_num, (v4l2_int_ioctl_func *) ioctl_s_std},
> > +   {vidioc_int_g_video_routing_num,
> > +           (v4l2_int_ioctl_func *) ioctl_g_routing},
> > +   {vidioc_int_s_video_routing_num,
> > +           (v4l2_int_ioctl_func *) ioctl_s_routing},
> > +};
> > +
> > +static struct v4l2_int_slave tvp514x_slave = {
> > +   .ioctls = tvp514x_ioctl_desc,
> > +   .num_ioctls = ARRAY_SIZE(tvp514x_ioctl_desc),
> > +};
> > +
> > +static struct tvp514x_decoder tvp514x_dev = {
> > +   .state = STATE_NOT_DETECTED,
> > +
> > +   .num_fmts = TVP514X_NUM_FORMATS,
> > +   .fmt_list = tvp514x_fmt_list,
> > +
> > +   .pix = {                /* Default to NTSC 8-bit YUV 422 */
> > +           .width = NTSC_NUM_ACTIVE_PIXELS,
> > +           .height = NTSC_NUM_ACTIVE_LINES,
> > +           .pixelformat = V4L2_PIX_FMT_UYVY,
> > +           .field = V4L2_FIELD_INTERLACED,
> > +           .bytesperline = NTSC_NUM_ACTIVE_PIXELS * 2,
> > +           .sizeimage =
> > +           NTSC_NUM_ACTIVE_PIXELS * 2 * NTSC_NUM_ACTIVE_LINES,
> > +           .colorspace = V4L2_COLORSPACE_SMPTE170M,
> > +           },
> > +
> > +   .current_std = STD_NTSC_MJ,
> > +   .num_stds = TVP514X_NUM_STANDARDS,
> > +   .std_list = tvp514x_std_list,
> > +
> > +   .num_ctrls = TVP514X_NUM_CONTROLS,
> > +   .ctrl_list = tvp514x_ctrl_list,
> > +
> > +};
> > +
> > +static struct v4l2_int_device tvp514x_int_device = {
> > +   .module = THIS_MODULE,
> > +   .name = MODULE_NAME,
> > +   .priv = &tvp514x_dev,
> > +   .type = v4l2_int_type_slave,
> > +   .u = {
> > +         .slave = &tvp514x_slave,
> > +         },
> > +};
> > +
> > +/**
> > + * tvp514x_probe - decoder driver i2c probe handler
> > + * @client: i2c driver client device structure
> > + *
> > + * Register decoder as an i2c client device and V4L2
> > + * device.
> > + */
> > +static int
> > +tvp514x_probe(struct i2c_client *client, const struct
> i2c_device_id
> > *id) +{
> > +   struct tvp514x_decoder *decoder = &tvp514x_dev;
> > +   int err;
> > +
> > +   /* Check if the adapter supports the needed features */
> > +   if (!i2c_check_functionality(client->adapter,
> > I2C_FUNC_SMBUS_BYTE_DATA)) +                return -EIO;
> > +
> > +   decoder->pdata = client->dev.platform_data;
> > +   if (!decoder->pdata) {
> > +           v4l_err(client, "No platform data\n!!");
> > +           return -ENODEV;
> > +   }
> > +   /*
> > +    * Fetch platform specific data, and configure the
> > +    * tvp514x_reg_list[] accordingly. Since this is one
> > +    * time configuration, no need to preserve.
> > +    */
> > +   decoder->inputidx = decoder->pdata->default_input;
> > +   tvp514x_reg_list[REG_OUTPUT_FORMATTER2].val |=
> > +                   (decoder->pdata->clk_polarity << 1);
> > +   tvp514x_reg_list[REG_OUTPUT_FORMATTER1].val |=
> > +                   decoder->pdata->fmt;
> > +   tvp514x_reg_list[REG_SYNC_CONTROL].val |=
> > +                   ((decoder->pdata->hs_polarity << 2) |
> > +                   (decoder->pdata->vs_polarity << 3));
> > +   /*
> > +    * Save the id data, required for power up sequence
> > +    */
> > +   decoder->id = (struct i2c_device_id *)id;
> > +   /* Attach to Master */
> > +   strcpy(tvp514x_int_device.u.slave->attach_to,
> > decoder->pdata->master); +  decoder->v4l2_int_device =
> > &tvp514x_int_device;
> > +   decoder->client = client;
> > +   i2c_set_clientdata(client, decoder);
> > +
> > +   /* Register with V4L2 layer as slave device */
> > +   err = v4l2_int_device_register(decoder->v4l2_int_device);
> > +   if (err) {
> > +           i2c_set_clientdata(client, NULL);
> > +           v4l_err(client,
> > +                   "Unable to register to v4l2. Err[%d]\n", err);
> > +
> > +   } else
> > +           v4l_info(client, "Registered to v4l2 master %s!!\n",
> > +                           decoder->pdata->master);
> > +
> > +   return 0;
> > +}
> > +
> > +/**
> > + * tvp514x_remove - decoder driver i2c remove handler
> > + * @client: i2c driver client device structure
> > + *
> > + * Unregister decoder as an i2c client device and V4L2
> > + * device. Complement of tvp514x_probe().
> > + */
> > +static int __exit tvp514x_remove(struct i2c_client *client)
> > +{
> > +   struct tvp514x_decoder *decoder = i2c_get_clientdata(client);
> > +
> > +   if (!client->adapter)
> > +           return -ENODEV; /* our client isn't attached */
> > +
> > +   v4l2_int_device_unregister(decoder->v4l2_int_device);
> > +   i2c_set_clientdata(client, NULL);
> > +
> > +   return 0;
> > +}
> > +/*
> > + * TVP5146 Init/Power on Sequence
> > + */
> > +static struct tvp514x_reg tvp5146_init_reg_seq[] = {
> > +   {TOK_WRITE, REG_VBUS_ADDRESS_ACCESS1, 0x02},
> > +   {TOK_WRITE, REG_VBUS_ADDRESS_ACCESS2, 0x00},
> > +   {TOK_WRITE, REG_VBUS_ADDRESS_ACCESS3, 0x80},
> > +   {TOK_WRITE, REG_VBUS_DATA_ACCESS_NO_VBUS_ADDR_INCR, 0x01},
> > +   {TOK_WRITE, REG_VBUS_ADDRESS_ACCESS1, 0x60},
> > +   {TOK_WRITE, REG_VBUS_ADDRESS_ACCESS2, 0x00},
> > +   {TOK_WRITE, REG_VBUS_ADDRESS_ACCESS3, 0xB0},
> > +   {TOK_WRITE, REG_VBUS_DATA_ACCESS_NO_VBUS_ADDR_INCR, 0x01},
> > +   {TOK_WRITE, REG_VBUS_DATA_ACCESS_NO_VBUS_ADDR_INCR, 0x00},
> > +   {TOK_WRITE, REG_OPERATION_MODE, 0x01},
> > +   {TOK_WRITE, REG_OPERATION_MODE, 0x00},
> > +};
> > +static struct tvp514x_init_seq tvp5146_init = {
> > +   .no_regs = ARRAY_SIZE(tvp5146_init_reg_seq),
> > +   .init_reg_seq = tvp5146_init_reg_seq,
> > +};
> > +/*
> > + * TVP5147 Init/Power on Sequence
> > + */
> > +static struct tvp514x_reg tvp5147_init_reg_seq[] = {
> > +   {TOK_WRITE, REG_VBUS_ADDRESS_ACCESS1, 0x02},
> > +   {TOK_WRITE, REG_VBUS_ADDRESS_ACCESS2, 0x00},
> > +   {TOK_WRITE, REG_VBUS_ADDRESS_ACCESS3, 0x80},
> > +   {TOK_WRITE, REG_VBUS_DATA_ACCESS_NO_VBUS_ADDR_INCR, 0x01},
> > +   {TOK_WRITE, REG_VBUS_ADDRESS_ACCESS1, 0x60},
> > +   {TOK_WRITE, REG_VBUS_ADDRESS_ACCESS2, 0x00},
> > +   {TOK_WRITE, REG_VBUS_ADDRESS_ACCESS3, 0xB0},
> > +   {TOK_WRITE, REG_VBUS_DATA_ACCESS_NO_VBUS_ADDR_INCR, 0x01},
> > +   {TOK_WRITE, REG_VBUS_ADDRESS_ACCESS1, 0x16},
> > +   {TOK_WRITE, REG_VBUS_ADDRESS_ACCESS2, 0x00},
> > +   {TOK_WRITE, REG_VBUS_ADDRESS_ACCESS3, 0xA0},
> > +   {TOK_WRITE, REG_VBUS_DATA_ACCESS_NO_VBUS_ADDR_INCR, 0x16},
> > +   {TOK_WRITE, REG_VBUS_ADDRESS_ACCESS1, 0x60},
> > +   {TOK_WRITE, REG_VBUS_ADDRESS_ACCESS2, 0x00},
> > +   {TOK_WRITE, REG_VBUS_ADDRESS_ACCESS3, 0xB0},
> > +   {TOK_WRITE, REG_VBUS_DATA_ACCESS_NO_VBUS_ADDR_INCR, 0x00},
> > +   {TOK_WRITE, REG_OPERATION_MODE, 0x01},
> > +   {TOK_WRITE, REG_OPERATION_MODE, 0x00},
> > +};
> > +static struct tvp514x_init_seq tvp5147_init = {
> > +   .no_regs = ARRAY_SIZE(tvp5147_init_reg_seq),
> > +   .init_reg_seq = tvp5147_init_reg_seq,
> > +};
> > +/*
> > + * TVP5146M2/TVP5147M1 Init/Power on Sequence
> > + */
> > +static struct tvp514x_reg tvp514xm_init_reg_seq[] = {
> > +   {TOK_WRITE, REG_OPERATION_MODE, 0x01},
> > +   {TOK_WRITE, REG_OPERATION_MODE, 0x00},
> > +};
> > +static struct tvp514x_init_seq tvp514xm_init = {
> > +   .no_regs = ARRAY_SIZE(tvp514xm_init_reg_seq),
> > +   .init_reg_seq = tvp514xm_init_reg_seq,
> > +};
> > +/*
> > + * I2C Device Table -
> > + *
> > + * name - Name of the actual device/chip.
> > + * driver_data - Driver data
> > + */
> > +static const struct i2c_device_id tvp514x_id[] = {
> > +   {"tvp5146", (unsigned int)&tvp5146_init},
> > +   {"tvp5146m2", (unsigned int)&tvp514xm_init},
> > +   {"tvp5147", (unsigned int)&tvp5147_init},
> > +   {"tvp5147m1", (unsigned int)&tvp514xm_init},
> > +   {},
> > +};
> > +
> > +MODULE_DEVICE_TABLE(i2c, tvp514x_id);
> > +
> > +static struct i2c_driver tvp514x_i2c_driver = {
> > +   .driver = {
> > +              .name = MODULE_NAME,
> > +              .owner = THIS_MODULE,
> > +              },
> > +   .probe = tvp514x_probe,
> > +   .remove = __exit_p(tvp514x_remove),
> > +   .id_table = tvp514x_id,
> > +};
> > +
> > +/**
> > + * tvp514x_init
> > + *
> > + * Module init function
> > + */
> > +static int __init tvp514x_init(void)
> > +{
> > +   int err;
> > +
> > +   err = i2c_add_driver(&tvp514x_i2c_driver);
> > +   if (err) {
> > +           printk(KERN_ERR "Failed to register " MODULE_NAME
> ".\n");
> > +           return err;
> > +   }
> > +   return 0;
> > +}
> > +
> > +/**
> > + * tvp514x_cleanup
> > + *
> > + * Module exit function
> > + */
> > +static void __exit tvp514x_cleanup(void)
> > +{
> > +   i2c_del_driver(&tvp514x_i2c_driver);
> > +}
> > +
> > +module_init(tvp514x_init);
> > +module_exit(tvp514x_cleanup);
> > +
> > +MODULE_AUTHOR("Texas Instruments");
> > +MODULE_DESCRIPTION("TVP514X linux decoder driver");
> > +MODULE_LICENSE("GPL");
> > diff --git a/drivers/media/video/tvp514x_regs.h
> > b/drivers/media/video/tvp514x_regs.h new file mode 100755
> > index 0000000..003a3c1
> > --- /dev/null
> > +++ b/drivers/media/video/tvp514x_regs.h
> > @@ -0,0 +1,292 @@
> > +/*
> > + * drivers/media/video/tvp514x_regs.h
> > + *
> > + * Copyright (C) 2008 Texas Instruments Inc
> > + * Author: Vaibhav Hiremath <hvaibhav@ti.com>
> > + *
> > + * Contributors:
> > + *     Sivaraj R <sivaraj@ti.com>
> > + *     Brijesh R Jadav <brijesh.j@ti.com>
> > + *     Hardik Shah <hardik.shah@ti.com>
> > + *     Manjunath Hadli <mrh@ti.com>
> > + *     Karicheri Muralidharan <m-karicheri2@ti.com>
> > + *
> > + * This package is free software; you can redistribute it and/or
> > modify + * it under the terms of the GNU General Public License
> > version 2 as + * published by the Free Software Foundation.
> > + *
> > + * This program is distributed in the hope that it will be
> useful,
> > + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> > + * GNU General Public License for more details.
> > + *
> > + * You should have received a copy of the GNU General Public
> License
> > + * along with this program; if not, write to the Free Software
> > + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
> > + *
> > + */
> > +
> > +#ifndef _TVP514X_REGS_H
> > +#define _TVP514X_REGS_H
> > +
> > +/*
> > + * TVP5146/47 registers
> > + */
> > +#define REG_INPUT_SEL                      (0x00)
> > +#define REG_AFE_GAIN_CTRL          (0x01)
> > +#define REG_VIDEO_STD                      (0x02)
> > +#define REG_OPERATION_MODE         (0x03)
> > +#define REG_AUTOSWITCH_MASK                (0x04)
> > +
> > +#define REG_COLOR_KILLER           (0x05)
> > +#define REG_LUMA_CONTROL1          (0x06)
> > +#define REG_LUMA_CONTROL2          (0x07)
> > +#define REG_LUMA_CONTROL3          (0x08)
> > +
> > +#define REG_BRIGHTNESS                     (0x09)
> > +#define REG_CONTRAST                       (0x0A)
> > +#define REG_SATURATION                     (0x0B)
> > +#define REG_HUE                            (0x0C)
> > +
> > +#define REG_CHROMA_CONTROL1                (0x0D)
> > +#define REG_CHROMA_CONTROL2                (0x0E)
> > +
> > +/* 0x0F Reserved */
> > +
> > +#define REG_COMP_PR_SATURATION             (0x10)
> > +#define REG_COMP_Y_CONTRAST                (0x11)
> > +#define REG_COMP_PB_SATURATION             (0x12)
> > +
> > +/* 0x13 Reserved */
> > +
> > +#define REG_COMP_Y_BRIGHTNESS              (0x14)
> > +
> > +/* 0x15 Reserved */
> > +
> > +#define REG_AVID_START_PIXEL_LSB   (0x16)
> > +#define REG_AVID_START_PIXEL_MSB   (0x17)
> > +#define REG_AVID_STOP_PIXEL_LSB            (0x18)
> > +#define REG_AVID_STOP_PIXEL_MSB            (0x19)
> > +
> > +#define REG_HSYNC_START_PIXEL_LSB  (0x1A)
> > +#define REG_HSYNC_START_PIXEL_MSB  (0x1B)
> > +#define REG_HSYNC_STOP_PIXEL_LSB   (0x1C)
> > +#define REG_HSYNC_STOP_PIXEL_MSB   (0x1D)
> > +
> > +#define REG_VSYNC_START_LINE_LSB   (0x1E)
> > +#define REG_VSYNC_START_LINE_MSB   (0x1F)
> > +#define REG_VSYNC_STOP_LINE_LSB            (0x20)
> > +#define REG_VSYNC_STOP_LINE_MSB            (0x21)
> > +
> > +#define REG_VBLK_START_LINE_LSB            (0x22)
> > +#define REG_VBLK_START_LINE_MSB            (0x23)
> > +#define REG_VBLK_STOP_LINE_LSB             (0x24)
> > +#define REG_VBLK_STOP_LINE_MSB             (0x25)
> > +
> > +/* 0x26 - 0x27 Reserved */
> > +
> > +#define REG_FAST_SWTICH_CONTROL            (0x28)
> > +
> > +/* 0x29 Reserved */
> > +
> > +#define REG_FAST_SWTICH_SCART_DELAY        (0x2A)
> > +
> > +/* 0x2B Reserved */
> > +
> > +#define REG_SCART_DELAY                    (0x2C)
> > +#define REG_CTI_DELAY                      (0x2D)
> > +#define REG_CTI_CONTROL                    (0x2E)
> > +
> > +/* 0x2F - 0x31 Reserved */
> > +
> > +#define REG_SYNC_CONTROL           (0x32)
> > +#define REG_OUTPUT_FORMATTER1              (0x33)
> > +#define REG_OUTPUT_FORMATTER2              (0x34)
> > +#define REG_OUTPUT_FORMATTER3              (0x35)
> > +#define REG_OUTPUT_FORMATTER4              (0x36)
> > +#define REG_OUTPUT_FORMATTER5              (0x37)
> > +#define REG_OUTPUT_FORMATTER6              (0x38)
> > +#define REG_CLEAR_LOST_LOCK                (0x39)
> > +
> > +#define REG_STATUS1                        (0x3A)
> > +#define REG_STATUS2                        (0x3B)
> > +
> > +#define REG_AGC_GAIN_STATUS_LSB            (0x3C)
> > +#define REG_AGC_GAIN_STATUS_MSB            (0x3D)
> > +
> > +/* 0x3E Reserved */
> > +
> > +#define REG_VIDEO_STD_STATUS               (0x3F)
> > +#define REG_GPIO_INPUT1                    (0x40)
> > +#define REG_GPIO_INPUT2                    (0x41)
> > +
> > +/* 0x42 - 0x45 Reserved */
> > +
> > +#define REG_AFE_COARSE_GAIN_CH1            (0x46)
> > +#define REG_AFE_COARSE_GAIN_CH2            (0x47)
> > +#define REG_AFE_COARSE_GAIN_CH3            (0x48)
> > +#define REG_AFE_COARSE_GAIN_CH4            (0x49)
> > +
> > +#define REG_AFE_FINE_GAIN_PB_B_LSB (0x4A)
> > +#define REG_AFE_FINE_GAIN_PB_B_MSB (0x4B)
> > +#define REG_AFE_FINE_GAIN_Y_G_CHROMA_LSB   (0x4C)
> > +#define REG_AFE_FINE_GAIN_Y_G_CHROMA_MSB   (0x4D)
> > +#define REG_AFE_FINE_GAIN_PR_R_LSB (0x4E)
> > +#define REG_AFE_FINE_GAIN_PR_R_MSB (0x4F)
> > +#define REG_AFE_FINE_GAIN_CVBS_LUMA_LSB    (0x50)
> > +#define REG_AFE_FINE_GAIN_CVBS_LUMA_MSB    (0x51)
> > +
> > +/* 0x52 - 0x68 Reserved */
> > +
> > +#define REG_FBIT_VBIT_CONTROL1             (0x69)
> > +
> > +/* 0x6A - 0x6B Reserved */
> > +
> > +#define REG_BACKEND_AGC_CONTROL            (0x6C)
> > +
> > +/* 0x6D - 0x6E Reserved */
> > +
> > +#define REG_AGC_DECREMENT_SPEED_CONTROL    (0x6F)
> > +#define REG_ROM_VERSION                    (0x70)
> > +
> > +/* 0x71 - 0x73 Reserved */
> > +
> > +#define REG_AGC_WHITE_PEAK_PROCESSING      (0x74)
> > +#define REG_FBIT_VBIT_CONTROL2             (0x75)
> > +#define REG_VCR_TRICK_MODE_CONTROL (0x76)
> > +#define REG_HORIZONTAL_SHAKE_INCREMENT     (0x77)
> > +#define REG_AGC_INCREMENT_SPEED            (0x78)
> > +#define REG_AGC_INCREMENT_DELAY            (0x79)
> > +
> > +/* 0x7A - 0x7F Reserved */
> > +
> > +#define REG_CHIP_ID_MSB                    (0x80)
> > +#define REG_CHIP_ID_LSB                    (0x81)
> > +
> > +/* 0x82 Reserved */
> > +
> > +#define REG_CPLL_SPEED_CONTROL             (0x83)
> > +
> > +/* 0x84 - 0x96 Reserved */
> > +
> > +#define REG_STATUS_REQUEST         (0x97)
> > +
> > +/* 0x98 - 0x99 Reserved */
> > +
> > +#define REG_VERTICAL_LINE_COUNT_LSB        (0x9A)
> > +#define REG_VERTICAL_LINE_COUNT_MSB        (0x9B)
> > +
> > +/* 0x9C - 0x9D Reserved */
> > +
> > +#define REG_AGC_DECREMENT_DELAY            (0x9E)
> > +
> > +/* 0x9F - 0xB0 Reserved */
> > +
> > +#define REG_VDP_TTX_FILTER_1_MASK1 (0xB1)
> > +#define REG_VDP_TTX_FILTER_1_MASK2 (0xB2)
> > +#define REG_VDP_TTX_FILTER_1_MASK3 (0xB3)
> > +#define REG_VDP_TTX_FILTER_1_MASK4 (0xB4)
> > +#define REG_VDP_TTX_FILTER_1_MASK5 (0xB5)
> > +#define REG_VDP_TTX_FILTER_2_MASK1 (0xB6)
> > +#define REG_VDP_TTX_FILTER_2_MASK2 (0xB7)
> > +#define REG_VDP_TTX_FILTER_2_MASK3 (0xB8)
> > +#define REG_VDP_TTX_FILTER_2_MASK4 (0xB9)
> > +#define REG_VDP_TTX_FILTER_2_MASK5 (0xBA)
> > +#define REG_VDP_TTX_FILTER_CONTROL (0xBB)
> > +#define REG_VDP_FIFO_WORD_COUNT            (0xBC)
> > +#define REG_VDP_FIFO_INTERRUPT_THRLD       (0xBD)
> > +
> > +/* 0xBE Reserved */
> > +
> > +#define REG_VDP_FIFO_RESET         (0xBF)
> > +#define REG_VDP_FIFO_OUTPUT_CONTROL        (0xC0)
> > +#define REG_VDP_LINE_NUMBER_INTERRUPT      (0xC1)
> > +#define REG_VDP_PIXEL_ALIGNMENT_LSB        (0xC2)
> > +#define REG_VDP_PIXEL_ALIGNMENT_MSB        (0xC3)
> > +
> > +/* 0xC4 - 0xD5 Reserved */
> > +
> > +#define REG_VDP_LINE_START         (0xD6)
> > +#define REG_VDP_LINE_STOP          (0xD7)
> > +#define REG_VDP_GLOBAL_LINE_MODE   (0xD8)
> > +#define REG_VDP_FULL_FIELD_ENABLE  (0xD9)
> > +#define REG_VDP_FULL_FIELD_MODE            (0xDA)
> > +
> > +/* 0xDB - 0xDF Reserved */
> > +
> > +#define REG_VBUS_DATA_ACCESS_NO_VBUS_ADDR_INCR     (0xE0)
> > +#define REG_VBUS_DATA_ACCESS_VBUS_ADDR_INCR        (0xE1)
> > +#define REG_FIFO_READ_DATA                 (0xE2)
> > +
> > +/* 0xE3 - 0xE7 Reserved */
> > +
> > +#define REG_VBUS_ADDRESS_ACCESS1   (0xE8)
> > +#define REG_VBUS_ADDRESS_ACCESS2   (0xE9)
> > +#define REG_VBUS_ADDRESS_ACCESS3   (0xEA)
> > +
> > +/* 0xEB - 0xEF Reserved */
> > +
> > +#define REG_INTERRUPT_RAW_STATUS0  (0xF0)
> > +#define REG_INTERRUPT_RAW_STATUS1  (0xF1)
> > +#define REG_INTERRUPT_STATUS0              (0xF2)
> > +#define REG_INTERRUPT_STATUS1              (0xF3)
> > +#define REG_INTERRUPT_MASK0                (0xF4)
> > +#define REG_INTERRUPT_MASK1                (0xF5)
> > +#define REG_INTERRUPT_CLEAR0               (0xF6)
> > +#define REG_INTERRUPT_CLEAR1               (0xF7)
> > +
> > +/* 0xF8 - 0xFF Reserved */
> > +
> > +/*
> > + * Mask and bit definitions of TVP5146/47 registers
> > + */
> > +/* The ID values we are looking for */
> > +#define TVP514X_CHIP_ID_MSB                (0x51)
> > +#define TVP5146_CHIP_ID_LSB                (0x46)
> > +#define TVP5147_CHIP_ID_LSB                (0x47)
> > +
> > +#define VIDEO_STD_MASK                     (0x07)
> > +#define VIDEO_STD_AUTO_SWITCH_BIT  (0x00)
> > +#define VIDEO_STD_NTSC_MJ_BIT              (0x01)
> > +#define VIDEO_STD_PAL_BDGHIN_BIT   (0x02)
> > +#define VIDEO_STD_PAL_M_BIT                (0x03)
> > +#define VIDEO_STD_PAL_COMBINATION_N_BIT    (0x04)
> > +#define VIDEO_STD_NTSC_4_43_BIT            (0x05)
> > +#define VIDEO_STD_SECAM_BIT                (0x06)
> > +#define VIDEO_STD_PAL_60_BIT               (0x07)
> > +
> > +/*
> > + * Status bit
> > + */
> > +#define STATUS_TV_VCR_BIT          (1<<0)
> > +#define STATUS_HORZ_SYNC_LOCK_BIT  (1<<1)
> > +#define STATUS_VIRT_SYNC_LOCK_BIT  (1<<2)
> > +#define STATUS_CLR_SUBCAR_LOCK_BIT (1<<3)
> > +#define STATUS_LOST_LOCK_DETECT_BIT        (1<<4)
> > +#define STATUS_FEILD_RATE_BIT              (1<<5)
> > +#define STATUS_LINE_ALTERNATING_BIT        (1<<6)
> > +#define STATUS_PEAK_WHITE_DETECT_BIT       (1<<7)
> > +
> > +/**
> > + * struct tvp514x_reg - Structure for TVP5146/47 register
> > initialization values + * @token - Token: TOK_WRITE, TOK_TERM
> etc..
> > + * @reg - Register offset
> > + * @val - Register Value for TOK_WRITE or delay in ms for
> TOK_DELAY
> > + */
> > +struct tvp514x_reg {
> > +   u8 token;
> > +   u8 reg;
> > +   u32 val;
> > +};
> > +
> > +/**
> > + * struct tvp514x_init_seq - Structure for TVP5146/47/46M2/47M1
> > power up + *                Sequence.
> > + * @ no_regs - Number of registers to write for power up
> sequence.
> > + * @ init_reg_seq - Array of registers and respective value to
> > write. + */
> > +struct tvp514x_init_seq {
> > +   unsigned int no_regs;
> > +   struct tvp514x_reg *init_reg_seq;
> > +};
> > +#endif                             /* ifndef _TVP514X_REGS_H */
> > diff --git a/include/media/tvp514x.h b/include/media/tvp514x.h
> > new file mode 100755
> > index 0000000..2fee5e7
> > --- /dev/null
> > +++ b/include/media/tvp514x.h
> > @@ -0,0 +1,232 @@
> > +/*
> > + * drivers/media/video/tvp514x.h
> > + *
> > + * Copyright (C) 2008 Texas Instruments Inc
> > + * Author: Vaibhav Hiremath <hvaibhav@ti.com>
> > + *
> > + * Contributors:
> > + *     Sivaraj R <sivaraj@ti.com>
> > + *     Brijesh R Jadav <brijesh.j@ti.com>
> > + *     Hardik Shah <hardik.shah@ti.com>
> > + *     Manjunath Hadli <mrh@ti.com>
> > + *     Karicheri Muralidharan <m-karicheri2@ti.com>
> > + *
> > + * This package is free software; you can redistribute it and/or
> > modify + * it under the terms of the GNU General Public License
> > version 2 as + * published by the Free Software Foundation.
> > + *
> > + * This program is distributed in the hope that it will be
> useful,
> > + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> > + * GNU General Public License for more details.
> > + *
> > + * You should have received a copy of the GNU General Public
> License
> > + * along with this program; if not, write to the Free Software
> > + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
> > + *
> > + */
> > +
> > +#ifndef _TVP514X_H
> > +#define _TVP514X_H
> > +
> > +/*
> > + * Other macros
> > + */
> > +#define TVP514X_MODULE_NAME                "tvp514x"
> > +#define TVP514X_I2C_DELAY          (3)
> > +#define I2C_RETRY_COUNT                    (5)
> > +#define LOCK_RETRY_COUNT           (5)
> > +#define LOCK_RETRY_DELAY           (200)
> > +
> > +#define TOK_WRITE                  (0)     /* token for write
> operation */
> > +#define TOK_TERM                   (1)     /* terminating token */
> > +#define TOK_DELAY                  (2)     /* delay token for reg
> list */
> > +#define TOK_SKIP                   (3)     /* token to skip a
> register */
> > +
> > +#define TVP514X_XCLK_BT656         (27000000)
> > +
> > +/* Number of pixels and number of lines per frame for different
> > standards */ +#define NTSC_NUM_ACTIVE_PIXELS                (720)
> > +#define NTSC_NUM_ACTIVE_LINES              (480)
> > +#define PAL_NUM_ACTIVE_PIXELS              (720)
> > +#define PAL_NUM_ACTIVE_LINES               (576)
> > +
> > +/**
> > + * enum tvp514x_std - enum for supported standards
> > + */
> > +enum tvp514x_std {
> > +   STD_NTSC_MJ = 0,
> > +   STD_PAL_BDGHIN,
> > +   STD_INVALID
> > +};
> > +
> > +/**
> > + * enum tvp514x_state - enum for different decoder states
> > + */
> > +enum tvp514x_state {
> > +   STATE_NOT_DETECTED,
> > +   STATE_DETECTED
> > +};
> > +
> > +/**
> > + * enum tvp514x_input - enum for different decoder input pin
> > + *         configuration.
> > + */
> > +enum tvp514x_input {
> > +   /*
> > +    * CVBS input selection
> > +    */
> > +   INPUT_CVBS_VI1A = 0x0,
> > +   INPUT_CVBS_VI1B,
> > +   INPUT_CVBS_VI1C,
> > +   INPUT_CVBS_VI2A = 0x04,
> > +   INPUT_CVBS_VI2B,
> > +   INPUT_CVBS_VI2C,
> > +   INPUT_CVBS_VI3A = 0x08,
> > +   INPUT_CVBS_VI3B,
> > +   INPUT_CVBS_VI3C,
> > +   INPUT_CVBS_VI4A = 0x0C,
> > +   /*
> > +    * S-Video input selection
> > +    */
> > +   INPUT_SVIDEO_VI2A_VI1A = 0x44,
> > +   INPUT_SVIDEO_VI2B_VI1B,
> > +   INPUT_SVIDEO_VI2C_VI1C,
> > +   INPUT_SVIDEO_VI2A_VI3A = 0x54,
> > +   INPUT_SVIDEO_VI2B_VI3B,
> > +   INPUT_SVIDEO_VI2C_VI3C,
> > +   INPUT_SVIDEO_VI4A_VI1A = 0x4C,
> > +   INPUT_SVIDEO_VI4A_VI1B,
> > +   INPUT_SVIDEO_VI4A_VI1C,
> > +   INPUT_SVIDEO_VI4A_VI3A = 0x5C,
> > +   INPUT_SVIDEO_VI4A_VI3B,
> > +   INPUT_SVIDEO_VI4A_VI3C
> > +
> > +   /* Need to add entries for
> > +    * RGB, YPbPr and SCART.
> > +    */
> > +};
> > +
> > +/**
> > + * enum tvp514x_output_fmt - enum for output format
> > + *                 supported.
> > + */
> > +enum tvp514x_output_fmt {
> > +   OUTPUT_10BIT_422_EMBEDDED_SYNC = 0,
> > +   OUTPUT_20BIT_422_SEPERATE_SYNC,
> > +   OUTPUT_10BIT_422_SEPERATE_SYNC = 3,
> > +   OUTPUT_INVALID
> > +};
> > +
> > +/**
> > + * struct tvp514x_std_info - Structure to store standard
> > informations + * @width: Line width in pixels
> > + * @height:Number of active lines
> > + * @video_std: Value to write in REG_VIDEO_STD register
> > + * @standard: v4l2 standard structure information
> > + */
> > +struct tvp514x_std_info {
> > +   unsigned long width;
> > +   unsigned long height;
> > +   u8 video_std;
> > +   struct v4l2_standard standard;
> > +};
> > +
> > +/**
> > + * struct tvp514x_ctrl_info - Information regarding supported
> > controls + * @reg_address: Register offset of control register
> > + * @query_ctrl: v4l2 query control information
> > + */
> > +struct tvp514x_ctrl_info {
> > +   u8 reg_address;
> > +   struct v4l2_queryctrl query_ctrl;
> > +};
> > +
> > +/**
> > + * struct tvp514x_input_info - Information regarding supported
> > inputs + * @input_sel: Input select register
> > + * @lock_mask: lock mask - depends on Svideo/CVBS
> > + * @input: v4l2 input information
> > + */
> > +struct tvp514x_input_info {
> > +   enum tvp514x_input input_sel;
> > +   struct v4l2_input input;
> > +};
> > +
> > +/**
> > + * struct tvp514x_platform_data - Platform data values and access
> > functions + * @power_set: Power state access function, zero is
> off,
> > non-zero is on. + * @ifparm: Interface parameters access function
> > + * @priv_data_set: Device private data (pointer) access function
> > + * @reg_list: The board dependent driver should fill the default
> > value for + *            required registers depending on board
> > layout. The TVP5146/47 + *            driver will update this
> > register list for the registers + *            whose values should
> be
> > maintained across open()/close() like + *            setting
> > brightness as defined in V4L2.
> > + *            The register list should be in the same order as
> > defined in + *            TVP5146/47 datasheet including reserved
> > registers. As of now + *            the driver expects the size of
> > this list to be a minimum of + *            57 + 1 (upto regsiter
> > REG_CLEAR_LOST_LOCK).
> > + *            The last member should be of the list should be
> > + *            {TOK_TERM, 0, 0} to indicate the end of register
> list.
> > + * @num_inputs: Number of input connection in board
> > + * @input_list: Input information list for num_inputs
> > + */
> > +struct tvp514x_platform_data {
> > +   char *master;
> > +   int (*power_set) (enum v4l2_power on);
> > +   int (*ifparm) (struct v4l2_ifparm *p);
> > +   int (*priv_data_set) (void *);
> > +   /* Input params */
> > +   int num_inputs;
> > +   const struct tvp514x_input_info *input_list;
> > +   int default_input;
> > +   /* Interface control params */
> > +   enum tvp514x_output_fmt fmt;
> > +   bool clk_polarity;
> > +   bool hs_polarity;
> > +   bool vs_polarity;
> > +};
> > +
> > +/**
> > + * struct tvp514x_decoded - TVP5146/47 decoder object
> > + * @v4l2_int_device: Slave handle
> > + * @pdata: Board specific
> > + * @client: I2C client data
> > + * @id: Entry from I2C table
> > + * @ver: Chip version
> > + * @state: TVP5146/47 decoder state - detected or not-detected
> > + * @pix: Current pixel format
> > + * @num_fmts: Number of formats
> > + * @fmt_list: Format list
> > + * @current_std: Current standard
> > + * @num_stds: Number of standards
> > + * @std_list: Standards list
> > + * @num_ctrls: Number of controls
> > + * @ctrl_list: Control list
> > + */
> > +struct tvp514x_decoder {
> > +   struct v4l2_int_device *v4l2_int_device;
> > +   const struct tvp514x_platform_data *pdata;
> > +   struct i2c_client *client;
> > +
> > +   struct i2c_device_id *id;
> > +
> > +   int ver;
> > +   enum tvp514x_state state;
> > +
> > +   struct v4l2_pix_format pix;
> > +   int num_fmts;
> > +   const struct v4l2_fmtdesc *fmt_list;
> > +
> > +   enum tvp514x_std current_std;
> > +   int num_stds;
> > +   struct tvp514x_std_info *std_list;
> > +
> > +   int num_ctrls;
> > +   const struct tvp514x_ctrl_info *ctrl_list;
> > +
> > +   int inputidx;
> > +};
> > +
> > +#endif                             /* ifndef _TVP514X_H */
> > --
> > 1.5.6
> >
> > --
> > video4linux-list mailing list
> > Unsubscribe
> > mailto:video4linux-list-request@redhat.com?subject=unsubscribe
> > https://www.redhat.com/mailman/listinfo/video4linux-list
>
>
>
> --
> Hans Verkuil - video4linux developer - sponsored by TANDBERG


^ permalink raw reply	[flat|nested] 263+ messages in thread

* V4L2 PIXEL buffer conversion
  2008-12-02 17:20   ` Hans Verkuil
  2008-12-03  3:58       ` Hiremath, Vaibhav
@ 2008-12-03 13:43     ` Jonathan Lafontaine
  1 sibling, 0 replies; 263+ messages in thread
From: Jonathan Lafontaine @ 2008-12-03 13:43 UTC (permalink / raw)
  To: video4linux-list

About processing some frames from

static void process_image (const void * p, unsigned int size)

I did some conversion from
const void * p TO char *

to treat buffers.

But I would like opinion about conversion from :

const void * p TO int []

because I am using a JNI entry point for my V4L2 C and would like to compare values between 0-255

but if u do something like

char 4 - char 5

this will not turn -1

this will turn 255.

And inside java I don't want to cast values and prefer to work with proper int types.

--
video4linux-list mailing list
Unsubscribe mailto:video4linux-list-request@redhat.com?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [PATCH (V2)] TVP514x: Migration to sub-device framework
@ 2009-05-06 18:31 hvaibhav
  2009-06-14 10:14 ` Hans Verkuil
  0 siblings, 1 reply; 263+ messages in thread
From: hvaibhav @ 2009-05-06 18:31 UTC (permalink / raw)
  To: linux-media
  Cc: linux-omap, davinci-linux-open-source, Vaibhav Hiremath,
	Brijesh Jadav, Hardik Shah

From: Vaibhav Hiremath <hvaibhav@ti.com>

This patch converts TVP514x driver to sub-device framework
from V4L2-int framework.

NOTE: Please note that this patch has not been tested on any board,
      only compilation/build tested.

Changes (From Previous post):
    - Added static function to_decoder which will replace all
      container_of instances.
    - "unsigned int" replaced with "u32".
    - Cleaned up for line indentation.
    - pdata initialized, was missing in earlier patch.

TODO:
    - Add support for some basic video/core functionality like,
        .g_chip_ident
	.reset
	.g_input_status
    - Migration master driver to validate this driver.
    - validate on Davinci and OMAP boards.

Reviewed By "Hans Verkuil".

Signed-off-by: Brijesh Jadav <brijesh.j@ti.com>
Signed-off-by: Hardik Shah <hardik.shah@ti.com>
Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
---
 drivers/media/video/tvp514x.c      |  854 ++++++++++++++----------------------
 drivers/media/video/tvp514x_regs.h |   10 -
 include/media/tvp514x.h            |    4 -
 3 files changed, 330 insertions(+), 538 deletions(-)

diff --git a/drivers/media/video/tvp514x.c b/drivers/media/video/tvp514x.c
index 4262e60..12b49ad 100644
--- a/drivers/media/video/tvp514x.c
+++ b/drivers/media/video/tvp514x.c
@@ -31,7 +31,11 @@
 #include <linux/i2c.h>
 #include <linux/delay.h>
 #include <linux/videodev2.h>
-#include <media/v4l2-int-device.h>
+
+#include <media/v4l2-device.h>
+#include <media/v4l2-common.h>
+#include <media/v4l2-chip-ident.h>
+#include <media/v4l2-i2c-drv.h>
 #include <media/tvp514x.h>

 #include "tvp514x_regs.h"
@@ -49,13 +53,13 @@ static int debug;
 module_param(debug, bool, 0644);
 MODULE_PARM_DESC(debug, "Debug level (0-1)");

-#define dump_reg(client, reg, val)				\
+#define dump_reg(sd, reg, val)				\
 	do {							\
-		val = tvp514x_read_reg(client, reg);		\
-		v4l_info(client, "Reg(0x%.2X): 0x%.2X\n", reg, val); \
+		val = tvp514x_read_reg(sd, reg);		\
+		v4l2_info(sd, "Reg(0x%.2X): 0x%.2X\n", reg, val); \
 	} while (0)

-/**
+/*
  * enum tvp514x_std - enum for supported standards
  */
 enum tvp514x_std {
@@ -64,15 +68,7 @@ enum tvp514x_std {
 	STD_INVALID
 };

-/**
- * enum tvp514x_state - enum for different decoder states
- */
-enum tvp514x_state {
-	STATE_NOT_DETECTED,
-	STATE_DETECTED
-};
-
-/**
+/*
  * struct tvp514x_std_info - Structure to store standard informations
  * @width: Line width in pixels
  * @height:Number of active lines
@@ -87,35 +83,29 @@ struct tvp514x_std_info {
 };

 static struct tvp514x_reg tvp514x_reg_list_default[0x40];
-/**
+/*
  * struct tvp514x_decoder - TVP5146/47 decoder object
- * @v4l2_int_device: Slave handle
- * @tvp514x_slave: Slave pointer which is used by @v4l2_int_device
+ * @sd: Subdevice Slave handle
  * @tvp514x_regs: copy of hw's regs with preset values.
  * @pdata: Board specific
- * @client: I2C client data
- * @id: Entry from I2C table
  * @ver: Chip version
- * @state: TVP5146/47 decoder state - detected or not-detected
+ * @state: TVP5146/47 decoder state - enabled or disabled.
  * @pix: Current pixel format
  * @num_fmts: Number of formats
  * @fmt_list: Format list
  * @current_std: Current standard
  * @num_stds: Number of standards
  * @std_list: Standards list
- * @route: input and output routing at chip level
+ * @input: Input routing at chip level
+ * @output: Output routing at chip level
  */
 struct tvp514x_decoder {
-	struct v4l2_int_device v4l2_int_device;
-	struct v4l2_int_slave tvp514x_slave;
+	struct v4l2_subdev sd;
 	struct tvp514x_reg tvp514x_regs[ARRAY_SIZE(tvp514x_reg_list_default)];
 	const struct tvp514x_platform_data *pdata;
-	struct i2c_client *client;
-
-	struct i2c_device_id *id;

 	int ver;
-	enum tvp514x_state state;
+	int state;

 	struct v4l2_pix_format pix;
 	int num_fmts;
@@ -124,8 +114,11 @@ struct tvp514x_decoder {
 	enum tvp514x_std current_std;
 	int num_stds;
 	struct tvp514x_std_info *std_list;
-
-	struct v4l2_routing route;
+	/*
+	 * Input and Output Routing parameters
+	 */
+	u32 input;
+	u32 output;
 };

 /* TVP514x default register values */
@@ -191,7 +184,8 @@ static struct tvp514x_reg tvp514x_reg_list_default[] = {
 	{TOK_TERM, 0, 0},
 };

-/* List of image formats supported by TVP5146/47 decoder
+/*
+ * List of image formats supported by TVP5146/47 decoder
  * Currently we are using 8 bit mode only, but can be
  * extended to 10/20 bit mode.
  */
@@ -240,35 +234,27 @@ static struct tvp514x_std_info tvp514x_std_list[] = {
 	},
 	/* Standard: need to add for additional standard */
 };
-/*
- * Control structure for Auto Gain
- *     This is temporary data, will get replaced once
- *     v4l2_ctrl_query_fill supports it.
- */
-static const struct v4l2_queryctrl tvp514x_autogain_ctrl = {
-	.id = V4L2_CID_AUTOGAIN,
-	.name = "Gain, Automatic",
-	.type = V4L2_CTRL_TYPE_BOOLEAN,
-	.minimum = 0,
-	.maximum = 1,
-	.step = 1,
-	.default_value = 1,
-};

+
+static inline struct tvp514x_decoder *to_decoder(struct v4l2_subdev *sd)
+{
+	return container_of(sd, struct tvp514x_decoder, sd);
+}
 /*
  * Read a value from a register in an TVP5146/47 decoder device.
  * Returns value read if successful, or non-zero (-1) otherwise.
  */
-static int tvp514x_read_reg(struct i2c_client *client, u8 reg)
+static int tvp514x_read_reg(struct v4l2_subdev *sd, u8 reg)
 {
-	int err;
-	int retry = 0;
+	int err, retry = 0;
+	struct i2c_client *client = v4l2_get_subdevdata(sd);
+
 read_again:

 	err = i2c_smbus_read_byte_data(client, reg);
 	if (err == -1) {
 		if (retry <= I2C_RETRY_COUNT) {
-			v4l_warn(client, "Read: retry ... %d\n", retry);
+			v4l2_warn(sd, "Read: retry ... %d\n", retry);
 			retry++;
 			msleep_interruptible(10);
 			goto read_again;
@@ -282,16 +268,17 @@ read_again:
  * Write a value to a register in an TVP5146/47 decoder device.
  * Returns zero if successful, or non-zero otherwise.
  */
-static int tvp514x_write_reg(struct i2c_client *client, u8 reg, u8 val)
+static int tvp514x_write_reg(struct v4l2_subdev *sd, u8 reg, u8 val)
 {
-	int err;
-	int retry = 0;
+	int err, retry = 0;
+	struct i2c_client *client = v4l2_get_subdevdata(sd);
+
 write_again:

 	err = i2c_smbus_write_byte_data(client, reg, val);
 	if (err) {
 		if (retry <= I2C_RETRY_COUNT) {
-			v4l_warn(client, "Write: retry ... %d\n", retry);
+			v4l2_warn(sd, "Write: retry ... %d\n", retry);
 			retry++;
 			msleep_interruptible(10);
 			goto write_again;
@@ -311,7 +298,7 @@ write_again:
  * reglist - list of registers to be written
  * Returns zero if successful, or non-zero otherwise.
  */
-static int tvp514x_write_regs(struct i2c_client *client,
+static int tvp514x_write_regs(struct v4l2_subdev *sd,
 			      const struct tvp514x_reg reglist[])
 {
 	int err;
@@ -326,9 +313,9 @@ static int tvp514x_write_regs(struct i2c_client *client,
 		if (next->token == TOK_SKIP)
 			continue;

-		err = tvp514x_write_reg(client, next->reg, (u8) next->val);
+		err = tvp514x_write_reg(sd, next->reg, (u8) next->val);
 		if (err) {
-			v4l_err(client, "Write failed. Err[%d]\n", err);
+			v4l2_err(sd, "Write failed. Err[%d]\n", err);
 			return err;
 		}
 	}
@@ -339,17 +326,15 @@ static int tvp514x_write_regs(struct i2c_client *client,
  * tvp514x_get_current_std:
  * Returns the current standard detected by TVP5146/47
  */
-static enum tvp514x_std tvp514x_get_current_std(struct tvp514x_decoder
-						*decoder)
+static enum tvp514x_std tvp514x_get_current_std(struct v4l2_subdev *sd)
 {
 	u8 std, std_status;

-	std = tvp514x_read_reg(decoder->client, REG_VIDEO_STD);
-	if ((std & VIDEO_STD_MASK) == VIDEO_STD_AUTO_SWITCH_BIT) {
+	std = tvp514x_read_reg(sd, REG_VIDEO_STD);
+	if ((std & VIDEO_STD_MASK) == VIDEO_STD_AUTO_SWITCH_BIT)
 		/* use the standard status register */
-		std_status = tvp514x_read_reg(decoder->client,
-				REG_VIDEO_STD_STATUS);
-	} else
+		std_status = tvp514x_read_reg(sd, REG_VIDEO_STD_STATUS);
+	else
 		std_status = std;	/* use the standard register itself */

 	switch (std_status & VIDEO_STD_MASK) {
@@ -369,70 +354,71 @@ static enum tvp514x_std tvp514x_get_current_std(struct tvp514x_decoder
 /*
  * TVP5146/47 register dump function
  */
-static void tvp514x_reg_dump(struct tvp514x_decoder *decoder)
+static void tvp514x_reg_dump(struct v4l2_subdev *sd)
 {
 	u8 value;

-	dump_reg(decoder->client, REG_INPUT_SEL, value);
-	dump_reg(decoder->client, REG_AFE_GAIN_CTRL, value);
-	dump_reg(decoder->client, REG_VIDEO_STD, value);
-	dump_reg(decoder->client, REG_OPERATION_MODE, value);
-	dump_reg(decoder->client, REG_COLOR_KILLER, value);
-	dump_reg(decoder->client, REG_LUMA_CONTROL1, value);
-	dump_reg(decoder->client, REG_LUMA_CONTROL2, value);
-	dump_reg(decoder->client, REG_LUMA_CONTROL3, value);
-	dump_reg(decoder->client, REG_BRIGHTNESS, value);
-	dump_reg(decoder->client, REG_CONTRAST, value);
-	dump_reg(decoder->client, REG_SATURATION, value);
-	dump_reg(decoder->client, REG_HUE, value);
-	dump_reg(decoder->client, REG_CHROMA_CONTROL1, value);
-	dump_reg(decoder->client, REG_CHROMA_CONTROL2, value);
-	dump_reg(decoder->client, REG_COMP_PR_SATURATION, value);
-	dump_reg(decoder->client, REG_COMP_Y_CONTRAST, value);
-	dump_reg(decoder->client, REG_COMP_PB_SATURATION, value);
-	dump_reg(decoder->client, REG_COMP_Y_BRIGHTNESS, value);
-	dump_reg(decoder->client, REG_AVID_START_PIXEL_LSB, value);
-	dump_reg(decoder->client, REG_AVID_START_PIXEL_MSB, value);
-	dump_reg(decoder->client, REG_AVID_STOP_PIXEL_LSB, value);
-	dump_reg(decoder->client, REG_AVID_STOP_PIXEL_MSB, value);
-	dump_reg(decoder->client, REG_HSYNC_START_PIXEL_LSB, value);
-	dump_reg(decoder->client, REG_HSYNC_START_PIXEL_MSB, value);
-	dump_reg(decoder->client, REG_HSYNC_STOP_PIXEL_LSB, value);
-	dump_reg(decoder->client, REG_HSYNC_STOP_PIXEL_MSB, value);
-	dump_reg(decoder->client, REG_VSYNC_START_LINE_LSB, value);
-	dump_reg(decoder->client, REG_VSYNC_START_LINE_MSB, value);
-	dump_reg(decoder->client, REG_VSYNC_STOP_LINE_LSB, value);
-	dump_reg(decoder->client, REG_VSYNC_STOP_LINE_MSB, value);
-	dump_reg(decoder->client, REG_VBLK_START_LINE_LSB, value);
-	dump_reg(decoder->client, REG_VBLK_START_LINE_MSB, value);
-	dump_reg(decoder->client, REG_VBLK_STOP_LINE_LSB, value);
-	dump_reg(decoder->client, REG_VBLK_STOP_LINE_MSB, value);
-	dump_reg(decoder->client, REG_SYNC_CONTROL, value);
-	dump_reg(decoder->client, REG_OUTPUT_FORMATTER1, value);
-	dump_reg(decoder->client, REG_OUTPUT_FORMATTER2, value);
-	dump_reg(decoder->client, REG_OUTPUT_FORMATTER3, value);
-	dump_reg(decoder->client, REG_OUTPUT_FORMATTER4, value);
-	dump_reg(decoder->client, REG_OUTPUT_FORMATTER5, value);
-	dump_reg(decoder->client, REG_OUTPUT_FORMATTER6, value);
-	dump_reg(decoder->client, REG_CLEAR_LOST_LOCK, value);
+	dump_reg(sd, REG_INPUT_SEL, value);
+	dump_reg(sd, REG_AFE_GAIN_CTRL, value);
+	dump_reg(sd, REG_VIDEO_STD, value);
+	dump_reg(sd, REG_OPERATION_MODE, value);
+	dump_reg(sd, REG_COLOR_KILLER, value);
+	dump_reg(sd, REG_LUMA_CONTROL1, value);
+	dump_reg(sd, REG_LUMA_CONTROL2, value);
+	dump_reg(sd, REG_LUMA_CONTROL3, value);
+	dump_reg(sd, REG_BRIGHTNESS, value);
+	dump_reg(sd, REG_CONTRAST, value);
+	dump_reg(sd, REG_SATURATION, value);
+	dump_reg(sd, REG_HUE, value);
+	dump_reg(sd, REG_CHROMA_CONTROL1, value);
+	dump_reg(sd, REG_CHROMA_CONTROL2, value);
+	dump_reg(sd, REG_COMP_PR_SATURATION, value);
+	dump_reg(sd, REG_COMP_Y_CONTRAST, value);
+	dump_reg(sd, REG_COMP_PB_SATURATION, value);
+	dump_reg(sd, REG_COMP_Y_BRIGHTNESS, value);
+	dump_reg(sd, REG_AVID_START_PIXEL_LSB, value);
+	dump_reg(sd, REG_AVID_START_PIXEL_MSB, value);
+	dump_reg(sd, REG_AVID_STOP_PIXEL_LSB, value);
+	dump_reg(sd, REG_AVID_STOP_PIXEL_MSB, value);
+	dump_reg(sd, REG_HSYNC_START_PIXEL_LSB, value);
+	dump_reg(sd, REG_HSYNC_START_PIXEL_MSB, value);
+	dump_reg(sd, REG_HSYNC_STOP_PIXEL_LSB, value);
+	dump_reg(sd, REG_HSYNC_STOP_PIXEL_MSB, value);
+	dump_reg(sd, REG_VSYNC_START_LINE_LSB, value);
+	dump_reg(sd, REG_VSYNC_START_LINE_MSB, value);
+	dump_reg(sd, REG_VSYNC_STOP_LINE_LSB, value);
+	dump_reg(sd, REG_VSYNC_STOP_LINE_MSB, value);
+	dump_reg(sd, REG_VBLK_START_LINE_LSB, value);
+	dump_reg(sd, REG_VBLK_START_LINE_MSB, value);
+	dump_reg(sd, REG_VBLK_STOP_LINE_LSB, value);
+	dump_reg(sd, REG_VBLK_STOP_LINE_MSB, value);
+	dump_reg(sd, REG_SYNC_CONTROL, value);
+	dump_reg(sd, REG_OUTPUT_FORMATTER1, value);
+	dump_reg(sd, REG_OUTPUT_FORMATTER2, value);
+	dump_reg(sd, REG_OUTPUT_FORMATTER3, value);
+	dump_reg(sd, REG_OUTPUT_FORMATTER4, value);
+	dump_reg(sd, REG_OUTPUT_FORMATTER5, value);
+	dump_reg(sd, REG_OUTPUT_FORMATTER6, value);
+	dump_reg(sd, REG_CLEAR_LOST_LOCK, value);
 }

 /*
  * Configure the TVP5146/47 with the current register settings
  * Returns zero if successful, or non-zero otherwise.
  */
-static int tvp514x_configure(struct tvp514x_decoder *decoder)
+static int tvp514x_configure(struct v4l2_subdev *sd,
+		struct tvp514x_decoder *decoder)
 {
 	int err;

 	/* common register initialization */
 	err =
-	    tvp514x_write_regs(decoder->client, decoder->tvp514x_regs);
+	    tvp514x_write_regs(sd, decoder->tvp514x_regs);
 	if (err)
 		return err;

 	if (debug)
-		tvp514x_reg_dump(decoder);
+		tvp514x_reg_dump(sd);

 	return 0;
 }
@@ -445,15 +431,17 @@ static int tvp514x_configure(struct tvp514x_decoder *decoder)
  * Returns ENODEV error number if no device is detected, or zero
  * if a device is detected.
  */
-static int tvp514x_detect(struct tvp514x_decoder *decoder)
+static int tvp514x_detect(struct v4l2_subdev *sd,
+		struct tvp514x_decoder *decoder)
 {
 	u8 chip_id_msb, chip_id_lsb, rom_ver;
+	struct i2c_client *client = v4l2_get_subdevdata(sd);

-	chip_id_msb = tvp514x_read_reg(decoder->client, REG_CHIP_ID_MSB);
-	chip_id_lsb = tvp514x_read_reg(decoder->client, REG_CHIP_ID_LSB);
-	rom_ver = tvp514x_read_reg(decoder->client, REG_ROM_VERSION);
+	chip_id_msb = tvp514x_read_reg(sd, REG_CHIP_ID_MSB);
+	chip_id_lsb = tvp514x_read_reg(sd, REG_CHIP_ID_LSB);
+	rom_ver = tvp514x_read_reg(sd, REG_ROM_VERSION);

-	v4l_dbg(1, debug, decoder->client,
+	v4l2_dbg(1, debug, sd,
 		 "chip id detected msb:0x%x lsb:0x%x rom version:0x%x\n",
 		 chip_id_msb, chip_id_lsb, rom_ver);
 	if ((chip_id_msb != TVP514X_CHIP_ID_MSB)
@@ -462,19 +450,16 @@ static int tvp514x_detect(struct tvp514x_decoder *decoder)
 		/* We didn't read the values we expected, so this must not be
 		 * an TVP5146/47.
 		 */
-		v4l_err(decoder->client,
-			"chip id mismatch msb:0x%x lsb:0x%x\n",
-			chip_id_msb, chip_id_lsb);
+		v4l2_err(sd, "chip id mismatch msb:0x%x lsb:0x%x\n",
+				chip_id_msb, chip_id_lsb);
 		return -ENODEV;
 	}

 	decoder->ver = rom_ver;
-	decoder->state = STATE_DETECTED;

-	v4l_info(decoder->client,
-			"%s found at 0x%x (%s)\n", decoder->client->name,
-			decoder->client->addr << 1,
-			decoder->client->adapter->name);
+	v4l2_info(sd, "%s (Version - 0x%.2x) found at 0x%x (%s)\n",
+			client->name, decoder->ver,
+			client->addr << 1, client->adapter->name);
 	return 0;
 }

@@ -483,17 +468,17 @@ static int tvp514x_detect(struct tvp514x_decoder *decoder)
  * TVP5146/47 decoder driver.
  */

-/**
- * ioctl_querystd - V4L2 decoder interface handler for VIDIOC_QUERYSTD ioctl
- * @s: pointer to standard V4L2 device structure
+/*
+ * tvp514x_querystd - V4L2 decoder interface handler for VIDIOC_QUERYSTD ioctl
+ * @sd: pointer to standard V4L2 sub-device structure
  * @std_id: standard V4L2 std_id ioctl enum
  *
  * Returns the current standard detected by TVP5146/47. If no active input is
  * detected, returns -EINVAL
  */
-static int ioctl_querystd(struct v4l2_int_device *s, v4l2_std_id *std_id)
+static int tvp514x_querystd(struct v4l2_subdev *sd, v4l2_std_id *std_id)
 {
-	struct tvp514x_decoder *decoder = s->priv;
+	struct tvp514x_decoder *decoder = to_decoder(sd);
 	enum tvp514x_std current_std;
 	enum tvp514x_input input_sel;
 	u8 sync_lock_status, lock_mask;
@@ -502,11 +487,11 @@ static int ioctl_querystd(struct v4l2_int_device *s, v4l2_std_id *std_id)
 		return -EINVAL;

 	/* get the current standard */
-	current_std = tvp514x_get_current_std(decoder);
+	current_std = tvp514x_get_current_std(sd);
 	if (current_std == STD_INVALID)
 		return -EINVAL;

-	input_sel = decoder->route.input;
+	input_sel = decoder->input;

 	switch (input_sel) {
 	case INPUT_CVBS_VI1A:
@@ -544,42 +529,39 @@ static int ioctl_querystd(struct v4l2_int_device *s, v4l2_std_id *std_id)
 		return -EINVAL;
 	}
 	/* check whether signal is locked */
-	sync_lock_status = tvp514x_read_reg(decoder->client, REG_STATUS1);
+	sync_lock_status = tvp514x_read_reg(sd, REG_STATUS1);
 	if (lock_mask != (sync_lock_status & lock_mask))
 		return -EINVAL;	/* No input detected */

 	decoder->current_std = current_std;
 	*std_id = decoder->std_list[current_std].standard.id;

-	v4l_dbg(1, debug, decoder->client, "Current STD: %s",
+	v4l2_dbg(1, debug, sd, "Current STD: %s",
 			decoder->std_list[current_std].standard.name);
 	return 0;
 }

-/**
- * ioctl_s_std - V4L2 decoder interface handler for VIDIOC_S_STD ioctl
- * @s: pointer to standard V4L2 device structure
+/*
+ * tvp514x_s_std - V4L2 decoder interface handler for VIDIOC_S_STD ioctl
+ * @sd: pointer to standard V4L2 sub-device structure
  * @std_id: standard V4L2 v4l2_std_id ioctl enum
  *
  * If std_id is supported, sets the requested standard. Otherwise, returns
  * -EINVAL
  */
-static int ioctl_s_std(struct v4l2_int_device *s, v4l2_std_id *std_id)
+static int tvp514x_s_std(struct v4l2_subdev *sd, v4l2_std_id std_id)
 {
-	struct tvp514x_decoder *decoder = s->priv;
+	struct tvp514x_decoder *decoder = to_decoder(sd);
 	int err, i;

-	if (std_id == NULL)
-		return -EINVAL;
-
 	for (i = 0; i < decoder->num_stds; i++)
-		if (*std_id & decoder->std_list[i].standard.id)
+		if (std_id & decoder->std_list[i].standard.id)
 			break;

 	if ((i == decoder->num_stds) || (i == STD_INVALID))
 		return -EINVAL;

-	err = tvp514x_write_reg(decoder->client, REG_VIDEO_STD,
+	err = tvp514x_write_reg(sd, REG_VIDEO_STD,
 				decoder->std_list[i].video_std);
 	if (err)
 		return err;
@@ -588,24 +570,24 @@ static int ioctl_s_std(struct v4l2_int_device *s, v4l2_std_id *std_id)
 	decoder->tvp514x_regs[REG_VIDEO_STD].val =
 		decoder->std_list[i].video_std;

-	v4l_dbg(1, debug, decoder->client, "Standard set to: %s",
+	v4l2_dbg(1, debug, sd, "Standard set to: %s",
 			decoder->std_list[i].standard.name);
 	return 0;
 }

-/**
- * ioctl_s_routing - V4L2 decoder interface handler for VIDIOC_S_INPUT ioctl
- * @s: pointer to standard V4L2 device structure
+/*
+ * tvp514x_s_routing - V4L2 decoder interface handler for VIDIOC_S_INPUT ioctl
+ * @sd: pointer to standard V4L2 sub-device structure
  * @index: number of the input
  *
  * If index is valid, selects the requested input. Otherwise, returns -EINVAL if
  * the input is not supported or there is no active signal present in the
  * selected input.
  */
-static int ioctl_s_routing(struct v4l2_int_device *s,
-				struct v4l2_routing *route)
+static int tvp514x_s_routing(struct v4l2_subdev *sd,
+				u32 input, u32 output, u32 config)
 {
-	struct tvp514x_decoder *decoder = s->priv;
+	struct tvp514x_decoder *decoder = to_decoder(sd);
 	int err;
 	enum tvp514x_input input_sel;
 	enum tvp514x_output output_sel;
@@ -613,20 +595,20 @@ static int ioctl_s_routing(struct v4l2_int_device *s,
 	u8 sync_lock_status, lock_mask;
 	int try_count = LOCK_RETRY_COUNT;

-	if ((!route) || (route->input >= INPUT_INVALID) ||
-			(route->output >= OUTPUT_INVALID))
+	if ((input >= INPUT_INVALID) ||
+			(output >= OUTPUT_INVALID))
 		return -EINVAL;	/* Index out of bound */

-	input_sel = route->input;
-	output_sel = route->output;
+	input_sel = input;
+	output_sel = output;

-	err = tvp514x_write_reg(decoder->client, REG_INPUT_SEL, input_sel);
+	err = tvp514x_write_reg(sd, REG_INPUT_SEL, input_sel);
 	if (err)
 		return err;

-	output_sel |= tvp514x_read_reg(decoder->client,
+	output_sel |= tvp514x_read_reg(sd,
 			REG_OUTPUT_FORMATTER1) & 0x7;
-	err = tvp514x_write_reg(decoder->client, REG_OUTPUT_FORMATTER1,
+	err = tvp514x_write_reg(sd, REG_OUTPUT_FORMATTER1,
 			output_sel);
 	if (err)
 		return err;
@@ -637,7 +619,7 @@ static int ioctl_s_routing(struct v4l2_int_device *s,
 	/* Clear status */
 	msleep(LOCK_RETRY_DELAY);
 	err =
-	    tvp514x_write_reg(decoder->client, REG_CLEAR_LOST_LOCK, 0x01);
+	    tvp514x_write_reg(sd, REG_CLEAR_LOST_LOCK, 0x01);
 	if (err)
 		return err;

@@ -682,11 +664,11 @@ static int ioctl_s_routing(struct v4l2_int_device *s,
 		msleep(LOCK_RETRY_DELAY);

 		/* get the current standard for future reference */
-		current_std = tvp514x_get_current_std(decoder);
+		current_std = tvp514x_get_current_std(sd);
 		if (current_std == STD_INVALID)
 			continue;

-		sync_lock_status = tvp514x_read_reg(decoder->client,
+		sync_lock_status = tvp514x_read_reg(sd,
 				REG_STATUS1);
 		if (lock_mask == (sync_lock_status & lock_mask))
 			break;	/* Input detected */
@@ -696,28 +678,26 @@ static int ioctl_s_routing(struct v4l2_int_device *s,
 		return -EINVAL;

 	decoder->current_std = current_std;
-	decoder->route.input = route->input;
-	decoder->route.output = route->output;
+	decoder->input = input;
+	decoder->output = output;

-	v4l_dbg(1, debug, decoder->client,
-			"Input set to: %d, std : %d",
+	v4l2_dbg(1, debug, sd, "Input set to: %d, std : %d",
 			input_sel, current_std);

 	return 0;
 }

-/**
- * ioctl_queryctrl - V4L2 decoder interface handler for VIDIOC_QUERYCTRL ioctl
- * @s: pointer to standard V4L2 device structure
+/*
+ * tvp514x_queryctrl - V4L2 decoder interface handler for VIDIOC_QUERYCTRL ioctl
+ * @sd: pointer to standard V4L2 sub-device structure
  * @qctrl: standard V4L2 v4l2_queryctrl structure
  *
  * If the requested control is supported, returns the control information.
  * Otherwise, returns -EINVAL if the control is not supported.
  */
 static int
-ioctl_queryctrl(struct v4l2_int_device *s, struct v4l2_queryctrl *qctrl)
+tvp514x_queryctrl(struct v4l2_subdev *sd, struct v4l2_queryctrl *qctrl)
 {
-	struct tvp514x_decoder *decoder = s->priv;
 	int err = -EINVAL;

 	if (qctrl == NULL)
@@ -744,30 +724,27 @@ ioctl_queryctrl(struct v4l2_int_device *s, struct v4l2_queryctrl *qctrl)
 		err = v4l2_ctrl_query_fill(qctrl, -180, 180, 180, 0);
 		break;
 	case V4L2_CID_AUTOGAIN:
-		/* Autogain is either 0 or 1*/
-		memcpy(qctrl, &tvp514x_autogain_ctrl,
-				sizeof(struct v4l2_queryctrl));
-		err = 0;
+		/*
+		 * Auto Gain supported is -
+		 * 	0 - 1 (Default - 1)
+		 */
+		err = v4l2_ctrl_query_fill(qctrl, 0, 1, 1, 1);
 		break;
 	default:
-		v4l_err(decoder->client,
-			"invalid control id %d\n", qctrl->id);
+		v4l2_err(sd, "invalid control id %d\n", qctrl->id);
 		return err;
 	}

-	v4l_dbg(1, debug, decoder->client,
-			"Query Control: %s : Min - %d, Max - %d, Def - %d",
-			qctrl->name,
-			qctrl->minimum,
-			qctrl->maximum,
+	v4l2_dbg(1, debug, sd, "Query Control:%s: Min - %d, Max - %d, Def - %d",
+			qctrl->name, qctrl->minimum, qctrl->maximum,
 			qctrl->default_value);

 	return err;
 }

-/**
- * ioctl_g_ctrl - V4L2 decoder interface handler for VIDIOC_G_CTRL ioctl
- * @s: pointer to standard V4L2 device structure
+/*
+ * tvp514x_g_ctrl - V4L2 decoder interface handler for VIDIOC_G_CTRL ioctl
+ * @sd: pointer to standard V4L2 sub-device structure
  * @ctrl: pointer to v4l2_control structure
  *
  * If the requested control is supported, returns the control's current
@@ -775,9 +752,9 @@ ioctl_queryctrl(struct v4l2_int_device *s, struct v4l2_queryctrl *qctrl)
  * supported.
  */
 static int
-ioctl_g_ctrl(struct v4l2_int_device *s, struct v4l2_control *ctrl)
+tvp514x_g_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
 {
-	struct tvp514x_decoder *decoder = s->priv;
+	struct tvp514x_decoder *decoder = to_decoder(sd);

 	if (ctrl == NULL)
 		return -EINVAL;
@@ -811,74 +788,70 @@ ioctl_g_ctrl(struct v4l2_int_device *s, struct v4l2_control *ctrl)

 		break;
 	default:
-		v4l_err(decoder->client,
-			"invalid control id %d\n", ctrl->id);
+		v4l2_err(sd, "invalid control id %d\n", ctrl->id);
 		return -EINVAL;
 	}

-	v4l_dbg(1, debug, decoder->client,
-			"Get Control: ID - %d - %d",
+	v4l2_dbg(1, debug, sd, "Get Control: ID - %d - %d",
 			ctrl->id, ctrl->value);
 	return 0;
 }

-/**
- * ioctl_s_ctrl - V4L2 decoder interface handler for VIDIOC_S_CTRL ioctl
- * @s: pointer to standard V4L2 device structure
+/*
+ * tvp514x_s_ctrl - V4L2 decoder interface handler for VIDIOC_S_CTRL ioctl
+ * @sd: pointer to standard V4L2 sub-device structure
  * @ctrl: pointer to v4l2_control structure
  *
  * If the requested control is supported, sets the control's current
  * value in HW. Otherwise, returns -EINVAL if the control is not supported.
  */
 static int
-ioctl_s_ctrl(struct v4l2_int_device *s, struct v4l2_control *ctrl)
+tvp514x_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
 {
-	struct tvp514x_decoder *decoder = s->priv;
+	struct tvp514x_decoder *decoder = to_decoder(sd);
 	int err = -EINVAL, value;

 	if (ctrl == NULL)
 		return err;

-	value = (__s32) ctrl->value;
+	value = ctrl->value;

 	switch (ctrl->id) {
 	case V4L2_CID_BRIGHTNESS:
 		if (ctrl->value < 0 || ctrl->value > 255) {
-			v4l_err(decoder->client,
-					"invalid brightness setting %d\n",
+			v4l2_err(sd, "invalid brightness setting %d\n",
 					ctrl->value);
 			return -ERANGE;
 		}
-		err = tvp514x_write_reg(decoder->client, REG_BRIGHTNESS,
+		err = tvp514x_write_reg(sd, REG_BRIGHTNESS,
 				value);
 		if (err)
 			return err;
+
 		decoder->tvp514x_regs[REG_BRIGHTNESS].val = value;
 		break;
 	case V4L2_CID_CONTRAST:
 		if (ctrl->value < 0 || ctrl->value > 255) {
-			v4l_err(decoder->client,
-					"invalid contrast setting %d\n",
+			v4l2_err(sd, "invalid contrast setting %d\n",
 					ctrl->value);
 			return -ERANGE;
 		}
-		err = tvp514x_write_reg(decoder->client, REG_CONTRAST,
-				value);
+		err = tvp514x_write_reg(sd, REG_CONTRAST, value);
 		if (err)
 			return err;
+
 		decoder->tvp514x_regs[REG_CONTRAST].val = value;
 		break;
 	case V4L2_CID_SATURATION:
 		if (ctrl->value < 0 || ctrl->value > 255) {
-			v4l_err(decoder->client,
-					"invalid saturation setting %d\n",
+			v4l2_err(sd, "invalid saturation setting %d\n",
 					ctrl->value);
 			return -ERANGE;
 		}
-		err = tvp514x_write_reg(decoder->client, REG_SATURATION,
-				value);
+		err = tvp514x_write_reg(sd, REG_SATURATION, value);
 		if (err)
 			return err;
+
 		decoder->tvp514x_regs[REG_SATURATION].val = value;
 		break;
 	case V4L2_CID_HUE:
@@ -889,15 +862,13 @@ ioctl_s_ctrl(struct v4l2_int_device *s, struct v4l2_control *ctrl)
 		else if (value == 0)
 			value = 0;
 		else {
-			v4l_err(decoder->client,
-					"invalid hue setting %d\n",
-					ctrl->value);
+			v4l2_err(sd, "invalid hue setting %d\n", ctrl->value);
 			return -ERANGE;
 		}
-		err = tvp514x_write_reg(decoder->client, REG_HUE,
-				value);
+		err = tvp514x_write_reg(sd, REG_HUE, value);
 		if (err)
 			return err;
+
 		decoder->tvp514x_regs[REG_HUE].val = value;
 		break;
 	case V4L2_CID_AUTOGAIN:
@@ -906,41 +877,38 @@ ioctl_s_ctrl(struct v4l2_int_device *s, struct v4l2_control *ctrl)
 		else if (value == 0)
 			value = 0x0C;
 		else {
-			v4l_err(decoder->client,
-					"invalid auto gain setting %d\n",
+			v4l2_err(sd, "invalid auto gain setting %d\n",
 					ctrl->value);
 			return -ERANGE;
 		}
-		err = tvp514x_write_reg(decoder->client, REG_AFE_GAIN_CTRL,
-				value);
+		err = tvp514x_write_reg(sd, REG_AFE_GAIN_CTRL, value);
 		if (err)
 			return err;
+
 		decoder->tvp514x_regs[REG_AFE_GAIN_CTRL].val = value;
 		break;
 	default:
-		v4l_err(decoder->client,
-			"invalid control id %d\n", ctrl->id);
+		v4l2_err(sd, "invalid control id %d\n", ctrl->id);
 		return err;
 	}

-	v4l_dbg(1, debug, decoder->client,
-			"Set Control: ID - %d - %d",
+	v4l2_dbg(1, debug, sd, "Set Control: ID - %d - %d",
 			ctrl->id, ctrl->value);

 	return err;
 }

-/**
- * ioctl_enum_fmt_cap - Implement the CAPTURE buffer VIDIOC_ENUM_FMT ioctl
- * @s: pointer to standard V4L2 device structure
+/*
+ * tvp514x_enum_fmt_cap - Implement the CAPTURE buffer VIDIOC_ENUM_FMT ioctl
+ * @sd: pointer to standard V4L2 sub-device structure
  * @fmt: standard V4L2 VIDIOC_ENUM_FMT ioctl structure
  *
  * Implement the VIDIOC_ENUM_FMT ioctl to enumerate supported formats
  */
 static int
-ioctl_enum_fmt_cap(struct v4l2_int_device *s, struct v4l2_fmtdesc *fmt)
+tvp514x_enum_fmt_cap(struct v4l2_subdev *sd, struct v4l2_fmtdesc *fmt)
 {
-	struct tvp514x_decoder *decoder = s->priv;
+	struct tvp514x_decoder *decoder = to_decoder(sd);
 	int index;

 	if (fmt == NULL)
@@ -956,16 +924,15 @@ ioctl_enum_fmt_cap(struct v4l2_int_device *s, struct v4l2_fmtdesc *fmt)
 	memcpy(fmt, &decoder->fmt_list[index],
 		sizeof(struct v4l2_fmtdesc));

-	v4l_dbg(1, debug, decoder->client,
-			"Current FMT: index - %d (%s)",
+	v4l2_dbg(1, debug, sd, "Current FMT: index - %d (%s)",
 			decoder->fmt_list[index].index,
 			decoder->fmt_list[index].description);
 	return 0;
 }

-/**
- * ioctl_try_fmt_cap - Implement the CAPTURE buffer VIDIOC_TRY_FMT ioctl
- * @s: pointer to standard V4L2 device structure
+/*
+ * tvp514x_try_fmt_cap - Implement the CAPTURE buffer VIDIOC_TRY_FMT ioctl
+ * @sd: pointer to standard V4L2 sub-device structure
  * @f: pointer to standard V4L2 VIDIOC_TRY_FMT ioctl structure
  *
  * Implement the VIDIOC_TRY_FMT ioctl for the CAPTURE buffer type. This
@@ -973,9 +940,9 @@ ioctl_enum_fmt_cap(struct v4l2_int_device *s, struct v4l2_fmtdesc *fmt)
  * without actually making it take effect.
  */
 static int
-ioctl_try_fmt_cap(struct v4l2_int_device *s, struct v4l2_format *f)
+tvp514x_try_fmt_cap(struct v4l2_subdev *sd, struct v4l2_format *f)
 {
-	struct tvp514x_decoder *decoder = s->priv;
+	struct tvp514x_decoder *decoder = to_decoder(sd);
 	int ifmt;
 	struct v4l2_pix_format *pix;
 	enum tvp514x_std current_std;
@@ -989,7 +956,7 @@ ioctl_try_fmt_cap(struct v4l2_int_device *s, struct v4l2_format *f)
 	pix = &f->fmt.pix;

 	/* Calculate height and width based on current standard */
-	current_std = tvp514x_get_current_std(decoder);
+	current_std = tvp514x_get_current_std(sd);
 	if (current_std == STD_INVALID)
 		return -EINVAL;

@@ -1012,17 +979,16 @@ ioctl_try_fmt_cap(struct v4l2_int_device *s, struct v4l2_format *f)
 	pix->colorspace = V4L2_COLORSPACE_SMPTE170M;
 	pix->priv = 0;

-	v4l_dbg(1, debug, decoder->client,
-			"Try FMT: pixelformat - %s, bytesperline - %d"
+	v4l2_dbg(1, debug, sd, "Try FMT: pixelformat - %s, bytesperline - %d"
 			"Width - %d, Height - %d",
 			decoder->fmt_list[ifmt].description, pix->bytesperline,
 			pix->width, pix->height);
 	return 0;
 }

-/**
- * ioctl_s_fmt_cap - V4L2 decoder interface handler for VIDIOC_S_FMT ioctl
- * @s: pointer to standard V4L2 device structure
+/*
+ * tvp514x_s_fmt_cap - V4L2 decoder interface handler for VIDIOC_S_FMT ioctl
+ * @sd: pointer to standard V4L2 sub-device structure
  * @f: pointer to standard V4L2 VIDIOC_S_FMT ioctl structure
  *
  * If the requested format is supported, configures the HW to use that
@@ -1030,9 +996,9 @@ ioctl_try_fmt_cap(struct v4l2_int_device *s, struct v4l2_format *f)
  * correctly configured.
  */
 static int
-ioctl_s_fmt_cap(struct v4l2_int_device *s, struct v4l2_format *f)
+tvp514x_s_fmt_cap(struct v4l2_subdev *sd, struct v4l2_format *f)
 {
-	struct tvp514x_decoder *decoder = s->priv;
+	struct tvp514x_decoder *decoder = to_decoder(sd);
 	struct v4l2_pix_format *pix;
 	int rval;

@@ -1043,7 +1009,7 @@ ioctl_s_fmt_cap(struct v4l2_int_device *s, struct v4l2_format *f)
 		return -EINVAL;	/* only capture is supported */

 	pix = &f->fmt.pix;
-	rval = ioctl_try_fmt_cap(s, f);
+	rval = tvp514x_try_fmt_cap(sd, f);
 	if (rval)
 		return rval;

@@ -1052,18 +1018,18 @@ ioctl_s_fmt_cap(struct v4l2_int_device *s, struct v4l2_format *f)
 	return rval;
 }

-/**
- * ioctl_g_fmt_cap - V4L2 decoder interface handler for ioctl_g_fmt_cap
- * @s: pointer to standard V4L2 device structure
+/*
+ * tvp514x_g_fmt_cap - V4L2 decoder interface handler for tvp514x_g_fmt_cap
+ * @sd: pointer to standard V4L2 sub-device structure
  * @f: pointer to standard V4L2 v4l2_format structure
  *
  * Returns the decoder's current pixel format in the v4l2_format
  * parameter.
  */
 static int
-ioctl_g_fmt_cap(struct v4l2_int_device *s, struct v4l2_format *f)
+tvp514x_g_fmt_cap(struct v4l2_subdev *sd, struct v4l2_format *f)
 {
-	struct tvp514x_decoder *decoder = s->priv;
+	struct tvp514x_decoder *decoder = to_decoder(sd);

 	if (f == NULL)
 		return -EINVAL;
@@ -1073,25 +1039,24 @@ ioctl_g_fmt_cap(struct v4l2_int_device *s, struct v4l2_format *f)

 	f->fmt.pix = decoder->pix;

-	v4l_dbg(1, debug, decoder->client,
-			"Current FMT: bytesperline - %d"
+	v4l2_dbg(1, debug, sd, "Current FMT: bytesperline - %d"
 			"Width - %d, Height - %d",
 			decoder->pix.bytesperline,
 			decoder->pix.width, decoder->pix.height);
 	return 0;
 }

-/**
- * ioctl_g_parm - V4L2 decoder interface handler for VIDIOC_G_PARM ioctl
- * @s: pointer to standard V4L2 device structure
+/*
+ * tvp514x_g_parm - V4L2 decoder interface handler for VIDIOC_G_PARM ioctl
+ * @sd: pointer to standard V4L2 sub-device structure
  * @a: pointer to standard V4L2 VIDIOC_G_PARM ioctl structure
  *
  * Returns the decoder's video CAPTURE parameters.
  */
 static int
-ioctl_g_parm(struct v4l2_int_device *s, struct v4l2_streamparm *a)
+tvp514x_g_parm(struct v4l2_subdev *sd, struct v4l2_streamparm *a)
 {
-	struct tvp514x_decoder *decoder = s->priv;
+	struct tvp514x_decoder *decoder = to_decoder(sd);
 	struct v4l2_captureparm *cparm;
 	enum tvp514x_std current_std;

@@ -1105,7 +1070,7 @@ ioctl_g_parm(struct v4l2_int_device *s, struct v4l2_streamparm *a)
 	a->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;

 	/* get the current standard */
-	current_std = tvp514x_get_current_std(decoder);
+	current_std = tvp514x_get_current_std(sd);
 	if (current_std == STD_INVALID)
 		return -EINVAL;

@@ -1119,18 +1084,18 @@ ioctl_g_parm(struct v4l2_int_device *s, struct v4l2_streamparm *a)
 	return 0;
 }

-/**
- * ioctl_s_parm - V4L2 decoder interface handler for VIDIOC_S_PARM ioctl
- * @s: pointer to standard V4L2 device structure
+/*
+ * tvp514x_s_parm - V4L2 decoder interface handler for VIDIOC_S_PARM ioctl
+ * @sd: pointer to standard V4L2 sub-device structure
  * @a: pointer to standard V4L2 VIDIOC_S_PARM ioctl structure
  *
  * Configures the decoder to use the input parameters, if possible. If
  * not possible, returns the appropriate error code.
  */
 static int
-ioctl_s_parm(struct v4l2_int_device *s, struct v4l2_streamparm *a)
+tvp514x_s_parm(struct v4l2_subdev *sd, struct v4l2_streamparm *a)
 {
-	struct tvp514x_decoder *decoder = s->priv;
+	struct tvp514x_decoder *decoder = to_decoder(sd);
 	struct v4l2_fract *timeperframe;
 	enum tvp514x_std current_std;

@@ -1143,7 +1108,7 @@ ioctl_s_parm(struct v4l2_int_device *s, struct v4l2_streamparm *a)
 	timeperframe = &a->parm.capture.timeperframe;

 	/* get the current standard */
-	current_std = tvp514x_get_current_std(decoder);
+	current_std = tvp514x_get_current_std(sd);
 	if (current_std == STD_INVALID)
 		return -EINVAL;

@@ -1155,112 +1120,59 @@ ioctl_s_parm(struct v4l2_int_device *s, struct v4l2_streamparm *a)
 	return 0;
 }

-/**
- * ioctl_g_ifparm - V4L2 decoder interface handler for vidioc_int_g_ifparm_num
- * @s: pointer to standard V4L2 device structure
- * @p: pointer to standard V4L2 vidioc_int_g_ifparm_num ioctl structure
- *
- * Gets slave interface parameters.
- * Calculates the required xclk value to support the requested
- * clock parameters in p. This value is returned in the p
- * parameter.
- */
-static int ioctl_g_ifparm(struct v4l2_int_device *s, struct v4l2_ifparm *p)
-{
-	struct tvp514x_decoder *decoder = s->priv;
-	int rval;
-
-	if (p == NULL)
-		return -EINVAL;
-
-	if (NULL == decoder->pdata->ifparm)
-		return -EINVAL;
-
-	rval = decoder->pdata->ifparm(p);
-	if (rval) {
-		v4l_err(decoder->client, "g_ifparm.Err[%d]\n", rval);
-		return rval;
-	}
-
-	p->u.bt656.clock_curr = TVP514X_XCLK_BT656;
-
-	return 0;
-}
-
-/**
- * ioctl_g_priv - V4L2 decoder interface handler for vidioc_int_g_priv_num
- * @s: pointer to standard V4L2 device structure
- * @p: void pointer to hold decoder's private data address
- *
- * Returns device's (decoder's) private data area address in p parameter
- */
-static int ioctl_g_priv(struct v4l2_int_device *s, void *p)
-{
-	struct tvp514x_decoder *decoder = s->priv;
-
-	if (NULL == decoder->pdata->priv_data_set)
-		return -EINVAL;
-
-	return decoder->pdata->priv_data_set(p);
-}
-
-/**
- * ioctl_s_power - V4L2 decoder interface handler for vidioc_int_s_power_num
- * @s: pointer to standard V4L2 device structure
+/*
+ * tvp514x_s_stream - V4L2 decoder interface handler for vidioc_int_s_power_num
+ * @sd: pointer to standard V4L2 sub-device structure
  * @on: power state to which device is to be set
  *
  * Sets devices power state to requrested state, if possible.
  */
-static int ioctl_s_power(struct v4l2_int_device *s, enum v4l2_power on)
+static int tvp514x_s_stream(struct v4l2_subdev *sd, int enable)
 {
-	struct tvp514x_decoder *decoder = s->priv;
 	int err = 0;
+	struct i2c_client *client = v4l2_get_subdevdata(sd);
+	struct tvp514x_decoder *decoder = to_decoder(sd);

-	switch (on) {
-	case V4L2_POWER_OFF:
-		/* Power Down Sequence */
-		err =
-		    tvp514x_write_reg(decoder->client, REG_OPERATION_MODE,
-					0x01);
-		/* Disable mux for TVP5146/47 decoder data path */
-		if (decoder->pdata->power_set)
-			err |= decoder->pdata->power_set(on);
-		decoder->state = STATE_NOT_DETECTED;
-		break;
+	if (decoder->state == enable)
+		return 0;

-	case V4L2_POWER_STANDBY:
-		if (decoder->pdata->power_set)
-			err = decoder->pdata->power_set(on);
+	switch (enable) {
+	case 0:
+	{
+		/* Power Down Sequence */
+		err = tvp514x_write_reg(sd, REG_OPERATION_MODE, 0x01);
+		if (err) {
+			v4l2_err(sd, "Unable to turn off decoder\n");
+			return err;
+		}
+		decoder->state = enable;
 		break;
+	}
+	case 1:
+	{
+		struct tvp514x_reg *int_seq = (struct tvp514x_reg *)
+				client->driver->id_table->driver_data;

-	case V4L2_POWER_ON:
-		/* Enable mux for TVP5146/47 decoder data path */
-		if ((decoder->pdata->power_set) &&
-				(decoder->state == STATE_NOT_DETECTED)) {
-			int i;
-			struct tvp514x_init_seq *int_seq =
-				(struct tvp514x_init_seq *)
-				decoder->id->driver_data;
-
-			err = decoder->pdata->power_set(on);
-
-			/* Power Up Sequence */
-			for (i = 0; i < int_seq->no_regs; i++) {
-				err |= tvp514x_write_reg(decoder->client,
-						int_seq->init_reg_seq[i].reg,
-						int_seq->init_reg_seq[i].val);
-			}
-			/* Detect the sensor is not already detected */
-			err |= tvp514x_detect(decoder);
-			if (err) {
-				v4l_err(decoder->client,
-						"Unable to detect decoder\n");
-				return err;
-			}
+		/* Power Up Sequence */
+		err = tvp514x_write_regs(sd, int_seq);
+		if (err) {
+			v4l2_err(sd, "Unable to turn on decoder\n");
+			return err;
+		}
+		/* Detect the sensor is not already detected */
+		err = tvp514x_detect(sd, decoder);
+		if (err) {
+			v4l2_err(sd, "Unable to detect decoder\n");
+			return err;
+		}
+		err = tvp514x_configure(sd, decoder);
+		if (err) {
+			v4l2_err(sd, "Unable to configure decoder\n");
+			return err;
 		}
-		err |= tvp514x_configure(decoder);
+		decoder->state = enable;
 		break;
-
+	}
 	default:
 		err = -ENODEV;
 		break;
@@ -1269,93 +1181,37 @@ static int ioctl_s_power(struct v4l2_int_device *s, enum v4l2_power on)
 	return err;
 }

-/**
- * ioctl_init - V4L2 decoder interface handler for VIDIOC_INT_INIT
- * @s: pointer to standard V4L2 device structure
- *
- * Initialize the decoder device (calls tvp514x_configure())
- */
-static int ioctl_init(struct v4l2_int_device *s)
-{
-	struct tvp514x_decoder *decoder = s->priv;
-
-	/* Set default standard to auto */
-	decoder->tvp514x_regs[REG_VIDEO_STD].val =
-	    VIDEO_STD_AUTO_SWITCH_BIT;
-
-	return tvp514x_configure(decoder);
-}
-
-/**
- * ioctl_dev_exit - V4L2 decoder interface handler for vidioc_int_dev_exit_num
- * @s: pointer to standard V4L2 device structure
- *
- * Delinitialise the dev. at slave detach. The complement of ioctl_dev_init.
- */
-static int ioctl_dev_exit(struct v4l2_int_device *s)
-{
-	return 0;
-}
-
-/**
- * ioctl_dev_init - V4L2 decoder interface handler for vidioc_int_dev_init_num
- * @s: pointer to standard V4L2 device structure
- *
- * Initialise the device when slave attaches to the master. Returns 0 if
- * TVP5146/47 device could be found, otherwise returns appropriate error.
- */
-static int ioctl_dev_init(struct v4l2_int_device *s)
-{
-	struct tvp514x_decoder *decoder = s->priv;
-	int err;
-
-	err = tvp514x_detect(decoder);
-	if (err < 0) {
-		v4l_err(decoder->client,
-			"Unable to detect decoder\n");
-		return err;
-	}
-
-	v4l_info(decoder->client,
-		 "chip version 0x%.2x detected\n", decoder->ver);
+static const struct v4l2_subdev_core_ops tvp514x_core_ops = {
+	.queryctrl = tvp514x_queryctrl,
+	.g_ctrl = tvp514x_g_ctrl,
+	.s_ctrl = tvp514x_s_ctrl,
+	.s_std = tvp514x_s_std,
+};

-	return 0;
-}
+static const struct v4l2_subdev_video_ops tvp514x_video_ops = {
+	.s_routing = tvp514x_s_routing,
+	.querystd = tvp514x_querystd,
+	.enum_fmt = tvp514x_enum_fmt_cap,
+	.g_fmt = tvp514x_g_fmt_cap,
+	.try_fmt = tvp514x_try_fmt_cap,
+	.s_fmt = tvp514x_s_fmt_cap,
+	.g_parm = tvp514x_g_parm,
+	.s_parm = tvp514x_s_parm,
+	.s_stream = tvp514x_s_stream,
+};

-static struct v4l2_int_ioctl_desc tvp514x_ioctl_desc[] = {
-	{vidioc_int_dev_init_num, (v4l2_int_ioctl_func*) ioctl_dev_init},
-	{vidioc_int_dev_exit_num, (v4l2_int_ioctl_func*) ioctl_dev_exit},
-	{vidioc_int_s_power_num, (v4l2_int_ioctl_func*) ioctl_s_power},
-	{vidioc_int_g_priv_num, (v4l2_int_ioctl_func*) ioctl_g_priv},
-	{vidioc_int_g_ifparm_num, (v4l2_int_ioctl_func*) ioctl_g_ifparm},
-	{vidioc_int_init_num, (v4l2_int_ioctl_func*) ioctl_init},
-	{vidioc_int_enum_fmt_cap_num,
-	 (v4l2_int_ioctl_func *) ioctl_enum_fmt_cap},
-	{vidioc_int_try_fmt_cap_num,
-	 (v4l2_int_ioctl_func *) ioctl_try_fmt_cap},
-	{vidioc_int_g_fmt_cap_num,
-	 (v4l2_int_ioctl_func *) ioctl_g_fmt_cap},
-	{vidioc_int_s_fmt_cap_num,
-	 (v4l2_int_ioctl_func *) ioctl_s_fmt_cap},
-	{vidioc_int_g_parm_num, (v4l2_int_ioctl_func *) ioctl_g_parm},
-	{vidioc_int_s_parm_num, (v4l2_int_ioctl_func *) ioctl_s_parm},
-	{vidioc_int_queryctrl_num,
-	 (v4l2_int_ioctl_func *) ioctl_queryctrl},
-	{vidioc_int_g_ctrl_num, (v4l2_int_ioctl_func *) ioctl_g_ctrl},
-	{vidioc_int_s_ctrl_num, (v4l2_int_ioctl_func *) ioctl_s_ctrl},
-	{vidioc_int_querystd_num, (v4l2_int_ioctl_func *) ioctl_querystd},
-	{vidioc_int_s_std_num, (v4l2_int_ioctl_func *) ioctl_s_std},
-	{vidioc_int_s_video_routing_num,
-		(v4l2_int_ioctl_func *) ioctl_s_routing},
+static const struct v4l2_subdev_ops tvp514x_ops = {
+	.core = &tvp514x_core_ops,
+	.video = &tvp514x_video_ops,
 };

 static struct tvp514x_decoder tvp514x_dev = {
-	.state = STATE_NOT_DETECTED,
+	.state = 0,

 	.fmt_list = tvp514x_fmt_list,
 	.num_fmts = ARRAY_SIZE(tvp514x_fmt_list),

-	.pix = {		/* Default to NTSC 8-bit YUV 422 */
+	.pix = {/* Default to NTSC 8-bit YUV 422 */
 		.width = NTSC_NUM_ACTIVE_PIXELS,
 		.height = NTSC_NUM_ACTIVE_LINES,
 		.pixelformat = V4L2_PIX_FMT_UYVY,
@@ -1369,20 +1225,13 @@ static struct tvp514x_decoder tvp514x_dev = {
 	.current_std = STD_NTSC_MJ,
 	.std_list = tvp514x_std_list,
 	.num_stds = ARRAY_SIZE(tvp514x_std_list),
-	.v4l2_int_device = {
-		.module = THIS_MODULE,
-		.name = TVP514X_MODULE_NAME,
-		.type = v4l2_int_type_slave,
-	},
-	.tvp514x_slave = {
-		.ioctls = tvp514x_ioctl_desc,
-		.num_ioctls = ARRAY_SIZE(tvp514x_ioctl_desc),
-	},
+
 };

-/**
+/*
  * tvp514x_probe - decoder driver i2c probe handler
  * @client: i2c driver client device structure
+ * @id: i2c driver id table
  *
  * Register decoder as an i2c client device and V4L2
  * device.
@@ -1391,67 +1240,59 @@ static int
 tvp514x_probe(struct i2c_client *client, const struct i2c_device_id *id)
 {
 	struct tvp514x_decoder *decoder;
-	int err;
+	struct v4l2_subdev *sd;

 	/* Check if the adapter supports the needed features */
 	if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA))
 		return -EIO;

+	if (!client->dev.platform_data) {
+		v4l2_err(client, "No platform data!!\n");
+		return -ENODEV;
+	}
+
 	decoder = kzalloc(sizeof(*decoder), GFP_KERNEL);
 	if (!decoder)
 		return -ENOMEM;

-	if (!client->dev.platform_data) {
-		v4l_err(client, "No platform data!!\n");
-		err = -ENODEV;
-		goto out_free;
-	}
-
+	/*
+	 * Initialize the tvp514x_decoder with default configuration
+	 */
 	*decoder = tvp514x_dev;
-	decoder->v4l2_int_device.priv = decoder;
-	decoder->pdata = client->dev.platform_data;
-	decoder->v4l2_int_device.u.slave = &decoder->tvp514x_slave;
+	/* Copy default register configuration */
 	memcpy(decoder->tvp514x_regs, tvp514x_reg_list_default,
 			sizeof(tvp514x_reg_list_default));
+
+	/*
+	 * Copy board specific information here
+	 */
+	decoder->pdata = client->dev.platform_data;
+
 	/*
 	 * Fetch platform specific data, and configure the
 	 * tvp514x_reg_list[] accordingly. Since this is one
 	 * time configuration, no need to preserve.
 	 */
 	decoder->tvp514x_regs[REG_OUTPUT_FORMATTER2].val |=
-			(decoder->pdata->clk_polarity << 1);
+		(decoder->pdata->clk_polarity << 1);
 	decoder->tvp514x_regs[REG_SYNC_CONTROL].val |=
-			((decoder->pdata->hs_polarity << 2) |
-			(decoder->pdata->vs_polarity << 3));
-	/*
-	 * Save the id data, required for power up sequence
-	 */
-	decoder->id = (struct i2c_device_id *)id;
-	/* Attach to Master */
-	strcpy(decoder->v4l2_int_device.u.slave->attach_to,
-			decoder->pdata->master);
-	decoder->client = client;
-	i2c_set_clientdata(client, decoder);
+		((decoder->pdata->hs_polarity << 2) |
+		 (decoder->pdata->vs_polarity << 3));
+	/* Set default standard to auto */
+	decoder->tvp514x_regs[REG_VIDEO_STD].val =
+		VIDEO_STD_AUTO_SWITCH_BIT;

 	/* Register with V4L2 layer as slave device */
-	err = v4l2_int_device_register(&decoder->v4l2_int_device);
-	if (err) {
-		i2c_set_clientdata(client, NULL);
-		v4l_err(client,
-			"Unable to register to v4l2. Err[%d]\n", err);
-		goto out_free;
-
-	} else
-		v4l_info(client, "Registered to v4l2 master %s!!\n",
-				decoder->pdata->master);
+	sd = &decoder->sd;
+	v4l2_i2c_subdev_init(sd, client, &tvp514x_ops);
+
+	v4l2_info(sd, "%s decoder driver registered !!\n", sd->name);
+
 	return 0;

-out_free:
-	kfree(decoder);
-	return err;
 }

-/**
+/*
  * tvp514x_remove - decoder driver i2c remove handler
  * @client: i2c driver client device structure
  *
@@ -1460,13 +1301,10 @@ out_free:
  */
 static int __exit tvp514x_remove(struct i2c_client *client)
 {
-	struct tvp514x_decoder *decoder = i2c_get_clientdata(client);
+	struct v4l2_subdev *sd = i2c_get_clientdata(client);
+	struct tvp514x_decoder *decoder = to_decoder(sd);

-	if (!client->adapter)
-		return -ENODEV;	/* our client isn't attached */
-
-	v4l2_int_device_unregister(&decoder->v4l2_int_device);
-	i2c_set_clientdata(client, NULL);
+	v4l2_device_unregister_subdev(sd);
 	kfree(decoder);
 	return 0;
 }
@@ -1485,11 +1323,9 @@ static const struct tvp514x_reg tvp5146_init_reg_seq[] = {
 	{TOK_WRITE, REG_VBUS_DATA_ACCESS_NO_VBUS_ADDR_INCR, 0x00},
 	{TOK_WRITE, REG_OPERATION_MODE, 0x01},
 	{TOK_WRITE, REG_OPERATION_MODE, 0x00},
+	{TOK_TERM, 0, 0},
 };
-static const struct tvp514x_init_seq tvp5146_init = {
-	.no_regs = ARRAY_SIZE(tvp5146_init_reg_seq),
-	.init_reg_seq = tvp5146_init_reg_seq,
-};
+
 /*
  * TVP5147 Init/Power on Sequence
  */
@@ -1512,22 +1348,18 @@ static const struct tvp514x_reg tvp5147_init_reg_seq[] =	{
 	{TOK_WRITE, REG_VBUS_DATA_ACCESS_NO_VBUS_ADDR_INCR, 0x00},
 	{TOK_WRITE, REG_OPERATION_MODE, 0x01},
 	{TOK_WRITE, REG_OPERATION_MODE, 0x00},
+	{TOK_TERM, 0, 0},
 };
-static const struct tvp514x_init_seq tvp5147_init = {
-	.no_regs = ARRAY_SIZE(tvp5147_init_reg_seq),
-	.init_reg_seq = tvp5147_init_reg_seq,
-};
+
 /*
  * TVP5146M2/TVP5147M1 Init/Power on Sequence
  */
 static const struct tvp514x_reg tvp514xm_init_reg_seq[] = {
 	{TOK_WRITE, REG_OPERATION_MODE, 0x01},
 	{TOK_WRITE, REG_OPERATION_MODE, 0x00},
+	{TOK_TERM, 0, 0},
 };
-static const struct tvp514x_init_seq tvp514xm_init = {
-	.no_regs = ARRAY_SIZE(tvp514xm_init_reg_seq),
-	.init_reg_seq = tvp514xm_init_reg_seq,
-};
+
 /*
  * I2C Device Table -
  *
@@ -1535,48 +1367,22 @@ static const struct tvp514x_init_seq tvp514xm_init = {
  * driver_data - Driver data
  */
 static const struct i2c_device_id tvp514x_id[] = {
-	{"tvp5146", (unsigned long)&tvp5146_init},
-	{"tvp5146m2", (unsigned long)&tvp514xm_init},
-	{"tvp5147", (unsigned long)&tvp5147_init},
-	{"tvp5147m1", (unsigned long)&tvp514xm_init},
+	{"tvp5146", (unsigned long)tvp5146_init_reg_seq},
+	{"tvp5146m2", (unsigned long)tvp514xm_init_reg_seq},
+	{"tvp5147", (unsigned long)tvp5147_init_reg_seq},
+	{"tvp5147m1", (unsigned long)tvp514xm_init_reg_seq},
 	{},
 };

 MODULE_DEVICE_TABLE(i2c, tvp514x_id);

-static struct i2c_driver tvp514x_i2c_driver = {
-	.driver = {
-		   .name = TVP514X_MODULE_NAME,
-		   .owner = THIS_MODULE,
-		   },
+static struct v4l2_i2c_driver_data v4l2_i2c_data = {
+	.name = TVP514X_MODULE_NAME,
 	.probe = tvp514x_probe,
 	.remove = __exit_p(tvp514x_remove),
 	.id_table = tvp514x_id,
 };

-/**
- * tvp514x_init
- *
- * Module init function
- */
-static int __init tvp514x_init(void)
-{
-	return i2c_add_driver(&tvp514x_i2c_driver);
-}
-
-/**
- * tvp514x_cleanup
- *
- * Module exit function
- */
-static void __exit tvp514x_cleanup(void)
-{
-	i2c_del_driver(&tvp514x_i2c_driver);
-}
-
-module_init(tvp514x_init);
-module_exit(tvp514x_cleanup);
-
 MODULE_AUTHOR("Texas Instruments");
 MODULE_DESCRIPTION("TVP514X linux decoder driver");
 MODULE_LICENSE("GPL");
diff --git a/drivers/media/video/tvp514x_regs.h b/drivers/media/video/tvp514x_regs.h
index 351620a..18f29ad 100644
--- a/drivers/media/video/tvp514x_regs.h
+++ b/drivers/media/video/tvp514x_regs.h
@@ -284,14 +284,4 @@ struct tvp514x_reg {
 	u32 val;
 };

-/**
- * struct tvp514x_init_seq - Structure for TVP5146/47/46M2/47M1 power up
- *		Sequence.
- * @ no_regs - Number of registers to write for power up sequence.
- * @ init_reg_seq - Array of registers and respective value to write.
- */
-struct tvp514x_init_seq {
-	unsigned int no_regs;
-	const struct tvp514x_reg *init_reg_seq;
-};
 #endif				/* ifndef _TVP514X_REGS_H */
diff --git a/include/media/tvp514x.h b/include/media/tvp514x.h
index 5e7ee96..74387e8 100644
--- a/include/media/tvp514x.h
+++ b/include/media/tvp514x.h
@@ -104,10 +104,6 @@ enum tvp514x_output {
  * @ vs_polarity: VSYNC Polarity configuration for current interface.
  */
 struct tvp514x_platform_data {
-	char *master;
-	int (*power_set) (enum v4l2_power on);
-	int (*ifparm) (struct v4l2_ifparm *p);
-	int (*priv_data_set) (void *);
 	/* Interface control params */
 	bool clk_polarity;
 	bool hs_polarity;
--
1.6.2.4


^ permalink raw reply related	[flat|nested] 263+ messages in thread

* Re: [PATCH (V2)] TVP514x: Migration to sub-device framework
  2009-05-06 18:31 [PATCH (V2)] TVP514x: Migration to sub-device framework hvaibhav
@ 2009-06-14 10:14 ` Hans Verkuil
  2009-06-14 12:44   ` Hans Verkuil
  2009-06-14 19:50     ` David Brownell
  0 siblings, 2 replies; 263+ messages in thread
From: Hans Verkuil @ 2009-06-14 10:14 UTC (permalink / raw)
  To: hvaibhav
  Cc: linux-media, linux-omap, davinci-linux-open-source,
	Brijesh Jadav, Hardik Shah

On Wednesday 06 May 2009 20:31:33 hvaibhav@ti.com wrote:
> From: Vaibhav Hiremath <hvaibhav@ti.com>
> 
> This patch converts TVP514x driver to sub-device framework
> from V4L2-int framework.
> 
> NOTE: Please note that this patch has not been tested on any board,
>       only compilation/build tested.
> 
> Changes (From Previous post):
>     - Added static function to_decoder which will replace all
>       container_of instances.
>     - "unsigned int" replaced with "u32".
>     - Cleaned up for line indentation.
>     - pdata initialized, was missing in earlier patch.
> 
> TODO:
>     - Add support for some basic video/core functionality like,
>         .g_chip_ident
> 	.reset
> 	.g_input_status
>     - Migration master driver to validate this driver.
>     - validate on Davinci and OMAP boards.
> 
> Reviewed By "Hans Verkuil".
> 
> Signed-off-by: Brijesh Jadav <brijesh.j@ti.com>
> Signed-off-by: Hardik Shah <hardik.shah@ti.com>
> Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
> ---
>  drivers/media/video/tvp514x.c      |  854 ++++++++++++++----------------------
>  drivers/media/video/tvp514x_regs.h |   10 -
>  include/media/tvp514x.h            |    4 -
>  3 files changed, 330 insertions(+), 538 deletions(-)
> 
> diff --git a/drivers/media/video/tvp514x.c b/drivers/media/video/tvp514x.c
> index 4262e60..12b49ad 100644
> --- a/drivers/media/video/tvp514x.c
> +++ b/drivers/media/video/tvp514x.c
> @@ -31,7 +31,11 @@
>  #include <linux/i2c.h>
>  #include <linux/delay.h>
>  #include <linux/videodev2.h>
> -#include <media/v4l2-int-device.h>
> +
> +#include <media/v4l2-device.h>
> +#include <media/v4l2-common.h>
> +#include <media/v4l2-chip-ident.h>
> +#include <media/v4l2-i2c-drv.h>
>  #include <media/tvp514x.h>
> 
>  #include "tvp514x_regs.h"
> @@ -49,13 +53,13 @@ static int debug;
>  module_param(debug, bool, 0644);
>  MODULE_PARM_DESC(debug, "Debug level (0-1)");
> 
> -#define dump_reg(client, reg, val)				\
> +#define dump_reg(sd, reg, val)				\
>  	do {							\
> -		val = tvp514x_read_reg(client, reg);		\
> -		v4l_info(client, "Reg(0x%.2X): 0x%.2X\n", reg, val); \
> +		val = tvp514x_read_reg(sd, reg);		\
> +		v4l2_info(sd, "Reg(0x%.2X): 0x%.2X\n", reg, val); \
>  	} while (0)

Why not turn this into a static inline function? Much better than a macro.

> 
> -/**
> +/*
>   * enum tvp514x_std - enum for supported standards
>   */
>  enum tvp514x_std {
> @@ -64,15 +68,7 @@ enum tvp514x_std {
>  	STD_INVALID
>  };
> 
> -/**
> - * enum tvp514x_state - enum for different decoder states
> - */
> -enum tvp514x_state {
> -	STATE_NOT_DETECTED,
> -	STATE_DETECTED
> -};
> -
> -/**
> +/*
>   * struct tvp514x_std_info - Structure to store standard informations
>   * @width: Line width in pixels
>   * @height:Number of active lines
> @@ -87,35 +83,29 @@ struct tvp514x_std_info {
>  };
> 
>  static struct tvp514x_reg tvp514x_reg_list_default[0x40];
> -/**
> +/*
>   * struct tvp514x_decoder - TVP5146/47 decoder object
> - * @v4l2_int_device: Slave handle
> - * @tvp514x_slave: Slave pointer which is used by @v4l2_int_device
> + * @sd: Subdevice Slave handle
>   * @tvp514x_regs: copy of hw's regs with preset values.
>   * @pdata: Board specific
> - * @client: I2C client data
> - * @id: Entry from I2C table
>   * @ver: Chip version
> - * @state: TVP5146/47 decoder state - detected or not-detected
> + * @state: TVP5146/47 decoder state - enabled or disabled.
>   * @pix: Current pixel format
>   * @num_fmts: Number of formats
>   * @fmt_list: Format list
>   * @current_std: Current standard
>   * @num_stds: Number of standards
>   * @std_list: Standards list
> - * @route: input and output routing at chip level
> + * @input: Input routing at chip level
> + * @output: Output routing at chip level
>   */
>  struct tvp514x_decoder {
> -	struct v4l2_int_device v4l2_int_device;
> -	struct v4l2_int_slave tvp514x_slave;
> +	struct v4l2_subdev sd;
>  	struct tvp514x_reg tvp514x_regs[ARRAY_SIZE(tvp514x_reg_list_default)];
>  	const struct tvp514x_platform_data *pdata;
> -	struct i2c_client *client;
> -
> -	struct i2c_device_id *id;
> 
>  	int ver;
> -	enum tvp514x_state state;
> +	int state;
> 
>  	struct v4l2_pix_format pix;
>  	int num_fmts;
> @@ -124,8 +114,11 @@ struct tvp514x_decoder {
>  	enum tvp514x_std current_std;
>  	int num_stds;
>  	struct tvp514x_std_info *std_list;
> -
> -	struct v4l2_routing route;
> +	/*
> +	 * Input and Output Routing parameters
> +	 */
> +	u32 input;
> +	u32 output;
>  };
> 
>  /* TVP514x default register values */
> @@ -191,7 +184,8 @@ static struct tvp514x_reg tvp514x_reg_list_default[] = {
>  	{TOK_TERM, 0, 0},
>  };
> 
> -/* List of image formats supported by TVP5146/47 decoder
> +/*
> + * List of image formats supported by TVP5146/47 decoder
>   * Currently we are using 8 bit mode only, but can be
>   * extended to 10/20 bit mode.
>   */
> @@ -240,35 +234,27 @@ static struct tvp514x_std_info tvp514x_std_list[] = {
>  	},
>  	/* Standard: need to add for additional standard */
>  };
> -/*
> - * Control structure for Auto Gain
> - *     This is temporary data, will get replaced once
> - *     v4l2_ctrl_query_fill supports it.
> - */
> -static const struct v4l2_queryctrl tvp514x_autogain_ctrl = {
> -	.id = V4L2_CID_AUTOGAIN,
> -	.name = "Gain, Automatic",
> -	.type = V4L2_CTRL_TYPE_BOOLEAN,
> -	.minimum = 0,
> -	.maximum = 1,
> -	.step = 1,
> -	.default_value = 1,
> -};
> 
> +
> +static inline struct tvp514x_decoder *to_decoder(struct v4l2_subdev *sd)
> +{
> +	return container_of(sd, struct tvp514x_decoder, sd);
> +}
>  /*
>   * Read a value from a register in an TVP5146/47 decoder device.
>   * Returns value read if successful, or non-zero (-1) otherwise.
>   */
> -static int tvp514x_read_reg(struct i2c_client *client, u8 reg)
> +static int tvp514x_read_reg(struct v4l2_subdev *sd, u8 reg)
>  {
> -	int err;
> -	int retry = 0;
> +	int err, retry = 0;
> +	struct i2c_client *client = v4l2_get_subdevdata(sd);
> +
>  read_again:
> 
>  	err = i2c_smbus_read_byte_data(client, reg);
>  	if (err == -1) {
>  		if (retry <= I2C_RETRY_COUNT) {
> -			v4l_warn(client, "Read: retry ... %d\n", retry);
> +			v4l2_warn(sd, "Read: retry ... %d\n", retry);
>  			retry++;
>  			msleep_interruptible(10);
>  			goto read_again;
> @@ -282,16 +268,17 @@ read_again:
>   * Write a value to a register in an TVP5146/47 decoder device.
>   * Returns zero if successful, or non-zero otherwise.
>   */
> -static int tvp514x_write_reg(struct i2c_client *client, u8 reg, u8 val)
> +static int tvp514x_write_reg(struct v4l2_subdev *sd, u8 reg, u8 val)
>  {
> -	int err;
> -	int retry = 0;
> +	int err, retry = 0;
> +	struct i2c_client *client = v4l2_get_subdevdata(sd);
> +
>  write_again:
> 
>  	err = i2c_smbus_write_byte_data(client, reg, val);
>  	if (err) {
>  		if (retry <= I2C_RETRY_COUNT) {
> -			v4l_warn(client, "Write: retry ... %d\n", retry);
> +			v4l2_warn(sd, "Write: retry ... %d\n", retry);
>  			retry++;
>  			msleep_interruptible(10);
>  			goto write_again;
> @@ -311,7 +298,7 @@ write_again:
>   * reglist - list of registers to be written
>   * Returns zero if successful, or non-zero otherwise.
>   */
> -static int tvp514x_write_regs(struct i2c_client *client,
> +static int tvp514x_write_regs(struct v4l2_subdev *sd,
>  			      const struct tvp514x_reg reglist[])
>  {
>  	int err;
> @@ -326,9 +313,9 @@ static int tvp514x_write_regs(struct i2c_client *client,
>  		if (next->token == TOK_SKIP)
>  			continue;
> 
> -		err = tvp514x_write_reg(client, next->reg, (u8) next->val);
> +		err = tvp514x_write_reg(sd, next->reg, (u8) next->val);
>  		if (err) {
> -			v4l_err(client, "Write failed. Err[%d]\n", err);
> +			v4l2_err(sd, "Write failed. Err[%d]\n", err);
>  			return err;
>  		}
>  	}
> @@ -339,17 +326,15 @@ static int tvp514x_write_regs(struct i2c_client *client,
>   * tvp514x_get_current_std:
>   * Returns the current standard detected by TVP5146/47
>   */
> -static enum tvp514x_std tvp514x_get_current_std(struct tvp514x_decoder
> -						*decoder)
> +static enum tvp514x_std tvp514x_get_current_std(struct v4l2_subdev *sd)
>  {
>  	u8 std, std_status;
> 
> -	std = tvp514x_read_reg(decoder->client, REG_VIDEO_STD);
> -	if ((std & VIDEO_STD_MASK) == VIDEO_STD_AUTO_SWITCH_BIT) {
> +	std = tvp514x_read_reg(sd, REG_VIDEO_STD);
> +	if ((std & VIDEO_STD_MASK) == VIDEO_STD_AUTO_SWITCH_BIT)
>  		/* use the standard status register */
> -		std_status = tvp514x_read_reg(decoder->client,
> -				REG_VIDEO_STD_STATUS);
> -	} else
> +		std_status = tvp514x_read_reg(sd, REG_VIDEO_STD_STATUS);
> +	else
>  		std_status = std;	/* use the standard register itself */
> 
>  	switch (std_status & VIDEO_STD_MASK) {
> @@ -369,70 +354,71 @@ static enum tvp514x_std tvp514x_get_current_std(struct tvp514x_decoder
>  /*
>   * TVP5146/47 register dump function
>   */
> -static void tvp514x_reg_dump(struct tvp514x_decoder *decoder)
> +static void tvp514x_reg_dump(struct v4l2_subdev *sd)
>  {
>  	u8 value;
> 
> -	dump_reg(decoder->client, REG_INPUT_SEL, value);
> -	dump_reg(decoder->client, REG_AFE_GAIN_CTRL, value);
> -	dump_reg(decoder->client, REG_VIDEO_STD, value);
> -	dump_reg(decoder->client, REG_OPERATION_MODE, value);
> -	dump_reg(decoder->client, REG_COLOR_KILLER, value);
> -	dump_reg(decoder->client, REG_LUMA_CONTROL1, value);
> -	dump_reg(decoder->client, REG_LUMA_CONTROL2, value);
> -	dump_reg(decoder->client, REG_LUMA_CONTROL3, value);
> -	dump_reg(decoder->client, REG_BRIGHTNESS, value);
> -	dump_reg(decoder->client, REG_CONTRAST, value);
> -	dump_reg(decoder->client, REG_SATURATION, value);
> -	dump_reg(decoder->client, REG_HUE, value);
> -	dump_reg(decoder->client, REG_CHROMA_CONTROL1, value);
> -	dump_reg(decoder->client, REG_CHROMA_CONTROL2, value);
> -	dump_reg(decoder->client, REG_COMP_PR_SATURATION, value);
> -	dump_reg(decoder->client, REG_COMP_Y_CONTRAST, value);
> -	dump_reg(decoder->client, REG_COMP_PB_SATURATION, value);
> -	dump_reg(decoder->client, REG_COMP_Y_BRIGHTNESS, value);
> -	dump_reg(decoder->client, REG_AVID_START_PIXEL_LSB, value);
> -	dump_reg(decoder->client, REG_AVID_START_PIXEL_MSB, value);
> -	dump_reg(decoder->client, REG_AVID_STOP_PIXEL_LSB, value);
> -	dump_reg(decoder->client, REG_AVID_STOP_PIXEL_MSB, value);
> -	dump_reg(decoder->client, REG_HSYNC_START_PIXEL_LSB, value);
> -	dump_reg(decoder->client, REG_HSYNC_START_PIXEL_MSB, value);
> -	dump_reg(decoder->client, REG_HSYNC_STOP_PIXEL_LSB, value);
> -	dump_reg(decoder->client, REG_HSYNC_STOP_PIXEL_MSB, value);
> -	dump_reg(decoder->client, REG_VSYNC_START_LINE_LSB, value);
> -	dump_reg(decoder->client, REG_VSYNC_START_LINE_MSB, value);
> -	dump_reg(decoder->client, REG_VSYNC_STOP_LINE_LSB, value);
> -	dump_reg(decoder->client, REG_VSYNC_STOP_LINE_MSB, value);
> -	dump_reg(decoder->client, REG_VBLK_START_LINE_LSB, value);
> -	dump_reg(decoder->client, REG_VBLK_START_LINE_MSB, value);
> -	dump_reg(decoder->client, REG_VBLK_STOP_LINE_LSB, value);
> -	dump_reg(decoder->client, REG_VBLK_STOP_LINE_MSB, value);
> -	dump_reg(decoder->client, REG_SYNC_CONTROL, value);
> -	dump_reg(decoder->client, REG_OUTPUT_FORMATTER1, value);
> -	dump_reg(decoder->client, REG_OUTPUT_FORMATTER2, value);
> -	dump_reg(decoder->client, REG_OUTPUT_FORMATTER3, value);
> -	dump_reg(decoder->client, REG_OUTPUT_FORMATTER4, value);
> -	dump_reg(decoder->client, REG_OUTPUT_FORMATTER5, value);
> -	dump_reg(decoder->client, REG_OUTPUT_FORMATTER6, value);
> -	dump_reg(decoder->client, REG_CLEAR_LOST_LOCK, value);
> +	dump_reg(sd, REG_INPUT_SEL, value);
> +	dump_reg(sd, REG_AFE_GAIN_CTRL, value);
> +	dump_reg(sd, REG_VIDEO_STD, value);
> +	dump_reg(sd, REG_OPERATION_MODE, value);
> +	dump_reg(sd, REG_COLOR_KILLER, value);
> +	dump_reg(sd, REG_LUMA_CONTROL1, value);
> +	dump_reg(sd, REG_LUMA_CONTROL2, value);
> +	dump_reg(sd, REG_LUMA_CONTROL3, value);
> +	dump_reg(sd, REG_BRIGHTNESS, value);
> +	dump_reg(sd, REG_CONTRAST, value);
> +	dump_reg(sd, REG_SATURATION, value);
> +	dump_reg(sd, REG_HUE, value);
> +	dump_reg(sd, REG_CHROMA_CONTROL1, value);
> +	dump_reg(sd, REG_CHROMA_CONTROL2, value);
> +	dump_reg(sd, REG_COMP_PR_SATURATION, value);
> +	dump_reg(sd, REG_COMP_Y_CONTRAST, value);
> +	dump_reg(sd, REG_COMP_PB_SATURATION, value);
> +	dump_reg(sd, REG_COMP_Y_BRIGHTNESS, value);
> +	dump_reg(sd, REG_AVID_START_PIXEL_LSB, value);
> +	dump_reg(sd, REG_AVID_START_PIXEL_MSB, value);
> +	dump_reg(sd, REG_AVID_STOP_PIXEL_LSB, value);
> +	dump_reg(sd, REG_AVID_STOP_PIXEL_MSB, value);
> +	dump_reg(sd, REG_HSYNC_START_PIXEL_LSB, value);
> +	dump_reg(sd, REG_HSYNC_START_PIXEL_MSB, value);
> +	dump_reg(sd, REG_HSYNC_STOP_PIXEL_LSB, value);
> +	dump_reg(sd, REG_HSYNC_STOP_PIXEL_MSB, value);
> +	dump_reg(sd, REG_VSYNC_START_LINE_LSB, value);
> +	dump_reg(sd, REG_VSYNC_START_LINE_MSB, value);
> +	dump_reg(sd, REG_VSYNC_STOP_LINE_LSB, value);
> +	dump_reg(sd, REG_VSYNC_STOP_LINE_MSB, value);
> +	dump_reg(sd, REG_VBLK_START_LINE_LSB, value);
> +	dump_reg(sd, REG_VBLK_START_LINE_MSB, value);
> +	dump_reg(sd, REG_VBLK_STOP_LINE_LSB, value);
> +	dump_reg(sd, REG_VBLK_STOP_LINE_MSB, value);
> +	dump_reg(sd, REG_SYNC_CONTROL, value);
> +	dump_reg(sd, REG_OUTPUT_FORMATTER1, value);
> +	dump_reg(sd, REG_OUTPUT_FORMATTER2, value);
> +	dump_reg(sd, REG_OUTPUT_FORMATTER3, value);
> +	dump_reg(sd, REG_OUTPUT_FORMATTER4, value);
> +	dump_reg(sd, REG_OUTPUT_FORMATTER5, value);
> +	dump_reg(sd, REG_OUTPUT_FORMATTER6, value);
> +	dump_reg(sd, REG_CLEAR_LOST_LOCK, value);
>  }
> 
>  /*
>   * Configure the TVP5146/47 with the current register settings
>   * Returns zero if successful, or non-zero otherwise.
>   */
> -static int tvp514x_configure(struct tvp514x_decoder *decoder)
> +static int tvp514x_configure(struct v4l2_subdev *sd,
> +		struct tvp514x_decoder *decoder)
>  {
>  	int err;
> 
>  	/* common register initialization */
>  	err =
> -	    tvp514x_write_regs(decoder->client, decoder->tvp514x_regs);
> +	    tvp514x_write_regs(sd, decoder->tvp514x_regs);
>  	if (err)
>  		return err;
> 
>  	if (debug)
> -		tvp514x_reg_dump(decoder);
> +		tvp514x_reg_dump(sd);
> 
>  	return 0;
>  }
> @@ -445,15 +431,17 @@ static int tvp514x_configure(struct tvp514x_decoder *decoder)
>   * Returns ENODEV error number if no device is detected, or zero
>   * if a device is detected.
>   */
> -static int tvp514x_detect(struct tvp514x_decoder *decoder)
> +static int tvp514x_detect(struct v4l2_subdev *sd,
> +		struct tvp514x_decoder *decoder)
>  {
>  	u8 chip_id_msb, chip_id_lsb, rom_ver;
> +	struct i2c_client *client = v4l2_get_subdevdata(sd);
> 
> -	chip_id_msb = tvp514x_read_reg(decoder->client, REG_CHIP_ID_MSB);
> -	chip_id_lsb = tvp514x_read_reg(decoder->client, REG_CHIP_ID_LSB);
> -	rom_ver = tvp514x_read_reg(decoder->client, REG_ROM_VERSION);
> +	chip_id_msb = tvp514x_read_reg(sd, REG_CHIP_ID_MSB);
> +	chip_id_lsb = tvp514x_read_reg(sd, REG_CHIP_ID_LSB);
> +	rom_ver = tvp514x_read_reg(sd, REG_ROM_VERSION);
> 
> -	v4l_dbg(1, debug, decoder->client,
> +	v4l2_dbg(1, debug, sd,
>  		 "chip id detected msb:0x%x lsb:0x%x rom version:0x%x\n",
>  		 chip_id_msb, chip_id_lsb, rom_ver);
>  	if ((chip_id_msb != TVP514X_CHIP_ID_MSB)
> @@ -462,19 +450,16 @@ static int tvp514x_detect(struct tvp514x_decoder *decoder)
>  		/* We didn't read the values we expected, so this must not be
>  		 * an TVP5146/47.
>  		 */
> -		v4l_err(decoder->client,
> -			"chip id mismatch msb:0x%x lsb:0x%x\n",
> -			chip_id_msb, chip_id_lsb);
> +		v4l2_err(sd, "chip id mismatch msb:0x%x lsb:0x%x\n",
> +				chip_id_msb, chip_id_lsb);
>  		return -ENODEV;
>  	}
> 
>  	decoder->ver = rom_ver;
> -	decoder->state = STATE_DETECTED;
> 
> -	v4l_info(decoder->client,
> -			"%s found at 0x%x (%s)\n", decoder->client->name,
> -			decoder->client->addr << 1,
> -			decoder->client->adapter->name);
> +	v4l2_info(sd, "%s (Version - 0x%.2x) found at 0x%x (%s)\n",
> +			client->name, decoder->ver,
> +			client->addr << 1, client->adapter->name);
>  	return 0;
>  }
> 
> @@ -483,17 +468,17 @@ static int tvp514x_detect(struct tvp514x_decoder *decoder)
>   * TVP5146/47 decoder driver.
>   */
> 
> -/**
> - * ioctl_querystd - V4L2 decoder interface handler for VIDIOC_QUERYSTD ioctl
> - * @s: pointer to standard V4L2 device structure
> +/*
> + * tvp514x_querystd - V4L2 decoder interface handler for VIDIOC_QUERYSTD ioctl
> + * @sd: pointer to standard V4L2 sub-device structure
>   * @std_id: standard V4L2 std_id ioctl enum
>   *
>   * Returns the current standard detected by TVP5146/47. If no active input is
>   * detected, returns -EINVAL
>   */
> -static int ioctl_querystd(struct v4l2_int_device *s, v4l2_std_id *std_id)
> +static int tvp514x_querystd(struct v4l2_subdev *sd, v4l2_std_id *std_id)
>  {
> -	struct tvp514x_decoder *decoder = s->priv;
> +	struct tvp514x_decoder *decoder = to_decoder(sd);
>  	enum tvp514x_std current_std;
>  	enum tvp514x_input input_sel;
>  	u8 sync_lock_status, lock_mask;
> @@ -502,11 +487,11 @@ static int ioctl_querystd(struct v4l2_int_device *s, v4l2_std_id *std_id)
>  		return -EINVAL;
> 
>  	/* get the current standard */
> -	current_std = tvp514x_get_current_std(decoder);
> +	current_std = tvp514x_get_current_std(sd);
>  	if (current_std == STD_INVALID)
>  		return -EINVAL;
> 
> -	input_sel = decoder->route.input;
> +	input_sel = decoder->input;
> 
>  	switch (input_sel) {
>  	case INPUT_CVBS_VI1A:
> @@ -544,42 +529,39 @@ static int ioctl_querystd(struct v4l2_int_device *s, v4l2_std_id *std_id)
>  		return -EINVAL;
>  	}
>  	/* check whether signal is locked */
> -	sync_lock_status = tvp514x_read_reg(decoder->client, REG_STATUS1);
> +	sync_lock_status = tvp514x_read_reg(sd, REG_STATUS1);
>  	if (lock_mask != (sync_lock_status & lock_mask))
>  		return -EINVAL;	/* No input detected */
> 
>  	decoder->current_std = current_std;
>  	*std_id = decoder->std_list[current_std].standard.id;
> 
> -	v4l_dbg(1, debug, decoder->client, "Current STD: %s",
> +	v4l2_dbg(1, debug, sd, "Current STD: %s",
>  			decoder->std_list[current_std].standard.name);
>  	return 0;
>  }
> 
> -/**
> - * ioctl_s_std - V4L2 decoder interface handler for VIDIOC_S_STD ioctl
> - * @s: pointer to standard V4L2 device structure
> +/*
> + * tvp514x_s_std - V4L2 decoder interface handler for VIDIOC_S_STD ioctl
> + * @sd: pointer to standard V4L2 sub-device structure
>   * @std_id: standard V4L2 v4l2_std_id ioctl enum
>   *
>   * If std_id is supported, sets the requested standard. Otherwise, returns
>   * -EINVAL
>   */
> -static int ioctl_s_std(struct v4l2_int_device *s, v4l2_std_id *std_id)
> +static int tvp514x_s_std(struct v4l2_subdev *sd, v4l2_std_id std_id)
>  {
> -	struct tvp514x_decoder *decoder = s->priv;
> +	struct tvp514x_decoder *decoder = to_decoder(sd);
>  	int err, i;
> 
> -	if (std_id == NULL)
> -		return -EINVAL;
> -
>  	for (i = 0; i < decoder->num_stds; i++)
> -		if (*std_id & decoder->std_list[i].standard.id)
> +		if (std_id & decoder->std_list[i].standard.id)
>  			break;
> 
>  	if ((i == decoder->num_stds) || (i == STD_INVALID))
>  		return -EINVAL;
> 
> -	err = tvp514x_write_reg(decoder->client, REG_VIDEO_STD,
> +	err = tvp514x_write_reg(sd, REG_VIDEO_STD,
>  				decoder->std_list[i].video_std);
>  	if (err)
>  		return err;
> @@ -588,24 +570,24 @@ static int ioctl_s_std(struct v4l2_int_device *s, v4l2_std_id *std_id)
>  	decoder->tvp514x_regs[REG_VIDEO_STD].val =
>  		decoder->std_list[i].video_std;
> 
> -	v4l_dbg(1, debug, decoder->client, "Standard set to: %s",
> +	v4l2_dbg(1, debug, sd, "Standard set to: %s",
>  			decoder->std_list[i].standard.name);
>  	return 0;
>  }
> 
> -/**
> - * ioctl_s_routing - V4L2 decoder interface handler for VIDIOC_S_INPUT ioctl
> - * @s: pointer to standard V4L2 device structure
> +/*
> + * tvp514x_s_routing - V4L2 decoder interface handler for VIDIOC_S_INPUT ioctl
> + * @sd: pointer to standard V4L2 sub-device structure
>   * @index: number of the input
>   *
>   * If index is valid, selects the requested input. Otherwise, returns -EINVAL if
>   * the input is not supported or there is no active signal present in the
>   * selected input.
>   */
> -static int ioctl_s_routing(struct v4l2_int_device *s,
> -				struct v4l2_routing *route)
> +static int tvp514x_s_routing(struct v4l2_subdev *sd,
> +				u32 input, u32 output, u32 config)
>  {
> -	struct tvp514x_decoder *decoder = s->priv;
> +	struct tvp514x_decoder *decoder = to_decoder(sd);
>  	int err;
>  	enum tvp514x_input input_sel;
>  	enum tvp514x_output output_sel;
> @@ -613,20 +595,20 @@ static int ioctl_s_routing(struct v4l2_int_device *s,
>  	u8 sync_lock_status, lock_mask;
>  	int try_count = LOCK_RETRY_COUNT;
> 
> -	if ((!route) || (route->input >= INPUT_INVALID) ||
> -			(route->output >= OUTPUT_INVALID))
> +	if ((input >= INPUT_INVALID) ||
> +			(output >= OUTPUT_INVALID))
>  		return -EINVAL;	/* Index out of bound */
> 
> -	input_sel = route->input;
> -	output_sel = route->output;
> +	input_sel = input;
> +	output_sel = output;
> 
> -	err = tvp514x_write_reg(decoder->client, REG_INPUT_SEL, input_sel);
> +	err = tvp514x_write_reg(sd, REG_INPUT_SEL, input_sel);
>  	if (err)
>  		return err;
> 
> -	output_sel |= tvp514x_read_reg(decoder->client,
> +	output_sel |= tvp514x_read_reg(sd,
>  			REG_OUTPUT_FORMATTER1) & 0x7;
> -	err = tvp514x_write_reg(decoder->client, REG_OUTPUT_FORMATTER1,
> +	err = tvp514x_write_reg(sd, REG_OUTPUT_FORMATTER1,
>  			output_sel);
>  	if (err)
>  		return err;
> @@ -637,7 +619,7 @@ static int ioctl_s_routing(struct v4l2_int_device *s,
>  	/* Clear status */
>  	msleep(LOCK_RETRY_DELAY);
>  	err =
> -	    tvp514x_write_reg(decoder->client, REG_CLEAR_LOST_LOCK, 0x01);
> +	    tvp514x_write_reg(sd, REG_CLEAR_LOST_LOCK, 0x01);
>  	if (err)
>  		return err;
> 
> @@ -682,11 +664,11 @@ static int ioctl_s_routing(struct v4l2_int_device *s,
>  		msleep(LOCK_RETRY_DELAY);
> 
>  		/* get the current standard for future reference */
> -		current_std = tvp514x_get_current_std(decoder);
> +		current_std = tvp514x_get_current_std(sd);
>  		if (current_std == STD_INVALID)
>  			continue;
> 
> -		sync_lock_status = tvp514x_read_reg(decoder->client,
> +		sync_lock_status = tvp514x_read_reg(sd,
>  				REG_STATUS1);
>  		if (lock_mask == (sync_lock_status & lock_mask))
>  			break;	/* Input detected */
> @@ -696,28 +678,26 @@ static int ioctl_s_routing(struct v4l2_int_device *s,
>  		return -EINVAL;
> 
>  	decoder->current_std = current_std;
> -	decoder->route.input = route->input;
> -	decoder->route.output = route->output;
> +	decoder->input = input;
> +	decoder->output = output;
> 
> -	v4l_dbg(1, debug, decoder->client,
> -			"Input set to: %d, std : %d",
> +	v4l2_dbg(1, debug, sd, "Input set to: %d, std : %d",
>  			input_sel, current_std);
> 
>  	return 0;
>  }
> 
> -/**
> - * ioctl_queryctrl - V4L2 decoder interface handler for VIDIOC_QUERYCTRL ioctl
> - * @s: pointer to standard V4L2 device structure
> +/*
> + * tvp514x_queryctrl - V4L2 decoder interface handler for VIDIOC_QUERYCTRL ioctl
> + * @sd: pointer to standard V4L2 sub-device structure
>   * @qctrl: standard V4L2 v4l2_queryctrl structure
>   *
>   * If the requested control is supported, returns the control information.
>   * Otherwise, returns -EINVAL if the control is not supported.
>   */
>  static int
> -ioctl_queryctrl(struct v4l2_int_device *s, struct v4l2_queryctrl *qctrl)
> +tvp514x_queryctrl(struct v4l2_subdev *sd, struct v4l2_queryctrl *qctrl)
>  {
> -	struct tvp514x_decoder *decoder = s->priv;
>  	int err = -EINVAL;
> 
>  	if (qctrl == NULL)
> @@ -744,30 +724,27 @@ ioctl_queryctrl(struct v4l2_int_device *s, struct v4l2_queryctrl *qctrl)
>  		err = v4l2_ctrl_query_fill(qctrl, -180, 180, 180, 0);
>  		break;
>  	case V4L2_CID_AUTOGAIN:
> -		/* Autogain is either 0 or 1*/
> -		memcpy(qctrl, &tvp514x_autogain_ctrl,
> -				sizeof(struct v4l2_queryctrl));
> -		err = 0;
> +		/*
> +		 * Auto Gain supported is -
> +		 * 	0 - 1 (Default - 1)
> +		 */
> +		err = v4l2_ctrl_query_fill(qctrl, 0, 1, 1, 1);
>  		break;
>  	default:
> -		v4l_err(decoder->client,
> -			"invalid control id %d\n", qctrl->id);
> +		v4l2_err(sd, "invalid control id %d\n", qctrl->id);
>  		return err;
>  	}
> 
> -	v4l_dbg(1, debug, decoder->client,
> -			"Query Control: %s : Min - %d, Max - %d, Def - %d",
> -			qctrl->name,
> -			qctrl->minimum,
> -			qctrl->maximum,
> +	v4l2_dbg(1, debug, sd, "Query Control:%s: Min - %d, Max - %d, Def - %d",
> +			qctrl->name, qctrl->minimum, qctrl->maximum,
>  			qctrl->default_value);
> 
>  	return err;
>  }
> 
> -/**
> - * ioctl_g_ctrl - V4L2 decoder interface handler for VIDIOC_G_CTRL ioctl
> - * @s: pointer to standard V4L2 device structure
> +/*
> + * tvp514x_g_ctrl - V4L2 decoder interface handler for VIDIOC_G_CTRL ioctl
> + * @sd: pointer to standard V4L2 sub-device structure
>   * @ctrl: pointer to v4l2_control structure
>   *
>   * If the requested control is supported, returns the control's current
> @@ -775,9 +752,9 @@ ioctl_queryctrl(struct v4l2_int_device *s, struct v4l2_queryctrl *qctrl)
>   * supported.
>   */
>  static int
> -ioctl_g_ctrl(struct v4l2_int_device *s, struct v4l2_control *ctrl)
> +tvp514x_g_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
>  {
> -	struct tvp514x_decoder *decoder = s->priv;
> +	struct tvp514x_decoder *decoder = to_decoder(sd);
> 
>  	if (ctrl == NULL)
>  		return -EINVAL;
> @@ -811,74 +788,70 @@ ioctl_g_ctrl(struct v4l2_int_device *s, struct v4l2_control *ctrl)
> 
>  		break;
>  	default:
> -		v4l_err(decoder->client,
> -			"invalid control id %d\n", ctrl->id);
> +		v4l2_err(sd, "invalid control id %d\n", ctrl->id);
>  		return -EINVAL;
>  	}
> 
> -	v4l_dbg(1, debug, decoder->client,
> -			"Get Control: ID - %d - %d",
> +	v4l2_dbg(1, debug, sd, "Get Control: ID - %d - %d",
>  			ctrl->id, ctrl->value);
>  	return 0;
>  }
> 
> -/**
> - * ioctl_s_ctrl - V4L2 decoder interface handler for VIDIOC_S_CTRL ioctl
> - * @s: pointer to standard V4L2 device structure
> +/*
> + * tvp514x_s_ctrl - V4L2 decoder interface handler for VIDIOC_S_CTRL ioctl
> + * @sd: pointer to standard V4L2 sub-device structure
>   * @ctrl: pointer to v4l2_control structure
>   *
>   * If the requested control is supported, sets the control's current
>   * value in HW. Otherwise, returns -EINVAL if the control is not supported.
>   */
>  static int
> -ioctl_s_ctrl(struct v4l2_int_device *s, struct v4l2_control *ctrl)
> +tvp514x_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
>  {
> -	struct tvp514x_decoder *decoder = s->priv;
> +	struct tvp514x_decoder *decoder = to_decoder(sd);
>  	int err = -EINVAL, value;
> 
>  	if (ctrl == NULL)
>  		return err;
> 
> -	value = (__s32) ctrl->value;
> +	value = ctrl->value;
> 
>  	switch (ctrl->id) {
>  	case V4L2_CID_BRIGHTNESS:
>  		if (ctrl->value < 0 || ctrl->value > 255) {
> -			v4l_err(decoder->client,
> -					"invalid brightness setting %d\n",
> +			v4l2_err(sd, "invalid brightness setting %d\n",
>  					ctrl->value);
>  			return -ERANGE;
>  		}
> -		err = tvp514x_write_reg(decoder->client, REG_BRIGHTNESS,
> +		err = tvp514x_write_reg(sd, REG_BRIGHTNESS,
>  				value);
>  		if (err)
>  			return err;
> +
>  		decoder->tvp514x_regs[REG_BRIGHTNESS].val = value;
>  		break;
>  	case V4L2_CID_CONTRAST:
>  		if (ctrl->value < 0 || ctrl->value > 255) {
> -			v4l_err(decoder->client,
> -					"invalid contrast setting %d\n",
> +			v4l2_err(sd, "invalid contrast setting %d\n",
>  					ctrl->value);
>  			return -ERANGE;
>  		}
> -		err = tvp514x_write_reg(decoder->client, REG_CONTRAST,
> -				value);
> +		err = tvp514x_write_reg(sd, REG_CONTRAST, value);
>  		if (err)
>  			return err;
> +
>  		decoder->tvp514x_regs[REG_CONTRAST].val = value;
>  		break;
>  	case V4L2_CID_SATURATION:
>  		if (ctrl->value < 0 || ctrl->value > 255) {
> -			v4l_err(decoder->client,
> -					"invalid saturation setting %d\n",
> +			v4l2_err(sd, "invalid saturation setting %d\n",
>  					ctrl->value);
>  			return -ERANGE;
>  		}
> -		err = tvp514x_write_reg(decoder->client, REG_SATURATION,
> -				value);
> +		err = tvp514x_write_reg(sd, REG_SATURATION, value);
>  		if (err)
>  			return err;
> +
>  		decoder->tvp514x_regs[REG_SATURATION].val = value;
>  		break;
>  	case V4L2_CID_HUE:
> @@ -889,15 +862,13 @@ ioctl_s_ctrl(struct v4l2_int_device *s, struct v4l2_control *ctrl)
>  		else if (value == 0)
>  			value = 0;
>  		else {
> -			v4l_err(decoder->client,
> -					"invalid hue setting %d\n",
> -					ctrl->value);
> +			v4l2_err(sd, "invalid hue setting %d\n", ctrl->value);
>  			return -ERANGE;
>  		}
> -		err = tvp514x_write_reg(decoder->client, REG_HUE,
> -				value);
> +		err = tvp514x_write_reg(sd, REG_HUE, value);
>  		if (err)
>  			return err;
> +
>  		decoder->tvp514x_regs[REG_HUE].val = value;
>  		break;
>  	case V4L2_CID_AUTOGAIN:
> @@ -906,41 +877,38 @@ ioctl_s_ctrl(struct v4l2_int_device *s, struct v4l2_control *ctrl)
>  		else if (value == 0)
>  			value = 0x0C;
>  		else {
> -			v4l_err(decoder->client,
> -					"invalid auto gain setting %d\n",
> +			v4l2_err(sd, "invalid auto gain setting %d\n",
>  					ctrl->value);
>  			return -ERANGE;
>  		}
> -		err = tvp514x_write_reg(decoder->client, REG_AFE_GAIN_CTRL,
> -				value);
> +		err = tvp514x_write_reg(sd, REG_AFE_GAIN_CTRL, value);
>  		if (err)
>  			return err;
> +
>  		decoder->tvp514x_regs[REG_AFE_GAIN_CTRL].val = value;
>  		break;
>  	default:
> -		v4l_err(decoder->client,
> -			"invalid control id %d\n", ctrl->id);
> +		v4l2_err(sd, "invalid control id %d\n", ctrl->id);
>  		return err;
>  	}
> 
> -	v4l_dbg(1, debug, decoder->client,
> -			"Set Control: ID - %d - %d",
> +	v4l2_dbg(1, debug, sd, "Set Control: ID - %d - %d",
>  			ctrl->id, ctrl->value);
> 
>  	return err;
>  }
> 
> -/**
> - * ioctl_enum_fmt_cap - Implement the CAPTURE buffer VIDIOC_ENUM_FMT ioctl
> - * @s: pointer to standard V4L2 device structure
> +/*
> + * tvp514x_enum_fmt_cap - Implement the CAPTURE buffer VIDIOC_ENUM_FMT ioctl
> + * @sd: pointer to standard V4L2 sub-device structure
>   * @fmt: standard V4L2 VIDIOC_ENUM_FMT ioctl structure
>   *
>   * Implement the VIDIOC_ENUM_FMT ioctl to enumerate supported formats
>   */
>  static int
> -ioctl_enum_fmt_cap(struct v4l2_int_device *s, struct v4l2_fmtdesc *fmt)
> +tvp514x_enum_fmt_cap(struct v4l2_subdev *sd, struct v4l2_fmtdesc *fmt)
>  {
> -	struct tvp514x_decoder *decoder = s->priv;
> +	struct tvp514x_decoder *decoder = to_decoder(sd);
>  	int index;
> 
>  	if (fmt == NULL)
> @@ -956,16 +924,15 @@ ioctl_enum_fmt_cap(struct v4l2_int_device *s, struct v4l2_fmtdesc *fmt)
>  	memcpy(fmt, &decoder->fmt_list[index],
>  		sizeof(struct v4l2_fmtdesc));
> 
> -	v4l_dbg(1, debug, decoder->client,
> -			"Current FMT: index - %d (%s)",
> +	v4l2_dbg(1, debug, sd, "Current FMT: index - %d (%s)",
>  			decoder->fmt_list[index].index,
>  			decoder->fmt_list[index].description);
>  	return 0;
>  }
> 
> -/**
> - * ioctl_try_fmt_cap - Implement the CAPTURE buffer VIDIOC_TRY_FMT ioctl
> - * @s: pointer to standard V4L2 device structure
> +/*
> + * tvp514x_try_fmt_cap - Implement the CAPTURE buffer VIDIOC_TRY_FMT ioctl
> + * @sd: pointer to standard V4L2 sub-device structure
>   * @f: pointer to standard V4L2 VIDIOC_TRY_FMT ioctl structure
>   *
>   * Implement the VIDIOC_TRY_FMT ioctl for the CAPTURE buffer type. This
> @@ -973,9 +940,9 @@ ioctl_enum_fmt_cap(struct v4l2_int_device *s, struct v4l2_fmtdesc *fmt)
>   * without actually making it take effect.
>   */
>  static int
> -ioctl_try_fmt_cap(struct v4l2_int_device *s, struct v4l2_format *f)
> +tvp514x_try_fmt_cap(struct v4l2_subdev *sd, struct v4l2_format *f)
>  {
> -	struct tvp514x_decoder *decoder = s->priv;
> +	struct tvp514x_decoder *decoder = to_decoder(sd);
>  	int ifmt;
>  	struct v4l2_pix_format *pix;
>  	enum tvp514x_std current_std;
> @@ -989,7 +956,7 @@ ioctl_try_fmt_cap(struct v4l2_int_device *s, struct v4l2_format *f)
>  	pix = &f->fmt.pix;
> 
>  	/* Calculate height and width based on current standard */
> -	current_std = tvp514x_get_current_std(decoder);
> +	current_std = tvp514x_get_current_std(sd);
>  	if (current_std == STD_INVALID)
>  		return -EINVAL;
> 
> @@ -1012,17 +979,16 @@ ioctl_try_fmt_cap(struct v4l2_int_device *s, struct v4l2_format *f)
>  	pix->colorspace = V4L2_COLORSPACE_SMPTE170M;
>  	pix->priv = 0;
> 
> -	v4l_dbg(1, debug, decoder->client,
> -			"Try FMT: pixelformat - %s, bytesperline - %d"
> +	v4l2_dbg(1, debug, sd, "Try FMT: pixelformat - %s, bytesperline - %d"
>  			"Width - %d, Height - %d",
>  			decoder->fmt_list[ifmt].description, pix->bytesperline,
>  			pix->width, pix->height);
>  	return 0;
>  }
> 
> -/**
> - * ioctl_s_fmt_cap - V4L2 decoder interface handler for VIDIOC_S_FMT ioctl
> - * @s: pointer to standard V4L2 device structure
> +/*
> + * tvp514x_s_fmt_cap - V4L2 decoder interface handler for VIDIOC_S_FMT ioctl
> + * @sd: pointer to standard V4L2 sub-device structure
>   * @f: pointer to standard V4L2 VIDIOC_S_FMT ioctl structure
>   *
>   * If the requested format is supported, configures the HW to use that
> @@ -1030,9 +996,9 @@ ioctl_try_fmt_cap(struct v4l2_int_device *s, struct v4l2_format *f)
>   * correctly configured.
>   */
>  static int
> -ioctl_s_fmt_cap(struct v4l2_int_device *s, struct v4l2_format *f)
> +tvp514x_s_fmt_cap(struct v4l2_subdev *sd, struct v4l2_format *f)
>  {
> -	struct tvp514x_decoder *decoder = s->priv;
> +	struct tvp514x_decoder *decoder = to_decoder(sd);
>  	struct v4l2_pix_format *pix;
>  	int rval;
> 
> @@ -1043,7 +1009,7 @@ ioctl_s_fmt_cap(struct v4l2_int_device *s, struct v4l2_format *f)
>  		return -EINVAL;	/* only capture is supported */
> 
>  	pix = &f->fmt.pix;
> -	rval = ioctl_try_fmt_cap(s, f);
> +	rval = tvp514x_try_fmt_cap(sd, f);
>  	if (rval)
>  		return rval;
> 
> @@ -1052,18 +1018,18 @@ ioctl_s_fmt_cap(struct v4l2_int_device *s, struct v4l2_format *f)
>  	return rval;
>  }
> 
> -/**
> - * ioctl_g_fmt_cap - V4L2 decoder interface handler for ioctl_g_fmt_cap
> - * @s: pointer to standard V4L2 device structure
> +/*
> + * tvp514x_g_fmt_cap - V4L2 decoder interface handler for tvp514x_g_fmt_cap
> + * @sd: pointer to standard V4L2 sub-device structure
>   * @f: pointer to standard V4L2 v4l2_format structure
>   *
>   * Returns the decoder's current pixel format in the v4l2_format
>   * parameter.
>   */
>  static int
> -ioctl_g_fmt_cap(struct v4l2_int_device *s, struct v4l2_format *f)
> +tvp514x_g_fmt_cap(struct v4l2_subdev *sd, struct v4l2_format *f)
>  {
> -	struct tvp514x_decoder *decoder = s->priv;
> +	struct tvp514x_decoder *decoder = to_decoder(sd);
> 
>  	if (f == NULL)
>  		return -EINVAL;
> @@ -1073,25 +1039,24 @@ ioctl_g_fmt_cap(struct v4l2_int_device *s, struct v4l2_format *f)
> 
>  	f->fmt.pix = decoder->pix;
> 
> -	v4l_dbg(1, debug, decoder->client,
> -			"Current FMT: bytesperline - %d"
> +	v4l2_dbg(1, debug, sd, "Current FMT: bytesperline - %d"
>  			"Width - %d, Height - %d",
>  			decoder->pix.bytesperline,
>  			decoder->pix.width, decoder->pix.height);
>  	return 0;
>  }
> 
> -/**
> - * ioctl_g_parm - V4L2 decoder interface handler for VIDIOC_G_PARM ioctl
> - * @s: pointer to standard V4L2 device structure
> +/*
> + * tvp514x_g_parm - V4L2 decoder interface handler for VIDIOC_G_PARM ioctl
> + * @sd: pointer to standard V4L2 sub-device structure
>   * @a: pointer to standard V4L2 VIDIOC_G_PARM ioctl structure
>   *
>   * Returns the decoder's video CAPTURE parameters.
>   */
>  static int
> -ioctl_g_parm(struct v4l2_int_device *s, struct v4l2_streamparm *a)
> +tvp514x_g_parm(struct v4l2_subdev *sd, struct v4l2_streamparm *a)
>  {
> -	struct tvp514x_decoder *decoder = s->priv;
> +	struct tvp514x_decoder *decoder = to_decoder(sd);
>  	struct v4l2_captureparm *cparm;
>  	enum tvp514x_std current_std;
> 
> @@ -1105,7 +1070,7 @@ ioctl_g_parm(struct v4l2_int_device *s, struct v4l2_streamparm *a)
>  	a->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
> 
>  	/* get the current standard */
> -	current_std = tvp514x_get_current_std(decoder);
> +	current_std = tvp514x_get_current_std(sd);
>  	if (current_std == STD_INVALID)
>  		return -EINVAL;
> 
> @@ -1119,18 +1084,18 @@ ioctl_g_parm(struct v4l2_int_device *s, struct v4l2_streamparm *a)
>  	return 0;
>  }
> 
> -/**
> - * ioctl_s_parm - V4L2 decoder interface handler for VIDIOC_S_PARM ioctl
> - * @s: pointer to standard V4L2 device structure
> +/*
> + * tvp514x_s_parm - V4L2 decoder interface handler for VIDIOC_S_PARM ioctl
> + * @sd: pointer to standard V4L2 sub-device structure
>   * @a: pointer to standard V4L2 VIDIOC_S_PARM ioctl structure
>   *
>   * Configures the decoder to use the input parameters, if possible. If
>   * not possible, returns the appropriate error code.
>   */
>  static int
> -ioctl_s_parm(struct v4l2_int_device *s, struct v4l2_streamparm *a)
> +tvp514x_s_parm(struct v4l2_subdev *sd, struct v4l2_streamparm *a)
>  {
> -	struct tvp514x_decoder *decoder = s->priv;
> +	struct tvp514x_decoder *decoder = to_decoder(sd);
>  	struct v4l2_fract *timeperframe;
>  	enum tvp514x_std current_std;
> 
> @@ -1143,7 +1108,7 @@ ioctl_s_parm(struct v4l2_int_device *s, struct v4l2_streamparm *a)
>  	timeperframe = &a->parm.capture.timeperframe;
> 
>  	/* get the current standard */
> -	current_std = tvp514x_get_current_std(decoder);
> +	current_std = tvp514x_get_current_std(sd);
>  	if (current_std == STD_INVALID)
>  		return -EINVAL;
> 
> @@ -1155,112 +1120,59 @@ ioctl_s_parm(struct v4l2_int_device *s, struct v4l2_streamparm *a)
>  	return 0;
>  }
> 
> -/**
> - * ioctl_g_ifparm - V4L2 decoder interface handler for vidioc_int_g_ifparm_num
> - * @s: pointer to standard V4L2 device structure
> - * @p: pointer to standard V4L2 vidioc_int_g_ifparm_num ioctl structure
> - *
> - * Gets slave interface parameters.
> - * Calculates the required xclk value to support the requested
> - * clock parameters in p. This value is returned in the p
> - * parameter.
> - */
> -static int ioctl_g_ifparm(struct v4l2_int_device *s, struct v4l2_ifparm *p)
> -{
> -	struct tvp514x_decoder *decoder = s->priv;
> -	int rval;
> -
> -	if (p == NULL)
> -		return -EINVAL;
> -
> -	if (NULL == decoder->pdata->ifparm)
> -		return -EINVAL;
> -
> -	rval = decoder->pdata->ifparm(p);
> -	if (rval) {
> -		v4l_err(decoder->client, "g_ifparm.Err[%d]\n", rval);
> -		return rval;
> -	}
> -
> -	p->u.bt656.clock_curr = TVP514X_XCLK_BT656;
> -
> -	return 0;
> -}
> -
> -/**
> - * ioctl_g_priv - V4L2 decoder interface handler for vidioc_int_g_priv_num
> - * @s: pointer to standard V4L2 device structure
> - * @p: void pointer to hold decoder's private data address
> - *
> - * Returns device's (decoder's) private data area address in p parameter
> - */
> -static int ioctl_g_priv(struct v4l2_int_device *s, void *p)
> -{
> -	struct tvp514x_decoder *decoder = s->priv;
> -
> -	if (NULL == decoder->pdata->priv_data_set)
> -		return -EINVAL;
> -
> -	return decoder->pdata->priv_data_set(p);
> -}
> -
> -/**
> - * ioctl_s_power - V4L2 decoder interface handler for vidioc_int_s_power_num
> - * @s: pointer to standard V4L2 device structure
> +/*
> + * tvp514x_s_stream - V4L2 decoder interface handler for vidioc_int_s_power_num
> + * @sd: pointer to standard V4L2 sub-device structure
>   * @on: power state to which device is to be set
>   *
>   * Sets devices power state to requrested state, if possible.
>   */
> -static int ioctl_s_power(struct v4l2_int_device *s, enum v4l2_power on)
> +static int tvp514x_s_stream(struct v4l2_subdev *sd, int enable)
>  {
> -	struct tvp514x_decoder *decoder = s->priv;
>  	int err = 0;
> +	struct i2c_client *client = v4l2_get_subdevdata(sd);
> +	struct tvp514x_decoder *decoder = to_decoder(sd);
> 
> -	switch (on) {
> -	case V4L2_POWER_OFF:
> -		/* Power Down Sequence */
> -		err =
> -		    tvp514x_write_reg(decoder->client, REG_OPERATION_MODE,
> -					0x01);
> -		/* Disable mux for TVP5146/47 decoder data path */
> -		if (decoder->pdata->power_set)
> -			err |= decoder->pdata->power_set(on);
> -		decoder->state = STATE_NOT_DETECTED;
> -		break;
> +	if (decoder->state == enable)
> +		return 0;
> 
> -	case V4L2_POWER_STANDBY:
> -		if (decoder->pdata->power_set)
> -			err = decoder->pdata->power_set(on);
> +	switch (enable) {
> +	case 0:
> +	{
> +		/* Power Down Sequence */
> +		err = tvp514x_write_reg(sd, REG_OPERATION_MODE, 0x01);
> +		if (err) {
> +			v4l2_err(sd, "Unable to turn off decoder\n");
> +			return err;
> +		}
> +		decoder->state = enable;

I suggest renaming 'state' to 'streaming'. The name 'state' is too generic:
I didn't understand what it meant until I saw this assignment.

>  		break;
> +	}
> +	case 1:
> +	{
> +		struct tvp514x_reg *int_seq = (struct tvp514x_reg *)
> +				client->driver->id_table->driver_data;
> 
> -	case V4L2_POWER_ON:
> -		/* Enable mux for TVP5146/47 decoder data path */
> -		if ((decoder->pdata->power_set) &&
> -				(decoder->state == STATE_NOT_DETECTED)) {
> -			int i;
> -			struct tvp514x_init_seq *int_seq =
> -				(struct tvp514x_init_seq *)
> -				decoder->id->driver_data;
> -
> -			err = decoder->pdata->power_set(on);
> -
> -			/* Power Up Sequence */
> -			for (i = 0; i < int_seq->no_regs; i++) {
> -				err |= tvp514x_write_reg(decoder->client,
> -						int_seq->init_reg_seq[i].reg,
> -						int_seq->init_reg_seq[i].val);
> -			}
> -			/* Detect the sensor is not already detected */
> -			err |= tvp514x_detect(decoder);
> -			if (err) {
> -				v4l_err(decoder->client,
> -						"Unable to detect decoder\n");
> -				return err;
> -			}
> +		/* Power Up Sequence */
> +		err = tvp514x_write_regs(sd, int_seq);
> +		if (err) {
> +			v4l2_err(sd, "Unable to turn on decoder\n");
> +			return err;
> +		}
> +		/* Detect the sensor is not already detected */

'sensor'??? And the comment is confusing in any case: 'detect if not
already detected'???

> +		err = tvp514x_detect(sd, decoder);
> +		if (err) {
> +			v4l2_err(sd, "Unable to detect decoder\n");
> +			return err;
> +		}
> +		err = tvp514x_configure(sd, decoder);
> +		if (err) {
> +			v4l2_err(sd, "Unable to configure decoder\n");
> +			return err;
>  		}
> -		err |= tvp514x_configure(decoder);
> +		decoder->state = enable;
>  		break;
> -
> +	}
>  	default:
>  		err = -ENODEV;
>  		break;
> @@ -1269,93 +1181,37 @@ static int ioctl_s_power(struct v4l2_int_device *s, enum v4l2_power on)
>  	return err;
>  }
> 
> -/**
> - * ioctl_init - V4L2 decoder interface handler for VIDIOC_INT_INIT
> - * @s: pointer to standard V4L2 device structure
> - *
> - * Initialize the decoder device (calls tvp514x_configure())
> - */
> -static int ioctl_init(struct v4l2_int_device *s)
> -{
> -	struct tvp514x_decoder *decoder = s->priv;
> -
> -	/* Set default standard to auto */
> -	decoder->tvp514x_regs[REG_VIDEO_STD].val =
> -	    VIDEO_STD_AUTO_SWITCH_BIT;
> -
> -	return tvp514x_configure(decoder);
> -}
> -
> -/**
> - * ioctl_dev_exit - V4L2 decoder interface handler for vidioc_int_dev_exit_num
> - * @s: pointer to standard V4L2 device structure
> - *
> - * Delinitialise the dev. at slave detach. The complement of ioctl_dev_init.
> - */
> -static int ioctl_dev_exit(struct v4l2_int_device *s)
> -{
> -	return 0;
> -}
> -
> -/**
> - * ioctl_dev_init - V4L2 decoder interface handler for vidioc_int_dev_init_num
> - * @s: pointer to standard V4L2 device structure
> - *
> - * Initialise the device when slave attaches to the master. Returns 0 if
> - * TVP5146/47 device could be found, otherwise returns appropriate error.
> - */
> -static int ioctl_dev_init(struct v4l2_int_device *s)
> -{
> -	struct tvp514x_decoder *decoder = s->priv;
> -	int err;
> -
> -	err = tvp514x_detect(decoder);
> -	if (err < 0) {
> -		v4l_err(decoder->client,
> -			"Unable to detect decoder\n");
> -		return err;
> -	}
> -
> -	v4l_info(decoder->client,
> -		 "chip version 0x%.2x detected\n", decoder->ver);
> +static const struct v4l2_subdev_core_ops tvp514x_core_ops = {
> +	.queryctrl = tvp514x_queryctrl,
> +	.g_ctrl = tvp514x_g_ctrl,
> +	.s_ctrl = tvp514x_s_ctrl,
> +	.s_std = tvp514x_s_std,
> +};
> 
> -	return 0;
> -}
> +static const struct v4l2_subdev_video_ops tvp514x_video_ops = {
> +	.s_routing = tvp514x_s_routing,
> +	.querystd = tvp514x_querystd,
> +	.enum_fmt = tvp514x_enum_fmt_cap,
> +	.g_fmt = tvp514x_g_fmt_cap,
> +	.try_fmt = tvp514x_try_fmt_cap,
> +	.s_fmt = tvp514x_s_fmt_cap,
> +	.g_parm = tvp514x_g_parm,
> +	.s_parm = tvp514x_s_parm,
> +	.s_stream = tvp514x_s_stream,
> +};
> 
> -static struct v4l2_int_ioctl_desc tvp514x_ioctl_desc[] = {
> -	{vidioc_int_dev_init_num, (v4l2_int_ioctl_func*) ioctl_dev_init},
> -	{vidioc_int_dev_exit_num, (v4l2_int_ioctl_func*) ioctl_dev_exit},
> -	{vidioc_int_s_power_num, (v4l2_int_ioctl_func*) ioctl_s_power},
> -	{vidioc_int_g_priv_num, (v4l2_int_ioctl_func*) ioctl_g_priv},
> -	{vidioc_int_g_ifparm_num, (v4l2_int_ioctl_func*) ioctl_g_ifparm},
> -	{vidioc_int_init_num, (v4l2_int_ioctl_func*) ioctl_init},
> -	{vidioc_int_enum_fmt_cap_num,
> -	 (v4l2_int_ioctl_func *) ioctl_enum_fmt_cap},
> -	{vidioc_int_try_fmt_cap_num,
> -	 (v4l2_int_ioctl_func *) ioctl_try_fmt_cap},
> -	{vidioc_int_g_fmt_cap_num,
> -	 (v4l2_int_ioctl_func *) ioctl_g_fmt_cap},
> -	{vidioc_int_s_fmt_cap_num,
> -	 (v4l2_int_ioctl_func *) ioctl_s_fmt_cap},
> -	{vidioc_int_g_parm_num, (v4l2_int_ioctl_func *) ioctl_g_parm},
> -	{vidioc_int_s_parm_num, (v4l2_int_ioctl_func *) ioctl_s_parm},
> -	{vidioc_int_queryctrl_num,
> -	 (v4l2_int_ioctl_func *) ioctl_queryctrl},
> -	{vidioc_int_g_ctrl_num, (v4l2_int_ioctl_func *) ioctl_g_ctrl},
> -	{vidioc_int_s_ctrl_num, (v4l2_int_ioctl_func *) ioctl_s_ctrl},
> -	{vidioc_int_querystd_num, (v4l2_int_ioctl_func *) ioctl_querystd},
> -	{vidioc_int_s_std_num, (v4l2_int_ioctl_func *) ioctl_s_std},
> -	{vidioc_int_s_video_routing_num,
> -		(v4l2_int_ioctl_func *) ioctl_s_routing},
> +static const struct v4l2_subdev_ops tvp514x_ops = {
> +	.core = &tvp514x_core_ops,
> +	.video = &tvp514x_video_ops,
>  };
> 
>  static struct tvp514x_decoder tvp514x_dev = {
> -	.state = STATE_NOT_DETECTED,
> +	.state = 0,
> 
>  	.fmt_list = tvp514x_fmt_list,
>  	.num_fmts = ARRAY_SIZE(tvp514x_fmt_list),
> 
> -	.pix = {		/* Default to NTSC 8-bit YUV 422 */
> +	.pix = {/* Default to NTSC 8-bit YUV 422 */
>  		.width = NTSC_NUM_ACTIVE_PIXELS,
>  		.height = NTSC_NUM_ACTIVE_LINES,
>  		.pixelformat = V4L2_PIX_FMT_UYVY,
> @@ -1369,20 +1225,13 @@ static struct tvp514x_decoder tvp514x_dev = {
>  	.current_std = STD_NTSC_MJ,
>  	.std_list = tvp514x_std_list,
>  	.num_stds = ARRAY_SIZE(tvp514x_std_list),
> -	.v4l2_int_device = {
> -		.module = THIS_MODULE,
> -		.name = TVP514X_MODULE_NAME,
> -		.type = v4l2_int_type_slave,
> -	},
> -	.tvp514x_slave = {
> -		.ioctls = tvp514x_ioctl_desc,
> -		.num_ioctls = ARRAY_SIZE(tvp514x_ioctl_desc),
> -	},
> +
>  };
> 
> -/**
> +/*
>   * tvp514x_probe - decoder driver i2c probe handler
>   * @client: i2c driver client device structure
> + * @id: i2c driver id table
>   *
>   * Register decoder as an i2c client device and V4L2
>   * device.
> @@ -1391,67 +1240,59 @@ static int
>  tvp514x_probe(struct i2c_client *client, const struct i2c_device_id *id)
>  {
>  	struct tvp514x_decoder *decoder;
> -	int err;
> +	struct v4l2_subdev *sd;
> 
>  	/* Check if the adapter supports the needed features */
>  	if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA))
>  		return -EIO;
> 
> +	if (!client->dev.platform_data) {
> +		v4l2_err(client, "No platform data!!\n");
> +		return -ENODEV;
> +	}
> +
>  	decoder = kzalloc(sizeof(*decoder), GFP_KERNEL);
>  	if (!decoder)
>  		return -ENOMEM;
> 
> -	if (!client->dev.platform_data) {
> -		v4l_err(client, "No platform data!!\n");
> -		err = -ENODEV;
> -		goto out_free;
> -	}
> -
> +	/*
> +	 * Initialize the tvp514x_decoder with default configuration
> +	 */
>  	*decoder = tvp514x_dev;
> -	decoder->v4l2_int_device.priv = decoder;
> -	decoder->pdata = client->dev.platform_data;
> -	decoder->v4l2_int_device.u.slave = &decoder->tvp514x_slave;
> +	/* Copy default register configuration */
>  	memcpy(decoder->tvp514x_regs, tvp514x_reg_list_default,
>  			sizeof(tvp514x_reg_list_default));
> +
> +	/*
> +	 * Copy board specific information here
> +	 */
> +	decoder->pdata = client->dev.platform_data;
> +
>  	/*
>  	 * Fetch platform specific data, and configure the
>  	 * tvp514x_reg_list[] accordingly. Since this is one
>  	 * time configuration, no need to preserve.
>  	 */
>  	decoder->tvp514x_regs[REG_OUTPUT_FORMATTER2].val |=
> -			(decoder->pdata->clk_polarity << 1);
> +		(decoder->pdata->clk_polarity << 1);
>  	decoder->tvp514x_regs[REG_SYNC_CONTROL].val |=
> -			((decoder->pdata->hs_polarity << 2) |
> -			(decoder->pdata->vs_polarity << 3));
> -	/*
> -	 * Save the id data, required for power up sequence
> -	 */
> -	decoder->id = (struct i2c_device_id *)id;
> -	/* Attach to Master */
> -	strcpy(decoder->v4l2_int_device.u.slave->attach_to,
> -			decoder->pdata->master);
> -	decoder->client = client;
> -	i2c_set_clientdata(client, decoder);
> +		((decoder->pdata->hs_polarity << 2) |
> +		 (decoder->pdata->vs_polarity << 3));
> +	/* Set default standard to auto */
> +	decoder->tvp514x_regs[REG_VIDEO_STD].val =
> +		VIDEO_STD_AUTO_SWITCH_BIT;
> 
>  	/* Register with V4L2 layer as slave device */
> -	err = v4l2_int_device_register(&decoder->v4l2_int_device);
> -	if (err) {
> -		i2c_set_clientdata(client, NULL);
> -		v4l_err(client,
> -			"Unable to register to v4l2. Err[%d]\n", err);
> -		goto out_free;
> -
> -	} else
> -		v4l_info(client, "Registered to v4l2 master %s!!\n",
> -				decoder->pdata->master);
> +	sd = &decoder->sd;
> +	v4l2_i2c_subdev_init(sd, client, &tvp514x_ops);
> +
> +	v4l2_info(sd, "%s decoder driver registered !!\n", sd->name);
> +
>  	return 0;
> 
> -out_free:
> -	kfree(decoder);
> -	return err;
>  }
> 
> -/**
> +/*
>   * tvp514x_remove - decoder driver i2c remove handler
>   * @client: i2c driver client device structure
>   *
> @@ -1460,13 +1301,10 @@ out_free:
>   */
>  static int __exit tvp514x_remove(struct i2c_client *client)
>  {
> -	struct tvp514x_decoder *decoder = i2c_get_clientdata(client);
> +	struct v4l2_subdev *sd = i2c_get_clientdata(client);
> +	struct tvp514x_decoder *decoder = to_decoder(sd);
> 
> -	if (!client->adapter)
> -		return -ENODEV;	/* our client isn't attached */
> -
> -	v4l2_int_device_unregister(&decoder->v4l2_int_device);
> -	i2c_set_clientdata(client, NULL);
> +	v4l2_device_unregister_subdev(sd);
>  	kfree(decoder);
>  	return 0;
>  }
> @@ -1485,11 +1323,9 @@ static const struct tvp514x_reg tvp5146_init_reg_seq[] = {
>  	{TOK_WRITE, REG_VBUS_DATA_ACCESS_NO_VBUS_ADDR_INCR, 0x00},
>  	{TOK_WRITE, REG_OPERATION_MODE, 0x01},
>  	{TOK_WRITE, REG_OPERATION_MODE, 0x00},
> +	{TOK_TERM, 0, 0},
>  };
> -static const struct tvp514x_init_seq tvp5146_init = {
> -	.no_regs = ARRAY_SIZE(tvp5146_init_reg_seq),
> -	.init_reg_seq = tvp5146_init_reg_seq,
> -};
> +
>  /*
>   * TVP5147 Init/Power on Sequence
>   */
> @@ -1512,22 +1348,18 @@ static const struct tvp514x_reg tvp5147_init_reg_seq[] =	{
>  	{TOK_WRITE, REG_VBUS_DATA_ACCESS_NO_VBUS_ADDR_INCR, 0x00},
>  	{TOK_WRITE, REG_OPERATION_MODE, 0x01},
>  	{TOK_WRITE, REG_OPERATION_MODE, 0x00},
> +	{TOK_TERM, 0, 0},
>  };
> -static const struct tvp514x_init_seq tvp5147_init = {
> -	.no_regs = ARRAY_SIZE(tvp5147_init_reg_seq),
> -	.init_reg_seq = tvp5147_init_reg_seq,
> -};
> +
>  /*
>   * TVP5146M2/TVP5147M1 Init/Power on Sequence
>   */
>  static const struct tvp514x_reg tvp514xm_init_reg_seq[] = {
>  	{TOK_WRITE, REG_OPERATION_MODE, 0x01},
>  	{TOK_WRITE, REG_OPERATION_MODE, 0x00},
> +	{TOK_TERM, 0, 0},
>  };
> -static const struct tvp514x_init_seq tvp514xm_init = {
> -	.no_regs = ARRAY_SIZE(tvp514xm_init_reg_seq),
> -	.init_reg_seq = tvp514xm_init_reg_seq,
> -};
> +
>  /*
>   * I2C Device Table -
>   *
> @@ -1535,48 +1367,22 @@ static const struct tvp514x_init_seq tvp514xm_init = {
>   * driver_data - Driver data
>   */
>  static const struct i2c_device_id tvp514x_id[] = {
> -	{"tvp5146", (unsigned long)&tvp5146_init},
> -	{"tvp5146m2", (unsigned long)&tvp514xm_init},
> -	{"tvp5147", (unsigned long)&tvp5147_init},
> -	{"tvp5147m1", (unsigned long)&tvp514xm_init},
> +	{"tvp5146", (unsigned long)tvp5146_init_reg_seq},
> +	{"tvp5146m2", (unsigned long)tvp514xm_init_reg_seq},
> +	{"tvp5147", (unsigned long)tvp5147_init_reg_seq},
> +	{"tvp5147m1", (unsigned long)tvp514xm_init_reg_seq},
>  	{},
>  };
> 
>  MODULE_DEVICE_TABLE(i2c, tvp514x_id);
> 
> -static struct i2c_driver tvp514x_i2c_driver = {
> -	.driver = {
> -		   .name = TVP514X_MODULE_NAME,
> -		   .owner = THIS_MODULE,
> -		   },
> +static struct v4l2_i2c_driver_data v4l2_i2c_data = {
> +	.name = TVP514X_MODULE_NAME,

Please don't use v4l2_i2c_driver_data. That is only necessary if this module
has to support pre-2.6.26 kernels. Since this driver will never be built for
such older kernels there is also no need to use this struct. Do it the same
as was done in the ths7303 driver, i.e. as a regular i2c driver.

Don't forget to remove the media/v4l2-i2c-drv.h include!

>  	.probe = tvp514x_probe,
>  	.remove = __exit_p(tvp514x_remove),
>  	.id_table = tvp514x_id,
>  };
> 
> -/**
> - * tvp514x_init
> - *
> - * Module init function
> - */
> -static int __init tvp514x_init(void)
> -{
> -	return i2c_add_driver(&tvp514x_i2c_driver);
> -}
> -
> -/**
> - * tvp514x_cleanup
> - *
> - * Module exit function
> - */
> -static void __exit tvp514x_cleanup(void)
> -{
> -	i2c_del_driver(&tvp514x_i2c_driver);
> -}
> -
> -module_init(tvp514x_init);
> -module_exit(tvp514x_cleanup);
> -
>  MODULE_AUTHOR("Texas Instruments");
>  MODULE_DESCRIPTION("TVP514X linux decoder driver");
>  MODULE_LICENSE("GPL");
> diff --git a/drivers/media/video/tvp514x_regs.h b/drivers/media/video/tvp514x_regs.h
> index 351620a..18f29ad 100644
> --- a/drivers/media/video/tvp514x_regs.h
> +++ b/drivers/media/video/tvp514x_regs.h
> @@ -284,14 +284,4 @@ struct tvp514x_reg {
>  	u32 val;
>  };
> 
> -/**
> - * struct tvp514x_init_seq - Structure for TVP5146/47/46M2/47M1 power up
> - *		Sequence.
> - * @ no_regs - Number of registers to write for power up sequence.
> - * @ init_reg_seq - Array of registers and respective value to write.
> - */
> -struct tvp514x_init_seq {
> -	unsigned int no_regs;
> -	const struct tvp514x_reg *init_reg_seq;
> -};
>  #endif				/* ifndef _TVP514X_REGS_H */
> diff --git a/include/media/tvp514x.h b/include/media/tvp514x.h
> index 5e7ee96..74387e8 100644
> --- a/include/media/tvp514x.h
> +++ b/include/media/tvp514x.h
> @@ -104,10 +104,6 @@ enum tvp514x_output {
>   * @ vs_polarity: VSYNC Polarity configuration for current interface.
>   */
>  struct tvp514x_platform_data {
> -	char *master;
> -	int (*power_set) (enum v4l2_power on);
> -	int (*ifparm) (struct v4l2_ifparm *p);
> -	int (*priv_data_set) (void *);
>  	/* Interface control params */
>  	bool clk_polarity;
>  	bool hs_polarity;
> --
> 1.6.2.4
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-media" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

Other than the four small points I mentioned it is OK. Just fix those and
I'm happy with it.

Reviewed-by: Hans Verkuil <hverkuil@xs4all.nl>

Regards,

	Hans


-- 
Hans Verkuil - video4linux developer - sponsored by TANDBERG Telecom

^ permalink raw reply	[flat|nested] 263+ messages in thread

* Re: [PATCH (V2)] TVP514x: Migration to sub-device framework
  2009-06-14 10:14 ` Hans Verkuil
@ 2009-06-14 12:44   ` Hans Verkuil
  2009-06-14 14:32     ` tcm825x.c: migrating to sub-device framework? (was: TVP514x: Migration to sub-device framework) Hans Verkuil
  2009-06-14 19:50     ` David Brownell
  1 sibling, 1 reply; 263+ messages in thread
From: Hans Verkuil @ 2009-06-14 12:44 UTC (permalink / raw)
  To: hvaibhav
  Cc: linux-media, linux-omap, davinci-linux-open-source,
	Brijesh Jadav, Hardik Shah

On Sunday 14 June 2009 12:14:38 Hans Verkuil wrote:
> On Wednesday 06 May 2009 20:31:33 hvaibhav@ti.com wrote:
> > From: Vaibhav Hiremath <hvaibhav@ti.com>
> > 
> > This patch converts TVP514x driver to sub-device framework
> > from V4L2-int framework.
> > 
> > NOTE: Please note that this patch has not been tested on any board,
> >       only compilation/build tested.
> > 
> > Changes (From Previous post):
> >     - Added static function to_decoder which will replace all
> >       container_of instances.
> >     - "unsigned int" replaced with "u32".
> >     - Cleaned up for line indentation.
> >     - pdata initialized, was missing in earlier patch.
> > 
> > TODO:
> >     - Add support for some basic video/core functionality like,
> >         .g_chip_ident
> > 	.reset
> > 	.g_input_status
> >     - Migration master driver to validate this driver.
> >     - validate on Davinci and OMAP boards.
> > 
> > Reviewed By "Hans Verkuil".
> > 
> > Signed-off-by: Brijesh Jadav <brijesh.j@ti.com>
> > Signed-off-by: Hardik Shah <hardik.shah@ti.com>
> > Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
> > ---
> >  drivers/media/video/tvp514x.c      |  854 ++++++++++++++----------------------
> >  drivers/media/video/tvp514x_regs.h |   10 -
> >  include/media/tvp514x.h            |    4 -
> >  3 files changed, 330 insertions(+), 538 deletions(-)
> > 
> > diff --git a/drivers/media/video/tvp514x.c b/drivers/media/video/tvp514x.c
> > index 4262e60..12b49ad 100644
> > --- a/drivers/media/video/tvp514x.c
> > +++ b/drivers/media/video/tvp514x.c

<snip>

> > +/*
> >   * tvp514x_remove - decoder driver i2c remove handler
> >   * @client: i2c driver client device structure
> >   *
> > @@ -1460,13 +1301,10 @@ out_free:
> >   */
> >  static int __exit tvp514x_remove(struct i2c_client *client)

This can't be __exit since it is called when the adapter is removed, not when
the driver is removed. And that's perfectly valid even if this driver is
compiled in the kernel instead of as a module.

> >  {
> > -	struct tvp514x_decoder *decoder = i2c_get_clientdata(client);
> > +	struct v4l2_subdev *sd = i2c_get_clientdata(client);
> > +	struct tvp514x_decoder *decoder = to_decoder(sd);
> > 
> > -	if (!client->adapter)
> > -		return -ENODEV;	/* our client isn't attached */
> > -
> > -	v4l2_int_device_unregister(&decoder->v4l2_int_device);
> > -	i2c_set_clientdata(client, NULL);
> > +	v4l2_device_unregister_subdev(sd);
> >  	kfree(decoder);
> >  	return 0;
> >  }
> > @@ -1485,11 +1323,9 @@ static const struct tvp514x_reg tvp5146_init_reg_seq[] = {
> >  	{TOK_WRITE, REG_VBUS_DATA_ACCESS_NO_VBUS_ADDR_INCR, 0x00},
> >  	{TOK_WRITE, REG_OPERATION_MODE, 0x01},
> >  	{TOK_WRITE, REG_OPERATION_MODE, 0x00},
> > +	{TOK_TERM, 0, 0},
> >  };
> > -static const struct tvp514x_init_seq tvp5146_init = {
> > -	.no_regs = ARRAY_SIZE(tvp5146_init_reg_seq),
> > -	.init_reg_seq = tvp5146_init_reg_seq,
> > -};
> > +
> >  /*
> >   * TVP5147 Init/Power on Sequence
> >   */
> > @@ -1512,22 +1348,18 @@ static const struct tvp514x_reg tvp5147_init_reg_seq[] =	{
> >  	{TOK_WRITE, REG_VBUS_DATA_ACCESS_NO_VBUS_ADDR_INCR, 0x00},
> >  	{TOK_WRITE, REG_OPERATION_MODE, 0x01},
> >  	{TOK_WRITE, REG_OPERATION_MODE, 0x00},
> > +	{TOK_TERM, 0, 0},
> >  };
> > -static const struct tvp514x_init_seq tvp5147_init = {
> > -	.no_regs = ARRAY_SIZE(tvp5147_init_reg_seq),
> > -	.init_reg_seq = tvp5147_init_reg_seq,
> > -};
> > +
> >  /*
> >   * TVP5146M2/TVP5147M1 Init/Power on Sequence
> >   */
> >  static const struct tvp514x_reg tvp514xm_init_reg_seq[] = {
> >  	{TOK_WRITE, REG_OPERATION_MODE, 0x01},
> >  	{TOK_WRITE, REG_OPERATION_MODE, 0x00},
> > +	{TOK_TERM, 0, 0},
> >  };
> > -static const struct tvp514x_init_seq tvp514xm_init = {
> > -	.no_regs = ARRAY_SIZE(tvp514xm_init_reg_seq),
> > -	.init_reg_seq = tvp514xm_init_reg_seq,
> > -};
> > +
> >  /*
> >   * I2C Device Table -
> >   *
> > @@ -1535,48 +1367,22 @@ static const struct tvp514x_init_seq tvp514xm_init = {
> >   * driver_data - Driver data
> >   */
> >  static const struct i2c_device_id tvp514x_id[] = {
> > -	{"tvp5146", (unsigned long)&tvp5146_init},
> > -	{"tvp5146m2", (unsigned long)&tvp514xm_init},
> > -	{"tvp5147", (unsigned long)&tvp5147_init},
> > -	{"tvp5147m1", (unsigned long)&tvp514xm_init},
> > +	{"tvp5146", (unsigned long)tvp5146_init_reg_seq},
> > +	{"tvp5146m2", (unsigned long)tvp514xm_init_reg_seq},
> > +	{"tvp5147", (unsigned long)tvp5147_init_reg_seq},
> > +	{"tvp5147m1", (unsigned long)tvp514xm_init_reg_seq},
> >  	{},
> >  };
> > 
> >  MODULE_DEVICE_TABLE(i2c, tvp514x_id);
> > 
> > -static struct i2c_driver tvp514x_i2c_driver = {
> > -	.driver = {
> > -		   .name = TVP514X_MODULE_NAME,
> > -		   .owner = THIS_MODULE,
> > -		   },
> > +static struct v4l2_i2c_driver_data v4l2_i2c_data = {
> > +	.name = TVP514X_MODULE_NAME,
> 
> Please don't use v4l2_i2c_driver_data. That is only necessary if this module
> has to support pre-2.6.26 kernels. Since this driver will never be built for
> such older kernels there is also no need to use this struct. Do it the same
> as was done in the ths7303 driver, i.e. as a regular i2c driver.
> 
> Don't forget to remove the media/v4l2-i2c-drv.h include!
> 
> >  	.probe = tvp514x_probe,
> >  	.remove = __exit_p(tvp514x_remove),

__exit_p should not be used.

> >  	.id_table = tvp514x_id,
> >  };

Regards,

	Hans

-- 
Hans Verkuil - video4linux developer - sponsored by TANDBERG Telecom

^ permalink raw reply	[flat|nested] 263+ messages in thread

* tcm825x.c: migrating to sub-device framework? (was: TVP514x: Migration to sub-device framework)
  2009-06-14 12:44   ` Hans Verkuil
@ 2009-06-14 14:32     ` Hans Verkuil
  2009-06-15  8:45       ` tcm825x.c: migrating to sub-device framework? Sakari Ailus
  0 siblings, 1 reply; 263+ messages in thread
From: Hans Verkuil @ 2009-06-14 14:32 UTC (permalink / raw)
  To: hvaibhav
  Cc: linux-media, linux-omap, davinci-linux-open-source,
	Brijesh Jadav, Hardik Shah, Sakari Ailus

On Sunday 14 June 2009 14:44:53 Hans Verkuil wrote:
> On Sunday 14 June 2009 12:14:38 Hans Verkuil wrote:
> > On Wednesday 06 May 2009 20:31:33 hvaibhav@ti.com wrote:
> > > From: Vaibhav Hiremath <hvaibhav@ti.com>
> > > 
> > > This patch converts TVP514x driver to sub-device framework
> > > from V4L2-int framework.

Now that tvp514x is converted to using v4l2_subdev (pending a few small final
tweaks) there is only one driver left that uses the v4l2-int-device.h API:
tcm825x.c.

What is involved in converting this driver as well? And who can do this?

Regards,

	Hans

-- 
Hans Verkuil - video4linux developer - sponsored by TANDBERG Telecom

^ permalink raw reply	[flat|nested] 263+ messages in thread

* Re: [PATCH (V2)] TVP514x: Migration to sub-device framework
@ 2009-06-14 19:50     ` David Brownell
  0 siblings, 0 replies; 263+ messages in thread
From: David Brownell @ 2009-06-14 19:50 UTC (permalink / raw)
  To: davinci-linux-open-source; +Cc: Hans Verkuil, hvaibhav, linux-omap, linux-media

On Sunday 14 June 2009, Hans Verkuil wrote:
> > +#define dump_reg(sd, reg, val)                               \
> >       do {                                                    \
> > -             val = tvp514x_read_reg(client, reg);            \
> > -             v4l_info(client, "Reg(0x%.2X): 0x%.2X\n", reg, val); \
> > +             val = tvp514x_read_reg(sd, reg);                \
> > +             v4l2_info(sd, "Reg(0x%.2X): 0x%.2X\n", reg, val); \
> >       } while (0)
> 
> Why not turn this into a static inline function? Much better than a macro.

IMO, too big for either.  Make it a real function.


^ permalink raw reply	[flat|nested] 263+ messages in thread

* Re: [PATCH (V2)] TVP514x: Migration to sub-device framework
@ 2009-06-14 19:50     ` David Brownell
  0 siblings, 0 replies; 263+ messages in thread
From: David Brownell @ 2009-06-14 19:50 UTC (permalink / raw)
  To: davinci-linux-open-source-VycZQUHpC/PFrsHnngEfi1aTQe2KTcn/
  Cc: linux-omap-u79uwXL29TY76Z2rM5mHXA, linux-media-u79uwXL29TY76Z2rM5mHXA

On Sunday 14 June 2009, Hans Verkuil wrote:
> > +#define dump_reg(sd, reg, val)                               \
> >       do {                                                    \
> > -             val = tvp514x_read_reg(client, reg);            \
> > -             v4l_info(client, "Reg(0x%.2X): 0x%.2X\n", reg, val); \
> > +             val = tvp514x_read_reg(sd, reg);                \
> > +             v4l2_info(sd, "Reg(0x%.2X): 0x%.2X\n", reg, val); \
> >       } while (0)
> 
> Why not turn this into a static inline function? Much better than a macro.

IMO, too big for either.  Make it a real function.

^ permalink raw reply	[flat|nested] 263+ messages in thread

* Re: tcm825x.c: migrating to sub-device framework?
  2009-06-14 14:32     ` tcm825x.c: migrating to sub-device framework? (was: TVP514x: Migration to sub-device framework) Hans Verkuil
@ 2009-06-15  8:45       ` Sakari Ailus
  0 siblings, 0 replies; 263+ messages in thread
From: Sakari Ailus @ 2009-06-15  8:45 UTC (permalink / raw)
  To: Hans Verkuil
  Cc: hvaibhav, linux-media, linux-omap, davinci-linux-open-source,
	Brijesh Jadav, Hardik Shah

Hans Verkuil wrote:
> On Sunday 14 June 2009 14:44:53 Hans Verkuil wrote:
>> On Sunday 14 June 2009 12:14:38 Hans Verkuil wrote:
>>> On Wednesday 06 May 2009 20:31:33 hvaibhav@ti.com wrote:
>>>> From: Vaibhav Hiremath <hvaibhav@ti.com>
>>>>
>>>> This patch converts TVP514x driver to sub-device framework
>>>> from V4L2-int framework.
> 
> Now that tvp514x is converted to using v4l2_subdev (pending a few small final
> tweaks) there is only one driver left that uses the v4l2-int-device.h API:
> tcm825x.c.

There's also the OMAP 2 camera driver (master), 
drivers/media/video/omap24xxcam.c. The tcm825x is the slave driver that 
is used in conjunction with omap24xxcam on N800 and N810.

-- 
Sakari Ailus
sakari.ailus@maxwell.research.nokia.com

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [U-Boot] [PATCH] OMAP3EVM: Added NAND support
@ 2009-11-18  6:58 ` hvaibhav at ti.com
  2009-11-18  7:30   ` Dirk Behme
  2009-11-18 18:07   ` Nishanth Menon
  0 siblings, 2 replies; 263+ messages in thread
From: hvaibhav at ti.com @ 2009-11-18  6:58 UTC (permalink / raw)
  To: u-boot

From: Vaibhav Hiremath <hvaibhav@ti.com>

User can now choose between NAND and ONENAND support in omap3_evm.h

Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
---
 include/configs/omap3_evm.h |   27 ++++++++++++++++++++++++++-
 1 files changed, 26 insertions(+), 1 deletions(-)

diff --git a/include/configs/omap3_evm.h b/include/configs/omap3_evm.h
index a5514ae..3434306 100644
--- a/include/configs/omap3_evm.h
+++ b/include/configs/omap3_evm.h
@@ -110,7 +110,8 @@

 #define CONFIG_CMD_I2C		/* I2C serial bus support	*/
 #define CONFIG_CMD_MMC		/* MMC support			*/
-#define CONFIG_CMD_ONENAND	/* ONENAND support		*/
+/*#define CONFIG_CMD_ONENAND*/	/* ONENAND support		*/
+#define CONFIG_CMD_NAND		/* NAND support			*/
 #define CONFIG_CMD_DHCP
 #define CONFIG_CMD_PING

@@ -141,6 +142,7 @@
 							/* to access */
 							/* nand at CS0 */

+
 #define CONFIG_SYS_MAX_NAND_DEVICE	1		/* Max number of */
 							/* NAND devices */
 #define CONFIG_SYS_64BIT_VSPRINTF		/* needed for nand_util.c */
@@ -268,7 +270,13 @@
 #define CONFIG_SYS_MONITOR_BASE		CONFIG_SYS_FLASH_BASE
 #define CONFIG_SYS_ONENAND_BASE		ONENAND_MAP

+#if defined(CONFIG_CMD_NAND)
+#define CONFIG_NAND_OMAP_GPMC
+#define GPMC_NAND_ECC_LP_x16_LAYOUT	1
+#define CONFIG_ENV_IS_IN_NAND		1
+#elif defined(CONFIG_CMD_ONENAND)
 #define CONFIG_ENV_IS_IN_ONENAND	1
+#endif
 #define ONENAND_ENV_OFFSET		0x260000 /* environment starts here */
 #define SMNAND_ENV_OFFSET		0x260000 /* environment starts here */

@@ -300,6 +308,23 @@ extern unsigned int boot_flash_sec;
 extern unsigned int boot_flash_type;
 #endif

+
+#define WRITE_NAND_COMMAND(d, adr)\
+			writel(d, &nand_cs_base->nand_cmd)
+#define WRITE_NAND_ADDRESS(d, adr)\
+			writel(d, &nand_cs_base->nand_adr)
+#define WRITE_NAND(d, adr) writew(d, &nand_cs_base->nand_dat)
+#define READ_NAND(adr) readl(&nand_cs_base->nand_dat)
+
+/* Other NAND Access APIs */
+#define NAND_WP_OFF() do {readl(&gpmc_cfg_base->config) |= GPMC_CONFIG_WP; } \
+			while (0)
+#define NAND_WP_ON() do {readl(&gpmc_cfg_base->config) &= ~GPMC_CONFIG_WP; } \
+			while (0)
+#define NAND_DISABLE_CE(nand)
+#define NAND_ENABLE_CE(nand)
+#define NAND_WAIT_READY(nand)	udelay(10)
+
 /*----------------------------------------------------------------------------
  * SMSC9115 Ethernet from SMSC9118 family
  *----------------------------------------------------------------------------
--
1.6.2.4

^ permalink raw reply related	[flat|nested] 263+ messages in thread

* [U-Boot] [PATCH] OMAP3EVM: Added NAND support
  2009-11-18  6:58 ` [U-Boot] [PATCH] OMAP3EVM: Added NAND support hvaibhav at ti.com
@ 2009-11-18  7:30   ` Dirk Behme
  2009-11-18  8:25     ` Hiremath, Vaibhav
  2009-11-18 18:07   ` Nishanth Menon
  1 sibling, 1 reply; 263+ messages in thread
From: Dirk Behme @ 2009-11-18  7:30 UTC (permalink / raw)
  To: u-boot

hvaibhav at ti.com wrote:
> From: Vaibhav Hiremath <hvaibhav@ti.com>
> 
> User can now choose between NAND and ONENAND support in omap3_evm.h
> 
> Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
> ---
>  include/configs/omap3_evm.h |   27 ++++++++++++++++++++++++++-
>  1 files changed, 26 insertions(+), 1 deletions(-)
> 
> diff --git a/include/configs/omap3_evm.h b/include/configs/omap3_evm.h
> index a5514ae..3434306 100644
> --- a/include/configs/omap3_evm.h
> +++ b/include/configs/omap3_evm.h
> @@ -110,7 +110,8 @@
> 
>  #define CONFIG_CMD_I2C		/* I2C serial bus support	*/
>  #define CONFIG_CMD_MMC		/* MMC support			*/
> -#define CONFIG_CMD_ONENAND	/* ONENAND support		*/
> +/*#define CONFIG_CMD_ONENAND*/	/* ONENAND support		*/
> +#define CONFIG_CMD_NAND		/* NAND support			*/

Is it okay to switch the default from ONENAND to NAND here?

>  #define CONFIG_CMD_DHCP
>  #define CONFIG_CMD_PING
> 
> @@ -141,6 +142,7 @@
>  							/* to access */
>  							/* nand at CS0 */
> 
> +

?

>  #define CONFIG_SYS_MAX_NAND_DEVICE	1		/* Max number of */
>  							/* NAND devices */
>  #define CONFIG_SYS_64BIT_VSPRINTF		/* needed for nand_util.c */
> @@ -268,7 +270,13 @@
>  #define CONFIG_SYS_MONITOR_BASE		CONFIG_SYS_FLASH_BASE
>  #define CONFIG_SYS_ONENAND_BASE		ONENAND_MAP
> 
> +#if defined(CONFIG_CMD_NAND)
> +#define CONFIG_NAND_OMAP_GPMC
> +#define GPMC_NAND_ECC_LP_x16_LAYOUT	1
> +#define CONFIG_ENV_IS_IN_NAND		1
> +#elif defined(CONFIG_CMD_ONENAND)
>  #define CONFIG_ENV_IS_IN_ONENAND	1
> +#endif
>  #define ONENAND_ENV_OFFSET		0x260000 /* environment starts here */
>  #define SMNAND_ENV_OFFSET		0x260000 /* environment starts here */
> 
> @@ -300,6 +308,23 @@ extern unsigned int boot_flash_sec;
>  extern unsigned int boot_flash_type;
>  #endif
> 
> +
> +#define WRITE_NAND_COMMAND(d, adr)\
> +			writel(d, &nand_cs_base->nand_cmd)
> +#define WRITE_NAND_ADDRESS(d, adr)\
> +			writel(d, &nand_cs_base->nand_adr)
> +#define WRITE_NAND(d, adr) writew(d, &nand_cs_base->nand_dat)
> +#define READ_NAND(adr) readl(&nand_cs_base->nand_dat)
> +
> +/* Other NAND Access APIs */
> +#define NAND_WP_OFF() do {readl(&gpmc_cfg_base->config) |= GPMC_CONFIG_WP; } \
> +			while (0)
> +#define NAND_WP_ON() do {readl(&gpmc_cfg_base->config) &= ~GPMC_CONFIG_WP; } \
> +			while (0)
> +#define NAND_DISABLE_CE(nand)
> +#define NAND_ENABLE_CE(nand)
> +#define NAND_WAIT_READY(nand)	udelay(10)

Would encapsulating this with

#if defined(CONFIG_CMD_NAND)

#endif

make sense here?

Best regards

Dirk

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [U-Boot] [PATCH] OMAP3EVM: Added NAND support
  2009-11-18  7:30   ` Dirk Behme
@ 2009-11-18  8:25     ` Hiremath, Vaibhav
  0 siblings, 0 replies; 263+ messages in thread
From: Hiremath, Vaibhav @ 2009-11-18  8:25 UTC (permalink / raw)
  To: u-boot


> -----Original Message-----
> From: Dirk Behme [mailto:dirk.behme at googlemail.com]
> Sent: Wednesday, November 18, 2009 1:01 PM
> To: Hiremath, Vaibhav
> Cc: u-boot at lists.denx.de
> Subject: Re: [U-Boot] [PATCH] OMAP3EVM: Added NAND support
> 
> hvaibhav at ti.com wrote:
> > From: Vaibhav Hiremath <hvaibhav@ti.com>
> >
> > User can now choose between NAND and ONENAND support in
> omap3_evm.h
> >
> > Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
> > ---
> >  include/configs/omap3_evm.h |   27 ++++++++++++++++++++++++++-
> >  1 files changed, 26 insertions(+), 1 deletions(-)
> >
> > diff --git a/include/configs/omap3_evm.h
> b/include/configs/omap3_evm.h
> > index a5514ae..3434306 100644
> > --- a/include/configs/omap3_evm.h
> > +++ b/include/configs/omap3_evm.h
> > @@ -110,7 +110,8 @@
> >
> >  #define CONFIG_CMD_I2C		/* I2C serial bus support	*/
> >  #define CONFIG_CMD_MMC		/* MMC support			*/
> > -#define CONFIG_CMD_ONENAND	/* ONENAND support		*/
> > +/*#define CONFIG_CMD_ONENAND*/	/* ONENAND support		*/
> > +#define CONFIG_CMD_NAND		/* NAND support			*/
> 
> Is it okay to switch the default from ONENAND to NAND here?
> 
[Hiremath, Vaibhav] Most EVM's which I have seen comes with NAND support, so I have chosen NAND as a default.  And anyway here user can select ONENAND also.

Do you see any issues with moving NAND as a default?

> >  #define CONFIG_CMD_DHCP
> >  #define CONFIG_CMD_PING
> >
> > @@ -141,6 +142,7 @@
> >  							/* to access */
> >  							/* nand at CS0 */
> >
> > +
> 
> ?
> 
> >  #define CONFIG_SYS_MAX_NAND_DEVICE	1		/* Max number
> of */
> >  							/* NAND devices */
> >  #define CONFIG_SYS_64BIT_VSPRINTF		/* needed for
> nand_util.c */
> > @@ -268,7 +270,13 @@
> >  #define CONFIG_SYS_MONITOR_BASE		CONFIG_SYS_FLASH_BASE
> >  #define CONFIG_SYS_ONENAND_BASE		ONENAND_MAP
> >
> > +#if defined(CONFIG_CMD_NAND)
> > +#define CONFIG_NAND_OMAP_GPMC
> > +#define GPMC_NAND_ECC_LP_x16_LAYOUT	1
> > +#define CONFIG_ENV_IS_IN_NAND		1
> > +#elif defined(CONFIG_CMD_ONENAND)
> >  #define CONFIG_ENV_IS_IN_ONENAND	1
> > +#endif
> >  #define ONENAND_ENV_OFFSET		0x260000 /* environment starts
> here */
> >  #define SMNAND_ENV_OFFSET		0x260000 /* environment starts
> here */
> >
> > @@ -300,6 +308,23 @@ extern unsigned int boot_flash_sec;
> >  extern unsigned int boot_flash_type;
> >  #endif
> >
> > +
> > +#define WRITE_NAND_COMMAND(d, adr)\
> > +			writel(d, &nand_cs_base->nand_cmd)
> > +#define WRITE_NAND_ADDRESS(d, adr)\
> > +			writel(d, &nand_cs_base->nand_adr)
> > +#define WRITE_NAND(d, adr) writew(d, &nand_cs_base->nand_dat)
> > +#define READ_NAND(adr) readl(&nand_cs_base->nand_dat)
> > +
> > +/* Other NAND Access APIs */
> > +#define NAND_WP_OFF() do {readl(&gpmc_cfg_base->config) |=
> GPMC_CONFIG_WP; } \
> > +			while (0)
> > +#define NAND_WP_ON() do {readl(&gpmc_cfg_base->config) &=
> ~GPMC_CONFIG_WP; } \
> > +			while (0)
> > +#define NAND_DISABLE_CE(nand)
> > +#define NAND_ENABLE_CE(nand)
> > +#define NAND_WAIT_READY(nand)	udelay(10)
> 
> Would encapsulating this with
> 
> #if defined(CONFIG_CMD_NAND)
> 
> #endif
> 
> make sense here?
> 
[Hiremath, Vaibhav] Opps. Sorry, by mistake I have sent old patch, sending you the cleaned one.

Thanks,
Vaibhav
> Best regards
> 
> Dirk

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [U-Boot] [PATCH] OMAP3EVM: Added NAND support
@ 2009-11-18  8:26 ` hvaibhav at ti.com
  2009-11-18  8:36   ` Dirk Behme
  0 siblings, 1 reply; 263+ messages in thread
From: hvaibhav at ti.com @ 2009-11-18  8:26 UTC (permalink / raw)
  To: u-boot

From: Vaibhav Hiremath <hvaibhav@ti.com>


Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
---
 include/configs/omap3_evm.h |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/include/configs/omap3_evm.h b/include/configs/omap3_evm.h
index a5514ae..fbc45dc 100644
--- a/include/configs/omap3_evm.h
+++ b/include/configs/omap3_evm.h
@@ -110,7 +110,8 @@
 
 #define CONFIG_CMD_I2C		/* I2C serial bus support	*/
 #define CONFIG_CMD_MMC		/* MMC support			*/
-#define CONFIG_CMD_ONENAND	/* ONENAND support		*/
+/*#define CONFIG_CMD_ONENAND*/	/* ONENAND support		*/
+#define CONFIG_CMD_NAND		/* NAND support			*/
 #define CONFIG_CMD_DHCP
 #define CONFIG_CMD_PING
 
@@ -141,6 +142,7 @@
 							/* to access */
 							/* nand at CS0 */
 
+
 #define CONFIG_SYS_MAX_NAND_DEVICE	1		/* Max number of */
 							/* NAND devices */
 #define CONFIG_SYS_64BIT_VSPRINTF		/* needed for nand_util.c */
@@ -268,7 +270,13 @@
 #define CONFIG_SYS_MONITOR_BASE		CONFIG_SYS_FLASH_BASE
 #define CONFIG_SYS_ONENAND_BASE		ONENAND_MAP
 
+#if defined(CONFIG_CMD_NAND)
+#define CONFIG_NAND_OMAP_GPMC
+#define GPMC_NAND_ECC_LP_x16_LAYOUT	1
+#define CONFIG_ENV_IS_IN_NAND		1
+#elif defined(CONFIG_CMD_ONENAND)
 #define CONFIG_ENV_IS_IN_ONENAND	1
+#endif
 #define ONENAND_ENV_OFFSET		0x260000 /* environment starts here */
 #define SMNAND_ENV_OFFSET		0x260000 /* environment starts here */
 
-- 
1.6.2.4

^ permalink raw reply related	[flat|nested] 263+ messages in thread

* [U-Boot] [PATCH] OMAP3EVM: Added NAND support
  2009-11-18  8:26 ` hvaibhav at ti.com
@ 2009-11-18  8:36   ` Dirk Behme
  2009-11-18 14:40     ` Hiremath, Vaibhav
  0 siblings, 1 reply; 263+ messages in thread
From: Dirk Behme @ 2009-11-18  8:36 UTC (permalink / raw)
  To: u-boot


It would have been nice if subject had a 'v2' now.

hvaibhav at ti.com wrote:
> From: Vaibhav Hiremath <hvaibhav@ti.com>

Patch description missing here now. And if you re-add, it would be 
good to mention that you switch from ONENAND to NAND, too.

> Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
> ---
>  include/configs/omap3_evm.h |   10 +++++++++-
>  1 files changed, 9 insertions(+), 1 deletions(-)
> 
> diff --git a/include/configs/omap3_evm.h b/include/configs/omap3_evm.h
> index a5514ae..fbc45dc 100644
> --- a/include/configs/omap3_evm.h
> +++ b/include/configs/omap3_evm.h
> @@ -110,7 +110,8 @@
>  
>  #define CONFIG_CMD_I2C		/* I2C serial bus support	*/
>  #define CONFIG_CMD_MMC		/* MMC support			*/
> -#define CONFIG_CMD_ONENAND	/* ONENAND support		*/
> +/*#define CONFIG_CMD_ONENAND*/	/* ONENAND support		*/
> +#define CONFIG_CMD_NAND		/* NAND support			*/

Often it can be irritating for users if default changes silently. But 
EVM people have to discuss about this, I can't say what the preferred 
NAND support is.

>  #define CONFIG_CMD_DHCP
>  #define CONFIG_CMD_PING
>  
> @@ -141,6 +142,7 @@
>  							/* to access */
>  							/* nand at CS0 */
>  
> +

What's this?

Best regards

Dirk

>  #define CONFIG_SYS_MAX_NAND_DEVICE	1		/* Max number of */
>  							/* NAND devices */
>  #define CONFIG_SYS_64BIT_VSPRINTF		/* needed for nand_util.c */
> @@ -268,7 +270,13 @@
>  #define CONFIG_SYS_MONITOR_BASE		CONFIG_SYS_FLASH_BASE
>  #define CONFIG_SYS_ONENAND_BASE		ONENAND_MAP
>  
> +#if defined(CONFIG_CMD_NAND)
> +#define CONFIG_NAND_OMAP_GPMC
> +#define GPMC_NAND_ECC_LP_x16_LAYOUT	1
> +#define CONFIG_ENV_IS_IN_NAND		1
> +#elif defined(CONFIG_CMD_ONENAND)
>  #define CONFIG_ENV_IS_IN_ONENAND	1
> +#endif
>  #define ONENAND_ENV_OFFSET		0x260000 /* environment starts here */
>  #define SMNAND_ENV_OFFSET		0x260000 /* environment starts here */
>  

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [U-Boot] [PATCH] OMAP3EVM: Added NAND support
  2009-11-18  8:36   ` Dirk Behme
@ 2009-11-18 14:40     ` Hiremath, Vaibhav
  0 siblings, 0 replies; 263+ messages in thread
From: Hiremath, Vaibhav @ 2009-11-18 14:40 UTC (permalink / raw)
  To: u-boot


> -----Original Message-----
> From: Dirk Behme [mailto:dirk.behme at googlemail.com]
> Sent: Wednesday, November 18, 2009 2:07 PM
> To: Hiremath, Vaibhav
> Cc: u-boot at lists.denx.de
> Subject: Re: [U-Boot] [PATCH] OMAP3EVM: Added NAND support
> 
> 
> It would have been nice if subject had a 'v2' now.
> 
[Hiremath, Vaibhav] Ok.

> hvaibhav at ti.com wrote:
> > From: Vaibhav Hiremath <hvaibhav@ti.com>
> 
> Patch description missing here now. And if you re-add, it would be
> good to mention that you switch from ONENAND to NAND, too.
> 
[Hiremath, Vaibhav] Will add the description accordingly and submit 'v3'.

> > Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
> > ---
> >  include/configs/omap3_evm.h |   10 +++++++++-
> >  1 files changed, 9 insertions(+), 1 deletions(-)
> >
> > diff --git a/include/configs/omap3_evm.h
> b/include/configs/omap3_evm.h
> > index a5514ae..fbc45dc 100644
> > --- a/include/configs/omap3_evm.h
> > +++ b/include/configs/omap3_evm.h
> > @@ -110,7 +110,8 @@
> >
> >  #define CONFIG_CMD_I2C		/* I2C serial bus support	*/
> >  #define CONFIG_CMD_MMC		/* MMC support			*/
> > -#define CONFIG_CMD_ONENAND	/* ONENAND support		*/
> > +/*#define CONFIG_CMD_ONENAND*/	/* ONENAND support		*/
> > +#define CONFIG_CMD_NAND		/* NAND support			*/
> 
> Often it can be irritating for users if default changes silently.
> But
> EVM people have to discuss about this, I can't say what the
> preferred
> NAND support is.
> 
[Hiremath, Vaibhav] If we don't get any objection/comments for this change, then I think it should be safe to change to NAND support by default.

> >  #define CONFIG_CMD_DHCP
> >  #define CONFIG_CMD_PING
> >
> > @@ -141,6 +142,7 @@
> >  							/* to access */
> >  							/* nand at CS0 */
> >
> > +
> 
> What's this?
[Hiremath, Vaibhav] Will remove in next version.

Thanks Dirk for reviewing this patch.

Thanks,
Vaibhav
> 
> Best regards
> 
> Dirk
> 
> >  #define CONFIG_SYS_MAX_NAND_DEVICE	1		/* Max number
> of */
> >  							/* NAND devices */
> >  #define CONFIG_SYS_64BIT_VSPRINTF		/* needed for
> nand_util.c */
> > @@ -268,7 +270,13 @@
> >  #define CONFIG_SYS_MONITOR_BASE		CONFIG_SYS_FLASH_BASE
> >  #define CONFIG_SYS_ONENAND_BASE		ONENAND_MAP
> >
> > +#if defined(CONFIG_CMD_NAND)
> > +#define CONFIG_NAND_OMAP_GPMC
> > +#define GPMC_NAND_ECC_LP_x16_LAYOUT	1
> > +#define CONFIG_ENV_IS_IN_NAND		1
> > +#elif defined(CONFIG_CMD_ONENAND)
> >  #define CONFIG_ENV_IS_IN_ONENAND	1
> > +#endif
> >  #define ONENAND_ENV_OFFSET		0x260000 /* environment starts
> here */
> >  #define SMNAND_ENV_OFFSET		0x260000 /* environment starts
> here */
> >
> 

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [U-Boot] [PATCH] OMAP3EVM: Added NAND support
  2009-11-18  6:58 ` [U-Boot] [PATCH] OMAP3EVM: Added NAND support hvaibhav at ti.com
  2009-11-18  7:30   ` Dirk Behme
@ 2009-11-18 18:07   ` Nishanth Menon
  2009-11-18 18:18     ` Scott Wood
  2009-11-18 18:40     ` Hiremath, Vaibhav
  1 sibling, 2 replies; 263+ messages in thread
From: Nishanth Menon @ 2009-11-18 18:07 UTC (permalink / raw)
  To: u-boot

On Wed, Nov 18, 2009 at 12:58 AM,  <hvaibhav@ti.com> wrote:
> From: Vaibhav Hiremath <hvaibhav@ti.com>
>
> User can now choose between NAND and ONENAND support in omap3_evm.h
>
> Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
> ---
> ?include/configs/omap3_evm.h | ? 27 ++++++++++++++++++++++++++-
> ?1 files changed, 26 insertions(+), 1 deletions(-)
>
> diff --git a/include/configs/omap3_evm.h b/include/configs/omap3_evm.h
> index a5514ae..3434306 100644
> --- a/include/configs/omap3_evm.h
> +++ b/include/configs/omap3_evm.h
> @@ -110,7 +110,8 @@
>
> ?#define CONFIG_CMD_I2C ? ? ? ? /* I2C serial bus support ? ? ? */
> ?#define CONFIG_CMD_MMC ? ? ? ? /* MMC support ? ? ? ? ? ? ? ? ?*/
> -#define CONFIG_CMD_ONENAND ? ? /* ONENAND support ? ? ? ? ? ? ?*/
> +/*#define CONFIG_CMD_ONENAND*/ /* ONENAND support ? ? ? ? ? ? ?*/
do you wish to use #undef instead of commented code? also adding a
comment on top saying this is an option might help..

This patch opens up a chain for me: how do we have the same build of
u-boot boot accross nand, onenand, mmc  type devices?
current  u-boot looks constrainted in that respect.

> +#define CONFIG_CMD_NAND ? ? ? ? ? ? ? ?/* NAND support ? ? ? ? ? ? ? ? */
> ?#define CONFIG_CMD_DHCP
> ?#define CONFIG_CMD_PING
>
> @@ -141,6 +142,7 @@
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?/* to access */
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?/* nand at CS0 */
>
> +
> ?#define CONFIG_SYS_MAX_NAND_DEVICE ? ? 1 ? ? ? ? ? ? ? /* Max number of */
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?/* NAND devices */
> ?#define CONFIG_SYS_64BIT_VSPRINTF ? ? ? ? ? ? ?/* needed for nand_util.c */
> @@ -268,7 +270,13 @@
> ?#define CONFIG_SYS_MONITOR_BASE ? ? ? ? ? ? ? ?CONFIG_SYS_FLASH_BASE
> ?#define CONFIG_SYS_ONENAND_BASE ? ? ? ? ? ? ? ?ONENAND_MAP
>
> +#if defined(CONFIG_CMD_NAND)
> +#define CONFIG_NAND_OMAP_GPMC
> +#define GPMC_NAND_ECC_LP_x16_LAYOUT ? ?1
> +#define CONFIG_ENV_IS_IN_NAND ? ? ? ? ?1
> +#elif defined(CONFIG_CMD_ONENAND)
> ?#define CONFIG_ENV_IS_IN_ONENAND ? ? ? 1
> +#endif

what if a user decided to enable NAND and ONENAND?

> ?#define ONENAND_ENV_OFFSET ? ? ? ? ? ? 0x260000 /* environment starts here */
> ?#define SMNAND_ENV_OFFSET ? ? ? ? ? ? ?0x260000 /* environment starts here */
>
> @@ -300,6 +308,23 @@ extern unsigned int boot_flash_sec;
> ?extern unsigned int boot_flash_type;
> ?#endif
>
> +
> +#define WRITE_NAND_COMMAND(d, adr)\
> + ? ? ? ? ? ? ? ? ? ? ? writel(d, &nand_cs_base->nand_cmd)
writel? i thought u had 16 bit nand device.

> +#define WRITE_NAND_ADDRESS(d, adr)\
> + ? ? ? ? ? ? ? ? ? ? ? writel(d, &nand_cs_base->nand_adr)
> +#define WRITE_NAND(d, adr) writew(d, &nand_cs_base->nand_dat)
> +#define READ_NAND(adr) readl(&nand_cs_base->nand_dat)
readl?? should'nt you be using readw?

Why these functions? does'nt mtd layer handle this? look at beagle ->
it does not use that..

> +
> +/* Other NAND Access APIs */
> +#define NAND_WP_OFF() do {readl(&gpmc_cfg_base->config) |= GPMC_CONFIG_WP; } \
> + ? ? ? ? ? ? ? ? ? ? ? while (0)
> +#define NAND_WP_ON() do {readl(&gpmc_cfg_base->config) &= ~GPMC_CONFIG_WP; } \
> + ? ? ? ? ? ? ? ? ? ? ? while (0)
> +#define NAND_DISABLE_CE(nand)
> +#define NAND_ENABLE_CE(nand)
> +#define NAND_WAIT_READY(nand) ?udelay(10)
> +
are these really needed?

> ?/*----------------------------------------------------------------------------
> ?* SMSC9115 Ethernet from SMSC9118 family
> ?*----------------------------------------------------------------------------
> --
> 1.6.2.4
>
> _______________________________________________
> U-Boot mailing list
> U-Boot at lists.denx.de
> http://lists.denx.de/mailman/listinfo/u-boot
>

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [U-Boot] [PATCH] OMAP3EVM: Added NAND support
  2009-11-18 18:07   ` Nishanth Menon
@ 2009-11-18 18:18     ` Scott Wood
  2009-11-18 18:40     ` Hiremath, Vaibhav
  1 sibling, 0 replies; 263+ messages in thread
From: Scott Wood @ 2009-11-18 18:18 UTC (permalink / raw)
  To: u-boot

Nishanth Menon wrote:
>> +
>> +#define WRITE_NAND_COMMAND(d, adr)\
>> +                       writel(d, &nand_cs_base->nand_cmd)
> writel? i thought u had 16 bit nand device.
> 
>> +#define WRITE_NAND_ADDRESS(d, adr)\
>> +                       writel(d, &nand_cs_base->nand_adr)
>> +#define WRITE_NAND(d, adr) writew(d, &nand_cs_base->nand_dat)
>> +#define READ_NAND(adr) readl(&nand_cs_base->nand_dat)
> readl?? should'nt you be using readw?
> 
> Why these functions? does'nt mtd layer handle this? look at beagle ->
> it does not use that..
> 
>> +
>> +/* Other NAND Access APIs */
>> +#define NAND_WP_OFF() do {readl(&gpmc_cfg_base->config) |= GPMC_CONFIG_WP; } \
>> +                       while (0)
>> +#define NAND_WP_ON() do {readl(&gpmc_cfg_base->config) &= ~GPMC_CONFIG_WP; } \
>> +                       while (0)
>> +#define NAND_DISABLE_CE(nand)
>> +#define NAND_ENABLE_CE(nand)
>> +#define NAND_WAIT_READY(nand)  udelay(10)
>> +
> are these really needed?

No, they're not needed.  That is the legacy NAND interface that has been 
superseded and removed.

-Scott

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [U-Boot] [PATCH] OMAP3EVM: Added NAND support
  2009-11-18 18:07   ` Nishanth Menon
  2009-11-18 18:18     ` Scott Wood
@ 2009-11-18 18:40     ` Hiremath, Vaibhav
  1 sibling, 0 replies; 263+ messages in thread
From: Hiremath, Vaibhav @ 2009-11-18 18:40 UTC (permalink / raw)
  To: u-boot


> -----Original Message-----
> From: Nishanth Menon [mailto:menon.nishanth at gmail.com]
> Sent: Wednesday, November 18, 2009 11:38 PM
> To: Hiremath, Vaibhav
> Cc: u-boot at lists.denx.de
> Subject: Re: [U-Boot] [PATCH] OMAP3EVM: Added NAND support
> 
> On Wed, Nov 18, 2009 at 12:58 AM,  <hvaibhav@ti.com> wrote:
> > From: Vaibhav Hiremath <hvaibhav@ti.com>
> >
> > User can now choose between NAND and ONENAND support in
> omap3_evm.h
> >
> > Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
> > ---
> > ?include/configs/omap3_evm.h | ? 27 ++++++++++++++++++++++++++-
> > ?1 files changed, 26 insertions(+), 1 deletions(-)
> >
> > diff --git a/include/configs/omap3_evm.h
> b/include/configs/omap3_evm.h
> > index a5514ae..3434306 100644
> > --- a/include/configs/omap3_evm.h
> > +++ b/include/configs/omap3_evm.h
> > @@ -110,7 +110,8 @@
> >
> > ?#define CONFIG_CMD_I2C ? ? ? ? /* I2C serial bus support ? ? ? */
> > ?#define CONFIG_CMD_MMC ? ? ? ? /* MMC support ? ? ? ? ? ? ? ? ?*/
> > -#define CONFIG_CMD_ONENAND ? ? /* ONENAND support ? ? ? ? ? ? ?*/
> > +/*#define CONFIG_CMD_ONENAND*/ /* ONENAND support ? ? ? ? ? ? ?*/
> do you wish to use #undef instead of commented code? also adding a
> comment on top saying this is an option might help..
> 
[Hiremath, Vaibhav] Good point, I will add this.

> This patch opens up a chain for me: how do we have the same build of
> u-boot boot accross nand, onenand, mmc  type devices?
> current  u-boot looks constrainted in that respect.
> 
[Hiremath, Vaibhav] Atleast for NAND and MMC we are using same build for obvious reasons, but I am not sure about onenand though. I need to look at it.

> > +#define CONFIG_CMD_NAND ? ? ? ? ? ? ? ?/* NAND support
> ? ? ? */
> > ?#define CONFIG_CMD_DHCP
> > ?#define CONFIG_CMD_PING
> >
> > @@ -141,6 +142,7 @@
> > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?/* to
> access */
> > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?/* nand at
> CS0 */
> >
> > +
> > ?#define CONFIG_SYS_MAX_NAND_DEVICE ? ? 1 ? ? ? ? ? ? ? /* Max
> number of */
> > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?/* NAND
> devices */
> > ?#define CONFIG_SYS_64BIT_VSPRINTF ? ? ? ? ? ? ?/* needed for
> nand_util.c */
> > @@ -268,7 +270,13 @@
> > ?#define CONFIG_SYS_MONITOR_BASE
> ?CONFIG_SYS_FLASH_BASE
> > ?#define CONFIG_SYS_ONENAND_BASE ? ? ? ? ? ? ? ?ONENAND_MAP
> >
> > +#if defined(CONFIG_CMD_NAND)
> > +#define CONFIG_NAND_OMAP_GPMC
> > +#define GPMC_NAND_ECC_LP_x16_LAYOUT ? ?1
> > +#define CONFIG_ENV_IS_IN_NAND ? ? ? ? ?1
> > +#elif defined(CONFIG_CMD_ONENAND)
> > ?#define CONFIG_ENV_IS_IN_ONENAND ? ? ? 1
> > +#endif
> 
> what if a user decided to enable NAND and ONENAND?
> 
> > ?#define ONENAND_ENV_OFFSET ? ? ? ? ? ? 0x260000 /* environment
> starts here */
> > ?#define SMNAND_ENV_OFFSET ? ? ? ? ? ? ?0x260000 /* environment
> starts here */
> >
> > @@ -300,6 +308,23 @@ extern unsigned int boot_flash_sec;
> > ?extern unsigned int boot_flash_type;
> > ?#endif
> >
> > +
> > +#define WRITE_NAND_COMMAND(d, adr)\
> > + ? ? ? ? ? ? ? ? ? ? ? writel(d, &nand_cs_base->nand_cmd)
> writel? i thought u had 16 bit nand device.
> 
> > +#define WRITE_NAND_ADDRESS(d, adr)\
> > + ? ? ? ? ? ? ? ? ? ? ? writel(d, &nand_cs_base->nand_adr)
> > +#define WRITE_NAND(d, adr) writew(d, &nand_cs_base->nand_dat)
> > +#define READ_NAND(adr) readl(&nand_cs_base->nand_dat)
> readl?? should'nt you be using readw?
> 
> Why these functions? does'nt mtd layer handle this? look at beagle -
> >
> it does not use that..
> 
> > +
> > +/* Other NAND Access APIs */
> > +#define NAND_WP_OFF() do {readl(&gpmc_cfg_base->config) |=
> GPMC_CONFIG_WP; } \
> > + ? ? ? ? ? ? ? ? ? ? ? while (0)
> > +#define NAND_WP_ON() do {readl(&gpmc_cfg_base->config) &=
> ~GPMC_CONFIG_WP; } \
> > + ? ? ? ? ? ? ? ? ? ? ? while (0)
> > +#define NAND_DISABLE_CE(nand)
> > +#define NAND_ENABLE_CE(nand)
> > +#define NAND_WAIT_READY(nand) ?udelay(10)
> > +
> are these really needed?
[Hiremath, Vaibhav] Nishant, you are looking at old patchset which I sent by mistake. Please review new V3 version of patch.

Thanks,
Vaibhav

> 
> > ?/*---------------------------------------------------------------
> -------------
> > ?* SMSC9115 Ethernet from SMSC9118 family
> > ?*----------------------------------------------------------------
> ------------
> > --
> > 1.6.2.4
> >
> > _______________________________________________
> > U-Boot mailing list
> > U-Boot at lists.denx.de
> > http://lists.denx.de/mailman/listinfo/u-boot
> >

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [U-Boot] [PATCH V4] OMAP3EVM: Added NAND support
@ 2009-11-23 11:05 ` hvaibhav at ti.com
  2009-11-27 15:51   ` Tom
  0 siblings, 1 reply; 263+ messages in thread
From: hvaibhav at ti.com @ 2009-11-23 11:05 UTC (permalink / raw)
  To: u-boot

From: Vaibhav Hiremath <hvaibhav@ti.com>

The EVMS have been shipping with NAND (instead of OneNAND) as default. So, this
patch sets NAND as default.

To choose OneNAND, define CMD_ONENAND instead of CMD_NAND in the config file
omap3_evm.h

Changes from V3 :-
	- Added undef statement for CMD_ONENAND.

Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
---
 include/configs/omap3_evm.h |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/include/configs/omap3_evm.h b/include/configs/omap3_evm.h
index 6709edc..36cb5e0 100644
--- a/include/configs/omap3_evm.h
+++ b/include/configs/omap3_evm.h
@@ -113,7 +113,8 @@

 #define CONFIG_CMD_I2C		/* I2C serial bus support	*/
 #define CONFIG_CMD_MMC		/* MMC support			*/
-#define CONFIG_CMD_ONENAND	/* ONENAND support		*/
+#undef CONFIG_CMD_ONENAND	/* ONENAND support		*/
+#define CONFIG_CMD_NAND		/* NAND support			*/
 #define CONFIG_CMD_DHCP
 #define CONFIG_CMD_PING

@@ -271,7 +272,13 @@
 #define CONFIG_SYS_MONITOR_BASE		CONFIG_SYS_FLASH_BASE
 #define CONFIG_SYS_ONENAND_BASE		ONENAND_MAP

+#if defined(CONFIG_CMD_NAND)
+#define CONFIG_NAND_OMAP_GPMC
+#define GPMC_NAND_ECC_LP_x16_LAYOUT	1
+#define CONFIG_ENV_IS_IN_NAND		1
+#elif defined(CONFIG_CMD_ONENAND)
 #define CONFIG_ENV_IS_IN_ONENAND	1
+#endif
 #define ONENAND_ENV_OFFSET		0x260000 /* environment starts here */
 #define SMNAND_ENV_OFFSET		0x260000 /* environment starts here */

--
1.6.2.4

^ permalink raw reply related	[flat|nested] 263+ messages in thread

* [U-Boot] [PATCH] omap3_mmc: Encapsulate twl4030 under option CONFIG_TWL4030_POWER
@ 2009-11-23 11:06 ` hvaibhav at ti.com
  2009-11-27 14:03   ` Tom
  0 siblings, 1 reply; 263+ messages in thread
From: hvaibhav at ti.com @ 2009-11-23 11:06 UTC (permalink / raw)
  To: u-boot

From: Vaibhav Hiremath <hvaibhav@ti.com>

Fixes the build/compilation error if we try to re-use the omap3_mmc code
without TWL4030_POWER.

Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
---
 drivers/mmc/omap3_mmc.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/drivers/mmc/omap3_mmc.c b/drivers/mmc/omap3_mmc.c
index 513dd25..96c0e65 100644
--- a/drivers/mmc/omap3_mmc.c
+++ b/drivers/mmc/omap3_mmc.c
@@ -63,7 +63,9 @@ unsigned char mmc_board_init(void)
 {
 	t2_t *t2_base = (t2_t *)T2_BASE;

+#if defined(CONFIG_TWL4030_POWER)
 	twl4030_power_mmc_init();
+#endif

 	writel(readl(&t2_base->pbias_lite) | PBIASLITEPWRDNZ1 |
 		PBIASSPEEDCTRL0 | PBIASLITEPWRDNZ0,
--
1.6.2.4

^ permalink raw reply related	[flat|nested] 263+ messages in thread

* [U-Boot] [PATCH 1/5] Introducing AM3517EVM support
@ 2009-11-23 11:06 ` hvaibhav at ti.com
  2009-11-23 19:43   ` Wolfgang Denk
  0 siblings, 1 reply; 263+ messages in thread
From: hvaibhav at ti.com @ 2009-11-23 11:06 UTC (permalink / raw)
  To: u-boot

From: Vaibhav Hiremath <hvaibhav@ti.com>

Changes:-
	- Added board specific directory under board/ti/am3517/
	- Basic board support.

Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
---
 board/ti/am3517evm/Makefile      |   46 +++++
 board/ti/am3517evm/am3517evm.c   |   76 ++++++++
 board/ti/am3517evm/am3517evm.h   |  388 ++++++++++++++++++++++++++++++++++++++
 board/ti/am3517evm/config.mk     |   29 +++
 include/asm-arm/arch-omap3/mem.h |   10 +
 5 files changed, 549 insertions(+), 0 deletions(-)
 create mode 100644 board/ti/am3517evm/Makefile
 create mode 100644 board/ti/am3517evm/am3517evm.c
 create mode 100644 board/ti/am3517evm/am3517evm.h
 create mode 100644 board/ti/am3517evm/config.mk

diff --git a/board/ti/am3517evm/Makefile b/board/ti/am3517evm/Makefile
new file mode 100644
index 0000000..68fb574
--- /dev/null
+++ b/board/ti/am3517evm/Makefile
@@ -0,0 +1,46 @@
+#
+# Author: Vaibhav Hiremath <hvaibhav@ti.com>
+#
+# Derived from evm code
+#
+# 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; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+#
+
+include $(TOPDIR)/config.mk
+
+LIB	= $(obj)lib$(BOARD).a
+
+COBJS	:= am3517evm.o
+
+SRCS	:= $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
+	$(AR) $(ARFLAGS) $@ $(OBJS)
+
+clean:
+	rm -f $(OBJS)
+
+distclean:	clean
+	rm -f $(LIB) core *.bak $(obj).depend
+
+#########################################################################
+
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
+
+sinclude $(obj).depend
diff --git a/board/ti/am3517evm/am3517evm.c b/board/ti/am3517evm/am3517evm.c
new file mode 100644
index 0000000..0b6b5a4
--- /dev/null
+++ b/board/ti/am3517evm/am3517evm.c
@@ -0,0 +1,76 @@
+/*
+ * am3517evm.c - board file for TI's AM3517 family of devices.
+ *
+ * Author: Vaibhav Hiremath <hvaibhav@ti.com>
+ *
+ * Derived from evm code
+ *
+ * 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <common.h>
+#include <asm/io.h>
+#include <asm/arch/mem.h>
+#include <asm/arch/mux.h>
+#include <asm/arch/sys_proto.h>
+#include <i2c.h>
+#include <asm/mach-types.h>
+#include "am3517evm.h"
+
+/*
+ * Routine: board_init
+ * Description: Early hardware init.
+ */
+int board_init(void)
+{
+	DECLARE_GLOBAL_DATA_PTR;
+
+	gpmc_init(); /* in SRAM or SDRAM, finish GPMC */
+	/* board id for Linux */
+	gd->bd->bi_arch_number = MACH_TYPE_OMAP3517EVM;
+	/* boot param addr */
+	gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100);
+
+	return 0;
+}
+
+/*
+ * Routine: misc_init_r
+ * Description: Init ethernet (done here so udelay works)
+ */
+int misc_init_r(void)
+{
+
+#ifdef CONFIG_DRIVER_OMAP34XX_I2C
+	i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
+#endif
+
+	dieid_num_r();
+
+	return 0;
+}
+
+/*
+ * Routine: set_muxconf_regs
+ * Description: Setting up the configuration Mux registers specific to the
+ *		hardware. Many pins need to be moved from protect to primary
+ *		mode.
+ */
+void set_muxconf_regs(void)
+{
+	MUX_AM3517EVM();
+}
diff --git a/board/ti/am3517evm/am3517evm.h b/board/ti/am3517evm/am3517evm.h
new file mode 100644
index 0000000..7897912
--- /dev/null
+++ b/board/ti/am3517evm/am3517evm.h
@@ -0,0 +1,388 @@
+/*
+ * am3517evm.h - board header file for TI's AM3517 family of devices.
+ *
+ * Author: Vaibhav Hiremath <hvaibhav@ti.com>
+ *
+ * Derived from evm code
+ *
+ * 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#ifndef _AM3517EVM_H_
+#define _AM3517EVM_H_
+
+const omap3_sysinfo sysinfo = {
+	DDR_DISCRETE,
+	"am3517evm board",
+	"NAND",
+};
+
+/*
+ * IEN  - Input Enable
+ * IDIS - Input Disable
+ * PTD  - Pull type Down
+ * PTU  - Pull type Up
+ * DIS  - Pull type selection is inactive
+ * EN   - Pull type selection is active
+ * M0   - Mode 0
+ * The commented string gives the final mux configuration for that pin
+ */
+#define MUX_AM3517EVM() \
+ /*SDRC*/\
+ MUX_VAL(CP(SDRC_D0),		(IEN  | PTD | DIS | M0)) /*SDRC_D0*/\
+ MUX_VAL(CP(SDRC_D1),		(IEN  | PTD | DIS | M0)) /*SDRC_D1*/\
+ MUX_VAL(CP(SDRC_D2),		(IEN  | PTD | DIS | M0)) /*SDRC_D2*/\
+ MUX_VAL(CP(SDRC_D3),		(IEN  | PTD | DIS | M0)) /*SDRC_D3*/\
+ MUX_VAL(CP(SDRC_D4),		(IEN  | PTD | DIS | M0)) /*SDRC_D4*/\
+ MUX_VAL(CP(SDRC_D5),		(IEN  | PTD | DIS | M0)) /*SDRC_D5*/\
+ MUX_VAL(CP(SDRC_D6),		(IEN  | PTD | DIS | M0)) /*SDRC_D6*/\
+ MUX_VAL(CP(SDRC_D7),		(IEN  | PTD | DIS | M0)) /*SDRC_D7*/\
+ MUX_VAL(CP(SDRC_D8),		(IEN  | PTD | DIS | M0)) /*SDRC_D8*/\
+ MUX_VAL(CP(SDRC_D9),		(IEN  | PTD | DIS | M0)) /*SDRC_D9*/\
+ MUX_VAL(CP(SDRC_D10),		(IEN  | PTD | DIS | M0)) /*SDRC_D10*/\
+ MUX_VAL(CP(SDRC_D11),		(IEN  | PTD | DIS | M0)) /*SDRC_D11*/\
+ MUX_VAL(CP(SDRC_D12),		(IEN  | PTD | DIS | M0)) /*SDRC_D12*/\
+ MUX_VAL(CP(SDRC_D13),		(IEN  | PTD | DIS | M0)) /*SDRC_D13*/\
+ MUX_VAL(CP(SDRC_D14),		(IEN  | PTD | DIS | M0)) /*SDRC_D14*/\
+ MUX_VAL(CP(SDRC_D15),		(IEN  | PTD | DIS | M0)) /*SDRC_D15*/\
+ MUX_VAL(CP(SDRC_D16),		(IEN  | PTD | DIS | M0)) /*SDRC_D16*/\
+ MUX_VAL(CP(SDRC_D17),		(IEN  | PTD | DIS | M0)) /*SDRC_D17*/\
+ MUX_VAL(CP(SDRC_D18),		(IEN  | PTD | DIS | M0)) /*SDRC_D18*/\
+ MUX_VAL(CP(SDRC_D19),		(IEN  | PTD | DIS | M0)) /*SDRC_D19*/\
+ MUX_VAL(CP(SDRC_D20),		(IEN  | PTD | DIS | M0)) /*SDRC_D20*/\
+ MUX_VAL(CP(SDRC_D21),		(IEN  | PTD | DIS | M0)) /*SDRC_D21*/\
+ MUX_VAL(CP(SDRC_D22),		(IEN  | PTD | DIS | M0)) /*SDRC_D22*/\
+ MUX_VAL(CP(SDRC_D23),		(IEN  | PTD | DIS | M0)) /*SDRC_D23*/\
+ MUX_VAL(CP(SDRC_D24),		(IEN  | PTD | DIS | M0)) /*SDRC_D24*/\
+ MUX_VAL(CP(SDRC_D25),		(IEN  | PTD | DIS | M0)) /*SDRC_D25*/\
+ MUX_VAL(CP(SDRC_D26),		(IEN  | PTD | DIS | M0)) /*SDRC_D26*/\
+ MUX_VAL(CP(SDRC_D27),		(IEN  | PTD | DIS | M0)) /*SDRC_D27*/\
+ MUX_VAL(CP(SDRC_D28),		(IEN  | PTD | DIS | M0)) /*SDRC_D28*/\
+ MUX_VAL(CP(SDRC_D29),		(IEN  | PTD | DIS | M0)) /*SDRC_D29*/\
+ MUX_VAL(CP(SDRC_D30),		(IEN  | PTD | DIS | M0)) /*SDRC_D30*/\
+ MUX_VAL(CP(SDRC_D31),		(IEN  | PTD | DIS | M0)) /*SDRC_D31*/\
+ MUX_VAL(CP(SDRC_CLK),		(IEN  | PTD | DIS | M0)) /*SDRC_CLK*/\
+ MUX_VAL(CP(SDRC_DQS0),		(IEN  | PTD | DIS | M0)) /*SDRC_DQS0*/\
+ MUX_VAL(CP(SDRC_DQS1),		(IEN  | PTD | DIS | M0)) /*SDRC_DQS1*/\
+ MUX_VAL(CP(SDRC_DQS2),		(IEN  | PTD | DIS | M0)) /*SDRC_DQS2*/\
+ MUX_VAL(CP(SDRC_DQS3),		(IEN  | PTD | DIS | M0)) /*SDRC_DQS3*/\
+ /*GPMC*/\
+ MUX_VAL(CP(GPMC_A1),		(IDIS | PTU | EN  | M0)) /*GPMC_A1*/\
+ MUX_VAL(CP(GPMC_A2),		(IDIS | PTU | EN  | M0)) /*GPMC_A2*/\
+ MUX_VAL(CP(GPMC_A3),		(IDIS | PTU | EN  | M0)) /*GPMC_A3*/\
+ MUX_VAL(CP(GPMC_A4),		(IDIS | PTU | EN  | M0)) /*GPMC_A4*/\
+ MUX_VAL(CP(GPMC_A5),		(IDIS | PTU | EN  | M0)) /*GPMC_A5*/\
+ MUX_VAL(CP(GPMC_A6),		(IDIS | PTU | EN  | M0)) /*GPMC_A6*/\
+ MUX_VAL(CP(GPMC_A7),		(IDIS | PTU | EN  | M0)) /*GPMC_A7*/\
+ MUX_VAL(CP(GPMC_A8),		(IDIS | PTU | EN  | M0)) /*GPMC_A8*/\
+ MUX_VAL(CP(GPMC_A9),		(IDIS | PTU | EN  | M0)) /*GPMC_A9*/\
+ MUX_VAL(CP(GPMC_A10),		(IDIS | PTU | EN  | M0)) /*GPMC_A10*/\
+ MUX_VAL(CP(GPMC_D0),		(IEN  | PTU | EN  | M0)) /*GPMC_D0*/\
+ MUX_VAL(CP(GPMC_D1),		(IEN  | PTU | EN  | M0)) /*GPMC_D1*/\
+ MUX_VAL(CP(GPMC_D2),		(IEN  | PTU | EN  | M0)) /*GPMC_D2*/\
+ MUX_VAL(CP(GPMC_D3),		(IEN  | PTU | EN  | M0)) /*GPMC_D3*/\
+ MUX_VAL(CP(GPMC_D4),		(IEN  | PTU | EN  | M0)) /*GPMC_D4*/\
+ MUX_VAL(CP(GPMC_D5),		(IEN  | PTU | EN  | M0)) /*GPMC_D5*/\
+ MUX_VAL(CP(GPMC_D6),		(IEN  | PTU | EN  | M0)) /*GPMC_D6*/\
+ MUX_VAL(CP(GPMC_D7),		(IEN  | PTU | EN  | M0)) /*GPMC_D7*/\
+ MUX_VAL(CP(GPMC_D8),		(IEN  | PTU | EN  | M0)) /*GPMC_D8*/\
+ MUX_VAL(CP(GPMC_D9),		(IEN  | PTU | EN  | M0)) /*GPMC_D9*/\
+ MUX_VAL(CP(GPMC_D10),		(IEN  | PTU | EN  | M0)) /*GPMC_D10*/\
+ MUX_VAL(CP(GPMC_D11),		(IEN  | PTU | EN  | M0)) /*GPMC_D11*/\
+ MUX_VAL(CP(GPMC_D12),		(IEN  | PTU | EN  | M0)) /*GPMC_D12*/\
+ MUX_VAL(CP(GPMC_D13),		(IEN  | PTU | EN  | M0)) /*GPMC_D13*/\
+ MUX_VAL(CP(GPMC_D14),		(IEN  | PTU | EN  | M0)) /*GPMC_D14*/\
+ MUX_VAL(CP(GPMC_D15),		(IEN  | PTU | EN  | M0)) /*GPMC_D15*/\
+ MUX_VAL(CP(GPMC_NCS0),		(IDIS | PTU | EN  | M0)) /*GPMC_nCS0*/\
+ MUX_VAL(CP(GPMC_NCS1),		(IDIS | PTU | EN  | M0)) /*GPMC_nCS1*/\
+ MUX_VAL(CP(GPMC_NCS2),		(IDIS | PTU | EN  | M0)) /*GPMC_nCS2*/\
+ MUX_VAL(CP(GPMC_NCS3),		(IDIS | PTU | EN  | M0)) /*GPMC_nCS3*/\
+ MUX_VAL(CP(GPMC_NCS4),		(IEN  | PTU | EN  | M0)) /*GPMC_nCS4*/\
+ MUX_VAL(CP(GPMC_NCS5),		(IDIS | PTU | EN  | M0)) /*GPMC_nCS5*/\
+ MUX_VAL(CP(GPMC_NCS6),		(IEN  | PTD | DIS | M0)) /*GPMC_nCS6*/\
+ MUX_VAL(CP(GPMC_NCS7),		(IEN  | PTU | EN  | M0)) /*GPMC_nCS7*/\
+ MUX_VAL(CP(GPMC_CLK),		(IDIS | PTU | EN  | M0)) /*GPMC_CLK*/\
+ MUX_VAL(CP(GPMC_NADV_ALE),	(IDIS | PTD | DIS | M0)) /*GPMC_nADV_ALE*/\
+ MUX_VAL(CP(GPMC_NOE),		(IDIS | PTD | DIS | M0)) /*GPMC_nOE*/\
+ MUX_VAL(CP(GPMC_NWE),		(IDIS | PTD | DIS | M0)) /*GPMC_nWE*/\
+ MUX_VAL(CP(GPMC_NBE0_CLE),	(IDIS | PTU | EN  | M0)) /*GPMC_nBE0_CLE*/\
+ MUX_VAL(CP(GPMC_NBE1),		(IEN  | PTU | EN  | M0)) /*GPMC_nBE1*/\
+ MUX_VAL(CP(GPMC_NWP),		(IEN  | PTD | DIS | M0)) /*GPMC_nWP*/\
+ MUX_VAL(CP(GPMC_WAIT0),	(IEN  | PTU | EN  | M0)) /*GPMC_WAIT0*/\
+ MUX_VAL(CP(GPMC_WAIT1),	(IEN  | PTU | EN  | M0)) /*GPMC_WAIT1*/\
+ MUX_VAL(CP(GPMC_WAIT2),	(IEN  | PTU | EN  | M4)) /*GPIO_64*/\
+							 /* - ETH_nRESET*/\
+ MUX_VAL(CP(GPMC_WAIT3),	(IEN  | PTU | EN  | M0)) /*GPMC_WAIT3*/\
+ /*DSS*/\
+ MUX_VAL(CP(DSS_PCLK),		(IDIS | PTD | DIS | M0)) /*DSS_PCLK*/\
+ MUX_VAL(CP(DSS_HSYNC),		(IDIS | PTD | DIS | M0)) /*DSS_HSYNC*/\
+ MUX_VAL(CP(DSS_VSYNC),		(IDIS | PTD | DIS | M0)) /*DSS_VSYNC*/\
+ MUX_VAL(CP(DSS_ACBIAS),		(IDIS | PTD | DIS | M0)) /*DSS_ACBIAS*/\
+ MUX_VAL(CP(DSS_DATA0),		(IDIS | PTD | DIS | M0)) /*DSS_DATA0*/\
+ MUX_VAL(CP(DSS_DATA1),		(IDIS | PTD | DIS | M0)) /*DSS_DATA1*/\
+ MUX_VAL(CP(DSS_DATA2),		(IDIS | PTD | DIS | M0)) /*DSS_DATA2*/\
+ MUX_VAL(CP(DSS_DATA3),		(IDIS | PTD | DIS | M0)) /*DSS_DATA3*/\
+ MUX_VAL(CP(DSS_DATA4),		(IDIS | PTD | DIS | M0)) /*DSS_DATA4*/\
+ MUX_VAL(CP(DSS_DATA5),		(IDIS | PTD | DIS | M0)) /*DSS_DATA5*/\
+ MUX_VAL(CP(DSS_DATA6),		(IDIS | PTD | DIS | M0)) /*DSS_DATA6*/\
+ MUX_VAL(CP(DSS_DATA7),		(IDIS | PTD | DIS | M0)) /*DSS_DATA7*/\
+ MUX_VAL(CP(DSS_DATA8),		(IDIS | PTD | DIS | M0)) /*DSS_DATA8*/\
+ MUX_VAL(CP(DSS_DATA9),		(IDIS | PTD | DIS | M0)) /*DSS_DATA9*/\
+ MUX_VAL(CP(DSS_DATA10),	(IDIS | PTD | DIS | M0)) /*DSS_DATA10*/\
+ MUX_VAL(CP(DSS_DATA11),	(IDIS | PTD | DIS | M0)) /*DSS_DATA11*/\
+ MUX_VAL(CP(DSS_DATA12),	(IDIS | PTD | DIS | M0)) /*DSS_DATA12*/\
+ MUX_VAL(CP(DSS_DATA13),	(IDIS | PTD | DIS | M0)) /*DSS_DATA13*/\
+ MUX_VAL(CP(DSS_DATA14),	(IDIS | PTD | DIS | M0)) /*DSS_DATA14*/\
+ MUX_VAL(CP(DSS_DATA15),	(IDIS | PTD | DIS | M0)) /*DSS_DATA15*/\
+ MUX_VAL(CP(DSS_DATA16),	(IDIS | PTD | DIS | M0)) /*DSS_DATA16*/\
+ MUX_VAL(CP(DSS_DATA17),	(IDIS | PTD | DIS | M0)) /*DSS_DATA17*/\
+ MUX_VAL(CP(DSS_DATA18),	(IDIS | PTD | DIS | M0)) /*DSS_DATA18*/\
+ MUX_VAL(CP(DSS_DATA19),	(IDIS | PTD | DIS | M0)) /*DSS_DATA19*/\
+ MUX_VAL(CP(DSS_DATA20),	(IDIS | PTD | DIS | M0)) /*DSS_DATA20*/\
+ MUX_VAL(CP(DSS_DATA21),	(IDIS | PTD | DIS | M0)) /*DSS_DATA21*/\
+ MUX_VAL(CP(DSS_DATA22),	(IDIS | PTD | DIS | M0)) /*DSS_DATA22*/\
+ MUX_VAL(CP(DSS_DATA23),	(IDIS | PTD | DIS | M0)) /*DSS_DATA23*/\
+ /*CAMERA*/\
+ MUX_VAL(CP(CAM_HS),		(IEN  | PTU | EN  | M0)) /*CAM_HS */\
+ MUX_VAL(CP(CAM_VS),		(IEN  | PTU | EN  | M0)) /*CAM_VS */\
+ MUX_VAL(CP(CAM_XCLKA),		(IDIS | PTD | DIS | M0)) /*CAM_XCLKA*/\
+ MUX_VAL(CP(CAM_PCLK),		(IEN  | PTU | EN  | M0)) /*CAM_PCLK*/\
+ MUX_VAL(CP(CAM_FLD),		(IDIS | PTD | DIS | M4)) /*GPIO_98*/\
+							 /* - CAM_RESET*/\
+ MUX_VAL(CP(CAM_D0),		(IEN  | PTD | DIS | M0)) /*CAM_D0*/\
+ MUX_VAL(CP(CAM_D1),		(IEN  | PTD | DIS | M0)) /*CAM_D1*/\
+ MUX_VAL(CP(CAM_D2),		(IEN  | PTD | DIS | M0)) /*CAM_D2*/\
+ MUX_VAL(CP(CAM_D3),		(IEN  | PTD | DIS | M0)) /*CAM_D3*/\
+ MUX_VAL(CP(CAM_D4),		(IEN  | PTD | DIS | M0)) /*CAM_D4*/\
+ MUX_VAL(CP(CAM_D5),		(IEN  | PTD | DIS | M0)) /*CAM_D5*/\
+ MUX_VAL(CP(CAM_D6),		(IEN  | PTD | DIS | M0)) /*CAM_D6*/\
+ MUX_VAL(CP(CAM_D7),		(IEN  | PTD | DIS | M0)) /*CAM_D7*/\
+ MUX_VAL(CP(CAM_D8),		(IEN  | PTD | DIS | M0)) /*CAM_D8*/\
+ MUX_VAL(CP(CAM_D9),		(IEN  | PTD | DIS | M0)) /*CAM_D9*/\
+ MUX_VAL(CP(CAM_D10),		(IEN  | PTD | DIS | M0)) /*CAM_D10*/\
+ MUX_VAL(CP(CAM_D11),		(IEN  | PTD | DIS | M0)) /*CAM_D11*/\
+ MUX_VAL(CP(CAM_XCLKB),		(IDIS | PTD | DIS | M0)) /*CAM_XCLKB*/\
+ MUX_VAL(CP(CAM_WEN),		(IEN  | PTD | DIS | M4)) /*GPIO_167*/\
+ MUX_VAL(CP(CAM_STROBE),	(IDIS | PTD | DIS | M0)) /*CAM_STROBE*/\
+ MUX_VAL(CP(CSI2_DX0),		(IEN  | PTD | DIS | M0)) /*CSI2_DX0*/\
+ MUX_VAL(CP(CSI2_DY0),		(IEN  | PTD | DIS | M0)) /*CSI2_DY0*/\
+ MUX_VAL(CP(CSI2_DX1),		(IEN  | PTD | DIS | M0)) /*CSI2_DX1*/\
+ MUX_VAL(CP(CSI2_DY1),		(IEN  | PTD | DIS | M0)) /*CSI2_DY1*/\
+ /*Audio Interface */\
+ MUX_VAL(CP(MCBSP2_FSX),	(IEN  | PTD | DIS | M0)) /*McBSP2_FSX*/\
+ MUX_VAL(CP(MCBSP2_CLKX),	(IEN  | PTD | DIS | M0)) /*McBSP2_CLKX*/\
+ MUX_VAL(CP(MCBSP2_DR),		(IEN  | PTD | DIS | M0)) /*McBSP2_DR*/\
+ MUX_VAL(CP(MCBSP2_DX),		(IDIS | PTD | DIS | M0)) /*McBSP2_DX*/\
+ /*Expansion card  */\
+ MUX_VAL(CP(MMC1_CLK),		(IEN  | PTU | EN  | M0)) /*MMC1_CLK*/\
+ MUX_VAL(CP(MMC1_CMD),		(IEN  | PTU | DIS | M0)) /*MMC1_CMD*/\
+ MUX_VAL(CP(MMC1_DAT0),		(IEN  | PTU | DIS | M0)) /*MMC1_DAT0*/\
+ MUX_VAL(CP(MMC1_DAT1),		(IEN  | PTU | DIS | M0)) /*MMC1_DAT1*/\
+ MUX_VAL(CP(MMC1_DAT2),		(IEN  | PTU | DIS | M0)) /*MMC1_DAT2*/\
+ MUX_VAL(CP(MMC1_DAT3),		(IEN  | PTU | DIS | M0)) /*MMC1_DAT3*/\
+ MUX_VAL(CP(MMC1_DAT4),		(IEN  | PTU | EN  | M4)) /*MMC1_DAT4,\
+							   WriteProtect*/\
+ MUX_VAL(CP(MMC1_DAT5),		(IEN  | PTU | EN  | M4)) /*MMC1_DAT5,\
+							   CardDetect*/\
+ MUX_VAL(CP(MMC1_DAT6),		(IEN  | PTU | EN | M4)) /*MMC1_DAT6*/\
+ MUX_VAL(CP(MMC1_DAT7),		(IEN  | PTU | EN | M4)) /*MMC1_DAT7*/\
+ /*Wireless LAN */\
+ MUX_VAL(CP(MMC2_CLK),		(IEN  | PTD | EN | M0)) /*MMC2_CLK*/\
+ MUX_VAL(CP(MMC2_CMD),		(IEN  | PTD | DIS | M0)) /*MMC2_CMD*/\
+ MUX_VAL(CP(MMC2_DAT0),		(IEN  | PTD | DIS | M0)) /*MMC2_DAT0*/\
+ MUX_VAL(CP(MMC2_DAT1),		(IEN  | PTD | DIS | M0)) /*MMC2_DAT1*/\
+ MUX_VAL(CP(MMC2_DAT2),		(IEN  | PTD | DIS | M0)) /*MMC2_DAT2*/\
+ MUX_VAL(CP(MMC2_DAT3),		(IEN  | PTD | DIS | M0)) /*MMC2_DAT3*/\
+ /*Bluetooth*/\
+ MUX_VAL(CP(MCBSP3_DX),		(IDIS | PTD | DIS | M0)) /*McBSP3_DX*/\
+ MUX_VAL(CP(MCBSP3_DR),		(IEN  | PTD | DIS | M0)) /*McBSP3_DR*/\
+ MUX_VAL(CP(MCBSP3_CLKX),	(IEN  | PTD | DIS | M0)) /*McBSP3_CLKX  */\
+ MUX_VAL(CP(MCBSP3_FSX),	(IEN  | PTD | DIS | M0)) /*McBSP3_FSX*/\
+ MUX_VAL(CP(UART2_CTS),		(IEN  | PTU | EN  | M0)) /*UART2_CTS*/\
+ MUX_VAL(CP(UART2_RTS),		(IDIS | PTD | DIS | M0)) /*UART2_RTS*/\
+ MUX_VAL(CP(UART2_TX),		(IDIS | PTD | DIS | M0)) /*UART2_TX*/\
+ MUX_VAL(CP(UART2_RX),		(IEN  | PTD | DIS | M0)) /*UART2_RX*/\
+ /*Modem Interface */\
+ MUX_VAL(CP(UART1_TX),		(IDIS | PTD | DIS | M0)) /*UART1_TX*/\
+ MUX_VAL(CP(UART1_RTS),		(IDIS | PTD | DIS | M0)) /*UART1_RTS*/\
+ MUX_VAL(CP(UART1_CTS),		(IEN  | PTU | DIS | M0)) /*UART1_CTS*/\
+ MUX_VAL(CP(UART1_RX),		(IEN  | PTD | DIS | M0)) /*UART1_RX*/\
+ MUX_VAL(CP(MCBSP4_CLKX),	(IDIS | PTD | DIS | M4)) /*GPIO_152*/\
+							 /* - LCD_INI*/\
+ MUX_VAL(CP(MCBSP4_DR),		(IDIS | PTD | DIS | M4)) /*GPIO_153*/\
+							 /* - LCD_ENVDD */\
+ MUX_VAL(CP(MCBSP4_DX),		(IDIS | PTD | DIS | M4)) /*GPIO_154*/\
+							 /* - LCD_QVGA/nVGA */\
+ MUX_VAL(CP(MCBSP4_FSX),	(IDIS | PTD | DIS | M4)) /*GPIO_155*/\
+							 /* - LCD_RESB */\
+ MUX_VAL(CP(MCBSP1_CLKR),	(IEN  | PTD | DIS | M0)) /*MCBSP1_CLKR  */\
+ MUX_VAL(CP(MCBSP1_FSR),	(IDIS | PTU | EN  | M0)) /*MCBSP1_FSR*/\
+ MUX_VAL(CP(MCBSP1_DX),		(IDIS | PTD | DIS | M0)) /*MCBSP1_DX*/\
+ MUX_VAL(CP(MCBSP1_DR),		(IEN  | PTD | DIS | M0)) /*MCBSP1_DR*/\
+ MUX_VAL(CP(MCBSP_CLKS),	(IEN  | PTU | DIS | M0)) /*MCBSP_CLKS  */\
+ MUX_VAL(CP(MCBSP1_FSX),	(IEN  | PTD | DIS | M0)) /*MCBSP1_FSX*/\
+ MUX_VAL(CP(MCBSP1_CLKX),	(IEN  | PTD | DIS | M0)) /*MCBSP1_CLKX  */\
+ /*Serial Interface*/\
+ MUX_VAL(CP(UART3_CTS_RCTX),	(IEN  | PTU | DIS  | M0)) /*UART3_CTS_*/\
+							 /* RCTX*/\
+ MUX_VAL(CP(UART3_RTS_SD),	(IDIS | PTD | DIS | M0)) /*UART3_RTS_SD */\
+ MUX_VAL(CP(UART3_RX_IRRX),	(IEN  | PTD | DIS | M0)) /*UART3_RX_IRRX*/\
+ MUX_VAL(CP(UART3_TX_IRTX),	(IDIS | PTD | DIS | M0)) /*UART3_TX_IRTX*/\
+ MUX_VAL(CP(HSUSB0_CLK),	(IEN  | PTD | DIS | M0)) /*HSUSB0_CLK*/\
+ MUX_VAL(CP(HSUSB0_STP),	(IDIS | PTU | EN  | M0)) /*HSUSB0_STP*/\
+ MUX_VAL(CP(HSUSB0_DIR),	(IEN  | PTD | DIS | M0)) /*HSUSB0_DIR*/\
+ MUX_VAL(CP(HSUSB0_NXT),	(IEN  | PTD | DIS | M0)) /*HSUSB0_NXT*/\
+ MUX_VAL(CP(HSUSB0_DATA0),	(IEN  | PTD | DIS | M0)) /*HSUSB0_DATA0*/\
+ MUX_VAL(CP(HSUSB0_DATA1),	(IEN  | PTD | DIS | M0)) /*HSUSB0_DATA1*/\
+ MUX_VAL(CP(HSUSB0_DATA2),	(IEN  | PTD | DIS | M0)) /*HSUSB0_DATA2*/\
+ MUX_VAL(CP(HSUSB0_DATA3),	(IEN  | PTD | DIS | M0)) /*HSUSB0_DATA3*/\
+ MUX_VAL(CP(HSUSB0_DATA4),	(IEN  | PTD | DIS | M0)) /*HSUSB0_DATA4*/\
+ MUX_VAL(CP(HSUSB0_DATA5),	(IEN  | PTD | DIS | M0)) /*HSUSB0_DATA5*/\
+ MUX_VAL(CP(HSUSB0_DATA6),	(IEN  | PTD | DIS | M0)) /*HSUSB0_DATA6*/\
+ MUX_VAL(CP(HSUSB0_DATA7),	(IEN  | PTD | DIS | M0)) /*HSUSB0_DATA7*/\
+ MUX_VAL(CP(I2C1_SCL),		(IEN  | PTU | EN  | M0)) /*I2C1_SCL*/\
+ MUX_VAL(CP(I2C1_SDA),		(IEN  | PTU | EN  | M0)) /*I2C1_SDA*/\
+ MUX_VAL(CP(I2C2_SCL),		(IEN  | PTU | EN  | M0)) /*I2C2_SCL*/\
+ MUX_VAL(CP(I2C2_SDA),		(IEN  | PTU | EN  | M0)) /*I2C2_SDA*/\
+ MUX_VAL(CP(I2C3_SCL),		(IEN  | PTU | EN  | M0)) /*I2C3_SCL*/\
+ MUX_VAL(CP(I2C3_SDA),		(IEN  | PTU | EN  | M0)) /*I2C3_SDA*/\
+ MUX_VAL(CP(I2C4_SCL),		(IEN  | PTU | EN  | M0)) /*I2C4_SCL*/\
+ MUX_VAL(CP(I2C4_SDA),		(IEN  | PTU | EN  | M0)) /*I2C4_SDA*/\
+ MUX_VAL(CP(HDQ_SIO),		(IEN  | PTU | EN  | M0)) /*HDQ_SIO*/\
+ MUX_VAL(CP(MCSPI1_CLK),	(IEN  | PTD | DIS | M0)) /*McSPI1_CLK*/\
+ MUX_VAL(CP(MCSPI1_SIMO),	(IEN  | PTD | DIS | M0)) /*McSPI1_SIMO  */\
+ MUX_VAL(CP(MCSPI1_SOMI),	(IEN  | PTD | DIS | M0)) /*McSPI1_SOMI  */\
+ MUX_VAL(CP(MCSPI1_CS0),	(IEN  | PTD | EN  | M0)) /*McSPI1_CS0*/\
+ MUX_VAL(CP(MCSPI1_CS1),	(IEN  | PTD | EN  | M4)) /*GPIO_175*/\
+							 /* TS_PEN_IRQ */\
+ MUX_VAL(CP(MCSPI1_CS2),	(IEN  | PTU | DIS | M4)) /*GPIO_176*/\
+							 /* - LAN_INTR*/\
+ MUX_VAL(CP(MCSPI1_CS3),	(IEN  | PTD | EN  | M0)) /*McSPI1_CS3*/\
+ MUX_VAL(CP(MCSPI2_CLK),	(IEN  | PTD | DIS | M0)) /*McSPI2_CLK*/\
+ MUX_VAL(CP(MCSPI2_SIMO),	(IEN  | PTD | DIS | M0)) /*McSPI2_SIMO*/\
+ MUX_VAL(CP(MCSPI2_SOMI),	(IEN  | PTD | DIS | M0)) /*McSPI2_SOMI*/\
+ MUX_VAL(CP(MCSPI2_CS0),	(IEN  | PTD | EN  | M4)) /*McSPI2_CS0*/\
+ MUX_VAL(CP(MCSPI2_CS1),	(IEN  | PTD | EN  | M4)) /*McSPI2_CS1*/\
+ /*Control and debug */\
+ MUX_VAL(CP(SYS_32K),		(IEN  | PTD | DIS | M0)) /*SYS_32K*/\
+ MUX_VAL(CP(SYS_CLKREQ),	(IEN  | PTD | DIS | M0)) /*SYS_CLKREQ*/\
+ MUX_VAL(CP(SYS_NIRQ),		(IEN  | PTU | EN  | M0)) /*SYS_nIRQ*/\
+ MUX_VAL(CP(SYS_BOOT0),		(IEN  | PTD | DIS | M4)) /*GPIO_2*/\
+							 /* - PEN_IRQ */\
+ MUX_VAL(CP(SYS_BOOT1),		(IEN  | PTD | DIS | M4)) /*GPIO_3 */\
+ MUX_VAL(CP(SYS_BOOT2),		(IEN  | PTD | DIS | M4)) /*GPIO_4*/\
+ MUX_VAL(CP(SYS_BOOT3),		(IEN  | PTD | DIS | M4)) /*GPIO_5*/\
+ MUX_VAL(CP(SYS_BOOT4),		(IEN  | PTD | DIS | M4)) /*GPIO_6*/\
+ MUX_VAL(CP(SYS_BOOT5),		(IEN  | PTD | DIS | M4)) /*GPIO_7*/\
+ MUX_VAL(CP(SYS_BOOT6),		(IDIS | PTD | DIS | M4)) /*GPIO_8*/\
+							 /* - VIO_1V8*/\
+ MUX_VAL(CP(SYS_OFF_MODE),	(IEN  | PTD | DIS | M0)) /*SYS_OFF_MODE*/\
+ MUX_VAL(CP(SYS_CLKOUT1),	(IEN  | PTD | DIS | M0)) /*SYS_CLKOUT1*/\
+ MUX_VAL(CP(SYS_CLKOUT2),	(IEN  | PTU | EN  | M0)) /*SYS_CLKOUT2*/\
+ MUX_VAL(CP(JTAG_nTRST),	(IEN  | PTD | DIS | M0)) /*JTAG_nTRST*/\
+ MUX_VAL(CP(JTAG_TCK),		(IEN  | PTD | DIS | M0)) /*JTAG_TCK*/\
+ MUX_VAL(CP(JTAG_TMS),		(IEN  | PTD | DIS | M0)) /*JTAG_TMS*/\
+ MUX_VAL(CP(JTAG_TDI),		(IEN  | PTD | DIS | M0)) /*JTAG_TDI*/\
+ MUX_VAL(CP(JTAG_EMU0),		(IEN  | PTD | DIS | M0)) /*JTAG_EMU0*/\
+ MUX_VAL(CP(JTAG_EMU1),		(IEN  | PTD | DIS | M0)) /*JTAG_EMU1*/\
+ MUX_VAL(CP(ETK_CLK_ES2),	(IDIS | PTU | EN  | M0)) /*ETK_CLK*/\
+ MUX_VAL(CP(ETK_CTL_ES2),	(IDIS | PTD | DIS | M0)) /*ETK_CTL*/\
+ MUX_VAL(CP(ETK_D0_ES2 ),	(IEN  | PTD | DIS | M0)) /*ETK_D0*/\
+ MUX_VAL(CP(ETK_D1_ES2 ),	(IEN  | PTD | DIS | M0)) /*ETK_D1*/\
+ MUX_VAL(CP(ETK_D2_ES2 ),	(IEN  | PTD | EN  | M0)) /*ETK_D2*/\
+ MUX_VAL(CP(ETK_D3_ES2 ),	(IEN  | PTD | DIS | M0)) /*ETK_D3*/\
+ MUX_VAL(CP(ETK_D4_ES2 ),	(IEN  | PTD | DIS | M0)) /*ETK_D4*/\
+ MUX_VAL(CP(ETK_D5_ES2 ),	(IEN  | PTD | DIS | M0)) /*ETK_D5*/\
+ MUX_VAL(CP(ETK_D6_ES2 ),	(IEN  | PTD | DIS | M0)) /*ETK_D6*/\
+ MUX_VAL(CP(ETK_D7_ES2 ),	(IEN  | PTD | DIS | M0)) /*ETK_D7*/\
+ MUX_VAL(CP(ETK_D8_ES2 ),	(IEN  | PTD | DIS | M0)) /*ETK_D8*/\
+ MUX_VAL(CP(ETK_D9_ES2 ),	(IEN  | PTD | DIS | M0)) /*ETK_D9*/\
+ MUX_VAL(CP(ETK_D10_ES2),	(IEN  | PTD | DIS | M0)) /*ETK_D10*/\
+ MUX_VAL(CP(ETK_D11_ES2),	(IEN  | PTD | DIS | M0)) /*ETK_D11*/\
+ MUX_VAL(CP(ETK_D12_ES2),	(IEN  | PTD | DIS | M0)) /*ETK_D12*/\
+ MUX_VAL(CP(ETK_D13_ES2),	(IEN  | PTD | DIS | M0)) /*ETK_D13*/\
+ MUX_VAL(CP(ETK_D14_ES2),	(IEN  | PTD | DIS | M0)) /*ETK_D14*/\
+ MUX_VAL(CP(ETK_D15_ES2),	(IEN  | PTD | DIS | M0)) /*ETK_D15*/\
+ /*Die to Die */\
+ MUX_VAL(CP(CCDC_PCLK),		(IEN  | PTU | EN  | M0)) /*ccdc_pclk*/\
+ MUX_VAL(CP(CCDC_FIELD),	(IEN  | PTD | DIS  | M1)) /*ccdc_field*/\
+ MUX_VAL(CP(CCDC_HD),		(IEN  | PTU | EN  | M0)) /*ccdc_hd*/\
+ MUX_VAL(CP(CCDC_VD),		(IEN  | PTU | EN  | M0)) /*ccdc_vd*/\
+ MUX_VAL(CP(CCDC_WEN),		(IEN  | PTD | DIS  | M1)) /*ccdc_wen*/\
+ MUX_VAL(CP(CCDC_DATA0),	(IEN  | PTD | DIS | M0)) /*ccdc_data0*/\
+ MUX_VAL(CP(CCDC_DATA1),        (IEN  | PTD | DIS | M0)) /*ccdc_data1*/\
+ MUX_VAL(CP(CCDC_DATA2),	(IEN  | PTD | DIS | M0)) /*ccdc_data2*/\
+ MUX_VAL(CP(CCDC_DATA3),	(IEN  | PTD | DIS | M0)) /*ccdc_data3*/\
+ MUX_VAL(CP(CCDC_DATA4),	(IEN  | PTD | DIS | M0)) /*ccdc_data4*/\
+ MUX_VAL(CP(CCDC_DATA5),	(IEN  | PTD | DIS | M0)) /*ccdc_data5*/\
+ MUX_VAL(CP(CCDC_DATA6),	(IEN  | PTD | DIS | M0)) /*ccdc_data6*/\
+ MUX_VAL(CP(CCDC_DATA7),	(IEN  | PTD | DIS | M0)) /*ccdc_data7*/\
+ MUX_VAL(CP(RMII_MDIO_DATA),	(IEN  |  M0)) /*rmii_mdio_data*/\
+ MUX_VAL(CP(RMII_MDIO_CLK),	(M0)) /*rmii_mdio_clk*/\
+ MUX_VAL(CP(RMII_RXD0)	,	(IEN  | PTD | M0)) /*rmii_rxd0*/\
+ MUX_VAL(CP(RMII_RXD1),		(IEN  | PTD | M0)) /*rmii_rxd1*/\
+ MUX_VAL(CP(RMII_CRS_DV),	(IEN  | PTD | M0)) /*rmii_crs_dv*/\
+ MUX_VAL(CP(RMII_RXER),		(PTD | M0)) /*rmii_rxer*/\
+ MUX_VAL(CP(RMII_TXD0),		(PTD | M0)) /*rmii_txd0*/\
+ MUX_VAL(CP(RMII_TXD1),		(PTD | M0)) /*rmii_txd1*/\
+ MUX_VAL(CP(RMII_TXEN),		(PTD | M0)) /*rmii_txen*/\
+ MUX_VAL(CP(RMII_50MHZ_CLK),	(IEN  | PTD | EN  | M0)) /*rmii_50mhz_clk*/\
+ MUX_VAL(CP(USB0_DRVBUS),	(IEN  | PTD | EN  | M0)) /*usb0_drvbus*/\
+ MUX_VAL(CP(HECC1_TXD),		(IEN  | PTU | EN  | M0)) /*hecc1_txd*/\
+ MUX_VAL(CP(HECC1_RXD),		(IEN  | PTU | EN  | M0)) /*hecc1_rxd*/\
+ MUX_VAL(CP(SYS_BOOT7),		(IEN  | PTD | EN  | M0)) /*sys_boot7*/\
+ MUX_VAL(CP(SDRC_DQS0N),	(IEN  | PTD | EN  | M0)) /*sdrc_dqs0n*/\
+ MUX_VAL(CP(SDRC_DQS1N),	(IEN  | PTD | EN  | M0)) /*sdrc_dqs1n*/\
+ MUX_VAL(CP(SDRC_DQS2N),	(IEN  | PTD | EN  | M0)) /*sdrc_dqs2n*/\
+ MUX_VAL(CP(SDRC_DQS3N),	(IEN  | PTD | EN  | M0)) /*sdrc_dqs3n*/\
+ MUX_VAL(CP(STRBEN_DLY0),	(IEN  | PTD | EN  | M0)) /*sdrc_strben_dly0*/\
+ MUX_VAL(CP(STRBEN_DLY1),	(IEN  | PTD | EN  | M0)) /*sdrc_strben_dly1*/\
+ MUX_VAL(CP(SYS_BOOT8),		(IEN  | PTD | EN  | M0)) /*sys_boot8*/\
+ MUX_VAL(CP(D2D_MCAD34),	(IEN  | PTD | EN  | M0)) /*d2d_mcad34*/\
+ MUX_VAL(CP(D2D_MCAD35),	(IEN  | PTD | EN  | M0)) /*d2d_mcad35*/\
+ MUX_VAL(CP(D2D_MCAD36),	(IEN  | PTD | EN  | M0)) /*d2d_mcad36*/\
+ MUX_VAL(CP(D2D_CLK26MI),	(IEN  | PTD | DIS | M0)) /*d2d_clk26mi*/\
+ MUX_VAL(CP(D2D_NRESPWRON),	(IEN  | PTD | EN  | M0)) /*d2d_nrespwron*/\
+ MUX_VAL(CP(D2D_NRESWARM),	(IEN  | PTU | EN  | M0)) /*d2d_nreswarm */\
+ MUX_VAL(CP(D2D_ARM9NIRQ),	(IEN  | PTD | DIS | M0)) /*d2d_arm9nirq */\
+ MUX_VAL(CP(D2D_UMA2P6FIQ),	(IEN  | PTD | DIS | M0)) /*d2d_uma2p6fiq*/\
+ MUX_VAL(CP(D2D_SPINT),		(IEN  | PTD | EN  | M0)) /*d2d_spint*/\
+ MUX_VAL(CP(D2D_FRINT),		(IEN  | PTD | EN  | M0)) /*d2d_frint*/\
+ MUX_VAL(CP(D2D_DMAREQ0),	(IEN  | PTD | DIS | M0)) /*d2d_dmareq0*/\
+ MUX_VAL(CP(D2D_DMAREQ1),	(IEN  | PTD | DIS | M0)) /*d2d_dmareq1*/\
+ MUX_VAL(CP(D2D_DMAREQ2),	(IEN  | PTD | DIS | M0)) /*d2d_dmareq2*/\
+ MUX_VAL(CP(D2D_DMAREQ3),	(IEN  | PTD | DIS | M0)) /*d2d_dmareq3*/\
+ MUX_VAL(CP(D2D_N3GTRST),	(IEN  | PTD | DIS | M0)) /*d2d_n3gtrst*/\
+ MUX_VAL(CP(D2D_N3GTDI),	(IEN  | PTD | DIS | M0)) /*d2d_n3gtdi*/\
+ MUX_VAL(CP(D2D_N3GTDO),	(IEN  | PTD | DIS | M0)) /*d2d_n3gtdo*/\
+ MUX_VAL(CP(D2D_N3GTMS),	(IEN  | PTD | DIS | M0)) /*d2d_n3gtms*/\
+ MUX_VAL(CP(D2D_N3GTCK),	(IEN  | PTD | DIS | M0)) /*d2d_n3gtck*/\
+ MUX_VAL(CP(D2D_N3GRTCK),	(IEN  | PTD | DIS | M0)) /*d2d_n3grtck*/\
+ MUX_VAL(CP(D2D_MSTDBY),	(IEN  | PTU | EN  | M0)) /*d2d_mstdby*/\
+ MUX_VAL(CP(D2D_SWAKEUP),	(IEN  | PTD | EN  | M0)) /*d2d_swakeup*/\
+ MUX_VAL(CP(D2D_IDLEREQ),	(IEN  | PTD | DIS | M0)) /*d2d_idlereq*/\
+ MUX_VAL(CP(D2D_IDLEACK),	(IEN  | PTU | EN  | M0)) /*d2d_idleack*/\
+ MUX_VAL(CP(D2D_MWRITE),	(IEN  | PTD | DIS | M0)) /*d2d_mwrite*/\
+ MUX_VAL(CP(D2D_SWRITE),	(IEN  | PTD | DIS | M0)) /*d2d_swrite*/\
+ MUX_VAL(CP(D2D_MREAD),		(IEN  | PTD | DIS | M0)) /*d2d_mread*/\
+ MUX_VAL(CP(D2D_SREAD),		(IEN  | PTD | DIS | M0)) /*d2d_sread*/\
+ MUX_VAL(CP(D2D_MBUSFLAG),	(IEN  | PTD | DIS | M0)) /*d2d_mbusflag*/\
+ MUX_VAL(CP(D2D_SBUSFLAG),	(IEN  | PTD | DIS | M0)) /*d2d_sbusflag*/\
+ MUX_VAL(CP(SDRC_CKE0),		(M0)) /*sdrc_cke0*/\
+ MUX_VAL(CP(SDRC_CKE1),		(M0)) /*sdrc_cke1*/\
+
+#endif
diff --git a/board/ti/am3517evm/config.mk b/board/ti/am3517evm/config.mk
new file mode 100644
index 0000000..869e719
--- /dev/null
+++ b/board/ti/am3517evm/config.mk
@@ -0,0 +1,29 @@
+#
+# Author: Vaibhav Hiremath <hvaibhav@ti.com>
+#
+# Derived from evm code
+#
+# 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; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+#
+# Physical Address:
+# 8000'0000 (bank0)
+# A000/0000 (bank1)
+# Linux-Kernel is expected to be at 8000'8000, entry 8000'8000
+# (mem base + reserved)
+
+# For use with external or internal boots.
+TEXT_BASE = 0x80e80000
diff --git a/include/asm-arm/arch-omap3/mem.h b/include/asm-arm/arch-omap3/mem.h
index 9439758..7dbfc92 100644
--- a/include/asm-arm/arch-omap3/mem.h
+++ b/include/asm-arm/arch-omap3/mem.h
@@ -191,6 +191,15 @@ enum {
 #define SMNAND_GPMC_CONFIG6	0x1F0F0A80
 #define SMNAND_GPMC_CONFIG7	0x00000C44
 
+#if defined (CONFIG_OMAP3_AM3517EVM)
+#define M_NAND_GPMC_CONFIG1	0x00001800
+#define M_NAND_GPMC_CONFIG2	0x00080800
+#define M_NAND_GPMC_CONFIG3	0x00080800
+#define M_NAND_GPMC_CONFIG4	0x06000600
+#define M_NAND_GPMC_CONFIG5	0x00080808
+#define M_NAND_GPMC_CONFIG6	0x000003cf
+#define M_NAND_GPMC_CONFIG7	0x00000848
+#else	/* CONFIG_OMAP3_AM3517EVM */
 #define M_NAND_GPMC_CONFIG1	0x00001800
 #define M_NAND_GPMC_CONFIG2	0x00141400
 #define M_NAND_GPMC_CONFIG3	0x00141400
@@ -198,6 +207,7 @@ enum {
 #define M_NAND_GPMC_CONFIG5	0x010C1414
 #define M_NAND_GPMC_CONFIG6	0x1f0f0A80
 #define M_NAND_GPMC_CONFIG7	0x00000C44
+#endif	/* CONFIG_OMAP3_AM3517EVM */
 
 #define STNOR_GPMC_CONFIG1	0x3
 #define STNOR_GPMC_CONFIG2	0x00151501
-- 
1.6.2.4

^ permalink raw reply related	[flat|nested] 263+ messages in thread

* [U-Boot] [PATCH 0/5] Introducing TI's New SoC/board AM3517EVM
@ 2009-11-23 11:08 ` hvaibhav at ti.com
  2009-11-23 13:50   ` Paulraj, Sandeep
  2009-11-25 20:24   ` Tom
  0 siblings, 2 replies; 263+ messages in thread
From: hvaibhav at ti.com @ 2009-11-23 11:08 UTC (permalink / raw)
  To: u-boot

From: Vaibhav Hiremath <hvaibhav@ti.com>

AM3517 device is high-performance, industrial applications processor designed
and developed keeping Software Compatible with OMAP3 Processors.

Below are some of the useful links -
AM3517 device is high-performance, industrial applications processor designed
and developed keeping Software Compatible with OMAP3 Processors.

Below are some of the useful links -

Migration from OMAP35x to AM35x :-
http://focus.ti.com/lit/an/sprab91/sprab91.pdf

Specs/TRM :-
http://focus.ti.com/docs/prod/folders/print/am3517.html

EVM Link -:
http://www.logicpd.com/products/development-kits/zoom-am3517-experimenter-kit

Vaibhav Hiremath (5):
  Introducing AM3517EVM support
  am3517_evm_config options added to Makfile
  Added configuration file for AM3517EVM
  Added AM3517EVM specific mux configuration to omap3/mux.h
  AM3517: Add support for EMIF4

 Makefile                               |    3 +
 board/ti/am3517evm/Makefile            |   46 ++++
 board/ti/am3517evm/am3517evm.c         |   76 +++++++
 board/ti/am3517evm/am3517evm.h         |  388 ++++++++++++++++++++++++++++++++
 board/ti/am3517evm/config.mk           |   29 +++
 cpu/arm_cortexa8/omap3/board.c         |   11 +-
 cpu/arm_cortexa8/omap3/mem.c           |  110 ++++++++--
 cpu/arm_cortexa8/omap3/sys_info.c      |   12 +-
 include/asm-arm/arch-omap3/cpu.h       |   26 +++
 include/asm-arm/arch-omap3/mem.h       |   66 ++++++-
 include/asm-arm/arch-omap3/mux.h       |   35 +++
 include/asm-arm/arch-omap3/sys_proto.h |    4 +
 include/configs/am3517_evm.h           |  299 ++++++++++++++++++++++++
 include/configs/devkit8000.h           |    4 +
 include/configs/omap3_beagle.h         |    4 +
 include/configs/omap3_evm.h            |    4 +
 include/configs/omap3_overo.h          |    4 +
 include/configs/omap3_pandora.h        |    4 +
 include/configs/omap3_sdp3430.h        |    4 +
 include/configs/omap3_zoom1.h          |    4 +
 include/configs/omap3_zoom2.h          |    4 +
 21 files changed, 1112 insertions(+), 25 deletions(-)
 create mode 100644 board/ti/am3517evm/Makefile
 create mode 100644 board/ti/am3517evm/am3517evm.c
 create mode 100644 board/ti/am3517evm/am3517evm.h
 create mode 100644 board/ti/am3517evm/config.mk
 create mode 100644 include/configs/am3517_evm.h

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [U-Boot] [PATCH 2/5] am3517_evm_config options added to Makfile
@ 2009-11-23 11:08 ` hvaibhav at ti.com
  2009-11-23 19:44   ` Wolfgang Denk
  0 siblings, 1 reply; 263+ messages in thread
From: hvaibhav at ti.com @ 2009-11-23 11:08 UTC (permalink / raw)
  To: u-boot

From: Vaibhav Hiremath <hvaibhav@ti.com>


Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
---
 Makefile |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/Makefile b/Makefile
index bcb3fe9..d1aa8ff 100644
--- a/Makefile
+++ b/Makefile
@@ -3156,6 +3156,9 @@ omap3_overo_config :	unconfig
 omap3_evm_config :	unconfig
 	@$(MKCONFIG) $(@:_config=) arm arm_cortexa8 evm ti omap3
 
+am3517_evm_config :	unconfig
+	@$(MKCONFIG) $(@:_config=) arm arm_cortexa8 am3517evm ti omap3
+
 omap3_pandora_config :	unconfig
 	@$(MKCONFIG) $(@:_config=) arm arm_cortexa8 pandora NULL omap3
 
-- 
1.6.2.4

^ permalink raw reply related	[flat|nested] 263+ messages in thread

* [U-Boot] [PATCH 3/5] Added configuration file for AM3517EVM
@ 2009-11-23 11:08 ` hvaibhav at ti.com
  2009-11-23 19:46   ` Wolfgang Denk
  0 siblings, 1 reply; 263+ messages in thread
From: hvaibhav at ti.com @ 2009-11-23 11:08 UTC (permalink / raw)
  To: u-boot

From: Vaibhav Hiremath <hvaibhav@ti.com>


Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
---
 include/configs/am3517_evm.h |  293 ++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 293 insertions(+), 0 deletions(-)
 create mode 100644 include/configs/am3517_evm.h

diff --git a/include/configs/am3517_evm.h b/include/configs/am3517_evm.h
new file mode 100644
index 0000000..d7eef73
--- /dev/null
+++ b/include/configs/am3517_evm.h
@@ -0,0 +1,293 @@
+/*
+ * am3517_evm.h - Configuration settings for the TI's AM3517 EVM board.
+ *
+ * Author: Vaibhav Hiremath <hvaibhav@ti.com>
+ *
+ * Derived from evm code
+ *
+ * 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#ifndef __CONFIG_H
+#define __CONFIG_H
+
+/*
+ * High Level Configuration Options
+ */
+#define CONFIG_ARMCORTEXA8	1	/* This is an ARM V7 CPU core */
+#define CONFIG_OMAP		1	/* in a TI OMAP core */
+#define CONFIG_OMAP34XX		1	/* which is a 34XX */
+#define CONFIG_OMAP3_AM3517EVM	1	/* working with AM3517EVM */
+
+#include <asm/arch/cpu.h>	/* get chip and board defs */
+#include <asm/arch/omap3.h>
+
+/*
+ * Display CPU and Board information
+ */
+#define CONFIG_DISPLAY_CPUINFO		1
+#define CONFIG_DISPLAY_BOARDINFO	1
+
+/* Clock Defines */
+#define V_OSCK			26000000	/* Clock output from T2 */
+#define V_SCLK			(V_OSCK >> 1)
+
+#undef CONFIG_USE_IRQ			/* no support for IRQs */
+#define CONFIG_MISC_INIT_R
+
+#define CONFIG_CMDLINE_TAG		1	/* enable passing of ATAGs */
+#define CONFIG_SETUP_MEMORY_TAGS	1
+#define CONFIG_INITRD_TAG		1
+#define CONFIG_REVISION_TAG		1
+
+/*
+ * Size of malloc() pool
+ */
+#define CONFIG_ENV_SIZE			(128 << 10)	/* 128 KiB */
+						/* Sector */
+#define CONFIG_SYS_MALLOC_LEN		(CONFIG_ENV_SIZE + (128 << 10))
+#define CONFIG_SYS_GBL_DATA_SIZE	128	/* bytes reserved for */
+						/* initial data */
+/*
+ * DDR size interfaced
+ */
+#define CONFIG_SYS_CS0_SIZE             (256 * 1024 * 1024)
+
+/*
+ * Hardware drivers
+ */
+
+/*
+ * NS16550 Configuration
+ */
+#define V_NS16550_CLK			48000000	/* 48MHz (APLL96/2) */
+
+#define CONFIG_SYS_NS16550
+#define CONFIG_SYS_NS16550_SERIAL
+#define CONFIG_SYS_NS16550_REG_SIZE	(-4)
+#define CONFIG_SYS_NS16550_CLK		V_NS16550_CLK
+
+/*
+ * select serial console configuration
+ */
+#define CONFIG_CONS_INDEX		3
+#define CONFIG_SYS_NS16550_COM3		OMAP34XX_UART3
+#define CONFIG_SERIAL3			3	/* UART3 on AM3517 EVM */
+
+/* allow to overwrite serial and ethaddr */
+#define CONFIG_ENV_OVERWRITE
+#define CONFIG_BAUDRATE			115200
+#define CONFIG_SYS_BAUDRATE_TABLE	{4800, 9600, 19200, 38400, 57600,\
+					115200}
+#define CONFIG_MMC			1
+#define CONFIG_OMAP3_MMC		1
+#define CONFIG_DOS_PARTITION		1
+
+/* commands to include */
+#include <config_cmd_default.h>
+
+#define CONFIG_CMD_EXT2		/* EXT2 Support			*/
+#define CONFIG_CMD_FAT		/* FAT support			*/
+#define CONFIG_CMD_JFFS2	/* JFFS2 Support		*/
+
+#define CONFIG_CMD_I2C		/* I2C serial bus support	*/
+#define CONFIG_CMD_MMC		/* MMC support			*/
+#define CONFIG_CMD_NAND		/* NAND support			*/
+
+#undef CONFIG_CMD_FLASH		/* flinfo, erase, protect	*/
+#undef CONFIG_CMD_FPGA		/* FPGA configuration Support	*/
+#undef CONFIG_CMD_IMI		/* iminfo			*/
+#undef CONFIG_CMD_IMLS		/* List all found images	*/
+
+#define CONFIG_SYS_NO_FLASH
+#define CONFIG_HARD_I2C			1
+#define CONFIG_SYS_I2C_SPEED		100000
+#define CONFIG_SYS_I2C_SLAVE		1
+#define CONFIG_SYS_I2C_BUS		0
+#define CONFIG_SYS_I2C_BUS_SELECT	1
+#define CONFIG_DRIVER_OMAP34XX_I2C	1
+
+#undef CONFIG_CMD_NET
+/*
+ * Board NAND Info.
+ */
+#define CONFIG_SYS_NAND_ADDR		NAND_BASE	/* physical address */
+							/* to access nand */
+#define CONFIG_SYS_NAND_BASE		NAND_BASE	/* physical address */
+							/* to access */
+							/* nand at CS0 */
+
+#define CONFIG_SYS_MAX_NAND_DEVICE	1		/* Max number of */
+							/* NAND devices */
+#define CONFIG_SYS_64BIT_VSPRINTF		/* needed for nand_util.c */
+
+#define CONFIG_JFFS2_NAND
+/* nand device jffs2 lives on */
+#define CONFIG_JFFS2_DEV		"nand0"
+/* start of jffs2 partition */
+#define CONFIG_JFFS2_PART_OFFSET	0x680000
+#define CONFIG_JFFS2_PART_SIZE		0xf980000	/* sz of jffs2 part */
+
+/* Environment information */
+#define CONFIG_BOOTDELAY	10
+
+#define CONFIG_BOOTFILE		uImage
+
+#define CONFIG_EXTRA_ENV_SETTINGS \
+	"loadaddr=0x82000000\0" \
+	"console=ttyS2,115200n8\0" \
+	"mmcargs=setenv bootargs console=${console} " \
+		"root=/dev/mmcblk0p2 rw " \
+		"rootfstype=ext3 rootwait\0" \
+	"nandargs=setenv bootargs console=${console} " \
+		"root=/dev/mtdblock4 rw " \
+		"rootfstype=jffs2\0" \
+	"loadbootscript=fatload mmc 0 ${loadaddr} boot.scr\0" \
+	"bootscript=echo Running bootscript from mmc ...; " \
+		"source ${loadaddr}\0" \
+	"loaduimage=fatload mmc 0 ${loadaddr} uImage\0" \
+	"mmcboot=echo Booting from mmc ...; " \
+		"run mmcargs; " \
+		"bootm ${loadaddr}\0" \
+	"nandboot=echo Booting from nand ...; " \
+		"run nandargs; " \
+		"nand read ${loadaddr} 280000 400000; " \
+		"bootm ${loadaddr}\0" \
+
+#define CONFIG_BOOTCOMMAND \
+	"if mmc init; then " \
+		"if run loadbootscript; then " \
+			"run bootscript; " \
+		"else " \
+			"if run loaduimage; then " \
+				"run mmcboot; " \
+			"else run nandboot; " \
+			"fi; " \
+		"fi; " \
+	"else run nandboot; fi"
+
+#define CONFIG_AUTO_COMPLETE	1
+/*
+ * Miscellaneous configurable options
+ */
+#define V_PROMPT		"AM3517_EVM # "
+
+#define CONFIG_SYS_LONGHELP		/* undef to save memory */
+#define CONFIG_SYS_HUSH_PARSER		/* use "hush" command parser */
+#define CONFIG_SYS_PROMPT_HUSH_PS2	"> "
+#define CONFIG_SYS_PROMPT		V_PROMPT
+#define CONFIG_SYS_CBSIZE		256	/* Console I/O Buffer Size */
+/* Print Buffer Size */
+#define CONFIG_SYS_PBSIZE		(CONFIG_SYS_CBSIZE + \
+					sizeof(CONFIG_SYS_PROMPT) + 16)
+#define CONFIG_SYS_MAXARGS		16	/* max number of command */
+						/* args */
+/* Boot Argument Buffer Size */
+#define CONFIG_SYS_BARGSIZE		(CONFIG_SYS_CBSIZE)
+/* memtest works on */
+#define CONFIG_SYS_MEMTEST_START	(OMAP34XX_SDRC_CS0)
+#define CONFIG_SYS_MEMTEST_END		(OMAP34XX_SDRC_CS0 + \
+					0x01F00000) /* 31MB */
+
+#define CONFIG_SYS_LOAD_ADDR		(OMAP34XX_SDRC_CS0) /* default load */
+								/* address */
+
+/*
+ * AM3517 has 12 GP timers, they can be driven by the system clock
+ * (12/13/16.8/19.2/38.4MHz) or by 32KHz clock. We use 13MHz (V_SCLK).
+ * This rate is divided by a local divisor.
+ */
+#define CONFIG_SYS_TIMERBASE		OMAP34XX_GPT2
+#define CONFIG_SYS_PTV			2	/* Divisor: 2^(PTV+1) => 8 */
+#define CONFIG_SYS_HZ			1000
+
+/*-----------------------------------------------------------------------
+ * Stack sizes
+ *
+ * The stack sizes are set up in start.S using the settings below
+ */
+#define CONFIG_STACKSIZE	(128 << 10)	/* regular stack 128 KiB */
+#ifdef CONFIG_USE_IRQ
+#define CONFIG_STACKSIZE_IRQ	(4 << 10)	/* IRQ stack 4 KiB */
+#define CONFIG_STACKSIZE_FIQ	(4 << 10)	/* FIQ stack 4 KiB */
+#endif
+
+/*-----------------------------------------------------------------------
+ * Physical Memory Map
+ */
+#define CONFIG_NR_DRAM_BANKS	2	/* CS1 may or may not be populated */
+#define PHYS_SDRAM_1		OMAP34XX_SDRC_CS0
+#define PHYS_SDRAM_1_SIZE	(32 << 20)	/* at least 32 MiB */
+#define PHYS_SDRAM_2		OMAP34XX_SDRC_CS1
+
+/* SDRAM Bank Allocation method */
+#define SDRC_R_B_C		1
+
+/*-----------------------------------------------------------------------
+ * FLASH and environment organization
+ */
+
+/* **** PISMO SUPPORT *** */
+
+/* Configure the PISMO */
+#define PISMO1_NAND_SIZE		GPMC_SIZE_128M
+#define PISMO1_ONEN_SIZE		GPMC_SIZE_128M
+
+#define CONFIG_SYS_MAX_FLASH_SECT	520	/* max number of sectors */
+						/* on one chip */
+#define CONFIG_SYS_MAX_FLASH_BANKS	2	/* max number of flash banks */
+#define CONFIG_SYS_MONITOR_LEN		(256 << 10)	/* Reserve 2 sectors */
+
+#define CONFIG_SYS_FLASH_BASE		boot_flash_base
+
+/* Monitor@start of flash */
+#define CONFIG_SYS_MONITOR_BASE		CONFIG_SYS_FLASH_BASE
+
+#define CONFIG_NAND_OMAP_GPMC
+#define GPMC_NAND_ECC_LP_x16_LAYOUT	1
+#define CONFIG_ENV_IS_IN_NAND		1
+#define SMNAND_ENV_OFFSET		0x260000 /* environment starts here */
+
+#define CONFIG_SYS_ENV_SECT_SIZE	boot_flash_sec
+#define CONFIG_ENV_OFFSET		boot_flash_off
+#define CONFIG_ENV_ADDR			boot_flash_env_addr
+
+/*-----------------------------------------------------------------------
+ * CFI FLASH driver setup
+ */
+/* timeout values are in ticks */
+#define CONFIG_SYS_FLASH_ERASE_TOUT	(100 * CONFIG_SYS_HZ)
+#define CONFIG_SYS_FLASH_WRITE_TOUT	(100 * CONFIG_SYS_HZ)
+
+/* Flash banks JFFS2 should use */
+#define CONFIG_SYS_MAX_MTD_BANKS	(CONFIG_SYS_MAX_FLASH_BANKS + \
+					CONFIG_SYS_MAX_NAND_DEVICE)
+#define CONFIG_SYS_JFFS2_MEM_NAND
+/* use flash_info[2] */
+#define CONFIG_SYS_JFFS2_FIRST_BANK	CONFIG_SYS_MAX_FLASH_BANKS
+#define CONFIG_SYS_JFFS2_NUM_BANKS	1
+
+#ifndef __ASSEMBLY__
+extern struct gpmc *gpmc_cfg;
+extern unsigned int boot_flash_base;
+extern volatile unsigned int boot_flash_env_addr;
+extern unsigned int boot_flash_off;
+extern unsigned int boot_flash_sec;
+extern unsigned int boot_flash_type;
+#endif
+
+#endif /* __CONFIG_H */
-- 
1.6.2.4

^ permalink raw reply related	[flat|nested] 263+ messages in thread

* [U-Boot] [PATCH 4/5] AM3517EVM: Add mux configuration
@ 2009-11-23 11:08 ` hvaibhav at ti.com
  2009-11-23 19:49   ` Wolfgang Denk
  0 siblings, 1 reply; 263+ messages in thread
From: hvaibhav at ti.com @ 2009-11-23 11:08 UTC (permalink / raw)
  To: u-boot

From: Vaibhav Hiremath <hvaibhav@ti.com>

Updated mux.h file for AM3517 specific mux configuration.

Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
---
 include/asm-arm/arch-omap3/mux.h |   35 +++++++++++++++++++++++++++++++++++
 1 files changed, 35 insertions(+), 0 deletions(-)

diff --git a/include/asm-arm/arch-omap3/mux.h b/include/asm-arm/arch-omap3/mux.h
index 0c01c73..9f06fbb 100644
--- a/include/asm-arm/arch-omap3/mux.h
+++ b/include/asm-arm/arch-omap3/mux.h
@@ -403,6 +403,41 @@
 #define CONTROL_PADCONF_D2D_SBUSFLAG	0x0260
 #define CONTROL_PADCONF_SDRC_CKE0	0x0262
 #define CONTROL_PADCONF_SDRC_CKE1	0x0264
+/* AM3517 specific */
+#define CONTROL_PADCONF_CCDC_PCLK       0x01E4
+#define CONTROL_PADCONF_CCDC_FIELD      0x01E6
+#define CONTROL_PADCONF_CCDC_HD         0x01E8
+#define CONTROL_PADCONF_CCDC_VD         0x01EA
+#define CONTROL_PADCONF_CCDC_WEN        0x01EC
+#define CONTROL_PADCONF_CCDC_DATA0      0x01EE
+#define CONTROL_PADCONF_CCDC_DATA1      0x01F0
+#define CONTROL_PADCONF_CCDC_DATA2      0x01F2
+#define CONTROL_PADCONF_CCDC_DATA3      0x01F4
+#define CONTROL_PADCONF_CCDC_DATA4      0x01F6
+#define CONTROL_PADCONF_CCDC_DATA5      0x01F8
+#define CONTROL_PADCONF_CCDC_DATA6      0x01FA
+#define CONTROL_PADCONF_CCDC_DATA7      0x01FC
+#define CONTROL_PADCONF_RMII_MDIO_DATA  0x01FE
+#define CONTROL_PADCONF_RMII_MDIO_CLK   0x0200
+#define CONTROL_PADCONF_RMII_RXD0       0x0202
+#define CONTROL_PADCONF_RMII_RXD1       0x0204
+#define CONTROL_PADCONF_RMII_CRS_DV     0x0206
+#define CONTROL_PADCONF_RMII_RXER       0x0208
+#define CONTROL_PADCONF_RMII_TXD0       0x020A
+#define CONTROL_PADCONF_RMII_TXD1       0x020C
+#define CONTROL_PADCONF_RMII_TXEN       0x020E
+#define CONTROL_PADCONF_RMII_50MHZ_CLK  0x0210
+#define CONTROL_PADCONF_USB0_DRVBUS     0x0212
+#define CONTROL_PADCONF_HECC1_TXD       0x0214
+#define CONTROL_PADCONF_HECC1_RXD       0x0216
+#define CONTROL_PADCONF_SYS_BOOT7       0x0218
+#define CONTROL_PADCONF_SDRC_DQS0N      0x021A
+#define CONTROL_PADCONF_SDRC_DQS1N      0x021C
+#define CONTROL_PADCONF_SDRC_DQS2N      0x021E
+#define CONTROL_PADCONF_SDRC_DQS3N      0x0220
+#define CONTROL_PADCONF_STRBEN_DLY0     0x0222
+#define CONTROL_PADCONF_STRBEN_DLY1     0x0224
+#define CONTROL_PADCONF_SYS_BOOT8       0x0226

 #define MUX_VAL(OFFSET,VALUE)\
 	writew((VALUE), OMAP34XX_CTRL_BASE + (OFFSET));
--
1.6.2.4

^ permalink raw reply related	[flat|nested] 263+ messages in thread

* [U-Boot] [PATCH 5/5] AM3517: Add support for EMIF4
@ 2009-11-23 11:09 ` hvaibhav at ti.com
  2009-11-23 19:50   ` Wolfgang Denk
  0 siblings, 1 reply; 263+ messages in thread
From: hvaibhav at ti.com @ 2009-11-23 11:09 UTC (permalink / raw)
  To: u-boot

From: Vaibhav Hiremath <hvaibhav@ti.com>

Changes:-

	- Created 2 seperate config option
		* CONFIG_SDRC (omap34xx family)
		* CONFIG_EMIF4 (am3517 family)
	- Changed all omap3 dependent file for CONFIG_SDRC

Tested On:-

        - AM3517EVM board
        - OMAP3EVM board
        - BEAGLE board

I would need help here from people to validate this change for SDP/ZOOMx
and other OMAP3 version of boards.

Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
---
 cpu/arm_cortexa8/omap3/board.c         |   11 ++-
 cpu/arm_cortexa8/omap3/mem.c           |  110 ++++++++++++++++++++++++++------
 cpu/arm_cortexa8/omap3/sys_info.c      |   12 +++-
 include/asm-arm/arch-omap3/cpu.h       |   26 ++++++++
 include/asm-arm/arch-omap3/mem.h       |   58 ++++++++++++++++-
 include/asm-arm/arch-omap3/sys_proto.h |    4 +
 include/configs/am3517_evm.h           |    6 ++
 include/configs/devkit8000.h           |    4 +
 include/configs/omap3_beagle.h         |    4 +
 include/configs/omap3_evm.h            |    4 +
 include/configs/omap3_overo.h          |    4 +
 include/configs/omap3_pandora.h        |    4 +
 include/configs/omap3_sdp3430.h        |    4 +
 include/configs/omap3_zoom1.h          |    4 +
 include/configs/omap3_zoom2.h          |    4 +
 15 files changed, 233 insertions(+), 26 deletions(-)

diff --git a/cpu/arm_cortexa8/omap3/board.c b/cpu/arm_cortexa8/omap3/board.c
index dd2c940..ce60f99 100644
--- a/cpu/arm_cortexa8/omap3/board.c
+++ b/cpu/arm_cortexa8/omap3/board.c
@@ -227,7 +227,11 @@ void s_init(void)
 	per_clocks_enable();

 	if (!in_sdram)
+#if defined(CONFIG_SDRC)
 		sdrc_init();
+#elif defined(CONFIG_EMIF4)
+		emif4_init();
+#endif
 }

 /******************************************************************************
@@ -276,19 +280,20 @@ int dram_init(void)
 	DECLARE_GLOBAL_DATA_PTR;
 	unsigned int size0 = 0, size1 = 0;

+	size0 = get_sdr_cs_size(CS0);
 	/*
 	 * If a second bank of DDR is attached to CS1 this is
 	 * where it can be started.  Early init code will init
 	 * memory on CS0.
 	 */
 	if ((sysinfo.mtype == DDR_COMBO) || (sysinfo.mtype == DDR_STACKED)) {
+#if defined(CONFIG_SDRC)
 		do_sdrc_init(CS1, NOT_EARLY);
 		make_cs1_contiguous();
+#endif
+		size1 = get_sdr_cs_size(CS1);
 	}

-	size0 = get_sdr_cs_size(CS0);
-	size1 = get_sdr_cs_size(CS1);
-
 	gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
 	gd->bd->bi_dram[0].size = size0;
 	gd->bd->bi_dram[1].start = PHYS_SDRAM_1 + get_sdr_cs_offset(CS1);
diff --git a/cpu/arm_cortexa8/omap3/mem.c b/cpu/arm_cortexa8/omap3/mem.c
index dfb7e4c..73e0918 100644
--- a/cpu/arm_cortexa8/omap3/mem.c
+++ b/cpu/arm_cortexa8/omap3/mem.c
@@ -79,26 +79,6 @@ static const u32 gpmc_onenand[GPMC_MAX_REG] = {

 #endif

-static struct sdrc *sdrc_base = (struct sdrc *)OMAP34XX_SDRC_BASE;
-
-/**************************************************************************
- * make_cs1_contiguous() - for es2 and above remap cs1 behind cs0 to allow
- *  command line mem=xyz use all memory with out discontinuous support
- *  compiled in.  Could do it at the ATAG, but there really is two banks...
- * Called as part of 2nd phase DDR init.
- **************************************************************************/
-void make_cs1_contiguous(void)
-{
-	u32 size, a_add_low, a_add_high;
-
-	size = get_sdr_cs_size(CS0);
-	size >>= 25;	/* divide by 32 MiB to find size to offset CS1 */
-	a_add_high = (size & 3) << 8;	/* set up low field */
-	a_add_low = (size & 0x3C) >> 2;	/* set up high field */
-	writel((a_add_high | a_add_low), &sdrc_base->cs_cfg);
-
-}
-
 /********************************************************
  *  mem_ok() - test used to see if timings are correct
  *             for a part. Helps in guessing which part
@@ -123,6 +103,27 @@ u32 mem_ok(u32 cs)
 		return 1;
 }

+#if defined(CONFIG_SDRC)
+static struct sdrc *sdrc_base = (struct sdrc *)OMAP34XX_SDRC_BASE;
+
+/**************************************************************************
+ * make_cs1_contiguous() - for es2 and above remap cs1 behind cs0 to allow
+ *  command line mem=xyz use all memory with out discontinuous support
+ *  compiled in.  Could do it at the ATAG, but there really is two banks...
+ * Called as part of 2nd phase DDR init.
+ **************************************************************************/
+void make_cs1_contiguous(void)
+{
+	u32 size, a_add_low, a_add_high;
+
+	size = get_sdr_cs_size(CS0);
+	size >>= 25;	/* divide by 32 MiB to find size to offset CS1 */
+	a_add_high = (size & 3) << 8;	/* set up low field */
+	a_add_low = (size & 0x3C) >> 2;	/* set up high field */
+	writel((a_add_high | a_add_low), &sdrc_base->cs_cfg);
+
+}
+
 /********************************************************
  *  sdrc_init() - init the sdrc chip selects CS0 and CS1
  *  - early init routines, called from flash or
@@ -192,6 +193,75 @@ void do_sdrc_init(u32 cs, u32 early)
 	if (!mem_ok(cs))
 		writel(0, &sdrc_base->cs[cs].mcfg);
 }
+#elif defined(CONFIG_EMIF4)	/* #if define (CONFIG_SDRC) */
+
+static emif4_t *emif4_base = (emif4_t *)OMAP34XX_SDRC_BASE;
+
+/********************************************************
+ * emif4 _init() - init the emif4 module for DDR access
+ *  - early init routines, called from flash or
+ *  SRAM.
+ *******************************************************/
+void emif4_init(void)
+{
+	unsigned int regval;
+	/* Set the DDR PHY parameters in PHY ctrl registers */
+	regval = (EMIF4_DDR1_READ_LAT | EMIF4_DDR1_PWRDN_DIS |
+		EMIF4_DDR1_EXT_STRB_DIS);
+	writel(regval, &emif4_base->ddr_phyctrl1);
+	writel(regval, &emif4_base->ddr_phyctrl1_shdw);
+	writel(0, &emif4_base->ddr_phyctrl2);
+
+	/* Reset the DDR PHY and wait till completed */
+	regval = readl(&emif4_base->sdram_iodft_tlgc);
+	regval |= (1<<10);
+	writel(regval, &emif4_base->sdram_iodft_tlgc);
+	/*Wait till that bit clears*/
+	while ((readl(&emif4_base->sdram_iodft_tlgc) & (1<<10)) == 0x1);
+	/*Re-verify the DDR PHY status*/
+	while ((readl(&emif4_base->sdram_sts) & (1<<2)) == 0x0);
+
+	regval |= (1<<0);
+	writel(regval, &emif4_base->sdram_iodft_tlgc);
+	/* Set SDR timing registers */
+	regval = (EMIF4_TIM1_T_WTR | EMIF4_TIM1_T_RRD |
+		EMIF4_TIM1_T_RC | EMIF4_TIM1_T_RAS |
+		EMIF4_TIM1_T_WR | EMIF4_TIM1_T_RCD |
+		EMIF4_TIM1_T_RP);
+	writel(regval, &emif4_base->sdram_time1);
+	writel(regval, &emif4_base->sdram_time1_shdw);
+
+	regval = (EMIF4_TIM2_T_CKE | EMIF4_TIM2_T_RTP |
+		EMIF4_TIM2_T_XSRD | EMIF4_TIM2_T_XSNR |
+		EMIF4_TIM2_T_ODT | EMIF4_TIM2_T_XP);
+	writel(regval, &emif4_base->sdram_time2);
+	writel(regval, &emif4_base->sdram_time2_shdw);
+
+	regval = (EMIF4_TIM3_T_RAS_MAX | EMIF4_TIM3_T_RFC);
+	writel(regval, &emif4_base->sdram_time3);
+	writel(regval, &emif4_base->sdram_time3_shdw);
+
+	/* Set the PWR control register */
+	regval = (EMIF4_PWR_PM_TIM | EMIF4_PWR_LP_MODE |
+		EMIF4_PWR_DPD_DIS | EMIF4_PWR_IDLE_MODE);
+	writel(regval, &emif4_base->sdram_pwr_mgmt);
+	writel(regval, &emif4_base->sdram_pwr_mgmt_shdw);
+
+	/* Set the DDR refresh rate control register */
+	regval = (EMIF4_REFRESH_RATE | EMIF4_INITREF_DIS);
+	writel(regval, &emif4_base->sdram_refresh_ctrl);
+	writel(regval, &emif4_base->sdram_refresh_ctrl_shdw);
+
+	/* set the SDRAM configuration register */
+	regval = (EMIF4_CFG_PGSIZE | EMIF4_CFG_EBANK |
+		EMIF4_CFG_IBANK | EMIF4_CFG_ROWSIZE |
+		EMIF4_CFG_CL | EMIF4_CFG_NARROW_MD |
+		EMIF4_CFG_SDR_DRV | EMIF4_CFG_DDR_DIS_DLL |
+		EMIF4_CFG_DDR2_DDQS | EMIF4_CFG_DDR_TERM |
+		EMIF4_CFG_IBANK_POS | EMIF4_CFG_SDRAM_TYP);
+	writel(regval, &emif4_base->sdram_config);
+}
+#endif	/* #if define (CONFIG_SDRC) */

 void enable_gpmc_cs_config(const u32 *gpmc_config, struct gpmc_cs *cs, u32 base,
 			u32 size)
diff --git a/cpu/arm_cortexa8/omap3/sys_info.c b/cpu/arm_cortexa8/omap3/sys_info.c
index 08fb32e..f396898 100644
--- a/cpu/arm_cortexa8/omap3/sys_info.c
+++ b/cpu/arm_cortexa8/omap3/sys_info.c
@@ -109,8 +109,10 @@ u32 get_cpu_rev(void)
  ****************************************************/
 u32 is_mem_sdr(void)
 {
+#if defined(CONFIG_SDRC)
 	if (readl(&sdrc_base->cs[CS0].mr) == SDRC_MR_0_SDR)
 		return 1;
+#endif
 	return 0;
 }

@@ -121,10 +123,16 @@ u32 get_sdr_cs_size(u32 cs)
 {
 	u32 size;

+#if defined(CONFIG_EMIF4)
+	/* TODO: Calculate the size based on EMIF4 configuration */
+	size = CONFIG_SYS_CS0_SIZE;
+#elif defined(CONFIG_SDRC)
 	/* get ram size field */
 	size = readl(&sdrc_base->cs[cs].mcfg) >> 8;
 	size &= 0x3FF;		/* remove unwanted bits */
 	size <<= 21;		/* multiply by 2 MiB to find size in MB */
+#endif
+
 	return size;
 }

@@ -133,13 +141,15 @@ u32 get_sdr_cs_size(u32 cs)
  ************************************************************************/
 u32 get_sdr_cs_offset(u32 cs)
 {
-	u32 offset;
+	u32 offset = 0;

 	if (!cs)
 		return 0;

+#if defined(CONFIG_SDRC)
 	offset = readl(&sdrc_base->cs_cfg);
 	offset = (offset & 15) << 27 | (offset & 0x30) >> 17;
+#endif

 	return offset;
 }
diff --git a/include/asm-arm/arch-omap3/cpu.h b/include/asm-arm/arch-omap3/cpu.h
index e51c4f3..f9aacb4 100644
--- a/include/asm-arm/arch-omap3/cpu.h
+++ b/include/asm-arm/arch-omap3/cpu.h
@@ -214,6 +214,32 @@ struct sdrc {
 #endif /* __ASSEMBLY__ */
 #endif /* __KERNEL_STRICT_NAMES */

+/* EMIF4 */
+#ifndef __ASSEMBLY__
+typedef struct emif4 {
+	unsigned int sdram_sts;
+	unsigned int sdram_config;
+	unsigned int res1;
+	unsigned int sdram_refresh_ctrl;
+	unsigned int sdram_refresh_ctrl_shdw;
+	unsigned int sdram_time1;
+	unsigned int sdram_time1_shdw;
+	unsigned int sdram_time2;
+	unsigned int sdram_time2_shdw;
+	unsigned int sdram_time3;
+	unsigned int sdram_time3_shdw;
+	unsigned char res2[8];
+	unsigned int sdram_pwr_mgmt;
+	unsigned int sdram_pwr_mgmt_shdw;
+	unsigned char res3[32];
+	unsigned int sdram_iodft_tlgc;
+	unsigned char res4[128];
+	unsigned int ddr_phyctrl1;
+	unsigned int ddr_phyctrl1_shdw;
+	unsigned int ddr_phyctrl2;
+} emif4_t;
+#endif /* __ASSEMBLY__ */
+
 #define DLLPHASE_90		(0x1 << 1)
 #define LOADDLL			(0x1 << 2)
 #define ENADLL			(0x1 << 3)
diff --git a/include/asm-arm/arch-omap3/mem.h b/include/asm-arm/arch-omap3/mem.h
index 7dbfc92..8e7df37 100644
--- a/include/asm-arm/arch-omap3/mem.h
+++ b/include/asm-arm/arch-omap3/mem.h
@@ -39,6 +39,60 @@ enum {

 #define EARLY_INIT	1

+/*
+ * EMIF4 -
+ * 	Configuration values
+ */
+#define EMIF4_TIM1_T_RP		(0x3 << 25)
+#define EMIF4_TIM1_T_RCD	(0x3 << 21)
+#define EMIF4_TIM1_T_WR		(0x3 << 17)
+#define EMIF4_TIM1_T_RAS	(0x8 << 12)
+#define EMIF4_TIM1_T_RC		(0xA << 6)
+#define EMIF4_TIM1_T_RRD	(0x2 << 3)
+#define EMIF4_TIM1_T_WTR	(0x2 << 0)
+
+#define EMIF4_TIM2_T_XP		(0x2 << 28)
+#define EMIF4_TIM2_T_ODT	(0x0 << 25)
+#define EMIF4_TIM2_T_XSNR	(0x1C << 16)
+#define EMIF4_TIM2_T_XSRD	(0xC8 << 6)
+#define EMIF4_TIM2_T_RTP	(0x1 << 3)
+#define EMIF4_TIM2_T_CKE	(0x2 << 0)
+
+#define EMIF4_TIM3_T_RFC	(0x25 << 4)
+#define EMIF4_TIM3_T_RAS_MAX	(0x7 << 0)
+
+#define EMIF4_PWR_IDLE_MODE	(0x2 << 30)
+#define EMIF4_PWR_DPD_DIS	(0x0 << 10)
+#define EMIF4_PWR_DPD_EN	(0x1 << 10)
+#define EMIF4_PWR_LP_MODE	(0x0 << 8)
+#define EMIF4_PWR_PM_TIM	(0x0 << 0)
+
+#define EMIF4_INITREF_DIS	(0x0 << 31)
+#define EMIF4_REFRESH_RATE	(0x50F << 0)
+
+#define EMIF4_CFG_SDRAM_TYP	(0x2 << 29)
+#define EMIF4_CFG_IBANK_POS	(0x0 << 27)
+#define EMIF4_CFG_DDR_TERM	(0x0 << 24)
+#define EMIF4_CFG_DDR2_DDQS	(0x1 << 23)
+#define EMIF4_CFG_DDR_DIS_DLL	(0x0 << 20)
+#define EMIF4_CFG_SDR_DRV	(0x0 << 18)
+#define EMIF4_CFG_NARROW_MD	(0x0 << 14)
+#define EMIF4_CFG_CL		(0x5 << 10)
+#define EMIF4_CFG_ROWSIZE	(0x0 << 7)
+#define EMIF4_CFG_IBANK		(0x3 << 4)
+#define EMIF4_CFG_EBANK		(0x0 << 3)
+#define EMIF4_CFG_PGSIZE	(0x2 << 0)
+/*
+ * EMIF4 PHY Control 1 register configuration
+ */
+#define EMIF4_DDR1_READ_LAT	(0x6 << 0)
+#define EMIF4_DDR1_PWRDN_DIS	(0x0 << 6)
+#define EMIF4_DDR1_PWRDN_EN	(0x1 << 6)
+#define EMIF4_DDR1_EXT_STRB_EN	(0x1 << 7)
+#define EMIF4_DDR1_EXT_STRB_DIS	(0x0 << 7)
+
+#if defined(CONFIG_SDRC)
+
 /* Slower full frequency range default timings for x32 operation*/
 #define SDRC_SHARING	0x00000100
 #define SDRC_MR_0_SDR	0x00000031
@@ -140,7 +194,7 @@ enum {
 #if !defined(V_ACTIMA_165) || !defined(V_ACTIMB_165)
 #error "Please choose the right DDR type in config header"
 #endif
-
+#endif	/* #if defined (CONFIG_SDRC) */
 /*
  * GPMC settings -
  * Definitions is as per the following format
@@ -191,7 +245,7 @@ enum {
 #define SMNAND_GPMC_CONFIG6	0x1F0F0A80
 #define SMNAND_GPMC_CONFIG7	0x00000C44

-#if defined (CONFIG_OMAP3_AM3517EVM)
+#if defined(CONFIG_OMAP3_AM3517EVM)
 #define M_NAND_GPMC_CONFIG1	0x00001800
 #define M_NAND_GPMC_CONFIG2	0x00080800
 #define M_NAND_GPMC_CONFIG3	0x00080800
diff --git a/include/asm-arm/arch-omap3/sys_proto.h b/include/asm-arm/arch-omap3/sys_proto.h
index 34bd515..cfbc84b 100644
--- a/include/asm-arm/arch-omap3/sys_proto.h
+++ b/include/asm-arm/arch-omap3/sys_proto.h
@@ -31,8 +31,12 @@ void prcm_init(void);
 void per_clocks_enable(void);

 void memif_init(void);
+#if defined(CONFIG_SDRC)
 void sdrc_init(void);
 void do_sdrc_init(u32, u32);
+#elif defined(CONFIG_EMIF4)
+void emif4_init(void);
+#endif
 void gpmc_init(void);
 void enable_gpmc_cs_config(const u32 *gpmc_config, struct gpmc_cs *cs, u32 base,
 			u32 size);
diff --git a/include/configs/am3517_evm.h b/include/configs/am3517_evm.h
index d7eef73..74e52c1 100644
--- a/include/configs/am3517_evm.h
+++ b/include/configs/am3517_evm.h
@@ -62,6 +62,12 @@
 #define CONFIG_SYS_MALLOC_LEN		(CONFIG_ENV_SIZE + (128 << 10))
 #define CONFIG_SYS_GBL_DATA_SIZE	128	/* bytes reserved for */
 						/* initial data */
+
+/*
+ * Support for EMIF4
+ */
+#define CONFIG_EMIF4			1
+
 /*
  * DDR size interfaced
  */
diff --git a/include/configs/devkit8000.h b/include/configs/devkit8000.h
index 1011770..8041416 100644
--- a/include/configs/devkit8000.h
+++ b/include/configs/devkit8000.h
@@ -66,6 +66,10 @@

 /* Hardware drivers */

+/*
+ * Support for SDRC
+ */
+#define CONFIG_SDRC			1
 /* DDR - I use Micron DDR */
 #define CONFIG_OMAP3_MICRON_DDR		1

diff --git a/include/configs/omap3_beagle.h b/include/configs/omap3_beagle.h
index 024b9b8..7fb3434 100644
--- a/include/configs/omap3_beagle.h
+++ b/include/configs/omap3_beagle.h
@@ -97,6 +97,10 @@
 #define CONFIG_OMAP3_MMC		1
 #define CONFIG_DOS_PARTITION		1

+/*
+ * Support for SDRC
+ */
+#define CONFIG_SDRC			1
 /* DDR - I use Micron DDR */
 #define CONFIG_OMAP3_MICRON_DDR		1

diff --git a/include/configs/omap3_evm.h b/include/configs/omap3_evm.h
index 36cb5e0..68e0569 100644
--- a/include/configs/omap3_evm.h
+++ b/include/configs/omap3_evm.h
@@ -101,6 +101,10 @@
 #define CONFIG_OMAP3_MMC		1
 #define CONFIG_DOS_PARTITION		1

+/*
+ * Support for SDRC
+ */
+#define CONFIG_SDRC			1
 /* DDR - I use Micron DDR */
 #define CONFIG_OMAP3_MICRON_DDR		1

diff --git a/include/configs/omap3_overo.h b/include/configs/omap3_overo.h
index 0f812a7..7ae4f0c 100644
--- a/include/configs/omap3_overo.h
+++ b/include/configs/omap3_overo.h
@@ -89,6 +89,10 @@
 #define CONFIG_OMAP3_MMC		1
 #define CONFIG_DOS_PARTITION		1

+/*
+ * Support for SDRC
+ */
+#define CONFIG_SDRC			1
 /* DDR - I use Micron DDR */
 #define CONFIG_OMAP3_MICRON_DDR		1

diff --git a/include/configs/omap3_pandora.h b/include/configs/omap3_pandora.h
index 0cafeb8..45c38bf 100644
--- a/include/configs/omap3_pandora.h
+++ b/include/configs/omap3_pandora.h
@@ -92,6 +92,10 @@
 #define CONFIG_OMAP3_MMC		1
 #define CONFIG_DOS_PARTITION		1

+/*
+ * Support for SDRC
+ */
+#define CONFIG_SDRC			1
 /* DDR - I use Micron DDR */
 #define CONFIG_OMAP3_MICRON_DDR		1

diff --git a/include/configs/omap3_sdp3430.h b/include/configs/omap3_sdp3430.h
index d91c8ff..a8deab5 100644
--- a/include/configs/omap3_sdp3430.h
+++ b/include/configs/omap3_sdp3430.h
@@ -137,6 +137,10 @@
 #define CONFIG_SYS_I2C_BUS_SELECT	1
 #define CONFIG_DRIVER_OMAP34XX_I2C	1

+/*
+ * Support for SDRC
+ */
+#define CONFIG_SDRC			1
 /* DDR - I use Infineon DDR */
 #define CONFIG_OMAP3_INFINEON_DDR	1

diff --git a/include/configs/omap3_zoom1.h b/include/configs/omap3_zoom1.h
index 2aef973..17cb3fb 100644
--- a/include/configs/omap3_zoom1.h
+++ b/include/configs/omap3_zoom1.h
@@ -98,6 +98,10 @@
 #define CONFIG_OMAP3_MMC		1
 #define CONFIG_DOS_PARTITION		1

+/*
+ * Support for SDRC
+ */
+#define CONFIG_SDRC			1
 /* DDR - I use Micron DDR */
 #define CONFIG_OMAP3_MICRON_DDR		1

diff --git a/include/configs/omap3_zoom2.h b/include/configs/omap3_zoom2.h
index 5b03fb6..cf09832 100644
--- a/include/configs/omap3_zoom2.h
+++ b/include/configs/omap3_zoom2.h
@@ -98,6 +98,10 @@
 #define CONFIG_OMAP3_MMC		1
 #define CONFIG_DOS_PARTITION		1

+/*
+ * Support for SDRC
+ */
+#define CONFIG_SDRC			1
 /* DDR - I use Micron DDR */
 #define CONFIG_OMAP3_MICRON_DDR		1

--
1.6.2.4

^ permalink raw reply related	[flat|nested] 263+ messages in thread

* [U-Boot] [PATCH 0/5] Introducing TI's New SoC/board AM3517EVM
  2009-11-23 11:08 ` [U-Boot] [PATCH 0/5] Introducing TI's New SoC/board AM3517EVM hvaibhav at ti.com
@ 2009-11-23 13:50   ` Paulraj, Sandeep
  2009-11-23 14:16     ` Hiremath, Vaibhav
  2009-11-23 20:03     ` Wolfgang Denk
  2009-11-25 20:24   ` Tom
  1 sibling, 2 replies; 263+ messages in thread
From: Paulraj, Sandeep @ 2009-11-23 13:50 UTC (permalink / raw)
  To: u-boot



> 
> From: Vaibhav Hiremath <hvaibhav@ti.com>
> 
> AM3517 device is high-performance, industrial applications processor
> designed
> and developed keeping Software Compatible with OMAP3 Processors.
> 
> Below are some of the useful links -
> AM3517 device is high-performance, industrial applications processor
> designed
> and developed keeping Software Compatible with OMAP3 Processors.
> 
> Below are some of the useful links -
> 
> Migration from OMAP35x to AM35x :-
> http://focus.ti.com/lit/an/sprab91/sprab91.pdf
> 
> Specs/TRM :-
> http://focus.ti.com/docs/prod/folders/print/am3517.html
> 
> EVM Link -:
> http://www.logicpd.com/products/development-kits/zoom-am3517-experimenter-
> kit
> 
> Vaibhav Hiremath (5):
>   Introducing AM3517EVM support
>   am3517_evm_config options added to Makfile
>   Added configuration file for AM3517EVM
>   Added AM3517EVM specific mux configuration to omap3/mux.h
>   AM3517: Add support for EMIF4
> 
>  Makefile                               |    3 +
>  board/ti/am3517evm/Makefile            |   46 ++++
>  board/ti/am3517evm/am3517evm.c         |   76 +++++++
>  board/ti/am3517evm/am3517evm.h         |  388
> ++++++++++++++++++++++++++++++++
>  board/ti/am3517evm/config.mk           |   29 +++
>  cpu/arm_cortexa8/omap3/board.c         |   11 +-
>  cpu/arm_cortexa8/omap3/mem.c           |  110 ++++++++--
>  cpu/arm_cortexa8/omap3/sys_info.c      |   12 +-
>  include/asm-arm/arch-omap3/cpu.h       |   26 +++
>  include/asm-arm/arch-omap3/mem.h       |   66 ++++++-
>  include/asm-arm/arch-omap3/mux.h       |   35 +++
>  include/asm-arm/arch-omap3/sys_proto.h |    4 +
>  include/configs/am3517_evm.h           |  299 ++++++++++++++++++++++++
>  include/configs/devkit8000.h           |    4 +
>  include/configs/omap3_beagle.h         |    4 +
>  include/configs/omap3_evm.h            |    4 +
>  include/configs/omap3_overo.h          |    4 +
>  include/configs/omap3_pandora.h        |    4 +
>  include/configs/omap3_sdp3430.h        |    4 +
>  include/configs/omap3_zoom1.h          |    4 +
>  include/configs/omap3_zoom2.h          |    4 +
>  21 files changed, 1112 insertions(+), 25 deletions(-)
>  create mode 100644 board/ti/am3517evm/Makefile
>  create mode 100644 board/ti/am3517evm/am3517evm.c
>  create mode 100644 board/ti/am3517evm/am3517evm.h
>  create mode 100644 board/ti/am3517evm/config.mk
>  create mode 100644 include/configs/am3517_evm.h

Vaibhav,

We will need entries to MAINTAINERS and MAKEALL as well.

Please submit it when you submit the next set of patches. I am sure you will receive some comments.

I hope you made the patches against the current u-boot-ti/master

Thanks,
Sandeep

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [U-Boot] [PATCH 0/5] Introducing TI's New SoC/board AM3517EVM
  2009-11-23 13:50   ` Paulraj, Sandeep
@ 2009-11-23 14:16     ` Hiremath, Vaibhav
  2009-11-23 20:03     ` Wolfgang Denk
  1 sibling, 0 replies; 263+ messages in thread
From: Hiremath, Vaibhav @ 2009-11-23 14:16 UTC (permalink / raw)
  To: u-boot


> -----Original Message-----
> From: Paulraj, Sandeep
> Sent: Monday, November 23, 2009 7:20 PM
> To: Hiremath, Vaibhav; u-boot at lists.denx.de
> Subject: RE: [PATCH 0/5] Introducing TI's New SoC/board AM3517EVM
> 
> 
> 
> >
> > From: Vaibhav Hiremath <hvaibhav@ti.com>
> >
> > AM3517 device is high-performance, industrial applications
> processor
> > designed
> > and developed keeping Software Compatible with OMAP3 Processors.
> >
> > Below are some of the useful links -
> > AM3517 device is high-performance, industrial applications
> processor
> > designed
> > and developed keeping Software Compatible with OMAP3 Processors.
> >
> > Below are some of the useful links -
> >
> > Migration from OMAP35x to AM35x :-
> > http://focus.ti.com/lit/an/sprab91/sprab91.pdf
> >
> > Specs/TRM :-
> > http://focus.ti.com/docs/prod/folders/print/am3517.html
> >
> > EVM Link -:
> > http://www.logicpd.com/products/development-kits/zoom-am3517-
> experimenter-
> > kit
> >
> > Vaibhav Hiremath (5):
> >   Introducing AM3517EVM support
> >   am3517_evm_config options added to Makfile
> >   Added configuration file for AM3517EVM
> >   Added AM3517EVM specific mux configuration to omap3/mux.h
> >   AM3517: Add support for EMIF4
> >
> >  Makefile                               |    3 +
> >  board/ti/am3517evm/Makefile            |   46 ++++
> >  board/ti/am3517evm/am3517evm.c         |   76 +++++++
> >  board/ti/am3517evm/am3517evm.h         |  388
> > ++++++++++++++++++++++++++++++++
> >  board/ti/am3517evm/config.mk           |   29 +++
> >  cpu/arm_cortexa8/omap3/board.c         |   11 +-
> >  cpu/arm_cortexa8/omap3/mem.c           |  110 ++++++++--
> >  cpu/arm_cortexa8/omap3/sys_info.c      |   12 +-
> >  include/asm-arm/arch-omap3/cpu.h       |   26 +++
> >  include/asm-arm/arch-omap3/mem.h       |   66 ++++++-
> >  include/asm-arm/arch-omap3/mux.h       |   35 +++
> >  include/asm-arm/arch-omap3/sys_proto.h |    4 +
> >  include/configs/am3517_evm.h           |  299
> ++++++++++++++++++++++++
> >  include/configs/devkit8000.h           |    4 +
> >  include/configs/omap3_beagle.h         |    4 +
> >  include/configs/omap3_evm.h            |    4 +
> >  include/configs/omap3_overo.h          |    4 +
> >  include/configs/omap3_pandora.h        |    4 +
> >  include/configs/omap3_sdp3430.h        |    4 +
> >  include/configs/omap3_zoom1.h          |    4 +
> >  include/configs/omap3_zoom2.h          |    4 +
> >  21 files changed, 1112 insertions(+), 25 deletions(-)
> >  create mode 100644 board/ti/am3517evm/Makefile
> >  create mode 100644 board/ti/am3517evm/am3517evm.c
> >  create mode 100644 board/ti/am3517evm/am3517evm.h
> >  create mode 100644 board/ti/am3517evm/config.mk
> >  create mode 100644 include/configs/am3517_evm.h
> 
> Vaibhav,
> 
> We will need entries to MAINTAINERS and MAKEALL as well.
> 
[Hiremath, Vaibhav] Ok, will do that.

> Please submit it when you submit the next set of patches. I am sure
> you will receive some comments.
[Hiremath, Vaibhav] I hope so.
> 
> I hope you made the patches against the current u-boot-ti/master
[Hiremath, Vaibhav] Yes that's correct.

Thanks,
Vaibhav
> 
> Thanks,
> Sandeep

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [U-Boot] [PATCH 1/5] Introducing AM3517EVM support
  2009-11-23 11:06 ` [U-Boot] [PATCH 1/5] Introducing AM3517EVM support hvaibhav at ti.com
@ 2009-11-23 19:43   ` Wolfgang Denk
  2009-11-26  4:24     ` Hiremath, Vaibhav
  0 siblings, 1 reply; 263+ messages in thread
From: Wolfgang Denk @ 2009-11-23 19:43 UTC (permalink / raw)
  To: u-boot

Dear hvaibhav at ti.com,

In message <1258974382-26568-1-git-send-email-hvaibhav@ti.com> you wrote:
> From: Vaibhav Hiremath <hvaibhav@ti.com>
> 
> Changes:-
> 	- Added board specific directory under board/ti/am3517/
> 	- Basic board support.
> 
> Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
> ---
>  board/ti/am3517evm/Makefile      |   46 +++++
>  board/ti/am3517evm/am3517evm.c   |   76 ++++++++
>  board/ti/am3517evm/am3517evm.h   |  388 ++++++++++++++++++++++++++++++++++++++
>  board/ti/am3517evm/config.mk     |   29 +++
>  include/asm-arm/arch-omap3/mem.h |   10 +
>  5 files changed, 549 insertions(+), 0 deletions(-)
>  create mode 100644 board/ti/am3517evm/Makefile
>  create mode 100644 board/ti/am3517evm/am3517evm.c
>  create mode 100644 board/ti/am3517evm/am3517evm.h
>  create mode 100644 board/ti/am3517evm/config.mk
...
> diff --git a/board/ti/am3517evm/am3517evm.h b/board/ti/am3517evm/am3517evm.h
> new file mode 100644
> index 0000000..7897912
> --- /dev/null
> +++ b/board/ti/am3517evm/am3517evm.h
...
> +#define MUX_AM3517EVM() \
> + /*SDRC*/\
> + MUX_VAL(CP(SDRC_D0),		(IEN  | PTD | DIS | M0)) /*SDRC_D0*/\
> + MUX_VAL(CP(SDRC_D1),		(IEN  | PTD | DIS | M0)) /*SDRC_D1*/\
...

Indentation by TAB, please.


Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
There are no data that cannot be plotted on a straight  line  if  the
axis are chosen correctly.

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [U-Boot] [PATCH 2/5] am3517_evm_config options added to Makfile
  2009-11-23 11:08 ` [U-Boot] [PATCH 2/5] am3517_evm_config options added to Makfile hvaibhav at ti.com
@ 2009-11-23 19:44   ` Wolfgang Denk
  2009-11-26  4:25     ` Hiremath, Vaibhav
  0 siblings, 1 reply; 263+ messages in thread
From: Wolfgang Denk @ 2009-11-23 19:44 UTC (permalink / raw)
  To: u-boot

Dear hvaibhav at ti.com,

In message <1258974509-28062-1-git-send-email-hvaibhav@ti.com> you wrote:
> From: Vaibhav Hiremath <hvaibhav@ti.com>
> 
> 
> Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
> ---
>  Makefile |    3 +++
>  1 files changed, 3 insertions(+), 0 deletions(-)

This patch must be part of the commit that adds the code. Don't split
it off.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
When the bosses talk about improving  productivity,  they  are  never
talking about themselves.

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [U-Boot] [PATCH 3/5] Added configuration file for AM3517EVM
  2009-11-23 11:08 ` [U-Boot] [PATCH 3/5] Added configuration file for AM3517EVM hvaibhav at ti.com
@ 2009-11-23 19:46   ` Wolfgang Denk
  2009-11-26  4:43     ` Hiremath, Vaibhav
  0 siblings, 1 reply; 263+ messages in thread
From: Wolfgang Denk @ 2009-11-23 19:46 UTC (permalink / raw)
  To: u-boot

Dear hvaibhav at ti.com,

In message <1258974524-28097-1-git-send-email-hvaibhav@ti.com> you wrote:
> From: Vaibhav Hiremath <hvaibhav@ti.com>
> 
> 
> Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
> ---
>  include/configs/am3517_evm.h |  293 ++++++++++++++++++++++++++++++++++++++++++
>  1 files changed, 293 insertions(+), 0 deletions(-)
>  create mode 100644 include/configs/am3517_evm.h

See before: this patch must be part of the commit that adds the board
code.


> +#ifndef __ASSEMBLY__
> +extern struct gpmc *gpmc_cfg;
> +extern unsigned int boot_flash_base;
> +extern volatile unsigned int boot_flash_env_addr;
> +extern unsigned int boot_flash_off;
> +extern unsigned int boot_flash_sec;
> +extern unsigned int boot_flash_type;
> +#endif

Please add prototype declarations to some appropriate header file
instead.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Es sind ?berhaupt nur die Dummk?pfe, die sich den Befehlen der  M?ch-
tigen  widersetzen.  Um  sie  zu ruinieren ist es genug, ihre Befehle
treu zu erf?llen.                  - Peter Hacks: "Die sch?ne Helena"

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [U-Boot] [PATCH 4/5] AM3517EVM: Add mux configuration
  2009-11-23 11:08 ` [U-Boot] [PATCH 4/5] AM3517EVM: Add mux configuration hvaibhav at ti.com
@ 2009-11-23 19:49   ` Wolfgang Denk
  2009-11-26  4:45     ` Hiremath, Vaibhav
  0 siblings, 1 reply; 263+ messages in thread
From: Wolfgang Denk @ 2009-11-23 19:49 UTC (permalink / raw)
  To: u-boot

Dear hvaibhav at ti.com,

In message <1258974539-28130-1-git-send-email-hvaibhav@ti.com> you wrote:
> From: Vaibhav Hiremath <hvaibhav@ti.com>
> 
> Updated mux.h file for AM3517 specific mux configuration.
> 
> Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
> ---
>  include/asm-arm/arch-omap3/mux.h |   35 +++++++++++++++++++++++++++++++++++
>  1 files changed, 35 insertions(+), 0 deletions(-)
> 
> diff --git a/include/asm-arm/arch-omap3/mux.h b/include/asm-arm/arch-omap3/mux.h
> index 0c01c73..9f06fbb 100644
> --- a/include/asm-arm/arch-omap3/mux.h
> +++ b/include/asm-arm/arch-omap3/mux.h
> @@ -403,6 +403,41 @@
>  #define CONTROL_PADCONF_D2D_SBUSFLAG	0x0260
>  #define CONTROL_PADCONF_SDRC_CKE0	0x0262
>  #define CONTROL_PADCONF_SDRC_CKE1	0x0264
> +/* AM3517 specific */
> +#define CONTROL_PADCONF_CCDC_PCLK       0x01E4
> +#define CONTROL_PADCONF_CCDC_FIELD      0x01E6
> +#define CONTROL_PADCONF_CCDC_HD         0x01E8
> +#define CONTROL_PADCONF_CCDC_VD         0x01EA
> +#define CONTROL_PADCONF_CCDC_WEN        0x01EC
...

Where are these defines used? I think I don't see them in any of the
patches of this patch series?


Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
f u cn rd ths, u cn gt a gd jb n cmptr prgrmmng.

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [U-Boot] [PATCH 5/5] AM3517: Add support for EMIF4
  2009-11-23 11:09 ` [U-Boot] [PATCH 5/5] AM3517: Add support for EMIF4 hvaibhav at ti.com
@ 2009-11-23 19:50   ` Wolfgang Denk
  2009-11-26  4:48     ` Hiremath, Vaibhav
  0 siblings, 1 reply; 263+ messages in thread
From: Wolfgang Denk @ 2009-11-23 19:50 UTC (permalink / raw)
  To: u-boot

Dear hvaibhav at ti.com,

In message <1258974555-28173-1-git-send-email-hvaibhav@ti.com> you wrote:
> From: Vaibhav Hiremath <hvaibhav@ti.com>
> 
> Changes:-
> 
> 	- Created 2 seperate config option
> 		* CONFIG_SDRC (omap34xx family)
> 		* CONFIG_EMIF4 (am3517 family)
> 	- Changed all omap3 dependent file for CONFIG_SDRC
> 
> Tested On:-
> 
>         - AM3517EVM board
>         - OMAP3EVM board
>         - BEAGLE board
> 
> I would need help here from people to validate this change for SDP/ZOOMx
> and other OMAP3 version of boards.

This commit adds a lot of  #ifdef's - maybe it would make more sense
to split code into different files?

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
You are an excellent tactician, Captain. You let your second in  com-
mand attack while you sit and watch for weakness.
	-- Khan Noonian Singh, "Space Seed", stardate 3141.9

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [U-Boot] [PATCH 0/5] Introducing TI's New SoC/board AM3517EVM
  2009-11-23 13:50   ` Paulraj, Sandeep
  2009-11-23 14:16     ` Hiremath, Vaibhav
@ 2009-11-23 20:03     ` Wolfgang Denk
  2009-11-26  4:49       ` Hiremath, Vaibhav
  1 sibling, 1 reply; 263+ messages in thread
From: Wolfgang Denk @ 2009-11-23 20:03 UTC (permalink / raw)
  To: u-boot

Dear "Paulraj, Sandeep",

In message <0554BEF07D437848AF01B9C9B5F0BC5D942DC993@dlee01.ent.ti.com> you wrote:
> 
> I hope you made the patches against the current u-boot-ti/master

Please note that this is a tendency I seriously dislike.


Please do NOT do this.


Please see bullet # 3 at http://www.denx.de/wiki/U-Boot/Patches :

	Please use the "master" branch of the mainline U-Boot git
	repository (git://git.denx.de/u-boot.git) as reference, unless
	(usually late in a release cycle) there has been an
	announcement to use the "next" branch of this repository
	instead.

If we see patches againt any of 30 or so custodian trees, which don't
apply against the "official" master tree, we will see chaos pretty
soon. Please let's make sure there is only minimal difference between
custdian trees and "master" (or "next"), so there is no reason to use
custodian tress as reference for patches instead.


Please _always_ use "master" (or "next") as base for patches!

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
A Perl script is correct if it's halfway readable and  gets  the  job
done before your boss fires you.
                       - L. Wall & R. L. Schwartz, _Programming Perl_

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [U-Boot] [PATCH 0/5] Introducing TI's New SoC/board AM3517EVM
  2009-11-23 11:08 ` [U-Boot] [PATCH 0/5] Introducing TI's New SoC/board AM3517EVM hvaibhav at ti.com
  2009-11-23 13:50   ` Paulraj, Sandeep
@ 2009-11-25 20:24   ` Tom
  1 sibling, 0 replies; 263+ messages in thread
From: Tom @ 2009-11-25 20:24 UTC (permalink / raw)
  To: u-boot

hvaibhav at ti.com wrote:
> From: Vaibhav Hiremath <hvaibhav@ti.com>
> 
> AM3517 device is high-performance, industrial applications processor designed
> and developed keeping Software Compatible with OMAP3 Processors.
> 

On the next revision of your patch set, please run it through
the linux kernel's checkpatch.pl script.  It is a good automated tool
to check basic whitespace issues.

I use checkpatch first when I have to review a large patch set.

Tom

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [U-Boot] [PATCH 1/5] Introducing AM3517EVM support
  2009-11-23 19:43   ` Wolfgang Denk
@ 2009-11-26  4:24     ` Hiremath, Vaibhav
  0 siblings, 0 replies; 263+ messages in thread
From: Hiremath, Vaibhav @ 2009-11-26  4:24 UTC (permalink / raw)
  To: u-boot


> -----Original Message-----
> From: Wolfgang Denk [mailto:wd at denx.de]
> Sent: Tuesday, November 24, 2009 1:13 AM
> To: Hiremath, Vaibhav
> Cc: u-boot at lists.denx.de
> Subject: Re: [U-Boot] [PATCH 1/5] Introducing AM3517EVM support
> 
> Dear hvaibhav at ti.com,
> 
> In message <1258974382-26568-1-git-send-email-hvaibhav@ti.com> you
> wrote:
> > From: Vaibhav Hiremath <hvaibhav@ti.com>
> >
> > Changes:-
> > 	- Added board specific directory under board/ti/am3517/
> > 	- Basic board support.
> >
> > Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
> > ---
> >  board/ti/am3517evm/Makefile      |   46 +++++
> >  board/ti/am3517evm/am3517evm.c   |   76 ++++++++
> >  board/ti/am3517evm/am3517evm.h   |  388
> ++++++++++++++++++++++++++++++++++++++
> >  board/ti/am3517evm/config.mk     |   29 +++
> >  include/asm-arm/arch-omap3/mem.h |   10 +
> >  5 files changed, 549 insertions(+), 0 deletions(-)
> >  create mode 100644 board/ti/am3517evm/Makefile
> >  create mode 100644 board/ti/am3517evm/am3517evm.c
> >  create mode 100644 board/ti/am3517evm/am3517evm.h
> >  create mode 100644 board/ti/am3517evm/config.mk
> ...
> > diff --git a/board/ti/am3517evm/am3517evm.h
> b/board/ti/am3517evm/am3517evm.h
> > new file mode 100644
> > index 0000000..7897912
> > --- /dev/null
> > +++ b/board/ti/am3517evm/am3517evm.h
> ...
> > +#define MUX_AM3517EVM() \
> > + /*SDRC*/\
> > + MUX_VAL(CP(SDRC_D0),		(IEN  | PTD | DIS | M0))
> /*SDRC_D0*/\
> > + MUX_VAL(CP(SDRC_D1),		(IEN  | PTD | DIS | M0))
> /*SDRC_D1*/\
> ...
> 
> Indentation by TAB, please.
> 
[Hiremath, Vaibhav] Ok, Will fix in next version.

Thanks,
Vaibhav
> 
> Best regards,
> 
> Wolfgang Denk
> 
> --
> DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev
> Zundel
> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell,
> Germany
> Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email:
> wd at denx.de
> There are no data that cannot be plotted on a straight  line  if
> the
> axis are chosen correctly.

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [U-Boot] [PATCH 2/5] am3517_evm_config options added to Makfile
  2009-11-23 19:44   ` Wolfgang Denk
@ 2009-11-26  4:25     ` Hiremath, Vaibhav
  0 siblings, 0 replies; 263+ messages in thread
From: Hiremath, Vaibhav @ 2009-11-26  4:25 UTC (permalink / raw)
  To: u-boot


> -----Original Message-----
> From: Wolfgang Denk [mailto:wd at denx.de]
> Sent: Tuesday, November 24, 2009 1:14 AM
> To: Hiremath, Vaibhav
> Cc: u-boot at lists.denx.de
> Subject: Re: [U-Boot] [PATCH 2/5] am3517_evm_config options added to
> Makfile
> 
> Dear hvaibhav at ti.com,
> 
> In message <1258974509-28062-1-git-send-email-hvaibhav@ti.com> you
> wrote:
> > From: Vaibhav Hiremath <hvaibhav@ti.com>
> >
> >
> > Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
> > ---
> >  Makefile |    3 +++
> >  1 files changed, 3 insertions(+), 0 deletions(-)
> 
> This patch must be part of the commit that adds the code. Don't
> split
> it off.
> 
[Hiremath, Vaibhav] Ok, Will fix in next version.

Thanks,
Vaibhav
> Best regards,
> 
> Wolfgang Denk
> 
> --
> DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev
> Zundel
> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell,
> Germany
> Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email:
> wd at denx.de
> When the bosses talk about improving  productivity,  they  are
> never
> talking about themselves.

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [U-Boot] [PATCH 3/5] Added configuration file for AM3517EVM
  2009-11-23 19:46   ` Wolfgang Denk
@ 2009-11-26  4:43     ` Hiremath, Vaibhav
  2009-11-26 16:04       ` Tom
  2009-12-05  0:20       ` Wolfgang Denk
  0 siblings, 2 replies; 263+ messages in thread
From: Hiremath, Vaibhav @ 2009-11-26  4:43 UTC (permalink / raw)
  To: u-boot


> -----Original Message-----
> From: Wolfgang Denk [mailto:wd at denx.de]
> Sent: Tuesday, November 24, 2009 1:16 AM
> To: Hiremath, Vaibhav
> Cc: u-boot at lists.denx.de
> Subject: Re: [U-Boot] [PATCH 3/5] Added configuration file for
> AM3517EVM
> 
> Dear hvaibhav at ti.com,
> 
> In message <1258974524-28097-1-git-send-email-hvaibhav@ti.com> you
> wrote:
> > From: Vaibhav Hiremath <hvaibhav@ti.com>
> >
> >
> > Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
> > ---
> >  include/configs/am3517_evm.h |  293
> ++++++++++++++++++++++++++++++++++++++++++
> >  1 files changed, 293 insertions(+), 0 deletions(-)
> >  create mode 100644 include/configs/am3517_evm.h
> 
> See before: this patch must be part of the commit that adds the
> board
> code.
> 
> 
> > +#ifndef __ASSEMBLY__
> > +extern struct gpmc *gpmc_cfg;
> > +extern unsigned int boot_flash_base;
> > +extern volatile unsigned int boot_flash_env_addr;
> > +extern unsigned int boot_flash_off;
> > +extern unsigned int boot_flash_sec;
> > +extern unsigned int boot_flash_type;
> > +#endif
> 
> Please add prototype declarations to some appropriate header file
> instead.
> 
[Hiremath, Vaibhav] Actually this code is borrowed from OMAP3EVM file, and I think almost all devices handles this same way.

It is bit difficult to handle this, since we are supporting multiple flash devices and these variables are initialized run-time and so the macros below,

CONFIG_SYS_FLASH_BASE,
CONFIG_ENV_OFFSET,
CONFIG_SYS_ENV_SECT_SIZE

I will try to dig bit more on this, but I think as of now we can go with this.

Thanks,
Vaibhav

> Best regards,
> 
> Wolfgang Denk
> 
> --
> DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev
> Zundel
> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell,
> Germany
> Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email:
> wd at denx.de
> Es sind ?berhaupt nur die Dummk?pfe, die sich den Befehlen der
> M?ch-
> tigen  widersetzen.  Um  sie  zu ruinieren ist es genug, ihre
> Befehle
> treu zu erf?llen.                  - Peter Hacks: "Die sch?ne
> Helena"

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [U-Boot] [PATCH 4/5] AM3517EVM: Add mux configuration
  2009-11-23 19:49   ` Wolfgang Denk
@ 2009-11-26  4:45     ` Hiremath, Vaibhav
  2009-11-26 16:07       ` Tom
  2009-12-05  0:23       ` Wolfgang Denk
  0 siblings, 2 replies; 263+ messages in thread
From: Hiremath, Vaibhav @ 2009-11-26  4:45 UTC (permalink / raw)
  To: u-boot

> -----Original Message-----
> From: Wolfgang Denk [mailto:wd at denx.de]
> Sent: Tuesday, November 24, 2009 1:19 AM
> To: Hiremath, Vaibhav
> Cc: u-boot at lists.denx.de
> Subject: Re: [U-Boot] [PATCH 4/5] AM3517EVM: Add mux configuration
> 
> Dear hvaibhav at ti.com,
> 
> In message <1258974539-28130-1-git-send-email-hvaibhav@ti.com> you
> wrote:
> > From: Vaibhav Hiremath <hvaibhav@ti.com>
> >
> > Updated mux.h file for AM3517 specific mux configuration.
> >
> > Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
> > ---
> >  include/asm-arm/arch-omap3/mux.h |   35
> +++++++++++++++++++++++++++++++++++
> >  1 files changed, 35 insertions(+), 0 deletions(-)
> >
> > diff --git a/include/asm-arm/arch-omap3/mux.h b/include/asm-
> arm/arch-omap3/mux.h
> > index 0c01c73..9f06fbb 100644
> > --- a/include/asm-arm/arch-omap3/mux.h
> > +++ b/include/asm-arm/arch-omap3/mux.h
> > @@ -403,6 +403,41 @@
> >  #define CONTROL_PADCONF_D2D_SBUSFLAG	0x0260
> >  #define CONTROL_PADCONF_SDRC_CKE0	0x0262
> >  #define CONTROL_PADCONF_SDRC_CKE1	0x0264
> > +/* AM3517 specific */
> > +#define CONTROL_PADCONF_CCDC_PCLK       0x01E4
> > +#define CONTROL_PADCONF_CCDC_FIELD      0x01E6
> > +#define CONTROL_PADCONF_CCDC_HD         0x01E8
> > +#define CONTROL_PADCONF_CCDC_VD         0x01EA
> > +#define CONTROL_PADCONF_CCDC_WEN        0x01EC
> ...
> 
> Where are these defines used? I think I don't see them in any of the
> patches of this patch series?
> 
[Hiremath, Vaibhav] These are being used in board/ty/am3517/am3517evm.c file under the function set_muxconf_regs().

Thanks,
Vaibhav

> 
> Best regards,
> 
> Wolfgang Denk
> 
> --
> DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev
> Zundel
> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell,
> Germany
> Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email:
> wd at denx.de
> f u cn rd ths, u cn gt a gd jb n cmptr prgrmmng.

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [U-Boot] [PATCH 5/5] AM3517: Add support for EMIF4
  2009-11-23 19:50   ` Wolfgang Denk
@ 2009-11-26  4:48     ` Hiremath, Vaibhav
  2009-11-26 16:14       ` Tom
  0 siblings, 1 reply; 263+ messages in thread
From: Hiremath, Vaibhav @ 2009-11-26  4:48 UTC (permalink / raw)
  To: u-boot


> -----Original Message-----
> From: Wolfgang Denk [mailto:wd at denx.de]
> Sent: Tuesday, November 24, 2009 1:21 AM
> To: Hiremath, Vaibhav
> Cc: u-boot at lists.denx.de
> Subject: Re: [U-Boot] [PATCH 5/5] AM3517: Add support for EMIF4
> 
> Dear hvaibhav at ti.com,
> 
> In message <1258974555-28173-1-git-send-email-hvaibhav@ti.com> you
> wrote:
> > From: Vaibhav Hiremath <hvaibhav@ti.com>
> >
> > Changes:-
> >
> > 	- Created 2 seperate config option
> > 		* CONFIG_SDRC (omap34xx family)
> > 		* CONFIG_EMIF4 (am3517 family)
> > 	- Changed all omap3 dependent file for CONFIG_SDRC
> >
> > Tested On:-
> >
> >         - AM3517EVM board
> >         - OMAP3EVM board
> >         - BEAGLE board
> >
> > I would need help here from people to validate this change for
> SDP/ZOOMx
> > and other OMAP3 version of boards.
> 
> This commit adds a lot of  #ifdef's - maybe it would make more sense
> to split code into different files?
> 
[Hiremath, Vaibhav] Initially I thought of this, but since currently AM3517 is the only device in OMAP3 series which uses EMIF and all others use SDRC. So I thought lets start with this approach and get peoples opinion on this, and then we can split the files.

Thanks,
Vaibhav

> Best regards,
> 
> Wolfgang Denk
> 
> --
> DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev
> Zundel
> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell,
> Germany
> Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email:
> wd at denx.de
> You are an excellent tactician, Captain. You let your second in
> com-
> mand attack while you sit and watch for weakness.
> 	-- Khan Noonian Singh, "Space Seed", stardate 3141.9

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [U-Boot] [PATCH 0/5] Introducing TI's New SoC/board AM3517EVM
  2009-11-23 20:03     ` Wolfgang Denk
@ 2009-11-26  4:49       ` Hiremath, Vaibhav
  0 siblings, 0 replies; 263+ messages in thread
From: Hiremath, Vaibhav @ 2009-11-26  4:49 UTC (permalink / raw)
  To: u-boot


> -----Original Message-----
> From: Wolfgang Denk [mailto:wd at denx.de]
> Sent: Tuesday, November 24, 2009 1:33 AM
> To: Paulraj, Sandeep
> Cc: Hiremath, Vaibhav; u-boot at lists.denx.de
> Subject: Re: [U-Boot] [PATCH 0/5] Introducing TI's New SoC/board
> AM3517EVM
> 
> Dear "Paulraj, Sandeep",
> 
> In message
> <0554BEF07D437848AF01B9C9B5F0BC5D942DC993@dlee01.ent.ti.com> you
> wrote:
> >
> > I hope you made the patches against the current u-boot-ti/master
> 
> Please note that this is a tendency I seriously dislike.
> 
> 
> Please do NOT do this.
> 
> 
> Please see bullet # 3 at http://www.denx.de/wiki/U-Boot/Patches :
> 
> 	Please use the "master" branch of the mainline U-Boot git
> 	repository (git://git.denx.de/u-boot.git) as reference, unless
> 	(usually late in a release cycle) there has been an
> 	announcement to use the "next" branch of this repository
> 	instead.
> 
> If we see patches againt any of 30 or so custodian trees, which
> don't
> apply against the "official" master tree, we will see chaos pretty
> soon. Please let's make sure there is only minimal difference
> between
> custdian trees and "master" (or "next"), so there is no reason to
> use
> custodian tress as reference for patches instead.
> 
> 
> Please _always_ use "master" (or "next") as base for patches!
> 
[Hiremath, Vaibhav] Before submitting patch I conformed that the patches gets applied on master branch cleanly.

Thanks,
Vaibhav

> Best regards,
> 
> Wolfgang Denk
> 
> --
> DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev
> Zundel
> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell,
> Germany
> Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email:
> wd at denx.de
> A Perl script is correct if it's halfway readable and  gets  the
> job
> done before your boss fires you.
>                        - L. Wall & R. L. Schwartz, _Programming
> Perl_

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [U-Boot] [PATCH 3/5] Added configuration file for AM3517EVM
  2009-11-26  4:43     ` Hiremath, Vaibhav
@ 2009-11-26 16:04       ` Tom
  2009-11-30 17:01         ` Hiremath, Vaibhav
  2009-12-05  0:20       ` Wolfgang Denk
  1 sibling, 1 reply; 263+ messages in thread
From: Tom @ 2009-11-26 16:04 UTC (permalink / raw)
  To: u-boot

Hiremath, Vaibhav wrote:
>> -----Original Message-----
>> From: Wolfgang Denk [mailto:wd at denx.de]
>> Sent: Tuesday, November 24, 2009 1:16 AM
>> To: Hiremath, Vaibhav
>> Cc: u-boot at lists.denx.de
>> Subject: Re: [U-Boot] [PATCH 3/5] Added configuration file for
>> AM3517EVM
>>
>> Dear hvaibhav at ti.com,
>>
>> In message <1258974524-28097-1-git-send-email-hvaibhav@ti.com> you
>> wrote:
>>> From: Vaibhav Hiremath <hvaibhav@ti.com>
>>>
>>>
>>> Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
>>> ---
>>>  include/configs/am3517_evm.h |  293
>> ++++++++++++++++++++++++++++++++++++++++++
>>>  1 files changed, 293 insertions(+), 0 deletions(-)
>>>  create mode 100644 include/configs/am3517_evm.h
>> See before: this patch must be part of the commit that adds the
>> board
>> code.
>>
>>
>>> +#ifndef __ASSEMBLY__
>>> +extern struct gpmc *gpmc_cfg;
>>> +extern unsigned int boot_flash_base;
>>> +extern volatile unsigned int boot_flash_env_addr;
>>> +extern unsigned int boot_flash_off;
>>> +extern unsigned int boot_flash_sec;
>>> +extern unsigned int boot_flash_type;
>>> +#endif
>> Please add prototype declarations to some appropriate header file
>> instead.
>>
> [Hiremath, Vaibhav] Actually this code is borrowed from OMAP3EVM file, and I think almost all devices handles this same way.
> 
> It is bit difficult to handle this, since we are supporting multiple flash devices and these variables are initialized run-time and so the macros below,
> 
> CONFIG_SYS_FLASH_BASE,
> CONFIG_ENV_OFFSET,
> CONFIG_SYS_ENV_SECT_SIZE
> 
> I will try to dig bit more on this, but I think as of now we can go with this.

This code is changing so you may want to wait on investing a lot of
effort into it.  Please see the CM-T35 board submission.
Please review what is already been proposed to fix this for all the omap3's and
comment.

Tom

> 
> Thanks,
> Vaibhav
> 
>> Best regards,
>>
>> Wolfgang Denk

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [U-Boot] [PATCH 4/5] AM3517EVM: Add mux configuration
  2009-11-26  4:45     ` Hiremath, Vaibhav
@ 2009-11-26 16:07       ` Tom
  2009-12-05  0:23       ` Wolfgang Denk
  1 sibling, 0 replies; 263+ messages in thread
From: Tom @ 2009-11-26 16:07 UTC (permalink / raw)
  To: u-boot

Hiremath, Vaibhav wrote:
>> -----Original Message-----
>> From: Wolfgang Denk [mailto:wd at denx.de]
>> Sent: Tuesday, November 24, 2009 1:19 AM
>> To: Hiremath, Vaibhav
>> Cc: u-boot at lists.denx.de
>> Subject: Re: [U-Boot] [PATCH 4/5] AM3517EVM: Add mux configuration
>>
>> Dear hvaibhav at ti.com,
>>
>> In message <1258974539-28130-1-git-send-email-hvaibhav@ti.com> you
>> wrote:
>>> From: Vaibhav Hiremath <hvaibhav@ti.com>
>>>
>>> Updated mux.h file for AM3517 specific mux configuration.
>>>
>>> Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
>>> ---
>>>  include/asm-arm/arch-omap3/mux.h |   35
>> +++++++++++++++++++++++++++++++++++
>>>  1 files changed, 35 insertions(+), 0 deletions(-)
>>>
>>> diff --git a/include/asm-arm/arch-omap3/mux.h b/include/asm-
>> arm/arch-omap3/mux.h
>>> index 0c01c73..9f06fbb 100644
>>> --- a/include/asm-arm/arch-omap3/mux.h
>>> +++ b/include/asm-arm/arch-omap3/mux.h
>>> @@ -403,6 +403,41 @@
>>>  #define CONTROL_PADCONF_D2D_SBUSFLAG	0x0260
>>>  #define CONTROL_PADCONF_SDRC_CKE0	0x0262
>>>  #define CONTROL_PADCONF_SDRC_CKE1	0x0264
>>> +/* AM3517 specific */
>>> +#define CONTROL_PADCONF_CCDC_PCLK       0x01E4
>>> +#define CONTROL_PADCONF_CCDC_FIELD      0x01E6
>>> +#define CONTROL_PADCONF_CCDC_HD         0x01E8
>>> +#define CONTROL_PADCONF_CCDC_VD         0x01EA
>>> +#define CONTROL_PADCONF_CCDC_WEN        0x01EC
>> ...
>>
>> Where are these defines used? I think I don't see them in any of the
>> patches of this patch series?
>>
> [Hiremath, Vaibhav] These are being used in board/ty/am3517/am3517evm.c file under the function set_muxconf_regs().
> 

It seems like these defines are only going to be used by the am3517.
If this is so, please move them to a board specific file.

Tom

> Thanks,
> Vaibhav
> 
>> Best regards,
>>
>> Wolfgang Denk

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [U-Boot] [PATCH 5/5] AM3517: Add support for EMIF4
  2009-11-26  4:48     ` Hiremath, Vaibhav
@ 2009-11-26 16:14       ` Tom
  2009-11-30 17:03         ` Hiremath, Vaibhav
  0 siblings, 1 reply; 263+ messages in thread
From: Tom @ 2009-11-26 16:14 UTC (permalink / raw)
  To: u-boot

Hiremath, Vaibhav wrote:
>> -----Original Message-----
>> From: Wolfgang Denk [mailto:wd at denx.de]
>> Sent: Tuesday, November 24, 2009 1:21 AM
>> To: Hiremath, Vaibhav
>> Cc: u-boot at lists.denx.de
>> Subject: Re: [U-Boot] [PATCH 5/5] AM3517: Add support for EMIF4
>>
>> Dear hvaibhav at ti.com,
>>
>> In message <1258974555-28173-1-git-send-email-hvaibhav@ti.com> you
>> wrote:
>>> From: Vaibhav Hiremath <hvaibhav@ti.com>
>>>
>>> Changes:-
>>>
>>> 	- Created 2 seperate config option
>>> 		* CONFIG_SDRC (omap34xx family)
>>> 		* CONFIG_EMIF4 (am3517 family)
>>> 	- Changed all omap3 dependent file for CONFIG_SDRC
>>>
>>> Tested On:-
>>>
>>>         - AM3517EVM board
>>>         - OMAP3EVM board
>>>         - BEAGLE board
>>>
>>> I would need help here from people to validate this change for
>> SDP/ZOOMx
>>> and other OMAP3 version of boards.
>> This commit adds a lot of  #ifdef's - maybe it would make more sense
>> to split code into different files?
>>
> [Hiremath, Vaibhav] Initially I thought of this, but since currently AM3517 is the only device in OMAP3 series which uses EMIF and all others use SDRC. So I thought lets start with this approach and get peoples opinion on this, and then we can split the files.
>

Please split this patch.
Add the logic for the exiting boards as the first patch.
Add the logic for the am3517 as the second.
This will allow this change to be bisected.

I would prefer each set of defines to have their own file.

Tom

> Thanks,
> Vaibhav
> 
>> Best regards,
>>
>> Wolfgang Denk
>>
>> --
>> DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev
>> Zundel
>> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell,
>> Germany
>> Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email:
>> wd at denx.de
>> You are an excellent tactician, Captain. You let your second in
>> com-
>> mand attack while you sit and watch for weakness.
>> 	-- Khan Noonian Singh, "Space Seed", stardate 3141.9
> _______________________________________________
> U-Boot mailing list
> U-Boot at lists.denx.de
> http://lists.denx.de/mailman/listinfo/u-boot

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [U-Boot] [PATCH] omap3_mmc: Encapsulate twl4030 under option CONFIG_TWL4030_POWER
  2009-11-23 11:06 ` [U-Boot] [PATCH] omap3_mmc: Encapsulate twl4030 under option CONFIG_TWL4030_POWER hvaibhav at ti.com
@ 2009-11-27 14:03   ` Tom
  2009-11-30 17:43     ` Hiremath, Vaibhav
  0 siblings, 1 reply; 263+ messages in thread
From: Tom @ 2009-11-27 14:03 UTC (permalink / raw)
  To: u-boot

hvaibhav at ti.com wrote:
> From: Vaibhav Hiremath <hvaibhav@ti.com>
> 
> Fixes the build/compilation error if we try to re-use the omap3_mmc code
> without TWL4030_POWER.
> 
> Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>

This is fine.
I have pushed this to arm/next.

Thanks
Tom

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [U-Boot] [PATCH V4] OMAP3EVM: Added NAND support
  2009-11-23 11:05 ` [U-Boot] [PATCH V4] " hvaibhav at ti.com
@ 2009-11-27 15:51   ` Tom
  2009-11-30 17:49     ` Hiremath, Vaibhav
  0 siblings, 1 reply; 263+ messages in thread
From: Tom @ 2009-11-27 15:51 UTC (permalink / raw)
  To: u-boot

hvaibhav at ti.com wrote:
> From: Vaibhav Hiremath <hvaibhav@ti.com>
> 
> The EVMS have been shipping with NAND (instead of OneNAND) as default. So, this
> patch sets NAND as default.
> 
> To choose OneNAND, define CMD_ONENAND instead of CMD_NAND in the config file
> omap3_evm.h
> 
> Changes from V3 :-
> 	- Added undef statement for CMD_ONENAND.
> 

This is looking good.
Is there interest in making the onenand a makefile config option?
It would depend on how common the onenand boards are.
Tom

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [U-Boot] [PATCH 3/5] Added configuration file for AM3517EVM
  2009-11-26 16:04       ` Tom
@ 2009-11-30 17:01         ` Hiremath, Vaibhav
  0 siblings, 0 replies; 263+ messages in thread
From: Hiremath, Vaibhav @ 2009-11-30 17:01 UTC (permalink / raw)
  To: u-boot


> -----Original Message-----
> From: Tom [mailto:Tom.Rix at windriver.com]
> Sent: Thursday, November 26, 2009 9:34 PM
> To: Hiremath, Vaibhav
> Cc: Wolfgang Denk; u-boot at lists.denx.de
> Subject: Re: [U-Boot] [PATCH 3/5] Added configuration file for
> AM3517EVM
> 
> Hiremath, Vaibhav wrote:
> >> -----Original Message-----
> >> From: Wolfgang Denk [mailto:wd at denx.de]
> >> Sent: Tuesday, November 24, 2009 1:16 AM
> >> To: Hiremath, Vaibhav
> >> Cc: u-boot at lists.denx.de
> >> Subject: Re: [U-Boot] [PATCH 3/5] Added configuration file for
> >> AM3517EVM
> >>
> >> Dear hvaibhav at ti.com,
> >>
> >> In message <1258974524-28097-1-git-send-email-hvaibhav@ti.com>
> you
> >> wrote:
> >>> From: Vaibhav Hiremath <hvaibhav@ti.com>
> >>>
> >>>
> >>> Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
> >>> ---
> >>>  include/configs/am3517_evm.h |  293
> >> ++++++++++++++++++++++++++++++++++++++++++
> >>>  1 files changed, 293 insertions(+), 0 deletions(-)
> >>>  create mode 100644 include/configs/am3517_evm.h
> >> See before: this patch must be part of the commit that adds the
> >> board
> >> code.
> >>
> >>
> >>> +#ifndef __ASSEMBLY__
> >>> +extern struct gpmc *gpmc_cfg;
> >>> +extern unsigned int boot_flash_base;
> >>> +extern volatile unsigned int boot_flash_env_addr;
> >>> +extern unsigned int boot_flash_off;
> >>> +extern unsigned int boot_flash_sec;
> >>> +extern unsigned int boot_flash_type;
> >>> +#endif
> >> Please add prototype declarations to some appropriate header file
> >> instead.
> >>
> > [Hiremath, Vaibhav] Actually this code is borrowed from OMAP3EVM
> file, and I think almost all devices handles this same way.
> >
> > It is bit difficult to handle this, since we are supporting
> multiple flash devices and these variables are initialized run-time
> and so the macros below,
> >
> > CONFIG_SYS_FLASH_BASE,
> > CONFIG_ENV_OFFSET,
> > CONFIG_SYS_ENV_SECT_SIZE
> >
> > I will try to dig bit more on this, but I think as of now we can
> go with this.
> 
> This code is changing so you may want to wait on investing a lot of
> effort into it.  Please see the CM-T35 board submission.
> Please review what is already been proposed to fix this for all the
> omap3's and
> comment.
> 
[Hiremath, Vaibhav] Thanks for pointing me to this, I will definitely go through this and get back to you if I have any issues/questions.

Thanks,
Vaibhav

> Tom
> 
> >
> > Thanks,
> > Vaibhav
> >
> >> Best regards,
> >>
> >> Wolfgang Denk

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [U-Boot] [PATCH 5/5] AM3517: Add support for EMIF4
  2009-11-26 16:14       ` Tom
@ 2009-11-30 17:03         ` Hiremath, Vaibhav
  0 siblings, 0 replies; 263+ messages in thread
From: Hiremath, Vaibhav @ 2009-11-30 17:03 UTC (permalink / raw)
  To: u-boot


> -----Original Message-----
> From: Tom [mailto:Tom.Rix at windriver.com]
> Sent: Thursday, November 26, 2009 9:44 PM
> To: Hiremath, Vaibhav
> Cc: Wolfgang Denk; u-boot at lists.denx.de
> Subject: Re: [U-Boot] [PATCH 5/5] AM3517: Add support for EMIF4
> 
> Hiremath, Vaibhav wrote:
> >> -----Original Message-----
> >> From: Wolfgang Denk [mailto:wd at denx.de]
> >> Sent: Tuesday, November 24, 2009 1:21 AM
> >> To: Hiremath, Vaibhav
> >> Cc: u-boot at lists.denx.de
> >> Subject: Re: [U-Boot] [PATCH 5/5] AM3517: Add support for EMIF4
> >>
> >> Dear hvaibhav at ti.com,
> >>
> >> In message <1258974555-28173-1-git-send-email-hvaibhav@ti.com>
> you
> >> wrote:
> >>> From: Vaibhav Hiremath <hvaibhav@ti.com>
> >>>
> >>> Changes:-
> >>>
> >>> 	- Created 2 seperate config option
> >>> 		* CONFIG_SDRC (omap34xx family)
> >>> 		* CONFIG_EMIF4 (am3517 family)
> >>> 	- Changed all omap3 dependent file for CONFIG_SDRC
> >>>
> >>> Tested On:-
> >>>
> >>>         - AM3517EVM board
> >>>         - OMAP3EVM board
> >>>         - BEAGLE board
> >>>
> >>> I would need help here from people to validate this change for
> >> SDP/ZOOMx
> >>> and other OMAP3 version of boards.
> >> This commit adds a lot of  #ifdef's - maybe it would make more
> sense
> >> to split code into different files?
> >>
> > [Hiremath, Vaibhav] Initially I thought of this, but since
> currently AM3517 is the only device in OMAP3 series which uses EMIF
> and all others use SDRC. So I thought lets start with this approach
> and get peoples opinion on this, and then we can split the files.
> >
> 
> Please split this patch.
> Add the logic for the exiting boards as the first patch.
> Add the logic for the am3517 as the second.
> This will allow this change to be bisected.
> 
[Hiremath, Vaibhav] Ok, will do in next version.

> I would prefer each set of defines to have their own file.
[Hiremath, Vaibhav] How about taking this is second version?

Thanks,
Vaibhav

> 
> Tom
> 
> > Thanks,
> > Vaibhav
> >
> >> Best regards,
> >>
> >> Wolfgang Denk
> >>
> >> --
> >> DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev
> >> Zundel
> >> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell,
> >> Germany
> >> Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email:
> >> wd at denx.de
> >> You are an excellent tactician, Captain. You let your second in
> >> com-
> >> mand attack while you sit and watch for weakness.
> >> 	-- Khan Noonian Singh, "Space Seed", stardate 3141.9
> > _______________________________________________
> > U-Boot mailing list
> > U-Boot at lists.denx.de
> > http://lists.denx.de/mailman/listinfo/u-boot

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [U-Boot] [PATCH] omap3_mmc: Encapsulate twl4030 under option CONFIG_TWL4030_POWER
  2009-11-27 14:03   ` Tom
@ 2009-11-30 17:43     ` Hiremath, Vaibhav
  0 siblings, 0 replies; 263+ messages in thread
From: Hiremath, Vaibhav @ 2009-11-30 17:43 UTC (permalink / raw)
  To: u-boot


> -----Original Message-----
> From: Tom [mailto:Tom.Rix at windriver.com]
> Sent: Friday, November 27, 2009 7:34 PM
> To: Hiremath, Vaibhav
> Cc: u-boot at lists.denx.de
> Subject: Re: [U-Boot] [PATCH] omap3_mmc: Encapsulate twl4030 under
> option CONFIG_TWL4030_POWER
> 
> hvaibhav at ti.com wrote:
> > From: Vaibhav Hiremath <hvaibhav@ti.com>
> >
> > Fixes the build/compilation error if we try to re-use the
> omap3_mmc code
> > without TWL4030_POWER.
> >
> > Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
> 
> This is fine.
> I have pushed this to arm/next.
> 
[Hiremath, Vaibhav] Thanks, 

Thanks,
Vaibhav

> Thanks
> Tom

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [U-Boot] [PATCH V4] OMAP3EVM: Added NAND support
  2009-11-27 15:51   ` Tom
@ 2009-11-30 17:49     ` Hiremath, Vaibhav
  0 siblings, 0 replies; 263+ messages in thread
From: Hiremath, Vaibhav @ 2009-11-30 17:49 UTC (permalink / raw)
  To: u-boot


> -----Original Message-----
> From: Tom [mailto:Tom.Rix at windriver.com]
> Sent: Friday, November 27, 2009 9:21 PM
> To: Hiremath, Vaibhav
> Cc: u-boot at lists.denx.de
> Subject: Re: [U-Boot] [PATCH V4] OMAP3EVM: Added NAND support
> 
> hvaibhav at ti.com wrote:
> > From: Vaibhav Hiremath <hvaibhav@ti.com>
> >
> > The EVMS have been shipping with NAND (instead of OneNAND) as
> default. So, this
> > patch sets NAND as default.
> >
> > To choose OneNAND, define CMD_ONENAND instead of CMD_NAND in the
> config file
> > omap3_evm.h
> >
> > Changes from V3 :-
> > 	- Added undef statement for CMD_ONENAND.
> >
> 
> This is looking good.
> Is there interest in making the onenand a makefile config option?
> It would depend on how common the onenand boards are.
[Hiremath, Vaibhav] As far as I know, majority of the EVM's shipping out are with NAND parts, so should be safe to move to NAND as a default.

Thanks,
Vaibhav

> Tom

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [U-Boot] [PATCH 3/5] Added configuration file for AM3517EVM
  2009-11-26  4:43     ` Hiremath, Vaibhav
  2009-11-26 16:04       ` Tom
@ 2009-12-05  0:20       ` Wolfgang Denk
  1 sibling, 0 replies; 263+ messages in thread
From: Wolfgang Denk @ 2009-12-05  0:20 UTC (permalink / raw)
  To: u-boot

Dear "Hiremath, Vaibhav",

In message <19F8576C6E063C45BE387C64729E739404370D7ACC@dbde02.ent.ti.com> you wrote:
> 
...
> > > +#ifndef __ASSEMBLY__
> > > +extern struct gpmc *gpmc_cfg;
> > > +extern unsigned int boot_flash_base;
> > > +extern volatile unsigned int boot_flash_env_addr;
> > > +extern unsigned int boot_flash_off;
> > > +extern unsigned int boot_flash_sec;
> > > +extern unsigned int boot_flash_type;
> > > +#endif
> > 
> > Please add prototype declarations to some appropriate header file
> > instead.
> > 
> [Hiremath, Vaibhav] Actually this code is borrowed from OMAP3EVM file, and
> I think almost all devices handles this same way.

Yes, this escaped us before - but now we got aware of this problem we
don't want to add more of this (and clean up the existing code ASAP).

> It is bit difficult to handle this, since we are supporting multiple flash
> devices and these variables are initialized run-time and so the macros below,
>
> CONFIG_SYS_FLASH_BASE,
> CONFIG_ENV_OFFSET,
> CONFIG_SYS_ENV_SECT_SIZE

Um... I cannot parse this senstence. Some words seem to be missing?

> I will try to dig bit more on this, but I think as of now we can go with this.

Sorry, I disagree.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
The IQ of the group is the lowest IQ of a member of the group divided
by the number of people in the group.

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [U-Boot] [PATCH 4/5] AM3517EVM: Add mux configuration
  2009-11-26  4:45     ` Hiremath, Vaibhav
  2009-11-26 16:07       ` Tom
@ 2009-12-05  0:23       ` Wolfgang Denk
  1 sibling, 0 replies; 263+ messages in thread
From: Wolfgang Denk @ 2009-12-05  0:23 UTC (permalink / raw)
  To: u-boot

Dear "Hiremath, Vaibhav",

In message <19F8576C6E063C45BE387C64729E739404370D7ACF@dbde02.ent.ti.com> you wrote:
>
> > >  #define CONTROL_PADCONF_D2D_SBUSFLAG	0x0260
> > >  #define CONTROL_PADCONF_SDRC_CKE0	0x0262
> > >  #define CONTROL_PADCONF_SDRC_CKE1	0x0264
> > > +/* AM3517 specific */
> > > +#define CONTROL_PADCONF_CCDC_PCLK       0x01E4
> > > +#define CONTROL_PADCONF_CCDC_FIELD      0x01E6
> > > +#define CONTROL_PADCONF_CCDC_HD         0x01E8
> > > +#define CONTROL_PADCONF_CCDC_VD         0x01EA
> > > +#define CONTROL_PADCONF_CCDC_WEN        0x01EC
> > ...
> > 
> > Where are these defines used? I think I don't see them in any of the
> > patches of this patch series?
> > 
> [Hiremath, Vaibhav] These are being used in board/ty/am3517/am3517evm.c
> file under the function set_muxconf_regs().

As Tom noted it probably makes sense to move these to a board specific
file.

But then, this looks very much like register offsets for some device.
If this should be the case, plase make sure to convert this into a C
struct and use appropriate accesor macros.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
The so-called "desktop metaphor" of today's workstations  is  instead
an  "airplane-seat"  metaphor.  Anyone who has shuffled a lap full of
papers while seated between two portly passengers will recognize  the
difference -- one can see only a very few things at once.
                                                   - Fred Brooks, Jr.

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [U-Boot] [PATCH 0/3] Add Support for AM3517EVM with EMIF4
@ 2010-01-30 10:16 ` hvaibhav at ti.com
  2010-02-02 18:40   ` Hiremath, Vaibhav
  0 siblings, 1 reply; 263+ messages in thread
From: hvaibhav at ti.com @ 2010-01-30 10:16 UTC (permalink / raw)
  To: u-boot

From: Vaibhav Hiremath <hvaibhav@ti.com>

AM3517 device is high-performance, industrial applications processor designed
and developed keeping Software Compatible with OMAP3 Processors.

Differances :-
===========
	- The SDRC controller has been replaced with EMIF4.
	- Some new IP's got added like, CAN, VPFE, etc...
	- Removed ISP completely

This patch series adds support for AM3517EVM along with EMIF4 configuration.

Tested :-
===========
	- OMAP3 EVM (both NAND and MMC boot mode)
	- OMAP3 BEAGLE (MMC boot mode)
	- AM3517 EVM (both NAND and MMC boot mode)

Below are some of the useful links :-
===========
AM3517 device is high-performance, industrial applications processor designed
and developed keeping Software Compatible with OMAP3 Processors.

Below are some of the useful links -

Migration from OMAP35x to AM35x :-
http://focus.ti.com/lit/an/sprab91/sprab91.pdf

Specs/TRM :-
http://focus.ti.com/docs/prod/folders/print/am3517.html

EVM Link -:
http://www.logicpd.com/products/development-kits/zoom-am3517-experimenter-kit


Vaibhav Hiremath (3):
  OMAP3: Consolidate SDRC related operations
  AM35x: Add support for AM3517EVM
  AM35x: Add support for EMIF4

 MAINTAINERS                            |    4 +
 Makefile                               |    3 +
 board/ti/am3517evm/Makefile            |   47 ++++
 board/ti/am3517evm/am3517evm.c         |   76 ++++++
 board/ti/am3517evm/am3517evm.h         |  400 ++++++++++++++++++++++++++++++++
 board/ti/am3517evm/config.mk           |   29 +++
 cpu/arm_cortexa8/omap3/Makefile        |    6 +
 cpu/arm_cortexa8/omap3/board.c         |   34 +---
 cpu/arm_cortexa8/omap3/emif4.c         |  160 +++++++++++++
 cpu/arm_cortexa8/omap3/mem.c           |   90 -------
 cpu/arm_cortexa8/omap3/sdrc.c          |  186 +++++++++++++++
 cpu/arm_cortexa8/omap3/sys_info.c      |   42 +----
 include/asm-arm/arch-omap3/cpu.h       |   26 ++
 include/asm-arm/arch-omap3/emif4.h     |   77 ++++++
 include/asm-arm/arch-omap3/mem.h       |   24 ++
 include/asm-arm/arch-omap3/mux.h       |   35 +++
 include/asm-arm/arch-omap3/sys_proto.h |    7 +-
 include/configs/am3517_evm.h           |  293 +++++++++++++++++++++++
 include/configs/omap3_beagle.h         |    2 +
 include/configs/omap3_evm.h            |    2 +
 include/configs/omap3_overo.h          |    2 +
 include/configs/omap3_pandora.h        |    2 +
 include/configs/omap3_sdp3430.h        |    2 +
 include/configs/omap3_zoom1.h          |    2 +
 include/configs/omap3_zoom2.h          |    2 +
 25 files changed, 1387 insertions(+), 166 deletions(-)
 create mode 100644 board/ti/am3517evm/Makefile
 create mode 100644 board/ti/am3517evm/am3517evm.c
 create mode 100644 board/ti/am3517evm/am3517evm.h
 create mode 100644 board/ti/am3517evm/config.mk
 create mode 100644 cpu/arm_cortexa8/omap3/emif4.c
 create mode 100644 cpu/arm_cortexa8/omap3/sdrc.c
 create mode 100644 include/asm-arm/arch-omap3/emif4.h
 create mode 100644 include/configs/am3517_evm.h

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [U-Boot] [PATCH 1/3] OMAP3: Consolidate SDRC related operations
@ 2010-01-30 10:16 ` hvaibhav at ti.com
  2010-02-07 16:13   ` Tom
  0 siblings, 1 reply; 263+ messages in thread
From: hvaibhav at ti.com @ 2010-01-30 10:16 UTC (permalink / raw)
  To: u-boot

From: Vaibhav Hiremath <hvaibhav@ti.com>

Consolidated all SDRC related functions/operations into separate
file - sdrc.c.

Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
Signed-off-by: Sanjeev Premi <premi@ti.com>
---
 cpu/arm_cortexa8/omap3/Makefile        |    3 +
 cpu/arm_cortexa8/omap3/board.c         |   34 +------
 cpu/arm_cortexa8/omap3/mem.c           |   90 ---------------
 cpu/arm_cortexa8/omap3/sdrc.c          |  186 ++++++++++++++++++++++++++++++++
 cpu/arm_cortexa8/omap3/sys_info.c      |   42 +-------
 include/asm-arm/arch-omap3/mem.h       |   14 +++
 include/asm-arm/arch-omap3/sys_proto.h |    4 +-
 include/configs/omap3_beagle.h         |    2 +
 include/configs/omap3_evm.h            |    2 +
 include/configs/omap3_overo.h          |    2 +
 include/configs/omap3_pandora.h        |    2 +
 include/configs/omap3_sdp3430.h        |    2 +
 include/configs/omap3_zoom1.h          |    2 +
 include/configs/omap3_zoom2.h          |    2 +
 14 files changed, 221 insertions(+), 166 deletions(-)
 create mode 100644 cpu/arm_cortexa8/omap3/sdrc.c

diff --git a/cpu/arm_cortexa8/omap3/Makefile b/cpu/arm_cortexa8/omap3/Makefile
index 136b163..8cc7802 100644
--- a/cpu/arm_cortexa8/omap3/Makefile
+++ b/cpu/arm_cortexa8/omap3/Makefile
@@ -33,6 +33,9 @@ COBJS	+= board.o
 COBJS	+= clock.o
 COBJS	+= gpio.o
 COBJS	+= mem.o
+ifdef	CONFIG_SDRC
+COBJS	+= sdrc.o
+endif
 COBJS	+= syslib.o
 COBJS	+= sys_info.o
 COBJS	+= timer.o
diff --git a/cpu/arm_cortexa8/omap3/board.c b/cpu/arm_cortexa8/omap3/board.c
index 2aa69b3..0bad682 100644
--- a/cpu/arm_cortexa8/omap3/board.c
+++ b/cpu/arm_cortexa8/omap3/board.c
@@ -40,8 +40,6 @@

 extern omap3_sysinfo sysinfo;

-extern u32 is_mem_sdr(void);
-
 /******************************************************************************
  * Routine: delay
  * Description: spinning delay to use before udelay works
@@ -227,7 +225,7 @@ void s_init(void)
 	per_clocks_enable();

 	if (!in_sdram)
-		sdrc_init();
+		mem_init();
 }

 /******************************************************************************
@@ -268,36 +266,6 @@ void watchdog_init(void)
 }

 /******************************************************************************
- * Routine: dram_init
- * Description: sets uboots idea of sdram size
- *****************************************************************************/
-int dram_init(void)
-{
-	DECLARE_GLOBAL_DATA_PTR;
-	unsigned int size0 = 0, size1 = 0;
-
-	/*
-	 * If a second bank of DDR is attached to CS1 this is
-	 * where it can be started.  Early init code will init
-	 * memory on CS0.
-	 */
-	if ((sysinfo.mtype == DDR_COMBO) || (sysinfo.mtype == DDR_STACKED)) {
-		do_sdrc_init(CS1, NOT_EARLY);
-		make_cs1_contiguous();
-	}
-
-	size0 = get_sdr_cs_size(CS0);
-	size1 = get_sdr_cs_size(CS1);
-
-	gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
-	gd->bd->bi_dram[0].size = size0;
-	gd->bd->bi_dram[1].start = PHYS_SDRAM_1 + get_sdr_cs_offset(CS1);
-	gd->bd->bi_dram[1].size = size1;
-
-	return 0;
-}
-
-/******************************************************************************
  * Dummy function to handle errors for EABI incompatibility
  *****************************************************************************/
 void abort(void)
diff --git a/cpu/arm_cortexa8/omap3/mem.c b/cpu/arm_cortexa8/omap3/mem.c
index dfb7e4c..bd914b0 100644
--- a/cpu/arm_cortexa8/omap3/mem.c
+++ b/cpu/arm_cortexa8/omap3/mem.c
@@ -79,26 +79,6 @@ static const u32 gpmc_onenand[GPMC_MAX_REG] = {

 #endif

-static struct sdrc *sdrc_base = (struct sdrc *)OMAP34XX_SDRC_BASE;
-
-/**************************************************************************
- * make_cs1_contiguous() - for es2 and above remap cs1 behind cs0 to allow
- *  command line mem=xyz use all memory with out discontinuous support
- *  compiled in.  Could do it at the ATAG, but there really is two banks...
- * Called as part of 2nd phase DDR init.
- **************************************************************************/
-void make_cs1_contiguous(void)
-{
-	u32 size, a_add_low, a_add_high;
-
-	size = get_sdr_cs_size(CS0);
-	size >>= 25;	/* divide by 32 MiB to find size to offset CS1 */
-	a_add_high = (size & 3) << 8;	/* set up low field */
-	a_add_low = (size & 0x3C) >> 2;	/* set up high field */
-	writel((a_add_high | a_add_low), &sdrc_base->cs_cfg);
-
-}
-
 /********************************************************
  *  mem_ok() - test used to see if timings are correct
  *             for a part. Helps in guessing which part
@@ -123,76 +103,6 @@ u32 mem_ok(u32 cs)
 		return 1;
 }

-/********************************************************
- *  sdrc_init() - init the sdrc chip selects CS0 and CS1
- *  - early init routines, called from flash or
- *  SRAM.
- *******************************************************/
-void sdrc_init(void)
-{
-	/* only init up first bank here */
-	do_sdrc_init(CS0, EARLY_INIT);
-}
-
-/*************************************************************************
- * do_sdrc_init(): initialize the SDRAM for use.
- *  -code sets up SDRAM basic SDRC timings for CS0
- *  -optimal settings can be placed here, or redone after i2c
- *      inspection of board info
- *
- *  - code called once in C-Stack only context for CS0 and a possible 2nd
- *      time depending on memory configuration from stack+global context
- **************************************************************************/
-
-void do_sdrc_init(u32 cs, u32 early)
-{
-	struct sdrc_actim *sdrc_actim_base;
-
-	if(cs)
-		sdrc_actim_base = (struct sdrc_actim *)SDRC_ACTIM_CTRL1_BASE;
-	else
-		sdrc_actim_base = (struct sdrc_actim *)SDRC_ACTIM_CTRL0_BASE;
-
-	if (early) {
-		/* reset sdrc controller */
-		writel(SOFTRESET, &sdrc_base->sysconfig);
-		wait_on_value(RESETDONE, RESETDONE, &sdrc_base->status,
-			      12000000);
-		writel(0, &sdrc_base->sysconfig);
-
-		/* setup sdrc to ball mux */
-		writel(SDRC_SHARING, &sdrc_base->sharing);
-
-		/* Disable Power Down of CKE cuz of 1 CKE on combo part */
-		writel(WAKEUPPROC | PWDNEN | SRFRONRESET | PAGEPOLICY_HIGH,
-				&sdrc_base->power);
-
-		writel(ENADLL | DLLPHASE_90, &sdrc_base->dlla_ctrl);
-		sdelay(0x20000);
-	}
-
-	writel(RASWIDTH_13BITS | CASWIDTH_10BITS | ADDRMUXLEGACY |
-		RAMSIZE_128 | BANKALLOCATION | B32NOT16 | B32NOT16 |
-		DEEPPD | DDR_SDRAM, &sdrc_base->cs[cs].mcfg);
-	writel(ARCV | ARE_ARCV_1, &sdrc_base->cs[cs].rfr_ctrl);
-	writel(V_ACTIMA_165, &sdrc_actim_base->ctrla);
-	writel(V_ACTIMB_165, &sdrc_actim_base->ctrlb);
-
-	writel(CMD_NOP, &sdrc_base ->cs[cs].manual);
-	writel(CMD_PRECHARGE, &sdrc_base->cs[cs].manual);
-	writel(CMD_AUTOREFRESH, &sdrc_base->cs[cs].manual);
-	writel(CMD_AUTOREFRESH, &sdrc_base->cs[cs].manual);
-
-	/*
-	 * CAS latency 3, Write Burst = Read Burst, Serial Mode,
-	 * Burst length = 4
-	 */
-	writel(CASL3 | BURSTLENGTH4, &sdrc_base->cs[cs].mr);
-
-	if (!mem_ok(cs))
-		writel(0, &sdrc_base->cs[cs].mcfg);
-}
-
 void enable_gpmc_cs_config(const u32 *gpmc_config, struct gpmc_cs *cs, u32 base,
 			u32 size)
 {
diff --git a/cpu/arm_cortexa8/omap3/sdrc.c b/cpu/arm_cortexa8/omap3/sdrc.c
new file mode 100644
index 0000000..9a46155
--- /dev/null
+++ b/cpu/arm_cortexa8/omap3/sdrc.c
@@ -0,0 +1,186 @@
+/*
+ * Functions related to SDRC.
+ *
+ * This file has been created after exctracting and consolidating
+ * the SDRC related content from mem.c and board.c.
+ *
+ * Copyright (C) 2009 Texas Instruments Incorporated - http://www.ti.com/
+ *
+ * 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; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <common.h>
+#include <asm/io.h>
+#include <asm/arch/mem.h>
+#include <asm/arch/sys_proto.h>
+
+extern omap3_sysinfo sysinfo;
+
+static struct sdrc *sdrc_base = (struct sdrc *)OMAP34XX_SDRC_BASE;
+
+/**
+ * make_cs1_contiguous() - for es2 and above remap cs1 behind cs0 to allow
+ *  command line mem=xyz use all memory with out discontinuous support
+ *  compiled in.  Could do it at the ATAG, but there really is two banks...
+ * Called as part of 2nd phase DDR init.
+ */
+void make_cs1_contiguous(void)
+{
+	u32 size, a_add_low, a_add_high;
+
+	size = get_sdr_cs_size(CS0);
+	size >>= 25;	/* divide by 32 MiB to find size to offset CS1 */
+	a_add_high = (size & 3) << 8;	/* set up low field */
+	a_add_low = (size & 0x3C) >> 2;	/* set up high field */
+	writel((a_add_high | a_add_low), &sdrc_base->cs_cfg);
+
+}
+/**
+ * is_mem_sdr() - return 1 if mem type in use is SDR
+ */
+u32 is_mem_sdr(void)
+{
+	if (readl(&sdrc_base->cs[CS0].mr) == SDRC_MR_0_SDR)
+		return 1;
+	return 0;
+}
+
+/**
+ * get_sdr_cs_size() - get size of chip select 0/1
+ */
+u32 get_sdr_cs_size(u32 cs)
+{
+	u32 size;
+
+	/* get ram size field */
+	size = readl(&sdrc_base->cs[cs].mcfg) >> 8;
+	size &= 0x3FF;		/* remove unwanted bits */
+	size <<= 21;		/* multiply by 2 MiB to find size in MB */
+	return size;
+}
+
+/**
+ * get_sdr_cs_offset() - get offset of cs from cs0 start
+ */
+u32 get_sdr_cs_offset(u32 cs)
+{
+	u32 offset;
+
+	if (!cs)
+		return 0;
+
+	offset = readl(&sdrc_base->cs_cfg);
+	offset = (offset & 15) << 27 | (offset & 0x30) >> 17;
+
+	return offset;
+}
+
+/**
+ * do_sdrc_init(): initialize the SDRAM for use.
+ *  -Sets up SDRAM basic SDRC timings for CS0
+ *  -Optimal settings can be placed here, or redone after i2c
+ *      inspection of board info
+ *
+ *  - code called once in C-Stack only context for CS0 and a possible 2nd
+ *    time depending on memory configuration from stack+global context
+ */
+void do_sdrc_init(u32 cs, u32 early)
+{
+	struct sdrc_actim *sdrc_actim_base;
+
+	if (cs)
+		sdrc_actim_base = (struct sdrc_actim *)SDRC_ACTIM_CTRL1_BASE;
+	else
+		sdrc_actim_base = (struct sdrc_actim *)SDRC_ACTIM_CTRL0_BASE;
+
+	if (early) {
+		/* reset sdrc controller */
+		writel(SOFTRESET, &sdrc_base->sysconfig);
+		wait_on_value(RESETDONE, RESETDONE, &sdrc_base->status,
+			      12000000);
+		writel(0, &sdrc_base->sysconfig);
+
+		/* setup sdrc to ball mux */
+		writel(SDRC_SHARING, &sdrc_base->sharing);
+
+		/* Disable Power Down of CKE cuz of 1 CKE on combo part */
+		writel(WAKEUPPROC | PWDNEN | SRFRONRESET | PAGEPOLICY_HIGH,
+				&sdrc_base->power);
+
+		writel(ENADLL | DLLPHASE_90, &sdrc_base->dlla_ctrl);
+		sdelay(0x20000);
+	}
+
+	writel(RASWIDTH_13BITS | CASWIDTH_10BITS | ADDRMUXLEGACY |
+		RAMSIZE_128 | BANKALLOCATION | B32NOT16 | B32NOT16 |
+		DEEPPD | DDR_SDRAM, &sdrc_base->cs[cs].mcfg);
+	writel(ARCV | ARE_ARCV_1, &sdrc_base->cs[cs].rfr_ctrl);
+	writel(V_ACTIMA_165, &sdrc_actim_base->ctrla);
+	writel(V_ACTIMB_165, &sdrc_actim_base->ctrlb);
+
+	writel(CMD_NOP, &sdrc_base->cs[cs].manual);
+	writel(CMD_PRECHARGE, &sdrc_base->cs[cs].manual);
+	writel(CMD_AUTOREFRESH, &sdrc_base->cs[cs].manual);
+	writel(CMD_AUTOREFRESH, &sdrc_base->cs[cs].manual);
+
+	/*
+	 * CAS latency 3, Write Burst = Read Burst, Serial Mode,
+	 * Burst length = 4
+	 */
+	writel(CASL3 | BURSTLENGTH4, &sdrc_base->cs[cs].mr);
+
+	if (!mem_ok(cs))
+		writel(0, &sdrc_base->cs[cs].mcfg);
+}
+
+/**
+ * dram_init - Sets uboots idea of sdram size
+ */
+int dram_init(void)
+{
+	DECLARE_GLOBAL_DATA_PTR;
+	unsigned int size0 = 0, size1 = 0;
+
+	size0 = get_sdr_cs_size(CS0);
+	/*
+	 * If a second bank of DDR is attached to CS1 this is
+	 * where it can be started.  Early init code will init
+	 * memory on CS0.
+	 */
+	if ((sysinfo.mtype == DDR_COMBO) || (sysinfo.mtype == DDR_STACKED)) {
+		do_sdrc_init(CS1, NOT_EARLY);
+		make_cs1_contiguous();
+
+		size1 = get_sdr_cs_size(CS1);
+	}
+
+	gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
+	gd->bd->bi_dram[0].size = size0;
+	gd->bd->bi_dram[1].start = PHYS_SDRAM_1 + get_sdr_cs_offset(CS1);
+	gd->bd->bi_dram[1].size = size1;
+
+	return 0;
+}
+
+/**
+ * mem_init() - init the sdrc chip selects CS0 and CS1
+ *  - early init routines, called from flash or SRAM.
+ */
+void mem_init(void)
+{
+	/* only init up first bank here */
+	do_sdrc_init(CS0, EARLY_INIT);
+}
diff --git a/cpu/arm_cortexa8/omap3/sys_info.c b/cpu/arm_cortexa8/omap3/sys_info.c
index 08fb32e..1458b89 100644
--- a/cpu/arm_cortexa8/omap3/sys_info.c
+++ b/cpu/arm_cortexa8/omap3/sys_info.c
@@ -32,7 +32,7 @@
 #include <i2c.h>

 extern omap3_sysinfo sysinfo;
-static struct sdrc *sdrc_base = (struct sdrc *)OMAP34XX_SDRC_BASE;
+
 static struct ctrl *ctrl_base = (struct ctrl *)OMAP34XX_CTRL_BASE;
 static char *rev_s[CPU_3XX_MAX_REV] = {
 				"1.0",
@@ -104,46 +104,6 @@ u32 get_cpu_rev(void)
 	}
 }

-/****************************************************
- * is_mem_sdr() - return 1 if mem type in use is SDR
- ****************************************************/
-u32 is_mem_sdr(void)
-{
-	if (readl(&sdrc_base->cs[CS0].mr) == SDRC_MR_0_SDR)
-		return 1;
-	return 0;
-}
-
-/***********************************************************************
- * get_cs0_size() - get size of chip select 0/1
- ************************************************************************/
-u32 get_sdr_cs_size(u32 cs)
-{
-	u32 size;
-
-	/* get ram size field */
-	size = readl(&sdrc_base->cs[cs].mcfg) >> 8;
-	size &= 0x3FF;		/* remove unwanted bits */
-	size <<= 21;		/* multiply by 2 MiB to find size in MB */
-	return size;
-}
-
-/***********************************************************************
- * get_sdr_cs_offset() - get offset of cs from cs0 start
- ************************************************************************/
-u32 get_sdr_cs_offset(u32 cs)
-{
-	u32 offset;
-
-	if (!cs)
-		return 0;
-
-	offset = readl(&sdrc_base->cs_cfg);
-	offset = (offset & 15) << 27 | (offset & 0x30) >> 17;
-
-	return offset;
-}
-
 /***************************************************************************
  *  get_gpmc0_base() - Return current address hardware will be
  *     fetching from. The below effectively gives what is correct, its a bit
diff --git a/include/asm-arm/arch-omap3/mem.h b/include/asm-arm/arch-omap3/mem.h
index 9439758..0f3733f 100644
--- a/include/asm-arm/arch-omap3/mem.h
+++ b/include/asm-arm/arch-omap3/mem.h
@@ -270,4 +270,18 @@ enum {
 #define PISMO1_ONEN_BASE	ONENAND_MAP
 #define DBG_MPDB_BASE		DEBUG_BASE

+#ifndef __ASSEMBLY__
+/*
+ * Function prototypes
+ */
+void mem_init(void);
+
+u32 is_mem_sdr(void);
+u32 mem_ok(u32 cs);
+
+u32 get_sdr_cs_size(u32);
+u32 get_sdr_cs_offset(u32);
+
+#endif /* __ASSEMBLY__ */
+
 #endif /* endif _MEM_H_ */
diff --git a/include/asm-arm/arch-omap3/sys_proto.h b/include/asm-arm/arch-omap3/sys_proto.h
index 34bd515..34e4e0d 100644
--- a/include/asm-arm/arch-omap3/sys_proto.h
+++ b/include/asm-arm/arch-omap3/sys_proto.h
@@ -31,8 +31,10 @@ void prcm_init(void);
 void per_clocks_enable(void);

 void memif_init(void);
+#if defined(CONFIG_SDRC)
 void sdrc_init(void);
 void do_sdrc_init(u32, u32);
+#endif
 void gpmc_init(void);
 void enable_gpmc_cs_config(const u32 *gpmc_config, struct gpmc_cs *cs, u32 base,
 			u32 size);
@@ -46,8 +48,6 @@ u32 get_sysboot_value(void);
 u32 is_gpmc_muxed(void);
 u32 get_gpmc0_type(void);
 u32 get_gpmc0_width(void);
-u32 get_sdr_cs_size(u32);
-u32 get_sdr_cs_offset(u32);
 u32 is_running_in_sdram(void);
 u32 is_running_in_sram(void);
 u32 is_running_in_flash(void);
diff --git a/include/configs/omap3_beagle.h b/include/configs/omap3_beagle.h
index a8abb0e..eeeb324 100644
--- a/include/configs/omap3_beagle.h
+++ b/include/configs/omap3_beagle.h
@@ -37,6 +37,8 @@
 #define CONFIG_OMAP3430		1	/* which is in a 3430 */
 #define CONFIG_OMAP3_BEAGLE	1	/* working with BEAGLE */

+#define CONFIG_SDRC		1	/* The chip has SDRC controller */
+
 #include <asm/arch/cpu.h>		/* get chip and board defs */
 #include <asm/arch/omap3.h>

diff --git a/include/configs/omap3_evm.h b/include/configs/omap3_evm.h
index 52cb202..72b2f72 100644
--- a/include/configs/omap3_evm.h
+++ b/include/configs/omap3_evm.h
@@ -42,6 +42,8 @@
 #define CONFIG_OMAP3430		1	/* which is in a 3430 */
 #define CONFIG_OMAP3_EVM	1	/* working with EVM */

+#define CONFIG_SDRC		1	/* The chip has SDRC controller */
+
 #include <asm/arch/cpu.h>	/* get chip and board defs */
 #include <asm/arch/omap3.h>

diff --git a/include/configs/omap3_overo.h b/include/configs/omap3_overo.h
index c72fb9d..d36b8f7 100644
--- a/include/configs/omap3_overo.h
+++ b/include/configs/omap3_overo.h
@@ -29,6 +29,8 @@
 #define CONFIG_OMAP3430		1	/* which is in a 3430 */
 #define CONFIG_OMAP3_OVERO	1	/* working with overo */

+#define CONFIG_SDRC		1	/* The chip has SDRC controller */
+
 #include <asm/arch/cpu.h>	/* get chip and board defs */
 #include <asm/arch/omap3.h>

diff --git a/include/configs/omap3_pandora.h b/include/configs/omap3_pandora.h
index f22fab5..f323d76 100644
--- a/include/configs/omap3_pandora.h
+++ b/include/configs/omap3_pandora.h
@@ -32,6 +32,8 @@
 #define CONFIG_OMAP3430		1	/* which is in a 3430 */
 #define CONFIG_OMAP3_PANDORA	1	/* working with pandora */

+#define CONFIG_SDRC		1	/* The chip has SDRC controller */
+
 #include <asm/arch/cpu.h>	/* get chip and board defs */
 #include <asm/arch/omap3.h>

diff --git a/include/configs/omap3_sdp3430.h b/include/configs/omap3_sdp3430.h
index 4d01933..ce20c9f 100644
--- a/include/configs/omap3_sdp3430.h
+++ b/include/configs/omap3_sdp3430.h
@@ -42,6 +42,8 @@
 #define CONFIG_OMAP3430		1	/* which is in a 3430 */
 #define CONFIG_OMAP3_3430SDP	1	/* working with SDP Rev2 */

+#define CONFIG_SDRC		1	/* The chip has SDRC controller */
+
 #include <asm/arch/cpu.h>		/* get chip and board defs */
 #include <asm/arch/omap3.h>

diff --git a/include/configs/omap3_zoom1.h b/include/configs/omap3_zoom1.h
index cdf95c0..22aca38 100644
--- a/include/configs/omap3_zoom1.h
+++ b/include/configs/omap3_zoom1.h
@@ -38,6 +38,8 @@
 #define CONFIG_OMAP3430		1	/* which is in a 3430 */
 #define CONFIG_OMAP3_ZOOM1	1	/* working with Zoom MDK Rev1 */

+#define CONFIG_SDRC		1	/* The chip has SDRC controller */
+
 #include <asm/arch/cpu.h>		/* get chip and board defs */
 #include <asm/arch/omap3.h>

diff --git a/include/configs/omap3_zoom2.h b/include/configs/omap3_zoom2.h
index 7a8beb8..49bf72f 100644
--- a/include/configs/omap3_zoom2.h
+++ b/include/configs/omap3_zoom2.h
@@ -39,6 +39,8 @@
 #define CONFIG_OMAP3430		1	/* which is in a 3430 */
 #define CONFIG_OMAP3_ZOOM2	1	/* working with Zoom II */

+#define CONFIG_SDRC		1	/* The chip has SDRC controller */
+
 #include <asm/arch/cpu.h>	/* get chip and board defs */
 #include <asm/arch/omap3.h>

--
1.6.2.4

^ permalink raw reply related	[flat|nested] 263+ messages in thread

* [U-Boot] [PATCH 0/3] Add Support for AM3517EVM with EMIF4
  2010-01-30 10:16 ` [U-Boot] [PATCH 0/3] Add Support for AM3517EVM with EMIF4 hvaibhav at ti.com
@ 2010-02-02 18:40   ` Hiremath, Vaibhav
  2010-02-03 13:24     ` Tom
  0 siblings, 1 reply; 263+ messages in thread
From: Hiremath, Vaibhav @ 2010-02-02 18:40 UTC (permalink / raw)
  To: u-boot

> -----Original Message-----
> From: Hiremath, Vaibhav
> Sent: Saturday, January 30, 2010 3:47 PM
> To: u-boot at lists.denx.de
> Cc: Paulraj, Sandeep; Tom.Rix at windriver.com; Hiremath, Vaibhav
> Subject: [PATCH 0/3] Add Support for AM3517EVM with EMIF4
> 
> From: Vaibhav Hiremath <hvaibhav@ti.com>
> 
> AM3517 device is high-performance, industrial applications processor
> designed
> and developed keeping Software Compatible with OMAP3 Processors.
> 
> Differances :-
> ===========
> 	- The SDRC controller has been replaced with EMIF4.
> 	- Some new IP's got added like, CAN, VPFE, etc...
> 	- Removed ISP completely
> 
> This patch series adds support for AM3517EVM along with EMIF4
> configuration.
> 
> Tested :-
> ===========
> 	- OMAP3 EVM (both NAND and MMC boot mode)
> 	- OMAP3 BEAGLE (MMC boot mode)
> 	- AM3517 EVM (both NAND and MMC boot mode)
> 
> Below are some of the useful links :-
> ===========
> AM3517 device is high-performance, industrial applications processor
> designed
> and developed keeping Software Compatible with OMAP3 Processors.
> 
> Below are some of the useful links -
> 
> Migration from OMAP35x to AM35x :-
> http://focus.ti.com/lit/an/sprab91/sprab91.pdf
> 
> Specs/TRM :-
> http://focus.ti.com/docs/prod/folders/print/am3517.html
> 
> EVM Link -:
> http://www.logicpd.com/products/development-kits/zoom-am3517-
> experimenter-kit
> 
> 
> Vaibhav Hiremath (3):
>   OMAP3: Consolidate SDRC related operations
>   AM35x: Add support for AM3517EVM
>   AM35x: Add support for EMIF4
> 
[Hiremath, Vaibhav] Sandeep,

Can you please merge these series of patches for next window?

Thanks,
Vaibhav

>  MAINTAINERS                            |    4 +
>  Makefile                               |    3 +
>  board/ti/am3517evm/Makefile            |   47 ++++
>  board/ti/am3517evm/am3517evm.c         |   76 ++++++
>  board/ti/am3517evm/am3517evm.h         |  400
> ++++++++++++++++++++++++++++++++
>  board/ti/am3517evm/config.mk           |   29 +++
>  cpu/arm_cortexa8/omap3/Makefile        |    6 +
>  cpu/arm_cortexa8/omap3/board.c         |   34 +---
>  cpu/arm_cortexa8/omap3/emif4.c         |  160 +++++++++++++
>  cpu/arm_cortexa8/omap3/mem.c           |   90 -------
>  cpu/arm_cortexa8/omap3/sdrc.c          |  186 +++++++++++++++
>  cpu/arm_cortexa8/omap3/sys_info.c      |   42 +----
>  include/asm-arm/arch-omap3/cpu.h       |   26 ++
>  include/asm-arm/arch-omap3/emif4.h     |   77 ++++++
>  include/asm-arm/arch-omap3/mem.h       |   24 ++
>  include/asm-arm/arch-omap3/mux.h       |   35 +++
>  include/asm-arm/arch-omap3/sys_proto.h |    7 +-
>  include/configs/am3517_evm.h           |  293
> +++++++++++++++++++++++
>  include/configs/omap3_beagle.h         |    2 +
>  include/configs/omap3_evm.h            |    2 +
>  include/configs/omap3_overo.h          |    2 +
>  include/configs/omap3_pandora.h        |    2 +
>  include/configs/omap3_sdp3430.h        |    2 +
>  include/configs/omap3_zoom1.h          |    2 +
>  include/configs/omap3_zoom2.h          |    2 +
>  25 files changed, 1387 insertions(+), 166 deletions(-)
>  create mode 100644 board/ti/am3517evm/Makefile
>  create mode 100644 board/ti/am3517evm/am3517evm.c
>  create mode 100644 board/ti/am3517evm/am3517evm.h
>  create mode 100644 board/ti/am3517evm/config.mk
>  create mode 100644 cpu/arm_cortexa8/omap3/emif4.c
>  create mode 100644 cpu/arm_cortexa8/omap3/sdrc.c
>  create mode 100644 include/asm-arm/arch-omap3/emif4.h
>  create mode 100644 include/configs/am3517_evm.h

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [U-Boot] [PATCH 0/3] Add Support for AM3517EVM with EMIF4
  2010-02-02 18:40   ` Hiremath, Vaibhav
@ 2010-02-03 13:24     ` Tom
  2010-02-03 13:26       ` Hiremath, Vaibhav
  0 siblings, 1 reply; 263+ messages in thread
From: Tom @ 2010-02-03 13:24 UTC (permalink / raw)
  To: u-boot

Hiremath, Vaibhav wrote:
>> -----Original Message-----
>> From: Hiremath, Vaibhav
>> Sent: Saturday, January 30, 2010 3:47 PM
>> To: u-boot at lists.denx.de
>> Cc: Paulraj, Sandeep; Tom.Rix at windriver.com; Hiremath, Vaibhav
>> Subject: [PATCH 0/3] Add Support for AM3517EVM with EMIF4
>>
>> From: Vaibhav Hiremath <hvaibhav@ti.com>
>>
<snip>

>>
> [Hiremath, Vaibhav] Sandeep,
> 
> Can you please merge these series of patches for next window?
> 

This patchset still needs to be reviewed.
I will post my review this weekend.
Tom

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [U-Boot] [PATCH 0/3] Add Support for AM3517EVM with EMIF4
  2010-02-03 13:24     ` Tom
@ 2010-02-03 13:26       ` Hiremath, Vaibhav
  0 siblings, 0 replies; 263+ messages in thread
From: Hiremath, Vaibhav @ 2010-02-03 13:26 UTC (permalink / raw)
  To: u-boot


> -----Original Message-----
> From: Tom [mailto:Tom.Rix at windriver.com]
> Sent: Wednesday, February 03, 2010 6:54 PM
> To: Hiremath, Vaibhav
> Cc: u-boot at lists.denx.de; Paulraj, Sandeep
> Subject: Re: [PATCH 0/3] Add Support for AM3517EVM with EMIF4
> 
> Hiremath, Vaibhav wrote:
> >> -----Original Message-----
> >> From: Hiremath, Vaibhav
> >> Sent: Saturday, January 30, 2010 3:47 PM
> >> To: u-boot at lists.denx.de
> >> Cc: Paulraj, Sandeep; Tom.Rix at windriver.com; Hiremath, Vaibhav
> >> Subject: [PATCH 0/3] Add Support for AM3517EVM with EMIF4
> >>
> >> From: Vaibhav Hiremath <hvaibhav@ti.com>
> >>
> <snip>
> 
> >>
> > [Hiremath, Vaibhav] Sandeep,
> >
> > Can you please merge these series of patches for next window?
> >
> 
> This patchset still needs to be reviewed.
> I will post my review this weekend.
[Hiremath, Vaibhav] Review comments are always welcomed. Since this is second version and we haven't had any comments last time. I requested to merge.

Looking forward for your comments.

Thanks,
Vaibhav

> Tom

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [U-Boot] [PATCH 1/3] OMAP3: Consolidate SDRC related operations
  2010-01-30 10:16 ` [U-Boot] [PATCH 1/3] OMAP3: Consolidate SDRC related operations hvaibhav at ti.com
@ 2010-02-07 16:13   ` Tom
  2010-02-10  9:35     ` Hiremath, Vaibhav
  0 siblings, 1 reply; 263+ messages in thread
From: Tom @ 2010-02-07 16:13 UTC (permalink / raw)
  To: u-boot

hvaibhav at ti.com wrote:
> From: Vaibhav Hiremath <hvaibhav@ti.com>
> 
> Consolidated all SDRC related functions/operations into separate
> file - sdrc.c.

Please add a long comment to explain why this is necessary.
Something like..
'Generalizing omap memory setup is necessary to support the new emif4 interface
that for am3517 uses.. '

> 
> Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
> Signed-off-by: Sanjeev Premi <premi@ti.com>

There is a regression.
Please check devkit8000
cpu/arm_cortexa8/omap3/libomap3.a(board.o): In function `checkboard':
.../cpu/arm_cortexa8/omap3/board.c:313: undefined reference to `is_mem_sdr'
cpu/arm_cortexa8/omap3/libomap3.a(board.o): In function `s_init':
.../cpu/arm_cortexa8/omap3/board.c:228: undefined reference to `mem_init'
cpu/arm_cortexa8/omap3/libomap3.a(mem.o): In function `mem_ok':
.../cpu/arm_cortexa8/omap3/mem.c:92: undefined reference to `get_sdr_cs_offset'
lib_arm/libarm.a(board.o):(.data+0x28): undefined reference to `dram_init'

The biggest problem with this patch is that though the comment says it is
a code movement patch, it has other changes it in.  These changes must
be separated into its own patch(s).

Because of these problems, this is only a partial review.

> ---
>  cpu/arm_cortexa8/omap3/Makefile        |    3 +
>  cpu/arm_cortexa8/omap3/board.c         |   34 +------

<snip>

>  			u32 size)
>  {
> diff --git a/cpu/arm_cortexa8/omap3/sdrc.c b/cpu/arm_cortexa8/omap3/sdrc.c
> new file mode 100644
> index 0000000..9a46155
> --- /dev/null
> +++ b/cpu/arm_cortexa8/omap3/sdrc.c
> @@ -0,0 +1,186 @@
> +/*
> + * Functions related to SDRC.
> + *
> + * This file has been created after exctracting and consolidating
> + * the SDRC related content from mem.c and board.c.
> + *
> + * Copyright (C) 2009 Texas Instruments Incorporated - http://www.ti.com/
> + *

Because this is code movement, include the original copyrights

> + * 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; either version 2 of
> + * the License, or (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program; if not, write to the Free Software
> + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
> + * MA 02111-1307 USA
> + */
> +

<snip>

> +
> +	if (!mem_ok(cs))
> +		writel(0, &sdrc_base->cs[cs].mcfg);
> +}
> +
> +/**

Follow the multi-line comment.
Remove the extra '*'
This happens other places in this patch.
Fix globally

> + * dram_init - Sets uboots idea of sdram size
> + */
> +int dram_init(void)
> +{
> +	DECLARE_GLOBAL_DATA_PTR;
> +	unsigned int size0 = 0, size1 = 0;
> +
> +	size0 = get_sdr_cs_size(CS0);
> +	/*
> +	 * If a second bank of DDR is attached to CS1 this is
> +	 * where it can be started.  Early init code will init
> +	 * memory on CS0.
> +	 */
> +	if ((sysinfo.mtype == DDR_COMBO) || (sysinfo.mtype == DDR_STACKED)) {
> +		do_sdrc_init(CS1, NOT_EARLY);
> +		make_cs1_contiguous();
> +
> +		size1 = get_sdr_cs_size(CS1);

This is different that a code movement change.
The comment of the change does not match what you have done.
Split the real changes into a separate patch.

Tom

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [U-Boot] [PATCH 1/3] OMAP3: Consolidate SDRC related operations
  2010-02-07 16:13   ` Tom
@ 2010-02-10  9:35     ` Hiremath, Vaibhav
  0 siblings, 0 replies; 263+ messages in thread
From: Hiremath, Vaibhav @ 2010-02-10  9:35 UTC (permalink / raw)
  To: u-boot


> -----Original Message-----
> From: Tom [mailto:Tom.Rix at windriver.com]
> Sent: Sunday, February 07, 2010 9:44 PM
> To: Hiremath, Vaibhav
> Cc: u-boot at lists.denx.de; Paulraj, Sandeep; Premi, Sanjeev
> Subject: Re: [PATCH 1/3] OMAP3: Consolidate SDRC related operations
> 
> hvaibhav at ti.com wrote:
> > From: Vaibhav Hiremath <hvaibhav@ti.com>
> >
> > Consolidated all SDRC related functions/operations into separate
> > file - sdrc.c.
> 
> Please add a long comment to explain why this is necessary.
> Something like..
> 'Generalizing omap memory setup is necessary to support the new
> emif4 interface
> that for am3517 uses.. '
[Hiremath, Vaibhav] Ok, will update in next version.

> 
> >
> > Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
> > Signed-off-by: Sanjeev Premi <premi@ti.com>
> 
> There is a regression.
> Please check devkit8000
> cpu/arm_cortexa8/omap3/libomap3.a(board.o): In function
> `checkboard':
> .../cpu/arm_cortexa8/omap3/board.c:313: undefined reference to
> `is_mem_sdr'
> cpu/arm_cortexa8/omap3/libomap3.a(board.o): In function `s_init':
> .../cpu/arm_cortexa8/omap3/board.c:228: undefined reference to
> `mem_init'
> cpu/arm_cortexa8/omap3/libomap3.a(mem.o): In function `mem_ok':
> .../cpu/arm_cortexa8/omap3/mem.c:92: undefined reference to
> `get_sdr_cs_offset'
> lib_arm/libarm.a(board.o):(.data+0x28): undefined reference to
> `dram_init'
> 
> The biggest problem with this patch is that though the comment says
> it is
> a code movement patch, it has other changes it in.  These changes
> must
> be separated into its own patch(s).
> 
> Because of these problems, this is only a partial review.
[Hiremath, Vaibhav] I will separate such changes into separate commit and submit it to list.

> 
> > ---
> >  cpu/arm_cortexa8/omap3/Makefile        |    3 +
> >  cpu/arm_cortexa8/omap3/board.c         |   34 +------
> 
> <snip>
> 
> >  			u32 size)
> >  {
> > diff --git a/cpu/arm_cortexa8/omap3/sdrc.c
> b/cpu/arm_cortexa8/omap3/sdrc.c
> > new file mode 100644
> > index 0000000..9a46155
> > --- /dev/null
> > +++ b/cpu/arm_cortexa8/omap3/sdrc.c
> > @@ -0,0 +1,186 @@
> > +/*
> > + * Functions related to SDRC.
> > + *
> > + * This file has been created after exctracting and consolidating
> > + * the SDRC related content from mem.c and board.c.
> > + *
> > + * Copyright (C) 2009 Texas Instruments Incorporated -
> http://www.ti.com/
> > + *
> 
> Because this is code movement, include the original copyrights
[Hiremath, Vaibhav] Ok, will update in next version.

> 
> > + * 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; either version 2 of
> > + * the License, or (at your option) any later version.
> > + *
> > + * This program is distributed in the hope that it will be
> useful,
> > + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> > + * GNU General Public License for more details.
> > + *
> > + * You should have received a copy of the GNU General Public
> License
> > + * along with this program; if not, write to the Free Software
> > + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
> > + * MA 02111-1307 USA
> > + */
> > +
> 
> <snip>
> 
> > +
> > +	if (!mem_ok(cs))
> > +		writel(0, &sdrc_base->cs[cs].mcfg);
> > +}
> > +
> > +/**
> 
> Follow the multi-line comment.
> Remove the extra '*'
> This happens other places in this patch.
> Fix globally
[Hiremath, Vaibhav] Ok.

Thanks Tom for the review, I will update the patch series and submit it again.

Thanks,
Vaibhav

> 
> > + * dram_init - Sets uboots idea of sdram size
> > + */
> > +int dram_init(void)
> > +{
> > +	DECLARE_GLOBAL_DATA_PTR;
> > +	unsigned int size0 = 0, size1 = 0;
> > +
> > +	size0 = get_sdr_cs_size(CS0);
> > +	/*
> > +	 * If a second bank of DDR is attached to CS1 this is
> > +	 * where it can be started.  Early init code will init
> > +	 * memory on CS0.
> > +	 */
> > +	if ((sysinfo.mtype == DDR_COMBO) || (sysinfo.mtype ==
> DDR_STACKED)) {
> > +		do_sdrc_init(CS1, NOT_EARLY);
> > +		make_cs1_contiguous();
> > +
> > +		size1 = get_sdr_cs_size(CS1);
> 
> This is different that a code movement change.
> The comment of the change does not match what you have done.
> Split the real changes into a separate patch.
> 
> Tom

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [U-Boot] [RESEND:PATCH-V4] OMAP3EVM: Added NAND support
@ 2010-04-23 14:55 ` hvaibhav at ti.com
  2010-05-05 20:01   ` Wolfgang Denk
  0 siblings, 1 reply; 263+ messages in thread
From: hvaibhav at ti.com @ 2010-04-23 14:55 UTC (permalink / raw)
  To: u-boot

From: Vaibhav Hiremath <hvaibhav@ti.com>

The EVMS have been shipping with NAND (instead of OneNAND) as default.
So, this patch sets NAND as default.

To choose OneNAND, define CMD_ONENAND instead of CMD_NAND in the
config file omap3_evm.h,

Changes from V3 :-
	- Added undef statement for CMD_ONENAND.

Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
---
 include/configs/omap3_evm.h |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/include/configs/omap3_evm.h b/include/configs/omap3_evm.h
index 0d99f7d..1d31731 100644
--- a/include/configs/omap3_evm.h
+++ b/include/configs/omap3_evm.h
@@ -151,7 +151,8 @@

 #define CONFIG_CMD_I2C		/* I2C serial bus support	*/
 #define CONFIG_CMD_MMC		/* MMC support			*/
-#define CONFIG_CMD_ONENAND	/* ONENAND support		*/
+#undef CONFIG_CMD_ONENAND	/* ONENAND support		*/
+#define CONFIG_CMD_NAND		/* NAND support			*/
 #define CONFIG_CMD_DHCP
 #define CONFIG_CMD_PING

@@ -306,7 +307,13 @@
 #define CONFIG_SYS_MONITOR_BASE		CONFIG_SYS_FLASH_BASE
 #define CONFIG_SYS_ONENAND_BASE		ONENAND_MAP

+#if defined(CONFIG_CMD_NAND)
+#define CONFIG_NAND_OMAP_GPMC
+#define GPMC_NAND_ECC_LP_x16_LAYOUT	1
+#define CONFIG_ENV_IS_IN_NAND
+#elif defined(CONFIG_CMD_ONENAND)
 #define CONFIG_ENV_IS_IN_ONENAND	1
+#endif
 #define ONENAND_ENV_OFFSET		0x260000 /* environment starts here */
 #define SMNAND_ENV_OFFSET		0x260000 /* environment starts here */

--
1.6.2.4

^ permalink raw reply related	[flat|nested] 263+ messages in thread

* [U-Boot] [PATCH-V2 2/4] omap3: Consolidate SDRC related operations
@ 2010-04-23 14:55 ` hvaibhav at ti.com
  2010-05-05 20:07   ` Wolfgang Denk
  0 siblings, 1 reply; 263+ messages in thread
From: hvaibhav at ti.com @ 2010-04-23 14:55 UTC (permalink / raw)
  To: u-boot

From: Vaibhav Hiremath <hvaibhav@ti.com>

Consolidated SDRC related functions into one file - sdrc.c

And also replaced sdrc_init with generic memory init
function (mem_init), this generalization of omap memory setup
is necessary to support the new emif4 interface introduced in AM3517.

Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
Signed-off-by: Sanjeev Premi <premi@ti.com>
---
 arch/arm/cpu/arm_cortexa8/omap3/Makefile    |    3 +
 arch/arm/cpu/arm_cortexa8/omap3/board.c     |   35 +-----
 arch/arm/cpu/arm_cortexa8/omap3/mem.c       |   90 ------------
 arch/arm/cpu/arm_cortexa8/omap3/sdrc.c      |  202 +++++++++++++++++++++++++++
 arch/arm/cpu/arm_cortexa8/omap3/sys_info.c  |   41 ------
 arch/arm/include/asm/arch-omap3/cpu.h       |    3 +
 arch/arm/include/asm/arch-omap3/mem.h       |   13 ++
 arch/arm/include/asm/arch-omap3/sys_proto.h |    4 +-
 include/configs/devkit8000.h                |    2 +
 include/configs/omap3_beagle.h              |    2 +
 include/configs/omap3_evm.h                 |    2 +
 include/configs/omap3_overo.h               |    2 +
 include/configs/omap3_pandora.h             |    2 +
 include/configs/omap3_sdp3430.h             |    2 +
 include/configs/omap3_zoom1.h               |    2 +
 include/configs/omap3_zoom2.h               |    2 +
 16 files changed, 240 insertions(+), 167 deletions(-)
 create mode 100644 arch/arm/cpu/arm_cortexa8/omap3/sdrc.c

diff --git a/arch/arm/cpu/arm_cortexa8/omap3/Makefile b/arch/arm/cpu/arm_cortexa8/omap3/Makefile
index 136b163..8cc7802 100644
--- a/arch/arm/cpu/arm_cortexa8/omap3/Makefile
+++ b/arch/arm/cpu/arm_cortexa8/omap3/Makefile
@@ -33,6 +33,9 @@ COBJS	+= board.o
 COBJS	+= clock.o
 COBJS	+= gpio.o
 COBJS	+= mem.o
+ifdef	CONFIG_SDRC
+COBJS	+= sdrc.o
+endif
 COBJS	+= syslib.o
 COBJS	+= sys_info.o
 COBJS	+= timer.o
diff --git a/arch/arm/cpu/arm_cortexa8/omap3/board.c b/arch/arm/cpu/arm_cortexa8/omap3/board.c
index 69a08fd..d2500ca 100644
--- a/arch/arm/cpu/arm_cortexa8/omap3/board.c
+++ b/arch/arm/cpu/arm_cortexa8/omap3/board.c
@@ -40,8 +40,6 @@

 extern omap3_sysinfo sysinfo;

-extern u32 is_mem_sdr(void);
-
 /******************************************************************************
  * Routine: delay
  * Description: spinning delay to use before udelay works
@@ -233,7 +231,7 @@ void s_init(void)
 	per_clocks_enable();

 	if (!in_sdram)
-		sdrc_init();
+		mem_init();
 }

 /******************************************************************************
@@ -274,37 +272,6 @@ void watchdog_init(void)
 }

 /******************************************************************************
- * Routine: dram_init
- * Description: sets uboots idea of sdram size
- *****************************************************************************/
-int dram_init(void)
-{
-	DECLARE_GLOBAL_DATA_PTR;
-	unsigned int size0 = 0, size1 = 0;
-
-	size0 = get_sdr_cs_size(CS0);
-
-	/*
-	 * If a second bank of DDR is attached to CS1 this is
-	 * where it can be started.  Early init code will init
-	 * memory on CS0.
-	 */
-	if ((sysinfo.mtype == DDR_COMBO) || (sysinfo.mtype == DDR_STACKED)) {
-		do_sdrc_init(CS1, NOT_EARLY);
-		make_cs1_contiguous();
-
-		size1 = get_sdr_cs_size(CS1);
-	}
-
-	gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
-	gd->bd->bi_dram[0].size = size0;
-	gd->bd->bi_dram[1].start = PHYS_SDRAM_1 + get_sdr_cs_offset(CS1);
-	gd->bd->bi_dram[1].size = size1;
-
-	return 0;
-}
-
-/******************************************************************************
  * Dummy function to handle errors for EABI incompatibility
  *****************************************************************************/
 void abort(void)
diff --git a/arch/arm/cpu/arm_cortexa8/omap3/mem.c b/arch/arm/cpu/arm_cortexa8/omap3/mem.c
index dfb7e4c..bd914b0 100644
--- a/arch/arm/cpu/arm_cortexa8/omap3/mem.c
+++ b/arch/arm/cpu/arm_cortexa8/omap3/mem.c
@@ -79,26 +79,6 @@ static const u32 gpmc_onenand[GPMC_MAX_REG] = {

 #endif

-static struct sdrc *sdrc_base = (struct sdrc *)OMAP34XX_SDRC_BASE;
-
-/**************************************************************************
- * make_cs1_contiguous() - for es2 and above remap cs1 behind cs0 to allow
- *  command line mem=xyz use all memory with out discontinuous support
- *  compiled in.  Could do it at the ATAG, but there really is two banks...
- * Called as part of 2nd phase DDR init.
- **************************************************************************/
-void make_cs1_contiguous(void)
-{
-	u32 size, a_add_low, a_add_high;
-
-	size = get_sdr_cs_size(CS0);
-	size >>= 25;	/* divide by 32 MiB to find size to offset CS1 */
-	a_add_high = (size & 3) << 8;	/* set up low field */
-	a_add_low = (size & 0x3C) >> 2;	/* set up high field */
-	writel((a_add_high | a_add_low), &sdrc_base->cs_cfg);
-
-}
-
 /********************************************************
  *  mem_ok() - test used to see if timings are correct
  *             for a part. Helps in guessing which part
@@ -123,76 +103,6 @@ u32 mem_ok(u32 cs)
 		return 1;
 }

-/********************************************************
- *  sdrc_init() - init the sdrc chip selects CS0 and CS1
- *  - early init routines, called from flash or
- *  SRAM.
- *******************************************************/
-void sdrc_init(void)
-{
-	/* only init up first bank here */
-	do_sdrc_init(CS0, EARLY_INIT);
-}
-
-/*************************************************************************
- * do_sdrc_init(): initialize the SDRAM for use.
- *  -code sets up SDRAM basic SDRC timings for CS0
- *  -optimal settings can be placed here, or redone after i2c
- *      inspection of board info
- *
- *  - code called once in C-Stack only context for CS0 and a possible 2nd
- *      time depending on memory configuration from stack+global context
- **************************************************************************/
-
-void do_sdrc_init(u32 cs, u32 early)
-{
-	struct sdrc_actim *sdrc_actim_base;
-
-	if(cs)
-		sdrc_actim_base = (struct sdrc_actim *)SDRC_ACTIM_CTRL1_BASE;
-	else
-		sdrc_actim_base = (struct sdrc_actim *)SDRC_ACTIM_CTRL0_BASE;
-
-	if (early) {
-		/* reset sdrc controller */
-		writel(SOFTRESET, &sdrc_base->sysconfig);
-		wait_on_value(RESETDONE, RESETDONE, &sdrc_base->status,
-			      12000000);
-		writel(0, &sdrc_base->sysconfig);
-
-		/* setup sdrc to ball mux */
-		writel(SDRC_SHARING, &sdrc_base->sharing);
-
-		/* Disable Power Down of CKE cuz of 1 CKE on combo part */
-		writel(WAKEUPPROC | PWDNEN | SRFRONRESET | PAGEPOLICY_HIGH,
-				&sdrc_base->power);
-
-		writel(ENADLL | DLLPHASE_90, &sdrc_base->dlla_ctrl);
-		sdelay(0x20000);
-	}
-
-	writel(RASWIDTH_13BITS | CASWIDTH_10BITS | ADDRMUXLEGACY |
-		RAMSIZE_128 | BANKALLOCATION | B32NOT16 | B32NOT16 |
-		DEEPPD | DDR_SDRAM, &sdrc_base->cs[cs].mcfg);
-	writel(ARCV | ARE_ARCV_1, &sdrc_base->cs[cs].rfr_ctrl);
-	writel(V_ACTIMA_165, &sdrc_actim_base->ctrla);
-	writel(V_ACTIMB_165, &sdrc_actim_base->ctrlb);
-
-	writel(CMD_NOP, &sdrc_base ->cs[cs].manual);
-	writel(CMD_PRECHARGE, &sdrc_base->cs[cs].manual);
-	writel(CMD_AUTOREFRESH, &sdrc_base->cs[cs].manual);
-	writel(CMD_AUTOREFRESH, &sdrc_base->cs[cs].manual);
-
-	/*
-	 * CAS latency 3, Write Burst = Read Burst, Serial Mode,
-	 * Burst length = 4
-	 */
-	writel(CASL3 | BURSTLENGTH4, &sdrc_base->cs[cs].mr);
-
-	if (!mem_ok(cs))
-		writel(0, &sdrc_base->cs[cs].mcfg);
-}
-
 void enable_gpmc_cs_config(const u32 *gpmc_config, struct gpmc_cs *cs, u32 base,
 			u32 size)
 {
diff --git a/arch/arm/cpu/arm_cortexa8/omap3/sdrc.c b/arch/arm/cpu/arm_cortexa8/omap3/sdrc.c
new file mode 100644
index 0000000..96fd990
--- /dev/null
+++ b/arch/arm/cpu/arm_cortexa8/omap3/sdrc.c
@@ -0,0 +1,202 @@
+/*
+ * Functions related to OMAP3 SDRC.
+ *
+ * This file has been created after exctracting and consolidating
+ * the SDRC related content from mem.c and board.c, also created
+ * generic init function (mem_init).
+ *
+ * Copyright (C) 2004-2010
+ * Texas Instruments Incorporated - http://www.ti.com/
+ *
+ * Author :
+ *     Vaibhav Hiremath <hvaibhav@ti.com>
+ *
+ * Original implementation by (mem.c, board.c) :
+ *      Sunil Kumar <sunilsaini05@gmail.com>
+ *      Shashi Ranjan <shashiranjanmca05@gmail.com>
+ *      Manikandan Pillai <mani.pillai@ti.com>
+ *
+ * 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; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <common.h>
+#include <asm/io.h>
+#include <asm/arch/mem.h>
+#include <asm/arch/sys_proto.h>
+
+extern omap3_sysinfo sysinfo;
+
+static struct sdrc *sdrc_base = (struct sdrc *)OMAP34XX_SDRC_BASE;
+
+/*
+ * is_mem_sdr -
+ *  - Return 1 if mem type in use is SDR
+ */
+u32 is_mem_sdr(void)
+{
+	if (readl(&sdrc_base->cs[CS0].mr) == SDRC_MR_0_SDR)
+		return 1;
+	return 0;
+}
+
+/*
+ * make_cs1_contiguous -
+ *  - For es2 and above remap cs1 behind cs0 to allow command line
+ *    mem=xyz use all memory with out discontinuous support compiled in.
+ *    Could do it at the ATAG, but there really is two banks...
+ *  - Called as part of 2nd phase DDR init.
+ */
+void make_cs1_contiguous(void)
+{
+	u32 size, a_add_low, a_add_high;
+
+	size = get_sdr_cs_size(CS0);
+	size >>= 25;	/* divide by 32 MiB to find size to offset CS1 */
+	a_add_high = (size & 3) << 8;	/* set up low field */
+	a_add_low = (size & 0x3C) >> 2;	/* set up high field */
+	writel((a_add_high | a_add_low), &sdrc_base->cs_cfg);
+
+}
+
+
+/*
+ * get_sdr_cs_size -
+ *  - Get size of chip select 0/1
+ */
+u32 get_sdr_cs_size(u32 cs)
+{
+	u32 size;
+
+	/* get ram size field */
+	size = readl(&sdrc_base->cs[cs].mcfg) >> 8;
+	size &= 0x3FF;		/* remove unwanted bits */
+	size <<= 21;		/* multiply by 2 MiB to find size in MB */
+	return size;
+}
+
+/*
+ * get_sdr_cs_offset -
+ *  - Get offset of cs from cs0 start
+ */
+u32 get_sdr_cs_offset(u32 cs)
+{
+	u32 offset;
+
+	if (!cs)
+		return 0;
+
+	offset = readl(&sdrc_base->cs_cfg);
+	offset = (offset & 15) << 27 | (offset & 0x30) >> 17;
+
+	return offset;
+}
+
+/*
+ * do_sdrc_init -
+ *  - Initialize the SDRAM for use.
+ *  - Sets up SDRC timings for CS0
+ *  - code called once in C-Stack only context for CS0 and a possible 2nd
+ *    time depending on memory configuration from stack+global context
+ */
+void do_sdrc_init(u32 cs, u32 early)
+{
+	struct sdrc_actim *sdrc_actim_base;
+
+	if (cs)
+		sdrc_actim_base = (struct sdrc_actim *)SDRC_ACTIM_CTRL1_BASE;
+	else
+		sdrc_actim_base = (struct sdrc_actim *)SDRC_ACTIM_CTRL0_BASE;
+
+	if (early) {
+		/* reset sdrc controller */
+		writel(SOFTRESET, &sdrc_base->sysconfig);
+		wait_on_value(RESETDONE, RESETDONE, &sdrc_base->status,
+				12000000);
+		writel(0, &sdrc_base->sysconfig);
+
+		/* setup sdrc to ball mux */
+		writel(SDRC_SHARING, &sdrc_base->sharing);
+
+		/* Disable Power Down of CKE cuz of 1 CKE on combo part */
+		writel(WAKEUPPROC | SRFRONRESET | PAGEPOLICY_HIGH,
+				&sdrc_base->power);
+
+		writel(ENADLL | DLLPHASE_90, &sdrc_base->dlla_ctrl);
+		sdelay(0x20000);
+	}
+
+	writel(RASWIDTH_13BITS | CASWIDTH_10BITS | ADDRMUXLEGACY |
+			RAMSIZE_128 | BANKALLOCATION | B32NOT16 | B32NOT16 |
+			DEEPPD | DDR_SDRAM, &sdrc_base->cs[cs].mcfg);
+	writel(ARCV | ARE_ARCV_1, &sdrc_base->cs[cs].rfr_ctrl);
+	writel(V_ACTIMA_165, &sdrc_actim_base->ctrla);
+	writel(V_ACTIMB_165, &sdrc_actim_base->ctrlb);
+
+	writel(CMD_NOP, &sdrc_base->cs[cs].manual);
+	writel(CMD_PRECHARGE, &sdrc_base->cs[cs].manual);
+	writel(CMD_AUTOREFRESH, &sdrc_base->cs[cs].manual);
+	writel(CMD_AUTOREFRESH, &sdrc_base->cs[cs].manual);
+
+	/*
+	 * CAS latency 3, Write Burst = Read Burst, Serial Mode,
+	 * Burst length = 4
+	 */
+	writel(CASL3 | BURSTLENGTH4, &sdrc_base->cs[cs].mr);
+
+	if (!mem_ok(cs))
+		writel(0, &sdrc_base->cs[cs].mcfg);
+}
+
+/*
+ * dram_init -
+ *  - Sets uboots idea of sdram size
+ */
+int dram_init(void)
+{
+	DECLARE_GLOBAL_DATA_PTR;
+	unsigned int size0 = 0, size1 = 0;
+
+	size0 = get_sdr_cs_size(CS0);
+	/*
+	 * If a second bank of DDR is attached to CS1 this is
+	 * where it can be started.  Early init code will init
+	 * memory on CS0.
+	 */
+	if ((sysinfo.mtype == DDR_COMBO) || (sysinfo.mtype == DDR_STACKED)) {
+		do_sdrc_init(CS1, NOT_EARLY);
+		make_cs1_contiguous();
+
+		size1 = get_sdr_cs_size(CS1);
+	}
+
+	gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
+	gd->bd->bi_dram[0].size = size0;
+	gd->bd->bi_dram[1].start = PHYS_SDRAM_1 + get_sdr_cs_offset(CS1);
+	gd->bd->bi_dram[1].size = size1;
+
+	return 0;
+}
+
+/*
+ * mem_init -
+ *  - Init the sdrc chip,
+ *  - Selects CS0 and CS1,
+ */
+void mem_init(void)
+{
+	/* only init up first bank here */
+	do_sdrc_init(CS0, EARLY_INIT);
+}
diff --git a/arch/arm/cpu/arm_cortexa8/omap3/sys_info.c b/arch/arm/cpu/arm_cortexa8/omap3/sys_info.c
index 08fb32e..1df4401 100644
--- a/arch/arm/cpu/arm_cortexa8/omap3/sys_info.c
+++ b/arch/arm/cpu/arm_cortexa8/omap3/sys_info.c
@@ -32,7 +32,6 @@
 #include <i2c.h>

 extern omap3_sysinfo sysinfo;
-static struct sdrc *sdrc_base = (struct sdrc *)OMAP34XX_SDRC_BASE;
 static struct ctrl *ctrl_base = (struct ctrl *)OMAP34XX_CTRL_BASE;
 static char *rev_s[CPU_3XX_MAX_REV] = {
 				"1.0",
@@ -104,46 +103,6 @@ u32 get_cpu_rev(void)
 	}
 }

-/****************************************************
- * is_mem_sdr() - return 1 if mem type in use is SDR
- ****************************************************/
-u32 is_mem_sdr(void)
-{
-	if (readl(&sdrc_base->cs[CS0].mr) == SDRC_MR_0_SDR)
-		return 1;
-	return 0;
-}
-
-/***********************************************************************
- * get_cs0_size() - get size of chip select 0/1
- ************************************************************************/
-u32 get_sdr_cs_size(u32 cs)
-{
-	u32 size;
-
-	/* get ram size field */
-	size = readl(&sdrc_base->cs[cs].mcfg) >> 8;
-	size &= 0x3FF;		/* remove unwanted bits */
-	size <<= 21;		/* multiply by 2 MiB to find size in MB */
-	return size;
-}
-
-/***********************************************************************
- * get_sdr_cs_offset() - get offset of cs from cs0 start
- ************************************************************************/
-u32 get_sdr_cs_offset(u32 cs)
-{
-	u32 offset;
-
-	if (!cs)
-		return 0;
-
-	offset = readl(&sdrc_base->cs_cfg);
-	offset = (offset & 15) << 27 | (offset & 0x30) >> 17;
-
-	return offset;
-}
-
 /***************************************************************************
  *  get_gpmc0_base() - Return current address hardware will be
  *     fetching from. The below effectively gives what is correct, its a bit
diff --git a/arch/arm/include/asm/arch-omap3/cpu.h b/arch/arm/include/asm/arch-omap3/cpu.h
index aa8de32..a49af10 100644
--- a/arch/arm/include/asm/arch-omap3/cpu.h
+++ b/arch/arm/include/asm/arch-omap3/cpu.h
@@ -183,6 +183,7 @@ struct sms {
 /* SDRC */
 #ifndef __KERNEL_STRICT_NAMES
 #ifndef __ASSEMBLY__
+#if defined(CONFIG_SDRC)
 struct sdrc_cs {
 	u32 mcfg;		/* 0x80 || 0xB0 */
 	u32 mr;			/* 0x84 || 0xB4 */
@@ -215,6 +216,8 @@ struct sdrc {
 	u8 res4[0xC];
 	struct sdrc_cs cs[2];	/* 0x80 || 0xB0 */
 };
+
+#endif	/* CONFIG_SDRC */
 #endif /* __ASSEMBLY__ */
 #endif /* __KERNEL_STRICT_NAMES */

diff --git a/arch/arm/include/asm/arch-omap3/mem.h b/arch/arm/include/asm/arch-omap3/mem.h
index 9439758..a78cf9f 100644
--- a/arch/arm/include/asm/arch-omap3/mem.h
+++ b/arch/arm/include/asm/arch-omap3/mem.h
@@ -270,4 +270,17 @@ enum {
 #define PISMO1_ONEN_BASE	ONENAND_MAP
 #define DBG_MPDB_BASE		DEBUG_BASE

+#ifndef __ASSEMBLY__
+
+/* Function prototypes */
+void mem_init(void);
+
+u32 is_mem_sdr(void);
+u32 mem_ok(u32 cs);
+
+u32 get_sdr_cs_size(u32);
+u32 get_sdr_cs_offset(u32);
+
+#endif	/* __ASSEMBLY__ */
+
 #endif /* endif _MEM_H_ */
diff --git a/arch/arm/include/asm/arch-omap3/sys_proto.h b/arch/arm/include/asm/arch-omap3/sys_proto.h
index 34bd515..34e4e0d 100644
--- a/arch/arm/include/asm/arch-omap3/sys_proto.h
+++ b/arch/arm/include/asm/arch-omap3/sys_proto.h
@@ -31,8 +31,10 @@ void prcm_init(void);
 void per_clocks_enable(void);

 void memif_init(void);
+#if defined(CONFIG_SDRC)
 void sdrc_init(void);
 void do_sdrc_init(u32, u32);
+#endif
 void gpmc_init(void);
 void enable_gpmc_cs_config(const u32 *gpmc_config, struct gpmc_cs *cs, u32 base,
 			u32 size);
@@ -46,8 +48,6 @@ u32 get_sysboot_value(void);
 u32 is_gpmc_muxed(void);
 u32 get_gpmc0_type(void);
 u32 get_gpmc0_width(void);
-u32 get_sdr_cs_size(u32);
-u32 get_sdr_cs_offset(u32);
 u32 is_running_in_sdram(void);
 u32 is_running_in_sram(void);
 u32 is_running_in_flash(void);
diff --git a/include/configs/devkit8000.h b/include/configs/devkit8000.h
index 7d1332f..1798bc6 100644
--- a/include/configs/devkit8000.h
+++ b/include/configs/devkit8000.h
@@ -38,6 +38,8 @@
 #define CONFIG_OMAP3430		1	/* which is in a 3430 */
 #define CONFIG_OMAP3_DEVKIT8000	1	/* working with DevKit8000 */

+#define CONFIG_SDRC		1	/* The chip has SDRC controller */
+
 #include <asm/arch/cpu.h>		/* get chip and board defs */
 #include <asm/arch/omap3.h>

diff --git a/include/configs/omap3_beagle.h b/include/configs/omap3_beagle.h
index 08d79ac..7584063 100644
--- a/include/configs/omap3_beagle.h
+++ b/include/configs/omap3_beagle.h
@@ -37,6 +37,8 @@
 #define CONFIG_OMAP3430		1	/* which is in a 3430 */
 #define CONFIG_OMAP3_BEAGLE	1	/* working with BEAGLE */

+#define CONFIG_SDRC		1	/* The chip has SDRC controller */
+
 #include <asm/arch/cpu.h>		/* get chip and board defs */
 #include <asm/arch/omap3.h>

diff --git a/include/configs/omap3_evm.h b/include/configs/omap3_evm.h
index 1d31731..8c17388 100644
--- a/include/configs/omap3_evm.h
+++ b/include/configs/omap3_evm.h
@@ -42,6 +42,8 @@
 #define CONFIG_OMAP3430		1	/* which is in a 3430 */
 #define CONFIG_OMAP3_EVM	1	/* working with EVM */

+#define CONFIG_SDRC		1	/* The chip has SDRC controller */
+
 #include <asm/arch/cpu.h>	/* get chip and board defs */
 #include <asm/arch/omap3.h>

diff --git a/include/configs/omap3_overo.h b/include/configs/omap3_overo.h
index a43500b..5ca9f3a 100644
--- a/include/configs/omap3_overo.h
+++ b/include/configs/omap3_overo.h
@@ -29,6 +29,8 @@
 #define CONFIG_OMAP3430		1	/* which is in a 3430 */
 #define CONFIG_OMAP3_OVERO	1	/* working with overo */

+#define CONFIG_SDRC		1	/* The chip has SDRC controller */
+
 #include <asm/arch/cpu.h>	/* get chip and board defs */
 #include <asm/arch/omap3.h>

diff --git a/include/configs/omap3_pandora.h b/include/configs/omap3_pandora.h
index 945c053..7c62685 100644
--- a/include/configs/omap3_pandora.h
+++ b/include/configs/omap3_pandora.h
@@ -32,6 +32,8 @@
 #define CONFIG_OMAP3430		1	/* which is in a 3430 */
 #define CONFIG_OMAP3_PANDORA	1	/* working with pandora */

+#define CONFIG_SDRC		1	/* The chip has SDRC controller */
+
 #include <asm/arch/cpu.h>	/* get chip and board defs */
 #include <asm/arch/omap3.h>

diff --git a/include/configs/omap3_sdp3430.h b/include/configs/omap3_sdp3430.h
index b4919db..f751592 100644
--- a/include/configs/omap3_sdp3430.h
+++ b/include/configs/omap3_sdp3430.h
@@ -42,6 +42,8 @@
 #define CONFIG_OMAP3430		1	/* which is in a 3430 */
 #define CONFIG_OMAP3_3430SDP	1	/* working with SDP Rev2 */

+#define CONFIG_SDRC		1	/* The chip has SDRC controller */
+
 #include <asm/arch/cpu.h>		/* get chip and board defs */
 #include <asm/arch/omap3.h>

diff --git a/include/configs/omap3_zoom1.h b/include/configs/omap3_zoom1.h
index ae7ebf9..30515b0 100644
--- a/include/configs/omap3_zoom1.h
+++ b/include/configs/omap3_zoom1.h
@@ -38,6 +38,8 @@
 #define CONFIG_OMAP3430		1	/* which is in a 3430 */
 #define CONFIG_OMAP3_ZOOM1	1	/* working with Zoom MDK Rev1 */

+#define CONFIG_SDRC		1	/* The chip has SDRC controller */
+
 #include <asm/arch/cpu.h>		/* get chip and board defs */
 #include <asm/arch/omap3.h>

diff --git a/include/configs/omap3_zoom2.h b/include/configs/omap3_zoom2.h
index c88c732..2861608 100644
--- a/include/configs/omap3_zoom2.h
+++ b/include/configs/omap3_zoom2.h
@@ -39,6 +39,8 @@
 #define CONFIG_OMAP3430		1	/* which is in a 3430 */
 #define CONFIG_OMAP3_ZOOM2	1	/* working with Zoom II */

+#define CONFIG_SDRC		1	/* The chip has SDRC controller */
+
 #include <asm/arch/cpu.h>	/* get chip and board defs */
 #include <asm/arch/omap3.h>

--
1.6.2.4

^ permalink raw reply related	[flat|nested] 263+ messages in thread

* [U-Boot] [PATCH-V2 3/4] AM35x: Add support for AM3517EVM
@ 2010-04-23 14:55 ` hvaibhav at ti.com
  2010-05-05 20:12   ` Wolfgang Denk
  0 siblings, 1 reply; 263+ messages in thread
From: hvaibhav at ti.com @ 2010-04-23 14:55 UTC (permalink / raw)
  To: u-boot

From: Vaibhav Hiremath <hvaibhav@ti.com>

This patch adds basic support for the AM3517EVM.
It includes:
	- Board int file (.c and .h)
	- Default configuration file
	- Updates for Makefile

Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
Signed-off-by: Sanjeev Premi <premi@ti.com>
---
 Makefile                              |    3 +
 arch/arm/include/asm/arch-omap3/mux.h |   36 +++
 board/logicpd/am3517evm/Makefile      |   47 ++++
 board/logicpd/am3517evm/am3517evm.c   |   76 ++++++
 board/logicpd/am3517evm/am3517evm.h   |  405 +++++++++++++++++++++++++++++++++
 board/logicpd/am3517evm/config.mk     |   30 +++
 include/configs/am3517_evm.h          |  297 ++++++++++++++++++++++++
 7 files changed, 894 insertions(+), 0 deletions(-)
 create mode 100644 board/logicpd/am3517evm/Makefile
 create mode 100644 board/logicpd/am3517evm/am3517evm.c
 create mode 100644 board/logicpd/am3517evm/am3517evm.h
 create mode 100644 board/logicpd/am3517evm/config.mk
 create mode 100644 include/configs/am3517_evm.h

diff --git a/Makefile b/Makefile
index 34f10ce..487ae73 100644
--- a/Makefile
+++ b/Makefile
@@ -3169,6 +3169,9 @@ omap3_zoom1_config :	unconfig
 omap3_zoom2_config :	unconfig
 	@$(MKCONFIG) $(@:_config=) arm arm_cortexa8 zoom2 logicpd omap3

+am3517_evm_config :	unconfig
+	@$(MKCONFIG) $(@:_config=) arm arm_cortexa8 am3517evm logicpd omap3
+
 smdkc100_config:	unconfig
 	@$(MKCONFIG) $(@:_config=) arm arm_cortexa8 smdkc100 samsung s5pc1xx

diff --git a/arch/arm/include/asm/arch-omap3/mux.h b/arch/arm/include/asm/arch-omap3/mux.h
index 0c01c73..8ea47b6 100644
--- a/arch/arm/include/asm/arch-omap3/mux.h
+++ b/arch/arm/include/asm/arch-omap3/mux.h
@@ -283,6 +283,7 @@
 /*Control and debug */
 #define CONTROL_PADCONF_SYS_32K		0x0A04
 #define CONTROL_PADCONF_SYS_CLKREQ	0x0A06
+#define CONTROL_PADCONF_SYS_NRESWARM	0x0A08
 #define CONTROL_PADCONF_SYS_NIRQ	0x01E0
 #define CONTROL_PADCONF_SYS_BOOT0	0x0A0A
 #define CONTROL_PADCONF_SYS_BOOT1	0x0A0C
@@ -403,6 +404,41 @@
 #define CONTROL_PADCONF_D2D_SBUSFLAG	0x0260
 #define CONTROL_PADCONF_SDRC_CKE0	0x0262
 #define CONTROL_PADCONF_SDRC_CKE1	0x0264
+/* AM3517 specific */
+#define CONTROL_PADCONF_CCDC_PCLK	0x01E4
+#define CONTROL_PADCONF_CCDC_FIELD	0x01E6
+#define CONTROL_PADCONF_CCDC_HD		0x01E8
+#define CONTROL_PADCONF_CCDC_VD		0x01EA
+#define CONTROL_PADCONF_CCDC_WEN	0x01EC
+#define CONTROL_PADCONF_CCDC_DATA0	0x01EE
+#define CONTROL_PADCONF_CCDC_DATA1	0x01F0
+#define CONTROL_PADCONF_CCDC_DATA2	0x01F2
+#define CONTROL_PADCONF_CCDC_DATA3	0x01F4
+#define CONTROL_PADCONF_CCDC_DATA4	0x01F6
+#define CONTROL_PADCONF_CCDC_DATA5	0x01F8
+#define CONTROL_PADCONF_CCDC_DATA6	0x01FA
+#define CONTROL_PADCONF_CCDC_DATA7	0x01FC
+#define CONTROL_PADCONF_RMII_MDIO_DATA	0x01FE
+#define CONTROL_PADCONF_RMII_MDIO_CLK	0x0200
+#define CONTROL_PADCONF_RMII_RXD0	0x0202
+#define CONTROL_PADCONF_RMII_RXD1	0x0204
+#define CONTROL_PADCONF_RMII_CRS_DV	0x0206
+#define CONTROL_PADCONF_RMII_RXER	0x0208
+#define CONTROL_PADCONF_RMII_TXD0	0x020A
+#define CONTROL_PADCONF_RMII_TXD1	0x020C
+#define CONTROL_PADCONF_RMII_TXEN	0x020E
+#define CONTROL_PADCONF_RMII_50MHZ_CLK	0x0210
+#define CONTROL_PADCONF_USB0_DRVBUS	0x0212
+#define CONTROL_PADCONF_HECC1_TXD	0x0214
+#define CONTROL_PADCONF_HECC1_RXD	0x0216
+#define CONTROL_PADCONF_SYS_BOOT7	0x0218
+#define CONTROL_PADCONF_SDRC_DQS0N	0x021A
+#define CONTROL_PADCONF_SDRC_DQS1N	0x021C
+#define CONTROL_PADCONF_SDRC_DQS2N	0x021E
+#define CONTROL_PADCONF_SDRC_DQS3N	0x0220
+#define CONTROL_PADCONF_STRBEN_DLY0	0x0222
+#define CONTROL_PADCONF_STRBEN_DLY1	0x0224
+#define CONTROL_PADCONF_SYS_BOOT8	0x0226

 #define MUX_VAL(OFFSET,VALUE)\
 	writew((VALUE), OMAP34XX_CTRL_BASE + (OFFSET));
diff --git a/board/logicpd/am3517evm/Makefile b/board/logicpd/am3517evm/Makefile
new file mode 100644
index 0000000..3c71fef
--- /dev/null
+++ b/board/logicpd/am3517evm/Makefile
@@ -0,0 +1,47 @@
+#
+# Author: Vaibhav Hiremath <hvaibhav@ti.com>
+#
+# Based on ti/evm/Makefile
+#
+# Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/
+#
+# 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; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+#
+
+include $(TOPDIR)/config.mk
+
+LIB	= $(obj)lib$(BOARD).a
+
+COBJS	:= am3517evm.o
+
+SRCS	:= $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
+	$(AR) $(ARFLAGS) $@ $(OBJS)
+
+clean:
+	rm -f $(OBJS)
+
+distclean:	clean
+	rm -f $(LIB) core *.bak $(obj).depend
+
+#########################################################################
+
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
+
+sinclude $(obj).depend
+
diff --git a/board/logicpd/am3517evm/am3517evm.c b/board/logicpd/am3517evm/am3517evm.c
new file mode 100644
index 0000000..2b912a9
--- /dev/null
+++ b/board/logicpd/am3517evm/am3517evm.c
@@ -0,0 +1,76 @@
+/*
+ * am3517evm.c - board file for TI's AM3517 family of devices.
+ *
+ * Author: Vaibhav Hiremath <hvaibhav@ti.com>
+ *
+ * Based on ti/evm/evm.c
+ *
+ * Copyright (C) 2010
+ * Texas Instruments Incorporated - http://www.ti.com/
+ *
+ * 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <common.h>
+#include <asm/io.h>
+#include <asm/arch/mem.h>
+#include <asm/arch/mux.h>
+#include <asm/arch/sys_proto.h>
+#include <asm/mach-types.h>
+#include <i2c.h>
+#include "am3517evm.h"
+
+/*
+ * Routine: board_init
+ * Description: Early hardware init.
+ */
+int board_init(void)
+{
+	DECLARE_GLOBAL_DATA_PTR;
+
+	gpmc_init(); /* in SRAM or SDRAM, finish GPMC */
+	/* board id for Linux */
+	gd->bd->bi_arch_number = MACH_TYPE_OMAP3517EVM;
+	/* boot param addr */
+	gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100);
+
+	return 0;
+}
+
+/*
+ * Routine: misc_init_r
+ * Description: Init i2c, ethernet, etc... (done here so udelay works)
+ */
+int misc_init_r(void)
+{
+#ifdef CONFIG_DRIVER_OMAP34XX_I2C
+	i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
+#endif
+
+	dieid_num_r();
+
+	return 0;
+}
+
+/*
+ * Routine: set_muxconf_regs
+ * Description: Setting up the configuration Mux registers specific to the
+ *		hardware. Many pins need to be moved from protect to primary
+ *		mode.
+ */
+void set_muxconf_regs(void)
+{
+	MUX_AM3517EVM();
+}
diff --git a/board/logicpd/am3517evm/am3517evm.h b/board/logicpd/am3517evm/am3517evm.h
new file mode 100644
index 0000000..68d746c
--- /dev/null
+++ b/board/logicpd/am3517evm/am3517evm.h
@@ -0,0 +1,405 @@
+/*
+ * am3517evm.h - Header file for the AM3517 EVM.
+ *
+ * Author: Vaibhav Hiremath <hvaibhav@ti.com>
+ *
+ * Based on ti/evm/evm.h
+ *
+ * Copyright (C) 2010
+ * Texas Instruments Incorporated - http://www.ti.com/
+ *
+ * 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#ifndef _AM3517EVM_H_
+#define _AM3517EVM_H_
+
+const omap3_sysinfo sysinfo = {
+	DDR_DISCRETE,
+	"AM3517EVM Board",
+	"NAND",
+};
+
+/*
+ * IEN  - Input Enable
+ * IDIS - Input Disable
+ * PTD  - Pull type Down
+ * PTU  - Pull type Up
+ * DIS  - Pull type selection is inactive
+ * EN   - Pull type selection is active
+ * M0   - Mode 0
+ * The commented string gives the final mux configuration for that pin
+ */
+#define MUX_AM3517EVM() \
+	/* SDRC */\
+	MUX_VAL(CP(SDRC_D0),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_D1),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_D2),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_D3),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_D4),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_D5),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_D6),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_D7),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_D8),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_D9),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_D10),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_D11),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_D12),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_D13),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_D14),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_D15),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_D16),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_D17),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_D18),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_D19),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_D20),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_D21),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_D22),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_D23),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_D24),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_D25),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_D26),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_D27),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_D28),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_D29),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_D30),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_D31),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_CLK),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_DQS0),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_DQS1),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_DQS2),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_DQS3),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_DQS0N),		(IEN  | PTD | EN  | M0)) \
+	MUX_VAL(CP(SDRC_DQS1N),		(IEN  | PTD | EN  | M0)) \
+	MUX_VAL(CP(SDRC_DQS2N),		(IEN  | PTD | EN  | M0)) \
+	MUX_VAL(CP(SDRC_DQS3N),		(IEN  | PTD | EN  | M0)) \
+	MUX_VAL(CP(SDRC_CKE0),		(M0)) \
+	MUX_VAL(CP(SDRC_CKE1),		(M0)) \
+	/*sdrc_strben_dly0*/\
+	MUX_VAL(CP(STRBEN_DLY0),	(IEN  | PTD | EN  | M0)) \
+	 /*sdrc_strben_dly1*/\
+	MUX_VAL(CP(STRBEN_DLY1),	(IEN  | PTD | EN  | M0)) \
+	/* GPMC */\
+	MUX_VAL(CP(GPMC_A1),		(IDIS | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_A2),		(IDIS | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_A3),		(IDIS | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_A4),		(IDIS | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_A5),		(IDIS | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_A6),		(IDIS | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_A7),		(IDIS | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_A8),		(IDIS | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_A9),		(IDIS | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_A10),		(IDIS | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_D0),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_D1),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_D2),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_D3),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_D4),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_D5),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_D6),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_D7),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_D8),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_D9),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_D10),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_D11),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_D12),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_D13),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_D14),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_D15),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_NCS0),		(IDIS | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_NCS1),		(IDIS | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_NCS2),		(IDIS | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_NCS3),		(IDIS | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_NCS4),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_NCS5),		(IDIS | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_NCS6),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(GPMC_NCS7),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_CLK),		(IDIS | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_NADV_ALE),	(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(GPMC_NOE),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(GPMC_NWE),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(GPMC_NBE0_CLE),	(IDIS | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_NBE1),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_NWP),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(GPMC_WAIT0),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_WAIT1),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_WAIT2),		(IEN  | PTU | EN  | M4)) /*GPIO_64*/\
+							 /* - ETH_nRESET*/\
+	MUX_VAL(CP(GPMC_WAIT3),		(IEN  | PTU | EN  | M0)) \
+	/* DSS */\
+	MUX_VAL(CP(DSS_PCLK),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(DSS_HSYNC),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(DSS_VSYNC),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(DSS_ACBIAS),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(DSS_DATA0),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(DSS_DATA1),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(DSS_DATA2),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(DSS_DATA3),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(DSS_DATA4),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(DSS_DATA5),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(DSS_DATA6),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(DSS_DATA7),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(DSS_DATA8),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(DSS_DATA9),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(DSS_DATA10),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(DSS_DATA11),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(DSS_DATA12),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(DSS_DATA13),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(DSS_DATA14),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(DSS_DATA15),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(DSS_DATA16),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(DSS_DATA17),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(DSS_DATA18),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(DSS_DATA19),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(DSS_DATA20),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(DSS_DATA21),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(DSS_DATA22),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(DSS_DATA23),		(IDIS | PTD | DIS | M0)) \
+	/* CAMERA */\
+	MUX_VAL(CP(CAM_HS),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(CAM_VS),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(CAM_XCLKA),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(CAM_PCLK),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(CAM_FLD),		(IDIS | PTD | DIS | M4)) /*GPIO_98*/\
+							 /* - CAM_RESET*/\
+	MUX_VAL(CP(CAM_D0),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(CAM_D1),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(CAM_D2),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(CAM_D3),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(CAM_D4),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(CAM_D5),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(CAM_D6),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(CAM_D7),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(CAM_D8),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(CAM_D9),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(CAM_D10),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(CAM_D11),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(CAM_XCLKB),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(CAM_WEN),		(IEN  | PTD | DIS | M4)) /*GPIO_167*/\
+	MUX_VAL(CP(CAM_STROBE),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(CSI2_DX0),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(CSI2_DY0),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(CSI2_DX1),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(CSI2_DY1),		(IEN  | PTD | DIS | M0)) \
+	/* MMC */\
+	MUX_VAL(CP(MMC1_CLK),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(MMC1_CMD),		(IEN  | PTU | DIS | M0)) \
+	MUX_VAL(CP(MMC1_DAT0),		(IEN  | PTU | DIS | M0)) \
+	MUX_VAL(CP(MMC1_DAT1),		(IEN  | PTU | DIS | M0)) \
+	MUX_VAL(CP(MMC1_DAT2),		(IEN  | PTU | DIS | M0)) \
+	MUX_VAL(CP(MMC1_DAT3),		(IEN  | PTU | DIS | M0)) \
+	/* WriteProtect */\
+	MUX_VAL(CP(MMC1_DAT4),		(IEN  | PTU | EN  | M4)) \
+	MUX_VAL(CP(MMC1_DAT5),		(IEN  | PTU | EN  | M4)) /*CardDetect*/\
+	MUX_VAL(CP(MMC1_DAT6),		(IEN  | PTU | EN  | M4)) \
+	MUX_VAL(CP(MMC1_DAT7),		(IEN  | PTU | EN  | M4)) \
+	\
+	MUX_VAL(CP(MMC2_CLK),		(IEN  | PTD | EN  | M0)) \
+	MUX_VAL(CP(MMC2_CMD),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(MMC2_DAT0),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(MMC2_DAT1),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(MMC2_DAT2),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(MMC2_DAT3),		(IEN  | PTD | DIS | M0)) \
+	/* McBSP */\
+	MUX_VAL(CP(MCBSP_CLKS),		(IEN  | PTU | DIS | M0)) \
+	MUX_VAL(CP(MCBSP1_CLKR),	(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(MCBSP1_FSR),		(IDIS | PTU | EN  | M0)) \
+	MUX_VAL(CP(MCBSP1_DX),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(MCBSP1_DR),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(MCBSP1_FSX),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(MCBSP1_CLKX),	(IEN  | PTD | DIS | M0)) \
+	\
+	MUX_VAL(CP(MCBSP2_FSX),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(MCBSP2_CLKX),	(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(MCBSP2_DR),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(MCBSP2_DX),		(IDIS | PTD | DIS | M0)) \
+	\
+	MUX_VAL(CP(MCBSP3_DX),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(MCBSP3_DR),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(MCBSP3_CLKX),	(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(MCBSP3_FSX),		(IEN  | PTD | DIS | M0)) \
+	\
+	MUX_VAL(CP(MCBSP4_CLKX),	(IDIS | PTD | DIS | M4)) /*GPIO_152*/\
+							 /* - LCD_INI*/\
+	MUX_VAL(CP(MCBSP4_DR),		(IDIS | PTD | DIS | M4)) /*GPIO_153*/\
+							 /* - LCD_ENVDD */\
+	MUX_VAL(CP(MCBSP4_DX),		(IDIS | PTD | DIS | M4)) /*GPIO_154*/\
+							 /* - LCD_QVGA/nVGA */\
+	MUX_VAL(CP(MCBSP4_FSX),		(IDIS | PTD | DIS | M4)) /*GPIO_155*/\
+							 /* - LCD_RESB */\
+	/* UART */\
+	MUX_VAL(CP(UART1_TX),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(UART1_RTS),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(UART1_CTS),		(IEN  | PTU | DIS | M0)) \
+	\
+	MUX_VAL(CP(UART1_RX),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(UART2_CTS),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(UART2_RTS),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(UART2_TX),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(UART2_RX),		(IEN  | PTD | DIS | M0)) \
+	\
+	MUX_VAL(CP(UART3_CTS_RCTX),	(IEN  | PTU | DIS | M0)) \
+	MUX_VAL(CP(UART3_RTS_SD),	(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(UART3_RX_IRRX),	(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(UART3_TX_IRTX),	(IDIS | PTD | DIS | M0)) \
+	/* I2C */\
+	MUX_VAL(CP(I2C1_SCL),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(I2C1_SDA),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(I2C2_SCL),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(I2C2_SDA),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(I2C3_SCL),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(I2C3_SDA),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(I2C4_SCL),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(I2C4_SDA),		(IEN  | PTU | EN  | M0)) \
+	/* McSPI */\
+	MUX_VAL(CP(MCSPI1_CLK),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(MCSPI1_SIMO),	(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(MCSPI1_SOMI),	(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(MCSPI1_CS0),		(IEN  | PTD | EN  | M0)) \
+	MUX_VAL(CP(MCSPI1_CS1),		(IEN  | PTD | EN  | M4)) /*GPIO_175*/\
+	MUX_VAL(CP(MCSPI1_CS2),		(IEN  | PTU | DIS | M4)) /*GPIO_176*/\
+							 /* - LAN_INTR*/\
+	MUX_VAL(CP(MCSPI1_CS3),		(IEN  | PTD | EN  | M0)) \
+	\
+	MUX_VAL(CP(MCSPI2_CLK),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(MCSPI2_SIMO),	(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(MCSPI2_SOMI),	(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(MCSPI2_CS0),		(IEN  | PTD | EN  | M4)) \
+	MUX_VAL(CP(MCSPI2_CS1),		(IEN  | PTD | EN  | M4)) \
+	/* CCDC */\
+	MUX_VAL(CP(CCDC_PCLK),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(CCDC_FIELD),		(IEN  | PTD | DIS | M1)) \
+	MUX_VAL(CP(CCDC_HD),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(CCDC_VD),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(CCDC_WEN),		(IEN  | PTD | DIS | M1)) \
+	MUX_VAL(CP(CCDC_DATA0),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(CCDC_DATA1),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(CCDC_DATA2),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(CCDC_DATA3),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(CCDC_DATA4),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(CCDC_DATA5),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(CCDC_DATA6),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(CCDC_DATA7),		(IEN  | PTD | DIS | M0)) \
+	/* RMII */\
+	MUX_VAL(CP(RMII_MDIO_DATA),	(IEN  |  M0)) \
+	MUX_VAL(CP(RMII_MDIO_CLK),	(M0)) \
+	MUX_VAL(CP(RMII_RXD0)	,	(IEN  | PTD | M0)) \
+	MUX_VAL(CP(RMII_RXD1),		(IEN  | PTD | M0)) \
+	MUX_VAL(CP(RMII_CRS_DV),	(IEN  | PTD | M0)) \
+	MUX_VAL(CP(RMII_RXER),		(PTD | M0)) \
+	MUX_VAL(CP(RMII_TXD0),		(PTD | M0)) \
+	MUX_VAL(CP(RMII_TXD1),		(PTD | M0)) \
+	MUX_VAL(CP(RMII_TXEN),		(PTD | M0)) \
+	MUX_VAL(CP(RMII_50MHZ_CLK),	(IEN  | PTD | EN  | M0)) \
+	/* HECC */\
+	MUX_VAL(CP(HECC1_TXD),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(HECC1_RXD),		(IEN  | PTU | EN  | M0)) \
+	/* HSUSB */\
+	MUX_VAL(CP(HSUSB0_CLK),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(HSUSB0_STP),		(IDIS | PTU | EN  | M0)) \
+	MUX_VAL(CP(HSUSB0_DIR),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(HSUSB0_NXT),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(HSUSB0_DATA0),	(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(HSUSB0_DATA1),	(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(HSUSB0_DATA2),	(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(HSUSB0_DATA3),	(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(HSUSB0_DATA4),	(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(HSUSB0_DATA5),	(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(HSUSB0_DATA6),	(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(HSUSB0_DATA7),	(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(USB0_DRVBUS),	(IEN  | PTD | EN  | M0)) \
+	/* HDQ */\
+	MUX_VAL(CP(HDQ_SIO),		(IEN  | PTU | EN  | M0)) \
+	/* Control and debug */\
+	MUX_VAL(CP(SYS_32K),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SYS_CLKREQ),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SYS_NIRQ),		(IEN  | PTU | EN  | M0)) \
+	/*SYS_nRESWARM */\
+	MUX_VAL(CP(SYS_NRESWARM),     	(IDIS | PTU | DIS | M4)) \
+							/* - GPIO30 */\
+	MUX_VAL(CP(SYS_BOOT0),		(IEN  | PTD | DIS | M4)) /*GPIO_2*/\
+							 /* - PEN_IRQ */\
+	MUX_VAL(CP(SYS_BOOT1),		(IEN  | PTD | DIS | M4)) /*GPIO_3 */\
+	MUX_VAL(CP(SYS_BOOT2),		(IEN  | PTD | DIS | M4)) /*GPIO_4*/\
+	MUX_VAL(CP(SYS_BOOT3),		(IEN  | PTD | DIS | M4)) /*GPIO_5*/\
+	MUX_VAL(CP(SYS_BOOT4),		(IEN  | PTD | DIS | M4)) /*GPIO_6*/\
+	MUX_VAL(CP(SYS_BOOT5),		(IEN  | PTD | DIS | M4)) /*GPIO_7*/\
+	MUX_VAL(CP(SYS_BOOT6),		(IDIS | PTD | DIS | M4)) /*GPIO_8*/\
+							 /* - VIO_1V8*/\
+	MUX_VAL(CP(SYS_BOOT7),		(IEN  | PTD | EN  | M0)) \
+	MUX_VAL(CP(SYS_BOOT8),		(IEN  | PTD | EN  | M0)) \
+	\
+	MUX_VAL(CP(SYS_OFF_MODE),	(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SYS_CLKOUT1),	(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SYS_CLKOUT2),	(IEN  | PTU | EN  | M0)) \
+	/* JTAG */\
+	MUX_VAL(CP(JTAG_nTRST),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(JTAG_TCK),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(JTAG_TMS),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(JTAG_TDI),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(JTAG_EMU0),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(JTAG_EMU1),		(IEN  | PTD | DIS | M0)) \
+	/* ETK (ES2 onwards) */\
+	MUX_VAL(CP(ETK_CLK_ES2),	(IDIS | PTU | EN  | M0)) \
+	MUX_VAL(CP(ETK_CTL_ES2),	(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(ETK_D0_ES2),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(ETK_D1_ES2),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(ETK_D2_ES2),		(IEN  | PTD | EN  | M0)) \
+	MUX_VAL(CP(ETK_D3_ES2),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(ETK_D4_ES2),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(ETK_D5_ES2),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(ETK_D6_ES2),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(ETK_D7_ES2),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(ETK_D8_ES2),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(ETK_D9_ES2),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(ETK_D10_ES2),	(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(ETK_D11_ES2),	(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(ETK_D12_ES2),	(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(ETK_D13_ES2),	(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(ETK_D14_ES2),	(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(ETK_D15_ES2),	(IEN  | PTD | DIS | M0)) \
+	/* Die to Die */\
+	MUX_VAL(CP(D2D_MCAD34),		(IEN  | PTD | EN  | M0)) \
+	MUX_VAL(CP(D2D_MCAD35),		(IEN  | PTD | EN  | M0)) \
+	MUX_VAL(CP(D2D_MCAD36),		(IEN  | PTD | EN  | M0)) \
+	MUX_VAL(CP(D2D_CLK26MI),	(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(D2D_NRESPWRON),	(IEN  | PTD | EN  | M0)) \
+	MUX_VAL(CP(D2D_NRESWARM),	(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(D2D_ARM9NIRQ),	(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(D2D_UMA2P6FIQ),	(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(D2D_SPINT),		(IEN  | PTD | EN  | M0)) \
+	MUX_VAL(CP(D2D_FRINT),		(IEN  | PTD | EN  | M0)) \
+	MUX_VAL(CP(D2D_DMAREQ0),	(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(D2D_DMAREQ1),	(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(D2D_DMAREQ2),	(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(D2D_DMAREQ3),	(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(D2D_N3GTRST),	(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(D2D_N3GTDI),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(D2D_N3GTDO),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(D2D_N3GTMS),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(D2D_N3GTCK),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(D2D_N3GRTCK),	(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(D2D_MSTDBY),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(D2D_SWAKEUP),	(IEN  | PTD | EN  | M0)) \
+	MUX_VAL(CP(D2D_IDLEREQ),	(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(D2D_IDLEACK),	(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(D2D_MWRITE),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(D2D_SWRITE),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(D2D_MREAD),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(D2D_SREAD),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(D2D_MBUSFLAG),	(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(D2D_SBUSFLAG),	(IEN  | PTD | DIS | M0)) \
+
+#endif
diff --git a/board/logicpd/am3517evm/config.mk b/board/logicpd/am3517evm/config.mk
new file mode 100644
index 0000000..f7a35ce
--- /dev/null
+++ b/board/logicpd/am3517evm/config.mk
@@ -0,0 +1,30 @@
+#
+# Author: Vaibhav Hiremath <hvaibhav@ti.com>
+#
+# Based on ti/evm/config.mk
+#
+# Copyright (C) 2010
+# Texas Instruments Incorporated - http://www.ti.com/
+#
+# 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; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+#
+# Physical Address:
+# 8000'0000 (bank0)
+# A000/0000 (bank1)
+# Linux-Kernel is expected to be at 8000'8000, entry 8000'8000
+# (mem base + reserved)
+
+# For use with external or internal boots.
+TEXT_BASE = 0x80e80000
diff --git a/include/configs/am3517_evm.h b/include/configs/am3517_evm.h
new file mode 100644
index 0000000..115bd0f
--- /dev/null
+++ b/include/configs/am3517_evm.h
@@ -0,0 +1,297 @@
+/*
+ * am3517_evm.h - Default configuration for AM3517 EVM board.
+ *
+ * Author: Vaibhav Hiremath <hvaibhav@ti.com>
+ *
+ * Based on omap3_evm_config.h
+ *
+ * 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#ifndef __CONFIG_H
+#define __CONFIG_H
+
+/*
+ * High Level Configuration Options
+ */
+#define CONFIG_ARMCORTEXA8	1	/* This is an ARM V7 CPU core */
+#define CONFIG_OMAP		1	/* in a TI OMAP core */
+#define CONFIG_OMAP34XX		1	/* which is a 34XX */
+#define CONFIG_OMAP3_AM3517EVM	1	/* working with AM3517EVM */
+
+#define CONFIG_EMIF4		1	/* The chip has EMIF4 controller */
+
+#include <asm/arch/cpu.h>		/* get chip and board defs */
+#include <asm/arch/omap3.h>
+
+/*
+ * Display CPU and Board information
+ */
+#define CONFIG_DISPLAY_CPUINFO		1
+#define CONFIG_DISPLAY_BOARDINFO	1
+
+/* Clock Defines */
+#define V_OSCK			26000000	/* Clock output from T2 */
+#define V_SCLK			(V_OSCK >> 1)
+
+#undef CONFIG_USE_IRQ				/* no support for IRQs */
+#define CONFIG_MISC_INIT_R
+
+#define CONFIG_CMDLINE_TAG		1	/* enable passing of ATAGs */
+#define CONFIG_SETUP_MEMORY_TAGS	1
+#define CONFIG_INITRD_TAG		1
+#define CONFIG_REVISION_TAG		1
+
+/*
+ * Size of malloc() pool
+ */
+#define CONFIG_ENV_SIZE			(128 << 10)	/* 128 KiB sector */
+#define CONFIG_SYS_MALLOC_LEN		(CONFIG_ENV_SIZE + (128 << 10))
+#define CONFIG_SYS_GBL_DATA_SIZE	128	/* bytes reserved for */
+						/* initial data */
+/*
+ * DDR related
+ */
+#define CONFIG_OMAP3_MICRON_DDR		1	/* Micron DDR */
+#define CONFIG_SYS_CS0_SIZE		(256 * 1024 * 1024)
+
+/*
+ * Hardware drivers
+ */
+
+/*
+ * NS16550 Configuration
+ */
+#define V_NS16550_CLK			48000000	/* 48MHz (APLL96/2) */
+
+#define CONFIG_SYS_NS16550
+#define CONFIG_SYS_NS16550_SERIAL
+#define CONFIG_SYS_NS16550_REG_SIZE	(-4)
+#define CONFIG_SYS_NS16550_CLK		V_NS16550_CLK
+
+/*
+ * select serial console configuration
+ */
+#define CONFIG_CONS_INDEX		3
+#define CONFIG_SYS_NS16550_COM3		OMAP34XX_UART3
+#define CONFIG_SERIAL3			3	/* UART3 on AM3517 EVM */
+
+/* allow to overwrite serial and ethaddr */
+#define CONFIG_ENV_OVERWRITE
+#define CONFIG_BAUDRATE			115200
+#define CONFIG_SYS_BAUDRATE_TABLE	{4800, 9600, 19200, 38400, 57600,\
+					115200}
+#define CONFIG_MMC			1
+#define CONFIG_OMAP3_MMC		1
+#define CONFIG_DOS_PARTITION		1
+
+/* commands to include */
+#include <config_cmd_default.h>
+
+#define CONFIG_CMD_EXT2		/* EXT2 Support			*/
+#define CONFIG_CMD_FAT		/* FAT support			*/
+#define CONFIG_CMD_JFFS2	/* JFFS2 Support		*/
+
+#define CONFIG_CMD_I2C		/* I2C serial bus support	*/
+#define CONFIG_CMD_MMC		/* MMC support			*/
+#define CONFIG_CMD_NAND		/* NAND support			*/
+#define CONFIG_CMD_DHCP
+#define CONFIG_CMD_PING
+
+#undef CONFIG_CMD_FLASH		/* flinfo, erase, protect	*/
+#undef CONFIG_CMD_FPGA		/* FPGA configuration Support	*/
+#undef CONFIG_CMD_IMI		/* iminfo			*/
+#undef CONFIG_CMD_IMLS		/* List all found images	*/
+
+#define CONFIG_SYS_NO_FLASH
+#define CONFIG_HARD_I2C			1
+#define CONFIG_SYS_I2C_SPEED		100000
+#define CONFIG_SYS_I2C_SLAVE		1
+#define CONFIG_SYS_I2C_BUS		0
+#define CONFIG_SYS_I2C_BUS_SELECT	1
+#define CONFIG_DRIVER_OMAP34XX_I2C	1
+
+#undef CONFIG_CMD_NET
+/*
+ * Board NAND Info.
+ */
+#define CONFIG_SYS_NAND_ADDR		NAND_BASE	/* physical address */
+							/* to access nand */
+#define CONFIG_SYS_NAND_BASE		NAND_BASE	/* physical address */
+							/* to access */
+							/* nand at CS0 */
+
+#define CONFIG_SYS_MAX_NAND_DEVICE	1		/* Max number of */
+							/* NAND devices */
+#define CONFIG_SYS_64BIT_VSPRINTF		/* needed for nand_util.c */
+
+#define CONFIG_JFFS2_NAND
+/* nand device jffs2 lives on */
+#define CONFIG_JFFS2_DEV		"nand0"
+/* start of jffs2 partition */
+#define CONFIG_JFFS2_PART_OFFSET	0x680000
+#define CONFIG_JFFS2_PART_SIZE		0xf980000	/* sz of jffs2 part */
+
+/* Environment information */
+#define CONFIG_BOOTDELAY	10
+
+#define CONFIG_BOOTFILE		uImage
+
+#define CONFIG_EXTRA_ENV_SETTINGS \
+	"loadaddr=0x82000000\0" \
+	"console=ttyS2,115200n8\0" \
+	"mmcargs=setenv bootargs console=${console} " \
+		"root=/dev/mmcblk0p2 rw " \
+		"rootfstype=ext3 rootwait\0" \
+	"nandargs=setenv bootargs console=${console} " \
+		"root=/dev/mtdblock4 rw " \
+		"rootfstype=jffs2\0" \
+	"loadbootscript=fatload mmc 0 ${loadaddr} boot.scr\0" \
+	"bootscript=echo Running bootscript from mmc ...; " \
+		"source ${loadaddr}\0" \
+	"loaduimage=fatload mmc 0 ${loadaddr} uImage\0" \
+	"mmcboot=echo Booting from mmc ...; " \
+		"run mmcargs; " \
+		"bootm ${loadaddr}\0" \
+	"nandboot=echo Booting from nand ...; " \
+		"run nandargs; " \
+		"nand read ${loadaddr} 280000 400000; " \
+		"bootm ${loadaddr}\0" \
+
+#define CONFIG_BOOTCOMMAND \
+	"if mmc init; then " \
+		"if run loadbootscript; then " \
+			"run bootscript; " \
+		"else " \
+			"if run loaduimage; then " \
+				"run mmcboot; " \
+			"else run nandboot; " \
+			"fi; " \
+		"fi; " \
+	"else run nandboot; fi"
+
+#define CONFIG_AUTO_COMPLETE	1
+/*
+ * Miscellaneous configurable options
+ */
+#define V_PROMPT			"AM3517_EVM # "
+
+#define CONFIG_SYS_LONGHELP		/* undef to save memory */
+#define CONFIG_SYS_HUSH_PARSER		/* use "hush" command parser */
+#define CONFIG_SYS_PROMPT_HUSH_PS2	"> "
+#define CONFIG_SYS_PROMPT		V_PROMPT
+#define CONFIG_SYS_CBSIZE		512	/* Console I/O Buffer Size */
+/* Print Buffer Size */
+#define CONFIG_SYS_PBSIZE		(CONFIG_SYS_CBSIZE + \
+					sizeof(CONFIG_SYS_PROMPT) + 16)
+#define CONFIG_SYS_MAXARGS		32	/* max number of command */
+						/* args */
+/* Boot Argument Buffer Size */
+#define CONFIG_SYS_BARGSIZE		(CONFIG_SYS_CBSIZE)
+/* memtest works on */
+#define CONFIG_SYS_MEMTEST_START	(OMAP34XX_SDRC_CS0)
+#define CONFIG_SYS_MEMTEST_END		(OMAP34XX_SDRC_CS0 + \
+					0x01F00000) /* 31MB */
+
+#define CONFIG_SYS_LOAD_ADDR		(OMAP34XX_SDRC_CS0) /* default load */
+								/* address */
+
+/*
+ * AM3517 has 12 GP timers, they can be driven by the system clock
+ * (12/13/16.8/19.2/38.4MHz) or by 32KHz clock. We use 13MHz (V_SCLK).
+ * This rate is divided by a local divisor.
+ */
+#define CONFIG_SYS_TIMERBASE		OMAP34XX_GPT2
+#define CONFIG_SYS_PTV			2	/* Divisor: 2^(PTV+1) => 8 */
+#define CONFIG_SYS_HZ			1000
+
+/*-----------------------------------------------------------------------
+ * Stack sizes
+ *
+ * The stack sizes are set up in start.S using the settings below
+ */
+#define CONFIG_STACKSIZE	(128 << 10)	/* regular stack 128 KiB */
+#ifdef CONFIG_USE_IRQ
+#define CONFIG_STACKSIZE_IRQ	(4 << 10)	/* IRQ stack 4 KiB */
+#define CONFIG_STACKSIZE_FIQ	(4 << 10)	/* FIQ stack 4 KiB */
+#endif
+
+/*-----------------------------------------------------------------------
+ * Physical Memory Map
+ */
+#define CONFIG_NR_DRAM_BANKS	2	/* CS1 may or may not be populated */
+#define PHYS_SDRAM_1		OMAP34XX_SDRC_CS0
+#define PHYS_SDRAM_1_SIZE	(32 << 20)	/* at least 32 MiB */
+#define PHYS_SDRAM_2		OMAP34XX_SDRC_CS1
+
+/* SDRAM Bank Allocation method */
+#define SDRC_R_B_C		1
+
+/*-----------------------------------------------------------------------
+ * FLASH and environment organization
+ */
+
+/* **** PISMO SUPPORT *** */
+
+/* Configure the PISMO */
+#define PISMO1_NAND_SIZE		GPMC_SIZE_128M
+#define PISMO1_ONEN_SIZE		GPMC_SIZE_128M
+
+#define CONFIG_SYS_MAX_FLASH_SECT	520	/* max number of sectors */
+						/* on one chip */
+#define CONFIG_SYS_MAX_FLASH_BANKS	2	/* max number of flash banks */
+#define CONFIG_SYS_MONITOR_LEN		(256 << 10)	/* Reserve 2 sectors */
+
+#define CONFIG_SYS_FLASH_BASE		boot_flash_base
+
+/* Monitor@start of flash */
+#define CONFIG_SYS_MONITOR_BASE		CONFIG_SYS_FLASH_BASE
+
+#define CONFIG_NAND_OMAP_GPMC
+#define GPMC_NAND_ECC_LP_x16_LAYOUT	1
+#define CONFIG_ENV_IS_IN_NAND		1
+#define SMNAND_ENV_OFFSET		0x260000 /* environment starts here */
+
+#define CONFIG_SYS_ENV_SECT_SIZE	boot_flash_sec
+#define CONFIG_ENV_OFFSET		boot_flash_off
+#define CONFIG_ENV_ADDR			boot_flash_env_addr
+
+/*-----------------------------------------------------------------------
+ * CFI FLASH driver setup
+ */
+/* timeout values are in ticks */
+#define CONFIG_SYS_FLASH_ERASE_TOUT	(100 * CONFIG_SYS_HZ)
+#define CONFIG_SYS_FLASH_WRITE_TOUT	(100 * CONFIG_SYS_HZ)
+
+/* Flash banks JFFS2 should use */
+#define CONFIG_SYS_MAX_MTD_BANKS	(CONFIG_SYS_MAX_FLASH_BANKS + \
+					CONFIG_SYS_MAX_NAND_DEVICE)
+#define CONFIG_SYS_JFFS2_MEM_NAND
+/* use flash_info[2] */
+#define CONFIG_SYS_JFFS2_FIRST_BANK	CONFIG_SYS_MAX_FLASH_BANKS
+#define CONFIG_SYS_JFFS2_NUM_BANKS	1
+
+#ifndef __ASSEMBLY__
+extern unsigned int boot_flash_base;
+extern volatile unsigned int boot_flash_env_addr;
+extern unsigned int boot_flash_off;
+extern unsigned int boot_flash_sec;
+extern unsigned int boot_flash_type;
+#endif
+
+#endif /* __CONFIG_H */
+
--
1.6.2.4

^ permalink raw reply related	[flat|nested] 263+ messages in thread

* [U-Boot] [PATCH-V2 4/4] AM35x: Add support for EMIF4
@ 2010-04-23 14:55 ` hvaibhav at ti.com
  2010-05-05 20:14   ` Wolfgang Denk
  0 siblings, 1 reply; 263+ messages in thread
From: hvaibhav at ti.com @ 2010-04-23 14:55 UTC (permalink / raw)
  To: u-boot

From: Vaibhav Hiremath <hvaibhav@ti.com>

This patch adds support for the EMIF4 interface
available in the AM35x processors.

Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
Signed-off-by: Sanjeev Premi <premi@ti.com>
---
 arch/arm/cpu/arm_cortexa8/omap3/Makefile    |    3 +
 arch/arm/cpu/arm_cortexa8/omap3/emif4.c     |  168 +++++++++++++++++++++++++++
 arch/arm/include/asm/arch-omap3/cpu.h       |   24 ++++
 arch/arm/include/asm/arch-omap3/emif4.h     |   79 +++++++++++++
 arch/arm/include/asm/arch-omap3/sys_proto.h |    3 +
 5 files changed, 277 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/cpu/arm_cortexa8/omap3/emif4.c
 create mode 100644 arch/arm/include/asm/arch-omap3/emif4.h

diff --git a/arch/arm/cpu/arm_cortexa8/omap3/Makefile b/arch/arm/cpu/arm_cortexa8/omap3/Makefile
index 8cc7802..0a23fa5 100644
--- a/arch/arm/cpu/arm_cortexa8/omap3/Makefile
+++ b/arch/arm/cpu/arm_cortexa8/omap3/Makefile
@@ -36,6 +36,9 @@ COBJS	+= mem.o
 ifdef	CONFIG_SDRC
 COBJS	+= sdrc.o
 endif
+ifdef	CONFIG_EMIF4
+COBJS	+= emif4.o
+endif
 COBJS	+= syslib.o
 COBJS	+= sys_info.o
 COBJS	+= timer.o
diff --git a/arch/arm/cpu/arm_cortexa8/omap3/emif4.c b/arch/arm/cpu/arm_cortexa8/omap3/emif4.c
new file mode 100644
index 0000000..749a394
--- /dev/null
+++ b/arch/arm/cpu/arm_cortexa8/omap3/emif4.c
@@ -0,0 +1,168 @@
+/*
+ * Author :
+ *     Vaibhav Hiremath <hvaibhav@ti.com>
+ *
+ * Based on mem.c and sdrc.c
+ *
+ * Copyright (C) 2010
+ * Texas Instruments Incorporated - http://www.ti.com/
+ *
+ * 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; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <common.h>
+#include <asm/io.h>
+#include <asm/arch/mem.h>
+#include <asm/arch/sys_proto.h>
+#include <asm/arch/emif4.h>
+
+extern omap3_sysinfo sysinfo;
+
+static emif4_t *emif4_base = (emif4_t *)OMAP34XX_SDRC_BASE;
+
+/*
+ * is_mem_sdr -
+ *  - Return 1 if mem type in use is SDR
+ */
+u32 is_mem_sdr(void)
+{
+	return 0;
+}
+
+/*
+ * get_sdr_cs_size -
+ *  - Get size of chip select 0/1
+ */
+u32 get_sdr_cs_size(u32 cs)
+{
+	u32 size;
+
+	/* TODO: Calculate the size based on EMIF4 configuration */
+	size = CONFIG_SYS_CS0_SIZE;
+
+	return size;
+}
+
+/*
+ * get_sdr_cs_offset -
+ *  - Get offset of cs from cs0 start
+ */
+u32 get_sdr_cs_offset(u32 cs)
+{
+	u32 offset = 0;
+
+	return offset;
+}
+
+/*
+ * do_emif4_init -
+ *  - Init the emif4 module for DDR access
+ *  - Early init routines, called from flash or SRAM.
+ */
+void do_emif4_init(void)
+{
+	unsigned int regval;
+	/* Set the DDR PHY parameters in PHY ctrl registers */
+	regval = (EMIF4_DDR1_READ_LAT | EMIF4_DDR1_PWRDN_DIS |
+		EMIF4_DDR1_EXT_STRB_DIS);
+	writel(regval, &emif4_base->ddr_phyctrl1);
+	writel(regval, &emif4_base->ddr_phyctrl1_shdw);
+	writel(0, &emif4_base->ddr_phyctrl2);
+
+	/* Reset the DDR PHY and wait till completed */
+	regval = readl(&emif4_base->sdram_iodft_tlgc);
+	regval |= (1<<10);
+	writel(regval, &emif4_base->sdram_iodft_tlgc);
+	/*Wait till that bit clears*/
+	while ((readl(&emif4_base->sdram_iodft_tlgc) & (1<<10)) == 0x1);
+	/*Re-verify the DDR PHY status*/
+	while ((readl(&emif4_base->sdram_sts) & (1<<2)) == 0x0);
+
+	regval |= (1<<0);
+	writel(regval, &emif4_base->sdram_iodft_tlgc);
+	/* Set SDR timing registers */
+	regval = (EMIF4_TIM1_T_WTR | EMIF4_TIM1_T_RRD |
+		EMIF4_TIM1_T_RC | EMIF4_TIM1_T_RAS |
+		EMIF4_TIM1_T_WR | EMIF4_TIM1_T_RCD |
+		EMIF4_TIM1_T_RP);
+	writel(regval, &emif4_base->sdram_time1);
+	writel(regval, &emif4_base->sdram_time1_shdw);
+
+	regval = (EMIF4_TIM2_T_CKE | EMIF4_TIM2_T_RTP |
+		EMIF4_TIM2_T_XSRD | EMIF4_TIM2_T_XSNR |
+		EMIF4_TIM2_T_ODT | EMIF4_TIM2_T_XP);
+	writel(regval, &emif4_base->sdram_time2);
+	writel(regval, &emif4_base->sdram_time2_shdw);
+
+	regval = (EMIF4_TIM3_T_RAS_MAX | EMIF4_TIM3_T_RFC);
+	writel(regval, &emif4_base->sdram_time3);
+	writel(regval, &emif4_base->sdram_time3_shdw);
+
+	/* Set the PWR control register */
+	regval = (EMIF4_PWR_PM_TIM | EMIF4_PWR_LP_MODE |
+		EMIF4_PWR_DPD_DIS | EMIF4_PWR_IDLE_MODE);
+	writel(regval, &emif4_base->sdram_pwr_mgmt);
+	writel(regval, &emif4_base->sdram_pwr_mgmt_shdw);
+
+	/* Set the DDR refresh rate control register */
+	regval = (EMIF4_REFRESH_RATE | EMIF4_INITREF_DIS);
+	writel(regval, &emif4_base->sdram_refresh_ctrl);
+	writel(regval, &emif4_base->sdram_refresh_ctrl_shdw);
+
+	/* set the SDRAM configuration register */
+	regval = (EMIF4_CFG_PGSIZE | EMIF4_CFG_EBANK |
+		EMIF4_CFG_IBANK | EMIF4_CFG_ROWSIZE |
+		EMIF4_CFG_CL | EMIF4_CFG_NARROW_MD |
+		EMIF4_CFG_SDR_DRV | EMIF4_CFG_DDR_DIS_DLL |
+		EMIF4_CFG_DDR2_DDQS | EMIF4_CFG_DDR_TERM |
+		EMIF4_CFG_IBANK_POS | EMIF4_CFG_SDRAM_TYP);
+	writel(regval, &emif4_base->sdram_config);
+}
+
+/*
+ * dram_init -
+ *  - Sets uboots idea of sdram size
+ */
+int dram_init(void)
+{
+	DECLARE_GLOBAL_DATA_PTR;
+	unsigned int size0 = 0, size1 = 0;
+
+	size0 = get_sdr_cs_size(CS0);
+	/*
+	 * If a second bank of DDR is attached to CS1 this is
+	 * where it can be started.  Early init code will init
+	 * memory on CS0.
+	 */
+	if ((sysinfo.mtype == DDR_COMBO) || (sysinfo.mtype == DDR_STACKED))
+		size1 = get_sdr_cs_size(CS1);
+
+	gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
+	gd->bd->bi_dram[0].size = size0;
+	gd->bd->bi_dram[1].start = PHYS_SDRAM_1 + get_sdr_cs_offset(CS1);
+	gd->bd->bi_dram[1].size = size1;
+
+	return 0;
+}
+
+/*
+ * mem_init() -
+ *  - Initialize memory subsystem
+ */
+void mem_init(void)
+{
+	do_emif4_init();
+}
diff --git a/arch/arm/include/asm/arch-omap3/cpu.h b/arch/arm/include/asm/arch-omap3/cpu.h
index a49af10..25668bd 100644
--- a/arch/arm/include/asm/arch-omap3/cpu.h
+++ b/arch/arm/include/asm/arch-omap3/cpu.h
@@ -217,6 +217,30 @@ struct sdrc {
 	struct sdrc_cs cs[2];	/* 0x80 || 0xB0 */
 };

+#elif defined(CONFIG_EMIF4)
+/* EMIF4 */
+typedef struct emif4 {
+	unsigned int sdram_sts;
+	unsigned int sdram_config;
+	unsigned int res1;
+	unsigned int sdram_refresh_ctrl;
+	unsigned int sdram_refresh_ctrl_shdw;
+	unsigned int sdram_time1;
+	unsigned int sdram_time1_shdw;
+	unsigned int sdram_time2;
+	unsigned int sdram_time2_shdw;
+	unsigned int sdram_time3;
+	unsigned int sdram_time3_shdw;
+	unsigned char res2[8];
+	unsigned int sdram_pwr_mgmt;
+	unsigned int sdram_pwr_mgmt_shdw;
+	unsigned char res3[32];
+	unsigned int sdram_iodft_tlgc;
+	unsigned char res4[128];
+	unsigned int ddr_phyctrl1;
+	unsigned int ddr_phyctrl1_shdw;
+	unsigned int ddr_phyctrl2;
+} emif4_t;
 #endif	/* CONFIG_SDRC */
 #endif /* __ASSEMBLY__ */
 #endif /* __KERNEL_STRICT_NAMES */
diff --git a/arch/arm/include/asm/arch-omap3/emif4.h b/arch/arm/include/asm/arch-omap3/emif4.h
new file mode 100644
index 0000000..579da0c
--- /dev/null
+++ b/arch/arm/include/asm/arch-omap3/emif4.h
@@ -0,0 +1,79 @@
+/*
+ * Auther:
+ *       Vaibhav Hiremath <hvaibhav@ti.com>
+ *
+ * Copyright (C) 2010
+ * Texas Instruments Incorporated - http://www.ti.com/
+ *
+ * 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; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#ifndef _EMIF_H_
+#define _EMIF_H_
+
+/*
+ * Configuration values
+ */
+#define EMIF4_TIM1_T_RP		(0x3 << 25)
+#define EMIF4_TIM1_T_RCD	(0x3 << 21)
+#define EMIF4_TIM1_T_WR		(0x3 << 17)
+#define EMIF4_TIM1_T_RAS	(0x8 << 12)
+#define EMIF4_TIM1_T_RC		(0xA << 6)
+#define EMIF4_TIM1_T_RRD	(0x2 << 3)
+#define EMIF4_TIM1_T_WTR	(0x2)
+
+#define EMIF4_TIM2_T_XP		(0x2 << 28)
+#define EMIF4_TIM2_T_ODT	(0x0 << 25)
+#define EMIF4_TIM2_T_XSNR	(0x1C << 16)
+#define EMIF4_TIM2_T_XSRD	(0xC8 << 6)
+#define EMIF4_TIM2_T_RTP	(0x1 << 3)
+#define EMIF4_TIM2_T_CKE	(0x2)
+
+#define EMIF4_TIM3_T_RFC	(0x25 << 4)
+#define EMIF4_TIM3_T_RAS_MAX	(0x7)
+
+#define EMIF4_PWR_IDLE_MODE	(0x2 << 30)
+#define EMIF4_PWR_DPD_DIS	(0x0 << 10)
+#define EMIF4_PWR_DPD_EN	(0x1 << 10)
+#define EMIF4_PWR_LP_MODE	(0x0 << 8)
+#define EMIF4_PWR_PM_TIM	(0x0)
+
+#define EMIF4_INITREF_DIS	(0x0 << 31)
+#define EMIF4_REFRESH_RATE	(0x50F)
+
+#define EMIF4_CFG_SDRAM_TYP	(0x2 << 29)
+#define EMIF4_CFG_IBANK_POS	(0x0 << 27)
+#define EMIF4_CFG_DDR_TERM	(0x0 << 24)
+#define EMIF4_CFG_DDR2_DDQS	(0x1 << 23)
+#define EMIF4_CFG_DDR_DIS_DLL	(0x0 << 20)
+#define EMIF4_CFG_SDR_DRV	(0x0 << 18)
+#define EMIF4_CFG_NARROW_MD	(0x0 << 14)
+#define EMIF4_CFG_CL		(0x5 << 10)
+#define EMIF4_CFG_ROWSIZE	(0x0 << 7)
+#define EMIF4_CFG_IBANK		(0x3 << 4)
+#define EMIF4_CFG_EBANK		(0x0 << 3)
+#define EMIF4_CFG_PGSIZE	(0x2)
+
+/*
+ * EMIF4 PHY Control 1 register configuration
+ */
+#define EMIF4_DDR1_EXT_STRB_EN	(0x1 << 7)
+#define EMIF4_DDR1_EXT_STRB_DIS	(0x0 << 7)
+#define EMIF4_DDR1_PWRDN_DIS	(0x0 << 6)
+#define EMIF4_DDR1_PWRDN_EN	(0x1 << 6)
+#define EMIF4_DDR1_READ_LAT	(0x6 << 0)
+
+#endif /* endif _EMIF_H_ */
diff --git a/arch/arm/include/asm/arch-omap3/sys_proto.h b/arch/arm/include/asm/arch-omap3/sys_proto.h
index 34e4e0d..7b425be 100644
--- a/arch/arm/include/asm/arch-omap3/sys_proto.h
+++ b/arch/arm/include/asm/arch-omap3/sys_proto.h
@@ -35,6 +35,9 @@ void memif_init(void);
 void sdrc_init(void);
 void do_sdrc_init(u32, u32);
 #endif
+#if defined(CONFIG_EMIF4)
+void emif4_init(void);
+#endif
 void gpmc_init(void);
 void enable_gpmc_cs_config(const u32 *gpmc_config, struct gpmc_cs *cs, u32 base,
 			u32 size);
--
1.6.2.4

^ permalink raw reply related	[flat|nested] 263+ messages in thread

* [U-Boot] [RESEND:PATCH-V4] OMAP3EVM: Added NAND support
  2010-04-23 14:55 ` [U-Boot] [RESEND:PATCH-V4] OMAP3EVM: Added NAND support hvaibhav at ti.com
@ 2010-05-05 20:01   ` Wolfgang Denk
  2010-05-06  5:36     ` Hiremath, Vaibhav
  0 siblings, 1 reply; 263+ messages in thread
From: Wolfgang Denk @ 2010-05-05 20:01 UTC (permalink / raw)
  To: u-boot

Dear hvaibhav at ti.com,

In message <1272034546-26041-2-git-send-email-hvaibhav@ti.com> you wrote:
>
> diff --git a/include/configs/omap3_evm.h b/include/configs/omap3_evm.h
> index 0d99f7d..1d31731 100644
> --- a/include/configs/omap3_evm.h
> +++ b/include/configs/omap3_evm.h
> @@ -151,7 +151,8 @@
> 
>  #define CONFIG_CMD_I2C		/* I2C serial bus support	*/
>  #define CONFIG_CMD_MMC		/* MMC support			*/
> -#define CONFIG_CMD_ONENAND	/* ONENAND support		*/
> +#undef CONFIG_CMD_ONENAND	/* ONENAND support		*/

Please do not #undef what is not #define'd anyway.


Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
What is tolerance? -- it is the consequence of humanity. We  are  all
formed  of frailty and error; let us pardon reciprocally each other's
folly -- that is the first law of nature.                  - Voltaire

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [U-Boot] [PATCH-V2 2/4] omap3: Consolidate SDRC related operations
  2010-04-23 14:55 ` [U-Boot] [PATCH-V2 2/4] omap3: Consolidate SDRC related operations hvaibhav at ti.com
@ 2010-05-05 20:07   ` Wolfgang Denk
  2010-05-06  6:49     ` Hiremath, Vaibhav
  0 siblings, 1 reply; 263+ messages in thread
From: Wolfgang Denk @ 2010-05-05 20:07 UTC (permalink / raw)
  To: u-boot

Dear hvaibhav at ti.com,

In message <1272034546-26041-4-git-send-email-hvaibhav@ti.com> you wrote:
> From: Vaibhav Hiremath <hvaibhav@ti.com>
> 
> Consolidated SDRC related functions into one file - sdrc.c
> 
> And also replaced sdrc_init with generic memory init
> function (mem_init), this generalization of omap memory setup
> is necessary to support the new emif4 interface introduced in AM3517.
> 
> Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
> Signed-off-by: Sanjeev Premi <premi@ti.com>

> diff --git a/arch/arm/cpu/arm_cortexa8/omap3/Makefile b/arch/arm/cpu/arm_cortexa8/omap3/Makefile
> index 136b163..8cc7802 100644
> --- a/arch/arm/cpu/arm_cortexa8/omap3/Makefile
> +++ b/arch/arm/cpu/arm_cortexa8/omap3/Makefile
> @@ -33,6 +33,9 @@ COBJS	+= board.o
>  COBJS	+= clock.o
>  COBJS	+= gpio.o
>  COBJS	+= mem.o
> +ifdef	CONFIG_SDRC
> +COBJS	+= sdrc.o
> +endif

Please don't use 'ifdef" here; instead, use `COBJS-$(CONFIG_SDRC)' 

> diff --git a/arch/arm/include/asm/arch-omap3/cpu.h b/arch/arm/include/asm/arch-omap3/cpu.h
> index aa8de32..a49af10 100644
> --- a/arch/arm/include/asm/arch-omap3/cpu.h
> +++ b/arch/arm/include/asm/arch-omap3/cpu.h
> @@ -183,6 +183,7 @@ struct sms {
>  /* SDRC */
>  #ifndef __KERNEL_STRICT_NAMES
>  #ifndef __ASSEMBLY__
> +#if defined(CONFIG_SDRC)
>  struct sdrc_cs {
>  	u32 mcfg;		/* 0x80 || 0xB0 */
>  	u32 mr;			/* 0x84 || 0xB4 */
> @@ -215,6 +216,8 @@ struct sdrc {
>  	u8 res4[0xC];
>  	struct sdrc_cs cs[2];	/* 0x80 || 0xB0 */
>  };
> +
> +#endif	/* CONFIG_SDRC */

I don't like such a #ifdef here - it is absolutely necessary? Why?

> diff --git a/arch/arm/include/asm/arch-omap3/sys_proto.h b/arch/arm/include/asm/arch-omap3/sys_proto.h
> index 34bd515..34e4e0d 100644
> --- a/arch/arm/include/asm/arch-omap3/sys_proto.h
> +++ b/arch/arm/include/asm/arch-omap3/sys_proto.h
> @@ -31,8 +31,10 @@ void prcm_init(void);
>  void per_clocks_enable(void);
> 
>  void memif_init(void);
> +#if defined(CONFIG_SDRC)
>  void sdrc_init(void);
>  void do_sdrc_init(u32, u32);
> +#endif

Ditto - please drop this #ifdef.


Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
People seldom know what they want until you give them what  they  ask
for.

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [U-Boot] [PATCH-V2 3/4] AM35x: Add support for AM3517EVM
  2010-04-23 14:55 ` [U-Boot] [PATCH-V2 3/4] AM35x: Add support for AM3517EVM hvaibhav at ti.com
@ 2010-05-05 20:12   ` Wolfgang Denk
  2010-05-06  6:52     ` Hiremath, Vaibhav
  0 siblings, 1 reply; 263+ messages in thread
From: Wolfgang Denk @ 2010-05-05 20:12 UTC (permalink / raw)
  To: u-boot

Dear hvaibhav at ti.com,

In message <1272034546-26041-5-git-send-email-hvaibhav@ti.com> you wrote:
> From: Vaibhav Hiremath <hvaibhav@ti.com>
> 
> This patch adds basic support for the AM3517EVM.
> It includes:
> 	- Board int file (.c and .h)
> 	- Default configuration file
> 	- Updates for Makefile
> 
> Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
> Signed-off-by: Sanjeev Premi <premi@ti.com>
> ---
>  Makefile                              |    3 +
>  arch/arm/include/asm/arch-omap3/mux.h |   36 +++
>  board/logicpd/am3517evm/Makefile      |   47 ++++
>  board/logicpd/am3517evm/am3517evm.c   |   76 ++++++
>  board/logicpd/am3517evm/am3517evm.h   |  405 +++++++++++++++++++++++++++++++++
>  board/logicpd/am3517evm/config.mk     |   30 +++
>  include/configs/am3517_evm.h          |  297 ++++++++++++++++++++++++
>  7 files changed, 894 insertions(+), 0 deletions(-)
>  create mode 100644 board/logicpd/am3517evm/Makefile
>  create mode 100644 board/logicpd/am3517evm/am3517evm.c
>  create mode 100644 board/logicpd/am3517evm/am3517evm.h
>  create mode 100644 board/logicpd/am3517evm/config.mk
>  create mode 100644 include/configs/am3517_evm.h

Entries to MAKEALL and MAINTAINERS missing.

> diff --git a/Makefile b/Makefile
> index 34f10ce..487ae73 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -3169,6 +3169,9 @@ omap3_zoom1_config :	unconfig
>  omap3_zoom2_config :	unconfig
>  	@$(MKCONFIG) $(@:_config=) arm arm_cortexa8 zoom2 logicpd omap3
> 
> +am3517_evm_config :	unconfig
> +	@$(MKCONFIG) $(@:_config=) arm arm_cortexa8 am3517evm logicpd omap3
> +
>  smdkc100_config:	unconfig
>  	@$(MKCONFIG) $(@:_config=) arm arm_cortexa8 smdkc100 samsung s5pc1xx

Please keep list sorted.

> diff --git a/arch/arm/include/asm/arch-omap3/mux.h b/arch/arm/include/asm/arch-omap3/mux.h
> index 0c01c73..8ea47b6 100644
> --- a/arch/arm/include/asm/arch-omap3/mux.h
> +++ b/arch/arm/include/asm/arch-omap3/mux.h
> @@ -283,6 +283,7 @@
>  /*Control and debug */
>  #define CONTROL_PADCONF_SYS_32K		0x0A04
>  #define CONTROL_PADCONF_SYS_CLKREQ	0x0A06
> +#define CONTROL_PADCONF_SYS_NRESWARM	0x0A08
>  #define CONTROL_PADCONF_SYS_NIRQ	0x01E0
>  #define CONTROL_PADCONF_SYS_BOOT0	0x0A0A
>  #define CONTROL_PADCONF_SYS_BOOT1	0x0A0C

CONTROL_PADCONF_SYS_NIRQ looks out of place here. And all this asks
to be converted into a proper C struct.

> diff --git a/board/logicpd/am3517evm/Makefile b/board/logicpd/am3517evm/Makefile
> new file mode 100644
> index 0000000..3c71fef
> --- /dev/null
> +++ b/board/logicpd/am3517evm/Makefile
...
> +include $(SRCTREE)/rules.mk
> +
> +sinclude $(obj).depend
> +

Don't add trailing empty lines. [Please check & fix globally.]


Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Any sufficiently advanced technology is indistinguishable from magic.
Clarke's Third Law       - _Profiles of the Future_ (1962; rev. 1973)
                  ``Hazards of Prophecy: The Failure of Imagination''

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [U-Boot] [PATCH-V2 4/4] AM35x: Add support for EMIF4
  2010-04-23 14:55 ` [U-Boot] [PATCH-V2 4/4] AM35x: Add support for EMIF4 hvaibhav at ti.com
@ 2010-05-05 20:14   ` Wolfgang Denk
  2010-05-06  6:56     ` Hiremath, Vaibhav
  0 siblings, 1 reply; 263+ messages in thread
From: Wolfgang Denk @ 2010-05-05 20:14 UTC (permalink / raw)
  To: u-boot

Dear hvaibhav at ti.com,

In message <1272034546-26041-6-git-send-email-hvaibhav@ti.com> you wrote:
> From: Vaibhav Hiremath <hvaibhav@ti.com>
> 
> This patch adds support for the EMIF4 interface
> available in the AM35x processors.
> 
> Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
> Signed-off-by: Sanjeev Premi <premi@ti.com>
> ---
>  arch/arm/cpu/arm_cortexa8/omap3/Makefile    |    3 +
>  arch/arm/cpu/arm_cortexa8/omap3/emif4.c     |  168 +++++++++++++++++++++++++++
>  arch/arm/include/asm/arch-omap3/cpu.h       |   24 ++++
>  arch/arm/include/asm/arch-omap3/emif4.h     |   79 +++++++++++++
>  arch/arm/include/asm/arch-omap3/sys_proto.h |    3 +
>  5 files changed, 277 insertions(+), 0 deletions(-)
>  create mode 100644 arch/arm/cpu/arm_cortexa8/omap3/emif4.c
>  create mode 100644 arch/arm/include/asm/arch-omap3/emif4.h
> 
> diff --git a/arch/arm/cpu/arm_cortexa8/omap3/Makefile b/arch/arm/cpu/arm_cortexa8/omap3/Makefile
> index 8cc7802..0a23fa5 100644
> --- a/arch/arm/cpu/arm_cortexa8/omap3/Makefile
> +++ b/arch/arm/cpu/arm_cortexa8/omap3/Makefile
> @@ -36,6 +36,9 @@ COBJS	+= mem.o
>  ifdef	CONFIG_SDRC
>  COBJS	+= sdrc.o
>  endif
> +ifdef	CONFIG_EMIF4
> +COBJS	+= emif4.o
> +endif

Don't use ifdef, use COBJS-$(CONFIG_EMIF4) instead.

> diff --git a/arch/arm/include/asm/arch-omap3/sys_proto.h b/arch/arm/include/asm/arch-omap3/sys_proto.h
> index 34e4e0d..7b425be 100644
> --- a/arch/arm/include/asm/arch-omap3/sys_proto.h
> +++ b/arch/arm/include/asm/arch-omap3/sys_proto.h
> @@ -35,6 +35,9 @@ void memif_init(void);
>  void sdrc_init(void);
>  void do_sdrc_init(u32, u32);
>  #endif
> +#if defined(CONFIG_EMIF4)
> +void emif4_init(void);
> +#endif

I guess you can omit the #ifdef here, right?

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
A failure will not appear until a unit has passed final inspection.

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [U-Boot] [RESEND:PATCH-V4] OMAP3EVM: Added NAND support
  2010-05-05 20:01   ` Wolfgang Denk
@ 2010-05-06  5:36     ` Hiremath, Vaibhav
  2010-05-06 10:40       ` Nishanth Menon
  2010-05-06 10:59       ` Wolfgang Denk
  0 siblings, 2 replies; 263+ messages in thread
From: Hiremath, Vaibhav @ 2010-05-06  5:36 UTC (permalink / raw)
  To: u-boot


> -----Original Message-----
> From: Wolfgang Denk [mailto:wd at denx.de]
> Sent: Thursday, May 06, 2010 1:31 AM
> To: Hiremath, Vaibhav
> Cc: u-boot at lists.denx.de
> Subject: Re: [U-Boot] [RESEND:PATCH-V4] OMAP3EVM: Added NAND support
> 
> Dear hvaibhav at ti.com,
> 
> In message <1272034546-26041-2-git-send-email-hvaibhav@ti.com> you wrote:
> >
> > diff --git a/include/configs/omap3_evm.h b/include/configs/omap3_evm.h
> > index 0d99f7d..1d31731 100644
> > --- a/include/configs/omap3_evm.h
> > +++ b/include/configs/omap3_evm.h
> > @@ -151,7 +151,8 @@
> >
> >  #define CONFIG_CMD_I2C		/* I2C serial bus support	*/
> >  #define CONFIG_CMD_MMC		/* MMC support			*/
> > -#define CONFIG_CMD_ONENAND	/* ONENAND support		*/
> > +#undef CONFIG_CMD_ONENAND	/* ONENAND support		*/
> 
> Please do not #undef what is not #define'd anyway.
> 
[Hiremath, Vaibhav] This was the initial comment received from Nishanth Menon on very first path, and that's where I added undef line.

The initial patch was something -

> -#define CONFIG_CMD_ONENAND     /* ONENAND support              */
> +/*#define CONFIG_CMD_ONENAND*/ /* ONENAND support              */
> +#define CONFIG_CMD_NAND        /* NAND support                 */

I do agree that we don't have to undef here, but agreed to Nishant's comment only because from user point of view, if user would like to enable ONENAND support then for him it's easy he just have to comment NAND line and make change this #define. He doesn't have to dig inside code to find out whether ONENAND is supported or not.


Thanks,
Vaibhav

> 
> Best regards,
> 
> Wolfgang Denk
> 
> --
> DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
> Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
> What is tolerance? -- it is the consequence of humanity. We  are  all
> formed  of frailty and error; let us pardon reciprocally each other's
> folly -- that is the first law of nature.                  - Voltaire

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [U-Boot] [PATCH-V2 2/4] omap3: Consolidate SDRC related operations
  2010-05-05 20:07   ` Wolfgang Denk
@ 2010-05-06  6:49     ` Hiremath, Vaibhav
  2010-05-06 10:55       ` Wolfgang Denk
  0 siblings, 1 reply; 263+ messages in thread
From: Hiremath, Vaibhav @ 2010-05-06  6:49 UTC (permalink / raw)
  To: u-boot


> -----Original Message-----
> From: Wolfgang Denk [mailto:wd at denx.de]
> Sent: Thursday, May 06, 2010 1:38 AM
> To: Hiremath, Vaibhav
> Cc: u-boot at lists.denx.de
> Subject: Re: [U-Boot] [PATCH-V2 2/4] omap3: Consolidate SDRC related
> operations
> 
> Dear hvaibhav at ti.com,
> 
[Hiremath, Vaibhav] Thanks Denk for your comments, see my response below -

> In message <1272034546-26041-4-git-send-email-hvaibhav@ti.com> you wrote:
> > From: Vaibhav Hiremath <hvaibhav@ti.com>
> >
> > Consolidated SDRC related functions into one file - sdrc.c
> >
> > And also replaced sdrc_init with generic memory init
> > function (mem_init), this generalization of omap memory setup
> > is necessary to support the new emif4 interface introduced in AM3517.
> >
> > Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
> > Signed-off-by: Sanjeev Premi <premi@ti.com>
> 
> > diff --git a/arch/arm/cpu/arm_cortexa8/omap3/Makefile
> b/arch/arm/cpu/arm_cortexa8/omap3/Makefile
> > index 136b163..8cc7802 100644
> > --- a/arch/arm/cpu/arm_cortexa8/omap3/Makefile
> > +++ b/arch/arm/cpu/arm_cortexa8/omap3/Makefile
> > @@ -33,6 +33,9 @@ COBJS	+= board.o
> >  COBJS	+= clock.o
> >  COBJS	+= gpio.o
> >  COBJS	+= mem.o
> > +ifdef	CONFIG_SDRC
> > +COBJS	+= sdrc.o
> > +endif
> 
> Please don't use 'ifdef" here; instead, use `COBJS-$(CONFIG_SDRC)'
[Hiremath, Vaibhav] ok, will incorporate in next version.


> 
> > diff --git a/arch/arm/include/asm/arch-omap3/cpu.h
> b/arch/arm/include/asm/arch-omap3/cpu.h
> > index aa8de32..a49af10 100644
> > --- a/arch/arm/include/asm/arch-omap3/cpu.h
> > +++ b/arch/arm/include/asm/arch-omap3/cpu.h
> > @@ -183,6 +183,7 @@ struct sms {
> >  /* SDRC */
> >  #ifndef __KERNEL_STRICT_NAMES
> >  #ifndef __ASSEMBLY__
> > +#if defined(CONFIG_SDRC)
> >  struct sdrc_cs {
> >  	u32 mcfg;		/* 0x80 || 0xB0 */
> >  	u32 mr;			/* 0x84 || 0xB4 */
> > @@ -215,6 +216,8 @@ struct sdrc {
> >  	u8 res4[0xC];
> >  	struct sdrc_cs cs[2];	/* 0x80 || 0xB0 */
> >  };
> > +
> > +#endif	/* CONFIG_SDRC */
> 
> I don't like such a #ifdef here - it is absolutely necessary? Why?
> 
[Hiremath, Vaibhav] Denk,

This is common file being used for all OMAP series of devices (OMAP2, OMAP3 and AM35x family) and OMAP2/3 family supports SDRC controller and AM35x family support EMIF4.

And due to this difference we need to add this #ifdef.

> > diff --git a/arch/arm/include/asm/arch-omap3/sys_proto.h
> b/arch/arm/include/asm/arch-omap3/sys_proto.h
> > index 34bd515..34e4e0d 100644
> > --- a/arch/arm/include/asm/arch-omap3/sys_proto.h
> > +++ b/arch/arm/include/asm/arch-omap3/sys_proto.h
> > @@ -31,8 +31,10 @@ void prcm_init(void);
> >  void per_clocks_enable(void);
> >
> >  void memif_init(void);
> > +#if defined(CONFIG_SDRC)
> >  void sdrc_init(void);
> >  void do_sdrc_init(u32, u32);
> > +#endif
> 
> Ditto - please drop this #ifdef.
> 
[Hiremath, Vaibhav] Same as above.

Thanks,
Vaibhav

> 
> Best regards,
> 
> Wolfgang Denk
> 
> --
> DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
> Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
> People seldom know what they want until you give them what  they  ask
> for.

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [U-Boot] [PATCH-V2 3/4] AM35x: Add support for AM3517EVM
  2010-05-05 20:12   ` Wolfgang Denk
@ 2010-05-06  6:52     ` Hiremath, Vaibhav
  2010-05-06 10:52       ` Wolfgang Denk
  0 siblings, 1 reply; 263+ messages in thread
From: Hiremath, Vaibhav @ 2010-05-06  6:52 UTC (permalink / raw)
  To: u-boot


> -----Original Message-----
> From: Wolfgang Denk [mailto:wd at denx.de]
> Sent: Thursday, May 06, 2010 1:42 AM
> To: Hiremath, Vaibhav
> Cc: u-boot at lists.denx.de
> Subject: Re: [U-Boot] [PATCH-V2 3/4] AM35x: Add support for AM3517EVM
> 
> Dear hvaibhav at ti.com,
> 
> In message <1272034546-26041-5-git-send-email-hvaibhav@ti.com> you wrote:
> > From: Vaibhav Hiremath <hvaibhav@ti.com>
> >
> > This patch adds basic support for the AM3517EVM.
> > It includes:
> > 	- Board int file (.c and .h)
> > 	- Default configuration file
> > 	- Updates for Makefile
> >
> > Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
> > Signed-off-by: Sanjeev Premi <premi@ti.com>
> > ---
> >  Makefile                              |    3 +
> >  arch/arm/include/asm/arch-omap3/mux.h |   36 +++
> >  board/logicpd/am3517evm/Makefile      |   47 ++++
> >  board/logicpd/am3517evm/am3517evm.c   |   76 ++++++
> >  board/logicpd/am3517evm/am3517evm.h   |  405
> +++++++++++++++++++++++++++++++++
> >  board/logicpd/am3517evm/config.mk     |   30 +++
> >  include/configs/am3517_evm.h          |  297 ++++++++++++++++++++++++
> >  7 files changed, 894 insertions(+), 0 deletions(-)
> >  create mode 100644 board/logicpd/am3517evm/Makefile
> >  create mode 100644 board/logicpd/am3517evm/am3517evm.c
> >  create mode 100644 board/logicpd/am3517evm/am3517evm.h
> >  create mode 100644 board/logicpd/am3517evm/config.mk
> >  create mode 100644 include/configs/am3517_evm.h
> 
> Entries to MAKEALL and MAINTAINERS missing.
[Hiremath, Vaibhav] Ok, will add this in next version.

> 
> > diff --git a/Makefile b/Makefile
> > index 34f10ce..487ae73 100644
> > --- a/Makefile
> > +++ b/Makefile
> > @@ -3169,6 +3169,9 @@ omap3_zoom1_config :	unconfig
> >  omap3_zoom2_config :	unconfig
> >  	@$(MKCONFIG) $(@:_config=) arm arm_cortexa8 zoom2 logicpd omap3
> >
> > +am3517_evm_config :	unconfig
> > +	@$(MKCONFIG) $(@:_config=) arm arm_cortexa8 am3517evm logicpd omap3
> > +
> >  smdkc100_config:	unconfig
> >  	@$(MKCONFIG) $(@:_config=) arm arm_cortexa8 smdkc100 samsung s5pc1xx
> 
> Please keep list sorted.
> 
[Hiremath, Vaibhav] ok, will move up.

> > diff --git a/arch/arm/include/asm/arch-omap3/mux.h
> b/arch/arm/include/asm/arch-omap3/mux.h
> > index 0c01c73..8ea47b6 100644
> > --- a/arch/arm/include/asm/arch-omap3/mux.h
> > +++ b/arch/arm/include/asm/arch-omap3/mux.h
> > @@ -283,6 +283,7 @@
> >  /*Control and debug */
> >  #define CONTROL_PADCONF_SYS_32K		0x0A04
> >  #define CONTROL_PADCONF_SYS_CLKREQ	0x0A06
> > +#define CONTROL_PADCONF_SYS_NRESWARM	0x0A08
> >  #define CONTROL_PADCONF_SYS_NIRQ	0x01E0
> >  #define CONTROL_PADCONF_SYS_BOOT0	0x0A0A
> >  #define CONTROL_PADCONF_SYS_BOOT1	0x0A0C
> 
> CONTROL_PADCONF_SYS_NIRQ looks out of place here. 
[Hiremath, Vaibhav] ok I will place it appropriately.

> And all this asks
> to be converted into a proper C struct.
[Hiremath, Vaibhav] This is following up the existing way of configuration like all other OMAP devices. I do agree that we need to clean this up.

Can it be done in sub-sequent series of patches on top of this? Let AM3517EVm support goes in. What's your opinion on this?

> 
> > diff --git a/board/logicpd/am3517evm/Makefile
> b/board/logicpd/am3517evm/Makefile
> > new file mode 100644
> > index 0000000..3c71fef
> > --- /dev/null
> > +++ b/board/logicpd/am3517evm/Makefile
> ...
> > +include $(SRCTREE)/rules.mk
> > +
> > +sinclude $(obj).depend
> > +
> 
> Don't add trailing empty lines. [Please check & fix globally.]
> 
[Hiremath, Vaibhav] Ok, I will cross-check and will fix in next version.

Thanks,
Vaibhav

> 
> Best regards,
> 
> Wolfgang Denk
> 
> --
> DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
> Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
> Any sufficiently advanced technology is indistinguishable from magic.
> Clarke's Third Law       - _Profiles of the Future_ (1962; rev. 1973)
>                   ``Hazards of Prophecy: The Failure of Imagination''

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [U-Boot] [PATCH-V2 4/4] AM35x: Add support for EMIF4
  2010-05-05 20:14   ` Wolfgang Denk
@ 2010-05-06  6:56     ` Hiremath, Vaibhav
  2010-05-06 10:56       ` Wolfgang Denk
  0 siblings, 1 reply; 263+ messages in thread
From: Hiremath, Vaibhav @ 2010-05-06  6:56 UTC (permalink / raw)
  To: u-boot


> -----Original Message-----
> From: Wolfgang Denk [mailto:wd at denx.de]
> Sent: Thursday, May 06, 2010 1:44 AM
> To: Hiremath, Vaibhav
> Cc: u-boot at lists.denx.de
> Subject: Re: [U-Boot] [PATCH-V2 4/4] AM35x: Add support for EMIF4
> 
> Dear hvaibhav at ti.com,
> 
> In message <1272034546-26041-6-git-send-email-hvaibhav@ti.com> you wrote:
> > From: Vaibhav Hiremath <hvaibhav@ti.com>
> >
> > This patch adds support for the EMIF4 interface
> > available in the AM35x processors.
> >
> > Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
> > Signed-off-by: Sanjeev Premi <premi@ti.com>
> > ---
> >  arch/arm/cpu/arm_cortexa8/omap3/Makefile    |    3 +
> >  arch/arm/cpu/arm_cortexa8/omap3/emif4.c     |  168
> +++++++++++++++++++++++++++
> >  arch/arm/include/asm/arch-omap3/cpu.h       |   24 ++++
> >  arch/arm/include/asm/arch-omap3/emif4.h     |   79 +++++++++++++
> >  arch/arm/include/asm/arch-omap3/sys_proto.h |    3 +
> >  5 files changed, 277 insertions(+), 0 deletions(-)
> >  create mode 100644 arch/arm/cpu/arm_cortexa8/omap3/emif4.c
> >  create mode 100644 arch/arm/include/asm/arch-omap3/emif4.h
> >
> > diff --git a/arch/arm/cpu/arm_cortexa8/omap3/Makefile
> b/arch/arm/cpu/arm_cortexa8/omap3/Makefile
> > index 8cc7802..0a23fa5 100644
> > --- a/arch/arm/cpu/arm_cortexa8/omap3/Makefile
> > +++ b/arch/arm/cpu/arm_cortexa8/omap3/Makefile
> > @@ -36,6 +36,9 @@ COBJS	+= mem.o
> >  ifdef	CONFIG_SDRC
> >  COBJS	+= sdrc.o
> >  endif
> > +ifdef	CONFIG_EMIF4
> > +COBJS	+= emif4.o
> > +endif
> 
> Don't use ifdef, use COBJS-$(CONFIG_EMIF4) instead.
> 
> > diff --git a/arch/arm/include/asm/arch-omap3/sys_proto.h
> b/arch/arm/include/asm/arch-omap3/sys_proto.h
> > index 34e4e0d..7b425be 100644
> > --- a/arch/arm/include/asm/arch-omap3/sys_proto.h
> > +++ b/arch/arm/include/asm/arch-omap3/sys_proto.h
> > @@ -35,6 +35,9 @@ void memif_init(void);
> >  void sdrc_init(void);
> >  void do_sdrc_init(u32, u32);
> >  #endif
> > +#if defined(CONFIG_EMIF4)
> > +void emif4_init(void);
> > +#endif
> 
> I guess you can omit the #ifdef here, right?
> 
[Hiremath, Vaibhav] Denk,

We have OMAP families supporting both SDRC and EMIF4 (obviously mutually exclusive), so we need to add this #ifdef.

Thanks,
Vaibhav

> Best regards,
> 
> Wolfgang Denk
> 
> --
> DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
> Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
> A failure will not appear until a unit has passed final inspection.

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [U-Boot] [RESEND:PATCH-V4] OMAP3EVM: Added NAND support
  2010-05-06  5:36     ` Hiremath, Vaibhav
@ 2010-05-06 10:40       ` Nishanth Menon
  2010-05-06 10:50         ` Wolfgang Denk
  2010-05-06 10:59       ` Wolfgang Denk
  1 sibling, 1 reply; 263+ messages in thread
From: Nishanth Menon @ 2010-05-06 10:40 UTC (permalink / raw)
  To: u-boot

On Thu, May 6, 2010 at 12:36 AM, Hiremath, Vaibhav <hvaibhav@ti.com> wrote:
>
>> -----Original Message-----
>> From: Wolfgang Denk [mailto:wd at denx.de]
>> Sent: Thursday, May 06, 2010 1:31 AM
>> To: Hiremath, Vaibhav
>> Cc: u-boot at lists.denx.de
>> Subject: Re: [U-Boot] [RESEND:PATCH-V4] OMAP3EVM: Added NAND support
>>
>> Dear hvaibhav at ti.com,
>>
>> In message <1272034546-26041-2-git-send-email-hvaibhav@ti.com> you wrote:
>> >
>> > diff --git a/include/configs/omap3_evm.h b/include/configs/omap3_evm.h
>> > index 0d99f7d..1d31731 100644
>> > --- a/include/configs/omap3_evm.h
>> > +++ b/include/configs/omap3_evm.h
>> > @@ -151,7 +151,8 @@
>> >
>> > ?#define CONFIG_CMD_I2C ? ? ? ? ? ? /* I2C serial bus support ? ? ? */
>> > ?#define CONFIG_CMD_MMC ? ? ? ? ? ? /* MMC support ? ? ? ? ? ? ? ? ?*/
>> > -#define CONFIG_CMD_ONENAND /* ONENAND support ? ? ? ? ? ? ?*/
>> > +#undef CONFIG_CMD_ONENAND ?/* ONENAND support ? ? ? ? ? ? ?*/
>>
>> Please do not #undef what is not #define'd anyway.
>>
> [Hiremath, Vaibhav] This was the initial comment received from Nishanth Menon on very first path, and that's where I added
> undef line.
>
> The initial patch was something -
>
>> -#define CONFIG_CMD_ONENAND ? ? /* ONENAND support ? ? ? ? ? ? ?*/
>> +/*#define CONFIG_CMD_ONENAND*/ /* ONENAND support ? ? ? ? ? ? ?*/
>> +#define CONFIG_CMD_NAND ? ? ? ?/* NAND support ? ? ? ? ? ? ? ? */
>
> I do agree that we don't have to undef here, but agreed to Nishant's comment only because from user point of view, if user would
> like to enable ONENAND support then for him it's easy he just have to comment NAND line and make change this #define. He
> doesn't have to dig inside code to find out whether ONENAND is supported or not.
my 2cents as a background:
platforms such as SDP platforms have three flash devices - nand,
onenand and nor - these are development platforms and are meant to
bootup from any of these devices based on which ever dip switch is
set. having a #undef is more elegant than /* */ and easier to use from
a developer perspective.

Regards,
Nishanth Menon

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [U-Boot] [RESEND:PATCH-V4] OMAP3EVM: Added NAND support
  2010-05-06 10:40       ` Nishanth Menon
@ 2010-05-06 10:50         ` Wolfgang Denk
  2010-05-06 10:54           ` Nishanth Menon
  2010-05-06 11:04           ` Hiremath, Vaibhav
  0 siblings, 2 replies; 263+ messages in thread
From: Wolfgang Denk @ 2010-05-06 10:50 UTC (permalink / raw)
  To: u-boot

Dear Nishanth Menon,

In message <u2h782515bb1005060340o3b366389mfdb71c240cbc7f90@mail.gmail.com> you wrote:
> On Thu, May 6, 2010 at 12:36 AM, Hiremath, Vaibhav <hvaibhav@ti.com> wrote:
...
> > I do agree that we don't have to undef here, but agreed to Nishant's comment only because from user point of view, if user would
> > like to enable ONENAND support then for him it's easy he just have to comment NAND line and make change this #define. He
> > doesn't have to dig inside code to find out whether ONENAND is supported or not.

Well, of course the user _has_ to dig into the code and check if the
feature is supported, because there is no information what the
"#undef" or the comment means - it can mean anything:

- disabled here and left in so you can easily re-add it if you like
- disabled because known to be unsupported or broken
- disabled because untested
- ...

> platforms such as SDP platforms have three flash devices - nand,
> onenand and nor - these are development platforms and are meant to
> bootup from any of these devices based on which ever dip switch is
> set. having a #undef is more elegant than /* */ and easier to use from
> a developer perspective.

Please provide one working configuration, or several config options,
but don't try to add kind of configuration menues using "#define" /
"#undef" lists. These are useless and confusing at best.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Motto of the Electrical Engineer: Working computer hardware is a  lot
like an erect penis: it stays up as long as you don't fuck with it.

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [U-Boot] [PATCH-V2 3/4] AM35x: Add support for AM3517EVM
  2010-05-06  6:52     ` Hiremath, Vaibhav
@ 2010-05-06 10:52       ` Wolfgang Denk
  0 siblings, 0 replies; 263+ messages in thread
From: Wolfgang Denk @ 2010-05-06 10:52 UTC (permalink / raw)
  To: u-boot

Dear "Hiremath, Vaibhav",

In message <19F8576C6E063C45BE387C64729E7394044E351BE4@dbde02.ent.ti.com> you wrote:
> 
...
> > > --- a/arch/arm/include/asm/arch-omap3/mux.h
> > > +++ b/arch/arm/include/asm/arch-omap3/mux.h
...
> > And all this asks
> > to be converted into a proper C struct.
> [Hiremath, Vaibhav] This is following up the existing way of configuration
> like all other OMAP devices. I do agree that we need to clean this up.
> 
> Can it be done in sub-sequent series of patches on top of this? Let AM3517E
> Vm support goes in. What's your opinion on this?

Agreed.


Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
It would seem that evil retreats when forcibly confronted
	-- Yarnek of Excalbia, "The Savage Curtain", stardate 5906.5

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [U-Boot] [RESEND:PATCH-V4] OMAP3EVM: Added NAND support
  2010-05-06 10:50         ` Wolfgang Denk
@ 2010-05-06 10:54           ` Nishanth Menon
  2010-05-06 11:03             ` Wolfgang Denk
  2010-05-06 11:04           ` Hiremath, Vaibhav
  1 sibling, 1 reply; 263+ messages in thread
From: Nishanth Menon @ 2010-05-06 10:54 UTC (permalink / raw)
  To: u-boot

On Thu, May 6, 2010 at 5:50 AM, Wolfgang Denk <wd@denx.de> wrote:
> Dear Nishanth Menon,
>
> In message <u2h782515bb1005060340o3b366389mfdb71c240cbc7f90@mail.gmail.com> you wrote:
>> On Thu, May 6, 2010 at 12:36 AM, Hiremath, Vaibhav <hvaibhav@ti.com> wrote:
> ...
>> > I do agree that we don't have to undef here, but agreed to Nishant's comment only because from user point of view, if user would
>> > like to enable ONENAND support then for him it's easy he just have to comment NAND line and make change this #define. He
>> > doesn't have to dig inside code to find out whether ONENAND is supported or not.
>
> Well, of course the user _has_ to dig into the code and check if the
> feature is supported, because there is no information what the
> "#undef" or the comment means - it can mean anything:
>
> - disabled here and left in so you can easily re-add it if you like
> - disabled because known to be unsupported or broken
> - disabled because untested
> - ...
>
>> platforms such as SDP platforms have three flash devices - nand,
>> onenand and nor - these are development platforms and are meant to
>> bootup from any of these devices based on which ever dip switch is
>> set. having a #undef is more elegant than /* */ and easier to use from
>> a developer perspective.
>
> Please provide one working configuration, or several config options,
> but don't try to add kind of configuration menues using "#define" /
> "#undef" lists. These are useless and confusing at best.
>
your points are valid, two options as I see here:
a) build configurations - nand_boot, nor_boot etc..
b) IMHO, the better solution would be to allow the same u-boot to boot
from all devices (nand, nor, onenand, mmc) without needing a rebuild.
but the neccessity for that is to have environment variable which can
be moved around.. TI has an implementation based on an ancient u-boot
which actually does this, it will be interesting to know if there are
others who may be interested in a similar feature in mainline u-boot.

Regards,
Nishanth Menon

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [U-Boot] [PATCH-V2 2/4] omap3: Consolidate SDRC related operations
  2010-05-06  6:49     ` Hiremath, Vaibhav
@ 2010-05-06 10:55       ` Wolfgang Denk
  0 siblings, 0 replies; 263+ messages in thread
From: Wolfgang Denk @ 2010-05-06 10:55 UTC (permalink / raw)
  To: u-boot

Dear "Hiremath, Vaibhav",

In message <19F8576C6E063C45BE387C64729E7394044E351BE0@dbde02.ent.ti.com> you wrote:
> 
> > > diff --git a/arch/arm/include/asm/arch-omap3/cpu.h
> > b/arch/arm/include/asm/arch-omap3/cpu.h
> > > index aa8de32..a49af10 100644
> > > --- a/arch/arm/include/asm/arch-omap3/cpu.h
> > > +++ b/arch/arm/include/asm/arch-omap3/cpu.h
> > > @@ -183,6 +183,7 @@ struct sms {
> > >  /* SDRC */
> > >  #ifndef __KERNEL_STRICT_NAMES
> > >  #ifndef __ASSEMBLY__
> > > +#if defined(CONFIG_SDRC)
> > >  struct sdrc_cs {
> > >  	u32 mcfg;		/* 0x80 || 0xB0 */
> > >  	u32 mr;			/* 0x84 || 0xB4 */
> > > @@ -215,6 +216,8 @@ struct sdrc {
> > >  	u8 res4[0xC];
> > >  	struct sdrc_cs cs[2];	/* 0x80 || 0xB0 */
> > >  };
> > > +
> > > +#endif	/* CONFIG_SDRC */
> > 
> > I don't like such a #ifdef here - it is absolutely necessary? Why?
> > 
> [Hiremath, Vaibhav] Denk,
> 
> This is common file being used for all OMAP series of devices (OMAP2, OMAP3
>  and AM35x family) and OMAP2/3 family supports SDRC controller and AM35x fa
> mily support EMIF4.
> 
> And due to this difference we need to add this #ifdef.

No. If different CPU fmilies need different versions of this struct
then they should use separate header files for these.

> > > diff --git a/arch/arm/include/asm/arch-omap3/sys_proto.h
> > b/arch/arm/include/asm/arch-omap3/sys_proto.h
> > > index 34bd515..34e4e0d 100644
> > > --- a/arch/arm/include/asm/arch-omap3/sys_proto.h
> > > +++ b/arch/arm/include/asm/arch-omap3/sys_proto.h
> > > @@ -31,8 +31,10 @@ void prcm_init(void);
> > >  void per_clocks_enable(void);
> > >
> > >  void memif_init(void);
> > > +#if defined(CONFIG_SDRC)
> > >  void sdrc_init(void);
> > >  void do_sdrc_init(u32, u32);
> > > +#endif
> > 
> > Ditto - please drop this #ifdef.
> > 
> [Hiremath, Vaibhav] Same as above.

Even less so here. The prototypes should not do any harm - just remove
the #if/#endif

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"Ahead warp factor 1"                                  - Captain Kirk

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [U-Boot] [PATCH-V2 4/4] AM35x: Add support for EMIF4
  2010-05-06  6:56     ` Hiremath, Vaibhav
@ 2010-05-06 10:56       ` Wolfgang Denk
  0 siblings, 0 replies; 263+ messages in thread
From: Wolfgang Denk @ 2010-05-06 10:56 UTC (permalink / raw)
  To: u-boot

Dear "Hiremath, Vaibhav",

In message <19F8576C6E063C45BE387C64729E7394044E351BE7@dbde02.ent.ti.com> you wrote:
> 
> > >  void sdrc_init(void);
> > >  void do_sdrc_init(u32, u32);
> > >  #endif
> > > +#if defined(CONFIG_EMIF4)
> > > +void emif4_init(void);
> > > +#endif
> > 
> > I guess you can omit the #ifdef here, right?
> > 
> [Hiremath, Vaibhav] Denk,
> 
> We have OMAP families supporting both SDRC and EMIF4 (obviously mutually ex
> clusive), so we need to add this #ifdef.

What makes you think you need it? Did you try what happens when you
just remove the #if/#endif ?

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Given a choice between two theories, take the one which is funnier.

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [U-Boot] [RESEND:PATCH-V4] OMAP3EVM: Added NAND support
  2010-05-06  5:36     ` Hiremath, Vaibhav
  2010-05-06 10:40       ` Nishanth Menon
@ 2010-05-06 10:59       ` Wolfgang Denk
  1 sibling, 0 replies; 263+ messages in thread
From: Wolfgang Denk @ 2010-05-06 10:59 UTC (permalink / raw)
  To: u-boot

Dear "Hiremath, Vaibhav",

In message <19F8576C6E063C45BE387C64729E7394044E351B9F@dbde02.ent.ti.com> you wrote:
> 
> I do agree that we don't have to undef here, but agreed to Nishant's
> comment only because from user point of view, if user would like to
> enable ONENAND support then for him it's easy he just have to comment
> NAND line and make change this #define. He doesn't have to dig inside
> code to find out whether ONENAND is supported or not.

Hm... what makes you think we could assume that commented out code is
actually working and can be enabled as we like?  This is a highly
speculative assumption, and probably more often wrong than right.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Why can you only have two doors on a chicken coop? If it had four  it
would be a chicken sedan.

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [U-Boot] [RESEND:PATCH-V4] OMAP3EVM: Added NAND support
  2010-05-06 10:54           ` Nishanth Menon
@ 2010-05-06 11:03             ` Wolfgang Denk
  2010-05-06 11:11               ` Nishanth Menon
  0 siblings, 1 reply; 263+ messages in thread
From: Wolfgang Denk @ 2010-05-06 11:03 UTC (permalink / raw)
  To: u-boot

Dear Nishanth Menon,

In message <j2h782515bb1005060354tc4574d80wb4a1aa3a2b40bc89@mail.gmail.com> you wrote:
>
> your points are valid, two options as I see here:
> a) build configurations - nand_boot, nor_boot etc..
> b) IMHO, the better solution would be to allow the same u-boot to boot
> from all devices (nand, nor, onenand, mmc) without needing a rebuild.

b) is clearly the better and more user-friendly solution.

> but the neccessity for that is to have environment variable which can
> be moved around.. ...

Hm... really? Assuming that all the storage devices are always
present, you can decide to use one standard location for the
environment independent of where the U-Boot image gets loaded from
(that may actually be considered an advantage by some).

>               ... TI has an implementation based on an ancient u-boot
> which actually does this, it will be interesting to know if there are
> others who may be interested in a similar feature in mainline u-boot.

Sure - please post a patch (as RFC) so we can see what you have in
mind.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Always leave room to add an explanation if it doesn't work out.

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [U-Boot] [RESEND:PATCH-V4] OMAP3EVM: Added NAND support
  2010-05-06 10:50         ` Wolfgang Denk
  2010-05-06 10:54           ` Nishanth Menon
@ 2010-05-06 11:04           ` Hiremath, Vaibhav
  1 sibling, 0 replies; 263+ messages in thread
From: Hiremath, Vaibhav @ 2010-05-06 11:04 UTC (permalink / raw)
  To: u-boot


> -----Original Message-----
> From: Wolfgang Denk [mailto:wd at denx.de]
> Sent: Thursday, May 06, 2010 4:20 PM
> To: Nishanth Menon
> Cc: Hiremath, Vaibhav; u-boot at lists.denx.de
> Subject: Re: [U-Boot] [RESEND:PATCH-V4] OMAP3EVM: Added NAND support
> 
> Dear Nishanth Menon,
> 
> In message <u2h782515bb1005060340o3b366389mfdb71c240cbc7f90@mail.gmail.com>
> you wrote:
> > On Thu, May 6, 2010 at 12:36 AM, Hiremath, Vaibhav <hvaibhav@ti.com>
> wrote:
> ...
> > > I do agree that we don't have to undef here, but agreed to Nishant's
> comment only because from user point of view, if user would
> > > like to enable ONENAND support then for him it's easy he just have to
> comment NAND line and make change this #define. He
> > > doesn't have to dig inside code to find out whether ONENAND is supported
> or not.
> 
> Well, of course the user _has_ to dig into the code and check if the
> feature is supported, because there is no information what the
> "#undef" or the comment means - it can mean anything:
> 
> - disabled here and left in so you can easily re-add it if you like
> - disabled because known to be unsupported or broken
> - disabled because untested
> - ...
[Hiremath, Vaibhav] Ok. Agreed. I will remove undef line and submit the patch.

Thanks,
Vaibhav

> 
> > platforms such as SDP platforms have three flash devices - nand,
> > onenand and nor - these are development platforms and are meant to
> > bootup from any of these devices based on which ever dip switch is
> > set. having a #undef is more elegant than /* */ and easier to use from
> > a developer perspective.
> 
> Please provide one working configuration, or several config options,
> but don't try to add kind of configuration menues using "#define" /
> "#undef" lists. These are useless and confusing at best.
> 
> Best regards,
> 
> Wolfgang Denk
> 
> --
> DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
> Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
> Motto of the Electrical Engineer: Working computer hardware is a  lot
> like an erect penis: it stays up as long as you don't fuck with it.

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [U-Boot] [RESEND:PATCH-V4] OMAP3EVM: Added NAND support
  2010-05-06 11:03             ` Wolfgang Denk
@ 2010-05-06 11:11               ` Nishanth Menon
  2010-05-06 11:28                 ` Wolfgang Denk
  0 siblings, 1 reply; 263+ messages in thread
From: Nishanth Menon @ 2010-05-06 11:11 UTC (permalink / raw)
  To: u-boot

On Thu, May 6, 2010 at 6:03 AM, Wolfgang Denk <wd@denx.de> wrote:
> Dear Nishanth Menon,
>
> In message <j2h782515bb1005060354tc4574d80wb4a1aa3a2b40bc89@mail.gmail.com> you wrote:
>>
>> your points are valid, two options as I see here:
>> a) build configurations - nand_boot, nor_boot etc..
>> b) IMHO, the better solution would be to allow the same u-boot to boot
>> from all devices (nand, nor, onenand, mmc) without needing a rebuild.
>
> b) is clearly the better and more user-friendly solution.
>
>> but the neccessity for that is to have environment variable which can
>> be moved around.. ...
>
> Hm... really? Assuming that all the storage devices are always
> present, you can decide to use one standard location for the
> environment independent of where the U-Boot image gets loaded from
> (that may actually be considered an advantage by some).
it is like
http://dev.omapzoom.org/?p=bootloader/u-boot.git;a=blob;f=board/omap3430sdp/mem.c;h=a3dad962390b35501c83f8cde1dd2fd1f6d779d6;hb=HEAD#l107

Infact in some of the settings, one of the chips might even not be mapped :(..

yes, one option could have been to use a single flash for all env (in
fact some platforms like (if i recollect beagle booting off MMC uses
NAND for env) - but is not a nice idea if the usecase is to use that
entire flash for filesystem.. so the safe option in general has been
to expect the environment to stick to the memory u-boot booted off
from..

>
>> ? ? ? ? ? ? ? ... TI has an implementation based on an ancient u-boot
>> which actually does this, it will be interesting to know if there are
>> others who may be interested in a similar feature in mainline u-boot.
>
> Sure - please post a patch (as RFC) so we can see what you have in
> mind.
Yep.. waiting for my next free cycle ;) i would have pointed as an RFC
to the git repo history, unfortunately the transition from clearcase
to git was done as a single blob :(

Regards,
Nishanth Menon

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [U-Boot] [RESEND:PATCH-V4] OMAP3EVM: Added NAND support
  2010-05-06 11:11               ` Nishanth Menon
@ 2010-05-06 11:28                 ` Wolfgang Denk
  0 siblings, 0 replies; 263+ messages in thread
From: Wolfgang Denk @ 2010-05-06 11:28 UTC (permalink / raw)
  To: u-boot

Dear Nishanth Menon,

In message <o2q782515bb1005060411u9e53fd21idbfcf95cd5e1ea59@mail.gmail.com> you wrote:
>
> Yep.. waiting for my next free cycle ;) i would have pointed as an RFC
> to the git repo history, unfortunately the transition from clearcase
> to git was done as a single blob :(

Heh. This matches my experience - each and every contact with
ClearCase has always been a clear case of PITA :-(

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Honest error is to be pitied, not ridiculed.
                                       -- Philip Earl of Chesterfield

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [U-Boot] [PATCH-V5] OMAP3EVM: Added NAND support
@ 2010-05-06 17:19 ` hvaibhav at ti.com
  2010-05-11  4:59   ` Hiremath, Vaibhav
  0 siblings, 1 reply; 263+ messages in thread
From: hvaibhav at ti.com @ 2010-05-06 17:19 UTC (permalink / raw)
  To: u-boot

From: Vaibhav Hiremath <hvaibhav@ti.com>

The EVMS have been shipping with NAND (instead of OneNAND) as default.
So, this patch sets NAND as default.

To choose OneNAND, define CMD_ONENAND instead of CMD_NAND in the
config file omap3_evm.h,

Changes From V4 :-
	- Removed #undef ONENAND line (comment from Denk)
Changes from V3 :-
	- Refreshed against latest u-boot/master
Changes from V2 :-
	- Added undef statement for CMD_ONENAND.

Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
---
 include/configs/omap3_evm.h |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/include/configs/omap3_evm.h b/include/configs/omap3_evm.h
index 0d99f7d..88af492 100644
--- a/include/configs/omap3_evm.h
+++ b/include/configs/omap3_evm.h
@@ -151,7 +151,7 @@

 #define CONFIG_CMD_I2C		/* I2C serial bus support	*/
 #define CONFIG_CMD_MMC		/* MMC support			*/
-#define CONFIG_CMD_ONENAND	/* ONENAND support		*/
+#define CONFIG_CMD_NAND		/* NAND support			*/
 #define CONFIG_CMD_DHCP
 #define CONFIG_CMD_PING

@@ -306,7 +306,13 @@
 #define CONFIG_SYS_MONITOR_BASE		CONFIG_SYS_FLASH_BASE
 #define CONFIG_SYS_ONENAND_BASE		ONENAND_MAP

+#if defined(CONFIG_CMD_NAND)
+#define CONFIG_NAND_OMAP_GPMC
+#define GPMC_NAND_ECC_LP_x16_LAYOUT	1
+#define CONFIG_ENV_IS_IN_NAND
+#elif defined(CONFIG_CMD_ONENAND)
 #define CONFIG_ENV_IS_IN_ONENAND	1
+#endif
 #define ONENAND_ENV_OFFSET		0x260000 /* environment starts here */
 #define SMNAND_ENV_OFFSET		0x260000 /* environment starts here */

--
1.6.2.4

^ permalink raw reply related	[flat|nested] 263+ messages in thread

* [U-Boot] [PATCH-V3 1/2] AM35x: Add support for AM3517EVM
@ 2010-05-06 17:23 ` hvaibhav at ti.com
  2010-05-11  5:00   ` Hiremath, Vaibhav
  2010-05-31  9:40   ` Wolfgang Denk
  0 siblings, 2 replies; 263+ messages in thread
From: hvaibhav at ti.com @ 2010-05-06 17:23 UTC (permalink / raw)
  To: u-boot

From: Vaibhav Hiremath <hvaibhav@ti.com>

This patch adds basic support for the AM3517EVM.
It includes:
	- Board int file (.c and .h)
	- Default configuration file
	- Updates for Makefile

Changes from V2:
	- Removed trailing spaces
	- Updated MAINTAINERS & MAKEALL for am3517_evm

Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
Signed-off-by: Sanjeev Premi <premi@ti.com>
---
 MAINTAINERS                           |    4 +
 MAKEALL                               |    1 +
 Makefile                              |    3 +
 arch/arm/include/asm/arch-omap3/mux.h |   38 +++-
 board/logicpd/am3517evm/Makefile      |   46 ++++
 board/logicpd/am3517evm/am3517evm.c   |   76 ++++++
 board/logicpd/am3517evm/am3517evm.h   |  405 +++++++++++++++++++++++++++++++++
 board/logicpd/am3517evm/config.mk     |   30 +++
 include/configs/am3517_evm.h          |  296 ++++++++++++++++++++++++
 9 files changed, 898 insertions(+), 1 deletions(-)
 create mode 100644 board/logicpd/am3517evm/Makefile
 create mode 100644 board/logicpd/am3517evm/am3517evm.c
 create mode 100644 board/logicpd/am3517evm/am3517evm.h
 create mode 100644 board/logicpd/am3517evm/config.mk
 create mode 100644 include/configs/am3517_evm.h

diff --git a/MAINTAINERS b/MAINTAINERS
index 5cbc845..0bc65e1 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -798,6 +798,10 @@ Alex Z
 	lart		SA1100
 	dnp1110		SA1110

+Vaibhav Hiremath <hvaibhav@ti.com>
+
+	am3517_evm	ARM CORTEX-A8 (AM35x SoC)
+
 -------------------------------------------------------------------------

 Unknown / orphaned boards:
diff --git a/MAKEALL b/MAKEALL
index bb09627..cd59daa 100755
--- a/MAKEALL
+++ b/MAKEALL
@@ -641,6 +641,7 @@ LIST_ARM11="			\
 ## ARM Cortex-A8 Systems
 #########################################################################
 LIST_ARM_CORTEX_A8="		\
+	am3517_evm		\
 	devkit8000		\
 	mx51evk			\
 	omap3_beagle		\
diff --git a/Makefile b/Makefile
index 2d96574..57b3491 100644
--- a/Makefile
+++ b/Makefile
@@ -3155,6 +3155,9 @@ SMN42_config	:	unconfig
 ## ARM CORTEX Systems
 #########################################################################

+am3517_evm_config :	unconfig
+	@$(MKCONFIG) $(@:_config=) arm arm_cortexa8 am3517evm logicpd omap3
+
 devkit8000_config :	unconfig
 	@$(MKCONFIG) $(@:_config=) arm arm_cortexa8 devkit8000 timll omap3

diff --git a/arch/arm/include/asm/arch-omap3/mux.h b/arch/arm/include/asm/arch-omap3/mux.h
index 0c01c73..ffeb982 100644
--- a/arch/arm/include/asm/arch-omap3/mux.h
+++ b/arch/arm/include/asm/arch-omap3/mux.h
@@ -283,7 +283,7 @@
 /*Control and debug */
 #define CONTROL_PADCONF_SYS_32K		0x0A04
 #define CONTROL_PADCONF_SYS_CLKREQ	0x0A06
-#define CONTROL_PADCONF_SYS_NIRQ	0x01E0
+#define CONTROL_PADCONF_SYS_NRESWARM	0x0A08
 #define CONTROL_PADCONF_SYS_BOOT0	0x0A0A
 #define CONTROL_PADCONF_SYS_BOOT1	0x0A0C
 #define CONTROL_PADCONF_SYS_BOOT2	0x0A0E
@@ -337,6 +337,7 @@
 #define CONTROL_PADCONF_ETK_D14_ES2	0x05F8
 #define CONTROL_PADCONF_ETK_D15_ES2	0x05FA
 /*Die to Die */
+#define CONTROL_PADCONF_SYS_NIRQ	0x01E0
 #define CONTROL_PADCONF_D2D_MCAD0	0x01E4
 #define CONTROL_PADCONF_D2D_MCAD1	0x01E6
 #define CONTROL_PADCONF_D2D_MCAD2	0x01E8
@@ -403,6 +404,41 @@
 #define CONTROL_PADCONF_D2D_SBUSFLAG	0x0260
 #define CONTROL_PADCONF_SDRC_CKE0	0x0262
 #define CONTROL_PADCONF_SDRC_CKE1	0x0264
+/* AM3517 specific */
+#define CONTROL_PADCONF_CCDC_PCLK	0x01E4
+#define CONTROL_PADCONF_CCDC_FIELD	0x01E6
+#define CONTROL_PADCONF_CCDC_HD		0x01E8
+#define CONTROL_PADCONF_CCDC_VD		0x01EA
+#define CONTROL_PADCONF_CCDC_WEN	0x01EC
+#define CONTROL_PADCONF_CCDC_DATA0	0x01EE
+#define CONTROL_PADCONF_CCDC_DATA1	0x01F0
+#define CONTROL_PADCONF_CCDC_DATA2	0x01F2
+#define CONTROL_PADCONF_CCDC_DATA3	0x01F4
+#define CONTROL_PADCONF_CCDC_DATA4	0x01F6
+#define CONTROL_PADCONF_CCDC_DATA5	0x01F8
+#define CONTROL_PADCONF_CCDC_DATA6	0x01FA
+#define CONTROL_PADCONF_CCDC_DATA7	0x01FC
+#define CONTROL_PADCONF_RMII_MDIO_DATA	0x01FE
+#define CONTROL_PADCONF_RMII_MDIO_CLK	0x0200
+#define CONTROL_PADCONF_RMII_RXD0	0x0202
+#define CONTROL_PADCONF_RMII_RXD1	0x0204
+#define CONTROL_PADCONF_RMII_CRS_DV	0x0206
+#define CONTROL_PADCONF_RMII_RXER	0x0208
+#define CONTROL_PADCONF_RMII_TXD0	0x020A
+#define CONTROL_PADCONF_RMII_TXD1	0x020C
+#define CONTROL_PADCONF_RMII_TXEN	0x020E
+#define CONTROL_PADCONF_RMII_50MHZ_CLK	0x0210
+#define CONTROL_PADCONF_USB0_DRVBUS	0x0212
+#define CONTROL_PADCONF_HECC1_TXD	0x0214
+#define CONTROL_PADCONF_HECC1_RXD	0x0216
+#define CONTROL_PADCONF_SYS_BOOT7	0x0218
+#define CONTROL_PADCONF_SDRC_DQS0N	0x021A
+#define CONTROL_PADCONF_SDRC_DQS1N	0x021C
+#define CONTROL_PADCONF_SDRC_DQS2N	0x021E
+#define CONTROL_PADCONF_SDRC_DQS3N	0x0220
+#define CONTROL_PADCONF_STRBEN_DLY0	0x0222
+#define CONTROL_PADCONF_STRBEN_DLY1	0x0224
+#define CONTROL_PADCONF_SYS_BOOT8	0x0226

 #define MUX_VAL(OFFSET,VALUE)\
 	writew((VALUE), OMAP34XX_CTRL_BASE + (OFFSET));
diff --git a/board/logicpd/am3517evm/Makefile b/board/logicpd/am3517evm/Makefile
new file mode 100644
index 0000000..3a6b1a1
--- /dev/null
+++ b/board/logicpd/am3517evm/Makefile
@@ -0,0 +1,46 @@
+#
+# Author: Vaibhav Hiremath <hvaibhav@ti.com>
+#
+# Based on ti/evm/Makefile
+#
+# Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/
+#
+# 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; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+#
+
+include $(TOPDIR)/config.mk
+
+LIB	= $(obj)lib$(BOARD).a
+
+COBJS	:= am3517evm.o
+
+SRCS	:= $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
+	$(AR) $(ARFLAGS) $@ $(OBJS)
+
+clean:
+	rm -f $(OBJS)
+
+distclean:	clean
+	rm -f $(LIB) core *.bak $(obj).depend
+
+#########################################################################
+
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
+
+sinclude $(obj).depend
diff --git a/board/logicpd/am3517evm/am3517evm.c b/board/logicpd/am3517evm/am3517evm.c
new file mode 100644
index 0000000..2b912a9
--- /dev/null
+++ b/board/logicpd/am3517evm/am3517evm.c
@@ -0,0 +1,76 @@
+/*
+ * am3517evm.c - board file for TI's AM3517 family of devices.
+ *
+ * Author: Vaibhav Hiremath <hvaibhav@ti.com>
+ *
+ * Based on ti/evm/evm.c
+ *
+ * Copyright (C) 2010
+ * Texas Instruments Incorporated - http://www.ti.com/
+ *
+ * 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <common.h>
+#include <asm/io.h>
+#include <asm/arch/mem.h>
+#include <asm/arch/mux.h>
+#include <asm/arch/sys_proto.h>
+#include <asm/mach-types.h>
+#include <i2c.h>
+#include "am3517evm.h"
+
+/*
+ * Routine: board_init
+ * Description: Early hardware init.
+ */
+int board_init(void)
+{
+	DECLARE_GLOBAL_DATA_PTR;
+
+	gpmc_init(); /* in SRAM or SDRAM, finish GPMC */
+	/* board id for Linux */
+	gd->bd->bi_arch_number = MACH_TYPE_OMAP3517EVM;
+	/* boot param addr */
+	gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100);
+
+	return 0;
+}
+
+/*
+ * Routine: misc_init_r
+ * Description: Init i2c, ethernet, etc... (done here so udelay works)
+ */
+int misc_init_r(void)
+{
+#ifdef CONFIG_DRIVER_OMAP34XX_I2C
+	i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
+#endif
+
+	dieid_num_r();
+
+	return 0;
+}
+
+/*
+ * Routine: set_muxconf_regs
+ * Description: Setting up the configuration Mux registers specific to the
+ *		hardware. Many pins need to be moved from protect to primary
+ *		mode.
+ */
+void set_muxconf_regs(void)
+{
+	MUX_AM3517EVM();
+}
diff --git a/board/logicpd/am3517evm/am3517evm.h b/board/logicpd/am3517evm/am3517evm.h
new file mode 100644
index 0000000..68d746c
--- /dev/null
+++ b/board/logicpd/am3517evm/am3517evm.h
@@ -0,0 +1,405 @@
+/*
+ * am3517evm.h - Header file for the AM3517 EVM.
+ *
+ * Author: Vaibhav Hiremath <hvaibhav@ti.com>
+ *
+ * Based on ti/evm/evm.h
+ *
+ * Copyright (C) 2010
+ * Texas Instruments Incorporated - http://www.ti.com/
+ *
+ * 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#ifndef _AM3517EVM_H_
+#define _AM3517EVM_H_
+
+const omap3_sysinfo sysinfo = {
+	DDR_DISCRETE,
+	"AM3517EVM Board",
+	"NAND",
+};
+
+/*
+ * IEN  - Input Enable
+ * IDIS - Input Disable
+ * PTD  - Pull type Down
+ * PTU  - Pull type Up
+ * DIS  - Pull type selection is inactive
+ * EN   - Pull type selection is active
+ * M0   - Mode 0
+ * The commented string gives the final mux configuration for that pin
+ */
+#define MUX_AM3517EVM() \
+	/* SDRC */\
+	MUX_VAL(CP(SDRC_D0),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_D1),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_D2),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_D3),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_D4),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_D5),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_D6),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_D7),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_D8),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_D9),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_D10),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_D11),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_D12),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_D13),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_D14),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_D15),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_D16),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_D17),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_D18),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_D19),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_D20),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_D21),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_D22),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_D23),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_D24),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_D25),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_D26),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_D27),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_D28),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_D29),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_D30),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_D31),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_CLK),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_DQS0),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_DQS1),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_DQS2),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_DQS3),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_DQS0N),		(IEN  | PTD | EN  | M0)) \
+	MUX_VAL(CP(SDRC_DQS1N),		(IEN  | PTD | EN  | M0)) \
+	MUX_VAL(CP(SDRC_DQS2N),		(IEN  | PTD | EN  | M0)) \
+	MUX_VAL(CP(SDRC_DQS3N),		(IEN  | PTD | EN  | M0)) \
+	MUX_VAL(CP(SDRC_CKE0),		(M0)) \
+	MUX_VAL(CP(SDRC_CKE1),		(M0)) \
+	/*sdrc_strben_dly0*/\
+	MUX_VAL(CP(STRBEN_DLY0),	(IEN  | PTD | EN  | M0)) \
+	 /*sdrc_strben_dly1*/\
+	MUX_VAL(CP(STRBEN_DLY1),	(IEN  | PTD | EN  | M0)) \
+	/* GPMC */\
+	MUX_VAL(CP(GPMC_A1),		(IDIS | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_A2),		(IDIS | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_A3),		(IDIS | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_A4),		(IDIS | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_A5),		(IDIS | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_A6),		(IDIS | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_A7),		(IDIS | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_A8),		(IDIS | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_A9),		(IDIS | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_A10),		(IDIS | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_D0),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_D1),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_D2),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_D3),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_D4),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_D5),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_D6),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_D7),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_D8),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_D9),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_D10),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_D11),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_D12),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_D13),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_D14),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_D15),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_NCS0),		(IDIS | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_NCS1),		(IDIS | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_NCS2),		(IDIS | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_NCS3),		(IDIS | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_NCS4),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_NCS5),		(IDIS | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_NCS6),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(GPMC_NCS7),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_CLK),		(IDIS | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_NADV_ALE),	(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(GPMC_NOE),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(GPMC_NWE),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(GPMC_NBE0_CLE),	(IDIS | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_NBE1),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_NWP),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(GPMC_WAIT0),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_WAIT1),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_WAIT2),		(IEN  | PTU | EN  | M4)) /*GPIO_64*/\
+							 /* - ETH_nRESET*/\
+	MUX_VAL(CP(GPMC_WAIT3),		(IEN  | PTU | EN  | M0)) \
+	/* DSS */\
+	MUX_VAL(CP(DSS_PCLK),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(DSS_HSYNC),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(DSS_VSYNC),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(DSS_ACBIAS),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(DSS_DATA0),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(DSS_DATA1),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(DSS_DATA2),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(DSS_DATA3),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(DSS_DATA4),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(DSS_DATA5),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(DSS_DATA6),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(DSS_DATA7),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(DSS_DATA8),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(DSS_DATA9),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(DSS_DATA10),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(DSS_DATA11),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(DSS_DATA12),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(DSS_DATA13),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(DSS_DATA14),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(DSS_DATA15),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(DSS_DATA16),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(DSS_DATA17),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(DSS_DATA18),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(DSS_DATA19),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(DSS_DATA20),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(DSS_DATA21),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(DSS_DATA22),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(DSS_DATA23),		(IDIS | PTD | DIS | M0)) \
+	/* CAMERA */\
+	MUX_VAL(CP(CAM_HS),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(CAM_VS),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(CAM_XCLKA),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(CAM_PCLK),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(CAM_FLD),		(IDIS | PTD | DIS | M4)) /*GPIO_98*/\
+							 /* - CAM_RESET*/\
+	MUX_VAL(CP(CAM_D0),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(CAM_D1),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(CAM_D2),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(CAM_D3),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(CAM_D4),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(CAM_D5),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(CAM_D6),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(CAM_D7),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(CAM_D8),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(CAM_D9),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(CAM_D10),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(CAM_D11),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(CAM_XCLKB),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(CAM_WEN),		(IEN  | PTD | DIS | M4)) /*GPIO_167*/\
+	MUX_VAL(CP(CAM_STROBE),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(CSI2_DX0),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(CSI2_DY0),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(CSI2_DX1),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(CSI2_DY1),		(IEN  | PTD | DIS | M0)) \
+	/* MMC */\
+	MUX_VAL(CP(MMC1_CLK),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(MMC1_CMD),		(IEN  | PTU | DIS | M0)) \
+	MUX_VAL(CP(MMC1_DAT0),		(IEN  | PTU | DIS | M0)) \
+	MUX_VAL(CP(MMC1_DAT1),		(IEN  | PTU | DIS | M0)) \
+	MUX_VAL(CP(MMC1_DAT2),		(IEN  | PTU | DIS | M0)) \
+	MUX_VAL(CP(MMC1_DAT3),		(IEN  | PTU | DIS | M0)) \
+	/* WriteProtect */\
+	MUX_VAL(CP(MMC1_DAT4),		(IEN  | PTU | EN  | M4)) \
+	MUX_VAL(CP(MMC1_DAT5),		(IEN  | PTU | EN  | M4)) /*CardDetect*/\
+	MUX_VAL(CP(MMC1_DAT6),		(IEN  | PTU | EN  | M4)) \
+	MUX_VAL(CP(MMC1_DAT7),		(IEN  | PTU | EN  | M4)) \
+	\
+	MUX_VAL(CP(MMC2_CLK),		(IEN  | PTD | EN  | M0)) \
+	MUX_VAL(CP(MMC2_CMD),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(MMC2_DAT0),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(MMC2_DAT1),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(MMC2_DAT2),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(MMC2_DAT3),		(IEN  | PTD | DIS | M0)) \
+	/* McBSP */\
+	MUX_VAL(CP(MCBSP_CLKS),		(IEN  | PTU | DIS | M0)) \
+	MUX_VAL(CP(MCBSP1_CLKR),	(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(MCBSP1_FSR),		(IDIS | PTU | EN  | M0)) \
+	MUX_VAL(CP(MCBSP1_DX),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(MCBSP1_DR),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(MCBSP1_FSX),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(MCBSP1_CLKX),	(IEN  | PTD | DIS | M0)) \
+	\
+	MUX_VAL(CP(MCBSP2_FSX),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(MCBSP2_CLKX),	(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(MCBSP2_DR),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(MCBSP2_DX),		(IDIS | PTD | DIS | M0)) \
+	\
+	MUX_VAL(CP(MCBSP3_DX),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(MCBSP3_DR),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(MCBSP3_CLKX),	(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(MCBSP3_FSX),		(IEN  | PTD | DIS | M0)) \
+	\
+	MUX_VAL(CP(MCBSP4_CLKX),	(IDIS | PTD | DIS | M4)) /*GPIO_152*/\
+							 /* - LCD_INI*/\
+	MUX_VAL(CP(MCBSP4_DR),		(IDIS | PTD | DIS | M4)) /*GPIO_153*/\
+							 /* - LCD_ENVDD */\
+	MUX_VAL(CP(MCBSP4_DX),		(IDIS | PTD | DIS | M4)) /*GPIO_154*/\
+							 /* - LCD_QVGA/nVGA */\
+	MUX_VAL(CP(MCBSP4_FSX),		(IDIS | PTD | DIS | M4)) /*GPIO_155*/\
+							 /* - LCD_RESB */\
+	/* UART */\
+	MUX_VAL(CP(UART1_TX),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(UART1_RTS),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(UART1_CTS),		(IEN  | PTU | DIS | M0)) \
+	\
+	MUX_VAL(CP(UART1_RX),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(UART2_CTS),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(UART2_RTS),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(UART2_TX),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(UART2_RX),		(IEN  | PTD | DIS | M0)) \
+	\
+	MUX_VAL(CP(UART3_CTS_RCTX),	(IEN  | PTU | DIS | M0)) \
+	MUX_VAL(CP(UART3_RTS_SD),	(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(UART3_RX_IRRX),	(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(UART3_TX_IRTX),	(IDIS | PTD | DIS | M0)) \
+	/* I2C */\
+	MUX_VAL(CP(I2C1_SCL),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(I2C1_SDA),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(I2C2_SCL),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(I2C2_SDA),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(I2C3_SCL),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(I2C3_SDA),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(I2C4_SCL),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(I2C4_SDA),		(IEN  | PTU | EN  | M0)) \
+	/* McSPI */\
+	MUX_VAL(CP(MCSPI1_CLK),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(MCSPI1_SIMO),	(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(MCSPI1_SOMI),	(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(MCSPI1_CS0),		(IEN  | PTD | EN  | M0)) \
+	MUX_VAL(CP(MCSPI1_CS1),		(IEN  | PTD | EN  | M4)) /*GPIO_175*/\
+	MUX_VAL(CP(MCSPI1_CS2),		(IEN  | PTU | DIS | M4)) /*GPIO_176*/\
+							 /* - LAN_INTR*/\
+	MUX_VAL(CP(MCSPI1_CS3),		(IEN  | PTD | EN  | M0)) \
+	\
+	MUX_VAL(CP(MCSPI2_CLK),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(MCSPI2_SIMO),	(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(MCSPI2_SOMI),	(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(MCSPI2_CS0),		(IEN  | PTD | EN  | M4)) \
+	MUX_VAL(CP(MCSPI2_CS1),		(IEN  | PTD | EN  | M4)) \
+	/* CCDC */\
+	MUX_VAL(CP(CCDC_PCLK),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(CCDC_FIELD),		(IEN  | PTD | DIS | M1)) \
+	MUX_VAL(CP(CCDC_HD),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(CCDC_VD),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(CCDC_WEN),		(IEN  | PTD | DIS | M1)) \
+	MUX_VAL(CP(CCDC_DATA0),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(CCDC_DATA1),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(CCDC_DATA2),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(CCDC_DATA3),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(CCDC_DATA4),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(CCDC_DATA5),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(CCDC_DATA6),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(CCDC_DATA7),		(IEN  | PTD | DIS | M0)) \
+	/* RMII */\
+	MUX_VAL(CP(RMII_MDIO_DATA),	(IEN  |  M0)) \
+	MUX_VAL(CP(RMII_MDIO_CLK),	(M0)) \
+	MUX_VAL(CP(RMII_RXD0)	,	(IEN  | PTD | M0)) \
+	MUX_VAL(CP(RMII_RXD1),		(IEN  | PTD | M0)) \
+	MUX_VAL(CP(RMII_CRS_DV),	(IEN  | PTD | M0)) \
+	MUX_VAL(CP(RMII_RXER),		(PTD | M0)) \
+	MUX_VAL(CP(RMII_TXD0),		(PTD | M0)) \
+	MUX_VAL(CP(RMII_TXD1),		(PTD | M0)) \
+	MUX_VAL(CP(RMII_TXEN),		(PTD | M0)) \
+	MUX_VAL(CP(RMII_50MHZ_CLK),	(IEN  | PTD | EN  | M0)) \
+	/* HECC */\
+	MUX_VAL(CP(HECC1_TXD),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(HECC1_RXD),		(IEN  | PTU | EN  | M0)) \
+	/* HSUSB */\
+	MUX_VAL(CP(HSUSB0_CLK),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(HSUSB0_STP),		(IDIS | PTU | EN  | M0)) \
+	MUX_VAL(CP(HSUSB0_DIR),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(HSUSB0_NXT),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(HSUSB0_DATA0),	(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(HSUSB0_DATA1),	(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(HSUSB0_DATA2),	(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(HSUSB0_DATA3),	(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(HSUSB0_DATA4),	(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(HSUSB0_DATA5),	(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(HSUSB0_DATA6),	(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(HSUSB0_DATA7),	(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(USB0_DRVBUS),	(IEN  | PTD | EN  | M0)) \
+	/* HDQ */\
+	MUX_VAL(CP(HDQ_SIO),		(IEN  | PTU | EN  | M0)) \
+	/* Control and debug */\
+	MUX_VAL(CP(SYS_32K),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SYS_CLKREQ),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SYS_NIRQ),		(IEN  | PTU | EN  | M0)) \
+	/*SYS_nRESWARM */\
+	MUX_VAL(CP(SYS_NRESWARM),     	(IDIS | PTU | DIS | M4)) \
+							/* - GPIO30 */\
+	MUX_VAL(CP(SYS_BOOT0),		(IEN  | PTD | DIS | M4)) /*GPIO_2*/\
+							 /* - PEN_IRQ */\
+	MUX_VAL(CP(SYS_BOOT1),		(IEN  | PTD | DIS | M4)) /*GPIO_3 */\
+	MUX_VAL(CP(SYS_BOOT2),		(IEN  | PTD | DIS | M4)) /*GPIO_4*/\
+	MUX_VAL(CP(SYS_BOOT3),		(IEN  | PTD | DIS | M4)) /*GPIO_5*/\
+	MUX_VAL(CP(SYS_BOOT4),		(IEN  | PTD | DIS | M4)) /*GPIO_6*/\
+	MUX_VAL(CP(SYS_BOOT5),		(IEN  | PTD | DIS | M4)) /*GPIO_7*/\
+	MUX_VAL(CP(SYS_BOOT6),		(IDIS | PTD | DIS | M4)) /*GPIO_8*/\
+							 /* - VIO_1V8*/\
+	MUX_VAL(CP(SYS_BOOT7),		(IEN  | PTD | EN  | M0)) \
+	MUX_VAL(CP(SYS_BOOT8),		(IEN  | PTD | EN  | M0)) \
+	\
+	MUX_VAL(CP(SYS_OFF_MODE),	(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SYS_CLKOUT1),	(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SYS_CLKOUT2),	(IEN  | PTU | EN  | M0)) \
+	/* JTAG */\
+	MUX_VAL(CP(JTAG_nTRST),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(JTAG_TCK),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(JTAG_TMS),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(JTAG_TDI),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(JTAG_EMU0),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(JTAG_EMU1),		(IEN  | PTD | DIS | M0)) \
+	/* ETK (ES2 onwards) */\
+	MUX_VAL(CP(ETK_CLK_ES2),	(IDIS | PTU | EN  | M0)) \
+	MUX_VAL(CP(ETK_CTL_ES2),	(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(ETK_D0_ES2),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(ETK_D1_ES2),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(ETK_D2_ES2),		(IEN  | PTD | EN  | M0)) \
+	MUX_VAL(CP(ETK_D3_ES2),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(ETK_D4_ES2),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(ETK_D5_ES2),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(ETK_D6_ES2),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(ETK_D7_ES2),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(ETK_D8_ES2),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(ETK_D9_ES2),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(ETK_D10_ES2),	(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(ETK_D11_ES2),	(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(ETK_D12_ES2),	(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(ETK_D13_ES2),	(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(ETK_D14_ES2),	(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(ETK_D15_ES2),	(IEN  | PTD | DIS | M0)) \
+	/* Die to Die */\
+	MUX_VAL(CP(D2D_MCAD34),		(IEN  | PTD | EN  | M0)) \
+	MUX_VAL(CP(D2D_MCAD35),		(IEN  | PTD | EN  | M0)) \
+	MUX_VAL(CP(D2D_MCAD36),		(IEN  | PTD | EN  | M0)) \
+	MUX_VAL(CP(D2D_CLK26MI),	(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(D2D_NRESPWRON),	(IEN  | PTD | EN  | M0)) \
+	MUX_VAL(CP(D2D_NRESWARM),	(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(D2D_ARM9NIRQ),	(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(D2D_UMA2P6FIQ),	(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(D2D_SPINT),		(IEN  | PTD | EN  | M0)) \
+	MUX_VAL(CP(D2D_FRINT),		(IEN  | PTD | EN  | M0)) \
+	MUX_VAL(CP(D2D_DMAREQ0),	(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(D2D_DMAREQ1),	(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(D2D_DMAREQ2),	(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(D2D_DMAREQ3),	(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(D2D_N3GTRST),	(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(D2D_N3GTDI),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(D2D_N3GTDO),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(D2D_N3GTMS),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(D2D_N3GTCK),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(D2D_N3GRTCK),	(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(D2D_MSTDBY),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(D2D_SWAKEUP),	(IEN  | PTD | EN  | M0)) \
+	MUX_VAL(CP(D2D_IDLEREQ),	(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(D2D_IDLEACK),	(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(D2D_MWRITE),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(D2D_SWRITE),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(D2D_MREAD),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(D2D_SREAD),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(D2D_MBUSFLAG),	(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(D2D_SBUSFLAG),	(IEN  | PTD | DIS | M0)) \
+
+#endif
diff --git a/board/logicpd/am3517evm/config.mk b/board/logicpd/am3517evm/config.mk
new file mode 100644
index 0000000..f7a35ce
--- /dev/null
+++ b/board/logicpd/am3517evm/config.mk
@@ -0,0 +1,30 @@
+#
+# Author: Vaibhav Hiremath <hvaibhav@ti.com>
+#
+# Based on ti/evm/config.mk
+#
+# Copyright (C) 2010
+# Texas Instruments Incorporated - http://www.ti.com/
+#
+# 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; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+#
+# Physical Address:
+# 8000'0000 (bank0)
+# A000/0000 (bank1)
+# Linux-Kernel is expected to be at 8000'8000, entry 8000'8000
+# (mem base + reserved)
+
+# For use with external or internal boots.
+TEXT_BASE = 0x80e80000
diff --git a/include/configs/am3517_evm.h b/include/configs/am3517_evm.h
new file mode 100644
index 0000000..63f853a
--- /dev/null
+++ b/include/configs/am3517_evm.h
@@ -0,0 +1,296 @@
+/*
+ * am3517_evm.h - Default configuration for AM3517 EVM board.
+ *
+ * Author: Vaibhav Hiremath <hvaibhav@ti.com>
+ *
+ * Based on omap3_evm_config.h
+ *
+ * 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#ifndef __CONFIG_H
+#define __CONFIG_H
+
+/*
+ * High Level Configuration Options
+ */
+#define CONFIG_ARMCORTEXA8	1	/* This is an ARM V7 CPU core */
+#define CONFIG_OMAP		1	/* in a TI OMAP core */
+#define CONFIG_OMAP34XX		1	/* which is a 34XX */
+#define CONFIG_OMAP3_AM3517EVM	1	/* working with AM3517EVM */
+
+#define CONFIG_EMIF4		1	/* The chip has EMIF4 controller */
+
+#include <asm/arch/cpu.h>		/* get chip and board defs */
+#include <asm/arch/omap3.h>
+
+/*
+ * Display CPU and Board information
+ */
+#define CONFIG_DISPLAY_CPUINFO		1
+#define CONFIG_DISPLAY_BOARDINFO	1
+
+/* Clock Defines */
+#define V_OSCK			26000000	/* Clock output from T2 */
+#define V_SCLK			(V_OSCK >> 1)
+
+#undef CONFIG_USE_IRQ				/* no support for IRQs */
+#define CONFIG_MISC_INIT_R
+
+#define CONFIG_CMDLINE_TAG		1	/* enable passing of ATAGs */
+#define CONFIG_SETUP_MEMORY_TAGS	1
+#define CONFIG_INITRD_TAG		1
+#define CONFIG_REVISION_TAG		1
+
+/*
+ * Size of malloc() pool
+ */
+#define CONFIG_ENV_SIZE			(128 << 10)	/* 128 KiB sector */
+#define CONFIG_SYS_MALLOC_LEN		(CONFIG_ENV_SIZE + (128 << 10))
+#define CONFIG_SYS_GBL_DATA_SIZE	128	/* bytes reserved for */
+						/* initial data */
+/*
+ * DDR related
+ */
+#define CONFIG_OMAP3_MICRON_DDR		1	/* Micron DDR */
+#define CONFIG_SYS_CS0_SIZE		(256 * 1024 * 1024)
+
+/*
+ * Hardware drivers
+ */
+
+/*
+ * NS16550 Configuration
+ */
+#define V_NS16550_CLK			48000000	/* 48MHz (APLL96/2) */
+
+#define CONFIG_SYS_NS16550
+#define CONFIG_SYS_NS16550_SERIAL
+#define CONFIG_SYS_NS16550_REG_SIZE	(-4)
+#define CONFIG_SYS_NS16550_CLK		V_NS16550_CLK
+
+/*
+ * select serial console configuration
+ */
+#define CONFIG_CONS_INDEX		3
+#define CONFIG_SYS_NS16550_COM3		OMAP34XX_UART3
+#define CONFIG_SERIAL3			3	/* UART3 on AM3517 EVM */
+
+/* allow to overwrite serial and ethaddr */
+#define CONFIG_ENV_OVERWRITE
+#define CONFIG_BAUDRATE			115200
+#define CONFIG_SYS_BAUDRATE_TABLE	{4800, 9600, 19200, 38400, 57600,\
+					115200}
+#define CONFIG_MMC			1
+#define CONFIG_OMAP3_MMC		1
+#define CONFIG_DOS_PARTITION		1
+
+/* commands to include */
+#include <config_cmd_default.h>
+
+#define CONFIG_CMD_EXT2		/* EXT2 Support			*/
+#define CONFIG_CMD_FAT		/* FAT support			*/
+#define CONFIG_CMD_JFFS2	/* JFFS2 Support		*/
+
+#define CONFIG_CMD_I2C		/* I2C serial bus support	*/
+#define CONFIG_CMD_MMC		/* MMC support			*/
+#define CONFIG_CMD_NAND		/* NAND support			*/
+#define CONFIG_CMD_DHCP
+#define CONFIG_CMD_PING
+
+#undef CONFIG_CMD_FLASH		/* flinfo, erase, protect	*/
+#undef CONFIG_CMD_FPGA		/* FPGA configuration Support	*/
+#undef CONFIG_CMD_IMI		/* iminfo			*/
+#undef CONFIG_CMD_IMLS		/* List all found images	*/
+
+#define CONFIG_SYS_NO_FLASH
+#define CONFIG_HARD_I2C			1
+#define CONFIG_SYS_I2C_SPEED		100000
+#define CONFIG_SYS_I2C_SLAVE		1
+#define CONFIG_SYS_I2C_BUS		0
+#define CONFIG_SYS_I2C_BUS_SELECT	1
+#define CONFIG_DRIVER_OMAP34XX_I2C	1
+
+#undef CONFIG_CMD_NET
+/*
+ * Board NAND Info.
+ */
+#define CONFIG_SYS_NAND_ADDR		NAND_BASE	/* physical address */
+							/* to access nand */
+#define CONFIG_SYS_NAND_BASE		NAND_BASE	/* physical address */
+							/* to access */
+							/* nand at CS0 */
+
+#define CONFIG_SYS_MAX_NAND_DEVICE	1		/* Max number of */
+							/* NAND devices */
+#define CONFIG_SYS_64BIT_VSPRINTF		/* needed for nand_util.c */
+
+#define CONFIG_JFFS2_NAND
+/* nand device jffs2 lives on */
+#define CONFIG_JFFS2_DEV		"nand0"
+/* start of jffs2 partition */
+#define CONFIG_JFFS2_PART_OFFSET	0x680000
+#define CONFIG_JFFS2_PART_SIZE		0xf980000	/* sz of jffs2 part */
+
+/* Environment information */
+#define CONFIG_BOOTDELAY	10
+
+#define CONFIG_BOOTFILE		uImage
+
+#define CONFIG_EXTRA_ENV_SETTINGS \
+	"loadaddr=0x82000000\0" \
+	"console=ttyS2,115200n8\0" \
+	"mmcargs=setenv bootargs console=${console} " \
+		"root=/dev/mmcblk0p2 rw " \
+		"rootfstype=ext3 rootwait\0" \
+	"nandargs=setenv bootargs console=${console} " \
+		"root=/dev/mtdblock4 rw " \
+		"rootfstype=jffs2\0" \
+	"loadbootscript=fatload mmc 0 ${loadaddr} boot.scr\0" \
+	"bootscript=echo Running bootscript from mmc ...; " \
+		"source ${loadaddr}\0" \
+	"loaduimage=fatload mmc 0 ${loadaddr} uImage\0" \
+	"mmcboot=echo Booting from mmc ...; " \
+		"run mmcargs; " \
+		"bootm ${loadaddr}\0" \
+	"nandboot=echo Booting from nand ...; " \
+		"run nandargs; " \
+		"nand read ${loadaddr} 280000 400000; " \
+		"bootm ${loadaddr}\0" \
+
+#define CONFIG_BOOTCOMMAND \
+	"if mmc init; then " \
+		"if run loadbootscript; then " \
+			"run bootscript; " \
+		"else " \
+			"if run loaduimage; then " \
+				"run mmcboot; " \
+			"else run nandboot; " \
+			"fi; " \
+		"fi; " \
+	"else run nandboot; fi"
+
+#define CONFIG_AUTO_COMPLETE	1
+/*
+ * Miscellaneous configurable options
+ */
+#define V_PROMPT			"AM3517_EVM # "
+
+#define CONFIG_SYS_LONGHELP		/* undef to save memory */
+#define CONFIG_SYS_HUSH_PARSER		/* use "hush" command parser */
+#define CONFIG_SYS_PROMPT_HUSH_PS2	"> "
+#define CONFIG_SYS_PROMPT		V_PROMPT
+#define CONFIG_SYS_CBSIZE		512	/* Console I/O Buffer Size */
+/* Print Buffer Size */
+#define CONFIG_SYS_PBSIZE		(CONFIG_SYS_CBSIZE + \
+					sizeof(CONFIG_SYS_PROMPT) + 16)
+#define CONFIG_SYS_MAXARGS		32	/* max number of command */
+						/* args */
+/* Boot Argument Buffer Size */
+#define CONFIG_SYS_BARGSIZE		(CONFIG_SYS_CBSIZE)
+/* memtest works on */
+#define CONFIG_SYS_MEMTEST_START	(OMAP34XX_SDRC_CS0)
+#define CONFIG_SYS_MEMTEST_END		(OMAP34XX_SDRC_CS0 + \
+					0x01F00000) /* 31MB */
+
+#define CONFIG_SYS_LOAD_ADDR		(OMAP34XX_SDRC_CS0) /* default load */
+								/* address */
+
+/*
+ * AM3517 has 12 GP timers, they can be driven by the system clock
+ * (12/13/16.8/19.2/38.4MHz) or by 32KHz clock. We use 13MHz (V_SCLK).
+ * This rate is divided by a local divisor.
+ */
+#define CONFIG_SYS_TIMERBASE		OMAP34XX_GPT2
+#define CONFIG_SYS_PTV			2	/* Divisor: 2^(PTV+1) => 8 */
+#define CONFIG_SYS_HZ			1000
+
+/*-----------------------------------------------------------------------
+ * Stack sizes
+ *
+ * The stack sizes are set up in start.S using the settings below
+ */
+#define CONFIG_STACKSIZE	(128 << 10)	/* regular stack 128 KiB */
+#ifdef CONFIG_USE_IRQ
+#define CONFIG_STACKSIZE_IRQ	(4 << 10)	/* IRQ stack 4 KiB */
+#define CONFIG_STACKSIZE_FIQ	(4 << 10)	/* FIQ stack 4 KiB */
+#endif
+
+/*-----------------------------------------------------------------------
+ * Physical Memory Map
+ */
+#define CONFIG_NR_DRAM_BANKS	2	/* CS1 may or may not be populated */
+#define PHYS_SDRAM_1		OMAP34XX_SDRC_CS0
+#define PHYS_SDRAM_1_SIZE	(32 << 20)	/* at least 32 MiB */
+#define PHYS_SDRAM_2		OMAP34XX_SDRC_CS1
+
+/* SDRAM Bank Allocation method */
+#define SDRC_R_B_C		1
+
+/*-----------------------------------------------------------------------
+ * FLASH and environment organization
+ */
+
+/* **** PISMO SUPPORT *** */
+
+/* Configure the PISMO */
+#define PISMO1_NAND_SIZE		GPMC_SIZE_128M
+#define PISMO1_ONEN_SIZE		GPMC_SIZE_128M
+
+#define CONFIG_SYS_MAX_FLASH_SECT	520	/* max number of sectors */
+						/* on one chip */
+#define CONFIG_SYS_MAX_FLASH_BANKS	2	/* max number of flash banks */
+#define CONFIG_SYS_MONITOR_LEN		(256 << 10)	/* Reserve 2 sectors */
+
+#define CONFIG_SYS_FLASH_BASE		boot_flash_base
+
+/* Monitor@start of flash */
+#define CONFIG_SYS_MONITOR_BASE		CONFIG_SYS_FLASH_BASE
+
+#define CONFIG_NAND_OMAP_GPMC
+#define GPMC_NAND_ECC_LP_x16_LAYOUT	1
+#define CONFIG_ENV_IS_IN_NAND		1
+#define SMNAND_ENV_OFFSET		0x260000 /* environment starts here */
+
+#define CONFIG_SYS_ENV_SECT_SIZE	boot_flash_sec
+#define CONFIG_ENV_OFFSET		boot_flash_off
+#define CONFIG_ENV_ADDR			boot_flash_env_addr
+
+/*-----------------------------------------------------------------------
+ * CFI FLASH driver setup
+ */
+/* timeout values are in ticks */
+#define CONFIG_SYS_FLASH_ERASE_TOUT	(100 * CONFIG_SYS_HZ)
+#define CONFIG_SYS_FLASH_WRITE_TOUT	(100 * CONFIG_SYS_HZ)
+
+/* Flash banks JFFS2 should use */
+#define CONFIG_SYS_MAX_MTD_BANKS	(CONFIG_SYS_MAX_FLASH_BANKS + \
+					CONFIG_SYS_MAX_NAND_DEVICE)
+#define CONFIG_SYS_JFFS2_MEM_NAND
+/* use flash_info[2] */
+#define CONFIG_SYS_JFFS2_FIRST_BANK	CONFIG_SYS_MAX_FLASH_BANKS
+#define CONFIG_SYS_JFFS2_NUM_BANKS	1
+
+#ifndef __ASSEMBLY__
+extern unsigned int boot_flash_base;
+extern volatile unsigned int boot_flash_env_addr;
+extern unsigned int boot_flash_off;
+extern unsigned int boot_flash_sec;
+extern unsigned int boot_flash_type;
+#endif
+
+#endif /* __CONFIG_H */
--
1.6.2.4

^ permalink raw reply related	[flat|nested] 263+ messages in thread

* [U-Boot] [PATCH-V3 2/2] AM35x: Add support for EMIF4
@ 2010-05-06 17:23 ` hvaibhav at ti.com
  2010-05-31  9:43   ` Wolfgang Denk
  0 siblings, 1 reply; 263+ messages in thread
From: hvaibhav at ti.com @ 2010-05-06 17:23 UTC (permalink / raw)
  To: u-boot

From: Vaibhav Hiremath <hvaibhav@ti.com>

This patch adds support for the EMIF4 interface
available in the AM35x processors.

Changes from V2:
	- Removed all instances of #ifdef CONFIG_EMIF4

Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
Signed-off-by: Sanjeev Premi <premi@ti.com>
---
 arch/arm/cpu/arm_cortexa8/omap3/Makefile    |    1 +
 arch/arm/cpu/arm_cortexa8/omap3/emif4.c     |  168 +++++++++++++++++++++++++++
 arch/arm/include/asm/arch-omap3/cpu.h       |   24 ++++
 arch/arm/include/asm/arch-omap3/emif4.h     |   79 +++++++++++++
 arch/arm/include/asm/arch-omap3/sys_proto.h |    1 +
 include/configs/am3517_evm.h                |    2 +-
 6 files changed, 274 insertions(+), 1 deletions(-)
 create mode 100644 arch/arm/cpu/arm_cortexa8/omap3/emif4.c
 create mode 100644 arch/arm/include/asm/arch-omap3/emif4.h

diff --git a/arch/arm/cpu/arm_cortexa8/omap3/Makefile b/arch/arm/cpu/arm_cortexa8/omap3/Makefile
index 1e80eb3..d25bfd5 100644
--- a/arch/arm/cpu/arm_cortexa8/omap3/Makefile
+++ b/arch/arm/cpu/arm_cortexa8/omap3/Makefile
@@ -38,6 +38,7 @@ COBJS	+= sys_info.o
 COBJS	+= timer.o

 COBJS-$(CONFIG_SDRC)	+= sdrc.o
+COBJS-$(CONFIG_EMIF4)	+=emif4.o

 SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
 OBJS	:= $(addprefix $(obj),$(COBJS) $(COBJS-y) $(SOBJS))
diff --git a/arch/arm/cpu/arm_cortexa8/omap3/emif4.c b/arch/arm/cpu/arm_cortexa8/omap3/emif4.c
new file mode 100644
index 0000000..fae5b11
--- /dev/null
+++ b/arch/arm/cpu/arm_cortexa8/omap3/emif4.c
@@ -0,0 +1,168 @@
+/*
+ * Author :
+ *     Vaibhav Hiremath <hvaibhav@ti.com>
+ *
+ * Based on mem.c and sdrc.c
+ *
+ * Copyright (C) 2010
+ * Texas Instruments Incorporated - http://www.ti.com/
+ *
+ * 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; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <common.h>
+#include <asm/io.h>
+#include <asm/arch/mem.h>
+#include <asm/arch/sys_proto.h>
+#include <asm/arch/emif4.h>
+
+extern omap3_sysinfo sysinfo;
+
+static emif4_t *emif4_base = (emif4_t *)OMAP34XX_SDRC_BASE;
+
+/*
+ * is_mem_sdr -
+ *  - Return 1 if mem type in use is SDR
+ */
+u32 is_mem_sdr(void)
+{
+	return 0;
+}
+
+/*
+ * get_sdr_cs_size -
+ *  - Get size of chip select 0/1
+ */
+u32 get_sdr_cs_size(u32 cs)
+{
+	u32 size;
+
+	/* TODO: Calculate the size based on EMIF4 configuration */
+	size = CONFIG_SYS_CS0_SIZE;
+
+	return size;
+}
+
+/*
+ * get_sdr_cs_offset -
+ *  - Get offset of cs from cs0 start
+ */
+u32 get_sdr_cs_offset(u32 cs)
+{
+	u32 offset = 0;
+
+	return offset;
+}
+
+/*
+ * do_emif4_init -
+ *  - Init the emif4 module for DDR access
+ *  - Early init routines, called from flash or SRAM.
+ */
+void do_emif4_init(void)
+{
+	unsigned int regval;
+	/* Set the DDR PHY parameters in PHY ctrl registers */
+	regval = (EMIF4_DDR1_READ_LAT | EMIF4_DDR1_PWRDN_DIS |
+		EMIF4_DDR1_EXT_STRB_DIS);
+	writel(regval, &emif4_base->ddr_phyctrl1);
+	writel(regval, &emif4_base->ddr_phyctrl1_shdw);
+	writel(0, &emif4_base->ddr_phyctrl2);
+
+	/* Reset the DDR PHY and wait till completed */
+	regval = readl(&emif4_base->sdram_iodft_tlgc);
+	regval |= (1<<10);
+	writel(regval, &emif4_base->sdram_iodft_tlgc);
+	/*Wait till that bit clears*/
+	while ((readl(&emif4_base->sdram_iodft_tlgc) & (1<<10)) == 0x1);
+	/*Re-verify the DDR PHY status*/
+	while ((readl(&emif4_base->sdram_sts) & (1<<2)) == 0x0);
+
+	regval |= (1<<0);
+	writel(regval, &emif4_base->sdram_iodft_tlgc);
+	/* Set SDR timing registers */
+	regval = (EMIF4_TIM1_T_WTR | EMIF4_TIM1_T_RRD |
+		EMIF4_TIM1_T_RC | EMIF4_TIM1_T_RAS |
+		EMIF4_TIM1_T_WR | EMIF4_TIM1_T_RCD |
+		EMIF4_TIM1_T_RP);
+	writel(regval, &emif4_base->sdram_time1);
+	writel(regval, &emif4_base->sdram_time1_shdw);
+
+	regval = (EMIF4_TIM2_T_CKE | EMIF4_TIM2_T_RTP |
+		EMIF4_TIM2_T_XSRD | EMIF4_TIM2_T_XSNR |
+		EMIF4_TIM2_T_ODT | EMIF4_TIM2_T_XP);
+	writel(regval, &emif4_base->sdram_time2);
+	writel(regval, &emif4_base->sdram_time2_shdw);
+
+	regval = (EMIF4_TIM3_T_RAS_MAX | EMIF4_TIM3_T_RFC);
+	writel(regval, &emif4_base->sdram_time3);
+	writel(regval, &emif4_base->sdram_time3_shdw);
+
+	/* Set the PWR control register */
+	regval = (EMIF4_PWR_PM_TIM | EMIF4_PWR_LP_MODE |
+		EMIF4_PWR_DPD_DIS | EMIF4_PWR_IDLE_MODE);
+	writel(regval, &emif4_base->sdram_pwr_mgmt);
+	writel(regval, &emif4_base->sdram_pwr_mgmt_shdw);
+
+	/* Set the DDR refresh rate control register */
+	regval = (EMIF4_REFRESH_RATE | EMIF4_INITREF_DIS);
+	writel(regval, &emif4_base->sdram_refresh_ctrl);
+	writel(regval, &emif4_base->sdram_refresh_ctrl_shdw);
+
+	/* set the SDRAM configuration register */
+	regval = (EMIF4_CFG_PGSIZE | EMIF4_CFG_EBANK |
+		EMIF4_CFG_IBANK | EMIF4_CFG_ROWSIZE |
+		EMIF4_CFG_CL | EMIF4_CFG_NARROW_MD |
+		EMIF4_CFG_SDR_DRV | EMIF4_CFG_DDR_DIS_DLL |
+		EMIF4_CFG_DDR2_DDQS | EMIF4_CFG_DDR_TERM |
+		EMIF4_CFG_IBANK_POS | EMIF4_CFG_SDRAM_TYP);
+	writel(regval, &emif4_base->sdram_config);
+}
+
+/*
+ * dram_init -
+ *  - Sets uboots idea of sdram size
+ */
+int dram_init(void)
+{
+	DECLARE_GLOBAL_DATA_PTR;
+	unsigned int size0 = 0, size1 = 0;
+
+	size0 = get_sdr_cs_size(CS0);
+	/*
+	 * If a second bank of DDR is attached to CS1 this is
+	 * where it can be started.  Early init code will init
+	 * memory on CS0.
+	 */
+	if ((sysinfo.mtype == DDR_COMBO) || (sysinfo.mtype == DDR_STACKED))
+		size1 = get_sdr_cs_size(CS1);
+
+	gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
+	gd->bd->bi_dram[0].size = size0;
+	gd->bd->bi_dram[1].start = PHYS_SDRAM_1 + get_sdr_cs_offset(CS1);
+	gd->bd->bi_dram[1].size = size1;
+
+	return 0;
+}
+
+/*
+ * mem_init() -
+ *  - Initialize memory subsystem
+ */
+void mem_init(void)
+{
+	do_emif4_init();
+}
diff --git a/arch/arm/include/asm/arch-omap3/cpu.h b/arch/arm/include/asm/arch-omap3/cpu.h
index ce16da7..c072c27 100644
--- a/arch/arm/include/asm/arch-omap3/cpu.h
+++ b/arch/arm/include/asm/arch-omap3/cpu.h
@@ -216,6 +216,30 @@ struct sdrc {
 	struct sdrc_cs cs[2];	/* 0x80 || 0xB0 */
 };

+/* EMIF4 */
+typedef struct emif4 {
+	unsigned int sdram_sts;
+	unsigned int sdram_config;
+	unsigned int res1;
+	unsigned int sdram_refresh_ctrl;
+	unsigned int sdram_refresh_ctrl_shdw;
+	unsigned int sdram_time1;
+	unsigned int sdram_time1_shdw;
+	unsigned int sdram_time2;
+	unsigned int sdram_time2_shdw;
+	unsigned int sdram_time3;
+	unsigned int sdram_time3_shdw;
+	unsigned char res2[8];
+	unsigned int sdram_pwr_mgmt;
+	unsigned int sdram_pwr_mgmt_shdw;
+	unsigned char res3[32];
+	unsigned int sdram_iodft_tlgc;
+	unsigned char res4[128];
+	unsigned int ddr_phyctrl1;
+	unsigned int ddr_phyctrl1_shdw;
+	unsigned int ddr_phyctrl2;
+} emif4_t;
+
 #endif /* __ASSEMBLY__ */
 #endif /* __KERNEL_STRICT_NAMES */

diff --git a/arch/arm/include/asm/arch-omap3/emif4.h b/arch/arm/include/asm/arch-omap3/emif4.h
new file mode 100644
index 0000000..579da0c
--- /dev/null
+++ b/arch/arm/include/asm/arch-omap3/emif4.h
@@ -0,0 +1,79 @@
+/*
+ * Auther:
+ *       Vaibhav Hiremath <hvaibhav@ti.com>
+ *
+ * Copyright (C) 2010
+ * Texas Instruments Incorporated - http://www.ti.com/
+ *
+ * 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; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#ifndef _EMIF_H_
+#define _EMIF_H_
+
+/*
+ * Configuration values
+ */
+#define EMIF4_TIM1_T_RP		(0x3 << 25)
+#define EMIF4_TIM1_T_RCD	(0x3 << 21)
+#define EMIF4_TIM1_T_WR		(0x3 << 17)
+#define EMIF4_TIM1_T_RAS	(0x8 << 12)
+#define EMIF4_TIM1_T_RC		(0xA << 6)
+#define EMIF4_TIM1_T_RRD	(0x2 << 3)
+#define EMIF4_TIM1_T_WTR	(0x2)
+
+#define EMIF4_TIM2_T_XP		(0x2 << 28)
+#define EMIF4_TIM2_T_ODT	(0x0 << 25)
+#define EMIF4_TIM2_T_XSNR	(0x1C << 16)
+#define EMIF4_TIM2_T_XSRD	(0xC8 << 6)
+#define EMIF4_TIM2_T_RTP	(0x1 << 3)
+#define EMIF4_TIM2_T_CKE	(0x2)
+
+#define EMIF4_TIM3_T_RFC	(0x25 << 4)
+#define EMIF4_TIM3_T_RAS_MAX	(0x7)
+
+#define EMIF4_PWR_IDLE_MODE	(0x2 << 30)
+#define EMIF4_PWR_DPD_DIS	(0x0 << 10)
+#define EMIF4_PWR_DPD_EN	(0x1 << 10)
+#define EMIF4_PWR_LP_MODE	(0x0 << 8)
+#define EMIF4_PWR_PM_TIM	(0x0)
+
+#define EMIF4_INITREF_DIS	(0x0 << 31)
+#define EMIF4_REFRESH_RATE	(0x50F)
+
+#define EMIF4_CFG_SDRAM_TYP	(0x2 << 29)
+#define EMIF4_CFG_IBANK_POS	(0x0 << 27)
+#define EMIF4_CFG_DDR_TERM	(0x0 << 24)
+#define EMIF4_CFG_DDR2_DDQS	(0x1 << 23)
+#define EMIF4_CFG_DDR_DIS_DLL	(0x0 << 20)
+#define EMIF4_CFG_SDR_DRV	(0x0 << 18)
+#define EMIF4_CFG_NARROW_MD	(0x0 << 14)
+#define EMIF4_CFG_CL		(0x5 << 10)
+#define EMIF4_CFG_ROWSIZE	(0x0 << 7)
+#define EMIF4_CFG_IBANK		(0x3 << 4)
+#define EMIF4_CFG_EBANK		(0x0 << 3)
+#define EMIF4_CFG_PGSIZE	(0x2)
+
+/*
+ * EMIF4 PHY Control 1 register configuration
+ */
+#define EMIF4_DDR1_EXT_STRB_EN	(0x1 << 7)
+#define EMIF4_DDR1_EXT_STRB_DIS	(0x0 << 7)
+#define EMIF4_DDR1_PWRDN_DIS	(0x0 << 6)
+#define EMIF4_DDR1_PWRDN_EN	(0x1 << 6)
+#define EMIF4_DDR1_READ_LAT	(0x6 << 0)
+
+#endif /* endif _EMIF_H_ */
diff --git a/arch/arm/include/asm/arch-omap3/sys_proto.h b/arch/arm/include/asm/arch-omap3/sys_proto.h
index 4608f30..db7b42a 100644
--- a/arch/arm/include/asm/arch-omap3/sys_proto.h
+++ b/arch/arm/include/asm/arch-omap3/sys_proto.h
@@ -33,6 +33,7 @@ void per_clocks_enable(void);
 void memif_init(void);
 void sdrc_init(void);
 void do_sdrc_init(u32, u32);
+void emif4_init(void);
 void gpmc_init(void);
 void enable_gpmc_cs_config(const u32 *gpmc_config, struct gpmc_cs *cs, u32 base,
 			u32 size);
diff --git a/include/configs/am3517_evm.h b/include/configs/am3517_evm.h
index 63f853a..0106031 100644
--- a/include/configs/am3517_evm.h
+++ b/include/configs/am3517_evm.h
@@ -33,7 +33,7 @@
 #define CONFIG_OMAP34XX		1	/* which is a 34XX */
 #define CONFIG_OMAP3_AM3517EVM	1	/* working with AM3517EVM */

-#define CONFIG_EMIF4		1	/* The chip has EMIF4 controller */
+#define CONFIG_EMIF4	/* The chip has EMIF4 controller */

 #include <asm/arch/cpu.h>		/* get chip and board defs */
 #include <asm/arch/omap3.h>
--
1.6.2.4

^ permalink raw reply related	[flat|nested] 263+ messages in thread

* [U-Boot] [PATCH-V5] OMAP3EVM: Added NAND support
  2010-05-06 17:19 ` [U-Boot] [PATCH-V5] OMAP3EVM: Added NAND support hvaibhav at ti.com
@ 2010-05-11  4:59   ` Hiremath, Vaibhav
  2010-05-11  8:59     ` Wolfgang Denk
  0 siblings, 1 reply; 263+ messages in thread
From: Hiremath, Vaibhav @ 2010-05-11  4:59 UTC (permalink / raw)
  To: u-boot

> -----Original Message-----
> From: Hiremath, Vaibhav
> Sent: Thursday, May 06, 2010 10:49 PM
> To: u-boot at lists.denx.de
> Cc: wd at denx.de; tom at bumblecow.com; Paulraj, Sandeep; Hiremath, Vaibhav
> Subject: [PATCH-V5] OMAP3EVM: Added NAND support
> 
> From: Vaibhav Hiremath <hvaibhav@ti.com>
> 
> The EVMS have been shipping with NAND (instead of OneNAND) as default.
> So, this patch sets NAND as default.
> 
> To choose OneNAND, define CMD_ONENAND instead of CMD_NAND in the
> config file omap3_evm.h,
> 
> Changes From V4 :-
> 	- Removed #undef ONENAND line (comment from Denk)
> Changes from V3 :-
> 	- Refreshed against latest u-boot/master
> Changes from V2 :-
> 	- Added undef statement for CMD_ONENAND.
> 
[Hiremath, Vaibhav] Denk,

If we do not have any further comments, can we merge these patches?

Thanks,
Vaibhav

> Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
> ---
>  include/configs/omap3_evm.h |    8 +++++++-
>  1 files changed, 7 insertions(+), 1 deletions(-)
> 
> diff --git a/include/configs/omap3_evm.h b/include/configs/omap3_evm.h
> index 0d99f7d..88af492 100644
> --- a/include/configs/omap3_evm.h
> +++ b/include/configs/omap3_evm.h
> @@ -151,7 +151,7 @@
> 
>  #define CONFIG_CMD_I2C		/* I2C serial bus support	*/
>  #define CONFIG_CMD_MMC		/* MMC support			*/
> -#define CONFIG_CMD_ONENAND	/* ONENAND support		*/
> +#define CONFIG_CMD_NAND		/* NAND support			*/
>  #define CONFIG_CMD_DHCP
>  #define CONFIG_CMD_PING
> 
> @@ -306,7 +306,13 @@
>  #define CONFIG_SYS_MONITOR_BASE		CONFIG_SYS_FLASH_BASE
>  #define CONFIG_SYS_ONENAND_BASE		ONENAND_MAP
> 
> +#if defined(CONFIG_CMD_NAND)
> +#define CONFIG_NAND_OMAP_GPMC
> +#define GPMC_NAND_ECC_LP_x16_LAYOUT	1
> +#define CONFIG_ENV_IS_IN_NAND
> +#elif defined(CONFIG_CMD_ONENAND)
>  #define CONFIG_ENV_IS_IN_ONENAND	1
> +#endif
>  #define ONENAND_ENV_OFFSET		0x260000 /* environment starts here */
>  #define SMNAND_ENV_OFFSET		0x260000 /* environment starts here */
> 
> --
> 1.6.2.4

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [U-Boot] [PATCH-V3 1/2] AM35x: Add support for AM3517EVM
  2010-05-06 17:23 ` [U-Boot] [PATCH-V3 1/2] AM35x: Add support for AM3517EVM hvaibhav at ti.com
@ 2010-05-11  5:00   ` Hiremath, Vaibhav
  2010-05-31  9:40   ` Wolfgang Denk
  1 sibling, 0 replies; 263+ messages in thread
From: Hiremath, Vaibhav @ 2010-05-11  5:00 UTC (permalink / raw)
  To: u-boot

> -----Original Message-----
> From: Hiremath, Vaibhav
> Sent: Thursday, May 06, 2010 10:53 PM
> To: u-boot at lists.denx.de
> Cc: wd at denx.de; tom at bumblecow.com; Paulraj, Sandeep; Hiremath, Vaibhav;
> Premi, Sanjeev
> Subject: [PATCH-V3 1/2] AM35x: Add support for AM3517EVM
>
> From: Vaibhav Hiremath <hvaibhav@ti.com>
>
> This patch adds basic support for the AM3517EVM.
> It includes:
>       - Board int file (.c and .h)
>       - Default configuration file
>       - Updates for Makefile
>
> Changes from V2:
>       - Removed trailing spaces
>       - Updated MAINTAINERS & MAKEALL for am3517_evm
>
[Hiremath, Vaibhav] Denk,

If we do not have any further comments, can we merge these patches?

Thanks,
Vaibhav

> Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
> Signed-off-by: Sanjeev Premi <premi@ti.com>
> ---
>  MAINTAINERS                           |    4 +
>  MAKEALL                               |    1 +
>  Makefile                              |    3 +
>  arch/arm/include/asm/arch-omap3/mux.h |   38 +++-
>  board/logicpd/am3517evm/Makefile      |   46 ++++
>  board/logicpd/am3517evm/am3517evm.c   |   76 ++++++
>  board/logicpd/am3517evm/am3517evm.h   |  405
> +++++++++++++++++++++++++++++++++
>  board/logicpd/am3517evm/config.mk     |   30 +++
>  include/configs/am3517_evm.h          |  296 ++++++++++++++++++++++++
>  9 files changed, 898 insertions(+), 1 deletions(-)
>  create mode 100644 board/logicpd/am3517evm/Makefile
>  create mode 100644 board/logicpd/am3517evm/am3517evm.c
>  create mode 100644 board/logicpd/am3517evm/am3517evm.h
>  create mode 100644 board/logicpd/am3517evm/config.mk
>  create mode 100644 include/configs/am3517_evm.h
>
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 5cbc845..0bc65e1 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -798,6 +798,10 @@ Alex Z
>       lart            SA1100
>       dnp1110         SA1110
>
> +Vaibhav Hiremath <hvaibhav@ti.com>
> +
> +     am3517_evm      ARM CORTEX-A8 (AM35x SoC)
> +
>  -------------------------------------------------------------------------
>
>  Unknown / orphaned boards:
> diff --git a/MAKEALL b/MAKEALL
> index bb09627..cd59daa 100755
> --- a/MAKEALL
> +++ b/MAKEALL
> @@ -641,6 +641,7 @@ LIST_ARM11="                      \
>  ## ARM Cortex-A8 Systems
>  #########################################################################
>  LIST_ARM_CORTEX_A8="         \
> +     am3517_evm              \
>       devkit8000              \
>       mx51evk                 \
>       omap3_beagle            \
> diff --git a/Makefile b/Makefile
> index 2d96574..57b3491 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -3155,6 +3155,9 @@ SMN42_config    :       unconfig
>  ## ARM CORTEX Systems
>  #########################################################################
>
> +am3517_evm_config :  unconfig
> +     @$(MKCONFIG) $(@:_config=) arm arm_cortexa8 am3517evm logicpd omap3
> +
>  devkit8000_config :  unconfig
>       @$(MKCONFIG) $(@:_config=) arm arm_cortexa8 devkit8000 timll omap3
>
> diff --git a/arch/arm/include/asm/arch-omap3/mux.h
> b/arch/arm/include/asm/arch-omap3/mux.h
> index 0c01c73..ffeb982 100644
> --- a/arch/arm/include/asm/arch-omap3/mux.h
> +++ b/arch/arm/include/asm/arch-omap3/mux.h
> @@ -283,7 +283,7 @@
>  /*Control and debug */
>  #define CONTROL_PADCONF_SYS_32K              0x0A04
>  #define CONTROL_PADCONF_SYS_CLKREQ   0x0A06
> -#define CONTROL_PADCONF_SYS_NIRQ     0x01E0
> +#define CONTROL_PADCONF_SYS_NRESWARM 0x0A08
>  #define CONTROL_PADCONF_SYS_BOOT0    0x0A0A
>  #define CONTROL_PADCONF_SYS_BOOT1    0x0A0C
>  #define CONTROL_PADCONF_SYS_BOOT2    0x0A0E
> @@ -337,6 +337,7 @@
>  #define CONTROL_PADCONF_ETK_D14_ES2  0x05F8
>  #define CONTROL_PADCONF_ETK_D15_ES2  0x05FA
>  /*Die to Die */
> +#define CONTROL_PADCONF_SYS_NIRQ     0x01E0
>  #define CONTROL_PADCONF_D2D_MCAD0    0x01E4
>  #define CONTROL_PADCONF_D2D_MCAD1    0x01E6
>  #define CONTROL_PADCONF_D2D_MCAD2    0x01E8
> @@ -403,6 +404,41 @@
>  #define CONTROL_PADCONF_D2D_SBUSFLAG 0x0260
>  #define CONTROL_PADCONF_SDRC_CKE0    0x0262
>  #define CONTROL_PADCONF_SDRC_CKE1    0x0264
> +/* AM3517 specific */
> +#define CONTROL_PADCONF_CCDC_PCLK    0x01E4
> +#define CONTROL_PADCONF_CCDC_FIELD   0x01E6
> +#define CONTROL_PADCONF_CCDC_HD              0x01E8
> +#define CONTROL_PADCONF_CCDC_VD              0x01EA
> +#define CONTROL_PADCONF_CCDC_WEN     0x01EC
> +#define CONTROL_PADCONF_CCDC_DATA0   0x01EE
> +#define CONTROL_PADCONF_CCDC_DATA1   0x01F0
> +#define CONTROL_PADCONF_CCDC_DATA2   0x01F2
> +#define CONTROL_PADCONF_CCDC_DATA3   0x01F4
> +#define CONTROL_PADCONF_CCDC_DATA4   0x01F6
> +#define CONTROL_PADCONF_CCDC_DATA5   0x01F8
> +#define CONTROL_PADCONF_CCDC_DATA6   0x01FA
> +#define CONTROL_PADCONF_CCDC_DATA7   0x01FC
> +#define CONTROL_PADCONF_RMII_MDIO_DATA       0x01FE
> +#define CONTROL_PADCONF_RMII_MDIO_CLK        0x0200
> +#define CONTROL_PADCONF_RMII_RXD0    0x0202
> +#define CONTROL_PADCONF_RMII_RXD1    0x0204
> +#define CONTROL_PADCONF_RMII_CRS_DV  0x0206
> +#define CONTROL_PADCONF_RMII_RXER    0x0208
> +#define CONTROL_PADCONF_RMII_TXD0    0x020A
> +#define CONTROL_PADCONF_RMII_TXD1    0x020C
> +#define CONTROL_PADCONF_RMII_TXEN    0x020E
> +#define CONTROL_PADCONF_RMII_50MHZ_CLK       0x0210
> +#define CONTROL_PADCONF_USB0_DRVBUS  0x0212
> +#define CONTROL_PADCONF_HECC1_TXD    0x0214
> +#define CONTROL_PADCONF_HECC1_RXD    0x0216
> +#define CONTROL_PADCONF_SYS_BOOT7    0x0218
> +#define CONTROL_PADCONF_SDRC_DQS0N   0x021A
> +#define CONTROL_PADCONF_SDRC_DQS1N   0x021C
> +#define CONTROL_PADCONF_SDRC_DQS2N   0x021E
> +#define CONTROL_PADCONF_SDRC_DQS3N   0x0220
> +#define CONTROL_PADCONF_STRBEN_DLY0  0x0222
> +#define CONTROL_PADCONF_STRBEN_DLY1  0x0224
> +#define CONTROL_PADCONF_SYS_BOOT8    0x0226
>
>  #define MUX_VAL(OFFSET,VALUE)\
>       writew((VALUE), OMAP34XX_CTRL_BASE + (OFFSET));
> diff --git a/board/logicpd/am3517evm/Makefile
> b/board/logicpd/am3517evm/Makefile
> new file mode 100644
> index 0000000..3a6b1a1
> --- /dev/null
> +++ b/board/logicpd/am3517evm/Makefile
> @@ -0,0 +1,46 @@
> +#
> +# Author: Vaibhav Hiremath <hvaibhav@ti.com>
> +#
> +# Based on ti/evm/Makefile
> +#
> +# Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/
> +#
> +# 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; either version 2 of the License, or
> +# (at your option) any later version.
> +#
> +# This program is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program; if not, write to the Free Software
> +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
> +#
> +
> +include $(TOPDIR)/config.mk
> +
> +LIB  = $(obj)lib$(BOARD).a
> +
> +COBJS        := am3517evm.o
> +
> +SRCS := $(COBJS:.o=.c)
> +OBJS := $(addprefix $(obj),$(COBJS))
> +
> +$(LIB):      $(obj).depend $(OBJS)
> +     $(AR) $(ARFLAGS) $@ $(OBJS)
> +
> +clean:
> +     rm -f $(OBJS)
> +
> +distclean:   clean
> +     rm -f $(LIB) core *.bak $(obj).depend
> +
> +#########################################################################
> +
> +# defines $(obj).depend target
> +include $(SRCTREE)/rules.mk
> +
> +sinclude $(obj).depend
> diff --git a/board/logicpd/am3517evm/am3517evm.c
> b/board/logicpd/am3517evm/am3517evm.c
> new file mode 100644
> index 0000000..2b912a9
> --- /dev/null
> +++ b/board/logicpd/am3517evm/am3517evm.c
> @@ -0,0 +1,76 @@
> +/*
> + * am3517evm.c - board file for TI's AM3517 family of devices.
> + *
> + * Author: Vaibhav Hiremath <hvaibhav@ti.com>
> + *
> + * Based on ti/evm/evm.c
> + *
> + * Copyright (C) 2010
> + * Texas Instruments Incorporated - http://www.ti.com/
> + *
> + * 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; either version 2 of the License, or
> + * (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program; if not, write to the Free Software
> + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
> + */
> +
> +#include <common.h>
> +#include <asm/io.h>
> +#include <asm/arch/mem.h>
> +#include <asm/arch/mux.h>
> +#include <asm/arch/sys_proto.h>
> +#include <asm/mach-types.h>
> +#include <i2c.h>
> +#include "am3517evm.h"
> +
> +/*
> + * Routine: board_init
> + * Description: Early hardware init.
> + */
> +int board_init(void)
> +{
> +     DECLARE_GLOBAL_DATA_PTR;
> +
> +     gpmc_init(); /* in SRAM or SDRAM, finish GPMC */
> +     /* board id for Linux */
> +     gd->bd->bi_arch_number = MACH_TYPE_OMAP3517EVM;
> +     /* boot param addr */
> +     gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100);
> +
> +     return 0;
> +}
> +
> +/*
> + * Routine: misc_init_r
> + * Description: Init i2c, ethernet, etc... (done here so udelay works)
> + */
> +int misc_init_r(void)
> +{
> +#ifdef CONFIG_DRIVER_OMAP34XX_I2C
> +     i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
> +#endif
> +
> +     dieid_num_r();
> +
> +     return 0;
> +}
> +
> +/*
> + * Routine: set_muxconf_regs
> + * Description: Setting up the configuration Mux registers specific to the
> + *           hardware. Many pins need to be moved from protect to primary
> + *           mode.
> + */
> +void set_muxconf_regs(void)
> +{
> +     MUX_AM3517EVM();
> +}
> diff --git a/board/logicpd/am3517evm/am3517evm.h
> b/board/logicpd/am3517evm/am3517evm.h
> new file mode 100644
> index 0000000..68d746c
> --- /dev/null
> +++ b/board/logicpd/am3517evm/am3517evm.h
> @@ -0,0 +1,405 @@
> +/*
> + * am3517evm.h - Header file for the AM3517 EVM.
> + *
> + * Author: Vaibhav Hiremath <hvaibhav@ti.com>
> + *
> + * Based on ti/evm/evm.h
> + *
> + * Copyright (C) 2010
> + * Texas Instruments Incorporated - http://www.ti.com/
> + *
> + * 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; either version 2 of the License, or
> + * (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program; if not, write to the Free Software
> + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
> + */
> +
> +#ifndef _AM3517EVM_H_
> +#define _AM3517EVM_H_
> +
> +const omap3_sysinfo sysinfo = {
> +     DDR_DISCRETE,
> +     "AM3517EVM Board",
> +     "NAND",
> +};
> +
> +/*
> + * IEN  - Input Enable
> + * IDIS - Input Disable
> + * PTD  - Pull type Down
> + * PTU  - Pull type Up
> + * DIS  - Pull type selection is inactive
> + * EN   - Pull type selection is active
> + * M0   - Mode 0
> + * The commented string gives the final mux configuration for that pin
> + */
> +#define MUX_AM3517EVM() \
> +     /* SDRC */\
> +     MUX_VAL(CP(SDRC_D0),            (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(SDRC_D1),            (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(SDRC_D2),            (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(SDRC_D3),            (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(SDRC_D4),            (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(SDRC_D5),            (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(SDRC_D6),            (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(SDRC_D7),            (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(SDRC_D8),            (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(SDRC_D9),            (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(SDRC_D10),           (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(SDRC_D11),           (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(SDRC_D12),           (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(SDRC_D13),           (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(SDRC_D14),           (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(SDRC_D15),           (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(SDRC_D16),           (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(SDRC_D17),           (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(SDRC_D18),           (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(SDRC_D19),           (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(SDRC_D20),           (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(SDRC_D21),           (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(SDRC_D22),           (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(SDRC_D23),           (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(SDRC_D24),           (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(SDRC_D25),           (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(SDRC_D26),           (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(SDRC_D27),           (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(SDRC_D28),           (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(SDRC_D29),           (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(SDRC_D30),           (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(SDRC_D31),           (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(SDRC_CLK),           (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(SDRC_DQS0),          (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(SDRC_DQS1),          (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(SDRC_DQS2),          (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(SDRC_DQS3),          (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(SDRC_DQS0N),         (IEN  | PTD | EN  | M0)) \
> +     MUX_VAL(CP(SDRC_DQS1N),         (IEN  | PTD | EN  | M0)) \
> +     MUX_VAL(CP(SDRC_DQS2N),         (IEN  | PTD | EN  | M0)) \
> +     MUX_VAL(CP(SDRC_DQS3N),         (IEN  | PTD | EN  | M0)) \
> +     MUX_VAL(CP(SDRC_CKE0),          (M0)) \
> +     MUX_VAL(CP(SDRC_CKE1),          (M0)) \
> +     /*sdrc_strben_dly0*/\
> +     MUX_VAL(CP(STRBEN_DLY0),        (IEN  | PTD | EN  | M0)) \
> +      /*sdrc_strben_dly1*/\
> +     MUX_VAL(CP(STRBEN_DLY1),        (IEN  | PTD | EN  | M0)) \
> +     /* GPMC */\
> +     MUX_VAL(CP(GPMC_A1),            (IDIS | PTU | EN  | M0)) \
> +     MUX_VAL(CP(GPMC_A2),            (IDIS | PTU | EN  | M0)) \
> +     MUX_VAL(CP(GPMC_A3),            (IDIS | PTU | EN  | M0)) \
> +     MUX_VAL(CP(GPMC_A4),            (IDIS | PTU | EN  | M0)) \
> +     MUX_VAL(CP(GPMC_A5),            (IDIS | PTU | EN  | M0)) \
> +     MUX_VAL(CP(GPMC_A6),            (IDIS | PTU | EN  | M0)) \
> +     MUX_VAL(CP(GPMC_A7),            (IDIS | PTU | EN  | M0)) \
> +     MUX_VAL(CP(GPMC_A8),            (IDIS | PTU | EN  | M0)) \
> +     MUX_VAL(CP(GPMC_A9),            (IDIS | PTU | EN  | M0)) \
> +     MUX_VAL(CP(GPMC_A10),           (IDIS | PTU | EN  | M0)) \
> +     MUX_VAL(CP(GPMC_D0),            (IEN  | PTU | EN  | M0)) \
> +     MUX_VAL(CP(GPMC_D1),            (IEN  | PTU | EN  | M0)) \
> +     MUX_VAL(CP(GPMC_D2),            (IEN  | PTU | EN  | M0)) \
> +     MUX_VAL(CP(GPMC_D3),            (IEN  | PTU | EN  | M0)) \
> +     MUX_VAL(CP(GPMC_D4),            (IEN  | PTU | EN  | M0)) \
> +     MUX_VAL(CP(GPMC_D5),            (IEN  | PTU | EN  | M0)) \
> +     MUX_VAL(CP(GPMC_D6),            (IEN  | PTU | EN  | M0)) \
> +     MUX_VAL(CP(GPMC_D7),            (IEN  | PTU | EN  | M0)) \
> +     MUX_VAL(CP(GPMC_D8),            (IEN  | PTU | EN  | M0)) \
> +     MUX_VAL(CP(GPMC_D9),            (IEN  | PTU | EN  | M0)) \
> +     MUX_VAL(CP(GPMC_D10),           (IEN  | PTU | EN  | M0)) \
> +     MUX_VAL(CP(GPMC_D11),           (IEN  | PTU | EN  | M0)) \
> +     MUX_VAL(CP(GPMC_D12),           (IEN  | PTU | EN  | M0)) \
> +     MUX_VAL(CP(GPMC_D13),           (IEN  | PTU | EN  | M0)) \
> +     MUX_VAL(CP(GPMC_D14),           (IEN  | PTU | EN  | M0)) \
> +     MUX_VAL(CP(GPMC_D15),           (IEN  | PTU | EN  | M0)) \
> +     MUX_VAL(CP(GPMC_NCS0),          (IDIS | PTU | EN  | M0)) \
> +     MUX_VAL(CP(GPMC_NCS1),          (IDIS | PTU | EN  | M0)) \
> +     MUX_VAL(CP(GPMC_NCS2),          (IDIS | PTU | EN  | M0)) \
> +     MUX_VAL(CP(GPMC_NCS3),          (IDIS | PTU | EN  | M0)) \
> +     MUX_VAL(CP(GPMC_NCS4),          (IEN  | PTU | EN  | M0)) \
> +     MUX_VAL(CP(GPMC_NCS5),          (IDIS | PTU | EN  | M0)) \
> +     MUX_VAL(CP(GPMC_NCS6),          (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(GPMC_NCS7),          (IEN  | PTU | EN  | M0)) \
> +     MUX_VAL(CP(GPMC_CLK),           (IDIS | PTU | EN  | M0)) \
> +     MUX_VAL(CP(GPMC_NADV_ALE),      (IDIS | PTD | DIS | M0)) \
> +     MUX_VAL(CP(GPMC_NOE),           (IDIS | PTD | DIS | M0)) \
> +     MUX_VAL(CP(GPMC_NWE),           (IDIS | PTD | DIS | M0)) \
> +     MUX_VAL(CP(GPMC_NBE0_CLE),      (IDIS | PTU | EN  | M0)) \
> +     MUX_VAL(CP(GPMC_NBE1),          (IEN  | PTU | EN  | M0)) \
> +     MUX_VAL(CP(GPMC_NWP),           (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(GPMC_WAIT0),         (IEN  | PTU | EN  | M0)) \
> +     MUX_VAL(CP(GPMC_WAIT1),         (IEN  | PTU | EN  | M0)) \
> +     MUX_VAL(CP(GPMC_WAIT2),         (IEN  | PTU | EN  | M4)) /*GPIO_64*/\
> +                                                      /* - ETH_nRESET*/\
> +     MUX_VAL(CP(GPMC_WAIT3),         (IEN  | PTU | EN  | M0)) \
> +     /* DSS */\
> +     MUX_VAL(CP(DSS_PCLK),           (IDIS | PTD | DIS | M0)) \
> +     MUX_VAL(CP(DSS_HSYNC),          (IDIS | PTD | DIS | M0)) \
> +     MUX_VAL(CP(DSS_VSYNC),          (IDIS | PTD | DIS | M0)) \
> +     MUX_VAL(CP(DSS_ACBIAS),         (IDIS | PTD | DIS | M0)) \
> +     MUX_VAL(CP(DSS_DATA0),          (IDIS | PTD | DIS | M0)) \
> +     MUX_VAL(CP(DSS_DATA1),          (IDIS | PTD | DIS | M0)) \
> +     MUX_VAL(CP(DSS_DATA2),          (IDIS | PTD | DIS | M0)) \
> +     MUX_VAL(CP(DSS_DATA3),          (IDIS | PTD | DIS | M0)) \
> +     MUX_VAL(CP(DSS_DATA4),          (IDIS | PTD | DIS | M0)) \
> +     MUX_VAL(CP(DSS_DATA5),          (IDIS | PTD | DIS | M0)) \
> +     MUX_VAL(CP(DSS_DATA6),          (IDIS | PTD | DIS | M0)) \
> +     MUX_VAL(CP(DSS_DATA7),          (IDIS | PTD | DIS | M0)) \
> +     MUX_VAL(CP(DSS_DATA8),          (IDIS | PTD | DIS | M0)) \
> +     MUX_VAL(CP(DSS_DATA9),          (IDIS | PTD | DIS | M0)) \
> +     MUX_VAL(CP(DSS_DATA10),         (IDIS | PTD | DIS | M0)) \
> +     MUX_VAL(CP(DSS_DATA11),         (IDIS | PTD | DIS | M0)) \
> +     MUX_VAL(CP(DSS_DATA12),         (IDIS | PTD | DIS | M0)) \
> +     MUX_VAL(CP(DSS_DATA13),         (IDIS | PTD | DIS | M0)) \
> +     MUX_VAL(CP(DSS_DATA14),         (IDIS | PTD | DIS | M0)) \
> +     MUX_VAL(CP(DSS_DATA15),         (IDIS | PTD | DIS | M0)) \
> +     MUX_VAL(CP(DSS_DATA16),         (IDIS | PTD | DIS | M0)) \
> +     MUX_VAL(CP(DSS_DATA17),         (IDIS | PTD | DIS | M0)) \
> +     MUX_VAL(CP(DSS_DATA18),         (IDIS | PTD | DIS | M0)) \
> +     MUX_VAL(CP(DSS_DATA19),         (IDIS | PTD | DIS | M0)) \
> +     MUX_VAL(CP(DSS_DATA20),         (IDIS | PTD | DIS | M0)) \
> +     MUX_VAL(CP(DSS_DATA21),         (IDIS | PTD | DIS | M0)) \
> +     MUX_VAL(CP(DSS_DATA22),         (IDIS | PTD | DIS | M0)) \
> +     MUX_VAL(CP(DSS_DATA23),         (IDIS | PTD | DIS | M0)) \
> +     /* CAMERA */\
> +     MUX_VAL(CP(CAM_HS),             (IEN  | PTU | EN  | M0)) \
> +     MUX_VAL(CP(CAM_VS),             (IEN  | PTU | EN  | M0)) \
> +     MUX_VAL(CP(CAM_XCLKA),          (IDIS | PTD | DIS | M0)) \
> +     MUX_VAL(CP(CAM_PCLK),           (IEN  | PTU | EN  | M0)) \
> +     MUX_VAL(CP(CAM_FLD),            (IDIS | PTD | DIS | M4)) /*GPIO_98*/\
> +                                                      /* - CAM_RESET*/\
> +     MUX_VAL(CP(CAM_D0),             (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(CAM_D1),             (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(CAM_D2),             (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(CAM_D3),             (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(CAM_D4),             (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(CAM_D5),             (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(CAM_D6),             (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(CAM_D7),             (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(CAM_D8),             (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(CAM_D9),             (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(CAM_D10),            (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(CAM_D11),            (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(CAM_XCLKB),          (IDIS | PTD | DIS | M0)) \
> +     MUX_VAL(CP(CAM_WEN),            (IEN  | PTD | DIS | M4)) /*GPIO_167*/\
> +     MUX_VAL(CP(CAM_STROBE),         (IDIS | PTD | DIS | M0)) \
> +     MUX_VAL(CP(CSI2_DX0),           (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(CSI2_DY0),           (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(CSI2_DX1),           (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(CSI2_DY1),           (IEN  | PTD | DIS | M0)) \
> +     /* MMC */\
> +     MUX_VAL(CP(MMC1_CLK),           (IEN  | PTU | EN  | M0)) \
> +     MUX_VAL(CP(MMC1_CMD),           (IEN  | PTU | DIS | M0)) \
> +     MUX_VAL(CP(MMC1_DAT0),          (IEN  | PTU | DIS | M0)) \
> +     MUX_VAL(CP(MMC1_DAT1),          (IEN  | PTU | DIS | M0)) \
> +     MUX_VAL(CP(MMC1_DAT2),          (IEN  | PTU | DIS | M0)) \
> +     MUX_VAL(CP(MMC1_DAT3),          (IEN  | PTU | DIS | M0)) \
> +     /* WriteProtect */\
> +     MUX_VAL(CP(MMC1_DAT4),          (IEN  | PTU | EN  | M4)) \
> +     MUX_VAL(CP(MMC1_DAT5),          (IEN  | PTU | EN  | M4)) /*CardDetect*/\
> +     MUX_VAL(CP(MMC1_DAT6),          (IEN  | PTU | EN  | M4)) \
> +     MUX_VAL(CP(MMC1_DAT7),          (IEN  | PTU | EN  | M4)) \
> +     \
> +     MUX_VAL(CP(MMC2_CLK),           (IEN  | PTD | EN  | M0)) \
> +     MUX_VAL(CP(MMC2_CMD),           (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(MMC2_DAT0),          (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(MMC2_DAT1),          (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(MMC2_DAT2),          (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(MMC2_DAT3),          (IEN  | PTD | DIS | M0)) \
> +     /* McBSP */\
> +     MUX_VAL(CP(MCBSP_CLKS),         (IEN  | PTU | DIS | M0)) \
> +     MUX_VAL(CP(MCBSP1_CLKR),        (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(MCBSP1_FSR),         (IDIS | PTU | EN  | M0)) \
> +     MUX_VAL(CP(MCBSP1_DX),          (IDIS | PTD | DIS | M0)) \
> +     MUX_VAL(CP(MCBSP1_DR),          (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(MCBSP1_FSX),         (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(MCBSP1_CLKX),        (IEN  | PTD | DIS | M0)) \
> +     \
> +     MUX_VAL(CP(MCBSP2_FSX),         (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(MCBSP2_CLKX),        (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(MCBSP2_DR),          (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(MCBSP2_DX),          (IDIS | PTD | DIS | M0)) \
> +     \
> +     MUX_VAL(CP(MCBSP3_DX),          (IDIS | PTD | DIS | M0)) \
> +     MUX_VAL(CP(MCBSP3_DR),          (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(MCBSP3_CLKX),        (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(MCBSP3_FSX),         (IEN  | PTD | DIS | M0)) \
> +     \
> +     MUX_VAL(CP(MCBSP4_CLKX),        (IDIS | PTD | DIS | M4)) /*GPIO_152*/\
> +                                                      /* - LCD_INI*/\
> +     MUX_VAL(CP(MCBSP4_DR),          (IDIS | PTD | DIS | M4)) /*GPIO_153*/\
> +                                                      /* - LCD_ENVDD */\
> +     MUX_VAL(CP(MCBSP4_DX),          (IDIS | PTD | DIS | M4)) /*GPIO_154*/\
> +                                                      /* - LCD_QVGA/nVGA */\
> +     MUX_VAL(CP(MCBSP4_FSX),         (IDIS | PTD | DIS | M4)) /*GPIO_155*/\
> +                                                      /* - LCD_RESB */\
> +     /* UART */\
> +     MUX_VAL(CP(UART1_TX),           (IDIS | PTD | DIS | M0)) \
> +     MUX_VAL(CP(UART1_RTS),          (IDIS | PTD | DIS | M0)) \
> +     MUX_VAL(CP(UART1_CTS),          (IEN  | PTU | DIS | M0)) \
> +     \
> +     MUX_VAL(CP(UART1_RX),           (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(UART2_CTS),          (IEN  | PTU | EN  | M0)) \
> +     MUX_VAL(CP(UART2_RTS),          (IDIS | PTD | DIS | M0)) \
> +     MUX_VAL(CP(UART2_TX),           (IDIS | PTD | DIS | M0)) \
> +     MUX_VAL(CP(UART2_RX),           (IEN  | PTD | DIS | M0)) \
> +     \
> +     MUX_VAL(CP(UART3_CTS_RCTX),     (IEN  | PTU | DIS | M0)) \
> +     MUX_VAL(CP(UART3_RTS_SD),       (IDIS | PTD | DIS | M0)) \
> +     MUX_VAL(CP(UART3_RX_IRRX),      (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(UART3_TX_IRTX),      (IDIS | PTD | DIS | M0)) \
> +     /* I2C */\
> +     MUX_VAL(CP(I2C1_SCL),           (IEN  | PTU | EN  | M0)) \
> +     MUX_VAL(CP(I2C1_SDA),           (IEN  | PTU | EN  | M0)) \
> +     MUX_VAL(CP(I2C2_SCL),           (IEN  | PTU | EN  | M0)) \
> +     MUX_VAL(CP(I2C2_SDA),           (IEN  | PTU | EN  | M0)) \
> +     MUX_VAL(CP(I2C3_SCL),           (IEN  | PTU | EN  | M0)) \
> +     MUX_VAL(CP(I2C3_SDA),           (IEN  | PTU | EN  | M0)) \
> +     MUX_VAL(CP(I2C4_SCL),           (IEN  | PTU | EN  | M0)) \
> +     MUX_VAL(CP(I2C4_SDA),           (IEN  | PTU | EN  | M0)) \
> +     /* McSPI */\
> +     MUX_VAL(CP(MCSPI1_CLK),         (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(MCSPI1_SIMO),        (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(MCSPI1_SOMI),        (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(MCSPI1_CS0),         (IEN  | PTD | EN  | M0)) \
> +     MUX_VAL(CP(MCSPI1_CS1),         (IEN  | PTD | EN  | M4)) /*GPIO_175*/\
> +     MUX_VAL(CP(MCSPI1_CS2),         (IEN  | PTU | DIS | M4)) /*GPIO_176*/\
> +                                                      /* - LAN_INTR*/\
> +     MUX_VAL(CP(MCSPI1_CS3),         (IEN  | PTD | EN  | M0)) \
> +     \
> +     MUX_VAL(CP(MCSPI2_CLK),         (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(MCSPI2_SIMO),        (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(MCSPI2_SOMI),        (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(MCSPI2_CS0),         (IEN  | PTD | EN  | M4)) \
> +     MUX_VAL(CP(MCSPI2_CS1),         (IEN  | PTD | EN  | M4)) \
> +     /* CCDC */\
> +     MUX_VAL(CP(CCDC_PCLK),          (IEN  | PTU | EN  | M0)) \
> +     MUX_VAL(CP(CCDC_FIELD),         (IEN  | PTD | DIS | M1)) \
> +     MUX_VAL(CP(CCDC_HD),            (IEN  | PTU | EN  | M0)) \
> +     MUX_VAL(CP(CCDC_VD),            (IEN  | PTU | EN  | M0)) \
> +     MUX_VAL(CP(CCDC_WEN),           (IEN  | PTD | DIS | M1)) \
> +     MUX_VAL(CP(CCDC_DATA0),         (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(CCDC_DATA1),         (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(CCDC_DATA2),         (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(CCDC_DATA3),         (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(CCDC_DATA4),         (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(CCDC_DATA5),         (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(CCDC_DATA6),         (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(CCDC_DATA7),         (IEN  | PTD | DIS | M0)) \
> +     /* RMII */\
> +     MUX_VAL(CP(RMII_MDIO_DATA),     (IEN  |  M0)) \
> +     MUX_VAL(CP(RMII_MDIO_CLK),      (M0)) \
> +     MUX_VAL(CP(RMII_RXD0)   ,       (IEN  | PTD | M0)) \
> +     MUX_VAL(CP(RMII_RXD1),          (IEN  | PTD | M0)) \
> +     MUX_VAL(CP(RMII_CRS_DV),        (IEN  | PTD | M0)) \
> +     MUX_VAL(CP(RMII_RXER),          (PTD | M0)) \
> +     MUX_VAL(CP(RMII_TXD0),          (PTD | M0)) \
> +     MUX_VAL(CP(RMII_TXD1),          (PTD | M0)) \
> +     MUX_VAL(CP(RMII_TXEN),          (PTD | M0)) \
> +     MUX_VAL(CP(RMII_50MHZ_CLK),     (IEN  | PTD | EN  | M0)) \
> +     /* HECC */\
> +     MUX_VAL(CP(HECC1_TXD),          (IEN  | PTU | EN  | M0)) \
> +     MUX_VAL(CP(HECC1_RXD),          (IEN  | PTU | EN  | M0)) \
> +     /* HSUSB */\
> +     MUX_VAL(CP(HSUSB0_CLK),         (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(HSUSB0_STP),         (IDIS | PTU | EN  | M0)) \
> +     MUX_VAL(CP(HSUSB0_DIR),         (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(HSUSB0_NXT),         (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(HSUSB0_DATA0),       (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(HSUSB0_DATA1),       (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(HSUSB0_DATA2),       (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(HSUSB0_DATA3),       (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(HSUSB0_DATA4),       (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(HSUSB0_DATA5),       (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(HSUSB0_DATA6),       (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(HSUSB0_DATA7),       (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(USB0_DRVBUS),        (IEN  | PTD | EN  | M0)) \
> +     /* HDQ */\
> +     MUX_VAL(CP(HDQ_SIO),            (IEN  | PTU | EN  | M0)) \
> +     /* Control and debug */\
> +     MUX_VAL(CP(SYS_32K),            (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(SYS_CLKREQ),         (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(SYS_NIRQ),           (IEN  | PTU | EN  | M0)) \
> +     /*SYS_nRESWARM */\
> +     MUX_VAL(CP(SYS_NRESWARM),       (IDIS | PTU | DIS | M4)) \
> +                                                     /* - GPIO30 */\
> +     MUX_VAL(CP(SYS_BOOT0),          (IEN  | PTD | DIS | M4)) /*GPIO_2*/\
> +                                                      /* - PEN_IRQ */\
> +     MUX_VAL(CP(SYS_BOOT1),          (IEN  | PTD | DIS | M4)) /*GPIO_3 */\
> +     MUX_VAL(CP(SYS_BOOT2),          (IEN  | PTD | DIS | M4)) /*GPIO_4*/\
> +     MUX_VAL(CP(SYS_BOOT3),          (IEN  | PTD | DIS | M4)) /*GPIO_5*/\
> +     MUX_VAL(CP(SYS_BOOT4),          (IEN  | PTD | DIS | M4)) /*GPIO_6*/\
> +     MUX_VAL(CP(SYS_BOOT5),          (IEN  | PTD | DIS | M4)) /*GPIO_7*/\
> +     MUX_VAL(CP(SYS_BOOT6),          (IDIS | PTD | DIS | M4)) /*GPIO_8*/\
> +                                                      /* - VIO_1V8*/\
> +     MUX_VAL(CP(SYS_BOOT7),          (IEN  | PTD | EN  | M0)) \
> +     MUX_VAL(CP(SYS_BOOT8),          (IEN  | PTD | EN  | M0)) \
> +     \
> +     MUX_VAL(CP(SYS_OFF_MODE),       (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(SYS_CLKOUT1),        (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(SYS_CLKOUT2),        (IEN  | PTU | EN  | M0)) \
> +     /* JTAG */\
> +     MUX_VAL(CP(JTAG_nTRST),         (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(JTAG_TCK),           (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(JTAG_TMS),           (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(JTAG_TDI),           (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(JTAG_EMU0),          (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(JTAG_EMU1),          (IEN  | PTD | DIS | M0)) \
> +     /* ETK (ES2 onwards) */\
> +     MUX_VAL(CP(ETK_CLK_ES2),        (IDIS | PTU | EN  | M0)) \
> +     MUX_VAL(CP(ETK_CTL_ES2),        (IDIS | PTD | DIS | M0)) \
> +     MUX_VAL(CP(ETK_D0_ES2),         (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(ETK_D1_ES2),         (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(ETK_D2_ES2),         (IEN  | PTD | EN  | M0)) \
> +     MUX_VAL(CP(ETK_D3_ES2),         (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(ETK_D4_ES2),         (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(ETK_D5_ES2),         (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(ETK_D6_ES2),         (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(ETK_D7_ES2),         (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(ETK_D8_ES2),         (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(ETK_D9_ES2),         (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(ETK_D10_ES2),        (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(ETK_D11_ES2),        (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(ETK_D12_ES2),        (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(ETK_D13_ES2),        (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(ETK_D14_ES2),        (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(ETK_D15_ES2),        (IEN  | PTD | DIS | M0)) \
> +     /* Die to Die */\
> +     MUX_VAL(CP(D2D_MCAD34),         (IEN  | PTD | EN  | M0)) \
> +     MUX_VAL(CP(D2D_MCAD35),         (IEN  | PTD | EN  | M0)) \
> +     MUX_VAL(CP(D2D_MCAD36),         (IEN  | PTD | EN  | M0)) \
> +     MUX_VAL(CP(D2D_CLK26MI),        (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(D2D_NRESPWRON),      (IEN  | PTD | EN  | M0)) \
> +     MUX_VAL(CP(D2D_NRESWARM),       (IEN  | PTU | EN  | M0)) \
> +     MUX_VAL(CP(D2D_ARM9NIRQ),       (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(D2D_UMA2P6FIQ),      (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(D2D_SPINT),          (IEN  | PTD | EN  | M0)) \
> +     MUX_VAL(CP(D2D_FRINT),          (IEN  | PTD | EN  | M0)) \
> +     MUX_VAL(CP(D2D_DMAREQ0),        (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(D2D_DMAREQ1),        (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(D2D_DMAREQ2),        (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(D2D_DMAREQ3),        (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(D2D_N3GTRST),        (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(D2D_N3GTDI),         (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(D2D_N3GTDO),         (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(D2D_N3GTMS),         (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(D2D_N3GTCK),         (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(D2D_N3GRTCK),        (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(D2D_MSTDBY),         (IEN  | PTU | EN  | M0)) \
> +     MUX_VAL(CP(D2D_SWAKEUP),        (IEN  | PTD | EN  | M0)) \
> +     MUX_VAL(CP(D2D_IDLEREQ),        (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(D2D_IDLEACK),        (IEN  | PTU | EN  | M0)) \
> +     MUX_VAL(CP(D2D_MWRITE),         (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(D2D_SWRITE),         (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(D2D_MREAD),          (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(D2D_SREAD),          (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(D2D_MBUSFLAG),       (IEN  | PTD | DIS | M0)) \
> +     MUX_VAL(CP(D2D_SBUSFLAG),       (IEN  | PTD | DIS | M0)) \
> +
> +#endif
> diff --git a/board/logicpd/am3517evm/config.mk
> b/board/logicpd/am3517evm/config.mk
> new file mode 100644
> index 0000000..f7a35ce
> --- /dev/null
> +++ b/board/logicpd/am3517evm/config.mk
> @@ -0,0 +1,30 @@
> +#
> +# Author: Vaibhav Hiremath <hvaibhav@ti.com>
> +#
> +# Based on ti/evm/config.mk
> +#
> +# Copyright (C) 2010
> +# Texas Instruments Incorporated - http://www.ti.com/
> +#
> +# 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; either version 2 of the License, or
> +# (at your option) any later version.
> +#
> +# This program is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program; if not, write to the Free Software
> +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
> +#
> +# Physical Address:
> +# 8000'0000 (bank0)
> +# A000/0000 (bank1)
> +# Linux-Kernel is expected to be at 8000'8000, entry 8000'8000
> +# (mem base + reserved)
> +
> +# For use with external or internal boots.
> +TEXT_BASE = 0x80e80000
> diff --git a/include/configs/am3517_evm.h b/include/configs/am3517_evm.h
> new file mode 100644
> index 0000000..63f853a
> --- /dev/null
> +++ b/include/configs/am3517_evm.h
> @@ -0,0 +1,296 @@
> +/*
> + * am3517_evm.h - Default configuration for AM3517 EVM board.
> + *
> + * Author: Vaibhav Hiremath <hvaibhav@ti.com>
> + *
> + * Based on omap3_evm_config.h
> + *
> + * 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; either version 2 of the License, or
> + * (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program; if not, write to the Free Software
> + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
> + */
> +
> +#ifndef __CONFIG_H
> +#define __CONFIG_H
> +
> +/*
> + * High Level Configuration Options
> + */
> +#define CONFIG_ARMCORTEXA8   1       /* This is an ARM V7 CPU core */
> +#define CONFIG_OMAP          1       /* in a TI OMAP core */
> +#define CONFIG_OMAP34XX              1       /* which is a 34XX */
> +#define CONFIG_OMAP3_AM3517EVM       1       /* working with AM3517EVM */
> +
> +#define CONFIG_EMIF4         1       /* The chip has EMIF4 controller */
> +
> +#include <asm/arch/cpu.h>            /* get chip and board defs */
> +#include <asm/arch/omap3.h>
> +
> +/*
> + * Display CPU and Board information
> + */
> +#define CONFIG_DISPLAY_CPUINFO               1
> +#define CONFIG_DISPLAY_BOARDINFO     1
> +
> +/* Clock Defines */
> +#define V_OSCK                       26000000        /* Clock output from T2 */
> +#define V_SCLK                       (V_OSCK >> 1)
> +
> +#undef CONFIG_USE_IRQ                                /* no support for IRQs */
> +#define CONFIG_MISC_INIT_R
> +
> +#define CONFIG_CMDLINE_TAG           1       /* enable passing of ATAGs */
> +#define CONFIG_SETUP_MEMORY_TAGS     1
> +#define CONFIG_INITRD_TAG            1
> +#define CONFIG_REVISION_TAG          1
> +
> +/*
> + * Size of malloc() pool
> + */
> +#define CONFIG_ENV_SIZE                      (128 << 10)     /* 128 KiB sector */
> +#define CONFIG_SYS_MALLOC_LEN                (CONFIG_ENV_SIZE + (128 << 10))
> +#define CONFIG_SYS_GBL_DATA_SIZE     128     /* bytes reserved for */
> +                                             /* initial data */
> +/*
> + * DDR related
> + */
> +#define CONFIG_OMAP3_MICRON_DDR              1       /* Micron DDR */
> +#define CONFIG_SYS_CS0_SIZE          (256 * 1024 * 1024)
> +
> +/*
> + * Hardware drivers
> + */
> +
> +/*
> + * NS16550 Configuration
> + */
> +#define V_NS16550_CLK                        48000000        /* 48MHz (APLL96/2) */
> +
> +#define CONFIG_SYS_NS16550
> +#define CONFIG_SYS_NS16550_SERIAL
> +#define CONFIG_SYS_NS16550_REG_SIZE  (-4)
> +#define CONFIG_SYS_NS16550_CLK               V_NS16550_CLK
> +
> +/*
> + * select serial console configuration
> + */
> +#define CONFIG_CONS_INDEX            3
> +#define CONFIG_SYS_NS16550_COM3              OMAP34XX_UART3
> +#define CONFIG_SERIAL3                       3       /* UART3 on AM3517 EVM */
> +
> +/* allow to overwrite serial and ethaddr */
> +#define CONFIG_ENV_OVERWRITE
> +#define CONFIG_BAUDRATE                      115200
> +#define CONFIG_SYS_BAUDRATE_TABLE    {4800, 9600, 19200, 38400, 57600,\
> +                                     115200}
> +#define CONFIG_MMC                   1
> +#define CONFIG_OMAP3_MMC             1
> +#define CONFIG_DOS_PARTITION         1
> +
> +/* commands to include */
> +#include <config_cmd_default.h>
> +
> +#define CONFIG_CMD_EXT2              /* EXT2 Support                 */
> +#define CONFIG_CMD_FAT               /* FAT support                  */
> +#define CONFIG_CMD_JFFS2     /* JFFS2 Support                */
> +
> +#define CONFIG_CMD_I2C               /* I2C serial bus support       */
> +#define CONFIG_CMD_MMC               /* MMC support                  */
> +#define CONFIG_CMD_NAND              /* NAND support                 */
> +#define CONFIG_CMD_DHCP
> +#define CONFIG_CMD_PING
> +
> +#undef CONFIG_CMD_FLASH              /* flinfo, erase, protect       */
> +#undef CONFIG_CMD_FPGA               /* FPGA configuration Support   */
> +#undef CONFIG_CMD_IMI                /* iminfo                       */
> +#undef CONFIG_CMD_IMLS               /* List all found images        */
> +
> +#define CONFIG_SYS_NO_FLASH
> +#define CONFIG_HARD_I2C                      1
> +#define CONFIG_SYS_I2C_SPEED         100000
> +#define CONFIG_SYS_I2C_SLAVE         1
> +#define CONFIG_SYS_I2C_BUS           0
> +#define CONFIG_SYS_I2C_BUS_SELECT    1
> +#define CONFIG_DRIVER_OMAP34XX_I2C   1
> +
> +#undef CONFIG_CMD_NET
> +/*
> + * Board NAND Info.
> + */
> +#define CONFIG_SYS_NAND_ADDR         NAND_BASE       /* physical address */
> +                                                     /* to access nand */
> +#define CONFIG_SYS_NAND_BASE         NAND_BASE       /* physical address */
> +                                                     /* to access */
> +                                                     /* nand at CS0 */
> +
> +#define CONFIG_SYS_MAX_NAND_DEVICE   1               /* Max number of */
> +                                                     /* NAND devices */
> +#define CONFIG_SYS_64BIT_VSPRINTF            /* needed for nand_util.c */
> +
> +#define CONFIG_JFFS2_NAND
> +/* nand device jffs2 lives on */
> +#define CONFIG_JFFS2_DEV             "nand0"
> +/* start of jffs2 partition */
> +#define CONFIG_JFFS2_PART_OFFSET     0x680000
> +#define CONFIG_JFFS2_PART_SIZE               0xf980000       /* sz of jffs2 part */
> +
> +/* Environment information */
> +#define CONFIG_BOOTDELAY     10
> +
> +#define CONFIG_BOOTFILE              uImage
> +
> +#define CONFIG_EXTRA_ENV_SETTINGS \
> +     "loadaddr=0x82000000\0" \
> +     "console=ttyS2,115200n8\0" \
> +     "mmcargs=setenv bootargs console=${console} " \
> +             "root=/dev/mmcblk0p2 rw " \
> +             "rootfstype=ext3 rootwait\0" \
> +     "nandargs=setenv bootargs console=${console} " \
> +             "root=/dev/mtdblock4 rw " \
> +             "rootfstype=jffs2\0" \
> +     "loadbootscript=fatload mmc 0 ${loadaddr} boot.scr\0" \
> +     "bootscript=echo Running bootscript from mmc ...; " \
> +             "source ${loadaddr}\0" \
> +     "loaduimage=fatload mmc 0 ${loadaddr} uImage\0" \
> +     "mmcboot=echo Booting from mmc ...; " \
> +             "run mmcargs; " \
> +             "bootm ${loadaddr}\0" \
> +     "nandboot=echo Booting from nand ...; " \
> +             "run nandargs; " \
> +             "nand read ${loadaddr} 280000 400000; " \
> +             "bootm ${loadaddr}\0" \
> +
> +#define CONFIG_BOOTCOMMAND \
> +     "if mmc init; then " \
> +             "if run loadbootscript; then " \
> +                     "run bootscript; " \
> +             "else " \
> +                     "if run loaduimage; then " \
> +                             "run mmcboot; " \
> +                     "else run nandboot; " \
> +                     "fi; " \
> +             "fi; " \
> +     "else run nandboot; fi"
> +
> +#define CONFIG_AUTO_COMPLETE 1
> +/*
> + * Miscellaneous configurable options
> + */
> +#define V_PROMPT                     "AM3517_EVM # "
> +
> +#define CONFIG_SYS_LONGHELP          /* undef to save memory */
> +#define CONFIG_SYS_HUSH_PARSER               /* use "hush" command parser */
> +#define CONFIG_SYS_PROMPT_HUSH_PS2   "> "
> +#define CONFIG_SYS_PROMPT            V_PROMPT
> +#define CONFIG_SYS_CBSIZE            512     /* Console I/O Buffer Size */
> +/* Print Buffer Size */
> +#define CONFIG_SYS_PBSIZE            (CONFIG_SYS_CBSIZE + \
> +                                     sizeof(CONFIG_SYS_PROMPT) + 16)
> +#define CONFIG_SYS_MAXARGS           32      /* max number of command */
> +                                             /* args */
> +/* Boot Argument Buffer Size */
> +#define CONFIG_SYS_BARGSIZE          (CONFIG_SYS_CBSIZE)
> +/* memtest works on */
> +#define CONFIG_SYS_MEMTEST_START     (OMAP34XX_SDRC_CS0)
> +#define CONFIG_SYS_MEMTEST_END               (OMAP34XX_SDRC_CS0 + \
> +                                     0x01F00000) /* 31MB */
> +
> +#define CONFIG_SYS_LOAD_ADDR         (OMAP34XX_SDRC_CS0) /* default load */
> +                                                             /* address */
> +
> +/*
> + * AM3517 has 12 GP timers, they can be driven by the system clock
> + * (12/13/16.8/19.2/38.4MHz) or by 32KHz clock. We use 13MHz (V_SCLK).
> + * This rate is divided by a local divisor.
> + */
> +#define CONFIG_SYS_TIMERBASE         OMAP34XX_GPT2
> +#define CONFIG_SYS_PTV                       2       /* Divisor: 2^(PTV+1) => 8 */
> +#define CONFIG_SYS_HZ                        1000
> +
> +/*-----------------------------------------------------------------------
> + * Stack sizes
> + *
> + * The stack sizes are set up in start.S using the settings below
> + */
> +#define CONFIG_STACKSIZE     (128 << 10)     /* regular stack 128 KiB */
> +#ifdef CONFIG_USE_IRQ
> +#define CONFIG_STACKSIZE_IRQ (4 << 10)       /* IRQ stack 4 KiB */
> +#define CONFIG_STACKSIZE_FIQ (4 << 10)       /* FIQ stack 4 KiB */
> +#endif
> +
> +/*-----------------------------------------------------------------------
> + * Physical Memory Map
> + */
> +#define CONFIG_NR_DRAM_BANKS 2       /* CS1 may or may not be populated */
> +#define PHYS_SDRAM_1         OMAP34XX_SDRC_CS0
> +#define PHYS_SDRAM_1_SIZE    (32 << 20)      /*@least 32 MiB */
> +#define PHYS_SDRAM_2         OMAP34XX_SDRC_CS1
> +
> +/* SDRAM Bank Allocation method */
> +#define SDRC_R_B_C           1
> +
> +/*-----------------------------------------------------------------------
> + * FLASH and environment organization
> + */
> +
> +/* **** PISMO SUPPORT *** */
> +
> +/* Configure the PISMO */
> +#define PISMO1_NAND_SIZE             GPMC_SIZE_128M
> +#define PISMO1_ONEN_SIZE             GPMC_SIZE_128M
> +
> +#define CONFIG_SYS_MAX_FLASH_SECT    520     /* max number of sectors */
> +                                             /* on one chip */
> +#define CONFIG_SYS_MAX_FLASH_BANKS   2       /* max number of flash banks */
> +#define CONFIG_SYS_MONITOR_LEN               (256 << 10)     /* Reserve 2 sectors
> */
> +
> +#define CONFIG_SYS_FLASH_BASE                boot_flash_base
> +
> +/* Monitor at start of flash */
> +#define CONFIG_SYS_MONITOR_BASE              CONFIG_SYS_FLASH_BASE
> +
> +#define CONFIG_NAND_OMAP_GPMC
> +#define GPMC_NAND_ECC_LP_x16_LAYOUT  1
> +#define CONFIG_ENV_IS_IN_NAND                1
> +#define SMNAND_ENV_OFFSET            0x260000 /* environment starts here */
> +
> +#define CONFIG_SYS_ENV_SECT_SIZE     boot_flash_sec
> +#define CONFIG_ENV_OFFSET            boot_flash_off
> +#define CONFIG_ENV_ADDR                      boot_flash_env_addr
> +
> +/*-----------------------------------------------------------------------
> + * CFI FLASH driver setup
> + */
> +/* timeout values are in ticks */
> +#define CONFIG_SYS_FLASH_ERASE_TOUT  (100 * CONFIG_SYS_HZ)
> +#define CONFIG_SYS_FLASH_WRITE_TOUT  (100 * CONFIG_SYS_HZ)
> +
> +/* Flash banks JFFS2 should use */
> +#define CONFIG_SYS_MAX_MTD_BANKS     (CONFIG_SYS_MAX_FLASH_BANKS + \
> +                                     CONFIG_SYS_MAX_NAND_DEVICE)
> +#define CONFIG_SYS_JFFS2_MEM_NAND
> +/* use flash_info[2] */
> +#define CONFIG_SYS_JFFS2_FIRST_BANK  CONFIG_SYS_MAX_FLASH_BANKS
> +#define CONFIG_SYS_JFFS2_NUM_BANKS   1
> +
> +#ifndef __ASSEMBLY__
> +extern unsigned int boot_flash_base;
> +extern volatile unsigned int boot_flash_env_addr;
> +extern unsigned int boot_flash_off;
> +extern unsigned int boot_flash_sec;
> +extern unsigned int boot_flash_type;
> +#endif
> +
> +#endif /* __CONFIG_H */
> --
> 1.6.2.4

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [U-Boot] [PATCH-V5] OMAP3EVM: Added NAND support
  2010-05-11  4:59   ` Hiremath, Vaibhav
@ 2010-05-11  8:59     ` Wolfgang Denk
  2010-05-11  9:01       ` Hiremath, Vaibhav
  2010-05-11 20:11       ` Scott Wood
  0 siblings, 2 replies; 263+ messages in thread
From: Wolfgang Denk @ 2010-05-11  8:59 UTC (permalink / raw)
  To: u-boot

Dear "Hiremath, Vaibhav",

In message <19F8576C6E063C45BE387C64729E7394044E404A8A@dbde02.ent.ti.com> you wrote:
>
> > Subject: [PATCH-V5] OMAP3EVM: Added NAND support
> > 
> > From: Vaibhav Hiremath <hvaibhav@ti.com>
> > 
> > The EVMS have been shipping with NAND (instead of OneNAND) as default.
> > So, this patch sets NAND as default.
> > 
> > To choose OneNAND, define CMD_ONENAND instead of CMD_NAND in the
> > config file omap3_evm.h,
> > 
> > Changes From V4 :-
> > 	- Removed #undef ONENAND line (comment from Denk)
> > Changes from V3 :-
> > 	- Refreshed against latest u-boot/master
> > Changes from V2 :-
> > 	- Added undef statement for CMD_ONENAND.
> > 
> [Hiremath, Vaibhav] Denk,
>
> If we do not have any further comments, can we merge these patches?

The patches you listed are either ARM related and as such to be
handdled by the ARM custodian, Tom, and/or NAND related ans as such to
be addressed by the NAND custodian, Scott.


I just wait for their pull requests.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"The glory of creation is in its infinite diversity." "And in the way
our differences combine to create meaning and beauty."
	-- Dr. Miranda Jones and Spock, "Is There in Truth No Beauty?",
	   stardate 5630.8

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [U-Boot] [PATCH-V5] OMAP3EVM: Added NAND support
  2010-05-11  8:59     ` Wolfgang Denk
@ 2010-05-11  9:01       ` Hiremath, Vaibhav
  2010-05-11 20:11       ` Scott Wood
  1 sibling, 0 replies; 263+ messages in thread
From: Hiremath, Vaibhav @ 2010-05-11  9:01 UTC (permalink / raw)
  To: u-boot


> -----Original Message-----
> From: Wolfgang Denk [mailto:wd at denx.de]
> Sent: Tuesday, May 11, 2010 2:29 PM
> To: Hiremath, Vaibhav
> Cc: u-boot at lists.denx.de; tom at bumblecow.com; Paulraj, Sandeep; Scott Wood
> Subject: Re: [PATCH-V5] OMAP3EVM: Added NAND support
> 
> Dear "Hiremath, Vaibhav",
> 
> In message <19F8576C6E063C45BE387C64729E7394044E404A8A@dbde02.ent.ti.com>
> you wrote:
> >
> > > Subject: [PATCH-V5] OMAP3EVM: Added NAND support
> > >
> > > From: Vaibhav Hiremath <hvaibhav@ti.com>
> > >
> > > The EVMS have been shipping with NAND (instead of OneNAND) as default.
> > > So, this patch sets NAND as default.
> > >
> > > To choose OneNAND, define CMD_ONENAND instead of CMD_NAND in the
> > > config file omap3_evm.h,
> > >
> > > Changes From V4 :-
> > > 	- Removed #undef ONENAND line (comment from Denk)
> > > Changes from V3 :-
> > > 	- Refreshed against latest u-boot/master
> > > Changes from V2 :-
> > > 	- Added undef statement for CMD_ONENAND.
> > >
> > [Hiremath, Vaibhav] Denk,
> >
> > If we do not have any further comments, can we merge these patches?
> 
> The patches you listed are either ARM related and as such to be
> handdled by the ARM custodian, Tom, and/or NAND related ans as such to
> be addressed by the NAND custodian, Scott.
> 
> 
> I just wait for their pull requests.
[Hiremath, Vaibhav] Thanks Denk,

I think all these patches falls under Tom's list.

Tom,

Can you please merge these patches?

Thanks,
Vaibhav

> 
> Best regards,
> 
> Wolfgang Denk
> 
> --
> DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
> Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
> "The glory of creation is in its infinite diversity." "And in the way
> our differences combine to create meaning and beauty."
> 	-- Dr. Miranda Jones and Spock, "Is There in Truth No Beauty?",
> 	   stardate 5630.8

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [U-Boot] [PATCH-V5] OMAP3EVM: Added NAND support
  2010-05-11  8:59     ` Wolfgang Denk
  2010-05-11  9:01       ` Hiremath, Vaibhav
@ 2010-05-11 20:11       ` Scott Wood
  1 sibling, 0 replies; 263+ messages in thread
From: Scott Wood @ 2010-05-11 20:11 UTC (permalink / raw)
  To: u-boot

On 05/11/2010 03:59 AM, Wolfgang Denk wrote:
> Dear "Hiremath, Vaibhav",
>
> In message<19F8576C6E063C45BE387C64729E7394044E404A8A@dbde02.ent.ti.com>  you wrote:
>>
>>> Subject: [PATCH-V5] OMAP3EVM: Added NAND support
>>>
>>> From: Vaibhav Hiremath<hvaibhav@ti.com>
>>>
>>> The EVMS have been shipping with NAND (instead of OneNAND) as default.
>>> So, this patch sets NAND as default.
>>>
>>> To choose OneNAND, define CMD_ONENAND instead of CMD_NAND in the
>>> config file omap3_evm.h,
>>>
>>> Changes From V4 :-
>>> 	- Removed #undef ONENAND line (comment from Denk)
>>> Changes from V3 :-
>>> 	- Refreshed against latest u-boot/master
>>> Changes from V2 :-
>>> 	- Added undef statement for CMD_ONENAND.
>>>
>> [Hiremath, Vaibhav] Denk,
>>
>> If we do not have any further comments, can we merge these patches?
>
> The patches you listed are either ARM related and as such to be
> handdled by the ARM custodian, Tom, and/or NAND related ans as such to
> be addressed by the NAND custodian, Scott.
>
>
> I just wait for their pull requests.

It's a board config change to turn on NAND, not a change to NAND itself, 
so it should go via the ARM tree.

-Scott

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [U-Boot] [PATCH-V3 1/2] AM35x: Add support for AM3517EVM
  2010-05-06 17:23 ` [U-Boot] [PATCH-V3 1/2] AM35x: Add support for AM3517EVM hvaibhav at ti.com
  2010-05-11  5:00   ` Hiremath, Vaibhav
@ 2010-05-31  9:40   ` Wolfgang Denk
  2010-06-03 17:27     ` Hiremath, Vaibhav
  2010-06-07  8:56     ` Hiremath, Vaibhav
  1 sibling, 2 replies; 263+ messages in thread
From: Wolfgang Denk @ 2010-05-31  9:40 UTC (permalink / raw)
  To: u-boot

Dear hvaibhav at ti.com,

In message <1273166585-26101-1-git-send-email-hvaibhav@ti.com> you wrote:
> From: Vaibhav Hiremath <hvaibhav@ti.com>
> 
> This patch adds basic support for the AM3517EVM.
> It includes:
> 	- Board int file (.c and .h)
> 	- Default configuration file
> 	- Updates for Makefile
> 
> Changes from V2:
> 	- Removed trailing spaces
> 	- Updated MAINTAINERS & MAKEALL for am3517_evm

Such comments do not belong into the commit message. Please place thes
ebelow the "---" line:

> Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
> Signed-off-by: Sanjeev Premi <premi@ti.com>
> ---

==> Comments should go here.

> diff --git a/MAINTAINERS b/MAINTAINERS
> index 5cbc845..0bc65e1 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -798,6 +798,10 @@ Alex Z
>  	lart		SA1100
>  	dnp1110		SA1110
> 
> +Vaibhav Hiremath <hvaibhav@ti.com>
> +
> +	am3517_evm	ARM CORTEX-A8 (AM35x SoC)
> +

Please keep list sorted.

...
> diff --git a/arch/arm/include/asm/arch-omap3/mux.h b/arch/arm/include/asm/arch-omap3/mux.h
> index 0c01c73..ffeb982 100644
> --- a/arch/arm/include/asm/arch-omap3/mux.h
> +++ b/arch/arm/include/asm/arch-omap3/mux.h
...
> +/* AM3517 specific */
> +#define CONTROL_PADCONF_CCDC_PCLK	0x01E4
> +#define CONTROL_PADCONF_CCDC_FIELD	0x01E6

Board specific defoinitions should not be added to global header
files. Please use a board specific header instead.

> --- /dev/null
> +++ b/board/logicpd/am3517evm/am3517evm.c
> @@ -0,0 +1,76 @@
...
> +int board_init(void)
> +{
> +	DECLARE_GLOBAL_DATA_PTR;

This is bound to break. DECLARE_GLOBAL_DATA_PTR must always be used on
file scope only; never use this on function scope.  Please check all
your code.


Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Genius doesn't work on an assembly line basis.  You can't simply say,
"Today I will be brilliant."
	-- Kirk, "The Ultimate Computer", stardate 4731.3

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [U-Boot] [PATCH-V3 2/2] AM35x: Add support for EMIF4
  2010-05-06 17:23 ` [U-Boot] [PATCH-V3 2/2] AM35x: Add support for EMIF4 hvaibhav at ti.com
@ 2010-05-31  9:43   ` Wolfgang Denk
  2010-06-03 17:28     ` Hiremath, Vaibhav
  0 siblings, 1 reply; 263+ messages in thread
From: Wolfgang Denk @ 2010-05-31  9:43 UTC (permalink / raw)
  To: u-boot

Dear hvaibhav at ti.com,

In message <1273166585-26101-2-git-send-email-hvaibhav@ti.com> you wrote:
> From: Vaibhav Hiremath <hvaibhav@ti.com>
> 
> This patch adds support for the EMIF4 interface
> available in the AM35x processors.
> 
> Changes from V2:
> 	- Removed all instances of #ifdef CONFIG_EMIF4

See previeos comment - such comments belong below the "---" line and
not into the commit message.

> diff --git a/arch/arm/cpu/arm_cortexa8/omap3/Makefile b/arch/arm/cpu/arm_cortexa8/omap3/Makefile
> index 1e80eb3..d25bfd5 100644
> --- a/arch/arm/cpu/arm_cortexa8/omap3/Makefile
> +++ b/arch/arm/cpu/arm_cortexa8/omap3/Makefile
> @@ -38,6 +38,7 @@ COBJS	+= sys_info.o
>  COBJS	+= timer.o
> 
>  COBJS-$(CONFIG_SDRC)	+= sdrc.o
> +COBJS-$(CONFIG_EMIF4)	+=emif4.o

Please keep lists sorted.


Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
The complexity of software is an essential property, not an  acciden-
tal  one. Hence, descriptions of a software entity that abstract away
its complexity often abstract away its essence.    - Fred Brooks, Jr.

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [U-Boot] [PATCH-V3 1/2] AM35x: Add support for AM3517EVM
  2010-05-31  9:40   ` Wolfgang Denk
@ 2010-06-03 17:27     ` Hiremath, Vaibhav
  2010-06-07  8:56     ` Hiremath, Vaibhav
  1 sibling, 0 replies; 263+ messages in thread
From: Hiremath, Vaibhav @ 2010-06-03 17:27 UTC (permalink / raw)
  To: u-boot


> -----Original Message-----
> From: Wolfgang Denk [mailto:wd at denx.de]
> Sent: Monday, May 31, 2010 3:11 PM
> To: Hiremath, Vaibhav
> Cc: u-boot at lists.denx.de; tom at bumblecow.com; Paulraj, Sandeep; Premi,
> Sanjeev
> Subject: Re: [PATCH-V3 1/2] AM35x: Add support for AM3517EVM
> 
> Dear hvaibhav at ti.com,
> 
> In message <1273166585-26101-1-git-send-email-hvaibhav@ti.com> you wrote:
> > From: Vaibhav Hiremath <hvaibhav@ti.com>
> >
> > This patch adds basic support for the AM3517EVM.
> > It includes:
> > 	- Board int file (.c and .h)
> > 	- Default configuration file
> > 	- Updates for Makefile
> >
> > Changes from V2:
> > 	- Removed trailing spaces
> > 	- Updated MAINTAINERS & MAKEALL for am3517_evm
> 
> Such comments do not belong into the commit message. Please place thes
> ebelow the "---" line:
> 
[Hiremath, Vaibhav] Ok will incorporate in next post.

> > Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
> > Signed-off-by: Sanjeev Premi <premi@ti.com>
> > ---
> 
> ==> Comments should go here.
> 
> > diff --git a/MAINTAINERS b/MAINTAINERS
> > index 5cbc845..0bc65e1 100644
> > --- a/MAINTAINERS
> > +++ b/MAINTAINERS
> > @@ -798,6 +798,10 @@ Alex Z
> >  	lart		SA1100
> >  	dnp1110		SA1110
> >
> > +Vaibhav Hiremath <hvaibhav@ti.com>
> > +
> > +	am3517_evm	ARM CORTEX-A8 (AM35x SoC)
> > +
> 
> Please keep list sorted.
> 
[Hiremath, Vaibhav] How does this sorted, I could not see any relation between the entries there. 

> ...
> > diff --git a/arch/arm/include/asm/arch-omap3/mux.h
> b/arch/arm/include/asm/arch-omap3/mux.h
> > index 0c01c73..ffeb982 100644
> > --- a/arch/arm/include/asm/arch-omap3/mux.h
> > +++ b/arch/arm/include/asm/arch-omap3/mux.h
> ...
> > +/* AM3517 specific */
> > +#define CONTROL_PADCONF_CCDC_PCLK	0x01E4
> > +#define CONTROL_PADCONF_CCDC_FIELD	0x01E6
> 
> Board specific defoinitions should not be added to global header
> files. Please use a board specific header instead.
> 
[Hiremath, Vaibhav] I think this has been placed at the right place. This is mux definition and got added to mux.h file. You could see all mux definition are present in this file.

Do you see any issues with this?

> > --- /dev/null
> > +++ b/board/logicpd/am3517evm/am3517evm.c
> > @@ -0,0 +1,76 @@
> ...
> > +int board_init(void)
> > +{
> > +	DECLARE_GLOBAL_DATA_PTR;
> 
> This is bound to break. DECLARE_GLOBAL_DATA_PTR must always be used on
> file scope only; never use this on function scope.  
[Hiremath, Vaibhav] Agreed. Actually this code is derived form board/ti/evm/, so followed the same here.

I will change it in next post.

> Please check all
> your code.
> 
[Hiremath, Vaibhav] Do you see any other issues? I don't get this statement.

Thanks,
Vaibhav

> 
> Best regards,
> 
> Wolfgang Denk
> 
> --
> DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
> Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
> Genius doesn't work on an assembly line basis.  You can't simply say,
> "Today I will be brilliant."
> 	-- Kirk, "The Ultimate Computer", stardate 4731.3

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [U-Boot] [PATCH-V3 2/2] AM35x: Add support for EMIF4
  2010-05-31  9:43   ` Wolfgang Denk
@ 2010-06-03 17:28     ` Hiremath, Vaibhav
  0 siblings, 0 replies; 263+ messages in thread
From: Hiremath, Vaibhav @ 2010-06-03 17:28 UTC (permalink / raw)
  To: u-boot


> -----Original Message-----
> From: Wolfgang Denk [mailto:wd at denx.de]
> Sent: Monday, May 31, 2010 3:14 PM
> To: Hiremath, Vaibhav
> Cc: u-boot at lists.denx.de; tom at bumblecow.com; Paulraj, Sandeep; Premi,
> Sanjeev
> Subject: Re: [PATCH-V3 2/2] AM35x: Add support for EMIF4
> 
> Dear hvaibhav at ti.com,
> 
> In message <1273166585-26101-2-git-send-email-hvaibhav@ti.com> you wrote:
> > From: Vaibhav Hiremath <hvaibhav@ti.com>
> >
> > This patch adds support for the EMIF4 interface
> > available in the AM35x processors.
> >
> > Changes from V2:
> > 	- Removed all instances of #ifdef CONFIG_EMIF4
> 
> See previeos comment - such comments belong below the "---" line and
> not into the commit message.
> 
[Hiremath, Vaibhav] OK, I will incorporate changes in next post.

> > diff --git a/arch/arm/cpu/arm_cortexa8/omap3/Makefile
> b/arch/arm/cpu/arm_cortexa8/omap3/Makefile
> > index 1e80eb3..d25bfd5 100644
> > --- a/arch/arm/cpu/arm_cortexa8/omap3/Makefile
> > +++ b/arch/arm/cpu/arm_cortexa8/omap3/Makefile
> > @@ -38,6 +38,7 @@ COBJS	+= sys_info.o
> >  COBJS	+= timer.o
> >
> >  COBJS-$(CONFIG_SDRC)	+= sdrc.o
> > +COBJS-$(CONFIG_EMIF4)	+=emif4.o
> 
> Please keep lists sorted.
> 
[Hiremath, Vaibhav] Will change and submit it again.

Thanks,
Vaibhav

> 
> Best regards,
> 
> Wolfgang Denk
> 
> --
> DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
> Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
> The complexity of software is an essential property, not an  acciden-
> tal  one. Hence, descriptions of a software entity that abstract away
> its complexity often abstract away its essence.    - Fred Brooks, Jr.

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [U-Boot] [PATCH-V3 1/2] AM35x: Add support for AM3517EVM
  2010-05-31  9:40   ` Wolfgang Denk
  2010-06-03 17:27     ` Hiremath, Vaibhav
@ 2010-06-07  8:56     ` Hiremath, Vaibhav
  2010-06-07 12:24       ` Wolfgang Denk
  1 sibling, 1 reply; 263+ messages in thread
From: Hiremath, Vaibhav @ 2010-06-07  8:56 UTC (permalink / raw)
  To: u-boot


> -----Original Message-----
> From: Hiremath, Vaibhav
> Sent: Thursday, June 03, 2010 10:57 PM
> To: 'Wolfgang Denk'
> Cc: u-boot at lists.denx.de; tom at bumblecow.com; Paulraj, Sandeep; Premi,
> Sanjeev
> Subject: RE: [PATCH-V3 1/2] AM35x: Add support for AM3517EVM
> 
[Hiremath, Vaibhav] Denk,

Can you please reply to below queries of mine, so that I can incorporate the changes and submit it again?

Thanks,
Vaibhav

> 
> > -----Original Message-----
> > From: Wolfgang Denk [mailto:wd at denx.de]
> > Sent: Monday, May 31, 2010 3:11 PM
> > To: Hiremath, Vaibhav
> > Cc: u-boot at lists.denx.de; tom at bumblecow.com; Paulraj, Sandeep; Premi,
> > Sanjeev
> > Subject: Re: [PATCH-V3 1/2] AM35x: Add support for AM3517EVM
> >
> > Dear hvaibhav at ti.com,
> >
> > In message <1273166585-26101-1-git-send-email-hvaibhav@ti.com> you wrote:
> > > From: Vaibhav Hiremath <hvaibhav@ti.com>
> > >
> > > This patch adds basic support for the AM3517EVM.
> > > It includes:
> > > 	- Board int file (.c and .h)
> > > 	- Default configuration file
> > > 	- Updates for Makefile
> > >
> > > Changes from V2:
> > > 	- Removed trailing spaces
> > > 	- Updated MAINTAINERS & MAKEALL for am3517_evm
> >
> > Such comments do not belong into the commit message. Please place thes
> > ebelow the "---" line:
> >
> [Hiremath, Vaibhav] Ok will incorporate in next post.
> 
> > > Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
> > > Signed-off-by: Sanjeev Premi <premi@ti.com>
> > > ---
> >
> > ==> Comments should go here.
> >
> > > diff --git a/MAINTAINERS b/MAINTAINERS
> > > index 5cbc845..0bc65e1 100644
> > > --- a/MAINTAINERS
> > > +++ b/MAINTAINERS
> > > @@ -798,6 +798,10 @@ Alex Z
> > >  	lart		SA1100
> > >  	dnp1110		SA1110
> > >
> > > +Vaibhav Hiremath <hvaibhav@ti.com>
> > > +
> > > +	am3517_evm	ARM CORTEX-A8 (AM35x SoC)
> > > +
> >
> > Please keep list sorted.
> >
> [Hiremath, Vaibhav] How does this sorted, I could not see any relation
> between the entries there.
> 
[Hiremath, Vaibhav] Denk,
> > ...
> > > diff --git a/arch/arm/include/asm/arch-omap3/mux.h
> > b/arch/arm/include/asm/arch-omap3/mux.h
> > > index 0c01c73..ffeb982 100644
> > > --- a/arch/arm/include/asm/arch-omap3/mux.h
> > > +++ b/arch/arm/include/asm/arch-omap3/mux.h
> > ...
> > > +/* AM3517 specific */
> > > +#define CONTROL_PADCONF_CCDC_PCLK	0x01E4
> > > +#define CONTROL_PADCONF_CCDC_FIELD	0x01E6
> >
> > Board specific defoinitions should not be added to global header
> > files. Please use a board specific header instead.
> >
> [Hiremath, Vaibhav] I think this has been placed at the right place. This is
> mux definition and got added to mux.h file. You could see all mux definition
> are present in this file.
> 
> Do you see any issues with this?
> 
> > > --- /dev/null
> > > +++ b/board/logicpd/am3517evm/am3517evm.c
> > > @@ -0,0 +1,76 @@
> > ...
> > > +int board_init(void)
> > > +{
> > > +	DECLARE_GLOBAL_DATA_PTR;
> >
> > This is bound to break. DECLARE_GLOBAL_DATA_PTR must always be used on
> > file scope only; never use this on function scope.
> [Hiremath, Vaibhav] Agreed. Actually this code is derived form
> board/ti/evm/, so followed the same here.
> 
> I will change it in next post.
> 
> > Please check all
> > your code.
> >
> [Hiremath, Vaibhav] Do you see any other issues? I don't get this statement.
> 
> Thanks,
> Vaibhav
> 
> >
> > Best regards,
> >
> > Wolfgang Denk
> >
> > --
> > DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
> > HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
> > Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
> > Genius doesn't work on an assembly line basis.  You can't simply say,
> > "Today I will be brilliant."
> > 	-- Kirk, "The Ultimate Computer", stardate 4731.3

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [U-Boot] [PATCH-V3 1/2] AM35x: Add support for AM3517EVM
  2010-06-07  8:56     ` Hiremath, Vaibhav
@ 2010-06-07 12:24       ` Wolfgang Denk
  2010-06-07 14:23         ` Hiremath, Vaibhav
  0 siblings, 1 reply; 263+ messages in thread
From: Wolfgang Denk @ 2010-06-07 12:24 UTC (permalink / raw)
  To: u-boot

Dear "Hiremath, Vaibhav",

In message <19F8576C6E063C45BE387C64729E7394044E7A16B5@dbde02.ent.ti.com> you wrote:
...
> > > > diff --git a/MAINTAINERS b/MAINTAINERS
> > > > index 5cbc845..0bc65e1 100644
> > > > --- a/MAINTAINERS
> > > > +++ b/MAINTAINERS
> > > > @@ -798,6 +798,10 @@ Alex Z
> > > >  	lart		SA1100
> > > >  	dnp1110		SA1110
> > > >
> > > > +Vaibhav Hiremath <hvaibhav@ti.com>
> > > > +
> > > > +	am3517_evm	ARM CORTEX-A8 (AM35x SoC)
> > > > +
> > >
> > > Please keep list sorted.
> > >
> > [Hiremath, Vaibhav] How does this sorted, I could not see any relation
> > between the entries there.

The list is sorted alphabetically by maintainer' last names, and then
by CPU / board names.

> > > > diff --git a/arch/arm/include/asm/arch-omap3/mux.h
> > > b/arch/arm/include/asm/arch-omap3/mux.h
> > > > index 0c01c73..ffeb982 100644
> > > > --- a/arch/arm/include/asm/arch-omap3/mux.h
> > > > +++ b/arch/arm/include/asm/arch-omap3/mux.h
> > > ...
> > > > +/* AM3517 specific */
> > > > +#define CONTROL_PADCONF_CCDC_PCLK	0x01E4
> > > > +#define CONTROL_PADCONF_CCDC_FIELD	0x01E6
> > >
> > > Board specific defoinitions should not be added to global header
> > > files. Please use a board specific header instead.
> > >
> > [Hiremath, Vaibhav] I think this has been placed at the right place. This is
> > mux definition and got added to mux.h file. You could see all mux definition
> > are present in this file.
> > 
> > Do you see any issues with this?

Yes, as I wrote: board specific definitions should not be added to
global header files. They should be added to board specific files
only, avoiding the need for tons of #ifdef's in global files.


Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
When you die, the first thing you lose is your life. The  next  thing
is the illusions.                       - Terry Pratchett, _Pyramids_

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [U-Boot] [PATCH-V3 1/2] AM35x: Add support for AM3517EVM
  2010-06-07 12:24       ` Wolfgang Denk
@ 2010-06-07 14:23         ` Hiremath, Vaibhav
  0 siblings, 0 replies; 263+ messages in thread
From: Hiremath, Vaibhav @ 2010-06-07 14:23 UTC (permalink / raw)
  To: u-boot


> -----Original Message-----
> From: Wolfgang Denk [mailto:wd at denx.de]
> Sent: Monday, June 07, 2010 5:55 PM
> To: Hiremath, Vaibhav
> Cc: u-boot at lists.denx.de; tom at bumblecow.com; Paulraj, Sandeep; Premi,
> Sanjeev
> Subject: Re: [PATCH-V3 1/2] AM35x: Add support for AM3517EVM
> 
> Dear "Hiremath, Vaibhav",
> 
> In message <19F8576C6E063C45BE387C64729E7394044E7A16B5@dbde02.ent.ti.com>
> you wrote:
> ...
> > > > > diff --git a/MAINTAINERS b/MAINTAINERS
> > > > > index 5cbc845..0bc65e1 100644
> > > > > --- a/MAINTAINERS
> > > > > +++ b/MAINTAINERS
> > > > > @@ -798,6 +798,10 @@ Alex Z
> > > > >  	lart		SA1100
> > > > >  	dnp1110		SA1110
> > > > >
> > > > > +Vaibhav Hiremath <hvaibhav@ti.com>
> > > > > +
> > > > > +	am3517_evm	ARM CORTEX-A8 (AM35x SoC)
> > > > > +
> > > >
> > > > Please keep list sorted.
> > > >
> > > [Hiremath, Vaibhav] How does this sorted, I could not see any relation
> > > between the entries there.
> 
> The list is sorted alphabetically by maintainer' last names, and then
> by CPU / board names.
> 
[Hiremath, Vaibhav] Thanks, I will update the patch and submit is shortly.

> > > > > diff --git a/arch/arm/include/asm/arch-omap3/mux.h
> > > > b/arch/arm/include/asm/arch-omap3/mux.h
> > > > > index 0c01c73..ffeb982 100644
> > > > > --- a/arch/arm/include/asm/arch-omap3/mux.h
> > > > > +++ b/arch/arm/include/asm/arch-omap3/mux.h
> > > > ...
> > > > > +/* AM3517 specific */
> > > > > +#define CONTROL_PADCONF_CCDC_PCLK	0x01E4
> > > > > +#define CONTROL_PADCONF_CCDC_FIELD	0x01E6
> > > >
> > > > Board specific defoinitions should not be added to global header
> > > > files. Please use a board specific header instead.
> > > >
> > > [Hiremath, Vaibhav] I think this has been placed at the right place.
> This is
> > > mux definition and got added to mux.h file. You could see all mux
> definition
> > > are present in this file.
> > >
> > > Do you see any issues with this?
> 
> Yes, as I wrote: board specific definitions should not be added to
> global header files. They should be added to board specific files
> only, avoiding the need for tons of #ifdef's in global files.
> 
[Hiremath, Vaibhav] Yes I agree this has to be there in board header file, but I don't think we are using #ifdefs anywhere for this, since the usage of this is happening through board header file.

I am moving these definitions to board/logicpd/am3517evm/am3517evm.h file.

Thanks,
Vaibhav
> 
> Best regards,
> 
> Wolfgang Denk
> 
> --
> DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
> Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
> When you die, the first thing you lose is your life. The  next  thing
> is the illusions.                       - Terry Pratchett, _Pyramids_

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [U-Boot] [PATCH-V4 1/2] AM35x: Add support for AM3517EVM
@ 2010-06-07 14:59 ` hvaibhav at ti.com
  2010-06-07 21:20   ` Paulraj, Sandeep
  0 siblings, 1 reply; 263+ messages in thread
From: hvaibhav at ti.com @ 2010-06-07 14:59 UTC (permalink / raw)
  To: u-boot

From: Vaibhav Hiremath <hvaibhav@ti.com>

This patch adds basic support for the AM3517EVM.
It includes:
	- Board files (.c and .h)
	- Default configuration file
	- Updates for Makefile

Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
Signed-off-by: Sanjeev Premi <premi@ti.com>
---
Changes from V2:
	- Removed trailing spaces
	- Updated MAINTAINERS & MAKEALL for am3517_evm
Changes from V3:
	- Corrected Maintainer entry to keep list sorted
	- Moved AM3537 macros to board header file

 MAINTAINERS                         |    4 +
 MAKEALL                             |    1 +
 Makefile                            |    3 +
 board/logicpd/am3517evm/Makefile    |   46 ++++
 board/logicpd/am3517evm/am3517evm.c |   76 ++++++
 board/logicpd/am3517evm/am3517evm.h |  445 +++++++++++++++++++++++++++++++++++
 board/logicpd/am3517evm/config.mk   |   30 +++
 include/configs/am3517_evm.h        |  296 +++++++++++++++++++++++
 8 files changed, 901 insertions(+), 0 deletions(-)
 create mode 100644 board/logicpd/am3517evm/Makefile
 create mode 100644 board/logicpd/am3517evm/am3517evm.c
 create mode 100644 board/logicpd/am3517evm/am3517evm.h
 create mode 100644 board/logicpd/am3517evm/config.mk
 create mode 100644 include/configs/am3517_evm.h

diff --git a/MAINTAINERS b/MAINTAINERS
index 7a13d28..3f9df78 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -600,6 +600,10 @@ Kshitij Gupta <kshitij@ti.com>
 	omap1510inn	ARM925T
 	omap1610inn	ARM926EJS

+Vaibhav Hiremath <hvaibhav@ti.com>
+
+	am3517_evm	ARM CORTEX-A8 (AM35x SoC)
+
 Grazvydas Ignotas <notasas@gmail.com>

 	omap3_pandora	ARM CORTEX-A8 (OMAP3xx SoC)
diff --git a/MAKEALL b/MAKEALL
index 2527352..2066587 100755
--- a/MAKEALL
+++ b/MAKEALL
@@ -641,6 +641,7 @@ LIST_ARM11="			\
 ## ARM Cortex-A8 Systems
 #########################################################################
 LIST_ARM_CORTEX_A8="		\
+	am3517_evm		\
 	devkit8000		\
 	mx51evk			\
 	omap3_beagle		\
diff --git a/Makefile b/Makefile
index c26e491..b935c1a 100644
--- a/Makefile
+++ b/Makefile
@@ -3155,6 +3155,9 @@ SMN42_config	:	unconfig
 ## ARM CORTEX Systems
 #########################################################################

+am3517_evm_config :	unconfig
+	@$(MKCONFIG) $(@:_config=) arm arm_cortexa8 am3517evm logicpd omap3
+
 devkit8000_config :	unconfig
 	@$(MKCONFIG) $(@:_config=) arm arm_cortexa8 devkit8000 timll omap3

diff --git a/board/logicpd/am3517evm/Makefile b/board/logicpd/am3517evm/Makefile
new file mode 100644
index 0000000..3a6b1a1
--- /dev/null
+++ b/board/logicpd/am3517evm/Makefile
@@ -0,0 +1,46 @@
+#
+# Author: Vaibhav Hiremath <hvaibhav@ti.com>
+#
+# Based on ti/evm/Makefile
+#
+# Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/
+#
+# 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; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+#
+
+include $(TOPDIR)/config.mk
+
+LIB	= $(obj)lib$(BOARD).a
+
+COBJS	:= am3517evm.o
+
+SRCS	:= $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
+	$(AR) $(ARFLAGS) $@ $(OBJS)
+
+clean:
+	rm -f $(OBJS)
+
+distclean:	clean
+	rm -f $(LIB) core *.bak $(obj).depend
+
+#########################################################################
+
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
+
+sinclude $(obj).depend
diff --git a/board/logicpd/am3517evm/am3517evm.c b/board/logicpd/am3517evm/am3517evm.c
new file mode 100644
index 0000000..bbb6e83
--- /dev/null
+++ b/board/logicpd/am3517evm/am3517evm.c
@@ -0,0 +1,76 @@
+/*
+ * am3517evm.c - board file for TI's AM3517 family of devices.
+ *
+ * Author: Vaibhav Hiremath <hvaibhav@ti.com>
+ *
+ * Based on ti/evm/evm.c
+ *
+ * Copyright (C) 2010
+ * Texas Instruments Incorporated - http://www.ti.com/
+ *
+ * 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <common.h>
+#include <asm/io.h>
+#include <asm/arch/mem.h>
+#include <asm/arch/mux.h>
+#include <asm/arch/sys_proto.h>
+#include <asm/mach-types.h>
+#include <i2c.h>
+#include "am3517evm.h"
+
+DECLARE_GLOBAL_DATA_PTR;
+
+/*
+ * Routine: board_init
+ * Description: Early hardware init.
+ */
+int board_init(void)
+{
+	gpmc_init(); /* in SRAM or SDRAM, finish GPMC */
+	/* board id for Linux */
+	gd->bd->bi_arch_number = MACH_TYPE_OMAP3517EVM;
+	/* boot param addr */
+	gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100);
+
+	return 0;
+}
+
+/*
+ * Routine: misc_init_r
+ * Description: Init i2c, ethernet, etc... (done here so udelay works)
+ */
+int misc_init_r(void)
+{
+#ifdef CONFIG_DRIVER_OMAP34XX_I2C
+	i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
+#endif
+
+	dieid_num_r();
+
+	return 0;
+}
+
+/*
+ * Routine: set_muxconf_regs
+ * Description: Setting up the configuration Mux registers specific to the
+ *		hardware. Many pins need to be moved from protect to primary
+ *		mode.
+ */
+void set_muxconf_regs(void)
+{
+	MUX_AM3517EVM();
+}
diff --git a/board/logicpd/am3517evm/am3517evm.h b/board/logicpd/am3517evm/am3517evm.h
new file mode 100644
index 0000000..3d74ef1
--- /dev/null
+++ b/board/logicpd/am3517evm/am3517evm.h
@@ -0,0 +1,445 @@
+/*
+ * am3517evm.h - Header file for the AM3517 EVM.
+ *
+ * Author: Vaibhav Hiremath <hvaibhav@ti.com>
+ *
+ * Based on ti/evm/evm.h
+ *
+ * Copyright (C) 2010
+ * Texas Instruments Incorporated - http://www.ti.com/
+ *
+ * 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#ifndef _AM3517EVM_H_
+#define _AM3517EVM_H_
+
+const omap3_sysinfo sysinfo = {
+	DDR_DISCRETE,
+	"AM3517EVM Board",
+	"NAND",
+};
+/* AM3517 specific mux configuration */
+#define CONTROL_PADCONF_SYS_NRESWARM	0x0A08
+/* CCDC */
+#define CONTROL_PADCONF_CCDC_PCLK	0x01E4
+#define CONTROL_PADCONF_CCDC_FIELD	0x01E6
+#define CONTROL_PADCONF_CCDC_HD		0x01E8
+#define CONTROL_PADCONF_CCDC_VD		0x01EA
+#define CONTROL_PADCONF_CCDC_WEN	0x01EC
+#define CONTROL_PADCONF_CCDC_DATA0	0x01EE
+#define CONTROL_PADCONF_CCDC_DATA1	0x01F0
+#define CONTROL_PADCONF_CCDC_DATA2	0x01F2
+#define CONTROL_PADCONF_CCDC_DATA3	0x01F4
+#define CONTROL_PADCONF_CCDC_DATA4	0x01F6
+#define CONTROL_PADCONF_CCDC_DATA5	0x01F8
+#define CONTROL_PADCONF_CCDC_DATA6	0x01FA
+#define CONTROL_PADCONF_CCDC_DATA7	0x01FC
+/* RMII */
+#define CONTROL_PADCONF_RMII_MDIO_DATA	0x01FE
+#define CONTROL_PADCONF_RMII_MDIO_CLK	0x0200
+#define CONTROL_PADCONF_RMII_RXD0	0x0202
+#define CONTROL_PADCONF_RMII_RXD1	0x0204
+#define CONTROL_PADCONF_RMII_CRS_DV	0x0206
+#define CONTROL_PADCONF_RMII_RXER	0x0208
+#define CONTROL_PADCONF_RMII_TXD0	0x020A
+#define CONTROL_PADCONF_RMII_TXD1	0x020C
+#define CONTROL_PADCONF_RMII_TXEN	0x020E
+#define CONTROL_PADCONF_RMII_50MHZ_CLK	0x0210
+#define CONTROL_PADCONF_USB0_DRVBUS	0x0212
+/* CAN */
+#define CONTROL_PADCONF_HECC1_TXD	0x0214
+#define CONTROL_PADCONF_HECC1_RXD	0x0216
+
+#define CONTROL_PADCONF_SYS_BOOT7	0x0218
+#define CONTROL_PADCONF_SDRC_DQS0N	0x021A
+#define CONTROL_PADCONF_SDRC_DQS1N	0x021C
+#define CONTROL_PADCONF_SDRC_DQS2N	0x021E
+#define CONTROL_PADCONF_SDRC_DQS3N	0x0220
+#define CONTROL_PADCONF_STRBEN_DLY0	0x0222
+#define CONTROL_PADCONF_STRBEN_DLY1	0x0224
+#define CONTROL_PADCONF_SYS_BOOT8	0x0226
+
+/*
+ * IEN  - Input Enable
+ * IDIS - Input Disable
+ * PTD  - Pull type Down
+ * PTU  - Pull type Up
+ * DIS  - Pull type selection is inactive
+ * EN   - Pull type selection is active
+ * M0   - Mode 0
+ * The commented string gives the final mux configuration for that pin
+ */
+#define MUX_AM3517EVM() \
+	/* SDRC */\
+	MUX_VAL(CP(SDRC_D0),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_D1),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_D2),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_D3),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_D4),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_D5),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_D6),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_D7),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_D8),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_D9),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_D10),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_D11),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_D12),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_D13),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_D14),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_D15),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_D16),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_D17),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_D18),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_D19),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_D20),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_D21),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_D22),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_D23),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_D24),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_D25),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_D26),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_D27),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_D28),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_D29),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_D30),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_D31),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_CLK),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_DQS0),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_DQS1),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_DQS2),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_DQS3),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SDRC_DQS0N),		(IEN  | PTD | EN  | M0)) \
+	MUX_VAL(CP(SDRC_DQS1N),		(IEN  | PTD | EN  | M0)) \
+	MUX_VAL(CP(SDRC_DQS2N),		(IEN  | PTD | EN  | M0)) \
+	MUX_VAL(CP(SDRC_DQS3N),		(IEN  | PTD | EN  | M0)) \
+	MUX_VAL(CP(SDRC_CKE0),		(M0)) \
+	MUX_VAL(CP(SDRC_CKE1),		(M0)) \
+	/*sdrc_strben_dly0*/\
+	MUX_VAL(CP(STRBEN_DLY0),	(IEN  | PTD | EN  | M0)) \
+	 /*sdrc_strben_dly1*/\
+	MUX_VAL(CP(STRBEN_DLY1),	(IEN  | PTD | EN  | M0)) \
+	/* GPMC */\
+	MUX_VAL(CP(GPMC_A1),		(IDIS | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_A2),		(IDIS | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_A3),		(IDIS | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_A4),		(IDIS | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_A5),		(IDIS | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_A6),		(IDIS | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_A7),		(IDIS | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_A8),		(IDIS | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_A9),		(IDIS | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_A10),		(IDIS | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_D0),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_D1),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_D2),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_D3),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_D4),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_D5),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_D6),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_D7),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_D8),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_D9),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_D10),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_D11),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_D12),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_D13),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_D14),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_D15),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_NCS0),		(IDIS | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_NCS1),		(IDIS | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_NCS2),		(IDIS | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_NCS3),		(IDIS | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_NCS4),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_NCS5),		(IDIS | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_NCS6),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(GPMC_NCS7),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_CLK),		(IDIS | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_NADV_ALE),	(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(GPMC_NOE),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(GPMC_NWE),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(GPMC_NBE0_CLE),	(IDIS | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_NBE1),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_NWP),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(GPMC_WAIT0),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_WAIT1),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(GPMC_WAIT2),		(IEN  | PTU | EN  | M4)) /*GPIO_64*/\
+							 /* - ETH_nRESET*/\
+	MUX_VAL(CP(GPMC_WAIT3),		(IEN  | PTU | EN  | M0)) \
+	/* DSS */\
+	MUX_VAL(CP(DSS_PCLK),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(DSS_HSYNC),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(DSS_VSYNC),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(DSS_ACBIAS),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(DSS_DATA0),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(DSS_DATA1),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(DSS_DATA2),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(DSS_DATA3),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(DSS_DATA4),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(DSS_DATA5),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(DSS_DATA6),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(DSS_DATA7),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(DSS_DATA8),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(DSS_DATA9),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(DSS_DATA10),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(DSS_DATA11),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(DSS_DATA12),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(DSS_DATA13),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(DSS_DATA14),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(DSS_DATA15),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(DSS_DATA16),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(DSS_DATA17),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(DSS_DATA18),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(DSS_DATA19),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(DSS_DATA20),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(DSS_DATA21),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(DSS_DATA22),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(DSS_DATA23),		(IDIS | PTD | DIS | M0)) \
+	/* CAMERA */\
+	MUX_VAL(CP(CAM_HS),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(CAM_VS),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(CAM_XCLKA),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(CAM_PCLK),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(CAM_FLD),		(IDIS | PTD | DIS | M4)) /*GPIO_98*/\
+							 /* - CAM_RESET*/\
+	MUX_VAL(CP(CAM_D0),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(CAM_D1),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(CAM_D2),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(CAM_D3),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(CAM_D4),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(CAM_D5),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(CAM_D6),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(CAM_D7),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(CAM_D8),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(CAM_D9),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(CAM_D10),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(CAM_D11),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(CAM_XCLKB),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(CAM_WEN),		(IEN  | PTD | DIS | M4)) /*GPIO_167*/\
+	MUX_VAL(CP(CAM_STROBE),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(CSI2_DX0),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(CSI2_DY0),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(CSI2_DX1),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(CSI2_DY1),		(IEN  | PTD | DIS | M0)) \
+	/* MMC */\
+	MUX_VAL(CP(MMC1_CLK),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(MMC1_CMD),		(IEN  | PTU | DIS | M0)) \
+	MUX_VAL(CP(MMC1_DAT0),		(IEN  | PTU | DIS | M0)) \
+	MUX_VAL(CP(MMC1_DAT1),		(IEN  | PTU | DIS | M0)) \
+	MUX_VAL(CP(MMC1_DAT2),		(IEN  | PTU | DIS | M0)) \
+	MUX_VAL(CP(MMC1_DAT3),		(IEN  | PTU | DIS | M0)) \
+	/* WriteProtect */\
+	MUX_VAL(CP(MMC1_DAT4),		(IEN  | PTU | EN  | M4)) \
+	MUX_VAL(CP(MMC1_DAT5),		(IEN  | PTU | EN  | M4)) /*CardDetect*/\
+	MUX_VAL(CP(MMC1_DAT6),		(IEN  | PTU | EN  | M4)) \
+	MUX_VAL(CP(MMC1_DAT7),		(IEN  | PTU | EN  | M4)) \
+	\
+	MUX_VAL(CP(MMC2_CLK),		(IEN  | PTD | EN  | M0)) \
+	MUX_VAL(CP(MMC2_CMD),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(MMC2_DAT0),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(MMC2_DAT1),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(MMC2_DAT2),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(MMC2_DAT3),		(IEN  | PTD | DIS | M0)) \
+	/* McBSP */\
+	MUX_VAL(CP(MCBSP_CLKS),		(IEN  | PTU | DIS | M0)) \
+	MUX_VAL(CP(MCBSP1_CLKR),	(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(MCBSP1_FSR),		(IDIS | PTU | EN  | M0)) \
+	MUX_VAL(CP(MCBSP1_DX),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(MCBSP1_DR),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(MCBSP1_FSX),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(MCBSP1_CLKX),	(IEN  | PTD | DIS | M0)) \
+	\
+	MUX_VAL(CP(MCBSP2_FSX),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(MCBSP2_CLKX),	(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(MCBSP2_DR),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(MCBSP2_DX),		(IDIS | PTD | DIS | M0)) \
+	\
+	MUX_VAL(CP(MCBSP3_DX),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(MCBSP3_DR),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(MCBSP3_CLKX),	(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(MCBSP3_FSX),		(IEN  | PTD | DIS | M0)) \
+	\
+	MUX_VAL(CP(MCBSP4_CLKX),	(IDIS | PTD | DIS | M4)) /*GPIO_152*/\
+							 /* - LCD_INI*/\
+	MUX_VAL(CP(MCBSP4_DR),		(IDIS | PTD | DIS | M4)) /*GPIO_153*/\
+							 /* - LCD_ENVDD */\
+	MUX_VAL(CP(MCBSP4_DX),		(IDIS | PTD | DIS | M4)) /*GPIO_154*/\
+							 /* - LCD_QVGA/nVGA */\
+	MUX_VAL(CP(MCBSP4_FSX),		(IDIS | PTD | DIS | M4)) /*GPIO_155*/\
+							 /* - LCD_RESB */\
+	/* UART */\
+	MUX_VAL(CP(UART1_TX),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(UART1_RTS),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(UART1_CTS),		(IEN  | PTU | DIS | M0)) \
+	\
+	MUX_VAL(CP(UART1_RX),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(UART2_CTS),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(UART2_RTS),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(UART2_TX),		(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(UART2_RX),		(IEN  | PTD | DIS | M0)) \
+	\
+	MUX_VAL(CP(UART3_CTS_RCTX),	(IEN  | PTU | DIS | M0)) \
+	MUX_VAL(CP(UART3_RTS_SD),	(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(UART3_RX_IRRX),	(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(UART3_TX_IRTX),	(IDIS | PTD | DIS | M0)) \
+	/* I2C */\
+	MUX_VAL(CP(I2C1_SCL),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(I2C1_SDA),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(I2C2_SCL),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(I2C2_SDA),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(I2C3_SCL),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(I2C3_SDA),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(I2C4_SCL),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(I2C4_SDA),		(IEN  | PTU | EN  | M0)) \
+	/* McSPI */\
+	MUX_VAL(CP(MCSPI1_CLK),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(MCSPI1_SIMO),	(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(MCSPI1_SOMI),	(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(MCSPI1_CS0),		(IEN  | PTD | EN  | M0)) \
+	MUX_VAL(CP(MCSPI1_CS1),		(IEN  | PTD | EN  | M4)) /*GPIO_175*/\
+	MUX_VAL(CP(MCSPI1_CS2),		(IEN  | PTU | DIS | M4)) /*GPIO_176*/\
+							 /* - LAN_INTR*/\
+	MUX_VAL(CP(MCSPI1_CS3),		(IEN  | PTD | EN  | M0)) \
+	\
+	MUX_VAL(CP(MCSPI2_CLK),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(MCSPI2_SIMO),	(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(MCSPI2_SOMI),	(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(MCSPI2_CS0),		(IEN  | PTD | EN  | M4)) \
+	MUX_VAL(CP(MCSPI2_CS1),		(IEN  | PTD | EN  | M4)) \
+	/* CCDC */\
+	MUX_VAL(CP(CCDC_PCLK),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(CCDC_FIELD),		(IEN  | PTD | DIS | M1)) \
+	MUX_VAL(CP(CCDC_HD),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(CCDC_VD),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(CCDC_WEN),		(IEN  | PTD | DIS | M1)) \
+	MUX_VAL(CP(CCDC_DATA0),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(CCDC_DATA1),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(CCDC_DATA2),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(CCDC_DATA3),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(CCDC_DATA4),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(CCDC_DATA5),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(CCDC_DATA6),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(CCDC_DATA7),		(IEN  | PTD | DIS | M0)) \
+	/* RMII */\
+	MUX_VAL(CP(RMII_MDIO_DATA),	(IEN  |  M0)) \
+	MUX_VAL(CP(RMII_MDIO_CLK),	(M0)) \
+	MUX_VAL(CP(RMII_RXD0)	,	(IEN  | PTD | M0)) \
+	MUX_VAL(CP(RMII_RXD1),		(IEN  | PTD | M0)) \
+	MUX_VAL(CP(RMII_CRS_DV),	(IEN  | PTD | M0)) \
+	MUX_VAL(CP(RMII_RXER),		(PTD | M0)) \
+	MUX_VAL(CP(RMII_TXD0),		(PTD | M0)) \
+	MUX_VAL(CP(RMII_TXD1),		(PTD | M0)) \
+	MUX_VAL(CP(RMII_TXEN),		(PTD | M0)) \
+	MUX_VAL(CP(RMII_50MHZ_CLK),	(IEN  | PTD | EN  | M0)) \
+	/* HECC */\
+	MUX_VAL(CP(HECC1_TXD),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(HECC1_RXD),		(IEN  | PTU | EN  | M0)) \
+	/* HSUSB */\
+	MUX_VAL(CP(HSUSB0_CLK),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(HSUSB0_STP),		(IDIS | PTU | EN  | M0)) \
+	MUX_VAL(CP(HSUSB0_DIR),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(HSUSB0_NXT),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(HSUSB0_DATA0),	(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(HSUSB0_DATA1),	(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(HSUSB0_DATA2),	(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(HSUSB0_DATA3),	(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(HSUSB0_DATA4),	(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(HSUSB0_DATA5),	(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(HSUSB0_DATA6),	(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(HSUSB0_DATA7),	(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(USB0_DRVBUS),	(IEN  | PTD | EN  | M0)) \
+	/* HDQ */\
+	MUX_VAL(CP(HDQ_SIO),		(IEN  | PTU | EN  | M0)) \
+	/* Control and debug */\
+	MUX_VAL(CP(SYS_32K),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SYS_CLKREQ),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SYS_NIRQ),		(IEN  | PTU | EN  | M0)) \
+	/*SYS_nRESWARM */\
+	MUX_VAL(CP(SYS_NRESWARM),     	(IDIS | PTU | DIS | M4)) \
+							/* - GPIO30 */\
+	MUX_VAL(CP(SYS_BOOT0),		(IEN  | PTD | DIS | M4)) /*GPIO_2*/\
+							 /* - PEN_IRQ */\
+	MUX_VAL(CP(SYS_BOOT1),		(IEN  | PTD | DIS | M4)) /*GPIO_3 */\
+	MUX_VAL(CP(SYS_BOOT2),		(IEN  | PTD | DIS | M4)) /*GPIO_4*/\
+	MUX_VAL(CP(SYS_BOOT3),		(IEN  | PTD | DIS | M4)) /*GPIO_5*/\
+	MUX_VAL(CP(SYS_BOOT4),		(IEN  | PTD | DIS | M4)) /*GPIO_6*/\
+	MUX_VAL(CP(SYS_BOOT5),		(IEN  | PTD | DIS | M4)) /*GPIO_7*/\
+	MUX_VAL(CP(SYS_BOOT6),		(IDIS | PTD | DIS | M4)) /*GPIO_8*/\
+							 /* - VIO_1V8*/\
+	MUX_VAL(CP(SYS_BOOT7),		(IEN  | PTD | EN  | M0)) \
+	MUX_VAL(CP(SYS_BOOT8),		(IEN  | PTD | EN  | M0)) \
+	\
+	MUX_VAL(CP(SYS_OFF_MODE),	(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SYS_CLKOUT1),	(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(SYS_CLKOUT2),	(IEN  | PTU | EN  | M0)) \
+	/* JTAG */\
+	MUX_VAL(CP(JTAG_nTRST),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(JTAG_TCK),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(JTAG_TMS),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(JTAG_TDI),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(JTAG_EMU0),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(JTAG_EMU1),		(IEN  | PTD | DIS | M0)) \
+	/* ETK (ES2 onwards) */\
+	MUX_VAL(CP(ETK_CLK_ES2),	(IDIS | PTU | EN  | M0)) \
+	MUX_VAL(CP(ETK_CTL_ES2),	(IDIS | PTD | DIS | M0)) \
+	MUX_VAL(CP(ETK_D0_ES2),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(ETK_D1_ES2),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(ETK_D2_ES2),		(IEN  | PTD | EN  | M0)) \
+	MUX_VAL(CP(ETK_D3_ES2),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(ETK_D4_ES2),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(ETK_D5_ES2),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(ETK_D6_ES2),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(ETK_D7_ES2),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(ETK_D8_ES2),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(ETK_D9_ES2),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(ETK_D10_ES2),	(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(ETK_D11_ES2),	(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(ETK_D12_ES2),	(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(ETK_D13_ES2),	(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(ETK_D14_ES2),	(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(ETK_D15_ES2),	(IEN  | PTD | DIS | M0)) \
+	/* Die to Die */\
+	MUX_VAL(CP(D2D_MCAD34),		(IEN  | PTD | EN  | M0)) \
+	MUX_VAL(CP(D2D_MCAD35),		(IEN  | PTD | EN  | M0)) \
+	MUX_VAL(CP(D2D_MCAD36),		(IEN  | PTD | EN  | M0)) \
+	MUX_VAL(CP(D2D_CLK26MI),	(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(D2D_NRESPWRON),	(IEN  | PTD | EN  | M0)) \
+	MUX_VAL(CP(D2D_NRESWARM),	(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(D2D_ARM9NIRQ),	(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(D2D_UMA2P6FIQ),	(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(D2D_SPINT),		(IEN  | PTD | EN  | M0)) \
+	MUX_VAL(CP(D2D_FRINT),		(IEN  | PTD | EN  | M0)) \
+	MUX_VAL(CP(D2D_DMAREQ0),	(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(D2D_DMAREQ1),	(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(D2D_DMAREQ2),	(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(D2D_DMAREQ3),	(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(D2D_N3GTRST),	(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(D2D_N3GTDI),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(D2D_N3GTDO),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(D2D_N3GTMS),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(D2D_N3GTCK),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(D2D_N3GRTCK),	(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(D2D_MSTDBY),		(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(D2D_SWAKEUP),	(IEN  | PTD | EN  | M0)) \
+	MUX_VAL(CP(D2D_IDLEREQ),	(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(D2D_IDLEACK),	(IEN  | PTU | EN  | M0)) \
+	MUX_VAL(CP(D2D_MWRITE),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(D2D_SWRITE),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(D2D_MREAD),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(D2D_SREAD),		(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(D2D_MBUSFLAG),	(IEN  | PTD | DIS | M0)) \
+	MUX_VAL(CP(D2D_SBUSFLAG),	(IEN  | PTD | DIS | M0)) \
+
+#endif
diff --git a/board/logicpd/am3517evm/config.mk b/board/logicpd/am3517evm/config.mk
new file mode 100644
index 0000000..f7a35ce
--- /dev/null
+++ b/board/logicpd/am3517evm/config.mk
@@ -0,0 +1,30 @@
+#
+# Author: Vaibhav Hiremath <hvaibhav@ti.com>
+#
+# Based on ti/evm/config.mk
+#
+# Copyright (C) 2010
+# Texas Instruments Incorporated - http://www.ti.com/
+#
+# 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; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+#
+# Physical Address:
+# 8000'0000 (bank0)
+# A000/0000 (bank1)
+# Linux-Kernel is expected to be at 8000'8000, entry 8000'8000
+# (mem base + reserved)
+
+# For use with external or internal boots.
+TEXT_BASE = 0x80e80000
diff --git a/include/configs/am3517_evm.h b/include/configs/am3517_evm.h
new file mode 100644
index 0000000..595b99c
--- /dev/null
+++ b/include/configs/am3517_evm.h
@@ -0,0 +1,296 @@
+/*
+ * am3517_evm.h - Default configuration for AM3517 EVM board.
+ *
+ * Author: Vaibhav Hiremath <hvaibhav@ti.com>
+ *
+ * Based on omap3_evm_config.h
+ *
+ * Copyright (C) 2010 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#ifndef __CONFIG_H
+#define __CONFIG_H
+
+/*
+ * High Level Configuration Options
+ */
+#define CONFIG_ARMCORTEXA8	1	/* This is an ARM V7 CPU core */
+#define CONFIG_OMAP		1	/* in a TI OMAP core */
+#define CONFIG_OMAP34XX		1	/* which is a 34XX */
+#define CONFIG_OMAP3_AM3517EVM	1	/* working with AM3517EVM */
+
+#define CONFIG_EMIF4		1	/* The chip has EMIF4 controller */
+
+#include <asm/arch/cpu.h>		/* get chip and board defs */
+#include <asm/arch/omap3.h>
+
+/*
+ * Display CPU and Board information
+ */
+#define CONFIG_DISPLAY_CPUINFO		1
+#define CONFIG_DISPLAY_BOARDINFO	1
+
+/* Clock Defines */
+#define V_OSCK			26000000	/* Clock output from T2 */
+#define V_SCLK			(V_OSCK >> 1)
+
+#undef CONFIG_USE_IRQ				/* no support for IRQs */
+#define CONFIG_MISC_INIT_R
+
+#define CONFIG_CMDLINE_TAG		1	/* enable passing of ATAGs */
+#define CONFIG_SETUP_MEMORY_TAGS	1
+#define CONFIG_INITRD_TAG		1
+#define CONFIG_REVISION_TAG		1
+
+/*
+ * Size of malloc() pool
+ */
+#define CONFIG_ENV_SIZE			(128 << 10)	/* 128 KiB sector */
+#define CONFIG_SYS_MALLOC_LEN		(CONFIG_ENV_SIZE + (128 << 10))
+#define CONFIG_SYS_GBL_DATA_SIZE	128	/* bytes reserved for */
+						/* initial data */
+/*
+ * DDR related
+ */
+#define CONFIG_OMAP3_MICRON_DDR		1	/* Micron DDR */
+#define CONFIG_SYS_CS0_SIZE		(256 * 1024 * 1024)
+
+/*
+ * Hardware drivers
+ */
+
+/*
+ * NS16550 Configuration
+ */
+#define V_NS16550_CLK			48000000	/* 48MHz (APLL96/2) */
+
+#define CONFIG_SYS_NS16550
+#define CONFIG_SYS_NS16550_SERIAL
+#define CONFIG_SYS_NS16550_REG_SIZE	(-4)
+#define CONFIG_SYS_NS16550_CLK		V_NS16550_CLK
+
+/*
+ * select serial console configuration
+ */
+#define CONFIG_CONS_INDEX		3
+#define CONFIG_SYS_NS16550_COM3		OMAP34XX_UART3
+#define CONFIG_SERIAL3			3	/* UART3 on AM3517 EVM */
+
+/* allow to overwrite serial and ethaddr */
+#define CONFIG_ENV_OVERWRITE
+#define CONFIG_BAUDRATE			115200
+#define CONFIG_SYS_BAUDRATE_TABLE	{4800, 9600, 19200, 38400, 57600,\
+					115200}
+#define CONFIG_MMC			1
+#define CONFIG_OMAP3_MMC		1
+#define CONFIG_DOS_PARTITION		1
+
+/* commands to include */
+#include <config_cmd_default.h>
+
+#define CONFIG_CMD_EXT2		/* EXT2 Support			*/
+#define CONFIG_CMD_FAT		/* FAT support			*/
+#define CONFIG_CMD_JFFS2	/* JFFS2 Support		*/
+
+#define CONFIG_CMD_I2C		/* I2C serial bus support	*/
+#define CONFIG_CMD_MMC		/* MMC support			*/
+#define CONFIG_CMD_NAND		/* NAND support			*/
+#define CONFIG_CMD_DHCP
+#define CONFIG_CMD_PING
+
+#undef CONFIG_CMD_FLASH		/* flinfo, erase, protect	*/
+#undef CONFIG_CMD_FPGA		/* FPGA configuration Support	*/
+#undef CONFIG_CMD_IMI		/* iminfo			*/
+#undef CONFIG_CMD_IMLS		/* List all found images	*/
+
+#define CONFIG_SYS_NO_FLASH
+#define CONFIG_HARD_I2C			1
+#define CONFIG_SYS_I2C_SPEED		100000
+#define CONFIG_SYS_I2C_SLAVE		1
+#define CONFIG_SYS_I2C_BUS		0
+#define CONFIG_SYS_I2C_BUS_SELECT	1
+#define CONFIG_DRIVER_OMAP34XX_I2C	1
+
+#undef CONFIG_CMD_NET
+/*
+ * Board NAND Info.
+ */
+#define CONFIG_SYS_NAND_ADDR		NAND_BASE	/* physical address */
+							/* to access nand */
+#define CONFIG_SYS_NAND_BASE		NAND_BASE	/* physical address */
+							/* to access */
+							/* nand at CS0 */
+
+#define CONFIG_SYS_MAX_NAND_DEVICE	1		/* Max number of */
+							/* NAND devices */
+#define CONFIG_SYS_64BIT_VSPRINTF		/* needed for nand_util.c */
+
+#define CONFIG_JFFS2_NAND
+/* nand device jffs2 lives on */
+#define CONFIG_JFFS2_DEV		"nand0"
+/* start of jffs2 partition */
+#define CONFIG_JFFS2_PART_OFFSET	0x680000
+#define CONFIG_JFFS2_PART_SIZE		0xf980000	/* sz of jffs2 part */
+
+/* Environment information */
+#define CONFIG_BOOTDELAY	10
+
+#define CONFIG_BOOTFILE		uImage
+
+#define CONFIG_EXTRA_ENV_SETTINGS \
+	"loadaddr=0x82000000\0" \
+	"console=ttyS2,115200n8\0" \
+	"mmcargs=setenv bootargs console=${console} " \
+		"root=/dev/mmcblk0p2 rw " \
+		"rootfstype=ext3 rootwait\0" \
+	"nandargs=setenv bootargs console=${console} " \
+		"root=/dev/mtdblock4 rw " \
+		"rootfstype=jffs2\0" \
+	"loadbootscript=fatload mmc 0 ${loadaddr} boot.scr\0" \
+	"bootscript=echo Running bootscript from mmc ...; " \
+		"source ${loadaddr}\0" \
+	"loaduimage=fatload mmc 0 ${loadaddr} uImage\0" \
+	"mmcboot=echo Booting from mmc ...; " \
+		"run mmcargs; " \
+		"bootm ${loadaddr}\0" \
+	"nandboot=echo Booting from nand ...; " \
+		"run nandargs; " \
+		"nand read ${loadaddr} 280000 400000; " \
+		"bootm ${loadaddr}\0" \
+
+#define CONFIG_BOOTCOMMAND \
+	"if mmc init; then " \
+		"if run loadbootscript; then " \
+			"run bootscript; " \
+		"else " \
+			"if run loaduimage; then " \
+				"run mmcboot; " \
+			"else run nandboot; " \
+			"fi; " \
+		"fi; " \
+	"else run nandboot; fi"
+
+#define CONFIG_AUTO_COMPLETE	1
+/*
+ * Miscellaneous configurable options
+ */
+#define V_PROMPT			"AM3517_EVM # "
+
+#define CONFIG_SYS_LONGHELP		/* undef to save memory */
+#define CONFIG_SYS_HUSH_PARSER		/* use "hush" command parser */
+#define CONFIG_SYS_PROMPT_HUSH_PS2	"> "
+#define CONFIG_SYS_PROMPT		V_PROMPT
+#define CONFIG_SYS_CBSIZE		512	/* Console I/O Buffer Size */
+/* Print Buffer Size */
+#define CONFIG_SYS_PBSIZE		(CONFIG_SYS_CBSIZE + \
+					sizeof(CONFIG_SYS_PROMPT) + 16)
+#define CONFIG_SYS_MAXARGS		32	/* max number of command */
+						/* args */
+/* Boot Argument Buffer Size */
+#define CONFIG_SYS_BARGSIZE		(CONFIG_SYS_CBSIZE)
+/* memtest works on */
+#define CONFIG_SYS_MEMTEST_START	(OMAP34XX_SDRC_CS0)
+#define CONFIG_SYS_MEMTEST_END		(OMAP34XX_SDRC_CS0 + \
+					0x01F00000) /* 31MB */
+
+#define CONFIG_SYS_LOAD_ADDR		(OMAP34XX_SDRC_CS0) /* default load */
+								/* address */
+
+/*
+ * AM3517 has 12 GP timers, they can be driven by the system clock
+ * (12/13/16.8/19.2/38.4MHz) or by 32KHz clock. We use 13MHz (V_SCLK).
+ * This rate is divided by a local divisor.
+ */
+#define CONFIG_SYS_TIMERBASE		OMAP34XX_GPT2
+#define CONFIG_SYS_PTV			2	/* Divisor: 2^(PTV+1) => 8 */
+#define CONFIG_SYS_HZ			1000
+
+/*-----------------------------------------------------------------------
+ * Stack sizes
+ *
+ * The stack sizes are set up in start.S using the settings below
+ */
+#define CONFIG_STACKSIZE	(128 << 10)	/* regular stack 128 KiB */
+#ifdef CONFIG_USE_IRQ
+#define CONFIG_STACKSIZE_IRQ	(4 << 10)	/* IRQ stack 4 KiB */
+#define CONFIG_STACKSIZE_FIQ	(4 << 10)	/* FIQ stack 4 KiB */
+#endif
+
+/*-----------------------------------------------------------------------
+ * Physical Memory Map
+ */
+#define CONFIG_NR_DRAM_BANKS	2	/* CS1 may or may not be populated */
+#define PHYS_SDRAM_1		OMAP34XX_SDRC_CS0
+#define PHYS_SDRAM_1_SIZE	(32 << 20)	/* at least 32 MiB */
+#define PHYS_SDRAM_2		OMAP34XX_SDRC_CS1
+
+/* SDRAM Bank Allocation method */
+#define SDRC_R_B_C		1
+
+/*-----------------------------------------------------------------------
+ * FLASH and environment organization
+ */
+
+/* **** PISMO SUPPORT *** */
+
+/* Configure the PISMO */
+#define PISMO1_NAND_SIZE		GPMC_SIZE_128M
+#define PISMO1_ONEN_SIZE		GPMC_SIZE_128M
+
+#define CONFIG_SYS_MAX_FLASH_SECT	520	/* max number of sectors */
+						/* on one chip */
+#define CONFIG_SYS_MAX_FLASH_BANKS	2	/* max number of flash banks */
+#define CONFIG_SYS_MONITOR_LEN		(256 << 10)	/* Reserve 2 sectors */
+
+#define CONFIG_SYS_FLASH_BASE		boot_flash_base
+
+/* Monitor@start of flash */
+#define CONFIG_SYS_MONITOR_BASE		CONFIG_SYS_FLASH_BASE
+
+#define CONFIG_NAND_OMAP_GPMC
+#define GPMC_NAND_ECC_LP_x16_LAYOUT	1
+#define CONFIG_ENV_IS_IN_NAND		1
+#define SMNAND_ENV_OFFSET		0x260000 /* environment starts here */
+
+#define CONFIG_SYS_ENV_SECT_SIZE	boot_flash_sec
+#define CONFIG_ENV_OFFSET		boot_flash_off
+#define CONFIG_ENV_ADDR			boot_flash_env_addr
+
+/*-----------------------------------------------------------------------
+ * CFI FLASH driver setup
+ */
+/* timeout values are in ticks */
+#define CONFIG_SYS_FLASH_ERASE_TOUT	(100 * CONFIG_SYS_HZ)
+#define CONFIG_SYS_FLASH_WRITE_TOUT	(100 * CONFIG_SYS_HZ)
+
+/* Flash banks JFFS2 should use */
+#define CONFIG_SYS_MAX_MTD_BANKS	(CONFIG_SYS_MAX_FLASH_BANKS + \
+					CONFIG_SYS_MAX_NAND_DEVICE)
+#define CONFIG_SYS_JFFS2_MEM_NAND
+/* use flash_info[2] */
+#define CONFIG_SYS_JFFS2_FIRST_BANK	CONFIG_SYS_MAX_FLASH_BANKS
+#define CONFIG_SYS_JFFS2_NUM_BANKS	1
+
+#ifndef __ASSEMBLY__
+extern unsigned int boot_flash_base;
+extern volatile unsigned int boot_flash_env_addr;
+extern unsigned int boot_flash_off;
+extern unsigned int boot_flash_sec;
+extern unsigned int boot_flash_type;
+#endif
+
+#endif /* __CONFIG_H */
--
1.6.2.4

^ permalink raw reply related	[flat|nested] 263+ messages in thread

* [U-Boot] [PATCH-V4 1/2] AM35x: Add support for AM3517EVM
  2010-06-07 14:59 ` [U-Boot] [PATCH-V4 1/2] AM35x: Add support for AM3517EVM hvaibhav at ti.com
@ 2010-06-07 21:20   ` Paulraj, Sandeep
  0 siblings, 0 replies; 263+ messages in thread
From: Paulraj, Sandeep @ 2010-06-07 21:20 UTC (permalink / raw)
  To: u-boot


> 
> From: Vaibhav Hiremath <hvaibhav@ti.com>
> 
> This patch adds basic support for the AM3517EVM.
> It includes:
> 	- Board files (.c and .h)
> 	- Default configuration file
> 	- Updates for Makefile
> 
> Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
> Signed-off-by: Sanjeev Premi <premi@ti.com>
> ---
> Changes from V2:
> 	- Removed trailing spaces
> 	- Updated MAINTAINERS & MAKEALL for am3517_evm
> Changes from V3:
> 	- Corrected Maintainer entry to keep list sorted
> 	- Moved AM3537 macros to board header file
> 
>  MAINTAINERS                         |    4 +
>  MAKEALL                             |    1 +
>  Makefile                            |    3 +
>  board/logicpd/am3517evm/Makefile    |   46 ++++
>  board/logicpd/am3517evm/am3517evm.c |   76 ++++++
>  board/logicpd/am3517evm/am3517evm.h |  445
> +++++++++++++++++++++++++++++++++++
>  board/logicpd/am3517evm/config.mk   |   30 +++
>  include/configs/am3517_evm.h        |  296 +++++++++++++++++++++++
>  8 files changed, 901 insertions(+), 0 deletions(-)
>  create mode 100644 board/logicpd/am3517evm/Makefile
>  create mode 100644 board/logicpd/am3517evm/am3517evm.c
>  create mode 100644 board/logicpd/am3517evm/am3517evm.h
>  create mode 100644 board/logicpd/am3517evm/config.mk
>  create mode 100644 include/configs/am3517_evm.h

I have pushed the following to u-boot-ti AFTER running MAKEALL for ALL
CORTEX AB boards

I pushed the following patches. There were some checkpatch errors. I fixed them myself.

[PATCH-V4 1/2] AM35x: Add support for AM3517EVM
[PATCH-V4 2/2] AM35x: Add support for EMIF4

[PATCH-V3 1/2] omap3: Calculate CS1 size only when SDRC is initialized for CS1
[PATCH-V3 2/2] omap3: Consolidate SDRC related operations

[PATCH-V4] OMAP3EVM: Added NAND support

Thanks,
Sandeep

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [U-Boot] [PATCH] AM3517:Fix for ARM Relocation support
@ 2010-11-29 16:21 ` hvaibhav at ti.com
  2010-11-29 16:24   ` Hiremath, Vaibhav
  0 siblings, 1 reply; 263+ messages in thread
From: hvaibhav at ti.com @ 2010-11-29 16:21 UTC (permalink / raw)
  To: u-boot

From: Vaibhav Hiremath <hvaibhav@ti.com>

Also change the CONFIG_SYS_TEXT_BASE to 0x80008000, required
with relocation support. This is the load address for primary
boot loader (x-loader).

Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
---
 board/logicpd/am3517evm/config.mk |    2 +-
 include/configs/am3517_evm.h      |    6 ++++++
 2 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/board/logicpd/am3517evm/config.mk b/board/logicpd/am3517evm/config.mk
index 102d32b..71ec5d0 100644
--- a/board/logicpd/am3517evm/config.mk
+++ b/board/logicpd/am3517evm/config.mk
@@ -27,4 +27,4 @@
 # (mem base + reserved)
 
 # For use with external or internal boots.
-CONFIG_SYS_TEXT_BASE = 0x80e80000
+CONFIG_SYS_TEXT_BASE = 0x80008000
diff --git a/include/configs/am3517_evm.h b/include/configs/am3517_evm.h
index 9a9ba88..3dda1e9 100644
--- a/include/configs/am3517_evm.h
+++ b/include/configs/am3517_evm.h
@@ -330,4 +330,10 @@ extern unsigned int boot_flash_sec;
 extern unsigned int boot_flash_type;
 #endif
 
+#define CONFIG_SYS_SDRAM_BASE		PHYS_SDRAM_1
+#define CONFIG_SYS_INIT_RAM_ADDR	0x4020f800
+#define CONFIG_SYS_INIT_RAM_SIZE	0x800
+#define CONFIG_SYS_INIT_SP_ADDR		(CONFIG_SYS_INIT_RAM_ADDR + \
+					 CONFIG_SYS_INIT_RAM_SIZE - \
+					 GENERATED_GBL_DATA_SIZE)
 #endif /* __CONFIG_H */
-- 
1.6.2.4

^ permalink raw reply related	[flat|nested] 263+ messages in thread

* [U-Boot] [PATCH] AM3517:Build FIX: undef CONFIG_CMD_NFS support
@ 2010-11-29 16:22 ` hvaibhav at ti.com
  2010-11-29 21:36   ` Paulraj, Sandeep
  0 siblings, 1 reply; 263+ messages in thread
From: hvaibhav at ti.com @ 2010-11-29 16:22 UTC (permalink / raw)
  To: u-boot

From: Vaibhav Hiremath <hvaibhav@ti.com>

Without CONFIG_CMD_NET support CONFIG_CMD_NFS leads
to linking error, so disable CONFIG_CMD_NFS option.

Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
---
 include/configs/am3517_evm.h |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/include/configs/am3517_evm.h b/include/configs/am3517_evm.h
index 3dda1e9..70e8f07 100644
--- a/include/configs/am3517_evm.h
+++ b/include/configs/am3517_evm.h
@@ -163,6 +163,7 @@
 #define CONFIG_DRIVER_OMAP34XX_I2C	1
 
 #undef CONFIG_CMD_NET
+#undef CONFIG_CMD_NFS
 /*
  * Board NAND Info.
  */
-- 
1.6.2.4

^ permalink raw reply related	[flat|nested] 263+ messages in thread

* [U-Boot] [PATCH] AM3517:EMIF4: fix SDRAM size to 256Mb
@ 2010-11-29 16:23 ` hvaibhav at ti.com
  2010-11-29 21:36   ` Paulraj, Sandeep
  2010-11-29 21:37   ` Paulraj, Sandeep
  0 siblings, 2 replies; 263+ messages in thread
From: hvaibhav at ti.com @ 2010-11-29 16:23 UTC (permalink / raw)
  To: u-boot

From: Vaibhav Hiremath <hvaibhav@ti.com>

With addition of "dram_init_banksize()" function from Heiko,Schocher
(commit ID: 561142af20f1fd7b425d9425730014e656defb91), the DRAM size
is getting configured wrongly to 512Mb (CS0 & CS1).
So fix it to 256Mb.

Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
---
 arch/arm/cpu/armv7/omap3/emif4.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/arch/arm/cpu/armv7/omap3/emif4.c b/arch/arm/cpu/armv7/omap3/emif4.c
index 0870857..2227576 100644
--- a/arch/arm/cpu/armv7/omap3/emif4.c
+++ b/arch/arm/cpu/armv7/omap3/emif4.c
@@ -48,10 +48,11 @@ u32 is_mem_sdr(void)
  */
 u32 get_sdr_cs_size(u32 cs)
 {
-	u32 size;
+	u32 size = 0;
 
 	/* TODO: Calculate the size based on EMIF4 configuration */
-	size = CONFIG_SYS_CS0_SIZE;
+	if (cs == CS0)
+		size = CONFIG_SYS_CS0_SIZE;
 
 	return size;
 }
-- 
1.6.2.4

^ permalink raw reply related	[flat|nested] 263+ messages in thread

* [U-Boot] [PATCH] AM3517:Fix for ARM Relocation support
  2010-11-29 16:21 ` [U-Boot] [PATCH] AM3517:Fix for ARM Relocation support hvaibhav at ti.com
@ 2010-11-29 16:24   ` Hiremath, Vaibhav
  2010-11-29 16:32     ` Paulraj, Sandeep
  0 siblings, 1 reply; 263+ messages in thread
From: Hiremath, Vaibhav @ 2010-11-29 16:24 UTC (permalink / raw)
  To: u-boot


> -----Original Message-----
> From: Hiremath, Vaibhav
> Sent: Monday, November 29, 2010 9:52 PM
> To: u-boot at lists.denx.de
> Cc: albert at aribaud.net; Paulraj, Sandeep; Hiremath, Vaibhav
> Subject: [PATCH] AM3517:Fix for ARM Relocation support
> 
> From: Vaibhav Hiremath <hvaibhav@ti.com>
> 
> Also change the CONFIG_SYS_TEXT_BASE to 0x80008000, required
> with relocation support. This is the load address for primary
> boot loader (x-loader).
> 
[Hiremath, Vaibhav] Albert, Denk and Sandeep,

I have tested this patch with Makefile change (remove sorting of $LIB) on AM3517EVM.

Thanks,
Vaibhav

> Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
> ---
>  board/logicpd/am3517evm/config.mk |    2 +-
>  include/configs/am3517_evm.h      |    6 ++++++
>  2 files changed, 7 insertions(+), 1 deletions(-)
> 
> diff --git a/board/logicpd/am3517evm/config.mk
> b/board/logicpd/am3517evm/config.mk
> index 102d32b..71ec5d0 100644
> --- a/board/logicpd/am3517evm/config.mk
> +++ b/board/logicpd/am3517evm/config.mk
> @@ -27,4 +27,4 @@
>  # (mem base + reserved)
> 
>  # For use with external or internal boots.
> -CONFIG_SYS_TEXT_BASE = 0x80e80000
> +CONFIG_SYS_TEXT_BASE = 0x80008000
> diff --git a/include/configs/am3517_evm.h b/include/configs/am3517_evm.h
> index 9a9ba88..3dda1e9 100644
> --- a/include/configs/am3517_evm.h
> +++ b/include/configs/am3517_evm.h
> @@ -330,4 +330,10 @@ extern unsigned int boot_flash_sec;
>  extern unsigned int boot_flash_type;
>  #endif
> 
> +#define CONFIG_SYS_SDRAM_BASE		PHYS_SDRAM_1
> +#define CONFIG_SYS_INIT_RAM_ADDR	0x4020f800
> +#define CONFIG_SYS_INIT_RAM_SIZE	0x800
> +#define CONFIG_SYS_INIT_SP_ADDR		(CONFIG_SYS_INIT_RAM_ADDR + \
> +					 CONFIG_SYS_INIT_RAM_SIZE - \
> +					 GENERATED_GBL_DATA_SIZE)
>  #endif /* __CONFIG_H */
> --
> 1.6.2.4

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [U-Boot] [PATCH] AM3517:Fix for ARM Relocation support
  2010-11-29 16:24   ` Hiremath, Vaibhav
@ 2010-11-29 16:32     ` Paulraj, Sandeep
  0 siblings, 0 replies; 263+ messages in thread
From: Paulraj, Sandeep @ 2010-11-29 16:32 UTC (permalink / raw)
  To: u-boot



> 
> > -----Original Message-----
> > From: Hiremath, Vaibhav
> > Sent: Monday, November 29, 2010 9:52 PM
> > To: u-boot at lists.denx.de
> > Cc: albert at aribaud.net; Paulraj, Sandeep; Hiremath, Vaibhav
> > Subject: [PATCH] AM3517:Fix for ARM Relocation support
> >
> > From: Vaibhav Hiremath <hvaibhav@ti.com>
> >
> > Also change the CONFIG_SYS_TEXT_BASE to 0x80008000, required
> > with relocation support. This is the load address for primary
> > boot loader (x-loader).
> >
> [Hiremath, Vaibhav] Albert, Denk and Sandeep,

Thanks,

I will apply this set to u-boot-ti/master sometime tonight and send a pull request to Wolfgang.



> 
> I have tested this patch with Makefile change (remove sorting of $LIB) on
> AM3517EVM.
> 
> Thanks,
> Vaibhav

Regards,
Sandeep

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [U-Boot] [PATCH] AM3517:EMIF4: fix SDRAM size to 256Mb
  2010-11-29 16:23 ` [U-Boot] [PATCH] AM3517:EMIF4: fix SDRAM size to 256Mb hvaibhav at ti.com
@ 2010-11-29 21:36   ` Paulraj, Sandeep
  2010-11-29 21:37   ` Paulraj, Sandeep
  1 sibling, 0 replies; 263+ messages in thread
From: Paulraj, Sandeep @ 2010-11-29 21:36 UTC (permalink / raw)
  To: u-boot



> 
> From: Vaibhav Hiremath <hvaibhav@ti.com>
> 
> With addition of "dram_init_banksize()" function from Heiko,Schocher
> (commit ID: 561142af20f1fd7b425d9425730014e656defb91), the DRAM size
> is getting configured wrongly to 512Mb (CS0 & CS1).
> So fix it to 256Mb.
> 
> Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
> ---
Pushed to u-boot-ti

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [U-Boot] [PATCH] AM3517:Build FIX: undef CONFIG_CMD_NFS support
  2010-11-29 16:22 ` [U-Boot] [PATCH] AM3517:Build FIX: undef CONFIG_CMD_NFS support hvaibhav at ti.com
@ 2010-11-29 21:36   ` Paulraj, Sandeep
  0 siblings, 0 replies; 263+ messages in thread
From: Paulraj, Sandeep @ 2010-11-29 21:36 UTC (permalink / raw)
  To: u-boot



> 
> From: Vaibhav Hiremath <hvaibhav@ti.com>
> 
> Without CONFIG_CMD_NET support CONFIG_CMD_NFS leads
> to linking error, so disable CONFIG_CMD_NFS option.
> 
> Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
> ---
>  include/configs/am3517_evm.h |    1 +
>  1 files changed, 1 insertions(+), 0 deletions(-)
> 
> diff --git a/include/configs/am3517_evm.h b/include/configs/am3517_evm.h
> index 3dda1e9..70e8f07 100644
> --- a/include/configs/am3517_evm.h
> +++ b/include/configs/am3517_evm.h
> @@ -163,6 +163,7 @@
>  #define CONFIG_DRIVER_OMAP34XX_I2C	1
> 
>  #undef CONFIG_CMD_NET
> +#undef CONFIG_CMD_NFS
>  /*
>   * Board NAND Info.
>   */
> --
> 1.6.2.4
Pushed to u-boot-ti

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [U-Boot] [PATCH] AM3517:EMIF4: fix SDRAM size to 256Mb
  2010-11-29 16:23 ` [U-Boot] [PATCH] AM3517:EMIF4: fix SDRAM size to 256Mb hvaibhav at ti.com
  2010-11-29 21:36   ` Paulraj, Sandeep
@ 2010-11-29 21:37   ` Paulraj, Sandeep
  1 sibling, 0 replies; 263+ messages in thread
From: Paulraj, Sandeep @ 2010-11-29 21:37 UTC (permalink / raw)
  To: u-boot



> From: Vaibhav Hiremath <hvaibhav@ti.com>
> 
> With addition of "dram_init_banksize()" function from Heiko,Schocher
> (commit ID: 561142af20f1fd7b425d9425730014e656defb91), the DRAM size
> is getting configured wrongly to 512Mb (CS0 & CS1).
> So fix it to 256Mb.
> 
> Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
> ---
>  arch/arm/cpu/armv7/omap3/emif4.c |    5 +++--
>  1 files changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/arm/cpu/armv7/omap3/emif4.c
> b/arch/arm/cpu/armv7/omap3/emif4.c
> index 0870857..2227576 100644
> --- a/arch/arm/cpu/armv7/omap3/emif4.c
> +++ b/arch/arm/cpu/armv7/omap3/emif4.c
> @@ -48,10 +48,11 @@ u32 is_mem_sdr(void)
>   */
>  u32 get_sdr_cs_size(u32 cs)
>  {
> -	u32 size;
> +	u32 size = 0;
> 
>  	/* TODO: Calculate the size based on EMIF4 configuration */
> -	size = CONFIG_SYS_CS0_SIZE;
> +	if (cs == CS0)
> +		size = CONFIG_SYS_CS0_SIZE;
> 
>  	return size;
>  }
> --
> 1.6.2.4

Pushed to u-boot-ti

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [U-Boot] [PATCH] omap3evm: Use generic MMC driver
@ 2011-08-01 14:21 ` hvaibhav at ti.com
  2011-08-17  2:32   ` Andy Fleming
  0 siblings, 1 reply; 263+ messages in thread
From: hvaibhav at ti.com @ 2011-08-01 14:21 UTC (permalink / raw)
  To: u-boot

From: Vaibhav Hiremath <hvaibhav@ti.com>

Switch from the legacy mmc driver to the
new generic mmc driver.

This patch is based on similar patch for beagle[1].

 [1] http://git.denx.de/?p=u-boot.git;a=commitdiff_plain;h=0cd31144240

Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
Signed-off-by: Sanjeev Premi <premi@ti.com>
---
 board/ti/evm/evm.c          |    9 +++++++++
 include/configs/omap3_evm.h |   10 ++++++----
 2 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/board/ti/evm/evm.c b/board/ti/evm/evm.c
index aaf3033..916a13e 100644
--- a/board/ti/evm/evm.c
+++ b/board/ti/evm/evm.c
@@ -33,6 +33,7 @@
 #include <asm/arch/mem.h>
 #include <asm/arch/mux.h>
 #include <asm/arch/sys_proto.h>
+#include <asm/arch/mmc_host_def.h>
 #include <i2c.h>
 #include <asm/mach-types.h>
 #include "evm.h"
@@ -192,3 +193,11 @@ int board_eth_init(bd_t *bis)
 #endif
 	return rc;
 }
+
+#ifdef CONFIG_GENERIC_MMC
+int board_mmc_init(bd_t *bis)
+{
+       omap_mmc_init(0);
+       return 0;
+}
+#endif
diff --git a/include/configs/omap3_evm.h b/include/configs/omap3_evm.h
index 6455b0e..72c00ab 100644
--- a/include/configs/omap3_evm.h
+++ b/include/configs/omap3_evm.h
@@ -99,7 +99,8 @@
 #define CONFIG_SYS_BAUDRATE_TABLE	{4800, 9600, 19200, 38400, 57600,\
 					115200}
 #define CONFIG_MMC			1
-#define CONFIG_OMAP3_MMC		1
+#define CONFIG_GENERIC_MMC		1
+#define CONFIG_OMAP_HSMMC		1
 #define CONFIG_DOS_PARTITION		1

 /* DDR - I use Micron DDR */
@@ -200,6 +201,7 @@
 #define CONFIG_EXTRA_ENV_SETTINGS \
 	"loadaddr=0x82000000\0" \
 	"usbtty=cdc_acm\0" \
+	"mmcdev=0\0" \
 	"console=ttyS2,115200n8\0" \
 	"mmcargs=setenv bootargs console=${console} " \
 		"root=/dev/mmcblk0p2 rw " \
@@ -207,10 +209,10 @@
 	"nandargs=setenv bootargs console=${console} " \
 		"root=/dev/mtdblock4 rw " \
 		"rootfstype=jffs2\0" \
-	"loadbootscript=fatload mmc 0 ${loadaddr} boot.scr\0" \
+	"loadbootscript=fatload mmc ${mmcdev} ${loadaddr} boot.scr\0" \
 	"bootscript=echo Running bootscript from mmc ...; " \
 		"source ${loadaddr}\0" \
-	"loaduimage=fatload mmc 0 ${loadaddr} uImage\0" \
+	"loaduimage=fatload mmc ${mmcdev} ${loadaddr} uImage\0" \
 	"mmcboot=echo Booting from mmc ...; " \
 		"run mmcargs; " \
 		"bootm ${loadaddr}\0" \
@@ -220,7 +222,7 @@
 		"bootm ${loadaddr}\0" \

 #define CONFIG_BOOTCOMMAND \
-	"if mmc init; then " \
+	"if mmc rescan ${mmcdev}; then " \
 		"if run loadbootscript; then " \
 			"run bootscript; " \
 		"else " \
--
1.6.2.4

^ permalink raw reply related	[flat|nested] 263+ messages in thread

* [U-Boot] [PATCH] am3517evm: Use generic MMC driver
@ 2011-08-01 14:21 ` hvaibhav at ti.com
  2011-08-17  2:33   ` Andy Fleming
  0 siblings, 1 reply; 263+ messages in thread
From: hvaibhav at ti.com @ 2011-08-01 14:21 UTC (permalink / raw)
  To: u-boot

From: Vaibhav Hiremath <hvaibhav@ti.com>

Switch from the legacy mmc driver to the
new generic mmc driver.

This patch is based on similar patch for beagle[1].

 [1] http://git.denx.de/?p=u-boot.git;a=commitdiff_plain;h=0cd31144240

Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
Signed-off-by: Sanjeev Premi <premi@ti.com>
---
 board/logicpd/am3517evm/am3517evm.c |    9 +++++++++
 include/configs/am3517_evm.h        |   12 +++++++-----
 2 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/board/logicpd/am3517evm/am3517evm.c b/board/logicpd/am3517evm/am3517evm.c
index bbb6e83..c0a006a 100644
--- a/board/logicpd/am3517evm/am3517evm.c
+++ b/board/logicpd/am3517evm/am3517evm.c
@@ -28,6 +28,7 @@
 #include <asm/arch/mem.h>
 #include <asm/arch/mux.h>
 #include <asm/arch/sys_proto.h>
+#include <asm/arch/mmc_host_def.h>
 #include <asm/mach-types.h>
 #include <i2c.h>
 #include "am3517evm.h"
@@ -74,3 +75,11 @@ void set_muxconf_regs(void)
 {
 	MUX_AM3517EVM();
 }
+
+#ifdef CONFIG_GENERIC_MMC
+int board_mmc_init(bd_t *bis)
+{
+       omap_mmc_init(0);
+       return 0;
+}
+#endif
diff --git a/include/configs/am3517_evm.h b/include/configs/am3517_evm.h
index 70e8f07..caae7fe 100644
--- a/include/configs/am3517_evm.h
+++ b/include/configs/am3517_evm.h
@@ -95,7 +95,8 @@
 #define CONFIG_SYS_BAUDRATE_TABLE	{4800, 9600, 19200, 38400, 57600,\
 					115200}
 #define CONFIG_MMC			1
-#define CONFIG_OMAP3_MMC		1
+#define CONFIG_GENERIC_MMC		1
+#define CONFIG_OMAP_HSMMC		1
 #define CONFIG_DOS_PARTITION		1

 /*
@@ -191,17 +192,18 @@

 #define CONFIG_EXTRA_ENV_SETTINGS \
 	"loadaddr=0x82000000\0" \
-	"console=ttyS2,115200n8\0" \
+	"console=ttyO2,115200n8\0" \
+	"mmcdev=0\0" \
 	"mmcargs=setenv bootargs console=${console} " \
 		"root=/dev/mmcblk0p2 rw " \
 		"rootfstype=ext3 rootwait\0" \
 	"nandargs=setenv bootargs console=${console} " \
 		"root=/dev/mtdblock4 rw " \
 		"rootfstype=jffs2\0" \
-	"loadbootscript=fatload mmc 0 ${loadaddr} boot.scr\0" \
+	"loadbootscript=fatload mmc ${mmcdev} ${loadaddr} boot.scr\0" \
 	"bootscript=echo Running bootscript from mmc ...; " \
 		"source ${loadaddr}\0" \
-	"loaduimage=fatload mmc 0 ${loadaddr} uImage\0" \
+	"loaduimage=fatload mmc ${mmcdev} ${loadaddr} uImage\0" \
 	"mmcboot=echo Booting from mmc ...; " \
 		"run mmcargs; " \
 		"bootm ${loadaddr}\0" \
@@ -211,7 +213,7 @@
 		"bootm ${loadaddr}\0" \

 #define CONFIG_BOOTCOMMAND \
-	"if mmc init; then " \
+	"if mmc rescan ${mmcdev}; then " \
 		"if run loadbootscript; then " \
 			"run bootscript; " \
 		"else " \
--
1.6.2.4

^ permalink raw reply related	[flat|nested] 263+ messages in thread

* [U-Boot] [PATCH] omap3evm: Use generic MMC driver
  2011-08-01 14:21 ` [U-Boot] [PATCH] omap3evm: Use generic MMC driver hvaibhav at ti.com
@ 2011-08-17  2:32   ` Andy Fleming
  0 siblings, 0 replies; 263+ messages in thread
From: Andy Fleming @ 2011-08-17  2:32 UTC (permalink / raw)
  To: u-boot

On Mon, Aug 1, 2011 at 9:21 AM,  <hvaibhav@ti.com> wrote:
> From: Vaibhav Hiremath <hvaibhav@ti.com>
>
> Switch from the legacy mmc driver to the
> new generic mmc driver.
>
> This patch is based on similar patch for beagle[1].
>
> ?[1] http://git.denx.de/?p=u-boot.git;a=commitdiff_plain;h=0cd31144240
>
> Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
> Signed-off-by: Sanjeev Premi <premi@ti.com>

Acked-by: Andy Fleming <afleming@freescale.com>

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [U-Boot] [PATCH] am3517evm: Use generic MMC driver
  2011-08-01 14:21 ` [U-Boot] [PATCH] am3517evm: " hvaibhav at ti.com
@ 2011-08-17  2:33   ` Andy Fleming
  0 siblings, 0 replies; 263+ messages in thread
From: Andy Fleming @ 2011-08-17  2:33 UTC (permalink / raw)
  To: u-boot

On Mon, Aug 1, 2011 at 9:21 AM,  <hvaibhav@ti.com> wrote:
> From: Vaibhav Hiremath <hvaibhav@ti.com>
>
> Switch from the legacy mmc driver to the
> new generic mmc driver.
>
> This patch is based on similar patch for beagle[1].
>
> ?[1] http://git.denx.de/?p=u-boot.git;a=commitdiff_plain;h=0cd31144240
>
> Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
> Signed-off-by: Sanjeev Premi <premi@ti.com>

Acked-by: Andy Fleming <afleming@freescale.com>

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [RFC PATCH-V2 0/4] Introducing TI's New SoC/board AM335XEVM
@ 2011-08-29 12:46 ` hvaibhav at ti.com
  0 siblings, 0 replies; 263+ messages in thread
From: hvaibhav @ 2011-08-29 12:46 UTC (permalink / raw)
  To: linux-omap; +Cc: tony, khilman, paul, linux-arm-kernel, Vaibhav Hiremath

From: Vaibhav Hiremath <hvaibhav@ti.com>

This patch set adds support for AM335x device having
Cortex-A8 MPU.

AM335X is treated as another OMAP3 variant, where,
along with existing cpu class OMAP34XX, new cpu class AM33XX is created
and the respective type is AM335X, which is newly added device in the family.
This means, cpu_is_omap34xx(), cpu_is_am33xx() and
cpu_is_am335x() checks return success for AM335X.

Currently submitting this patch series as a RFC (V2), to initiate the
discussion on the approach we have chosen for AM335x device support.
Based on the feedback, will submit the final version of patch series
immediately.

This patch series is created on top of linux-omap/master and
Hemant's TI814X patches submitted recently.

http://www.mail-archive.com/linux-omap@vger.kernel.org/msg53457.html

Also, I have validated OMAP3 boot test with this patch-series on OMAP3EVM.

Changes from V1:
  - Created separate cpu/SoC class for AM33XX family of devices,
    due to all known facts. This is been mentioned in main-chain

      https://patchwork.kernel.org/patch/1056312/

  - BUG Fix in debug-macro.S, which was leading to build failure.

      https://patchwork.kernel.org/patch/1056302/

Afzal Mohammed (4):
  AM335X: Update common omap platform files
  AM335X: Update common OMAP machine specific sources
  AM335X: Create board support and enable build for AM335XEVM
  AM335X: Add low level debugging support

 arch/arm/mach-omap2/Kconfig                    |   10 ++++
 arch/arm/mach-omap2/Makefile                   |    2 +
 arch/arm/mach-omap2/board-am335xevm.c          |   57 ++++++++++++++++++++++++
 arch/arm/mach-omap2/clock3xxx_data.c           |    3 +
 arch/arm/mach-omap2/common.c                   |   16 +++++++
 arch/arm/mach-omap2/id.c                       |    6 +++
 arch/arm/mach-omap2/include/mach/debug-macro.S |   22 +++++++++
 arch/arm/mach-omap2/io.c                       |   25 ++++++++++
 arch/arm/plat-omap/include/plat/am33xx.h       |   25 ++++++++++
 arch/arm/plat-omap/include/plat/clkdev_omap.h  |    1 +
 arch/arm/plat-omap/include/plat/clock.h        |    1 +
 arch/arm/plat-omap/include/plat/common.h       |    1 +
 arch/arm/plat-omap/include/plat/cpu.h          |   23 ++++++++++
 arch/arm/plat-omap/include/plat/hardware.h     |    1 +
 arch/arm/plat-omap/include/plat/io.h           |   20 ++++++++
 arch/arm/plat-omap/include/plat/omap34xx.h     |    2 +
 arch/arm/plat-omap/include/plat/serial.h       |    4 ++
 arch/arm/plat-omap/include/plat/uncompress.h   |    6 +++
 arch/arm/plat-omap/io.c                        |    3 +
 19 files changed, 228 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/mach-omap2/board-am335xevm.c
 create mode 100644 arch/arm/plat-omap/include/plat/am33xx.h


^ permalink raw reply	[flat|nested] 263+ messages in thread

* [RFC PATCH-V2 0/4] Introducing TI's New SoC/board AM335XEVM
@ 2011-08-29 12:46 ` hvaibhav at ti.com
  0 siblings, 0 replies; 263+ messages in thread
From: hvaibhav at ti.com @ 2011-08-29 12:46 UTC (permalink / raw)
  To: linux-arm-kernel

From: Vaibhav Hiremath <hvaibhav@ti.com>

This patch set adds support for AM335x device having
Cortex-A8 MPU.

AM335X is treated as another OMAP3 variant, where,
along with existing cpu class OMAP34XX, new cpu class AM33XX is created
and the respective type is AM335X, which is newly added device in the family.
This means, cpu_is_omap34xx(), cpu_is_am33xx() and
cpu_is_am335x() checks return success for AM335X.

Currently submitting this patch series as a RFC (V2), to initiate the
discussion on the approach we have chosen for AM335x device support.
Based on the feedback, will submit the final version of patch series
immediately.

This patch series is created on top of linux-omap/master and
Hemant's TI814X patches submitted recently.

http://www.mail-archive.com/linux-omap at vger.kernel.org/msg53457.html

Also, I have validated OMAP3 boot test with this patch-series on OMAP3EVM.

Changes from V1:
  - Created separate cpu/SoC class for AM33XX family of devices,
    due to all known facts. This is been mentioned in main-chain

      https://patchwork.kernel.org/patch/1056312/

  - BUG Fix in debug-macro.S, which was leading to build failure.

      https://patchwork.kernel.org/patch/1056302/

Afzal Mohammed (4):
  AM335X: Update common omap platform files
  AM335X: Update common OMAP machine specific sources
  AM335X: Create board support and enable build for AM335XEVM
  AM335X: Add low level debugging support

 arch/arm/mach-omap2/Kconfig                    |   10 ++++
 arch/arm/mach-omap2/Makefile                   |    2 +
 arch/arm/mach-omap2/board-am335xevm.c          |   57 ++++++++++++++++++++++++
 arch/arm/mach-omap2/clock3xxx_data.c           |    3 +
 arch/arm/mach-omap2/common.c                   |   16 +++++++
 arch/arm/mach-omap2/id.c                       |    6 +++
 arch/arm/mach-omap2/include/mach/debug-macro.S |   22 +++++++++
 arch/arm/mach-omap2/io.c                       |   25 ++++++++++
 arch/arm/plat-omap/include/plat/am33xx.h       |   25 ++++++++++
 arch/arm/plat-omap/include/plat/clkdev_omap.h  |    1 +
 arch/arm/plat-omap/include/plat/clock.h        |    1 +
 arch/arm/plat-omap/include/plat/common.h       |    1 +
 arch/arm/plat-omap/include/plat/cpu.h          |   23 ++++++++++
 arch/arm/plat-omap/include/plat/hardware.h     |    1 +
 arch/arm/plat-omap/include/plat/io.h           |   20 ++++++++
 arch/arm/plat-omap/include/plat/omap34xx.h     |    2 +
 arch/arm/plat-omap/include/plat/serial.h       |    4 ++
 arch/arm/plat-omap/include/plat/uncompress.h   |    6 +++
 arch/arm/plat-omap/io.c                        |    3 +
 19 files changed, 228 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/mach-omap2/board-am335xevm.c
 create mode 100644 arch/arm/plat-omap/include/plat/am33xx.h

^ permalink raw reply	[flat|nested] 263+ messages in thread

* Re: [RFC PATCH-V2 0/4] Introducing TI's New SoC/board AM335XEVM
  2011-08-29 12:46 ` hvaibhav at ti.com
@ 2011-09-15  0:32   ` Tony Lindgren
  -1 siblings, 0 replies; 263+ messages in thread
From: Tony Lindgren @ 2011-09-15  0:32 UTC (permalink / raw)
  To: hvaibhav; +Cc: linux-omap, khilman, paul, linux-arm-kernel

* hvaibhav@ti.com <hvaibhav@ti.com> [110829 05:52]:
> From: Vaibhav Hiremath <hvaibhav@ti.com>
> 
> This patch set adds support for AM335x device having
> Cortex-A8 MPU.
> 
> AM335X is treated as another OMAP3 variant, where,
> along with existing cpu class OMAP34XX, new cpu class AM33XX is created
> and the respective type is AM335X, which is newly added device in the family.
> This means, cpu_is_omap34xx(), cpu_is_am33xx() and
> cpu_is_am335x() checks return success for AM335X.
> 
> Currently submitting this patch series as a RFC (V2), to initiate the
> discussion on the approach we have chosen for AM335x device support.
> Based on the feedback, will submit the final version of patch series
> immediately.

Can you please rebase these on Paul's CHIP_IS removal series?

Those patches are available at:

git://git.pwsan.com/linux-2.6 omap_chip_remove_cleanup_3.2

Regards,

Tony

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [RFC PATCH-V2 0/4] Introducing TI's New SoC/board AM335XEVM
@ 2011-09-15  0:32   ` Tony Lindgren
  0 siblings, 0 replies; 263+ messages in thread
From: Tony Lindgren @ 2011-09-15  0:32 UTC (permalink / raw)
  To: linux-arm-kernel

* hvaibhav at ti.com <hvaibhav@ti.com> [110829 05:52]:
> From: Vaibhav Hiremath <hvaibhav@ti.com>
> 
> This patch set adds support for AM335x device having
> Cortex-A8 MPU.
> 
> AM335X is treated as another OMAP3 variant, where,
> along with existing cpu class OMAP34XX, new cpu class AM33XX is created
> and the respective type is AM335X, which is newly added device in the family.
> This means, cpu_is_omap34xx(), cpu_is_am33xx() and
> cpu_is_am335x() checks return success for AM335X.
> 
> Currently submitting this patch series as a RFC (V2), to initiate the
> discussion on the approach we have chosen for AM335x device support.
> Based on the feedback, will submit the final version of patch series
> immediately.

Can you please rebase these on Paul's CHIP_IS removal series?

Those patches are available at:

git://git.pwsan.com/linux-2.6 omap_chip_remove_cleanup_3.2

Regards,

Tony

^ permalink raw reply	[flat|nested] 263+ messages in thread

* RE: [RFC PATCH-V2 0/4] Introducing TI's New SoC/board AM335XEVM
  2011-09-15  0:32   ` Tony Lindgren
@ 2011-09-15  7:13     ` Hiremath, Vaibhav
  -1 siblings, 0 replies; 263+ messages in thread
From: Hiremath, Vaibhav @ 2011-09-15  7:13 UTC (permalink / raw)
  To: Tony Lindgren; +Cc: linux-omap, Hilman, Kevin, paul, linux-arm-kernel


> -----Original Message-----
> From: Tony Lindgren [mailto:tony@atomide.com]
> Sent: Thursday, September 15, 2011 6:02 AM
> To: Hiremath, Vaibhav
> Cc: linux-omap@vger.kernel.org; Hilman, Kevin; paul@pwsan.com; linux-arm-
> kernel@lists.infradead.org
> Subject: Re: [RFC PATCH-V2 0/4] Introducing TI's New SoC/board AM335XEVM
> 
> * hvaibhav@ti.com <hvaibhav@ti.com> [110829 05:52]:
> > From: Vaibhav Hiremath <hvaibhav@ti.com>
> >
> > This patch set adds support for AM335x device having
> > Cortex-A8 MPU.
> >
> > AM335X is treated as another OMAP3 variant, where,
> > along with existing cpu class OMAP34XX, new cpu class AM33XX is created
> > and the respective type is AM335X, which is newly added device in the
> family.
> > This means, cpu_is_omap34xx(), cpu_is_am33xx() and
> > cpu_is_am335x() checks return success for AM335X.
> >
> > Currently submitting this patch series as a RFC (V2), to initiate the
> > discussion on the approach we have chosen for AM335x device support.
> > Based on the feedback, will submit the final version of patch series
> > immediately.
> 
> Can you please rebase these on Paul's CHIP_IS removal series?
> 
> Those patches are available at:
> 
> git://git.pwsan.com/linux-2.6 omap_chip_remove_cleanup_3.2
> 
[Hiremath, Vaibhav] Thanks Tony for your comments, 

Yeah, I will rebase and submit it again ASAP.


Thanks,
Vaibhav
> Regards,
> 
> Tony

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [RFC PATCH-V2 0/4] Introducing TI's New SoC/board AM335XEVM
@ 2011-09-15  7:13     ` Hiremath, Vaibhav
  0 siblings, 0 replies; 263+ messages in thread
From: Hiremath, Vaibhav @ 2011-09-15  7:13 UTC (permalink / raw)
  To: linux-arm-kernel


> -----Original Message-----
> From: Tony Lindgren [mailto:tony at atomide.com]
> Sent: Thursday, September 15, 2011 6:02 AM
> To: Hiremath, Vaibhav
> Cc: linux-omap at vger.kernel.org; Hilman, Kevin; paul at pwsan.com; linux-arm-
> kernel at lists.infradead.org
> Subject: Re: [RFC PATCH-V2 0/4] Introducing TI's New SoC/board AM335XEVM
> 
> * hvaibhav at ti.com <hvaibhav@ti.com> [110829 05:52]:
> > From: Vaibhav Hiremath <hvaibhav@ti.com>
> >
> > This patch set adds support for AM335x device having
> > Cortex-A8 MPU.
> >
> > AM335X is treated as another OMAP3 variant, where,
> > along with existing cpu class OMAP34XX, new cpu class AM33XX is created
> > and the respective type is AM335X, which is newly added device in the
> family.
> > This means, cpu_is_omap34xx(), cpu_is_am33xx() and
> > cpu_is_am335x() checks return success for AM335X.
> >
> > Currently submitting this patch series as a RFC (V2), to initiate the
> > discussion on the approach we have chosen for AM335x device support.
> > Based on the feedback, will submit the final version of patch series
> > immediately.
> 
> Can you please rebase these on Paul's CHIP_IS removal series?
> 
> Those patches are available at:
> 
> git://git.pwsan.com/linux-2.6 omap_chip_remove_cleanup_3.2
> 
[Hiremath, Vaibhav] Thanks Tony for your comments, 

Yeah, I will rebase and submit it again ASAP.


Thanks,
Vaibhav
> Regards,
> 
> Tony

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [PATCH-V3 1/4] arm:omap:am33xx: Update common omap platform files
@ 2011-09-20 14:32 ` hvaibhav at ti.com
  0 siblings, 0 replies; 263+ messages in thread
From: hvaibhav @ 2011-09-20 14:32 UTC (permalink / raw)
  To: linux-omap
  Cc: khilman, paul, tony, linux-arm-kernel, Afzal Mohammed,
	Vaibhav Hiremath, Hemant Pedanekar

From: Afzal Mohammed <afzal@ti.com>

This patch updates the common platform files with AM335X device
support (AM33XX family).

The approach taken in this patch is,
AM33XX device will be considered as OMAP3 variant, and a separate
SoC class created for AM33XX family of devices with a subclass type
for AM335X device, which is newly added device in the family.

This means, cpu_is_omap34xx(), cpu_is_am33xx() and cpu_is_am335x()
checks will return success on AM335X device.
A kernel config option CONFIG_SOC_OMAPAM33XX is added under OMAP3
to include support for AM33XX build.

Also, cpu_mask and RATE_IN_XXX flags have crossed 8 bit hence
struct clksel_rate.flags, struct prcm_config.flags and cpu_mask
are changed to u16 from u8.

Signed-off-by: Afzal Mohammed <afzal@ti.com>
Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
Cc: Hemant Pedanekar <hemantp@ti.com>
---
 arch/arm/mach-omap2/Kconfig                   |    5 +++++
 arch/arm/mach-omap2/clock.c                   |    2 +-
 arch/arm/mach-omap2/clock.h                   |    2 +-
 arch/arm/mach-omap2/opp2xxx.h                 |    2 +-
 arch/arm/plat-omap/include/plat/clkdev_omap.h |    1 +
 arch/arm/plat-omap/include/plat/clock.h       |    3 ++-
 arch/arm/plat-omap/include/plat/cpu.h         |   25 +++++++++++++++++++++++++
 7 files changed, 36 insertions(+), 4 deletions(-)

diff --git a/arch/arm/mach-omap2/Kconfig b/arch/arm/mach-omap2/Kconfig
index 57b66d5..12ab835 100644
--- a/arch/arm/mach-omap2/Kconfig
+++ b/arch/arm/mach-omap2/Kconfig
@@ -78,6 +78,11 @@ config SOC_OMAPTI816X
 	depends on ARCH_OMAP3
 	default y

+config SOC_OMAPAM33XX
+	bool "AM33XX support"
+	depends on ARCH_OMAP3
+	default y
+
 config OMAP_PACKAGE_ZAF
        bool

diff --git a/arch/arm/mach-omap2/clock.c b/arch/arm/mach-omap2/clock.c
index 1f3481f..f57ed5b 100644
--- a/arch/arm/mach-omap2/clock.c
+++ b/arch/arm/mach-omap2/clock.c
@@ -35,7 +35,7 @@
 #include "cm-regbits-24xx.h"
 #include "cm-regbits-34xx.h"

-u8 cpu_mask;
+u16 cpu_mask;

 /*
  * clkdm_control: if true, then when a clock is enabled in the
diff --git a/arch/arm/mach-omap2/clock.h b/arch/arm/mach-omap2/clock.h
index 48ac568..687d3d3 100644
--- a/arch/arm/mach-omap2/clock.h
+++ b/arch/arm/mach-omap2/clock.h
@@ -130,7 +130,7 @@ void omap2_clk_print_new_rates(const char *hfclkin_ck_name,
 			       const char *core_ck_name,
 			       const char *mpu_ck_name);

-extern u8 cpu_mask;
+extern u16 cpu_mask;

 extern const struct clkops clkops_omap2_dflt_wait;
 extern const struct clkops clkops_dummy;
diff --git a/arch/arm/mach-omap2/opp2xxx.h b/arch/arm/mach-omap2/opp2xxx.h
index 8affc66..8fae534 100644
--- a/arch/arm/mach-omap2/opp2xxx.h
+++ b/arch/arm/mach-omap2/opp2xxx.h
@@ -51,7 +51,7 @@ struct prcm_config {
 	unsigned long cm_clksel2_pll;	/* dpllx1 or x2 out */
 	unsigned long cm_clksel_mdm;	/* modem dividers 2430 only */
 	unsigned long base_sdrc_rfr;	/* base refresh timing for a set */
-	unsigned char flags;
+	unsigned short flags;
 };


diff --git a/arch/arm/plat-omap/include/plat/clkdev_omap.h b/arch/arm/plat-omap/include/plat/clkdev_omap.h
index 387a963..6d84c0c 100644
--- a/arch/arm/plat-omap/include/plat/clkdev_omap.h
+++ b/arch/arm/plat-omap/include/plat/clkdev_omap.h
@@ -40,6 +40,7 @@ struct omap_clk {
 #define CK_443X		(1 << 11)
 #define CK_TI816X	(1 << 12)
 #define CK_446X		(1 << 13)
+#define CK_AM33XX	(1 << 14)	/* AM33xx specific clocks */


 #define CK_34XX		(CK_3430ES1 | CK_3430ES2PLUS)
diff --git a/arch/arm/plat-omap/include/plat/clock.h b/arch/arm/plat-omap/include/plat/clock.h
index 197ca03..168c54e 100644
--- a/arch/arm/plat-omap/include/plat/clock.h
+++ b/arch/arm/plat-omap/include/plat/clock.h
@@ -59,6 +59,7 @@ struct clkops {
 #define RATE_IN_4430		(1 << 5)
 #define RATE_IN_TI816X		(1 << 6)
 #define RATE_IN_4460		(1 << 7)
+#define RATE_IN_AM33XX		(1 << 8)

 #define RATE_IN_24XX		(RATE_IN_242X | RATE_IN_243X)
 #define RATE_IN_34XX		(RATE_IN_3430ES1 | RATE_IN_3430ES2PLUS)
@@ -84,7 +85,7 @@ struct clkops {
 struct clksel_rate {
 	u32			val;
 	u8			div;
-	u8			flags;
+	u16			flags;
 };

 /**
diff --git a/arch/arm/plat-omap/include/plat/cpu.h b/arch/arm/plat-omap/include/plat/cpu.h
index 2f90269..9f4d5c3 100644
--- a/arch/arm/plat-omap/include/plat/cpu.h
+++ b/arch/arm/plat-omap/include/plat/cpu.h
@@ -78,6 +78,14 @@ static inline int is_omap ##class (void)		\
 	return (GET_OMAP_CLASS == (id)) ? 1 : 0;	\
 }

+#define GET_AM_CLASS	((omap_rev() >> 24) & 0xff)
+
+#define IS_AM_CLASS(class, id)			\
+static inline int is_am ##class (void)		\
+{							\
+	return (GET_AM_CLASS == (id)) ? 1 : 0;	\
+}
+
 #define GET_OMAP_SUBCLASS	((omap_rev() >> 20) & 0x0fff)

 #define IS_OMAP_SUBCLASS(subclass, id)			\
@@ -92,12 +100,19 @@ static inline int is_ti ##subclass (void)		\
 	return (GET_OMAP_SUBCLASS == (id)) ? 1 : 0;	\
 }

+#define IS_AM_SUBCLASS(subclass, id)			\
+static inline int is_am ##subclass (void)		\
+{							\
+	return (GET_OMAP_SUBCLASS == (id)) ? 1 : 0;	\
+}
+
 IS_OMAP_CLASS(7xx, 0x07)
 IS_OMAP_CLASS(15xx, 0x15)
 IS_OMAP_CLASS(16xx, 0x16)
 IS_OMAP_CLASS(24xx, 0x24)
 IS_OMAP_CLASS(34xx, 0x34)
 IS_OMAP_CLASS(44xx, 0x44)
+IS_AM_CLASS(33xx, 0x33)

 IS_OMAP_SUBCLASS(242x, 0x242)
 IS_OMAP_SUBCLASS(243x, 0x243)
@@ -107,6 +122,7 @@ IS_OMAP_SUBCLASS(443x, 0x443)
 IS_OMAP_SUBCLASS(446x, 0x446)

 IS_TI_SUBCLASS(816x, 0x816)
+IS_AM_SUBCLASS(335x, 0x335)

 #define cpu_is_omap7xx()		0
 #define cpu_is_omap15xx()		0
@@ -117,6 +133,8 @@ IS_TI_SUBCLASS(816x, 0x816)
 #define cpu_is_omap34xx()		0
 #define cpu_is_omap343x()		0
 #define cpu_is_ti816x()			0
+#define cpu_is_am33xx()			0
+#define cpu_is_am335x()			0
 #define cpu_is_omap44xx()		0
 #define cpu_is_omap443x()		0
 #define cpu_is_omap446x()		0
@@ -323,6 +341,8 @@ IS_OMAP_TYPE(3517, 0x3517)
 # undef cpu_is_omap3505
 # undef cpu_is_omap3517
 # undef cpu_is_ti816x
+# undef cpu_is_am33xx
+# undef cpu_is_am335x
 # define cpu_is_omap3430()		is_omap3430()
 # define cpu_is_omap3503()		(cpu_is_omap3430() &&		\
 						(!omap3_has_iva()) &&	\
@@ -340,6 +360,8 @@ IS_OMAP_TYPE(3517, 0x3517)
 # undef cpu_is_omap3630
 # define cpu_is_omap3630()		is_omap363x()
 # define cpu_is_ti816x()		is_ti816x()
+# define cpu_is_am33xx()		is_am33xx()
+# define cpu_is_am335x()		is_am335x()
 #endif

 # if defined(CONFIG_ARCH_OMAP4)
@@ -386,6 +408,9 @@ IS_OMAP_TYPE(3517, 0x3517)
 #define TI8168_REV_ES1_0	TI816X_CLASS
 #define TI8168_REV_ES1_1	(TI816X_CLASS | (0x1 << 8))

+#define AM335X_CLASS		0x33500034
+#define AM335X_REV_ES1_0	AM335X_CLASS
+
 #define OMAP443X_CLASS		0x44300044
 #define OMAP4430_REV_ES1_0	(OMAP443X_CLASS | (0x10 << 8))
 #define OMAP4430_REV_ES2_0	(OMAP443X_CLASS | (0x20 << 8))
--
1.7.0.4


^ permalink raw reply related	[flat|nested] 263+ messages in thread

* [PATCH-V3 1/4] arm:omap:am33xx: Update common omap platform files
@ 2011-09-20 14:32 ` hvaibhav at ti.com
  0 siblings, 0 replies; 263+ messages in thread
From: hvaibhav at ti.com @ 2011-09-20 14:32 UTC (permalink / raw)
  To: linux-arm-kernel

From: Afzal Mohammed <afzal@ti.com>

This patch updates the common platform files with AM335X device
support (AM33XX family).

The approach taken in this patch is,
AM33XX device will be considered as OMAP3 variant, and a separate
SoC class created for AM33XX family of devices with a subclass type
for AM335X device, which is newly added device in the family.

This means, cpu_is_omap34xx(), cpu_is_am33xx() and cpu_is_am335x()
checks will return success on AM335X device.
A kernel config option CONFIG_SOC_OMAPAM33XX is added under OMAP3
to include support for AM33XX build.

Also, cpu_mask and RATE_IN_XXX flags have crossed 8 bit hence
struct clksel_rate.flags, struct prcm_config.flags and cpu_mask
are changed to u16 from u8.

Signed-off-by: Afzal Mohammed <afzal@ti.com>
Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
Cc: Hemant Pedanekar <hemantp@ti.com>
---
 arch/arm/mach-omap2/Kconfig                   |    5 +++++
 arch/arm/mach-omap2/clock.c                   |    2 +-
 arch/arm/mach-omap2/clock.h                   |    2 +-
 arch/arm/mach-omap2/opp2xxx.h                 |    2 +-
 arch/arm/plat-omap/include/plat/clkdev_omap.h |    1 +
 arch/arm/plat-omap/include/plat/clock.h       |    3 ++-
 arch/arm/plat-omap/include/plat/cpu.h         |   25 +++++++++++++++++++++++++
 7 files changed, 36 insertions(+), 4 deletions(-)

diff --git a/arch/arm/mach-omap2/Kconfig b/arch/arm/mach-omap2/Kconfig
index 57b66d5..12ab835 100644
--- a/arch/arm/mach-omap2/Kconfig
+++ b/arch/arm/mach-omap2/Kconfig
@@ -78,6 +78,11 @@ config SOC_OMAPTI816X
 	depends on ARCH_OMAP3
 	default y

+config SOC_OMAPAM33XX
+	bool "AM33XX support"
+	depends on ARCH_OMAP3
+	default y
+
 config OMAP_PACKAGE_ZAF
        bool

diff --git a/arch/arm/mach-omap2/clock.c b/arch/arm/mach-omap2/clock.c
index 1f3481f..f57ed5b 100644
--- a/arch/arm/mach-omap2/clock.c
+++ b/arch/arm/mach-omap2/clock.c
@@ -35,7 +35,7 @@
 #include "cm-regbits-24xx.h"
 #include "cm-regbits-34xx.h"

-u8 cpu_mask;
+u16 cpu_mask;

 /*
  * clkdm_control: if true, then when a clock is enabled in the
diff --git a/arch/arm/mach-omap2/clock.h b/arch/arm/mach-omap2/clock.h
index 48ac568..687d3d3 100644
--- a/arch/arm/mach-omap2/clock.h
+++ b/arch/arm/mach-omap2/clock.h
@@ -130,7 +130,7 @@ void omap2_clk_print_new_rates(const char *hfclkin_ck_name,
 			       const char *core_ck_name,
 			       const char *mpu_ck_name);

-extern u8 cpu_mask;
+extern u16 cpu_mask;

 extern const struct clkops clkops_omap2_dflt_wait;
 extern const struct clkops clkops_dummy;
diff --git a/arch/arm/mach-omap2/opp2xxx.h b/arch/arm/mach-omap2/opp2xxx.h
index 8affc66..8fae534 100644
--- a/arch/arm/mach-omap2/opp2xxx.h
+++ b/arch/arm/mach-omap2/opp2xxx.h
@@ -51,7 +51,7 @@ struct prcm_config {
 	unsigned long cm_clksel2_pll;	/* dpllx1 or x2 out */
 	unsigned long cm_clksel_mdm;	/* modem dividers 2430 only */
 	unsigned long base_sdrc_rfr;	/* base refresh timing for a set */
-	unsigned char flags;
+	unsigned short flags;
 };


diff --git a/arch/arm/plat-omap/include/plat/clkdev_omap.h b/arch/arm/plat-omap/include/plat/clkdev_omap.h
index 387a963..6d84c0c 100644
--- a/arch/arm/plat-omap/include/plat/clkdev_omap.h
+++ b/arch/arm/plat-omap/include/plat/clkdev_omap.h
@@ -40,6 +40,7 @@ struct omap_clk {
 #define CK_443X		(1 << 11)
 #define CK_TI816X	(1 << 12)
 #define CK_446X		(1 << 13)
+#define CK_AM33XX	(1 << 14)	/* AM33xx specific clocks */


 #define CK_34XX		(CK_3430ES1 | CK_3430ES2PLUS)
diff --git a/arch/arm/plat-omap/include/plat/clock.h b/arch/arm/plat-omap/include/plat/clock.h
index 197ca03..168c54e 100644
--- a/arch/arm/plat-omap/include/plat/clock.h
+++ b/arch/arm/plat-omap/include/plat/clock.h
@@ -59,6 +59,7 @@ struct clkops {
 #define RATE_IN_4430		(1 << 5)
 #define RATE_IN_TI816X		(1 << 6)
 #define RATE_IN_4460		(1 << 7)
+#define RATE_IN_AM33XX		(1 << 8)

 #define RATE_IN_24XX		(RATE_IN_242X | RATE_IN_243X)
 #define RATE_IN_34XX		(RATE_IN_3430ES1 | RATE_IN_3430ES2PLUS)
@@ -84,7 +85,7 @@ struct clkops {
 struct clksel_rate {
 	u32			val;
 	u8			div;
-	u8			flags;
+	u16			flags;
 };

 /**
diff --git a/arch/arm/plat-omap/include/plat/cpu.h b/arch/arm/plat-omap/include/plat/cpu.h
index 2f90269..9f4d5c3 100644
--- a/arch/arm/plat-omap/include/plat/cpu.h
+++ b/arch/arm/plat-omap/include/plat/cpu.h
@@ -78,6 +78,14 @@ static inline int is_omap ##class (void)		\
 	return (GET_OMAP_CLASS == (id)) ? 1 : 0;	\
 }

+#define GET_AM_CLASS	((omap_rev() >> 24) & 0xff)
+
+#define IS_AM_CLASS(class, id)			\
+static inline int is_am ##class (void)		\
+{							\
+	return (GET_AM_CLASS == (id)) ? 1 : 0;	\
+}
+
 #define GET_OMAP_SUBCLASS	((omap_rev() >> 20) & 0x0fff)

 #define IS_OMAP_SUBCLASS(subclass, id)			\
@@ -92,12 +100,19 @@ static inline int is_ti ##subclass (void)		\
 	return (GET_OMAP_SUBCLASS == (id)) ? 1 : 0;	\
 }

+#define IS_AM_SUBCLASS(subclass, id)			\
+static inline int is_am ##subclass (void)		\
+{							\
+	return (GET_OMAP_SUBCLASS == (id)) ? 1 : 0;	\
+}
+
 IS_OMAP_CLASS(7xx, 0x07)
 IS_OMAP_CLASS(15xx, 0x15)
 IS_OMAP_CLASS(16xx, 0x16)
 IS_OMAP_CLASS(24xx, 0x24)
 IS_OMAP_CLASS(34xx, 0x34)
 IS_OMAP_CLASS(44xx, 0x44)
+IS_AM_CLASS(33xx, 0x33)

 IS_OMAP_SUBCLASS(242x, 0x242)
 IS_OMAP_SUBCLASS(243x, 0x243)
@@ -107,6 +122,7 @@ IS_OMAP_SUBCLASS(443x, 0x443)
 IS_OMAP_SUBCLASS(446x, 0x446)

 IS_TI_SUBCLASS(816x, 0x816)
+IS_AM_SUBCLASS(335x, 0x335)

 #define cpu_is_omap7xx()		0
 #define cpu_is_omap15xx()		0
@@ -117,6 +133,8 @@ IS_TI_SUBCLASS(816x, 0x816)
 #define cpu_is_omap34xx()		0
 #define cpu_is_omap343x()		0
 #define cpu_is_ti816x()			0
+#define cpu_is_am33xx()			0
+#define cpu_is_am335x()			0
 #define cpu_is_omap44xx()		0
 #define cpu_is_omap443x()		0
 #define cpu_is_omap446x()		0
@@ -323,6 +341,8 @@ IS_OMAP_TYPE(3517, 0x3517)
 # undef cpu_is_omap3505
 # undef cpu_is_omap3517
 # undef cpu_is_ti816x
+# undef cpu_is_am33xx
+# undef cpu_is_am335x
 # define cpu_is_omap3430()		is_omap3430()
 # define cpu_is_omap3503()		(cpu_is_omap3430() &&		\
 						(!omap3_has_iva()) &&	\
@@ -340,6 +360,8 @@ IS_OMAP_TYPE(3517, 0x3517)
 # undef cpu_is_omap3630
 # define cpu_is_omap3630()		is_omap363x()
 # define cpu_is_ti816x()		is_ti816x()
+# define cpu_is_am33xx()		is_am33xx()
+# define cpu_is_am335x()		is_am335x()
 #endif

 # if defined(CONFIG_ARCH_OMAP4)
@@ -386,6 +408,9 @@ IS_OMAP_TYPE(3517, 0x3517)
 #define TI8168_REV_ES1_0	TI816X_CLASS
 #define TI8168_REV_ES1_1	(TI816X_CLASS | (0x1 << 8))

+#define AM335X_CLASS		0x33500034
+#define AM335X_REV_ES1_0	AM335X_CLASS
+
 #define OMAP443X_CLASS		0x44300044
 #define OMAP4430_REV_ES1_0	(OMAP443X_CLASS | (0x10 << 8))
 #define OMAP4430_REV_ES2_0	(OMAP443X_CLASS | (0x20 << 8))
--
1.7.0.4

^ permalink raw reply related	[flat|nested] 263+ messages in thread

* [PATCH-V3 2/4] arm:omap:am33xx: Update common OMAP machine specific sources
@ 2011-09-20 14:32 ` hvaibhav at ti.com
  0 siblings, 0 replies; 263+ messages in thread
From: hvaibhav @ 2011-09-20 14:32 UTC (permalink / raw)
  To: linux-omap
  Cc: khilman, paul, tony, linux-arm-kernel, Afzal Mohammed, Vaibhav Hiremath

From: Afzal Mohammed <afzal@ti.com>

This patch updates the common machine specific source files for
support for AM33XX/AM335x with cpu type, macros for identification of
AM33XX/AM335X device.

Signed-off-by: Afzal Mohammed <afzal@ti.com>
Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
---
 arch/arm/mach-omap2/clock3xxx_data.c       |    6 +++++-
 arch/arm/mach-omap2/common.c               |   16 ++++++++++++++++
 arch/arm/mach-omap2/id.c                   |   10 ++++++++--
 arch/arm/mach-omap2/io.c                   |   25 +++++++++++++++++++++++++
 arch/arm/mach-omap2/serial.c               |    6 +++---
 arch/arm/plat-omap/include/plat/am33xx.h   |   25 +++++++++++++++++++++++++
 arch/arm/plat-omap/include/plat/common.h   |    1 +
 arch/arm/plat-omap/include/plat/hardware.h |    1 +
 arch/arm/plat-omap/include/plat/io.h       |   20 ++++++++++++++++++++
 arch/arm/plat-omap/include/plat/omap34xx.h |    2 ++
 arch/arm/plat-omap/io.c                    |    5 +++++
 11 files changed, 111 insertions(+), 6 deletions(-)
 create mode 100644 arch/arm/plat-omap/include/plat/am33xx.h

diff --git a/arch/arm/mach-omap2/clock3xxx_data.c b/arch/arm/mach-omap2/clock3xxx_data.c
index dadb8c6..2ee472c 100644
--- a/arch/arm/mach-omap2/clock3xxx_data.c
+++ b/arch/arm/mach-omap2/clock3xxx_data.c
@@ -3493,6 +3493,9 @@ int __init omap3xxx_clk_init(void)
 	} else if (cpu_is_ti816x()) {
 		cpu_mask = RATE_IN_TI816X;
 		cpu_clkflg = CK_TI816X;
+	} else if (cpu_is_am33xx()) {
+		cpu_mask = RATE_IN_AM33XX;
+		cpu_clkflg = CK_AM33XX;
 	} else if (cpu_is_omap34xx()) {
 		if (omap_rev() == OMAP3430_REV_ES1_0) {
 			cpu_mask = RATE_IN_3430ES1;
@@ -3576,7 +3579,8 @@ int __init omap3xxx_clk_init(void)
 	 * Lock DPLL5 -- here only until other device init code can
 	 * handle this
 	 */
-	if (!cpu_is_ti816x() && (omap_rev() >= OMAP3430_REV_ES2_0))
+	if (!cpu_is_ti816x() && !cpu_is_am33xx() &&
+			(omap_rev() >= OMAP3430_REV_ES2_0))
 		omap3_clk_lock_dpll5();

 	/* Avoid sleeping during omap3_core_dpll_m2_set_rate() */
diff --git a/arch/arm/mach-omap2/common.c b/arch/arm/mach-omap2/common.c
index 3f20cbb..395a9b6 100644
--- a/arch/arm/mach-omap2/common.c
+++ b/arch/arm/mach-omap2/common.c
@@ -119,6 +119,22 @@ void __init omap2_set_globals_ti816x(void)
 {
 	__omap2_set_globals(&ti816x_globals);
 }
+
+#define AM33XX_TAP_BASE		(AM33XX_CTRL_BASE + \
+				TI816X_CONTROL_DEVICE_ID - 0x204)
+
+static struct omap_globals am33xx_globals = {
+	.class  = OMAP343X_CLASS,
+	.tap    = OMAP2_L4_IO_ADDRESS(AM33XX_TAP_BASE),
+	.ctrl   = AM33XX_CTRL_BASE,
+	.prm    = AM33XX_PRCM_BASE,
+	.cm     = AM33XX_PRCM_BASE,
+};
+
+void __init omap2_set_globals_am33xx(void)
+{
+	__omap2_set_globals(&am33xx_globals);
+}
 #endif

 #if defined(CONFIG_ARCH_OMAP4)
diff --git a/arch/arm/mach-omap2/id.c b/arch/arm/mach-omap2/id.c
index d27daf9..540b6f1 100644
--- a/arch/arm/mach-omap2/id.c
+++ b/arch/arm/mach-omap2/id.c
@@ -337,6 +337,10 @@ static void __init omap3_check_revision(const char **cpu_rev)
 			break;
 		}
 		break;
+	case 0xb944:
+		omap_revision = AM335X_REV_ES1_0;
+		*cpu_rev = "1.0";
+		break;
 	default:
 		/* Unknown default to latest silicon rev as default */
 		omap_revision = OMAP3630_REV_ES1_2;
@@ -429,6 +433,8 @@ static void __init omap3_cpuinfo(const char *cpu_rev)
 		cpu_name = (omap3_has_sgx()) ? "AM3517" : "AM3505";
 	} else if (cpu_is_ti816x()) {
 		cpu_name = "TI816X";
+	} else if (cpu_is_am335x()) {
+		cpu_name =  "AM335X";
 	} else if (omap3_has_iva() && omap3_has_sgx()) {
 		/* OMAP3430, OMAP3525, OMAP3515, OMAP3503 devices */
 		cpu_name = "OMAP3430/3530";
@@ -469,8 +475,8 @@ void __init omap2_check_revision(void)
 	} else if (cpu_is_omap34xx()) {
 		omap3_check_revision(&cpu_rev);

-		/* TI816X doesn't have feature register */
-		if (!cpu_is_ti816x())
+		/* TI816X/AM335X doesn't have feature register */
+		if (!cpu_is_ti816x() && !cpu_is_am33xx())
 			omap3_check_features();
 		else
 			ti816x_check_features();
diff --git a/arch/arm/mach-omap2/io.c b/arch/arm/mach-omap2/io.c
index 40b6d47..ccd50de 100644
--- a/arch/arm/mach-omap2/io.c
+++ b/arch/arm/mach-omap2/io.c
@@ -182,7 +182,24 @@ static struct map_desc omapti816x_io_desc[] __initdata = {
 		.pfn		= __phys_to_pfn(L4_34XX_PHYS),
 		.length		= L4_34XX_SIZE,
 		.type		= MT_DEVICE
+	}
+};
+#endif
+
+#ifdef CONFIG_SOC_OMAPAM33XX
+static struct map_desc omapam33xx_io_desc[] __initdata = {
+	{
+		.virtual	= L4_34XX_VIRT,
+		.pfn		= __phys_to_pfn(L4_34XX_PHYS),
+		.length		= L4_34XX_SIZE,
+		.type		= MT_DEVICE
 	},
+	{
+		.virtual	= L4_WK_AM33XX_VIRT,
+		.pfn		= __phys_to_pfn(L4_WK_AM33XX_PHYS),
+		.length		= L4_WK_AM33XX_SIZE,
+		.type		= MT_DEVICE
+	}
 };
 #endif

@@ -286,6 +303,14 @@ void __init omapti816x_map_common_io(void)
 }
 #endif

+#ifdef CONFIG_SOC_OMAPAM33XX
+void __init omapam33xx_map_common_io(void)
+{
+	iotable_init(omapam33xx_io_desc, ARRAY_SIZE(omapam33xx_io_desc));
+	_omap2_map_common_io();
+}
+#endif
+
 #ifdef CONFIG_ARCH_OMAP4
 void __init omap44xx_map_common_io(void)
 {
diff --git a/arch/arm/mach-omap2/serial.c b/arch/arm/mach-omap2/serial.c
index 466fc72..b7782ee 100644
--- a/arch/arm/mach-omap2/serial.c
+++ b/arch/arm/mach-omap2/serial.c
@@ -486,7 +486,7 @@ static void omap_uart_idle_init(struct omap_uart_state *uart)
 		mod_timer(&uart->timer, jiffies + uart->timeout);
 	omap_uart_smart_idle_enable(uart, 0);

-	if (cpu_is_omap34xx() && !cpu_is_ti816x()) {
+	if (cpu_is_omap34xx() && !(cpu_is_ti816x() || cpu_is_am33xx())) {
 		u32 mod = (uart->num > 1) ? OMAP3430_PER_MOD : CORE_MOD;
 		u32 wk_mask = 0;
 		u32 padconf = 0;
@@ -768,7 +768,7 @@ void __init omap_serial_init_port(struct omap_board_data *bdata)
 	 */
 	uart->regshift = p->regshift;
 	uart->membase = p->membase;
-	if (cpu_is_omap44xx() || cpu_is_ti816x())
+	if (cpu_is_omap44xx() || cpu_is_ti816x() || cpu_is_am33xx())
 		uart->errata |= UART_ERRATA_FIFO_FULL_ABORT;
 	else if ((serial_read_reg(uart, UART_OMAP_MVER) & 0xFF)
 			>= UART_OMAP_NO_EMPTY_FIFO_READ_IP_REV)
@@ -851,7 +851,7 @@ void __init omap_serial_init_port(struct omap_board_data *bdata)
 	}

 	/* Enable the MDR1 errata for OMAP3 */
-	if (cpu_is_omap34xx() && !cpu_is_ti816x())
+	if (cpu_is_omap34xx() && !(cpu_is_ti816x() || cpu_is_am33xx()))
 		uart->errata |= UART_ERRATA_i202_MDR1_ACCESS;
 }

diff --git a/arch/arm/plat-omap/include/plat/am33xx.h b/arch/arm/plat-omap/include/plat/am33xx.h
new file mode 100644
index 0000000..06c19bb
--- /dev/null
+++ b/arch/arm/plat-omap/include/plat/am33xx.h
@@ -0,0 +1,25 @@
+/*
+ * This file contains the address info for various AM33XX modules.
+ *
+ * Copyright (C) 2011 Texas Instruments, Inc. - http://www.ti.com/
+ *
+ * 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.
+ */
+
+#ifndef __ASM_ARCH_AM33XX_H
+#define __ASM_ARCH_AM33XX_H
+
+#define L4_SLOW_AM33XX_BASE	0x48000000
+
+#define AM33XX_SCM_BASE		0x44E10000
+#define AM33XX_CTRL_BASE	AM33XX_SCM_BASE
+#define AM33XX_PRCM_BASE	0x44E00000
+
+#endif /* __ASM_ARCH_AM33XX_H */
diff --git a/arch/arm/plat-omap/include/plat/common.h b/arch/arm/plat-omap/include/plat/common.h
index 4564cc6..6827e34 100644
--- a/arch/arm/plat-omap/include/plat/common.h
+++ b/arch/arm/plat-omap/include/plat/common.h
@@ -67,6 +67,7 @@ void omap2_set_globals_243x(void);
 void omap2_set_globals_3xxx(void);
 void omap2_set_globals_443x(void);
 void omap2_set_globals_ti816x(void);
+void omap2_set_globals_am33xx(void);

 /* These get called from omap2_set_globals_xxxx(), do not call these */
 void omap2_set_globals_tap(struct omap_globals *);
diff --git a/arch/arm/plat-omap/include/plat/hardware.h b/arch/arm/plat-omap/include/plat/hardware.h
index e87efe1..e6521e1 100644
--- a/arch/arm/plat-omap/include/plat/hardware.h
+++ b/arch/arm/plat-omap/include/plat/hardware.h
@@ -287,5 +287,6 @@
 #include <plat/omap34xx.h>
 #include <plat/omap44xx.h>
 #include <plat/ti816x.h>
+#include <plat/am33xx.h>

 #endif	/* __ASM_ARCH_OMAP_HARDWARE_H */
diff --git a/arch/arm/plat-omap/include/plat/io.h b/arch/arm/plat-omap/include/plat/io.h
index d72ec85..0c54a00 100644
--- a/arch/arm/plat-omap/include/plat/io.h
+++ b/arch/arm/plat-omap/include/plat/io.h
@@ -73,6 +73,9 @@
 #define OMAP4_L3_IO_OFFSET	0xb4000000
 #define OMAP4_L3_IO_ADDRESS(pa)	IOMEM((pa) + OMAP4_L3_IO_OFFSET) /* L3 */

+#define AM33XX_L4_WK_IO_OFFSET	0xb5000000
+#define AM33XX_L4_WK_IO_ADDRESS(pa)	IOMEM((pa) + AM33XX_L4_WK_IO_OFFSET)
+
 #define OMAP4_L3_PER_IO_OFFSET	0xb1100000
 #define OMAP4_L3_PER_IO_ADDRESS(pa)	IOMEM((pa) + OMAP4_L3_PER_IO_OFFSET)

@@ -154,6 +157,15 @@
 #define L4_34XX_SIZE		SZ_4M   /* 1MB of 128MB used, want 1MB sect */

 /*
+ * ----------------------------------------------------------------------------
+ * AM33XX specific IO mapping
+ * ----------------------------------------------------------------------------
+ */
+#define L4_WK_AM33XX_PHYS		L4_WK_AM33XX_BASE
+#define L4_WK_AM33XX_VIRT		(L4_WK_AM33XX_PHYS + AM33XX_L4_WK_IO_OFFSET)
+#define L4_WK_AM33XX_SIZE		SZ_4M   /* 1MB of 128MB used, want 1MB sect */
+
+/*
  * Need to look at the Size 4M for L4.
  * VPOM3430 was not working for Int controller
  */
@@ -291,6 +303,14 @@ static inline void omapti816x_map_common_io(void)
 }
 #endif

+#ifdef CONFIG_SOC_OMAPAM33XX
+extern void omapam33xx_map_common_io(void);
+#else
+static inline void omapam33xx_map_common_io(void)
+{
+}
+#endif
+
 #ifdef CONFIG_ARCH_OMAP4
 extern void omap44xx_map_common_io(void);
 #else
diff --git a/arch/arm/plat-omap/include/plat/omap34xx.h b/arch/arm/plat-omap/include/plat/omap34xx.h
index b9e8588..0d818ac 100644
--- a/arch/arm/plat-omap/include/plat/omap34xx.h
+++ b/arch/arm/plat-omap/include/plat/omap34xx.h
@@ -35,6 +35,8 @@
 #define L4_EMU_34XX_BASE	0x54000000
 #define L3_34XX_BASE		0x68000000

+#define L4_WK_AM33XX_BASE	0x44C00000
+
 #define OMAP3430_32KSYNCT_BASE	0x48320000
 #define OMAP3430_CM_BASE	0x48004800
 #define OMAP3430_PRM_BASE	0x48306800
diff --git a/arch/arm/plat-omap/io.c b/arch/arm/plat-omap/io.c
index f1ecfa9..25a32b2 100644
--- a/arch/arm/plat-omap/io.c
+++ b/arch/arm/plat-omap/io.c
@@ -88,6 +88,11 @@ void __iomem *omap_ioremap(unsigned long p, size_t size, unsigned int type)
 	if (cpu_is_ti816x()) {
 		if (BETWEEN(p, L4_34XX_PHYS, L4_34XX_SIZE))
 			return XLATE(p, L4_34XX_PHYS, L4_34XX_VIRT);
+	} else if (cpu_is_am33xx()) {
+		if (BETWEEN(p, L4_34XX_PHYS, L4_34XX_SIZE))
+			return XLATE(p, L4_34XX_PHYS, L4_34XX_VIRT);
+		if (BETWEEN(p, L4_WK_AM33XX_PHYS, L4_WK_AM33XX_SIZE))
+			return XLATE(p, L4_WK_AM33XX_PHYS, L4_WK_AM33XX_VIRT);
 	} else if (cpu_is_omap34xx()) {
 		if (BETWEEN(p, L3_34XX_PHYS, L3_34XX_SIZE))
 			return XLATE(p, L3_34XX_PHYS, L3_34XX_VIRT);
--
1.7.0.4


^ permalink raw reply related	[flat|nested] 263+ messages in thread

* [PATCH-V3 2/4] arm:omap:am33xx: Update common OMAP machine specific sources
@ 2011-09-20 14:32 ` hvaibhav at ti.com
  0 siblings, 0 replies; 263+ messages in thread
From: hvaibhav at ti.com @ 2011-09-20 14:32 UTC (permalink / raw)
  To: linux-arm-kernel

From: Afzal Mohammed <afzal@ti.com>

This patch updates the common machine specific source files for
support for AM33XX/AM335x with cpu type, macros for identification of
AM33XX/AM335X device.

Signed-off-by: Afzal Mohammed <afzal@ti.com>
Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
---
 arch/arm/mach-omap2/clock3xxx_data.c       |    6 +++++-
 arch/arm/mach-omap2/common.c               |   16 ++++++++++++++++
 arch/arm/mach-omap2/id.c                   |   10 ++++++++--
 arch/arm/mach-omap2/io.c                   |   25 +++++++++++++++++++++++++
 arch/arm/mach-omap2/serial.c               |    6 +++---
 arch/arm/plat-omap/include/plat/am33xx.h   |   25 +++++++++++++++++++++++++
 arch/arm/plat-omap/include/plat/common.h   |    1 +
 arch/arm/plat-omap/include/plat/hardware.h |    1 +
 arch/arm/plat-omap/include/plat/io.h       |   20 ++++++++++++++++++++
 arch/arm/plat-omap/include/plat/omap34xx.h |    2 ++
 arch/arm/plat-omap/io.c                    |    5 +++++
 11 files changed, 111 insertions(+), 6 deletions(-)
 create mode 100644 arch/arm/plat-omap/include/plat/am33xx.h

diff --git a/arch/arm/mach-omap2/clock3xxx_data.c b/arch/arm/mach-omap2/clock3xxx_data.c
index dadb8c6..2ee472c 100644
--- a/arch/arm/mach-omap2/clock3xxx_data.c
+++ b/arch/arm/mach-omap2/clock3xxx_data.c
@@ -3493,6 +3493,9 @@ int __init omap3xxx_clk_init(void)
 	} else if (cpu_is_ti816x()) {
 		cpu_mask = RATE_IN_TI816X;
 		cpu_clkflg = CK_TI816X;
+	} else if (cpu_is_am33xx()) {
+		cpu_mask = RATE_IN_AM33XX;
+		cpu_clkflg = CK_AM33XX;
 	} else if (cpu_is_omap34xx()) {
 		if (omap_rev() == OMAP3430_REV_ES1_0) {
 			cpu_mask = RATE_IN_3430ES1;
@@ -3576,7 +3579,8 @@ int __init omap3xxx_clk_init(void)
 	 * Lock DPLL5 -- here only until other device init code can
 	 * handle this
 	 */
-	if (!cpu_is_ti816x() && (omap_rev() >= OMAP3430_REV_ES2_0))
+	if (!cpu_is_ti816x() && !cpu_is_am33xx() &&
+			(omap_rev() >= OMAP3430_REV_ES2_0))
 		omap3_clk_lock_dpll5();

 	/* Avoid sleeping during omap3_core_dpll_m2_set_rate() */
diff --git a/arch/arm/mach-omap2/common.c b/arch/arm/mach-omap2/common.c
index 3f20cbb..395a9b6 100644
--- a/arch/arm/mach-omap2/common.c
+++ b/arch/arm/mach-omap2/common.c
@@ -119,6 +119,22 @@ void __init omap2_set_globals_ti816x(void)
 {
 	__omap2_set_globals(&ti816x_globals);
 }
+
+#define AM33XX_TAP_BASE		(AM33XX_CTRL_BASE + \
+				TI816X_CONTROL_DEVICE_ID - 0x204)
+
+static struct omap_globals am33xx_globals = {
+	.class  = OMAP343X_CLASS,
+	.tap    = OMAP2_L4_IO_ADDRESS(AM33XX_TAP_BASE),
+	.ctrl   = AM33XX_CTRL_BASE,
+	.prm    = AM33XX_PRCM_BASE,
+	.cm     = AM33XX_PRCM_BASE,
+};
+
+void __init omap2_set_globals_am33xx(void)
+{
+	__omap2_set_globals(&am33xx_globals);
+}
 #endif

 #if defined(CONFIG_ARCH_OMAP4)
diff --git a/arch/arm/mach-omap2/id.c b/arch/arm/mach-omap2/id.c
index d27daf9..540b6f1 100644
--- a/arch/arm/mach-omap2/id.c
+++ b/arch/arm/mach-omap2/id.c
@@ -337,6 +337,10 @@ static void __init omap3_check_revision(const char **cpu_rev)
 			break;
 		}
 		break;
+	case 0xb944:
+		omap_revision = AM335X_REV_ES1_0;
+		*cpu_rev = "1.0";
+		break;
 	default:
 		/* Unknown default to latest silicon rev as default */
 		omap_revision = OMAP3630_REV_ES1_2;
@@ -429,6 +433,8 @@ static void __init omap3_cpuinfo(const char *cpu_rev)
 		cpu_name = (omap3_has_sgx()) ? "AM3517" : "AM3505";
 	} else if (cpu_is_ti816x()) {
 		cpu_name = "TI816X";
+	} else if (cpu_is_am335x()) {
+		cpu_name =  "AM335X";
 	} else if (omap3_has_iva() && omap3_has_sgx()) {
 		/* OMAP3430, OMAP3525, OMAP3515, OMAP3503 devices */
 		cpu_name = "OMAP3430/3530";
@@ -469,8 +475,8 @@ void __init omap2_check_revision(void)
 	} else if (cpu_is_omap34xx()) {
 		omap3_check_revision(&cpu_rev);

-		/* TI816X doesn't have feature register */
-		if (!cpu_is_ti816x())
+		/* TI816X/AM335X doesn't have feature register */
+		if (!cpu_is_ti816x() && !cpu_is_am33xx())
 			omap3_check_features();
 		else
 			ti816x_check_features();
diff --git a/arch/arm/mach-omap2/io.c b/arch/arm/mach-omap2/io.c
index 40b6d47..ccd50de 100644
--- a/arch/arm/mach-omap2/io.c
+++ b/arch/arm/mach-omap2/io.c
@@ -182,7 +182,24 @@ static struct map_desc omapti816x_io_desc[] __initdata = {
 		.pfn		= __phys_to_pfn(L4_34XX_PHYS),
 		.length		= L4_34XX_SIZE,
 		.type		= MT_DEVICE
+	}
+};
+#endif
+
+#ifdef CONFIG_SOC_OMAPAM33XX
+static struct map_desc omapam33xx_io_desc[] __initdata = {
+	{
+		.virtual	= L4_34XX_VIRT,
+		.pfn		= __phys_to_pfn(L4_34XX_PHYS),
+		.length		= L4_34XX_SIZE,
+		.type		= MT_DEVICE
 	},
+	{
+		.virtual	= L4_WK_AM33XX_VIRT,
+		.pfn		= __phys_to_pfn(L4_WK_AM33XX_PHYS),
+		.length		= L4_WK_AM33XX_SIZE,
+		.type		= MT_DEVICE
+	}
 };
 #endif

@@ -286,6 +303,14 @@ void __init omapti816x_map_common_io(void)
 }
 #endif

+#ifdef CONFIG_SOC_OMAPAM33XX
+void __init omapam33xx_map_common_io(void)
+{
+	iotable_init(omapam33xx_io_desc, ARRAY_SIZE(omapam33xx_io_desc));
+	_omap2_map_common_io();
+}
+#endif
+
 #ifdef CONFIG_ARCH_OMAP4
 void __init omap44xx_map_common_io(void)
 {
diff --git a/arch/arm/mach-omap2/serial.c b/arch/arm/mach-omap2/serial.c
index 466fc72..b7782ee 100644
--- a/arch/arm/mach-omap2/serial.c
+++ b/arch/arm/mach-omap2/serial.c
@@ -486,7 +486,7 @@ static void omap_uart_idle_init(struct omap_uart_state *uart)
 		mod_timer(&uart->timer, jiffies + uart->timeout);
 	omap_uart_smart_idle_enable(uart, 0);

-	if (cpu_is_omap34xx() && !cpu_is_ti816x()) {
+	if (cpu_is_omap34xx() && !(cpu_is_ti816x() || cpu_is_am33xx())) {
 		u32 mod = (uart->num > 1) ? OMAP3430_PER_MOD : CORE_MOD;
 		u32 wk_mask = 0;
 		u32 padconf = 0;
@@ -768,7 +768,7 @@ void __init omap_serial_init_port(struct omap_board_data *bdata)
 	 */
 	uart->regshift = p->regshift;
 	uart->membase = p->membase;
-	if (cpu_is_omap44xx() || cpu_is_ti816x())
+	if (cpu_is_omap44xx() || cpu_is_ti816x() || cpu_is_am33xx())
 		uart->errata |= UART_ERRATA_FIFO_FULL_ABORT;
 	else if ((serial_read_reg(uart, UART_OMAP_MVER) & 0xFF)
 			>= UART_OMAP_NO_EMPTY_FIFO_READ_IP_REV)
@@ -851,7 +851,7 @@ void __init omap_serial_init_port(struct omap_board_data *bdata)
 	}

 	/* Enable the MDR1 errata for OMAP3 */
-	if (cpu_is_omap34xx() && !cpu_is_ti816x())
+	if (cpu_is_omap34xx() && !(cpu_is_ti816x() || cpu_is_am33xx()))
 		uart->errata |= UART_ERRATA_i202_MDR1_ACCESS;
 }

diff --git a/arch/arm/plat-omap/include/plat/am33xx.h b/arch/arm/plat-omap/include/plat/am33xx.h
new file mode 100644
index 0000000..06c19bb
--- /dev/null
+++ b/arch/arm/plat-omap/include/plat/am33xx.h
@@ -0,0 +1,25 @@
+/*
+ * This file contains the address info for various AM33XX modules.
+ *
+ * Copyright (C) 2011 Texas Instruments, Inc. - http://www.ti.com/
+ *
+ * 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.
+ */
+
+#ifndef __ASM_ARCH_AM33XX_H
+#define __ASM_ARCH_AM33XX_H
+
+#define L4_SLOW_AM33XX_BASE	0x48000000
+
+#define AM33XX_SCM_BASE		0x44E10000
+#define AM33XX_CTRL_BASE	AM33XX_SCM_BASE
+#define AM33XX_PRCM_BASE	0x44E00000
+
+#endif /* __ASM_ARCH_AM33XX_H */
diff --git a/arch/arm/plat-omap/include/plat/common.h b/arch/arm/plat-omap/include/plat/common.h
index 4564cc6..6827e34 100644
--- a/arch/arm/plat-omap/include/plat/common.h
+++ b/arch/arm/plat-omap/include/plat/common.h
@@ -67,6 +67,7 @@ void omap2_set_globals_243x(void);
 void omap2_set_globals_3xxx(void);
 void omap2_set_globals_443x(void);
 void omap2_set_globals_ti816x(void);
+void omap2_set_globals_am33xx(void);

 /* These get called from omap2_set_globals_xxxx(), do not call these */
 void omap2_set_globals_tap(struct omap_globals *);
diff --git a/arch/arm/plat-omap/include/plat/hardware.h b/arch/arm/plat-omap/include/plat/hardware.h
index e87efe1..e6521e1 100644
--- a/arch/arm/plat-omap/include/plat/hardware.h
+++ b/arch/arm/plat-omap/include/plat/hardware.h
@@ -287,5 +287,6 @@
 #include <plat/omap34xx.h>
 #include <plat/omap44xx.h>
 #include <plat/ti816x.h>
+#include <plat/am33xx.h>

 #endif	/* __ASM_ARCH_OMAP_HARDWARE_H */
diff --git a/arch/arm/plat-omap/include/plat/io.h b/arch/arm/plat-omap/include/plat/io.h
index d72ec85..0c54a00 100644
--- a/arch/arm/plat-omap/include/plat/io.h
+++ b/arch/arm/plat-omap/include/plat/io.h
@@ -73,6 +73,9 @@
 #define OMAP4_L3_IO_OFFSET	0xb4000000
 #define OMAP4_L3_IO_ADDRESS(pa)	IOMEM((pa) + OMAP4_L3_IO_OFFSET) /* L3 */

+#define AM33XX_L4_WK_IO_OFFSET	0xb5000000
+#define AM33XX_L4_WK_IO_ADDRESS(pa)	IOMEM((pa) + AM33XX_L4_WK_IO_OFFSET)
+
 #define OMAP4_L3_PER_IO_OFFSET	0xb1100000
 #define OMAP4_L3_PER_IO_ADDRESS(pa)	IOMEM((pa) + OMAP4_L3_PER_IO_OFFSET)

@@ -154,6 +157,15 @@
 #define L4_34XX_SIZE		SZ_4M   /* 1MB of 128MB used, want 1MB sect */

 /*
+ * ----------------------------------------------------------------------------
+ * AM33XX specific IO mapping
+ * ----------------------------------------------------------------------------
+ */
+#define L4_WK_AM33XX_PHYS		L4_WK_AM33XX_BASE
+#define L4_WK_AM33XX_VIRT		(L4_WK_AM33XX_PHYS + AM33XX_L4_WK_IO_OFFSET)
+#define L4_WK_AM33XX_SIZE		SZ_4M   /* 1MB of 128MB used, want 1MB sect */
+
+/*
  * Need to look at the Size 4M for L4.
  * VPOM3430 was not working for Int controller
  */
@@ -291,6 +303,14 @@ static inline void omapti816x_map_common_io(void)
 }
 #endif

+#ifdef CONFIG_SOC_OMAPAM33XX
+extern void omapam33xx_map_common_io(void);
+#else
+static inline void omapam33xx_map_common_io(void)
+{
+}
+#endif
+
 #ifdef CONFIG_ARCH_OMAP4
 extern void omap44xx_map_common_io(void);
 #else
diff --git a/arch/arm/plat-omap/include/plat/omap34xx.h b/arch/arm/plat-omap/include/plat/omap34xx.h
index b9e8588..0d818ac 100644
--- a/arch/arm/plat-omap/include/plat/omap34xx.h
+++ b/arch/arm/plat-omap/include/plat/omap34xx.h
@@ -35,6 +35,8 @@
 #define L4_EMU_34XX_BASE	0x54000000
 #define L3_34XX_BASE		0x68000000

+#define L4_WK_AM33XX_BASE	0x44C00000
+
 #define OMAP3430_32KSYNCT_BASE	0x48320000
 #define OMAP3430_CM_BASE	0x48004800
 #define OMAP3430_PRM_BASE	0x48306800
diff --git a/arch/arm/plat-omap/io.c b/arch/arm/plat-omap/io.c
index f1ecfa9..25a32b2 100644
--- a/arch/arm/plat-omap/io.c
+++ b/arch/arm/plat-omap/io.c
@@ -88,6 +88,11 @@ void __iomem *omap_ioremap(unsigned long p, size_t size, unsigned int type)
 	if (cpu_is_ti816x()) {
 		if (BETWEEN(p, L4_34XX_PHYS, L4_34XX_SIZE))
 			return XLATE(p, L4_34XX_PHYS, L4_34XX_VIRT);
+	} else if (cpu_is_am33xx()) {
+		if (BETWEEN(p, L4_34XX_PHYS, L4_34XX_SIZE))
+			return XLATE(p, L4_34XX_PHYS, L4_34XX_VIRT);
+		if (BETWEEN(p, L4_WK_AM33XX_PHYS, L4_WK_AM33XX_SIZE))
+			return XLATE(p, L4_WK_AM33XX_PHYS, L4_WK_AM33XX_VIRT);
 	} else if (cpu_is_omap34xx()) {
 		if (BETWEEN(p, L3_34XX_PHYS, L3_34XX_SIZE))
 			return XLATE(p, L3_34XX_PHYS, L3_34XX_VIRT);
--
1.7.0.4

^ permalink raw reply related	[flat|nested] 263+ messages in thread

* [PATCH-V3 3/4] arm:omap:am33xx: Create board support and enable build for AM335XEVM
@ 2011-09-20 14:32 ` hvaibhav at ti.com
  0 siblings, 0 replies; 263+ messages in thread
From: hvaibhav @ 2011-09-20 14:32 UTC (permalink / raw)
  To: linux-omap
  Cc: khilman, paul, tony, linux-arm-kernel, Afzal Mohammed, Vaibhav Hiremath

From: Afzal Mohammed <afzal@ti.com>

This patch adds minimal support and build configuration for
AM335X EVM.

Signed-off-by: Afzal Mohammed <afzal@ti.com>
Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
---
 arch/arm/mach-omap2/Kconfig           |    5 +++
 arch/arm/mach-omap2/Makefile          |    2 +
 arch/arm/mach-omap2/board-am335xevm.c |   57 +++++++++++++++++++++++++++++++++
 3 files changed, 64 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/mach-omap2/board-am335xevm.c

diff --git a/arch/arm/mach-omap2/Kconfig b/arch/arm/mach-omap2/Kconfig
index 12ab835..8533008 100644
--- a/arch/arm/mach-omap2/Kconfig
+++ b/arch/arm/mach-omap2/Kconfig
@@ -315,6 +315,11 @@ config MACH_TI8168EVM
 	depends on SOC_OMAPTI816X
 	default y

+config MACH_AM335XEVM
+	bool "AM335X Evaluation Module"
+	depends on SOC_OMAPAM33XX
+	default y
+
 config MACH_OMAP_4430SDP
 	bool "OMAP 4430 SDP board"
 	default y
diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile
index 5a6fe73..47d8de1 100644
--- a/arch/arm/mach-omap2/Makefile
+++ b/arch/arm/mach-omap2/Makefile
@@ -259,6 +259,8 @@ obj-$(CONFIG_MACH_CRANEBOARD)		+= board-am3517crane.o
 obj-$(CONFIG_MACH_SBC3530)		+= board-omap3stalker.o \
 					   hsmmc.o
 obj-$(CONFIG_MACH_TI8168EVM)		+= board-ti8168evm.o
+obj-$(CONFIG_MACH_AM335XEVM)		+= board-am335xevm.o
+
 # Platform specific device init code
 usbfs-$(CONFIG_ARCH_OMAP_OTG)		:= usb-fs.o
 obj-y					+= $(usbfs-m) $(usbfs-y)
diff --git a/arch/arm/mach-omap2/board-am335xevm.c b/arch/arm/mach-omap2/board-am335xevm.c
new file mode 100644
index 0000000..afa3f26
--- /dev/null
+++ b/arch/arm/mach-omap2/board-am335xevm.c
@@ -0,0 +1,57 @@
+/*
+ * Code for AM335X EVM.
+ *
+ * Copyright (C) 2011 Texas Instruments, Inc. - http://www.ti.com/
+ *
+ * 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 <mach/hardware.h>
+#include <asm/mach-types.h>
+#include <asm/mach/arch.h>
+#include <asm/mach/map.h>
+
+#include <plat/irqs.h>
+#include <plat/board.h>
+#include <plat/common.h>
+
+static struct omap_board_config_kernel am335x_evm_config[] __initdata = {
+};
+
+static void __init am335x_init_early(void)
+{
+	omap2_init_common_infrastructure();
+	omap2_init_common_devices(NULL, NULL);
+}
+
+static void __init am335x_evm_init(void)
+{
+	omap_serial_init();
+	omap_board_config = am335x_evm_config;
+	omap_board_config_size = ARRAY_SIZE(am335x_evm_config);
+}
+
+static void __init am335x_evm_map_io(void)
+{
+	omap2_set_globals_am33xx();
+	omapam33xx_map_common_io();
+}
+
+MACHINE_START(AM335XEVM, "am335xevm")
+	/* Maintainer: Texas Instruments */
+	.boot_params	= 0x80000100,
+	.map_io		= am335x_evm_map_io,
+	.init_early	= am335x_init_early,
+	.init_irq	= ti816x_init_irq,
+	.timer		= &omap3_timer,
+	.init_machine	= am335x_evm_init,
+MACHINE_END
--
1.7.0.4


^ permalink raw reply related	[flat|nested] 263+ messages in thread

* [PATCH-V3 3/4] arm:omap:am33xx: Create board support and enable build for AM335XEVM
@ 2011-09-20 14:32 ` hvaibhav at ti.com
  0 siblings, 0 replies; 263+ messages in thread
From: hvaibhav at ti.com @ 2011-09-20 14:32 UTC (permalink / raw)
  To: linux-arm-kernel

From: Afzal Mohammed <afzal@ti.com>

This patch adds minimal support and build configuration for
AM335X EVM.

Signed-off-by: Afzal Mohammed <afzal@ti.com>
Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
---
 arch/arm/mach-omap2/Kconfig           |    5 +++
 arch/arm/mach-omap2/Makefile          |    2 +
 arch/arm/mach-omap2/board-am335xevm.c |   57 +++++++++++++++++++++++++++++++++
 3 files changed, 64 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/mach-omap2/board-am335xevm.c

diff --git a/arch/arm/mach-omap2/Kconfig b/arch/arm/mach-omap2/Kconfig
index 12ab835..8533008 100644
--- a/arch/arm/mach-omap2/Kconfig
+++ b/arch/arm/mach-omap2/Kconfig
@@ -315,6 +315,11 @@ config MACH_TI8168EVM
 	depends on SOC_OMAPTI816X
 	default y

+config MACH_AM335XEVM
+	bool "AM335X Evaluation Module"
+	depends on SOC_OMAPAM33XX
+	default y
+
 config MACH_OMAP_4430SDP
 	bool "OMAP 4430 SDP board"
 	default y
diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile
index 5a6fe73..47d8de1 100644
--- a/arch/arm/mach-omap2/Makefile
+++ b/arch/arm/mach-omap2/Makefile
@@ -259,6 +259,8 @@ obj-$(CONFIG_MACH_CRANEBOARD)		+= board-am3517crane.o
 obj-$(CONFIG_MACH_SBC3530)		+= board-omap3stalker.o \
 					   hsmmc.o
 obj-$(CONFIG_MACH_TI8168EVM)		+= board-ti8168evm.o
+obj-$(CONFIG_MACH_AM335XEVM)		+= board-am335xevm.o
+
 # Platform specific device init code
 usbfs-$(CONFIG_ARCH_OMAP_OTG)		:= usb-fs.o
 obj-y					+= $(usbfs-m) $(usbfs-y)
diff --git a/arch/arm/mach-omap2/board-am335xevm.c b/arch/arm/mach-omap2/board-am335xevm.c
new file mode 100644
index 0000000..afa3f26
--- /dev/null
+++ b/arch/arm/mach-omap2/board-am335xevm.c
@@ -0,0 +1,57 @@
+/*
+ * Code for AM335X EVM.
+ *
+ * Copyright (C) 2011 Texas Instruments, Inc. - http://www.ti.com/
+ *
+ * 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 <mach/hardware.h>
+#include <asm/mach-types.h>
+#include <asm/mach/arch.h>
+#include <asm/mach/map.h>
+
+#include <plat/irqs.h>
+#include <plat/board.h>
+#include <plat/common.h>
+
+static struct omap_board_config_kernel am335x_evm_config[] __initdata = {
+};
+
+static void __init am335x_init_early(void)
+{
+	omap2_init_common_infrastructure();
+	omap2_init_common_devices(NULL, NULL);
+}
+
+static void __init am335x_evm_init(void)
+{
+	omap_serial_init();
+	omap_board_config = am335x_evm_config;
+	omap_board_config_size = ARRAY_SIZE(am335x_evm_config);
+}
+
+static void __init am335x_evm_map_io(void)
+{
+	omap2_set_globals_am33xx();
+	omapam33xx_map_common_io();
+}
+
+MACHINE_START(AM335XEVM, "am335xevm")
+	/* Maintainer: Texas Instruments */
+	.boot_params	= 0x80000100,
+	.map_io		= am335x_evm_map_io,
+	.init_early	= am335x_init_early,
+	.init_irq	= ti816x_init_irq,
+	.timer		= &omap3_timer,
+	.init_machine	= am335x_evm_init,
+MACHINE_END
--
1.7.0.4

^ permalink raw reply related	[flat|nested] 263+ messages in thread

* [PATCH-V3 4/4] arm:omap:am33xx: Add low level debugging support
@ 2011-09-20 14:32 ` hvaibhav at ti.com
  0 siblings, 0 replies; 263+ messages in thread
From: hvaibhav @ 2011-09-20 14:32 UTC (permalink / raw)
  To: linux-omap
  Cc: khilman, paul, tony, linux-arm-kernel, Afzal Mohammed, Vaibhav Hiremath

From: Afzal Mohammed <afzal@ti.com>

Add support for low level debugging on AM335X EVM (AM33XX family).
Currently only support for UART1 console, which is used on AM335X EVM
is added.

Signed-off-by: Afzal Mohammed <afzal@ti.com>
Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
---
 arch/arm/mach-omap2/include/mach/debug-macro.S |   22 ++++++++++++++++++++++
 arch/arm/plat-omap/include/plat/serial.h       |    4 ++++
 arch/arm/plat-omap/include/plat/uncompress.h   |    6 ++++++
 3 files changed, 32 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-omap2/include/mach/debug-macro.S b/arch/arm/mach-omap2/include/mach/debug-macro.S
index 48adfe9..f649973 100644
--- a/arch/arm/mach-omap2/include/mach/debug-macro.S
+++ b/arch/arm/mach-omap2/include/mach/debug-macro.S
@@ -78,6 +78,8 @@ omap_uart_lsr:	.word	0
 		beq	82f			@ configure UART2
 		cmp	\rp, #TI816XUART3	@ ti816x UART offsets different
 		beq	83f			@ configure UART3
+		cmp	\rp, #AM33XXUART1	@ AM33XX UART offsets different
+		beq	84f			@ configure UART1
 		cmp	\rp, #ZOOM_UART		@ only on zoom2/3
 		beq	95f			@ configure ZOOM_UART

@@ -106,6 +108,9 @@ omap_uart_lsr:	.word	0
 		b	98f
 83:		mov	\rp, #UART_OFFSET(TI816X_UART3_BASE)
 		b	98f
+84:		ldr	\rp, =AM33XX_UART1_BASE
+		and	\rp, \rp, #0x00ffffff
+		b	97f
 95:		ldr	\rp, =ZOOM_UART_BASE
 		mrc	p15, 0, \rv, c1, c0
 		tst	\rv, #1			@ MMU enabled?
@@ -121,6 +126,23 @@ omap_uart_lsr:	.word	0
 		b	10b

 		/* Store both phys and virt address for the uart */
+97:		add	\rp, \rp, #0x44000000	@ phys base
+		mrc	p15, 0, \rv, c1, c0
+		tst	\rv, #1			@ MMU enabled?
+		ldreq	\rv, =omap_uart_v2p(omap_uart_phys)	@ MMU disabled
+		ldrne	\rv, =omap_uart_phys	@ MMU enabled
+		str	\rp, [\rv, #0]
+		sub	\rp, \rp, #0x44000000	@ phys base
+		add	\rp, \rp, #0xf9000000	@ virt base
+		add	\rv, \rv, #4		@ omap_uart_virt
+		str	\rp, [\rv, #0]
+		mov	\rp, #(UART_LSR << OMAP_PORT_SHIFT)
+		add	\rv, \rv, #4		@ omap_uart_lsr
+		str	\rp, [\rv, #0]
+
+		b	10b
+
+		/* Store both phys and virt address for the uart */
 98:		add	\rp, \rp, #0x48000000	@ phys base
 		mrc	p15, 0, \rv, c1, c0
 		tst	\rv, #1			@ MMU enabled?
diff --git a/arch/arm/plat-omap/include/plat/serial.h b/arch/arm/plat-omap/include/plat/serial.h
index de3b10c..ad19377 100644
--- a/arch/arm/plat-omap/include/plat/serial.h
+++ b/arch/arm/plat-omap/include/plat/serial.h
@@ -59,6 +59,9 @@
 /* AM3505/3517 UART4 */
 #define AM35XX_UART4_BASE	0x4809E000	/* Only on AM3505/3517 */

+/* AM33XX serial port */
+#define AM33XX_UART1_BASE	0x44E09000
+
 /* External port on Zoom2/3 */
 #define ZOOM_UART_BASE		0x10000000
 #define ZOOM_UART_VIRT		0xfa400000
@@ -92,6 +95,7 @@
 #define TI816XUART1		81
 #define TI816XUART2		82
 #define TI816XUART3		83
+#define AM33XXUART1		84
 #define ZOOM_UART		95		/* Only on zoom2/3 */

 /* This is only used by 8250.c for omap1510 */
diff --git a/arch/arm/plat-omap/include/plat/uncompress.h b/arch/arm/plat-omap/include/plat/uncompress.h
index a067484..bd1e051 100644
--- a/arch/arm/plat-omap/include/plat/uncompress.h
+++ b/arch/arm/plat-omap/include/plat/uncompress.h
@@ -97,6 +97,10 @@ static inline void flush(void)
 	_DEBUG_LL_ENTRY(mach, TI816X_UART##p##_BASE, OMAP_PORT_SHIFT,	\
 		TI816XUART##p)

+#define DEBUG_LL_AM33XX(p, mach)					\
+	_DEBUG_LL_ENTRY(mach, AM33XX_UART##p##_BASE, OMAP_PORT_SHIFT,	\
+		AM33XXUART##p)
+
 static inline void __arch_decomp_setup(unsigned long arch_id)
 {
 	int port = 0;
@@ -173,6 +177,8 @@ static inline void __arch_decomp_setup(unsigned long arch_id)
 		/* TI8168 base boards using UART3 */
 		DEBUG_LL_TI816X(3, ti8168evm);

+		/* AM33XX base boards using UART1 */
+		DEBUG_LL_AM33XX(1, am335xevm);
 	} while (0);
 }

--
1.7.0.4


^ permalink raw reply related	[flat|nested] 263+ messages in thread

* [PATCH-V3 4/4] arm:omap:am33xx: Add low level debugging support
@ 2011-09-20 14:32 ` hvaibhav at ti.com
  0 siblings, 0 replies; 263+ messages in thread
From: hvaibhav at ti.com @ 2011-09-20 14:32 UTC (permalink / raw)
  To: linux-arm-kernel

From: Afzal Mohammed <afzal@ti.com>

Add support for low level debugging on AM335X EVM (AM33XX family).
Currently only support for UART1 console, which is used on AM335X EVM
is added.

Signed-off-by: Afzal Mohammed <afzal@ti.com>
Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
---
 arch/arm/mach-omap2/include/mach/debug-macro.S |   22 ++++++++++++++++++++++
 arch/arm/plat-omap/include/plat/serial.h       |    4 ++++
 arch/arm/plat-omap/include/plat/uncompress.h   |    6 ++++++
 3 files changed, 32 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-omap2/include/mach/debug-macro.S b/arch/arm/mach-omap2/include/mach/debug-macro.S
index 48adfe9..f649973 100644
--- a/arch/arm/mach-omap2/include/mach/debug-macro.S
+++ b/arch/arm/mach-omap2/include/mach/debug-macro.S
@@ -78,6 +78,8 @@ omap_uart_lsr:	.word	0
 		beq	82f			@ configure UART2
 		cmp	\rp, #TI816XUART3	@ ti816x UART offsets different
 		beq	83f			@ configure UART3
+		cmp	\rp, #AM33XXUART1	@ AM33XX UART offsets different
+		beq	84f			@ configure UART1
 		cmp	\rp, #ZOOM_UART		@ only on zoom2/3
 		beq	95f			@ configure ZOOM_UART

@@ -106,6 +108,9 @@ omap_uart_lsr:	.word	0
 		b	98f
 83:		mov	\rp, #UART_OFFSET(TI816X_UART3_BASE)
 		b	98f
+84:		ldr	\rp, =AM33XX_UART1_BASE
+		and	\rp, \rp, #0x00ffffff
+		b	97f
 95:		ldr	\rp, =ZOOM_UART_BASE
 		mrc	p15, 0, \rv, c1, c0
 		tst	\rv, #1			@ MMU enabled?
@@ -121,6 +126,23 @@ omap_uart_lsr:	.word	0
 		b	10b

 		/* Store both phys and virt address for the uart */
+97:		add	\rp, \rp, #0x44000000	@ phys base
+		mrc	p15, 0, \rv, c1, c0
+		tst	\rv, #1			@ MMU enabled?
+		ldreq	\rv, =omap_uart_v2p(omap_uart_phys)	@ MMU disabled
+		ldrne	\rv, =omap_uart_phys	@ MMU enabled
+		str	\rp, [\rv, #0]
+		sub	\rp, \rp, #0x44000000	@ phys base
+		add	\rp, \rp, #0xf9000000	@ virt base
+		add	\rv, \rv, #4		@ omap_uart_virt
+		str	\rp, [\rv, #0]
+		mov	\rp, #(UART_LSR << OMAP_PORT_SHIFT)
+		add	\rv, \rv, #4		@ omap_uart_lsr
+		str	\rp, [\rv, #0]
+
+		b	10b
+
+		/* Store both phys and virt address for the uart */
 98:		add	\rp, \rp, #0x48000000	@ phys base
 		mrc	p15, 0, \rv, c1, c0
 		tst	\rv, #1			@ MMU enabled?
diff --git a/arch/arm/plat-omap/include/plat/serial.h b/arch/arm/plat-omap/include/plat/serial.h
index de3b10c..ad19377 100644
--- a/arch/arm/plat-omap/include/plat/serial.h
+++ b/arch/arm/plat-omap/include/plat/serial.h
@@ -59,6 +59,9 @@
 /* AM3505/3517 UART4 */
 #define AM35XX_UART4_BASE	0x4809E000	/* Only on AM3505/3517 */

+/* AM33XX serial port */
+#define AM33XX_UART1_BASE	0x44E09000
+
 /* External port on Zoom2/3 */
 #define ZOOM_UART_BASE		0x10000000
 #define ZOOM_UART_VIRT		0xfa400000
@@ -92,6 +95,7 @@
 #define TI816XUART1		81
 #define TI816XUART2		82
 #define TI816XUART3		83
+#define AM33XXUART1		84
 #define ZOOM_UART		95		/* Only on zoom2/3 */

 /* This is only used by 8250.c for omap1510 */
diff --git a/arch/arm/plat-omap/include/plat/uncompress.h b/arch/arm/plat-omap/include/plat/uncompress.h
index a067484..bd1e051 100644
--- a/arch/arm/plat-omap/include/plat/uncompress.h
+++ b/arch/arm/plat-omap/include/plat/uncompress.h
@@ -97,6 +97,10 @@ static inline void flush(void)
 	_DEBUG_LL_ENTRY(mach, TI816X_UART##p##_BASE, OMAP_PORT_SHIFT,	\
 		TI816XUART##p)

+#define DEBUG_LL_AM33XX(p, mach)					\
+	_DEBUG_LL_ENTRY(mach, AM33XX_UART##p##_BASE, OMAP_PORT_SHIFT,	\
+		AM33XXUART##p)
+
 static inline void __arch_decomp_setup(unsigned long arch_id)
 {
 	int port = 0;
@@ -173,6 +177,8 @@ static inline void __arch_decomp_setup(unsigned long arch_id)
 		/* TI8168 base boards using UART3 */
 		DEBUG_LL_TI816X(3, ti8168evm);

+		/* AM33XX base boards using UART1 */
+		DEBUG_LL_AM33XX(1, am335xevm);
 	} while (0);
 }

--
1.7.0.4

^ permalink raw reply related	[flat|nested] 263+ messages in thread

* Re: [PATCH-V3 2/4] arm:omap:am33xx: Update common OMAP machine specific sources
  2011-09-20 14:32 ` hvaibhav at ti.com
@ 2011-09-26 18:45   ` Kevin Hilman
  -1 siblings, 0 replies; 263+ messages in thread
From: Kevin Hilman @ 2011-09-26 18:45 UTC (permalink / raw)
  To: hvaibhav; +Cc: linux-omap, paul, tony, linux-arm-kernel, Afzal Mohammed

<hvaibhav@ti.com> writes:

> From: Afzal Mohammed <afzal@ti.com>
>
> This patch updates the common machine specific source files for
> support for AM33XX/AM335x with cpu type, macros for identification of
> AM33XX/AM335X device.
>
> Signed-off-by: Afzal Mohammed <afzal@ti.com>
> Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>

[...]

> @@ -3576,7 +3579,8 @@ int __init omap3xxx_clk_init(void)
>  	 * Lock DPLL5 -- here only until other device init code can
>  	 * handle this
>  	 */
> -	if (!cpu_is_ti816x() && (omap_rev() >= OMAP3430_REV_ES2_0))
> +	if (!cpu_is_ti816x() && !cpu_is_am33xx() &&
> +			(omap_rev() >= OMAP3430_REV_ES2_0))
>  		omap3_clk_lock_dpll5();

This is getting ugly.  

Instead of continuing to expand this if-list, I think it's time for a
new feature-flag for whether or not an SoC has DPLL5 instead.

Kevin


^ permalink raw reply	[flat|nested] 263+ messages in thread

* [PATCH-V3 2/4] arm:omap:am33xx: Update common OMAP machine specific sources
@ 2011-09-26 18:45   ` Kevin Hilman
  0 siblings, 0 replies; 263+ messages in thread
From: Kevin Hilman @ 2011-09-26 18:45 UTC (permalink / raw)
  To: linux-arm-kernel

<hvaibhav@ti.com> writes:

> From: Afzal Mohammed <afzal@ti.com>
>
> This patch updates the common machine specific source files for
> support for AM33XX/AM335x with cpu type, macros for identification of
> AM33XX/AM335X device.
>
> Signed-off-by: Afzal Mohammed <afzal@ti.com>
> Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>

[...]

> @@ -3576,7 +3579,8 @@ int __init omap3xxx_clk_init(void)
>  	 * Lock DPLL5 -- here only until other device init code can
>  	 * handle this
>  	 */
> -	if (!cpu_is_ti816x() && (omap_rev() >= OMAP3430_REV_ES2_0))
> +	if (!cpu_is_ti816x() && !cpu_is_am33xx() &&
> +			(omap_rev() >= OMAP3430_REV_ES2_0))
>  		omap3_clk_lock_dpll5();

This is getting ugly.  

Instead of continuing to expand this if-list, I think it's time for a
new feature-flag for whether or not an SoC has DPLL5 instead.

Kevin

^ permalink raw reply	[flat|nested] 263+ messages in thread

* RE: [PATCH-V3 2/4] arm:omap:am33xx: Update common OMAP machine specific sources
  2011-09-26 18:45   ` Kevin Hilman
@ 2011-09-30 12:09     ` Premi, Sanjeev
  -1 siblings, 0 replies; 263+ messages in thread
From: Premi, Sanjeev @ 2011-09-30 12:09 UTC (permalink / raw)
  To: Hilman, Kevin, Hiremath, Vaibhav
  Cc: linux-omap, paul, tony, linux-arm-kernel, Mohammed, Afzal

> -----Original Message-----
> From: linux-omap-owner@vger.kernel.org 
> [mailto:linux-omap-owner@vger.kernel.org] On Behalf Of Hilman, Kevin
> Sent: Tuesday, September 27, 2011 12:16 AM
> To: Hiremath, Vaibhav
> Cc: linux-omap@vger.kernel.org; paul@pwsan.com; 
> tony@atomide.com; linux-arm-kernel@lists.infradead.org; 
> Mohammed, Afzal
> Subject: Re: [PATCH-V3 2/4] arm:omap:am33xx: Update common 
> OMAP machine specific sources
> 
> <hvaibhav@ti.com> writes:
> 
> > From: Afzal Mohammed <afzal@ti.com>
> >
> > This patch updates the common machine specific source files for
> > support for AM33XX/AM335x with cpu type, macros for 
> identification of
> > AM33XX/AM335X device.
> >
> > Signed-off-by: Afzal Mohammed <afzal@ti.com>
> > Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
> 
> [...]
> 
> > @@ -3576,7 +3579,8 @@ int __init omap3xxx_clk_init(void)
> >  	 * Lock DPLL5 -- here only until other device init code can
> >  	 * handle this
> >  	 */
> > -	if (!cpu_is_ti816x() && (omap_rev() >= OMAP3430_REV_ES2_0))
> > +	if (!cpu_is_ti816x() && !cpu_is_am33xx() &&
> > +			(omap_rev() >= OMAP3430_REV_ES2_0))
> >  		omap3_clk_lock_dpll5();
> 
> This is getting ugly.  
> 
> Instead of continuing to expand this if-list, I think it's time for a
> new feature-flag for whether or not an SoC has DPLL5 instead.

I agree that the code is really getting ugly here. But, isn't
feature-flag going to be over-used with this and similar features?

Just thinking ahead, for these possible cases:
1) An soc adds DPLL6.
2) An soc uses DPLL5, but mechanism to lock is different.

Wouldn't it be better to have a scheme like this:
1) Define a simple structure for DPLLs.
2) Initialize the unused DPLLs to be null/ -1 early
   in arch/soc specific init.
3) The DPLL functions check for corresponding flag on
   entry.

~sanjeev

> 
> Kevin
> 
> --
> To unsubscribe from this list: send the line "unsubscribe 
> linux-omap" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [PATCH-V3 2/4] arm:omap:am33xx: Update common OMAP machine specific sources
@ 2011-09-30 12:09     ` Premi, Sanjeev
  0 siblings, 0 replies; 263+ messages in thread
From: Premi, Sanjeev @ 2011-09-30 12:09 UTC (permalink / raw)
  To: linux-arm-kernel

> -----Original Message-----
> From: linux-omap-owner at vger.kernel.org 
> [mailto:linux-omap-owner at vger.kernel.org] On Behalf Of Hilman, Kevin
> Sent: Tuesday, September 27, 2011 12:16 AM
> To: Hiremath, Vaibhav
> Cc: linux-omap at vger.kernel.org; paul at pwsan.com; 
> tony at atomide.com; linux-arm-kernel at lists.infradead.org; 
> Mohammed, Afzal
> Subject: Re: [PATCH-V3 2/4] arm:omap:am33xx: Update common 
> OMAP machine specific sources
> 
> <hvaibhav@ti.com> writes:
> 
> > From: Afzal Mohammed <afzal@ti.com>
> >
> > This patch updates the common machine specific source files for
> > support for AM33XX/AM335x with cpu type, macros for 
> identification of
> > AM33XX/AM335X device.
> >
> > Signed-off-by: Afzal Mohammed <afzal@ti.com>
> > Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
> 
> [...]
> 
> > @@ -3576,7 +3579,8 @@ int __init omap3xxx_clk_init(void)
> >  	 * Lock DPLL5 -- here only until other device init code can
> >  	 * handle this
> >  	 */
> > -	if (!cpu_is_ti816x() && (omap_rev() >= OMAP3430_REV_ES2_0))
> > +	if (!cpu_is_ti816x() && !cpu_is_am33xx() &&
> > +			(omap_rev() >= OMAP3430_REV_ES2_0))
> >  		omap3_clk_lock_dpll5();
> 
> This is getting ugly.  
> 
> Instead of continuing to expand this if-list, I think it's time for a
> new feature-flag for whether or not an SoC has DPLL5 instead.

I agree that the code is really getting ugly here. But, isn't
feature-flag going to be over-used with this and similar features?

Just thinking ahead, for these possible cases:
1) An soc adds DPLL6.
2) An soc uses DPLL5, but mechanism to lock is different.

Wouldn't it be better to have a scheme like this:
1) Define a simple structure for DPLLs.
2) Initialize the unused DPLLs to be null/ -1 early
   in arch/soc specific init.
3) The DPLL functions check for corresponding flag on
   entry.

~sanjeev

> 
> Kevin
> 
> --
> To unsubscribe from this list: send the line "unsubscribe 
> linux-omap" in
> the body of a message to majordomo at vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

^ permalink raw reply	[flat|nested] 263+ messages in thread

* Re: [PATCH-V3 2/4] arm:omap:am33xx: Update common OMAP machine specific sources
  2011-09-30 12:09     ` Premi, Sanjeev
@ 2011-09-30 17:09       ` Kevin Hilman
  -1 siblings, 0 replies; 263+ messages in thread
From: Kevin Hilman @ 2011-09-30 17:09 UTC (permalink / raw)
  To: Premi, Sanjeev
  Cc: paul, tony, Mohammed, Afzal, Hiremath, Vaibhav, linux-omap,
	linux-arm-kernel

"Premi, Sanjeev" <premi@ti.com> writes:

>> -----Original Message-----
>> From: linux-omap-owner@vger.kernel.org 
>> [mailto:linux-omap-owner@vger.kernel.org] On Behalf Of Hilman, Kevin
>> Sent: Tuesday, September 27, 2011 12:16 AM
>> To: Hiremath, Vaibhav
>> Cc: linux-omap@vger.kernel.org; paul@pwsan.com; 
>> tony@atomide.com; linux-arm-kernel@lists.infradead.org; 
>> Mohammed, Afzal
>> Subject: Re: [PATCH-V3 2/4] arm:omap:am33xx: Update common 
>> OMAP machine specific sources
>> 
>> <hvaibhav@ti.com> writes:
>> 
>> > From: Afzal Mohammed <afzal@ti.com>
>> >
>> > This patch updates the common machine specific source files for
>> > support for AM33XX/AM335x with cpu type, macros for 
>> identification of
>> > AM33XX/AM335X device.
>> >
>> > Signed-off-by: Afzal Mohammed <afzal@ti.com>
>> > Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
>> 
>> [...]
>> 
>> > @@ -3576,7 +3579,8 @@ int __init omap3xxx_clk_init(void)
>> >  	 * Lock DPLL5 -- here only until other device init code can
>> >  	 * handle this
>> >  	 */
>> > -	if (!cpu_is_ti816x() && (omap_rev() >= OMAP3430_REV_ES2_0))
>> > +	if (!cpu_is_ti816x() && !cpu_is_am33xx() &&
>> > +			(omap_rev() >= OMAP3430_REV_ES2_0))
>> >  		omap3_clk_lock_dpll5();
>> 
>> This is getting ugly.  
>> 
>> Instead of continuing to expand this if-list, I think it's time for a
>> new feature-flag for whether or not an SoC has DPLL5 instead.
>
> I agree that the code is really getting ugly here. But, isn't
> feature-flag going to be over-used with this and similar features?
>
> Just thinking ahead, for these possible cases:
> 1) An soc adds DPLL6.
> 2) An soc uses DPLL5, but mechanism to lock is different.

You're right.

> Wouldn't it be better to have a scheme like this:
> 1) Define a simple structure for DPLLs.
> 2) Initialize the unused DPLLs to be null/ -1 early
>    in arch/soc specific init.
> 3) The DPLL functions check for corresponding flag on
>    entry.

Actually, looking at this closer, I think the infrastructure is already
there to handle this cleanly.

Basically, dpll5 should not even be registered for SoCs where it doesn't
exist.  Then, any attempts to use DPLL5 would know it doesn't exist
because the call to clk_get() in omap3_clk_lock_dpll5() would fail.

I think the clock3xxx_data.c needs a bit more cleanup so that only
clocks that exist for a given SoC are registered.

Paul already did a similar cleanup for the powerdomain data files by
creating separate lists for common ones and unique ones.  Looks like we
need the same for the clock data.

Patches welcome.

Kevin

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [PATCH-V3 2/4] arm:omap:am33xx: Update common OMAP machine specific sources
@ 2011-09-30 17:09       ` Kevin Hilman
  0 siblings, 0 replies; 263+ messages in thread
From: Kevin Hilman @ 2011-09-30 17:09 UTC (permalink / raw)
  To: linux-arm-kernel

"Premi, Sanjeev" <premi@ti.com> writes:

>> -----Original Message-----
>> From: linux-omap-owner at vger.kernel.org 
>> [mailto:linux-omap-owner at vger.kernel.org] On Behalf Of Hilman, Kevin
>> Sent: Tuesday, September 27, 2011 12:16 AM
>> To: Hiremath, Vaibhav
>> Cc: linux-omap at vger.kernel.org; paul at pwsan.com; 
>> tony at atomide.com; linux-arm-kernel at lists.infradead.org; 
>> Mohammed, Afzal
>> Subject: Re: [PATCH-V3 2/4] arm:omap:am33xx: Update common 
>> OMAP machine specific sources
>> 
>> <hvaibhav@ti.com> writes:
>> 
>> > From: Afzal Mohammed <afzal@ti.com>
>> >
>> > This patch updates the common machine specific source files for
>> > support for AM33XX/AM335x with cpu type, macros for 
>> identification of
>> > AM33XX/AM335X device.
>> >
>> > Signed-off-by: Afzal Mohammed <afzal@ti.com>
>> > Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
>> 
>> [...]
>> 
>> > @@ -3576,7 +3579,8 @@ int __init omap3xxx_clk_init(void)
>> >  	 * Lock DPLL5 -- here only until other device init code can
>> >  	 * handle this
>> >  	 */
>> > -	if (!cpu_is_ti816x() && (omap_rev() >= OMAP3430_REV_ES2_0))
>> > +	if (!cpu_is_ti816x() && !cpu_is_am33xx() &&
>> > +			(omap_rev() >= OMAP3430_REV_ES2_0))
>> >  		omap3_clk_lock_dpll5();
>> 
>> This is getting ugly.  
>> 
>> Instead of continuing to expand this if-list, I think it's time for a
>> new feature-flag for whether or not an SoC has DPLL5 instead.
>
> I agree that the code is really getting ugly here. But, isn't
> feature-flag going to be over-used with this and similar features?
>
> Just thinking ahead, for these possible cases:
> 1) An soc adds DPLL6.
> 2) An soc uses DPLL5, but mechanism to lock is different.

You're right.

> Wouldn't it be better to have a scheme like this:
> 1) Define a simple structure for DPLLs.
> 2) Initialize the unused DPLLs to be null/ -1 early
>    in arch/soc specific init.
> 3) The DPLL functions check for corresponding flag on
>    entry.

Actually, looking at this closer, I think the infrastructure is already
there to handle this cleanly.

Basically, dpll5 should not even be registered for SoCs where it doesn't
exist.  Then, any attempts to use DPLL5 would know it doesn't exist
because the call to clk_get() in omap3_clk_lock_dpll5() would fail.

I think the clock3xxx_data.c needs a bit more cleanup so that only
clocks that exist for a given SoC are registered.

Paul already did a similar cleanup for the powerdomain data files by
creating separate lists for common ones and unique ones.  Looks like we
need the same for the clock data.

Patches welcome.

Kevin

^ permalink raw reply	[flat|nested] 263+ messages in thread

* Re: [PATCH-V3 2/4] arm:omap:am33xx: Update common OMAP machine specific sources
  2011-09-30 17:09       ` Kevin Hilman
@ 2011-10-06 23:03         ` Tony Lindgren
  -1 siblings, 0 replies; 263+ messages in thread
From: Tony Lindgren @ 2011-10-06 23:03 UTC (permalink / raw)
  To: Kevin Hilman
  Cc: Premi, Sanjeev, Hiremath, Vaibhav, linux-omap, paul,
	linux-arm-kernel, Mohammed, Afzal

* Kevin Hilman <khilman@ti.com> [110930 09:35]:
> "Premi, Sanjeev" <premi@ti.com> writes:
> 
> Actually, looking at this closer, I think the infrastructure is already
> there to handle this cleanly.
> 
> Basically, dpll5 should not even be registered for SoCs where it doesn't
> exist.  Then, any attempts to use DPLL5 would know it doesn't exist
> because the call to clk_get() in omap3_clk_lock_dpll5() would fail.

Yes please use the SoC specific lists, see what we have now queued
up in sram-map-io branch. So using SoC specific map_io + init_early +
set_globals should do the trick.
 
> I think the clock3xxx_data.c needs a bit more cleanup so that only
> clocks that exist for a given SoC are registered.
> 
> Paul already did a similar cleanup for the powerdomain data files by
> creating separate lists for common ones and unique ones.  Looks like we
> need the same for the clock data.

Right.

Regards,

Tony

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [PATCH-V3 2/4] arm:omap:am33xx: Update common OMAP machine specific sources
@ 2011-10-06 23:03         ` Tony Lindgren
  0 siblings, 0 replies; 263+ messages in thread
From: Tony Lindgren @ 2011-10-06 23:03 UTC (permalink / raw)
  To: linux-arm-kernel

* Kevin Hilman <khilman@ti.com> [110930 09:35]:
> "Premi, Sanjeev" <premi@ti.com> writes:
> 
> Actually, looking at this closer, I think the infrastructure is already
> there to handle this cleanly.
> 
> Basically, dpll5 should not even be registered for SoCs where it doesn't
> exist.  Then, any attempts to use DPLL5 would know it doesn't exist
> because the call to clk_get() in omap3_clk_lock_dpll5() would fail.

Yes please use the SoC specific lists, see what we have now queued
up in sram-map-io branch. So using SoC specific map_io + init_early +
set_globals should do the trick.
 
> I think the clock3xxx_data.c needs a bit more cleanup so that only
> clocks that exist for a given SoC are registered.
> 
> Paul already did a similar cleanup for the powerdomain data files by
> creating separate lists for common ones and unique ones.  Looks like we
> need the same for the clock data.

Right.

Regards,

Tony

^ permalink raw reply	[flat|nested] 263+ messages in thread

* Re: [PATCH-V3 1/4] arm:omap:am33xx: Update common omap platform files
  2011-09-20 14:32 ` hvaibhav at ti.com
@ 2011-10-06 23:03   ` Tony Lindgren
  -1 siblings, 0 replies; 263+ messages in thread
From: Tony Lindgren @ 2011-10-06 23:03 UTC (permalink / raw)
  To: hvaibhav
  Cc: khilman, paul, Hemant Pedanekar, Afzal Mohammed, linux-omap,
	linux-arm-kernel

* hvaibhav@ti.com <hvaibhav@ti.com> [110920 06:59]:
> From: Afzal Mohammed <afzal@ti.com>
> 
> This patch updates the common platform files with AM335X device
> support (AM33XX family).
> 
> The approach taken in this patch is,
> AM33XX device will be considered as OMAP3 variant, and a separate
> SoC class created for AM33XX family of devices with a subclass type
> for AM335X device, which is newly added device in the family.
> 
> This means, cpu_is_omap34xx(), cpu_is_am33xx() and cpu_is_am335x()
> checks will return success on AM335X device.
> A kernel config option CONFIG_SOC_OMAPAM33XX is added under OMAP3
> to include support for AM33XX build.
> 
> Also, cpu_mask and RATE_IN_XXX flags have crossed 8 bit hence
> struct clksel_rate.flags, struct prcm_config.flags and cpu_mask
> are changed to u16 from u8.
> 
> Signed-off-by: Afzal Mohammed <afzal@ti.com>
> Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
> Cc: Hemant Pedanekar <hemantp@ti.com>

I'll add this one into soc branch.

Regards,

Tony

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [PATCH-V3 1/4] arm:omap:am33xx: Update common omap platform files
@ 2011-10-06 23:03   ` Tony Lindgren
  0 siblings, 0 replies; 263+ messages in thread
From: Tony Lindgren @ 2011-10-06 23:03 UTC (permalink / raw)
  To: linux-arm-kernel

* hvaibhav at ti.com <hvaibhav@ti.com> [110920 06:59]:
> From: Afzal Mohammed <afzal@ti.com>
> 
> This patch updates the common platform files with AM335X device
> support (AM33XX family).
> 
> The approach taken in this patch is,
> AM33XX device will be considered as OMAP3 variant, and a separate
> SoC class created for AM33XX family of devices with a subclass type
> for AM335X device, which is newly added device in the family.
> 
> This means, cpu_is_omap34xx(), cpu_is_am33xx() and cpu_is_am335x()
> checks will return success on AM335X device.
> A kernel config option CONFIG_SOC_OMAPAM33XX is added under OMAP3
> to include support for AM33XX build.
> 
> Also, cpu_mask and RATE_IN_XXX flags have crossed 8 bit hence
> struct clksel_rate.flags, struct prcm_config.flags and cpu_mask
> are changed to u16 from u8.
> 
> Signed-off-by: Afzal Mohammed <afzal@ti.com>
> Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
> Cc: Hemant Pedanekar <hemantp@ti.com>

I'll add this one into soc branch.

Regards,

Tony

^ permalink raw reply	[flat|nested] 263+ messages in thread

* Re: [PATCH-V3 3/4] arm:omap:am33xx: Create board support and enable build for AM335XEVM
  2011-09-20 14:32 ` hvaibhav at ti.com
@ 2011-10-06 23:07   ` Tony Lindgren
  -1 siblings, 0 replies; 263+ messages in thread
From: Tony Lindgren @ 2011-10-06 23:07 UTC (permalink / raw)
  To: hvaibhav; +Cc: linux-omap, khilman, paul, linux-arm-kernel, Afzal Mohammed

* hvaibhav@ti.com <hvaibhav@ti.com> [110920 06:59]:
> From: Afzal Mohammed <afzal@ti.com>
> 
> This patch adds minimal support and build configuration for
> AM335X EVM.
...

> --- /dev/null
> +++ b/arch/arm/mach-omap2/board-am335xevm.c
> +
> +MACHINE_START(AM335XEVM, "am335xevm")
> +	/* Maintainer: Texas Instruments */
> +	.boot_params	= 0x80000100,
> +	.map_io		= am335x_evm_map_io,
> +	.init_early	= am335x_init_early,
> +	.init_irq	= ti816x_init_irq,
> +	.timer		= &omap3_timer,
> +	.init_machine	= am335x_evm_init,
> +MACHINE_END

Please just add the support into board-am3517evm.c, the board-*.c
files will be going away with device tree.

Regards,

Tony

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [PATCH-V3 3/4] arm:omap:am33xx: Create board support and enable build for AM335XEVM
@ 2011-10-06 23:07   ` Tony Lindgren
  0 siblings, 0 replies; 263+ messages in thread
From: Tony Lindgren @ 2011-10-06 23:07 UTC (permalink / raw)
  To: linux-arm-kernel

* hvaibhav at ti.com <hvaibhav@ti.com> [110920 06:59]:
> From: Afzal Mohammed <afzal@ti.com>
> 
> This patch adds minimal support and build configuration for
> AM335X EVM.
...

> --- /dev/null
> +++ b/arch/arm/mach-omap2/board-am335xevm.c
> +
> +MACHINE_START(AM335XEVM, "am335xevm")
> +	/* Maintainer: Texas Instruments */
> +	.boot_params	= 0x80000100,
> +	.map_io		= am335x_evm_map_io,
> +	.init_early	= am335x_init_early,
> +	.init_irq	= ti816x_init_irq,
> +	.timer		= &omap3_timer,
> +	.init_machine	= am335x_evm_init,
> +MACHINE_END

Please just add the support into board-am3517evm.c, the board-*.c
files will be going away with device tree.

Regards,

Tony

^ permalink raw reply	[flat|nested] 263+ messages in thread

* Re: [PATCH-V3 4/4] arm:omap:am33xx: Add low level debugging support
  2011-09-20 14:32 ` hvaibhav at ti.com
@ 2011-10-06 23:09   ` Tony Lindgren
  -1 siblings, 0 replies; 263+ messages in thread
From: Tony Lindgren @ 2011-10-06 23:09 UTC (permalink / raw)
  To: hvaibhav; +Cc: linux-omap, khilman, paul, linux-arm-kernel, Afzal Mohammed

* hvaibhav@ti.com <hvaibhav@ti.com> [110920 06:59]:
> From: Afzal Mohammed <afzal@ti.com>
> 
> Add support for low level debugging on AM335X EVM (AM33XX family).
> Currently only support for UART1 console, which is used on AM335X EVM
> is added.

Let's wait a bit on this one as there are other DEBUG_LL patches
pending from Nico.

Regards,

Tony

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [PATCH-V3 4/4] arm:omap:am33xx: Add low level debugging support
@ 2011-10-06 23:09   ` Tony Lindgren
  0 siblings, 0 replies; 263+ messages in thread
From: Tony Lindgren @ 2011-10-06 23:09 UTC (permalink / raw)
  To: linux-arm-kernel

* hvaibhav at ti.com <hvaibhav@ti.com> [110920 06:59]:
> From: Afzal Mohammed <afzal@ti.com>
> 
> Add support for low level debugging on AM335X EVM (AM33XX family).
> Currently only support for UART1 console, which is used on AM335X EVM
> is added.

Let's wait a bit on this one as there are other DEBUG_LL patches
pending from Nico.

Regards,

Tony

^ permalink raw reply	[flat|nested] 263+ messages in thread

* RE: [PATCH-V3 2/4] arm:omap:am33xx: Update common OMAP machine specific sources
  2011-10-06 23:03         ` Tony Lindgren
@ 2011-11-03 13:48           ` Hiremath, Vaibhav
  -1 siblings, 0 replies; 263+ messages in thread
From: Hiremath, Vaibhav @ 2011-11-03 13:48 UTC (permalink / raw)
  To: Tony Lindgren, Hilman, Kevin
  Cc: Premi, Sanjeev, linux-omap, paul, linux-arm-kernel, Mohammed, Afzal

> -----Original Message-----
> From: Tony Lindgren [mailto:tony@atomide.com]
> Sent: Friday, October 07, 2011 4:33 AM
> To: Hilman, Kevin
> Cc: Premi, Sanjeev; Hiremath, Vaibhav; linux-omap@vger.kernel.org;
> paul@pwsan.com; linux-arm-kernel@lists.infradead.org; Mohammed, Afzal
> Subject: Re: [PATCH-V3 2/4] arm:omap:am33xx: Update common OMAP machine
> specific sources
> 
> * Kevin Hilman <khilman@ti.com> [110930 09:35]:
> > "Premi, Sanjeev" <premi@ti.com> writes:
> >
> > Actually, looking at this closer, I think the infrastructure is already
> > there to handle this cleanly.
> >
> > Basically, dpll5 should not even be registered for SoCs where it doesn't
> > exist.  Then, any attempts to use DPLL5 would know it doesn't exist
> > because the call to clk_get() in omap3_clk_lock_dpll5() would fail.
> 
> Yes please use the SoC specific lists, see what we have now queued
> up in sram-map-io branch. So using SoC specific map_io + init_early +
> set_globals should do the trick.
> 
Sorry for delayed response, was on festival vacation...

> > I think the clock3xxx_data.c needs a bit more cleanup so that only
> > clocks that exist for a given SoC are registered.
> >
> > Paul already did a similar cleanup for the powerdomain data files by
> > creating separate lists for common ones and unique ones.  Looks like we
> > need the same for the clock data.
> 
> Right.
> 
I agree that we need to clean clock data, but with the current discussion,
feel it may not be so useful, since the clock tree of the AM335x device is
different than OMAP3 family of devices -

http://www.ti.com/product/am3359

Public TRM -
http://www.ti.com/lit/ug/spruh73/spruh73.pdf


While porting Linux kernel to AM335x EVM, I had created separate clock data
file for AM33xx -
	- arch/arm/mach-omap2/clock33xx_data.c

Similar for clock domain data -
	- arch/arm/mach-omap2/clockdomains33xx_data.c

So we don't need any of the changes which we are discussing about, since execution doesn't reach there.


Currently looking at clock data, to see how this cleanup can be achieved,
any suggestions/comments/pointers would be helpful.


Thanks,
Vaibhav

> Regards,
> 
> Tony

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [PATCH-V3 2/4] arm:omap:am33xx: Update common OMAP machine specific sources
@ 2011-11-03 13:48           ` Hiremath, Vaibhav
  0 siblings, 0 replies; 263+ messages in thread
From: Hiremath, Vaibhav @ 2011-11-03 13:48 UTC (permalink / raw)
  To: linux-arm-kernel

> -----Original Message-----
> From: Tony Lindgren [mailto:tony at atomide.com]
> Sent: Friday, October 07, 2011 4:33 AM
> To: Hilman, Kevin
> Cc: Premi, Sanjeev; Hiremath, Vaibhav; linux-omap at vger.kernel.org;
> paul at pwsan.com; linux-arm-kernel at lists.infradead.org; Mohammed, Afzal
> Subject: Re: [PATCH-V3 2/4] arm:omap:am33xx: Update common OMAP machine
> specific sources
> 
> * Kevin Hilman <khilman@ti.com> [110930 09:35]:
> > "Premi, Sanjeev" <premi@ti.com> writes:
> >
> > Actually, looking at this closer, I think the infrastructure is already
> > there to handle this cleanly.
> >
> > Basically, dpll5 should not even be registered for SoCs where it doesn't
> > exist.  Then, any attempts to use DPLL5 would know it doesn't exist
> > because the call to clk_get() in omap3_clk_lock_dpll5() would fail.
> 
> Yes please use the SoC specific lists, see what we have now queued
> up in sram-map-io branch. So using SoC specific map_io + init_early +
> set_globals should do the trick.
> 
Sorry for delayed response, was on festival vacation...

> > I think the clock3xxx_data.c needs a bit more cleanup so that only
> > clocks that exist for a given SoC are registered.
> >
> > Paul already did a similar cleanup for the powerdomain data files by
> > creating separate lists for common ones and unique ones.  Looks like we
> > need the same for the clock data.
> 
> Right.
> 
I agree that we need to clean clock data, but with the current discussion,
feel it may not be so useful, since the clock tree of the AM335x device is
different than OMAP3 family of devices -

http://www.ti.com/product/am3359

Public TRM -
http://www.ti.com/lit/ug/spruh73/spruh73.pdf


While porting Linux kernel to AM335x EVM, I had created separate clock data
file for AM33xx -
	- arch/arm/mach-omap2/clock33xx_data.c

Similar for clock domain data -
	- arch/arm/mach-omap2/clockdomains33xx_data.c

So we don't need any of the changes which we are discussing about, since execution doesn't reach there.


Currently looking at clock data, to see how this cleanup can be achieved,
any suggestions/comments/pointers would be helpful.


Thanks,
Vaibhav

> Regards,
> 
> Tony

^ permalink raw reply	[flat|nested] 263+ messages in thread

* RE: [PATCH-V3 2/4] arm:omap:am33xx: Update common OMAP machine specific sources
  2011-09-20 14:32 ` hvaibhav at ti.com
@ 2011-11-05  9:41   ` Hiremath, Vaibhav
  -1 siblings, 0 replies; 263+ messages in thread
From: Hiremath, Vaibhav @ 2011-11-05  9:41 UTC (permalink / raw)
  To: Hiremath, Vaibhav, linux-omap
  Cc: Hilman, Kevin, paul, tony, linux-arm-kernel, Mohammed, Afzal

> -----Original Message-----
> From: Hiremath, Vaibhav
> Sent: Tuesday, September 20, 2011 8:02 PM
> To: linux-omap@vger.kernel.org
> Cc: Hilman, Kevin; paul@pwsan.com; tony@atomide.com; linux-arm-
> kernel@lists.infradead.org; Mohammed, Afzal; Hiremath, Vaibhav
> Subject: [PATCH-V3 2/4] arm:omap:am33xx: Update common OMAP machine
> specific sources
> 
> From: Afzal Mohammed <afzal@ti.com>
> 
> This patch updates the common machine specific source files for
> support for AM33XX/AM335x with cpu type, macros for identification of
> AM33XX/AM335X device.
> 
> Signed-off-by: Afzal Mohammed <afzal@ti.com>
> Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
> ---
>  arch/arm/mach-omap2/clock3xxx_data.c       |    6 +++++-
>  arch/arm/mach-omap2/common.c               |   16 ++++++++++++++++
>  arch/arm/mach-omap2/id.c                   |   10 ++++++++--
>  arch/arm/mach-omap2/io.c                   |   25
> +++++++++++++++++++++++++
>  arch/arm/mach-omap2/serial.c               |    6 +++---
>  arch/arm/plat-omap/include/plat/am33xx.h   |   25
> +++++++++++++++++++++++++
>  arch/arm/plat-omap/include/plat/common.h   |    1 +
>  arch/arm/plat-omap/include/plat/hardware.h |    1 +
>  arch/arm/plat-omap/include/plat/io.h       |   20 ++++++++++++++++++++
>  arch/arm/plat-omap/include/plat/omap34xx.h |    2 ++
>  arch/arm/plat-omap/io.c                    |    5 +++++
>  11 files changed, 111 insertions(+), 6 deletions(-)
>  create mode 100644 arch/arm/plat-omap/include/plat/am33xx.h
> 
> diff --git a/arch/arm/mach-omap2/clock3xxx_data.c b/arch/arm/mach-
> omap2/clock3xxx_data.c
> index dadb8c6..2ee472c 100644
> --- a/arch/arm/mach-omap2/clock3xxx_data.c
> +++ b/arch/arm/mach-omap2/clock3xxx_data.c
> @@ -3493,6 +3493,9 @@ int __init omap3xxx_clk_init(void)
>  	} else if (cpu_is_ti816x()) {
>  		cpu_mask = RATE_IN_TI816X;
>  		cpu_clkflg = CK_TI816X;
> +	} else if (cpu_is_am33xx()) {
> +		cpu_mask = RATE_IN_AM33XX;
> +		cpu_clkflg = CK_AM33XX;
>  	} else if (cpu_is_omap34xx()) {
>  		if (omap_rev() == OMAP3430_REV_ES1_0) {
>  			cpu_mask = RATE_IN_3430ES1;
> @@ -3576,7 +3579,8 @@ int __init omap3xxx_clk_init(void)
>  	 * Lock DPLL5 -- here only until other device init code can
>  	 * handle this
>  	 */
> -	if (!cpu_is_ti816x() && (omap_rev() >= OMAP3430_REV_ES2_0))
> +	if (!cpu_is_ti816x() && !cpu_is_am33xx() &&
> +			(omap_rev() >= OMAP3430_REV_ES2_0))
>  		omap3_clk_lock_dpll5();
> 
>  	/* Avoid sleeping during omap3_core_dpll_m2_set_rate() */
> diff --git a/arch/arm/mach-omap2/common.c b/arch/arm/mach-omap2/common.c
> index 3f20cbb..395a9b6 100644
> --- a/arch/arm/mach-omap2/common.c
> +++ b/arch/arm/mach-omap2/common.c
> @@ -119,6 +119,22 @@ void __init omap2_set_globals_ti816x(void)
>  {
>  	__omap2_set_globals(&ti816x_globals);
>  }
> +
> +#define AM33XX_TAP_BASE		(AM33XX_CTRL_BASE + \
> +				TI816X_CONTROL_DEVICE_ID - 0x204)
> +
> +static struct omap_globals am33xx_globals = {
> +	.class  = OMAP343X_CLASS,
> +	.tap    = OMAP2_L4_IO_ADDRESS(AM33XX_TAP_BASE),
> +	.ctrl   = AM33XX_CTRL_BASE,
> +	.prm    = AM33XX_PRCM_BASE,
> +	.cm     = AM33XX_PRCM_BASE,
> +};
> +
> +void __init omap2_set_globals_am33xx(void)
> +{
> +	__omap2_set_globals(&am33xx_globals);
> +}
>  #endif
> 
>  #if defined(CONFIG_ARCH_OMAP4)
> diff --git a/arch/arm/mach-omap2/id.c b/arch/arm/mach-omap2/id.c
> index d27daf9..540b6f1 100644
> --- a/arch/arm/mach-omap2/id.c
> +++ b/arch/arm/mach-omap2/id.c
> @@ -337,6 +337,10 @@ static void __init omap3_check_revision(const char
> **cpu_rev)
>  			break;
>  		}
>  		break;
> +	case 0xb944:
> +		omap_revision = AM335X_REV_ES1_0;
> +		*cpu_rev = "1.0";
> +		break;
>  	default:
>  		/* Unknown default to latest silicon rev as default */
>  		omap_revision = OMAP3630_REV_ES1_2;
> @@ -429,6 +433,8 @@ static void __init omap3_cpuinfo(const char *cpu_rev)
>  		cpu_name = (omap3_has_sgx()) ? "AM3517" : "AM3505";
>  	} else if (cpu_is_ti816x()) {
>  		cpu_name = "TI816X";
> +	} else if (cpu_is_am335x()) {
> +		cpu_name =  "AM335X";
>  	} else if (omap3_has_iva() && omap3_has_sgx()) {
>  		/* OMAP3430, OMAP3525, OMAP3515, OMAP3503 devices */
>  		cpu_name = "OMAP3430/3530";
> @@ -469,8 +475,8 @@ void __init omap2_check_revision(void)
>  	} else if (cpu_is_omap34xx()) {
>  		omap3_check_revision(&cpu_rev);
> 
> -		/* TI816X doesn't have feature register */
> -		if (!cpu_is_ti816x())
> +		/* TI816X/AM335X doesn't have feature register */
> +		if (!cpu_is_ti816x() && !cpu_is_am33xx())
>  			omap3_check_features();
>  		else
>  			ti816x_check_features();
> diff --git a/arch/arm/mach-omap2/io.c b/arch/arm/mach-omap2/io.c
> index 40b6d47..ccd50de 100644
> --- a/arch/arm/mach-omap2/io.c
> +++ b/arch/arm/mach-omap2/io.c
> @@ -182,7 +182,24 @@ static struct map_desc omapti816x_io_desc[]
> __initdata = {
>  		.pfn		= __phys_to_pfn(L4_34XX_PHYS),
>  		.length		= L4_34XX_SIZE,
>  		.type		= MT_DEVICE
> +	}
> +};
> +#endif
> +
> +#ifdef CONFIG_SOC_OMAPAM33XX
> +static struct map_desc omapam33xx_io_desc[] __initdata = {
> +	{
> +		.virtual	= L4_34XX_VIRT,
> +		.pfn		= __phys_to_pfn(L4_34XX_PHYS),
> +		.length		= L4_34XX_SIZE,
> +		.type		= MT_DEVICE
>  	},
> +	{
> +		.virtual	= L4_WK_AM33XX_VIRT,
> +		.pfn		= __phys_to_pfn(L4_WK_AM33XX_PHYS),
> +		.length		= L4_WK_AM33XX_SIZE,
> +		.type		= MT_DEVICE
> +	}
>  };
>  #endif
> 
> @@ -286,6 +303,14 @@ void __init omapti816x_map_common_io(void)
>  }
>  #endif
> 
> +#ifdef CONFIG_SOC_OMAPAM33XX
> +void __init omapam33xx_map_common_io(void)
> +{
> +	iotable_init(omapam33xx_io_desc, ARRAY_SIZE(omapam33xx_io_desc));
> +	_omap2_map_common_io();
> +}
> +#endif
> +
>  #ifdef CONFIG_ARCH_OMAP4
>  void __init omap44xx_map_common_io(void)
>  {
> diff --git a/arch/arm/mach-omap2/serial.c b/arch/arm/mach-omap2/serial.c
> index 466fc72..b7782ee 100644
> --- a/arch/arm/mach-omap2/serial.c
> +++ b/arch/arm/mach-omap2/serial.c
> @@ -486,7 +486,7 @@ static void omap_uart_idle_init(struct omap_uart_state
> *uart)
>  		mod_timer(&uart->timer, jiffies + uart->timeout);
>  	omap_uart_smart_idle_enable(uart, 0);
> 
> -	if (cpu_is_omap34xx() && !cpu_is_ti816x()) {
> +	if (cpu_is_omap34xx() && !(cpu_is_ti816x() || cpu_is_am33xx())) {
>  		u32 mod = (uart->num > 1) ? OMAP3430_PER_MOD : CORE_MOD;
>  		u32 wk_mask = 0;
>  		u32 padconf = 0;
> @@ -768,7 +768,7 @@ void __init omap_serial_init_port(struct
> omap_board_data *bdata)
>  	 */
>  	uart->regshift = p->regshift;
>  	uart->membase = p->membase;
> -	if (cpu_is_omap44xx() || cpu_is_ti816x())
> +	if (cpu_is_omap44xx() || cpu_is_ti816x() || cpu_is_am33xx())
>  		uart->errata |= UART_ERRATA_FIFO_FULL_ABORT;
>  	else if ((serial_read_reg(uart, UART_OMAP_MVER) & 0xFF)
>  			>= UART_OMAP_NO_EMPTY_FIFO_READ_IP_REV)
> @@ -851,7 +851,7 @@ void __init omap_serial_init_port(struct
> omap_board_data *bdata)
>  	}

Can I get rid of this if condition as well here with below change - 

-        * omap44xx, ti816x: Never read empty UART fifo
+        * all >omap3 family of devices: Never read empty UART fifo
         * omap3xxx: Never read empty UART fifo on UARTs
         * with IP rev >=0x52
         */
        uart->regshift = p->regshift;
        uart->membase = p->membase;
-       if (cpu_is_omap44xx() || cpu_is_ti816x() || cpu_is_am33xx())
-               uart->errata |= UART_ERRATA_FIFO_FULL_ABORT;
-       else if ((serial_read_reg(uart, UART_OMAP_MVER) & 0xFF)
-                       >= UART_OMAP_NO_EMPTY_FIFO_READ_IP_REV)
+
+       if ((serial_read_reg(uart, UART_OMAP_MVER) & 0xFF)
+                       < UART_OMAP_NO_EMPTY_FIFO_READ_IP_REV)
+               uart->errata &= ~UART_ERRATA_FIFO_FULL_ABORT;
+       else
                uart->errata |= UART_ERRATA_FIFO_FULL_ABORT;

        if (uart->errata & UART_ERRATA_FIFO_FULL_ABORT) {


Thanks,
Vaibhav

> 
>  	/* Enable the MDR1 errata for OMAP3 */
> -	if (cpu_is_omap34xx() && !cpu_is_ti816x())
> +	if (cpu_is_omap34xx() && !(cpu_is_ti816x() || cpu_is_am33xx()))
>  		uart->errata |= UART_ERRATA_i202_MDR1_ACCESS;
>  }
> 
> diff --git a/arch/arm/plat-omap/include/plat/am33xx.h b/arch/arm/plat-
> omap/include/plat/am33xx.h
> new file mode 100644
> index 0000000..06c19bb
> --- /dev/null
> +++ b/arch/arm/plat-omap/include/plat/am33xx.h
> @@ -0,0 +1,25 @@
> +/*
> + * This file contains the address info for various AM33XX modules.
> + *
> + * Copyright (C) 2011 Texas Instruments, Inc. - http://www.ti.com/
> + *
> + * 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.
> + */
> +
> +#ifndef __ASM_ARCH_AM33XX_H
> +#define __ASM_ARCH_AM33XX_H
> +
> +#define L4_SLOW_AM33XX_BASE	0x48000000
> +
> +#define AM33XX_SCM_BASE		0x44E10000
> +#define AM33XX_CTRL_BASE	AM33XX_SCM_BASE
> +#define AM33XX_PRCM_BASE	0x44E00000
> +
> +#endif /* __ASM_ARCH_AM33XX_H */
> diff --git a/arch/arm/plat-omap/include/plat/common.h b/arch/arm/plat-
> omap/include/plat/common.h
> index 4564cc6..6827e34 100644
> --- a/arch/arm/plat-omap/include/plat/common.h
> +++ b/arch/arm/plat-omap/include/plat/common.h
> @@ -67,6 +67,7 @@ void omap2_set_globals_243x(void);
>  void omap2_set_globals_3xxx(void);
>  void omap2_set_globals_443x(void);
>  void omap2_set_globals_ti816x(void);
> +void omap2_set_globals_am33xx(void);
> 
>  /* These get called from omap2_set_globals_xxxx(), do not call these */
>  void omap2_set_globals_tap(struct omap_globals *);
> diff --git a/arch/arm/plat-omap/include/plat/hardware.h b/arch/arm/plat-
> omap/include/plat/hardware.h
> index e87efe1..e6521e1 100644
> --- a/arch/arm/plat-omap/include/plat/hardware.h
> +++ b/arch/arm/plat-omap/include/plat/hardware.h
> @@ -287,5 +287,6 @@
>  #include <plat/omap34xx.h>
>  #include <plat/omap44xx.h>
>  #include <plat/ti816x.h>
> +#include <plat/am33xx.h>
> 
>  #endif	/* __ASM_ARCH_OMAP_HARDWARE_H */
> diff --git a/arch/arm/plat-omap/include/plat/io.h b/arch/arm/plat-
> omap/include/plat/io.h
> index d72ec85..0c54a00 100644
> --- a/arch/arm/plat-omap/include/plat/io.h
> +++ b/arch/arm/plat-omap/include/plat/io.h
> @@ -73,6 +73,9 @@
>  #define OMAP4_L3_IO_OFFSET	0xb4000000
>  #define OMAP4_L3_IO_ADDRESS(pa)	IOMEM((pa) + OMAP4_L3_IO_OFFSET) /* L3
> */
> 
> +#define AM33XX_L4_WK_IO_OFFSET	0xb5000000
> +#define AM33XX_L4_WK_IO_ADDRESS(pa)	IOMEM((pa) +
> AM33XX_L4_WK_IO_OFFSET)
> +
>  #define OMAP4_L3_PER_IO_OFFSET	0xb1100000
>  #define OMAP4_L3_PER_IO_ADDRESS(pa)	IOMEM((pa) +
> OMAP4_L3_PER_IO_OFFSET)
> 
> @@ -154,6 +157,15 @@
>  #define L4_34XX_SIZE		SZ_4M   /* 1MB of 128MB used, want 1MB sect
> */
> 
>  /*
> + * ----------------------------------------------------------------------
> ------
> + * AM33XX specific IO mapping
> + * ----------------------------------------------------------------------
> ------
> + */
> +#define L4_WK_AM33XX_PHYS		L4_WK_AM33XX_BASE
> +#define L4_WK_AM33XX_VIRT		(L4_WK_AM33XX_PHYS +
> AM33XX_L4_WK_IO_OFFSET)
> +#define L4_WK_AM33XX_SIZE		SZ_4M   /* 1MB of 128MB used, want 1MB
> sect */
> +
> +/*
>   * Need to look at the Size 4M for L4.
>   * VPOM3430 was not working for Int controller
>   */
> @@ -291,6 +303,14 @@ static inline void omapti816x_map_common_io(void)
>  }
>  #endif
> 
> +#ifdef CONFIG_SOC_OMAPAM33XX
> +extern void omapam33xx_map_common_io(void);
> +#else
> +static inline void omapam33xx_map_common_io(void)
> +{
> +}
> +#endif
> +
>  #ifdef CONFIG_ARCH_OMAP4
>  extern void omap44xx_map_common_io(void);
>  #else
> diff --git a/arch/arm/plat-omap/include/plat/omap34xx.h b/arch/arm/plat-
> omap/include/plat/omap34xx.h
> index b9e8588..0d818ac 100644
> --- a/arch/arm/plat-omap/include/plat/omap34xx.h
> +++ b/arch/arm/plat-omap/include/plat/omap34xx.h
> @@ -35,6 +35,8 @@
>  #define L4_EMU_34XX_BASE	0x54000000
>  #define L3_34XX_BASE		0x68000000
> 
> +#define L4_WK_AM33XX_BASE	0x44C00000
> +
>  #define OMAP3430_32KSYNCT_BASE	0x48320000
>  #define OMAP3430_CM_BASE	0x48004800
>  #define OMAP3430_PRM_BASE	0x48306800
> diff --git a/arch/arm/plat-omap/io.c b/arch/arm/plat-omap/io.c
> index f1ecfa9..25a32b2 100644
> --- a/arch/arm/plat-omap/io.c
> +++ b/arch/arm/plat-omap/io.c
> @@ -88,6 +88,11 @@ void __iomem *omap_ioremap(unsigned long p, size_t size,
> unsigned int type)
>  	if (cpu_is_ti816x()) {
>  		if (BETWEEN(p, L4_34XX_PHYS, L4_34XX_SIZE))
>  			return XLATE(p, L4_34XX_PHYS, L4_34XX_VIRT);
> +	} else if (cpu_is_am33xx()) {
> +		if (BETWEEN(p, L4_34XX_PHYS, L4_34XX_SIZE))
> +			return XLATE(p, L4_34XX_PHYS, L4_34XX_VIRT);
> +		if (BETWEEN(p, L4_WK_AM33XX_PHYS, L4_WK_AM33XX_SIZE))
> +			return XLATE(p, L4_WK_AM33XX_PHYS, L4_WK_AM33XX_VIRT);
>  	} else if (cpu_is_omap34xx()) {
>  		if (BETWEEN(p, L3_34XX_PHYS, L3_34XX_SIZE))
>  			return XLATE(p, L3_34XX_PHYS, L3_34XX_VIRT);
> --
> 1.7.0.4


^ permalink raw reply	[flat|nested] 263+ messages in thread

* [PATCH-V3 2/4] arm:omap:am33xx: Update common OMAP machine specific sources
@ 2011-11-05  9:41   ` Hiremath, Vaibhav
  0 siblings, 0 replies; 263+ messages in thread
From: Hiremath, Vaibhav @ 2011-11-05  9:41 UTC (permalink / raw)
  To: linux-arm-kernel

> -----Original Message-----
> From: Hiremath, Vaibhav
> Sent: Tuesday, September 20, 2011 8:02 PM
> To: linux-omap at vger.kernel.org
> Cc: Hilman, Kevin; paul at pwsan.com; tony at atomide.com; linux-arm-
> kernel at lists.infradead.org; Mohammed, Afzal; Hiremath, Vaibhav
> Subject: [PATCH-V3 2/4] arm:omap:am33xx: Update common OMAP machine
> specific sources
> 
> From: Afzal Mohammed <afzal@ti.com>
> 
> This patch updates the common machine specific source files for
> support for AM33XX/AM335x with cpu type, macros for identification of
> AM33XX/AM335X device.
> 
> Signed-off-by: Afzal Mohammed <afzal@ti.com>
> Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
> ---
>  arch/arm/mach-omap2/clock3xxx_data.c       |    6 +++++-
>  arch/arm/mach-omap2/common.c               |   16 ++++++++++++++++
>  arch/arm/mach-omap2/id.c                   |   10 ++++++++--
>  arch/arm/mach-omap2/io.c                   |   25
> +++++++++++++++++++++++++
>  arch/arm/mach-omap2/serial.c               |    6 +++---
>  arch/arm/plat-omap/include/plat/am33xx.h   |   25
> +++++++++++++++++++++++++
>  arch/arm/plat-omap/include/plat/common.h   |    1 +
>  arch/arm/plat-omap/include/plat/hardware.h |    1 +
>  arch/arm/plat-omap/include/plat/io.h       |   20 ++++++++++++++++++++
>  arch/arm/plat-omap/include/plat/omap34xx.h |    2 ++
>  arch/arm/plat-omap/io.c                    |    5 +++++
>  11 files changed, 111 insertions(+), 6 deletions(-)
>  create mode 100644 arch/arm/plat-omap/include/plat/am33xx.h
> 
> diff --git a/arch/arm/mach-omap2/clock3xxx_data.c b/arch/arm/mach-
> omap2/clock3xxx_data.c
> index dadb8c6..2ee472c 100644
> --- a/arch/arm/mach-omap2/clock3xxx_data.c
> +++ b/arch/arm/mach-omap2/clock3xxx_data.c
> @@ -3493,6 +3493,9 @@ int __init omap3xxx_clk_init(void)
>  	} else if (cpu_is_ti816x()) {
>  		cpu_mask = RATE_IN_TI816X;
>  		cpu_clkflg = CK_TI816X;
> +	} else if (cpu_is_am33xx()) {
> +		cpu_mask = RATE_IN_AM33XX;
> +		cpu_clkflg = CK_AM33XX;
>  	} else if (cpu_is_omap34xx()) {
>  		if (omap_rev() == OMAP3430_REV_ES1_0) {
>  			cpu_mask = RATE_IN_3430ES1;
> @@ -3576,7 +3579,8 @@ int __init omap3xxx_clk_init(void)
>  	 * Lock DPLL5 -- here only until other device init code can
>  	 * handle this
>  	 */
> -	if (!cpu_is_ti816x() && (omap_rev() >= OMAP3430_REV_ES2_0))
> +	if (!cpu_is_ti816x() && !cpu_is_am33xx() &&
> +			(omap_rev() >= OMAP3430_REV_ES2_0))
>  		omap3_clk_lock_dpll5();
> 
>  	/* Avoid sleeping during omap3_core_dpll_m2_set_rate() */
> diff --git a/arch/arm/mach-omap2/common.c b/arch/arm/mach-omap2/common.c
> index 3f20cbb..395a9b6 100644
> --- a/arch/arm/mach-omap2/common.c
> +++ b/arch/arm/mach-omap2/common.c
> @@ -119,6 +119,22 @@ void __init omap2_set_globals_ti816x(void)
>  {
>  	__omap2_set_globals(&ti816x_globals);
>  }
> +
> +#define AM33XX_TAP_BASE		(AM33XX_CTRL_BASE + \
> +				TI816X_CONTROL_DEVICE_ID - 0x204)
> +
> +static struct omap_globals am33xx_globals = {
> +	.class  = OMAP343X_CLASS,
> +	.tap    = OMAP2_L4_IO_ADDRESS(AM33XX_TAP_BASE),
> +	.ctrl   = AM33XX_CTRL_BASE,
> +	.prm    = AM33XX_PRCM_BASE,
> +	.cm     = AM33XX_PRCM_BASE,
> +};
> +
> +void __init omap2_set_globals_am33xx(void)
> +{
> +	__omap2_set_globals(&am33xx_globals);
> +}
>  #endif
> 
>  #if defined(CONFIG_ARCH_OMAP4)
> diff --git a/arch/arm/mach-omap2/id.c b/arch/arm/mach-omap2/id.c
> index d27daf9..540b6f1 100644
> --- a/arch/arm/mach-omap2/id.c
> +++ b/arch/arm/mach-omap2/id.c
> @@ -337,6 +337,10 @@ static void __init omap3_check_revision(const char
> **cpu_rev)
>  			break;
>  		}
>  		break;
> +	case 0xb944:
> +		omap_revision = AM335X_REV_ES1_0;
> +		*cpu_rev = "1.0";
> +		break;
>  	default:
>  		/* Unknown default to latest silicon rev as default */
>  		omap_revision = OMAP3630_REV_ES1_2;
> @@ -429,6 +433,8 @@ static void __init omap3_cpuinfo(const char *cpu_rev)
>  		cpu_name = (omap3_has_sgx()) ? "AM3517" : "AM3505";
>  	} else if (cpu_is_ti816x()) {
>  		cpu_name = "TI816X";
> +	} else if (cpu_is_am335x()) {
> +		cpu_name =  "AM335X";
>  	} else if (omap3_has_iva() && omap3_has_sgx()) {
>  		/* OMAP3430, OMAP3525, OMAP3515, OMAP3503 devices */
>  		cpu_name = "OMAP3430/3530";
> @@ -469,8 +475,8 @@ void __init omap2_check_revision(void)
>  	} else if (cpu_is_omap34xx()) {
>  		omap3_check_revision(&cpu_rev);
> 
> -		/* TI816X doesn't have feature register */
> -		if (!cpu_is_ti816x())
> +		/* TI816X/AM335X doesn't have feature register */
> +		if (!cpu_is_ti816x() && !cpu_is_am33xx())
>  			omap3_check_features();
>  		else
>  			ti816x_check_features();
> diff --git a/arch/arm/mach-omap2/io.c b/arch/arm/mach-omap2/io.c
> index 40b6d47..ccd50de 100644
> --- a/arch/arm/mach-omap2/io.c
> +++ b/arch/arm/mach-omap2/io.c
> @@ -182,7 +182,24 @@ static struct map_desc omapti816x_io_desc[]
> __initdata = {
>  		.pfn		= __phys_to_pfn(L4_34XX_PHYS),
>  		.length		= L4_34XX_SIZE,
>  		.type		= MT_DEVICE
> +	}
> +};
> +#endif
> +
> +#ifdef CONFIG_SOC_OMAPAM33XX
> +static struct map_desc omapam33xx_io_desc[] __initdata = {
> +	{
> +		.virtual	= L4_34XX_VIRT,
> +		.pfn		= __phys_to_pfn(L4_34XX_PHYS),
> +		.length		= L4_34XX_SIZE,
> +		.type		= MT_DEVICE
>  	},
> +	{
> +		.virtual	= L4_WK_AM33XX_VIRT,
> +		.pfn		= __phys_to_pfn(L4_WK_AM33XX_PHYS),
> +		.length		= L4_WK_AM33XX_SIZE,
> +		.type		= MT_DEVICE
> +	}
>  };
>  #endif
> 
> @@ -286,6 +303,14 @@ void __init omapti816x_map_common_io(void)
>  }
>  #endif
> 
> +#ifdef CONFIG_SOC_OMAPAM33XX
> +void __init omapam33xx_map_common_io(void)
> +{
> +	iotable_init(omapam33xx_io_desc, ARRAY_SIZE(omapam33xx_io_desc));
> +	_omap2_map_common_io();
> +}
> +#endif
> +
>  #ifdef CONFIG_ARCH_OMAP4
>  void __init omap44xx_map_common_io(void)
>  {
> diff --git a/arch/arm/mach-omap2/serial.c b/arch/arm/mach-omap2/serial.c
> index 466fc72..b7782ee 100644
> --- a/arch/arm/mach-omap2/serial.c
> +++ b/arch/arm/mach-omap2/serial.c
> @@ -486,7 +486,7 @@ static void omap_uart_idle_init(struct omap_uart_state
> *uart)
>  		mod_timer(&uart->timer, jiffies + uart->timeout);
>  	omap_uart_smart_idle_enable(uart, 0);
> 
> -	if (cpu_is_omap34xx() && !cpu_is_ti816x()) {
> +	if (cpu_is_omap34xx() && !(cpu_is_ti816x() || cpu_is_am33xx())) {
>  		u32 mod = (uart->num > 1) ? OMAP3430_PER_MOD : CORE_MOD;
>  		u32 wk_mask = 0;
>  		u32 padconf = 0;
> @@ -768,7 +768,7 @@ void __init omap_serial_init_port(struct
> omap_board_data *bdata)
>  	 */
>  	uart->regshift = p->regshift;
>  	uart->membase = p->membase;
> -	if (cpu_is_omap44xx() || cpu_is_ti816x())
> +	if (cpu_is_omap44xx() || cpu_is_ti816x() || cpu_is_am33xx())
>  		uart->errata |= UART_ERRATA_FIFO_FULL_ABORT;
>  	else if ((serial_read_reg(uart, UART_OMAP_MVER) & 0xFF)
>  			>= UART_OMAP_NO_EMPTY_FIFO_READ_IP_REV)
> @@ -851,7 +851,7 @@ void __init omap_serial_init_port(struct
> omap_board_data *bdata)
>  	}

Can I get rid of this if condition as well here with below change - 

-        * omap44xx, ti816x: Never read empty UART fifo
+        * all >omap3 family of devices: Never read empty UART fifo
         * omap3xxx: Never read empty UART fifo on UARTs
         * with IP rev >=0x52
         */
        uart->regshift = p->regshift;
        uart->membase = p->membase;
-       if (cpu_is_omap44xx() || cpu_is_ti816x() || cpu_is_am33xx())
-               uart->errata |= UART_ERRATA_FIFO_FULL_ABORT;
-       else if ((serial_read_reg(uart, UART_OMAP_MVER) & 0xFF)
-                       >= UART_OMAP_NO_EMPTY_FIFO_READ_IP_REV)
+
+       if ((serial_read_reg(uart, UART_OMAP_MVER) & 0xFF)
+                       < UART_OMAP_NO_EMPTY_FIFO_READ_IP_REV)
+               uart->errata &= ~UART_ERRATA_FIFO_FULL_ABORT;
+       else
                uart->errata |= UART_ERRATA_FIFO_FULL_ABORT;

        if (uart->errata & UART_ERRATA_FIFO_FULL_ABORT) {


Thanks,
Vaibhav

> 
>  	/* Enable the MDR1 errata for OMAP3 */
> -	if (cpu_is_omap34xx() && !cpu_is_ti816x())
> +	if (cpu_is_omap34xx() && !(cpu_is_ti816x() || cpu_is_am33xx()))
>  		uart->errata |= UART_ERRATA_i202_MDR1_ACCESS;
>  }
> 
> diff --git a/arch/arm/plat-omap/include/plat/am33xx.h b/arch/arm/plat-
> omap/include/plat/am33xx.h
> new file mode 100644
> index 0000000..06c19bb
> --- /dev/null
> +++ b/arch/arm/plat-omap/include/plat/am33xx.h
> @@ -0,0 +1,25 @@
> +/*
> + * This file contains the address info for various AM33XX modules.
> + *
> + * Copyright (C) 2011 Texas Instruments, Inc. - http://www.ti.com/
> + *
> + * 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.
> + */
> +
> +#ifndef __ASM_ARCH_AM33XX_H
> +#define __ASM_ARCH_AM33XX_H
> +
> +#define L4_SLOW_AM33XX_BASE	0x48000000
> +
> +#define AM33XX_SCM_BASE		0x44E10000
> +#define AM33XX_CTRL_BASE	AM33XX_SCM_BASE
> +#define AM33XX_PRCM_BASE	0x44E00000
> +
> +#endif /* __ASM_ARCH_AM33XX_H */
> diff --git a/arch/arm/plat-omap/include/plat/common.h b/arch/arm/plat-
> omap/include/plat/common.h
> index 4564cc6..6827e34 100644
> --- a/arch/arm/plat-omap/include/plat/common.h
> +++ b/arch/arm/plat-omap/include/plat/common.h
> @@ -67,6 +67,7 @@ void omap2_set_globals_243x(void);
>  void omap2_set_globals_3xxx(void);
>  void omap2_set_globals_443x(void);
>  void omap2_set_globals_ti816x(void);
> +void omap2_set_globals_am33xx(void);
> 
>  /* These get called from omap2_set_globals_xxxx(), do not call these */
>  void omap2_set_globals_tap(struct omap_globals *);
> diff --git a/arch/arm/plat-omap/include/plat/hardware.h b/arch/arm/plat-
> omap/include/plat/hardware.h
> index e87efe1..e6521e1 100644
> --- a/arch/arm/plat-omap/include/plat/hardware.h
> +++ b/arch/arm/plat-omap/include/plat/hardware.h
> @@ -287,5 +287,6 @@
>  #include <plat/omap34xx.h>
>  #include <plat/omap44xx.h>
>  #include <plat/ti816x.h>
> +#include <plat/am33xx.h>
> 
>  #endif	/* __ASM_ARCH_OMAP_HARDWARE_H */
> diff --git a/arch/arm/plat-omap/include/plat/io.h b/arch/arm/plat-
> omap/include/plat/io.h
> index d72ec85..0c54a00 100644
> --- a/arch/arm/plat-omap/include/plat/io.h
> +++ b/arch/arm/plat-omap/include/plat/io.h
> @@ -73,6 +73,9 @@
>  #define OMAP4_L3_IO_OFFSET	0xb4000000
>  #define OMAP4_L3_IO_ADDRESS(pa)	IOMEM((pa) + OMAP4_L3_IO_OFFSET) /* L3
> */
> 
> +#define AM33XX_L4_WK_IO_OFFSET	0xb5000000
> +#define AM33XX_L4_WK_IO_ADDRESS(pa)	IOMEM((pa) +
> AM33XX_L4_WK_IO_OFFSET)
> +
>  #define OMAP4_L3_PER_IO_OFFSET	0xb1100000
>  #define OMAP4_L3_PER_IO_ADDRESS(pa)	IOMEM((pa) +
> OMAP4_L3_PER_IO_OFFSET)
> 
> @@ -154,6 +157,15 @@
>  #define L4_34XX_SIZE		SZ_4M   /* 1MB of 128MB used, want 1MB sect
> */
> 
>  /*
> + * ----------------------------------------------------------------------
> ------
> + * AM33XX specific IO mapping
> + * ----------------------------------------------------------------------
> ------
> + */
> +#define L4_WK_AM33XX_PHYS		L4_WK_AM33XX_BASE
> +#define L4_WK_AM33XX_VIRT		(L4_WK_AM33XX_PHYS +
> AM33XX_L4_WK_IO_OFFSET)
> +#define L4_WK_AM33XX_SIZE		SZ_4M   /* 1MB of 128MB used, want 1MB
> sect */
> +
> +/*
>   * Need to look at the Size 4M for L4.
>   * VPOM3430 was not working for Int controller
>   */
> @@ -291,6 +303,14 @@ static inline void omapti816x_map_common_io(void)
>  }
>  #endif
> 
> +#ifdef CONFIG_SOC_OMAPAM33XX
> +extern void omapam33xx_map_common_io(void);
> +#else
> +static inline void omapam33xx_map_common_io(void)
> +{
> +}
> +#endif
> +
>  #ifdef CONFIG_ARCH_OMAP4
>  extern void omap44xx_map_common_io(void);
>  #else
> diff --git a/arch/arm/plat-omap/include/plat/omap34xx.h b/arch/arm/plat-
> omap/include/plat/omap34xx.h
> index b9e8588..0d818ac 100644
> --- a/arch/arm/plat-omap/include/plat/omap34xx.h
> +++ b/arch/arm/plat-omap/include/plat/omap34xx.h
> @@ -35,6 +35,8 @@
>  #define L4_EMU_34XX_BASE	0x54000000
>  #define L3_34XX_BASE		0x68000000
> 
> +#define L4_WK_AM33XX_BASE	0x44C00000
> +
>  #define OMAP3430_32KSYNCT_BASE	0x48320000
>  #define OMAP3430_CM_BASE	0x48004800
>  #define OMAP3430_PRM_BASE	0x48306800
> diff --git a/arch/arm/plat-omap/io.c b/arch/arm/plat-omap/io.c
> index f1ecfa9..25a32b2 100644
> --- a/arch/arm/plat-omap/io.c
> +++ b/arch/arm/plat-omap/io.c
> @@ -88,6 +88,11 @@ void __iomem *omap_ioremap(unsigned long p, size_t size,
> unsigned int type)
>  	if (cpu_is_ti816x()) {
>  		if (BETWEEN(p, L4_34XX_PHYS, L4_34XX_SIZE))
>  			return XLATE(p, L4_34XX_PHYS, L4_34XX_VIRT);
> +	} else if (cpu_is_am33xx()) {
> +		if (BETWEEN(p, L4_34XX_PHYS, L4_34XX_SIZE))
> +			return XLATE(p, L4_34XX_PHYS, L4_34XX_VIRT);
> +		if (BETWEEN(p, L4_WK_AM33XX_PHYS, L4_WK_AM33XX_SIZE))
> +			return XLATE(p, L4_WK_AM33XX_PHYS, L4_WK_AM33XX_VIRT);
>  	} else if (cpu_is_omap34xx()) {
>  		if (BETWEEN(p, L3_34XX_PHYS, L3_34XX_SIZE))
>  			return XLATE(p, L3_34XX_PHYS, L3_34XX_VIRT);
> --
> 1.7.0.4

^ permalink raw reply	[flat|nested] 263+ messages in thread

* RE: [PATCH-V3 2/4] arm:omap:am33xx: Update common OMAP machine specific sources
  2011-11-05  9:41   ` Hiremath, Vaibhav
@ 2011-11-05 10:29     ` Hiremath, Vaibhav
  -1 siblings, 0 replies; 263+ messages in thread
From: Hiremath, Vaibhav @ 2011-11-05 10:29 UTC (permalink / raw)
  To: Hiremath, Vaibhav, linux-omap
  Cc: Hilman, Kevin, paul, tony, linux-arm-kernel, Mohammed, Afzal


> -----Original Message-----
> From: Hiremath, Vaibhav
> Sent: Saturday, November 05, 2011 3:11 PM
> To: Hiremath, Vaibhav; linux-omap@vger.kernel.org
> Cc: Hilman, Kevin; paul@pwsan.com; tony@atomide.com; linux-arm-
> kernel@lists.infradead.org; Mohammed, Afzal
> Subject: RE: [PATCH-V3 2/4] arm:omap:am33xx: Update common OMAP machine
> specific sources
> 
> > -----Original Message-----
> > From: Hiremath, Vaibhav
> > Sent: Tuesday, September 20, 2011 8:02 PM
> > To: linux-omap@vger.kernel.org
> > Cc: Hilman, Kevin; paul@pwsan.com; tony@atomide.com; linux-arm-
> > kernel@lists.infradead.org; Mohammed, Afzal; Hiremath, Vaibhav
> > Subject: [PATCH-V3 2/4] arm:omap:am33xx: Update common OMAP machine
> > specific sources
> >
> > From: Afzal Mohammed <afzal@ti.com>
> >
> > This patch updates the common machine specific source files for
> > support for AM33XX/AM335x with cpu type, macros for identification of
> > AM33XX/AM335X device.
> >
> > Signed-off-by: Afzal Mohammed <afzal@ti.com>
> > Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
> > ---
> >  arch/arm/mach-omap2/clock3xxx_data.c       |    6 +++++-
> >  arch/arm/mach-omap2/common.c               |   16 ++++++++++++++++
> >  arch/arm/mach-omap2/id.c                   |   10 ++++++++--
> >  arch/arm/mach-omap2/io.c                   |   25
> > +++++++++++++++++++++++++
> >  arch/arm/mach-omap2/serial.c               |    6 +++---
> >  arch/arm/plat-omap/include/plat/am33xx.h   |   25
> > +++++++++++++++++++++++++
> >  arch/arm/plat-omap/include/plat/common.h   |    1 +
> >  arch/arm/plat-omap/include/plat/hardware.h |    1 +
> >  arch/arm/plat-omap/include/plat/io.h       |   20 ++++++++++++++++++++
> >  arch/arm/plat-omap/include/plat/omap34xx.h |    2 ++
> >  arch/arm/plat-omap/io.c                    |    5 +++++
> >  11 files changed, 111 insertions(+), 6 deletions(-)
> >  create mode 100644 arch/arm/plat-omap/include/plat/am33xx.h
> >
<snip>
> > diff --git a/arch/arm/mach-omap2/serial.c b/arch/arm/mach-omap2/serial.c
> > index 466fc72..b7782ee 100644
> > --- a/arch/arm/mach-omap2/serial.c
> > +++ b/arch/arm/mach-omap2/serial.c
> > @@ -486,7 +486,7 @@ static void omap_uart_idle_init(struct
> omap_uart_state
> > *uart)
> >  		mod_timer(&uart->timer, jiffies + uart->timeout);
> >  	omap_uart_smart_idle_enable(uart, 0);
> >
> > -	if (cpu_is_omap34xx() && !cpu_is_ti816x()) {
> > +	if (cpu_is_omap34xx() && !(cpu_is_ti816x() || cpu_is_am33xx())) {
> >  		u32 mod = (uart->num > 1) ? OMAP3430_PER_MOD : CORE_MOD;
> >  		u32 wk_mask = 0;
> >  		u32 padconf = 0;
> > @@ -768,7 +768,7 @@ void __init omap_serial_init_port(struct
> > omap_board_data *bdata)
> >  	 */
> >  	uart->regshift = p->regshift;
> >  	uart->membase = p->membase;
> > -	if (cpu_is_omap44xx() || cpu_is_ti816x())
> > +	if (cpu_is_omap44xx() || cpu_is_ti816x() || cpu_is_am33xx())
> >  		uart->errata |= UART_ERRATA_FIFO_FULL_ABORT;
> >  	else if ((serial_read_reg(uart, UART_OMAP_MVER) & 0xFF)
> >  			>= UART_OMAP_NO_EMPTY_FIFO_READ_IP_REV)
> > @@ -851,7 +851,7 @@ void __init omap_serial_init_port(struct
> > omap_board_data *bdata)
> >  	}
> 
> Can I get rid of this if condition as well here with below change -
> 
> -        * omap44xx, ti816x: Never read empty UART fifo
> +        * all >omap3 family of devices: Never read empty UART fifo
>          * omap3xxx: Never read empty UART fifo on UARTs
>          * with IP rev >=0x52
>          */
>         uart->regshift = p->regshift;
>         uart->membase = p->membase;
> -       if (cpu_is_omap44xx() || cpu_is_ti816x() || cpu_is_am33xx())
> -               uart->errata |= UART_ERRATA_FIFO_FULL_ABORT;
> -       else if ((serial_read_reg(uart, UART_OMAP_MVER) & 0xFF)
> -                       >= UART_OMAP_NO_EMPTY_FIFO_READ_IP_REV)
> +
> +       if ((serial_read_reg(uart, UART_OMAP_MVER) & 0xFF)
> +                       < UART_OMAP_NO_EMPTY_FIFO_READ_IP_REV)
> +               uart->errata &= ~UART_ERRATA_FIFO_FULL_ABORT;
> +       else
>                 uart->errata |= UART_ERRATA_FIFO_FULL_ABORT;
> 
>         if (uart->errata & UART_ERRATA_FIFO_FULL_ABORT) {
> 

Hit send button bit early, realized that, on all other devices (like AM33xx) the rev id is not incremental order, it has been reseted again, sp right condition here would be - 

-       if (cpu_is_omap44xx() || cpu_is_ti816x() || cpu_is_am33xx())
-               uart->errata |= UART_ERRATA_FIFO_FULL_ABORT;
-       else if ((serial_read_reg(uart, UART_OMAP_MVER) & 0xFF)
-                       >= UART_OMAP_NO_EMPTY_FIFO_READ_IP_REV)
+
+       if (cpu_is_omap34xx() && (serial_read_reg(uart, UART_OMAP_MVER) & 0xFF)
+                       < UART_OMAP_NO_EMPTY_FIFO_READ_IP_REV)
+               uart->errata &= ~UART_ERRATA_FIFO_FULL_ABORT;
+       else
                 uart->errata |= UART_ERRATA_FIFO_FULL_ABORT;

Thanks,
Vaibhav

> 
> Thanks,
> Vaibhav


^ permalink raw reply	[flat|nested] 263+ messages in thread

* [PATCH-V3 2/4] arm:omap:am33xx: Update common OMAP machine specific sources
@ 2011-11-05 10:29     ` Hiremath, Vaibhav
  0 siblings, 0 replies; 263+ messages in thread
From: Hiremath, Vaibhav @ 2011-11-05 10:29 UTC (permalink / raw)
  To: linux-arm-kernel


> -----Original Message-----
> From: Hiremath, Vaibhav
> Sent: Saturday, November 05, 2011 3:11 PM
> To: Hiremath, Vaibhav; linux-omap at vger.kernel.org
> Cc: Hilman, Kevin; paul at pwsan.com; tony at atomide.com; linux-arm-
> kernel at lists.infradead.org; Mohammed, Afzal
> Subject: RE: [PATCH-V3 2/4] arm:omap:am33xx: Update common OMAP machine
> specific sources
> 
> > -----Original Message-----
> > From: Hiremath, Vaibhav
> > Sent: Tuesday, September 20, 2011 8:02 PM
> > To: linux-omap at vger.kernel.org
> > Cc: Hilman, Kevin; paul at pwsan.com; tony at atomide.com; linux-arm-
> > kernel at lists.infradead.org; Mohammed, Afzal; Hiremath, Vaibhav
> > Subject: [PATCH-V3 2/4] arm:omap:am33xx: Update common OMAP machine
> > specific sources
> >
> > From: Afzal Mohammed <afzal@ti.com>
> >
> > This patch updates the common machine specific source files for
> > support for AM33XX/AM335x with cpu type, macros for identification of
> > AM33XX/AM335X device.
> >
> > Signed-off-by: Afzal Mohammed <afzal@ti.com>
> > Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
> > ---
> >  arch/arm/mach-omap2/clock3xxx_data.c       |    6 +++++-
> >  arch/arm/mach-omap2/common.c               |   16 ++++++++++++++++
> >  arch/arm/mach-omap2/id.c                   |   10 ++++++++--
> >  arch/arm/mach-omap2/io.c                   |   25
> > +++++++++++++++++++++++++
> >  arch/arm/mach-omap2/serial.c               |    6 +++---
> >  arch/arm/plat-omap/include/plat/am33xx.h   |   25
> > +++++++++++++++++++++++++
> >  arch/arm/plat-omap/include/plat/common.h   |    1 +
> >  arch/arm/plat-omap/include/plat/hardware.h |    1 +
> >  arch/arm/plat-omap/include/plat/io.h       |   20 ++++++++++++++++++++
> >  arch/arm/plat-omap/include/plat/omap34xx.h |    2 ++
> >  arch/arm/plat-omap/io.c                    |    5 +++++
> >  11 files changed, 111 insertions(+), 6 deletions(-)
> >  create mode 100644 arch/arm/plat-omap/include/plat/am33xx.h
> >
<snip>
> > diff --git a/arch/arm/mach-omap2/serial.c b/arch/arm/mach-omap2/serial.c
> > index 466fc72..b7782ee 100644
> > --- a/arch/arm/mach-omap2/serial.c
> > +++ b/arch/arm/mach-omap2/serial.c
> > @@ -486,7 +486,7 @@ static void omap_uart_idle_init(struct
> omap_uart_state
> > *uart)
> >  		mod_timer(&uart->timer, jiffies + uart->timeout);
> >  	omap_uart_smart_idle_enable(uart, 0);
> >
> > -	if (cpu_is_omap34xx() && !cpu_is_ti816x()) {
> > +	if (cpu_is_omap34xx() && !(cpu_is_ti816x() || cpu_is_am33xx())) {
> >  		u32 mod = (uart->num > 1) ? OMAP3430_PER_MOD : CORE_MOD;
> >  		u32 wk_mask = 0;
> >  		u32 padconf = 0;
> > @@ -768,7 +768,7 @@ void __init omap_serial_init_port(struct
> > omap_board_data *bdata)
> >  	 */
> >  	uart->regshift = p->regshift;
> >  	uart->membase = p->membase;
> > -	if (cpu_is_omap44xx() || cpu_is_ti816x())
> > +	if (cpu_is_omap44xx() || cpu_is_ti816x() || cpu_is_am33xx())
> >  		uart->errata |= UART_ERRATA_FIFO_FULL_ABORT;
> >  	else if ((serial_read_reg(uart, UART_OMAP_MVER) & 0xFF)
> >  			>= UART_OMAP_NO_EMPTY_FIFO_READ_IP_REV)
> > @@ -851,7 +851,7 @@ void __init omap_serial_init_port(struct
> > omap_board_data *bdata)
> >  	}
> 
> Can I get rid of this if condition as well here with below change -
> 
> -        * omap44xx, ti816x: Never read empty UART fifo
> +        * all >omap3 family of devices: Never read empty UART fifo
>          * omap3xxx: Never read empty UART fifo on UARTs
>          * with IP rev >=0x52
>          */
>         uart->regshift = p->regshift;
>         uart->membase = p->membase;
> -       if (cpu_is_omap44xx() || cpu_is_ti816x() || cpu_is_am33xx())
> -               uart->errata |= UART_ERRATA_FIFO_FULL_ABORT;
> -       else if ((serial_read_reg(uart, UART_OMAP_MVER) & 0xFF)
> -                       >= UART_OMAP_NO_EMPTY_FIFO_READ_IP_REV)
> +
> +       if ((serial_read_reg(uart, UART_OMAP_MVER) & 0xFF)
> +                       < UART_OMAP_NO_EMPTY_FIFO_READ_IP_REV)
> +               uart->errata &= ~UART_ERRATA_FIFO_FULL_ABORT;
> +       else
>                 uart->errata |= UART_ERRATA_FIFO_FULL_ABORT;
> 
>         if (uart->errata & UART_ERRATA_FIFO_FULL_ABORT) {
> 

Hit send button bit early, realized that, on all other devices (like AM33xx) the rev id is not incremental order, it has been reseted again, sp right condition here would be - 

-       if (cpu_is_omap44xx() || cpu_is_ti816x() || cpu_is_am33xx())
-               uart->errata |= UART_ERRATA_FIFO_FULL_ABORT;
-       else if ((serial_read_reg(uart, UART_OMAP_MVER) & 0xFF)
-                       >= UART_OMAP_NO_EMPTY_FIFO_READ_IP_REV)
+
+       if (cpu_is_omap34xx() && (serial_read_reg(uart, UART_OMAP_MVER) & 0xFF)
+                       < UART_OMAP_NO_EMPTY_FIFO_READ_IP_REV)
+               uart->errata &= ~UART_ERRATA_FIFO_FULL_ABORT;
+       else
                 uart->errata |= UART_ERRATA_FIFO_FULL_ABORT;

Thanks,
Vaibhav

> 
> Thanks,
> Vaibhav

^ permalink raw reply	[flat|nested] 263+ messages in thread

* RE: [PATCH-V3 4/4] arm:omap:am33xx: Add low level debugging support
  2011-10-06 23:09   ` Tony Lindgren
@ 2011-11-07 15:17     ` Hiremath, Vaibhav
  -1 siblings, 0 replies; 263+ messages in thread
From: Hiremath, Vaibhav @ 2011-11-07 15:17 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: linux-omap, Hilman, Kevin, paul, linux-arm-kernel, Mohammed, Afzal

> -----Original Message-----
> From: Tony Lindgren [mailto:tony@atomide.com]
> Sent: Friday, October 07, 2011 4:39 AM
> To: Hiremath, Vaibhav
> Cc: linux-omap@vger.kernel.org; Hilman, Kevin; paul@pwsan.com; linux-arm-
> kernel@lists.infradead.org; Mohammed, Afzal
> Subject: Re: [PATCH-V3 4/4] arm:omap:am33xx: Add low level debugging
> support
> 
> * hvaibhav@ti.com <hvaibhav@ti.com> [110920 06:59]:
> > From: Afzal Mohammed <afzal@ti.com>
> >
> > Add support for low level debugging on AM335X EVM (AM33XX family).
> > Currently only support for UART1 console, which is used on AM335X EVM
> > is added.
> 
> Let's wait a bit on this one as there are other DEBUG_LL patches
> pending from Nico.
> 
Tony,

Is there any branch or repo against which I can rebase my patches?

Thanks,
Vaibhav
> Regards,
> 
> Tony

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [PATCH-V3 4/4] arm:omap:am33xx: Add low level debugging support
@ 2011-11-07 15:17     ` Hiremath, Vaibhav
  0 siblings, 0 replies; 263+ messages in thread
From: Hiremath, Vaibhav @ 2011-11-07 15:17 UTC (permalink / raw)
  To: linux-arm-kernel

> -----Original Message-----
> From: Tony Lindgren [mailto:tony at atomide.com]
> Sent: Friday, October 07, 2011 4:39 AM
> To: Hiremath, Vaibhav
> Cc: linux-omap at vger.kernel.org; Hilman, Kevin; paul at pwsan.com; linux-arm-
> kernel at lists.infradead.org; Mohammed, Afzal
> Subject: Re: [PATCH-V3 4/4] arm:omap:am33xx: Add low level debugging
> support
> 
> * hvaibhav at ti.com <hvaibhav@ti.com> [110920 06:59]:
> > From: Afzal Mohammed <afzal@ti.com>
> >
> > Add support for low level debugging on AM335X EVM (AM33XX family).
> > Currently only support for UART1 console, which is used on AM335X EVM
> > is added.
> 
> Let's wait a bit on this one as there are other DEBUG_LL patches
> pending from Nico.
> 
Tony,

Is there any branch or repo against which I can rebase my patches?

Thanks,
Vaibhav
> Regards,
> 
> Tony

^ permalink raw reply	[flat|nested] 263+ messages in thread

* Re: [PATCH-V3 4/4] arm:omap:am33xx: Add low level debugging support
  2011-11-07 15:17     ` Hiremath, Vaibhav
@ 2011-11-07 18:16       ` Tony Lindgren
  -1 siblings, 0 replies; 263+ messages in thread
From: Tony Lindgren @ 2011-11-07 18:16 UTC (permalink / raw)
  To: Hiremath, Vaibhav
  Cc: linux-omap, Hilman, Kevin, paul, linux-arm-kernel, Mohammed, Afzal

* Hiremath, Vaibhav <hvaibhav@ti.com> [111107 06:42]:
> > -----Original Message-----
> > From: Tony Lindgren [mailto:tony@atomide.com]
> > Sent: Friday, October 07, 2011 4:39 AM
> > To: Hiremath, Vaibhav
> > Cc: linux-omap@vger.kernel.org; Hilman, Kevin; paul@pwsan.com; linux-arm-
> > kernel@lists.infradead.org; Mohammed, Afzal
> > Subject: Re: [PATCH-V3 4/4] arm:omap:am33xx: Add low level debugging
> > support
> > 
> > * hvaibhav@ti.com <hvaibhav@ti.com> [110920 06:59]:
> > > From: Afzal Mohammed <afzal@ti.com>
> > >
> > > Add support for low level debugging on AM335X EVM (AM33XX family).
> > > Currently only support for UART1 console, which is used on AM335X EVM
> > > is added.
> > 
> > Let's wait a bit on this one as there are other DEBUG_LL patches
> > pending from Nico.
> > 
> Tony,
> 
> Is there any branch or repo against which I can rebase my patches?

I recommend the current fixes branch.

Tony

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [PATCH-V3 4/4] arm:omap:am33xx: Add low level debugging support
@ 2011-11-07 18:16       ` Tony Lindgren
  0 siblings, 0 replies; 263+ messages in thread
From: Tony Lindgren @ 2011-11-07 18:16 UTC (permalink / raw)
  To: linux-arm-kernel

* Hiremath, Vaibhav <hvaibhav@ti.com> [111107 06:42]:
> > -----Original Message-----
> > From: Tony Lindgren [mailto:tony at atomide.com]
> > Sent: Friday, October 07, 2011 4:39 AM
> > To: Hiremath, Vaibhav
> > Cc: linux-omap at vger.kernel.org; Hilman, Kevin; paul at pwsan.com; linux-arm-
> > kernel at lists.infradead.org; Mohammed, Afzal
> > Subject: Re: [PATCH-V3 4/4] arm:omap:am33xx: Add low level debugging
> > support
> > 
> > * hvaibhav at ti.com <hvaibhav@ti.com> [110920 06:59]:
> > > From: Afzal Mohammed <afzal@ti.com>
> > >
> > > Add support for low level debugging on AM335X EVM (AM33XX family).
> > > Currently only support for UART1 console, which is used on AM335X EVM
> > > is added.
> > 
> > Let's wait a bit on this one as there are other DEBUG_LL patches
> > pending from Nico.
> > 
> Tony,
> 
> Is there any branch or repo against which I can rebase my patches?

I recommend the current fixes branch.

Tony

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [PATCH-V5 0/3] Introducing TI's New SoC/board AM335XEVM
@ 2011-12-02  6:43 ` hvaibhav at ti.com
  0 siblings, 0 replies; 263+ messages in thread
From: hvaibhav @ 2011-12-02  6:43 UTC (permalink / raw)
  To: linux-omap; +Cc: tony, khilman, linux-arm-kernel, paul, Vaibhav Hiremath

From: Vaibhav Hiremath <hvaibhav@ti.com>

This patch set adds support for AM335x device having
Cortex-A8 MPU.

Official website - http://www.ti.com/product/am3359

AM335X is treated as another OMAP3 variant, where,
along with existing cpu class OMAP34XX, new cpu class AM33XX is created
and the respective type is AM335X, which is newly added device in
the family.
This means, cpu_is_omap34xx(), cpu_is_am33xx() and
cpu_is_am335x() checks return success for AM335X.

Also, I have validated OMAP3 boot test with this patch-series on
OMAP3EVM.

Changes from V4:
	- Patches have been reviewed by Kevin Hilman.
	- As per Kevin Hilman's comments updated comment in debug-macro.S,
	  for AM33XX.

Changes from V3:
	- Common platform patch has already been accepted and available
	  under linux-omap/soc and linux-omap/master branch.
  	- Clean-up where cpu_is_xxxx instances are being used and patches
	  has been submitted to the list.
  	- These patches have been created on top of cleanup patches -
	    http://www.mail-archive.com/linux-omap@vger.kernel.org/msg58276.html
	    http://www.mail-archive.com/linux-omap@vger.kernel.org/msg58277.html
	- Based on Tony's request, rebased patches against linux-omap/fixes
	  (+ common platform patch).

Changes from V2(RFC):
	- Rebased against Paul's OMAP_CHIP* cleanup patches
	    git://git.pwsan.com/linux-2.6_omap_chip_remove_cleanup_3.2

Changes from V1(RFC):
	- Created separate cpu/SoC class for AM33XX family of devices,
	  due to all known facts. This is been mentioned in main-chain
	    https://patchwork.kernel.org/patch/1056312/
	- BUG Fix in debug-macro.S, which was leading to build failure.
	    https://patchwork.kernel.org/patch/1056302/

Afzal Mohammed (3):
  arm:omap:am33xx: Update common OMAP machine specific sources
  arm:omap:am33xx: Add AM335XEVM machine support
  arm:omap:am33xx: Add low level debugging support

 arch/arm/mach-omap2/Kconfig                    |    5 ++++
 arch/arm/mach-omap2/Makefile                   |    1 +
 arch/arm/mach-omap2/board-am3517evm.c          |   21 ++++++++++++++++
 arch/arm/mach-omap2/clock3xxx_data.c           |    3 ++
 arch/arm/mach-omap2/common.c                   |   21 ++++++++++++++++
 arch/arm/mach-omap2/id.c                       |    6 ++++
 arch/arm/mach-omap2/include/mach/debug-macro.S |   17 ++++++++++++-
 arch/arm/mach-omap2/io.c                       |   31 ++++++++++++++++++++++++
 arch/arm/mach-omap2/serial.c                   |    4 +-
 arch/arm/mach-omap2/timer.c                    |    2 +
 arch/arm/plat-omap/include/plat/am33xx.h       |   25 +++++++++++++++++++
 arch/arm/plat-omap/include/plat/common.h       |    4 +++
 arch/arm/plat-omap/include/plat/hardware.h     |    1 +
 arch/arm/plat-omap/include/plat/io.h           |   20 +++++++++++++++
 arch/arm/plat-omap/include/plat/omap34xx.h     |    2 +
 arch/arm/plat-omap/include/plat/serial.h       |    4 +++
 arch/arm/plat-omap/include/plat/uncompress.h   |    6 ++++
 arch/arm/plat-omap/io.c                        |    5 ++++
 18 files changed, 175 insertions(+), 3 deletions(-)
 create mode 100644 arch/arm/plat-omap/include/plat/am33xx.h


^ permalink raw reply	[flat|nested] 263+ messages in thread

* [PATCH-V5 0/3] Introducing TI's New SoC/board AM335XEVM
@ 2011-12-02  6:43 ` hvaibhav at ti.com
  0 siblings, 0 replies; 263+ messages in thread
From: hvaibhav at ti.com @ 2011-12-02  6:43 UTC (permalink / raw)
  To: linux-arm-kernel

From: Vaibhav Hiremath <hvaibhav@ti.com>

This patch set adds support for AM335x device having
Cortex-A8 MPU.

Official website - http://www.ti.com/product/am3359

AM335X is treated as another OMAP3 variant, where,
along with existing cpu class OMAP34XX, new cpu class AM33XX is created
and the respective type is AM335X, which is newly added device in
the family.
This means, cpu_is_omap34xx(), cpu_is_am33xx() and
cpu_is_am335x() checks return success for AM335X.

Also, I have validated OMAP3 boot test with this patch-series on
OMAP3EVM.

Changes from V4:
	- Patches have been reviewed by Kevin Hilman.
	- As per Kevin Hilman's comments updated comment in debug-macro.S,
	  for AM33XX.

Changes from V3:
	- Common platform patch has already been accepted and available
	  under linux-omap/soc and linux-omap/master branch.
  	- Clean-up where cpu_is_xxxx instances are being used and patches
	  has been submitted to the list.
  	- These patches have been created on top of cleanup patches -
	    http://www.mail-archive.com/linux-omap at vger.kernel.org/msg58276.html
	    http://www.mail-archive.com/linux-omap at vger.kernel.org/msg58277.html
	- Based on Tony's request, rebased patches against linux-omap/fixes
	  (+ common platform patch).

Changes from V2(RFC):
	- Rebased against Paul's OMAP_CHIP* cleanup patches
	    git://git.pwsan.com/linux-2.6_omap_chip_remove_cleanup_3.2

Changes from V1(RFC):
	- Created separate cpu/SoC class for AM33XX family of devices,
	  due to all known facts. This is been mentioned in main-chain
	    https://patchwork.kernel.org/patch/1056312/
	- BUG Fix in debug-macro.S, which was leading to build failure.
	    https://patchwork.kernel.org/patch/1056302/

Afzal Mohammed (3):
  arm:omap:am33xx: Update common OMAP machine specific sources
  arm:omap:am33xx: Add AM335XEVM machine support
  arm:omap:am33xx: Add low level debugging support

 arch/arm/mach-omap2/Kconfig                    |    5 ++++
 arch/arm/mach-omap2/Makefile                   |    1 +
 arch/arm/mach-omap2/board-am3517evm.c          |   21 ++++++++++++++++
 arch/arm/mach-omap2/clock3xxx_data.c           |    3 ++
 arch/arm/mach-omap2/common.c                   |   21 ++++++++++++++++
 arch/arm/mach-omap2/id.c                       |    6 ++++
 arch/arm/mach-omap2/include/mach/debug-macro.S |   17 ++++++++++++-
 arch/arm/mach-omap2/io.c                       |   31 ++++++++++++++++++++++++
 arch/arm/mach-omap2/serial.c                   |    4 +-
 arch/arm/mach-omap2/timer.c                    |    2 +
 arch/arm/plat-omap/include/plat/am33xx.h       |   25 +++++++++++++++++++
 arch/arm/plat-omap/include/plat/common.h       |    4 +++
 arch/arm/plat-omap/include/plat/hardware.h     |    1 +
 arch/arm/plat-omap/include/plat/io.h           |   20 +++++++++++++++
 arch/arm/plat-omap/include/plat/omap34xx.h     |    2 +
 arch/arm/plat-omap/include/plat/serial.h       |    4 +++
 arch/arm/plat-omap/include/plat/uncompress.h   |    6 ++++
 arch/arm/plat-omap/io.c                        |    5 ++++
 18 files changed, 175 insertions(+), 3 deletions(-)
 create mode 100644 arch/arm/plat-omap/include/plat/am33xx.h

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [PATCH-V5 1/3] arm:omap:am33xx: Update common OMAP machine specific sources
@ 2011-12-02  6:43 ` hvaibhav at ti.com
  0 siblings, 0 replies; 263+ messages in thread
From: hvaibhav @ 2011-12-02  6:43 UTC (permalink / raw)
  To: linux-omap
  Cc: tony, khilman, linux-arm-kernel, paul, Afzal Mohammed, Vaibhav Hiremath

From: Afzal Mohammed <afzal@ti.com>

This patch updates the common machine specific source files for
support for AM33XX/AM335x with cpu type, macros for identification of
AM33XX/AM335X device.

Signed-off-by: Afzal Mohammed <afzal@ti.com>
Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
Reviewed-by: Kevin Hilman <khilman@ti.com>
---
 arch/arm/mach-omap2/clock3xxx_data.c       |    3 +++
 arch/arm/mach-omap2/common.c               |   21 +++++++++++++++++++++
 arch/arm/mach-omap2/id.c                   |    6 ++++++
 arch/arm/mach-omap2/io.c                   |   24 ++++++++++++++++++++++++
 arch/arm/mach-omap2/serial.c               |    4 ++--
 arch/arm/plat-omap/include/plat/am33xx.h   |   25 +++++++++++++++++++++++++
 arch/arm/plat-omap/include/plat/common.h   |    2 ++
 arch/arm/plat-omap/include/plat/hardware.h |    1 +
 arch/arm/plat-omap/include/plat/io.h       |   20 ++++++++++++++++++++
 arch/arm/plat-omap/include/plat/omap34xx.h |    2 ++
 arch/arm/plat-omap/io.c                    |    5 +++++
 11 files changed, 111 insertions(+), 2 deletions(-)
 create mode 100644 arch/arm/plat-omap/include/plat/am33xx.h

diff --git a/arch/arm/mach-omap2/clock3xxx_data.c b/arch/arm/mach-omap2/clock3xxx_data.c
index 5d0064a..c1ab6bc 100644
--- a/arch/arm/mach-omap2/clock3xxx_data.c
+++ b/arch/arm/mach-omap2/clock3xxx_data.c
@@ -3517,6 +3517,9 @@ int __init omap3xxx_clk_init(void)
 	} else if (cpu_is_ti816x()) {
 		cpu_mask = RATE_IN_TI816X;
 		cpu_clkflg = CK_TI816X;
+	} else if (cpu_is_am33xx()) {
+		cpu_mask = RATE_IN_AM33XX;
+		cpu_clkflg = CK_AM33XX;
 	} else if (cpu_is_omap34xx()) {
 		if (omap_rev() == OMAP3430_REV_ES1_0) {
 			cpu_mask = RATE_IN_3430ES1;
diff --git a/arch/arm/mach-omap2/common.c b/arch/arm/mach-omap2/common.c
index 110e5b9..16bac26 100644
--- a/arch/arm/mach-omap2/common.c
+++ b/arch/arm/mach-omap2/common.c
@@ -128,6 +128,27 @@ void __init omap2_set_globals_ti816x(void)
 {
 	__omap2_set_globals(&ti816x_globals);
 }
+
+#define AM33XX_TAP_BASE		(AM33XX_CTRL_BASE + \
+				TI816X_CONTROL_DEVICE_ID - 0x204)
+
+static struct omap_globals am33xx_globals = {
+	.class  = AM335X_CLASS,
+	.tap    = AM33XX_L4_WK_IO_ADDRESS(AM33XX_TAP_BASE),
+	.ctrl   = AM33XX_L4_WK_IO_ADDRESS(AM33XX_CTRL_BASE),
+	.prm    = AM33XX_L4_WK_IO_ADDRESS(AM33XX_PRCM_BASE),
+	.cm     = AM33XX_L4_WK_IO_ADDRESS(AM33XX_PRCM_BASE),
+};
+
+void __init omap2_set_globals_am33xx(void)
+{
+	__omap2_set_globals(&am33xx_globals);
+}
+
+void __init am33xx_map_io(void)
+{
+	omapam33xx_map_common_io();
+}
 #endif

 #if defined(CONFIG_ARCH_OMAP4)
diff --git a/arch/arm/mach-omap2/id.c b/arch/arm/mach-omap2/id.c
index f1784ee..37fe42f 100644
--- a/arch/arm/mach-omap2/id.c
+++ b/arch/arm/mach-omap2/id.c
@@ -340,6 +340,10 @@ static void __init omap3_check_revision(const char **cpu_rev)
 			break;
 		}
 		break;
+	case 0xb944:
+		omap_revision = AM335X_REV_ES1_0;
+		*cpu_rev = "1.0";
+		break;
 	default:
 		/* Unknown default to latest silicon rev as default */
 		omap_revision = OMAP3630_REV_ES1_2;
@@ -432,6 +436,8 @@ static void __init omap3_cpuinfo(const char *cpu_rev)
 		cpu_name = (omap3_has_sgx()) ? "AM3517" : "AM3505";
 	} else if (cpu_is_ti816x()) {
 		cpu_name = "TI816X";
+	} else if (cpu_is_am335x()) {
+		cpu_name =  "AM335X";
 	} else if (omap3_has_iva() && omap3_has_sgx()) {
 		/* OMAP3430, OMAP3525, OMAP3515, OMAP3503 devices */
 		cpu_name = "OMAP3430/3530";
diff --git a/arch/arm/mach-omap2/io.c b/arch/arm/mach-omap2/io.c
index da9bc4a..74e84c6 100644
--- a/arch/arm/mach-omap2/io.c
+++ b/arch/arm/mach-omap2/io.c
@@ -183,7 +183,24 @@ static struct map_desc omapti816x_io_desc[] __initdata = {
 		.pfn		= __phys_to_pfn(L4_34XX_PHYS),
 		.length		= L4_34XX_SIZE,
 		.type		= MT_DEVICE
+	}
+};
+#endif
+
+#ifdef CONFIG_SOC_OMAPAM33XX
+static struct map_desc omapam33xx_io_desc[] __initdata = {
+	{
+		.virtual	= L4_34XX_VIRT,
+		.pfn		= __phys_to_pfn(L4_34XX_PHYS),
+		.length		= L4_34XX_SIZE,
+		.type		= MT_DEVICE
 	},
+	{
+		.virtual	= L4_WK_AM33XX_VIRT,
+		.pfn		= __phys_to_pfn(L4_WK_AM33XX_PHYS),
+		.length		= L4_WK_AM33XX_SIZE,
+		.type		= MT_DEVICE
+	}
 };
 #endif

@@ -270,6 +287,13 @@ void __init omapti816x_map_common_io(void)
 }
 #endif

+#ifdef CONFIG_SOC_OMAPAM33XX
+void __init omapam33xx_map_common_io(void)
+{
+	iotable_init(omapam33xx_io_desc, ARRAY_SIZE(omapam33xx_io_desc));
+}
+#endif
+
 #ifdef CONFIG_ARCH_OMAP4
 void __init omap44xx_map_common_io(void)
 {
diff --git a/arch/arm/mach-omap2/serial.c b/arch/arm/mach-omap2/serial.c
index 0dbd5a2..03fc153 100644
--- a/arch/arm/mach-omap2/serial.c
+++ b/arch/arm/mach-omap2/serial.c
@@ -464,7 +464,7 @@ static void omap_uart_idle_init(struct omap_uart_state *uart)
 		mod_timer(&uart->timer, jiffies + uart->timeout);
 	omap_uart_smart_idle_enable(uart, 0);

-	if (cpu_is_omap34xx() && !cpu_is_ti816x()) {
+	if (cpu_is_omap34xx() && !(cpu_is_ti816x() || cpu_is_am33xx())) {
 		u32 mod = (uart->num > 1) ? OMAP3430_PER_MOD : CORE_MOD;
 		u32 wk_mask = 0;
 		u32 padconf = 0;
@@ -828,7 +828,7 @@ void __init omap_serial_init_port(struct omap_board_data *bdata)
 	}

 	/* Enable the MDR1 errata for OMAP3 */
-	if (cpu_is_omap34xx() && !cpu_is_ti816x())
+	if (cpu_is_omap34xx() && !(cpu_is_ti816x() || cpu_is_am33xx()))
 		uart->errata |= UART_ERRATA_i202_MDR1_ACCESS;
 }

diff --git a/arch/arm/plat-omap/include/plat/am33xx.h b/arch/arm/plat-omap/include/plat/am33xx.h
new file mode 100644
index 0000000..06c19bb
--- /dev/null
+++ b/arch/arm/plat-omap/include/plat/am33xx.h
@@ -0,0 +1,25 @@
+/*
+ * This file contains the address info for various AM33XX modules.
+ *
+ * Copyright (C) 2011 Texas Instruments, Inc. - http://www.ti.com/
+ *
+ * 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.
+ */
+
+#ifndef __ASM_ARCH_AM33XX_H
+#define __ASM_ARCH_AM33XX_H
+
+#define L4_SLOW_AM33XX_BASE	0x48000000
+
+#define AM33XX_SCM_BASE		0x44E10000
+#define AM33XX_CTRL_BASE	AM33XX_SCM_BASE
+#define AM33XX_PRCM_BASE	0x44E00000
+
+#endif /* __ASM_ARCH_AM33XX_H */
diff --git a/arch/arm/plat-omap/include/plat/common.h b/arch/arm/plat-omap/include/plat/common.h
index 3ff3e36..bb8a6c1 100644
--- a/arch/arm/plat-omap/include/plat/common.h
+++ b/arch/arm/plat-omap/include/plat/common.h
@@ -82,6 +82,7 @@ void omap2_set_globals_243x(void);
 void omap2_set_globals_3xxx(void);
 void omap2_set_globals_443x(void);
 void omap2_set_globals_ti816x(void);
+void omap2_set_globals_am33xx(void);

 /* These get called from omap2_set_globals_xxxx(), do not call these */
 void omap2_set_globals_tap(struct omap_globals *);
@@ -92,6 +93,7 @@ void omap2_set_globals_prcm(struct omap_globals *);
 void omap242x_map_io(void);
 void omap243x_map_io(void);
 void omap3_map_io(void);
+void am33xx_map_io(void);
 void omap4_map_io(void);


diff --git a/arch/arm/plat-omap/include/plat/hardware.h b/arch/arm/plat-omap/include/plat/hardware.h
index e87efe1..e6521e1 100644
--- a/arch/arm/plat-omap/include/plat/hardware.h
+++ b/arch/arm/plat-omap/include/plat/hardware.h
@@ -287,5 +287,6 @@
 #include <plat/omap34xx.h>
 #include <plat/omap44xx.h>
 #include <plat/ti816x.h>
+#include <plat/am33xx.h>

 #endif	/* __ASM_ARCH_OMAP_HARDWARE_H */
diff --git a/arch/arm/plat-omap/include/plat/io.h b/arch/arm/plat-omap/include/plat/io.h
index 7f2969e..ffed821 100644
--- a/arch/arm/plat-omap/include/plat/io.h
+++ b/arch/arm/plat-omap/include/plat/io.h
@@ -73,6 +73,9 @@
 #define OMAP4_L3_IO_OFFSET	0xb4000000
 #define OMAP4_L3_IO_ADDRESS(pa)	IOMEM((pa) + OMAP4_L3_IO_OFFSET) /* L3 */

+#define AM33XX_L4_WK_IO_OFFSET	0xb5000000
+#define AM33XX_L4_WK_IO_ADDRESS(pa)	IOMEM((pa) + AM33XX_L4_WK_IO_OFFSET)
+
 #define OMAP4_L3_PER_IO_OFFSET	0xb1100000
 #define OMAP4_L3_PER_IO_ADDRESS(pa)	IOMEM((pa) + OMAP4_L3_PER_IO_OFFSET)

@@ -154,6 +157,15 @@
 #define L4_34XX_SIZE		SZ_4M   /* 1MB of 128MB used, want 1MB sect */

 /*
+ * ----------------------------------------------------------------------------
+ * AM33XX specific IO mapping
+ * ----------------------------------------------------------------------------
+ */
+#define L4_WK_AM33XX_PHYS	L4_WK_AM33XX_BASE
+#define L4_WK_AM33XX_VIRT	(L4_WK_AM33XX_PHYS + AM33XX_L4_WK_IO_OFFSET)
+#define L4_WK_AM33XX_SIZE	SZ_4M   /* 1MB of 128MB used, want 1MB sect */
+
+/*
  * Need to look at the Size 4M for L4.
  * VPOM3430 was not working for Int controller
  */
@@ -316,6 +328,14 @@ static inline void omapti816x_map_common_io(void)
 }
 #endif

+#ifdef CONFIG_SOC_OMAPAM33XX
+extern void omapam33xx_map_common_io(void);
+#else
+static inline void omapam33xx_map_common_io(void)
+{
+}
+#endif
+
 #ifdef CONFIG_ARCH_OMAP4
 extern void omap44xx_map_common_io(void);
 #else
diff --git a/arch/arm/plat-omap/include/plat/omap34xx.h b/arch/arm/plat-omap/include/plat/omap34xx.h
index b9e8588..0d818ac 100644
--- a/arch/arm/plat-omap/include/plat/omap34xx.h
+++ b/arch/arm/plat-omap/include/plat/omap34xx.h
@@ -35,6 +35,8 @@
 #define L4_EMU_34XX_BASE	0x54000000
 #define L3_34XX_BASE		0x68000000

+#define L4_WK_AM33XX_BASE	0x44C00000
+
 #define OMAP3430_32KSYNCT_BASE	0x48320000
 #define OMAP3430_CM_BASE	0x48004800
 #define OMAP3430_PRM_BASE	0x48306800
diff --git a/arch/arm/plat-omap/io.c b/arch/arm/plat-omap/io.c
index 333871f..14c421a 100644
--- a/arch/arm/plat-omap/io.c
+++ b/arch/arm/plat-omap/io.c
@@ -94,6 +94,11 @@ void __iomem *omap_ioremap(unsigned long p, size_t size, unsigned int type)
 	if (cpu_is_ti816x()) {
 		if (BETWEEN(p, L4_34XX_PHYS, L4_34XX_SIZE))
 			return XLATE(p, L4_34XX_PHYS, L4_34XX_VIRT);
+	} else if (cpu_is_am33xx()) {
+		if (BETWEEN(p, L4_34XX_PHYS, L4_34XX_SIZE))
+			return XLATE(p, L4_34XX_PHYS, L4_34XX_VIRT);
+		if (BETWEEN(p, L4_WK_AM33XX_PHYS, L4_WK_AM33XX_SIZE))
+			return XLATE(p, L4_WK_AM33XX_PHYS, L4_WK_AM33XX_VIRT);
 	} else if (cpu_is_omap34xx()) {
 		if (BETWEEN(p, L3_34XX_PHYS, L3_34XX_SIZE))
 			return XLATE(p, L3_34XX_PHYS, L3_34XX_VIRT);
--
1.7.0.4


^ permalink raw reply related	[flat|nested] 263+ messages in thread

* [PATCH-V5 1/3] arm:omap:am33xx: Update common OMAP machine specific sources
@ 2011-12-02  6:43 ` hvaibhav at ti.com
  0 siblings, 0 replies; 263+ messages in thread
From: hvaibhav at ti.com @ 2011-12-02  6:43 UTC (permalink / raw)
  To: linux-arm-kernel

From: Afzal Mohammed <afzal@ti.com>

This patch updates the common machine specific source files for
support for AM33XX/AM335x with cpu type, macros for identification of
AM33XX/AM335X device.

Signed-off-by: Afzal Mohammed <afzal@ti.com>
Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
Reviewed-by: Kevin Hilman <khilman@ti.com>
---
 arch/arm/mach-omap2/clock3xxx_data.c       |    3 +++
 arch/arm/mach-omap2/common.c               |   21 +++++++++++++++++++++
 arch/arm/mach-omap2/id.c                   |    6 ++++++
 arch/arm/mach-omap2/io.c                   |   24 ++++++++++++++++++++++++
 arch/arm/mach-omap2/serial.c               |    4 ++--
 arch/arm/plat-omap/include/plat/am33xx.h   |   25 +++++++++++++++++++++++++
 arch/arm/plat-omap/include/plat/common.h   |    2 ++
 arch/arm/plat-omap/include/plat/hardware.h |    1 +
 arch/arm/plat-omap/include/plat/io.h       |   20 ++++++++++++++++++++
 arch/arm/plat-omap/include/plat/omap34xx.h |    2 ++
 arch/arm/plat-omap/io.c                    |    5 +++++
 11 files changed, 111 insertions(+), 2 deletions(-)
 create mode 100644 arch/arm/plat-omap/include/plat/am33xx.h

diff --git a/arch/arm/mach-omap2/clock3xxx_data.c b/arch/arm/mach-omap2/clock3xxx_data.c
index 5d0064a..c1ab6bc 100644
--- a/arch/arm/mach-omap2/clock3xxx_data.c
+++ b/arch/arm/mach-omap2/clock3xxx_data.c
@@ -3517,6 +3517,9 @@ int __init omap3xxx_clk_init(void)
 	} else if (cpu_is_ti816x()) {
 		cpu_mask = RATE_IN_TI816X;
 		cpu_clkflg = CK_TI816X;
+	} else if (cpu_is_am33xx()) {
+		cpu_mask = RATE_IN_AM33XX;
+		cpu_clkflg = CK_AM33XX;
 	} else if (cpu_is_omap34xx()) {
 		if (omap_rev() == OMAP3430_REV_ES1_0) {
 			cpu_mask = RATE_IN_3430ES1;
diff --git a/arch/arm/mach-omap2/common.c b/arch/arm/mach-omap2/common.c
index 110e5b9..16bac26 100644
--- a/arch/arm/mach-omap2/common.c
+++ b/arch/arm/mach-omap2/common.c
@@ -128,6 +128,27 @@ void __init omap2_set_globals_ti816x(void)
 {
 	__omap2_set_globals(&ti816x_globals);
 }
+
+#define AM33XX_TAP_BASE		(AM33XX_CTRL_BASE + \
+				TI816X_CONTROL_DEVICE_ID - 0x204)
+
+static struct omap_globals am33xx_globals = {
+	.class  = AM335X_CLASS,
+	.tap    = AM33XX_L4_WK_IO_ADDRESS(AM33XX_TAP_BASE),
+	.ctrl   = AM33XX_L4_WK_IO_ADDRESS(AM33XX_CTRL_BASE),
+	.prm    = AM33XX_L4_WK_IO_ADDRESS(AM33XX_PRCM_BASE),
+	.cm     = AM33XX_L4_WK_IO_ADDRESS(AM33XX_PRCM_BASE),
+};
+
+void __init omap2_set_globals_am33xx(void)
+{
+	__omap2_set_globals(&am33xx_globals);
+}
+
+void __init am33xx_map_io(void)
+{
+	omapam33xx_map_common_io();
+}
 #endif

 #if defined(CONFIG_ARCH_OMAP4)
diff --git a/arch/arm/mach-omap2/id.c b/arch/arm/mach-omap2/id.c
index f1784ee..37fe42f 100644
--- a/arch/arm/mach-omap2/id.c
+++ b/arch/arm/mach-omap2/id.c
@@ -340,6 +340,10 @@ static void __init omap3_check_revision(const char **cpu_rev)
 			break;
 		}
 		break;
+	case 0xb944:
+		omap_revision = AM335X_REV_ES1_0;
+		*cpu_rev = "1.0";
+		break;
 	default:
 		/* Unknown default to latest silicon rev as default */
 		omap_revision = OMAP3630_REV_ES1_2;
@@ -432,6 +436,8 @@ static void __init omap3_cpuinfo(const char *cpu_rev)
 		cpu_name = (omap3_has_sgx()) ? "AM3517" : "AM3505";
 	} else if (cpu_is_ti816x()) {
 		cpu_name = "TI816X";
+	} else if (cpu_is_am335x()) {
+		cpu_name =  "AM335X";
 	} else if (omap3_has_iva() && omap3_has_sgx()) {
 		/* OMAP3430, OMAP3525, OMAP3515, OMAP3503 devices */
 		cpu_name = "OMAP3430/3530";
diff --git a/arch/arm/mach-omap2/io.c b/arch/arm/mach-omap2/io.c
index da9bc4a..74e84c6 100644
--- a/arch/arm/mach-omap2/io.c
+++ b/arch/arm/mach-omap2/io.c
@@ -183,7 +183,24 @@ static struct map_desc omapti816x_io_desc[] __initdata = {
 		.pfn		= __phys_to_pfn(L4_34XX_PHYS),
 		.length		= L4_34XX_SIZE,
 		.type		= MT_DEVICE
+	}
+};
+#endif
+
+#ifdef CONFIG_SOC_OMAPAM33XX
+static struct map_desc omapam33xx_io_desc[] __initdata = {
+	{
+		.virtual	= L4_34XX_VIRT,
+		.pfn		= __phys_to_pfn(L4_34XX_PHYS),
+		.length		= L4_34XX_SIZE,
+		.type		= MT_DEVICE
 	},
+	{
+		.virtual	= L4_WK_AM33XX_VIRT,
+		.pfn		= __phys_to_pfn(L4_WK_AM33XX_PHYS),
+		.length		= L4_WK_AM33XX_SIZE,
+		.type		= MT_DEVICE
+	}
 };
 #endif

@@ -270,6 +287,13 @@ void __init omapti816x_map_common_io(void)
 }
 #endif

+#ifdef CONFIG_SOC_OMAPAM33XX
+void __init omapam33xx_map_common_io(void)
+{
+	iotable_init(omapam33xx_io_desc, ARRAY_SIZE(omapam33xx_io_desc));
+}
+#endif
+
 #ifdef CONFIG_ARCH_OMAP4
 void __init omap44xx_map_common_io(void)
 {
diff --git a/arch/arm/mach-omap2/serial.c b/arch/arm/mach-omap2/serial.c
index 0dbd5a2..03fc153 100644
--- a/arch/arm/mach-omap2/serial.c
+++ b/arch/arm/mach-omap2/serial.c
@@ -464,7 +464,7 @@ static void omap_uart_idle_init(struct omap_uart_state *uart)
 		mod_timer(&uart->timer, jiffies + uart->timeout);
 	omap_uart_smart_idle_enable(uart, 0);

-	if (cpu_is_omap34xx() && !cpu_is_ti816x()) {
+	if (cpu_is_omap34xx() && !(cpu_is_ti816x() || cpu_is_am33xx())) {
 		u32 mod = (uart->num > 1) ? OMAP3430_PER_MOD : CORE_MOD;
 		u32 wk_mask = 0;
 		u32 padconf = 0;
@@ -828,7 +828,7 @@ void __init omap_serial_init_port(struct omap_board_data *bdata)
 	}

 	/* Enable the MDR1 errata for OMAP3 */
-	if (cpu_is_omap34xx() && !cpu_is_ti816x())
+	if (cpu_is_omap34xx() && !(cpu_is_ti816x() || cpu_is_am33xx()))
 		uart->errata |= UART_ERRATA_i202_MDR1_ACCESS;
 }

diff --git a/arch/arm/plat-omap/include/plat/am33xx.h b/arch/arm/plat-omap/include/plat/am33xx.h
new file mode 100644
index 0000000..06c19bb
--- /dev/null
+++ b/arch/arm/plat-omap/include/plat/am33xx.h
@@ -0,0 +1,25 @@
+/*
+ * This file contains the address info for various AM33XX modules.
+ *
+ * Copyright (C) 2011 Texas Instruments, Inc. - http://www.ti.com/
+ *
+ * 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.
+ */
+
+#ifndef __ASM_ARCH_AM33XX_H
+#define __ASM_ARCH_AM33XX_H
+
+#define L4_SLOW_AM33XX_BASE	0x48000000
+
+#define AM33XX_SCM_BASE		0x44E10000
+#define AM33XX_CTRL_BASE	AM33XX_SCM_BASE
+#define AM33XX_PRCM_BASE	0x44E00000
+
+#endif /* __ASM_ARCH_AM33XX_H */
diff --git a/arch/arm/plat-omap/include/plat/common.h b/arch/arm/plat-omap/include/plat/common.h
index 3ff3e36..bb8a6c1 100644
--- a/arch/arm/plat-omap/include/plat/common.h
+++ b/arch/arm/plat-omap/include/plat/common.h
@@ -82,6 +82,7 @@ void omap2_set_globals_243x(void);
 void omap2_set_globals_3xxx(void);
 void omap2_set_globals_443x(void);
 void omap2_set_globals_ti816x(void);
+void omap2_set_globals_am33xx(void);

 /* These get called from omap2_set_globals_xxxx(), do not call these */
 void omap2_set_globals_tap(struct omap_globals *);
@@ -92,6 +93,7 @@ void omap2_set_globals_prcm(struct omap_globals *);
 void omap242x_map_io(void);
 void omap243x_map_io(void);
 void omap3_map_io(void);
+void am33xx_map_io(void);
 void omap4_map_io(void);


diff --git a/arch/arm/plat-omap/include/plat/hardware.h b/arch/arm/plat-omap/include/plat/hardware.h
index e87efe1..e6521e1 100644
--- a/arch/arm/plat-omap/include/plat/hardware.h
+++ b/arch/arm/plat-omap/include/plat/hardware.h
@@ -287,5 +287,6 @@
 #include <plat/omap34xx.h>
 #include <plat/omap44xx.h>
 #include <plat/ti816x.h>
+#include <plat/am33xx.h>

 #endif	/* __ASM_ARCH_OMAP_HARDWARE_H */
diff --git a/arch/arm/plat-omap/include/plat/io.h b/arch/arm/plat-omap/include/plat/io.h
index 7f2969e..ffed821 100644
--- a/arch/arm/plat-omap/include/plat/io.h
+++ b/arch/arm/plat-omap/include/plat/io.h
@@ -73,6 +73,9 @@
 #define OMAP4_L3_IO_OFFSET	0xb4000000
 #define OMAP4_L3_IO_ADDRESS(pa)	IOMEM((pa) + OMAP4_L3_IO_OFFSET) /* L3 */

+#define AM33XX_L4_WK_IO_OFFSET	0xb5000000
+#define AM33XX_L4_WK_IO_ADDRESS(pa)	IOMEM((pa) + AM33XX_L4_WK_IO_OFFSET)
+
 #define OMAP4_L3_PER_IO_OFFSET	0xb1100000
 #define OMAP4_L3_PER_IO_ADDRESS(pa)	IOMEM((pa) + OMAP4_L3_PER_IO_OFFSET)

@@ -154,6 +157,15 @@
 #define L4_34XX_SIZE		SZ_4M   /* 1MB of 128MB used, want 1MB sect */

 /*
+ * ----------------------------------------------------------------------------
+ * AM33XX specific IO mapping
+ * ----------------------------------------------------------------------------
+ */
+#define L4_WK_AM33XX_PHYS	L4_WK_AM33XX_BASE
+#define L4_WK_AM33XX_VIRT	(L4_WK_AM33XX_PHYS + AM33XX_L4_WK_IO_OFFSET)
+#define L4_WK_AM33XX_SIZE	SZ_4M   /* 1MB of 128MB used, want 1MB sect */
+
+/*
  * Need to look at the Size 4M for L4.
  * VPOM3430 was not working for Int controller
  */
@@ -316,6 +328,14 @@ static inline void omapti816x_map_common_io(void)
 }
 #endif

+#ifdef CONFIG_SOC_OMAPAM33XX
+extern void omapam33xx_map_common_io(void);
+#else
+static inline void omapam33xx_map_common_io(void)
+{
+}
+#endif
+
 #ifdef CONFIG_ARCH_OMAP4
 extern void omap44xx_map_common_io(void);
 #else
diff --git a/arch/arm/plat-omap/include/plat/omap34xx.h b/arch/arm/plat-omap/include/plat/omap34xx.h
index b9e8588..0d818ac 100644
--- a/arch/arm/plat-omap/include/plat/omap34xx.h
+++ b/arch/arm/plat-omap/include/plat/omap34xx.h
@@ -35,6 +35,8 @@
 #define L4_EMU_34XX_BASE	0x54000000
 #define L3_34XX_BASE		0x68000000

+#define L4_WK_AM33XX_BASE	0x44C00000
+
 #define OMAP3430_32KSYNCT_BASE	0x48320000
 #define OMAP3430_CM_BASE	0x48004800
 #define OMAP3430_PRM_BASE	0x48306800
diff --git a/arch/arm/plat-omap/io.c b/arch/arm/plat-omap/io.c
index 333871f..14c421a 100644
--- a/arch/arm/plat-omap/io.c
+++ b/arch/arm/plat-omap/io.c
@@ -94,6 +94,11 @@ void __iomem *omap_ioremap(unsigned long p, size_t size, unsigned int type)
 	if (cpu_is_ti816x()) {
 		if (BETWEEN(p, L4_34XX_PHYS, L4_34XX_SIZE))
 			return XLATE(p, L4_34XX_PHYS, L4_34XX_VIRT);
+	} else if (cpu_is_am33xx()) {
+		if (BETWEEN(p, L4_34XX_PHYS, L4_34XX_SIZE))
+			return XLATE(p, L4_34XX_PHYS, L4_34XX_VIRT);
+		if (BETWEEN(p, L4_WK_AM33XX_PHYS, L4_WK_AM33XX_SIZE))
+			return XLATE(p, L4_WK_AM33XX_PHYS, L4_WK_AM33XX_VIRT);
 	} else if (cpu_is_omap34xx()) {
 		if (BETWEEN(p, L3_34XX_PHYS, L3_34XX_SIZE))
 			return XLATE(p, L3_34XX_PHYS, L3_34XX_VIRT);
--
1.7.0.4

^ permalink raw reply related	[flat|nested] 263+ messages in thread

* [PATCH-V5 2/3] arm:omap:am33xx: Add AM335XEVM machine support
@ 2011-12-02  6:43 ` hvaibhav at ti.com
  0 siblings, 0 replies; 263+ messages in thread
From: hvaibhav @ 2011-12-02  6:43 UTC (permalink / raw)
  To: linux-omap
  Cc: tony, khilman, linux-arm-kernel, paul, Afzal Mohammed, Vaibhav Hiremath

From: Afzal Mohammed <afzal@ti.com>

This patch adds minimal support for AM335X EVM.
The approach taken here is to add AM335X EVM support
to AM3517EVM, considering the fact that with device tree
developement we will get rid of board-*.c.

Signed-off-by: Afzal Mohammed <afzal@ti.com>
Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
Reviewed-by: Kevin Hilman <khilman@ti.com>
---
 arch/arm/mach-omap2/Kconfig              |    5 +++++
 arch/arm/mach-omap2/Makefile             |    1 +
 arch/arm/mach-omap2/board-am3517evm.c    |   21 +++++++++++++++++++++
 arch/arm/mach-omap2/io.c                 |    7 +++++++
 arch/arm/mach-omap2/timer.c              |    2 ++
 arch/arm/plat-omap/include/plat/common.h |    2 ++
 6 files changed, 38 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-omap2/Kconfig b/arch/arm/mach-omap2/Kconfig
index 09ea525..c0e4a70 100644
--- a/arch/arm/mach-omap2/Kconfig
+++ b/arch/arm/mach-omap2/Kconfig
@@ -326,6 +326,11 @@ config MACH_TI8168EVM
 	depends on SOC_OMAPTI816X
 	default y

+config MACH_AM335XEVM
+	bool "AM335X Evaluation Module"
+	depends on SOC_OMAPAM33XX
+	default y
+
 config MACH_OMAP_4430SDP
 	bool "OMAP 4430 SDP board"
 	default y
diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile
index a12a069..89099a3 100644
--- a/arch/arm/mach-omap2/Makefile
+++ b/arch/arm/mach-omap2/Makefile
@@ -233,6 +233,7 @@ obj-$(CONFIG_MACH_CRANEBOARD)		+= board-am3517crane.o

 obj-$(CONFIG_MACH_SBC3530)		+= board-omap3stalker.o
 obj-$(CONFIG_MACH_TI8168EVM)		+= board-ti8168evm.o
+obj-$(CONFIG_MACH_AM335XEVM)		+= board-am3517evm.o

 # Platform specific device init code

diff --git a/arch/arm/mach-omap2/board-am3517evm.c b/arch/arm/mach-omap2/board-am3517evm.c
index f7df8d3..090457f 100644
--- a/arch/arm/mach-omap2/board-am3517evm.c
+++ b/arch/arm/mach-omap2/board-am3517evm.c
@@ -516,3 +516,24 @@ MACHINE_START(OMAP3517EVM, "OMAP3517/AM3517 EVM")
 	.init_machine	= am3517_evm_init,
 	.timer		= &omap3_timer,
 MACHINE_END
+
+static struct omap_board_config_kernel am335x_evm_config[] __initdata = {
+};
+
+static void __init am335x_evm_init(void)
+{
+	omap_serial_init();
+	omap_sdrc_init(NULL, NULL);
+	omap_board_config = am335x_evm_config;
+	omap_board_config_size = ARRAY_SIZE(am335x_evm_config);
+}
+
+MACHINE_START(AM335XEVM, "am335xevm")
+	/* Maintainer: Texas Instruments */
+	.atag_offset	= 0x100,
+	.map_io		= am33xx_map_io,
+	.init_early	= am33xx_init_early,
+	.init_irq	= ti816x_init_irq,
+	.timer		= &omap3_am33xx_timer,
+	.init_machine	= am335x_evm_init,
+MACHINE_END
diff --git a/arch/arm/mach-omap2/io.c b/arch/arm/mach-omap2/io.c
index 74e84c6..e958c04 100644
--- a/arch/arm/mach-omap2/io.c
+++ b/arch/arm/mach-omap2/io.c
@@ -460,6 +460,13 @@ void __init ti816x_init_early(void)
 	omap_hwmod_init_postsetup();
 	omap3xxx_clk_init();
 }
+
+void __init am33xx_init_early(void)
+{
+	omap2_set_globals_am33xx();
+	omap_common_init_early();
+	omap3xxx_clk_init();
+}
 #endif

 #ifdef CONFIG_ARCH_OMAP4
diff --git a/arch/arm/mach-omap2/timer.c b/arch/arm/mach-omap2/timer.c
index 037b0d7..7b29197 100644
--- a/arch/arm/mach-omap2/timer.c
+++ b/arch/arm/mach-omap2/timer.c
@@ -333,6 +333,8 @@ OMAP_SYS_TIMER(3)
 OMAP_SYS_TIMER_INIT(3_secure, OMAP3_SECURE_TIMER, OMAP3_CLKEV_SOURCE,
 			2, OMAP3_MPU_SOURCE)
 OMAP_SYS_TIMER(3_secure)
+OMAP_SYS_TIMER_INIT(3_am33xx, 1, OMAP4_MPU_SOURCE, 2, OMAP4_MPU_SOURCE)
+OMAP_SYS_TIMER(3_am33xx)
 #endif

 #ifdef CONFIG_ARCH_OMAP4
diff --git a/arch/arm/plat-omap/include/plat/common.h b/arch/arm/plat-omap/include/plat/common.h
index bb8a6c1..9d7cc3c 100644
--- a/arch/arm/plat-omap/include/plat/common.h
+++ b/arch/arm/plat-omap/include/plat/common.h
@@ -39,6 +39,7 @@ extern struct sys_timer omap1_timer;
 extern struct sys_timer omap2_timer;
 extern struct sys_timer omap3_timer;
 extern struct sys_timer omap3_secure_timer;
+extern struct sys_timer omap3_am33xx_timer;
 extern struct sys_timer omap4_timer;
 extern bool omap_32k_timer_init(void);
 extern int __init omap_init_clocksource_32k(void);
@@ -55,6 +56,7 @@ void omap3_init_early(void);	/* Do not use this one */
 void am35xx_init_early(void);
 void ti816x_init_early(void);
 void omap4430_init_early(void);
+void am33xx_init_early(void);

 extern int omap_dss_reset(struct omap_hwmod *);

--
1.7.0.4


^ permalink raw reply related	[flat|nested] 263+ messages in thread

* [PATCH-V5 2/3] arm:omap:am33xx: Add AM335XEVM machine support
@ 2011-12-02  6:43 ` hvaibhav at ti.com
  0 siblings, 0 replies; 263+ messages in thread
From: hvaibhav at ti.com @ 2011-12-02  6:43 UTC (permalink / raw)
  To: linux-arm-kernel

From: Afzal Mohammed <afzal@ti.com>

This patch adds minimal support for AM335X EVM.
The approach taken here is to add AM335X EVM support
to AM3517EVM, considering the fact that with device tree
developement we will get rid of board-*.c.

Signed-off-by: Afzal Mohammed <afzal@ti.com>
Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
Reviewed-by: Kevin Hilman <khilman@ti.com>
---
 arch/arm/mach-omap2/Kconfig              |    5 +++++
 arch/arm/mach-omap2/Makefile             |    1 +
 arch/arm/mach-omap2/board-am3517evm.c    |   21 +++++++++++++++++++++
 arch/arm/mach-omap2/io.c                 |    7 +++++++
 arch/arm/mach-omap2/timer.c              |    2 ++
 arch/arm/plat-omap/include/plat/common.h |    2 ++
 6 files changed, 38 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-omap2/Kconfig b/arch/arm/mach-omap2/Kconfig
index 09ea525..c0e4a70 100644
--- a/arch/arm/mach-omap2/Kconfig
+++ b/arch/arm/mach-omap2/Kconfig
@@ -326,6 +326,11 @@ config MACH_TI8168EVM
 	depends on SOC_OMAPTI816X
 	default y

+config MACH_AM335XEVM
+	bool "AM335X Evaluation Module"
+	depends on SOC_OMAPAM33XX
+	default y
+
 config MACH_OMAP_4430SDP
 	bool "OMAP 4430 SDP board"
 	default y
diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile
index a12a069..89099a3 100644
--- a/arch/arm/mach-omap2/Makefile
+++ b/arch/arm/mach-omap2/Makefile
@@ -233,6 +233,7 @@ obj-$(CONFIG_MACH_CRANEBOARD)		+= board-am3517crane.o

 obj-$(CONFIG_MACH_SBC3530)		+= board-omap3stalker.o
 obj-$(CONFIG_MACH_TI8168EVM)		+= board-ti8168evm.o
+obj-$(CONFIG_MACH_AM335XEVM)		+= board-am3517evm.o

 # Platform specific device init code

diff --git a/arch/arm/mach-omap2/board-am3517evm.c b/arch/arm/mach-omap2/board-am3517evm.c
index f7df8d3..090457f 100644
--- a/arch/arm/mach-omap2/board-am3517evm.c
+++ b/arch/arm/mach-omap2/board-am3517evm.c
@@ -516,3 +516,24 @@ MACHINE_START(OMAP3517EVM, "OMAP3517/AM3517 EVM")
 	.init_machine	= am3517_evm_init,
 	.timer		= &omap3_timer,
 MACHINE_END
+
+static struct omap_board_config_kernel am335x_evm_config[] __initdata = {
+};
+
+static void __init am335x_evm_init(void)
+{
+	omap_serial_init();
+	omap_sdrc_init(NULL, NULL);
+	omap_board_config = am335x_evm_config;
+	omap_board_config_size = ARRAY_SIZE(am335x_evm_config);
+}
+
+MACHINE_START(AM335XEVM, "am335xevm")
+	/* Maintainer: Texas Instruments */
+	.atag_offset	= 0x100,
+	.map_io		= am33xx_map_io,
+	.init_early	= am33xx_init_early,
+	.init_irq	= ti816x_init_irq,
+	.timer		= &omap3_am33xx_timer,
+	.init_machine	= am335x_evm_init,
+MACHINE_END
diff --git a/arch/arm/mach-omap2/io.c b/arch/arm/mach-omap2/io.c
index 74e84c6..e958c04 100644
--- a/arch/arm/mach-omap2/io.c
+++ b/arch/arm/mach-omap2/io.c
@@ -460,6 +460,13 @@ void __init ti816x_init_early(void)
 	omap_hwmod_init_postsetup();
 	omap3xxx_clk_init();
 }
+
+void __init am33xx_init_early(void)
+{
+	omap2_set_globals_am33xx();
+	omap_common_init_early();
+	omap3xxx_clk_init();
+}
 #endif

 #ifdef CONFIG_ARCH_OMAP4
diff --git a/arch/arm/mach-omap2/timer.c b/arch/arm/mach-omap2/timer.c
index 037b0d7..7b29197 100644
--- a/arch/arm/mach-omap2/timer.c
+++ b/arch/arm/mach-omap2/timer.c
@@ -333,6 +333,8 @@ OMAP_SYS_TIMER(3)
 OMAP_SYS_TIMER_INIT(3_secure, OMAP3_SECURE_TIMER, OMAP3_CLKEV_SOURCE,
 			2, OMAP3_MPU_SOURCE)
 OMAP_SYS_TIMER(3_secure)
+OMAP_SYS_TIMER_INIT(3_am33xx, 1, OMAP4_MPU_SOURCE, 2, OMAP4_MPU_SOURCE)
+OMAP_SYS_TIMER(3_am33xx)
 #endif

 #ifdef CONFIG_ARCH_OMAP4
diff --git a/arch/arm/plat-omap/include/plat/common.h b/arch/arm/plat-omap/include/plat/common.h
index bb8a6c1..9d7cc3c 100644
--- a/arch/arm/plat-omap/include/plat/common.h
+++ b/arch/arm/plat-omap/include/plat/common.h
@@ -39,6 +39,7 @@ extern struct sys_timer omap1_timer;
 extern struct sys_timer omap2_timer;
 extern struct sys_timer omap3_timer;
 extern struct sys_timer omap3_secure_timer;
+extern struct sys_timer omap3_am33xx_timer;
 extern struct sys_timer omap4_timer;
 extern bool omap_32k_timer_init(void);
 extern int __init omap_init_clocksource_32k(void);
@@ -55,6 +56,7 @@ void omap3_init_early(void);	/* Do not use this one */
 void am35xx_init_early(void);
 void ti816x_init_early(void);
 void omap4430_init_early(void);
+void am33xx_init_early(void);

 extern int omap_dss_reset(struct omap_hwmod *);

--
1.7.0.4

^ permalink raw reply related	[flat|nested] 263+ messages in thread

* Re: [PATCH-V5 0/3] Introducing TI's New SoC/board AM335XEVM
  2011-12-02  6:43 ` hvaibhav at ti.com
@ 2011-12-07  0:24   ` Kevin Hilman
  -1 siblings, 0 replies; 263+ messages in thread
From: Kevin Hilman @ 2011-12-07  0:24 UTC (permalink / raw)
  To: hvaibhav; +Cc: linux-omap, tony, linux-arm-kernel, paul

<hvaibhav@ti.com> writes:

> From: Vaibhav Hiremath <hvaibhav@ti.com>
>
> This patch set adds support for AM335x device having
> Cortex-A8 MPU.
>
> Official website - http://www.ti.com/product/am3359
>
> AM335X is treated as another OMAP3 variant, where,
> along with existing cpu class OMAP34XX, new cpu class AM33XX is created
> and the respective type is AM335X, which is newly added device in
> the family.
> This means, cpu_is_omap34xx(), cpu_is_am33xx() and
> cpu_is_am335x() checks return success for AM335X.
>
> Also, I have validated OMAP3 boot test with this patch-series on
> OMAP3EVM.

Tony, this series looks good to me.

I've also tested it on a BeagleBone, so feel free to also add:

Tested-by: Kevin Hilman <khilman@ti.com>

Kevin

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [PATCH-V5 0/3] Introducing TI's New SoC/board AM335XEVM
@ 2011-12-07  0:24   ` Kevin Hilman
  0 siblings, 0 replies; 263+ messages in thread
From: Kevin Hilman @ 2011-12-07  0:24 UTC (permalink / raw)
  To: linux-arm-kernel

<hvaibhav@ti.com> writes:

> From: Vaibhav Hiremath <hvaibhav@ti.com>
>
> This patch set adds support for AM335x device having
> Cortex-A8 MPU.
>
> Official website - http://www.ti.com/product/am3359
>
> AM335X is treated as another OMAP3 variant, where,
> along with existing cpu class OMAP34XX, new cpu class AM33XX is created
> and the respective type is AM335X, which is newly added device in
> the family.
> This means, cpu_is_omap34xx(), cpu_is_am33xx() and
> cpu_is_am335x() checks return success for AM335X.
>
> Also, I have validated OMAP3 boot test with this patch-series on
> OMAP3EVM.

Tony, this series looks good to me.

I've also tested it on a BeagleBone, so feel free to also add:

Tested-by: Kevin Hilman <khilman@ti.com>

Kevin

^ permalink raw reply	[flat|nested] 263+ messages in thread

* Re: [PATCH-V5 1/3] arm:omap:am33xx: Update common OMAP machine specific sources
  2011-12-02  6:43 ` hvaibhav at ti.com
@ 2011-12-07 21:09   ` Tony Lindgren
  -1 siblings, 0 replies; 263+ messages in thread
From: Tony Lindgren @ 2011-12-07 21:09 UTC (permalink / raw)
  To: hvaibhav; +Cc: linux-omap, khilman, linux-arm-kernel, paul, Afzal Mohammed

* hvaibhav@ti.com <hvaibhav@ti.com> [111201 22:08]:
> From: Afzal Mohammed <afzal@ti.com>
> 
> This patch updates the common machine specific source files for
> support for AM33XX/AM335x with cpu type, macros for identification of
> AM33XX/AM335X device.

Applying this one updated for the map_io and common.h changes, updated
patch below. The other two will have to wait a little because of the
machine_id dependency.

Regards,

Tony

From: Afzal Mohammed <afzal@ti.com>
Date: Fri, 2 Dec 2011 12:13:22 +0530
Subject: [PATCH] arm:omap:am33xx: Update common OMAP machine specific sources

This patch updates the common machine specific source files for
support for AM33XX/AM335x with cpu type, macros for identification of
AM33XX/AM335X device.

Signed-off-by: Afzal Mohammed <afzal@ti.com>
Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
Reviewed-by: Kevin Hilman <khilman@ti.com>
Tested-by: Kevin Hilman <khilman@ti.com>
[tony@atomide.com: updated for map_io and common.h changes]
Signed-off-by: Tony Lindgren <tony@atomide.com>

diff --git a/arch/arm/mach-omap2/clock3xxx_data.c b/arch/arm/mach-omap2/clock3xxx_data.c
index 5d0064a..c1ab6bc 100644
--- a/arch/arm/mach-omap2/clock3xxx_data.c
+++ b/arch/arm/mach-omap2/clock3xxx_data.c
@@ -3517,6 +3517,9 @@ int __init omap3xxx_clk_init(void)
 	} else if (cpu_is_ti816x()) {
 		cpu_mask = RATE_IN_TI816X;
 		cpu_clkflg = CK_TI816X;
+	} else if (cpu_is_am33xx()) {
+		cpu_mask = RATE_IN_AM33XX;
+		cpu_clkflg = CK_AM33XX;
 	} else if (cpu_is_omap34xx()) {
 		if (omap_rev() == OMAP3430_REV_ES1_0) {
 			cpu_mask = RATE_IN_3430ES1;
diff --git a/arch/arm/mach-omap2/common.c b/arch/arm/mach-omap2/common.c
index 684b8a7..c900dcb 100644
--- a/arch/arm/mach-omap2/common.c
+++ b/arch/arm/mach-omap2/common.c
@@ -128,6 +128,27 @@ void __init omap2_set_globals_ti816x(void)
 {
 	__omap2_set_globals(&ti816x_globals);
 }
+
+#define AM33XX_TAP_BASE		(AM33XX_CTRL_BASE + \
+				TI816X_CONTROL_DEVICE_ID - 0x204)
+
+static struct omap_globals am33xx_globals = {
+	.class  = AM335X_CLASS,
+	.tap    = AM33XX_L4_WK_IO_ADDRESS(AM33XX_TAP_BASE),
+	.ctrl   = AM33XX_L4_WK_IO_ADDRESS(AM33XX_CTRL_BASE),
+	.prm    = AM33XX_L4_WK_IO_ADDRESS(AM33XX_PRCM_BASE),
+	.cm     = AM33XX_L4_WK_IO_ADDRESS(AM33XX_PRCM_BASE),
+};
+
+void __init omap2_set_globals_am33xx(void)
+{
+	__omap2_set_globals(&am33xx_globals);
+}
+
+void __init am33xx_map_io(void)
+{
+	omapam33xx_map_common_io();
+}
 #endif
 
 #if defined(CONFIG_ARCH_OMAP4)
diff --git a/arch/arm/mach-omap2/common.h b/arch/arm/mach-omap2/common.h
index 012bac7..9b733e3 100644
--- a/arch/arm/mach-omap2/common.h
+++ b/arch/arm/mach-omap2/common.h
@@ -60,6 +60,14 @@ static inline void omapti816x_map_common_io(void)
 }
 #endif
 
+#ifdef CONFIG_SOC_OMAPAM33XX
+extern void omapam33xx_map_common_io(void);
+#else
+static inline void omapam33xx_map_common_io(void)
+{
+}
+#endif
+
 #ifdef CONFIG_ARCH_OMAP4
 extern void omap44xx_map_common_io(void);
 #else
@@ -107,6 +115,7 @@ void omap2_set_globals_243x(void);
 void omap2_set_globals_3xxx(void);
 void omap2_set_globals_443x(void);
 void omap2_set_globals_ti816x(void);
+void omap2_set_globals_am33xx(void);
 
 /* These get called from omap2_set_globals_xxxx(), do not call these */
 void omap2_set_globals_tap(struct omap_globals *);
@@ -117,6 +126,7 @@ void omap2_set_globals_prcm(struct omap_globals *);
 void omap242x_map_io(void);
 void omap243x_map_io(void);
 void omap3_map_io(void);
+void am33xx_map_io(void);
 void omap4_map_io(void);
 
 /**
diff --git a/arch/arm/mach-omap2/id.c b/arch/arm/mach-omap2/id.c
index 27ad722..7ab09f7 100644
--- a/arch/arm/mach-omap2/id.c
+++ b/arch/arm/mach-omap2/id.c
@@ -340,6 +340,10 @@ static void __init omap3_check_revision(const char **cpu_rev)
 			break;
 		}
 		break;
+	case 0xb944:
+		omap_revision = AM335X_REV_ES1_0;
+		*cpu_rev = "1.0";
+		break;
 	default:
 		/* Unknown default to latest silicon rev as default */
 		omap_revision = OMAP3630_REV_ES1_2;
@@ -432,6 +436,8 @@ static void __init omap3_cpuinfo(const char *cpu_rev)
 		cpu_name = (omap3_has_sgx()) ? "AM3517" : "AM3505";
 	} else if (cpu_is_ti816x()) {
 		cpu_name = "TI816X";
+	} else if (cpu_is_am335x()) {
+		cpu_name =  "AM335X";
 	} else if (omap3_has_iva() && omap3_has_sgx()) {
 		/* OMAP3430, OMAP3525, OMAP3515, OMAP3503 devices */
 		cpu_name = "OMAP3430/3530";
diff --git a/arch/arm/mach-omap2/io.c b/arch/arm/mach-omap2/io.c
index 3f565dd..088d2ba 100644
--- a/arch/arm/mach-omap2/io.c
+++ b/arch/arm/mach-omap2/io.c
@@ -183,7 +183,24 @@ static struct map_desc omapti816x_io_desc[] __initdata = {
 		.pfn		= __phys_to_pfn(L4_34XX_PHYS),
 		.length		= L4_34XX_SIZE,
 		.type		= MT_DEVICE
+	}
+};
+#endif
+
+#ifdef CONFIG_SOC_OMAPAM33XX
+static struct map_desc omapam33xx_io_desc[] __initdata = {
+	{
+		.virtual	= L4_34XX_VIRT,
+		.pfn		= __phys_to_pfn(L4_34XX_PHYS),
+		.length		= L4_34XX_SIZE,
+		.type		= MT_DEVICE
 	},
+	{
+		.virtual	= L4_WK_AM33XX_VIRT,
+		.pfn		= __phys_to_pfn(L4_WK_AM33XX_PHYS),
+		.length		= L4_WK_AM33XX_SIZE,
+		.type		= MT_DEVICE
+	}
 };
 #endif
 
@@ -270,6 +287,13 @@ void __init omapti816x_map_common_io(void)
 }
 #endif
 
+#ifdef CONFIG_SOC_OMAPAM33XX
+void __init omapam33xx_map_common_io(void)
+{
+	iotable_init(omapam33xx_io_desc, ARRAY_SIZE(omapam33xx_io_desc));
+}
+#endif
+
 #ifdef CONFIG_ARCH_OMAP4
 void __init omap44xx_map_common_io(void)
 {
diff --git a/arch/arm/mach-omap2/serial.c b/arch/arm/mach-omap2/serial.c
index 42c3267..9770c76 100644
--- a/arch/arm/mach-omap2/serial.c
+++ b/arch/arm/mach-omap2/serial.c
@@ -464,7 +464,7 @@ static void omap_uart_idle_init(struct omap_uart_state *uart)
 		mod_timer(&uart->timer, jiffies + uart->timeout);
 	omap_uart_smart_idle_enable(uart, 0);
 
-	if (cpu_is_omap34xx() && !cpu_is_ti816x()) {
+	if (cpu_is_omap34xx() && !(cpu_is_ti816x() || cpu_is_am33xx())) {
 		u32 mod = (uart->num > 1) ? OMAP3430_PER_MOD : CORE_MOD;
 		u32 wk_mask = 0;
 		u32 padconf = 0;
@@ -828,7 +828,7 @@ void __init omap_serial_init_port(struct omap_board_data *bdata)
 	}
 
 	/* Enable the MDR1 errata for OMAP3 */
-	if (cpu_is_omap34xx() && !cpu_is_ti816x())
+	if (cpu_is_omap34xx() && !(cpu_is_ti816x() || cpu_is_am33xx()))
 		uart->errata |= UART_ERRATA_i202_MDR1_ACCESS;
 }
 
diff --git a/arch/arm/plat-omap/include/plat/am33xx.h b/arch/arm/plat-omap/include/plat/am33xx.h
new file mode 100644
index 0000000..06c19bb
--- /dev/null
+++ b/arch/arm/plat-omap/include/plat/am33xx.h
@@ -0,0 +1,25 @@
+/*
+ * This file contains the address info for various AM33XX modules.
+ *
+ * Copyright (C) 2011 Texas Instruments, Inc. - http://www.ti.com/
+ *
+ * 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.
+ */
+
+#ifndef __ASM_ARCH_AM33XX_H
+#define __ASM_ARCH_AM33XX_H
+
+#define L4_SLOW_AM33XX_BASE	0x48000000
+
+#define AM33XX_SCM_BASE		0x44E10000
+#define AM33XX_CTRL_BASE	AM33XX_SCM_BASE
+#define AM33XX_PRCM_BASE	0x44E00000
+
+#endif /* __ASM_ARCH_AM33XX_H */
diff --git a/arch/arm/plat-omap/include/plat/hardware.h b/arch/arm/plat-omap/include/plat/hardware.h
index e87efe1..e6521e1 100644
--- a/arch/arm/plat-omap/include/plat/hardware.h
+++ b/arch/arm/plat-omap/include/plat/hardware.h
@@ -287,5 +287,6 @@
 #include <plat/omap34xx.h>
 #include <plat/omap44xx.h>
 #include <plat/ti816x.h>
+#include <plat/am33xx.h>
 
 #endif	/* __ASM_ARCH_OMAP_HARDWARE_H */
diff --git a/arch/arm/plat-omap/include/plat/io.h b/arch/arm/plat-omap/include/plat/io.h
index 1234944..0696bae 100644
--- a/arch/arm/plat-omap/include/plat/io.h
+++ b/arch/arm/plat-omap/include/plat/io.h
@@ -73,6 +73,9 @@
 #define OMAP4_L3_IO_OFFSET	0xb4000000
 #define OMAP4_L3_IO_ADDRESS(pa)	IOMEM((pa) + OMAP4_L3_IO_OFFSET) /* L3 */
 
+#define AM33XX_L4_WK_IO_OFFSET	0xb5000000
+#define AM33XX_L4_WK_IO_ADDRESS(pa)	IOMEM((pa) + AM33XX_L4_WK_IO_OFFSET)
+
 #define OMAP4_L3_PER_IO_OFFSET	0xb1100000
 #define OMAP4_L3_PER_IO_ADDRESS(pa)	IOMEM((pa) + OMAP4_L3_PER_IO_OFFSET)
 
@@ -154,6 +157,15 @@
 #define L4_34XX_SIZE		SZ_4M   /* 1MB of 128MB used, want 1MB sect */
 
 /*
+ * ----------------------------------------------------------------------------
+ * AM33XX specific IO mapping
+ * ----------------------------------------------------------------------------
+ */
+#define L4_WK_AM33XX_PHYS	L4_WK_AM33XX_BASE
+#define L4_WK_AM33XX_VIRT	(L4_WK_AM33XX_PHYS + AM33XX_L4_WK_IO_OFFSET)
+#define L4_WK_AM33XX_SIZE	SZ_4M   /* 1MB of 128MB used, want 1MB sect */
+
+/*
  * Need to look at the Size 4M for L4.
  * VPOM3430 was not working for Int controller
  */
diff --git a/arch/arm/plat-omap/include/plat/omap34xx.h b/arch/arm/plat-omap/include/plat/omap34xx.h
index b9e8588..0d818ac 100644
--- a/arch/arm/plat-omap/include/plat/omap34xx.h
+++ b/arch/arm/plat-omap/include/plat/omap34xx.h
@@ -35,6 +35,8 @@
 #define L4_EMU_34XX_BASE	0x54000000
 #define L3_34XX_BASE		0x68000000
 
+#define L4_WK_AM33XX_BASE	0x44C00000
+
 #define OMAP3430_32KSYNCT_BASE	0x48320000
 #define OMAP3430_CM_BASE	0x48004800
 #define OMAP3430_PRM_BASE	0x48306800

^ permalink raw reply related	[flat|nested] 263+ messages in thread

* [PATCH-V5 1/3] arm:omap:am33xx: Update common OMAP machine specific sources
@ 2011-12-07 21:09   ` Tony Lindgren
  0 siblings, 0 replies; 263+ messages in thread
From: Tony Lindgren @ 2011-12-07 21:09 UTC (permalink / raw)
  To: linux-arm-kernel

* hvaibhav at ti.com <hvaibhav@ti.com> [111201 22:08]:
> From: Afzal Mohammed <afzal@ti.com>
> 
> This patch updates the common machine specific source files for
> support for AM33XX/AM335x with cpu type, macros for identification of
> AM33XX/AM335X device.

Applying this one updated for the map_io and common.h changes, updated
patch below. The other two will have to wait a little because of the
machine_id dependency.

Regards,

Tony

From: Afzal Mohammed <afzal@ti.com>
Date: Fri, 2 Dec 2011 12:13:22 +0530
Subject: [PATCH] arm:omap:am33xx: Update common OMAP machine specific sources

This patch updates the common machine specific source files for
support for AM33XX/AM335x with cpu type, macros for identification of
AM33XX/AM335X device.

Signed-off-by: Afzal Mohammed <afzal@ti.com>
Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
Reviewed-by: Kevin Hilman <khilman@ti.com>
Tested-by: Kevin Hilman <khilman@ti.com>
[tony at atomide.com: updated for map_io and common.h changes]
Signed-off-by: Tony Lindgren <tony@atomide.com>

diff --git a/arch/arm/mach-omap2/clock3xxx_data.c b/arch/arm/mach-omap2/clock3xxx_data.c
index 5d0064a..c1ab6bc 100644
--- a/arch/arm/mach-omap2/clock3xxx_data.c
+++ b/arch/arm/mach-omap2/clock3xxx_data.c
@@ -3517,6 +3517,9 @@ int __init omap3xxx_clk_init(void)
 	} else if (cpu_is_ti816x()) {
 		cpu_mask = RATE_IN_TI816X;
 		cpu_clkflg = CK_TI816X;
+	} else if (cpu_is_am33xx()) {
+		cpu_mask = RATE_IN_AM33XX;
+		cpu_clkflg = CK_AM33XX;
 	} else if (cpu_is_omap34xx()) {
 		if (omap_rev() == OMAP3430_REV_ES1_0) {
 			cpu_mask = RATE_IN_3430ES1;
diff --git a/arch/arm/mach-omap2/common.c b/arch/arm/mach-omap2/common.c
index 684b8a7..c900dcb 100644
--- a/arch/arm/mach-omap2/common.c
+++ b/arch/arm/mach-omap2/common.c
@@ -128,6 +128,27 @@ void __init omap2_set_globals_ti816x(void)
 {
 	__omap2_set_globals(&ti816x_globals);
 }
+
+#define AM33XX_TAP_BASE		(AM33XX_CTRL_BASE + \
+				TI816X_CONTROL_DEVICE_ID - 0x204)
+
+static struct omap_globals am33xx_globals = {
+	.class  = AM335X_CLASS,
+	.tap    = AM33XX_L4_WK_IO_ADDRESS(AM33XX_TAP_BASE),
+	.ctrl   = AM33XX_L4_WK_IO_ADDRESS(AM33XX_CTRL_BASE),
+	.prm    = AM33XX_L4_WK_IO_ADDRESS(AM33XX_PRCM_BASE),
+	.cm     = AM33XX_L4_WK_IO_ADDRESS(AM33XX_PRCM_BASE),
+};
+
+void __init omap2_set_globals_am33xx(void)
+{
+	__omap2_set_globals(&am33xx_globals);
+}
+
+void __init am33xx_map_io(void)
+{
+	omapam33xx_map_common_io();
+}
 #endif
 
 #if defined(CONFIG_ARCH_OMAP4)
diff --git a/arch/arm/mach-omap2/common.h b/arch/arm/mach-omap2/common.h
index 012bac7..9b733e3 100644
--- a/arch/arm/mach-omap2/common.h
+++ b/arch/arm/mach-omap2/common.h
@@ -60,6 +60,14 @@ static inline void omapti816x_map_common_io(void)
 }
 #endif
 
+#ifdef CONFIG_SOC_OMAPAM33XX
+extern void omapam33xx_map_common_io(void);
+#else
+static inline void omapam33xx_map_common_io(void)
+{
+}
+#endif
+
 #ifdef CONFIG_ARCH_OMAP4
 extern void omap44xx_map_common_io(void);
 #else
@@ -107,6 +115,7 @@ void omap2_set_globals_243x(void);
 void omap2_set_globals_3xxx(void);
 void omap2_set_globals_443x(void);
 void omap2_set_globals_ti816x(void);
+void omap2_set_globals_am33xx(void);
 
 /* These get called from omap2_set_globals_xxxx(), do not call these */
 void omap2_set_globals_tap(struct omap_globals *);
@@ -117,6 +126,7 @@ void omap2_set_globals_prcm(struct omap_globals *);
 void omap242x_map_io(void);
 void omap243x_map_io(void);
 void omap3_map_io(void);
+void am33xx_map_io(void);
 void omap4_map_io(void);
 
 /**
diff --git a/arch/arm/mach-omap2/id.c b/arch/arm/mach-omap2/id.c
index 27ad722..7ab09f7 100644
--- a/arch/arm/mach-omap2/id.c
+++ b/arch/arm/mach-omap2/id.c
@@ -340,6 +340,10 @@ static void __init omap3_check_revision(const char **cpu_rev)
 			break;
 		}
 		break;
+	case 0xb944:
+		omap_revision = AM335X_REV_ES1_0;
+		*cpu_rev = "1.0";
+		break;
 	default:
 		/* Unknown default to latest silicon rev as default */
 		omap_revision = OMAP3630_REV_ES1_2;
@@ -432,6 +436,8 @@ static void __init omap3_cpuinfo(const char *cpu_rev)
 		cpu_name = (omap3_has_sgx()) ? "AM3517" : "AM3505";
 	} else if (cpu_is_ti816x()) {
 		cpu_name = "TI816X";
+	} else if (cpu_is_am335x()) {
+		cpu_name =  "AM335X";
 	} else if (omap3_has_iva() && omap3_has_sgx()) {
 		/* OMAP3430, OMAP3525, OMAP3515, OMAP3503 devices */
 		cpu_name = "OMAP3430/3530";
diff --git a/arch/arm/mach-omap2/io.c b/arch/arm/mach-omap2/io.c
index 3f565dd..088d2ba 100644
--- a/arch/arm/mach-omap2/io.c
+++ b/arch/arm/mach-omap2/io.c
@@ -183,7 +183,24 @@ static struct map_desc omapti816x_io_desc[] __initdata = {
 		.pfn		= __phys_to_pfn(L4_34XX_PHYS),
 		.length		= L4_34XX_SIZE,
 		.type		= MT_DEVICE
+	}
+};
+#endif
+
+#ifdef CONFIG_SOC_OMAPAM33XX
+static struct map_desc omapam33xx_io_desc[] __initdata = {
+	{
+		.virtual	= L4_34XX_VIRT,
+		.pfn		= __phys_to_pfn(L4_34XX_PHYS),
+		.length		= L4_34XX_SIZE,
+		.type		= MT_DEVICE
 	},
+	{
+		.virtual	= L4_WK_AM33XX_VIRT,
+		.pfn		= __phys_to_pfn(L4_WK_AM33XX_PHYS),
+		.length		= L4_WK_AM33XX_SIZE,
+		.type		= MT_DEVICE
+	}
 };
 #endif
 
@@ -270,6 +287,13 @@ void __init omapti816x_map_common_io(void)
 }
 #endif
 
+#ifdef CONFIG_SOC_OMAPAM33XX
+void __init omapam33xx_map_common_io(void)
+{
+	iotable_init(omapam33xx_io_desc, ARRAY_SIZE(omapam33xx_io_desc));
+}
+#endif
+
 #ifdef CONFIG_ARCH_OMAP4
 void __init omap44xx_map_common_io(void)
 {
diff --git a/arch/arm/mach-omap2/serial.c b/arch/arm/mach-omap2/serial.c
index 42c3267..9770c76 100644
--- a/arch/arm/mach-omap2/serial.c
+++ b/arch/arm/mach-omap2/serial.c
@@ -464,7 +464,7 @@ static void omap_uart_idle_init(struct omap_uart_state *uart)
 		mod_timer(&uart->timer, jiffies + uart->timeout);
 	omap_uart_smart_idle_enable(uart, 0);
 
-	if (cpu_is_omap34xx() && !cpu_is_ti816x()) {
+	if (cpu_is_omap34xx() && !(cpu_is_ti816x() || cpu_is_am33xx())) {
 		u32 mod = (uart->num > 1) ? OMAP3430_PER_MOD : CORE_MOD;
 		u32 wk_mask = 0;
 		u32 padconf = 0;
@@ -828,7 +828,7 @@ void __init omap_serial_init_port(struct omap_board_data *bdata)
 	}
 
 	/* Enable the MDR1 errata for OMAP3 */
-	if (cpu_is_omap34xx() && !cpu_is_ti816x())
+	if (cpu_is_omap34xx() && !(cpu_is_ti816x() || cpu_is_am33xx()))
 		uart->errata |= UART_ERRATA_i202_MDR1_ACCESS;
 }
 
diff --git a/arch/arm/plat-omap/include/plat/am33xx.h b/arch/arm/plat-omap/include/plat/am33xx.h
new file mode 100644
index 0000000..06c19bb
--- /dev/null
+++ b/arch/arm/plat-omap/include/plat/am33xx.h
@@ -0,0 +1,25 @@
+/*
+ * This file contains the address info for various AM33XX modules.
+ *
+ * Copyright (C) 2011 Texas Instruments, Inc. - http://www.ti.com/
+ *
+ * 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.
+ */
+
+#ifndef __ASM_ARCH_AM33XX_H
+#define __ASM_ARCH_AM33XX_H
+
+#define L4_SLOW_AM33XX_BASE	0x48000000
+
+#define AM33XX_SCM_BASE		0x44E10000
+#define AM33XX_CTRL_BASE	AM33XX_SCM_BASE
+#define AM33XX_PRCM_BASE	0x44E00000
+
+#endif /* __ASM_ARCH_AM33XX_H */
diff --git a/arch/arm/plat-omap/include/plat/hardware.h b/arch/arm/plat-omap/include/plat/hardware.h
index e87efe1..e6521e1 100644
--- a/arch/arm/plat-omap/include/plat/hardware.h
+++ b/arch/arm/plat-omap/include/plat/hardware.h
@@ -287,5 +287,6 @@
 #include <plat/omap34xx.h>
 #include <plat/omap44xx.h>
 #include <plat/ti816x.h>
+#include <plat/am33xx.h>
 
 #endif	/* __ASM_ARCH_OMAP_HARDWARE_H */
diff --git a/arch/arm/plat-omap/include/plat/io.h b/arch/arm/plat-omap/include/plat/io.h
index 1234944..0696bae 100644
--- a/arch/arm/plat-omap/include/plat/io.h
+++ b/arch/arm/plat-omap/include/plat/io.h
@@ -73,6 +73,9 @@
 #define OMAP4_L3_IO_OFFSET	0xb4000000
 #define OMAP4_L3_IO_ADDRESS(pa)	IOMEM((pa) + OMAP4_L3_IO_OFFSET) /* L3 */
 
+#define AM33XX_L4_WK_IO_OFFSET	0xb5000000
+#define AM33XX_L4_WK_IO_ADDRESS(pa)	IOMEM((pa) + AM33XX_L4_WK_IO_OFFSET)
+
 #define OMAP4_L3_PER_IO_OFFSET	0xb1100000
 #define OMAP4_L3_PER_IO_ADDRESS(pa)	IOMEM((pa) + OMAP4_L3_PER_IO_OFFSET)
 
@@ -154,6 +157,15 @@
 #define L4_34XX_SIZE		SZ_4M   /* 1MB of 128MB used, want 1MB sect */
 
 /*
+ * ----------------------------------------------------------------------------
+ * AM33XX specific IO mapping
+ * ----------------------------------------------------------------------------
+ */
+#define L4_WK_AM33XX_PHYS	L4_WK_AM33XX_BASE
+#define L4_WK_AM33XX_VIRT	(L4_WK_AM33XX_PHYS + AM33XX_L4_WK_IO_OFFSET)
+#define L4_WK_AM33XX_SIZE	SZ_4M   /* 1MB of 128MB used, want 1MB sect */
+
+/*
  * Need to look at the Size 4M for L4.
  * VPOM3430 was not working for Int controller
  */
diff --git a/arch/arm/plat-omap/include/plat/omap34xx.h b/arch/arm/plat-omap/include/plat/omap34xx.h
index b9e8588..0d818ac 100644
--- a/arch/arm/plat-omap/include/plat/omap34xx.h
+++ b/arch/arm/plat-omap/include/plat/omap34xx.h
@@ -35,6 +35,8 @@
 #define L4_EMU_34XX_BASE	0x54000000
 #define L3_34XX_BASE		0x68000000
 
+#define L4_WK_AM33XX_BASE	0x44C00000
+
 #define OMAP3430_32KSYNCT_BASE	0x48320000
 #define OMAP3430_CM_BASE	0x48004800
 #define OMAP3430_PRM_BASE	0x48306800

^ permalink raw reply related	[flat|nested] 263+ messages in thread

* Re: [PATCH-V5 0/3] Introducing TI's New SoC/board AM335XEVM
  2011-12-07  0:24   ` Kevin Hilman
@ 2011-12-07 21:10     ` Tony Lindgren
  -1 siblings, 0 replies; 263+ messages in thread
From: Tony Lindgren @ 2011-12-07 21:10 UTC (permalink / raw)
  To: Kevin Hilman; +Cc: hvaibhav, linux-omap, linux-arm-kernel, paul

* Kevin Hilman <khilman@ti.com> [111206 15:52]:
> <hvaibhav@ti.com> writes:
> 
> > From: Vaibhav Hiremath <hvaibhav@ti.com>
> >
> > This patch set adds support for AM335x device having
> > Cortex-A8 MPU.
> >
> > Official website - http://www.ti.com/product/am3359
> >
> > AM335X is treated as another OMAP3 variant, where,
> > along with existing cpu class OMAP34XX, new cpu class AM33XX is created
> > and the respective type is AM335X, which is newly added device in
> > the family.
> > This means, cpu_is_omap34xx(), cpu_is_am33xx() and
> > cpu_is_am335x() checks return success for AM335X.
> >
> > Also, I have validated OMAP3 boot test with this patch-series on
> > OMAP3EVM.
> 
> Tony, this series looks good to me.
> 
> I've also tested it on a BeagleBone, so feel free to also add:
> 
> Tested-by: Kevin Hilman <khilman@ti.com>

Thanks looks good to me. We still need the machine_id update to
apply patches 2 and 3 in this series, so applying only the first
patch into soc branch for now.

Tony

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [PATCH-V5 0/3] Introducing TI's New SoC/board AM335XEVM
@ 2011-12-07 21:10     ` Tony Lindgren
  0 siblings, 0 replies; 263+ messages in thread
From: Tony Lindgren @ 2011-12-07 21:10 UTC (permalink / raw)
  To: linux-arm-kernel

* Kevin Hilman <khilman@ti.com> [111206 15:52]:
> <hvaibhav@ti.com> writes:
> 
> > From: Vaibhav Hiremath <hvaibhav@ti.com>
> >
> > This patch set adds support for AM335x device having
> > Cortex-A8 MPU.
> >
> > Official website - http://www.ti.com/product/am3359
> >
> > AM335X is treated as another OMAP3 variant, where,
> > along with existing cpu class OMAP34XX, new cpu class AM33XX is created
> > and the respective type is AM335X, which is newly added device in
> > the family.
> > This means, cpu_is_omap34xx(), cpu_is_am33xx() and
> > cpu_is_am335x() checks return success for AM335X.
> >
> > Also, I have validated OMAP3 boot test with this patch-series on
> > OMAP3EVM.
> 
> Tony, this series looks good to me.
> 
> I've also tested it on a BeagleBone, so feel free to also add:
> 
> Tested-by: Kevin Hilman <khilman@ti.com>

Thanks looks good to me. We still need the machine_id update to
apply patches 2 and 3 in this series, so applying only the first
patch into soc branch for now.

Tony

^ permalink raw reply	[flat|nested] 263+ messages in thread

* RE: [PATCH-V5 0/3] Introducing TI's New SoC/board AM335XEVM
  2011-12-07 21:10     ` Tony Lindgren
@ 2011-12-08 13:45       ` Hiremath, Vaibhav
  -1 siblings, 0 replies; 263+ messages in thread
From: Hiremath, Vaibhav @ 2011-12-08 13:45 UTC (permalink / raw)
  To: Tony Lindgren, Hilman, Kevin; +Cc: linux-omap, linux-arm-kernel, paul, rmk


> -----Original Message-----
> From: Tony Lindgren [mailto:tony@atomide.com]
> Sent: Thursday, December 08, 2011 2:40 AM
> To: Hilman, Kevin
> Cc: Hiremath, Vaibhav; linux-omap@vger.kernel.org; linux-arm-
> kernel@lists.infradead.org; paul@pwsan.com
> Subject: Re: [PATCH-V5 0/3] Introducing TI's New SoC/board AM335XEVM
> 
> * Kevin Hilman <khilman@ti.com> [111206 15:52]:
> > <hvaibhav@ti.com> writes:
> >
> > > From: Vaibhav Hiremath <hvaibhav@ti.com>
> > >
> > > This patch set adds support for AM335x device having
> > > Cortex-A8 MPU.
> > >
> > > Official website - http://www.ti.com/product/am3359
> > >
> > > AM335X is treated as another OMAP3 variant, where,
> > > along with existing cpu class OMAP34XX, new cpu class AM33XX is
> created
> > > and the respective type is AM335X, which is newly added device in
> > > the family.
> > > This means, cpu_is_omap34xx(), cpu_is_am33xx() and
> > > cpu_is_am335x() checks return success for AM335X.
> > >
> > > Also, I have validated OMAP3 boot test with this patch-series on
> > > OMAP3EVM.
> >
> > Tony, this series looks good to me.
> >
> > I've also tested it on a BeagleBone, so feel free to also add:
> >
> > Tested-by: Kevin Hilman <khilman@ti.com>
> 
> Thanks looks good to me. We still need the machine_id update to
> apply patches 2 and 3 in this series, so applying only the first
> patch into soc branch for now.
> 

Tony,

Should I ping Russell for this? The machine-id patch is already registered
and present at

http://www.arm.linux.org.uk/developer/machines/download.php

Thanks,
Vaibhav

> Tony

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [PATCH-V5 0/3] Introducing TI's New SoC/board AM335XEVM
@ 2011-12-08 13:45       ` Hiremath, Vaibhav
  0 siblings, 0 replies; 263+ messages in thread
From: Hiremath, Vaibhav @ 2011-12-08 13:45 UTC (permalink / raw)
  To: linux-arm-kernel


> -----Original Message-----
> From: Tony Lindgren [mailto:tony at atomide.com]
> Sent: Thursday, December 08, 2011 2:40 AM
> To: Hilman, Kevin
> Cc: Hiremath, Vaibhav; linux-omap at vger.kernel.org; linux-arm-
> kernel at lists.infradead.org; paul at pwsan.com
> Subject: Re: [PATCH-V5 0/3] Introducing TI's New SoC/board AM335XEVM
> 
> * Kevin Hilman <khilman@ti.com> [111206 15:52]:
> > <hvaibhav@ti.com> writes:
> >
> > > From: Vaibhav Hiremath <hvaibhav@ti.com>
> > >
> > > This patch set adds support for AM335x device having
> > > Cortex-A8 MPU.
> > >
> > > Official website - http://www.ti.com/product/am3359
> > >
> > > AM335X is treated as another OMAP3 variant, where,
> > > along with existing cpu class OMAP34XX, new cpu class AM33XX is
> created
> > > and the respective type is AM335X, which is newly added device in
> > > the family.
> > > This means, cpu_is_omap34xx(), cpu_is_am33xx() and
> > > cpu_is_am335x() checks return success for AM335X.
> > >
> > > Also, I have validated OMAP3 boot test with this patch-series on
> > > OMAP3EVM.
> >
> > Tony, this series looks good to me.
> >
> > I've also tested it on a BeagleBone, so feel free to also add:
> >
> > Tested-by: Kevin Hilman <khilman@ti.com>
> 
> Thanks looks good to me. We still need the machine_id update to
> apply patches 2 and 3 in this series, so applying only the first
> patch into soc branch for now.
> 

Tony,

Should I ping Russell for this? The machine-id patch is already registered
and present at

http://www.arm.linux.org.uk/developer/machines/download.php

Thanks,
Vaibhav

> Tony

^ permalink raw reply	[flat|nested] 263+ messages in thread

* Re: [PATCH-V5 0/3] Introducing TI's New SoC/board AM335XEVM
  2011-12-08 13:45       ` Hiremath, Vaibhav
@ 2011-12-08 17:18         ` Tony Lindgren
  -1 siblings, 0 replies; 263+ messages in thread
From: Tony Lindgren @ 2011-12-08 17:18 UTC (permalink / raw)
  To: Hiremath, Vaibhav; +Cc: Hilman, Kevin, linux-omap, linux-arm-kernel, paul, rmk

Russell,

* Hiremath, Vaibhav <hvaibhav@ti.com> [111208 05:14]:
> > From: Tony Lindgren [mailto:tony@atomide.com]
> > * Kevin Hilman <khilman@ti.com> [111206 15:52]:
> > >
> > > I've also tested it on a BeagleBone, so feel free to also add:
> > >
> > > Tested-by: Kevin Hilman <khilman@ti.com>
> > 
> > Thanks looks good to me. We still need the machine_id update to
> > apply patches 2 and 3 in this series, so applying only the first
> > patch into soc branch for now.
> 
> Tony,
> 
> Should I ping Russell for this? The machine-id patch is already registered
> and present at
> 
> http://www.arm.linux.org.uk/developer/machines/download.php

Care to push the machine_id updates into devel-stable?

Regards,

Tony

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [PATCH-V5 0/3] Introducing TI's New SoC/board AM335XEVM
@ 2011-12-08 17:18         ` Tony Lindgren
  0 siblings, 0 replies; 263+ messages in thread
From: Tony Lindgren @ 2011-12-08 17:18 UTC (permalink / raw)
  To: linux-arm-kernel

Russell,

* Hiremath, Vaibhav <hvaibhav@ti.com> [111208 05:14]:
> > From: Tony Lindgren [mailto:tony at atomide.com]
> > * Kevin Hilman <khilman@ti.com> [111206 15:52]:
> > >
> > > I've also tested it on a BeagleBone, so feel free to also add:
> > >
> > > Tested-by: Kevin Hilman <khilman@ti.com>
> > 
> > Thanks looks good to me. We still need the machine_id update to
> > apply patches 2 and 3 in this series, so applying only the first
> > patch into soc branch for now.
> 
> Tony,
> 
> Should I ping Russell for this? The machine-id patch is already registered
> and present at
> 
> http://www.arm.linux.org.uk/developer/machines/download.php

Care to push the machine_id updates into devel-stable?

Regards,

Tony

^ permalink raw reply	[flat|nested] 263+ messages in thread

* RE: [PATCH-V5 0/3] Introducing TI's New SoC/board AM335XEVM
  2011-12-07 21:10     ` Tony Lindgren
@ 2012-01-18  8:47       ` Hiremath, Vaibhav
  -1 siblings, 0 replies; 263+ messages in thread
From: Hiremath, Vaibhav @ 2012-01-18  8:47 UTC (permalink / raw)
  To: Tony Lindgren, Hilman, Kevin; +Cc: linux-omap, linux-arm-kernel, paul

On Thu, Dec 08, 2011 at 02:40:29, Tony Lindgren wrote:
> * Kevin Hilman <khilman@ti.com> [111206 15:52]:
> > <hvaibhav@ti.com> writes:
> > 
> > > From: Vaibhav Hiremath <hvaibhav@ti.com>
> > >
> > > This patch set adds support for AM335x device having
> > > Cortex-A8 MPU.
> > >
> > > Official website - http://www.ti.com/product/am3359
> > >
> > > AM335X is treated as another OMAP3 variant, where,
> > > along with existing cpu class OMAP34XX, new cpu class AM33XX is created
> > > and the respective type is AM335X, which is newly added device in
> > > the family.
> > > This means, cpu_is_omap34xx(), cpu_is_am33xx() and
> > > cpu_is_am335x() checks return success for AM335X.
> > >
> > > Also, I have validated OMAP3 boot test with this patch-series on
> > > OMAP3EVM.
> > 
> > Tony, this series looks good to me.
> > 
> > I've also tested it on a BeagleBone, so feel free to also add:
> > 
> > Tested-by: Kevin Hilman <khilman@ti.com>
> 
> Thanks looks good to me. We still need the machine_id update to
> apply patches 2 and 3 in this series, so applying only the first
> patch into soc branch for now.
> 
Tony,

Can you also merge this patch, as machine_id for am335x-evm is already
updated in linus/master?

Thanks,
Vaibhav

> Tony
> 


^ permalink raw reply	[flat|nested] 263+ messages in thread

* [PATCH-V5 0/3] Introducing TI's New SoC/board AM335XEVM
@ 2012-01-18  8:47       ` Hiremath, Vaibhav
  0 siblings, 0 replies; 263+ messages in thread
From: Hiremath, Vaibhav @ 2012-01-18  8:47 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Dec 08, 2011 at 02:40:29, Tony Lindgren wrote:
> * Kevin Hilman <khilman@ti.com> [111206 15:52]:
> > <hvaibhav@ti.com> writes:
> > 
> > > From: Vaibhav Hiremath <hvaibhav@ti.com>
> > >
> > > This patch set adds support for AM335x device having
> > > Cortex-A8 MPU.
> > >
> > > Official website - http://www.ti.com/product/am3359
> > >
> > > AM335X is treated as another OMAP3 variant, where,
> > > along with existing cpu class OMAP34XX, new cpu class AM33XX is created
> > > and the respective type is AM335X, which is newly added device in
> > > the family.
> > > This means, cpu_is_omap34xx(), cpu_is_am33xx() and
> > > cpu_is_am335x() checks return success for AM335X.
> > >
> > > Also, I have validated OMAP3 boot test with this patch-series on
> > > OMAP3EVM.
> > 
> > Tony, this series looks good to me.
> > 
> > I've also tested it on a BeagleBone, so feel free to also add:
> > 
> > Tested-by: Kevin Hilman <khilman@ti.com>
> 
> Thanks looks good to me. We still need the machine_id update to
> apply patches 2 and 3 in this series, so applying only the first
> patch into soc branch for now.
> 
Tony,

Can you also merge this patch, as machine_id for am335x-evm is already
updated in linus/master?

Thanks,
Vaibhav

> Tony
> 

^ permalink raw reply	[flat|nested] 263+ messages in thread

* RE: [PATCH-V5 0/3] Introducing TI's New SoC/board AM335XEVM
  2011-12-08 17:18         ` Tony Lindgren
@ 2012-02-01  6:53           ` Hiremath, Vaibhav
  -1 siblings, 0 replies; 263+ messages in thread
From: Hiremath, Vaibhav @ 2012-02-01  6:53 UTC (permalink / raw)
  To: Tony Lindgren; +Cc: Hilman, Kevin, linux-omap, linux-arm-kernel, paul, rmk

On Thu, Dec 08, 2011 at 22:48:54, Tony Lindgren wrote:
> Russell,
> 
> * Hiremath, Vaibhav <hvaibhav@ti.com> [111208 05:14]:
> > > From: Tony Lindgren [mailto:tony@atomide.com]
> > > * Kevin Hilman <khilman@ti.com> [111206 15:52]:
> > > >
> > > > I've also tested it on a BeagleBone, so feel free to also add:
> > > >
> > > > Tested-by: Kevin Hilman <khilman@ti.com>
> > > 
> > > Thanks looks good to me. We still need the machine_id update to
> > > apply patches 2 and 3 in this series, so applying only the first
> > > patch into soc branch for now.
> > 
> > Tony,
> > 
> > Should I ping Russell for this? The machine-id patch is already registered
> > and present at
> > 
> > http://www.arm.linux.org.uk/developer/machines/download.php
> 
> Care to push the machine_id updates into devel-stable?
> 
Tony,

Can you merge patches 2 & 3 from this series,
as mach-id for AM335xEVM is already available in Mainline
(linus/master or linux-omap/master)?

Thanks,
Vaibhav

> Regards,
> 
> Tony
> 


^ permalink raw reply	[flat|nested] 263+ messages in thread

* [PATCH-V5 0/3] Introducing TI's New SoC/board AM335XEVM
@ 2012-02-01  6:53           ` Hiremath, Vaibhav
  0 siblings, 0 replies; 263+ messages in thread
From: Hiremath, Vaibhav @ 2012-02-01  6:53 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Dec 08, 2011 at 22:48:54, Tony Lindgren wrote:
> Russell,
> 
> * Hiremath, Vaibhav <hvaibhav@ti.com> [111208 05:14]:
> > > From: Tony Lindgren [mailto:tony at atomide.com]
> > > * Kevin Hilman <khilman@ti.com> [111206 15:52]:
> > > >
> > > > I've also tested it on a BeagleBone, so feel free to also add:
> > > >
> > > > Tested-by: Kevin Hilman <khilman@ti.com>
> > > 
> > > Thanks looks good to me. We still need the machine_id update to
> > > apply patches 2 and 3 in this series, so applying only the first
> > > patch into soc branch for now.
> > 
> > Tony,
> > 
> > Should I ping Russell for this? The machine-id patch is already registered
> > and present at
> > 
> > http://www.arm.linux.org.uk/developer/machines/download.php
> 
> Care to push the machine_id updates into devel-stable?
> 
Tony,

Can you merge patches 2 & 3 from this series,
as mach-id for AM335xEVM is already available in Mainline
(linus/master or linux-omap/master)?

Thanks,
Vaibhav

> Regards,
> 
> Tony
> 

^ permalink raw reply	[flat|nested] 263+ messages in thread

* Re: [PATCH-V5 2/3] arm:omap:am33xx: Add AM335XEVM machine support
  2011-12-02  6:43 ` hvaibhav at ti.com
@ 2012-05-02  9:23   ` Paul Walmsley
  -1 siblings, 0 replies; 263+ messages in thread
From: Paul Walmsley @ 2012-05-02  9:23 UTC (permalink / raw)
  To: Vaibhav Hiremath, tony
  Cc: linux-omap, khilman, linux-arm-kernel, Afzal Mohammed

Hi

On Fri, 2 Dec 2011, hvaibhav@ti.com wrote:

> From: Afzal Mohammed <afzal@ti.com>
> 
> This patch adds minimal support for AM335X EVM.
> The approach taken here is to add AM335X EVM support
> to AM3517EVM, considering the fact that with device tree
> developement we will get rid of board-*.c.
> 
> Signed-off-by: Afzal Mohammed <afzal@ti.com>
> Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
> Reviewed-by: Kevin Hilman <khilman@ti.com>

I realize people may not necessarily like this, but I think that the 
AM33xx EVM needs its own board file.  This is because it really has 
nothing to do with the AM3517EVM.  Also, the AM3517EVM depends on 
CONFIG_ARCH_OMAP3, but the AM33xx EVM should not: it should depend on 
either CONFIG_ARCH_OMAPAM33XX, or CONFIG_ARCH_OMAP4.

So the following modification of this patch opts for the former Kconfig 
option, CONFIG_ARCH_OMAPAM33XX.  It also adds a new, minimal board file 
for the AM33xx EVM.  

If, on the other hand, people want to use CONFIG_ARCH_OMAP4 instead for 
the AM33xx, then we could potentially add the new machine record into 
board-omap4panda.c.  Although even then, if political considerations were 
set aside, the best technical decision would probably be to create a 
separate board file, since the boards don't have much in common.


- Paul

From: Afzal Mohammed <afzal@ti.com>
Date: Fri, 2 Dec 2011 12:13:23 +0530
Subject: [PATCH] ARM: OMAP: AM33xx: Add AM335XEVM machine support

This patch adds minimal support for AM335X EVM.

Signed-off-by: Afzal Mohammed <afzal@ti.com>
Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
Reviewed-by: Kevin Hilman <khilman@ti.com>
[paul@pwsan.com: created new board file for AM33xx; moved am33xx_init_early()
 outside of CONFIG_ARCH_OMAP3; modified commit message]
---
 arch/arm/mach-omap2/Kconfig           |    5 ++++
 arch/arm/mach-omap2/Makefile          |    1 +
 arch/arm/mach-omap2/board-am335xevm.c |   46 +++++++++++++++++++++++++++++++++
 arch/arm/mach-omap2/common.h          |    2 ++
 arch/arm/mach-omap2/io.c              |    8 ++++++
 arch/arm/mach-omap2/timer.c           |    2 ++
 6 files changed, 64 insertions(+)
 create mode 100644 arch/arm/mach-omap2/board-am335xevm.c

diff --git a/arch/arm/mach-omap2/Kconfig b/arch/arm/mach-omap2/Kconfig
index 5ae756a..d5aa936 100644
--- a/arch/arm/mach-omap2/Kconfig
+++ b/arch/arm/mach-omap2/Kconfig
@@ -335,6 +335,11 @@ config MACH_TI8148EVM
 	depends on SOC_OMAPTI81XX
 	default y
 
+config MACH_AM335XEVM
+	bool "AM335X Evaluation Module"
+	depends on SOC_OMAPAM33XX
+	default y
+
 config MACH_OMAP_4430SDP
 	bool "OMAP 4430 SDP board"
 	default y
diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile
index c538b3e..d3c33df 100644
--- a/arch/arm/mach-omap2/Makefile
+++ b/arch/arm/mach-omap2/Makefile
@@ -241,6 +241,7 @@ obj-$(CONFIG_MACH_CRANEBOARD)		+= board-am3517crane.o
 obj-$(CONFIG_MACH_SBC3530)		+= board-omap3stalker.o
 obj-$(CONFIG_MACH_TI8168EVM)		+= board-ti8168evm.o
 obj-$(CONFIG_MACH_TI8148EVM)		+= board-ti8168evm.o
+obj-$(CONFIG_MACH_AM335XEVM)		+= board-am335xevm.o
 
 # Platform specific device init code
 
diff --git a/arch/arm/mach-omap2/board-am335xevm.c b/arch/arm/mach-omap2/board-am335xevm.c
new file mode 100644
index 0000000..324752e
--- /dev/null
+++ b/arch/arm/mach-omap2/board-am335xevm.c
@@ -0,0 +1,46 @@
+/*
+ * board-am335xevm.c - support the TI AM335x EVM board
+ *
+ * Copyright (C) 2011-2012 Texas Instruments, Inc.
+ *
+ * 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 <mach/hardware.h>
+#include <asm/mach-types.h>
+#include <asm/mach/arch.h>
+#include <asm/mach/map.h>
+
+#include <plat/board.h>
+#include "common.h"
+
+static struct omap_board_config_kernel am335x_evm_config[] __initdata = {
+};
+
+static void __init am335x_evm_init(void)
+{
+	omap_serial_init();
+	omap_sdrc_init(NULL, NULL);
+	omap_board_config = am335x_evm_config;
+	omap_board_config_size = ARRAY_SIZE(am335x_evm_config);
+}
+
+MACHINE_START(AM335XEVM, "am335xevm")
+	/* Maintainer: Texas Instruments */
+	.atag_offset	= 0x100,
+	.map_io		= am33xx_map_io,
+	.init_early	= am33xx_init_early,
+	.init_irq	= ti81xx_init_irq,
+	.timer		= &omap3_am33xx_timer,
+	.init_machine	= am335x_evm_init,
+MACHINE_END
diff --git a/arch/arm/mach-omap2/common.h b/arch/arm/mach-omap2/common.h
index 57da7f4..dae39a3 100644
--- a/arch/arm/mach-omap2/common.h
+++ b/arch/arm/mach-omap2/common.h
@@ -83,6 +83,7 @@ extern void omap2_init_common_infrastructure(void);
 extern struct sys_timer omap2_timer;
 extern struct sys_timer omap3_timer;
 extern struct sys_timer omap3_secure_timer;
+extern struct sys_timer omap3_am33xx_timer;
 extern struct sys_timer omap4_timer;
 
 void omap2420_init_early(void);
@@ -94,6 +95,7 @@ void omap3_init_early(void);	/* Do not use this one */
 void am35xx_init_early(void);
 void ti81xx_init_early(void);
 void omap4430_init_early(void);
+void am33xx_init_early(void);
 void omap_prcm_restart(char, const char *);
 
 /*
diff --git a/arch/arm/mach-omap2/io.c b/arch/arm/mach-omap2/io.c
index 065bd76..056db56 100644
--- a/arch/arm/mach-omap2/io.c
+++ b/arch/arm/mach-omap2/io.c
@@ -466,6 +466,14 @@ void __init ti81xx_init_early(void)
 	omap_hwmod_init_postsetup();
 	omap3xxx_clk_init();
 }
+#endif /* CONFIG_ARCH_OMAP3 */
+
+#ifdef CONFIG_SOC_OMAPAM33XX
+void __init am33xx_init_early(void)
+{
+	omap2_set_globals_am33xx();
+	omap_common_init_early();
+}
 #endif
 
 #ifdef CONFIG_ARCH_OMAP4
diff --git a/arch/arm/mach-omap2/timer.c b/arch/arm/mach-omap2/timer.c
index c512bac..b2f747b 100644
--- a/arch/arm/mach-omap2/timer.c
+++ b/arch/arm/mach-omap2/timer.c
@@ -321,6 +321,8 @@ OMAP_SYS_TIMER(3)
 OMAP_SYS_TIMER_INIT(3_secure, OMAP3_SECURE_TIMER, OMAP3_CLKEV_SOURCE,
 			2, OMAP3_MPU_SOURCE)
 OMAP_SYS_TIMER(3_secure)
+OMAP_SYS_TIMER_INIT(3_am33xx, 1, OMAP4_MPU_SOURCE, 2, OMAP4_MPU_SOURCE)
+OMAP_SYS_TIMER(3_am33xx)
 #endif
 
 #ifdef CONFIG_ARCH_OMAP4
-- 
1.7.10


^ permalink raw reply related	[flat|nested] 263+ messages in thread

* [PATCH-V5 2/3] arm:omap:am33xx: Add AM335XEVM machine support
@ 2012-05-02  9:23   ` Paul Walmsley
  0 siblings, 0 replies; 263+ messages in thread
From: Paul Walmsley @ 2012-05-02  9:23 UTC (permalink / raw)
  To: linux-arm-kernel

Hi

On Fri, 2 Dec 2011, hvaibhav at ti.com wrote:

> From: Afzal Mohammed <afzal@ti.com>
> 
> This patch adds minimal support for AM335X EVM.
> The approach taken here is to add AM335X EVM support
> to AM3517EVM, considering the fact that with device tree
> developement we will get rid of board-*.c.
> 
> Signed-off-by: Afzal Mohammed <afzal@ti.com>
> Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
> Reviewed-by: Kevin Hilman <khilman@ti.com>

I realize people may not necessarily like this, but I think that the 
AM33xx EVM needs its own board file.  This is because it really has 
nothing to do with the AM3517EVM.  Also, the AM3517EVM depends on 
CONFIG_ARCH_OMAP3, but the AM33xx EVM should not: it should depend on 
either CONFIG_ARCH_OMAPAM33XX, or CONFIG_ARCH_OMAP4.

So the following modification of this patch opts for the former Kconfig 
option, CONFIG_ARCH_OMAPAM33XX.  It also adds a new, minimal board file 
for the AM33xx EVM.  

If, on the other hand, people want to use CONFIG_ARCH_OMAP4 instead for 
the AM33xx, then we could potentially add the new machine record into 
board-omap4panda.c.  Although even then, if political considerations were 
set aside, the best technical decision would probably be to create a 
separate board file, since the boards don't have much in common.


- Paul

From: Afzal Mohammed <afzal@ti.com>
Date: Fri, 2 Dec 2011 12:13:23 +0530
Subject: [PATCH] ARM: OMAP: AM33xx: Add AM335XEVM machine support

This patch adds minimal support for AM335X EVM.

Signed-off-by: Afzal Mohammed <afzal@ti.com>
Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
Reviewed-by: Kevin Hilman <khilman@ti.com>
[paul at pwsan.com: created new board file for AM33xx; moved am33xx_init_early()
 outside of CONFIG_ARCH_OMAP3; modified commit message]
---
 arch/arm/mach-omap2/Kconfig           |    5 ++++
 arch/arm/mach-omap2/Makefile          |    1 +
 arch/arm/mach-omap2/board-am335xevm.c |   46 +++++++++++++++++++++++++++++++++
 arch/arm/mach-omap2/common.h          |    2 ++
 arch/arm/mach-omap2/io.c              |    8 ++++++
 arch/arm/mach-omap2/timer.c           |    2 ++
 6 files changed, 64 insertions(+)
 create mode 100644 arch/arm/mach-omap2/board-am335xevm.c

diff --git a/arch/arm/mach-omap2/Kconfig b/arch/arm/mach-omap2/Kconfig
index 5ae756a..d5aa936 100644
--- a/arch/arm/mach-omap2/Kconfig
+++ b/arch/arm/mach-omap2/Kconfig
@@ -335,6 +335,11 @@ config MACH_TI8148EVM
 	depends on SOC_OMAPTI81XX
 	default y
 
+config MACH_AM335XEVM
+	bool "AM335X Evaluation Module"
+	depends on SOC_OMAPAM33XX
+	default y
+
 config MACH_OMAP_4430SDP
 	bool "OMAP 4430 SDP board"
 	default y
diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile
index c538b3e..d3c33df 100644
--- a/arch/arm/mach-omap2/Makefile
+++ b/arch/arm/mach-omap2/Makefile
@@ -241,6 +241,7 @@ obj-$(CONFIG_MACH_CRANEBOARD)		+= board-am3517crane.o
 obj-$(CONFIG_MACH_SBC3530)		+= board-omap3stalker.o
 obj-$(CONFIG_MACH_TI8168EVM)		+= board-ti8168evm.o
 obj-$(CONFIG_MACH_TI8148EVM)		+= board-ti8168evm.o
+obj-$(CONFIG_MACH_AM335XEVM)		+= board-am335xevm.o
 
 # Platform specific device init code
 
diff --git a/arch/arm/mach-omap2/board-am335xevm.c b/arch/arm/mach-omap2/board-am335xevm.c
new file mode 100644
index 0000000..324752e
--- /dev/null
+++ b/arch/arm/mach-omap2/board-am335xevm.c
@@ -0,0 +1,46 @@
+/*
+ * board-am335xevm.c - support the TI AM335x EVM board
+ *
+ * Copyright (C) 2011-2012 Texas Instruments, Inc.
+ *
+ * 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 <mach/hardware.h>
+#include <asm/mach-types.h>
+#include <asm/mach/arch.h>
+#include <asm/mach/map.h>
+
+#include <plat/board.h>
+#include "common.h"
+
+static struct omap_board_config_kernel am335x_evm_config[] __initdata = {
+};
+
+static void __init am335x_evm_init(void)
+{
+	omap_serial_init();
+	omap_sdrc_init(NULL, NULL);
+	omap_board_config = am335x_evm_config;
+	omap_board_config_size = ARRAY_SIZE(am335x_evm_config);
+}
+
+MACHINE_START(AM335XEVM, "am335xevm")
+	/* Maintainer: Texas Instruments */
+	.atag_offset	= 0x100,
+	.map_io		= am33xx_map_io,
+	.init_early	= am33xx_init_early,
+	.init_irq	= ti81xx_init_irq,
+	.timer		= &omap3_am33xx_timer,
+	.init_machine	= am335x_evm_init,
+MACHINE_END
diff --git a/arch/arm/mach-omap2/common.h b/arch/arm/mach-omap2/common.h
index 57da7f4..dae39a3 100644
--- a/arch/arm/mach-omap2/common.h
+++ b/arch/arm/mach-omap2/common.h
@@ -83,6 +83,7 @@ extern void omap2_init_common_infrastructure(void);
 extern struct sys_timer omap2_timer;
 extern struct sys_timer omap3_timer;
 extern struct sys_timer omap3_secure_timer;
+extern struct sys_timer omap3_am33xx_timer;
 extern struct sys_timer omap4_timer;
 
 void omap2420_init_early(void);
@@ -94,6 +95,7 @@ void omap3_init_early(void);	/* Do not use this one */
 void am35xx_init_early(void);
 void ti81xx_init_early(void);
 void omap4430_init_early(void);
+void am33xx_init_early(void);
 void omap_prcm_restart(char, const char *);
 
 /*
diff --git a/arch/arm/mach-omap2/io.c b/arch/arm/mach-omap2/io.c
index 065bd76..056db56 100644
--- a/arch/arm/mach-omap2/io.c
+++ b/arch/arm/mach-omap2/io.c
@@ -466,6 +466,14 @@ void __init ti81xx_init_early(void)
 	omap_hwmod_init_postsetup();
 	omap3xxx_clk_init();
 }
+#endif /* CONFIG_ARCH_OMAP3 */
+
+#ifdef CONFIG_SOC_OMAPAM33XX
+void __init am33xx_init_early(void)
+{
+	omap2_set_globals_am33xx();
+	omap_common_init_early();
+}
 #endif
 
 #ifdef CONFIG_ARCH_OMAP4
diff --git a/arch/arm/mach-omap2/timer.c b/arch/arm/mach-omap2/timer.c
index c512bac..b2f747b 100644
--- a/arch/arm/mach-omap2/timer.c
+++ b/arch/arm/mach-omap2/timer.c
@@ -321,6 +321,8 @@ OMAP_SYS_TIMER(3)
 OMAP_SYS_TIMER_INIT(3_secure, OMAP3_SECURE_TIMER, OMAP3_CLKEV_SOURCE,
 			2, OMAP3_MPU_SOURCE)
 OMAP_SYS_TIMER(3_secure)
+OMAP_SYS_TIMER_INIT(3_am33xx, 1, OMAP4_MPU_SOURCE, 2, OMAP4_MPU_SOURCE)
+OMAP_SYS_TIMER(3_am33xx)
 #endif
 
 #ifdef CONFIG_ARCH_OMAP4
-- 
1.7.10

^ permalink raw reply related	[flat|nested] 263+ messages in thread

* RE: [PATCH-V5 2/3] arm:omap:am33xx: Add AM335XEVM machine support
  2012-05-02  9:23   ` Paul Walmsley
@ 2012-05-02  9:34     ` Hiremath, Vaibhav
  -1 siblings, 0 replies; 263+ messages in thread
From: Hiremath, Vaibhav @ 2012-05-02  9:34 UTC (permalink / raw)
  To: Paul Walmsley, tony
  Cc: linux-omap, Hilman, Kevin, linux-arm-kernel, Mohammed, Afzal

On Wed, May 02, 2012 at 14:53:24, Paul Walmsley wrote:
> Hi
> 
> On Fri, 2 Dec 2011, hvaibhav@ti.com wrote:
> 
> > From: Afzal Mohammed <afzal@ti.com>
> > 
> > This patch adds minimal support for AM335X EVM.
> > The approach taken here is to add AM335X EVM support
> > to AM3517EVM, considering the fact that with device tree
> > developement we will get rid of board-*.c.
> > 
> > Signed-off-by: Afzal Mohammed <afzal@ti.com>
> > Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
> > Reviewed-by: Kevin Hilman <khilman@ti.com>
> 
> I realize people may not necessarily like this, but I think that the 
> AM33xx EVM needs its own board file.  This is because it really has 
> nothing to do with the AM3517EVM.  Also, the AM3517EVM depends on 
> CONFIG_ARCH_OMAP3, but the AM33xx EVM should not: it should depend on 
> either CONFIG_ARCH_OMAPAM33XX, or CONFIG_ARCH_OMAP4.
> 
> So the following modification of this patch opts for the former Kconfig 
> option, CONFIG_ARCH_OMAPAM33XX.  It also adds a new, minimal board file 
> for the AM33xx EVM.  
> 
> If, on the other hand, people want to use CONFIG_ARCH_OMAP4 instead for 
> the AM33xx, then we could potentially add the new machine record into 
> board-omap4panda.c.  Although even then, if political considerations were 
> set aside, the best technical decision would probably be to create a 
> separate board file, since the boards don't have much in common.
> 
> 
Paul,
I completely agree with all of your comments, let Tony comment and conform 
on this. 
If you go back to history, that was our initial proposal, to create
separate Kconfig option for AM33XX.

Tony,

Can you please comment on this discussion? This is very important, since 
lots of patches (accepted or about to accept) are dependent on this. The 
early we can conclude on this, early I can rework on the patches and 
resubmit them.

Thanks,
Vaibhav

> - Paul
> 
> From: Afzal Mohammed <afzal@ti.com>
> Date: Fri, 2 Dec 2011 12:13:23 +0530
> Subject: [PATCH] ARM: OMAP: AM33xx: Add AM335XEVM machine support
> 
> This patch adds minimal support for AM335X EVM.
> 
> Signed-off-by: Afzal Mohammed <afzal@ti.com>
> Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
> Reviewed-by: Kevin Hilman <khilman@ti.com>
> [paul@pwsan.com: created new board file for AM33xx; moved am33xx_init_early()
>  outside of CONFIG_ARCH_OMAP3; modified commit message]
> ---
>  arch/arm/mach-omap2/Kconfig           |    5 ++++
>  arch/arm/mach-omap2/Makefile          |    1 +
>  arch/arm/mach-omap2/board-am335xevm.c |   46 +++++++++++++++++++++++++++++++++
>  arch/arm/mach-omap2/common.h          |    2 ++
>  arch/arm/mach-omap2/io.c              |    8 ++++++
>  arch/arm/mach-omap2/timer.c           |    2 ++
>  6 files changed, 64 insertions(+)
>  create mode 100644 arch/arm/mach-omap2/board-am335xevm.c
> 
> diff --git a/arch/arm/mach-omap2/Kconfig b/arch/arm/mach-omap2/Kconfig
> index 5ae756a..d5aa936 100644
> --- a/arch/arm/mach-omap2/Kconfig
> +++ b/arch/arm/mach-omap2/Kconfig
> @@ -335,6 +335,11 @@ config MACH_TI8148EVM
>  	depends on SOC_OMAPTI81XX
>  	default y
>  
> +config MACH_AM335XEVM
> +	bool "AM335X Evaluation Module"
> +	depends on SOC_OMAPAM33XX
> +	default y
> +
>  config MACH_OMAP_4430SDP
>  	bool "OMAP 4430 SDP board"
>  	default y
> diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile
> index c538b3e..d3c33df 100644
> --- a/arch/arm/mach-omap2/Makefile
> +++ b/arch/arm/mach-omap2/Makefile
> @@ -241,6 +241,7 @@ obj-$(CONFIG_MACH_CRANEBOARD)		+= board-am3517crane.o
>  obj-$(CONFIG_MACH_SBC3530)		+= board-omap3stalker.o
>  obj-$(CONFIG_MACH_TI8168EVM)		+= board-ti8168evm.o
>  obj-$(CONFIG_MACH_TI8148EVM)		+= board-ti8168evm.o
> +obj-$(CONFIG_MACH_AM335XEVM)		+= board-am335xevm.o
>  
>  # Platform specific device init code
>  
> diff --git a/arch/arm/mach-omap2/board-am335xevm.c b/arch/arm/mach-omap2/board-am335xevm.c
> new file mode 100644
> index 0000000..324752e
> --- /dev/null
> +++ b/arch/arm/mach-omap2/board-am335xevm.c
> @@ -0,0 +1,46 @@
> +/*
> + * board-am335xevm.c - support the TI AM335x EVM board
> + *
> + * Copyright (C) 2011-2012 Texas Instruments, Inc.
> + *
> + * 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 <mach/hardware.h>
> +#include <asm/mach-types.h>
> +#include <asm/mach/arch.h>
> +#include <asm/mach/map.h>
> +
> +#include <plat/board.h>
> +#include "common.h"
> +
> +static struct omap_board_config_kernel am335x_evm_config[] __initdata = {
> +};
> +
> +static void __init am335x_evm_init(void)
> +{
> +	omap_serial_init();
> +	omap_sdrc_init(NULL, NULL);
> +	omap_board_config = am335x_evm_config;
> +	omap_board_config_size = ARRAY_SIZE(am335x_evm_config);
> +}
> +
> +MACHINE_START(AM335XEVM, "am335xevm")
> +	/* Maintainer: Texas Instruments */
> +	.atag_offset	= 0x100,
> +	.map_io		= am33xx_map_io,
> +	.init_early	= am33xx_init_early,
> +	.init_irq	= ti81xx_init_irq,
> +	.timer		= &omap3_am33xx_timer,
> +	.init_machine	= am335x_evm_init,
> +MACHINE_END
> diff --git a/arch/arm/mach-omap2/common.h b/arch/arm/mach-omap2/common.h
> index 57da7f4..dae39a3 100644
> --- a/arch/arm/mach-omap2/common.h
> +++ b/arch/arm/mach-omap2/common.h
> @@ -83,6 +83,7 @@ extern void omap2_init_common_infrastructure(void);
>  extern struct sys_timer omap2_timer;
>  extern struct sys_timer omap3_timer;
>  extern struct sys_timer omap3_secure_timer;
> +extern struct sys_timer omap3_am33xx_timer;
>  extern struct sys_timer omap4_timer;
>  
>  void omap2420_init_early(void);
> @@ -94,6 +95,7 @@ void omap3_init_early(void);	/* Do not use this one */
>  void am35xx_init_early(void);
>  void ti81xx_init_early(void);
>  void omap4430_init_early(void);
> +void am33xx_init_early(void);
>  void omap_prcm_restart(char, const char *);
>  
>  /*
> diff --git a/arch/arm/mach-omap2/io.c b/arch/arm/mach-omap2/io.c
> index 065bd76..056db56 100644
> --- a/arch/arm/mach-omap2/io.c
> +++ b/arch/arm/mach-omap2/io.c
> @@ -466,6 +466,14 @@ void __init ti81xx_init_early(void)
>  	omap_hwmod_init_postsetup();
>  	omap3xxx_clk_init();
>  }
> +#endif /* CONFIG_ARCH_OMAP3 */
> +
> +#ifdef CONFIG_SOC_OMAPAM33XX
> +void __init am33xx_init_early(void)
> +{
> +	omap2_set_globals_am33xx();
> +	omap_common_init_early();
> +}
>  #endif
>  
>  #ifdef CONFIG_ARCH_OMAP4
> diff --git a/arch/arm/mach-omap2/timer.c b/arch/arm/mach-omap2/timer.c
> index c512bac..b2f747b 100644
> --- a/arch/arm/mach-omap2/timer.c
> +++ b/arch/arm/mach-omap2/timer.c
> @@ -321,6 +321,8 @@ OMAP_SYS_TIMER(3)
>  OMAP_SYS_TIMER_INIT(3_secure, OMAP3_SECURE_TIMER, OMAP3_CLKEV_SOURCE,
>  			2, OMAP3_MPU_SOURCE)
>  OMAP_SYS_TIMER(3_secure)
> +OMAP_SYS_TIMER_INIT(3_am33xx, 1, OMAP4_MPU_SOURCE, 2, OMAP4_MPU_SOURCE)
> +OMAP_SYS_TIMER(3_am33xx)
>  #endif
>  
>  #ifdef CONFIG_ARCH_OMAP4
> -- 
> 1.7.10
> 
> 


^ permalink raw reply	[flat|nested] 263+ messages in thread

* [PATCH-V5 2/3] arm:omap:am33xx: Add AM335XEVM machine support
@ 2012-05-02  9:34     ` Hiremath, Vaibhav
  0 siblings, 0 replies; 263+ messages in thread
From: Hiremath, Vaibhav @ 2012-05-02  9:34 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, May 02, 2012 at 14:53:24, Paul Walmsley wrote:
> Hi
> 
> On Fri, 2 Dec 2011, hvaibhav at ti.com wrote:
> 
> > From: Afzal Mohammed <afzal@ti.com>
> > 
> > This patch adds minimal support for AM335X EVM.
> > The approach taken here is to add AM335X EVM support
> > to AM3517EVM, considering the fact that with device tree
> > developement we will get rid of board-*.c.
> > 
> > Signed-off-by: Afzal Mohammed <afzal@ti.com>
> > Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
> > Reviewed-by: Kevin Hilman <khilman@ti.com>
> 
> I realize people may not necessarily like this, but I think that the 
> AM33xx EVM needs its own board file.  This is because it really has 
> nothing to do with the AM3517EVM.  Also, the AM3517EVM depends on 
> CONFIG_ARCH_OMAP3, but the AM33xx EVM should not: it should depend on 
> either CONFIG_ARCH_OMAPAM33XX, or CONFIG_ARCH_OMAP4.
> 
> So the following modification of this patch opts for the former Kconfig 
> option, CONFIG_ARCH_OMAPAM33XX.  It also adds a new, minimal board file 
> for the AM33xx EVM.  
> 
> If, on the other hand, people want to use CONFIG_ARCH_OMAP4 instead for 
> the AM33xx, then we could potentially add the new machine record into 
> board-omap4panda.c.  Although even then, if political considerations were 
> set aside, the best technical decision would probably be to create a 
> separate board file, since the boards don't have much in common.
> 
> 
Paul,
I completely agree with all of your comments, let Tony comment and conform 
on this. 
If you go back to history, that was our initial proposal, to create
separate Kconfig option for AM33XX.

Tony,

Can you please comment on this discussion? This is very important, since 
lots of patches (accepted or about to accept) are dependent on this. The 
early we can conclude on this, early I can rework on the patches and 
resubmit them.

Thanks,
Vaibhav

> - Paul
> 
> From: Afzal Mohammed <afzal@ti.com>
> Date: Fri, 2 Dec 2011 12:13:23 +0530
> Subject: [PATCH] ARM: OMAP: AM33xx: Add AM335XEVM machine support
> 
> This patch adds minimal support for AM335X EVM.
> 
> Signed-off-by: Afzal Mohammed <afzal@ti.com>
> Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
> Reviewed-by: Kevin Hilman <khilman@ti.com>
> [paul at pwsan.com: created new board file for AM33xx; moved am33xx_init_early()
>  outside of CONFIG_ARCH_OMAP3; modified commit message]
> ---
>  arch/arm/mach-omap2/Kconfig           |    5 ++++
>  arch/arm/mach-omap2/Makefile          |    1 +
>  arch/arm/mach-omap2/board-am335xevm.c |   46 +++++++++++++++++++++++++++++++++
>  arch/arm/mach-omap2/common.h          |    2 ++
>  arch/arm/mach-omap2/io.c              |    8 ++++++
>  arch/arm/mach-omap2/timer.c           |    2 ++
>  6 files changed, 64 insertions(+)
>  create mode 100644 arch/arm/mach-omap2/board-am335xevm.c
> 
> diff --git a/arch/arm/mach-omap2/Kconfig b/arch/arm/mach-omap2/Kconfig
> index 5ae756a..d5aa936 100644
> --- a/arch/arm/mach-omap2/Kconfig
> +++ b/arch/arm/mach-omap2/Kconfig
> @@ -335,6 +335,11 @@ config MACH_TI8148EVM
>  	depends on SOC_OMAPTI81XX
>  	default y
>  
> +config MACH_AM335XEVM
> +	bool "AM335X Evaluation Module"
> +	depends on SOC_OMAPAM33XX
> +	default y
> +
>  config MACH_OMAP_4430SDP
>  	bool "OMAP 4430 SDP board"
>  	default y
> diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile
> index c538b3e..d3c33df 100644
> --- a/arch/arm/mach-omap2/Makefile
> +++ b/arch/arm/mach-omap2/Makefile
> @@ -241,6 +241,7 @@ obj-$(CONFIG_MACH_CRANEBOARD)		+= board-am3517crane.o
>  obj-$(CONFIG_MACH_SBC3530)		+= board-omap3stalker.o
>  obj-$(CONFIG_MACH_TI8168EVM)		+= board-ti8168evm.o
>  obj-$(CONFIG_MACH_TI8148EVM)		+= board-ti8168evm.o
> +obj-$(CONFIG_MACH_AM335XEVM)		+= board-am335xevm.o
>  
>  # Platform specific device init code
>  
> diff --git a/arch/arm/mach-omap2/board-am335xevm.c b/arch/arm/mach-omap2/board-am335xevm.c
> new file mode 100644
> index 0000000..324752e
> --- /dev/null
> +++ b/arch/arm/mach-omap2/board-am335xevm.c
> @@ -0,0 +1,46 @@
> +/*
> + * board-am335xevm.c - support the TI AM335x EVM board
> + *
> + * Copyright (C) 2011-2012 Texas Instruments, Inc.
> + *
> + * 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 <mach/hardware.h>
> +#include <asm/mach-types.h>
> +#include <asm/mach/arch.h>
> +#include <asm/mach/map.h>
> +
> +#include <plat/board.h>
> +#include "common.h"
> +
> +static struct omap_board_config_kernel am335x_evm_config[] __initdata = {
> +};
> +
> +static void __init am335x_evm_init(void)
> +{
> +	omap_serial_init();
> +	omap_sdrc_init(NULL, NULL);
> +	omap_board_config = am335x_evm_config;
> +	omap_board_config_size = ARRAY_SIZE(am335x_evm_config);
> +}
> +
> +MACHINE_START(AM335XEVM, "am335xevm")
> +	/* Maintainer: Texas Instruments */
> +	.atag_offset	= 0x100,
> +	.map_io		= am33xx_map_io,
> +	.init_early	= am33xx_init_early,
> +	.init_irq	= ti81xx_init_irq,
> +	.timer		= &omap3_am33xx_timer,
> +	.init_machine	= am335x_evm_init,
> +MACHINE_END
> diff --git a/arch/arm/mach-omap2/common.h b/arch/arm/mach-omap2/common.h
> index 57da7f4..dae39a3 100644
> --- a/arch/arm/mach-omap2/common.h
> +++ b/arch/arm/mach-omap2/common.h
> @@ -83,6 +83,7 @@ extern void omap2_init_common_infrastructure(void);
>  extern struct sys_timer omap2_timer;
>  extern struct sys_timer omap3_timer;
>  extern struct sys_timer omap3_secure_timer;
> +extern struct sys_timer omap3_am33xx_timer;
>  extern struct sys_timer omap4_timer;
>  
>  void omap2420_init_early(void);
> @@ -94,6 +95,7 @@ void omap3_init_early(void);	/* Do not use this one */
>  void am35xx_init_early(void);
>  void ti81xx_init_early(void);
>  void omap4430_init_early(void);
> +void am33xx_init_early(void);
>  void omap_prcm_restart(char, const char *);
>  
>  /*
> diff --git a/arch/arm/mach-omap2/io.c b/arch/arm/mach-omap2/io.c
> index 065bd76..056db56 100644
> --- a/arch/arm/mach-omap2/io.c
> +++ b/arch/arm/mach-omap2/io.c
> @@ -466,6 +466,14 @@ void __init ti81xx_init_early(void)
>  	omap_hwmod_init_postsetup();
>  	omap3xxx_clk_init();
>  }
> +#endif /* CONFIG_ARCH_OMAP3 */
> +
> +#ifdef CONFIG_SOC_OMAPAM33XX
> +void __init am33xx_init_early(void)
> +{
> +	omap2_set_globals_am33xx();
> +	omap_common_init_early();
> +}
>  #endif
>  
>  #ifdef CONFIG_ARCH_OMAP4
> diff --git a/arch/arm/mach-omap2/timer.c b/arch/arm/mach-omap2/timer.c
> index c512bac..b2f747b 100644
> --- a/arch/arm/mach-omap2/timer.c
> +++ b/arch/arm/mach-omap2/timer.c
> @@ -321,6 +321,8 @@ OMAP_SYS_TIMER(3)
>  OMAP_SYS_TIMER_INIT(3_secure, OMAP3_SECURE_TIMER, OMAP3_CLKEV_SOURCE,
>  			2, OMAP3_MPU_SOURCE)
>  OMAP_SYS_TIMER(3_secure)
> +OMAP_SYS_TIMER_INIT(3_am33xx, 1, OMAP4_MPU_SOURCE, 2, OMAP4_MPU_SOURCE)
> +OMAP_SYS_TIMER(3_am33xx)
>  #endif
>  
>  #ifdef CONFIG_ARCH_OMAP4
> -- 
> 1.7.10
> 
> 

^ permalink raw reply	[flat|nested] 263+ messages in thread

* Re: [PATCH-V5 2/3] arm:omap:am33xx: Add AM335XEVM machine support
  2012-05-02  9:34     ` Hiremath, Vaibhav
@ 2012-05-03 15:57       ` Tony Lindgren
  -1 siblings, 0 replies; 263+ messages in thread
From: Tony Lindgren @ 2012-05-03 15:57 UTC (permalink / raw)
  To: Hiremath, Vaibhav
  Cc: Paul Walmsley, linux-omap, Hilman, Kevin, linux-arm-kernel,
	Mohammed, Afzal

Hi,

* Hiremath, Vaibhav <hvaibhav@ti.com> [120502 02:37]:
> On Wed, May 02, 2012 at 14:53:24, Paul Walmsley wrote:
> > Hi
> > 
> > On Fri, 2 Dec 2011, hvaibhav@ti.com wrote:
> > 
> > > From: Afzal Mohammed <afzal@ti.com>
> > > 
> > > This patch adds minimal support for AM335X EVM.
> > > The approach taken here is to add AM335X EVM support
> > > to AM3517EVM, considering the fact that with device tree
> > > developement we will get rid of board-*.c.
> > > 
> > > Signed-off-by: Afzal Mohammed <afzal@ti.com>
> > > Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
> > > Reviewed-by: Kevin Hilman <khilman@ti.com>
> > 
> > I realize people may not necessarily like this, but I think that the 
> > AM33xx EVM needs its own board file.  This is because it really has 
> > nothing to do with the AM3517EVM.  Also, the AM3517EVM depends on 
> > CONFIG_ARCH_OMAP3, but the AM33xx EVM should not: it should depend on 
> > either CONFIG_ARCH_OMAPAM33XX, or CONFIG_ARCH_OMAP4.

I guess adding CONFIG_SOC_AM33XX makes sense if it does not share anything
except core with omap3. And the SOC is independent of the core selected,
there is no dependency between SoC and the core.

Note that we have CONFIG_ARCH_OMAP2PLUS, all the other ones should be just
CONFIG_SOC_XXX. As all omap3 omap4 and am33xx are v7, there's no need to
compile with different flags either.
 
> > So the following modification of this patch opts for the former Kconfig 
> > option, CONFIG_ARCH_OMAPAM33XX.  It also adds a new, minimal board file 
> > for the AM33xx EVM.  

Sorry, no more new board files. Please make it device tree only then.

> > If, on the other hand, people want to use CONFIG_ARCH_OMAP4 instead for 
> > the AM33xx, then we could potentially add the new machine record into 
> > board-omap4panda.c.  Although even then, if political considerations were 
> > set aside, the best technical decision would probably be to create a 
> > separate board file, since the boards don't have much in common.
> > 
> > 
> Paul,
> I completely agree with all of your comments, let Tony comment and conform 
> on this. 
> If you go back to history, that was our initial proposal, to create
> separate Kconfig option for AM33XX.
> 
> Tony,
> 
> Can you please comment on this discussion? This is very important, since 
> lots of patches (accepted or about to accept) are dependent on this. The 
> early we can conclude on this, early I can rework on the patches and 
> resubmit them.

Yes, please do. Also note that if this means sprinkling tons of cpu_is_omapxxx
all over the code, we need to find a cleaner solution.

Regards,

Tony

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [PATCH-V5 2/3] arm:omap:am33xx: Add AM335XEVM machine support
@ 2012-05-03 15:57       ` Tony Lindgren
  0 siblings, 0 replies; 263+ messages in thread
From: Tony Lindgren @ 2012-05-03 15:57 UTC (permalink / raw)
  To: linux-arm-kernel

Hi,

* Hiremath, Vaibhav <hvaibhav@ti.com> [120502 02:37]:
> On Wed, May 02, 2012 at 14:53:24, Paul Walmsley wrote:
> > Hi
> > 
> > On Fri, 2 Dec 2011, hvaibhav at ti.com wrote:
> > 
> > > From: Afzal Mohammed <afzal@ti.com>
> > > 
> > > This patch adds minimal support for AM335X EVM.
> > > The approach taken here is to add AM335X EVM support
> > > to AM3517EVM, considering the fact that with device tree
> > > developement we will get rid of board-*.c.
> > > 
> > > Signed-off-by: Afzal Mohammed <afzal@ti.com>
> > > Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
> > > Reviewed-by: Kevin Hilman <khilman@ti.com>
> > 
> > I realize people may not necessarily like this, but I think that the 
> > AM33xx EVM needs its own board file.  This is because it really has 
> > nothing to do with the AM3517EVM.  Also, the AM3517EVM depends on 
> > CONFIG_ARCH_OMAP3, but the AM33xx EVM should not: it should depend on 
> > either CONFIG_ARCH_OMAPAM33XX, or CONFIG_ARCH_OMAP4.

I guess adding CONFIG_SOC_AM33XX makes sense if it does not share anything
except core with omap3. And the SOC is independent of the core selected,
there is no dependency between SoC and the core.

Note that we have CONFIG_ARCH_OMAP2PLUS, all the other ones should be just
CONFIG_SOC_XXX. As all omap3 omap4 and am33xx are v7, there's no need to
compile with different flags either.
 
> > So the following modification of this patch opts for the former Kconfig 
> > option, CONFIG_ARCH_OMAPAM33XX.  It also adds a new, minimal board file 
> > for the AM33xx EVM.  

Sorry, no more new board files. Please make it device tree only then.

> > If, on the other hand, people want to use CONFIG_ARCH_OMAP4 instead for 
> > the AM33xx, then we could potentially add the new machine record into 
> > board-omap4panda.c.  Although even then, if political considerations were 
> > set aside, the best technical decision would probably be to create a 
> > separate board file, since the boards don't have much in common.
> > 
> > 
> Paul,
> I completely agree with all of your comments, let Tony comment and conform 
> on this. 
> If you go back to history, that was our initial proposal, to create
> separate Kconfig option for AM33XX.
> 
> Tony,
> 
> Can you please comment on this discussion? This is very important, since 
> lots of patches (accepted or about to accept) are dependent on this. The 
> early we can conclude on this, early I can rework on the patches and 
> resubmit them.

Yes, please do. Also note that if this means sprinkling tons of cpu_is_omapxxx
all over the code, we need to find a cleaner solution.

Regards,

Tony

^ permalink raw reply	[flat|nested] 263+ messages in thread

* RE: [PATCH-V5 2/3] arm:omap:am33xx: Add AM335XEVM machine support
  2012-05-03 15:57       ` Tony Lindgren
@ 2012-05-03 16:41         ` Hiremath, Vaibhav
  -1 siblings, 0 replies; 263+ messages in thread
From: Hiremath, Vaibhav @ 2012-05-03 16:41 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: Paul Walmsley, linux-omap, Hilman, Kevin, linux-arm-kernel,
	Mohammed, Afzal

On Thu, May 03, 2012 at 21:27:18, Tony Lindgren wrote:
> Hi,
> 
> * Hiremath, Vaibhav <hvaibhav@ti.com> [120502 02:37]:
> > On Wed, May 02, 2012 at 14:53:24, Paul Walmsley wrote:
> > > Hi
> > > 
> > > On Fri, 2 Dec 2011, hvaibhav@ti.com wrote:
> > > 
> > > > From: Afzal Mohammed <afzal@ti.com>
> > > > 
> > > > This patch adds minimal support for AM335X EVM.
> > > > The approach taken here is to add AM335X EVM support
> > > > to AM3517EVM, considering the fact that with device tree
> > > > developement we will get rid of board-*.c.
> > > > 
> > > > Signed-off-by: Afzal Mohammed <afzal@ti.com>
> > > > Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
> > > > Reviewed-by: Kevin Hilman <khilman@ti.com>
> > > 
> > > I realize people may not necessarily like this, but I think that the 
> > > AM33xx EVM needs its own board file.  This is because it really has 
> > > nothing to do with the AM3517EVM.  Also, the AM3517EVM depends on 
> > > CONFIG_ARCH_OMAP3, but the AM33xx EVM should not: it should depend on 
> > > either CONFIG_ARCH_OMAPAM33XX, or CONFIG_ARCH_OMAP4.
> 
> I guess adding CONFIG_SOC_AM33XX makes sense if it does not share anything
> except core with omap3. And the SOC is independent of the core selected,
> there is no dependency between SoC and the core.
> 
> Note that we have CONFIG_ARCH_OMAP2PLUS, all the other ones should be just
> CONFIG_SOC_XXX. As all omap3 omap4 and am33xx are v7, there's no need to
> compile with different flags either.
>  

What about cpu_is_omap34xx() true for am33xx? Should we follow it?


Thanks,
Vaibhav

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [PATCH-V5 2/3] arm:omap:am33xx: Add AM335XEVM machine support
@ 2012-05-03 16:41         ` Hiremath, Vaibhav
  0 siblings, 0 replies; 263+ messages in thread
From: Hiremath, Vaibhav @ 2012-05-03 16:41 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, May 03, 2012 at 21:27:18, Tony Lindgren wrote:
> Hi,
> 
> * Hiremath, Vaibhav <hvaibhav@ti.com> [120502 02:37]:
> > On Wed, May 02, 2012 at 14:53:24, Paul Walmsley wrote:
> > > Hi
> > > 
> > > On Fri, 2 Dec 2011, hvaibhav at ti.com wrote:
> > > 
> > > > From: Afzal Mohammed <afzal@ti.com>
> > > > 
> > > > This patch adds minimal support for AM335X EVM.
> > > > The approach taken here is to add AM335X EVM support
> > > > to AM3517EVM, considering the fact that with device tree
> > > > developement we will get rid of board-*.c.
> > > > 
> > > > Signed-off-by: Afzal Mohammed <afzal@ti.com>
> > > > Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
> > > > Reviewed-by: Kevin Hilman <khilman@ti.com>
> > > 
> > > I realize people may not necessarily like this, but I think that the 
> > > AM33xx EVM needs its own board file.  This is because it really has 
> > > nothing to do with the AM3517EVM.  Also, the AM3517EVM depends on 
> > > CONFIG_ARCH_OMAP3, but the AM33xx EVM should not: it should depend on 
> > > either CONFIG_ARCH_OMAPAM33XX, or CONFIG_ARCH_OMAP4.
> 
> I guess adding CONFIG_SOC_AM33XX makes sense if it does not share anything
> except core with omap3. And the SOC is independent of the core selected,
> there is no dependency between SoC and the core.
> 
> Note that we have CONFIG_ARCH_OMAP2PLUS, all the other ones should be just
> CONFIG_SOC_XXX. As all omap3 omap4 and am33xx are v7, there's no need to
> compile with different flags either.
>  

What about cpu_is_omap34xx() true for am33xx? Should we follow it?


Thanks,
Vaibhav

^ permalink raw reply	[flat|nested] 263+ messages in thread

* Re: [PATCH-V5 2/3] arm:omap:am33xx: Add AM335XEVM machine support
  2012-05-03 16:41         ` Hiremath, Vaibhav
@ 2012-05-03 19:37           ` Tony Lindgren
  -1 siblings, 0 replies; 263+ messages in thread
From: Tony Lindgren @ 2012-05-03 19:37 UTC (permalink / raw)
  To: Hiremath, Vaibhav
  Cc: Paul Walmsley, linux-omap, Hilman, Kevin, linux-arm-kernel,
	Mohammed, Afzal

* Hiremath, Vaibhav <hvaibhav@ti.com> [120503 09:45]:
> 
> What about cpu_is_omap34xx() true for am33xx? Should we follow it?

Well are there components that could be used as is with that?
If not, then it probably does not make sense.

BTW, you should post your patches on top of the clean-up patches
Santosh posted as that already leaves out some cpu_is_omapxxxx
checks. That's the "ARM: OMAP2+: Misc cleanup" thread.

Regards,

Tony

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [PATCH-V5 2/3] arm:omap:am33xx: Add AM335XEVM machine support
@ 2012-05-03 19:37           ` Tony Lindgren
  0 siblings, 0 replies; 263+ messages in thread
From: Tony Lindgren @ 2012-05-03 19:37 UTC (permalink / raw)
  To: linux-arm-kernel

* Hiremath, Vaibhav <hvaibhav@ti.com> [120503 09:45]:
> 
> What about cpu_is_omap34xx() true for am33xx? Should we follow it?

Well are there components that could be used as is with that?
If not, then it probably does not make sense.

BTW, you should post your patches on top of the clean-up patches
Santosh posted as that already leaves out some cpu_is_omapxxxx
checks. That's the "ARM: OMAP2+: Misc cleanup" thread.

Regards,

Tony

^ permalink raw reply	[flat|nested] 263+ messages in thread

* Re: [PATCH-V5 2/3] arm:omap:am33xx: Add AM335XEVM machine support
  2012-05-03 16:41         ` Hiremath, Vaibhav
@ 2012-05-03 21:17           ` Kevin Hilman
  -1 siblings, 0 replies; 263+ messages in thread
From: Kevin Hilman @ 2012-05-03 21:17 UTC (permalink / raw)
  To: Hiremath, Vaibhav
  Cc: Tony Lindgren, Paul Walmsley, linux-omap, linux-arm-kernel,
	Mohammed, Afzal

"Hiremath, Vaibhav" <hvaibhav@ti.com> writes:

> On Thu, May 03, 2012 at 21:27:18, Tony Lindgren wrote:
>> Hi,
>> 
>> * Hiremath, Vaibhav <hvaibhav@ti.com> [120502 02:37]:
>> > On Wed, May 02, 2012 at 14:53:24, Paul Walmsley wrote:
>> > > Hi
>> > > 
>> > > On Fri, 2 Dec 2011, hvaibhav@ti.com wrote:
>> > > 
>> > > > From: Afzal Mohammed <afzal@ti.com>
>> > > > 
>> > > > This patch adds minimal support for AM335X EVM.
>> > > > The approach taken here is to add AM335X EVM support
>> > > > to AM3517EVM, considering the fact that with device tree
>> > > > developement we will get rid of board-*.c.
>> > > > 
>> > > > Signed-off-by: Afzal Mohammed <afzal@ti.com>
>> > > > Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
>> > > > Reviewed-by: Kevin Hilman <khilman@ti.com>
>> > > 
>> > > I realize people may not necessarily like this, but I think that the 
>> > > AM33xx EVM needs its own board file.  This is because it really has 
>> > > nothing to do with the AM3517EVM.  Also, the AM3517EVM depends on 
>> > > CONFIG_ARCH_OMAP3, but the AM33xx EVM should not: it should depend on 
>> > > either CONFIG_ARCH_OMAPAM33XX, or CONFIG_ARCH_OMAP4.
>> 
>> I guess adding CONFIG_SOC_AM33XX makes sense if it does not share anything
>> except core with omap3. And the SOC is independent of the core selected,
>> there is no dependency between SoC and the core.
>> 
>> Note that we have CONFIG_ARCH_OMAP2PLUS, all the other ones should be just
>> CONFIG_SOC_XXX. As all omap3 omap4 and am33xx are v7, there's no need to
>> compile with different flags either.
>>  
>
> What about cpu_is_omap34xx() true for am33xx? Should we follow it?

Please, no.

I've already demonstrated that that is not necessary and only leads to
confusion and maintenance headaches.

Kevin

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [PATCH-V5 2/3] arm:omap:am33xx: Add AM335XEVM machine support
@ 2012-05-03 21:17           ` Kevin Hilman
  0 siblings, 0 replies; 263+ messages in thread
From: Kevin Hilman @ 2012-05-03 21:17 UTC (permalink / raw)
  To: linux-arm-kernel

"Hiremath, Vaibhav" <hvaibhav@ti.com> writes:

> On Thu, May 03, 2012 at 21:27:18, Tony Lindgren wrote:
>> Hi,
>> 
>> * Hiremath, Vaibhav <hvaibhav@ti.com> [120502 02:37]:
>> > On Wed, May 02, 2012 at 14:53:24, Paul Walmsley wrote:
>> > > Hi
>> > > 
>> > > On Fri, 2 Dec 2011, hvaibhav at ti.com wrote:
>> > > 
>> > > > From: Afzal Mohammed <afzal@ti.com>
>> > > > 
>> > > > This patch adds minimal support for AM335X EVM.
>> > > > The approach taken here is to add AM335X EVM support
>> > > > to AM3517EVM, considering the fact that with device tree
>> > > > developement we will get rid of board-*.c.
>> > > > 
>> > > > Signed-off-by: Afzal Mohammed <afzal@ti.com>
>> > > > Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
>> > > > Reviewed-by: Kevin Hilman <khilman@ti.com>
>> > > 
>> > > I realize people may not necessarily like this, but I think that the 
>> > > AM33xx EVM needs its own board file.  This is because it really has 
>> > > nothing to do with the AM3517EVM.  Also, the AM3517EVM depends on 
>> > > CONFIG_ARCH_OMAP3, but the AM33xx EVM should not: it should depend on 
>> > > either CONFIG_ARCH_OMAPAM33XX, or CONFIG_ARCH_OMAP4.
>> 
>> I guess adding CONFIG_SOC_AM33XX makes sense if it does not share anything
>> except core with omap3. And the SOC is independent of the core selected,
>> there is no dependency between SoC and the core.
>> 
>> Note that we have CONFIG_ARCH_OMAP2PLUS, all the other ones should be just
>> CONFIG_SOC_XXX. As all omap3 omap4 and am33xx are v7, there's no need to
>> compile with different flags either.
>>  
>
> What about cpu_is_omap34xx() true for am33xx? Should we follow it?

Please, no.

I've already demonstrated that that is not necessary and only leads to
confusion and maintenance headaches.

Kevin

^ permalink raw reply	[flat|nested] 263+ messages in thread

* RE: [PATCH-V5 2/3] arm:omap:am33xx: Add AM335XEVM machine support
  2012-05-03 21:17           ` Kevin Hilman
@ 2012-05-04  6:00             ` Hiremath, Vaibhav
  -1 siblings, 0 replies; 263+ messages in thread
From: Hiremath, Vaibhav @ 2012-05-04  6:00 UTC (permalink / raw)
  To: Hilman, Kevin
  Cc: Tony Lindgren, Paul Walmsley, linux-omap, linux-arm-kernel,
	Mohammed, Afzal

On Fri, May 04, 2012 at 02:47:34, Hilman, Kevin wrote:
> "Hiremath, Vaibhav" <hvaibhav@ti.com> writes:
> 
> > On Thu, May 03, 2012 at 21:27:18, Tony Lindgren wrote:
> >> Hi,
> >> 
> >> * Hiremath, Vaibhav <hvaibhav@ti.com> [120502 02:37]:
> >> > On Wed, May 02, 2012 at 14:53:24, Paul Walmsley wrote:
> >> > > Hi
> >> > > 
> >> > > On Fri, 2 Dec 2011, hvaibhav@ti.com wrote:
> >> > > 
> >> > > > From: Afzal Mohammed <afzal@ti.com>
> >> > > > 
> >> > > > This patch adds minimal support for AM335X EVM.
> >> > > > The approach taken here is to add AM335X EVM support
> >> > > > to AM3517EVM, considering the fact that with device tree
> >> > > > developement we will get rid of board-*.c.
> >> > > > 
> >> > > > Signed-off-by: Afzal Mohammed <afzal@ti.com>
> >> > > > Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
> >> > > > Reviewed-by: Kevin Hilman <khilman@ti.com>
> >> > > 
> >> > > I realize people may not necessarily like this, but I think that the 
> >> > > AM33xx EVM needs its own board file.  This is because it really has 
> >> > > nothing to do with the AM3517EVM.  Also, the AM3517EVM depends on 
> >> > > CONFIG_ARCH_OMAP3, but the AM33xx EVM should not: it should depend on 
> >> > > either CONFIG_ARCH_OMAPAM33XX, or CONFIG_ARCH_OMAP4.
> >> 
> >> I guess adding CONFIG_SOC_AM33XX makes sense if it does not share anything
> >> except core with omap3. And the SOC is independent of the core selected,
> >> there is no dependency between SoC and the core.
> >> 
> >> Note that we have CONFIG_ARCH_OMAP2PLUS, all the other ones should be just
> >> CONFIG_SOC_XXX. As all omap3 omap4 and am33xx are v7, there's no need to
> >> compile with different flags either.
> >>  
> >
> > What about cpu_is_omap34xx() true for am33xx? Should we follow it?
> 
> Please, no.
> 
> I've already demonstrated that that is not necessary and only leads to
> confusion and maintenance headaches.
> 

That's what I was expecting...

Probably last question where I have confusion,

Tony, seems to be against adding new ARCH_OMAPAM33XX, but which _ARCH_ we need to follow for AM33XX?
I have to choose between ARCH_OMAP3 or ARCH_OMAP4 and what should I choose 
here?

Does it make sense to follow ARCH_OMAPx but not follow cpu_is_omapxxx()?
OR
Should we create ARCH_AMXXXX, assuming that all AM devices have similar 
memory map layout, interrupt mapping, etc...
OR
Should I just add SOC_OMAPAM33XX, wherever required?


Also, there are lot of thing wrapped under ARCH_OMAP3 || ARCH_OMAP4 option, which is required for AM33XX, how should we handle this?

For example,

"arch/arm/plat-omap/include/plat/clock.h"
struct dpll_data {
#if defined(CONFIG_ARCH_OMAP3) || defined(CONFIG_ARCH_OMAP4)
	<dpll related variables>
#endif
};

"arch/arm/mach-omap2/clock.c"

#if defined(CONFIG_ARCH_OMAP3) || defined(CONFIG_ARCH_OMAP4)

const struct clkops clkops_omap3_noncore_dpll_ops = {
};
const struct clkops clkops_omap3_core_dpll_ops = {
}




^ permalink raw reply	[flat|nested] 263+ messages in thread

* [PATCH-V5 2/3] arm:omap:am33xx: Add AM335XEVM machine support
@ 2012-05-04  6:00             ` Hiremath, Vaibhav
  0 siblings, 0 replies; 263+ messages in thread
From: Hiremath, Vaibhav @ 2012-05-04  6:00 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, May 04, 2012 at 02:47:34, Hilman, Kevin wrote:
> "Hiremath, Vaibhav" <hvaibhav@ti.com> writes:
> 
> > On Thu, May 03, 2012 at 21:27:18, Tony Lindgren wrote:
> >> Hi,
> >> 
> >> * Hiremath, Vaibhav <hvaibhav@ti.com> [120502 02:37]:
> >> > On Wed, May 02, 2012 at 14:53:24, Paul Walmsley wrote:
> >> > > Hi
> >> > > 
> >> > > On Fri, 2 Dec 2011, hvaibhav at ti.com wrote:
> >> > > 
> >> > > > From: Afzal Mohammed <afzal@ti.com>
> >> > > > 
> >> > > > This patch adds minimal support for AM335X EVM.
> >> > > > The approach taken here is to add AM335X EVM support
> >> > > > to AM3517EVM, considering the fact that with device tree
> >> > > > developement we will get rid of board-*.c.
> >> > > > 
> >> > > > Signed-off-by: Afzal Mohammed <afzal@ti.com>
> >> > > > Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
> >> > > > Reviewed-by: Kevin Hilman <khilman@ti.com>
> >> > > 
> >> > > I realize people may not necessarily like this, but I think that the 
> >> > > AM33xx EVM needs its own board file.  This is because it really has 
> >> > > nothing to do with the AM3517EVM.  Also, the AM3517EVM depends on 
> >> > > CONFIG_ARCH_OMAP3, but the AM33xx EVM should not: it should depend on 
> >> > > either CONFIG_ARCH_OMAPAM33XX, or CONFIG_ARCH_OMAP4.
> >> 
> >> I guess adding CONFIG_SOC_AM33XX makes sense if it does not share anything
> >> except core with omap3. And the SOC is independent of the core selected,
> >> there is no dependency between SoC and the core.
> >> 
> >> Note that we have CONFIG_ARCH_OMAP2PLUS, all the other ones should be just
> >> CONFIG_SOC_XXX. As all omap3 omap4 and am33xx are v7, there's no need to
> >> compile with different flags either.
> >>  
> >
> > What about cpu_is_omap34xx() true for am33xx? Should we follow it?
> 
> Please, no.
> 
> I've already demonstrated that that is not necessary and only leads to
> confusion and maintenance headaches.
> 

That's what I was expecting...

Probably last question where I have confusion,

Tony, seems to be against adding new ARCH_OMAPAM33XX, but which _ARCH_ we need to follow for AM33XX?
I have to choose between ARCH_OMAP3 or ARCH_OMAP4 and what should I choose 
here?

Does it make sense to follow ARCH_OMAPx but not follow cpu_is_omapxxx()?
OR
Should we create ARCH_AMXXXX, assuming that all AM devices have similar 
memory map layout, interrupt mapping, etc...
OR
Should I just add SOC_OMAPAM33XX, wherever required?


Also, there are lot of thing wrapped under ARCH_OMAP3 || ARCH_OMAP4 option, which is required for AM33XX, how should we handle this?

For example,

"arch/arm/plat-omap/include/plat/clock.h"
struct dpll_data {
#if defined(CONFIG_ARCH_OMAP3) || defined(CONFIG_ARCH_OMAP4)
	<dpll related variables>
#endif
};

"arch/arm/mach-omap2/clock.c"

#if defined(CONFIG_ARCH_OMAP3) || defined(CONFIG_ARCH_OMAP4)

const struct clkops clkops_omap3_noncore_dpll_ops = {
};
const struct clkops clkops_omap3_core_dpll_ops = {
}

^ permalink raw reply	[flat|nested] 263+ messages in thread

* RE: [PATCH-V5 2/3] arm:omap:am33xx: Add AM335XEVM machine support
  2012-05-03 19:37           ` Tony Lindgren
@ 2012-05-04  6:14             ` Hiremath, Vaibhav
  -1 siblings, 0 replies; 263+ messages in thread
From: Hiremath, Vaibhav @ 2012-05-04  6:14 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: Hilman, Kevin, Paul Walmsley, linux-omap, Mohammed, Afzal,
	linux-arm-kernel

On Fri, May 04, 2012 at 01:07:32, Tony Lindgren wrote:
> * Hiremath, Vaibhav <hvaibhav@ti.com> [120503 09:45]:
> > 
> > What about cpu_is_omap34xx() true for am33xx? Should we follow it?
> 
> Well are there components that could be used as is with that?
> If not, then it probably does not make sense.
> 

I am also in favor of not following cpu_is_omap34xx() for am33xx, but what about ARCH_OMAP?
I don't see that you are in agreement in creating ARCH_OMAPAM33XX. 
Does it make sense to say that, for am33xx, cpu_is_omap34xx() is false, but still it is under ARCH_OMAP3?


> BTW, you should post your patches on top of the clean-up patches
> Santosh posted as that already leaves out some cpu_is_omapxxxx
> checks. That's the "ARM: OMAP2+: Misc cleanup" thread.
> 

Ok. I will do that.

Thanks,
Vaibhav

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [PATCH-V5 2/3] arm:omap:am33xx: Add AM335XEVM machine support
@ 2012-05-04  6:14             ` Hiremath, Vaibhav
  0 siblings, 0 replies; 263+ messages in thread
From: Hiremath, Vaibhav @ 2012-05-04  6:14 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, May 04, 2012 at 01:07:32, Tony Lindgren wrote:
> * Hiremath, Vaibhav <hvaibhav@ti.com> [120503 09:45]:
> > 
> > What about cpu_is_omap34xx() true for am33xx? Should we follow it?
> 
> Well are there components that could be used as is with that?
> If not, then it probably does not make sense.
> 

I am also in favor of not following cpu_is_omap34xx() for am33xx, but what about ARCH_OMAP?
I don't see that you are in agreement in creating ARCH_OMAPAM33XX. 
Does it make sense to say that, for am33xx, cpu_is_omap34xx() is false, but still it is under ARCH_OMAP3?


> BTW, you should post your patches on top of the clean-up patches
> Santosh posted as that already leaves out some cpu_is_omapxxxx
> checks. That's the "ARM: OMAP2+: Misc cleanup" thread.
> 

Ok. I will do that.

Thanks,
Vaibhav

^ permalink raw reply	[flat|nested] 263+ messages in thread

* RE: [PATCH-V5 2/3] arm:omap:am33xx: Add AM335XEVM machine support
  2012-05-03 15:57       ` Tony Lindgren
@ 2012-05-04  6:28         ` Hiremath, Vaibhav
  -1 siblings, 0 replies; 263+ messages in thread
From: Hiremath, Vaibhav @ 2012-05-04  6:28 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: Paul Walmsley, linux-omap, Hilman, Kevin, linux-arm-kernel,
	Mohammed, Afzal

On Thu, May 03, 2012 at 21:27:18, Tony Lindgren wrote:
> Hi,
> 
> * Hiremath, Vaibhav <hvaibhav@ti.com> [120502 02:37]:
> > On Wed, May 02, 2012 at 14:53:24, Paul Walmsley wrote:
> > > Hi
> > > 
> > > On Fri, 2 Dec 2011, hvaibhav@ti.com wrote:
> > > 
> > > > From: Afzal Mohammed <afzal@ti.com>
> > > > 
> > > > This patch adds minimal support for AM335X EVM.
> > > > The approach taken here is to add AM335X EVM support
> > > > to AM3517EVM, considering the fact that with device tree
> > > > developement we will get rid of board-*.c.
> > > > 
> > > > Signed-off-by: Afzal Mohammed <afzal@ti.com>
> > > > Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
> > > > Reviewed-by: Kevin Hilman <khilman@ti.com>
> > > 
> > > I realize people may not necessarily like this, but I think that the 
> > > AM33xx EVM needs its own board file.  This is because it really has 
> > > nothing to do with the AM3517EVM.  Also, the AM3517EVM depends on 
> > > CONFIG_ARCH_OMAP3, but the AM33xx EVM should not: it should depend on 
> > > either CONFIG_ARCH_OMAPAM33XX, or CONFIG_ARCH_OMAP4.
> 
> I guess adding CONFIG_SOC_AM33XX makes sense if it does not share anything
> except core with omap3. And the SOC is independent of the core selected,
> there is no dependency between SoC and the core.
> 
> Note that we have CONFIG_ARCH_OMAP2PLUS, all the other ones should be just
> CONFIG_SOC_XXX. As all omap3 omap4 and am33xx are v7, there's no need to
> compile with different flags either.
>  

But still we do have ARCH_OMAP2, ARCH_OMAP3 and ARCH_OMAP4? And that's where, 
we have issues for adding new devices like AM33xx and TI81xx.

Thanks,
Vaibhav

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [PATCH-V5 2/3] arm:omap:am33xx: Add AM335XEVM machine support
@ 2012-05-04  6:28         ` Hiremath, Vaibhav
  0 siblings, 0 replies; 263+ messages in thread
From: Hiremath, Vaibhav @ 2012-05-04  6:28 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, May 03, 2012 at 21:27:18, Tony Lindgren wrote:
> Hi,
> 
> * Hiremath, Vaibhav <hvaibhav@ti.com> [120502 02:37]:
> > On Wed, May 02, 2012 at 14:53:24, Paul Walmsley wrote:
> > > Hi
> > > 
> > > On Fri, 2 Dec 2011, hvaibhav at ti.com wrote:
> > > 
> > > > From: Afzal Mohammed <afzal@ti.com>
> > > > 
> > > > This patch adds minimal support for AM335X EVM.
> > > > The approach taken here is to add AM335X EVM support
> > > > to AM3517EVM, considering the fact that with device tree
> > > > developement we will get rid of board-*.c.
> > > > 
> > > > Signed-off-by: Afzal Mohammed <afzal@ti.com>
> > > > Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
> > > > Reviewed-by: Kevin Hilman <khilman@ti.com>
> > > 
> > > I realize people may not necessarily like this, but I think that the 
> > > AM33xx EVM needs its own board file.  This is because it really has 
> > > nothing to do with the AM3517EVM.  Also, the AM3517EVM depends on 
> > > CONFIG_ARCH_OMAP3, but the AM33xx EVM should not: it should depend on 
> > > either CONFIG_ARCH_OMAPAM33XX, or CONFIG_ARCH_OMAP4.
> 
> I guess adding CONFIG_SOC_AM33XX makes sense if it does not share anything
> except core with omap3. And the SOC is independent of the core selected,
> there is no dependency between SoC and the core.
> 
> Note that we have CONFIG_ARCH_OMAP2PLUS, all the other ones should be just
> CONFIG_SOC_XXX. As all omap3 omap4 and am33xx are v7, there's no need to
> compile with different flags either.
>  

But still we do have ARCH_OMAP2, ARCH_OMAP3 and ARCH_OMAP4? And that's where, 
we have issues for adding new devices like AM33xx and TI81xx.

Thanks,
Vaibhav

^ permalink raw reply	[flat|nested] 263+ messages in thread

* Re: [PATCH-V5 2/3] arm:omap:am33xx: Add AM335XEVM machine support
  2012-05-04  6:28         ` Hiremath, Vaibhav
@ 2012-05-04 20:00           ` Tony Lindgren
  -1 siblings, 0 replies; 263+ messages in thread
From: Tony Lindgren @ 2012-05-04 20:00 UTC (permalink / raw)
  To: Hiremath, Vaibhav
  Cc: Paul Walmsley, linux-omap, Hilman, Kevin, linux-arm-kernel,
	Mohammed, Afzal

* Hiremath, Vaibhav <hvaibhav@ti.com> [120503 23:31]:
> On Thu, May 03, 2012 at 21:27:18, Tony Lindgren wrote:
> > Hi,
> > 
> > * Hiremath, Vaibhav <hvaibhav@ti.com> [120502 02:37]:
> > > On Wed, May 02, 2012 at 14:53:24, Paul Walmsley wrote:
> > > > Hi
> > > > 
> > > > On Fri, 2 Dec 2011, hvaibhav@ti.com wrote:
> > > > 
> > > > > From: Afzal Mohammed <afzal@ti.com>
> > > > > 
> > > > > This patch adds minimal support for AM335X EVM.
> > > > > The approach taken here is to add AM335X EVM support
> > > > > to AM3517EVM, considering the fact that with device tree
> > > > > developement we will get rid of board-*.c.
> > > > > 
> > > > > Signed-off-by: Afzal Mohammed <afzal@ti.com>
> > > > > Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
> > > > > Reviewed-by: Kevin Hilman <khilman@ti.com>
> > > > 
> > > > I realize people may not necessarily like this, but I think that the 
> > > > AM33xx EVM needs its own board file.  This is because it really has 
> > > > nothing to do with the AM3517EVM.  Also, the AM3517EVM depends on 
> > > > CONFIG_ARCH_OMAP3, but the AM33xx EVM should not: it should depend on 
> > > > either CONFIG_ARCH_OMAPAM33XX, or CONFIG_ARCH_OMAP4.
> > 
> > I guess adding CONFIG_SOC_AM33XX makes sense if it does not share anything
> > except core with omap3. And the SOC is independent of the core selected,
> > there is no dependency between SoC and the core.
> > 
> > Note that we have CONFIG_ARCH_OMAP2PLUS, all the other ones should be just
> > CONFIG_SOC_XXX. As all omap3 omap4 and am33xx are v7, there's no need to
> > compile with different flags either.
> >  
> 
> But still we do have ARCH_OMAP2, ARCH_OMAP3 and ARCH_OMAP4? And that's where, 
> we have issues for adding new devices like AM33xx and TI81xx.

Those will be going away, but doing it has not been done because of the amount
of churn it creates. But if we add #define CONFIG_ARCH_OMAP3 CONFIG_SOC_OMAP3
we can do it piecemeal along with other cleanups.

Tony

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [PATCH-V5 2/3] arm:omap:am33xx: Add AM335XEVM machine support
@ 2012-05-04 20:00           ` Tony Lindgren
  0 siblings, 0 replies; 263+ messages in thread
From: Tony Lindgren @ 2012-05-04 20:00 UTC (permalink / raw)
  To: linux-arm-kernel

* Hiremath, Vaibhav <hvaibhav@ti.com> [120503 23:31]:
> On Thu, May 03, 2012 at 21:27:18, Tony Lindgren wrote:
> > Hi,
> > 
> > * Hiremath, Vaibhav <hvaibhav@ti.com> [120502 02:37]:
> > > On Wed, May 02, 2012 at 14:53:24, Paul Walmsley wrote:
> > > > Hi
> > > > 
> > > > On Fri, 2 Dec 2011, hvaibhav at ti.com wrote:
> > > > 
> > > > > From: Afzal Mohammed <afzal@ti.com>
> > > > > 
> > > > > This patch adds minimal support for AM335X EVM.
> > > > > The approach taken here is to add AM335X EVM support
> > > > > to AM3517EVM, considering the fact that with device tree
> > > > > developement we will get rid of board-*.c.
> > > > > 
> > > > > Signed-off-by: Afzal Mohammed <afzal@ti.com>
> > > > > Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
> > > > > Reviewed-by: Kevin Hilman <khilman@ti.com>
> > > > 
> > > > I realize people may not necessarily like this, but I think that the 
> > > > AM33xx EVM needs its own board file.  This is because it really has 
> > > > nothing to do with the AM3517EVM.  Also, the AM3517EVM depends on 
> > > > CONFIG_ARCH_OMAP3, but the AM33xx EVM should not: it should depend on 
> > > > either CONFIG_ARCH_OMAPAM33XX, or CONFIG_ARCH_OMAP4.
> > 
> > I guess adding CONFIG_SOC_AM33XX makes sense if it does not share anything
> > except core with omap3. And the SOC is independent of the core selected,
> > there is no dependency between SoC and the core.
> > 
> > Note that we have CONFIG_ARCH_OMAP2PLUS, all the other ones should be just
> > CONFIG_SOC_XXX. As all omap3 omap4 and am33xx are v7, there's no need to
> > compile with different flags either.
> >  
> 
> But still we do have ARCH_OMAP2, ARCH_OMAP3 and ARCH_OMAP4? And that's where, 
> we have issues for adding new devices like AM33xx and TI81xx.

Those will be going away, but doing it has not been done because of the amount
of churn it creates. But if we add #define CONFIG_ARCH_OMAP3 CONFIG_SOC_OMAP3
we can do it piecemeal along with other cleanups.

Tony

^ permalink raw reply	[flat|nested] 263+ messages in thread

* Re: [PATCH-V5 2/3] arm:omap:am33xx: Add AM335XEVM machine support
  2012-05-04  6:00             ` Hiremath, Vaibhav
@ 2012-05-04 20:05               ` Tony Lindgren
  -1 siblings, 0 replies; 263+ messages in thread
From: Tony Lindgren @ 2012-05-04 20:05 UTC (permalink / raw)
  To: Hiremath, Vaibhav
  Cc: Hilman, Kevin, Paul Walmsley, linux-omap, linux-arm-kernel,
	Mohammed, Afzal

* Hiremath, Vaibhav <hvaibhav@ti.com> [120503 23:04]:
> 
> Tony, seems to be against adding new ARCH_OMAPAM33XX, but which _ARCH_ we need to follow for AM33XX?
> I have to choose between ARCH_OMAP3 or ARCH_OMAP4 and what should I choose 
> here?

I think you're getting confused now :) I'm against ARCH_XXX but I'm OK with
adding SOC_XXX.

We should only need ARCH_OMAP2PLUS + SOC_XXX, there should not be any need
to add new ARCH_XXX under mach-omap2. Whatever we have left for ARCH_OMAP
in mach-omap2 will be eventually converted to SOC_OMAP.
 
> Does it make sense to follow ARCH_OMAPx but not follow cpu_is_omapxxx()?
> OR

No

> Should we create ARCH_AMXXXX, assuming that all AM devices have similar 

No

> memory map layout, interrupt mapping, etc...
> OR
> Should I just add SOC_OMAPAM33XX, wherever required?

Yes, but how about just use SOC_AM33XX? 
 
> Also, there are lot of thing wrapped under ARCH_OMAP3 || ARCH_OMAP4 option, which is required for AM33XX, how should we handle this?
> 
> For example,
> 
> "arch/arm/plat-omap/include/plat/clock.h"
> struct dpll_data {
> #if defined(CONFIG_ARCH_OMAP3) || defined(CONFIG_ARCH_OMAP4)
> 	<dpll related variables>
> #endif
> };
> 
> "arch/arm/mach-omap2/clock.c"
> 
> #if defined(CONFIG_ARCH_OMAP3) || defined(CONFIG_ARCH_OMAP4)
> 
> const struct clkops clkops_omap3_noncore_dpll_ops = {
> };
> const struct clkops clkops_omap3_core_dpll_ops = {
> }

I suggest doing some clean-up patches before adding SOC_AM33XX where
you just convert those to be

#if defined(CONFIG_ARCH_OMAP2PLUS) && !defined(CONFIG_ARCH_OMAP2)

or something similar depending if they already are inside mach-omap2
directory. This will make them future proof for adding new SoCs
without having to patch all over the place.

Regards,

Tony

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [PATCH-V5 2/3] arm:omap:am33xx: Add AM335XEVM machine support
@ 2012-05-04 20:05               ` Tony Lindgren
  0 siblings, 0 replies; 263+ messages in thread
From: Tony Lindgren @ 2012-05-04 20:05 UTC (permalink / raw)
  To: linux-arm-kernel

* Hiremath, Vaibhav <hvaibhav@ti.com> [120503 23:04]:
> 
> Tony, seems to be against adding new ARCH_OMAPAM33XX, but which _ARCH_ we need to follow for AM33XX?
> I have to choose between ARCH_OMAP3 or ARCH_OMAP4 and what should I choose 
> here?

I think you're getting confused now :) I'm against ARCH_XXX but I'm OK with
adding SOC_XXX.

We should only need ARCH_OMAP2PLUS + SOC_XXX, there should not be any need
to add new ARCH_XXX under mach-omap2. Whatever we have left for ARCH_OMAP
in mach-omap2 will be eventually converted to SOC_OMAP.
 
> Does it make sense to follow ARCH_OMAPx but not follow cpu_is_omapxxx()?
> OR

No

> Should we create ARCH_AMXXXX, assuming that all AM devices have similar 

No

> memory map layout, interrupt mapping, etc...
> OR
> Should I just add SOC_OMAPAM33XX, wherever required?

Yes, but how about just use SOC_AM33XX? 
 
> Also, there are lot of thing wrapped under ARCH_OMAP3 || ARCH_OMAP4 option, which is required for AM33XX, how should we handle this?
> 
> For example,
> 
> "arch/arm/plat-omap/include/plat/clock.h"
> struct dpll_data {
> #if defined(CONFIG_ARCH_OMAP3) || defined(CONFIG_ARCH_OMAP4)
> 	<dpll related variables>
> #endif
> };
> 
> "arch/arm/mach-omap2/clock.c"
> 
> #if defined(CONFIG_ARCH_OMAP3) || defined(CONFIG_ARCH_OMAP4)
> 
> const struct clkops clkops_omap3_noncore_dpll_ops = {
> };
> const struct clkops clkops_omap3_core_dpll_ops = {
> }

I suggest doing some clean-up patches before adding SOC_AM33XX where
you just convert those to be

#if defined(CONFIG_ARCH_OMAP2PLUS) && !defined(CONFIG_ARCH_OMAP2)

or something similar depending if they already are inside mach-omap2
directory. This will make them future proof for adding new SoCs
without having to patch all over the place.

Regards,

Tony

^ permalink raw reply	[flat|nested] 263+ messages in thread

* RE: [PATCH-V5 2/3] arm:omap:am33xx: Add AM335XEVM machine support
  2012-05-04 20:05               ` Tony Lindgren
@ 2012-05-07 14:38                 ` Hiremath, Vaibhav
  -1 siblings, 0 replies; 263+ messages in thread
From: Hiremath, Vaibhav @ 2012-05-07 14:38 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: Hilman, Kevin, Paul Walmsley, linux-omap, linux-arm-kernel,
	Mohammed, Afzal

On Sat, May 05, 2012 at 01:35:47, Tony Lindgren wrote:
> * Hiremath, Vaibhav <hvaibhav@ti.com> [120503 23:04]:
> > 
> > Tony, seems to be against adding new ARCH_OMAPAM33XX, but which _ARCH_ we need to follow for AM33XX?
> > I have to choose between ARCH_OMAP3 or ARCH_OMAP4 and what should I choose 
> > here?
> 
> I think you're getting confused now :) I'm against ARCH_XXX but I'm OK with
> adding SOC_XXX.
> 
> We should only need ARCH_OMAP2PLUS + SOC_XXX, there should not be any need
> to add new ARCH_XXX under mach-omap2. Whatever we have left for ARCH_OMAP
> in mach-omap2 will be eventually converted to SOC_OMAP.
>  
> > Does it make sense to follow ARCH_OMAPx but not follow cpu_is_omapxxx()?
> > OR
> 
> No
> 
> > Should we create ARCH_AMXXXX, assuming that all AM devices have similar 
> 
> No
> 
> > memory map layout, interrupt mapping, etc...
> > OR
> > Should I just add SOC_OMAPAM33XX, wherever required?
> 
> Yes, but how about just use SOC_AM33XX? 
>  

I will submit patches shortly (in the last cleanup now), where for am33xx

 - cpu_is_omap34xx() will be false.

 - Only cpu_is_am33xx() will be true here.

 - Neither be under ARCH_OMAP3 nor ARCH_OMAP4, instead will be an 
   independent device under SOC_OMAPAM33XX.

This brings-in, some cleanup in existing code, which I will also submit 
shortly.


> > Also, there are lot of thing wrapped under ARCH_OMAP3 || ARCH_OMAP4 option, which is required for AM33XX, how should we handle this?
> > 
> > For example,
> > 
> > "arch/arm/plat-omap/include/plat/clock.h"
> > struct dpll_data {
> > #if defined(CONFIG_ARCH_OMAP3) || defined(CONFIG_ARCH_OMAP4)
> > 	<dpll related variables>
> > #endif
> > };
> > 
> > "arch/arm/mach-omap2/clock.c"
> > 
> > #if defined(CONFIG_ARCH_OMAP3) || defined(CONFIG_ARCH_OMAP4)
> > 
> > const struct clkops clkops_omap3_noncore_dpll_ops = {
> > };
> > const struct clkops clkops_omap3_core_dpll_ops = {
> > }
> 
> I suggest doing some clean-up patches before adding SOC_AM33XX where
> you just convert those to be
> 
> #if defined(CONFIG_ARCH_OMAP2PLUS) && !defined(CONFIG_ARCH_OMAP2)
> 
> or something similar depending if they already are inside mach-omap2
> directory. This will make them future proof for adding new SoCs
> without having to patch all over the place.
> 

Tony,

Cool, I also thought exactly same solution on this, but next thought came to 
my mind was, it won't scale up, since we still have dependency on ARCH_OMAP2 
option. However, it will be a good temporary solution for our problem, lets 
review them first (I will submit shortly).

Thanks,
Vaibhav

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [PATCH-V5 2/3] arm:omap:am33xx: Add AM335XEVM machine support
@ 2012-05-07 14:38                 ` Hiremath, Vaibhav
  0 siblings, 0 replies; 263+ messages in thread
From: Hiremath, Vaibhav @ 2012-05-07 14:38 UTC (permalink / raw)
  To: linux-arm-kernel

On Sat, May 05, 2012 at 01:35:47, Tony Lindgren wrote:
> * Hiremath, Vaibhav <hvaibhav@ti.com> [120503 23:04]:
> > 
> > Tony, seems to be against adding new ARCH_OMAPAM33XX, but which _ARCH_ we need to follow for AM33XX?
> > I have to choose between ARCH_OMAP3 or ARCH_OMAP4 and what should I choose 
> > here?
> 
> I think you're getting confused now :) I'm against ARCH_XXX but I'm OK with
> adding SOC_XXX.
> 
> We should only need ARCH_OMAP2PLUS + SOC_XXX, there should not be any need
> to add new ARCH_XXX under mach-omap2. Whatever we have left for ARCH_OMAP
> in mach-omap2 will be eventually converted to SOC_OMAP.
>  
> > Does it make sense to follow ARCH_OMAPx but not follow cpu_is_omapxxx()?
> > OR
> 
> No
> 
> > Should we create ARCH_AMXXXX, assuming that all AM devices have similar 
> 
> No
> 
> > memory map layout, interrupt mapping, etc...
> > OR
> > Should I just add SOC_OMAPAM33XX, wherever required?
> 
> Yes, but how about just use SOC_AM33XX? 
>  

I will submit patches shortly (in the last cleanup now), where for am33xx

 - cpu_is_omap34xx() will be false.

 - Only cpu_is_am33xx() will be true here.

 - Neither be under ARCH_OMAP3 nor ARCH_OMAP4, instead will be an 
   independent device under SOC_OMAPAM33XX.

This brings-in, some cleanup in existing code, which I will also submit 
shortly.


> > Also, there are lot of thing wrapped under ARCH_OMAP3 || ARCH_OMAP4 option, which is required for AM33XX, how should we handle this?
> > 
> > For example,
> > 
> > "arch/arm/plat-omap/include/plat/clock.h"
> > struct dpll_data {
> > #if defined(CONFIG_ARCH_OMAP3) || defined(CONFIG_ARCH_OMAP4)
> > 	<dpll related variables>
> > #endif
> > };
> > 
> > "arch/arm/mach-omap2/clock.c"
> > 
> > #if defined(CONFIG_ARCH_OMAP3) || defined(CONFIG_ARCH_OMAP4)
> > 
> > const struct clkops clkops_omap3_noncore_dpll_ops = {
> > };
> > const struct clkops clkops_omap3_core_dpll_ops = {
> > }
> 
> I suggest doing some clean-up patches before adding SOC_AM33XX where
> you just convert those to be
> 
> #if defined(CONFIG_ARCH_OMAP2PLUS) && !defined(CONFIG_ARCH_OMAP2)
> 
> or something similar depending if they already are inside mach-omap2
> directory. This will make them future proof for adding new SoCs
> without having to patch all over the place.
> 

Tony,

Cool, I also thought exactly same solution on this, but next thought came to 
my mind was, it won't scale up, since we still have dependency on ARCH_OMAP2 
option. However, it will be a good temporary solution for our problem, lets 
review them first (I will submit shortly).

Thanks,
Vaibhav

^ permalink raw reply	[flat|nested] 263+ messages in thread

* Re: [PATCH-V5 2/3] arm:omap:am33xx: Add AM335XEVM machine support
  2012-05-07 14:38                 ` Hiremath, Vaibhav
@ 2012-05-07 17:32                   ` Tony Lindgren
  -1 siblings, 0 replies; 263+ messages in thread
From: Tony Lindgren @ 2012-05-07 17:32 UTC (permalink / raw)
  To: Hiremath, Vaibhav
  Cc: Hilman, Kevin, Paul Walmsley, linux-omap, linux-arm-kernel,
	Mohammed, Afzal

* Hiremath, Vaibhav <hvaibhav@ti.com> [120507 07:41]:
> On Sat, May 05, 2012 at 01:35:47, Tony Lindgren wrote:
> > 
> > I suggest doing some clean-up patches before adding SOC_AM33XX where
> > you just convert those to be
> > 
> > #if defined(CONFIG_ARCH_OMAP2PLUS) && !defined(CONFIG_ARCH_OMAP2)
> > 
> > or something similar depending if they already are inside mach-omap2
> > directory. This will make them future proof for adding new SoCs
> > without having to patch all over the place.

BTW, just noticied that the above won't work the right way in the
multi-omap case when all of them are compiled in..

> Cool, I also thought exactly same solution on this, but next thought came to 
> my mind was, it won't scale up, since we still have dependency on ARCH_OMAP2 
> option. However, it will be a good temporary solution for our problem, lets 
> review them first (I will submit shortly).

..so probably the best way to deal with that is with the additional
CONFIG_SOC_OMAP3PLUS and CONFIG_SOC_OMAP4PLUS options that I posted
at:

http://www.mail-archive.com/linux-omap@vger.kernel.org/msg67938.html

Can you please take a look and see how that works for am33xx?

Regards,

Tony

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [PATCH-V5 2/3] arm:omap:am33xx: Add AM335XEVM machine support
@ 2012-05-07 17:32                   ` Tony Lindgren
  0 siblings, 0 replies; 263+ messages in thread
From: Tony Lindgren @ 2012-05-07 17:32 UTC (permalink / raw)
  To: linux-arm-kernel

* Hiremath, Vaibhav <hvaibhav@ti.com> [120507 07:41]:
> On Sat, May 05, 2012 at 01:35:47, Tony Lindgren wrote:
> > 
> > I suggest doing some clean-up patches before adding SOC_AM33XX where
> > you just convert those to be
> > 
> > #if defined(CONFIG_ARCH_OMAP2PLUS) && !defined(CONFIG_ARCH_OMAP2)
> > 
> > or something similar depending if they already are inside mach-omap2
> > directory. This will make them future proof for adding new SoCs
> > without having to patch all over the place.

BTW, just noticied that the above won't work the right way in the
multi-omap case when all of them are compiled in..

> Cool, I also thought exactly same solution on this, but next thought came to 
> my mind was, it won't scale up, since we still have dependency on ARCH_OMAP2 
> option. However, it will be a good temporary solution for our problem, lets 
> review them first (I will submit shortly).

..so probably the best way to deal with that is with the additional
CONFIG_SOC_OMAP3PLUS and CONFIG_SOC_OMAP4PLUS options that I posted
at:

http://www.mail-archive.com/linux-omap at vger.kernel.org/msg67938.html

Can you please take a look and see how that works for am33xx?

Regards,

Tony

^ permalink raw reply	[flat|nested] 263+ messages in thread

* RE: [PATCH-V5 2/3] arm:omap:am33xx: Add AM335XEVM machine support
  2012-05-07 17:32                   ` Tony Lindgren
@ 2012-05-07 18:55                     ` Hiremath, Vaibhav
  -1 siblings, 0 replies; 263+ messages in thread
From: Hiremath, Vaibhav @ 2012-05-07 18:55 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: Hilman, Kevin, Paul Walmsley, linux-omap, linux-arm-kernel,
	Mohammed, Afzal

On Mon, May 07, 2012 at 23:02:29, Tony Lindgren wrote:
> * Hiremath, Vaibhav <hvaibhav@ti.com> [120507 07:41]:
> > On Sat, May 05, 2012 at 01:35:47, Tony Lindgren wrote:
> > > 
> > > I suggest doing some clean-up patches before adding SOC_AM33XX where
> > > you just convert those to be
> > > 
> > > #if defined(CONFIG_ARCH_OMAP2PLUS) && !defined(CONFIG_ARCH_OMAP2)
> > > 
> > > or something similar depending if they already are inside mach-omap2
> > > directory. This will make them future proof for adding new SoCs
> > > without having to patch all over the place.
> 
> BTW, just noticied that the above won't work the right way in the
> multi-omap case when all of them are compiled in..
> 
> > Cool, I also thought exactly same solution on this, but next thought came to 
> > my mind was, it won't scale up, since we still have dependency on ARCH_OMAP2 
> > option. However, it will be a good temporary solution for our problem, lets 
> > review them first (I will submit shortly).
> 
> ..so probably the best way to deal with that is with the additional
> CONFIG_SOC_OMAP3PLUS and CONFIG_SOC_OMAP4PLUS options that I posted
> at:
> 
> http://www.mail-archive.com/linux-omap@vger.kernel.org/msg67938.html
> 
> Can you please take a look and see how that works for am33xx?
> 

I still don't understand, how this will help am33xx, and for that matter any 
new future devices based on cortex-a8 or a9 core, but not omap exactly 
families? 
As I said earlier, am33xx doesn't fall under either omap3 or omap4; we have 
again same question in front of us, which to follow, either omap3 or omap4??

What is the thought process of creating these config options? Isn't it same 
as just replacing ARCH_OMAP3/4 with SOC_OMAP3PLUS and SOC_OMAP4PLUS? What is 
the criteria for the device to get into this umbrella?

Thanks,
Vaibhav


^ permalink raw reply	[flat|nested] 263+ messages in thread

* [PATCH-V5 2/3] arm:omap:am33xx: Add AM335XEVM machine support
@ 2012-05-07 18:55                     ` Hiremath, Vaibhav
  0 siblings, 0 replies; 263+ messages in thread
From: Hiremath, Vaibhav @ 2012-05-07 18:55 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, May 07, 2012 at 23:02:29, Tony Lindgren wrote:
> * Hiremath, Vaibhav <hvaibhav@ti.com> [120507 07:41]:
> > On Sat, May 05, 2012 at 01:35:47, Tony Lindgren wrote:
> > > 
> > > I suggest doing some clean-up patches before adding SOC_AM33XX where
> > > you just convert those to be
> > > 
> > > #if defined(CONFIG_ARCH_OMAP2PLUS) && !defined(CONFIG_ARCH_OMAP2)
> > > 
> > > or something similar depending if they already are inside mach-omap2
> > > directory. This will make them future proof for adding new SoCs
> > > without having to patch all over the place.
> 
> BTW, just noticied that the above won't work the right way in the
> multi-omap case when all of them are compiled in..
> 
> > Cool, I also thought exactly same solution on this, but next thought came to 
> > my mind was, it won't scale up, since we still have dependency on ARCH_OMAP2 
> > option. However, it will be a good temporary solution for our problem, lets 
> > review them first (I will submit shortly).
> 
> ..so probably the best way to deal with that is with the additional
> CONFIG_SOC_OMAP3PLUS and CONFIG_SOC_OMAP4PLUS options that I posted
> at:
> 
> http://www.mail-archive.com/linux-omap at vger.kernel.org/msg67938.html
> 
> Can you please take a look and see how that works for am33xx?
> 

I still don't understand, how this will help am33xx, and for that matter any 
new future devices based on cortex-a8 or a9 core, but not omap exactly 
families? 
As I said earlier, am33xx doesn't fall under either omap3 or omap4; we have 
again same question in front of us, which to follow, either omap3 or omap4??

What is the thought process of creating these config options? Isn't it same 
as just replacing ARCH_OMAP3/4 with SOC_OMAP3PLUS and SOC_OMAP4PLUS? What is 
the criteria for the device to get into this umbrella?

Thanks,
Vaibhav

^ permalink raw reply	[flat|nested] 263+ messages in thread

* Re: [PATCH-V5 2/3] arm:omap:am33xx: Add AM335XEVM machine support
  2012-05-07 18:55                     ` Hiremath, Vaibhav
@ 2012-05-08 19:06                       ` Tony Lindgren
  -1 siblings, 0 replies; 263+ messages in thread
From: Tony Lindgren @ 2012-05-08 19:06 UTC (permalink / raw)
  To: Hiremath, Vaibhav
  Cc: Hilman, Kevin, Paul Walmsley, linux-omap, linux-arm-kernel,
	Mohammed, Afzal

* Hiremath, Vaibhav <hvaibhav@ti.com> [120507 11:59]:
> On Mon, May 07, 2012 at 23:02:29, Tony Lindgren wrote:
> > * Hiremath, Vaibhav <hvaibhav@ti.com> [120507 07:41]:
> > > On Sat, May 05, 2012 at 01:35:47, Tony Lindgren wrote:
> > > > 
> > > > I suggest doing some clean-up patches before adding SOC_AM33XX where
> > > > you just convert those to be
> > > > 
> > > > #if defined(CONFIG_ARCH_OMAP2PLUS) && !defined(CONFIG_ARCH_OMAP2)
> > > > 
> > > > or something similar depending if they already are inside mach-omap2
> > > > directory. This will make them future proof for adding new SoCs
> > > > without having to patch all over the place.
> > 
> > BTW, just noticied that the above won't work the right way in the
> > multi-omap case when all of them are compiled in..
> > 
> > > Cool, I also thought exactly same solution on this, but next thought came to 
> > > my mind was, it won't scale up, since we still have dependency on ARCH_OMAP2 
> > > option. However, it will be a good temporary solution for our problem, lets 
> > > review them first (I will submit shortly).
> > 
> > ..so probably the best way to deal with that is with the additional
> > CONFIG_SOC_OMAP3PLUS and CONFIG_SOC_OMAP4PLUS options that I posted
> > at:
> > 
> > http://www.mail-archive.com/linux-omap@vger.kernel.org/msg67938.html
> > 
> > Can you please take a look and see how that works for am33xx?
> > 
> 
> I still don't understand, how this will help am33xx, and for that matter any 
> new future devices based on cortex-a8 or a9 core, but not omap exactly 
> families? 
> As I said earlier, am33xx doesn't fall under either omap3 or omap4; we have 
> again same question in front of us, which to follow, either omap3 or omap4??
> 
> What is the thought process of creating these config options? Isn't it same 
> as just replacing ARCH_OMAP3/4 with SOC_OMAP3PLUS and SOC_OMAP4PLUS? What is 
> the criteria for the device to get into this umbrella?

Just to recap: As we've discussed elsewhere, these new options need to be finer
grained SOC_HAS_OMAPXYZ_ABC type options like you've already posted.

Tony

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [PATCH-V5 2/3] arm:omap:am33xx: Add AM335XEVM machine support
@ 2012-05-08 19:06                       ` Tony Lindgren
  0 siblings, 0 replies; 263+ messages in thread
From: Tony Lindgren @ 2012-05-08 19:06 UTC (permalink / raw)
  To: linux-arm-kernel

* Hiremath, Vaibhav <hvaibhav@ti.com> [120507 11:59]:
> On Mon, May 07, 2012 at 23:02:29, Tony Lindgren wrote:
> > * Hiremath, Vaibhav <hvaibhav@ti.com> [120507 07:41]:
> > > On Sat, May 05, 2012 at 01:35:47, Tony Lindgren wrote:
> > > > 
> > > > I suggest doing some clean-up patches before adding SOC_AM33XX where
> > > > you just convert those to be
> > > > 
> > > > #if defined(CONFIG_ARCH_OMAP2PLUS) && !defined(CONFIG_ARCH_OMAP2)
> > > > 
> > > > or something similar depending if they already are inside mach-omap2
> > > > directory. This will make them future proof for adding new SoCs
> > > > without having to patch all over the place.
> > 
> > BTW, just noticied that the above won't work the right way in the
> > multi-omap case when all of them are compiled in..
> > 
> > > Cool, I also thought exactly same solution on this, but next thought came to 
> > > my mind was, it won't scale up, since we still have dependency on ARCH_OMAP2 
> > > option. However, it will be a good temporary solution for our problem, lets 
> > > review them first (I will submit shortly).
> > 
> > ..so probably the best way to deal with that is with the additional
> > CONFIG_SOC_OMAP3PLUS and CONFIG_SOC_OMAP4PLUS options that I posted
> > at:
> > 
> > http://www.mail-archive.com/linux-omap at vger.kernel.org/msg67938.html
> > 
> > Can you please take a look and see how that works for am33xx?
> > 
> 
> I still don't understand, how this will help am33xx, and for that matter any 
> new future devices based on cortex-a8 or a9 core, but not omap exactly 
> families? 
> As I said earlier, am33xx doesn't fall under either omap3 or omap4; we have 
> again same question in front of us, which to follow, either omap3 or omap4??
> 
> What is the thought process of creating these config options? Isn't it same 
> as just replacing ARCH_OMAP3/4 with SOC_OMAP3PLUS and SOC_OMAP4PLUS? What is 
> the criteria for the device to get into this umbrella?

Just to recap: As we've discussed elsewhere, these new options need to be finer
grained SOC_HAS_OMAPXYZ_ABC type options like you've already posted.

Tony

^ permalink raw reply	[flat|nested] 263+ messages in thread

* RE: [PATCH-V5 2/3] arm:omap:am33xx: Add AM335XEVM machine support
  2012-05-08 19:06                       ` Tony Lindgren
@ 2012-05-08 19:57                         ` Hiremath, Vaibhav
  -1 siblings, 0 replies; 263+ messages in thread
From: Hiremath, Vaibhav @ 2012-05-08 19:57 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: Hilman, Kevin, Paul Walmsley, linux-omap, linux-arm-kernel,
	Mohammed, Afzal

On Wed, May 09, 2012 at 00:36:51, Tony Lindgren wrote:
> * Hiremath, Vaibhav <hvaibhav@ti.com> [120507 11:59]:
> > On Mon, May 07, 2012 at 23:02:29, Tony Lindgren wrote:
> > > * Hiremath, Vaibhav <hvaibhav@ti.com> [120507 07:41]:
> > > > On Sat, May 05, 2012 at 01:35:47, Tony Lindgren wrote:
> > > > > 
> > > > > I suggest doing some clean-up patches before adding SOC_AM33XX where
> > > > > you just convert those to be
> > > > > 
> > > > > #if defined(CONFIG_ARCH_OMAP2PLUS) && !defined(CONFIG_ARCH_OMAP2)
> > > > > 
> > > > > or something similar depending if they already are inside mach-omap2
> > > > > directory. This will make them future proof for adding new SoCs
> > > > > without having to patch all over the place.
> > > 
> > > BTW, just noticied that the above won't work the right way in the
> > > multi-omap case when all of them are compiled in..
> > > 
> > > > Cool, I also thought exactly same solution on this, but next thought came to 
> > > > my mind was, it won't scale up, since we still have dependency on ARCH_OMAP2 
> > > > option. However, it will be a good temporary solution for our problem, lets 
> > > > review them first (I will submit shortly).
> > > 
> > > ..so probably the best way to deal with that is with the additional
> > > CONFIG_SOC_OMAP3PLUS and CONFIG_SOC_OMAP4PLUS options that I posted
> > > at:
> > > 
> > > http://www.mail-archive.com/linux-omap@vger.kernel.org/msg67938.html
> > > 
> > > Can you please take a look and see how that works for am33xx?
> > > 
> > 
> > I still don't understand, how this will help am33xx, and for that matter any 
> > new future devices based on cortex-a8 or a9 core, but not omap exactly 
> > families? 
> > As I said earlier, am33xx doesn't fall under either omap3 or omap4; we have 
> > again same question in front of us, which to follow, either omap3 or omap4??
> > 
> > What is the thought process of creating these config options? Isn't it same 
> > as just replacing ARCH_OMAP3/4 with SOC_OMAP3PLUS and SOC_OMAP4PLUS? What is 
> > the criteria for the device to get into this umbrella?
> 
> Just to recap: As we've discussed elsewhere, these new options need to be finer
> grained SOC_HAS_OMAPXYZ_ABC type options like you've already posted.
> 

Absolutely... I will be submitting machine and low-level early printk patch
Based on this only.

Thanks,
Vaibhav

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [PATCH-V5 2/3] arm:omap:am33xx: Add AM335XEVM machine support
@ 2012-05-08 19:57                         ` Hiremath, Vaibhav
  0 siblings, 0 replies; 263+ messages in thread
From: Hiremath, Vaibhav @ 2012-05-08 19:57 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, May 09, 2012 at 00:36:51, Tony Lindgren wrote:
> * Hiremath, Vaibhav <hvaibhav@ti.com> [120507 11:59]:
> > On Mon, May 07, 2012 at 23:02:29, Tony Lindgren wrote:
> > > * Hiremath, Vaibhav <hvaibhav@ti.com> [120507 07:41]:
> > > > On Sat, May 05, 2012 at 01:35:47, Tony Lindgren wrote:
> > > > > 
> > > > > I suggest doing some clean-up patches before adding SOC_AM33XX where
> > > > > you just convert those to be
> > > > > 
> > > > > #if defined(CONFIG_ARCH_OMAP2PLUS) && !defined(CONFIG_ARCH_OMAP2)
> > > > > 
> > > > > or something similar depending if they already are inside mach-omap2
> > > > > directory. This will make them future proof for adding new SoCs
> > > > > without having to patch all over the place.
> > > 
> > > BTW, just noticied that the above won't work the right way in the
> > > multi-omap case when all of them are compiled in..
> > > 
> > > > Cool, I also thought exactly same solution on this, but next thought came to 
> > > > my mind was, it won't scale up, since we still have dependency on ARCH_OMAP2 
> > > > option. However, it will be a good temporary solution for our problem, lets 
> > > > review them first (I will submit shortly).
> > > 
> > > ..so probably the best way to deal with that is with the additional
> > > CONFIG_SOC_OMAP3PLUS and CONFIG_SOC_OMAP4PLUS options that I posted
> > > at:
> > > 
> > > http://www.mail-archive.com/linux-omap at vger.kernel.org/msg67938.html
> > > 
> > > Can you please take a look and see how that works for am33xx?
> > > 
> > 
> > I still don't understand, how this will help am33xx, and for that matter any 
> > new future devices based on cortex-a8 or a9 core, but not omap exactly 
> > families? 
> > As I said earlier, am33xx doesn't fall under either omap3 or omap4; we have 
> > again same question in front of us, which to follow, either omap3 or omap4??
> > 
> > What is the thought process of creating these config options? Isn't it same 
> > as just replacing ARCH_OMAP3/4 with SOC_OMAP3PLUS and SOC_OMAP4PLUS? What is 
> > the criteria for the device to get into this umbrella?
> 
> Just to recap: As we've discussed elsewhere, these new options need to be finer
> grained SOC_HAS_OMAPXYZ_ABC type options like you've already posted.
> 

Absolutely... I will be submitting machine and low-level early printk patch
Based on this only.

Thanks,
Vaibhav

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [RFC PATCH 0/3] ARM: OMAP2+: Add command line parameter for debugSS module control
@ 2013-03-04 11:35 ` hvaibhav at ti.com
  0 siblings, 0 replies; 263+ messages in thread
From: hvaibhav @ 2013-03-04 11:35 UTC (permalink / raw)
  To: linux-omap
  Cc: tony, khilman, paul, rnayak, linux-arm-kernel, Vaibhav Hiremath

From: Vaibhav Hiremath <hvaibhav@ti.com>

Currently there is no clean mechanism to control debugSS module and
you have to always keep clocks enabled, either,

    - By enabling it during boot as part of clk_init function
      (post common-clock migration).
    Or
    - By having HWMOD_INIT_NO_IDLE flag in hwmod data
      (Joel submitted patch for AM335x earlier).

Based on the discussion with Kevin H,
http://www.mail-archive.com/linux-omap@vger.kernel.org/msg81771.html

This patch introduces new kernel parameter "omap_debugss_en",
which will allow user to control debugSS module enable/disable
part during boot-time.

In case of OMAP3, the debugSS is part of EMU domain and
is currently controlled by clock tree alone.

In case of OMAP4, the debugSS is part of EMU domain and
is currently controlled by clock tree, as MODULEMODE_SWCTRL
is not defined for hwmod.

In case of AM335x, the debugSS is in wakeup domain and is currently
controlled through hwmod alone. Currently we keep it always enabled.

Testing:
	- Tested on AM335x based EVM and BeagleBone platform

	  As required, without this flag the debugSS module will be disabled
	  during kernel boot.

OMAP (2/3/4) may require some changes from clock/hwmod perspective
in order to use this new parameter.
I am still looking into OMAP spec and this RFC version of patch-series
is to get comments or opinion from list.

Vaibhav Hiremath (3):
  ARM: AM33XX: clock: Add debugSS clock nodes to clock tree
  ARM: AM33XX: hwmod: Add hwmod data for debugSS
  ARM: OMAP2+: Add command line parameter for debugSS module control

 Documentation/kernel-parameters.txt        |    3 +
 arch/arm/mach-omap2/Makefile               |    2 +-
 arch/arm/mach-omap2/cclock33xx_data.c      |   47 +++++++++++++++--
 arch/arm/mach-omap2/debugss.c              |   80 ++++++++++++++++++++++++++++
 arch/arm/mach-omap2/omap_hwmod_33xx_data.c |   69 ++++++++++++++++--------
 5 files changed, 173 insertions(+), 28 deletions(-)
 create mode 100644 arch/arm/mach-omap2/debugss.c


^ permalink raw reply	[flat|nested] 263+ messages in thread

* [RFC PATCH 0/3] ARM: OMAP2+: Add command line parameter for debugSS module control
@ 2013-03-04 11:35 ` hvaibhav at ti.com
  0 siblings, 0 replies; 263+ messages in thread
From: hvaibhav at ti.com @ 2013-03-04 11:35 UTC (permalink / raw)
  To: linux-arm-kernel

From: Vaibhav Hiremath <hvaibhav@ti.com>

Currently there is no clean mechanism to control debugSS module and
you have to always keep clocks enabled, either,

    - By enabling it during boot as part of clk_init function
      (post common-clock migration).
    Or
    - By having HWMOD_INIT_NO_IDLE flag in hwmod data
      (Joel submitted patch for AM335x earlier).

Based on the discussion with Kevin H,
http://www.mail-archive.com/linux-omap at vger.kernel.org/msg81771.html

This patch introduces new kernel parameter "omap_debugss_en",
which will allow user to control debugSS module enable/disable
part during boot-time.

In case of OMAP3, the debugSS is part of EMU domain and
is currently controlled by clock tree alone.

In case of OMAP4, the debugSS is part of EMU domain and
is currently controlled by clock tree, as MODULEMODE_SWCTRL
is not defined for hwmod.

In case of AM335x, the debugSS is in wakeup domain and is currently
controlled through hwmod alone. Currently we keep it always enabled.

Testing:
	- Tested on AM335x based EVM and BeagleBone platform

	  As required, without this flag the debugSS module will be disabled
	  during kernel boot.

OMAP (2/3/4) may require some changes from clock/hwmod perspective
in order to use this new parameter.
I am still looking into OMAP spec and this RFC version of patch-series
is to get comments or opinion from list.

Vaibhav Hiremath (3):
  ARM: AM33XX: clock: Add debugSS clock nodes to clock tree
  ARM: AM33XX: hwmod: Add hwmod data for debugSS
  ARM: OMAP2+: Add command line parameter for debugSS module control

 Documentation/kernel-parameters.txt        |    3 +
 arch/arm/mach-omap2/Makefile               |    2 +-
 arch/arm/mach-omap2/cclock33xx_data.c      |   47 +++++++++++++++--
 arch/arm/mach-omap2/debugss.c              |   80 ++++++++++++++++++++++++++++
 arch/arm/mach-omap2/omap_hwmod_33xx_data.c |   69 ++++++++++++++++--------
 5 files changed, 173 insertions(+), 28 deletions(-)
 create mode 100644 arch/arm/mach-omap2/debugss.c

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [RFC PATCH 1/3] ARM: AM33XX: clock: Add debugSS clock nodes to clock tree
@ 2013-03-04 11:35 ` hvaibhav at ti.com
  0 siblings, 0 replies; 263+ messages in thread
From: hvaibhav @ 2013-03-04 11:35 UTC (permalink / raw)
  To: linux-omap
  Cc: tony, khilman, paul, rnayak, linux-arm-kernel, Vaibhav Hiremath

From: Vaibhav Hiremath <hvaibhav@ti.com>

Represent debugSS clock interface as provided in
CM_WKUP_DEBUGSS_CLKCTRL register, which includes,
	- Clock gate for optional DEBUG_CLKA and DBGSYSCLK
	- Clock Mux for TRC_PMD and STM_PMD
	- Clock divider for STM and TPIU

Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
Cc: Kevin Hilman <khilman@linaro.org>
Cc: Paul Walmsley <paul@pwsan.com>
Cc: Tony Lindgren <tony@atomide.com>
Cc: Rajendra Nayak <rnayak@ti.com>
---
 arch/arm/mach-omap2/cclock33xx_data.c |   47 +++++++++++++++++++++++++++++---
 1 files changed, 42 insertions(+), 5 deletions(-)

diff --git a/arch/arm/mach-omap2/cclock33xx_data.c b/arch/arm/mach-omap2/cclock33xx_data.c
index 3d5a0e5..12db88c 100644
--- a/arch/arm/mach-omap2/cclock33xx_data.c
+++ b/arch/arm/mach-omap2/cclock33xx_data.c
@@ -422,15 +422,11 @@ DEFINE_STRUCT_CLK(smartreflex1_fck, dpll_core_ck_parents, clk_ops_null);
  *  - Driver code is not yet migrated to use hwmod/runtime pm
  *  - Modules outside kernel access (to disable them by default)
  *
- *     - debugss
  *     - mmu (gfx domain)
  *     - cefuse
  *     - usbotg_fck (its additional clock and not really a modulemode)
  *     - ieee5000
  */
-DEFINE_CLK_GATE(debugss_ick, "dpll_core_m4_ck", &dpll_core_m4_ck, 0x0,
-		AM33XX_CM_WKUP_DEBUGSS_CLKCTRL, AM33XX_MODULEMODE_SWCTRL_SHIFT,
-		0x0, NULL);

 DEFINE_CLK_GATE(mmu_fck, "dpll_core_m4_ck", &dpll_core_m4_ck, 0x0,
 		AM33XX_CM_GFX_MMUDATA_CLKCTRL, AM33XX_MODULEMODE_SWCTRL_SHIFT,
@@ -833,6 +829,42 @@ static struct clk_hw_omap wdt1_fck_hw = {
 DEFINE_STRUCT_CLK(wdt1_fck, wdt_ck_parents, gpio_fck_ops);

 /*
+ * debugss optional clocks
+ */
+DEFINE_CLK_GATE(dbg_sysclk_ck, "sys_clkin_ck", &sys_clkin_ck,
+		0x0, AM33XX_CM_WKUP_DEBUGSS_CLKCTRL,
+		AM33XX_OPTFCLKEN_DBGSYSCLK_SHIFT, 0x0, NULL);
+
+DEFINE_CLK_GATE(dbg_clka_ck, "dpll_core_m4_ck", &dpll_core_m4_ck,
+		0x0, AM33XX_CM_WKUP_DEBUGSS_CLKCTRL,
+		AM33XX_OPTCLK_DEBUG_CLKA_SHIFT, 0x0, NULL);
+
+static const char *stm_pmd_clock_mux_ck_parents[] = {
+	"dbg_sysclk_ck", "dbg_clka_ck",
+};
+
+DEFINE_CLK_MUX(stm_pmd_clock_mux_ck, stm_pmd_clock_mux_ck_parents, NULL, 0x0,
+	       AM33XX_CM_WKUP_DEBUGSS_CLKCTRL, AM33XX_STM_PMD_CLKSEL_SHIFT,
+	       AM33XX_STM_PMD_CLKSEL_WIDTH, 0x0, NULL);
+
+DEFINE_CLK_MUX(trace_pmd_clk_mux_ck, stm_pmd_clock_mux_ck_parents, NULL, 0x0,
+	       AM33XX_CM_WKUP_DEBUGSS_CLKCTRL,
+	       AM33XX_TRC_PMD_CLKSEL_SHIFT,
+	       AM33XX_TRC_PMD_CLKSEL_WIDTH, 0x0, NULL);
+
+DEFINE_CLK_DIVIDER(stm_clk_div_ck, "stm_pmd_clock_mux_ck",
+		   &stm_pmd_clock_mux_ck, 0x0, AM33XX_CM_WKUP_DEBUGSS_CLKCTRL,
+		   AM33XX_STM_PMD_CLKDIVSEL_SHIFT,
+		   AM33XX_STM_PMD_CLKDIVSEL_WIDTH, CLK_DIVIDER_POWER_OF_TWO,
+		   NULL);
+
+DEFINE_CLK_DIVIDER(trace_clk_div_ck, "trace_pmd_clk_mux_ck",
+		   &trace_pmd_clk_mux_ck, 0x0, AM33XX_CM_WKUP_DEBUGSS_CLKCTRL,
+		   AM33XX_TRC_PMD_CLKDIVSEL_SHIFT,
+		   AM33XX_TRC_PMD_CLKDIVSEL_WIDTH, CLK_DIVIDER_POWER_OF_TWO,
+		   NULL);
+
+/*
  * clkdev
  */
 static struct omap_clk am33xx_clks[] = {
@@ -869,7 +901,6 @@ static struct omap_clk am33xx_clks[] = {
 	CLK("481cc000.d_can",	NULL,		&dcan0_fck,	CK_AM33XX),
 	CLK(NULL,	"dcan1_fck",		&dcan1_fck,	CK_AM33XX),
 	CLK("481d0000.d_can",	NULL,		&dcan1_fck,	CK_AM33XX),
-	CLK(NULL,	"debugss_ick",		&debugss_ick,	CK_AM33XX),
 	CLK(NULL,	"pruss_ocp_gclk",	&pruss_ocp_gclk,	CK_AM33XX),
 	CLK(NULL,	"mcasp0_fck",		&mcasp0_fck,	CK_AM33XX),
 	CLK(NULL,	"mcasp1_fck",		&mcasp1_fck,	CK_AM33XX),
@@ -910,6 +941,12 @@ static struct omap_clk am33xx_clks[] = {
 	CLK(NULL,	"clkout2_div_ck",	&clkout2_div_ck,	CK_AM33XX),
 	CLK(NULL,	"timer_32k_ck",		&clkdiv32k_ick,	CK_AM33XX),
 	CLK(NULL,	"timer_sys_ck",		&sys_clkin_ck,	CK_AM33XX),
+	CLK(NULL,	"dbg_sysclk_ck",	&dbg_sysclk_ck,	CK_AM33XX),
+	CLK(NULL,	"dbg_clka_ck",		&dbg_clka_ck,	CK_AM33XX),
+	CLK(NULL,	"stm_pmd_clock_mux_ck",	&stm_pmd_clock_mux_ck,	CK_AM33XX),
+	CLK(NULL,	"trace_pmd_clk_mux_ck",	&trace_pmd_clk_mux_ck,	CK_AM33XX),
+	CLK(NULL,	"stm_clk_div_ck",	&stm_clk_div_ck,	CK_AM33XX),
+	CLK(NULL,	"trace_clk_div_ck",	&trace_clk_div_ck,	CK_AM33XX),
 };


--
1.7.0.4


^ permalink raw reply related	[flat|nested] 263+ messages in thread

* [RFC PATCH 1/3] ARM: AM33XX: clock: Add debugSS clock nodes to clock tree
@ 2013-03-04 11:35 ` hvaibhav at ti.com
  0 siblings, 0 replies; 263+ messages in thread
From: hvaibhav at ti.com @ 2013-03-04 11:35 UTC (permalink / raw)
  To: linux-arm-kernel

From: Vaibhav Hiremath <hvaibhav@ti.com>

Represent debugSS clock interface as provided in
CM_WKUP_DEBUGSS_CLKCTRL register, which includes,
	- Clock gate for optional DEBUG_CLKA and DBGSYSCLK
	- Clock Mux for TRC_PMD and STM_PMD
	- Clock divider for STM and TPIU

Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
Cc: Kevin Hilman <khilman@linaro.org>
Cc: Paul Walmsley <paul@pwsan.com>
Cc: Tony Lindgren <tony@atomide.com>
Cc: Rajendra Nayak <rnayak@ti.com>
---
 arch/arm/mach-omap2/cclock33xx_data.c |   47 +++++++++++++++++++++++++++++---
 1 files changed, 42 insertions(+), 5 deletions(-)

diff --git a/arch/arm/mach-omap2/cclock33xx_data.c b/arch/arm/mach-omap2/cclock33xx_data.c
index 3d5a0e5..12db88c 100644
--- a/arch/arm/mach-omap2/cclock33xx_data.c
+++ b/arch/arm/mach-omap2/cclock33xx_data.c
@@ -422,15 +422,11 @@ DEFINE_STRUCT_CLK(smartreflex1_fck, dpll_core_ck_parents, clk_ops_null);
  *  - Driver code is not yet migrated to use hwmod/runtime pm
  *  - Modules outside kernel access (to disable them by default)
  *
- *     - debugss
  *     - mmu (gfx domain)
  *     - cefuse
  *     - usbotg_fck (its additional clock and not really a modulemode)
  *     - ieee5000
  */
-DEFINE_CLK_GATE(debugss_ick, "dpll_core_m4_ck", &dpll_core_m4_ck, 0x0,
-		AM33XX_CM_WKUP_DEBUGSS_CLKCTRL, AM33XX_MODULEMODE_SWCTRL_SHIFT,
-		0x0, NULL);

 DEFINE_CLK_GATE(mmu_fck, "dpll_core_m4_ck", &dpll_core_m4_ck, 0x0,
 		AM33XX_CM_GFX_MMUDATA_CLKCTRL, AM33XX_MODULEMODE_SWCTRL_SHIFT,
@@ -833,6 +829,42 @@ static struct clk_hw_omap wdt1_fck_hw = {
 DEFINE_STRUCT_CLK(wdt1_fck, wdt_ck_parents, gpio_fck_ops);

 /*
+ * debugss optional clocks
+ */
+DEFINE_CLK_GATE(dbg_sysclk_ck, "sys_clkin_ck", &sys_clkin_ck,
+		0x0, AM33XX_CM_WKUP_DEBUGSS_CLKCTRL,
+		AM33XX_OPTFCLKEN_DBGSYSCLK_SHIFT, 0x0, NULL);
+
+DEFINE_CLK_GATE(dbg_clka_ck, "dpll_core_m4_ck", &dpll_core_m4_ck,
+		0x0, AM33XX_CM_WKUP_DEBUGSS_CLKCTRL,
+		AM33XX_OPTCLK_DEBUG_CLKA_SHIFT, 0x0, NULL);
+
+static const char *stm_pmd_clock_mux_ck_parents[] = {
+	"dbg_sysclk_ck", "dbg_clka_ck",
+};
+
+DEFINE_CLK_MUX(stm_pmd_clock_mux_ck, stm_pmd_clock_mux_ck_parents, NULL, 0x0,
+	       AM33XX_CM_WKUP_DEBUGSS_CLKCTRL, AM33XX_STM_PMD_CLKSEL_SHIFT,
+	       AM33XX_STM_PMD_CLKSEL_WIDTH, 0x0, NULL);
+
+DEFINE_CLK_MUX(trace_pmd_clk_mux_ck, stm_pmd_clock_mux_ck_parents, NULL, 0x0,
+	       AM33XX_CM_WKUP_DEBUGSS_CLKCTRL,
+	       AM33XX_TRC_PMD_CLKSEL_SHIFT,
+	       AM33XX_TRC_PMD_CLKSEL_WIDTH, 0x0, NULL);
+
+DEFINE_CLK_DIVIDER(stm_clk_div_ck, "stm_pmd_clock_mux_ck",
+		   &stm_pmd_clock_mux_ck, 0x0, AM33XX_CM_WKUP_DEBUGSS_CLKCTRL,
+		   AM33XX_STM_PMD_CLKDIVSEL_SHIFT,
+		   AM33XX_STM_PMD_CLKDIVSEL_WIDTH, CLK_DIVIDER_POWER_OF_TWO,
+		   NULL);
+
+DEFINE_CLK_DIVIDER(trace_clk_div_ck, "trace_pmd_clk_mux_ck",
+		   &trace_pmd_clk_mux_ck, 0x0, AM33XX_CM_WKUP_DEBUGSS_CLKCTRL,
+		   AM33XX_TRC_PMD_CLKDIVSEL_SHIFT,
+		   AM33XX_TRC_PMD_CLKDIVSEL_WIDTH, CLK_DIVIDER_POWER_OF_TWO,
+		   NULL);
+
+/*
  * clkdev
  */
 static struct omap_clk am33xx_clks[] = {
@@ -869,7 +901,6 @@ static struct omap_clk am33xx_clks[] = {
 	CLK("481cc000.d_can",	NULL,		&dcan0_fck,	CK_AM33XX),
 	CLK(NULL,	"dcan1_fck",		&dcan1_fck,	CK_AM33XX),
 	CLK("481d0000.d_can",	NULL,		&dcan1_fck,	CK_AM33XX),
-	CLK(NULL,	"debugss_ick",		&debugss_ick,	CK_AM33XX),
 	CLK(NULL,	"pruss_ocp_gclk",	&pruss_ocp_gclk,	CK_AM33XX),
 	CLK(NULL,	"mcasp0_fck",		&mcasp0_fck,	CK_AM33XX),
 	CLK(NULL,	"mcasp1_fck",		&mcasp1_fck,	CK_AM33XX),
@@ -910,6 +941,12 @@ static struct omap_clk am33xx_clks[] = {
 	CLK(NULL,	"clkout2_div_ck",	&clkout2_div_ck,	CK_AM33XX),
 	CLK(NULL,	"timer_32k_ck",		&clkdiv32k_ick,	CK_AM33XX),
 	CLK(NULL,	"timer_sys_ck",		&sys_clkin_ck,	CK_AM33XX),
+	CLK(NULL,	"dbg_sysclk_ck",	&dbg_sysclk_ck,	CK_AM33XX),
+	CLK(NULL,	"dbg_clka_ck",		&dbg_clka_ck,	CK_AM33XX),
+	CLK(NULL,	"stm_pmd_clock_mux_ck",	&stm_pmd_clock_mux_ck,	CK_AM33XX),
+	CLK(NULL,	"trace_pmd_clk_mux_ck",	&trace_pmd_clk_mux_ck,	CK_AM33XX),
+	CLK(NULL,	"stm_clk_div_ck",	&stm_clk_div_ck,	CK_AM33XX),
+	CLK(NULL,	"trace_clk_div_ck",	&trace_clk_div_ck,	CK_AM33XX),
 };


--
1.7.0.4

^ permalink raw reply related	[flat|nested] 263+ messages in thread

* [RFC PATCH 3/3] ARM: OMAP2+: Add command line parameter for debugSS module control
@ 2013-03-04 11:35 ` hvaibhav at ti.com
  0 siblings, 0 replies; 263+ messages in thread
From: hvaibhav @ 2013-03-04 11:35 UTC (permalink / raw)
  To: linux-omap
  Cc: tony, khilman, paul, rnayak, linux-arm-kernel, Vaibhav Hiremath

From: Vaibhav Hiremath <hvaibhav@ti.com>

Currently there is no clean mechanism to control debugSS module and
you have to always keep clocks enabled, either,

    - By enabling it during boot as part of clk_init function.
    Or
    - By having HWMOD_INIT_NO_IDLE flag in hwmod data.

Based on the discussion,
http://www.mail-archive.com/linux-omap@vger.kernel.org/msg81771.html

This patch introduces new kernel parameter "omap_debugss_en",
which will allow user to control debugSS module enable/disable
part during boot-time.

Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
Cc: Kevin Hilman <khilman@linaro.org>
Cc: Paul Walmsley <paul@pwsan.com>
Cc: Tony Lindgren <tony@atomide.com>
---
Tested on
	- AM335x based EVM and BeagleBone platforms

 Documentation/kernel-parameters.txt |    3 +
 arch/arm/mach-omap2/Makefile        |    2 +-
 arch/arm/mach-omap2/debugss.c       |   80 +++++++++++++++++++++++++++++++++++
 3 files changed, 84 insertions(+), 1 deletions(-)
 create mode 100644 arch/arm/mach-omap2/debugss.c

diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
index 6c72381..bf1c822 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -2051,6 +2051,9 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
 			For example, to override I2C bus2:
 			omap_mux=i2c2_scl.i2c2_scl=0x100,i2c2_sda.i2c2_sda=0x100

+	omap_debugss_en	[OMAP] Enable Debug Sub-System module required
+			for JTAG debugging.
+
 	oprofile.timer=	[HW]
 			Use timer interrupt instead of performance counters

diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile
index d1156cf..aaf5cc2 100644
--- a/arch/arm/mach-omap2/Makefile
+++ b/arch/arm/mach-omap2/Makefile
@@ -5,7 +5,7 @@
 # Common support
 obj-y := id.o io.o control.o mux.o devices.o fb.o serial.o gpmc.o timer.o pm.o \
 	 common.o gpio.o dma.o wd_timer.o display.o i2c.o hdq1w.o omap_hwmod.o \
-	 omap_device.o sram.o
+	 omap_device.o sram.o debugss.o

 omap-2-3-common				= irq.o
 hwmod-common				= omap_hwmod.o \
diff --git a/arch/arm/mach-omap2/debugss.c b/arch/arm/mach-omap2/debugss.c
new file mode 100644
index 0000000..b45bf2c
--- /dev/null
+++ b/arch/arm/mach-omap2/debugss.c
@@ -0,0 +1,80 @@
+/*
+ * debugss.c: Debug Sus-System related code goes in here
+ *
+ * Copyright (C) {2013} Texas Instruments Incorporated - http://www.ti.com/
+ *
+ * This file is automatically generated from the AM33XX hardware databases.
+ * 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/init.h>
+#include <linux/err.h>
+#include <linux/clk.h>
+
+#include "omap_hwmod.h"
+
+static bool is_debugss_en;
+
+/**
+ * omap_debugss_en - Enable debugss clock/module based on user config
+ *
+ * During kernel bootup, omap2 hwmod framework will disable all the
+ * unused/unclaimed modules, which in turn also disables debugss module.
+ * This breaks any further debugging capability provided by HW.
+ *
+ *
+ * Introduce early param which allows user to enable clock/module -
+ *
+ *   omap_debugss_en	(For all OMAP2 architectures)
+ *
+ * Please note that, with this command-line param, module always remain
+ * enabled.
+ */
+static int __init omap_debugss_en(char *str)
+{
+	is_debugss_en = true;
+	return 0;
+}
+early_param("omap_debugss_en", omap_debugss_en);
+
+static int __init _omap2_debugss_enable(void)
+{
+	const char oh_name[10] = "debugss";
+	struct omap_hwmod *oh;
+	int ret;
+
+	if (is_debugss_en) {
+		struct omap_hwmod_opt_clk *oc;
+		int i;
+
+		oh = omap_hwmod_lookup(oh_name);
+		if (!oh) {
+			pr_err("debugss device not found\n");
+			return 0;
+		}
+
+		/* Make sure that hwmod internal data structures are setup */
+		ret = omap_hwmod_setup_one(oh_name);
+		if (ret) {
+			pr_err("failed to setup hwmod for %s\n", oh_name);
+			return 0;
+		}
+		/* Enable optional clocks */
+		for (i = oh->opt_clks_cnt, oc = oh->opt_clks; i > 0; i--, oc++)	{
+			if (oc->_clk)
+				clk_prepare_enable(oc->_clk);
+		}
+		/* Enable debugss clock/module  */
+		omap_hwmod_enable(oh);
+	}
+
+	return 0;
+}
+device_initcall(_omap2_debugss_enable);
--
1.7.0.4


^ permalink raw reply related	[flat|nested] 263+ messages in thread

* [RFC PATCH 3/3] ARM: OMAP2+: Add command line parameter for debugSS module control
@ 2013-03-04 11:35 ` hvaibhav at ti.com
  0 siblings, 0 replies; 263+ messages in thread
From: hvaibhav at ti.com @ 2013-03-04 11:35 UTC (permalink / raw)
  To: linux-arm-kernel

From: Vaibhav Hiremath <hvaibhav@ti.com>

Currently there is no clean mechanism to control debugSS module and
you have to always keep clocks enabled, either,

    - By enabling it during boot as part of clk_init function.
    Or
    - By having HWMOD_INIT_NO_IDLE flag in hwmod data.

Based on the discussion,
http://www.mail-archive.com/linux-omap at vger.kernel.org/msg81771.html

This patch introduces new kernel parameter "omap_debugss_en",
which will allow user to control debugSS module enable/disable
part during boot-time.

Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
Cc: Kevin Hilman <khilman@linaro.org>
Cc: Paul Walmsley <paul@pwsan.com>
Cc: Tony Lindgren <tony@atomide.com>
---
Tested on
	- AM335x based EVM and BeagleBone platforms

 Documentation/kernel-parameters.txt |    3 +
 arch/arm/mach-omap2/Makefile        |    2 +-
 arch/arm/mach-omap2/debugss.c       |   80 +++++++++++++++++++++++++++++++++++
 3 files changed, 84 insertions(+), 1 deletions(-)
 create mode 100644 arch/arm/mach-omap2/debugss.c

diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
index 6c72381..bf1c822 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -2051,6 +2051,9 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
 			For example, to override I2C bus2:
 			omap_mux=i2c2_scl.i2c2_scl=0x100,i2c2_sda.i2c2_sda=0x100

+	omap_debugss_en	[OMAP] Enable Debug Sub-System module required
+			for JTAG debugging.
+
 	oprofile.timer=	[HW]
 			Use timer interrupt instead of performance counters

diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile
index d1156cf..aaf5cc2 100644
--- a/arch/arm/mach-omap2/Makefile
+++ b/arch/arm/mach-omap2/Makefile
@@ -5,7 +5,7 @@
 # Common support
 obj-y := id.o io.o control.o mux.o devices.o fb.o serial.o gpmc.o timer.o pm.o \
 	 common.o gpio.o dma.o wd_timer.o display.o i2c.o hdq1w.o omap_hwmod.o \
-	 omap_device.o sram.o
+	 omap_device.o sram.o debugss.o

 omap-2-3-common				= irq.o
 hwmod-common				= omap_hwmod.o \
diff --git a/arch/arm/mach-omap2/debugss.c b/arch/arm/mach-omap2/debugss.c
new file mode 100644
index 0000000..b45bf2c
--- /dev/null
+++ b/arch/arm/mach-omap2/debugss.c
@@ -0,0 +1,80 @@
+/*
+ * debugss.c: Debug Sus-System related code goes in here
+ *
+ * Copyright (C) {2013} Texas Instruments Incorporated - http://www.ti.com/
+ *
+ * This file is automatically generated from the AM33XX hardware databases.
+ * 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/init.h>
+#include <linux/err.h>
+#include <linux/clk.h>
+
+#include "omap_hwmod.h"
+
+static bool is_debugss_en;
+
+/**
+ * omap_debugss_en - Enable debugss clock/module based on user config
+ *
+ * During kernel bootup, omap2 hwmod framework will disable all the
+ * unused/unclaimed modules, which in turn also disables debugss module.
+ * This breaks any further debugging capability provided by HW.
+ *
+ *
+ * Introduce early param which allows user to enable clock/module -
+ *
+ *   omap_debugss_en	(For all OMAP2 architectures)
+ *
+ * Please note that, with this command-line param, module always remain
+ * enabled.
+ */
+static int __init omap_debugss_en(char *str)
+{
+	is_debugss_en = true;
+	return 0;
+}
+early_param("omap_debugss_en", omap_debugss_en);
+
+static int __init _omap2_debugss_enable(void)
+{
+	const char oh_name[10] = "debugss";
+	struct omap_hwmod *oh;
+	int ret;
+
+	if (is_debugss_en) {
+		struct omap_hwmod_opt_clk *oc;
+		int i;
+
+		oh = omap_hwmod_lookup(oh_name);
+		if (!oh) {
+			pr_err("debugss device not found\n");
+			return 0;
+		}
+
+		/* Make sure that hwmod internal data structures are setup */
+		ret = omap_hwmod_setup_one(oh_name);
+		if (ret) {
+			pr_err("failed to setup hwmod for %s\n", oh_name);
+			return 0;
+		}
+		/* Enable optional clocks */
+		for (i = oh->opt_clks_cnt, oc = oh->opt_clks; i > 0; i--, oc++)	{
+			if (oc->_clk)
+				clk_prepare_enable(oc->_clk);
+		}
+		/* Enable debugss clock/module  */
+		omap_hwmod_enable(oh);
+	}
+
+	return 0;
+}
+device_initcall(_omap2_debugss_enable);
--
1.7.0.4

^ permalink raw reply related	[flat|nested] 263+ messages in thread

* RE: [RFC PATCH 0/3] ARM: OMAP2+: Add command line parameter for debugSS module control
  2013-03-04 11:35 ` hvaibhav at ti.com
@ 2013-03-14 11:29   ` Hiremath, Vaibhav
  -1 siblings, 0 replies; 263+ messages in thread
From: Hiremath, Vaibhav @ 2013-03-14 11:29 UTC (permalink / raw)
  To: Hiremath, Vaibhav, linux-omap
  Cc: tony, khilman, paul, Nayak, Rajendra, linux-arm-kernel


> -----Original Message-----
> From: Hiremath, Vaibhav
> Sent: Monday, March 04, 2013 5:06 PM
> To: linux-omap@vger.kernel.org
> Cc: tony@atomide.com; khilman@linaro.org; paul@pwsan.com; Nayak,
> Rajendra; linux-arm-kernel@lists.infradead.org; Hiremath, Vaibhav
> Subject: [RFC PATCH 0/3] ARM: OMAP2+: Add command line parameter for
> debugSS module control
> 
> From: Vaibhav Hiremath <hvaibhav@ti.com>
> 
> Currently there is no clean mechanism to control debugSS module and
> you have to always keep clocks enabled, either,
> 
>     - By enabling it during boot as part of clk_init function
>       (post common-clock migration).
>     Or
>     - By having HWMOD_INIT_NO_IDLE flag in hwmod data
>       (Joel submitted patch for AM335x earlier).
> 
> Based on the discussion with Kevin H,
> http://www.mail-archive.com/linux-omap@vger.kernel.org/msg81771.html
> 
> This patch introduces new kernel parameter "omap_debugss_en",
> which will allow user to control debugSS module enable/disable
> part during boot-time.
> 
> In case of OMAP3, the debugSS is part of EMU domain and
> is currently controlled by clock tree alone.
> 
> In case of OMAP4, the debugSS is part of EMU domain and
> is currently controlled by clock tree, as MODULEMODE_SWCTRL
> is not defined for hwmod.
> 
> In case of AM335x, the debugSS is in wakeup domain and is currently
> controlled through hwmod alone. Currently we keep it always enabled.
> 
> Testing:
> 	- Tested on AM335x based EVM and BeagleBone platform
> 
> 	  As required, without this flag the debugSS module will be
> disabled
> 	  during kernel boot.
> 
> OMAP (2/3/4) may require some changes from clock/hwmod perspective
> in order to use this new parameter.
> I am still looking into OMAP spec and this RFC version of patch-series
> is to get comments or opinion from list.
> 
> Vaibhav Hiremath (3):
>   ARM: AM33XX: clock: Add debugSS clock nodes to clock tree
>   ARM: AM33XX: hwmod: Add hwmod data for debugSS
>   ARM: OMAP2+: Add command line parameter for debugSS module control
> 
>  Documentation/kernel-parameters.txt        |    3 +
>  arch/arm/mach-omap2/Makefile               |    2 +-
>  arch/arm/mach-omap2/cclock33xx_data.c      |   47 +++++++++++++++--
>  arch/arm/mach-omap2/debugss.c              |   80
> ++++++++++++++++++++++++++++
>  arch/arm/mach-omap2/omap_hwmod_33xx_data.c |   69 ++++++++++++++++----
> ----
>  5 files changed, 173 insertions(+), 28 deletions(-)
>  create mode 100644 arch/arm/mach-omap2/debugss.c

Kevin/Tony,

Any comments or input on this patch series?

Thanks,
Vaibhav




^ permalink raw reply	[flat|nested] 263+ messages in thread

* [RFC PATCH 0/3] ARM: OMAP2+: Add command line parameter for debugSS module control
@ 2013-03-14 11:29   ` Hiremath, Vaibhav
  0 siblings, 0 replies; 263+ messages in thread
From: Hiremath, Vaibhav @ 2013-03-14 11:29 UTC (permalink / raw)
  To: linux-arm-kernel


> -----Original Message-----
> From: Hiremath, Vaibhav
> Sent: Monday, March 04, 2013 5:06 PM
> To: linux-omap at vger.kernel.org
> Cc: tony at atomide.com; khilman at linaro.org; paul at pwsan.com; Nayak,
> Rajendra; linux-arm-kernel at lists.infradead.org; Hiremath, Vaibhav
> Subject: [RFC PATCH 0/3] ARM: OMAP2+: Add command line parameter for
> debugSS module control
> 
> From: Vaibhav Hiremath <hvaibhav@ti.com>
> 
> Currently there is no clean mechanism to control debugSS module and
> you have to always keep clocks enabled, either,
> 
>     - By enabling it during boot as part of clk_init function
>       (post common-clock migration).
>     Or
>     - By having HWMOD_INIT_NO_IDLE flag in hwmod data
>       (Joel submitted patch for AM335x earlier).
> 
> Based on the discussion with Kevin H,
> http://www.mail-archive.com/linux-omap at vger.kernel.org/msg81771.html
> 
> This patch introduces new kernel parameter "omap_debugss_en",
> which will allow user to control debugSS module enable/disable
> part during boot-time.
> 
> In case of OMAP3, the debugSS is part of EMU domain and
> is currently controlled by clock tree alone.
> 
> In case of OMAP4, the debugSS is part of EMU domain and
> is currently controlled by clock tree, as MODULEMODE_SWCTRL
> is not defined for hwmod.
> 
> In case of AM335x, the debugSS is in wakeup domain and is currently
> controlled through hwmod alone. Currently we keep it always enabled.
> 
> Testing:
> 	- Tested on AM335x based EVM and BeagleBone platform
> 
> 	  As required, without this flag the debugSS module will be
> disabled
> 	  during kernel boot.
> 
> OMAP (2/3/4) may require some changes from clock/hwmod perspective
> in order to use this new parameter.
> I am still looking into OMAP spec and this RFC version of patch-series
> is to get comments or opinion from list.
> 
> Vaibhav Hiremath (3):
>   ARM: AM33XX: clock: Add debugSS clock nodes to clock tree
>   ARM: AM33XX: hwmod: Add hwmod data for debugSS
>   ARM: OMAP2+: Add command line parameter for debugSS module control
> 
>  Documentation/kernel-parameters.txt        |    3 +
>  arch/arm/mach-omap2/Makefile               |    2 +-
>  arch/arm/mach-omap2/cclock33xx_data.c      |   47 +++++++++++++++--
>  arch/arm/mach-omap2/debugss.c              |   80
> ++++++++++++++++++++++++++++
>  arch/arm/mach-omap2/omap_hwmod_33xx_data.c |   69 ++++++++++++++++----
> ----
>  5 files changed, 173 insertions(+), 28 deletions(-)
>  create mode 100644 arch/arm/mach-omap2/debugss.c

Kevin/Tony,

Any comments or input on this patch series?

Thanks,
Vaibhav

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [U-Boot] [PATCH] am335x: Enable DDR PHY dynamic power down bit for DDR3 boards
@ 2013-03-15  7:11 ` Vaibhav Hiremath
  2013-03-15 15:05   ` Tom Rini
  2013-03-26 14:53   ` [U-Boot] " Tom Rini
  0 siblings, 2 replies; 263+ messages in thread
From: Vaibhav Hiremath @ 2013-03-15  7:11 UTC (permalink / raw)
  To: u-boot

Enable DDR PHY dynamic power down bit, which enables
powering down the IO receiver when not performing read.

This also helps in reducing overall power consumption in
low power states (suspend/standby).

Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
Signed-off-by: Satyanarayana, Sandhya <sandhya.satyanarayana@ti.com>
Cc: Tom Rini <trini@ti.com>
---
 arch/arm/include/asm/arch-am33xx/ddr_defs.h |    1 +
 board/ti/am335x/board.c                     |    6 ++++--
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/arch/arm/include/asm/arch-am33xx/ddr_defs.h b/arch/arm/include/asm/arch-am33xx/ddr_defs.h
index ae43ef8..7ab3baf 100644
--- a/arch/arm/include/asm/arch-am33xx/ddr_defs.h
+++ b/arch/arm/include/asm/arch-am33xx/ddr_defs.h
@@ -28,6 +28,7 @@
 #define VTP_CTRL_START_EN	(0x1)
 #define PHY_DLL_LOCK_DIFF	0x0
 #define DDR_CKE_CTRL_NORMAL	0x1
+#define PHY_EN_DYN_PWRDN	(0x1 << 20)
 
 /* Micron MT47H128M16RT-25E */
 #define MT47H128M16RT25E_EMIF_READ_LATENCY	0x100005
diff --git a/board/ti/am335x/board.c b/board/ti/am335x/board.c
index 48e6896..22d7b25 100644
--- a/board/ti/am335x/board.c
+++ b/board/ti/am335x/board.c
@@ -251,7 +251,8 @@ static struct emif_regs ddr3_emif_reg_data = {
 	.sdram_tim2 = MT41J128MJT125_EMIF_TIM2,
 	.sdram_tim3 = MT41J128MJT125_EMIF_TIM3,
 	.zq_config = MT41J128MJT125_ZQ_CFG,
-	.emif_ddr_phy_ctlr_1 = MT41J128MJT125_EMIF_READ_LATENCY,
+	.emif_ddr_phy_ctlr_1 = MT41J128MJT125_EMIF_READ_LATENCY |
+				PHY_EN_DYN_PWRDN,
 };
 
 static struct emif_regs ddr3_evm_emif_reg_data = {
@@ -261,7 +262,8 @@ static struct emif_regs ddr3_evm_emif_reg_data = {
 	.sdram_tim2 = MT41J512M8RH125_EMIF_TIM2,
 	.sdram_tim3 = MT41J512M8RH125_EMIF_TIM3,
 	.zq_config = MT41J512M8RH125_ZQ_CFG,
-	.emif_ddr_phy_ctlr_1 = MT41J512M8RH125_EMIF_READ_LATENCY,
+	.emif_ddr_phy_ctlr_1 = MT41J512M8RH125_EMIF_READ_LATENCY |
+				PHY_EN_DYN_PWRDN,
 };
 #endif
 
-- 
1.7.0.4

^ permalink raw reply related	[flat|nested] 263+ messages in thread

* [U-Boot] [PATCH] am335x: Enable DDR PHY dynamic power down bit for DDR3 boards
  2013-03-15  7:11 ` [U-Boot] [PATCH] am335x: Enable DDR PHY dynamic power down bit for DDR3 boards Vaibhav Hiremath
@ 2013-03-15 15:05   ` Tom Rini
  2013-03-15 15:56     ` Lars Poeschel
  2013-03-26 14:53   ` [U-Boot] " Tom Rini
  1 sibling, 1 reply; 263+ messages in thread
From: Tom Rini @ 2013-03-15 15:05 UTC (permalink / raw)
  To: u-boot

On Fri, Mar 15, 2013 at 12:41:16PM +0530, Vaibhav Hiremath wrote:

> Enable DDR PHY dynamic power down bit, which enables
> powering down the IO receiver when not performing read.
> 
> This also helps in reducing overall power consumption in
> low power states (suspend/standby).
> 
> Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
> Signed-off-by: Satyanarayana, Sandhya <sandhya.satyanarayana@ti.com>
> Cc: Tom Rini <trini@ti.com>
> ---
>  arch/arm/include/asm/arch-am33xx/ddr_defs.h |    1 +
>  board/ti/am335x/board.c                     |    6 ++++--
>  2 files changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/arm/include/asm/arch-am33xx/ddr_defs.h b/arch/arm/include/asm/arch-am33xx/ddr_defs.h
> index ae43ef8..7ab3baf 100644
> --- a/arch/arm/include/asm/arch-am33xx/ddr_defs.h
> +++ b/arch/arm/include/asm/arch-am33xx/ddr_defs.h
> @@ -28,6 +28,7 @@
>  #define VTP_CTRL_START_EN	(0x1)
>  #define PHY_DLL_LOCK_DIFF	0x0
>  #define DDR_CKE_CTRL_NORMAL	0x1
> +#define PHY_EN_DYN_PWRDN	(0x1 << 20)
>  
>  /* Micron MT47H128M16RT-25E */
>  #define MT47H128M16RT25E_EMIF_READ_LATENCY	0x100005
> diff --git a/board/ti/am335x/board.c b/board/ti/am335x/board.c
> index 48e6896..22d7b25 100644
> --- a/board/ti/am335x/board.c
> +++ b/board/ti/am335x/board.c
> @@ -251,7 +251,8 @@ static struct emif_regs ddr3_emif_reg_data = {
>  	.sdram_tim2 = MT41J128MJT125_EMIF_TIM2,
>  	.sdram_tim3 = MT41J128MJT125_EMIF_TIM3,
>  	.zq_config = MT41J128MJT125_ZQ_CFG,
> -	.emif_ddr_phy_ctlr_1 = MT41J128MJT125_EMIF_READ_LATENCY,
> +	.emif_ddr_phy_ctlr_1 = MT41J128MJT125_EMIF_READ_LATENCY |
> +				PHY_EN_DYN_PWRDN,
>  };
>  
>  static struct emif_regs ddr3_evm_emif_reg_data = {
> @@ -261,7 +262,8 @@ static struct emif_regs ddr3_evm_emif_reg_data = {
>  	.sdram_tim2 = MT41J512M8RH125_EMIF_TIM2,
>  	.sdram_tim3 = MT41J512M8RH125_EMIF_TIM3,
>  	.zq_config = MT41J512M8RH125_ZQ_CFG,
> -	.emif_ddr_phy_ctlr_1 = MT41J512M8RH125_EMIF_READ_LATENCY,
> +	.emif_ddr_phy_ctlr_1 = MT41J512M8RH125_EMIF_READ_LATENCY |
> +				PHY_EN_DYN_PWRDN,
>  };
>  #endif

Reviewed-by: Tom Rini <trini@ti.com>

Lars, I suspect pcm051 also could use a change like this.

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20130315/deefa054/attachment.pgp>

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [U-Boot] [PATCH] am335x: Enable DDR PHY dynamic power down bit for DDR3 boards
  2013-03-15 15:05   ` Tom Rini
@ 2013-03-15 15:56     ` Lars Poeschel
  0 siblings, 0 replies; 263+ messages in thread
From: Lars Poeschel @ 2013-03-15 15:56 UTC (permalink / raw)
  To: u-boot

On Friday 15 March 2013 at 16:05:24, Tom Rini wrote:
> On Fri, Mar 15, 2013 at 12:41:16PM +0530, Vaibhav Hiremath wrote:
> > Enable DDR PHY dynamic power down bit, which enables
> > powering down the IO receiver when not performing read.
> > 
> > This also helps in reducing overall power consumption in
> > low power states (suspend/standby).
> > 
> > Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
> > Signed-off-by: Satyanarayana, Sandhya <sandhya.satyanarayana@ti.com>
> > Cc: Tom Rini <trini@ti.com>
> > ---
> > 
> >  arch/arm/include/asm/arch-am33xx/ddr_defs.h |    1 +
> >  board/ti/am335x/board.c                     |    6 ++++--
> >  2 files changed, 5 insertions(+), 2 deletions(-)
> > 
> > diff --git a/arch/arm/include/asm/arch-am33xx/ddr_defs.h
> > b/arch/arm/include/asm/arch-am33xx/ddr_defs.h index ae43ef8..7ab3baf
> > 100644
> > --- a/arch/arm/include/asm/arch-am33xx/ddr_defs.h
> > +++ b/arch/arm/include/asm/arch-am33xx/ddr_defs.h
> > @@ -28,6 +28,7 @@
> > 
> >  #define VTP_CTRL_START_EN	(0x1)
> >  #define PHY_DLL_LOCK_DIFF	0x0
> >  #define DDR_CKE_CTRL_NORMAL	0x1
> > 
> > +#define PHY_EN_DYN_PWRDN	(0x1 << 20)
> > 
> >  /* Micron MT47H128M16RT-25E */
> >  #define MT47H128M16RT25E_EMIF_READ_LATENCY	0x100005
> > 
> > diff --git a/board/ti/am335x/board.c b/board/ti/am335x/board.c
> > index 48e6896..22d7b25 100644
> > --- a/board/ti/am335x/board.c
> > +++ b/board/ti/am335x/board.c
> > @@ -251,7 +251,8 @@ static struct emif_regs ddr3_emif_reg_data = {
> > 
> >  	.sdram_tim2 = MT41J128MJT125_EMIF_TIM2,
> >  	.sdram_tim3 = MT41J128MJT125_EMIF_TIM3,
> >  	.zq_config = MT41J128MJT125_ZQ_CFG,
> > 
> > -	.emif_ddr_phy_ctlr_1 = MT41J128MJT125_EMIF_READ_LATENCY,
> > +	.emif_ddr_phy_ctlr_1 = MT41J128MJT125_EMIF_READ_LATENCY |
> > +				PHY_EN_DYN_PWRDN,
> > 
> >  };
> >  
> >  static struct emif_regs ddr3_evm_emif_reg_data = {
> > 
> > @@ -261,7 +262,8 @@ static struct emif_regs ddr3_evm_emif_reg_data = {
> > 
> >  	.sdram_tim2 = MT41J512M8RH125_EMIF_TIM2,
> >  	.sdram_tim3 = MT41J512M8RH125_EMIF_TIM3,
> >  	.zq_config = MT41J512M8RH125_ZQ_CFG,
> > 
> > -	.emif_ddr_phy_ctlr_1 = MT41J512M8RH125_EMIF_READ_LATENCY,
> > +	.emif_ddr_phy_ctlr_1 = MT41J512M8RH125_EMIF_READ_LATENCY |
> > +				PHY_EN_DYN_PWRDN,
> > 
> >  };
> >  #endif
> 
> Reviewed-by: Tom Rini <trini@ti.com>
> 
> Lars, I suspect pcm051 also could use a change like this.

Many thanks for the hint! Yes, I think this could also be of use for pcm051. 
I can care about it and make a patch for pcm051 after my two weeks holiday :)

Lars

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [U-Boot] am335x: Enable DDR PHY dynamic power down bit for DDR3 boards
  2013-03-15  7:11 ` [U-Boot] [PATCH] am335x: Enable DDR PHY dynamic power down bit for DDR3 boards Vaibhav Hiremath
  2013-03-15 15:05   ` Tom Rini
@ 2013-03-26 14:53   ` Tom Rini
  1 sibling, 0 replies; 263+ messages in thread
From: Tom Rini @ 2013-03-26 14:53 UTC (permalink / raw)
  To: u-boot

On Thu, Mar 14, 2013 at 09:11:16PM -0000, hvaibhav at ti.com wrote:

> Enable DDR PHY dynamic power down bit, which enables
> powering down the IO receiver when not performing read.
> 
> This also helps in reducing overall power consumption in
> low power states (suspend/standby).
> 
> Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
> Signed-off-by: Satyanarayana, Sandhya <sandhya.satyanarayana@ti.com>
> Cc: Tom Rini <trini@ti.com>
> Reviewed-by: Tom Rini <trini@ti.com>

Applied to u-boot-ti/master (and already pulled into u-boot-arm),
thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20130326/98092055/attachment.pgp>

^ permalink raw reply	[flat|nested] 263+ messages in thread

* Re: [RFC PATCH 3/3] ARM: OMAP2+: Add command line parameter for debugSS module control
  2013-03-04 11:35 ` hvaibhav at ti.com
@ 2013-04-08 17:29   ` Tony Lindgren
  -1 siblings, 0 replies; 263+ messages in thread
From: Tony Lindgren @ 2013-04-08 17:29 UTC (permalink / raw)
  To: hvaibhav; +Cc: linux-omap, khilman, paul, rnayak, linux-arm-kernel

Hi,

* hvaibhav@ti.com <hvaibhav@ti.com> [130304 03:40]:
> From: Vaibhav Hiremath <hvaibhav@ti.com>
> 
> Currently there is no clean mechanism to control debugSS module and
> you have to always keep clocks enabled, either,
> 
>     - By enabling it during boot as part of clk_init function.
>     Or
>     - By having HWMOD_INIT_NO_IDLE flag in hwmod data.
> 
> Based on the discussion,
> http://www.mail-archive.com/linux-omap@vger.kernel.org/msg81771.html
> 
> This patch introduces new kernel parameter "omap_debugss_en",
> which will allow user to control debugSS module enable/disable
> part during boot-time.

I suggest you just make this part into a standard DT only
device driver. That way the command line parsing and clock
enabling can happen the normal way.

Is there any reason why this could not be a loadable module?

Regards,

Tony
 
> Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
> Cc: Kevin Hilman <khilman@linaro.org>
> Cc: Paul Walmsley <paul@pwsan.com>
> Cc: Tony Lindgren <tony@atomide.com>
> ---
> Tested on
> 	- AM335x based EVM and BeagleBone platforms
> 
>  Documentation/kernel-parameters.txt |    3 +
>  arch/arm/mach-omap2/Makefile        |    2 +-
>  arch/arm/mach-omap2/debugss.c       |   80 +++++++++++++++++++++++++++++++++++
>  3 files changed, 84 insertions(+), 1 deletions(-)
>  create mode 100644 arch/arm/mach-omap2/debugss.c
> 
> diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
> index 6c72381..bf1c822 100644
> --- a/Documentation/kernel-parameters.txt
> +++ b/Documentation/kernel-parameters.txt
> @@ -2051,6 +2051,9 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
>  			For example, to override I2C bus2:
>  			omap_mux=i2c2_scl.i2c2_scl=0x100,i2c2_sda.i2c2_sda=0x100
> 
> +	omap_debugss_en	[OMAP] Enable Debug Sub-System module required
> +			for JTAG debugging.
> +
>  	oprofile.timer=	[HW]
>  			Use timer interrupt instead of performance counters
> 
> diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile
> index d1156cf..aaf5cc2 100644
> --- a/arch/arm/mach-omap2/Makefile
> +++ b/arch/arm/mach-omap2/Makefile
> @@ -5,7 +5,7 @@
>  # Common support
>  obj-y := id.o io.o control.o mux.o devices.o fb.o serial.o gpmc.o timer.o pm.o \
>  	 common.o gpio.o dma.o wd_timer.o display.o i2c.o hdq1w.o omap_hwmod.o \
> -	 omap_device.o sram.o
> +	 omap_device.o sram.o debugss.o
> 
>  omap-2-3-common				= irq.o
>  hwmod-common				= omap_hwmod.o \
> diff --git a/arch/arm/mach-omap2/debugss.c b/arch/arm/mach-omap2/debugss.c
> new file mode 100644
> index 0000000..b45bf2c
> --- /dev/null
> +++ b/arch/arm/mach-omap2/debugss.c
> @@ -0,0 +1,80 @@
> +/*
> + * debugss.c: Debug Sus-System related code goes in here
> + *
> + * Copyright (C) {2013} Texas Instruments Incorporated - http://www.ti.com/
> + *
> + * This file is automatically generated from the AM33XX hardware databases.
> + * 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/init.h>
> +#include <linux/err.h>
> +#include <linux/clk.h>
> +
> +#include "omap_hwmod.h"
> +
> +static bool is_debugss_en;
> +
> +/**
> + * omap_debugss_en - Enable debugss clock/module based on user config
> + *
> + * During kernel bootup, omap2 hwmod framework will disable all the
> + * unused/unclaimed modules, which in turn also disables debugss module.
> + * This breaks any further debugging capability provided by HW.
> + *
> + *
> + * Introduce early param which allows user to enable clock/module -
> + *
> + *   omap_debugss_en	(For all OMAP2 architectures)
> + *
> + * Please note that, with this command-line param, module always remain
> + * enabled.
> + */
> +static int __init omap_debugss_en(char *str)
> +{
> +	is_debugss_en = true;
> +	return 0;
> +}
> +early_param("omap_debugss_en", omap_debugss_en);
> +
> +static int __init _omap2_debugss_enable(void)
> +{
> +	const char oh_name[10] = "debugss";
> +	struct omap_hwmod *oh;
> +	int ret;
> +
> +	if (is_debugss_en) {
> +		struct omap_hwmod_opt_clk *oc;
> +		int i;
> +
> +		oh = omap_hwmod_lookup(oh_name);
> +		if (!oh) {
> +			pr_err("debugss device not found\n");
> +			return 0;
> +		}
> +
> +		/* Make sure that hwmod internal data structures are setup */
> +		ret = omap_hwmod_setup_one(oh_name);
> +		if (ret) {
> +			pr_err("failed to setup hwmod for %s\n", oh_name);
> +			return 0;
> +		}
> +		/* Enable optional clocks */
> +		for (i = oh->opt_clks_cnt, oc = oh->opt_clks; i > 0; i--, oc++)	{
> +			if (oc->_clk)
> +				clk_prepare_enable(oc->_clk);
> +		}
> +		/* Enable debugss clock/module  */
> +		omap_hwmod_enable(oh);
> +	}
> +
> +	return 0;
> +}
> +device_initcall(_omap2_debugss_enable);
> --
> 1.7.0.4
> 

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [RFC PATCH 3/3] ARM: OMAP2+: Add command line parameter for debugSS module control
@ 2013-04-08 17:29   ` Tony Lindgren
  0 siblings, 0 replies; 263+ messages in thread
From: Tony Lindgren @ 2013-04-08 17:29 UTC (permalink / raw)
  To: linux-arm-kernel

Hi,

* hvaibhav at ti.com <hvaibhav@ti.com> [130304 03:40]:
> From: Vaibhav Hiremath <hvaibhav@ti.com>
> 
> Currently there is no clean mechanism to control debugSS module and
> you have to always keep clocks enabled, either,
> 
>     - By enabling it during boot as part of clk_init function.
>     Or
>     - By having HWMOD_INIT_NO_IDLE flag in hwmod data.
> 
> Based on the discussion,
> http://www.mail-archive.com/linux-omap at vger.kernel.org/msg81771.html
> 
> This patch introduces new kernel parameter "omap_debugss_en",
> which will allow user to control debugSS module enable/disable
> part during boot-time.

I suggest you just make this part into a standard DT only
device driver. That way the command line parsing and clock
enabling can happen the normal way.

Is there any reason why this could not be a loadable module?

Regards,

Tony
 
> Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
> Cc: Kevin Hilman <khilman@linaro.org>
> Cc: Paul Walmsley <paul@pwsan.com>
> Cc: Tony Lindgren <tony@atomide.com>
> ---
> Tested on
> 	- AM335x based EVM and BeagleBone platforms
> 
>  Documentation/kernel-parameters.txt |    3 +
>  arch/arm/mach-omap2/Makefile        |    2 +-
>  arch/arm/mach-omap2/debugss.c       |   80 +++++++++++++++++++++++++++++++++++
>  3 files changed, 84 insertions(+), 1 deletions(-)
>  create mode 100644 arch/arm/mach-omap2/debugss.c
> 
> diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
> index 6c72381..bf1c822 100644
> --- a/Documentation/kernel-parameters.txt
> +++ b/Documentation/kernel-parameters.txt
> @@ -2051,6 +2051,9 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
>  			For example, to override I2C bus2:
>  			omap_mux=i2c2_scl.i2c2_scl=0x100,i2c2_sda.i2c2_sda=0x100
> 
> +	omap_debugss_en	[OMAP] Enable Debug Sub-System module required
> +			for JTAG debugging.
> +
>  	oprofile.timer=	[HW]
>  			Use timer interrupt instead of performance counters
> 
> diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile
> index d1156cf..aaf5cc2 100644
> --- a/arch/arm/mach-omap2/Makefile
> +++ b/arch/arm/mach-omap2/Makefile
> @@ -5,7 +5,7 @@
>  # Common support
>  obj-y := id.o io.o control.o mux.o devices.o fb.o serial.o gpmc.o timer.o pm.o \
>  	 common.o gpio.o dma.o wd_timer.o display.o i2c.o hdq1w.o omap_hwmod.o \
> -	 omap_device.o sram.o
> +	 omap_device.o sram.o debugss.o
> 
>  omap-2-3-common				= irq.o
>  hwmod-common				= omap_hwmod.o \
> diff --git a/arch/arm/mach-omap2/debugss.c b/arch/arm/mach-omap2/debugss.c
> new file mode 100644
> index 0000000..b45bf2c
> --- /dev/null
> +++ b/arch/arm/mach-omap2/debugss.c
> @@ -0,0 +1,80 @@
> +/*
> + * debugss.c: Debug Sus-System related code goes in here
> + *
> + * Copyright (C) {2013} Texas Instruments Incorporated - http://www.ti.com/
> + *
> + * This file is automatically generated from the AM33XX hardware databases.
> + * 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/init.h>
> +#include <linux/err.h>
> +#include <linux/clk.h>
> +
> +#include "omap_hwmod.h"
> +
> +static bool is_debugss_en;
> +
> +/**
> + * omap_debugss_en - Enable debugss clock/module based on user config
> + *
> + * During kernel bootup, omap2 hwmod framework will disable all the
> + * unused/unclaimed modules, which in turn also disables debugss module.
> + * This breaks any further debugging capability provided by HW.
> + *
> + *
> + * Introduce early param which allows user to enable clock/module -
> + *
> + *   omap_debugss_en	(For all OMAP2 architectures)
> + *
> + * Please note that, with this command-line param, module always remain
> + * enabled.
> + */
> +static int __init omap_debugss_en(char *str)
> +{
> +	is_debugss_en = true;
> +	return 0;
> +}
> +early_param("omap_debugss_en", omap_debugss_en);
> +
> +static int __init _omap2_debugss_enable(void)
> +{
> +	const char oh_name[10] = "debugss";
> +	struct omap_hwmod *oh;
> +	int ret;
> +
> +	if (is_debugss_en) {
> +		struct omap_hwmod_opt_clk *oc;
> +		int i;
> +
> +		oh = omap_hwmod_lookup(oh_name);
> +		if (!oh) {
> +			pr_err("debugss device not found\n");
> +			return 0;
> +		}
> +
> +		/* Make sure that hwmod internal data structures are setup */
> +		ret = omap_hwmod_setup_one(oh_name);
> +		if (ret) {
> +			pr_err("failed to setup hwmod for %s\n", oh_name);
> +			return 0;
> +		}
> +		/* Enable optional clocks */
> +		for (i = oh->opt_clks_cnt, oc = oh->opt_clks; i > 0; i--, oc++)	{
> +			if (oc->_clk)
> +				clk_prepare_enable(oc->_clk);
> +		}
> +		/* Enable debugss clock/module  */
> +		omap_hwmod_enable(oh);
> +	}
> +
> +	return 0;
> +}
> +device_initcall(_omap2_debugss_enable);
> --
> 1.7.0.4
> 

^ permalink raw reply	[flat|nested] 263+ messages in thread

* Re: [RFC PATCH 0/3] ARM: OMAP2+: Add command line parameter for debugSS module control
  2013-03-14 11:29   ` Hiremath, Vaibhav
@ 2013-04-08 17:30     ` Tony Lindgren
  -1 siblings, 0 replies; 263+ messages in thread
From: Tony Lindgren @ 2013-04-08 17:30 UTC (permalink / raw)
  To: Hiremath, Vaibhav
  Cc: linux-omap, khilman, paul, Nayak, Rajendra, linux-arm-kernel

* Hiremath, Vaibhav <hvaibhav@ti.com> [130314 04:33]:
> > From: Hiremath, Vaibhav
> > This patch introduces new kernel parameter "omap_debugss_en",
> > which will allow user to control debugSS module enable/disable
> > part during boot-time.
> > 
> > In case of OMAP3, the debugSS is part of EMU domain and
> > is currently controlled by clock tree alone.
> > 
> > In case of OMAP4, the debugSS is part of EMU domain and
> > is currently controlled by clock tree, as MODULEMODE_SWCTRL
> > is not defined for hwmod.
> > 
> > In case of AM335x, the debugSS is in wakeup domain and is currently
> > controlled through hwmod alone. Currently we keep it always enabled.
> 
> Any comments or input on this patch series?

No comments on adding the clocks, but the enabling of
them should be just a regular device driver.

Regards,

Tony

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [RFC PATCH 0/3] ARM: OMAP2+: Add command line parameter for debugSS module control
@ 2013-04-08 17:30     ` Tony Lindgren
  0 siblings, 0 replies; 263+ messages in thread
From: Tony Lindgren @ 2013-04-08 17:30 UTC (permalink / raw)
  To: linux-arm-kernel

* Hiremath, Vaibhav <hvaibhav@ti.com> [130314 04:33]:
> > From: Hiremath, Vaibhav
> > This patch introduces new kernel parameter "omap_debugss_en",
> > which will allow user to control debugSS module enable/disable
> > part during boot-time.
> > 
> > In case of OMAP3, the debugSS is part of EMU domain and
> > is currently controlled by clock tree alone.
> > 
> > In case of OMAP4, the debugSS is part of EMU domain and
> > is currently controlled by clock tree, as MODULEMODE_SWCTRL
> > is not defined for hwmod.
> > 
> > In case of AM335x, the debugSS is in wakeup domain and is currently
> > controlled through hwmod alone. Currently we keep it always enabled.
> 
> Any comments or input on this patch series?

No comments on adding the clocks, but the enabling of
them should be just a regular device driver.

Regards,

Tony

^ permalink raw reply	[flat|nested] 263+ messages in thread

* RE: [RFC PATCH 3/3] ARM: OMAP2+: Add command line parameter for debugSS module control
  2013-04-08 17:29   ` Tony Lindgren
@ 2013-04-09  8:07     ` Hiremath, Vaibhav
  -1 siblings, 0 replies; 263+ messages in thread
From: Hiremath, Vaibhav @ 2013-04-09  8:07 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: linux-omap, khilman, paul, Nayak, Rajendra, linux-arm-kernel


> -----Original Message-----
> From: Tony Lindgren [mailto:tony@atomide.com]
> Sent: Monday, April 08, 2013 11:00 PM
> To: Hiremath, Vaibhav
> Cc: linux-omap@vger.kernel.org; khilman@linaro.org; paul@pwsan.com;
> Nayak, Rajendra; linux-arm-kernel@lists.infradead.org
> Subject: Re: [RFC PATCH 3/3] ARM: OMAP2+: Add command line parameter
> for debugSS module control
> 
> Hi,
> 
> * hvaibhav@ti.com <hvaibhav@ti.com> [130304 03:40]:
> > From: Vaibhav Hiremath <hvaibhav@ti.com>
> >
> > Currently there is no clean mechanism to control debugSS module and
> > you have to always keep clocks enabled, either,
> >
> >     - By enabling it during boot as part of clk_init function.
> >     Or
> >     - By having HWMOD_INIT_NO_IDLE flag in hwmod data.
> >
> > Based on the discussion,
> > http://www.mail-archive.com/linux-omap@vger.kernel.org/msg81771.html
> >
> > This patch introduces new kernel parameter "omap_debugss_en",
> > which will allow user to control debugSS module enable/disable
> > part during boot-time.
> 
> I suggest you just make this part into a standard DT only
> device driver. That way the command line parsing and clock
> enabling can happen the normal way.
> 

That’s good idea, as we are moving towards DT only boot support.
Also, are you suggesting to have both command-line param and DT
Property for this?


> Is there any reason why this could not be a loadable module?
> 

Because we want to keep it enabled before late_initcall. As part of late_initcall
Clock/hwmod framework will start disabling unused modules, which will impact the
Debugs as well. Consider the case where this debugss is loaded as a module, the user
Will loose the JTAG connection until the module is loaded; and once module is
Loaded, he has to again re-connect to the debugss.


With only DT option the code will look like below, is this what you also have in your mind -

arch/arm/boot/dts/am33xx.dtsi:

	debugss: debugss@4b000000 {
		compatible = "ti,debugss";
		ti,hwmods = "debugss";
		reg = <0x4b000000 1000000>;
		status = "disabled";	/* User need to enable it if he need JTAG connectivity*/
	};


arch/arm/mach-omap2/debugss.c:

	static int __init _omap2_debugss_enable(void)
	{
		struct device_node *np;
	
		np = of_find_matching_node(oh_name);
		if (!node || ! of_device_is_available()) {
			pr_err("debugss device is not found\n");
			return -ENODEV;
		}
		...
		hwmod lookup./setup/enable along with optional clock enable.
		...

	}
	device_initcall(_omap2_debugss_enable);

Thanks,
Vaibhav
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [RFC PATCH 3/3] ARM: OMAP2+: Add command line parameter for debugSS module control
@ 2013-04-09  8:07     ` Hiremath, Vaibhav
  0 siblings, 0 replies; 263+ messages in thread
From: Hiremath, Vaibhav @ 2013-04-09  8:07 UTC (permalink / raw)
  To: linux-arm-kernel


> -----Original Message-----
> From: Tony Lindgren [mailto:tony at atomide.com]
> Sent: Monday, April 08, 2013 11:00 PM
> To: Hiremath, Vaibhav
> Cc: linux-omap at vger.kernel.org; khilman at linaro.org; paul at pwsan.com;
> Nayak, Rajendra; linux-arm-kernel at lists.infradead.org
> Subject: Re: [RFC PATCH 3/3] ARM: OMAP2+: Add command line parameter
> for debugSS module control
> 
> Hi,
> 
> * hvaibhav at ti.com <hvaibhav@ti.com> [130304 03:40]:
> > From: Vaibhav Hiremath <hvaibhav@ti.com>
> >
> > Currently there is no clean mechanism to control debugSS module and
> > you have to always keep clocks enabled, either,
> >
> >     - By enabling it during boot as part of clk_init function.
> >     Or
> >     - By having HWMOD_INIT_NO_IDLE flag in hwmod data.
> >
> > Based on the discussion,
> > http://www.mail-archive.com/linux-omap at vger.kernel.org/msg81771.html
> >
> > This patch introduces new kernel parameter "omap_debugss_en",
> > which will allow user to control debugSS module enable/disable
> > part during boot-time.
> 
> I suggest you just make this part into a standard DT only
> device driver. That way the command line parsing and clock
> enabling can happen the normal way.
> 

That?s good idea, as we are moving towards DT only boot support.
Also, are you suggesting to have both command-line param and DT
Property for this?


> Is there any reason why this could not be a loadable module?
> 

Because we want to keep it enabled before late_initcall. As part of late_initcall
Clock/hwmod framework will start disabling unused modules, which will impact the
Debugs as well. Consider the case where this debugss is loaded as a module, the user
Will loose the JTAG connection until the module is loaded; and once module is
Loaded, he has to again re-connect to the debugss.


With only DT option the code will look like below, is this what you also have in your mind -

arch/arm/boot/dts/am33xx.dtsi:

	debugss: debugss at 4b000000 {
		compatible = "ti,debugss";
		ti,hwmods = "debugss";
		reg = <0x4b000000 1000000>;
		status = "disabled";	/* User need to enable it if he need JTAG connectivity*/
	};


arch/arm/mach-omap2/debugss.c:

	static int __init _omap2_debugss_enable(void)
	{
		struct device_node *np;
	
		np = of_find_matching_node(oh_name);
		if (!node || ! of_device_is_available()) {
			pr_err("debugss device is not found\n");
			return -ENODEV;
		}
		...
		hwmod lookup./setup/enable along with optional clock enable.
		...

	}
	device_initcall(_omap2_debugss_enable);

Thanks,
Vaibhav

^ permalink raw reply	[flat|nested] 263+ messages in thread

* RE: [RFC PATCH 0/3] ARM: OMAP2+: Add command line parameter for debugSS module control
  2013-04-08 17:30     ` Tony Lindgren
@ 2013-04-09  8:11       ` Hiremath, Vaibhav
  -1 siblings, 0 replies; 263+ messages in thread
From: Hiremath, Vaibhav @ 2013-04-09  8:11 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: linux-omap, khilman, paul, Nayak, Rajendra, linux-arm-kernel


> -----Original Message-----
> From: Tony Lindgren [mailto:tony@atomide.com]
> Sent: Monday, April 08, 2013 11:01 PM
> To: Hiremath, Vaibhav
> Cc: linux-omap@vger.kernel.org; khilman@linaro.org; paul@pwsan.com;
> Nayak, Rajendra; linux-arm-kernel@lists.infradead.org
> Subject: Re: [RFC PATCH 0/3] ARM: OMAP2+: Add command line parameter
> for debugSS module control
> 
> * Hiremath, Vaibhav <hvaibhav@ti.com> [130314 04:33]:
> > > From: Hiremath, Vaibhav
> > > This patch introduces new kernel parameter "omap_debugss_en",
> > > which will allow user to control debugSS module enable/disable
> > > part during boot-time.
> > >
> > > In case of OMAP3, the debugSS is part of EMU domain and
> > > is currently controlled by clock tree alone.
> > >
> > > In case of OMAP4, the debugSS is part of EMU domain and
> > > is currently controlled by clock tree, as MODULEMODE_SWCTRL
> > > is not defined for hwmod.
> > >
> > > In case of AM335x, the debugSS is in wakeup domain and is currently
> > > controlled through hwmod alone. Currently we keep it always
> enabled.
> >
> > Any comments or input on this patch series?
> 
> No comments on adding the clocks, but the enabling of
> them should be just a regular device driver.
> 

Thanks for review, on this patch I will add your Reviewed-by line on next version
Of the patch-series.

I have just responded my comment to the other mail on this, and based on
Your response we can conclude. 

Thanks,
Vaibhav
.


^ permalink raw reply	[flat|nested] 263+ messages in thread

* [RFC PATCH 0/3] ARM: OMAP2+: Add command line parameter for debugSS module control
@ 2013-04-09  8:11       ` Hiremath, Vaibhav
  0 siblings, 0 replies; 263+ messages in thread
From: Hiremath, Vaibhav @ 2013-04-09  8:11 UTC (permalink / raw)
  To: linux-arm-kernel


> -----Original Message-----
> From: Tony Lindgren [mailto:tony at atomide.com]
> Sent: Monday, April 08, 2013 11:01 PM
> To: Hiremath, Vaibhav
> Cc: linux-omap at vger.kernel.org; khilman at linaro.org; paul at pwsan.com;
> Nayak, Rajendra; linux-arm-kernel at lists.infradead.org
> Subject: Re: [RFC PATCH 0/3] ARM: OMAP2+: Add command line parameter
> for debugSS module control
> 
> * Hiremath, Vaibhav <hvaibhav@ti.com> [130314 04:33]:
> > > From: Hiremath, Vaibhav
> > > This patch introduces new kernel parameter "omap_debugss_en",
> > > which will allow user to control debugSS module enable/disable
> > > part during boot-time.
> > >
> > > In case of OMAP3, the debugSS is part of EMU domain and
> > > is currently controlled by clock tree alone.
> > >
> > > In case of OMAP4, the debugSS is part of EMU domain and
> > > is currently controlled by clock tree, as MODULEMODE_SWCTRL
> > > is not defined for hwmod.
> > >
> > > In case of AM335x, the debugSS is in wakeup domain and is currently
> > > controlled through hwmod alone. Currently we keep it always
> enabled.
> >
> > Any comments or input on this patch series?
> 
> No comments on adding the clocks, but the enabling of
> them should be just a regular device driver.
> 

Thanks for review, on this patch I will add your Reviewed-by line on next version
Of the patch-series.

I have just responded my comment to the other mail on this, and based on
Your response we can conclude. 

Thanks,
Vaibhav
.

^ permalink raw reply	[flat|nested] 263+ messages in thread

* Re: [RFC PATCH 3/3] ARM: OMAP2+: Add command line parameter for debugSS module control
  2013-04-09  8:07     ` Hiremath, Vaibhav
@ 2013-04-09 16:34       ` Tony Lindgren
  -1 siblings, 0 replies; 263+ messages in thread
From: Tony Lindgren @ 2013-04-09 16:34 UTC (permalink / raw)
  To: Hiremath, Vaibhav
  Cc: linux-omap, khilman, paul, Nayak, Rajendra, linux-arm-kernel

* Hiremath, Vaibhav <hvaibhav@ti.com> [130409 01:12]:
> > From: Tony Lindgren [mailto:tony@atomide.com]
> > 
> > I suggest you just make this part into a standard DT only
> > device driver. That way the command line parsing and clock
> > enabling can happen the normal way.
> > 
> 
> That’s good idea, as we are moving towards DT only boot support.
> Also, are you suggesting to have both command-line param and DT
> Property for this?
> 
> 
> > Is there any reason why this could not be a loadable module?
> > 
> 
> Because we want to keep it enabled before late_initcall. As part of late_initcall
> Clock/hwmod framework will start disabling unused modules, which will impact the
> Debugs as well. Consider the case where this debugss is loaded as a module, the user
> Will loose the JTAG connection until the module is loaded; and once module is
> Loaded, he has to again re-connect to the debugss.

It will get run before late_initcall if compiled in. Sounds
like there are no issues also make it work as a loadable module
as needed.
 
> With only DT option the code will look like below, is this what you also have in your mind -
> 
> arch/arm/boot/dts/am33xx.dtsi:
> 
> 	debugss: debugss@4b000000 {
> 		compatible = "ti,debugss";
> 		ti,hwmods = "debugss";
> 		reg = <0x4b000000 1000000>;
> 		status = "disabled";	/* User need to enable it if he need JTAG connectivity*/
> 	};
>
>
> arch/arm/mach-omap2/debugss.c:
> 
> 	static int __init _omap2_debugss_enable(void)
> 	{
> 		struct device_node *np;
> 	
> 		np = of_find_matching_node(oh_name);
> 		if (!node || ! of_device_is_available()) {
> 			pr_err("debugss device is not found\n");
> 			return -ENODEV;
> 		}
> 		...
> 		hwmod lookup./setup/enable along with optional clock enable.
> 		...
> 
> 	}
> 	device_initcall(_omap2_debugss_enable);

It should be all standard device driver stuff. I'd make it just
regular module_platform_driver and only initialize it earlier if
compiled in.

Regards,

Tony


--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [RFC PATCH 3/3] ARM: OMAP2+: Add command line parameter for debugSS module control
@ 2013-04-09 16:34       ` Tony Lindgren
  0 siblings, 0 replies; 263+ messages in thread
From: Tony Lindgren @ 2013-04-09 16:34 UTC (permalink / raw)
  To: linux-arm-kernel

* Hiremath, Vaibhav <hvaibhav@ti.com> [130409 01:12]:
> > From: Tony Lindgren [mailto:tony at atomide.com]
> > 
> > I suggest you just make this part into a standard DT only
> > device driver. That way the command line parsing and clock
> > enabling can happen the normal way.
> > 
> 
> That?s good idea, as we are moving towards DT only boot support.
> Also, are you suggesting to have both command-line param and DT
> Property for this?
> 
> 
> > Is there any reason why this could not be a loadable module?
> > 
> 
> Because we want to keep it enabled before late_initcall. As part of late_initcall
> Clock/hwmod framework will start disabling unused modules, which will impact the
> Debugs as well. Consider the case where this debugss is loaded as a module, the user
> Will loose the JTAG connection until the module is loaded; and once module is
> Loaded, he has to again re-connect to the debugss.

It will get run before late_initcall if compiled in. Sounds
like there are no issues also make it work as a loadable module
as needed.
 
> With only DT option the code will look like below, is this what you also have in your mind -
> 
> arch/arm/boot/dts/am33xx.dtsi:
> 
> 	debugss: debugss at 4b000000 {
> 		compatible = "ti,debugss";
> 		ti,hwmods = "debugss";
> 		reg = <0x4b000000 1000000>;
> 		status = "disabled";	/* User need to enable it if he need JTAG connectivity*/
> 	};
>
>
> arch/arm/mach-omap2/debugss.c:
> 
> 	static int __init _omap2_debugss_enable(void)
> 	{
> 		struct device_node *np;
> 	
> 		np = of_find_matching_node(oh_name);
> 		if (!node || ! of_device_is_available()) {
> 			pr_err("debugss device is not found\n");
> 			return -ENODEV;
> 		}
> 		...
> 		hwmod lookup./setup/enable along with optional clock enable.
> 		...
> 
> 	}
> 	device_initcall(_omap2_debugss_enable);

It should be all standard device driver stuff. I'd make it just
regular module_platform_driver and only initialize it earlier if
compiled in.

Regards,

Tony

^ permalink raw reply	[flat|nested] 263+ messages in thread

* RE: [RFC PATCH 3/3] ARM: OMAP2+: Add command line parameter for debugSS module control
  2013-04-09 16:34       ` Tony Lindgren
@ 2013-04-10  5:11         ` Hiremath, Vaibhav
  -1 siblings, 0 replies; 263+ messages in thread
From: Hiremath, Vaibhav @ 2013-04-10  5:11 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: linux-omap, khilman, paul, Nayak, Rajendra, linux-arm-kernel


> -----Original Message-----
> From: Tony Lindgren [mailto:tony@atomide.com]
> Sent: Tuesday, April 09, 2013 10:05 PM
> To: Hiremath, Vaibhav
> Cc: linux-omap@vger.kernel.org; khilman@linaro.org; paul@pwsan.com;
> Nayak, Rajendra; linux-arm-kernel@lists.infradead.org
> Subject: Re: [RFC PATCH 3/3] ARM: OMAP2+: Add command line parameter
> for debugSS module control
> 
> * Hiremath, Vaibhav <hvaibhav@ti.com> [130409 01:12]:
> > > From: Tony Lindgren [mailto:tony@atomide.com]
> > >
> > > I suggest you just make this part into a standard DT only
> > > device driver. That way the command line parsing and clock
> > > enabling can happen the normal way.
> > >
> >
> > That’s good idea, as we are moving towards DT only boot support.
> > Also, are you suggesting to have both command-line param and DT
> > Property for this?
> >
> >
> > > Is there any reason why this could not be a loadable module?
> > >
> >
> > Because we want to keep it enabled before late_initcall. As part of
> late_initcall
> > Clock/hwmod framework will start disabling unused modules, which will
> impact the
> > Debugs as well. Consider the case where this debugss is loaded as a
> module, the user
> > Will loose the JTAG connection until the module is loaded; and once
> module is
> > Loaded, he has to again re-connect to the debugss.
> 
> It will get run before late_initcall if compiled in. Sounds
> like there are no issues also make it work as a loadable module
> as needed.
> 
Agreed on making it as a module.

But do you think we should allow it as a loadable module (M) as well, 
as user will loose Connectivity to JTAG during boot.
Another perspective here would be, user can insert the module and
Get JTAG connectivity, which also seems ok to me.

Can you also confirm on having command line argument? I think
We can only live with DT based approach, right?

Thanks,
Vaibhav 


^ permalink raw reply	[flat|nested] 263+ messages in thread

* [RFC PATCH 3/3] ARM: OMAP2+: Add command line parameter for debugSS module control
@ 2013-04-10  5:11         ` Hiremath, Vaibhav
  0 siblings, 0 replies; 263+ messages in thread
From: Hiremath, Vaibhav @ 2013-04-10  5:11 UTC (permalink / raw)
  To: linux-arm-kernel


> -----Original Message-----
> From: Tony Lindgren [mailto:tony at atomide.com]
> Sent: Tuesday, April 09, 2013 10:05 PM
> To: Hiremath, Vaibhav
> Cc: linux-omap at vger.kernel.org; khilman at linaro.org; paul at pwsan.com;
> Nayak, Rajendra; linux-arm-kernel at lists.infradead.org
> Subject: Re: [RFC PATCH 3/3] ARM: OMAP2+: Add command line parameter
> for debugSS module control
> 
> * Hiremath, Vaibhav <hvaibhav@ti.com> [130409 01:12]:
> > > From: Tony Lindgren [mailto:tony at atomide.com]
> > >
> > > I suggest you just make this part into a standard DT only
> > > device driver. That way the command line parsing and clock
> > > enabling can happen the normal way.
> > >
> >
> > That?s good idea, as we are moving towards DT only boot support.
> > Also, are you suggesting to have both command-line param and DT
> > Property for this?
> >
> >
> > > Is there any reason why this could not be a loadable module?
> > >
> >
> > Because we want to keep it enabled before late_initcall. As part of
> late_initcall
> > Clock/hwmod framework will start disabling unused modules, which will
> impact the
> > Debugs as well. Consider the case where this debugss is loaded as a
> module, the user
> > Will loose the JTAG connection until the module is loaded; and once
> module is
> > Loaded, he has to again re-connect to the debugss.
> 
> It will get run before late_initcall if compiled in. Sounds
> like there are no issues also make it work as a loadable module
> as needed.
> 
Agreed on making it as a module.

But do you think we should allow it as a loadable module (M) as well, 
as user will loose Connectivity to JTAG during boot.
Another perspective here would be, user can insert the module and
Get JTAG connectivity, which also seems ok to me.

Can you also confirm on having command line argument? I think
We can only live with DT based approach, right?

Thanks,
Vaibhav 

^ permalink raw reply	[flat|nested] 263+ messages in thread

* Re: [RFC PATCH 3/3] ARM: OMAP2+: Add command line parameter for debugSS module control
  2013-04-10  5:11         ` Hiremath, Vaibhav
@ 2013-04-10 17:07           ` Tony Lindgren
  -1 siblings, 0 replies; 263+ messages in thread
From: Tony Lindgren @ 2013-04-10 17:07 UTC (permalink / raw)
  To: Hiremath, Vaibhav
  Cc: linux-omap, khilman, paul, Nayak, Rajendra, linux-arm-kernel

* Hiremath, Vaibhav <hvaibhav@ti.com> [130409 22:16]:
> Agreed on making it as a module.
> 
> But do you think we should allow it as a loadable module (M) as well, 
> as user will loose Connectivity to JTAG during boot.
> Another perspective here would be, user can insert the module and
> Get JTAG connectivity, which also seems ok to me.

Yes both ways should be doable.
 
> Can you also confirm on having command line argument? I think
> We can only live with DT based approach, right?

Well I doubt that anybody wants to keep it permanently enabled
because of the power consumption and blocking of PM states, so
an additional cmdline might make sense.

It would be nice to have it most of the time built-in but disable
itself unless something debug is specified in the cmdline.

Maybe the JTAG driver can detect when the cable is connected?
Or maybe that would be only when there's clock coming over
JTAG?

Regards,

Tony

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [RFC PATCH 3/3] ARM: OMAP2+: Add command line parameter for debugSS module control
@ 2013-04-10 17:07           ` Tony Lindgren
  0 siblings, 0 replies; 263+ messages in thread
From: Tony Lindgren @ 2013-04-10 17:07 UTC (permalink / raw)
  To: linux-arm-kernel

* Hiremath, Vaibhav <hvaibhav@ti.com> [130409 22:16]:
> Agreed on making it as a module.
> 
> But do you think we should allow it as a loadable module (M) as well, 
> as user will loose Connectivity to JTAG during boot.
> Another perspective here would be, user can insert the module and
> Get JTAG connectivity, which also seems ok to me.

Yes both ways should be doable.
 
> Can you also confirm on having command line argument? I think
> We can only live with DT based approach, right?

Well I doubt that anybody wants to keep it permanently enabled
because of the power consumption and blocking of PM states, so
an additional cmdline might make sense.

It would be nice to have it most of the time built-in but disable
itself unless something debug is specified in the cmdline.

Maybe the JTAG driver can detect when the cable is connected?
Or maybe that would be only when there's clock coming over
JTAG?

Regards,

Tony

^ permalink raw reply	[flat|nested] 263+ messages in thread

* Re: [RFC PATCH 1/3] ARM: AM33XX: clock: Add debugSS clock nodes to clock tree
  2013-03-04 11:35 ` hvaibhav at ti.com
@ 2013-05-29 19:07   ` Paul Walmsley
  -1 siblings, 0 replies; 263+ messages in thread
From: Paul Walmsley @ 2013-05-29 19:07 UTC (permalink / raw)
  To: Vaibhav Hiremath
  Cc: linux-omap, tony, khilman, b-cousson, rnayak, linux-arm-kernel

On Mon, 4 Mar 2013, hvaibhav@ti.com wrote:

> From: Vaibhav Hiremath <hvaibhav@ti.com>
> 
> Represent debugSS clock interface as provided in
> CM_WKUP_DEBUGSS_CLKCTRL register, which includes,
> 	- Clock gate for optional DEBUG_CLKA and DBGSYSCLK
> 	- Clock Mux for TRC_PMD and STM_PMD
> 	- Clock divider for STM and TPIU
> 
> Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
> Cc: Kevin Hilman <khilman@linaro.org>
> Cc: Paul Walmsley <paul@pwsan.com>
> Cc: Tony Lindgren <tony@atomide.com>
> Cc: Rajendra Nayak <rnayak@ti.com>

Acked-by: Paul Walmsley <paul@pwsan.com>

based on a quick glance.


- Paul

^ permalink raw reply	[flat|nested] 263+ messages in thread

* [RFC PATCH 1/3] ARM: AM33XX: clock: Add debugSS clock nodes to clock tree
@ 2013-05-29 19:07   ` Paul Walmsley
  0 siblings, 0 replies; 263+ messages in thread
From: Paul Walmsley @ 2013-05-29 19:07 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, 4 Mar 2013, hvaibhav at ti.com wrote:

> From: Vaibhav Hiremath <hvaibhav@ti.com>
> 
> Represent debugSS clock interface as provided in
> CM_WKUP_DEBUGSS_CLKCTRL register, which includes,
> 	- Clock gate for optional DEBUG_CLKA and DBGSYSCLK
> 	- Clock Mux for TRC_PMD and STM_PMD
> 	- Clock divider for STM and TPIU
> 
> Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
> Cc: Kevin Hilman <khilman@linaro.org>
> Cc: Paul Walmsley <paul@pwsan.com>
> Cc: Tony Lindgren <tony@atomide.com>
> Cc: Rajendra Nayak <rnayak@ti.com>

Acked-by: Paul Walmsley <paul@pwsan.com>

based on a quick glance.


- Paul

^ permalink raw reply	[flat|nested] 263+ messages in thread

end of thread, other threads:[~2013-05-29 19:07 UTC | newest]

Thread overview: 263+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-12-02  6:43 [PATCH-V5 2/3] arm:omap:am33xx: Add AM335XEVM machine support hvaibhav
2011-12-02  6:43 ` hvaibhav at ti.com
2012-05-02  9:23 ` Paul Walmsley
2012-05-02  9:23   ` Paul Walmsley
2012-05-02  9:34   ` Hiremath, Vaibhav
2012-05-02  9:34     ` Hiremath, Vaibhav
2012-05-03 15:57     ` Tony Lindgren
2012-05-03 15:57       ` Tony Lindgren
2012-05-03 16:41       ` Hiremath, Vaibhav
2012-05-03 16:41         ` Hiremath, Vaibhav
2012-05-03 19:37         ` Tony Lindgren
2012-05-03 19:37           ` Tony Lindgren
2012-05-04  6:14           ` Hiremath, Vaibhav
2012-05-04  6:14             ` Hiremath, Vaibhav
2012-05-03 21:17         ` Kevin Hilman
2012-05-03 21:17           ` Kevin Hilman
2012-05-04  6:00           ` Hiremath, Vaibhav
2012-05-04  6:00             ` Hiremath, Vaibhav
2012-05-04 20:05             ` Tony Lindgren
2012-05-04 20:05               ` Tony Lindgren
2012-05-07 14:38               ` Hiremath, Vaibhav
2012-05-07 14:38                 ` Hiremath, Vaibhav
2012-05-07 17:32                 ` Tony Lindgren
2012-05-07 17:32                   ` Tony Lindgren
2012-05-07 18:55                   ` Hiremath, Vaibhav
2012-05-07 18:55                     ` Hiremath, Vaibhav
2012-05-08 19:06                     ` Tony Lindgren
2012-05-08 19:06                       ` Tony Lindgren
2012-05-08 19:57                       ` Hiremath, Vaibhav
2012-05-08 19:57                         ` Hiremath, Vaibhav
2012-05-04  6:28       ` Hiremath, Vaibhav
2012-05-04  6:28         ` Hiremath, Vaibhav
2012-05-04 20:00         ` Tony Lindgren
2012-05-04 20:00           ` Tony Lindgren
  -- strict thread matches above, loose matches on Subject: below --
2013-03-04 11:35 [RFC PATCH 3/3] ARM: OMAP2+: Add command line parameter for debugSS module control hvaibhav
2013-03-04 11:35 ` hvaibhav at ti.com
2013-04-08 17:29 ` Tony Lindgren
2013-04-08 17:29   ` Tony Lindgren
2013-04-09  8:07   ` Hiremath, Vaibhav
2013-04-09  8:07     ` Hiremath, Vaibhav
2013-04-09 16:34     ` Tony Lindgren
2013-04-09 16:34       ` Tony Lindgren
2013-04-10  5:11       ` Hiremath, Vaibhav
2013-04-10  5:11         ` Hiremath, Vaibhav
2013-04-10 17:07         ` Tony Lindgren
2013-04-10 17:07           ` Tony Lindgren
2013-03-04 11:35 [RFC PATCH 1/3] ARM: AM33XX: clock: Add debugSS clock nodes to clock tree hvaibhav
2013-03-04 11:35 ` hvaibhav at ti.com
2013-05-29 19:07 ` Paul Walmsley
2013-05-29 19:07   ` Paul Walmsley
2013-03-04 11:35 [RFC PATCH 0/3] ARM: OMAP2+: Add command line parameter for debugSS module control hvaibhav
2013-03-04 11:35 ` hvaibhav at ti.com
2013-03-14 11:29 ` Hiremath, Vaibhav
2013-03-14 11:29   ` Hiremath, Vaibhav
2013-04-08 17:30   ` Tony Lindgren
2013-04-08 17:30     ` Tony Lindgren
2013-04-09  8:11     ` Hiremath, Vaibhav
2013-04-09  8:11       ` Hiremath, Vaibhav
2011-12-02  6:43 [PATCH-V5 1/3] arm:omap:am33xx: Update common OMAP machine specific sources hvaibhav
2011-12-02  6:43 ` hvaibhav at ti.com
2011-12-07 21:09 ` Tony Lindgren
2011-12-07 21:09   ` Tony Lindgren
2011-12-02  6:43 [PATCH-V5 0/3] Introducing TI's New SoC/board AM335XEVM hvaibhav
2011-12-02  6:43 ` hvaibhav at ti.com
2011-12-07  0:24 ` Kevin Hilman
2011-12-07  0:24   ` Kevin Hilman
2011-12-07 21:10   ` Tony Lindgren
2011-12-07 21:10     ` Tony Lindgren
2011-12-08 13:45     ` Hiremath, Vaibhav
2011-12-08 13:45       ` Hiremath, Vaibhav
2011-12-08 17:18       ` Tony Lindgren
2011-12-08 17:18         ` Tony Lindgren
2012-02-01  6:53         ` Hiremath, Vaibhav
2012-02-01  6:53           ` Hiremath, Vaibhav
2012-01-18  8:47     ` Hiremath, Vaibhav
2012-01-18  8:47       ` Hiremath, Vaibhav
2011-09-20 14:32 [PATCH-V3 4/4] arm:omap:am33xx: Add low level debugging support hvaibhav
2011-09-20 14:32 ` hvaibhav at ti.com
2011-10-06 23:09 ` Tony Lindgren
2011-10-06 23:09   ` Tony Lindgren
2011-11-07 15:17   ` Hiremath, Vaibhav
2011-11-07 15:17     ` Hiremath, Vaibhav
2011-11-07 18:16     ` Tony Lindgren
2011-11-07 18:16       ` Tony Lindgren
2011-09-20 14:32 [PATCH-V3 3/4] arm:omap:am33xx: Create board support and enable build for AM335XEVM hvaibhav
2011-09-20 14:32 ` hvaibhav at ti.com
2011-10-06 23:07 ` Tony Lindgren
2011-10-06 23:07   ` Tony Lindgren
2011-09-20 14:32 [PATCH-V3 2/4] arm:omap:am33xx: Update common OMAP machine specific sources hvaibhav
2011-09-20 14:32 ` hvaibhav at ti.com
2011-09-26 18:45 ` Kevin Hilman
2011-09-26 18:45   ` Kevin Hilman
2011-09-30 12:09   ` Premi, Sanjeev
2011-09-30 12:09     ` Premi, Sanjeev
2011-09-30 17:09     ` Kevin Hilman
2011-09-30 17:09       ` Kevin Hilman
2011-10-06 23:03       ` Tony Lindgren
2011-10-06 23:03         ` Tony Lindgren
2011-11-03 13:48         ` Hiremath, Vaibhav
2011-11-03 13:48           ` Hiremath, Vaibhav
2011-11-05  9:41 ` Hiremath, Vaibhav
2011-11-05  9:41   ` Hiremath, Vaibhav
2011-11-05 10:29   ` Hiremath, Vaibhav
2011-11-05 10:29     ` Hiremath, Vaibhav
2011-09-20 14:32 [PATCH-V3 1/4] arm:omap:am33xx: Update common omap platform files hvaibhav
2011-09-20 14:32 ` hvaibhav at ti.com
2011-10-06 23:03 ` Tony Lindgren
2011-10-06 23:03   ` Tony Lindgren
2011-08-29 12:46 [RFC PATCH-V2 0/4] Introducing TI's New SoC/board AM335XEVM hvaibhav
2011-08-29 12:46 ` hvaibhav at ti.com
2011-09-15  0:32 ` Tony Lindgren
2011-09-15  0:32   ` Tony Lindgren
2011-09-15  7:13   ` Hiremath, Vaibhav
2011-09-15  7:13     ` Hiremath, Vaibhav
     [not found] <hvaibhav@ti.com>
2008-11-21 15:22 ` [PATCH 2/2] TVP514x V4L int device driver support hvaibhav
2008-11-21 16:16   ` Hans Verkuil
2008-11-21 18:12   ` Trilok Soni
2008-11-21 18:12     ` Trilok Soni
2008-11-21 19:07     ` Hiremath, Vaibhav
2008-11-21 19:07       ` Hiremath, Vaibhav
2008-11-21 19:11     ` David Brownell
2008-11-23 22:00   ` Hans Verkuil
2008-11-23 22:04     ` Koen Kooi
2008-11-24  6:16     ` Trilok Soni
2008-11-24  6:16       ` Trilok Soni
2008-11-24  6:32       ` David Brownell
2008-11-24  7:53         ` Hans Verkuil
2008-11-24  8:53           ` Hiremath, Vaibhav
2008-11-24  8:53             ` Hiremath, Vaibhav
2008-11-24  8:04       ` Hans Verkuil
2008-11-24  8:04         ` Hans Verkuil
2008-11-24  8:43         ` Trilok Soni
2008-11-24  8:43           ` Trilok Soni
2008-11-24  8:59           ` Hiremath, Vaibhav
2008-11-24  8:59             ` Hiremath, Vaibhav
2008-11-24 10:06   ` David Brownell
2008-11-26 17:04 ` [PATCH 1/2] Add Input/Output related ioctl support hvaibhav
2008-11-26 17:15   ` Hans Verkuil
2008-11-26 17:15     ` Hans Verkuil
2008-11-26 17:05 ` [PATCH 2/2] TVP514x Driver with Review comments fixed hvaibhav
2008-11-26 17:05   ` hvaibhav
2008-11-26 17:48   ` Hans Verkuil
2008-12-02 15:35 ` [PATCH 2/2] TVP514x Driver with Review comments fixed [V4] hvaibhav
2008-12-02 15:35   ` hvaibhav
2008-12-02 17:20   ` Hans Verkuil
2008-12-03  3:58     ` Hiremath, Vaibhav
2008-12-03  3:58       ` Hiremath, Vaibhav
2008-12-03 13:43     ` V4L2 PIXEL buffer conversion Jonathan Lafontaine
2008-12-02 19:29   ` [PATCH 2/2] TVP514x Driver with Review comments fixed [V4] David Brownell
2008-12-02 19:44   ` David Brownell
2009-11-18  6:58 ` [U-Boot] [PATCH] OMAP3EVM: Added NAND support hvaibhav at ti.com
2009-11-18  7:30   ` Dirk Behme
2009-11-18  8:25     ` Hiremath, Vaibhav
2009-11-18 18:07   ` Nishanth Menon
2009-11-18 18:18     ` Scott Wood
2009-11-18 18:40     ` Hiremath, Vaibhav
2009-11-18  8:26 ` hvaibhav at ti.com
2009-11-18  8:36   ` Dirk Behme
2009-11-18 14:40     ` Hiremath, Vaibhav
2009-11-23 11:05 ` [U-Boot] [PATCH V4] " hvaibhav at ti.com
2009-11-27 15:51   ` Tom
2009-11-30 17:49     ` Hiremath, Vaibhav
2009-11-23 11:06 ` [U-Boot] [PATCH] omap3_mmc: Encapsulate twl4030 under option CONFIG_TWL4030_POWER hvaibhav at ti.com
2009-11-27 14:03   ` Tom
2009-11-30 17:43     ` Hiremath, Vaibhav
2009-11-23 11:06 ` [U-Boot] [PATCH 1/5] Introducing AM3517EVM support hvaibhav at ti.com
2009-11-23 19:43   ` Wolfgang Denk
2009-11-26  4:24     ` Hiremath, Vaibhav
2009-11-23 11:08 ` [U-Boot] [PATCH 0/5] Introducing TI's New SoC/board AM3517EVM hvaibhav at ti.com
2009-11-23 13:50   ` Paulraj, Sandeep
2009-11-23 14:16     ` Hiremath, Vaibhav
2009-11-23 20:03     ` Wolfgang Denk
2009-11-26  4:49       ` Hiremath, Vaibhav
2009-11-25 20:24   ` Tom
2009-11-23 11:08 ` [U-Boot] [PATCH 2/5] am3517_evm_config options added to Makfile hvaibhav at ti.com
2009-11-23 19:44   ` Wolfgang Denk
2009-11-26  4:25     ` Hiremath, Vaibhav
2009-11-23 11:08 ` [U-Boot] [PATCH 3/5] Added configuration file for AM3517EVM hvaibhav at ti.com
2009-11-23 19:46   ` Wolfgang Denk
2009-11-26  4:43     ` Hiremath, Vaibhav
2009-11-26 16:04       ` Tom
2009-11-30 17:01         ` Hiremath, Vaibhav
2009-12-05  0:20       ` Wolfgang Denk
2009-11-23 11:08 ` [U-Boot] [PATCH 4/5] AM3517EVM: Add mux configuration hvaibhav at ti.com
2009-11-23 19:49   ` Wolfgang Denk
2009-11-26  4:45     ` Hiremath, Vaibhav
2009-11-26 16:07       ` Tom
2009-12-05  0:23       ` Wolfgang Denk
2009-11-23 11:09 ` [U-Boot] [PATCH 5/5] AM3517: Add support for EMIF4 hvaibhav at ti.com
2009-11-23 19:50   ` Wolfgang Denk
2009-11-26  4:48     ` Hiremath, Vaibhav
2009-11-26 16:14       ` Tom
2009-11-30 17:03         ` Hiremath, Vaibhav
2010-01-30 10:16 ` [U-Boot] [PATCH 0/3] Add Support for AM3517EVM with EMIF4 hvaibhav at ti.com
2010-02-02 18:40   ` Hiremath, Vaibhav
2010-02-03 13:24     ` Tom
2010-02-03 13:26       ` Hiremath, Vaibhav
2010-01-30 10:16 ` [U-Boot] [PATCH 1/3] OMAP3: Consolidate SDRC related operations hvaibhav at ti.com
2010-02-07 16:13   ` Tom
2010-02-10  9:35     ` Hiremath, Vaibhav
2010-04-23 14:55 ` [U-Boot] [RESEND:PATCH-V4] OMAP3EVM: Added NAND support hvaibhav at ti.com
2010-05-05 20:01   ` Wolfgang Denk
2010-05-06  5:36     ` Hiremath, Vaibhav
2010-05-06 10:40       ` Nishanth Menon
2010-05-06 10:50         ` Wolfgang Denk
2010-05-06 10:54           ` Nishanth Menon
2010-05-06 11:03             ` Wolfgang Denk
2010-05-06 11:11               ` Nishanth Menon
2010-05-06 11:28                 ` Wolfgang Denk
2010-05-06 11:04           ` Hiremath, Vaibhav
2010-05-06 10:59       ` Wolfgang Denk
2010-04-23 14:55 ` [U-Boot] [PATCH-V2 2/4] omap3: Consolidate SDRC related operations hvaibhav at ti.com
2010-05-05 20:07   ` Wolfgang Denk
2010-05-06  6:49     ` Hiremath, Vaibhav
2010-05-06 10:55       ` Wolfgang Denk
2010-04-23 14:55 ` [U-Boot] [PATCH-V2 3/4] AM35x: Add support for AM3517EVM hvaibhav at ti.com
2010-05-05 20:12   ` Wolfgang Denk
2010-05-06  6:52     ` Hiremath, Vaibhav
2010-05-06 10:52       ` Wolfgang Denk
2010-04-23 14:55 ` [U-Boot] [PATCH-V2 4/4] AM35x: Add support for EMIF4 hvaibhav at ti.com
2010-05-05 20:14   ` Wolfgang Denk
2010-05-06  6:56     ` Hiremath, Vaibhav
2010-05-06 10:56       ` Wolfgang Denk
2010-05-06 17:19 ` [U-Boot] [PATCH-V5] OMAP3EVM: Added NAND support hvaibhav at ti.com
2010-05-11  4:59   ` Hiremath, Vaibhav
2010-05-11  8:59     ` Wolfgang Denk
2010-05-11  9:01       ` Hiremath, Vaibhav
2010-05-11 20:11       ` Scott Wood
2010-05-06 17:23 ` [U-Boot] [PATCH-V3 1/2] AM35x: Add support for AM3517EVM hvaibhav at ti.com
2010-05-11  5:00   ` Hiremath, Vaibhav
2010-05-31  9:40   ` Wolfgang Denk
2010-06-03 17:27     ` Hiremath, Vaibhav
2010-06-07  8:56     ` Hiremath, Vaibhav
2010-06-07 12:24       ` Wolfgang Denk
2010-06-07 14:23         ` Hiremath, Vaibhav
2010-05-06 17:23 ` [U-Boot] [PATCH-V3 2/2] AM35x: Add support for EMIF4 hvaibhav at ti.com
2010-05-31  9:43   ` Wolfgang Denk
2010-06-03 17:28     ` Hiremath, Vaibhav
2010-06-07 14:59 ` [U-Boot] [PATCH-V4 1/2] AM35x: Add support for AM3517EVM hvaibhav at ti.com
2010-06-07 21:20   ` Paulraj, Sandeep
2010-11-29 16:21 ` [U-Boot] [PATCH] AM3517:Fix for ARM Relocation support hvaibhav at ti.com
2010-11-29 16:24   ` Hiremath, Vaibhav
2010-11-29 16:32     ` Paulraj, Sandeep
2010-11-29 16:22 ` [U-Boot] [PATCH] AM3517:Build FIX: undef CONFIG_CMD_NFS support hvaibhav at ti.com
2010-11-29 21:36   ` Paulraj, Sandeep
2010-11-29 16:23 ` [U-Boot] [PATCH] AM3517:EMIF4: fix SDRAM size to 256Mb hvaibhav at ti.com
2010-11-29 21:36   ` Paulraj, Sandeep
2010-11-29 21:37   ` Paulraj, Sandeep
2011-08-01 14:21 ` [U-Boot] [PATCH] omap3evm: Use generic MMC driver hvaibhav at ti.com
2011-08-17  2:32   ` Andy Fleming
2011-08-01 14:21 ` [U-Boot] [PATCH] am3517evm: " hvaibhav at ti.com
2011-08-17  2:33   ` Andy Fleming
2013-03-15  7:11 ` [U-Boot] [PATCH] am335x: Enable DDR PHY dynamic power down bit for DDR3 boards Vaibhav Hiremath
2013-03-15 15:05   ` Tom Rini
2013-03-15 15:56     ` Lars Poeschel
2013-03-26 14:53   ` [U-Boot] " Tom Rini
2009-05-06 18:31 [PATCH (V2)] TVP514x: Migration to sub-device framework hvaibhav
2009-06-14 10:14 ` Hans Verkuil
2009-06-14 12:44   ` Hans Verkuil
2009-06-14 14:32     ` tcm825x.c: migrating to sub-device framework? (was: TVP514x: Migration to sub-device framework) Hans Verkuil
2009-06-15  8:45       ` tcm825x.c: migrating to sub-device framework? Sakari Ailus
2009-06-14 19:50   ` [PATCH (V2)] TVP514x: Migration to sub-device framework David Brownell
2009-06-14 19:50     ` David Brownell

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.