linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/17] Allwinner R40 HDMI refactoring
@ 2018-07-06 17:50 Jernej Skrabec
  2018-07-06 17:50 ` [PATCH 01/17] dt-bindings: display: sun4i-drm: Add R40 display engine compatible Jernej Skrabec
                   ` (16 more replies)
  0 siblings, 17 replies; 40+ messages in thread
From: Jernej Skrabec @ 2018-07-06 17:50 UTC (permalink / raw)
  To: maxime.ripard, wens, robh+dt
  Cc: airlied, mark.rutland, dri-devel, devicetree, linux-arm-kernel,
	linux-kernel, linux-sunxi

This series fixes several issues found in R40 HDMI patch series after
it was applied. Conversation can be found here:
http://lists.infradead.org/pipermail/linux-arm-kernel/2018-June/586011.html

One issue raised in that thread is probably not solved (conversation
still on going), but I want to send these patches for review before
I'm going on vacation.

There is also additional DW HDMI driver fix not mentioned in mails.

Patches are based on latest linux-next (next-20180706) and are ordered
in such way that they don't break R40 HDMI at any time. Because of that
I suggest that whole series goes through drm-misc to preserve that order.

I also tested those patches on H3 to make sure it doesn't break other
platforms. However, it would be nice to test for regressions also on
older SoCs (with DE1).

Best regards,
Jernej

Jernej Skrabec (17):
  dt-bindings: display: sun4i-drm: Add R40 display engine compatible
  drm/sun4i: Add R40 display engine compatible
  ARM: dts: sun8i: r40: Remove fallback display engine compatible
  drm/sun4i: tcon-top: Cleanup clock handling
  drm/sun4i: tcon: Release node when traversing of graph
  dt-bindings: display: sun4i-drm: Add R40 TV TCON description
  drm/sun4i: DW HDMI: Release nodes if error happens during CRTC search
  ARM: dts: sun8i: r40: Add mixer ids to TCON TOP
  drm/sun4i: mixer: Read id from DT
  drm/sun4i: tcon-top: Add helpers for switching mux
  drm/sun4i: tcon: Add another way for matching mixers with tcon
  drm/sun4i: tcon: Add support for R40 TCON
  ARM: dts: sun8i: r40: Remove fallback compatible for TCON TV
  ARM: dts: sun8i: r40: Add missing TCON-TOP - TCON connections
  ARM: dts: sun8i: r40: Disable TCONs by default.
  drm/sun4i: tcon-top: Remove mux configuration at probe time
  dt-bindings: display: sun4i-drm: Fix order of DW HDMI PHY compatibles

 .../bindings/display/sunxi/sun4i-drm.txt      |   6 +-
 .../boot/dts/sun8i-r40-bananapi-m2-ultra.dts  |  20 +-
 arch/arm/boot/dts/sun8i-r40.dtsi              |  65 ++++++-
 drivers/gpu/drm/sun4i/sun4i_drv.c             |   1 +
 drivers/gpu/drm/sun4i/sun4i_tcon.c            |  92 ++++++++-
 drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c         |  15 +-
 drivers/gpu/drm/sun4i/sun8i_mixer.c           |  35 +++-
 drivers/gpu/drm/sun4i/sun8i_tcon_top.c        | 183 ++++++++----------
 drivers/gpu/drm/sun4i/sun8i_tcon_top.h        |   4 +
 9 files changed, 278 insertions(+), 143 deletions(-)

-- 
2.18.0


^ permalink raw reply	[flat|nested] 40+ messages in thread

* [PATCH 01/17] dt-bindings: display: sun4i-drm: Add R40 display engine compatible
  2018-07-06 17:50 [PATCH 00/17] Allwinner R40 HDMI refactoring Jernej Skrabec
@ 2018-07-06 17:50 ` Jernej Skrabec
  2018-07-10 15:20   ` Chen-Yu Tsai
  2018-07-06 17:50 ` [PATCH 02/17] drm/sun4i: " Jernej Skrabec
                   ` (15 subsequent siblings)
  16 siblings, 1 reply; 40+ messages in thread
From: Jernej Skrabec @ 2018-07-06 17:50 UTC (permalink / raw)
  To: maxime.ripard, wens, robh+dt
  Cc: airlied, mark.rutland, dri-devel, devicetree, linux-arm-kernel,
	linux-kernel, linux-sunxi

R40 has pretty unique display pipeline. It supports two outputs at the
same time.

Possible outputs:
- 1x HDMI,
- 2x TV output
- 1x VGA,
- 1x MIPI DSI and
- 2x LCD outputs

That is the biggest number of possible outputs from all Allwinner SoC.
Because of that, add new compatible for it.

Signed-off-by: Jernej Skrabec <jernej.skrabec@siol.net>
---
 Documentation/devicetree/bindings/display/sunxi/sun4i-drm.txt | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/display/sunxi/sun4i-drm.txt b/Documentation/devicetree/bindings/display/sunxi/sun4i-drm.txt
index 5a9319ad8861..288b4cbc255e 100644
--- a/Documentation/devicetree/bindings/display/sunxi/sun4i-drm.txt
+++ b/Documentation/devicetree/bindings/display/sunxi/sun4i-drm.txt
@@ -399,6 +399,7 @@ Required properties:
     * allwinner,sun8i-a33-display-engine
     * allwinner,sun8i-a83t-display-engine
     * allwinner,sun8i-h3-display-engine
+    * allwinner,sun8i-r40-display-engine
     * allwinner,sun8i-v3s-display-engine
     * allwinner,sun9i-a80-display-engine
 
-- 
2.18.0


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH 02/17] drm/sun4i: Add R40 display engine compatible
  2018-07-06 17:50 [PATCH 00/17] Allwinner R40 HDMI refactoring Jernej Skrabec
  2018-07-06 17:50 ` [PATCH 01/17] dt-bindings: display: sun4i-drm: Add R40 display engine compatible Jernej Skrabec
@ 2018-07-06 17:50 ` Jernej Skrabec
  2018-07-10 15:20   ` Chen-Yu Tsai
  2018-07-06 17:50 ` [PATCH 03/17] ARM: dts: sun8i: r40: Remove fallback " Jernej Skrabec
                   ` (14 subsequent siblings)
  16 siblings, 1 reply; 40+ messages in thread
From: Jernej Skrabec @ 2018-07-06 17:50 UTC (permalink / raw)
  To: maxime.ripard, wens, robh+dt
  Cc: airlied, mark.rutland, dri-devel, devicetree, linux-arm-kernel,
	linux-kernel, linux-sunxi

R40 has versatile display pipeline. It supports two simultanious outputs
on various outputs (TVE, VGA, HDMI, MIPI DSI, LCD).

Signed-off-by: Jernej Skrabec <jernej.skrabec@siol.net>
---
 drivers/gpu/drm/sun4i/sun4i_drv.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/sun4i/sun4i_drv.c b/drivers/gpu/drm/sun4i/sun4i_drv.c
index 6ddf4eaccb40..a15feb807393 100644
--- a/drivers/gpu/drm/sun4i/sun4i_drv.c
+++ b/drivers/gpu/drm/sun4i/sun4i_drv.c
@@ -417,6 +417,7 @@ static const struct of_device_id sun4i_drv_of_table[] = {
 	{ .compatible = "allwinner,sun8i-a33-display-engine" },
 	{ .compatible = "allwinner,sun8i-a83t-display-engine" },
 	{ .compatible = "allwinner,sun8i-h3-display-engine" },
+	{ .compatible = "allwinner,sun8i-r40-display-engine" },
 	{ .compatible = "allwinner,sun8i-v3s-display-engine" },
 	{ .compatible = "allwinner,sun9i-a80-display-engine" },
 	{ }
-- 
2.18.0


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH 03/17] ARM: dts: sun8i: r40: Remove fallback display engine compatible
  2018-07-06 17:50 [PATCH 00/17] Allwinner R40 HDMI refactoring Jernej Skrabec
  2018-07-06 17:50 ` [PATCH 01/17] dt-bindings: display: sun4i-drm: Add R40 display engine compatible Jernej Skrabec
  2018-07-06 17:50 ` [PATCH 02/17] drm/sun4i: " Jernej Skrabec
@ 2018-07-06 17:50 ` Jernej Skrabec
  2018-07-10 15:21   ` Chen-Yu Tsai
  2018-07-06 17:51 ` [PATCH 04/17] drm/sun4i: tcon-top: Cleanup clock handling Jernej Skrabec
                   ` (13 subsequent siblings)
  16 siblings, 1 reply; 40+ messages in thread
From: Jernej Skrabec @ 2018-07-06 17:50 UTC (permalink / raw)
  To: maxime.ripard, wens, robh+dt
  Cc: airlied, mark.rutland, dri-devel, devicetree, linux-arm-kernel,
	linux-kernel, linux-sunxi

R40 has pretty unique display pipeline. Because of that, H3 display
engine compatible fallback should be removed.

Fixes: 05a43a262d03 ("ARM: dts: sun8i: r40: Add HDMI pipeline")

Signed-off-by: Jernej Skrabec <jernej.skrabec@siol.net>
---
 arch/arm/boot/dts/sun8i-r40.dtsi | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/arm/boot/dts/sun8i-r40.dtsi b/arch/arm/boot/dts/sun8i-r40.dtsi
index c95a59aac48f..2afb079a3776 100644
--- a/arch/arm/boot/dts/sun8i-r40.dtsi
+++ b/arch/arm/boot/dts/sun8i-r40.dtsi
@@ -102,8 +102,7 @@
 	};
 
 	de: display-engine {
-		compatible = "allwinner,sun8i-r40-display-engine",
-			     "allwinner,sun8i-h3-display-engine";
+		compatible = "allwinner,sun8i-r40-display-engine";
 		allwinner,pipelines = <&mixer0>, <&mixer1>;
 		status = "disabled";
 	};
-- 
2.18.0


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH 04/17] drm/sun4i: tcon-top: Cleanup clock handling
  2018-07-06 17:50 [PATCH 00/17] Allwinner R40 HDMI refactoring Jernej Skrabec
                   ` (2 preceding siblings ...)
  2018-07-06 17:50 ` [PATCH 03/17] ARM: dts: sun8i: r40: Remove fallback " Jernej Skrabec
@ 2018-07-06 17:51 ` Jernej Skrabec
  2018-07-10 15:23   ` Chen-Yu Tsai
  2018-07-06 17:51 ` [PATCH 05/17] drm/sun4i: tcon: Release node when traversing of graph Jernej Skrabec
                   ` (12 subsequent siblings)
  16 siblings, 1 reply; 40+ messages in thread
From: Jernej Skrabec @ 2018-07-06 17:51 UTC (permalink / raw)
  To: maxime.ripard, wens, robh+dt
  Cc: airlied, mark.rutland, dri-devel, devicetree, linux-arm-kernel,
	linux-kernel, linux-sunxi

There is no need to acquire reference to clock just to get its name.

This commit just cleans up the code. There is no functional change.

Signed-off-by: Jernej Skrabec <jernej.skrabec@siol.net>
---
 drivers/gpu/drm/sun4i/sun8i_tcon_top.c | 48 ++++++--------------------
 1 file changed, 11 insertions(+), 37 deletions(-)

diff --git a/drivers/gpu/drm/sun4i/sun8i_tcon_top.c b/drivers/gpu/drm/sun4i/sun8i_tcon_top.c
index 8da0460e0028..9fb51940156f 100644
--- a/drivers/gpu/drm/sun4i/sun8i_tcon_top.c
+++ b/drivers/gpu/drm/sun4i/sun8i_tcon_top.c
@@ -44,15 +44,20 @@ static int sun8i_tcon_top_get_connected_ep_id(struct device_node *node,
 }
 
 static struct clk_hw *sun8i_tcon_top_register_gate(struct device *dev,
-						   struct clk *parent,
+						   const char *parent,
 						   void __iomem *regs,
 						   spinlock_t *lock,
 						   u8 bit, int name_index)
 {
 	const char *clk_name, *parent_name;
-	int ret;
+	int ret, index;
+
+	index = of_property_match_string(dev->of_node, "clock-names", parent);
+	if (IS_ERR_VALUE(index))
+		return ERR_PTR(index);
+
+	parent_name = of_clk_get_parent_name(dev->of_node, index);
 
-	parent_name = __clk_get_name(parent);
 	ret = of_property_read_string_index(dev->of_node,
 					    "clock-output-names", name_index,
 					    &clk_name);
@@ -69,7 +74,6 @@ static int sun8i_tcon_top_bind(struct device *dev, struct device *master,
 			       void *data)
 {
 	struct platform_device *pdev = to_platform_device(dev);
-	struct clk *dsi, *tcon_tv0, *tcon_tv1, *tve0, *tve1;
 	struct clk_hw_onecell_data *clk_data;
 	struct sun8i_tcon_top *tcon_top;
 	bool mixer0_unused = false;
@@ -103,36 +107,6 @@ static int sun8i_tcon_top_bind(struct device *dev, struct device *master,
 		return PTR_ERR(tcon_top->bus);
 	}
 
-	dsi = devm_clk_get(dev, "dsi");
-	if (IS_ERR(dsi)) {
-		dev_err(dev, "Couldn't get the dsi clock\n");
-		return PTR_ERR(dsi);
-	}
-
-	tcon_tv0 = devm_clk_get(dev, "tcon-tv0");
-	if (IS_ERR(tcon_tv0)) {
-		dev_err(dev, "Couldn't get the tcon-tv0 clock\n");
-		return PTR_ERR(tcon_tv0);
-	}
-
-	tcon_tv1 = devm_clk_get(dev, "tcon-tv1");
-	if (IS_ERR(tcon_tv1)) {
-		dev_err(dev, "Couldn't get the tcon-tv1 clock\n");
-		return PTR_ERR(tcon_tv1);
-	}
-
-	tve0 = devm_clk_get(dev, "tve0");
-	if (IS_ERR(tve0)) {
-		dev_err(dev, "Couldn't get the tve0 clock\n");
-		return PTR_ERR(tve0);
-	}
-
-	tve1 = devm_clk_get(dev, "tve1");
-	if (IS_ERR(tve1)) {
-		dev_err(dev, "Couldn't get the tve1 clock\n");
-		return PTR_ERR(tve1);
-	}
-
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	regs = devm_ioremap_resource(dev, res);
 	if (IS_ERR(regs))
@@ -203,17 +177,17 @@ static int sun8i_tcon_top_bind(struct device *dev, struct device *master,
 	 * to TVE clock parent.
 	 */
 	clk_data->hws[CLK_TCON_TOP_TV0] =
-		sun8i_tcon_top_register_gate(dev, tcon_tv0, regs,
+		sun8i_tcon_top_register_gate(dev, "tcon-tv0", regs,
 					     &tcon_top->reg_lock,
 					     TCON_TOP_TCON_TV0_GATE, 0);
 
 	clk_data->hws[CLK_TCON_TOP_TV1] =
-		sun8i_tcon_top_register_gate(dev, tcon_tv1, regs,
+		sun8i_tcon_top_register_gate(dev, "tcon-tv1", regs,
 					     &tcon_top->reg_lock,
 					     TCON_TOP_TCON_TV1_GATE, 1);
 
 	clk_data->hws[CLK_TCON_TOP_DSI] =
-		sun8i_tcon_top_register_gate(dev, dsi, regs,
+		sun8i_tcon_top_register_gate(dev, "dsi", regs,
 					     &tcon_top->reg_lock,
 					     TCON_TOP_TCON_DSI_GATE, 2);
 
-- 
2.18.0


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH 05/17] drm/sun4i: tcon: Release node when traversing of graph
  2018-07-06 17:50 [PATCH 00/17] Allwinner R40 HDMI refactoring Jernej Skrabec
                   ` (3 preceding siblings ...)
  2018-07-06 17:51 ` [PATCH 04/17] drm/sun4i: tcon-top: Cleanup clock handling Jernej Skrabec
@ 2018-07-06 17:51 ` Jernej Skrabec
  2018-07-10 15:23   ` Chen-Yu Tsai
  2018-07-06 17:51 ` [PATCH 06/17] dt-bindings: display: sun4i-drm: Add R40 TV TCON description Jernej Skrabec
                   ` (11 subsequent siblings)
  16 siblings, 1 reply; 40+ messages in thread
From: Jernej Skrabec @ 2018-07-06 17:51 UTC (permalink / raw)
  To: maxime.ripard, wens, robh+dt
  Cc: airlied, mark.rutland, dri-devel, devicetree, linux-arm-kernel,
	linux-kernel, linux-sunxi

Function sun4i_tcon_find_engine_traverse() doesn't release node if it
needs to traverse of graph deeper than 1 level.

Fix this by calling of_node_put().

Fixes: 49836b11fe71 ("drm/sun4i: tcon: Generalize engine search algorithm")

Signed-off-by: Jernej Skrabec <jernej.skrabec@siol.net>
---
 drivers/gpu/drm/sun4i/sun4i_tcon.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/sun4i/sun4i_tcon.c b/drivers/gpu/drm/sun4i/sun4i_tcon.c
index aacc841d3dc6..3fb084f802e2 100644
--- a/drivers/gpu/drm/sun4i/sun4i_tcon.c
+++ b/drivers/gpu/drm/sun4i/sun4i_tcon.c
@@ -811,6 +811,7 @@ sun4i_tcon_find_engine_traverse(struct sun4i_drv *drv,
 	 * remote output id. If this for some reason can't be done, 0
 	 * is used as input port id.
 	 */
+	of_node_put(port);
 	port = of_graph_get_remote_port(ep);
 	if (!of_property_read_u32(port, "reg", &reg) && reg > 0)
 		reg -= 1;
-- 
2.18.0


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH 06/17] dt-bindings: display: sun4i-drm: Add R40 TV TCON description
  2018-07-06 17:50 [PATCH 00/17] Allwinner R40 HDMI refactoring Jernej Skrabec
                   ` (4 preceding siblings ...)
  2018-07-06 17:51 ` [PATCH 05/17] drm/sun4i: tcon: Release node when traversing of graph Jernej Skrabec
@ 2018-07-06 17:51 ` Jernej Skrabec
  2018-07-06 20:40   ` Rob Herring
  2018-07-10 15:26   ` Chen-Yu Tsai
  2018-07-06 17:51 ` [PATCH 07/17] drm/sun4i: DW HDMI: Release nodes if error happens during CRTC search Jernej Skrabec
                   ` (10 subsequent siblings)
  16 siblings, 2 replies; 40+ messages in thread
