From 581738642fbeacdf97fc737a41b3128d72cf1a1c Mon Sep 17 00:00:00 2001 From: Nico Huber Date: Tue, 1 Aug 2017 17:09:35 +0200 Subject: Reinvent I2C ops MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Do not use the global platform_i2c_transfer() function that can only be implemented by a single driver. Instead, make a `struct device` aware transfer() function the only interface function for I2C controller dri- vers to implement. To not force the slave device drivers to be implemented either above generic I2C or specialized SMBus operations, we support SMBus control- lers in the slave device interface too. We start with four simple slave functions: i2c_readb(), i2c_writeb(), i2c_readb_at() and i2c_writeb_at(). They are all compatible to respec- tive SMBus functions. But we keep aliases because it would be weird to force e.g. an I2C EEPROM driver to call smbus_read_byte(). Change-Id: I98386f91bf4799ba3df84ec8bc0f64edd4142818 Signed-off-by: Nico Huber Reviewed-on: https://review.coreboot.org/20846 Tested-by: build bot (Jenkins) Reviewed-by: Aaron Durbin Reviewed-by: Kyösti Mälkki --- src/soc/intel/common/block/i2c/i2c.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/soc/intel/common/block/i2c/i2c.c') diff --git a/src/soc/intel/common/block/i2c/i2c.c b/src/soc/intel/common/block/i2c/i2c.c index aeb6d8f2ed..625bb991d4 100644 --- a/src/soc/intel/common/block/i2c/i2c.c +++ b/src/soc/intel/common/block/i2c/i2c.c @@ -150,8 +150,14 @@ static void lpss_i2c_acpi_fill_ssdt(struct device *dev) acpigen_pop_len(); } -static struct i2c_bus_operations i2c_bus_ops = { - .dev_to_bus = &lpss_i2c_dev_to_bus, +static int lpss_i2c_dev_transfer(struct device *dev, + const struct i2c_msg *msg, size_t count) +{ + return lpss_i2c_transfer(lpss_i2c_dev_to_bus(dev), msg, count); +} + +static const struct i2c_bus_operations i2c_bus_ops = { + .transfer = lpss_i2c_dev_transfer, }; static struct device_operations i2c_dev_ops = { -- cgit v1.2.3