diff options
author | Nico Huber <nico.huber@secunet.com> | 2017-08-02 16:57:17 +0200 |
---|---|---|
committer | Martin Roth <martinroth@google.com> | 2017-08-18 15:34:15 +0000 |
commit | 632d6abb8ab3d93e3efe313eedecc1293b418966 (patch) | |
tree | 5db944071d3a0644e827033adbdb2a6d4ade0efb /src/include/device | |
parent | 0594c5973ca6612e151d206a5a68ca4b0dcb955e (diff) |
device/smbus: Reuse I2C bus operations where applicable
Reuse generic I2C functions that work for SMBus operations as well.
Change-Id: I5a93f17b905de38752254891aa4347ba4ed3b205
Signed-off-by: Nico Huber <nico.huber@secunet.com>
Reviewed-on: https://review.coreboot.org/20855
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Diffstat (limited to 'src/include/device')
-rw-r--r-- | src/include/device/smbus.h | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/src/include/device/smbus.h b/src/include/device/smbus.h index 80eafdb969..5e51b5d267 100644 --- a/src/include/device/smbus.h +++ b/src/include/device/smbus.h @@ -3,7 +3,7 @@ #include <stdint.h> #include <device/device.h> -#include <device/path.h> +#include <device/i2c_bus.h> #include <device/smbus_def.h> /* Common SMBus bus operations */ @@ -30,10 +30,26 @@ static inline const struct smbus_bus_operations *ops_smbus_bus(struct bus *bus) struct bus *get_pbus_smbus(device_t dev); int smbus_set_link(device_t dev); -int smbus_recv_byte(device_t dev); -int smbus_send_byte(device_t dev, u8 byte); -int smbus_read_byte(device_t dev, u8 addr); -int smbus_write_byte(device_t dev, u8 addr, u8 val); +static inline int smbus_recv_byte(struct device *const dev) +{ + return i2c_readb(dev); +} + +static inline int smbus_send_byte(struct device *const dev, u8 byte) +{ + return i2c_writeb(dev, byte); +} + +static inline int smbus_read_byte(struct device *const dev, u8 addr) +{ + return i2c_readb_at(dev, addr); +} + +static inline int smbus_write_byte(struct device *const dev, u8 addr, u8 val) +{ + return i2c_writeb_at(dev, addr, val); +} + int smbus_block_read(device_t dev, u8 cmd, u8 bytes, u8 *buffer); int smbus_block_write(device_t dev, u8 cmd, u8 bytes, const u8 *buffer); |