Hello Simon,

Am 03.07.2015 um 02:15 schrieb Simon Glass:
Sometimes it is useful to be able to transfer a raw I2C message. This
happens when the chip address needs to be set manually, or when the data to
be sent/received is in another buffer.

Add a function to provide access to this.

Signed-off-by: Simon Glass <s...@chromium.org>
---

  drivers/i2c/i2c-uclass.c | 11 +++++++++++
  include/i2c.h            | 13 +++++++++++++
  2 files changed, 24 insertions(+)

Acked-by: Heiko Schocher <h...@denx.de>

bye,
Heiko

diff --git a/drivers/i2c/i2c-uclass.c b/drivers/i2c/i2c-uclass.c
index 42d6e89..50b99ea 100644
--- a/drivers/i2c/i2c-uclass.c
+++ b/drivers/i2c/i2c-uclass.c
@@ -202,6 +202,17 @@ int dm_i2c_write(struct udevice *dev, uint offset, const 
uint8_t *buffer,
        }
  }

+int dm_i2c_xfer(struct udevice *dev, struct i2c_msg *msg, int nmsgs)
+{
+       struct udevice *bus = dev_get_parent(dev);
+       struct dm_i2c_ops *ops = i2c_get_ops(bus);
+
+       if (!ops->xfer)
+               return -ENOSYS;
+
+       return ops->xfer(bus, msg, nmsgs);
+}
+
  int dm_i2c_reg_read(struct udevice *dev, uint offset)
  {
        uint8_t val;
diff --git a/include/i2c.h b/include/i2c.h
index 4c0e263..d191829 100644
--- a/include/i2c.h
+++ b/include/i2c.h
@@ -191,6 +191,19 @@ int dm_i2c_reg_read(struct udevice *dev, uint offset);
  int dm_i2c_reg_write(struct udevice *dev, uint offset, unsigned int val);

  /**
+ * dm_i2c_xfer() - Transfer messages over I2C
+ *
+ * This transfers a raw message. It is best to use dm_i2c_reg_read/write()
+ * instead.
+ *
+ * @dev:       Device to use for transfer
+ * @msg:       List of messages to transfer
+ * @nmsgs:     Number of messages to transfer
+ * @return 0 on success, -ve on error
+ */
+int dm_i2c_xfer(struct udevice *dev, struct i2c_msg *msg, int nmsgs);
+
+/**
   * dm_i2c_set_bus_speed() - set the speed of a bus
   *
   * @bus:      Bus to adjust


--
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

Reply via email to