From: Jernej Skrabec @ 2018-07-06 17:51 UTC (permalink / raw)
  To: maxime.ripard, wens, robh+dt
  Cc: airlied, mark.rutland, dri-devel, devicetree, linux-arm-kernel,
	linux-kernel, linux-sunxi

TCON description is expanded with R40 TV TCON compatible. It is a bit
special, because it is connected to TCON TOP instead directly to mixer
and it needs special handling.

Signed-off-by: Jernej Skrabec <jernej.skrabec@siol.net>
---
 Documentation/devicetree/bindings/display/sunxi/sun4i-drm.txt | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/display/sunxi/sun4i-drm.txt b/Documentation/devicetree/bindings/display/sunxi/sun4i-drm.txt
index 288b4cbc255e..7e2451396a28 100644
--- a/Documentation/devicetree/bindings/display/sunxi/sun4i-drm.txt
+++ b/Documentation/devicetree/bindings/display/sunxi/sun4i-drm.txt
@@ -147,6 +147,7 @@ Required properties:
    * allwinner,sun8i-a33-tcon
    * allwinner,sun8i-a83t-tcon-lcd
    * allwinner,sun8i-a83t-tcon-tv
+   * allwinner,sun8i-r40-tcon-tv
    * allwinner,sun8i-v3s-tcon
    * allwinner,sun9i-a80-tcon-lcd
    * allwinner,sun9i-a80-tcon-tv
@@ -181,7 +182,7 @@ For TCONs with channel 0, there is one more clock required:
 For TCONs with channel 1, there is one more clock required:
    - 'tcon-ch1': The clock driving the TCON channel 1
 
-When TCON support LVDS (all TCONs except TV TCON on A83T and those found
+When TCON support LVDS (all TCONs except TV TCONs on A83T, R40 and those found
 in A13, H3, H5 and V3s SoCs), you need one more reset line:
    - 'lvds': The reset line driving the LVDS logic
 
-- 
2.18.0


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH 07/17] drm/sun4i: DW HDMI: Release nodes if error happens during CRTC search
  2018-07-06 17:50 [PATCH 00/17] Allwinner R40 HDMI refactoring Jernej Skrabec
                   ` (5 preceding siblings ...)
  2018-07-06 17:51 ` [PATCH 06/17] dt-bindings: display: sun4i-drm: Add R40 TV TCON description Jernej Skrabec
@ 2018-07-06 17:51 ` Jernej Skrabec
  2018-07-10 15:31   ` Chen-Yu Tsai
  2018-07-06 17:51 ` [PATCH 08/17] ARM: dts: sun8i: r40: Add mixer ids to TCON TOP Jernej Skrabec
                   ` (9 subsequent siblings)
  16 siblings, 1 reply; 40+ messages in thread
From: Jernej Skrabec @ 2018-07-06 17:51 UTC (permalink / raw)
  To: maxime.ripard, wens, robh+dt
  Cc: airlied, mark.rutland, dri-devel, devicetree, linux-arm-kernel,
	linux-kernel, linux-sunxi

If error happens in sun8i_dw_hdmi_find_possible_crtcs(), nodes are not
released with of_node_put() before returning.

Fix that by calling of_node_put() when necessary. While on it, clean up
the code by using of_graph_get_remote_node() which also lowers number of
cases where error handling has to be performed.

Fixes: 57e23de02f48 ("drm/sun4i: DW HDMI: Expand algorithm for possible crtcs")

Signed-off-by: Jernej Skrabec <jernej.skrabec@siol.net>
---
 drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c b/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c
