Skip to content

Commit 3880f62

Browse files
committed
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
1 parent 633ba1e commit 3880f62

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed

drivers/gpu/drm/rockchip/rockchip_drm_drv.c

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include <linux/pm_runtime.h>
2525
#include <linux/module.h>
2626
#include <linux/of_graph.h>
27+
#include <linux/of_platform.h>
2728
#include <linux/component.h>
2829
#include <linux/console.h>
2930
#include <linux/iommu.h>
@@ -267,6 +268,53 @@ static const struct dev_pm_ops rockchip_drm_pm_ops = {
267268
static struct platform_driver *rockchip_sub_drivers[MAX_ROCKCHIP_SUB_DRIVERS];
268269
static int num_rockchip_sub_drivers;
269270

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+
*/
281+
int 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+
270318
static int compare_dev(struct device *dev, void *data)
271319
{
272320
return dev == (struct device *)data;

drivers/gpu/drm/rockchip/rockchip_drm_drv.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ void rockchip_drm_dma_detach_device(struct drm_device *drm_dev,
6464
struct device *dev);
6565
int rockchip_drm_wait_vact_end(struct drm_crtc *crtc, unsigned int mstimeout);
6666

67+
int rockchip_drm_endpoint_is_subdriver(struct device_node *ep);
6768
extern struct platform_driver cdn_dp_driver;
6869
extern struct platform_driver dw_hdmi_rockchip_pltfm_driver;
6970
extern struct platform_driver dw_mipi_dsi_driver;

0 commit comments

Comments
 (0)