video: exynos_dp: Add function to parse DP DT node
authorAjay Kumar <ajaykumar.rs@samsung.com>
Thu, 21 Feb 2013 23:53:06 +0000 (23:53 +0000)
committerMinkyu Kang <mk7.kang@samsung.com>
Wed, 27 Mar 2013 12:23:15 +0000 (21:23 +0900)
Add function to parse the required platform data fron DP DT node
and fill the edp_info structure.

Signed-off-by: Ajay Kumar <ajaykumar.rs@samsung.com>
Signed-off-by: Minkyu Kang <mk7.kang@samsung.com>
drivers/video/exynos_dp.c
drivers/video/exynos_dp_lowlevel.c

index 5f4f25e..87bb907 100644 (file)
 #include <asm/arch/cpu.h>
 #include <asm/arch/dp_info.h>
 #include <asm/arch/dp.h>
+#include <fdtdec.h>
+#include <libfdt.h>
 
 #include "exynos_dp_lowlevel.h"
 
+DECLARE_GLOBAL_DATA_PTR;
+
 static struct exynos_dp_platform_data *dp_pd;
 
 void __exynos_set_dp_phy(unsigned int onoff)
@@ -859,6 +863,62 @@ static unsigned int exynos_dp_config_video(struct edp_device_info *edp_info)
        return ret;
 }
 
+#ifdef CONFIG_OF_CONTROL
+int exynos_dp_parse_dt(const void *blob, struct edp_device_info *edp_info)
+{
+       unsigned int node = fdtdec_next_compatible(blob, 0,
+                                               COMPAT_SAMSUNG_EXYNOS5_DP);
+       if (node <= 0) {
+               debug("exynos_dp: Can't get device node for dp\n");
+               return -ENODEV;
+       }
+
+       edp_info->disp_info.h_res = fdtdec_get_int(blob, node,
+                                                       "samsung,h-res", 0);
+       edp_info->disp_info.h_sync_width = fdtdec_get_int(blob, node,
+                                               "samsung,h-sync-width", 0);
+       edp_info->disp_info.h_back_porch = fdtdec_get_int(blob, node,
+                                               "samsung,h-back-porch", 0);
+       edp_info->disp_info.h_front_porch = fdtdec_get_int(blob, node,
+                                               "samsung,h-front-porch", 0);
+       edp_info->disp_info.v_res = fdtdec_get_int(blob, node,
+                                               "samsung,v-res", 0);
+       edp_info->disp_info.v_sync_width = fdtdec_get_int(blob, node,
+                                               "samsung,v-sync-width", 0);
+       edp_info->disp_info.v_back_porch = fdtdec_get_int(blob, node,
+                                               "samsung,v-back-porch", 0);
+       edp_info->disp_info.v_front_porch = fdtdec_get_int(blob, node,
+                                               "samsung,v-front-porch", 0);
+       edp_info->disp_info.v_sync_rate = fdtdec_get_int(blob, node,
+                                               "samsung,v-sync-rate", 0);
+
+       edp_info->lt_info.lt_status = fdtdec_get_int(blob, node,
+                                               "samsung,lt-status", 0);
+
+       edp_info->video_info.master_mode = fdtdec_get_int(blob, node,
+                                               "samsung,master-mode", 0);
+       edp_info->video_info.bist_mode = fdtdec_get_int(blob, node,
+                                               "samsung,bist-mode", 0);
+       edp_info->video_info.bist_pattern = fdtdec_get_int(blob, node,
+                                               "samsung,bist-pattern", 0);
+       edp_info->video_info.h_sync_polarity = fdtdec_get_int(blob, node,
+                                               "samsung,h-sync-polarity", 0);
+       edp_info->video_info.v_sync_polarity = fdtdec_get_int(blob, node,
+                                               "samsung,v-sync-polarity", 0);
+       edp_info->video_info.interlaced = fdtdec_get_int(blob, node,
+                                               "samsung,interlaced", 0);
+       edp_info->video_info.color_space = fdtdec_get_int(blob, node,
+                                               "samsung,color-space", 0);
+       edp_info->video_info.dynamic_range = fdtdec_get_int(blob, node,
+                                               "samsung,dynamic-range", 0);
+       edp_info->video_info.ycbcr_coeff = fdtdec_get_int(blob, node,
+                                               "samsung,ycbcr-coeff", 0);
+       edp_info->video_info.color_depth = fdtdec_get_int(blob, node,
+                                               "samsung,color-depth", 0);
+       return 0;
+}
+#endif
+
 unsigned int exynos_init_dp(void)
 {
        unsigned int ret;
@@ -870,11 +930,16 @@ unsigned int exynos_init_dp(void)
                return -EFAULT;
        }
 
+#ifdef CONFIG_OF_CONTROL
+       if (exynos_dp_parse_dt(gd->fdt_blob, edp_info))
+               debug("unable to parse DP DT node\n");
+#else
        edp_info = dp_pd->edp_dev_info;
        if (edp_info == NULL) {
                debug("failed to get edp_info data.\n");
                return -EFAULT;
        }
+#endif
 
        exynos_dp_set_base_addr();
 
index 0be91a5..748d9b8 100644 (file)
 #include <asm/arch/cpu.h>
 #include <asm/arch/dp_info.h>
 #include <asm/arch/dp.h>
+#include <fdtdec.h>
+#include <libfdt.h>
+
+/* Declare global data pointer */
+DECLARE_GLOBAL_DATA_PTR;
 
 struct exynos_dp *dp_regs;
 
 void exynos_dp_set_base_addr(void)
 {
+#ifdef CONFIG_OF_CONTROL
+       unsigned int node = fdtdec_next_compatible(gd->fdt_blob,
+                                       0, COMPAT_SAMSUNG_EXYNOS5_DP);
+       if (node <= 0)
+               debug("exynos_dp: Can't get device node for dp\n");
+
+       dp_regs = (struct exynos_dp *)fdtdec_get_addr(gd->fdt_blob,
+                                                               node, "reg");
+       if (dp_regs == NULL)
+               debug("Can't get the DP base address\n");
+#else
        dp_regs = (struct exynos_dp *)samsung_get_base_dp();
+#endif
 }
 
 static void exynos_dp_enable_video_input(unsigned int enable)