Skip to contentSkip to conversation

dm: i2c: Add compatibility functions for dm_i2c_reg_read/write()

PATCH New Simon Glass 2 participants 3 messages May 16, 2015 – Jun 11, 2015 I2C

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---

 drivers/i2c/i2c-uclass-compat.c | 21 +++++++++++++++++++++
 include/i2c.h                   |  6 ++++++
 2 files changed, 27 insertions(+)
drivers/i2c/i2c-uclass-compat.c +21 -0
index 223f238..5606d1f 100644
@@ -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);
+}
include/i2c.h +6 -0
index ddfebc4..9300d97 100644
@@ -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
 
 /*
Signature · 1 line
2.2.0.rc0.207.ga3a616c
#1 lore raw

PATCH 1/1 dm: i2c: Add compatibility functions for dm_i2c_reg_read/write()

Hello Simon,

Am 16.05.2015 23:01, schrieb Simon Glass:

Quoted 9 lines

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.

---

  drivers/i2c/i2c-uclass-compat.c | 21 +++++++++++++++++++++
  include/i2c.h                   |  6 ++++++
  2 files changed, 27 insertions(+)

Thanks!

bye,
Heiko

Quoted 48 lines
drivers/i2c/i2c-uclass-compat.c +21 -0
index 223f238..5606d1f 100644
@@ -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);
+}
include/i2c.h +6 -0
index ddfebc4..9300d97 100644
@@ -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
 
  /*
Signature · 2 lines
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
#2 lore raw

PATCH 1/1 dm: i2c: Add compatibility functions for dm_i2c_reg_read/write()

Quoted 11 lines · Heiko Schocher

Hello Simon,

Am 16.05.2015 23:01, schrieb Simon Glass:

Quoted 7 lines

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.

---

Quoted 7 lines
Quoted 3 lines
  drivers/i2c/i2c-uclass-compat.c | 21 +++++++++++++++++++++
  include/i2c.h                   |  6 ++++++
  2 files changed, 27 insertions(+)

Applied to u-boot-dm.