Skip to content

Commit

Permalink
media: i2c: ov9281: Read chip ID via 2 reads
Browse files Browse the repository at this point in the history
Vision Components have made an OV9281 module which blocks reading
back the majority of registers to comply with NDAs, and in doing
so doesn't allow auto-increment register reading as used when
reading the chip ID.

Use two reads and manually combine the results.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
  • Loading branch information
6by9 authored and popcornmix committed Jan 27, 2021
1 parent 0801ac0 commit e19e5fa
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions drivers/media/i2c/ov9281.c
Original file line number Diff line number Diff line change
Expand Up @@ -904,13 +904,17 @@ static int ov9281_check_sensor_id(struct ov9281 *ov9281,
struct i2c_client *client)
{
struct device *dev = &ov9281->client->dev;
u32 id = 0;
u32 id = 0, id_msb;
int ret;

ret = ov9281_read_reg(client, OV9281_REG_CHIP_ID,
OV9281_REG_VALUE_16BIT, &id);
if (id != CHIP_ID) {
dev_err(dev, "Unexpected sensor id(%06x), ret(%d)\n", id, ret);
ret = ov9281_read_reg(client, OV9281_REG_CHIP_ID + 1,
OV9281_REG_VALUE_08BIT, &id);
if (!ret)
ret = ov9281_read_reg(client, OV9281_REG_CHIP_ID,
OV9281_REG_VALUE_08BIT, &id_msb);
id |= (id_msb << 8);
if (ret || id != CHIP_ID) {
dev_err(dev, "Unexpected sensor id(%04x), ret(%d)\n", id, ret);
return -ENODEV;
}

Expand Down

0 comments on commit e19e5fa

Please sign in to comment.