Linux Audio

Check our new training course

Linux BSP upgrade and security maintenance

Need help to get security updates for your Linux BSP?
Loading...
Note: File does not exist in v5.9.
 1/*
 2 * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/
 3 * Author: Tomi Valkeinen <tomi.valkeinen@ti.com>
 4 *
 5 * This program is free software; you can redistribute it and/or modify it
 6 * under the terms of the GNU General Public License version 2 as published by
 7 * the Free Software Foundation.
 8 *
 9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
12 * more details.
13 */
14
15#include <linux/device.h>
16#include <linux/err.h>
17#include <linux/module.h>
18#include <linux/of.h>
19#include <linux/of_graph.h>
20#include <linux/seq_file.h>
21
22#include "omapdss.h"
23
24struct device_node *dss_of_port_get_parent_device(struct device_node *port)
25{
26	struct device_node *np;
27	int i;
28
29	if (!port)
30		return NULL;
31
32	np = of_get_parent(port);
33
34	for (i = 0; i < 2 && np; ++i) {
35		struct property *prop;
36
37		prop = of_find_property(np, "compatible", NULL);
38
39		if (prop)
40			return np;
41
42		np = of_get_next_parent(np);
43	}
44
45	return NULL;
46}
47
48u32 dss_of_port_get_port_number(struct device_node *port)
49{
50	int r;
51	u32 reg;
52
53	r = of_property_read_u32(port, "reg", &reg);
54	if (r)
55		reg = 0;
56
57	return reg;
58}
59
60struct omap_dss_device *
61omapdss_of_find_source_for_first_ep(struct device_node *node)
62{
63	struct device_node *ep;
64	struct device_node *src_port;
65	struct omap_dss_device *src;
66
67	ep = of_graph_get_endpoint_by_regs(node, 0, 0);
68	if (!ep)
69		return ERR_PTR(-EINVAL);
70
71	src_port = of_graph_get_remote_port(ep);
72	if (!src_port) {
73		of_node_put(ep);
74		return ERR_PTR(-EINVAL);
75	}
76
77	of_node_put(ep);
78
79	src = omap_dss_find_output_by_port_node(src_port);
80
81	of_node_put(src_port);
82
83	return src ? src : ERR_PTR(-EPROBE_DEFER);
84}
85EXPORT_SYMBOL_GPL(omapdss_of_find_source_for_first_ep);