drm/rockchip: Don't change hdmi reference clock rate
[drm/drm-misc.git] / drivers / video / fbdev / omap2 / omapfb / dss / dss-of.c
blobc04cbe0ef173d604959d897fe3230c2ea15869c7
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3 * Copyright (C) 2013 Texas Instruments
4 * Author: Tomi Valkeinen <tomi.valkeinen@ti.com>
5 */
7 #include <linux/device.h>
8 #include <linux/err.h>
9 #include <linux/module.h>
10 #include <linux/of.h>
11 #include <linux/of_graph.h>
12 #include <linux/seq_file.h>
14 #include <video/omapfb_dss.h>
16 #include "dss.h"
18 struct device_node *dss_of_port_get_parent_device(struct device_node *port)
20 struct device_node *np;
21 int i;
23 if (!port)
24 return NULL;
26 np = of_get_parent(port);
28 for (i = 0; i < 2 && np; ++i) {
29 struct property *prop;
31 prop = of_find_property(np, "compatible", NULL);
33 if (prop)
34 return np;
36 np = of_get_next_parent(np);
39 return NULL;
42 u32 dss_of_port_get_port_number(struct device_node *port)
44 int r;
45 u32 reg;
47 r = of_property_read_u32(port, "reg", &reg);
48 if (r)
49 reg = 0;
51 return reg;
54 struct omap_dss_device *
55 omapdss_of_find_source_for_first_ep(struct device_node *node)
57 struct device_node *ep;
58 struct device_node *src_port;
59 struct omap_dss_device *src;
61 ep = of_graph_get_endpoint_by_regs(node, 0, -1);
62 if (!ep)
63 return ERR_PTR(-EINVAL);
65 src_port = of_graph_get_remote_port(ep);
66 of_node_put(ep);
67 if (!src_port)
68 return ERR_PTR(-EINVAL);
70 src = omap_dss_find_output_by_port_node(src_port);
72 of_node_put(src_port);
74 return src ? src : ERR_PTR(-EPROBE_DEFER);
76 EXPORT_SYMBOL_GPL(omapdss_of_find_source_for_first_ep);