aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilipp Zabel <p.zabel@pengutronix.de>2014-02-14 05:53:56 -0500
committerPhilipp Zabel <p.zabel@pengutronix.de>2014-03-06 11:41:48 -0500
commitf2a575f67695dcba9062acd666ae5aab2380b95c (patch)
tree86f69c5cfb33eee11693e496bf02103e50d3a3c9
parent4329b93b283cce828967c01bc3827fdff51c8d7e (diff)
[media] of: move common endpoint parsing to drivers/of
This patch adds a new struct of_endpoint which is then embedded in struct v4l2_of_endpoint and contains the endpoint properties that are not V4L2 (or even media) specific: the port number, endpoint id, local device tree node and remote endpoint phandle. of_graph_parse_endpoint parses those properties and is used by v4l2_of_parse_endpoint, which just adds the V4L2 MBUS information to the containing v4l2_of_endpoint structure. Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de> Acked-by: Tomi Valkeinen <tomi.valkeinen@ti.com> Acked-by: Mauro Carvalho Chehab <m.chehab@samsung.com> Acked-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
-rw-r--r--drivers/media/platform/exynos4-is/media-dev.c10
-rw-r--r--drivers/media/platform/exynos4-is/mipi-csis.c2
-rw-r--r--drivers/media/v4l2-core/v4l2-of.c16
-rw-r--r--drivers/of/base.c28
-rw-r--r--include/linux/of_graph.h20
-rw-r--r--include/media/v4l2-of.h8
6 files changed, 59 insertions, 25 deletions
diff --git a/drivers/media/platform/exynos4-is/media-dev.c b/drivers/media/platform/exynos4-is/media-dev.c
index d0f82da59ac5..04d6ecdd314c 100644
--- a/drivers/media/platform/exynos4-is/media-dev.c
+++ b/drivers/media/platform/exynos4-is/media-dev.c
@@ -469,10 +469,10 @@ static int fimc_md_parse_port_node(struct fimc_md *fmd,
469 return 0; 469 return 0;
470 470
471 v4l2_of_parse_endpoint(ep, &endpoint); 471 v4l2_of_parse_endpoint(ep, &endpoint);
472 if (WARN_ON(endpoint.port == 0) || index >= FIMC_MAX_SENSORS) 472 if (WARN_ON(endpoint.base.port == 0) || index >= FIMC_MAX_SENSORS)
473 return -EINVAL; 473 return -EINVAL;
474 474
475 pd->mux_id = (endpoint.port - 1) & 0x1; 475 pd->mux_id = (endpoint.base.port - 1) & 0x1;
476 476
477 rem = of_graph_get_remote_port_parent(ep); 477 rem = of_graph_get_remote_port_parent(ep);
478 of_node_put(ep); 478 of_node_put(ep);
@@ -494,13 +494,13 @@ static int fimc_md_parse_port_node(struct fimc_md *fmd,
494 return -EINVAL; 494 return -EINVAL;
495 } 495 }
496 496
497 if (fimc_input_is_parallel(endpoint.port)) { 497 if (fimc_input_is_parallel(endpoint.base.port)) {
498 if (endpoint.bus_type == V4L2_MBUS_PARALLEL) 498 if (endpoint.bus_type == V4L2_MBUS_PARALLEL)
499 pd->sensor_bus_type = FIMC_BUS_TYPE_ITU_601; 499 pd->sensor_bus_type = FIMC_BUS_TYPE_ITU_601;
500 else 500 else
501 pd->sensor_bus_type = FIMC_BUS_TYPE_ITU_656; 501 pd->sensor_bus_type = FIMC_BUS_TYPE_ITU_656;
502 pd->flags = endpoint.bus.parallel.flags; 502 pd->flags = endpoint.bus.parallel.flags;
503 } else if (fimc_input_is_mipi_csi(endpoint.port)) { 503 } else if (fimc_input_is_mipi_csi(endpoint.base.port)) {
504 /* 504 /*
505 * MIPI CSI-2: only input mux selection and 505 * MIPI CSI-2: only input mux selection and
506 * the sensor's clock frequency is needed. 506 * the sensor's clock frequency is needed.
@@ -508,7 +508,7 @@ static int fimc_md_parse_port_node(struct fimc_md *fmd,
508 pd->sensor_bus_type = FIMC_BUS_TYPE_MIPI_CSI2; 508 pd->sensor_bus_type = FIMC_BUS_TYPE_MIPI_CSI2;
509 } else { 509 } else {
510 v4l2_err(&fmd->v4l2_dev, "Wrong port id (%u) at node %s\n", 510 v4l2_err(&fmd->v4l2_dev, "Wrong port id (%u) at node %s\n",
511 endpoint.port, rem->full_name); 511 endpoint.base.port, rem->full_name);
512 } 512 }
513 /* 513 /*
514 * For FIMC-IS handled sensors, that are placed under i2c-isp device 514 * For FIMC-IS handled sensors, that are placed under i2c-isp device
diff --git a/drivers/media/platform/exynos4-is/mipi-csis.c b/drivers/media/platform/exynos4-is/mipi-csis.c
index fd1ae6549607..3678ba59725c 100644
--- a/drivers/media/platform/exynos4-is/mipi-csis.c
+++ b/drivers/media/platform/exynos4-is/mipi-csis.c
@@ -772,7 +772,7 @@ static int s5pcsis_parse_dt(struct platform_device *pdev,
772 /* Get port node and validate MIPI-CSI channel id. */ 772 /* Get port node and validate MIPI-CSI channel id. */
773 v4l2_of_parse_endpoint(node, &endpoint); 773 v4l2_of_parse_endpoint(node, &endpoint);
774 774
775 state->index = endpoint.port - FIMC_INPUT_MIPI_CSI2_0; 775 state->index = endpoint.base.port - FIMC_INPUT_MIPI_CSI2_0;
776 if (state->index < 0 || state->index >= CSIS_MAX_ENTITIES) 776 if (state->index < 0 || state->index >= CSIS_MAX_ENTITIES)
777 return -ENXIO; 777 return -ENXIO;
778 778
diff --git a/drivers/media/v4l2-core/v4l2-of.c b/drivers/media/v4l2-core/v4l2-of.c
index f919db358bbe..b4ed9a955fbe 100644
--- a/drivers/media/v4l2-core/v4l2-of.c
+++ b/drivers/media/v4l2-core/v4l2-of.c
@@ -127,17 +127,9 @@ static void v4l2_of_parse_parallel_bus(const struct device_node *node,
127int v4l2_of_parse_endpoint(const struct device_node *node, 127int v4l2_of_parse_endpoint(const struct device_node *node,
128 struct v4l2_of_endpoint *endpoint) 128 struct v4l2_of_endpoint *endpoint)
129{ 129{
130 struct device_node *port_node = of_get_parent(node); 130 of_graph_parse_endpoint(node, &endpoint->base);
131 131 endpoint->bus_type = 0;
132 memset(endpoint, 0, offsetof(struct v4l2_of_endpoint, head)); 132 memset(&endpoint->bus, 0, sizeof(endpoint->bus));
133
134 endpoint->local_node = node;
135 /*
136 * It doesn't matter whether the two calls below succeed.
137 * If they don't then the default value 0 is used.
138 */
139 of_property_read_u32(port_node, "reg", &endpoint->port);
140 of_property_read_u32(node, "reg", &endpoint->id);
141 133
142 v4l2_of_parse_csi_bus(node, endpoint); 134 v4l2_of_parse_csi_bus(node, endpoint);
143 /* 135 /*
@@ -147,8 +139,6 @@ int v4l2_of_parse_endpoint(const struct device_node *node,
147 if (endpoint->bus.mipi_csi2.flags == 0) 139 if (endpoint->bus.mipi_csi2.flags == 0)
148 v4l2_of_parse_parallel_bus(node, endpoint); 140 v4l2_of_parse_parallel_bus(node, endpoint);
149 141
150 of_node_put(port_node);
151
152 return 0; 142 return 0;
153} 143}
154EXPORT_SYMBOL(v4l2_of_parse_endpoint); 144EXPORT_SYMBOL(v4l2_of_parse_endpoint);
diff --git a/drivers/of/base.c b/drivers/of/base.c
index a8e47d37cc7f..715144af3a83 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -1985,6 +1985,34 @@ struct device_node *of_find_next_cache_node(const struct device_node *np)
1985} 1985}
1986 1986
1987/** 1987/**
1988 * of_graph_parse_endpoint() - parse common endpoint node properties
1989 * @node: pointer to endpoint device_node
1990 * @endpoint: pointer to the OF endpoint data structure
1991 *
1992 * The caller should hold a reference to @node.
1993 */
1994int of_graph_parse_endpoint(const struct device_node *node,
1995 struct of_endpoint *endpoint)
1996{
1997 struct device_node *port_node = of_get_parent(node);
1998
1999 memset(endpoint, 0, sizeof(*endpoint));
2000
2001 endpoint->local_node = node;
2002 /*
2003 * It doesn't matter whether the two calls below succeed.
2004 * If they don't then the default value 0 is used.
2005 */
2006 of_property_read_u32(port_node, "reg", &endpoint->port);
2007 of_property_read_u32(node, "reg", &endpoint->id);
2008
2009 of_node_put(port_node);
2010
2011 return 0;
2012}
2013EXPORT_SYMBOL(of_graph_parse_endpoint);
2014
2015/**
1988 * of_graph_get_next_endpoint() - get next endpoint node 2016 * of_graph_get_next_endpoint() - get next endpoint node
1989 * @parent: pointer to the parent device node 2017 * @parent: pointer to the parent device node
1990 * @prev: previous endpoint node, or NULL to get first 2018 * @prev: previous endpoint node, or NULL to get first
diff --git a/include/linux/of_graph.h b/include/linux/of_graph.h
index 3bbeb609a360..2b233db76237 100644
--- a/include/linux/of_graph.h
+++ b/include/linux/of_graph.h
@@ -14,7 +14,21 @@
14#ifndef __LINUX_OF_GRAPH_H 14#ifndef __LINUX_OF_GRAPH_H
15#define __LINUX_OF_GRAPH_H 15#define __LINUX_OF_GRAPH_H
16 16
17/**
18 * struct of_endpoint - the OF graph endpoint data structure
19 * @port: identifier (value of reg property) of a port this endpoint belongs to
20 * @id: identifier (value of reg property) of this endpoint
21 * @local_node: pointer to device_node of this endpoint
22 */
23struct of_endpoint {
24 unsigned int port;
25 unsigned int id;
26 const struct device_node *local_node;
27};
28
17#ifdef CONFIG_OF 29#ifdef CONFIG_OF
30int of_graph_parse_endpoint(const struct device_node *node,
31 struct of_endpoint *endpoint);
18struct device_node *of_graph_get_next_endpoint(const struct device_node *parent, 32struct device_node *of_graph_get_next_endpoint(const struct device_node *parent,
19 struct device_node *previous); 33 struct device_node *previous);
20struct device_node *of_graph_get_remote_port_parent( 34struct device_node *of_graph_get_remote_port_parent(
@@ -22,6 +36,12 @@ struct device_node *of_graph_get_remote_port_parent(
22struct device_node *of_graph_get_remote_port(const struct device_node *node); 36struct device_node *of_graph_get_remote_port(const struct device_node *node);
23#else 37#else
24 38
39static inline int of_graph_parse_endpoint(const struct device_node *node,
40 struct of_endpoint *endpoint);
41{
42 return -ENOSYS;
43}
44
25static inline struct device_node *of_graph_get_next_endpoint( 45static inline struct device_node *of_graph_get_next_endpoint(
26 const struct device_node *parent, 46 const struct device_node *parent,
27 struct device_node *previous) 47 struct device_node *previous)
diff --git a/include/media/v4l2-of.h b/include/media/v4l2-of.h
index 3a49735c56a0..70fa7b7b0487 100644
--- a/include/media/v4l2-of.h
+++ b/include/media/v4l2-of.h
@@ -51,17 +51,13 @@ struct v4l2_of_bus_parallel {
51 51
52/** 52/**
53 * struct v4l2_of_endpoint - the endpoint data structure 53 * struct v4l2_of_endpoint - the endpoint data structure
54 * @port: identifier (value of reg property) of a port this endpoint belongs to 54 * @base: struct of_endpoint containing port, id, and local of_node
55 * @id: identifier (value of reg property) of this endpoint
56 * @local_node: pointer to device_node of this endpoint
57 * @bus_type: bus type 55 * @bus_type: bus type
58 * @bus: bus configuration data structure 56 * @bus: bus configuration data structure
59 * @head: list head for this structure 57 * @head: list head for this structure
60 */ 58 */
61struct v4l2_of_endpoint { 59struct v4l2_of_endpoint {
62 unsigned int port; 60 struct of_endpoint base;
63 unsigned int id;
64 const struct device_node *local_node;
65 enum v4l2_mbus_type bus_type; 61 enum v4l2_mbus_type bus_type;
66 union { 62 union {
67 struct v4l2_of_bus_parallel parallel; 63 struct v4l2_of_bus_parallel parallel;