brcm2708: update to latest patches from the RPi foundation
[openwrt/staging/lynxis.git] / target / linux / brcm2708 / patches-4.14 / 950-0324-ov5647-Add-support-for-non-continuous-clock-mode.patch
1 From f4d559078cab81209b721a83ffd87a40a6fb52c4 Mon Sep 17 00:00:00 2001
2 From: Dave Stevenson <dave.stevenson@raspberrypi.org>
3 Date: Fri, 23 Jun 2017 17:58:55 +0100
4 Subject: [PATCH 324/454] ov5647: Add support for non-continuous clock mode
5
6 The driver was only supporting continuous clock mode
7 although this was not stated anywhere.
8 Non-continuous clock saves a small amount of power and
9 on some SoCs is easier to interface with.
10
11 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
12 ---
13 drivers/media/i2c/ov5647.c | 13 ++++++++++---
14 1 file changed, 10 insertions(+), 3 deletions(-)
15
16 --- a/drivers/media/i2c/ov5647.c
17 +++ b/drivers/media/i2c/ov5647.c
18 @@ -86,6 +86,7 @@ struct ov5647 {
19 int power_count;
20 struct clk *xclk;
21 struct gpio_desc *pwdn;
22 + unsigned int flags;
23 };
24
25 static inline struct ov5647 *to_state(struct v4l2_subdev *sd)
26 @@ -302,6 +303,7 @@ static int __sensor_init(struct v4l2_sub
27 int ret;
28 u8 resetval, rdval;
29 struct i2c_client *client = v4l2_get_subdevdata(sd);
30 + struct ov5647 *ov5647 = to_state(sd);
31
32 ret = ov5647_read(sd, 0x0100, &rdval);
33 if (ret < 0)
34 @@ -329,7 +331,9 @@ static int __sensor_init(struct v4l2_sub
35 return ret;
36 }
37
38 - return ov5647_write(sd, 0x4800, 0x04);
39 + return ov5647_write(sd, 0x4800,
40 + (ov5647->flags & V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK) ?
41 + 0x34 : 0x04);
42 }
43
44 static int ov5647_sensor_power(struct v4l2_subdev *sd, int on)
45 @@ -547,7 +551,7 @@ static const struct v4l2_subdev_internal
46 .open = ov5647_open,
47 };
48
49 -static int ov5647_parse_dt(struct device_node *np)
50 +static int ov5647_parse_dt(struct device_node *np, struct ov5647 *sensor)
51 {
52 struct v4l2_fwnode_endpoint bus_cfg;
53 struct device_node *ep;
54 @@ -560,6 +564,9 @@ static int ov5647_parse_dt(struct device
55
56 ret = v4l2_fwnode_endpoint_parse(of_fwnode_handle(ep), &bus_cfg);
57
58 + if (!ret)
59 + sensor->flags = bus_cfg.bus.mipi_csi2.flags;
60 +
61 of_node_put(ep);
62 return ret;
63 }
64 @@ -579,7 +586,7 @@ static int ov5647_probe(struct i2c_clien
65 return -ENOMEM;
66
67 if (IS_ENABLED(CONFIG_OF) && np) {
68 - ret = ov5647_parse_dt(np);
69 + ret = ov5647_parse_dt(np, sensor);
70 if (ret) {
71 dev_err(dev, "DT parsing error: %d\n", ret);
72 return ret;