diff options
author | Sakari Ailus <sakari.ailus@linux.intel.com> | 2020-10-08 12:09:07 +0200 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab+huawei@kernel.org> | 2021-01-12 17:50:10 +0100 |
commit | 51fc72e541b44d5ba52673b1e2b492ffc164b71c (patch) | |
tree | c188c4426816265c699382b573717686ae8cd035 /drivers/media/i2c | |
parent | media: ccs: Only do software reset if we have no hardware reset (diff) | |
download | linux-51fc72e541b44d5ba52673b1e2b492ffc164b71c.tar.xz linux-51fc72e541b44d5ba52673b1e2b492ffc164b71c.zip |
media: ccs: Wait until software reset is done
Verify the software reset has been completed until proceeding.
The spec does not guarantee a delay but presumably 100 ms should be
enough.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Diffstat (limited to 'drivers/media/i2c')
-rw-r--r-- | drivers/media/i2c/ccs/ccs-core.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/drivers/media/i2c/ccs/ccs-core.c b/drivers/media/i2c/ccs/ccs-core.c index fdf2e83eeac3..e1b3c5693e01 100644 --- a/drivers/media/i2c/ccs/ccs-core.c +++ b/drivers/media/i2c/ccs/ccs-core.c @@ -1553,11 +1553,26 @@ static int ccs_power_on(struct device *dev) */ if (!sensor->reset && !sensor->xshutdown) { + u8 retry = 100; + u32 reset; + rval = ccs_write(sensor, SOFTWARE_RESET, CCS_SOFTWARE_RESET_ON); if (rval < 0) { dev_err(dev, "software reset failed\n"); goto out_cci_addr_fail; } + + do { + rval = ccs_read(sensor, SOFTWARE_RESET, &reset); + reset = !rval && reset == CCS_SOFTWARE_RESET_OFF; + if (reset) + break; + + usleep_range(1000, 2000); + } while (--retry); + + if (!reset) + return -EIO; } if (sensor->hwcfg.i2c_addr_alt) { |