Skip to content

Commit

Permalink
drm: convert drivers to use drm_of_find_panel_or_bridge
Browse files Browse the repository at this point in the history
Similar to the previous commit, convert drivers open coding OF graph
parsing to use drm_of_find_panel_or_bridge instead.

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>
Reviewed-by: Archit Taneja <architt@codeaurora.org>
Tested-by: Philipp Zabel <p.zabel@pengutronix.de>
Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>
[seanpaul dropped rockchip changes since they're now obsolete]
Signed-off-by: Sean Paul <seanpaul@chromium.org>
  • Loading branch information
Rob Herring authored and Sean Paul committed Apr 6, 2017
1 parent 86418f9 commit ebc9446
Show file tree
Hide file tree
Showing 14 changed files with 95 additions and 396 deletions.
73 changes: 21 additions & 52 deletions drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_output.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include <linux/of_graph.h>

#include <drm/drmP.h>
#include <drm/drm_panel.h>
#include <drm/drm_of.h>

#include "atmel_hlcdc_dc.h"

Expand Down Expand Up @@ -152,29 +152,11 @@ static const struct drm_connector_funcs atmel_hlcdc_panel_connector_funcs = {
.atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
};

static int atmel_hlcdc_check_endpoint(struct drm_device *dev,
const struct of_endpoint *ep)
{
struct device_node *np;
void *obj;

np = of_graph_get_remote_port_parent(ep->local_node);

obj = of_drm_find_panel(np);
if (!obj)
obj = of_drm_find_bridge(np);

of_node_put(np);

return obj ? 0 : -EPROBE_DEFER;
}

static int atmel_hlcdc_attach_endpoint(struct drm_device *dev,
const struct of_endpoint *ep)
const struct device_node *np)
{
struct atmel_hlcdc_dc *dc = dev->dev_private;
struct atmel_hlcdc_rgb_output *output;
struct device_node *np;
struct drm_panel *panel;
struct drm_bridge *bridge;
int ret;
Expand All @@ -195,13 +177,11 @@ static int atmel_hlcdc_attach_endpoint(struct drm_device *dev,

output->encoder.possible_crtcs = 0x1;

np = of_graph_get_remote_port_parent(ep->local_node);

ret = -EPROBE_DEFER;
ret = drm_of_find_panel_or_bridge(np, 0, 0, &panel, &bridge);
if (ret)
return ret;

panel = of_drm_find_panel(np);
if (panel) {
of_node_put(np);
output->connector.dpms = DRM_MODE_DPMS_OFF;
output->connector.polled = DRM_CONNECTOR_POLL_CONNECT;
drm_connector_helper_add(&output->connector,
Expand All @@ -226,9 +206,6 @@ static int atmel_hlcdc_attach_endpoint(struct drm_device *dev,
return 0;
}

bridge = of_drm_find_bridge(np);
of_node_put(np);

if (bridge) {
ret = drm_bridge_attach(&output->encoder, bridge, NULL);
if (!ret)
Expand All @@ -243,31 +220,23 @@ static int atmel_hlcdc_attach_endpoint(struct drm_device *dev,

int atmel_hlcdc_create_outputs(struct drm_device *dev)
{
struct device_node *ep_np = NULL;
struct of_endpoint ep;
int ret;

for_each_endpoint_of_node(dev->dev->of_node, ep_np) {
ret = of_graph_parse_endpoint(ep_np, &ep);
if (!ret)
ret = atmel_hlcdc_check_endpoint(dev, &ep);

if (ret) {
of_node_put(ep_np);
return ret;
}
}

for_each_endpoint_of_node(dev->dev->of_node, ep_np) {
ret = of_graph_parse_endpoint(ep_np, &ep);
if (!ret)
ret = atmel_hlcdc_attach_endpoint(dev, &ep);

if (ret) {
of_node_put(ep_np);
struct device_node *remote;
int ret, endpoint = 0;

while (true) {
/* Loop thru possible multiple connections to the output */
remote = of_graph_get_remote_node(dev->dev->of_node, 0,
endpoint++);
if (!remote)
break;

ret = atmel_hlcdc_attach_endpoint(dev, remote);
of_node_put(remote);
if (ret)
return ret;
}
}

return 0;
if (!endpoint)
return -ENODEV;
return ret;
}
16 changes: 4 additions & 12 deletions drivers/gpu/drm/bridge/nxp-ptn3460.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
#include <linux/module.h>
#include <linux/of.h>
#include <linux/of_gpio.h>
#include <linux/of_graph.h>

#include <drm/drm_of.h>
#include <drm/drm_panel.h>

#include "drm_crtc.h"
Expand Down Expand Up @@ -292,24 +292,16 @@ static int ptn3460_probe(struct i2c_client *client,
{
struct device *dev = &client->dev;
struct ptn3460_bridge *ptn_bridge;
struct device_node *endpoint, *panel_node;
int ret;

ptn_bridge = devm_kzalloc(dev, sizeof(*ptn_bridge), GFP_KERNEL);
if (!ptn_bridge) {
return -ENOMEM;
}

endpoint = of_graph_get_next_endpoint(dev->of_node, NULL);
if (endpoint) {
panel_node = of_graph_get_remote_port_parent(endpoint);
if (panel_node) {
ptn_bridge->panel = of_drm_find_panel(panel_node);
of_node_put(panel_node);
if (!ptn_bridge->panel)
return -EPROBE_DEFER;
}
}
ret = drm_of_find_panel_or_bridge(dev->of_node, 0, 0, &ptn_bridge->panel, NULL);
if (ret)
return ret;

ptn_bridge->client = client;

Expand Down
16 changes: 4 additions & 12 deletions drivers/gpu/drm/bridge/parade-ps8622.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
#include <linux/module.h>
#include <linux/of.h>
#include <linux/of_device.h>
#include <linux/of_graph.h>
#include <linux/pm.h>
#include <linux/regulator/consumer.h>

#include <drm/drm_of.h>
#include <drm/drm_panel.h>

#include "drmP.h"
Expand Down Expand Up @@ -536,24 +536,16 @@ static int ps8622_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
struct device *dev = &client->dev;
struct device_node *endpoint, *panel_node;
struct ps8622_bridge *ps8622;
int ret;

ps8622 = devm_kzalloc(dev, sizeof(*ps8622), GFP_KERNEL);
if (!ps8622)
return -ENOMEM;

endpoint = of_graph_get_next_endpoint(dev->of_node, NULL);
if (endpoint) {
panel_node = of_graph_get_remote_port_parent(endpoint);
if (panel_node) {
ps8622->panel = of_drm_find_panel(panel_node);
of_node_put(panel_node);
if (!ps8622->panel)
return -EPROBE_DEFER;
}
}
ret = drm_of_find_panel_or_bridge(dev->of_node, 0, 0, &ps8622->panel, NULL);
if (ret)
return ret;

ps8622->client = client;

Expand Down
27 changes: 3 additions & 24 deletions drivers/gpu/drm/bridge/tc358767.c
Original file line number Diff line number Diff line change
Expand Up @@ -1244,7 +1244,6 @@ static const struct regmap_config tc_regmap_config = {
static int tc_probe(struct i2c_client *client, const struct i2c_device_id *id)
{
struct device *dev = &client->dev;
struct device_node *ep;
struct tc_data *tc;
int ret;

Expand All @@ -1255,29 +1254,9 @@ static int tc_probe(struct i2c_client *client, const struct i2c_device_id *id)
tc->dev = dev;

/* port@2 is the output port */
ep = of_graph_get_endpoint_by_regs(dev->of_node, 2, -1);
if (ep) {
struct device_node *remote;

remote = of_graph_get_remote_port_parent(ep);
if (!remote) {
dev_warn(dev, "endpoint %s not connected\n",
ep->full_name);
of_node_put(ep);
return -ENODEV;
}
of_node_put(ep);
tc->panel = of_drm_find_panel(remote);
if (tc->panel) {
dev_dbg(dev, "found panel %s\n", remote->full_name);
} else {
dev_dbg(dev, "waiting for panel %s\n",
remote->full_name);
of_node_put(remote);
return -EPROBE_DEFER;
}
of_node_put(remote);
}
ret = drm_of_find_panel_or_bridge(dev->of_node, 2, 0, &tc->panel, NULL);
if (ret)
return ret;

/* Shut down GPIO is optional */
tc->sd_gpio = devm_gpiod_get_optional(dev, "shutdown", GPIOD_OUT_HIGH);
Expand Down
35 changes: 12 additions & 23 deletions drivers/gpu/drm/exynos/exynos_dp.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <drm/drmP.h>
#include <drm/drm_crtc.h>
#include <drm/drm_crtc_helper.h>
#include <drm/drm_of.h>
#include <drm/drm_panel.h>

#include <drm/bridge/analogix_dp.h>
Expand Down Expand Up @@ -211,8 +212,11 @@ static const struct component_ops exynos_dp_ops = {
static int exynos_dp_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
struct device_node *np = NULL, *endpoint = NULL;
struct device_node *np;
struct exynos_dp_device *dp;
struct drm_panel *panel;
struct drm_bridge *bridge;
int ret;

dp = devm_kzalloc(&pdev->dev, sizeof(struct exynos_dp_device),
GFP_KERNEL);
Expand All @@ -236,28 +240,13 @@ static int exynos_dp_probe(struct platform_device *pdev)
goto out;
}

endpoint = of_graph_get_next_endpoint(dev->of_node, NULL);
if (endpoint) {
np = of_graph_get_remote_port_parent(endpoint);
if (np) {
/* The remote port can be either a panel or a bridge */
dp->plat_data.panel = of_drm_find_panel(np);
if (!dp->plat_data.panel) {
dp->ptn_bridge = of_drm_find_bridge(np);
if (!dp->ptn_bridge) {
of_node_put(np);
return -EPROBE_DEFER;
}
}
of_node_put(np);
} else {
DRM_ERROR("no remote endpoint device node found.\n");
return -EINVAL;
}
} else {
DRM_ERROR("no port endpoint subnode found.\n");
return -EINVAL;
}
ret = drm_of_find_panel_or_bridge(dev->of_node, 0, 0, &panel, &bridge);
if (ret)
return ret;

/* The remote port can be either a panel or a bridge */
dp->plat_data.panel = panel;
dp->ptn_bridge = bridge;

out:
return component_add(&pdev->dev, &exynos_dp_ops);
Expand Down
44 changes: 12 additions & 32 deletions drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_rgb.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <drm/drmP.h>
#include <drm/drm_atomic_helper.h>
#include <drm/drm_crtc_helper.h>
#include <drm/drm_of.h>
#include <drm/drm_panel.h>

#include "fsl_dcu_drm_drv.h"
Expand Down Expand Up @@ -141,32 +142,11 @@ static int fsl_dcu_attach_panel(struct fsl_dcu_drm_device *fsl_dev,
return ret;
}

static int fsl_dcu_attach_endpoint(struct fsl_dcu_drm_device *fsl_dev,
const struct of_endpoint *ep)
{
struct drm_bridge *bridge;
struct device_node *np;

np = of_graph_get_remote_port_parent(ep->local_node);

fsl_dev->connector.panel = of_drm_find_panel(np);
if (fsl_dev->connector.panel) {
of_node_put(np);
return fsl_dcu_attach_panel(fsl_dev, fsl_dev->connector.panel);
}

bridge = of_drm_find_bridge(np);
of_node_put(np);
if (!bridge)
return -ENODEV;

return drm_bridge_attach(&fsl_dev->encoder, bridge, NULL);
}

int fsl_dcu_create_outputs(struct fsl_dcu_drm_device *fsl_dev)
{
struct of_endpoint ep;
struct device_node *ep_node, *panel_node;
struct device_node *panel_node;
struct drm_panel *panel;
struct drm_bridge *bridge;
int ret;

/* This is for backward compatibility */
Expand All @@ -179,14 +159,14 @@ int fsl_dcu_create_outputs(struct fsl_dcu_drm_device *fsl_dev)
return fsl_dcu_attach_panel(fsl_dev, fsl_dev->connector.panel);
}

ep_node = of_graph_get_next_endpoint(fsl_dev->np, NULL);
if (!ep_node)
return -ENODEV;

ret = of_graph_parse_endpoint(ep_node, &ep);
of_node_put(ep_node);
ret = drm_of_find_panel_or_bridge(fsl_dev->np, 0, 0, &panel, &bridge);
if (ret)
return -ENODEV;
return ret;

if (panel) {
fsl_dev->connector.panel = panel;
return fsl_dcu_attach_panel(fsl_dev, panel);
}

return fsl_dcu_attach_endpoint(fsl_dev, &ep);
return drm_bridge_attach(&fsl_dev->encoder, bridge, NULL);
}
Loading

0 comments on commit ebc9446

Please sign in to comment.