aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorSakari Ailus <sakari.ailus@iki.fi>2015-03-25 18:57:37 -0400
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>2015-04-02 15:46:42 -0400
commitb6eec1c4939962838ff51b10a8feb7a49bccc0d2 (patch)
tree9b4c792f2c4a1b7b4b57ee3a8b209f81bb681e5d /drivers
parent9e1ee1b7307e384716a8c2cefca9036a2cf170e5 (diff)
[media] v4l: of: Read lane-polarities endpoint property
Add lane_polarities field to struct v4l2_of_bus_mipi_csi2 and write the contents of the lane-polarities property to it. The field tells the polarity of the physical lanes starting from the first one. Any unused lanes are ignored, i.e. only the polarity of the used lanes is specified. Also rework reading the "data-lanes" property a little. Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi> Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/media/v4l2-core/v4l2-of.c41
1 files changed, 32 insertions, 9 deletions
diff --git a/drivers/media/v4l2-core/v4l2-of.c b/drivers/media/v4l2-core/v4l2-of.c
index b4ed9a955fbe..58e401f4893a 100644
--- a/drivers/media/v4l2-core/v4l2-of.c
+++ b/drivers/media/v4l2-core/v4l2-of.c
@@ -19,11 +19,10 @@
19 19
20#include <media/v4l2-of.h> 20#include <media/v4l2-of.h>
21 21
22static void v4l2_of_parse_csi_bus(const struct device_node *node, 22static int v4l2_of_parse_csi_bus(const struct device_node *node,
23 struct v4l2_of_endpoint *endpoint) 23 struct v4l2_of_endpoint *endpoint)
24{ 24{
25 struct v4l2_of_bus_mipi_csi2 *bus = &endpoint->bus.mipi_csi2; 25 struct v4l2_of_bus_mipi_csi2 *bus = &endpoint->bus.mipi_csi2;
26 u32 data_lanes[ARRAY_SIZE(bus->data_lanes)];
27 struct property *prop; 26 struct property *prop;
28 bool have_clk_lane = false; 27 bool have_clk_lane = false;
29 unsigned int flags = 0; 28 unsigned int flags = 0;
@@ -32,16 +31,34 @@ static void v4l2_of_parse_csi_bus(const struct device_node *node,
32 prop = of_find_property(node, "data-lanes", NULL); 31 prop = of_find_property(node, "data-lanes", NULL);
33 if (prop) { 32 if (prop) {
34 const __be32 *lane = NULL; 33 const __be32 *lane = NULL;
35 int i; 34 unsigned int i;
36 35
37 for (i = 0; i < ARRAY_SIZE(data_lanes); i++) { 36 for (i = 0; i < ARRAY_SIZE(bus->data_lanes); i++) {
38 lane = of_prop_next_u32(prop, lane, &data_lanes[i]); 37 lane = of_prop_next_u32(prop, lane, &v);
39 if (!lane) 38 if (!lane)
40 break; 39 break;
40 bus->data_lanes[i] = v;
41 } 41 }
42 bus->num_data_lanes = i; 42 bus->num_data_lanes = i;
43 while (i--) 43 }
44 bus->data_lanes[i] = data_lanes[i]; 44
45 prop = of_find_property(node, "lane-polarities", NULL);
46 if (prop) {
47 const __be32 *polarity = NULL;
48 unsigned int i;
49
50 for (i = 0; i < ARRAY_SIZE(bus->lane_polarities); i++) {
51 polarity = of_prop_next_u32(prop, polarity, &v);
52 if (!polarity)
53 break;
54 bus->lane_polarities[i] = v;
55 }
56
57 if (i < 1 + bus->num_data_lanes /* clock + data */) {
58 pr_warn("%s: too few lane-polarities entries (need %u, got %u)\n",
59 node->full_name, 1 + bus->num_data_lanes, i);
60 return -EINVAL;
61 }
45 } 62 }
46 63
47 if (!of_property_read_u32(node, "clock-lanes", &v)) { 64 if (!of_property_read_u32(node, "clock-lanes", &v)) {
@@ -56,6 +73,8 @@ static void v4l2_of_parse_csi_bus(const struct device_node *node,
56 73
57 bus->flags = flags; 74 bus->flags = flags;
58 endpoint->bus_type = V4L2_MBUS_CSI2; 75 endpoint->bus_type = V4L2_MBUS_CSI2;
76
77 return 0;
59} 78}
60 79
61static void v4l2_of_parse_parallel_bus(const struct device_node *node, 80static void v4l2_of_parse_parallel_bus(const struct device_node *node,
@@ -127,11 +146,15 @@ static void v4l2_of_parse_parallel_bus(const struct device_node *node,
127int v4l2_of_parse_endpoint(const struct device_node *node, 146int v4l2_of_parse_endpoint(const struct device_node *node,
128 struct v4l2_of_endpoint *endpoint) 147 struct v4l2_of_endpoint *endpoint)
129{ 148{
149 int rval;
150
130 of_graph_parse_endpoint(node, &endpoint->base); 151 of_graph_parse_endpoint(node, &endpoint->base);
131 endpoint->bus_type = 0; 152 endpoint->bus_type = 0;
132 memset(&endpoint->bus, 0, sizeof(endpoint->bus)); 153 memset(&endpoint->bus, 0, sizeof(endpoint->bus));
133 154
134 v4l2_of_parse_csi_bus(node, endpoint); 155 rval = v4l2_of_parse_csi_bus(node, endpoint);
156 if (rval)
157 return rval;
135 /* 158 /*
136 * Parse the parallel video bus properties only if none 159 * Parse the parallel video bus properties only if none
137 * of the MIPI CSI-2 specific properties were found. 160 * of the MIPI CSI-2 specific properties were found.