Hello Russell,

This patch is part of the vpfe capture driver (V4L) that adds platform code for 
the driver on DM6446 which is an ARM based SoC. I have attached the original 
pull request to this email. Please review this and Let us know your comments.

Thanks.

Murali Karicheri
[email protected]

From: [email protected]
To: [email protected],
 [email protected]
Cc: Muralidharan Karicheri <[email protected]>
Subject: [PATCH 8/11 - v3] DM6446 platform changes for vpfe capture driver
Date: Mon,  6 Jul 2009 13:32:37 -0400

From: Muralidharan Karicheri <[email protected]>

DM644x platform and board setup

This adds plarform and board setup changes required to support
vpfe capture driver on DM644x

Reviewed by: Hans Verkuil <[email protected]>
Reviewed by: Laurent Pinchart <[email protected]>
Reviewed by: Kevin Hilman <[email protected]>
Reviewed by: David Brownell <[email protected]>

Signed-off-by: Muralidharan Karicheri <[email protected]>
---
Applies to Linus' GIT Tree

 arch/arm/mach-davinci/board-dm644x-evm.c    |   72 ++++++++++++++++++++++++++-
 arch/arm/mach-davinci/dm644x.c              |   56 +++++++++++++++++++++
 arch/arm/mach-davinci/include/mach/dm644x.h |    2 +
 3 files changed, 128 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-davinci/board-dm644x-evm.c 
b/arch/arm/mach-davinci/board-dm644x-evm.c
index d9d4045..151a622 100644
--- a/arch/arm/mach-davinci/board-dm644x-evm.c
+++ b/arch/arm/mach-davinci/board-dm644x-evm.c
@@ -28,7 +28,8 @@
 #include <linux/io.h>
 #include <linux/phy.h>
 #include <linux/clk.h>
-
+#include <linux/videodev2.h>
+#include <media/tvp514x.h>
 #include <asm/setup.h>
 #include <asm/mach-types.h>
 
@@ -195,6 +196,72 @@ static struct platform_device davinci_fb_device = {
        .num_resources = 0,
 };
 
+static struct tvp514x_platform_data tvp5146_pdata = {
+       .clk_polarity = 0,
+       .hs_polarity = 1,
+       .vs_polarity = 1
+};
+
+#define TVP514X_STD_ALL        (V4L2_STD_NTSC | V4L2_STD_PAL)
+/* Inputs available at the TVP5146 */
+static struct v4l2_input tvp5146_inputs[] = {
+       {
+               .index = 0,
+               .name = "Composite",
+               .type = V4L2_INPUT_TYPE_CAMERA,
+               .std = TVP514X_STD_ALL,
+       },
+       {
+               .index = 1,
+               .name = "S-Video",
+               .type = V4L2_INPUT_TYPE_CAMERA,
+               .std = TVP514X_STD_ALL,
+       },
+};
+
+/*
+ * this is the route info for connecting each input to decoder
+ * ouput that goes to vpfe. There is a one to one correspondence
+ * with tvp5146_inputs
+ */
+static struct vpfe_route tvp5146_routes[] = {
+       {
+               .input = INPUT_CVBS_VI2B,
+               .output = OUTPUT_10BIT_422_EMBEDDED_SYNC,
+       },
+       {
+               .input = INPUT_SVIDEO_VI2C_VI1C,
+               .output = OUTPUT_10BIT_422_EMBEDDED_SYNC,
+       },
+};
+
+static struct vpfe_subdev_info vpfe_sub_devs[] = {
+       {
+               .name = "tvp5146",
+               .grp_id = 0,
+               .num_inputs = ARRAY_SIZE(tvp5146_inputs),
+               .inputs = tvp5146_inputs,
+               .routes = tvp5146_routes,
+               .can_route = 1,
+               .ccdc_if_params = {
+                       .if_type = VPFE_BT656,
+                       .hdpol = VPFE_PINPOL_POSITIVE,
+                       .vdpol = VPFE_PINPOL_POSITIVE,
+               },
+               .board_info = {
+                       I2C_BOARD_INFO("tvp5146", 0x5d),
+                       .platform_data = &tvp5146_pdata,
+               },
+       },
+};
+
+static struct vpfe_config vpfe_cfg = {
+       .num_subdevs = ARRAY_SIZE(vpfe_sub_devs),
+       .sub_devs = vpfe_sub_devs,
+       .card_name = "DM6446 EVM",
+       .ccdc = "DM6446 CCDC",
+};
+
 static struct platform_device rtc_dev = {
        .name           = "rtc_davinci_evm",
        .id             = -1,
@@ -560,7 +627,6 @@ static struct i2c_board_info __initdata i2c_info[] =  {
        },
        /* ALSO:
         * - tvl320aic33 audio codec (0x1b)
-        * - tvp5146 video decoder (0x5d)
         */
 };
 
