linux-sunxi.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/4] drm/sun4i: dsi: Support the A100/D1 controller variant
@ 2022-11-07  5:35 Samuel Holland
  2022-11-07  5:35 ` [PATCH v2 1/4] dt-bindings: display: sun6i-dsi: Fix clock conditional Samuel Holland
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Samuel Holland @ 2022-11-07  5:35 UTC (permalink / raw)
  To: Chen-Yu Tsai, Jernej Skrabec, Maxime Ripard
  Cc: Samuel Holland, Daniel Vetter, David Airlie, Jagan Teki,
	Krzysztof Kozlowski, Rob Herring, devicetree, dri-devel,
	linux-arm-kernel, linux-kernel, linux-sunxi

This series adds support for the digital part of the DSI controller
found in the A100 and D1 SoCs (plus T7, which is not supported by
mainline Linux). There are two changes to the hardware integration:
  1) the module clock routes through the TCON TOP, and
  2) the separate I/O domain is removed.

The actual register interface appears to be the same as before. The
register definitions in the D1 BSP exactly match the A64 BSP.

The BSP describes this as the "40nm" DSI controller variant. There is
also a "28nm" variant with a different register interface; that one is
found in a different subset of SoCs (V5 and A50).

A100/D1 also come with an updated DPHY, described by the BSP as a
"combo" PHY, which is now also used for LVDS channel 0. (LVDS and DSI
share the same pins on Port D.) Since that is a different subsystem,
I am sending that as a separate series.

Changes in v2:
 - Add the variant check to the probe error path

Samuel Holland (4):
  dt-bindings: display: sun6i-dsi: Fix clock conditional
  dt-bindings: display: sun6i-dsi: Add the A100 variant
  drm/sun4i: dsi: Add a variant structure
  drm/sun4i: dsi: Add the A100 variant

 .../display/allwinner,sun6i-a31-mipi-dsi.yaml | 30 ++++++---
 drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c        | 61 +++++++++++++------
 drivers/gpu/drm/sun4i/sun6i_mipi_dsi.h        |  7 +++
 3 files changed, 71 insertions(+), 27 deletions(-)

-- 
2.37.3


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

* [PATCH v2 1/4] dt-bindings: display: sun6i-dsi: Fix clock conditional
  2022-11-07  5:35 [PATCH v2 0/4] drm/sun4i: dsi: Support the A100/D1 controller variant Samuel Holland
@ 2022-11-07  5:35 ` Samuel Holland
  2022-11-07  5:35 ` [PATCH v2 2/4] dt-bindings: display: sun6i-dsi: Add the A100 variant Samuel Holland
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Samuel Holland @ 2022-11-07  5:35 UTC (permalink / raw)
  To: Chen-Yu Tsai, Jernej Skrabec, Maxime Ripard
  Cc: Samuel Holland, Daniel Vetter, David Airlie, Jagan Teki,
	Krzysztof Kozlowski, Rob Herring, devicetree, dri-devel,
	linux-arm-kernel, linux-kernel, linux-sunxi, Krzysztof Kozlowski

The A64 case should have limited maxItems, instead of duplicating the
minItems value from the main binding. While here, simplify the binding
by making this an "else" case of the two-clock conditional block.

Fixes: fe5040f2843a ("dt-bindings: sun6i-dsi: Document A64 MIPI-DSI controller")
Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Signed-off-by: Samuel Holland <samuel@sholland.org>
---

(no changes since v1)

 .../bindings/display/allwinner,sun6i-a31-mipi-dsi.yaml | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/Documentation/devicetree/bindings/display/allwinner,sun6i-a31-mipi-dsi.yaml b/Documentation/devicetree/bindings/display/allwinner,sun6i-a31-mipi-dsi.yaml
index 7910831fa4b8..bf9bfe8f88ae 100644
--- a/Documentation/devicetree/bindings/display/allwinner,sun6i-a31-mipi-dsi.yaml
+++ b/Documentation/devicetree/bindings/display/allwinner,sun6i-a31-mipi-dsi.yaml
@@ -78,16 +78,10 @@ allOf:
       required:
         - clock-names
 
-  - if:
-      properties:
-        compatible:
-          contains:
-            const: allwinner,sun50i-a64-mipi-dsi
-
-    then:
+    else:
       properties:
         clocks:
-          minItems: 1
+          maxItems: 1
 
 unevaluatedProperties: false
 
-- 
2.37.3


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

* [PATCH v2 2/4] dt-bindings: display: sun6i-dsi: Add the A100 variant
  2022-11-07  5:35 [PATCH v2 0/4] drm/sun4i: dsi: Support the A100/D1 controller variant Samuel Holland
  2022-11-07  5:35 ` [PATCH v2 1/4] dt-bindings: display: sun6i-dsi: Fix clock conditional Samuel Holland
