Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ebc94461 authored by Rob Herring's avatar Rob Herring Committed by Sean Paul
Browse files

drm: convert drivers to use drm_of_find_panel_or_bridge



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: default avatarRob Herring <robh@kernel.org>
Reviewed-by: default avatarArchit Taneja <architt@codeaurora.org>
Tested-by: default avatarPhilipp Zabel <p.zabel@pengutronix.de>
Acked-by: default avatarMaxime Ripard <maxime.ripard@free-electrons.com>
[seanpaul dropped rockchip changes since they're now obsolete]
Signed-off-by: default avatarSean Paul <seanpaul@chromium.org>
parent 86418f90
Loading
Loading
Loading
Loading
+21 −52
Original line number Diff line number Diff line
@@ -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"

@@ -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;
@@ -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,
@@ -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)
@@ -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);
	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;
	}
	}

	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);
	if (!endpoint)
		return -ENODEV;
	return ret;
}
	}

	return 0;
}
+4 −12
Original line number Diff line number Diff line
@@ -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"
@@ -292,7 +292,6 @@ 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);
@@ -300,16 +299,9 @@ static int ptn3460_probe(struct i2c_client *client,
		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;

+4 −12
Original line number Diff line number Diff line
@@ -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"
@@ -536,7 +536,6 @@ 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;

@@ -544,16 +543,9 @@ static int ps8622_probe(struct i2c_client *client,
	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;

+3 −24
Original line number Diff line number Diff line
@@ -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;

@@ -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);
+12 −23
Original line number Diff line number Diff line
@@ -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>
@@ -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);
@@ -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) {
	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 = 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;
	}
	dp->plat_data.panel = panel;
	dp->ptn_bridge = bridge;

out:
	return component_add(&pdev->dev, &exynos_dp_ops);
Loading