]> git.sur5r.net Git - u-boot/blobdiff - drivers/i2c/i2c-uclass-compat.c
Merge branch 'master' of git://git.denx.de/u-boot
[u-boot] / drivers / i2c / i2c-uclass-compat.c
index 11239da2b997d9568fa3dac488689a5c39fd271c..5606d1f807f64dead14b8ba65a66cfc4f3852b08 100644 (file)
@@ -17,13 +17,13 @@ static int i2c_compat_get_device(uint chip_addr, int alen,
        struct dm_i2c_chip *chip;
        int ret;
 
-       ret = i2c_get_chip_for_busnum(cur_busnum, chip_addr, devp);
+       ret = i2c_get_chip_for_busnum(cur_busnum, chip_addr, alen, devp);
        if (ret)
                return ret;
        chip = dev_get_parent_platdata(*devp);
        if (chip->offset_len != alen) {
-               printf("Requested alen %d does not match chip offset_len %d\n",
-                      alen, chip->offset_len);
+               printf("I2C chip %x: requested alen %d does not match chip offset_len %d\n",
+                      chip_addr, alen, chip->offset_len);
                return -EADDRNOTAVAIL;
        }
 
@@ -96,3 +96,34 @@ int i2c_set_bus_num(unsigned int bus)
 
        return 0;
 }
+
+void i2c_init(int speed, int slaveaddr)
+{
+       /* Nothing to do here - the init happens through driver model */
+}
+
+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);
+}