index 3459b9ec56c9..21dc9ebad0b4 100644
--- a/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c
+++ b/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c
@@ -53,22 +53,14 @@ static u32 sun8i_dw_hdmi_find_possible_crtcs(struct drm_device *drm,
 	struct device_node *port, *ep, *remote, *remote_port;
 	u32 crtcs = 0;
 
-	port = of_graph_get_port_by_id(node, 0);
-	if (!port)
-		return 0;
-
-	ep = of_get_next_available_child(port, NULL);
-	if (!ep)
-		return 0;
-
-	remote = of_graph_get_remote_port_parent(ep);
+	remote = of_graph_get_remote_node(node, 0, -1);
 	if (!remote)
 		return 0;
 
 	if (sun8i_dw_hdmi_node_is_tcon_top(remote)) {
 		port = of_graph_get_port_by_id(remote, 4);
 		if (!port)
-			return 0;
+			goto crtcs_exit;
 
 		for_each_child_of_node(port, ep) {
 			remote_port = of_graph_get_remote_port(ep);
@@ -81,6 +73,9 @@ static u32 sun8i_dw_hdmi_find_possible_crtcs(struct drm_device *drm,
 		crtcs = drm_of_find_possible_crtcs(drm, node);
 	}
 
+crtcs_exit:
+	of_node_put(remote);
+
 	return crtcs;
 }
 
-- 
2.18.0


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH 08/17] ARM: dts: sun8i: r40: Add mixer ids to TCON TOP
  2018-07-06 17:50 [PATCH 00/17] Allwinner R40 HDMI refactoring Jernej Skrabec
                   ` (6 preceding siblings ...)
  2018-07-06 17:51 ` [PATCH 07/17] drm/sun4i: DW HDMI: Release nodes if error happens during CRTC search Jernej Skrabec
@ 2018-07-06 17:51 ` Jernej Skrabec
  2018-07-10 15:35   ` Chen-Yu Tsai
  2018-07-06 17:51 ` [PATCH 09/17] drm/sun4i: mixer: Read id from DT Jernej Skrabec
                   ` (8 subsequent siblings)
  16 siblings, 1 reply; 40+ messages in thread
From: Jernej Skrabec @ 2018-07-06 17:51 UTC (permalink / raw)
  To: maxime.ripard, wens, robh+dt
  Cc: airlied, mark.rutland, dri-devel, devicetree, linux-arm-kernel,
	linux-kernel, linux-sunxi

Mixer has to have a way to read its id, if needed.

Add them in R40 DT.

Signed-off-by: Jernej Skrabec <jernej.skrabec@siol.net>
---
 arch/arm/boot/dts/sun8i-r40.dtsi | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/arch/arm/boot/dts/sun8i-r40.dtsi b/arch/arm/boot/dts/sun8i-r40.dtsi
index 2afb079a3776..1dd088d82773 100644
--- a/arch/arm/boot/dts/sun8i-r40.dtsi
+++ b/arch/arm/boot/dts/sun8i-r40.dtsi
@@ -576,9 +576,12 @@
 				#size-cells = <0>;
 
 				tcon_top_mixer0_in: port@0 {
+					#address-cells = <1>;
+					#size-cells = <0>;
 					reg = <0>;
 
-					tcon_top_mixer0_in_mixer0: endpoint {
+					tcon_top_mixer0_in_mixer0: endpoint@0 {
+						reg = <0>;
 						remote-endpoint = <&mixer0_out_tcon_top>;
 					};
 				};
@@ -606,9 +609,12 @@
 				};
 
 				tcon_top_mixer1_in: port@2 {
+					#address-cells = <1>;
+					#size-cells = <0>;
 					reg = <2>;
 
-					tcon_top_mixer1_in_mixer1: endpoint {
+					tcon_top_mixer1_in_mixer1: endpoint@1 {
+						reg = <1>;
 						remote-endpoint = <&mixer1_out_tcon_top>;
 					};
 				};
-- 
2.18.0


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH 09/17] drm/sun4i: mixer: Read id from DT
  2018-07-06 17:50 [PATCH 00/17] Allwinner R40 HDMI refactoring Jernej Skrabec
                   ` (7 preceding siblings ...)
  2018-07-06 17:51 ` [PATCH 08/17] ARM: dts: sun8i: r40: Add mixer ids to TCON TOP Jernej Skrabec
@ 2018-07-06 17:51 ` Jernej Skrabec
  2018-07-10 15:40   ` Chen-Yu Tsai
  2018-07-06 17:51 ` [PATCH 10/17] drm/sun4i: tcon-top: Add helpers for switching mux Jernej Skrabec
                   ` (7 subsequent siblings)
  16 siblings, 1 reply; 40+ messages in thread
From: Jernej Skrabec @ 2018-07-06 17:51 UTC (permalink / raw)
  To: maxime.ripard, wens, robh+dt
  Cc: airlied, mark.rutland, dri-devel, devicetree, linux-arm-kernel,
	linux-kernel, linux-sunxi

Currently, TCON supports 2 ways to match TCON with engine (mixer in this
case). Old way is to just traverse of graph backwards and compare node
pointer. New way is to match TCON and engine by their respective ids.
All SoCs with DE2 enabled till now used the old way, which means mixer
id was never used and thus never implemented.

However, for R40, only the new way will be used. To prepare for that,
implemend fetching mixer id from DT.

Signed-off-by: Jernej Skrabec <jernej.skrabec@siol.net>
---
 drivers/gpu/drm/sun4i/sun8i_mixer.c | 35 +++++++++++++++++++++++++++--
 1 file changed, 33 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/sun4i/sun8i_mixer.c b/drivers/gpu/drm/sun4i/sun8i_mixer.c
index ee8febb25903..11221f96746d 100644
--- a/drivers/gpu/drm/sun4i/sun8i_mixer.c
+++ b/drivers/gpu/drm/sun4i/sun8i_mixer.c
@@ -23,6 +23,7 @@
 #include <linux/dma-mapping.h>
 #include <linux/reset.h>
 #include <linux/of_device.h>
+#include <linux/of_graph.h>
 
 #include "sun4i_drv.h"
 #include "sun8i_mixer.h"
@@ -322,6 +323,37 @@ static struct regmap_config sun8i_mixer_regmap_config = {
 	.max_register	= 0xbfffc, /* guessed */
 };
 
+static int sun8i_mixer_of_get_id(struct device_node *node)
+{
+	struct device_node *port, *ep;
+	int ret = -EINVAL;
+
+	/* output is port 1 */
+	port = of_graph_get_port_by_id(node, 1);
+	if (!port)
+		return -EINVAL;
+
+	/* try finding an upstream endpoint */
+	for_each_available_child_of_node(port, ep) {
+		struct device_node *remote;
+		u32 reg;
+
+		remote = of_graph_get_remote_endpoint(ep);
+		if (!remote)
+			continue;
+
+		ret = of_property_read_u32(remote, "reg", &reg);
+		if (ret)
+			continue;
+
+		ret = reg;
+	}
+
+	of_node_put(port);
+
+	return ret;
+}
+
 static int sun8i_mixer_bind(struct device *dev, struct device *master,
 			      void *data)
 {
@@ -353,8 +385,7 @@ static int sun8i_mixer_bind(struct device *dev, struct device *master,
 	dev_set_drvdata(dev, mixer);
 	mixer->engine.ops = &sun8i_engine_ops;
 	mixer->engine.node = dev->of_node;
-	/* The ID of the mixer currently doesn't matter */
-	mixer->engine.id = -1;
+	mixer->engine.id = sun8i_mixer_of_get_id(dev->of_node);
 
 	mixer->cfg = of_device_get_match_data(dev);
 	if (!mixer->cfg)
-- 
2.18.0


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH 10/17] drm/sun4i: tcon-top: Add helpers for switching mux
  2018-07-06 17:50 [PATCH 00/17] Allwinner R40 HDMI refactoring Jernej Skrabec
                   ` (8 preceding siblings ...)
  2018-07-06 17:51 ` [PATCH 09/17] drm/sun4i: mixer: Read id from DT Jernej Skrabec
@ 2018-07-06 17:51 ` Jernej Skrabec
  2018-07-10 15:56   ` Chen-Yu Tsai
  2018-07-06 17:51 ` [PATCH 11/17] drm/sun4i: tcon: Add another way for matching mixers with tcon Jernej Skrabec
                   ` (6 subsequent siblings)
  16 siblings, 1 reply; 40+ messages in thread
From: Jernej Skrabec @ 2018-07-06 17:51 UTC (permalink / raw)
  To: maxime.ripard, wens, robh+dt
  Cc: airlied, mark.rutland, dri-devel, devicetree, linux-arm-kernel,
	linux-kernel, linux-sunxi

We want to be able to set TCON TOP muxes at runtime. Add helpers for
that.

Old, static configuration of muxes at probe time is preserved for now.
It will be removed when R40 TCON starts using them.

Signed-off-by: Jernej Skrabec <jernej.skrabec@siol.net>
---
 drivers/gpu/drm/sun4i/sun8i_tcon_top.c | 74 ++++++++++++++++++++++++++
 drivers/gpu/drm/sun4i/sun8i_tcon_top.h |  4 ++
 2 files changed, 78 insertions(+)

diff --git a/drivers/gpu/drm/sun4i/sun8i_tcon_top.c b/drivers/gpu/drm/sun4i/sun8i_tcon_top.c
index 9fb51940156f..c09b15b64192 100644
--- a/drivers/gpu/drm/sun4i/sun8i_tcon_top.c
+++ b/drivers/gpu/drm/sun4i/sun8i_tcon_top.c
@@ -14,6 +14,79 @@
 
 #include "sun8i_tcon_top.h"
 
+static bool sun8i_tcon_top_node_is_tcon_top(struct device_node *node)
+{
+	return !!of_match_node(sun8i_tcon_top_of_table, node);
+}
+
+int sun8i_tcon_top_set_hdmi_src(struct device *dev, int tcon)
+{
+	struct sun8i_tcon_top *tcon_top = dev_get_drvdata(dev);
+	unsigned long flags;
+	u32 val;
+
+	if (!sun8i_tcon_top_node_is_tcon_top(dev->of_node)) {
+		dev_err(dev, "Device is not TCON TOP!\n");
+		return -EINVAL;
+	}
+
+	if (tcon < 2 || tcon > 3) {
+		dev_err(dev, "TCON index must be 2 or 3!\n");
+		return -EINVAL;
+	}
+
+	spin_lock_irqsave(&tcon_top->reg_lock, flags);
+
+	val = readl(tcon_top->regs + TCON_TOP_GATE_SRC_REG);
+	val &= ~TCON_TOP_HDMI_SRC_MSK;
+	val |= FIELD_PREP(TCON_TOP_HDMI_SRC_MSK, tcon - 1);
+	writel(val, tcon_top->regs + TCON_TOP_GATE_SRC_REG);
+
+	spin_unlock_irqrestore(&tcon_top->reg_lock, flags);
+
+	return 0;
+}
+EXPORT_SYMBOL(sun8i_tcon_top_set_hdmi_src);
+
+int sun8i_tcon_top_de_config(struct device *dev, int mixer, int tcon)
+{
+	struct sun8i_tcon_top *tcon_top = dev_get_drvdata(dev);
+	unsigned long flags;
+	u32 reg;
+
+	if (!sun8i_tcon_top_node_is_tcon_top(dev->of_node)) {
+		dev_err(dev, "Device is not TCON TOP!\n");
+		return -EINVAL;
+	}
+
+	if (mixer > 1) {
+		dev_err(dev, "Mixer index is too high!\n");
+		return -EINVAL;
+	}
+
+	if (tcon > 3) {
+		dev_err(dev, "TCON index is too high!\n");
+		return -EINVAL;
+	}
+
+	spin_lock_irqsave(&tcon_top->reg_lock, flags);
+
+	reg = readl(tcon_top->regs + TCON_TOP_PORT_SEL_REG);
+	if (mixer == 0) {
+		reg &= ~TCON_TOP_PORT_DE0_MSK;
+		reg |= FIELD_PREP(TCON_TOP_PORT_DE0_MSK, tcon);
+	} else {
+		reg &= ~TCON_TOP_PORT_DE1_MSK;
+		reg |= FIELD_PREP(TCON_TOP_PORT_DE1_MSK, tcon);
+	}
+	writel(reg, tcon_top->regs + TCON_TOP_PORT_SEL_REG);
+
+	spin_unlock_irqrestore(&tcon_top->reg_lock, flags);
+
+	return 0;
+}
+EXPORT_SYMBOL(sun8i_tcon_top_de_config);
+
 static int sun8i_tcon_top_get_connected_ep_id(struct device_node *node,
 					      int port_id)
 {
@@ -109,6 +182,7 @@ static int sun8i_tcon_top_bind(struct device *dev, struct device *master,
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	regs = devm_ioremap_resource(dev, res);
+	tcon_top->regs = regs;
 	if (IS_ERR(regs))
 		return PTR_ERR(regs);
 
diff --git a/drivers/gpu/drm/sun4i/sun8i_tcon_top.h b/drivers/gpu/drm/sun4i/sun8i_tcon_top.h
index 39838bbfeaee..0390584a330e 100644
--- a/drivers/gpu/drm/sun4i/sun8i_tcon_top.h
+++ b/drivers/gpu/drm/sun4i/sun8i_tcon_top.h
@@ -26,6 +26,7 @@
 struct sun8i_tcon_top {
 	struct clk			*bus;
 	struct clk_hw_onecell_data	*clk_data;
+	void __iomem			*regs;
 	struct reset_control		*rst;
 
 	/*
@@ -37,4 +38,7 @@ struct sun8i_tcon_top {
 
 extern const struct of_device_id sun8i_tcon_top_of_table[];
 
+int sun8i_tcon_top_set_hdmi_src(struct device *dev, int tcon);
+int sun8i_tcon_top_de_config(struct device *dev, int mixer, int tcon);
+
 #endif /* _SUN8I_TCON_TOP_H_ */
-- 
2.18.0


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH 11/17] drm/sun4i: tcon: Add another way for matching mixers with tcon
  2018-07-06 17:50 [PATCH 00/17] Allwinner R40 HDMI refactoring Jernej Skrabec
                   ` (9 preceding siblings ...)
  2018-07-06 17:51 ` [PATCH 10/17] drm/sun4i: tcon-top: Add helpers for switching mux Jernej Skrabec
@ 2018-07-06 17:51 ` Jernej Skrabec
  2018-07-10 16:12   ` Chen-Yu Tsai
  2018-07-06 17:51 ` [PATCH 12/17] drm/sun4i: tcon: Add support for R40 TCON Jernej Skrabec
                   ` (5 subsequent siblings)
  16 siblings, 1 reply; 40+ messages in thread
From: Jernej Skrabec @ 2018-07-06 17:51 UTC (permalink / raw)
  To: maxime.ripard, wens, robh+dt
  Cc: airlied, mark.rutland, dri-devel, devicetree, linux-arm-kernel,
	linux-kernel, linux-sunxi

Till now, new way of matching engines with TCONs was reading their
respective ids and match them by those ids. However, with introduction
of TCON TOP, that might not be so straightforward anymore.
- there might be more TCONs that engines (mixers)
- TCON ids might have non-consecutive ids

Workaround that by matching mixer id with TCON index from TCON list.

For example, R40 has 2 mixers and 4 TCONs. Board designer can choose
2 outputs, which are connected to any of those 4 TCONs. As long as there
are only 2 TCONs enabled in DT, using index in list as alternative id,
will allow to match them with mixer 0 and 1.

Signed-off-by: Jernej Skrabec <jernej.skrabec@siol.net>
---
 drivers/gpu/drm/sun4i/sun4i_tcon.c | 51 ++++++++++++++++++++++++++++--
 1 file changed, 49 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/sun4i/sun4i_tcon.c b/drivers/gpu/drm/sun4i/sun4i_tcon.c
index 3fb084f802e2..44ec3a3d4d64 100644
--- a/drivers/gpu/drm/sun4i/sun4i_tcon.c
+++ b/drivers/gpu/drm/sun4i/sun4i_tcon.c
@@ -35,6 +35,7 @@
 #include "sun4i_rgb.h"
 #include "sun4i_tcon.h"
 #include "sun6i_mipi_dsi.h"
+#include "sun8i_tcon_top.h"
 #include "sunxi_engine.h"
 
 static struct drm_connector *sun4i_tcon_get_connector(const struct drm_encoder *encoder)
@@ -880,6 +881,36 @@ static struct sunxi_engine *sun4i_tcon_get_engine_by_id(struct sun4i_drv *drv,
 	return ERR_PTR(-EINVAL);
 }
 
+static bool sun4i_tcon_connected_to_tcon_top(struct device_node *node)
+{
+	struct device_node *remote;
+	bool ret = false;
+
+	remote = of_graph_get_remote_node(node, 0, -1);
+	if (remote) {
+		ret = !!of_match_node(sun8i_tcon_top_of_table, remote);
+		of_node_put(remote);
+	}
+
+	return ret;
+}
+
+static int sun4i_tcon_get_index(struct sun4i_drv *drv)
+{
+	struct list_head *pos;
+	int size = 0;
+
+	/*
+	 * Because TCON is added to the list at the end of the probe
+	 * (after this function is called), index of the current TCON
+	 * will be same as current TCON list size.
+	 */
+	list_for_each(pos, &drv->tcon_list)
+		++size;
+
+	return size;
+}
+
 /*
  * On SoCs with the old display pipeline design (Display Engine 1.0),
  * we assumed the TCON was always tied to just one backend. However
@@ -928,8 +959,24 @@ static struct sunxi_engine *sun4i_tcon_find_engine(struct sun4i_drv *drv,
 	 * connections between the backend and TCON?
 	 */
 	if (of_get_child_count(port) > 1) {
-		/* Get our ID directly from an upstream endpoint */
-		int id = sun4i_tcon_of_get_id_from_port(port);
+		int id;
+
+		/*
+		 * When pipeline has the same number of TCONs and engines which
+		 * are represented by frontends/backends (DE1) or mixers (DE2),
+		 * we match them by their respective IDs. However, if pipeline
+		 * contains TCON TOP, chances are that there are either more
+		 * TCONs than engines (R40) or TCONs with non-consecutive ids.
+		 * (H6). In that case it's easier just use TCON index in list
+		 * as an id. That means that on R40, any 2 TCONs can be enabled
+		 * in DT out of 4 (there are 2 mixers). Due to the design of
+		 * TCON TOP, remaining 2 TCONs can't be connected to anything
+		 * anyway.
+		 */
+		if (sun4i_tcon_connected_to_tcon_top(node))
+			id = sun4i_tcon_get_index(drv);
+		else
+			id = sun4i_tcon_of_get_id_from_port(port);
 
 		/* Get our engine by matching our ID */
 		engine = sun4i_tcon_get_engine_by_id(drv, id);
-- 
2.18.0


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH 12/17] drm/sun4i: tcon: Add support for R40 TCON
  2018-07-06 17:50 [PATCH 00/17] Allwinner R40 HDMI refactoring Jernej Skrabec
                   ` (10 preceding siblings ...)
  2018-07-06 17:51 ` [PATCH 11/17] drm/sun4i: tcon: Add another way for matching mixers with tcon Jernej Skrabec
@ 2018-07-06 17:51 ` Jernej Skrabec
  2018-07-10 16:14   ` Chen-Yu Tsai
  2018-07-06 17:51 ` [PATCH 13/17] ARM: dts: sun8i: r40: Remove fallback compatible for TCON TV Jernej Skrabec
                   ` (4 subsequent siblings)
  16 siblings, 1 reply; 40+ messages in thread
From: Jernej Skrabec @ 2018-07-06 17:51 UTC (permalink / raw)
  To: maxime.ripard, wens, robh+dt
  Cc: airlied, mark.rutland, dri-devel, devicetree, linux-arm-kernel,
	linux-kernel, linux-sunxi

R40 TV TCON is basically the same as on A83T. However, it needs special
handling, because it has to set up TCON TOP muxes at runtime.

Signed-off-by: Jernej Skrabec <jernej.skrabec@siol.net>
---
 drivers/gpu/drm/sun4i/sun4i_tcon.c | 40 ++++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)

diff --git a/drivers/gpu/drm/sun4i/sun4i_tcon.c b/drivers/gpu/drm/sun4i/sun4i_tcon.c
index 44ec3a3d4d64..5676b7faaca0 100644
--- a/drivers/gpu/drm/sun4i/sun4i_tcon.c
+++ b/drivers/gpu/drm/sun4i/sun4i_tcon.c
@@ -1291,6 +1291,40 @@ static int sun6i_tcon_set_mux(struct sun4i_tcon *tcon,
 	return 0;
 }
 
+static int sun8i_r40_tcon_tv_set_mux(struct sun4i_tcon *tcon,
+				     const struct drm_encoder *encoder)
+{
+	struct device_node *port, *remote;
+	struct platform_device *pdev;
+	int id, ret;
+
+	/* find TCON TOP platform device and TCON id */
+
+	port = of_graph_get_port_by_id(tcon->dev->of_node, 0);
+	if (!port)
+		return -EINVAL;
+
+	id = sun4i_tcon_of_get_id_from_port(port);
+	of_node_put(port);
+
+	remote = of_graph_get_remote_node(tcon->dev->of_node, 0, -1);
+	if (!remote)
+		return -EINVAL;
+
+	pdev = of_find_device_by_node(remote);
+	of_node_put(remote);
+	if (!pdev)
+		return -EINVAL;
+
+	if (encoder->encoder_type == DRM_MODE_ENCODER_TMDS) {
+		ret = sun8i_tcon_top_set_hdmi_src(&pdev->dev, id);
+		if (ret)
+			return ret;
+	}
+
+	return sun8i_tcon_top_de_config(&pdev->dev, tcon->id, id);
+}
+
 static const struct sun4i_tcon_quirks sun4i_a10_quirks = {
 	.has_channel_0		= true,
 	.has_channel_1		= true,
@@ -1338,6 +1372,11 @@ static const struct sun4i_tcon_quirks sun8i_a83t_tv_quirks = {
 	.has_channel_1		= true,
 };
 
+static const struct sun4i_tcon_quirks sun8i_r40_tv_quirks = {
+	.has_channel_1		= true,
+	.set_mux		= sun8i_r40_tcon_tv_set_mux,
+};
+
 static const struct sun4i_tcon_quirks sun8i_v3s_quirks = {
 	.has_channel_0		= true,
 };
@@ -1362,6 +1401,7 @@ const struct of_device_id sun4i_tcon_of_table[] = {
 	{ .compatible = "allwinner,sun8i-a33-tcon", .data = &sun8i_a33_quirks },
 	{ .compatible = "allwinner,sun8i-a83t-tcon-lcd", .data = &sun8i_a83t_lcd_quirks },
 	{ .compatible = "allwinner,sun8i-a83t-tcon-tv", .data = &sun8i_a83t_tv_quirks },
+	{ .compatible = "allwinner,sun8i-r40-tcon-tv", .data = &sun8i_r40_tv_quirks },
 	{ .compatible = "allwinner,sun8i-v3s-tcon", .data = &sun8i_v3s_quirks },
 	{ .compatible = "allwinner,sun9i-a80-tcon-lcd", .data = &sun9i_a80_tcon_lcd_quirks },
 	{ .compatible = "allwinner,sun9i-a80-tcon-tv", .data = &sun9i_a80_tcon_tv_quirks },
-- 
2.18.0


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH 13/17] ARM: dts: sun8i: r40: Remove fallback compatible for TCON TV
  2018-07-06 17:50 [PATCH 00/17] Allwinner R40 HDMI refactoring Jernej Skrabec
                   ` (11 preceding siblings ...)
  2018-07-06 17:51 ` [PATCH 12/17] drm/sun4i: tcon: Add support for R40 TCON Jernej Skrabec
@ 2018-07-06 17:51 ` Jernej Skrabec
  2018-07-10 15:49   ` Chen-Yu Tsai
  2018-07-06 17:51 ` [PATCH 14/17] ARM: dts: sun8i: r40: Add missing TCON-TOP - TCON connections Jernej Skrabec
                   ` (3 subsequent siblings)
  16 siblings, 1 reply; 40+ messages in thread
From: Jernej Skrabec @ 2018-07-06 17:51 UTC (permalink / raw)
  To: maxime.ripard, wens, robh+dt
  Cc: airlied, mark.rutland, dri-devel, devicetree, linux-arm-kernel,
	linux-kernel, linux-sunxi

While registers between A83T and R40 TV TCON are the same, R40 TCON TV
driver has to set additional muxes in TCON TOP. Because of that, remove
fallback A83T TCON TV compatible.

Signed-off-by: Jernej Skrabec <jernej.skrabec@siol.net>
---
 arch/arm/boot/dts/sun8i-r40.dtsi | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/arch/arm/boot/dts/sun8i-r40.dtsi b/arch/arm/boot/dts/sun8i-r40.dtsi
index 1dd088d82773..6b4fe8eeee99 100644
--- a/arch/arm/boot/dts/sun8i-r40.dtsi
+++ b/arch/arm/boot/dts/sun8i-r40.dtsi
@@ -666,8 +666,7 @@
 		};
 
 		tcon_tv0: lcd-controller@1c73000 {
-			compatible = "allwinner,sun8i-r40-tcon-tv",
-				     "allwinner,sun8i-a83t-tcon-tv";
+			compatible = "allwinner,sun8i-r40-tcon-tv";
 			reg = <0x01c73000 0x1000>;
 			interrupts = <GIC_SPI 51 IRQ_TYPE_LEVEL_HIGH>;
 			clocks = <&ccu CLK_BUS_TCON_TV0>, <&tcon_top 0>;
@@ -690,8 +689,7 @@
 		};
 
 		tcon_tv1: lcd-controller@1c74000 {
-			compatible = "allwinner,sun8i-r40-tcon-tv",
-				     "allwinner,sun8i-a83t-tcon-tv";
+			compatible = "allwinner,sun8i-r40-tcon-tv";
 			reg = <0x01c74000 0x1000>;
 			interrupts = <GIC_SPI 52 IRQ_TYPE_LEVEL_HIGH>;
 			clocks = <&ccu CLK_BUS_TCON_TV1>, <&tcon_top 1>;
-- 
2.18.0


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH 14/17] ARM: dts: sun8i: r40: Add missing TCON-TOP - TCON connections
  2018-07-06 17:50 [PATCH 00/17] Allwinner R40 HDMI refactoring Jernej Skrabec
                   ` (12 preceding siblings ...)
  2018-07-06 17:51 ` [PATCH 13/17] ARM: dts: sun8i: r40: Remove fallback compatible for TCON TV Jernej Skrabec
@ 2018-07-06 17:51 ` Jernej Skrabec
  2018-07-10 15:53   ` Chen-Yu Tsai
  2018-07-06 17:51 ` [PATCH 15/17] ARM: dts: sun8i: r40: Disable TCONs by default Jernej Skrabec
                   ` (2 subsequent siblings)
  16 siblings, 1 reply; 40+ messages in thread
From: Jernej Skrabec @ 2018-07-06 17:51 UTC (permalink / raw)
  To: maxime.ripard, wens, robh+dt
  Cc: airlied, mark.rutland, dri-devel, devicetree, linux-arm-kernel,
	linux-kernel, linux-sunxi

Current R40 is missing some graph connections between TCON TOP and
TCONs.

Add them.

Fixes: 05a43a262d03 ("ARM: dts: sun8i: r40: Add HDMI pipeline")

Signed-off-by: Jernej Skrabec <jernej.skrabec@siol.net>
---
 .../boot/dts/sun8i-r40-bananapi-m2-ultra.dts  | 20 ---------
 arch/arm/boot/dts/sun8i-r40.dtsi              | 44 +++++++++++++++++++
 2 files changed, 44 insertions(+), 20 deletions(-)

diff --git a/arch/arm/boot/dts/sun8i-r40-bananapi-m2-ultra.dts b/arch/arm/boot/dts/sun8i-r40-bananapi-m2-ultra.dts
index 4f3d583183dc..737cf01b1acd 100644
--- a/arch/arm/boot/dts/sun8i-r40-bananapi-m2-ultra.dts
+++ b/arch/arm/boot/dts/sun8i-r40-bananapi-m2-ultra.dts
@@ -251,26 +251,6 @@
 	regulator-name = "vcc-wifi";
 };
 
-&tcon_top_hdmi_in_tcon_tv0 {
-	remote-endpoint = <&tcon_tv0_out_tcon_top>;
-};
-
-&tcon_top_mixer0_out_tcon_tv0 {
-	remote-endpoint = <&tcon_tv0_in_tcon_top>;
-};
-
-&tcon_tv0_in {
-	tcon_tv0_in_tcon_top: endpoint {
-		remote-endpoint = <&tcon_top_mixer0_out_tcon_tv0>;
-	};
-};
-
-&tcon_tv0_out {
-	tcon_tv0_out_tcon_top: endpoint {
-		remote-endpoint = <&tcon_top_hdmi_in_tcon_tv0>;
-	};
-};
-
 &uart0 {
 	pinctrl-names = "default";
 	pinctrl-0 = <&uart0_pb_pins>;
diff --git a/arch/arm/boot/dts/sun8i-r40.dtsi b/arch/arm/boot/dts/sun8i-r40.dtsi
index 6b4fe8eeee99..e5c7e4804384 100644
--- a/arch/arm/boot/dts/sun8i-r40.dtsi
+++ b/arch/arm/boot/dts/sun8i-r40.dtsi
@@ -601,10 +601,12 @@
 
 					tcon_top_mixer0_out_tcon_tv0: endpoint@2 {
 						reg = <2>;
+						remote-endpoint = <&tcon_tv0_in_tcon_top_mixer0>;
 					};
 
 					tcon_top_mixer0_out_tcon_tv1: endpoint@3 {
 						reg = <3>;
+						remote-endpoint = <&tcon_tv1_in_tcon_top_mixer0>;
 					};
 				};
 
@@ -634,10 +636,12 @@
 
 					tcon_top_mixer1_out_tcon_tv0: endpoint@2 {
 						reg = <2>;
+						remote-endpoint = <&tcon_tv0_in_tcon_top_mixer1>;
 					};
 
 					tcon_top_mixer1_out_tcon_tv1: endpoint@3 {
 						reg = <3>;
+						remote-endpoint = <&tcon_tv1_in_tcon_top_mixer1>;
 					};
 				};
 
@@ -648,10 +652,12 @@
 
 					tcon_top_hdmi_in_tcon_tv0: endpoint@0 {
 						reg = <0>;
+						remote-endpoint = <&tcon_tv0_out_tcon_top>;
 					};
 
 					tcon_top_hdmi_in_tcon_tv1: endpoint@1 {
 						reg = <1>;
+						remote-endpoint = <&tcon_tv1_out_tcon_top>;
 					};
 				};
 
