summaryrefslogtreecommitdiff
path: root/drivers/i2c/i2c-uclass-compat.c
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2015-05-16 15:01:41 -0600
committerSimon Glass <sjg@chromium.org>2015-06-10 19:26:54 -0600
commita2879764ba392229dc7aba89951e74524750af18 (patch)
tree142fc50a5e76f5dab76fa154463fc0fd8577d3a9 /drivers/i2c/i2c-uclass-compat.c
parentb2016133edec9ece02dca7881e2e0c059d2b421c (diff)
dm: i2c: Add compatibility functions for dm_i2c_reg_read/write()
Add the legacy i2c_reg_read/write() functions to the compatibility layer so that they can be used when CONFIG_DM_I2C_COMPAT is defined. Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: Heiko Schocher <hs@denx.de>
Diffstat (limited to 'drivers/i2c/i2c-uclass-compat.c')
-rw-r--r--drivers/i2c/i2c-uclass-compat.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/drivers/i2c/i2c-uclass-compat.c b/drivers/i2c/i2c-uclass-compat.c
index 223f238f4be..5606d1f807f 100644
--- a/drivers/i2c/i2c-uclass-compat.c
+++ b/drivers/i2c/i2c-uclass-compat.c
@@ -106,3 +106,24 @@ void board_i2c_init(const void *blob)
{
/* Nothing to do here - the init happens through driver model */
}
+
+uint8_t i2c_reg_read(uint8_t chip_addr, uint8_t offset)
+{
+ struct udevice *dev;
+ int ret;
+
+ ret = i2c_compat_get_device(chip_addr, 1, &dev);
+ if (ret)
+ return 0xff;
+ return dm_i2c_reg_read(dev, offset);
+}
+
+void i2c_reg_write(uint8_t chip_addr, uint8_t offset, uint8_t val)
+{
+ struct udevice *dev;
+ int ret;
+
+ ret = i2c_compat_get_device(chip_addr, 1, &dev);
+ if (!ret)
+ dm_i2c_reg_write(dev, offset, val);
+}