@ 2022-11-07  5:35 ` Samuel Holland
  2022-11-07  5:35 ` [PATCH v2 3/4] drm/sun4i: dsi: Add a variant structure Samuel Holland
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Samuel Holland @ 2022-11-07  5:35 UTC (permalink / raw)
  To: Chen-Yu Tsai, Jernej Skrabec, Maxime Ripard
  Cc: Samuel Holland, Daniel Vetter, David Airlie, Jagan Teki,
	Krzysztof Kozlowski, Rob Herring, devicetree, dri-devel,
	linux-arm-kernel, linux-kernel, linux-sunxi, Krzysztof Kozlowski

The "40nm" MIPI DSI controller found in the A100 and D1 SoCs has the
same register layout as previous SoC integrations. However, its module
clock now comes from the TCON, which means it no longer runs at a fixed
rate, so this needs to be distinguished in the driver.

The controller also now uses pins on Port D instead of dedicated pins,
so it drops the separate power domain.

Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Signed-off-by: Samuel Holland <samuel@sholland.org>
---
Removal of the vcc-dsi-supply is maybe a bit questionable. Since there
is no "VCC-DSI" pin anymore, it's not obvious which pin actually does
power the DSI controller/PHY. Possibly power comes from VCC-PD or VCC-IO
or VCC-LVDS. So far, all boards have all of these as always-on supplies,
so it is hard to test.

(no changes since v1)

 .../display/allwinner,sun6i-a31-mipi-dsi.yaml | 28 +++++++++++++++----
 1 file changed, 23 insertions(+), 5 deletions(-)

diff --git a/Documentation/devicetree/bindings/display/allwinner,sun6i-a31-mipi-dsi.yaml b/Documentation/devicetree/bindings/display/allwinner,sun6i-a31-mipi-dsi.yaml
index bf9bfe8f88ae..c731fbdc2fe0 100644
--- a/Documentation/devicetree/bindings/display/allwinner,sun6i-a31-mipi-dsi.yaml
+++ b/Documentation/devicetree/bindings/display/allwinner,sun6i-a31-mipi-dsi.yaml
@@ -12,9 +12,14 @@ maintainers:
 
 properties:
   compatible:
-    enum:
-      - allwinner,sun6i-a31-mipi-dsi
-      - allwinner,sun50i-a64-mipi-dsi
+    oneOf:
+      - enum:
+          - allwinner,sun6i-a31-mipi-dsi
+          - allwinner,sun50i-a64-mipi-dsi
+          - allwinner,sun50i-a100-mipi-dsi
+      - items:
+          - const: allwinner,sun20i-d1-mipi-dsi
+          - const: allwinner,sun50i-a100-mipi-dsi
 
   reg:
     maxItems: 1
@@ -59,7 +64,6 @@ required:
   - phys
   - phy-names
   - resets
-  - vcc-dsi-supply
   - port
 
 allOf:
@@ -68,7 +72,9 @@ allOf:
       properties:
         compatible:
           contains:
-            const: allwinner,sun6i-a31-mipi-dsi
+            enum:
+              - allwinner,sun6i-a31-mipi-dsi
+              - allwinner,sun50i-a100-mipi-dsi
 
     then:
       properties:
@@ -83,6 +89,18 @@ allOf:
         clocks:
           maxItems: 1
 
+  - if:
+      properties:
+        compatible:
+          contains:
+            enum:
+              - allwinner,sun6i-a31-mipi-dsi
+              - allwinner,sun50i-a64-mipi-dsi
+
+    then:
+      required:
+        - vcc-dsi-supply
+
 unevaluatedProperties: false
 
 examples:
-- 
2.37.3


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

