Skip to contentSkip to conversation

drm/rockchip: migrate to common dw-mipi-dsi bridge and dual-dsi

PATCH Superseded Heiko Stuebner 4 participants 14 messages Aug 14, 2018 – Aug 21, 2018 3 messages not in the archive

Subsystems (6)

v4 of 8 Superseded Latest is v8 →

lore
Share & tools
lore

Heiko Stuebner

author maintainer
#0 lore raw

v4 cover drm/rockchip: migrate to common dw-mipi-dsi bridge and dual-dsi

The Rockchip DSI driver was separate till now, not using the common bridge driver that was introduced a bit later. So this series migrates over to use that common bridge driver and then also adds support for dual-dsi to both the bridge and Rockchip glue code.

The bridge-migration itself is based on Nickeys earlier v8 work, but adapted to current kernels and with a new split between probe and bind, so that we do not create and drop the dsi-host on each deferred bind attempt.

changes in v2:
- rebase against newer drm code (dsi-bridge+rockchip changes)
- add SPDX header to new glue driver
- expect regular interface lanes from panel (like 4) not the double number Similar to tegra
- keep links to both master and slave
changes in v3:
- don't defer in bridge_attach, instead add ability to check for finalized panel attachement, for example in bind
- address bridge-conversion comments from Andrzej:
- include ordering
- moved hwaccess from mode_set to enable callback
- move pllref_clk enablement to bind (needed by bridge mode_set->lane_mbps)
- limited slave settings to dw_mipi_dsi_set_slave
- address dual-dsi comments from Philippe:
- remove unneeded separate variables
- remove unneeded second slave settings
- disable slave before master
- lane-sum calculation comments
changes in v4:
- rebase against some legacy rockchip-dsi changes
- add dsi-component only after panel has attached to dsi host This solves quite some concurrency problems that happen when trying to determine dsi-panel availability

Unchanged from review comments:
- kept dw_mipi_dsi_bind, as the dsi->bridge member is only part of the bridge drivers struct, so not accessible from glue drivers
- kept helper to find second host, as I think it's pretty near to Archit's description
- kept dual-dsi handling that mimicks tegra

Heiko Stuebner (5):
drm/bridge/synopsys: dsi: move mipi_dsi_host_unregister to
__dw_mipi_dsi_remove
drm/bridge/synopsys: dsi: don't call __dw_mipi_dsi_probe from
dw_mipi_dsi_bind
drm/bridge/synopsys: dsi: add ability to have glue-specific attach and
detach
drm/dsi: add helper function to find the second host in a dual-dsi
setup
drm/rockchip: dsi: add dual mipi support

Nickey Yang (3):
dt-bindings: display: rockchip: update DSI controller drm/rockchip: dsi: migrate to use dw-mipi-dsi bridge driver drm/bridge/synopsys: dsi: add dual-dsi support

 .../display/rockchip/dw_mipi_dsi_rockchip.txt |   23 +-
 drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c |  114 +-
 drivers/gpu/drm/drm_mipi_dsi.c                |   56 +
 drivers/gpu/drm/rockchip/Kconfig              |    2 +-
 drivers/gpu/drm/rockchip/Makefile             |    2 +-
 .../gpu/drm/rockchip/dw-mipi-dsi-rockchip.c   | 1032 +++++++++++++
 drivers/gpu/drm/rockchip/dw-mipi-dsi.c        | 1349 -----------------
 drivers/gpu/drm/rockchip/rockchip_drm_drv.c   |    2 +-
 drivers/gpu/drm/rockchip/rockchip_drm_drv.h   |    3 +-
 drivers/gpu/drm/rockchip/rockchip_drm_vop.c   |    3 +
 drivers/gpu/drm/rockchip/rockchip_drm_vop.h   |    4 +
 drivers/gpu/drm/rockchip/rockchip_vop_reg.c   |    1 +
 include/drm/bridge/dw_mipi_dsi.h              |   14 +-
 include/drm/drm_mipi_dsi.h                    |    2 +
 14 files changed, 1228 insertions(+), 1379 deletions(-)
 create mode 100644 drivers/gpu/drm/rockchip/dw-mipi-dsi-rockchip.c
 delete mode 100644 drivers/gpu/drm/rockchip/dw-mipi-dsi.c
Signature · 6 lines
2.17.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

A message that is not in the archive (sent off-list or not yet received): 20180814102654.29113-1-heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org

#2 lore raw

PATCH v4 1/8 drm/bridge/synopsys: dsi: move mipi_dsi_host_unregister to __dw_mipi_dsi_remove

Right now the host is only unregistered when the driver is used via the bridge api and not via the component api, leading to the host staying registered in cases like probe deferral.

So move the host unregister to the general remove function, so that it gets cleaned up in all cases.

---
 drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c +2 -2
