[PATCH 3/4] drm: add helper to lookup panel-id

From: Rob Clark
Date: Sun Jun 30 2019 - 16:37:06 EST


From: Rob Clark <robdclark@xxxxxxxxxxxx>

Finds the panel-id from chosen, so drivers can use this to pick the
correct endpoint when looking up panel.

Signed-off-by: Rob Clark <robdclark@xxxxxxxxxxxx>
---
drivers/gpu/drm/drm_of.c | 21 +++++++++++++++++++++
include/drm/drm_of.h | 7 +++++++
2 files changed, 28 insertions(+)

diff --git a/drivers/gpu/drm/drm_of.c b/drivers/gpu/drm/drm_of.c
index 43d89dd59c6b..3ba65750048b 100644
--- a/drivers/gpu/drm/drm_of.c
+++ b/drivers/gpu/drm/drm_of.c
@@ -279,3 +279,24 @@ int drm_of_find_panel_or_bridge(const struct device_node *np,
return ret;
}
EXPORT_SYMBOL_GPL(drm_of_find_panel_or_bridge);
+
+/**
+ * drm_of_find_panel_id - return id of panel from chosen
+ *
+ * Returns the panel id, or zero if none specified
+ */
+int drm_of_find_panel_id(void)
+{
+ struct device_node *np = NULL;
+ u32 panel_id;
+
+ np = of_find_node_by_path("/chosen");
+ if (!np)
+ return 0;
+
+ if (of_property_read_u32(np, "panel-id", &panel_id))
+ return 0;
+
+ return panel_id;
+}
+EXPORT_SYMBOL_GPL(drm_of_find_panel_id);
diff --git a/include/drm/drm_of.h b/include/drm/drm_of.h
index ead34ab5ca4e..6cd2d59cb1db 100644
--- a/include/drm/drm_of.h
+++ b/include/drm/drm_of.h
@@ -35,6 +35,8 @@ int drm_of_find_panel_or_bridge(const struct device_node *np,
int port, int endpoint,
struct drm_panel **panel,
struct drm_bridge **bridge);
+int drm_of_find_panel_id(void);
+
#else
static inline uint32_t drm_of_crtc_port_mask(struct drm_device *dev,
struct device_node *port)
@@ -77,6 +79,11 @@ static inline int drm_of_find_panel_or_bridge(const struct device_node *np,
{
return -EINVAL;
}
+
+static inline int drm_of_find_panel_id(void)
+{
+ return 0;
+}
#endif

/*
--
2.20.1