* [PATCH v2 3/4] drm/sun4i: dsi: Add a variant structure
  2022-11-07  5:35 [PATCH v2 0/4] drm/sun4i: dsi: Support the A100/D1 controller variant Samuel Holland
  2022-11-07  5:35 ` [PATCH v2 1/4] dt-bindings: display: sun6i-dsi: Fix clock conditional Samuel Holland
  2022-11-07  5:35 ` [PATCH v2 2/4] dt-bindings: display: sun6i-dsi: Add the A100 variant Samuel Holland
@ 2022-11-07  5:35 ` Samuel Holland
  2022-11-07  5:35 ` [PATCH v2 4/4] drm/sun4i: dsi: Add the A100 variant Samuel Holland
  2022-11-07 13:13 ` [PATCH v2 0/4] drm/sun4i: dsi: Support the A100/D1 controller variant Maxime Ripard
  4 siblings, 0 replies; 6+ messages in thread
From: Samuel Holland @ 2022-11-07  5:35 UTC (permalink / raw)
  To: Chen-Yu Tsai, Jernej Skrabec, Maxime Ripard
  Cc: Samuel Holland, Daniel Vetter, David Airlie, Jagan Teki,
	Krzysztof Kozlowski, Rob Herring, devicetree, dri-devel,
	linux-arm-kernel, linux-kernel, linux-sunxi

Replace the ad-hoc calls to of_device_is_compatible() with a structure
describing the differences between variants. This is in preparation for
adding more variants to the driver.

Reviewed-by: Jernej Skrabec <jernej.skrabec@gmail.com>
Signed-off-by: Samuel Holland <samuel@sholland.org>
---

Changes in v2:
 - Add the variant check to the probe error path

 drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c | 53 +++++++++++++++++---------
 drivers/gpu/drm/sun4i/sun6i_mipi_dsi.h |  7 ++++
 2 files changed, 42 insertions(+), 18 deletions(-)

diff --git a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c
index 34234a144e87..f22c96cc8408 100644
--- a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c
+++ b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c
@@ -1101,12 +1101,16 @@ static const struct component_ops sun6i_dsi_ops = {
 
 static int sun6i_dsi_probe(struct platform_device *pdev)
 {
+	const struct sun6i_dsi_variant *variant;
 	struct device *dev = &pdev->dev;
-	const char *bus_clk_name = NULL;
 	struct sun6i_dsi *dsi;
 	void __iomem *base;
 	int ret;
 
+	variant = device_get_match_data(dev);
+	if (!variant)
+		return -EINVAL;
+
 	dsi = devm_kzalloc(dev, sizeof(*dsi), GFP_KERNEL);
 	if (!dsi)
 		return -ENOMEM;
@@ -1114,10 +1118,7 @@ static int sun6i_dsi_probe(struct platform_device *pdev)
 	dsi->dev = dev;
 	dsi->host.ops = &sun6i_dsi_host_ops;
 	dsi->host.dev = dev;
-
-	if (of_device_is_compatible(dev->of_node,
-				    "allwinner,sun6i-a31-mipi-dsi"))
-		bus_clk_name = "bus";
+	dsi->variant = variant;
 
 	base = devm_platform_ioremap_resource(pdev, 0);
 	if (IS_ERR(base)) {
@@ -1142,7 +1143,7 @@ static int sun6i_dsi_probe(struct platform_device *pdev)
 		return PTR_ERR(dsi->regs);
 	}
 
-	dsi->bus_clk = devm_clk_get(dev, bus_clk_name);
+	dsi->bus_clk = devm_clk_get(dev, variant->has_mod_clk ? "bus" : NULL);
 	if (IS_ERR(dsi->bus_clk))
 		return dev_err_probe(dev, PTR_ERR(dsi->bus_clk),
 				     "Couldn't get the DSI bus clock\n");
@@ -1151,21 +1152,21 @@ static int sun6i_dsi_probe(struct platform_device *pdev)
 	if (ret)
 		return ret;
 
-	if (of_device_is_compatible(dev->of_node,
-				    "allwinner,sun6i-a31-mipi-dsi")) {
+	if (variant->has_mod_clk) {
 		dsi->mod_clk = devm_clk_get(dev, "mod");
 		if (IS_ERR(dsi->mod_clk)) {
 			dev_err(dev, "Couldn't get the DSI mod clock\n");
 			ret = PTR_ERR(dsi->mod_clk);
 			goto err_attach_clk;
 		}
-	}
 
-	/*
-	 * In order to operate properly, that clock seems to be always
-	 * set to 297MHz.
-	 */
-	clk_set_rate_exclusive(dsi->mod_clk, 297000000);
+		/*
+		 * In order to operate properly, the module clock on the
+		 * A31 variant always seems to be set to 297MHz.
+		 */
+		if (variant->set_mod_clk)
+			clk_set_rate_exclusive(dsi->mod_clk, 297000000);
+	}
 
 	dsi->dphy = devm_phy_get(dev, "dphy");
 	if (IS_ERR(dsi->dphy)) {
@@ -1191,7 +1192,8 @@ static int sun6i_dsi_probe(struct platform_device *pdev)
 err_remove_dsi_host:
 	mipi_dsi_host_unregister(&dsi->host);
 err_unprotect_clk:
-	clk_rate_exclusive_put(dsi->mod_clk);
+	if (dsi->variant->has_mod_clk && dsi->variant->set_mod_clk)
+		clk_rate_exclusive_put(dsi->mod_clk);
 err_attach_clk:
 	regmap_mmio_detach_clk(dsi->regs);
 
@@ -1205,16 +1207,31 @@ static int sun6i_dsi_remove(struct platform_device *pdev)
 
 	component_del(&pdev->dev, &sun6i_dsi_ops);
 	mipi_dsi_host_unregister(&dsi->host);
-	clk_rate_exclusive_put(dsi->mod_clk);
+	if (dsi->variant->has_mod_clk && dsi->variant->set_mod_clk)
+		clk_rate_exclusive_put(dsi->mod_clk);
 
 	regmap_mmio_detach_clk(dsi->regs);
 
 	return 0;
 }
 
+static const struct sun6i_dsi_variant sun6i_a31_mipi_dsi_variant = {
+	.has_mod_clk	= true,
+	.set_mod_clk	= true,
+};
+
+static const struct sun6i_dsi_variant sun50i_a64_mipi_dsi_variant = {
+};
+
 static const struct of_device_id sun6i_dsi_of_table[] = {
-	{ .compatible = "allwinner,sun6i-a31-mipi-dsi" },
-	{ .compatible = "allwinner,sun50i-a64-mipi-dsi" },
+	{
+		.compatible	= "allwinner,sun6i-a31-mipi-dsi",
+		.data		= &sun6i_a31_mipi_dsi_variant,
+	},
+	{
+		.compatible	= "allwinner,sun50i-a64-mipi-dsi",
+		.data		= &sun50i_a64_mipi_dsi_variant,
+	},
 	{ }
 };
 MODULE_DEVICE_TABLE(of, sun6i_dsi_of_table);
diff --git a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.h b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.h
index c863900ae3b4..f1ddefe0f554 100644
--- a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.h
+++ b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.h
@@ -15,6 +15,11 @@
 
 #define SUN6I_DSI_TCON_DIV	4
 
+struct sun6i_dsi_variant {
+	bool			has_mod_clk;
+	bool			set_mod_clk;
+};
+
 struct sun6i_dsi {
 	struct drm_connector	connector;
 	struct drm_encoder	encoder;
@@ -31,6 +36,8 @@ struct sun6i_dsi {
 	struct mipi_dsi_device	*device;
 	struct drm_device	*drm;
 	struct drm_panel	*panel;
+
+	const struct sun6i_dsi_variant *variant;
 };
 
 static inline struct sun6i_dsi *host_to_sun6i_dsi(struct mipi_dsi_host *host)
-- 
2.37.3


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

* [PATCH v2 4/4] drm/sun4i: dsi: Add the A100 variant
  2022-11-07  5:35 [PATCH v2 0/4] drm/sun4i: dsi: Support the A100/D1 controller variant Samuel Holland
                   ` (2 preceding siblings ...)
  2022-11-07  5:35 ` [PATCH v2 3/4] drm/sun4i: dsi: Add a variant structure Samuel Holland
@ 2022-11-07  5:35 ` Samuel Holland
  2022-11-07 13:13 ` [PATCH v2 0/4] drm/sun4i: dsi: Support the A100/D1 controller variant Maxime Ripard
  4 siblings, 0 replies; 6+ messages in thread
From: Samuel Holland @ 2022-11-07  5:35 UTC (permalink / raw)
  To: Chen-Yu Tsai, Jernej Skrabec, Maxime Ripard
  Cc: Samuel Holland, Daniel Vetter, David Airlie, Jagan Teki,
	Krzysztof Kozlowski, Rob Herring, devicetree, dri-devel,
	linux-arm-kernel, linux-kernel, linux-sunxi

The A100 variant of the MIPI DSI controller now gets its module clock
from the TCON via the TCON TOP, so the clock rate cannot be set to a
fixed value. Otherwise, it appears to be the same as the A31 variant.

Reviewed-by: Jernej Skrabec <jernej.skrabec@gmail.com>
Signed-off-by: Samuel Holland <samuel@sholland.org>
---

(no changes since v1)

 drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c
index f22c96cc8408..760ff05eabf4 100644
--- a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c
+++ b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c
@@ -1223,6 +1223,10 @@ static const struct sun6i_dsi_variant sun6i_a31_mipi_dsi_variant = {
 static const struct sun6i_dsi_variant sun50i_a64_mipi_dsi_variant = {
 };
 
+static const struct sun6i_dsi_variant sun50i_a100_mipi_dsi_variant = {
+	.has_mod_clk	= true,
+};
+
 static const struct of_device_id sun6i_dsi_of_table[] = {
 	{
 		.compatible	= "allwinner,sun6i-a31-mipi-dsi",
@@ -1232,6 +1236,10 @@ static const struct of_device_id sun6i_dsi_of_table[] = {
 		.compatible	= "allwinner,sun50i-a64-mipi-dsi",
 		.data		= &sun50i_a64_mipi_dsi_variant,
 	},
+	{
+		.compatible	= "allwinner,sun50i-a100-mipi-dsi",
+		.data		= &sun50i_a100_mipi_dsi_variant,
+	},
 	{ }
 };
 MODULE_DEVICE_TABLE(of, sun6i_dsi_of_table);
-- 
2.37.3


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

* Re: [PATCH v2 0/4] drm/sun4i: dsi: Support the A100/D1 controller variant
  2022-11-07  5:35 [PATCH v2 0/4] drm/sun4i: dsi: Support the A100/D1 controller variant Samuel Holland
                   ` (3 preceding siblings ...)
  2022-11-07  5:35 ` [PATCH v2 4/4] drm/sun4i: dsi: Add the A100 variant Samuel Holland
@ 2022-11-07 13:13 ` Maxime Ripard
  4 siblings, 0 replies; 6+ messages in thread
