FROMLIST: drm: bridge: analogix/dp: try force hpd after plug in lookup failed
authorYakir Yang <ykk@rock-chips.com>
Mon, 15 Feb 2016 11:11:15 +0000 (19:11 +0800)
committerHuang, Tao <huangtao@rock-chips.com>
Mon, 21 Mar 2016 11:43:41 +0000 (19:43 +0800)
Some edp screen do not have hpd signal, so we can't just return
failed when hpd plug in detect failed.

This is an hardware property, so we need add a devicetree property
"analogix,need-force-hpd" to indicate this sutiation.

(am from https://patchwork.kernel.org/patch/8313081/)

Change-Id: If99d29936aafd996c98568d6e184aee6d9c8bc47
Acked-by: Rob Herring <robh@kernel.org>
Tested-by: Javier Martinez Canillas <javier@osg.samsung.com>
Signed-off-by: Yakir Yang <ykk@rock-chips.com>
Documentation/devicetree/bindings/display/bridge/analogix_dp.txt
Documentation/devicetree/bindings/display/exynos/exynos_dp.txt
Documentation/devicetree/bindings/display/rockchip/analogix_dp-rockchip.txt
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
drivers/gpu/drm/bridge/analogix/analogix_dp_core.h
drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c

index 7659a7a96d568792cdef0b3774a6297e6aa638eb..4f2ba8c13d9259c528322070790f92da84b3bb58 100644 (file)
@@ -22,6 +22,9 @@ Required properties for dp-controller:
                from general PHY binding: Should be "dp".
 
 Optional properties for dp-controller:
+       -force-hpd:
+               Indicate driver need force hpd when hpd detect failed, this
+               is used for some eDP screen which don't have hpd signal.
        -hpd-gpios:
                Hotplug detect GPIO.
                Indicates which GPIO should be used for hotplug detection
@@ -31,7 +34,6 @@ Optional properties for dp-controller:
                * Documentation/devicetree/bindings/display/exynos/exynos_dp.txt
                * Documentation/devicetree/bindings/video/analogix_dp-rockchip.txt
 
-
 [1]: Documentation/devicetree/bindings/media/video-interfaces.txt
 -------------------------------------------------------------------------------
 
index 4fa8aca6a545a772010bbbe953cbdcf5a649e9de..ade5d8eebf85e509132dad456dc2be838903a12c 100644 (file)
@@ -56,6 +56,7 @@ For the below properties, please refer to Analogix DP binding document:
        -phys (required)
        -phy-names (required)
        -hpd-gpios (optional)
+        force-hpd (optional)
 
 Deprecated properties for DisplayPort:
 -interlaced:            deprecated prop that can parsed from drm_display_mode.
index 04d99e31e703a2c0113ca6ee7befe59bda9fdc12..e832ff98fd61c1e527ac40a92cf80f1df0e20594 100644 (file)
@@ -32,6 +32,7 @@ For the below properties, please refer to Analogix DP binding document:
 - phys (required)
 - phy-names (required)
 - hpd-gpios (optional)
+- force-hpd (optional)
 -------------------------------------------------------------------------------
 
 Example:
index a62e8d07b06ae532cefc321423a549ff361e369f..13986b7b9a612a61eef65ab24b3a1c74d0191ead 100644 (file)
@@ -62,15 +62,38 @@ static int analogix_dp_detect_hpd(struct analogix_dp_device *dp)
 {
        int timeout_loop = 0;
 
-       while (analogix_dp_get_plug_in_status(dp) != 0) {
+       while (timeout_loop < DP_TIMEOUT_LOOP_COUNT) {
+               if (analogix_dp_get_plug_in_status(dp) == 0)
+                       return 0;
+
                timeout_loop++;
-               if (timeout_loop > DP_TIMEOUT_LOOP_COUNT) {
-                       dev_err(dp->dev, "failed to get hpd plug status\n");
-                       return -ETIMEDOUT;
-               }
                usleep_range(10, 11);
        }
 
+       /*
+        * Some edp screen do not have hpd signal, so we can't just
+        * return failed when hpd plug in detect failed, DT property
+        * "force-hpd" would indicate whether driver need this.
+        */
+       if (!dp->force_hpd)
+               return -ETIMEDOUT;
+
+       /*
+        * The eDP TRM indicate that if HPD_STATUS(RO) is 0, AUX CH
+        * will not work, so we need to give a force hpd action to
+        * set HPD_STATUS manually.
+        */
+       dev_dbg(dp->dev, "failed to get hpd plug status, try to force hpd\n");
+
+       analogix_dp_force_hpd(dp);
+
+       if (analogix_dp_get_plug_in_status(dp) != 0) {
+               dev_err(dp->dev, "failed to get hpd plug in status\n");
+               return -EINVAL;
+       }
+
+       dev_dbg(dp->dev, "success to get plug in status after force hpd\n");
+
        return 0;
 }
 
@@ -1291,6 +1314,8 @@ int analogix_dp_bind(struct device *dev, struct drm_device *drm_dev,
        if (IS_ERR(dp->reg_base))
                return PTR_ERR(dp->reg_base);
 
+       dp->force_hpd = of_property_read_bool(dev->of_node, "force-hpd");
+
        dp->hpd_gpio = of_get_named_gpio(dev->of_node, "hpd-gpios", 0);
        if (!gpio_is_valid(dp->hpd_gpio))
                dp->hpd_gpio = of_get_named_gpio(dev->of_node,
index 02c0ecffa804574c1c27f1d205f334c486877b84..22aff07c199577d5a6a145b4e80ef72c8ee1765b 100644 (file)
@@ -154,6 +154,7 @@ struct analogix_dp_device {
        struct phy              *phy;
        int                     dpms_mode;
        int                     hpd_gpio;
+       bool                    force_hpd;
 
        struct analogix_dp_plat_data *plat_data;
 };
@@ -174,6 +175,7 @@ void analogix_dp_set_analog_power_down(struct analogix_dp_device *dp,
                                       bool enable);
 void analogix_dp_init_analog_func(struct analogix_dp_device *dp);
 void analogix_dp_init_hpd(struct analogix_dp_device *dp);
+void analogix_dp_force_hpd(struct analogix_dp_device *dp);
 enum dp_irq_type analogix_dp_get_irq_type(struct analogix_dp_device *dp);
 void analogix_dp_clear_hotplug_interrupts(struct analogix_dp_device *dp);
 void analogix_dp_reset_aux(struct analogix_dp_device *dp);
index 1e24b3722ff158cf6f4da3108c7a836d5920395e..cba3ffd886492b254dbb2713b5ea1dbe87f5f1bd 100644 (file)
@@ -365,6 +365,15 @@ void analogix_dp_init_hpd(struct analogix_dp_device *dp)
        writel(reg, dp->reg_base + ANALOGIX_DP_SYS_CTL_3);
 }
 
+void analogix_dp_force_hpd(struct analogix_dp_device *dp)
+{
+       u32 reg;
+
+       reg = readl(dp->reg_base + ANALOGIX_DP_SYS_CTL_3);
+       reg = (F_HPD | HPD_CTRL);
+       writel(reg, dp->reg_base + ANALOGIX_DP_SYS_CTL_3);
+}
+
 enum dp_irq_type analogix_dp_get_irq_type(struct analogix_dp_device *dp)
 {
        u32 reg;