diff options
author | Simon Glass <sjg@chromium.org> | 2015-04-20 18:37:14 (GMT) |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2015-05-06 02:58:19 (GMT) |
commit | ba3864f8037f58dd1f46cad3b76adc0a84bd33b3 (patch) | |
tree | c635c755acd3922067cba3c1ca98a100ec5059fe /drivers/i2c/i2c-uclass.c | |
parent | 1bde67b1f492cbb0177241a56af59f706d45fccf (diff) | |
download | u-boot-ba3864f8037f58dd1f46cad3b76adc0a84bd33b3.tar.xz |
dm: i2c: Add functions to read and write a register
Add driver model versions of the legacy functions to read and write a
single byte register. These are a useful shortcut in many cases.
Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Heiko Schocher <hs@denx.de>
Diffstat (limited to 'drivers/i2c/i2c-uclass.c')
-rw-r--r-- | drivers/i2c/i2c-uclass.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/drivers/i2c/i2c-uclass.c b/drivers/i2c/i2c-uclass.c index f2e95c0..b8eb2d6 100644 --- a/drivers/i2c/i2c-uclass.c +++ b/drivers/i2c/i2c-uclass.c @@ -186,6 +186,25 @@ int dm_i2c_write(struct udevice *dev, uint offset, const uint8_t *buffer, } } +int dm_i2c_reg_read(struct udevice *dev, uint offset) +{ + uint8_t val; + int ret; + + ret = dm_i2c_read(dev, offset, &val, 1); + if (ret < 0) + return ret; + + return val; +} + +int dm_i2c_reg_write(struct udevice *dev, uint offset, uint value) +{ + uint8_t val = value; + + return dm_i2c_write(dev, offset, &val, 1); +} + /** * i2c_probe_chip() - probe for a chip on a bus * |