From: Sandy Huang <hjc@rock-chips.com>
Date: Mon, 7 Aug 2017 09:53:30 +0000 (+0800)
Subject: drm/rockchip: lvds: add pinctrl for rk3288 rgb output
X-Git-Tag: release-20171130_firefly~4^2~6
X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=69b4bbba55e200eb9162a2366687c545ab48af1c;p=firefly-linux-kernel-4.4.55.git

drm/rockchip: lvds: add pinctrl for rk3288 rgb output

Change-Id: I4c483eb269d021860fe4249a3d25bcfb6c4f3f5f
Signed-off-by: Sandy Huang <hjc@rock-chips.com>
---

diff --git a/Documentation/devicetree/bindings/display/rockchip/rockchip-lvds.txt b/Documentation/devicetree/bindings/display/rockchip/rockchip-lvds.txt
index 1f436f2261ec..5be5b5a96d2b 100644
--- a/Documentation/devicetree/bindings/display/rockchip/rockchip-lvds.txt
+++ b/Documentation/devicetree/bindings/display/rockchip/rockchip-lvds.txt
@@ -23,17 +23,9 @@ Required properties:
 
 - rockchip,grf: phandle to the general register files syscon
 
-- rockchip,data-mapping: should be "vesa" or "jeida",
-	This describes how the color bits are laid out in the
-	serialized LVDS signal.
-- rockchip,data-width : should be <18> or <24>;
-- rockchip,output: should be "rgb", "lvds" or "duallvds",
-	This describes the output face.
-
 Optional properties
-- pinctrl-names: must contain a "default" entry.
+- pinctrl-names: must contain a "lcdc" entry.
 - pinctrl-0: pin control group to be used for this controller.
-- pinctrl-1: pin control group to be used for gpio.
 
 Required nodes:
 
@@ -45,8 +37,35 @@ Their connections are modeled using the OF graph bindings specified in
 - video port 0 for the VOP inputs
 - video port 1 for either a panel or subsequent encoder
 
+the lvds panel described by
+	Documentation/devicetree/bindings/display/panel/simple-panel.txt
+
+- rockchip,data-mapping: should be "vesa" or "jeida",
+	This describes how the color bits are laid out in the
+	serialized LVDS signal.
+- rockchip,data-width : should be <18> or <24>;
+- rockchip,output: should be "rgb", "lvds" or "duallvds",
+	This describes the output face.
+- ports for remote LVDS output
+
 Example:
 
+lvds_panel: lvds-panel {
+	status = "okay";
+	compatible = "simple-panel";
+	enable-gpios = <&gpio7 21 GPIO_ACTIVE_HIGH>;
+	rockchip,data-mapping = "jeida";
+	rockchip,data-width = <24>;
+	rockchip,output = "rgb";
+
+	ports {
+		panel_in_lvds: endpoint {
+			remote-endpoint = <&lvds_out_panel>;
+		};
+	};
+};
+
+
 For Rockchip RK3288:
 
 	lvds: lvds@ff96c000 {
@@ -55,6 +74,8 @@ For Rockchip RK3288:
 		reg = <0xff96c000 0x4000>;
 		clocks = <&cru PCLK_LVDS_PHY>;
 		clock-names = "pclk_lvds";
+		pinctrl-names = "lcdc";
+		pinctrl-0 = <&lcdc_ctl>;
 		avdd1v0-supply = <&vdd10_lcd>;
 		avdd1v8-supply = <&vcc18_lcd>;
 		avdd3v3-supply = <&vcca_33>;
@@ -98,9 +119,8 @@ For Rockchip RK3368:
 		clock-names = "pclk_lvds", "pclk_lvds_ctl";
 		power-domains = <&power RK3368_PD_VIO>;
 		rockchip,grf = <&grf>;
-		pinctrl-names = "lcdc", "gpio";
+		pinctrl-names = "lcdc";
 		pinctrl-0 = <&lcdc_lcdc>;
-		pinctrl-1 = <&lcdc_gpio>;
 
 		ports {
 
diff --git a/arch/arm/boot/dts/rk3288.dtsi b/arch/arm/boot/dts/rk3288.dtsi
index e49268c477c0..18e68974c336 100644
--- a/arch/arm/boot/dts/rk3288.dtsi
+++ b/arch/arm/boot/dts/rk3288.dtsi
@@ -1402,8 +1402,8 @@
 		reg = <0x0 0xff96c000 0x0 0x4000>;
 		clocks = <&cru PCLK_LVDS_PHY>;
 		clock-names = "pclk_lvds";
-		pinctrl-names = "default";
-		pinctrl-0 = <&lcdc0_ctl>;
+		pinctrl-names = "lcdc";
+		pinctrl-0 = <&lcdc_ctl>;
 		power-domains = <&power RK3288_PD_VIO>;
 		rockchip,grf = <&grf>;
 		status = "disabled";
@@ -1865,8 +1865,8 @@
 			};
 		};
 