From: Maxime Ripard @ 2022-11-07 13:13 UTC (permalink / raw)
  To: Samuel Holland, Jernej Skrabec, Chen-Yu Tsai, Maxime Ripard
  Cc: linux-arm-kernel, linux-kernel, dri-devel, linux-sunxi,
	devicetree, Rob Herring, Daniel Vetter, David Airlie, Jagan Teki,
	Krzysztof Kozlowski

On Sun, 6 Nov 2022 23:35:48 -0600, Samuel Holland wrote:
> This series adds support for the digital part of the DSI controller
> found in the A100 and D1 SoCs (plus T7, which is not supported by
> mainline Linux). There are two changes to the hardware integration:
>   1) the module clock routes through the TCON TOP, and
>   2) the separate I/O domain is removed.
> 
> The actual register interface appears to be the same as before. The
> register definitions in the D1 BSP exactly match the A64 BSP.
> 
> [...]

Applied to drm/drm-misc (drm-misc-next).

Thanks!
Maxime

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

end of thread, other threads:[~2022-11-07 13:13 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-07  5:35 [PATCH v2 0/4] drm/sun4i: dsi: Support the A100/D1 controller variant Samuel Holland
2022-11-07  5:35 ` [PATCH v2 1/4] dt-bindings: display: sun6i-dsi: Fix clock conditional Samuel Holland
2022-11-07  5:35 ` [PATCH v2 2/4] dt-bindings: display: sun6i-dsi: Add the A100 variant Samuel Holland
2022-11-07  5:35 ` [PATCH v2 3/4] drm/sun4i: dsi: Add a variant structure Samuel Holland
2022-11-07  5:35 ` [PATCH v2 4/4] drm/sun4i: dsi: Add the A100 variant Samuel Holland
2022-11-07 13:13 ` [PATCH v2 0/4] drm/sun4i: dsi: Support the A100/D1 controller variant Maxime Ripard

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).