drm/rockchip: migrate to common dw-mipi-dsi bridge and dual-dsi
Subsystems (6)
Heiko Stuebner
maintainercover 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 v8 based on Nickeys earlier 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.
The dual-dsi setup follows the port description introduced by Archit [0], in that the panel defines two input ports that get connected to both dsi-controllers instances. So on Gru-Scarlett this looks for example like:
&mipi_dsi {
status = "okay";
clock-master;
ports {
mipi_out: port@1 {
reg = <1>;
mipi_out_panel: endpoint {
remote-endpoint = <&mipi_in_panel>;
};
};
};
mipi_panel: panel@0 {
/* 2 different panels are used, compatibles are in dts files */
reg = <0>;
backlight = <&backlight>;
enable-gpios = <&gpio4 25 GPIO_ACTIVE_HIGH>;
pinctrl-names = "default";
pinctrl-0 = <&display_rst_l>;
ports {
#address-cells = <1>;
#size-cells = <0>;
port@0 {
reg = <0>;
mipi_in_panel: endpoint {
remote-endpoint = <&mipi_out_panel>;
};
};
port@1 {
reg = <1>;
mipi1_in_panel: endpoint@1 {
remote-endpoint = <&mipi1_out_panel>;
};
};
};
};
};&mipi_dsi1 {
status = "okay";
ports {
mipi1_out: port@1 {
reg = <1>;
mipi1_out_panel: endpoint {
remote-endpoint = <&mipi1_in_panel>;
};
};
};
};The driver internal setup is pretty similar to what tegra does with its ganged-mode [1][2]. Here a new helper function allows to traverse the devicetree from one controller port through the panel to find another dsi-controller using that same panel. This way we don't need a special phandle-property to link the controllers together.
Looking at the tegra-code it seems that it expects the panel to just declare 4 lanes which then get assigned to each dsi instance, where ours currently declares 8 which then get divided in the dual-case.
I think both have merrit, so I guess I'll let people with more clue decide that ;-) .
For the CRTC it is still one single display to handle, only with an additional switch that enables the dual-dsi output.
For practical purposes it is possible to just pick half the series (till patch 5) to get the migration to the bridge driver first, so that we can get rid of the dw-dsi copy in the Rockchip driver.
[0] https://patchwork.kernel.org/patch/10172381/
[1] https://lkml.org/lkml/2014/8/5/396
[2] https://patchwork.kernel.org/patch/5075161/
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: defer probing if panel not available in
bridge-attach
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 | 115 +- 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 | 1001 ++++++++++++ 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 | 6 +- include/drm/drm_mipi_dsi.h | 2 + 14 files changed, 1188 insertions(+), 1381 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
Heiko Stuebner
maintainerPATCH 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
@@ -945,6 +945,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); }
@@ -961,8 +963,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 · 6 lines
2.17.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Heiko Stuebner
maintainerPATCH 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 call dw_mipi_dsi_probe separately in their probe function 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
@@ -970,31 +970,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 · 6 lines
2.17.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Heiko Stuebner
maintainerPATCH 3/8 drm/bridge/synopsys: dsi: defer probing if panel not available in bridge-attach
In reply to Heiko StuebnerWhen 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
So emit a -EPROBE_DEFER in that case to give the driver another chance at getting the display later.
--- drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c +3 -0
@@ -839,6 +839,9 @@ static int dw_mipi_dsi_bridge_attach(struct drm_bridge *bridge)return -ENODEV ; } +if (!dsi->panel_bridge) +return -EPROBE_DEFER ; +/* Set the encoder type as caller does not know it */ bridge->encoder->encoder_type =DRM_MODE_ENCODER_DSI ;
Signature · 6 lines
2.17.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Heiko Stuebner
maintainerPATCH 4/8 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@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
Heiko Stuebner
maintainerPATCH v8 5/8 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
--- drivers/gpu/drm/rockchip/Kconfig | 2 +- drivers/gpu/drm/rockchip/Makefile | 2 +- .../gpu/drm/rockchip/dw-mipi-dsi-rockchip.c | 936 ++++++++++++ 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, 940 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 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
@@ -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 +936 -0
936 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
@@ -477,7 +477,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
@@ -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
PATCH 6/8 drm/dsi: add helper function to find the second host in a dual-dsi setup
In reply to a message not in the archiveQuoted 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.
--- 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
@@ -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
@@ -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 · 1 line
2.17.0
Heiko Stuebner
maintainerPATCH 7/8 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().
--- drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 93 +++++++++++++++++-- include/drm/bridge/dw_mipi_dsi.h | 1 + 2 files changed, 86 insertions(+), 8 deletions(-)
drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c +85 -8
@@ -234,9 +234,17 @@ struct dw_mipi_dsi {u32 format;unsigned long mode_flags; +struct dw_mipi_dsi *slave;/* dual-dsi slave ptr */ +bool is_slave;/* dual-dsi slave state */ +const struct dw_mipi_dsi_plat_data *plat_data; }; +static inline bool dw_mipi_is_dual_mode (struct dw_mipi_dsi *dsi) +{ +return dsi->slave || dsi->is_slave; +} +/* * The controller should generate 2 frames before * preparing the peripheral.
@@ -276,19 +284,37 @@ static int dw_mipi_dsi_host_attach(struct mipi_dsi_host *host,struct dw_mipi_dsi *dsi =host_to_dsi (host);struct drm_bridge *bridge;struct drm_panel *panel; +struct device_node *np;int ret; +int lanes = device->lanes; + +/* check for dual-dsi */ + np =of_mipi_dsi_find_second_host (dsi->dev->of_node,1 ,0 ); +if (IS_ERR (np)) +return PTR_ERR (np); +if (np) { +of_node_put (np); + lanes /=2 ; + } -if (device->lanes > dsi->plat_data->max_data_lanes) { +if (lanes > dsi->plat_data->max_data_lanes) {dev_err (dsi->dev,"the number of data lanes(%u) is too many\n" , device->lanes);return -EINVAL ; } - dsi->lanes = device->lanes; + dsi->lanes = lanes; dsi->channel = device->channel; dsi->format = device->format; dsi->mode_flags = device->mode_flags; +if (dsi->slave) { + dsi->slave->lanes = dsi->lanes; + dsi->slave->channel = dsi->channel; + dsi->slave->format = dsi->format; + dsi->slave->mode_flags = dsi->mode_flags; + } + ret =drm_of_find_panel_or_bridge (host->dev->of_node,1 ,0 , &panel, &bridge);if (ret)
@@ -445,10 +471,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);
@@ -587,7 +620,15 @@ 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)); + +int pkt_size; + +if (dw_mipi_is_dual_mode (dsi)) + pkt_size =VID_PKT_SIZE (mode->hdisplay /2 ); +else + pkt_size =VID_PKT_SIZE (mode->hdisplay); + +dsi_write (dsi,DSI_VID_PKT_SIZE , pkt_size); }static void dw_mipi_dsi_command_mode_config (struct dw_mipi_dsi *dsi)
@@ -760,23 +801,33 @@ static void dw_mipi_dsi_bridge_post_disable(struct drm_bridge *bridge) dsi->panel_bridge->funcs->post_disable (dsi->panel_bridge);dw_mipi_dsi_disable (dsi); +if (dsi->slave) { +dw_mipi_dsi_disable (dsi->slave); +clk_disable_unprepare (dsi->slave->pclk); +pm_runtime_put (dsi->slave->dev); + } +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 void dw_mipi_dsi_mode_set (struct dw_mipi_dsi *dsi, +struct drm_display_mode *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;clk_prepare_enable (dsi->pclk); +if (dw_mipi_is_dual_mode (dsi)) + lanes = dsi->lanes *2 ; +else + lanes = dsi->lanes; + ret = phy_ops->get_lane_mbps (priv_data, 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" );
@@ -808,12 +859,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, mode); +if (dsi->slave) +dw_mipi_dsi_mode_set (dsi->slave, 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
@@ -953,6 +1017,19 @@ 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) +{ + dsi->slave = slave; + +/* migrate settings for already attached displays */ + dsi->slave->is_slave = true; + 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
@@ -37,5 +37,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
Heiko Stuebner
maintainerPATCH 8/8 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.
--- .../gpu/drm/rockchip/dw-mipi-dsi-rockchip.c | 67 ++++++++++++++++++- 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, 75 insertions(+), 1 deletion(-)
drivers/gpu/drm/rockchip/dw-mipi-dsi-rockchip.c +66 -1
@@ -227,6 +227,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;
@@ -613,6 +617,8 @@ static void dw_mipi_dsi_encoder_mode_set(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); }
@@ -641,6 +647,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 ; }
@@ -650,6 +658,8 @@ static void dw_mipi_dsi_encoder_disable(struct drm_encoder *encoder)struct dw_mipi_dsi_rockchip *dsi =to_dsi (encoder);pm_runtime_put (dsi->dev); +if (dsi->slave) +pm_runtime_put (dsi->slave->dev); } static const struct drm_encoder_helper_funcs
@@ -690,18 +700,70 @@ 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;struct drm_bridge *bridge;struct drm_panel *panel; +bool master1, master2;int ret;/* -* Handle probe-deferrals due to missing display. +* At this point both DSIs (if in use) should have probed and found +* any connected displays or bridges. +* This also takes care of handling possible probe-deferrals. */ ret =drm_of_find_panel_or_bridge (dsi->dev->of_node,1 ,0 , &panel, &bridge);if (ret)return 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 =rockchip_dsi_drm_create_encoder (dsi, drm_dev);if (ret) {DRM_DEV_ERROR (dev,"Failed to create drm encoder\n" );
@@ -723,6 +785,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); }
drivers/gpu/drm/rockchip/rockchip_drm_drv.h +1 -0
@@ -36,6 +36,7 @@ struct rockchip_crtc_state {struct drm_crtc_state base;int output_type;int output_mode; +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
@@ -905,6 +905,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 :
@@ -922,6 +923,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; };
@@ -212,6 +213,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
@@ -420,6 +420,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
Rob Herring
Reviewed-byRe: [PATCH 4/8] dt-bindings: display: rockchip: update DSI controller
In reply to a message not in the archiveQuoted 7 lines · 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.
Quoted 6 lines
Signed-off-by Nickey Yang <[email protected]>Reviewed-by Brian Norris <[email protected]>Signed-off-by Heiko Stuebner <[email protected]>--- .../display/rockchip/dw_mipi_dsi_rockchip.txt | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-)