]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
dm: i2c: Add compatibility functions for dm_i2c_reg_read/write()
authorSimon Glass <sjg@chromium.org>
Sat, 16 May 2015 21:01:41 +0000 (15:01 -0600)
committerLothar Waßmann <LW@KARO-electronics.de>
Tue, 8 Sep 2015 22:42:36 +0000 (00:42 +0200)
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>
drivers/i2c/i2c-uclass-compat.c
include/i2c.h

index 223f238f4bed0cc475743c94931ed25fd2a2427b..5606d1f807f64dead14b8ba65a66cfc4f3852b08 100644 (file)
@@ -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);
+}
index ddfebc4107f638d68f0d0296d335fd67c9f6120d..9300d97e146b03f406b1b5ea505be2d5886d9325 100644 (file)
@@ -284,6 +284,12 @@ void i2c_init(int speed, int slaveaddr);
  */
 void board_i2c_init(const void *blob);
 
+/*
+ * Compatibility functions for driver model.
+ */
+uint8_t i2c_reg_read(uint8_t addr, uint8_t reg);
+void i2c_reg_write(uint8_t addr, uint8_t reg, uint8_t val);
+
 #endif
 
 /*