Commit 51fc72e5 authored by Sakari Ailus's avatar Sakari Ailus Committed by Mauro Carvalho Chehab

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: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
parent e1988e7a
...@@ -1553,11 +1553,26 @@ static int ccs_power_on(struct device *dev) ...@@ -1553,11 +1553,26 @@ static int ccs_power_on(struct device *dev)
*/ */
if (!sensor->reset && !sensor->xshutdown) { if (!sensor->reset && !sensor->xshutdown) {
u8 retry = 100;
u32 reset;
rval = ccs_write(sensor, SOFTWARE_RESET, CCS_SOFTWARE_RESET_ON); rval = ccs_write(sensor, SOFTWARE_RESET, CCS_SOFTWARE_RESET_ON);
if (rval < 0) { if (rval < 0) {
dev_err(dev, "software reset failed\n"); dev_err(dev, "software reset failed\n");
goto out_cci_addr_fail; 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) { if (sensor->hwcfg.i2c_addr_alt) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment