Add omapdss_of_get_endpoint() helper function to get the endpoint node for the given port index and endpoint index. Signed-off-by: Tomi Valkeinen <tomi.valkeinen@xxxxxx> --- drivers/gpu/drm/omapdrm/dss/dss-of.c | 61 +++++++++++++++++++++++++++++++++++ drivers/gpu/drm/omapdrm/dss/omapdss.h | 3 ++ 2 files changed, 64 insertions(+) diff --git a/drivers/gpu/drm/omapdrm/dss/dss-of.c b/drivers/gpu/drm/omapdrm/dss/dss-of.c index dfd4e9621e3b..aa9415d3c60b 100644 --- a/drivers/gpu/drm/omapdrm/dss/dss-of.c +++ b/drivers/gpu/drm/omapdrm/dss/dss-of.c @@ -180,3 +180,64 @@ omapdss_of_find_source_for_first_ep(struct device_node *node) return src ? src : ERR_PTR(-EPROBE_DEFER); } EXPORT_SYMBOL_GPL(omapdss_of_find_source_for_first_ep); + +static struct device_node *omapdss_of_get_port_by_index(struct device_node *parent, + int index) +{ + struct device_node *port; + + for (port = omapdss_of_get_next_port(parent, NULL); + port != NULL; + port = omapdss_of_get_next_port(parent, port)) { + u32 reg; + int r; + + r = of_property_read_u32(port, "reg", ®); + if (r) + reg = 0; + + if (reg == index) + return port; + } + + return NULL; +} + +static struct device_node *omapdss_of_get_endpoint_by_index(struct device_node *port, + int index) +{ + struct device_node *ep; + + for (ep = omapdss_of_get_next_endpoint(port, NULL); + ep != NULL; + ep = omapdss_of_get_next_endpoint(port, ep)) { + u32 reg; + int r; + + r = of_property_read_u32(ep, "reg", ®); + if (r) + reg = 0; + + if (reg == index) + return ep; + } + + return NULL; +} + +struct device_node *omapdss_of_get_endpoint(struct device_node *parent, + int port_index, int ep_index) +{ + struct device_node *port, *ep; + + port = omapdss_of_get_port_by_index(parent, port_index); + if (port == NULL) + return NULL; + + ep = omapdss_of_get_endpoint_by_index(port, ep_index); + + of_node_put(port); + + return ep; +} +EXPORT_SYMBOL_GPL(omapdss_of_get_endpoint); diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h b/drivers/gpu/drm/omapdrm/dss/omapdss.h index b420dde8c0fb..403bab718738 100644 --- a/drivers/gpu/drm/omapdrm/dss/omapdss.h +++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h @@ -844,6 +844,9 @@ omapdss_of_get_first_endpoint(const struct device_node *parent); struct omap_dss_device * omapdss_of_find_source_for_first_ep(struct device_node *node); +struct device_node *omapdss_of_get_endpoint(struct device_node *parent, + int port_index, int ep_index); + u32 dispc_read_irqstatus(void); void dispc_clear_irqstatus(u32 mask); u32 dispc_read_irqenable(void); -- 2.7.4 _______________________________________________ dri-devel mailing list dri-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/dri-devel