@@ -679,11 +685,30 @@
 				#size-cells = <0>;
 
 				tcon_tv0_in: port@0 {
+					#address-cells = <1>;
+					#size-cells = <0>;
 					reg = <0>;
+
+					tcon_tv0_in_tcon_top_mixer0: endpoint@0 {
+						reg = <0>;
+						remote-endpoint = <&tcon_top_mixer0_out_tcon_tv0>;
+					};
+
+					tcon_tv0_in_tcon_top_mixer1: endpoint@1 {
+						reg = <1>;
+						remote-endpoint = <&tcon_top_mixer1_out_tcon_tv0>;
+					};
 				};
 
 				tcon_tv0_out: port@1 {
+					#address-cells = <1>;
+					#size-cells = <0>;
 					reg = <1>;
+
+					tcon_tv0_out_tcon_top: endpoint@1 {
+						reg = <1>;
+						remote-endpoint = <&tcon_top_hdmi_in_tcon_tv0>;
+					};
 				};
 			};
 		};
@@ -702,11 +727,30 @@
 				#size-cells = <0>;
 
 				tcon_tv1_in: port@0 {
+					#address-cells = <1>;
+					#size-cells = <0>;
 					reg = <0>;
+
+					tcon_tv1_in_tcon_top_mixer0: endpoint@0 {
+						reg = <0>;
+						remote-endpoint = <&tcon_top_mixer0_out_tcon_tv1>;
+					};
+
+					tcon_tv1_in_tcon_top_mixer1: endpoint@1 {
+						reg = <1>;
+						remote-endpoint = <&tcon_top_mixer1_out_tcon_tv1>;
+					};
 				};
 
 				tcon_tv1_out: port@1 {
+					#address-cells = <1>;
+					#size-cells = <0>;
 					reg = <1>;
+
+					tcon_tv1_out_tcon_top: endpoint@1 {
+						reg = <1>;
+						remote-endpoint = <&tcon_top_hdmi_in_tcon_tv1>;
+					};
 				};
 			};
 		};
-- 
2.18.0


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH 15/17] ARM: dts: sun8i: r40: Disable TCONs by default.
  2018-07-06 17:50 [PATCH 00/17] Allwinner R40 HDMI refactoring Jernej Skrabec
                   ` (13 preceding siblings ...)
  2018-07-06 17:51 ` [PATCH 14/17] ARM: dts: sun8i: r40: Add missing TCON-TOP - TCON connections Jernej Skrabec
@ 2018-07-06 17:51 ` Jernej Skrabec
  2018-07-10 16:16   ` Chen-Yu Tsai
  2018-07-06 17:51 ` [PATCH 16/17] drm/sun4i: tcon-top: Remove mux configuration at probe time Jernej Skrabec
  2018-07-06 17:51 ` [PATCH 17/17] dt-bindings: display: sun4i-drm: Fix order of DW HDMI PHY compatibles Jernej Skrabec
  16 siblings, 1 reply; 40+ messages in thread
From: Jernej Skrabec @ 2018-07-06 17:51 UTC (permalink / raw)
  To: maxime.ripard, wens, robh+dt
  Cc: airlied, mark.rutland, dri-devel, devicetree, linux-arm-kernel,
	linux-kernel, linux-sunxi

R40 has 4 TCONs, but only 2 of them can receive some kind of output at
the same time. Let's disable them by default, so only those which are
really connected on board can be enabled in board dts file.

Signed-off-by: Jernej Skrabec <jernej.skrabec@siol.net>
---
 arch/arm/boot/dts/sun8i-r40-bananapi-m2-ultra.dts | 4 ++++
 arch/arm/boot/dts/sun8i-r40.dtsi                  | 2 ++
 2 files changed, 6 insertions(+)

diff --git a/arch/arm/boot/dts/sun8i-r40-bananapi-m2-ultra.dts b/arch/arm/boot/dts/sun8i-r40-bananapi-m2-ultra.dts
index 737cf01b1acd..c39b9169ea64 100644
--- a/arch/arm/boot/dts/sun8i-r40-bananapi-m2-ultra.dts
+++ b/arch/arm/boot/dts/sun8i-r40-bananapi-m2-ultra.dts
@@ -251,6 +251,10 @@
 	regulator-name = "vcc-wifi";
 };
 
