Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at v3.17-rc2 159 lines 3.3 kB view raw
1/* 2 * Copyright (C) 2013 Texas Instruments 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/seq_file.h> 20 21#include <video/omapdss.h> 22 23struct device_node * 24omapdss_of_get_next_port(const struct device_node *parent, 25 struct device_node *prev) 26{ 27 struct device_node *port = NULL; 28 29 if (!parent) 30 return NULL; 31 32 if (!prev) { 33 struct device_node *ports; 34 /* 35 * It's the first call, we have to find a port subnode 36 * within this node or within an optional 'ports' node. 37 */ 38 ports = of_get_child_by_name(parent, "ports"); 39 if (ports) 40 parent = ports; 41 42 port = of_get_child_by_name(parent, "port"); 43 44 /* release the 'ports' node */ 45 of_node_put(ports); 46 } else { 47 struct device_node *ports; 48 49 ports = of_get_parent(prev); 50 if (!ports) 51 return NULL; 52 53 do { 54 port = of_get_next_child(ports, prev); 55 if (!port) { 56 of_node_put(ports); 57 return NULL; 58 } 59 prev = port; 60 } while (of_node_cmp(port->name, "port") != 0); 61 } 62 63 return port; 64} 65EXPORT_SYMBOL_GPL(omapdss_of_get_next_port); 66 67struct device_node * 68omapdss_of_get_next_endpoint(const struct device_node *parent, 69 struct device_node *prev) 70{ 71 struct device_node *ep = NULL; 72 73 if (!parent) 74 return NULL; 75 76 do { 77 ep = of_get_next_child(parent, prev); 78 if (!ep) 79 return NULL; 80 prev = ep; 81 } while (of_node_cmp(ep->name, "endpoint") != 0); 82 83 return ep; 84} 85EXPORT_SYMBOL_GPL(omapdss_of_get_next_endpoint); 86 87static struct device_node * 88omapdss_of_get_remote_device_node(const struct device_node *node) 89{ 90 struct device_node *np; 91 int i; 92 93 np = of_parse_phandle(node, "remote-endpoint", 0); 94 95 if (!np) 96 return NULL; 97 98 np = of_get_next_parent(np); 99 100 for (i = 0; i < 3 && np; ++i) { 101 struct property *prop; 102 103 prop = of_find_property(np, "compatible", NULL); 104 105 if (prop) 106 return np; 107 108 np = of_get_next_parent(np); 109 } 110 111 return NULL; 112} 113 114struct device_node * 115omapdss_of_get_first_endpoint(const struct device_node *parent) 116{ 117 struct device_node *port, *ep; 118 119 port = omapdss_of_get_next_port(parent, NULL); 120 121 if (!port) 122 return NULL; 123 124 ep = omapdss_of_get_next_endpoint(port, NULL); 125 126 of_node_put(port); 127 128 return ep; 129} 130EXPORT_SYMBOL_GPL(omapdss_of_get_first_endpoint); 131 132struct omap_dss_device * 133omapdss_of_find_source_for_first_ep(struct device_node *node) 134{ 135 struct device_node *ep; 136 struct device_node *src_node; 137 struct omap_dss_device *src; 138 139 ep = omapdss_of_get_first_endpoint(node); 140 if (!ep) 141 return ERR_PTR(-EINVAL); 142 143 src_node = omapdss_of_get_remote_device_node(ep); 144 145 of_node_put(ep); 146 147 if (!src_node) 148 return ERR_PTR(-EINVAL); 149 150 src = omap_dss_find_output_by_node(src_node); 151 152 of_node_put(src_node); 153 154 if (!src) 155 return ERR_PTR(-EPROBE_DEFER); 156 157 return src; 158} 159EXPORT_SYMBOL_GPL(omapdss_of_find_source_for_first_ep);