firmware-utils: bump to git HEAD
[openwrt/openwrt.git] / target / linux / bcm27xx / patches-5.4 / 950-0874-media-i2c-ov9281-Read-chip-ID-via-2-reads.patch
1 From 5c6b7b60d7d607b59b4208e758180d4f93be8788 Mon Sep 17 00:00:00 2001
2 From: Dave Stevenson <dave.stevenson@raspberrypi.com>
3 Date: Mon, 6 Jul 2020 17:51:32 +0100
4 Subject: [PATCH] media: i2c: ov9281: Read chip ID via 2 reads
5
6 Vision Components have made an OV9281 module which blocks reading
7 back the majority of registers to comply with NDAs, and in doing
8 so doesn't allow auto-increment register reading as used when
9 reading the chip ID.
10
11 Use two reads and manually combine the results.
12
13 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
14 ---
15 drivers/media/i2c/ov9281.c | 14 +++++++++-----
16 1 file changed, 9 insertions(+), 5 deletions(-)
17
18 --- a/drivers/media/i2c/ov9281.c
19 +++ b/drivers/media/i2c/ov9281.c
20 @@ -904,13 +904,17 @@ static int ov9281_check_sensor_id(struct
21 struct i2c_client *client)
22 {
23 struct device *dev = &ov9281->client->dev;
24 - u32 id = 0;
25 + u32 id = 0, id_msb;
26 int ret;
27
28 - ret = ov9281_read_reg(client, OV9281_REG_CHIP_ID,
29 - OV9281_REG_VALUE_16BIT, &id);
30 - if (id != CHIP_ID) {
31 - dev_err(dev, "Unexpected sensor id(%06x), ret(%d)\n", id, ret);
32 + ret = ov9281_read_reg(client, OV9281_REG_CHIP_ID + 1,
33 + OV9281_REG_VALUE_08BIT, &id);
34 + if (!ret)
35 + ret = ov9281_read_reg(client, OV9281_REG_CHIP_ID,
36 + OV9281_REG_VALUE_08BIT, &id_msb);
37 + id |= (id_msb << 8);
38 + if (ret || id != CHIP_ID) {
39 + dev_err(dev, "Unexpected sensor id(%04x), ret(%d)\n", id, ret);
40 return -ENODEV;
41 }
42