aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil@xs4all.nl>2021-08-26 16:25:50 +0200
committerHans Verkuil <hverkuil@xs4all.nl>2021-08-26 16:25:50 +0200
commita112fb6d0a4eb6f25ebb5dc4779fced8b4fe49bd (patch)
treef8ce33a660475c74067c99762fe8d81cc370b776
parentb0c52d665455c15ae03f5fe6ecaf550dd6af8641 (diff)
cat24c208: introduce WRITE_CYCLE_TIMEhdmi-dbg-orig
A 5ms delay is needed after each write. Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
-rw-r--r--drivers/media/i2c/cat24c208.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/drivers/media/i2c/cat24c208.c b/drivers/media/i2c/cat24c208.c
index d758023873b2..e4681d6514cc 100644
--- a/drivers/media/i2c/cat24c208.c
+++ b/drivers/media/i2c/cat24c208.c
@@ -45,6 +45,16 @@ MODULE_LICENSE("GPL v2");
#define CONFIG_WE_BIT BIT(3)
/*
+ * From the datasheet:
+ *
+ * The write cycle time is the time from a valid stop condition of a write
+ * sequence to the end of the internal program/erase cycle. During the write
+ * cycle, the bus interface circuits are disabled, SDA is allowed to remain
+ * high, and the device does not respond to its slave address.
+ */
+#define WRITE_CYCLE_TIME_US 5000
+
+/*
* CAT24C208 addresses
*/
#define CONFIG_I2C_ADDR 0x31
@@ -99,11 +109,8 @@ static int cat24c208_seg_write(struct cat24c208_state *state, u8 *data, u16 len,
if (err < 0)
dev_err(&dev_client->dev, "Writing to 0x%x failed (segment %d)\n",
data_client->addr, seg);
- /*
- * For some unexplained reason this sleep is needed, otherwise the
- * next transfer will return a EREMOTEIO error on the Raspberry Pi 4B.
- */
- usleep_range(1000, 10000);
+
+ usleep_range(WRITE_CYCLE_TIME_US, 2 * WRITE_CYCLE_TIME_US);
return err < 0 ? err : 0;
}
@@ -168,11 +175,7 @@ static int cat24c208_set_config(struct i2c_client *client)
err = i2c_transfer(client->adapter, &msg, 1);
if (err < 0)
dev_err(&client->dev, "Could not set config register\n");
- /*
- * For some unexplained reason this sleep is needed, otherwise the
- * next transfer will return a EREMOTEIO error on the Raspberry Pi 4B.
- */
- usleep_range(1000, 10000);
+ usleep_range(WRITE_CYCLE_TIME_US, 2 * WRITE_CYCLE_TIME_US);
return err < 0 ? err : 0;
}

Privacy Policy