+&tcon_tv0 {
+	status = "okay";
+};
+
 &uart0 {
 	pinctrl-names = "default";
 	pinctrl-0 = <&uart0_pb_pins>;
diff --git a/arch/arm/boot/dts/sun8i-r40.dtsi b/arch/arm/boot/dts/sun8i-r40.dtsi
index e5c7e4804384..e2cbd4f645c5 100644
--- a/arch/arm/boot/dts/sun8i-r40.dtsi
+++ b/arch/arm/boot/dts/sun8i-r40.dtsi
@@ -679,6 +679,7 @@
 			clock-names = "ahb", "tcon-ch1";
 			resets = <&ccu RST_BUS_TCON_TV0>;
 			reset-names = "lcd";
+			status = "disabled";
 
 			ports {
 				#address-cells = <1>;
@@ -721,6 +722,7 @@
 			clock-names = "ahb", "tcon-ch1";
 			resets = <&ccu RST_BUS_TCON_TV1>;
 			reset-names = "lcd";
+			status = "disabled";
 
 			ports {
 				#address-cells = <1>;
-- 
2.18.0


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH 16/17] drm/sun4i: tcon-top: Remove mux configuration at probe time
  2018-07-06 17:50 [PATCH 00/17] Allwinner R40 HDMI refactoring Jernej Skrabec
                   ` (14 preceding siblings ...)
  2018-07-06 17:51 ` [PATCH 15/17] ARM: dts: sun8i: r40: Disable TCONs by default Jernej Skrabec
@ 2018-07-06 17:51 ` Jernej Skrabec
  2018-07-10 16:09   ` Chen-Yu Tsai
  2018-07-06 17:51 ` [PATCH 17/17] dt-bindings: display: sun4i-drm: Fix order of DW HDMI PHY compatibles Jernej Skrabec
  16 siblings, 1 reply; 40+ messages in thread
From: Jernej Skrabec @ 2018-07-06 17:51 UTC (permalink / raw)
  To: maxime.ripard, wens, robh+dt
  Cc: airlied, mark.rutland, dri-devel, devicetree, linux-arm-kernel,
	linux-kernel, linux-sunxi

Now that R40 TCON migrated to runtime mux configuration, old code can be
removed.

Signed-off-by: Jernej Skrabec <jernej.skrabec@siol.net>
---
 drivers/gpu/drm/sun4i/sun8i_tcon_top.c | 81 +++-----------------------
 1 file changed, 7 insertions(+), 74 deletions(-)

diff --git a/drivers/gpu/drm/sun4i/sun8i_tcon_top.c b/drivers/gpu/drm/sun4i/sun8i_tcon_top.c
index c09b15b64192..78795d6cb174 100644
--- a/drivers/gpu/drm/sun4i/sun8i_tcon_top.c
+++ b/drivers/gpu/drm/sun4i/sun8i_tcon_top.c
@@ -87,34 +87,6 @@ int sun8i_tcon_top_de_config(struct device *dev, int mixer, int tcon)
 }
 EXPORT_SYMBOL(sun8i_tcon_top_de_config);
 
-static int sun8i_tcon_top_get_connected_ep_id(struct device_node *node,
-					      int port_id)
-{
-	struct device_node *ep, *remote, *port;
-	struct of_endpoint endpoint;
-
-	port = of_graph_get_port_by_id(node, port_id);
-	if (!port)
-		return -ENOENT;
-
-	for_each_available_child_of_node(port, ep) {
-		remote = of_graph_get_remote_port_parent(ep);
-		if (!remote)
-			continue;
-
-		if (of_device_is_available(remote)) {
-			of_graph_parse_endpoint(ep, &endpoint);
-
-			of_node_put(remote);
-
-			return endpoint.id;
-		}
-
-		of_node_put(remote);
-	}
-
-	return -ENOENT;
-}
 
 static struct clk_hw *sun8i_tcon_top_register_gate(struct device *dev,
 						   const char *parent,
@@ -149,11 +121,9 @@ static int sun8i_tcon_top_bind(struct device *dev, struct device *master,
 	struct platform_device *pdev = to_platform_device(dev);
 	struct clk_hw_onecell_data *clk_data;
 	struct sun8i_tcon_top *tcon_top;
-	bool mixer0_unused = false;
 	struct resource *res;
 	void __iomem *regs;
-	int ret, i, id;
-	u32 val;
+	int ret, i;
 
 	tcon_top = devm_kzalloc(dev, sizeof(*tcon_top), GFP_KERNEL);
 	if (!tcon_top)
@@ -198,49 +168,12 @@ static int sun8i_tcon_top_bind(struct device *dev, struct device *master,
 		goto err_assert_reset;
 	}
 
-	val = 0;
-
-	/* check if HDMI mux output is connected */
-	if (sun8i_tcon_top_get_connected_ep_id(dev->of_node, 5) >= 0) {
-		/* find HDMI input endpoint id, if it is connected at all*/
-		id = sun8i_tcon_top_get_connected_ep_id(dev->of_node, 4);
-		if (id >= 0)
-			val = FIELD_PREP(TCON_TOP_HDMI_SRC_MSK, id + 1);
-		else
-			DRM_DEBUG_DRIVER("TCON TOP HDMI input is not connected\n");
-	} else {
-		DRM_DEBUG_DRIVER("TCON TOP HDMI output is not connected\n");
-	}
-
-	writel(val, regs + TCON_TOP_GATE_SRC_REG);
-
-	val = 0;
-
-	/* process mixer0 mux output */
-	id = sun8i_tcon_top_get_connected_ep_id(dev->of_node, 1);
-	if (id >= 0) {
-		val = FIELD_PREP(TCON_TOP_PORT_DE0_MSK, id);
-	} else {
-		DRM_DEBUG_DRIVER("TCON TOP mixer0 output is not connected\n");
-		mixer0_unused = true;
-	}
-
-	/* process mixer1 mux output */
-	id = sun8i_tcon_top_get_connected_ep_id(dev->of_node, 3);
-	if (id >= 0) {
-		val |= FIELD_PREP(TCON_TOP_PORT_DE1_MSK, id);
-
-		/*
-		 * mixer0 mux has priority over mixer1 mux. We have to
-		 * make sure mixer0 doesn't overtake TCON from mixer1.
-		 */
-		if (mixer0_unused && id == 0)
-			val |= FIELD_PREP(TCON_TOP_PORT_DE0_MSK, 1);
-	} else {
-		DRM_DEBUG_DRIVER("TCON TOP mixer1 output is not connected\n");
-	}
-
-	writel(val, regs + TCON_TOP_PORT_SEL_REG);
+	/*
+	 * Default register values might have some reserved bits set, which
+	 * prevents TCON TOP from working properly. Set them to 0 here.
+	 */
+	writel(0, regs + TCON_TOP_GATE_SRC_REG);
+	writel(0, regs + TCON_TOP_PORT_SEL_REG);
 
 	/*
 	 * TCON TOP has two muxes, which select parent clock for each TCON TV
-- 
2.18.0


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH 17/17] dt-bindings: display: sun4i-drm: Fix order of DW HDMI PHY compatibles
  2018-07-06 17:50 [PATCH 00/17] Allwinner R40 HDMI refactoring Jernej Skrabec
                   ` (15 preceding siblings ...)
  2018-07-06 17:51 ` [PATCH 16/17] drm/sun4i: tcon-top: Remove mux configuration at probe time Jernej Skrabec
@ 2018-07-06 17:51 ` Jernej Skrabec
  2018-07-10 16:09   ` Chen-Yu Tsai
  16 siblings, 1 reply; 40+ messages in thread
From: Jernej Skrabec @ 2018-07-06 17:51 UTC (permalink / raw)
  To: maxime.ripard, wens, robh+dt
  Cc: airlied, mark.rutland, dri-devel, devicetree, linux-arm-kernel,
	linux-kernel, linux-sunxi

They are currently sorted alphabetically. However, they should be sorted
by release date of the family and then alphabetically.

Fixes: 03c35dbf73e0 ("dt-bindings: display: sun4i-drm: Add description of A64 HDMI PHY")

Signed-off-by: Jernej Skrabec <jernej.skrabec@siol.net>
---
 Documentation/devicetree/bindings/display/sunxi/sun4i-drm.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/display/sunxi/sun4i-drm.txt b/Documentation/devicetree/bindings/display/sunxi/sun4i-drm.txt
index 7e2451396a28..f8773ecb7525 100644
--- a/Documentation/devicetree/bindings/display/sunxi/sun4i-drm.txt
+++ b/Documentation/devicetree/bindings/display/sunxi/sun4i-drm.txt
@@ -101,9 +101,9 @@ DWC HDMI PHY
 
 Required properties:
   - compatible: value must be one of:
-    * allwinner,sun50i-a64-hdmi-phy
     * allwinner,sun8i-a83t-hdmi-phy
     * allwinner,sun8i-h3-hdmi-phy
+    * allwinner,sun50i-a64-hdmi-phy
   - reg: base address and size of memory-mapped region
   - clocks: phandles to the clocks feeding the HDMI PHY
     * bus: the HDMI PHY interface clock
-- 
2.18.0


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* Re: [PATCH 06/17] dt-bindings: display: sun4i-drm: Add R40 TV TCON description
  2018-07-06 17:51 ` [PATCH 06/17] dt-bindings: display: sun4i-drm: Add R40 TV TCON description Jernej Skrabec
@ 2018-07-06 20:40   ` Rob Herring
  2018-07-06 20:44     ` Jernej Škrabec
  2018-07-10 15:26   ` Chen-Yu Tsai
  1 sibling, 1 reply; 40+ messages in thread
From: Rob Herring @ 2018-07-06 20:40 UTC (permalink / raw)
  To: Jernej Skrabec
  Cc: maxime.ripard, wens, airlied, mark.rutland, dri-devel,
	devicetree, linux-arm-kernel, linux-kernel, linux-sunxi

On Fri, Jul 06, 2018 at 07:51:02PM +0200, Jernej Skrabec wrote:
> TCON description is expanded with R40 TV TCON compatible. It is a bit
> special, because it is connected to TCON TOP instead directly to mixer
> and it needs special handling.
> 
> Signed-off-by: Jernej Skrabec <jernej.skrabec@siol.net>
> ---
>  Documentation/devicetree/bindings/display/sunxi/sun4i-drm.txt | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)

Please add acks/reviews when posting new versions.

Rob

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH 06/17] dt-bindings: display: sun4i-drm: Add R40 TV TCON description
  2018-07-06 20:40   ` Rob Herring
@ 2018-07-06 20:44     ` Jernej Škrabec
  2018-07-09 14:16       ` Rob Herring
  0 siblings, 1 reply; 40+ messages in thread
From: Jernej Škrabec @ 2018-07-06 20:44 UTC (permalink / raw)
  To: Rob Herring
  Cc: maxime.ripard, wens, airlied, mark.rutland, dri-devel,
	devicetree, linux-arm-kernel, linux-kernel, linux-sunxi

Dne petek, 06. julij 2018 ob 22:40:52 CEST je Rob Herring napisal(a):
> On Fri, Jul 06, 2018 at 07:51:02PM +0200, Jernej Skrabec wrote:
> > TCON description is expanded with R40 TV TCON compatible. It is a bit
> > special, because it is connected to TCON TOP instead directly to mixer
> > and it needs special handling.
> > 
> > Signed-off-by: Jernej Skrabec <jernej.skrabec@siol.net>
> > ---
> > 
> >  Documentation/devicetree/bindings/display/sunxi/sun4i-drm.txt | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> Please add acks/reviews when posting new versions.

This is not exactly the same version you give ack for, so I didn't include it. 
I'm not sure where the line for that is.

In contrast to previous version, it doesn't introduce additional clock.

Best regards,
Jernej




^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH 06/17] dt-bindings: display: sun4i-drm: Add R40 TV TCON description
  2018-07-06 20:44     ` Jernej Škrabec
@ 2018-07-09 14:16       ` Rob Herring
  0 siblings, 0 replies; 40+ messages in thread
From: Rob Herring @ 2018-07-09 14:16 UTC (permalink / raw)
  To: Jernej Skrabec
  Cc: Maxime Ripard, Chen-Yu Tsai, David Airlie, Mark Rutland,
	dri-devel, devicetree,
	moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE,
	linux-kernel, linux-sunxi

On Fri, Jul 6, 2018 at 2:46 PM Jernej Škrabec <jernej.skrabec@siol.net> wrote:
>
> Dne petek, 06. julij 2018 ob 22:40:52 CEST je Rob Herring napisal(a):
> > On Fri, Jul 06, 2018 at 07:51:02PM +0200, Jernej Skrabec wrote:
> > > TCON description is expanded with R40 TV TCON compatible. It is a bit
> > > special, because it is connected to TCON TOP instead directly to mixer
> > > and it needs special handling.
> > >
> > > Signed-off-by: Jernej Skrabec <jernej.skrabec@siol.net>
> > > ---
> > >
> > >  Documentation/devicetree/bindings/display/sunxi/sun4i-drm.txt | 3 ++-
> > >  1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > Please add acks/reviews when posting new versions.
>
> This is not exactly the same version you give ack for, so I didn't include it.

Then you need to state what changed (in this patch) and why you didn't
add the ack.

> I'm not sure where the line for that is.
>
> In contrast to previous version, it doesn't introduce additional clock.

Sounds trivial enough to keep the ack.

Rob

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH 01/17] dt-bindings: display: sun4i-drm: Add R40 display engine compatible
  2018-07-06 17:50 ` [PATCH 01/17] dt-bindings: display: sun4i-drm: Add R40 display engine compatible Jernej Skrabec
@ 2018-07-10 15:20   ` Chen-Yu Tsai
  0 siblings, 0 replies; 40+ messages in thread
From: Chen-Yu Tsai @ 2018-07-10 15:20 UTC (permalink / raw)
  To: Jernej Skrabec
  Cc: Maxime Ripard, Rob Herring, David Airlie, Mark Rutland,
	dri-devel, devicetree, linux-arm-kernel, linux-kernel,
	linux-sunxi

On Sat, Jul 7, 2018 at 1:50 AM, Jernej Skrabec <jernej.skrabec@siol.net> wrote:
> R40 has pretty unique display pipeline. It supports two outputs at the
> same time.
>
> Possible outputs:
> - 1x HDMI,
> - 2x TV output
> - 1x VGA,
> - 1x MIPI DSI and
> - 2x LCD outputs
>
> That is the biggest number of possible outputs from all Allwinner SoC.
> Because of that, add new compatible for it.
>
> Signed-off-by: Jernej Skrabec <jernej.skrabec@siol.net>

Reviewed-by: Chen-Yu Tsai <wens@csie.org>

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH 02/17] drm/sun4i: Add R40 display engine compatible
  2018-07-06 17:50 ` [PATCH 02/17] drm/sun4i: " Jernej Skrabec
@ 2018-07-10 15:20   ` Chen-Yu Tsai
  0 siblings, 0 replies; 40+ messages in thread
From: Chen-Yu Tsai @ 2018-07-10 15:20 UTC (permalink / raw)
  To: Jernej Skrabec
  Cc: Maxime Ripard, Rob Herring, David Airlie, Mark Rutland,
	dri-devel, devicetree, linux-arm-kernel, linux-kernel,
	linux-sunxi

On Sat, Jul 7, 2018 at 1:50 AM, Jernej Skrabec <jernej.skrabec@siol.net> wrote:
> R40 has versatile display pipeline. It supports two simultanious outputs
> on various outputs (TVE, VGA, HDMI, MIPI DSI, LCD).
>
> Signed-off-by: Jernej Skrabec <jernej.skrabec@siol.net>

Reviewed-by: Chen-Yu Tsai <wens@csie.org>

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH 03/17] ARM: dts: sun8i: r40: Remove fallback display engine compatible
  2018-07-06 17:50 ` [PATCH 03/17] ARM: dts: sun8i: r40: Remove fallback " Jernej Skrabec
@ 2018-07-10 15:21   ` Chen-Yu Tsai
  0 siblings, 0 replies; 40+ messages in thread
From: Chen-Yu Tsai @ 2018-07-10 15:21 UTC (permalink / raw)
  To: Jernej Skrabec
  Cc: Maxime Ripard, Rob Herring, David Airlie, Mark Rutland,
	dri-devel, devicetree, linux-arm-kernel, linux-kernel,
	linux-sunxi

On Sat, Jul 7, 2018 at 1:50 AM, Jernej Skrabec <jernej.skrabec@siol.net> wrote:
> R40 has pretty unique display pipeline. Because of that, H3 display
> engine compatible fallback should be removed.
>
> Fixes: 05a43a262d03 ("ARM: dts: sun8i: r40: Add HDMI pipeline")
>
> Signed-off-by: Jernej Skrabec <jernej.skrabec@siol.net>

Reviewed-by: Chen-Yu Tsai <wens@csie.org>

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH 04/17] drm/sun4i: tcon-top: Cleanup clock handling
  2018-07-06 17:51 ` [PATCH 04/17] drm/sun4i: tcon-top: Cleanup clock handling Jernej Skrabec
@ 2018-07-10 15:23   ` Chen-Yu Tsai
  0 siblings, 0 replies; 40+ messages in thread
From: Chen-Yu Tsai @ 2018-07-10 15:23 UTC (permalink / raw)
  To: Jernej Skrabec
  Cc: Maxime Ripard, Rob Herring, David Airlie, Mark Rutland,
	dri-devel, devicetree, linux-arm-kernel, linux-kernel,
	linux-sunxi

On Sat, Jul 7, 2018 at 1:51 AM, Jernej Skrabec <jernej.skrabec@siol.net> wrote:
> There is no need to acquire reference to clock just to get its name.
>
> This commit just cleans up the code. There is no functional change.
>
> Signed-off-by: Jernej Skrabec <jernej.skrabec@siol.net>

Reviewed-by: Chen-Yu Tsai <wens@csie.org>

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH 05/17] drm/sun4i: tcon: Release node when traversing of graph
  2018-07-06 17:51 ` [PATCH 05/17] drm/sun4i: tcon: Release node when traversing of graph Jernej Skrabec
@ 2018-07-10 15:23   ` Chen-Yu Tsai
  0 siblings, 0 replies; 40+ messages in thread
From: Chen-Yu Tsai @ 2018-07-10 15:23 UTC (permalink / raw)
  To: Jernej Skrabec
  Cc: Maxime Ripard, Rob Herring, David Airlie, Mark Rutland,
	dri-devel, devicetree, linux-arm-kernel, linux-kernel,
	linux-sunxi

On Sat, Jul 7, 2018 at 1:51 AM, Jernej Skrabec <jernej.skrabec@siol.net> wrote:
> Function sun4i_tcon_find_engine_traverse() doesn't release node if it
> needs to traverse of graph deeper than 1 level.
>
> Fix this by calling of_node_put().
>
> Fixes: 49836b11fe71 ("drm/sun4i: tcon: Generalize engine search algorithm")
>
> Signed-off-by: Jernej Skrabec <jernej.skrabec@siol.net>

Reviewed-by: Chen-Yu Tsai <wens@csie.org>

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH 06/17] dt-bindings: display: sun4i-drm: Add R40 TV TCON description
  2018-07-06 17:51 ` [PATCH 06/17] dt-bindings: display: sun4i-drm: Add R40 TV TCON description Jernej Skrabec
  2018-07-06 20:40   ` Rob Herring
@ 2018-07-10 15:26   ` Chen-Yu Tsai
  1 sibling, 0 replies; 40+ messages in thread
From: Chen-Yu Tsai @ 2018-07-10 15:26 UTC (permalink / raw)
  To: Jernej Skrabec
  Cc: Maxime Ripard, Rob Herring, David Airlie, Mark Rutland,
	dri-devel, devicetree, linux-arm-kernel, linux-kernel,
	linux-sunxi

On Sat, Jul 7, 2018 at 1:51 AM, Jernej Skrabec <jernej.skrabec@siol.net> wrote:
> TCON description is expanded with R40 TV TCON compatible. It is a bit
> special, because it is connected to TCON TOP instead directly to mixer
> and it needs special handling.
>
> Signed-off-by: Jernej Skrabec <jernej.skrabec@siol.net>

Reviewed-by: Chen-Yu Tsai <wens@csie.org>

> ---
>  Documentation/devicetree/bindings/display/sunxi/sun4i-drm.txt | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/Documentation/devicetree/bindings/display/sunxi/sun4i-drm.txt b/Documentation/devicetree/bindings/display/sunxi/sun4i-drm.txt
> index 288b4cbc255e..7e2451396a28 100644
> --- a/Documentation/devicetree/bindings/display/sunxi/sun4i-drm.txt
> +++ b/Documentation/devicetree/bindings/display/sunxi/sun4i-drm.txt
> @@ -147,6 +147,7 @@ Required properties:
>     * allwinner,sun8i-a33-tcon
>     * allwinner,sun8i-a83t-tcon-lcd
>     * allwinner,sun8i-a83t-tcon-tv
> +   * allwinner,sun8i-r40-tcon-tv
>     * allwinner,sun8i-v3s-tcon
>     * allwinner,sun9i-a80-tcon-lcd
>     * allwinner,sun9i-a80-tcon-tv
> @@ -181,7 +182,7 @@ For TCONs with channel 0, there is one more clock required:
>  For TCONs with channel 1, there is one more clock required:
>     - 'tcon-ch1': The clock driving the TCON channel 1
>
> -When TCON support LVDS (all TCONs except TV TCON on A83T and those found
> +When TCON support LVDS (all TCONs except TV TCONs on A83T, R40 and those found
>  in A13, H3, H5 and V3s SoCs), you need one more reset line:

I think this line is getting more convoluted as we add more exceptions.
We may want to reword it somehow.

>     - 'lvds': The reset line driving the LVDS logic
>
> --
> 2.18.0
>

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH 07/17] drm/sun4i: DW HDMI: Release nodes if error happens during CRTC search
  2018-07-06 17:51 ` [PATCH 07/17] drm/sun4i: DW HDMI: Release nodes if error happens during CRTC search Jernej Skrabec
@ 2018-07-10 15:31   ` Chen-Yu Tsai
  0 siblings, 0 replies; 40+ messages in thread
From: Chen-Yu Tsai @ 2018-07-10 15:31 UTC (permalink / raw)
  To: Jernej Skrabec
  Cc: Maxime Ripard, Rob Herring, David Airlie, Mark Rutland,
	dri-devel, devicetree, linux-arm-kernel, linux-kernel,
	linux-sunxi

On Sat, Jul 7, 2018 at 1:51 AM, Jernej Skrabec <jernej.skrabec@siol.net> wrote:
> If error happens in sun8i_dw_hdmi_find_possible_crtcs(), nodes are not
> released with of_node_put() before returning.
>
> Fix that by calling of_node_put() when necessary. While on it, clean up
> the code by using of_graph_get_remote_node() which also lowers number of
> cases where error handling has to be performed.

Good job!

> Fixes: 57e23de02f48 ("drm/sun4i: DW HDMI: Expand algorithm for possible crtcs")
>
> Signed-off-by: Jernej Skrabec <jernej.skrabec@siol.net>

Reviewed-by: Chen-Yu Tsai <wens@csie.org>

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH 08/17] ARM: dts: sun8i: r40: Add mixer ids to TCON TOP
  2018-07-06 17:51 ` [PATCH 08/17] ARM: dts: sun8i: r40: Add mixer ids to TCON TOP Jernej Skrabec
@ 2018-07-10 15:35   ` Chen-Yu Tsai
  0 siblings, 0 replies; 40+ messages in thread
From: Chen-Yu Tsai @ 2018-07-10 15:35 UTC (permalink / raw)
  To: Jernej Skrabec
  Cc: Maxime Ripard, Rob Herring, David Airlie, Mark Rutland,
	dri-devel, devicetree, linux-arm-kernel, linux-kernel,
	linux-sunxi

On Sat, Jul 7, 2018 at 1:51 AM, Jernej Skrabec <jernej.skrabec@siol.net> wrote:
> Mixer has to have a way to read its id, if needed.

You should mention that this is required by the device tree binding sun4i-drm,
in the second paragraph of the first section:

    For all connections between components up to the TCONs in the display
    pipeline, when there are multiple components of the same type at the
    same depth, the local endpoint ID must be the same as the remote
    component's index.

You might also want to update the diagram for TCON TOP in the binding doc.

ChenYu

> Add them in R40 DT.
>
> Signed-off-by: Jernej Skrabec <jernej.skrabec@siol.net>
> ---
>  arch/arm/boot/dts/sun8i-r40.dtsi | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/arch/arm/boot/dts/sun8i-r40.dtsi b/arch/arm/boot/dts/sun8i-r40.dtsi
> index 2afb079a3776..1dd088d82773 100644
> --- a/arch/arm/boot/dts/sun8i-r40.dtsi
> +++ b/arch/arm/boot/dts/sun8i-r40.dtsi
> @@ -576,9 +576,12 @@
>                                 #size-cells = <0>;
>
>                                 tcon_top_mixer0_in: port@0 {
> +                                       #address-cells = <1>;
> +                                       #size-cells = <0>;
>                                         reg = <0>;
>
> -                                       tcon_top_mixer0_in_mixer0: endpoint {
> +                                       tcon_top_mixer0_in_mixer0: endpoint@0 {
> +                                               reg = <0>;
>                                                 remote-endpoint = <&mixer0_out_tcon_top>;
>                                         };
>                                 };
> @@ -606,9 +609,12 @@
>                                 };
>
>                                 tcon_top_mixer1_in: port@2 {
> +                                       #address-cells = <1>;
> +                                       #size-cells = <0>;
>                                         reg = <2>;
>
> -                                       tcon_top_mixer1_in_mixer1: endpoint {
> +                                       tcon_top_mixer1_in_mixer1: endpoint@1 {
> +                                               reg = <1>;
>                                                 remote-endpoint = <&mixer1_out_tcon_top>;
>                                         };
>                                 };
> --
> 2.18.0
>

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH 09/17] drm/sun4i: mixer: Read id from DT
  2018-07-06 17:51 ` [PATCH 09/17] drm/sun4i: mixer: Read id from DT Jernej Skrabec
@ 2018-07-10 15:40   ` Chen-Yu Tsai
  0 siblings, 0 replies; 40+ messages in thread
From: Chen-Yu Tsai @ 2018-07-10 15:40 UTC (permalink / raw)
  To: Jernej Skrabec
  Cc: Maxime Ripard, Rob Herring, David Airlie, Mark Rutland,
	dri-devel, devicetree, linux-arm-kernel, linux-kernel,
	linux-sunxi

On Sat, Jul 7, 2018 at 1:51 AM, Jernej Skrabec <jernej.skrabec@siol.net> wrote:
> Currently, TCON supports 2 ways to match TCON with engine (mixer in this
> case). Old way is to just traverse of graph backwards and compare node
> pointer. New way is to match TCON and engine by their respective ids.
> All SoCs with DE2 enabled till now used the old way, which means mixer
> id was never used and thus never implemented.
>
> However, for R40, only the new way will be used. To prepare for that,
> implemend fetching mixer id from DT.
>
> Signed-off-by: Jernej Skrabec <jernej.skrabec@siol.net>
> ---
>  drivers/gpu/drm/sun4i/sun8i_mixer.c | 35 +++++++++++++++++++++++++++--
>  1 file changed, 33 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/sun4i/sun8i_mixer.c b/drivers/gpu/drm/sun4i/sun8i_mixer.c
> index ee8febb25903..11221f96746d 100644
> --- a/drivers/gpu/drm/sun4i/sun8i_mixer.c
> +++ b/drivers/gpu/drm/sun4i/sun8i_mixer.c
> @@ -23,6 +23,7 @@
>  #include <linux/dma-mapping.h>
>  #include <linux/reset.h>
>  #include <linux/of_device.h>
> +#include <linux/of_graph.h>

These should be alphabetically ordered.

>
>  #include "sun4i_drv.h"
>  #include "sun8i_mixer.h"
> @@ -322,6 +323,37 @@ static struct regmap_config sun8i_mixer_regmap_config = {
>         .max_register   = 0xbfffc, /* guessed */
>  };
>
> +static int sun8i_mixer_of_get_id(struct device_node *node)
> +{
> +       struct device_node *port, *ep;
> +       int ret = -EINVAL;
> +
> +       /* output is port 1 */
> +       port = of_graph_get_port_by_id(node, 1);
> +       if (!port)
> +               return -EINVAL;
> +
> +       /* try finding an upstream endpoint */

You mean downstream.

> +       for_each_available_child_of_node(port, ep) {
> +               struct device_node *remote;
> +               u32 reg;
> +
> +               remote = of_graph_get_remote_endpoint(ep);
> +               if (!remote)
> +                       continue;
> +
> +               ret = of_property_read_u32(remote, "reg", &reg);
> +               if (ret)
> +                       continue;

This is somewhat redundant, given the current code structure will loop
over all available child nodes. What you want is probably an early
termination condition instead, i.e. if (!ret).

Also, remember to call of_node_put on the remote node.

ChenYu

> +
> +               ret = reg;
> +       }
> +
> +       of_node_put(port);
> +
> +       return ret;
> +}
> +
>  static int sun8i_mixer_bind(struct device *dev, struct device *master,
>                               void *data)
>  {
> @@ -353,8 +385,7 @@ static int sun8i_mixer_bind(struct device *dev, struct device *master,
>         dev_set_drvdata(dev, mixer);
>         mixer->engine.ops = &sun8i_engine_ops;
>         mixer->engine.node = dev->of_node;
> -       /* The ID of the mixer currently doesn't matter */
> -       mixer->engine.id = -1;
> +       mixer->engine.id = sun8i_mixer_of_get_id(dev->of_node);
>
>         mixer->cfg = of_device_get_match_data(dev);
>         if (!mixer->cfg)
> --
> 2.18.0
>

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH 13/17] ARM: dts: sun8i: r40: Remove fallback compatible for TCON TV
  2018-07-06 17:51 ` [PATCH 13/17] ARM: dts: sun8i: r40: Remove fallback compatible for TCON TV Jernej Skrabec
@ 2018-07-10 15:49   ` Chen-Yu Tsai
  0 siblings, 0 replies; 40+ messages in thread
From: Chen-Yu Tsai @ 2018-07-10 15:49 UTC (permalink / raw)
  To: Jernej Skrabec
  Cc: Maxime Ripard, Rob Herring, David Airlie, Mark Rutland,
	dri-devel, devicetree, linux-arm-kernel, linux-kernel,
	linux-sunxi

On Sat, Jul 7, 2018 at 1:51 AM, Jernej Skrabec <jernej.skrabec@siol.net> wrote:
> While registers between A83T and R40 TV TCON are the same, R40 TCON TV
> driver has to set additional muxes in TCON TOP. Because of that, remove
> fallback A83T TCON TV compatible.

Nit: device tree doesn't care about the implementation. You can however
mention that hardware interaction makes it not so compatible. :)

> Signed-off-by: Jernej Skrabec <jernej.skrabec@siol.net>

Otherwise,

Reviewed-by: Chen-Yu Tsai <wens@csie.org>

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH 14/17] ARM: dts: sun8i: r40: Add missing TCON-TOP - TCON connections
  2018-07-06 17:51 ` [PATCH 14/17] ARM: dts: sun8i: r40: Add missing TCON-TOP - TCON connections Jernej Skrabec
@ 2018-07-10 15:53   ` Chen-Yu Tsai
  0 siblings, 0 replies; 40+ messages in thread
From: Chen-Yu Tsai @ 2018-07-10 15:53 UTC (permalink / raw)
  To: Jernej Skrabec
  Cc: Maxime Ripard, Rob Herring, David Airlie, Mark Rutland,
	dri-devel, devicetree, linux-arm-kernel, linux-kernel,
	linux-sunxi

On Sat, Jul 7, 2018 at 1:51 AM, Jernej Skrabec <jernej.skrabec@siol.net> wrote:
> Current R40 is missing some graph connections between TCON TOP and
> TCONs.
>
> Add them.
>
> Fixes: 05a43a262d03 ("ARM: dts: sun8i: r40: Add HDMI pipeline")
>
> Signed-off-by: Jernej Skrabec <jernej.skrabec@siol.net>

Reviewed-by: Chen-Yu Tsai <wens@csie.org>

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH 10/17] drm/sun4i: tcon-top: Add helpers for switching mux
  2018-07-06 17:51 ` [PATCH 10/17] drm/sun4i: tcon-top: Add helpers for switching mux Jernej Skrabec
@ 2018-07-10 15:56   ` Chen-Yu Tsai
  0 siblings, 0 replies; 40+ messages in thread
From: Chen-Yu Tsai @ 2018-07-10 15:56 UTC (permalink / raw)
  To: Jernej Skrabec
  Cc: Maxime Ripard, Rob Herring, David Airlie, Mark Rutland,
	dri-devel, devicetree, linux-arm-kernel, linux-kernel,
	linux-sunxi

On Sat, Jul 7, 2018 at 1:51 AM, Jernej Skrabec <jernej.skrabec@siol.net> wrote:
> We want to be able to set TCON TOP muxes at runtime. Add helpers for
> that.
>
> Old, static configuration of muxes at probe time is preserved for now.
> It will be removed when R40 TCON starts using them.
>
> Signed-off-by: Jernej Skrabec <jernej.skrabec@siol.net>

Reviewed-by: Chen-Yu Tsai <wens@csie.org>

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH 16/17] drm/sun4i: tcon-top: Remove mux configuration at probe time
  2018-07-06 17:51 ` [PATCH 16/17] drm/sun4i: tcon-top: Remove mux configuration at probe time Jernej Skrabec
@ 2018-07-10 16:09   ` Chen-Yu Tsai
  2018-07-10 16:18     ` Jernej Škrabec
  0 siblings, 1 reply; 40+ messages in thread
From: Chen-Yu Tsai @ 2018-07-10 16:09 UTC (permalink / raw)
  To: Jernej Skrabec
  Cc: Maxime Ripard, Rob Herring, David Airlie, Mark Rutland,
	dri-devel, devicetree, linux-arm-kernel, linux-kernel,
	linux-sunxi

On Sat, Jul 7, 2018 at 1:51 AM, Jernej Skrabec <jernej.skrabec@siol.net> wrote:
> Now that R40 TCON migrated to runtime mux configuration, old code can be
> removed.
>
> Signed-off-by: Jernej Skrabec <jernej.skrabec@siol.net>
> ---
>  drivers/gpu/drm/sun4i/sun8i_tcon_top.c | 81 +++-----------------------
>  1 file changed, 7 insertions(+), 74 deletions(-)
>
> diff --git a/drivers/gpu/drm/sun4i/sun8i_tcon_top.c b/drivers/gpu/drm/sun4i/sun8i_tcon_top.c
> index c09b15b64192..78795d6cb174 100644
> --- a/drivers/gpu/drm/sun4i/sun8i_tcon_top.c
> +++ b/drivers/gpu/drm/sun4i/sun8i_tcon_top.c
> @@ -87,34 +87,6 @@ int sun8i_tcon_top_de_config(struct device *dev, int mixer, int tcon)
>  }
>  EXPORT_SYMBOL(sun8i_tcon_top_de_config);
>
> -static int sun8i_tcon_top_get_connected_ep_id(struct device_node *node,
> -                                             int port_id)
> -{
> -       struct device_node *ep, *remote, *port;
> -       struct of_endpoint endpoint;
> -
> -       port = of_graph_get_port_by_id(node, port_id);
> -       if (!port)
> -               return -ENOENT;
> -
> -       for_each_available_child_of_node(port, ep) {
> -               remote = of_graph_get_remote_port_parent(ep);
> -               if (!remote)
> -                       continue;
> -
> -               if (of_device_is_available(remote)) {
> -                       of_graph_parse_endpoint(ep, &endpoint);
> -
> -                       of_node_put(remote);
> -
> -                       return endpoint.id;
> -               }
> -
> -               of_node_put(remote);
> -       }
> -
> -       return -ENOENT;
> -}
>
>  static struct clk_hw *sun8i_tcon_top_register_gate(struct device *dev,
>                                                    const char *parent,
> @@ -149,11 +121,9 @@ static int sun8i_tcon_top_bind(struct device *dev, struct device *master,
>         struct platform_device *pdev = to_platform_device(dev);
>         struct clk_hw_onecell_data *clk_data;
>         struct sun8i_tcon_top *tcon_top;
> -       bool mixer0_unused = false;
>         struct resource *res;
>         void __iomem *regs;
> -       int ret, i, id;
> -       u32 val;
> +       int ret, i;
>
>         tcon_top = devm_kzalloc(dev, sizeof(*tcon_top), GFP_KERNEL);
>         if (!tcon_top)
> @@ -198,49 +168,12 @@ static int sun8i_tcon_top_bind(struct device *dev, struct device *master,
>                 goto err_assert_reset;
>         }
>
> -       val = 0;
> -
> -       /* check if HDMI mux output is connected */
> -       if (sun8i_tcon_top_get_connected_ep_id(dev->of_node, 5) >= 0) {
> -               /* find HDMI input endpoint id, if it is connected at all*/
> -               id = sun8i_tcon_top_get_connected_ep_id(dev->of_node, 4);
> -               if (id >= 0)
> -                       val = FIELD_PREP(TCON_TOP_HDMI_SRC_MSK, id + 1);
> -               else
> -                       DRM_DEBUG_DRIVER("TCON TOP HDMI input is not connected\n");
> -       } else {
> -               DRM_DEBUG_DRIVER("TCON TOP HDMI output is not connected\n");
> -       }
> -
> -       writel(val, regs + TCON_TOP_GATE_SRC_REG);
> -
> -       val = 0;
> -
> -       /* process mixer0 mux output */
> -       id = sun8i_tcon_top_get_connected_ep_id(dev->of_node, 1);
> -       if (id >= 0) {
> -               val = FIELD_PREP(TCON_TOP_PORT_DE0_MSK, id);
> -       } else {
> -               DRM_DEBUG_DRIVER("TCON TOP mixer0 output is not connected\n");
> -               mixer0_unused = true;
> -       }
> -
> -       /* process mixer1 mux output */
> -       id = sun8i_tcon_top_get_connected_ep_id(dev->of_node, 3);
> -       if (id >= 0) {
> -               val |= FIELD_PREP(TCON_TOP_PORT_DE1_MSK, id);
> -
> -               /*
> -                * mixer0 mux has priority over mixer1 mux. We have to
> -                * make sure mixer0 doesn't overtake TCON from mixer1.
> -                */
> -               if (mixer0_unused && id == 0)
> -                       val |= FIELD_PREP(TCON_TOP_PORT_DE0_MSK, 1);
> -       } else {
> -               DRM_DEBUG_DRIVER("TCON TOP mixer1 output is not connected\n");
> -       }
> -
> -       writel(val, regs + TCON_TOP_PORT_SEL_REG);
> +       /*
> +        * Default register values might have some reserved bits set, which
> +        * prevents TCON TOP from working properly. Set them to 0 here.
> +        */
> +       writel(0, regs + TCON_TOP_GATE_SRC_REG);
> +       writel(0, regs + TCON_TOP_PORT_SEL_REG);

Would it make sense to just force a reset using the reset control?

ChenYu

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH 17/17] dt-bindings: display: sun4i-drm: Fix order of DW HDMI PHY compatibles
  2018-07-06 17:51 ` [PATCH 17/17] dt-bindings: display: sun4i-drm: Fix order of DW HDMI PHY compatibles Jernej Skrabec
@ 2018-07-10 16:09   ` Chen-Yu Tsai
  0 siblings, 0 replies; 40+ messages in thread
From: Chen-Yu Tsai @ 2018-07-10 16:09 UTC (permalink / raw)
  To: Jernej Skrabec
  Cc: Maxime Ripard, Rob Herring, David Airlie, Mark Rutland,
	dri-devel, devicetree, linux-arm-kernel, linux-kernel,
	linux-sunxi

On Sat, Jul 7, 2018 at 1:51 AM, Jernej Skrabec <jernej.skrabec@siol.net> wrote:
> They are currently sorted alphabetically. However, they should be sorted
> by release date of the family and then alphabetically.
>
> Fixes: 03c35dbf73e0 ("dt-bindings: display: sun4i-drm: Add description of A64 HDMI PHY")
>
> Signed-off-by: Jernej Skrabec <jernej.skrabec@siol.net>

Reviewed-by: Chen-Yu Tsai <wens@csie.org>

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH 11/17] drm/sun4i: tcon: Add another way for matching mixers with tcon
  2018-07-06 17:51 ` [PATCH 11/17] drm/sun4i: tcon: Add another way for matching mixers with tcon Jernej Skrabec
@ 2018-07-10 16:12   ` Chen-Yu Tsai
  0 siblings, 0 replies; 40+ messages in thread
From: Chen-Yu Tsai @ 2018-07-10 16:12 UTC (permalink / raw)
  To: Jernej Skrabec
  Cc: Maxime Ripard, Rob Herring, David Airlie, Mark Rutland,
	dri-devel, devicetree, linux-arm-kernel, linux-kernel,
	linux-sunxi

On Sat, Jul 7, 2018 at 1:51 AM, Jernej Skrabec <jernej.skrabec@siol.net> wrote:
> Till now, new way of matching engines with TCONs was reading their
> respective ids and match them by those ids. However, with introduction
> of TCON TOP, that might not be so straightforward anymore.
> - there might be more TCONs that engines (mixers)
> - TCON ids might have non-consecutive ids
>
> Workaround that by matching mixer id with TCON index from TCON list.
>
> For example, R40 has 2 mixers and 4 TCONs. Board designer can choose
> 2 outputs, which are connected to any of those 4 TCONs. As long as there
> are only 2 TCONs enabled in DT, using index in list as alternative id,
> will allow to match them with mixer 0 and 1.
>
> Signed-off-by: Jernej Skrabec <jernej.skrabec@siol.net>

Reviewed-by: Chen-Yu Tsai <wens@csie.org>

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH 12/17] drm/sun4i: tcon: Add support for R40 TCON
  2018-07-06 17:51 ` [PATCH 12/17] drm/sun4i: tcon: Add support for R40 TCON Jernej Skrabec
@ 2018-07-10 16:14   ` Chen-Yu Tsai
  0 siblings, 0 replies; 40+ messages in thread
From: Chen-Yu Tsai @ 2018-07-10 16:14 UTC (permalink / raw)
  To: Jernej Skrabec
  Cc: Maxime Ripard, Rob Herring, David Airlie, Mark Rutland,
	dri-devel, devicetree, linux-arm-kernel, linux-kernel,
	linux-sunxi

On Sat, Jul 7, 2018 at 1:51 AM, Jernej Skrabec <jernej.skrabec@siol.net> wrote:
> R40 TV TCON is basically the same as on A83T. However, it needs special
> handling, because it has to set up TCON TOP muxes at runtime.
>
> Signed-off-by: Jernej Skrabec <jernej.skrabec@siol.net>

Reviewed-by: Chen-Yu Tsai <wens@csie.org>

The runtime muxing of mixer <-> TCON is quite clever.

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH 15/17] ARM: dts: sun8i: r40: Disable TCONs by default.
  2018-07-06 17:51 ` [PATCH 15/17] ARM: dts: sun8i: r40: Disable TCONs by default Jernej Skrabec
@ 2018-07-10 16:16   ` Chen-Yu Tsai
  0 siblings, 0 replies; 40+ messages in thread
From: Chen-Yu Tsai @ 2018-07-10 16:16 UTC (permalink / raw)
  To: Jernej Skrabec
  Cc: Maxime Ripard, Rob Herring, David Airlie, Mark Rutland,
	dri-devel, devicetree, linux-arm-kernel, linux-kernel,
	linux-sunxi

On Sat, Jul 7, 2018 at 1:51 AM, Jernej Skrabec <jernej.skrabec@siol.net> wrote:
> R40 has 4 TCONs, but only 2 of them can receive some kind of output at
> the same time. Let's disable them by default, so only those which are
> really connected on board can be enabled in board dts file.
>
> Signed-off-by: Jernej Skrabec <jernej.skrabec@siol.net>

Originally I had wanted all TCONs enabled by default. But that would
require some more work for dynamic assignment of TCONs to CRTCs, which
is way out of scope for this series. So,

Reviewed-by: Chen-Yu Tsai <wens@csie.org>

