aboutsummaryrefslogtreecommitdiff
path: root/include/i2c.h
diff options
context:
space:
mode:
authorSebastian Reichel2021-07-15 17:39:59 +0200
committerHeiko Schocher2021-08-22 10:52:53 +0200
commit2aefa6e3f2ab621483ca645b16c7bf8cb9334fa3 (patch)
treece32ac1a9ee05266489dd58f9ff0ade8852e51cb /include/i2c.h
parent79d389a54891a67269bfa366f044a2079409e499 (diff)
i2c: add dm_i2c_reg_clrset
Add function to apply a bitmask to an i2c register, so that specific bits can be cleared and/or set. Suggested-by: Simon Glass <sjg@chromium.org> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com> Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'include/i2c.h')
-rw-r--r--include/i2c.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/include/i2c.h b/include/i2c.h
index 8db34a67fee..3d9ecaba0b6 100644
--- a/include/i2c.h
+++ b/include/i2c.h
@@ -243,6 +243,20 @@ int dm_i2c_reg_read(struct udevice *dev, uint offset);
int dm_i2c_reg_write(struct udevice *dev, uint offset, unsigned int val);
/**
+ * dm_i2c_reg_clrset() - Apply bitmask to an I2C register
+ *
+ * Read value, apply bitmask and write modified value back to the
+ * given address in an I2C chip
+ *
+ * @dev: Device to use for transfer
+ * @offset: Address for the R/W operation
+ * @clr: Bitmask of bits that should be cleared
+ * @set: Bitmask of bits that should be set
+ * @return 0 on success, -ve on error
+ */
+int dm_i2c_reg_clrset(struct udevice *dev, uint offset, u32 clr, u32 set);
+
+/**
* dm_i2c_xfer() - Transfer messages over I2C
*
* This transfers a raw message. It is best to use dm_i2c_reg_read/write()