drm/rockchip: migrate to common dw-mipi-dsi bridge and dual-dsi
Subsystems (6)
Heiko Stuebner
maintainerv6 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
changes in v5:
- use driver-internal method to find second host
- drop of-graph based dsi method for it
changes in v6:
- patch7 don't add component on empty local dsi-bus, as some
dsi bridges might live on an i2c bus or so and attach from there. Instead check for a slave in dsi-attach and add the slave-component from there if needed
- Go back to reading dsi-slave from dt, to prevent possible driver- probe races
Heiko Stuebner (4):
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/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/rockchip/Kconfig | 2 +- drivers/gpu/drm/rockchip/Makefile | 2 +- .../gpu/drm/rockchip/dw-mipi-dsi-rockchip.c | 1075 +++++++++++++ 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 +- 12 files changed, 1213 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 · 1 line
2.18.0
Heiko Stuebner
maintainerPATCH v6 1/7 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
@@ -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.18.0
Heiko Stuebner
maintainerPATCH v6 2/7 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
@@ -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
@@ -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 · 1 line
2.18.0
Heiko Stuebner
maintainerPATCH v6 3/7 drm/bridge/synopsys: dsi: add ability to have glue-specific attach and detach
In reply to Heiko StuebnerWith 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
@@ -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
@@ -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.18.0
Heiko Stuebner
maintainerPATCH v6 4/7 dt-bindings: display: rockchip: update DSI controller
In reply to Heiko StuebnerFrom: 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
@@ -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 at 0 { + reg = <0>; #address-cells = <1>; #size-cells = <0>; + mipi_in_vopb: endpoint at 0 { reg = <0>; remote-endpoint = <&vopb_out_mipi>;
@@ -54,6 +57,16 @@ Example: remote-endpoint = <&vopl_out_mipi>; }; }; + + mipi_out: port at 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 · 1 line
2.18.0
Heiko Stuebner
maintainerPATCH v6 5/7 drm/rockchip: dsi: migrate to use dw-mipi-dsi bridge driver
In reply to Heiko StuebnerFrom: 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
@@ -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 DRM_RGB if ROCKCHIP_RGB select SND_SOC_HDMI_CODEC if ROCKCHIP_CDN_DP && SND_SOC help
drivers/gpu/drm/rockchip/Makefile +1 -1
@@ -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 rockchipdrm-$(CONFIG_ROCKCHIP_RGB) += rockchip_rgb.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
@@ -489,7 +489,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
@@ -67,7 +67,7 @@ int rockchip_drm_wait_vact_end(struct drm_crtc *crtc, unsigned int mstimeout);int rockchip_drm_endpoint_is_subdriver (struct device_node *ep);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 · 1 line
2.18.0
Heiko Stuebner
maintainerPATCH v6 6/7 drm/bridge/synopsys: dsi: add dual-dsi support
In reply to Heiko StuebnerFrom: 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
@@ -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
@@ -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 · 1 line
2.18.0
Heiko Stuebner
maintainerPATCH v6 7/7 drm/rockchip: dsi: add dual mipi support
In reply to Heiko StuebnerAdd 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.
v6:
handle master+slave component in dsi-attach
v5:
use driver-internal mechanism to find dual dsi slave
v4:
add component directly in probe when adding empty dsi slave controller
--- .../gpu/drm/rockchip/dw-mipi-dsi-rockchip.c | 136 ++++++++++++++++++ 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, 145 insertions(+)
drivers/gpu/drm/rockchip/dw-mipi-dsi-rockchip.c +137 -0
@@ -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); }
@@ -673,14 +686,113 @@ static int rockchip_dsi_drm_create_encoder(struct dw_mipi_dsi_rockchip *dsi,return 0 ; } +static struct device +*dw_mipi_dsi_rockchip_find_second (struct dw_mipi_dsi_rockchip *dsi) +{ +const struct of_device_id *match; +struct device_node *node =NULL , *local; + + match =of_match_device (dsi->dev->driver->of_match_table, dsi->dev); + + local =of_graph_get_remote_node (dsi->dev->of_node,1 ,0 ); +if (!local) +return NULL ; + +while ((node =of_find_compatible_node (node,NULL , + match->compatible))) { +struct device_node *remote; + +/* found ourself */ +if (node == dsi->dev->of_node) +continue ; + + remote =of_graph_get_remote_node (node,1 ,0 ); +if (!remote) +continue ; + +/* same display device in port1-ep0 for both */ +if (remote == local) { +struct dw_mipi_dsi_rockchip *dsi2; +struct platform_device *pdev; + + pdev =of_find_device_by_node (node); + +/* +* we have found the second, so will either return it +* or return with an error. In any case won't need the +* nodes anymore nor continue the loop. +*/ +of_node_put (remote); +of_node_put (node); +of_node_put (local); + +if (!pdev) +return ERR_PTR (-EPROBE_DEFER ); + + dsi2 =platform_get_drvdata (pdev); +if (!dsi2) { +platform_device_put (pdev); +return ERR_PTR (-EPROBE_DEFER ); + } + +return &pdev->dev; + } + +of_node_put (remote); + } + +of_node_put (local); + +return NULL ; +} +static int dw_mipi_dsi_rockchip_bind (struct device *dev,struct device *master,void *data) {struct dw_mipi_dsi_rockchip *dsi =dev_get_drvdata (dev);struct drm_device *drm_dev = data; +struct device *second; +bool master1, master2;int ret; + second =dw_mipi_dsi_rockchip_find_second (dsi); +if (IS_ERR (second)) +return PTR_ERR (second); + +if (second) { + master1 =of_property_read_bool (dsi->dev->of_node, +"clock-master" ); + master2 =of_property_read_bool (second->of_node, +"clock-master" ); + +if (master1 && master2) { +DRM_DEV_ERROR (dsi->dev,"only one clock-master allowed\n" ); +return -EINVAL ; + } + +if (!master1 && !master2) { +DRM_DEV_ERROR (dsi->dev,"no clock-master defined\n" ); +return -EINVAL ; + } + +/* we are the slave in dual-DSI */ +if (!master1) { + dsi->is_slave = true; +return 0 ; + } + + dsi->slave =dev_get_drvdata (second); +if (!dsi->slave) { +DRM_DEV_ERROR (dev,"could not get slaves data\n" ); +return -ENODEV ; + } + + dsi->slave->is_slave = true; +dw_mipi_dsi_set_slave (dsi->dmd, dsi->slave->dmd); +put_device (second); + } + ret =clk_prepare_enable (dsi->pllref_clk);if (ret) {DRM_DEV_ERROR (dev,"Failed to enable pllref_clk: %d\n" , ret);
@@ -708,6 +819,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);
@@ -722,6 +836,7 @@ static int dw_mipi_dsi_rockchip_host_attach(void *priv_data, struct mipi_dsi_device *device) {struct dw_mipi_dsi_rockchip *dsi = priv_data; +struct device *second;int ret; ret =component_add (dsi->dev, &dw_mipi_dsi_rockchip_ops);
@@ -731,6 +846,19 @@ static int dw_mipi_dsi_rockchip_host_attach(void *priv_data,return ret; } + second =dw_mipi_dsi_rockchip_find_second (dsi); +if (IS_ERR (second)) +return PTR_ERR (second); +if (second) { + ret =component_add (second, &dw_mipi_dsi_rockchip_ops); +if (ret) { +DRM_DEV_ERROR (second, +"Failed to register component: %d\n" , + ret); +return ret; + } + } +return 0 ; }
@@ -738,6 +866,11 @@ static int dw_mipi_dsi_rockchip_host_detach(void *priv_data, struct mipi_dsi_device *device) {struct dw_mipi_dsi_rockchip *dsi = priv_data; +struct device *second; + + second =dw_mipi_dsi_rockchip_find_second (dsi); +if (second && !IS_ERR (second)) +component_del (second, &dw_mipi_dsi_rockchip_ops);component_del (dsi->dev, &dw_mipi_dsi_rockchip_ops);
@@ -846,6 +979,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
@@ -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
@@ -916,6 +916,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 :
@@ -933,6 +934,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
@@ -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; };
@@ -214,6 +215,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
@@ -634,6 +634,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 · 1 line
2.18.0
Re: [PATCH v6 7/7] drm/rockchip: dsi: add dual mipi support
Quoted 7 lines · 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.
Quoted 8 lines
v6:
handle master+slave component in dsi-attach
v5:
use driver-internal mechanism to find dual dsi slave
v4:
add component directly in probe when adding empty dsi slave controllerSigned-off-by Heiko Stuebner <[email protected]>
This is not what I really like (putting dual display functionality into poor dsi driver), but it at least works.
So:
The patchset is quite long on the list so if there will be no objections I will merge it tomorrow.
?--
Regards
Andrzej
Quoted 308 lines
--- .../gpu/drm/rockchip/dw-mipi-dsi-rockchip.c | 136 ++++++++++++++++++ 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, 145 insertions(+)drivers/gpu/drm/rockchip/dw-mipi-dsi-rockchip.c +137
-0@@ -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); }@@ -673,14 +686,113 @@ static int rockchip_dsi_drm_create_encoder(struct dw_mipi_dsi_rockchip *dsi,return 0 ; } +static struct device +*dw_mipi_dsi_rockchip_find_second (struct dw_mipi_dsi_rockchip *dsi) +{ +const struct of_device_id *match; +struct device_node *node =NULL , *local; + + match =of_match_device (dsi->dev->driver->of_match_table, dsi->dev); + + local =of_graph_get_remote_node (dsi->dev->of_node,1 ,0 ); +if (!local) +return NULL ; + +while ((node =of_find_compatible_node (node,NULL , + match->compatible))) { +struct device_node *remote; + +/* found ourself */ +if (node == dsi->dev->of_node) +continue ; + + remote =of_graph_get_remote_node (node,1 ,0 ); +if (!remote) +continue ; + +/* same display device in port1-ep0 for both */ +if (remote == local) { +struct dw_mipi_dsi_rockchip *dsi2; +struct platform_device *pdev; + + pdev =of_find_device_by_node (node); + +/* +* we have found the second, so will either return it +* or return with an error. In any case won't need the +* nodes anymore nor continue the loop. +*/ +of_node_put (remote); +of_node_put (node); +of_node_put (local); + +if (!pdev) +return ERR_PTR (-EPROBE_DEFER ); + + dsi2 =platform_get_drvdata (pdev); +if (!dsi2) { +platform_device_put (pdev); +return ERR_PTR (-EPROBE_DEFER ); + } + +return &pdev->dev; + } + +of_node_put (remote); + } + +of_node_put (local); + +return NULL ; +} +static int dw_mipi_dsi_rockchip_bind (struct device *dev,struct device *master,void *data) {struct dw_mipi_dsi_rockchip *dsi =dev_get_drvdata (dev);struct drm_device *drm_dev = data; +struct device *second; +bool master1, master2;int ret; + second =dw_mipi_dsi_rockchip_find_second (dsi); +if (IS_ERR (second)) +return PTR_ERR (second); + +if (second) { + master1 =of_property_read_bool (dsi->dev->of_node, +"clock-master" ); + master2 =of_property_read_bool (second->of_node, +"clock-master" ); + +if (master1 && master2) { +DRM_DEV_ERROR (dsi->dev,"only one clock-master allowed\n" ); +return -EINVAL ; + } + +if (!master1 && !master2) { +DRM_DEV_ERROR (dsi->dev,"no clock-master defined\n" ); +return -EINVAL ; + } + +/* we are the slave in dual-DSI */ +if (!master1) { + dsi->is_slave = true; +return 0 ; + } + + dsi->slave =dev_get_drvdata (second); +if (!dsi->slave) { +DRM_DEV_ERROR (dev,"could not get slaves data\n" ); +return -ENODEV ; + } + + dsi->slave->is_slave = true; +dw_mipi_dsi_set_slave (dsi->dmd, dsi->slave->dmd); +put_device (second); + } + ret =clk_prepare_enable (dsi->pllref_clk);if (ret) {DRM_DEV_ERROR (dev,"Failed to enable pllref_clk: %d\n" , ret);@@ -708,6 +819,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);@@ -722,6 +836,7 @@ static int dw_mipi_dsi_rockchip_host_attach(void *priv_data, struct mipi_dsi_device *device) {struct dw_mipi_dsi_rockchip *dsi = priv_data; +struct device *second;int ret; ret =component_add (dsi->dev, &dw_mipi_dsi_rockchip_ops);@@ -731,6 +846,19 @@ static int dw_mipi_dsi_rockchip_host_attach(void *priv_data,return ret; } + second =dw_mipi_dsi_rockchip_find_second (dsi); +if (IS_ERR (second)) +return PTR_ERR (second); +if (second) { + ret =component_add (second, &dw_mipi_dsi_rockchip_ops); +if (ret) { +DRM_DEV_ERROR (second, +"Failed to register component: %d\n" , + ret); +return ret; + } + } +return 0 ; }@@ -738,6 +866,11 @@ static int dw_mipi_dsi_rockchip_host_detach(void *priv_data, struct mipi_dsi_device *device) {struct dw_mipi_dsi_rockchip *dsi = priv_data; +struct device *second; + + second =dw_mipi_dsi_rockchip_find_second (dsi); +if (second && !IS_ERR (second)) +component_del (second, &dw_mipi_dsi_rockchip_ops);component_del (dsi->dev, &dw_mipi_dsi_rockchip_ops);@@ -846,6 +979,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@@ -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@@ -916,6 +916,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 :@@ -933,6 +934,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@@ -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; };@@ -214,6 +215,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@@ -634,6 +634,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 = {
Andrzej Hajda
AppliedQuoted 4 lines · Heiko Stuebner
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.
Queued to drm-misc-next.
Regards
Andrzej