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>
This commit is contained in:
Sebastian Reichel
2021-07-15 17:39:59 +02:00
committed by Heiko Schocher
parent 79d389a548
commit 2aefa6e3f2
3 changed files with 58 additions and 0 deletions

View File

@@ -242,6 +242,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
*