aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHeiko Stuebner <heiko@sntech.de>2018-08-30 17:12:05 -0400
committerHeiko Stuebner <heiko@sntech.de>2018-09-05 06:24:25 -0400
commit3880f62e476df5fb6fe4ac3ebd2442a9ce306c6b (patch)
tree26d012f5d8a64edce98a8707cbed3c6cacd28844
parent633ba1e086e1abbeef1ffd899911de8cf3987d9f (diff)
drm/rockchip: add function to check if endpoint is a subdriver
To be able to have both internal subdrivers and external bridge drivers as output endpoints of vops, add a function to be able to distinguish these. changes in v8: - improved function documentation - better error handling - put calls for node and pdev references changes in v6: - added function to check subdriver vs. bridge Signed-off-by: Heiko Stuebner <heiko@sntech.de> Reviewed-by: Sandy Huang <hjc@rock-chips.com> Link: https://patchwork.freedesktop.org/patch/msgid/20180830211207.10480-2-heiko@sntech.de
-rw-r--r--drivers/gpu/drm/rockchip/rockchip_drm_drv.c48
-rw-r--r--drivers/gpu/drm/rockchip/rockchip_drm_drv.h1
2 files changed, 49 insertions, 0 deletions
diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
index 1d9c4a9201c8..5864cb452c5c 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
@@ -24,6 +24,7 @@
24#include <linux/pm_runtime.h> 24#include <linux/pm_runtime.h>
25#include <linux/module.h> 25#include <linux/module.h>
26#include <linux/of_graph.h> 26#include <linux/of_graph.h>
27#include <linux/of_platform.h>
27#include <linux/component.h> 28#include <linux/component.h>
28#include <linux/console.h> 29#include <linux/console.h>
29#include <linux/iommu.h> 30#include <linux/iommu.h>
@@ -267,6 +268,53 @@ static const struct dev_pm_ops rockchip_drm_pm_ops = {
267static struct platform_driver *rockchip_sub_drivers[MAX_ROCKCHIP_SUB_DRIVERS]; 268static struct platform_driver *rockchip_sub_drivers[MAX_ROCKCHIP_SUB_DRIVERS];
268static int num_rockchip_sub_drivers; 269static int num_rockchip_sub_drivers;
269 270
271/*
272 * Check if a vop endpoint is leading to a rockchip subdriver or bridge.
273 * Should be called from the component bind stage of the drivers
274 * to ensure that all subdrivers are probed.
275 *
276 * @ep: endpoint of a rockchip vop
277 *
278 * returns true if subdriver, false if external bridge and -ENODEV
279 * if remote port does not contain a device.
280 */
281int rockchip_drm_endpoint_is_subdriver(struct device_node *ep)
282{
283 struct device_node *node = of_graph_get_remote_port_parent(ep);
284 struct platform_device *pdev;
285 struct device_driver *drv;
286 int i;
287
288 if (!node)
289 return -ENODEV;
290
291 /* status disabled will prevent creation of platform-devices */
292 pdev = of_find_device_by_node(node);
293 of_node_put(node);
294 if (!pdev)
295 return -ENODEV;
296
297 /*
298 * All rockchip subdrivers have probed at this point, so
299 * any device not having a driver now is an external bridge.
300 */
301 drv = pdev->dev.driver;
302 if (!drv) {
303 platform_device_put(pdev);
304 return false;
305 }
306
307 for (i = 0; i < num_rockchip_sub_drivers; i++) {
308 if (rockchip_sub_drivers[i] == to_platform_driver(drv)) {
309 platform_device_put(pdev);
310 return true;
311 }
312 }
313
314 platform_device_put(pdev);
315 return false;
316}
317
270static int compare_dev(struct device *dev, void *data) 318static int compare_dev(struct device *dev, void *data)
271{ 319{
272 return dev == (struct device *)data; 320 return dev == (struct device *)data;
diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.h b/drivers/gpu/drm/rockchip/rockchip_drm_drv.h
index d67ad0a3cf36..21a023a97bb8 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.h
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.h
@@ -64,6 +64,7 @@ void rockchip_drm_dma_detach_device(struct drm_device *drm_dev,
64 struct device *dev); 64 struct device *dev);
65int rockchip_drm_wait_vact_end(struct drm_crtc *crtc, unsigned int mstimeout); 65int rockchip_drm_wait_vact_end(struct drm_crtc *crtc, unsigned int mstimeout);
66 66
67int rockchip_drm_endpoint_is_subdriver(struct device_node *ep);
67extern struct platform_driver cdn_dp_driver; 68extern struct platform_driver cdn_dp_driver;
68extern struct platform_driver dw_hdmi_rockchip_pltfm_driver; 69extern struct platform_driver dw_hdmi_rockchip_pltfm_driver;
69extern struct platform_driver dw_mipi_dsi_driver; 70extern struct platform_driver dw_mipi_dsi_driver;