I'll think about if and how this could be done.

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH 16/17] drm/sun4i: tcon-top: Remove mux configuration at probe time
  2018-07-10 16:09   ` Chen-Yu Tsai
@ 2018-07-10 16:18     ` Jernej Škrabec
  2018-07-10 19:41       ` [linux-sunxi] " Jernej Škrabec
  0 siblings, 1 reply; 40+ messages in thread
From: Jernej Škrabec @ 2018-07-10 16:18 UTC (permalink / raw)
  To: Chen-Yu Tsai
  Cc: Maxime Ripard, Rob Herring, David Airlie, Mark Rutland,
	dri-devel, devicetree, linux-arm-kernel, linux-kernel,
	linux-sunxi

Dne torek, 10. julij 2018 ob 18:09:26 CEST je Chen-Yu Tsai napisal(a):
> On Sat, Jul 7, 2018 at 1:51 AM, Jernej Skrabec <jernej.skrabec@siol.net> 
wrote:
> > Now that R40 TCON migrated to runtime mux configuration, old code can be
> > removed.
> > 
> > Signed-off-by: Jernej Skrabec <jernej.skrabec@siol.net>
> > ---
> > 
> >  drivers/gpu/drm/sun4i/sun8i_tcon_top.c | 81 +++-----------------------
> >  1 file changed, 7 insertions(+), 74 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/sun4i/sun8i_tcon_top.c
> > b/drivers/gpu/drm/sun4i/sun8i_tcon_top.c index c09b15b64192..78795d6cb174
> > 100644
> > --- a/drivers/gpu/drm/sun4i/sun8i_tcon_top.c
> > +++ b/drivers/gpu/drm/sun4i/sun8i_tcon_top.c
> > @@ -87,34 +87,6 @@ int sun8i_tcon_top_de_config(struct device *dev, int
> > mixer, int tcon)> 
> >  }
> >  EXPORT_SYMBOL(sun8i_tcon_top_de_config);
> > 
> > -static int sun8i_tcon_top_get_connected_ep_id(struct device_node *node,
> > -                                             int port_id)
> > -{
> > -       struct device_node *ep, *remote, *port;
> > -       struct of_endpoint endpoint;
> > -
> > -       port = of_graph_get_port_by_id(node, port_id);
> > -       if (!port)
> > -               return -ENOENT;
> > -
> > -       for_each_available_child_of_node(port, ep) {
> > -               remote = of_graph_get_remote_port_parent(ep);
> > -               if (!remote)
> > -                       continue;
> > -
> > -               if (of_device_is_available(remote)) {
> > -                       of_graph_parse_endpoint(ep, &endpoint);
> > -
> > -                       of_node_put(remote);
> > -
> > -                       return endpoint.id;
> > -               }
> > -
> > -               of_node_put(remote);
> > -       }
> > -
> > -       return -ENOENT;
> > -}
> > 
> >  static struct clk_hw *sun8i_tcon_top_register_gate(struct device *dev,
> >  
> >                                                    const char *parent,
> > 
> > @@ -149,11 +121,9 @@ static int sun8i_tcon_top_bind(struct device *dev,
> > struct device *master,> 
> >         struct platform_device *pdev = to_platform_device(dev);
> >         struct clk_hw_onecell_data *clk_data;
> >         struct sun8i_tcon_top *tcon_top;
> > 
> > -       bool mixer0_unused = false;
> > 
> >         struct resource *res;
> >         void __iomem *regs;
> > 
> > -       int ret, i, id;
> > -       u32 val;
> > +       int ret, i;
> > 
> >         tcon_top = devm_kzalloc(dev, sizeof(*tcon_top), GFP_KERNEL);
> >         if (!tcon_top)
> > 
> > @@ -198,49 +168,12 @@ static int sun8i_tcon_top_bind(struct device *dev,
> > struct device *master,> 
> >                 goto err_assert_reset;
> >         
> >         }
> > 
> > -       val = 0;
> > -
> > -       /* check if HDMI mux output is connected */
> > -       if (sun8i_tcon_top_get_connected_ep_id(dev->of_node, 5) >= 0) {
> > -               /* find HDMI input endpoint id, if it is connected at
> > all*/
> > -               id = sun8i_tcon_top_get_connected_ep_id(dev->of_node, 4);
> > -               if (id >= 0)
> > -                       val = FIELD_PREP(TCON_TOP_HDMI_SRC_MSK, id + 1);
> > -               else
> > -                       DRM_DEBUG_DRIVER("TCON TOP HDMI input is not
> > connected\n"); -       } else {
> > -               DRM_DEBUG_DRIVER("TCON TOP HDMI output is not
> > connected\n"); -       }
> > -
> > -       writel(val, regs + TCON_TOP_GATE_SRC_REG);
> > -
> > -       val = 0;
> > -
> > -       /* process mixer0 mux output */
> > -       id = sun8i_tcon_top_get_connected_ep_id(dev->of_node, 1);
> > -       if (id >= 0) {
> > -               val = FIELD_PREP(TCON_TOP_PORT_DE0_MSK, id);
> > -       } else {
> > -               DRM_DEBUG_DRIVER("TCON TOP mixer0 output is not
> > connected\n"); -               mixer0_unused = true;
> > -       }
> > -
> > -       /* process mixer1 mux output */
> > -       id = sun8i_tcon_top_get_connected_ep_id(dev->of_node, 3);
> > -       if (id >= 0) {
> > -               val |= FIELD_PREP(TCON_TOP_PORT_DE1_MSK, id);
> > -
> > -               /*
> > -                * mixer0 mux has priority over mixer1 mux. We have to
> > -                * make sure mixer0 doesn't overtake TCON from mixer1.
> > -                */
> > -               if (mixer0_unused && id == 0)
> > -                       val |= FIELD_PREP(TCON_TOP_PORT_DE0_MSK, 1);
> > -       } else {
> > -               DRM_DEBUG_DRIVER("TCON TOP mixer1 output is not
> > connected\n"); -       }
> > -
> > -       writel(val, regs + TCON_TOP_PORT_SEL_REG);
> > +       /*
> > +        * Default register values might have some reserved bits set,
> > which
> > +        * prevents TCON TOP from working properly. Set them to 0 here.
> > +        */
> > +       writel(0, regs + TCON_TOP_GATE_SRC_REG);
> > +       writel(0, regs + TCON_TOP_PORT_SEL_REG);
> 
> Would it make sense to just force a reset using the reset control?

I wrote TCON TOP driver for H6 at first. For some reason, some registers had 
reserved bits set after reset line was released. TCON TOP was not used in U-
Boot, so I guess this counts as full reset.

I never tried to find out how it behaves on R40 because setting those 
registers to 0 seems like simple, good enough solution, which works 
everywhere.

Best regards,
Jernej




^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [linux-sunxi] Re: [PATCH 16/17] drm/sun4i: tcon-top: Remove mux configuration at probe time
  2018-07-10 16:18     ` Jernej Škrabec
@ 2018-07-10 19:41       ` Jernej Škrabec
  0 siblings, 0 replies; 40+ messages in thread
From: Jernej Škrabec @ 2018-07-10 19:41 UTC (permalink / raw)
  To: linux-sunxi
  Cc: Chen-Yu Tsai, Maxime Ripard, Rob Herring, David Airlie,
	Mark Rutland, dri-devel, devicetree, linux-arm-kernel,
	linux-kernel

Dne torek, 10. julij 2018 ob 18:18:43 CEST je Jernej Škrabec napisal(a):
> Dne torek, 10. julij 2018 ob 18:09:26 CEST je Chen-Yu Tsai napisal(a):
> > On Sat, Jul 7, 2018 at 1:51 AM, Jernej Skrabec <jernej.skrabec@siol.net>
> 
> wrote:
> > > Now that R40 TCON migrated to runtime mux configuration, old code can be
> > > removed.
> > > 
> > > Signed-off-by: Jernej Skrabec <jernej.skrabec@siol.net>
> > > ---
> > > 
> > >  drivers/gpu/drm/sun4i/sun8i_tcon_top.c | 81 +++-----------------------
> > >  1 file changed, 7 insertions(+), 74 deletions(-)
> > > 
> > > diff --git a/drivers/gpu/drm/sun4i/sun8i_tcon_top.c
> > > b/drivers/gpu/drm/sun4i/sun8i_tcon_top.c index
> > > c09b15b64192..78795d6cb174
> > > 100644
> > > --- a/drivers/gpu/drm/sun4i/sun8i_tcon_top.c
> > > +++ b/drivers/gpu/drm/sun4i/sun8i_tcon_top.c
> > > @@ -87,34 +87,6 @@ int sun8i_tcon_top_de_config(struct device *dev, int
> > > mixer, int tcon)>
> > > 
> > >  }
> > >  EXPORT_SYMBOL(sun8i_tcon_top_de_config);
> > > 
> > > -static int sun8i_tcon_top_get_connected_ep_id(struct device_node *node,
> > > -                                             int port_id)
> > > -{
> > > -       struct device_node *ep, *remote, *port;
> > > -       struct of_endpoint endpoint;
> > > -
> > > -       port = of_graph_get_port_by_id(node, port_id);
> > > -       if (!port)
> > > -               return -ENOENT;
> > > -
> > > -       for_each_available_child_of_node(port, ep) {
> > > -               remote = of_graph_get_remote_port_parent(ep);
> > > -               if (!remote)
> > > -                       continue;
> > > -
> > > -               if (of_device_is_available(remote)) {
> > > -                       of_graph_parse_endpoint(ep, &endpoint);
> > > -
> > > -                       of_node_put(remote);
> > > -
> > > -                       return endpoint.id;
> > > -               }
> > > -
> > > -               of_node_put(remote);
> > > -       }
> > > -
> > > -       return -ENOENT;
> > > -}
> > > 
> > >  static struct clk_hw *sun8i_tcon_top_register_gate(struct device *dev,
> > >  
> > >                                                    const char *parent,
> > > 
> > > @@ -149,11 +121,9 @@ static int sun8i_tcon_top_bind(struct device *dev,
> > > struct device *master,>
> > > 
> > >         struct platform_device *pdev = to_platform_device(dev);
> > >         struct clk_hw_onecell_data *clk_data;
> > >         struct sun8i_tcon_top *tcon_top;
> > > 
> > > -       bool mixer0_unused = false;
> > > 
> > >         struct resource *res;
> > >         void __iomem *regs;
> > > 
> > > -       int ret, i, id;
> > > -       u32 val;
> > > +       int ret, i;
> > > 
> > >         tcon_top = devm_kzalloc(dev, sizeof(*tcon_top), GFP_KERNEL);
> > >         if (!tcon_top)
> > > 
> > > @@ -198,49 +168,12 @@ static int sun8i_tcon_top_bind(struct device *dev,
> > > struct device *master,>
> > > 
> > >                 goto err_assert_reset;
> > >         
> > >         }
> > > 
> > > -       val = 0;
> > > -
> > > -       /* check if HDMI mux output is connected */
> > > -       if (sun8i_tcon_top_get_connected_ep_id(dev->of_node, 5) >= 0) {
> > > -               /* find HDMI input endpoint id, if it is connected at
> > > all*/
> > > -               id = sun8i_tcon_top_get_connected_ep_id(dev->of_node,
> > > 4);
> > > -               if (id >= 0)
> > > -                       val = FIELD_PREP(TCON_TOP_HDMI_SRC_MSK, id + 1);
> > > -               else
> > > -                       DRM_DEBUG_DRIVER("TCON TOP HDMI input is not
> > > connected\n"); -       } else {
> > > -               DRM_DEBUG_DRIVER("TCON TOP HDMI output is not
> > > connected\n"); -       }
> > > -
> > > -       writel(val, regs + TCON_TOP_GATE_SRC_REG);
> > > -
> > > -       val = 0;
> > > -
> > > -       /* process mixer0 mux output */
> > > -       id = sun8i_tcon_top_get_connected_ep_id(dev->of_node, 1);
> > > -       if (id >= 0) {
> > > -               val = FIELD_PREP(TCON_TOP_PORT_DE0_MSK, id);
> > > -       } else {
> > > -               DRM_DEBUG_DRIVER("TCON TOP mixer0 output is not
> > > connected\n"); -               mixer0_unused = true;
> > > -       }
> > > -
> > > -       /* process mixer1 mux output */
> > > -       id = sun8i_tcon_top_get_connected_ep_id(dev->of_node, 3);
> > > -       if (id >= 0) {
> > > -               val |= FIELD_PREP(TCON_TOP_PORT_DE1_MSK, id);
> > > -
> > > -               /*
> > > -                * mixer0 mux has priority over mixer1 mux. We have to
> > > -                * make sure mixer0 doesn't overtake TCON from mixer1.
> > > -                */
> > > -               if (mixer0_unused && id == 0)
> > > -                       val |= FIELD_PREP(TCON_TOP_PORT_DE0_MSK, 1);
> > > -       } else {
> > > -               DRM_DEBUG_DRIVER("TCON TOP mixer1 output is not
> > > connected\n"); -       }
> > > -
> > > -       writel(val, regs + TCON_TOP_PORT_SEL_REG);
> > > +       /*
> > > +        * Default register values might have some reserved bits set,
> > > which
> > > +        * prevents TCON TOP from working properly. Set them to 0 here.
> > > +        */
> > > +       writel(0, regs + TCON_TOP_GATE_SRC_REG);
> > > +       writel(0, regs + TCON_TOP_PORT_SEL_REG);
> > 
> > Would it make sense to just force a reset using the reset control?
> 
> I wrote TCON TOP driver for H6 at first. For some reason, some registers had
> reserved bits set after reset line was released. TCON TOP was not used in
> U- Boot, so I guess this counts as full reset.
> 
> I never tried to find out how it behaves on R40 because setting those
> registers to 0 seems like simple, good enough solution, which works
> everywhere.

It seems those bits are not needed for R40. I'll leave them out for now. TCON 
TOP will need some adjustments for H6 anyway and I'll take a look at that 
then.
 
Best regards,
Jernej





^ permalink raw reply	[flat|nested] 40+ messages in thread

end of thread, other threads:[~2018-07-10 19:42 UTC | newest]

Thread overview: 40+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-06 17:50 [PATCH 00/17] Allwinner R40 HDMI refactoring Jernej Skrabec
2018-07-06 17:50 ` [PATCH 01/17] dt-bindings: display: sun4i-drm: Add R40 display engine compatible Jernej Skrabec
2018-07-10 15:20   ` Chen-Yu Tsai
2018-07-06 17:50 ` [PATCH 02/17] drm/sun4i: " Jernej Skrabec
2018-07-10 15:20   ` Chen-Yu Tsai
2018-07-06 17:50 ` [PATCH 03/17] ARM: dts: sun8i: r40: Remove fallback " Jernej Skrabec
2018-07-10 15:21   ` Chen-Yu Tsai
2018-07-06 17:51 ` [PATCH 04/17] drm/sun4i: tcon-top: Cleanup clock handling Jernej Skrabec
2018-07-10 15:23   ` Chen-Yu Tsai
2018-07-06 17:51 ` [PATCH 05/17] drm/sun4i: tcon: Release node when traversing of graph Jernej Skrabec
2018-07-10 15:23   ` Chen-Yu Tsai
2018-07-06 17:51 ` [PATCH 06/17] dt-bindings: display: sun4i-drm: Add R40 TV TCON description Jernej Skrabec
2018-07-06 20:40   ` Rob Herring
2018-07-06 20:44     ` Jernej Škrabec
2018-07-09 14:16       ` Rob Herring
2018-07-10 15:26   ` Chen-Yu Tsai
2018-07-06 17:51 ` [PATCH 07/17] drm/sun4i: DW HDMI: Release nodes if error happens during CRTC search Jernej Skrabec
2018-07-10 15:31   ` Chen-Yu Tsai
2018-07-06 17:51 ` [PATCH 08/17] ARM: dts: sun8i: r40: Add mixer ids to TCON TOP Jernej Skrabec
2018-07-10 15:35   ` Chen-Yu Tsai
2018-07-06 17:51 ` [PATCH 09/17] drm/sun4i: mixer: Read id from DT Jernej Skrabec
2018-07-10 15:40   ` Chen-Yu Tsai
2018-07-06 17:51 ` [PATCH 10/17] drm/sun4i: tcon-top: Add helpers for switching mux Jernej Skrabec
2018-07-10 15:56   ` Chen-Yu Tsai
2018-07-06 17:51 ` [PATCH 11/17] drm/sun4i: tcon: Add another way for matching mixers with tcon Jernej Skrabec
2018-07-10 16:12   ` Chen-Yu Tsai
2018-07-06 17:51 ` [PATCH 12/17] drm/sun4i: tcon: Add support for R40 TCON Jernej Skrabec
2018-07-10 16:14   ` Chen-Yu Tsai
2018-07-06 17:51 ` [PATCH 13/17] ARM: dts: sun8i: r40: Remove fallback compatible for TCON TV Jernej Skrabec
2018-07-10 15:49   ` Chen-Yu Tsai
2018-07-06 17:51 ` [PATCH 14/17] ARM: dts: sun8i: r40: Add missing TCON-TOP - TCON connections Jernej Skrabec
2018-07-10 15:53   ` Chen-Yu Tsai
2018-07-06 17:51 ` [PATCH 15/17] ARM: dts: sun8i: r40: Disable TCONs by default Jernej Skrabec
2018-07-10 16:16   ` Chen-Yu Tsai
2018-07-06 17:51 ` [PATCH 16/17] drm/sun4i: tcon-top: Remove mux configuration at probe time Jernej Skrabec
2018-07-10 16:09   ` Chen-Yu Tsai
2018-07-10 16:18     ` Jernej Škrabec
2018-07-10 19:41       ` [linux-sunxi] " Jernej Škrabec
2018-07-06 17:51 ` [PATCH 17/17] dt-bindings: display: sun4i-drm: Fix order of DW HDMI PHY compatibles Jernej Skrabec
2018-07-10 16:09   ` Chen-Yu Tsai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).