e7c976b58530936e0971cf63f651c62ef11ae750
[openwrt/staging/neocturne.git] /
1 From d8eb44c8aa81de883c154c46b3323895e6a70a35 Mon Sep 17 00:00:00 2001
2 From: Dave Stevenson <dave.stevenson@raspberrypi.org>
3 Date: Wed, 31 Oct 2018 14:56:47 +0000
4 Subject: [PATCH 189/703] media: ov5647: Add support for non-continuous clock
5 mode
6
7 The driver was only supporting continuous clock mode
8 although this was not stated anywhere.
9 Non-continuous clock saves a small amount of power and
10 on some SoCs is easier to interface with.
11
12 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
13 ---
14 drivers/media/i2c/ov5647.c | 17 ++++++++++++++---
15 1 file changed, 14 insertions(+), 3 deletions(-)
16
17 --- a/drivers/media/i2c/ov5647.c
18 +++ b/drivers/media/i2c/ov5647.c
19 @@ -44,6 +44,7 @@
20 #define PWDN_ACTIVE_DELAY_MS 20
21
22 #define MIPI_CTRL00_CLOCK_LANE_GATE BIT(5)
23 +#define MIPI_CTRL00_LINE_SYNC_ENABLE BIT(4)
24 #define MIPI_CTRL00_BUS_IDLE BIT(2)
25 #define MIPI_CTRL00_CLOCK_LANE_DISABLE BIT(0)
26
27 @@ -95,6 +96,7 @@ struct ov5647 {
28 int power_count;
29 struct clk *xclk;
30 struct gpio_desc *pwdn;
31 + unsigned int flags;
32 };
33
34 static inline struct ov5647 *to_state(struct v4l2_subdev *sd)
35 @@ -269,9 +271,15 @@ static int ov5647_set_virtual_channel(st
36
37 static int ov5647_stream_on(struct v4l2_subdev *sd)
38 {
39 + struct ov5647 *ov5647 = to_state(sd);
40 + u8 val = MIPI_CTRL00_BUS_IDLE;
41 int ret;
42
43 - ret = ov5647_write(sd, OV5647_REG_MIPI_CTRL00, MIPI_CTRL00_BUS_IDLE);
44 + if (ov5647->flags & V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK)
45 + val |= MIPI_CTRL00_CLOCK_LANE_GATE |
46 + MIPI_CTRL00_LINE_SYNC_ENABLE;
47 +
48 + ret = ov5647_write(sd, OV5647_REG_MIPI_CTRL00, val);
49 if (ret < 0)
50 return ret;
51
52 @@ -568,7 +576,7 @@ static const struct v4l2_subdev_internal
53 .open = ov5647_open,
54 };
55
56 -static int ov5647_parse_dt(struct device_node *np)
57 +static int ov5647_parse_dt(struct device_node *np, struct ov5647 *sensor)
58 {
59 struct v4l2_fwnode_endpoint bus_cfg;
60 struct device_node *ep;
61 @@ -581,6 +589,9 @@ static int ov5647_parse_dt(struct device
62
63 ret = v4l2_fwnode_endpoint_parse(of_fwnode_handle(ep), &bus_cfg);
64
65 + if (!ret)
66 + sensor->flags = bus_cfg.bus.mipi_csi2.flags;
67 +
68 of_node_put(ep);
69 return ret;
70 }
71 @@ -600,7 +611,7 @@ static int ov5647_probe(struct i2c_clien
72 return -ENOMEM;
73
74 if (IS_ENABLED(CONFIG_OF) && np) {
75 - ret = ov5647_parse_dt(np);
76 + ret = ov5647_parse_dt(np, sensor);
77 if (ret) {
78 dev_err(dev, "DT parsing error: %d\n", ret);
79 return ret;