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>
diff --git a/include/i2c.h b/include/i2c.h
index 8db34a6..3d9ecab 100644
--- a/include/i2c.h
+++ b/include/i2c.h
@@ -243,6 +243,20 @@
 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()