index fd7999642cf8..07cde255cab2 100644
@@ -941,6 +941,8 @@ __dw_mipi_dsi_probe(struct platform_device *pdev,
 
 static void __dw_mipi_dsi_remove(struct dw_mipi_dsi *dsi)
 {
+	mipi_dsi_host_unregister(&dsi->dsi_host);
+
 	pm_runtime_disable(dsi->dev);
 }
 
@@ -957,8 +959,6 @@ EXPORT_SYMBOL_GPL(dw_mipi_dsi_probe);
 
 void dw_mipi_dsi_remove(struct dw_mipi_dsi *dsi)
 {
-	mipi_dsi_host_unregister(&dsi->dsi_host);
-
 	__dw_mipi_dsi_remove(dsi);
 }
 EXPORT_SYMBOL_GPL(dw_mipi_dsi_remove);
Signature · 1 line
2.17.0
#3 lore raw

PATCH v4 3/8 drm/bridge/synopsys: dsi: add ability to have glue-specific attach and detach

In reply to a message not in the archive

With the regular means of adding the dsi-component in probe it creates a race condition with the panel probing, as the panel device only gets created after the dsi-bus got created.

When the panel-driver is build as a module it currently fails hard as the panel cannot be probed directly:

dw_mipi_dsi_bind()
__dw_mipi_dsi_probe()
creates dsi bus
creates panel device
triggers panel module load
panel not probed (module not loaded or panel probe slow)
drm_bridge_attach
fails with -EINVAL due to empty panel_bridge

Additionally the panel probing can run concurrently with dsi bringup making it possible that the panel can already be found but dsi-attach hasn't finished running.

To solve that cleanly we may want to only create the component after the panel has finished probing, by calling component_add from the host-attach dsi callback.

As that is specific to glue drivers, add a new struct for host_ops so that glue drivers can tell the bridge to call specific functions after the common host-attach and before the common host-detach run.

---
 drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 15 +++++++++++++++
 include/drm/bridge/dw_mipi_dsi.h              |  8 ++++++++
 2 files changed, 23 insertions(+)
drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c +15 -0
index bb4aeca5c0f9..3962e5d84e1e 100644
@@ -270,6 +270,7 @@ static int dw_mipi_dsi_host_attach(struct mipi_dsi_host *host,
 				   struct mipi_dsi_device *device)
 {
 	struct dw_mipi_dsi *dsi = host_to_dsi(host);
+	const struct dw_mipi_dsi_plat_data *pdata = dsi->plat_data;
 	struct drm_bridge *bridge;
 	struct drm_panel *panel;
 	int ret;
@@ -300,6 +301,12 @@ static int dw_mipi_dsi_host_attach(struct mipi_dsi_host *host,
 
 	drm_bridge_add(&dsi->bridge);
 
+	if (pdata->host_ops && pdata->host_ops->attach) {
+		ret = pdata->host_ops->attach(pdata->priv_data, device);
+		if (ret < 0)
+			return ret;
+	}
+
 	return 0;
 }
 
@@ -307,6 +314,14 @@ static int dw_mipi_dsi_host_detach(struct mipi_dsi_host *host,
 				   struct mipi_dsi_device *device)
 {
 	struct dw_mipi_dsi *dsi = host_to_dsi(host);
+	const struct dw_mipi_dsi_plat_data *pdata = dsi->plat_data;
+	int ret;
+
+	if (pdata->host_ops && pdata->host_ops->detach) {
+		ret = pdata->host_ops->detach(pdata->priv_data, device);
+		if (ret < 0)
+			return ret;
+	}
 
 	drm_of_panel_bridge_remove(host->dev->of_node, 1, 0);
 
include/drm/bridge/dw_mipi_dsi.h +8 -0
index 6d7f8eb5d9f2..a9c03099cf3e 100644
@@ -19,6 +19,13 @@ struct dw_mipi_dsi_phy_ops {
 			     unsigned int *lane_mbps);
 };
 
+struct dw_mipi_dsi_host_ops {
+	int (*attach)(void *priv_data,
+		      struct mipi_dsi_device *dsi);
+	int (*detach)(void *priv_data,
+		      struct mipi_dsi_device *dsi);
+};
+
 struct dw_mipi_dsi_plat_data {
 	void __iomem *base;
 	unsigned int max_data_lanes;
@@ -27,6 +34,7 @@ struct dw_mipi_dsi_plat_data {
 					   const struct drm_display_mode *mode);
 
 	const struct dw_mipi_dsi_phy_ops *phy_ops;
+	const struct dw_mipi_dsi_host_ops *host_ops;
 
 	void *priv_data;
 };
Signature · 1 line
2.17.0

A message that is not in the archive (sent off-list or not yet received): 20180814102654.29113-4-heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org

Reviewed-by
#5 lore raw

Re: [PATCH v4 3/8] drm/bridge/synopsys: dsi: add ability to have glue-specific attach and detach

Quoted 20 lines · Heiko Stuebner

With the regular means of adding the dsi-component in probe it creates a race condition with the panel probing, as the panel device only gets created after the dsi-bus got created.

When the panel-driver is build as a module it currently fails hard as the panel cannot be probed directly:

dw_mipi_dsi_bind()
__dw_mipi_dsi_probe()
creates dsi bus
creates panel device
triggers panel module load
panel not probed (module not loaded or panel probe slow)
drm_bridge_attach
fails with -EINVAL due to empty panel_bridge

Additionally the panel probing can run concurrently with dsi bringup making it possible that the panel can already be found but dsi-attach hasn't finished running.

Quoted 7 lines

To solve that cleanly we may want to only create the component after the panel has finished probing, by calling component_add from the host-attach dsi callback.

As that is specific to glue drivers, add a new struct for host_ops so that glue drivers can tell the bridge to call specific functions after the common host-attach and before the common host-detach run.

Sometimes I have an impression that core/glue driver architecture with callbacks to glue drivers is quite complicated, and smells mid-layer mistake :), I wonder if simple bunch of helpers with some base object wouldn't be better, but this is subject for other discussion.

Quoted 21 lines
---
 drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 15 +++++++++++++++
 include/drm/bridge/dw_mipi_dsi.h              |  8 ++++++++
 2 files changed, 23 insertions(+)
drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c +1 -0
index bb4aeca5c0f9..3962e5d84e1e 100644
@@ -270,6 +270,7 @@ static int dw_mipi_dsi_host_attach(struct mipi_dsi_host *host,
 				   struct mipi_dsi_device *device)
 {
 	struct dw_mipi_dsi *dsi = host_to_dsi(host);
+	const struct dw_mipi_dsi_plat_data *pdata = dsi->plat_data;
 	struct drm_bridge *bridge;
 	struct drm_panel *panel;
 	int ret;

drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c static int dw_mipi_dsi_host_attach(struct mipi_dsi_host *host, · line 307

Quoted 7 lines
drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c +4 -0
@@ -300,6 +301,12 @@ static int dw_mipi_dsi_host_attach(struct mipi_dsi_host *host,
 
 	drm_bridge_add(&dsi->bridge);
 
+	if (pdata->host_ops && pdata->host_ops->attach) {
+		ret = pdata->host_ops->attach(pdata->priv_data, device);
+		if (ret < 0)
+			return ret;

It could be replaced by:
    return pdata->host_ops->attach(pdata->priv_data, device);

But no strong feelings. With or without the change:

 --
Regards
Andrzej

Quoted 39 lines
drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c +10 -0
+	}
+
 	return 0;
 }
 
@@ -307,6 +314,14 @@ static int dw_mipi_dsi_host_detach(struct mipi_dsi_host *host,
 				   struct mipi_dsi_device *device)
 {
 	struct dw_mipi_dsi *dsi = host_to_dsi(host);
+	const struct dw_mipi_dsi_plat_data *pdata = dsi->plat_data;
+	int ret;
+
+	if (pdata->host_ops && pdata->host_ops->detach) {
+		ret = pdata->host_ops->detach(pdata->priv_data, device);
+		if (ret < 0)
+			return ret;
+	}
 
 	drm_of_panel_bridge_remove(host->dev->of_node, 1, 0);
 
include/drm/bridge/dw_mipi_dsi.h +7 -0
index 6d7f8eb5d9f2..a9c03099cf3e 100644
@@ -19,6 +19,13 @@ struct dw_mipi_dsi_phy_ops {
 			     unsigned int *lane_mbps);
 };
 
+struct dw_mipi_dsi_host_ops {
+	int (*attach)(void *priv_data,
+		      struct mipi_dsi_device *dsi);
+	int (*detach)(void *priv_data,
+		      struct mipi_dsi_device *dsi);
+};
+
 struct dw_mipi_dsi_plat_data {
 	void __iomem *base;
 	unsigned int max_data_lanes;

include/drm/bridge/dw_mipi_dsi.h struct dw_mipi_dsi_plat_data { · line 40

Quoted 7 lines
include/drm/bridge/dw_mipi_dsi.h +1 -0
@@ -27,6 +34,7 @@ struct dw_mipi_dsi_plat_data {
 					   const struct drm_display_mode *mode);
 
 	const struct dw_mipi_dsi_phy_ops *phy_ops;
+	const struct dw_mipi_dsi_host_ops *host_ops;
 
 	void *priv_data;
 };

_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip

author maintainer
#6 lore raw

Re: [PATCH v4 3/8] drm/bridge/synopsys: dsi: add ability to have glue-specific attach and detach

Hi,

Am Montag, 20. August 2018, 12:34:37 CEST schrieb Andrzej Hajda:

Quoted 48 lines · Heiko Stuebner
Quoted 20 lines

With the regular means of adding the dsi-component in probe it creates a race condition with the panel probing, as the panel device only gets created after the dsi-bus got created.

When the panel-driver is build as a module it currently fails hard as the panel cannot be probed directly:

dw_mipi_dsi_bind()
__dw_mipi_dsi_probe()
creates dsi bus
creates panel device
triggers panel module load
panel not probed (module not loaded or panel probe slow)
drm_bridge_attach
fails with -EINVAL due to empty panel_bridge

Additionally the panel probing can run concurrently with dsi bringup making it possible that the panel can already be found but dsi-attach hasn't finished running.

Quoted 7 lines

To solve that cleanly we may want to only create the component after the panel has finished probing, by calling component_add from the host-attach dsi callback.

As that is specific to glue drivers, add a new struct for host_ops so that glue drivers can tell the bridge to call specific functions after the common host-attach and before the common host-detach run.

Sometimes I have an impression that core/glue driver architecture with callbacks to glue drivers is quite complicated, and smells mid-layer mistake :), I wonder if simple bunch of helpers with some base object wouldn't be better, but this is subject for other discussion.

drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c static int dw_mipi_dsi_host_attach(struct mipi_dsi_host *host, · line 307

Quoted 12 lines
drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c +4 -0
@@ -300,6 +301,12 @@ static int dw_mipi_dsi_host_attach(struct mipi_dsi_host *host,
 
 	drm_bridge_add(&dsi->bridge);
 
+	if (pdata->host_ops && pdata->host_ops->attach) {
+		ret = pdata->host_ops->attach(pdata->priv_data, device);
+		if (ret < 0)
+			return ret;

It could be replaced by:

Quoted 3 lines
    return pdata->host_ops->attach(pdata->priv_data, device);

But no strong feelings. With or without the change:

I'll keep it the way it is then ;-) .

My rationale is that the "return 0" below is the last line of this function and returns the success.

The specialized attach is only called in a fraction of instances, so having a return on success in there, might be surprising if later on additional code gets added between the attach call and the return below and might be missed to modify in that case, possibly causing breakage.

Quoted 4 lines

drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c static int dw_mipi_dsi_host_attach(struct mipi_dsi_host *host, · line 311

Quoted 4 lines
drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c +2 -0
+	}
+
 	return 0;
 }

Heiko

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

author maintainer
#7 lore raw

PATCH v4 2/8 drm/bridge/synopsys: dsi: don't call __dw_mipi_dsi_probe from dw_mipi_dsi_bind

In reply to Heiko Stuebner

__dw_mipi_dsi_probe() does all the grabbing of resources and does it using devm-helpers. So this is happening on each try of master bringup possibly slowing down things a lot.

Drivers using the component framework may instead want to call dw_mipi_dsi_probe separately in their probe function to setup resources early. That way the dsi bus also gets created earlier and also not recreated on each bind-try, so that attached panels can load their modules and be probed way before the bridge-attach in the bind call.

So drop the call to __dw_mipi_dsi_probe and modify the function to take a struct dw_mipi_dsi instead of the platform-device.

---
 drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 15 +++------------
 include/drm/bridge/dw_mipi_dsi.h              |  5 +----
 2 files changed, 4 insertions(+), 16 deletions(-)
drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c +3 -12
index 07cde255cab2..bb4aeca5c0f9 100644
@@ -966,31 +966,22 @@ EXPORT_SYMBOL_GPL(dw_mipi_dsi_remove);
 /*
  * Bind/unbind API, used from platforms based on the component framework.
  */
-struct dw_mipi_dsi *
-dw_mipi_dsi_bind(struct platform_device *pdev, struct drm_encoder *encoder,
-		 const struct dw_mipi_dsi_plat_data *plat_data)
+int dw_mipi_dsi_bind(struct dw_mipi_dsi *dsi, struct drm_encoder *encoder)
 {
-	struct dw_mipi_dsi *dsi;
 	int ret;
 
-	dsi = __dw_mipi_dsi_probe(pdev, plat_data);
-	if (IS_ERR(dsi))
-		return dsi;
-
 	ret = drm_bridge_attach(encoder, &dsi->bridge, NULL);
 	if (ret) {
-		dw_mipi_dsi_remove(dsi);
 		DRM_ERROR("Failed to initialize bridge with drm\n");
-		return ERR_PTR(ret);
+		return ret;
 	}
 
-	return dsi;
+	return ret;
 }
 EXPORT_SYMBOL_GPL(dw_mipi_dsi_bind);
 
 void dw_mipi_dsi_unbind(struct dw_mipi_dsi *dsi)
 {
-	__dw_mipi_dsi_remove(dsi);
 }
 EXPORT_SYMBOL_GPL(dw_mipi_dsi_unbind);
 
include/drm/bridge/dw_mipi_dsi.h +1 -4
index d9c6d549f971..6d7f8eb5d9f2 100644
@@ -35,10 +35,7 @@ struct dw_mipi_dsi *dw_mipi_dsi_probe(struct platform_device *pdev,
 				      const struct dw_mipi_dsi_plat_data
 				      *plat_data);
 void dw_mipi_dsi_remove(struct dw_mipi_dsi *dsi);
-struct dw_mipi_dsi *dw_mipi_dsi_bind(struct platform_device *pdev,
-				     struct drm_encoder *encoder,
-				     const struct dw_mipi_dsi_plat_data
-				     *plat_data);
+int dw_mipi_dsi_bind(struct dw_mipi_dsi *dsi, struct drm_encoder *encoder);
 void dw_mipi_dsi_unbind(struct dw_mipi_dsi *dsi);
 
 #endif /* __DW_MIPI_DSI__ */
Signature · 6 lines
2.17.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
author maintainer
#8 lore raw

PATCH v4 4/8 dt-bindings: display: rockchip: update DSI controller

In reply to Heiko Stuebner

From: Nickey Yang <[email protected]>

This patch update describe panel/port links, including unit addresses in documentation of device tree bindings for the rockchip DSI controller based on the Synopsys DesignWare MIPI DSI host controller.

---
 .../display/rockchip/dw_mipi_dsi_rockchip.txt | 23 +++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/display/rockchip/dw_mipi_dsi_rockchip.txt +21 -2
index 6bb59ab39f2f..ce4c1fc9116c 100644
@@ -14,6 +14,8 @@ Required properties:
 - rockchip,grf: this soc should set GRF regs to mux vopl/vopb.
 - ports: contain a port node with endpoint definitions as defined in [2].
   For vopb,set the reg = <0> and set the reg = <1> for vopl.
+- video port 0 for the VOP input, the remote endpoint maybe vopb or vopl
+- video port 1 for either a panel or subsequent encoder
 
 Optional properties:
 - power-domains: a phandle to mipi dsi power domain node.
@@ -40,11 +42,12 @@ Example:
 		ports {
 			#address-cells = <1>;
 			#size-cells = <0>;
-			reg = <1>;
 
-			mipi_in: port {
+			mipi_in: port@0 {
+				reg = <0>;
 				#address-cells = <1>;
 				#size-cells = <0>;
+
 				mipi_in_vopb: endpoint@0 {
 					reg = <0>;
 					remote-endpoint = <&vopb_out_mipi>;
@@ -54,6 +57,16 @@ Example:
 					remote-endpoint = <&vopl_out_mipi>;
 				};
 			};
+
+			mipi_out: port@1 {
+				reg = <1>;
+				#address-cells = <1>;
+				#size-cells = <0>;
+
+				mipi_out_panel: endpoint {
+					remote-endpoint = <&panel_in_mipi>;
+				};
+			};
 		};
 
 		panel {
@@ -64,5 +77,11 @@ Example:
 			pinctrl-names = "default";
 			pinctrl-0 = <&lcd_en>;
 			backlight = <&backlight>;
+
+			port {
+				panel_in_mipi: endpoint {
+					remote-endpoint = <&mipi_out_panel>;
+				};
+			};
 		};
 	};
Signature · 6 lines
2.17.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
author maintainer
#9 lore raw

PATCH v4 5/8 drm/rockchip: dsi: migrate to use dw-mipi-dsi bridge driver

In reply to Heiko Stuebner

From: Nickey Yang <[email protected]>

Add the ROCKCHIP DSI controller driver that uses the Synopsys DesignWare MIPI DSI host controller bridge and remove the old separate one.

changes:

v2:
add err_pllref, remove unnecessary encoder.enable & disable correct spelling mistakes
v3:
call dw_mipi_dsi_unbind() in dw_mipi_dsi_rockchip_unbind() fix typo, use of_device_get_match_data(),
change some bind() logic into probe()
add 'dev_set_drvdata()'
v4:
return -EINVAL when can not get best_freq
add a clarifying comment when get vco
add review tag
v5:
keep our power domain enabled while touching GRF
v6:
change func name dw_mipi_encoder_disable to dw_mipi_dsi_encoder_disable
v7:
none
v8: Heiko
add Archit's Review tag
adapt to recent changes in the original rockchip-dsi driver beautify grf-handling
split hw-setup (resources, dsi-host) from bind into probe
v2-new: Heiko
add SPDX header instead of license blurb
drop old versioning to not confuse people
v3-new: Heiko
include ordering
moved hwaccess from mode_set to enable callback
move pllref_clk enablement to bind (needed by bridge mode_set->lane_mbps)
v4-new: Heiko
rebase against recent rockchip-dsi changes
move to call component_add in the new glue host-attach

---
 drivers/gpu/drm/rockchip/Kconfig              |    2 +-
 drivers/gpu/drm/rockchip/Makefile             |    2 +-
 .../gpu/drm/rockchip/dw-mipi-dsi-rockchip.c   |  939 ++++++++++++
 drivers/gpu/drm/rockchip/dw-mipi-dsi.c        | 1349 -----------------
 drivers/gpu/drm/rockchip/rockchip_drm_drv.c   |    2 +-
 drivers/gpu/drm/rockchip/rockchip_drm_drv.h   |    2 +-
 6 files changed, 943 insertions(+), 1353 deletions(-)
 create mode 100644 drivers/gpu/drm/rockchip/dw-mipi-dsi-rockchip.c
 delete mode 100644 drivers/gpu/drm/rockchip/dw-mipi-dsi.c
drivers/gpu/drm/rockchip/Kconfig +1 -1
index 0ccc76217ee4..9eb4795596d3 100644
@@ -7,7 +7,7 @@ config DRM_ROCKCHIP
 	select VIDEOMODE_HELPERS
 	select DRM_ANALOGIX_DP if ROCKCHIP_ANALOGIX_DP
 	select DRM_DW_HDMI if ROCKCHIP_DW_HDMI
-	select DRM_MIPI_DSI if ROCKCHIP_DW_MIPI_DSI
+	select DRM_DW_MIPI_DSI if ROCKCHIP_DW_MIPI_DSI
 	select SND_SOC_HDMI_CODEC if ROCKCHIP_CDN_DP && SND_SOC
 	help
 	  Choose this option if you have a Rockchip soc chipset.
drivers/gpu/drm/rockchip/Makefile +1 -1
index a314e2109e76..0f22dad1c996 100644
@@ -11,7 +11,7 @@ rockchipdrm-$(CONFIG_DRM_FBDEV_EMULATION) += rockchip_drm_fbdev.o
 rockchipdrm-$(CONFIG_ROCKCHIP_ANALOGIX_DP) += analogix_dp-rockchip.o
 rockchipdrm-$(CONFIG_ROCKCHIP_CDN_DP) += cdn-dp-core.o cdn-dp-reg.o
 rockchipdrm-$(CONFIG_ROCKCHIP_DW_HDMI) += dw_hdmi-rockchip.o
-rockchipdrm-$(CONFIG_ROCKCHIP_DW_MIPI_DSI) += dw-mipi-dsi.o
+rockchipdrm-$(CONFIG_ROCKCHIP_DW_MIPI_DSI) += dw-mipi-dsi-rockchip.o
 rockchipdrm-$(CONFIG_ROCKCHIP_INNO_HDMI) += inno_hdmi.o
 rockchipdrm-$(CONFIG_ROCKCHIP_LVDS) += rockchip_lvds.o
 
drivers/gpu/drm/rockchip/dw-mipi-dsi-rockchip.c new file +939 -0

939 lines not on this page · raw message

drivers/gpu/drm/rockchip/dw-mipi-dsi.c deleted +0 -1349

1,349 lines not on this page · raw message

drivers/gpu/drm/rockchip/rockchip_drm_drv.c +1 -1
index 1d9c4a9201c8..bf6e0ef86aba 100644
@@ -435,7 +435,7 @@ static int __init rockchip_drm_init(void)
 	ADD_ROCKCHIP_SUB_DRIVER(cdn_dp_driver, CONFIG_ROCKCHIP_CDN_DP);
 	ADD_ROCKCHIP_SUB_DRIVER(dw_hdmi_rockchip_pltfm_driver,
 				CONFIG_ROCKCHIP_DW_HDMI);
-	ADD_ROCKCHIP_SUB_DRIVER(dw_mipi_dsi_driver,
+	ADD_ROCKCHIP_SUB_DRIVER(dw_mipi_dsi_rockchip_driver,
 				CONFIG_ROCKCHIP_DW_MIPI_DSI);
 	ADD_ROCKCHIP_SUB_DRIVER(inno_hdmi_driver, CONFIG_ROCKCHIP_INNO_HDMI);
 
drivers/gpu/drm/rockchip/rockchip_drm_drv.h +1 -1
index d67ad0a3cf36..67bbd274b71f 100644
@@ -66,7 +66,7 @@ int rockchip_drm_wait_vact_end(struct drm_crtc *crtc, unsigned int mstimeout);
 
 extern struct platform_driver cdn_dp_driver;
 extern struct platform_driver dw_hdmi_rockchip_pltfm_driver;
-extern struct platform_driver dw_mipi_dsi_driver;
+extern struct platform_driver dw_mipi_dsi_rockchip_driver;
 extern struct platform_driver inno_hdmi_driver;
 extern struct platform_driver rockchip_dp_driver;
 extern struct platform_driver rockchip_lvds_driver;
Signature · 6 lines
2.17.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

A message that is not in the archive (sent off-list or not yet received): 20180814102654.29113-6-heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org

Reviewed-by
#11 lore raw

Re: [PATCH v4 5/8] drm/rockchip: dsi: migrate to use dw-mipi-dsi bridge driver

Quoted 42 lines · Heiko Stuebner

From: Nickey Yang <[email protected]>

Add the ROCKCHIP DSI controller driver that uses the Synopsys DesignWare MIPI DSI host controller bridge and remove the old separate one.

changes:

v2:
add err_pllref, remove unnecessary encoder.enable & disable correct spelling mistakes
v3:
call dw_mipi_dsi_unbind() in dw_mipi_dsi_rockchip_unbind() fix typo, use of_device_get_match_data(),
change some bind() logic into probe()
add 'dev_set_drvdata()'
v4:
return -EINVAL when can not get best_freq
add a clarifying comment when get vco
add review tag
v5:
keep our power domain enabled while touching GRF
v6:
change func name dw_mipi_encoder_disable to dw_mipi_dsi_encoder_disable
v7:
none
v8: Heiko
add Archit's Review tag
adapt to recent changes in the original rockchip-dsi driver beautify grf-handling
split hw-setup (resources, dsi-host) from bind into probe
v2-new: Heiko
add SPDX header instead of license blurb
drop old versioning to not confuse people
v3-new: Heiko
include ordering
moved hwaccess from mode_set to enable callback
move pllref_clk enablement to bind (needed by bridge mode_set->lane_mbps)
v4-new: Heiko
rebase against recent rockchip-dsi changes
move to call component_add in the new glue host-attach

Quoted 6 lines

 --
Regards
Andrzej

_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip

author maintainer
#12 lore raw

PATCH v4 6/8 drm/dsi: add helper function to find the second host in a dual-dsi setup

In reply to Heiko Stuebner

From a specified output port of one dsi controller this function allows to iterate over the list of registered dsi controllers trying to find a second instance connected to the same display, like it is used in dual-dsi setups.

---
 drivers/gpu/drm/drm_mipi_dsi.c | 56 ++++++++++++++++++++++++++++++++++
 include/drm/drm_mipi_dsi.h     |  2 ++
 2 files changed, 58 insertions(+)
drivers/gpu/drm/drm_mipi_dsi.c +56 -0
index bc73b7f5b9fc..0c3c9c7aa3b8 100644
@@ -30,6 +30,7 @@
 #include <linux/device.h>
 #include <linux/module.h>
 #include <linux/of_device.h>
+#include <linux/of_graph.h>
 #include <linux/pm_runtime.h>
 #include <linux/slab.h>
 
@@ -282,6 +283,61 @@ struct mipi_dsi_host *of_find_mipi_dsi_host_by_node(struct device_node *node)
 }
 EXPORT_SYMBOL(of_find_mipi_dsi_host_by_node);
 
+struct device_node *of_mipi_dsi_find_second_host(struct device_node *first_np,
+						 int port, int endpoint)
+{
+	struct mipi_dsi_host *first, *host;
+	struct device_node *remote, *np, *second_np = NULL;
+	int num = 0;
+
+	first = of_find_mipi_dsi_host_by_node(first_np);
+	if (!first) {
+		pr_err("no dsi-host for node %s\n", first_np->full_name);
+		return ERR_PTR(-ENODEV);
+	}
+
+	/* output-node of the known dsi-host */
+	remote = of_graph_get_remote_node(first_np, port, endpoint);
+	if (!remote) {
+		dev_err(first->dev, "no output node found\n");
+		return ERR_PTR(-ENODEV);
+	}
+
+	mutex_lock(&host_lock);
+
+	list_for_each_entry(host, &host_list, list) {
+		np = of_graph_get_remote_node(host->dev->of_node,
+					      port, endpoint);
+
+		/* found a host connected to this panel */
+		if (np == remote)
+			num++;
+
+		/* found one second host */
+		if (host->dev->of_node != first_np)
+			second_np = host->dev->of_node;
+
+		of_node_put(np);
+	}
+
+	/* of_node_get the node under host_lock */
+	if (num == 2)
+		of_node_get(second_np);
+
+	mutex_unlock(&host_lock);
+
+	of_node_put(remote);
+
+	if (num > 2) {
+		dev_err(first->dev,
+			      "too many DSI links for output: %d links\n", num);
+		return ERR_PTR(-EINVAL);
+	}
+
+	return second_np;
+}
+EXPORT_SYMBOL(of_mipi_dsi_find_second_host);
+
 int mipi_dsi_host_register(struct mipi_dsi_host *host)
 {
 	struct device_node *node;
include/drm/drm_mipi_dsi.h +2 -0
index 4fef19064b0f..89532ae69c91 100644
@@ -107,6 +107,8 @@ struct mipi_dsi_host {
 int mipi_dsi_host_register(struct mipi_dsi_host *host);
 void mipi_dsi_host_unregister(struct mipi_dsi_host *host);
 struct mipi_dsi_host *of_find_mipi_dsi_host_by_node(struct device_node *node);
+struct device_node *of_mipi_dsi_find_second_host(struct device_node *first_np,
+						 int port, int endpoint);
 
 /* DSI mode flags */
 
Signature · 6 lines
2.17.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#13 lore raw

Re: [PATCH v4 6/8] drm/dsi: add helper function to find the second host in a dual-dsi setup

Quoted 3 lines · Heiko Stuebner
Quoted 1 line

From a specified output port of one dsi controller this function allows to

iterate over the list of registered dsi controllers trying to find a second instance connected to the same display, like it is used in dual-dsi setups.

As I said earlier it looks for me incorrectly. You create helper to access/control one DSI controller from another but there is no point in doing it. If CRTC is able to send video stream via two links it should be CRTC's responsibility to setup and use DSI controllers attached to these links. If the panel is able to combine stream from two DSI links into one image it should be panel's responsibility to inform DSI controllers about each link's configuration.

Moreover from usage of this helper (patch 8/8) it looks like you assumes, that second host must be also synopsys, this is not true/generic at all.

I know there could be many obstacles in alternative approach, so you really insist on this hack, please use it inside the driver, you can use for example driver_for_each_device/driver_find_device to find 2nd DSI host.

Regards
Andrzej

Quoted 86 lines
---
 drivers/gpu/drm/drm_mipi_dsi.c | 56 ++++++++++++++++++++++++++++++++++
 include/drm/drm_mipi_dsi.h     |  2 ++
 2 files changed, 58 insertions(+)
drivers/gpu/drm/drm_mipi_dsi.c +56 -0
index bc73b7f5b9fc..0c3c9c7aa3b8 100644
@@ -30,6 +30,7 @@
 #include <linux/device.h>
 #include <linux/module.h>
 #include <linux/of_device.h>
+#include <linux/of_graph.h>
 #include <linux/pm_runtime.h>
 #include <linux/slab.h>
 
@@ -282,6 +283,61 @@ struct mipi_dsi_host *of_find_mipi_dsi_host_by_node(struct device_node *node)
 }
 EXPORT_SYMBOL(of_find_mipi_dsi_host_by_node);
 
+struct device_node *of_mipi_dsi_find_second_host(struct device_node *first_np,
+						 int port, int endpoint)
+{
+	struct mipi_dsi_host *first, *host;
+	struct device_node *remote, *np, *second_np = NULL;
+	int num = 0;
+
+	first = of_find_mipi_dsi_host_by_node(first_np);
+	if (!first) {
+		pr_err("no dsi-host for node %s\n", first_np->full_name);
+		return ERR_PTR(-ENODEV);
+	}
+
+	/* output-node of the known dsi-host */
+	remote = of_graph_get_remote_node(first_np, port, endpoint);
+	if (!remote) {
+		dev_err(first->dev, "no output node found\n");
+		return ERR_PTR(-ENODEV);
+	}
+
+	mutex_lock(&host_lock);
+
+	list_for_each_entry(host, &host_list, list) {
+		np = of_graph_get_remote_node(host->dev->of_node,
+					      port, endpoint);
+
+		/* found a host connected to this panel */
+		if (np == remote)
+			num++;
+
+		/* found one second host */
+		if (host->dev->of_node != first_np)
+			second_np = host->dev->of_node;
+
+		of_node_put(np);
+	}
+
+	/* of_node_get the node under host_lock */
+	if (num == 2)
+		of_node_get(second_np);
+
+	mutex_unlock(&host_lock);
+
+	of_node_put(remote);
+
+	if (num > 2) {
+		dev_err(first->dev,
+			      "too many DSI links for output: %d links\n", num);
+		return ERR_PTR(-EINVAL);
+	}
+
+	return second_np;
+}
+EXPORT_SYMBOL(of_mipi_dsi_find_second_host);
+
 int mipi_dsi_host_register(struct mipi_dsi_host *host)
 {
 	struct device_node *node;
include/drm/drm_mipi_dsi.h +0 -0
index 4fef19064b0f..89532ae69c91 100644

include/drm/drm_mipi_dsi.h struct mipi_dsi_host { · line 114

Quoted 8 lines
include/drm/drm_mipi_dsi.h +2 -0
@@ -107,6 +107,8 @@ struct mipi_dsi_host {
 int mipi_dsi_host_register(struct mipi_dsi_host *host);
 void mipi_dsi_host_unregister(struct mipi_dsi_host *host);
 struct mipi_dsi_host *of_find_mipi_dsi_host_by_node(struct device_node *node);
+struct device_node *of_mipi_dsi_find_second_host(struct device_node *first_np,
+						 int port, int endpoint);
 
 /* DSI mode flags */
 

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

author maintainer
#14 lore raw

Re: [PATCH v4 6/8] drm/dsi: add helper function to find the second host in a dual-dsi setup

Hi Andrzej,

Am Montag, 20. August 2018, 13:37:24 CEST schrieb Andrzej Hajda:

Quoted 13 lines · Heiko Stuebner
Quoted 3 lines
Quoted 1 line

From a specified output port of one dsi controller this function allows to

iterate over the list of registered dsi controllers trying to find a second instance connected to the same display, like it is used in dual-dsi setups.

As I said earlier it looks for me incorrectly. You create helper to access/control one DSI controller from another but there is no point in doing it. If CRTC is able to send video stream via two links it should be CRTC's responsibility to setup and use DSI controllers attached to these links. If the panel is able to combine stream from two DSI links into one image it should be panel's responsibility to inform DSI controllers about each link's configuration.

Quoted 7 lines

Moreover from usage of this helper (patch 8/8) it looks like you assumes, that second host must be also synopsys, this is not true/generic at all.

I know there could be many obstacles in alternative approach, so you really insist on this hack, please use it inside the driver, you can use for example driver_for_each_device/driver_find_device to find 2nd DSI host.

Ok, I'll move that inside the rockchip-driver.

My rationale still is that both msm (with a Committer-Signed-off by Rob Clark) and Tegra (code from Thierry), do follow the expectation of two controllers of the same type) ... people doing graphics stuff way longer than me. So I'd like to believe the valid issue you are raising will have been discussed at least two times already ;-) .

So I really prefer not to open that can of worms myself if I don't have to ;-) .

Heiko

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

author maintainer
#15 lore raw

PATCH v4 7/8 drm/bridge/synopsys: dsi: add dual-dsi support

In reply to Heiko Stuebner

From: Nickey Yang <[email protected]>

Allow to also drive a slave dw-mipi-dsi controller in a dual-dsi setup. This will require additional implementation-specific code to look up the slave instance and do specific setup. Also will probably need code in the specific crtcs as dual-dsi does not equal two separate dsi outputs.

To activate, the implementation-specific code should set the slave using dw_mipi_dsi_set_slave() before calling __dw_mipi_dsi_bind().

v2:
- expect real interface number of lanes
- keep links to both master and slave
v3:
- remove unneeded separate variables
- remove unneeded second slave settings
- disable slave before master
- lane-sum calculation comments

---
 drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 80 +++++++++++++++++--
 include/drm/bridge/dw_mipi_dsi.h              |  1 +
 2 files changed, 75 insertions(+), 6 deletions(-)
drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c +74 -6
index 3962e5d84e1e..2f4b145b73af 100644
@@ -230,9 +230,20 @@ struct dw_mipi_dsi {
 	u32 format;
 	unsigned long mode_flags;
 
+	struct dw_mipi_dsi *master; /* dual-dsi master ptr */
+	struct dw_mipi_dsi *slave; /* dual-dsi slave ptr */
+
 	const struct dw_mipi_dsi_plat_data *plat_data;
 };
 
+/*
+ * Check if either a link to a master or slave is present
+ */
+static inline bool dw_mipi_is_dual_mode(struct dw_mipi_dsi *dsi)
+{
+	return dsi->slave || dsi->master;
+}
+
 /*
  * The controller should generate 2 frames before
  * preparing the peripheral.
@@ -456,10 +467,17 @@ static ssize_t dw_mipi_dsi_host_transfer(struct mipi_dsi_host *host,
 	}
 
 	dw_mipi_message_config(dsi, msg);
+	if (dsi->slave)
+		dw_mipi_message_config(dsi->slave, msg);
 
 	ret = dw_mipi_dsi_write(dsi, &packet);
 	if (ret)
 		return ret;
+	if (dsi->slave) {
+		ret = dw_mipi_dsi_write(dsi->slave, &packet);
+		if (ret)
+			return ret;
+	}
 
 	if (msg->rx_buf && msg->rx_len) {
 		ret = dw_mipi_dsi_read(dsi, msg);
@@ -598,7 +616,11 @@ static void dw_mipi_dsi_video_packet_config(struct dw_mipi_dsi *dsi,
 	 * DSI_VNPCR.NPSIZE... especially because this driver supports
 	 * non-burst video modes, see dw_mipi_dsi_video_mode_config()...
 	 */
-	dsi_write(dsi, DSI_VID_PKT_SIZE, VID_PKT_SIZE(mode->hdisplay));
+
+	dsi_write(dsi, DSI_VID_PKT_SIZE,
+		       dw_mipi_is_dual_mode(dsi) ?
+				VID_PKT_SIZE(mode->hdisplay / 2) :
+				VID_PKT_SIZE(mode->hdisplay));
 }
 
 static void dw_mipi_dsi_command_mode_config(struct dw_mipi_dsi *dsi)
@@ -770,24 +792,43 @@ static void dw_mipi_dsi_bridge_post_disable(struct drm_bridge *bridge)
 	 */
 	dsi->panel_bridge->funcs->post_disable(dsi->panel_bridge);
 
+	if (dsi->slave) {
+		dw_mipi_dsi_disable(dsi->slave);
+		clk_disable_unprepare(dsi->slave->pclk);
+		pm_runtime_put(dsi->slave->dev);
+	}
 	dw_mipi_dsi_disable(dsi);
+
 	clk_disable_unprepare(dsi->pclk);
 	pm_runtime_put(dsi->dev);
 }
 
-static void dw_mipi_dsi_bridge_mode_set(struct drm_bridge *bridge,
-					struct drm_display_mode *mode,
-					struct drm_display_mode *adjusted_mode)
+static unsigned int dw_mipi_dsi_get_lanes(struct dw_mipi_dsi *dsi)
+{
+	/* this instance is the slave, so add the master's lanes */
+	if (dsi->master)
+		return dsi->master->lanes + dsi->lanes;
+
+	/* this instance is the master, so add the slave's lanes */
+	if (dsi->slave)
+		return dsi->lanes + dsi->slave->lanes;
+
+	/* single-dsi, so no other instance to consider */
+	return dsi->lanes;
+}
+
+static void dw_mipi_dsi_mode_set(struct dw_mipi_dsi *dsi,
+				struct drm_display_mode *adjusted_mode)
 {
-	struct dw_mipi_dsi *dsi = bridge_to_dsi(bridge);
 	const struct dw_mipi_dsi_phy_ops *phy_ops = dsi->plat_data->phy_ops;
 	void *priv_data = dsi->plat_data->priv_data;
 	int ret;
+	u32 lanes = dw_mipi_dsi_get_lanes(dsi);
 
 	clk_prepare_enable(dsi->pclk);
 
 	ret = phy_ops->get_lane_mbps(priv_data, adjusted_mode, dsi->mode_flags,
-				     dsi->lanes, dsi->format, &dsi->lane_mbps);
+				     lanes, dsi->format, &dsi->lane_mbps);
 	if (ret)
 		DRM_DEBUG_DRIVER("Phy get_lane_mbps() failed\n");
 
@@ -819,12 +860,25 @@ static void dw_mipi_dsi_bridge_mode_set(struct drm_bridge *bridge,
 	dw_mipi_dsi_set_mode(dsi, 0);
 }
 
+static void dw_mipi_dsi_bridge_mode_set(struct drm_bridge *bridge,
+					struct drm_display_mode *mode,
+					struct drm_display_mode *adjusted_mode)
+{
+	struct dw_mipi_dsi *dsi = bridge_to_dsi(bridge);
+
+	dw_mipi_dsi_mode_set(dsi, adjusted_mode);
+	if (dsi->slave)
+		dw_mipi_dsi_mode_set(dsi->slave, adjusted_mode);
+}
+
 static void dw_mipi_dsi_bridge_enable(struct drm_bridge *bridge)
 {
 	struct dw_mipi_dsi *dsi = bridge_to_dsi(bridge);
 
 	/* Switch to video mode for panel-bridge enable & panel enable */
 	dw_mipi_dsi_set_mode(dsi, MIPI_DSI_MODE_VIDEO);
+	if (dsi->slave)
+		dw_mipi_dsi_set_mode(dsi->slave, MIPI_DSI_MODE_VIDEO);
 }
 
 static enum drm_mode_status
@@ -961,6 +1015,20 @@ static void __dw_mipi_dsi_remove(struct dw_mipi_dsi *dsi)
 	pm_runtime_disable(dsi->dev);
 }
 
+void dw_mipi_dsi_set_slave(struct dw_mipi_dsi *dsi, struct dw_mipi_dsi *slave)
+{
+	/* introduce controllers to each other */
+	dsi->slave = slave;
+	dsi->slave->master = dsi;
+
+	/* migrate settings for already attached displays */
+	dsi->slave->lanes = dsi->lanes;
+	dsi->slave->channel = dsi->channel;
+	dsi->slave->format = dsi->format;
+	dsi->slave->mode_flags = dsi->mode_flags;
+}
+EXPORT_SYMBOL_GPL(dw_mipi_dsi_set_slave);
+
 /*
  * Probe/remove API, used from platforms based on the DRM bridge API.
  */
include/drm/bridge/dw_mipi_dsi.h +1 -0
index a9c03099cf3e..48a671e782ca 100644
@@ -45,5 +45,6 @@ struct dw_mipi_dsi *dw_mipi_dsi_probe(struct platform_device *pdev,
 void dw_mipi_dsi_remove(struct dw_mipi_dsi *dsi);
 int dw_mipi_dsi_bind(struct dw_mipi_dsi *dsi, struct drm_encoder *encoder);
 void dw_mipi_dsi_unbind(struct dw_mipi_dsi *dsi);
+void dw_mipi_dsi_set_slave(struct dw_mipi_dsi *dsi, struct dw_mipi_dsi *slave);
 
 #endif /* __DW_MIPI_DSI__ */
Signature · 6 lines
2.17.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
author maintainer
#16 lore raw

PATCH v4 8/8 drm/rockchip: dsi: add dual mipi support

In reply to Heiko Stuebner

Add the Rockchip-sepcific dual-dsi setup and hook it into the VOP as well. As described in the general dual-dsi devicetree binding, the panel should define two input ports and point each of them to one of the used dsi- controllers, as well as declare one of them as clock-master. This is used to determine the dual-dsi state and get access to both controller instances.

v4:
add component directly in probe when adding empty dsi slave controller

---
 .../gpu/drm/rockchip/dw-mipi-dsi-rockchip.c   | 93 +++++++++++++++++++
 drivers/gpu/drm/rockchip/rockchip_drm_drv.h   |  1 +
 drivers/gpu/drm/rockchip/rockchip_drm_vop.c   |  3 +
 drivers/gpu/drm/rockchip/rockchip_drm_vop.h   |  4 +
 drivers/gpu/drm/rockchip/rockchip_vop_reg.c   |  1 +
 5 files changed, 102 insertions(+)
drivers/gpu/drm/rockchip/dw-mipi-dsi-rockchip.c +93 -0
index b3aae8439aa3..fd872e855939 100644
@@ -218,6 +218,10 @@ struct dw_mipi_dsi_rockchip {
 	struct clk *grf_clk;
 	struct clk *phy_cfg_clk;
 
+	/* dual-channel */
+	bool is_slave;
+	struct dw_mipi_dsi_rockchip *slave;
+
 	unsigned int lane_mbps; /* per lane */
 	u16 input_div;
 	u16 feedback_div;
@@ -226,6 +230,7 @@ struct dw_mipi_dsi_rockchip {
 	struct dw_mipi_dsi *dmd;
 	const struct rockchip_dw_dsi_chip_data *cdata;
 	struct dw_mipi_dsi_plat_data pdata;
+	int devcnt;
 };
 
 struct dphy_pll_parameter_map {
@@ -602,6 +607,8 @@ dw_mipi_dsi_encoder_atomic_check(struct drm_encoder *encoder,
 	}
 
 	s->output_type = DRM_MODE_CONNECTOR_DSI;
+	if (dsi->slave)
+		s->output_flags = ROCKCHIP_OUTPUT_DSI_DUAL;
 
 	return 0;
 }
@@ -617,6 +624,8 @@ static void dw_mipi_dsi_encoder_enable(struct drm_encoder *encoder)
 		return;
 
 	pm_runtime_get_sync(dsi->dev);
+	if (dsi->slave)
+		pm_runtime_get_sync(dsi->slave->dev);
 
 	/*
 	 * For the RK3399, the clk of grf must be enabled before writing grf
@@ -630,6 +639,8 @@ static void dw_mipi_dsi_encoder_enable(struct drm_encoder *encoder)
 	}
 
 	dw_mipi_dsi_rockchip_config(dsi, mux);
+	if (dsi->slave)
+		dw_mipi_dsi_rockchip_config(dsi->slave, mux);
 
 	clk_disable_unprepare(dsi->grf_clk);
 }
@@ -638,6 +649,8 @@ static void dw_mipi_dsi_encoder_disable(struct drm_encoder *encoder)
 {
 	struct dw_mipi_dsi_rockchip *dsi = to_dsi(encoder);
 
+	if (dsi->slave)
+		pm_runtime_put(dsi->slave->dev);
 	pm_runtime_put(dsi->dev);
 }
 
@@ -679,8 +692,58 @@ static int dw_mipi_dsi_rockchip_bind(struct device *dev,
 {
 	struct dw_mipi_dsi_rockchip *dsi = dev_get_drvdata(dev);
 	struct drm_device *drm_dev = data;
+	struct device_node *second_np;
+	bool master1, master2;
 	int ret;
 
+	second_np = of_mipi_dsi_find_second_host(dsi->dev->of_node, 1, 0);
+	if (IS_ERR(second_np))
+		return PTR_ERR(second_np);
+
+	if (second_np) {
+		struct platform_device *pdev;
+
+		master1 = of_property_read_bool(dsi->dev->of_node,
+						"clock-master");
+		master2 = of_property_read_bool(second_np, "clock-master");
+
+		if (master1 && master2) {
+			DRM_DEV_ERROR(dsi->dev, "only one clock-master allowed\n");
+			of_node_put(second_np);
+			return -EINVAL;
+		}
+
+		if (!master1 && !master2) {
+			DRM_DEV_ERROR(dsi->dev, "no clock-master defined\n");
+			of_node_put(second_np);
+			return -EINVAL;
+		}
+
+		/* we are the slave in dual-DSI */
+		if (!master1) {
+			dsi->is_slave = true;
+			of_node_put(second_np);
+			return 0;
+		}
+
+		pdev = of_find_device_by_node(second_np);
+		if (!pdev) {
+			DRM_DEV_ERROR(dev, "could not find slave controller\n");
+			return -ENODEV;
+		}
+
+		dsi->slave = platform_get_drvdata(pdev);
+		if (!dsi->slave) {
+			DRM_DEV_ERROR(dev, "could not get slaves platform-data\n");
+			return -ENODEV;
+		}
+
+		dsi->slave->is_slave = true;
+		dw_mipi_dsi_set_slave(dsi->dmd, dsi->slave->dmd);
+
+		of_node_put(second_np);
+	}
+
 	ret = clk_prepare_enable(dsi->pllref_clk);
 	if (ret) {
 		DRM_DEV_ERROR(dev, "Failed to enable pllref_clk: %d\n", ret);
@@ -708,6 +771,9 @@ static void dw_mipi_dsi_rockchip_unbind(struct device *dev,
 {
 	struct dw_mipi_dsi_rockchip *dsi = dev_get_drvdata(dev);
 
+	if (dsi->is_slave)
+		return;
+
 	dw_mipi_dsi_unbind(dsi->dmd);
 
 	clk_disable_unprepare(dsi->pllref_clk);
@@ -749,6 +815,14 @@ static const struct dw_mipi_dsi_host_ops dw_mipi_dsi_rockchip_host_ops = {
 	.detach = dw_mipi_dsi_rockchip_host_detach,
 };
 
+static int dw_mipi_dsi_rockchip_cnt_dev(struct device *dev, void *data)
+{
+	struct dw_mipi_dsi_rockchip *dsi = data;
+
+	dsi->devcnt++;
+	return 0;
+}
+
 static int dw_mipi_dsi_rockchip_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
@@ -835,6 +909,22 @@ static int dw_mipi_dsi_rockchip_probe(struct platform_device *pdev)
 		goto err_clkdisable;
 	}
 
+	/*
+	 * All dsi child devices will have been created, so we can check
+	 * their number and add the component here if there will be no
+	 * host-attach call.
+	 */
+	device_for_each_child(dsi->dev, dsi, dw_mipi_dsi_rockchip_cnt_dev);
+	if (dsi->devcnt == 0) {
+		ret = component_add(dsi->dev, &dw_mipi_dsi_rockchip_ops);
+		if (ret) {
+			DRM_DEV_ERROR(dsi->dev, "Failed to register component: %d\n",
+						ret);
+			dw_mipi_dsi_remove(dsi->dmd);
+			goto err_clkdisable;
+		}
+	}
+
 	return 0;
 
 err_clkdisable:
@@ -846,6 +936,9 @@ static int dw_mipi_dsi_rockchip_remove(struct platform_device *pdev)
 {
 	struct dw_mipi_dsi_rockchip *dsi = platform_get_drvdata(pdev);
 
+	if (dsi->devcnt == 0)
+		component_del(dsi->dev, &dw_mipi_dsi_rockchip_ops);
+
 	dw_mipi_dsi_remove(dsi->dmd);
 
 	return 0;
drivers/gpu/drm/rockchip/rockchip_drm_drv.h +1 -0
index 67bbd274b71f..acdd4facca67 100644
@@ -37,6 +37,7 @@ struct rockchip_crtc_state {
 	int output_type;
 	int output_mode;
 	int output_bpc;
+	int output_flags;
 };
 #define to_rockchip_crtc_state(s) \
 		container_of(s, struct rockchip_crtc_state, base)
drivers/gpu/drm/rockchip/rockchip_drm_vop.c +3 -0
index 1359e5c773e4..4f63be275059 100644
@@ -910,6 +910,7 @@ static void vop_crtc_atomic_enable(struct drm_crtc *crtc,
 	pin_pol |= (adjusted_mode->flags & DRM_MODE_FLAG_PVSYNC) ?
 		   BIT(VSYNC_POSITIVE) : 0;
 	VOP_REG_SET(vop, output, pin_pol, pin_pol);
+	VOP_REG_SET(vop, output, mipi_dual_channel_en, 0);
 
 	switch (s->output_type) {
 	case DRM_MODE_CONNECTOR_LVDS:
@@ -927,6 +928,8 @@ static void vop_crtc_atomic_enable(struct drm_crtc *crtc,
 	case DRM_MODE_CONNECTOR_DSI:
 		VOP_REG_SET(vop, output, mipi_pin_pol, pin_pol);
 		VOP_REG_SET(vop, output, mipi_en, 1);
+		VOP_REG_SET(vop, output, mipi_dual_channel_en,
+			    !!(s->output_flags & ROCKCHIP_OUTPUT_DSI_DUAL));
 		break;
 	case DRM_MODE_CONNECTOR_DisplayPort:
 		pin_pol &= ~BIT(DCLK_INVERT);
drivers/gpu/drm/rockchip/rockchip_drm_vop.h +4 -0
index fcb91041a666..361e4c7d225c 100644
@@ -60,6 +60,7 @@ struct vop_output {
 	struct vop_reg edp_en;
 	struct vop_reg hdmi_en;
 	struct vop_reg mipi_en;
+	struct vop_reg mipi_dual_channel_en;
 	struct vop_reg rgb_en;
 };
 
@@ -213,6 +214,9 @@ struct vop_data {
 /* for use special outface */
 #define ROCKCHIP_OUT_MODE_AAAA	15
 
+/* output flags */
+#define ROCKCHIP_OUTPUT_DSI_DUAL	BIT(0)
+
 enum alpha_mode {
 	ALPHA_STRAIGHT,
 	ALPHA_INVERSE,
drivers/gpu/drm/rockchip/rockchip_vop_reg.c +1 -0
index d824ca60c1a4..44d73c7beb5c 100644
@@ -543,6 +543,7 @@ static const struct vop_output rk3399_output = {
 	.hdmi_en = VOP_REG(RK3288_SYS_CTRL, 0x1, 13),
 	.edp_en = VOP_REG(RK3288_SYS_CTRL, 0x1, 14),
 	.mipi_en = VOP_REG(RK3288_SYS_CTRL, 0x1, 15),
+	.mipi_dual_channel_en = VOP_REG(RK3288_SYS_CTRL, 0x1, 3),
 };
 
 static const struct vop_data rk3399_vop_big = {
Signature · 6 lines
2.17.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel