From 439cee90984ed9b5b614af2707aa0017528890d0 Mon Sep 17 00:00:00 2001 From: Aaron Durbin Date: Mon, 22 Jan 2018 21:24:35 -0700 Subject: device/i2c_bus: allow i2c_bus and i2c_simple to coexist If one wants to implement both i2c_bus.h and i2c_simple.h APIs the compilation unit needs to be guarded or coordinated carefully with different compilation units. Instead, name the i2c_bus functions with _dev such that it indicates that they operate on struct device. One other change to allow i2c_bus.h to be built in non-ramstage environments is to ensure DEVTREE_CONST is used for the dev field in struct bus. BUG=b:72121803 Change-Id: I267e27e62c95013e8ff8b0728dbe9e7b523de453 Signed-off-by: Aaron Durbin Reviewed-on: https://review.coreboot.org/23370 Tested-by: build bot (Jenkins) Reviewed-by: Martin Roth Reviewed-by: Furquan Shaikh --- src/device/i2c_bus.c | 10 +++++----- src/drivers/i2c/rx6110sa/rx6110sa.c | 4 ++-- src/include/device/i2c_bus.h | 10 +++++----- src/include/device/smbus.h | 8 ++++---- 4 files changed, 16 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/device/i2c_bus.c b/src/device/i2c_bus.c index 1c543efaba..30bb80ca98 100644 --- a/src/device/i2c_bus.c +++ b/src/device/i2c_bus.c @@ -44,7 +44,7 @@ struct bus *i2c_link(struct device *const dev) return link; } -int i2c_readb(struct device *const dev) +int i2c_dev_readb(struct device *const dev) { struct device *const busdev = i2c_busdev(dev); if (!busdev) @@ -74,7 +74,7 @@ int i2c_readb(struct device *const dev) } } -int i2c_writeb(struct device *const dev, uint8_t val) +int i2c_dev_writeb(struct device *const dev, uint8_t val) { struct device *const busdev = i2c_busdev(dev); if (!busdev) @@ -97,7 +97,7 @@ int i2c_writeb(struct device *const dev, uint8_t val) } } -int i2c_readb_at(struct device *const dev, uint8_t off) +int i2c_dev_readb_at(struct device *const dev, uint8_t off) { struct device *const busdev = i2c_busdev(dev); if (!busdev) @@ -135,8 +135,8 @@ int i2c_readb_at(struct device *const dev, uint8_t off) } } -int i2c_writeb_at(struct device *const dev, - const uint8_t off, const uint8_t val) +int i2c_dev_writeb_at(struct device *const dev, + const uint8_t off, const uint8_t val) { struct device *const busdev = i2c_busdev(dev); if (!busdev) diff --git a/src/drivers/i2c/rx6110sa/rx6110sa.c b/src/drivers/i2c/rx6110sa/rx6110sa.c index d793c4dd9c..266b5a8ac5 100644 --- a/src/drivers/i2c/rx6110sa/rx6110sa.c +++ b/src/drivers/i2c/rx6110sa/rx6110sa.c @@ -25,13 +25,13 @@ /* Function to write a register in the RTC with the given value. */ static void rx6110sa_write(struct device *dev, uint8_t reg, uint8_t val) { - i2c_writeb_at(dev, reg, val); + i2c_dev_writeb_at(dev, reg, val); } /* Function to read a register in the RTC. */ static uint8_t rx6110sa_read(struct device *dev, uint8_t reg) { - return (uint8_t)i2c_readb_at(dev, reg); + return (uint8_t)i2c_dev_readb_at(dev, reg); } /* Set RTC date from coreboot build date. */ diff --git a/src/include/device/i2c_bus.h b/src/include/device/i2c_bus.h index f1416a7411..6aa4f9ba9d 100644 --- a/src/include/device/i2c_bus.h +++ b/src/include/device/i2c_bus.h @@ -39,7 +39,7 @@ struct bus *i2c_link(struct device *); * * Returns NULL if i2c_link(dev) returns NULL. */ -static inline struct device *i2c_busdev(struct device *dev) +static inline DEVTREE_CONST struct device *i2c_busdev(struct device *dev) { struct bus *const link = i2c_link(dev); return link ? link->dev : NULL; @@ -63,7 +63,7 @@ static inline struct device *i2c_busdev(struct device *dev) * * Returns the read byte on success, negative `enum cb_err` value on error. */ -int i2c_readb(struct device *); +int i2c_dev_readb(struct device *); /* * Writes the byte `val`. @@ -71,7 +71,7 @@ int i2c_readb(struct device *); * * Returns 0 on success, negative `enum cb_err` value on error. */ -int i2c_writeb(struct device *, uint8_t val); +int i2c_dev_writeb(struct device *, uint8_t val); /* * Sends the register offset `off` and reads one byte. @@ -79,7 +79,7 @@ int i2c_writeb(struct device *, uint8_t val); * * Returns the read byte on success, negative `enum cb_err` value on error. */ -int i2c_readb_at(struct device *, uint8_t off); +int i2c_dev_readb_at(struct device *, uint8_t off); /* * Sends the register offset `off` followed by the byte `val`. @@ -87,6 +87,6 @@ int i2c_readb_at(struct device *, uint8_t off); * * Returns 0 on success, negative `enum cb_err` value on error. */ -int i2c_writeb_at(struct device *, uint8_t off, uint8_t val); +int i2c_dev_writeb_at(struct device *, uint8_t off, uint8_t val); #endif /* _DEVICE_I2C_BUS_H_ */ diff --git a/src/include/device/smbus.h b/src/include/device/smbus.h index 5e51b5d267..50857fe85f 100644 --- a/src/include/device/smbus.h +++ b/src/include/device/smbus.h @@ -32,22 +32,22 @@ int smbus_set_link(device_t dev); static inline int smbus_recv_byte(struct device *const dev) { - return i2c_readb(dev); + return i2c_dev_readb(dev); } static inline int smbus_send_byte(struct device *const dev, u8 byte) { - return i2c_writeb(dev, byte); + return i2c_dev_writeb(dev, byte); } static inline int smbus_read_byte(struct device *const dev, u8 addr) { - return i2c_readb_at(dev, addr); + return i2c_dev_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); + return i2c_dev_writeb_at(dev, addr, val); } int smbus_block_read(device_t dev, u8 cmd, u8 bytes, u8 *buffer); -- cgit v1.2.3