1 From 79bbd278272416aa61c29bda88e79f8f6dd35903 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] media: ov5647: Add support for non-continuous clock
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.
12 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
14 drivers/media/i2c/ov5647.c | 17 ++++++++++++++---
15 1 file changed, 14 insertions(+), 3 deletions(-)
17 --- a/drivers/media/i2c/ov5647.c
18 +++ b/drivers/media/i2c/ov5647.c
20 #define PWDN_ACTIVE_DELAY_MS 20
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)
27 @@ -95,6 +96,7 @@ struct ov5647 {
30 struct gpio_desc *pwdn;
34 static inline struct ov5647 *to_state(struct v4l2_subdev *sd)
35 @@ -269,9 +271,15 @@ static int ov5647_set_virtual_channel(st
37 static int ov5647_stream_on(struct v4l2_subdev *sd)
39 + struct ov5647 *ov5647 = to_state(sd);
40 + u8 val = MIPI_CTRL00_BUS_IDLE;
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;
48 + ret = ov5647_write(sd, OV5647_REG_MIPI_CTRL00, val);
52 @@ -568,7 +576,7 @@ static const struct v4l2_subdev_internal
56 -static int ov5647_parse_dt(struct device_node *np)
57 +static int ov5647_parse_dt(struct device_node *np, struct ov5647 *sensor)
59 struct v4l2_fwnode_endpoint bus_cfg;
60 struct device_node *ep;
61 @@ -581,6 +589,9 @@ static int ov5647_parse_dt(struct device
63 ret = v4l2_fwnode_endpoint_parse(of_fwnode_handle(ep), &bus_cfg);
66 + sensor->flags = bus_cfg.bus.mipi_csi2.flags;
71 @@ -600,7 +611,7 @@ static int ov5647_probe(struct i2c_clien
74 if (IS_ENABLED(CONFIG_OF) && np) {
75 - ret = ov5647_parse_dt(np);
76 + ret = ov5647_parse_dt(np, sensor);
78 dev_err(dev, "DT parsing error: %d\n", ret);