From: Santiago Nunez-Corrales <[email protected]>

This patch provides support for TVP7002 in architecture definitions
within DM365.

Signed-off-by: Santiago Nunez-Corrales <[email protected]>
---
 arch/arm/mach-davinci/board-dm365-evm.c |   60 ++++++++++++++++++++++++++++--
 1 files changed, 56 insertions(+), 4 deletions(-)

diff --git a/arch/arm/mach-davinci/board-dm365-evm.c 
b/arch/arm/mach-davinci/board-dm365-evm.c
index 362ac62..ce91724 100644
--- a/arch/arm/mach-davinci/board-dm365-evm.c
+++ b/arch/arm/mach-davinci/board-dm365-evm.c
@@ -43,6 +43,7 @@
 #include <mach/nand.h>
 #include <linux/videodev2.h>
 #include <media/tvp514x.h>
+#include <media/tvp7002.h>
 
 
 static inline int have_imager(void)
@@ -53,14 +54,20 @@ static inline int have_imager(void)
 
 static inline int have_tvp7002(void)
 {
-       /* REVISIT when it's supported, trigger via Kconfig */
+#ifdef CONFIG_VIDEO_TVP7002
+       return 1;
+#else
        return 0;
+#endif
 }
 
 
 #define DM365_ASYNC_EMIF_CONTROL_BASE  0x01d10000
 #define DM365_ASYNC_EMIF_DATA_CE0_BASE 0x02000000
 #define DM365_ASYNC_EMIF_DATA_CE1_BASE 0x04000000
+#define DM365_ASYNC_EMIF_DATA_CE1_REG3 0x18
+#define DM365_ASYNC_EMIF_VIDEO_MUX_MASK        (0x07070707)
+#define DM365_ASYNC_EMIF_TVP7002_SEL   (0x01010101)
 
 #define DM365_EVM_PHY_MASK             (0x2)
 #define DM365_EVM_MDIO_FREQUENCY       (2200000) /* PHY bus frequency */
@@ -243,6 +250,23 @@ static struct v4l2_input tvp5146_inputs[] = {
        },
 };
 
+#define TVP7002_STD_ALL        (V4L2_STD_480P_60   | V4L2_STD_576P_50  |\
+                               V4L2_STD_480I_60   | V4L2_STD_576I_50   |\
+                               V4L2_STD_720P_50   | V4L2_STD_720P_60   |\
+                               V4L2_STD_1080I_50  | V4L2_STD_1080I_60  |\
+                               V4L2_STD_1080P_50  | V4L2_STD_1080P_60)
+
+                               
+/* Inputs available at the TVP7002 */
+static struct v4l2_input tvp7002_inputs[] = {
+       {
+               .index = 0,
+               .name = "Component",
+               .type = V4L2_INPUT_TYPE_CAMERA,
+               .std = TVP7002_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
@@ -260,7 +284,7 @@ static struct vpfe_route tvp5146_routes[] = {
 };
 
 static struct vpfe_subdev_info vpfe_sub_devs[] = {
-{
+        {
                .module_name = "tvp5146",
                .grp_id = 0,
                .num_inputs = ARRAY_SIZE(tvp5146_inputs),
@@ -276,6 +300,22 @@ static struct vpfe_subdev_info vpfe_sub_devs[] = {
                        I2C_BOARD_INFO("tvp5146", 0x5d),
                        .platform_data = &tvp5146_pdata,
                },
+       },
+        {
+               .module_name = "tvp7002",
+               .grp_id = 0,
+               .num_inputs = ARRAY_SIZE(tvp7002_inputs),
+               .inputs = tvp7002_inputs,
+               .can_route = 1,
+               .ccdc_if_params = {
+                       .if_type = VPFE_BT1120,
+                       .hdpol = VPFE_PINPOL_POSITIVE,
+                       .vdpol = VPFE_PINPOL_POSITIVE,
+               },
+               .board_info = {
+                       I2C_BOARD_INFO("tvp7002", 0x5c),
+                       .platform_data = &tvp7002_pdata,
+               },
        }
 };
 
@@ -439,6 +479,16 @@ static int __init cpld_leds_init(void)
 /* run after subsys_initcall() for LEDs */
 fs_initcall(cpld_leds_init);
 
+/* Set the input mux for TVP7002 */
+int tvp7002_set_input_mux(unsigned char channel)
+{
+       u32 val;
+       val = __raw_readl(DM365_ASYNC_EMIF_DATA_CE1_REG3);
+       val &= ~DM365_ASYNC_EMIF_VIDEO_MUX_MASK;
+       val |= DM365_ASYNC_EMIF_TVP7002_SEL;
+       __raw_writel(val, DM365_ASYNC_EMIF_DATA_CE1_REG3);
+       return 0;
+}
 
 static void __init evm_init_cpld(void)
 {
@@ -519,6 +569,8 @@ fail:
                        mux |= 2;
                        resets &= ~BIT(2);
                        label = "tvp7002 HD";
+                       // Call the input setter
+                       tvp7002_set_input_mux(0);
                } else {
                        /* default to tvp5146 */
                        mux |= 5;
@@ -526,8 +578,8 @@ fail:
                        label = "tvp5146 SD";
                }
        }
-       __raw_writeb(mux, cpld + CPLD_MUX);
-       __raw_writeb(resets, cpld + CPLD_RESETS);
+       __raw_writel(mux, cpld + CPLD_MUX);
+       __raw_writel(resets, cpld + CPLD_RESETS);
        pr_info("EVM: %s video input\n", label);
 
        /* REVISIT export switches: NTSC/PAL (SW5.6), EXTRA1 (SW5.2), etc */
-- 
1.6.0.4


_______________________________________________
Davinci-linux-open-source mailing list
[email protected]
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source

Reply via email to