]> git.sur5r.net Git - u-boot/blobdiff - drivers/video/exynos_dp.c
video: add CONFIG_I2C_EDID and disable CONFIG_DISPLAY by default
[u-boot] / drivers / video / exynos_dp.c
index 53e410120ac77cf3fb08d311d78f9ba1f3f58dc3..0d5d090d0ee79db5c3e5d26bc79d760a3f071eff 100644 (file)
@@ -3,34 +3,30 @@
  *
  * Author: Donghwa Lee <dh09.lee@samsung.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
+ * SPDX-License-Identifier:    GPL-2.0+
  */
 
 #include <config.h>
 #include <common.h>
 #include <malloc.h>
+#include <linux/compat.h>
 #include <linux/err.h>
 #include <asm/arch/clk.h>
 #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"
 
-static struct exynos_dp_platform_data *dp_pd;
+DECLARE_GLOBAL_DATA_PTR;
+
+void __exynos_set_dp_phy(unsigned int onoff)
+{
+}
+void exynos_set_dp_phy(unsigned int onoff)
+       __attribute__((weak, alias("__exynos_set_dp_phy")));
 
 static void exynos_dp_disp_info(struct edp_disp_info *disp_info)
 {
@@ -211,7 +207,7 @@ static unsigned int exynos_dp_handle_edid(struct edp_device_info *edp_info)
                return -EINVAL;
        }
 
-       /*Refer VESA Display Port Stnadard Ver1.1a Page 120 */
+       /* Refer VESA Display Port Standard Ver1.1a Page 120 */
        if (edp_info->dpcd_rev == DP_DPCD_REV_11) {
                temp = buf[DPCD_MAX_LANE_COUNT] & 0x1f;
                if (buf[DPCD_MAX_LANE_COUNT] & 0x80)
@@ -274,7 +270,7 @@ static unsigned int exynos_dp_link_start(struct edp_device_info *edp_info)
                return ret;
        }
 
-       /* Set link rate and count as you want to establish*/
+       /* Set link rate and count as you want to establish */
        exynos_dp_set_link_bandwidth(edp_info->lane_bw);
        exynos_dp_set_lane_count(edp_info->lane_cnt);
 
@@ -326,7 +322,7 @@ static unsigned int exynos_dp_training_pattern_dis(void)
        ret = exynos_dp_write_byte_to_dpcd(DPCD_TRAINING_PATTERN_SET,
                        DPCD_TRAINING_PATTERN_DISABLED);
        if (ret != EXYNOS_DP_SUCCESS) {
-               printf("DP requst_link_traninig_req failed\n");
+               printf("DP request_link_training_req failed\n");
                return -EAGAIN;
        }
 
@@ -416,7 +412,7 @@ static unsigned int exynos_dp_read_dpcd_adj_req(unsigned char lane_num,
        unsigned int dpcd_addr;
        unsigned char shift_val[DP_LANE_CNT_4] = {0, 4, 0, 4};
 
-       /*lane_num value is used as arry index, so this range 0 ~ 3 */
+       /* lane_num value is used as array index, so this range 0 ~ 3 */
        dpcd_addr = DPCD_ADJUST_REQUEST_LANE0_1 + (lane_num / 2);
 
        ret = exynos_dp_read_byte_from_dpcd(dpcd_addr, &buf);
@@ -437,7 +433,7 @@ static int exynos_dp_equalizer_err_link(struct edp_device_info *edp_info)
 
        ret = exynos_dp_training_pattern_dis();
        if (ret != EXYNOS_DP_SUCCESS) {
-               printf("DP training_patter_disable() failed\n");
+               printf("DP training_pattern_disable() failed\n");
                edp_info->lt_info.lt_status = DP_LT_FAIL;
        }
 
@@ -527,7 +523,7 @@ static unsigned int exynos_dp_process_clock_recovery(struct edp_device_info
                ret = exynos_dp_write_bytes_to_dpcd(
                                DPCD_TRAINING_PATTERN_SET, 5, buf);
                if (ret != EXYNOS_DP_SUCCESS) {
-                       printf("DP write traning pattern1 failed\n");
+                       printf("DP write training pattern1 failed\n");
                        edp_info->lt_info.lt_status = DP_LT_FAIL;
                        return ret;
                } else
@@ -571,7 +567,7 @@ static unsigned int exynos_dp_process_clock_recovery(struct edp_device_info
                ret = exynos_dp_write_bytes_to_dpcd(
                                DPCD_TRAINING_LANE0_SET, 4, lt_ctl_val);
                if (ret != EXYNOS_DP_SUCCESS) {
-                       printf("DP write traning pattern2 failed\n");
+                       printf("DP write training pattern2 failed\n");
                        edp_info->lt_info.lt_status = DP_LT_FAIL;
                        return ret;
                }
@@ -742,7 +738,7 @@ static unsigned int exynos_dp_set_link_train(struct edp_device_info *edp_info)
 
        ret = exynos_dp_sw_link_training(edp_info);
        if (ret != EXYNOS_DP_SUCCESS)
-               printf("DP dp_sw_link_traning() failed\n");
+               printf("DP dp_sw_link_training() failed\n");
 
        return ret;
 }
@@ -853,11 +849,64 @@ static unsigned int exynos_dp_config_video(struct edp_device_info *edp_info)
        return ret;
 }
 
+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;
+}
+
 unsigned int exynos_init_dp(void)
 {
        unsigned int ret;
        struct edp_device_info *edp_info;
-       struct edp_disp_info disp_info;
 
        edp_info = kzalloc(sizeof(struct edp_device_info), GFP_KERNEL);
        if (!edp_info) {
@@ -865,17 +914,14 @@ unsigned int exynos_init_dp(void)
                return -EFAULT;
        }
 
-       edp_info = dp_pd->edp_dev_info;
-       if (edp_info == NULL) {
-               debug("failed to get edp_info data.\n");
-               return -EFAULT;
-       }
-       disp_info = edp_info->disp_info;
+       if (exynos_dp_parse_dt(gd->fdt_blob, edp_info))
+               debug("unable to parse DP DT node\n");
+
+       exynos_dp_set_base_addr();
 
        exynos_dp_disp_info(&edp_info->disp_info);
 
-       if (dp_pd->phy_enable)
-               dp_pd->phy_enable(1);
+       exynos_set_dp_phy(1);
 
        ret = exynos_dp_init_dp();
        if (ret != EXYNOS_DP_SUCCESS) {
@@ -909,17 +955,7 @@ unsigned int exynos_init_dp(void)
                return ret;
        }
 
-       printf("Exynos DP init done\n");
+       debug("Exynos DP init done\n");
 
        return ret;
 }
-
-void exynos_set_dp_platform_data(struct exynos_dp_platform_data *pd)
-{
-       if (pd == NULL) {
-               debug("pd is NULL\n");
-               return;
-       }
-
-       dp_pd = pd;
-}