-		lcdc0 {
-			lcdc0_ctl: lcdc0-ctl {
+		lcdc {
+			lcdc_ctl: lcdc-ctl {
 				rockchip,pins = <1 24 RK_FUNC_1 &pcfg_pull_none>,
 						<1 25 RK_FUNC_1 &pcfg_pull_none>,
 						<1 26 RK_FUNC_1 &pcfg_pull_none>,
diff --git a/drivers/gpu/drm/rockchip/rockchip_lvds.c b/drivers/gpu/drm/rockchip/rockchip_lvds.c
index ff23c68cfa35..7a0a27c97f88 100644
--- a/drivers/gpu/drm/rockchip/rockchip_lvds.c
+++ b/drivers/gpu/drm/rockchip/rockchip_lvds.c
@@ -506,6 +506,11 @@ static void rockchip_lvds_grf_config(struct drm_encoder *encoder,
 	u32 val;
 	int ret;
 
+	/* iomux to LCD data/sync mode */
+	if (lvds->output == DISPLAY_OUTPUT_RGB)
+		if (lvds->pins && !IS_ERR(lvds->pins->default_state))
+			pinctrl_select_state(lvds->pins->p,
+					     lvds->pins->default_state);
 	if (LVDS_CHIP(lvds) == RK3288_LVDS) {
 		val = lvds->format;
 		if (lvds->output == DISPLAY_OUTPUT_DUAL_LVDS)
@@ -527,11 +532,6 @@ static void rockchip_lvds_grf_config(struct drm_encoder *encoder,
 		}
 	} else if (LVDS_CHIP(lvds) == RK336X_LVDS) {
 		if (lvds->output == DISPLAY_OUTPUT_RGB) {
-			/* iomux to lcdc */
-			if (lvds->pins && !IS_ERR(lvds->pins->default_state))
-				pinctrl_select_state(lvds->pins->p,
-						     lvds->pins->default_state);
-
 			/* enable lvds mode */
 			val = v_RK336X_LVDSMODE_EN(0) |
 				v_RK336X_MIPIPHY_TTL_EN(1) |
@@ -933,31 +933,33 @@ static int rockchip_lvds_probe(struct platform_device *pdev)
 			dev_err(dev, "could not get pclk_ctrl\n");
 			lvds->pclk_ctrl = NULL;
 		}
-		lvds->pins = devm_kzalloc(lvds->dev, sizeof(*lvds->pins),
-					  GFP_KERNEL);
-		if (!lvds->pins)
-			return -ENOMEM;
-
-		lvds->pins->p = devm_pinctrl_get(lvds->dev);
-		if (IS_ERR(lvds->pins->p)) {
-			dev_info(lvds->dev, "no pinctrl handle\n");
-			devm_kfree(lvds->dev, lvds->pins);
-			lvds->pins = NULL;
-		} else {
-			lvds->pins->default_state =
-				pinctrl_lookup_state(lvds->pins->p, "lcdc");
-			if (IS_ERR(lvds->pins->default_state)) {
-				dev_info(lvds->dev, "no default pinctrl state\n");
-				devm_kfree(lvds->dev, lvds->pins);
-				lvds->pins = NULL;
-			}
-		}
 	}
 	lvds->pclk = devm_clk_get(&pdev->dev, "pclk_lvds");
 	if (IS_ERR(lvds->pclk)) {
 		dev_err(dev, "could not get pclk_lvds\n");
 		return PTR_ERR(lvds->pclk);
 	}
+
+	lvds->pins = devm_kzalloc(lvds->dev, sizeof(*lvds->pins),
+				  GFP_KERNEL);
+	if (!lvds->pins)
+		return -ENOMEM;
+
+	lvds->pins->p = devm_pinctrl_get(lvds->dev);
+	if (IS_ERR(lvds->pins->p)) {
+		dev_info(lvds->dev, "no pinctrl handle\n");
+		devm_kfree(lvds->dev, lvds->pins);
+		lvds->pins = NULL;
+	} else {
+		lvds->pins->default_state =
+			pinctrl_lookup_state(lvds->pins->p, "lcdc");
+		if (IS_ERR(lvds->pins->default_state)) {
+			dev_info(lvds->dev, "no lcdc pinctrl state\n");
+			devm_kfree(lvds->dev, lvds->pins);
+			lvds->pins = NULL;
+		}
+	}
+
 	lvds->grf = syscon_regmap_lookup_by_phandle(dev->of_node,
 						    "rockchip,grf");
 	if (IS_ERR(lvds->grf)) {