@@ -591,6 +657,8 @@ static struct davinci_uart_config uart_config __initdata = {
 static void __init
 davinci_evm_map_io(void)
 {
+       /* setup input configuration for VPFE input devices */
+       dm644x_set_vpfe_config(&vpfe_cfg);
        dm644x_init();
 }
 
diff --git a/arch/arm/mach-davinci/dm644x.c b/arch/arm/mach-davinci/dm644x.c
index fb5449b..cc8fc78 100644
--- a/arch/arm/mach-davinci/dm644x.c
+++ b/arch/arm/mach-davinci/dm644x.c
@@ -530,6 +530,59 @@ static struct platform_device dm644x_edma_device = {
        .resource               = edma_resources,
 };
 
+static struct resource dm644x_vpss_resources[] = {
+       {
+               /* VPSS Base address */
+               .name           = "vpss",
+               .start          = 0x01c73400,
+               .end            = 0x01c73400 + 0xff,
+               .flags          = IORESOURCE_MEM,
+       },
+};
+
+static struct platform_device dm644x_vpss_device = {
+       .name                   = "vpss",
+       .id                     = -1,
+       .dev.platform_data      = "dm644x_vpss",
+       .num_resources          = ARRAY_SIZE(dm644x_vpss_resources),
+       .resource               = dm644x_vpss_resources,
+};
+
+static struct resource vpfe_resources[] = {
+       {
+               .start          = IRQ_VDINT0,
+               .end            = IRQ_VDINT0,
+               .flags          = IORESOURCE_IRQ,
+       },
+       {
+               .start          = IRQ_VDINT1,
+               .end            = IRQ_VDINT1,
+               .flags          = IORESOURCE_IRQ,
+       },
+       {
+               .start          = 0x01c70400,
+               .end            = 0x01c70400 + 0xff,
+               .flags          = IORESOURCE_MEM,
+       },
+};
+
+static u64 vpfe_capture_dma_mask = DMA_BIT_MASK(32);
+static struct platform_device vpfe_capture_dev = {
+       .name           = CAPTURE_DRV_NAME,
+       .id             = -1,
+       .num_resources  = ARRAY_SIZE(vpfe_resources),
+       .resource       = vpfe_resources,
+       .dev = {
+               .dma_mask               = &vpfe_capture_dma_mask,
+               .coherent_dma_mask      = DMA_BIT_MASK(32),
+       },
+};
+
+void dm644x_set_vpfe_config(struct vpfe_config *cfg)
+{
+       vpfe_capture_dev.dev.platform_data = cfg;
+}
+
 /*----------------------------------------------------------------------*/
 
 static struct map_desc dm644x_io_desc[] = {
@@ -652,6 +705,9 @@ static int __init dm644x_init_devices(void)
 
        platform_device_register(&dm644x_edma_device);
        platform_device_register(&dm644x_emac_device);
+       platform_device_register(&dm644x_vpss_device);
+       platform_device_register(&vpfe_capture_dev);
+
        return 0;
 }
 postcore_initcall(dm644x_init_devices);
diff --git a/arch/arm/mach-davinci/include/mach/dm644x.h 
b/arch/arm/mach-davinci/include/mach/dm644x.h
index 15d42b9..0066db3 100644
--- a/arch/arm/mach-davinci/include/mach/dm644x.h
+++ b/arch/arm/mach-davinci/include/mach/dm644x.h
@@ -25,6 +25,7 @@
 #include <linux/platform_device.h>
 #include <mach/hardware.h>
 #include <mach/emac.h>
+#include <media/davinci/vpfe_capture.h>
 
 #define DM644X_EMAC_BASE               (0x01C80000)
 #define DM644X_EMAC_CNTRL_OFFSET       (0x0000)
@@ -34,5 +35,6 @@
 #define DM644X_EMAC_CNTRL_RAM_SIZE     (0x2000)
 
 void __init dm644x_init(void);
+void dm644x_set_vpfe_config(struct vpfe_config *cfg);
 
 #endif /* __ASM_ARCH_DM644X_H */
-- 
1.6.0.4
--- Begin Message ---
Em Fri, 26 Jun 2009 21:01:50 +0200
Hans Verkuil <[email protected]> escreveu:

> Hi Mauro,
> 
> Please pull from http://www.linuxtv.org/hg/~hverkuil/v4l-dvb-dm646x for the 
> following:
> 
> - ARM: DaVinci: DM646x Video: VPIF driver
> - ARM: DaVinci: DM646x Video: Add VPIF display driver
> - ARM: DaVinci: DM646x Video: Makefile and config files modifications for 
> Display
> - ARM: DaVinci: DM646x Video: Fix compile time warnings for mutex locking
> 
> Note that these four patches depend on the attached platform patch that
> should be applied to the git tree first.
> 
> If possible, it would be great if this (like the vpfe capture driver) can be
> merged for 2.6.31.

Hmm... I'm not seeing Russel ack on the arch/arm patch. Russel, could you
please review the enclosed patch? Would this be ok for 2.6.31?

Cheers,
Mauro.

---

[PATCH] ARM: DaVinci: DM646x Video: Platform and board specific setup
From: Chaithrika U S <[email protected]>

Platform specific display device setup for DM646x EVM

Add platform device and resource structures. Also define a platform specific
clock setup function that can be accessed by the driver to configure the clock
and CPLD.

Signed-off-by: Chaithrika U S <[email protected]>
Signed-off-by: Manjunath Hadli <[email protected]>
Signed-off-by: Brijesh Jadav <[email protected]>
Signed-off-by: Kevin Hilman <[email protected]>

 arch/arm/mach-davinci/board-dm646x-evm.c    |  122 +++++++++++++++++++++++++++
 arch/arm/mach-davinci/dm646x.c              |   62 ++++++++++++++
 arch/arm/mach-davinci/include/mach/dm646x.h |   24 +++++
 3 files changed, 208 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-davinci/board-dm646x-evm.c 
b/arch/arm/mach-davinci/board-dm646x-evm.c
index e17de63..eb4bd01 100644
--- a/arch/arm/mach-davinci/board-dm646x-evm.c
+++ b/arch/arm/mach-davinci/board-dm646x-evm.c
@@ -52,6 +52,19 @@
 #define DM646X_EVM_PHY_MASK            (0x2)
 #define DM646X_EVM_MDIO_FREQUENCY      (2200000) /* PHY bus frequency */
 
+#define VIDCLKCTL_OFFSET       (0x38)
+#define VSCLKDIS_OFFSET                (0x6c)
+
+#define VCH2CLK_MASK           (BIT_MASK(10) | BIT_MASK(9) | BIT_MASK(8))
+#define VCH2CLK_SYSCLK8                (BIT(9))
+#define VCH2CLK_AUXCLK         (BIT(9) | BIT(8))
+#define VCH3CLK_MASK           (BIT_MASK(14) | BIT_MASK(13) | BIT_MASK(12))
+#define VCH3CLK_SYSCLK8                (BIT(13))
+#define VCH3CLK_AUXCLK         (BIT(14) | BIT(13))
+
+#define VIDCH2CLK              (BIT(10))
+#define VIDCH3CLK              (BIT(11))
+
 static struct davinci_uart_config uart_config __initdata = {
        .enabled_uarts = (1 << 0),
 };
@@ -207,6 +220,40 @@ static struct at24_platform_data eeprom_info = {
        .context        = (void *)0x7f00,
 };
 
+static struct i2c_client *cpld_client;
+
+static int cpld_video_probe(struct i2c_client *client,
+                       const struct i2c_device_id *id)
+{
+       cpld_client = client;
+       return 0;
+}
+
+static int __devexit cpld_video_remove(struct i2c_client *client)
+{
+       cpld_client = NULL;
+       return 0;
+}
+
+static const struct i2c_device_id cpld_video_id[] = {
+       { "cpld_video", 0 },
+       { }
+};
+
+static struct i2c_driver cpld_video_driver = {
+       .driver = {
+               .name   = "cpld_video",
+       },
+       .probe          = cpld_video_probe,
+       .remove         = cpld_video_remove,
+       .id_table       = cpld_video_id,
+};
+
+static void evm_init_cpld(void)
+{
+       i2c_add_driver(&cpld_video_driver);
+}
+
 static struct i2c_board_info __initdata i2c_info[] =  {
        {
                I2C_BOARD_INFO("24c256", 0x50),
@@ -216,6 +263,9 @@ static struct i2c_board_info __initdata i2c_info[] =  {
                I2C_BOARD_INFO("pcf8574a", 0x38),
                .platform_data  = &pcf_data,
        },
+       {
+               I2C_BOARD_INFO("cpld_video", 0x3B),
+       },
 };
 
 static struct davinci_i2c_platform_data i2c_pdata = {
@@ -223,10 +273,81 @@ static struct davinci_i2c_platform_data i2c_pdata = {
        .bus_delay      = 0 /* usec */,
 };
 
+static int set_vpif_clock(int mux_mode, int hd)
+{
+       int val = 0;
+       int err = 0;
+       unsigned int value;
+       void __iomem *base = IO_ADDRESS(DAVINCI_SYSTEM_MODULE_BASE);
+
+       /* disable the clock */
+       value = __raw_readl(base + VSCLKDIS_OFFSET);
+       value |= (VIDCH3CLK | VIDCH2CLK);
+       __raw_writel(value, base + VSCLKDIS_OFFSET);
+
+       val = i2c_smbus_read_byte(cpld_client);
+       if (val < 0)
+               return val;
+
+       if (mux_mode == 1)
+               val &= ~0x40;
+       else
+               val |= 0x40;
+
+       err = i2c_smbus_write_byte(cpld_client, val);
+       if (err)
+               return err;
+
+       value = __raw_readl(base + VIDCLKCTL_OFFSET);
+       value &= ~(VCH2CLK_MASK);
+       value &= ~(VCH3CLK_MASK);
+
+       if (hd >= 1)
+               value |= (VCH2CLK_SYSCLK8 | VCH3CLK_SYSCLK8);
+       else
+               value |= (VCH2CLK_AUXCLK | VCH3CLK_AUXCLK);
+
+       __raw_writel(value, base + VIDCLKCTL_OFFSET);
+
+       /* enable the clock */
+       value = __raw_readl(base + VSCLKDIS_OFFSET);
+       value &= ~(VIDCH3CLK | VIDCH2CLK);
+       __raw_writel(value, base + VSCLKDIS_OFFSET);
+
+       return 0;
+}
+
+static const struct subdev_info dm646x_vpif_subdev[] = {
+       {
+               .addr   = 0x2A,
+               .name   = "adv7343",
+       },
+       {
+               .addr   = 0x2C,
+               .name   = "ths7303",
+       },
+};
+
+static const char *output[] = {
+       "Composite",
+       "Component",
+       "S-Video",
+};
+
+static struct vpif_config dm646x_vpif_config = {
+       .set_clock      = set_vpif_clock,
+       .subdevinfo     = dm646x_vpif_subdev,
+       .subdev_count   = ARRAY_SIZE(dm646x_vpif_subdev),
+       .output         = output,
+       .output_count   = ARRAY_SIZE(output),
+       .card_name      = "DM646x EVM",
+};
+
 static void __init evm_init_i2c(void)
 {
        davinci_init_i2c(&i2c_pdata);
        i2c_register_board_info(1, i2c_info, ARRAY_SIZE(i2c_info));
+       evm_init_cpld();
 }
 
 static void __init davinci_map_io(void)
@@ -243,6 +364,7 @@ static __init void evm_init(void)
 
        soc_info->emac_pdata->phy_mask = DM646X_EVM_PHY_MASK;
        soc_info->emac_pdata->mdio_max_freq = DM646X_EVM_MDIO_FREQUENCY;
+       dm646x_setup_vpif(&dm646x_vpif_config);
 }
 
 static __init void davinci_dm646x_evm_irq_init(void)
diff --git a/arch/arm/mach-davinci/dm646x.c b/arch/arm/mach-davinci/dm646x.c
index 64a291f..50dba53 100644
--- a/arch/arm/mach-davinci/dm646x.c
+++ b/arch/arm/mach-davinci/dm646x.c
@@ -31,6 +31,15 @@
 #include "clock.h"
 #include "mux.h"
 
+#define DAVINCI_VPIF_BASE       (0x01C12000)
+#define VDD3P3V_PWDN_OFFSET    (0x48)
+#define VSCLKDIS_OFFSET                (0x6C)
+
+#define VDD3P3V_VID_MASK       (BIT_MASK(7) | BIT_MASK(6) | BIT_MASK(5) |\
+                                       BIT_MASK(4))
+#define VSCLKDIS_MASK          (BIT_MASK(11) | BIT_MASK(10) | BIT_MASK(9) |\
+                                       BIT_MASK(8))
+
 /*
  * Device specific clocks
  */
