aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRob Herring <robh@kernel.org>2017-03-22 09:26:06 -0400
committerSean Paul <seanpaul@chromium.org>2017-04-06 17:00:27 -0400
commit86418f90a4c1a0073db65d8a1e2bf94421117a60 (patch)
treea82b9534e5f5c89ceeaa93abaad71da000c7f8d3
parent1f2db3034c9f16ed918e34809167546f21d0fcb4 (diff)
drm: convert drivers to use of_graph_get_remote_node
Convert drivers to use the new of_graph_get_remote_node() helper instead of parsing the endpoint node and then getting the remote device node. Now drivers can just specify the device node and which port/endpoint and get back the connected remote device node. The details of the graph binding are nicely abstracted into the core OF graph code. This changes some error messages to debug messages (in the graph core). Graph connections are often "no connects" depending on the particular board, so we want to avoid spurious messages. Plus the kernel is not a DT validator. Signed-off-by: Rob Herring <robh@kernel.org> Acked-by: Neil Armstrong <narmstrong@baylibre.com> Tested-by: Liviu Dudau <liviu.dudau@arm.com> Tested-by: Eric Anholt <eric@anholt.net> Tested-by: Jyri Sarha <jsarha@ti.com> Tested by: Archit Taneja <architt@codeaurora.org> Signed-off-by: Sean Paul <seanpaul@chromium.org>
-rw-r--r--drivers/gpu/drm/arm/hdlcd_drv.c22
-rw-r--r--drivers/gpu/drm/arm/malidp_drv.c28
-rw-r--r--drivers/gpu/drm/bridge/adv7511/adv7533.c12
-rw-r--r--drivers/gpu/drm/bridge/dumb-vga-dac.c15
-rw-r--r--drivers/gpu/drm/bridge/ti-tfp410.c15
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_dpi.c16
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_dsi.c13
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_mic.c25
-rw-r--r--drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c30
-rw-r--r--drivers/gpu/drm/mediatek/mtk_dpi.c12
-rw-r--r--drivers/gpu/drm/mediatek/mtk_hdmi.c26
-rw-r--r--drivers/gpu/drm/meson/meson_venc_cvbs.c19
-rw-r--r--drivers/gpu/drm/msm/dsi/dsi_host.c2
-rw-r--r--drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.c28
-rw-r--r--drivers/gpu/drm/tilcdc/tilcdc_crtc.c12
-rw-r--r--drivers/gpu/drm/tilcdc/tilcdc_external.c68
-rw-r--r--drivers/gpu/drm/vc4/vc4_dpi.c15
17 files changed, 48 insertions, 310 deletions
diff --git a/drivers/gpu/drm/arm/hdlcd_drv.c b/drivers/gpu/drm/arm/hdlcd_drv.c
index 0e74880b5e94..0f49c4b12772 100644
--- a/drivers/gpu/drm/arm/hdlcd_drv.c
+++ b/drivers/gpu/drm/arm/hdlcd_drv.c
@@ -392,29 +392,13 @@ static int compare_dev(struct device *dev, void *data)
392 392
393static int hdlcd_probe(struct platform_device *pdev) 393static int hdlcd_probe(struct platform_device *pdev)
394{ 394{
395 struct device_node *port, *ep; 395 struct device_node *port;
396 struct component_match *match = NULL; 396 struct component_match *match = NULL;
397 397
398 if (!pdev->dev.of_node)
399 return -ENODEV;
400
401 /* there is only one output port inside each device, find it */ 398 /* there is only one output port inside each device, find it */
402 ep = of_graph_get_next_endpoint(pdev->dev.of_node, NULL); 399 port = of_graph_get_remote_node(pdev->dev.of_node, 0, 0);
403 if (!ep) 400 if (!port)
404 return -ENODEV;
405
406 if (!of_device_is_available(ep)) {
407 of_node_put(ep);
408 return -ENODEV; 401 return -ENODEV;
409 }
410
411 /* add the remote encoder port as component */
412 port = of_graph_get_remote_port_parent(ep);
413 of_node_put(ep);
414 if (!port || !of_device_is_available(port)) {
415 of_node_put(port);
416 return -EAGAIN;
417 }
418 402
419 drm_of_component_match_add(&pdev->dev, &match, compare_dev, port); 403 drm_of_component_match_add(&pdev->dev, &match, compare_dev, port);
420 of_node_put(port); 404 of_node_put(port);
diff --git a/drivers/gpu/drm/arm/malidp_drv.c b/drivers/gpu/drm/arm/malidp_drv.c
index ea2546f766c2..898c2b58e73d 100644
--- a/drivers/gpu/drm/arm/malidp_drv.c
+++ b/drivers/gpu/drm/arm/malidp_drv.c
@@ -283,7 +283,6 @@ static int malidp_bind(struct device *dev)
283{ 283{
284 struct resource *res; 284 struct resource *res;
285 struct drm_device *drm; 285 struct drm_device *drm;
286 struct device_node *ep;
287 struct malidp_drm *malidp; 286 struct malidp_drm *malidp;
288 struct malidp_hw_device *hwdev; 287 struct malidp_hw_device *hwdev;
289 struct platform_device *pdev = to_platform_device(dev); 288 struct platform_device *pdev = to_platform_device(dev);
@@ -398,12 +397,7 @@ static int malidp_bind(struct device *dev)
398 goto init_fail; 397 goto init_fail;
399 398
400 /* Set the CRTC's port so that the encoder component can find it */ 399 /* Set the CRTC's port so that the encoder component can find it */
401 ep = of_graph_get_next_endpoint(dev->of_node, NULL); 400 malidp->crtc.port = of_graph_get_port_by_id(dev->of_node, 0);
402 if (!ep) {
403 ret = -EINVAL;
404 goto port_fail;
405 }
406 malidp->crtc.port = of_get_next_parent(ep);
407 401
408 ret = component_bind_all(dev, drm); 402 ret = component_bind_all(dev, drm);
409 if (ret) { 403 if (ret) {
@@ -458,7 +452,6 @@ irq_init_fail:
458bind_fail: 452bind_fail:
459 of_node_put(malidp->crtc.port); 453 of_node_put(malidp->crtc.port);
460 malidp->crtc.port = NULL; 454 malidp->crtc.port = NULL;
461port_fail:
462 malidp_fini(drm); 455 malidp_fini(drm);
463init_fail: 456init_fail:
464 drm->dev_private = NULL; 457 drm->dev_private = NULL;
@@ -516,29 +509,16 @@ static int malidp_compare_dev(struct device *dev, void *data)
516 509
517static int malidp_platform_probe(struct platform_device *pdev) 510static int malidp_platform_probe(struct platform_device *pdev)
518{ 511{
519 struct device_node *port, *ep; 512 struct device_node *port;
520 struct component_match *match = NULL; 513 struct component_match *match = NULL;
521 514
522 if (!pdev->dev.of_node) 515 if (!pdev->dev.of_node)
523 return -ENODEV; 516 return -ENODEV;
524 517
525 /* there is only one output port inside each device, find it */ 518 /* there is only one output port inside each device, find it */
526 ep = of_graph_get_next_endpoint(pdev->dev.of_node, NULL); 519 port = of_graph_get_remote_node(pdev->dev.of_node, 0, 0);
527 if (!ep) 520 if (!port)
528 return -ENODEV;
529
530 if (!of_device_is_available(ep)) {
531 of_node_put(ep);
532 return -ENODEV; 521 return -ENODEV;
533 }
534
535 /* add the remote encoder port as component */
536 port = of_graph_get_remote_port_parent(ep);
537 of_node_put(ep);
538 if (!port || !of_device_is_available(port)) {
539 of_node_put(port);
540 return -EAGAIN;
541 }
542 522
543 drm_of_component_match_add(&pdev->dev, &match, malidp_compare_dev, 523 drm_of_component_match_add(&pdev->dev, &match, malidp_compare_dev,
544 port); 524 port);
diff --git a/drivers/gpu/drm/bridge/adv7511/adv7533.c b/drivers/gpu/drm/bridge/adv7511/adv7533.c
index 8b210373cfa2..ac804f81e2f6 100644
--- a/drivers/gpu/drm/bridge/adv7511/adv7533.c
+++ b/drivers/gpu/drm/bridge/adv7511/adv7533.c
@@ -232,7 +232,6 @@ void adv7533_detach_dsi(struct adv7511 *adv)
232int adv7533_parse_dt(struct device_node *np, struct adv7511 *adv) 232int adv7533_parse_dt(struct device_node *np, struct adv7511 *adv)
233{ 233{
234 u32 num_lanes; 234 u32 num_lanes;
235 struct device_node *endpoint;
236 235
237 of_property_read_u32(np, "adi,dsi-lanes", &num_lanes); 236 of_property_read_u32(np, "adi,dsi-lanes", &num_lanes);
238 237
@@ -241,17 +240,10 @@ int adv7533_parse_dt(struct device_node *np, struct adv7511 *adv)
241 240
242 adv->num_dsi_lanes = num_lanes; 241 adv->num_dsi_lanes = num_lanes;
243 242
244 endpoint = of_graph_get_next_endpoint(np, NULL); 243 adv->host_node = of_graph_get_remote_node(np, 0, 0);
245 if (!endpoint) 244 if (!adv->host_node)
246 return -ENODEV; 245 return -ENODEV;
247 246
248 adv->host_node = of_graph_get_remote_port_parent(endpoint);
249 if (!adv->host_node) {
250 of_node_put(endpoint);
251 return -ENODEV;
252 }
253
254 of_node_put(endpoint);
255 of_node_put(adv->host_node); 247 of_node_put(adv->host_node);
256 248
257 adv->use_timing_gen = !of_property_read_bool(np, 249 adv->use_timing_gen = !of_property_read_bool(np,
diff --git a/drivers/gpu/drm/bridge/dumb-vga-dac.c b/drivers/gpu/drm/bridge/dumb-vga-dac.c
index 63e113bd21d2..831a606c4706 100644
--- a/drivers/gpu/drm/bridge/dumb-vga-dac.c
+++ b/drivers/gpu/drm/bridge/dumb-vga-dac.c
@@ -154,21 +154,12 @@ static const struct drm_bridge_funcs dumb_vga_bridge_funcs = {
154 154
155static struct i2c_adapter *dumb_vga_retrieve_ddc(struct device *dev) 155static struct i2c_adapter *dumb_vga_retrieve_ddc(struct device *dev)
156{ 156{
157 struct device_node *end_node, *phandle, *remote; 157 struct device_node *phandle, *remote;
158 struct i2c_adapter *ddc; 158 struct i2c_adapter *ddc;
159 159
160 end_node = of_graph_get_endpoint_by_regs(dev->of_node, 1, -1); 160 remote = of_graph_get_remote_node(dev->of_node, 1, -1);
161 if (!end_node) { 161 if (!remote)
162 dev_err(dev, "Missing connector endpoint\n");
163 return ERR_PTR(-ENODEV);
164 }
165
166 remote = of_graph_get_remote_port_parent(end_node);
167 of_node_put(end_node);
168 if (!remote) {
169 dev_err(dev, "Enable to parse remote node\n");
170 return ERR_PTR(-EINVAL); 162 return ERR_PTR(-EINVAL);
171 }
172 163
173 phandle = of_parse_phandle(remote, "ddc-i2c-bus", 0); 164 phandle = of_parse_phandle(remote, "ddc-i2c-bus", 0);
174 of_node_put(remote); 165 of_node_put(remote);
diff --git a/drivers/gpu/drm/bridge/ti-tfp410.c b/drivers/gpu/drm/bridge/ti-tfp410.c
index 7d519b46aee4..eee4efda829e 100644
--- a/drivers/gpu/drm/bridge/ti-tfp410.c
+++ b/drivers/gpu/drm/bridge/ti-tfp410.c
@@ -165,18 +165,13 @@ static irqreturn_t tfp410_hpd_irq_thread(int irq, void *arg)
165 165
166static int tfp410_get_connector_properties(struct tfp410 *dvi) 166static int tfp410_get_connector_properties(struct tfp410 *dvi)
167{ 167{
168 struct device_node *ep = NULL, *connector_node = NULL; 168 struct device_node *connector_node, *ddc_phandle;
169 struct device_node *ddc_phandle = NULL;
170 int ret = 0; 169 int ret = 0;
171 170
172 /* port@1 is the connector node */ 171 /* port@1 is the connector node */
173 ep = of_graph_get_endpoint_by_regs(dvi->dev->of_node, 1, -1); 172 connector_node = of_graph_get_remote_node(dvi->dev->of_node, 1, -1);
174 if (!ep)
175 goto fail;
176
177 connector_node = of_graph_get_remote_port_parent(ep);
178 if (!connector_node) 173 if (!connector_node)
179 goto fail; 174 return -ENODEV;
180 175
181 dvi->hpd = fwnode_get_named_gpiod(&connector_node->fwnode, 176 dvi->hpd = fwnode_get_named_gpiod(&connector_node->fwnode,
182 "hpd-gpios", 0, GPIOD_IN, "hpd"); 177 "hpd-gpios", 0, GPIOD_IN, "hpd");
@@ -199,10 +194,10 @@ static int tfp410_get_connector_properties(struct tfp410 *dvi)
199 else 194 else
200 ret = -EPROBE_DEFER; 195 ret = -EPROBE_DEFER;
201 196
197 of_node_put(ddc_phandle);
198
202fail: 199fail:
203 of_node_put(ep);
204 of_node_put(connector_node); 200 of_node_put(connector_node);
205 of_node_put(ddc_phandle);
206 return ret; 201 return ret;
207} 202}
208 203
diff --git a/drivers/gpu/drm/exynos/exynos_drm_dpi.c b/drivers/gpu/drm/exynos/exynos_drm_dpi.c
index 3aab71a485ba..63abcd280fa0 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_dpi.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_dpi.c
@@ -163,27 +163,13 @@ enum {
163 FIMD_PORT_WRB, 163 FIMD_PORT_WRB,
164}; 164};
165 165
166static struct device_node *exynos_dpi_of_find_panel_node(struct device *dev)
167{
168 struct device_node *np, *ep;
169
170 ep = of_graph_get_endpoint_by_regs(dev->of_node, FIMD_PORT_RGB, 0);
171 if (!ep)
172 return NULL;
173
174 np = of_graph_get_remote_port_parent(ep);
175 of_node_put(ep);
176
177 return np;
178}
179
180static int exynos_dpi_parse_dt(struct exynos_dpi *ctx) 166static int exynos_dpi_parse_dt(struct exynos_dpi *ctx)
181{ 167{
182 struct device *dev = ctx->dev; 168 struct device *dev = ctx->dev;
183 struct device_node *dn = dev->of_node; 169 struct device_node *dn = dev->of_node;
184 struct device_node *np; 170 struct device_node *np;
185 171
186 ctx->panel_node = exynos_dpi_of_find_panel_node(dev); 172 ctx->panel_node = of_graph_get_remote_node(dn, FIMD_PORT_RGB, 0);
187 173
188 np = of_get_child_by_name(dn, "display-timings"); 174 np = of_get_child_by_name(dn, "display-timings");
189 if (np) { 175 if (np) {
diff --git a/drivers/gpu/drm/exynos/exynos_drm_dsi.c b/drivers/gpu/drm/exynos/exynos_drm_dsi.c
index 6d4da2f0932d..fc4fda738906 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_dsi.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_dsi.c
@@ -1659,17 +1659,10 @@ static int exynos_dsi_parse_dt(struct exynos_dsi *dsi)
1659 1659
1660 of_node_put(ep); 1660 of_node_put(ep);
1661 1661
1662 ep = of_graph_get_next_endpoint(node, NULL); 1662 dsi->bridge_node = of_graph_get_remote_node(node, DSI_PORT_OUT, 0);
1663 if (!ep) { 1663 if (!dsi->bridge_node)
1664 ret = -EINVAL; 1664 return -EINVAL;
1665 goto end;
1666 }
1667 1665
1668 dsi->bridge_node = of_graph_get_remote_port_parent(ep);
1669 if (!dsi->bridge_node) {
1670 ret = -EINVAL;
1671 goto end;
1672 }
1673end: 1666end:
1674 of_node_put(ep); 1667 of_node_put(ep);
1675 1668
diff --git a/drivers/gpu/drm/exynos/exynos_drm_mic.c b/drivers/gpu/drm/exynos/exynos_drm_mic.c
index 2ef43d403eaa..e45720543a45 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_mic.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_mic.c
@@ -229,29 +229,6 @@ static void mic_set_reg_on(struct exynos_mic *mic, bool enable)
229 writel(reg, mic->reg + MIC_OP); 229 writel(reg, mic->reg + MIC_OP);
230} 230}
231 231
232static struct device_node *get_remote_node(struct device_node *from, int reg)
233{
234 struct device_node *endpoint = NULL, *remote_node = NULL;
235
236 endpoint = of_graph_get_endpoint_by_regs(from, reg, -1);
237 if (!endpoint) {
238 DRM_ERROR("mic: Failed to find remote port from %s",
239 from->full_name);
240 goto exit;
241 }
242
243 remote_node = of_graph_get_remote_port_parent(endpoint);
244 if (!remote_node) {
245 DRM_ERROR("mic: Failed to find remote port parent from %s",
246 from->full_name);
247 goto exit;
248 }
249
250exit:
251 of_node_put(endpoint);
252 return remote_node;
253}
254
255static int parse_dt(struct exynos_mic *mic) 232static int parse_dt(struct exynos_mic *mic)
256{ 233{
257 int ret = 0, i, j; 234 int ret = 0, i, j;
@@ -263,7 +240,7 @@ static int parse_dt(struct exynos_mic *mic)
263 * The first node must be for decon and the second one must be for dsi. 240 * The first node must be for decon and the second one must be for dsi.
264 */ 241 */
265 for (i = 0, j = 0; i < NUM_ENDPOINTS; i++) { 242 for (i = 0, j = 0; i < NUM_ENDPOINTS; i++) {
266 remote_node = get_remote_node(mic->dev->of_node, i); 243 remote_node = of_graph_get_remote_node(mic->dev->of_node, i, 0);
267 if (!remote_node) { 244 if (!remote_node) {
268 ret = -EPIPE; 245 ret = -EPIPE;
269 goto exit; 246 goto exit;
diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c
index df4f50713e54..9c903672f582 100644
--- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c
+++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c
@@ -230,34 +230,6 @@ static const struct component_master_ops kirin_drm_ops = {
230 .unbind = kirin_drm_unbind, 230 .unbind = kirin_drm_unbind,
231}; 231};
232 232
233static struct device_node *kirin_get_remote_node(struct device_node *np)
234{
235 struct device_node *endpoint, *remote;
236
237 /* get the first endpoint, in our case only one remote node
238 * is connected to display controller.
239 */
240 endpoint = of_graph_get_next_endpoint(np, NULL);
241 if (!endpoint) {
242 DRM_ERROR("no valid endpoint node\n");
243 return ERR_PTR(-ENODEV);
244 }
245
246 remote = of_graph_get_remote_port_parent(endpoint);
247 of_node_put(endpoint);
248 if (!remote) {
249 DRM_ERROR("no valid remote node\n");
250 return ERR_PTR(-ENODEV);
251 }
252
253 if (!of_device_is_available(remote)) {
254 DRM_ERROR("not available for remote node\n");
255 return ERR_PTR(-ENODEV);
256 }
257
258 return remote;
259}
260
261static int kirin_drm_platform_probe(struct platform_device *pdev) 233static int kirin_drm_platform_probe(struct platform_device *pdev)
262{ 234{
263 struct device *dev = &pdev->dev; 235 struct device *dev = &pdev->dev;
@@ -271,7 +243,7 @@ static int kirin_drm_platform_probe(struct platform_device *pdev)
271 return -EINVAL; 243 return -EINVAL;
272 } 244 }
273 245
274 remote = kirin_get_remote_node(np); 246 remote = of_graph_get_remote_node(np, 0, 0);
275 if (IS_ERR(remote)) 247 if (IS_ERR(remote))
276 return PTR_ERR(remote); 248 return PTR_ERR(remote);
277 249
diff --git a/drivers/gpu/drm/mediatek/mtk_dpi.c b/drivers/gpu/drm/mediatek/mtk_dpi.c
index 3bd3bd688d1a..32ca351ecd09 100644
--- a/drivers/gpu/drm/mediatek/mtk_dpi.c
+++ b/drivers/gpu/drm/mediatek/mtk_dpi.c
@@ -661,7 +661,7 @@ static int mtk_dpi_probe(struct platform_device *pdev)
661 struct device *dev = &pdev->dev; 661 struct device *dev = &pdev->dev;
662 struct mtk_dpi *dpi; 662 struct mtk_dpi *dpi;
663 struct resource *mem; 663 struct resource *mem;
664 struct device_node *ep, *bridge_node = NULL; 664 struct device_node *bridge_node;
665 int comp_id; 665 int comp_id;
666 int ret; 666 int ret;
667 667
@@ -706,15 +706,9 @@ static int mtk_dpi_probe(struct platform_device *pdev)
706 return -EINVAL; 706 return -EINVAL;
707 } 707 }
708 708
709 ep = of_graph_get_next_endpoint(dev->of_node, NULL); 709 bridge_node = of_graph_get_remote_node(dev->of_node, 0, 0);
710 if (ep) { 710 if (!bridge_node)
711 bridge_node = of_graph_get_remote_port_parent(ep);
712 of_node_put(ep);
713 }
714 if (!bridge_node) {
715 dev_err(dev, "Failed to find bridge node\n");
716 return -ENODEV; 711 return -ENODEV;
717 }
718 712
719 dev_info(dev, "Found bridge node: %s\n", bridge_node->full_name); 713 dev_info(dev, "Found bridge node: %s\n", bridge_node->full_name);
720 714
diff --git a/drivers/gpu/drm/mediatek/mtk_hdmi.c b/drivers/gpu/drm/mediatek/mtk_hdmi.c
index c26251260b83..41a1c03b0347 100644
--- a/drivers/gpu/drm/mediatek/mtk_hdmi.c
+++ b/drivers/gpu/drm/mediatek/mtk_hdmi.c
@@ -1434,7 +1434,7 @@ static int mtk_hdmi_dt_parse_pdata(struct mtk_hdmi *hdmi,
1434{ 1434{
1435 struct device *dev = &pdev->dev; 1435 struct device *dev = &pdev->dev;
1436 struct device_node *np = dev->of_node; 1436 struct device_node *np = dev->of_node;
1437 struct device_node *cec_np, *port, *ep, *remote, *i2c_np; 1437 struct device_node *cec_np, *remote, *i2c_np;
1438 struct platform_device *cec_pdev; 1438 struct platform_device *cec_pdev;
1439 struct regmap *regmap; 1439 struct regmap *regmap;
1440 struct resource *mem; 1440 struct resource *mem;
@@ -1486,29 +1486,9 @@ static int mtk_hdmi_dt_parse_pdata(struct mtk_hdmi *hdmi,
1486 if (IS_ERR(hdmi->regs)) 1486 if (IS_ERR(hdmi->regs))
1487 return PTR_ERR(hdmi->regs); 1487 return PTR_ERR(hdmi->regs);
1488 1488
1489 port = of_graph_get_port_by_id(np, 1); 1489 remote = of_graph_get_remote_node(np, 1, 0);
1490 if (!port) { 1490 if (!remote)
1491 dev_err(dev, "Missing output port node\n");
1492 return -EINVAL; 1491 return -EINVAL;
1493 }
1494
1495 ep = of_get_child_by_name(port, "endpoint");
1496 if (!ep) {
1497 dev_err(dev, "Missing endpoint node in port %s\n",
1498 port->full_name);
1499 of_node_put(port);
1500 return -EINVAL;
1501 }
1502 of_node_put(port);
1503
1504 remote = of_graph_get_remote_port_parent(ep);
1505 if (!remote) {
1506 dev_err(dev, "Missing connector/bridge node for endpoint %s\n",
1507 ep->full_name);
1508 of_node_put(ep);
1509 return -EINVAL;
1510 }
1511 of_node_put(ep);
1512 1492
1513 if (!of_device_is_compatible(remote, "hdmi-connector")) { 1493 if (!of_device_is_compatible(remote, "hdmi-connector")) {
1514 hdmi->next_bridge = of_drm_find_bridge(remote); 1494 hdmi->next_bridge = of_drm_find_bridge(remote);
diff --git a/drivers/gpu/drm/meson/meson_venc_cvbs.c b/drivers/gpu/drm/meson/meson_venc_cvbs.c
index 5d4f19ac98fc..00775b397dba 100644
--- a/drivers/gpu/drm/meson/meson_venc_cvbs.c
+++ b/drivers/gpu/drm/meson/meson_venc_cvbs.c
@@ -224,25 +224,14 @@ static const struct drm_encoder_helper_funcs
224 224
225static bool meson_venc_cvbs_connector_is_available(struct meson_drm *priv) 225static bool meson_venc_cvbs_connector_is_available(struct meson_drm *priv)
226{ 226{
227 struct device_node *ep, *remote; 227 struct device_node *remote;
228 228
229 /* CVBS VDAC output is on the first port, first endpoint */ 229 remote = of_graph_get_remote_node(priv->dev->of_node, 0, 0);
230 ep = of_graph_get_endpoint_by_regs(priv->dev->of_node, 0, 0); 230 if (!remote)
231 if (!ep)
232 return false; 231 return false;
233 232
234
235 /* If the endpoint node exists, consider it enabled */
236 remote = of_graph_get_remote_port(ep);
237 if (remote) {
238 of_node_put(ep);
239 return true;
240 }
241
242 of_node_put(ep);
243 of_node_put(remote); 233 of_node_put(remote);
244 234 return true;
245 return false;
246} 235}
247 236
248int meson_venc_cvbs_create(struct meson_drm *priv) 237int meson_venc_cvbs_create(struct meson_drm *priv)
diff --git a/drivers/gpu/drm/msm/dsi/dsi_host.c b/drivers/gpu/drm/msm/dsi/dsi_host.c
index 4f79b109173d..f97a7803a02d 100644
--- a/drivers/gpu/drm/msm/dsi/dsi_host.c
+++ b/drivers/gpu/drm/msm/dsi/dsi_host.c
@@ -1635,7 +1635,7 @@ static int dsi_host_parse_dt(struct msm_dsi_host *msm_host)
1635 } 1635 }
1636 1636
1637 /* Get panel node from the output port's endpoint data */ 1637 /* Get panel node from the output port's endpoint data */
1638 device_node = of_graph_get_remote_port_parent(endpoint); 1638 device_node = of_graph_get_remote_node(np, 1, 0);
1639 if (!device_node) { 1639 if (!device_node) {
1640 dev_dbg(dev, "%s: no valid device\n", __func__); 1640 dev_dbg(dev, "%s: no valid device\n", __func__);
1641 goto err; 1641 goto err;
diff --git a/drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.c b/drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.c
index a4e1206a66a8..5b6516bb9d06 100644
--- a/drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.c
+++ b/drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.c
@@ -225,32 +225,6 @@ int mdp4_enable(struct mdp4_kms *mdp4_kms)
225 return 0; 225 return 0;
226} 226}
227 227
228static struct device_node *mdp4_detect_lcdc_panel(struct drm_device *dev)
229{
230 struct device_node *endpoint, *panel_node;
231 struct device_node *np = dev->dev->of_node;
232
233 /*
234 * LVDS/LCDC is the first port described in the list of ports in the
235 * MDP4 DT node.
236 */
237 endpoint = of_graph_get_endpoint_by_regs(np, 0, -1);
238 if (!endpoint) {
239 DBG("no LVDS remote endpoint\n");
240 return NULL;
241 }
242
243 panel_node = of_graph_get_remote_port_parent(endpoint);
244 if (!panel_node) {
245 DBG("no valid panel node in LVDS endpoint\n");
246 of_node_put(endpoint);
247 return NULL;
248 }
249
250 of_node_put(endpoint);
251
252 return panel_node;
253}
254 228
255static int mdp4_modeset_init_intf(struct mdp4_kms *mdp4_kms, 229static int mdp4_modeset_init_intf(struct mdp4_kms *mdp4_kms,
256 int intf_type) 230 int intf_type)
@@ -269,7 +243,7 @@ static int mdp4_modeset_init_intf(struct mdp4_kms *mdp4_kms,
269 * bail out early if there is no panel node (no need to 243 * bail out early if there is no panel node (no need to
270 * initialize LCDC encoder and LVDS connector) 244 * initialize LCDC encoder and LVDS connector)
271 */ 245 */
272 panel_node = mdp4_detect_lcdc_panel(dev); 246 panel_node = of_graph_get_remote_node(dev->dev->of_node, 0, 0);
273 if (!panel_node) 247 if (!panel_node)
274 return 0; 248 return 0;
275 249
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
index afd2a7b2aff7..d524ed0d5146 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
@@ -23,6 +23,7 @@
23#include <linux/workqueue.h> 23#include <linux/workqueue.h>
24#include <linux/completion.h> 24#include <linux/completion.h>
25#include <linux/dma-mapping.h> 25#include <linux/dma-mapping.h>
26#include <linux/of_graph.h>
26 27
27#include "tilcdc_drv.h" 28#include "tilcdc_drv.h"
28#include "tilcdc_regs.h" 29#include "tilcdc_regs.h"
@@ -1035,16 +1036,7 @@ int tilcdc_crtc_create(struct drm_device *dev)
1035 drm_crtc_helper_add(crtc, &tilcdc_crtc_helper_funcs); 1036 drm_crtc_helper_add(crtc, &tilcdc_crtc_helper_funcs);
1036 1037
1037 if (priv->is_componentized) { 1038 if (priv->is_componentized) {
1038 struct device_node *ports = 1039 crtc->port = of_graph_get_port_by_id(dev->dev->of_node, 0);
1039 of_get_child_by_name(dev->dev->of_node, "ports");
1040
1041 if (ports) {
1042 crtc->port = of_get_child_by_name(ports, "port");
1043 of_node_put(ports);
1044 } else {
1045 crtc->port =
1046 of_get_child_by_name(dev->dev->of_node, "port");
1047 }
1048 if (!crtc->port) { /* This should never happen */ 1040 if (!crtc->port) { /* This should never happen */
1049 dev_err(dev->dev, "Port node not found in %s\n", 1041 dev_err(dev->dev, "Port node not found in %s\n",
1050 dev->dev->of_node->full_name); 1042 dev->dev->of_node->full_name);
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_external.c b/drivers/gpu/drm/tilcdc/tilcdc_external.c
index b0dd5e8634ae..711c7b3289d3 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_external.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_external.c
@@ -185,39 +185,6 @@ int tilcdc_attach_bridge(struct drm_device *ddev, struct drm_bridge *bridge)
185 return ret; 185 return ret;
186} 186}
187 187
188static int tilcdc_node_has_port(struct device_node *dev_node)
189{
190 struct device_node *node;
191
192 node = of_get_child_by_name(dev_node, "ports");
193 if (!node)
194 node = of_get_child_by_name(dev_node, "port");
195 if (!node)
196 return 0;
197 of_node_put(node);
198
199 return 1;
200}
201
202static
203struct device_node *tilcdc_get_remote_node(struct device_node *node)
204{
205 struct device_node *ep;
206 struct device_node *parent;
207
208 if (!tilcdc_node_has_port(node))
209 return NULL;
210
211 ep = of_graph_get_next_endpoint(node, NULL);
212 if (!ep)
213 return NULL;
214
215 parent = of_graph_get_remote_port_parent(ep);
216 of_node_put(ep);
217
218 return parent;
219}
220
221int tilcdc_attach_external_device(struct drm_device *ddev) 188int tilcdc_attach_external_device(struct drm_device *ddev)
222{ 189{
223 struct tilcdc_drm_private *priv = ddev->dev_private; 190 struct tilcdc_drm_private *priv = ddev->dev_private;
@@ -225,7 +192,7 @@ int tilcdc_attach_external_device(struct drm_device *ddev)
225 struct drm_bridge *bridge; 192 struct drm_bridge *bridge;
226 int ret; 193 int ret;
227 194
228 remote_node = tilcdc_get_remote_node(ddev->dev->of_node); 195 remote_node = of_graph_get_remote_node(ddev->dev->of_node, 0, 0);
229 if (!remote_node) 196 if (!remote_node)
230 return 0; 197 return 0;
231 198
@@ -264,35 +231,16 @@ int tilcdc_get_external_components(struct device *dev,
264 struct component_match **match) 231 struct component_match **match)
265{ 232{
266 struct device_node *node; 233 struct device_node *node;
267 struct device_node *ep = NULL;
268 int count = 0;
269 int ret = 0;
270
271 if (!tilcdc_node_has_port(dev->of_node))
272 return 0;
273 234
274 while ((ep = of_graph_get_next_endpoint(dev->of_node, ep))) { 235 node = of_graph_get_remote_node(dev->of_node, 0, 0);
275 node = of_graph_get_remote_port_parent(ep);
276 if (!node || !of_device_is_available(node)) {
277 of_node_put(node);
278 continue;
279 }
280
281 dev_dbg(dev, "Subdevice node '%s' found\n", node->name);
282
283 if (of_device_is_compatible(node, "nxp,tda998x")) {
284 if (match)
285 drm_of_component_match_add(dev, match,
286 dev_match_of, node);
287 ret = 1;
288 }
289 236
237 if (!of_device_is_compatible(node, "nxp,tda998x")) {
290 of_node_put(node); 238 of_node_put(node);
291 if (count++ > 1) { 239 return 0;
292 dev_err(dev, "Only one port is supported\n");
293 return -EINVAL;
294 }
295 } 240 }
296 241
297 return ret; 242 if (match)
243 drm_of_component_match_add(dev, match, dev_match_of, node);
244 of_node_put(node);
245 return 1;
298} 246}
diff --git a/drivers/gpu/drm/vc4/vc4_dpi.c b/drivers/gpu/drm/vc4/vc4_dpi.c
index 71435796c710..c6d703903fd9 100644
--- a/drivers/gpu/drm/vc4/vc4_dpi.c
+++ b/drivers/gpu/drm/vc4/vc4_dpi.c
@@ -356,23 +356,14 @@ static const struct of_device_id vc4_dpi_dt_match[] = {
356 */ 356 */
357static struct drm_panel *vc4_dpi_get_panel(struct device *dev) 357static struct drm_panel *vc4_dpi_get_panel(struct device *dev)
358{ 358{
359 struct device_node *endpoint, *panel_node; 359 struct device_node *panel_node;
360 struct device_node *np = dev->of_node; 360 struct device_node *np = dev->of_node;
361 struct drm_panel *panel; 361 struct drm_panel *panel;
362 362
363 endpoint = of_graph_get_next_endpoint(np, NULL);
364 if (!endpoint) {
365 dev_err(dev, "no endpoint to fetch DPI panel\n");
366 return NULL;
367 }
368
369 /* don't proceed if we have an endpoint but no panel_node tied to it */ 363 /* don't proceed if we have an endpoint but no panel_node tied to it */
370 panel_node = of_graph_get_remote_port_parent(endpoint); 364 panel_node = of_graph_get_remote_node(np, 0, 0);
371 of_node_put(endpoint); 365 if (!panel_node)
372 if (!panel_node) {
373 dev_err(dev, "no valid panel node\n");
374 return NULL; 366 return NULL;
375 }
376 367
377 panel = of_drm_find_panel(panel_node); 368 panel = of_drm_find_panel(panel_node);
378 of_node_put(panel_node); 369 of_node_put(panel_node);