@@ -587,6 +596,37 @@ static struct platform_device dm646x_edma_device = {
        .resource               = edma_resources,
 };
 
+static u64 vpif_dma_mask = DMA_BIT_MASK(32);
+
+static struct resource vpif_resource[] = {
+       {
+               .start  = DAVINCI_VPIF_BASE,
+               .end    = DAVINCI_VPIF_BASE + 0x03fff,
+               .flags  = IORESOURCE_MEM,
+       },
+       {
+               .start = IRQ_DM646X_VP_VERTINT2,
+               .end   = IRQ_DM646X_VP_VERTINT2,
+               .flags = IORESOURCE_IRQ,
+       },
+       {
+               .start = IRQ_DM646X_VP_VERTINT3,
+               .end   = IRQ_DM646X_VP_VERTINT3,
+               .flags = IORESOURCE_IRQ,
+       },
+};
+
+static struct platform_device vpif_display_dev = {
+       .name           = "vpif_display",
+       .id             = -1,
+       .dev            = {
+                       .dma_mask               = &vpif_dma_mask,
+                       .coherent_dma_mask      = DMA_32BIT_MASK,
+       },
+       .resource       = vpif_resource,
+       .num_resources  = ARRAY_SIZE(vpif_resource),
+};
+
 /*----------------------------------------------------------------------*/
 
 static struct map_desc dm646x_io_desc[] = {
@@ -696,6 +736,28 @@ static struct davinci_soc_info davinci_soc_info_dm646x = {
        .sram_len               = SZ_32K,
 };
 
+void dm646x_setup_vpif(struct vpif_config *config)
+{
+       unsigned int value;
+       void __iomem *base = IO_ADDRESS(DAVINCI_SYSTEM_MODULE_BASE);
+
+       value = __raw_readl(base + VSCLKDIS_OFFSET);
+       value &= ~VSCLKDIS_MASK;
+       __raw_writel(value, base + VSCLKDIS_OFFSET);
+
+       value = __raw_readl(base + VDD3P3V_PWDN_OFFSET);
+       value &= ~VDD3P3V_VID_MASK;
+       __raw_writel(value, base + VDD3P3V_PWDN_OFFSET);
+
+       davinci_cfg_reg(DM646X_STSOMUX_DISABLE);
+       davinci_cfg_reg(DM646X_STSIMUX_DISABLE);
+       davinci_cfg_reg(DM646X_PTSOMUX_DISABLE);
+       davinci_cfg_reg(DM646X_PTSIMUX_DISABLE);
+
+       vpif_display_dev.dev.platform_data = config;
+       platform_device_register(&vpif_display_dev);
+}
+
 void __init dm646x_init(void)
 {
        davinci_common_init(&davinci_soc_info_dm646x);
diff --git a/arch/arm/mach-davinci/include/mach/dm646x.h 
b/arch/arm/mach-davinci/include/mach/dm646x.h
index 1fc764c..7409b6d 100644
--- a/arch/arm/mach-davinci/include/mach/dm646x.h
+++ b/arch/arm/mach-davinci/include/mach/dm646x.h
@@ -23,4 +23,28 @@
 
 void __init dm646x_init(void);
 
+void dm646x_video_init(void);
+
+struct vpif_output {
+       u16 id;
+       const char *name;
+};
+
+struct subdev_info {
+       unsigned short addr;
+       const char *name;
+};
+
+struct vpif_config {
+       int (*set_clock)(int, int);
+       const struct subdev_info *subdevinfo;
+       int subdev_count;
+       const char **output;
+       int output_count;
+       const char *card_name;
+};
+
+
+void dm646x_setup_vpif(struct vpif_config *config);
+
 #endif /* __ASM_ARCH_DM646X_H */




Cheers,
Mauro


--- End Message ---

Reply via email to