aboutsummaryrefslogtreecommitdiff
path: root/src/soc/intel/common/block/i2c/lpss_i2c.c
diff options
context:
space:
mode:
authorNico Huber <nico.huber@secunet.com>2017-08-01 17:09:35 +0200
committerMartin Roth <martinroth@google.com>2017-08-18 15:33:45 +0000
commit581738642fbeacdf97fc737a41b3128d72cf1a1c (patch)
tree8f40edb039a66fb6ccdc29b88f7e3b007b048e82 /src/soc/intel/common/block/i2c/lpss_i2c.c
parent0f2dd1eff9930e30dddd9aabceb5d85ee3b4e980 (diff)
Reinvent I2C ops
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 <nico.huber@secunet.com> Reviewed-on: https://review.coreboot.org/20846 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Aaron Durbin <adurbin@chromium.org> Reviewed-by: Kyösti Mälkki <kyosti.malkki@gmail.com>
Diffstat (limited to 'src/soc/intel/common/block/i2c/lpss_i2c.c')
-rw-r--r--src/soc/intel/common/block/i2c/lpss_i2c.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/soc/intel/common/block/i2c/lpss_i2c.c b/src/soc/intel/common/block/i2c/lpss_i2c.c
index 868a6ad300..7db3fe9668 100644
--- a/src/soc/intel/common/block/i2c/lpss_i2c.c
+++ b/src/soc/intel/common/block/i2c/lpss_i2c.c
@@ -258,7 +258,7 @@ static int lpss_i2c_wait_for_bus_idle(struct lpss_i2c_regs *regs)
/* Transfer one byte of one segment, sending stop bit if requested */
static int lpss_i2c_transfer_byte(struct lpss_i2c_regs *regs,
- struct i2c_msg *segment,
+ const struct i2c_msg *segment,
size_t byte, int send_stop)
{
struct stopwatch sw;
@@ -297,16 +297,15 @@ static int lpss_i2c_transfer_byte(struct lpss_i2c_regs *regs,
return 0;
}
-/* Global I2C bus handler, defined in include/i2c.h */
-int platform_i2c_transfer(unsigned int bus, struct i2c_msg *segments,
- int count)
+int lpss_i2c_transfer(unsigned int bus,
+ const struct i2c_msg *segments, size_t count)
{
struct stopwatch sw;
struct lpss_i2c_regs *regs;
size_t byte;
int ret = -1;
- if (count <= 0 || !segments)
+ if (count == 0 || !segments)
return -1;
regs = (struct lpss_i2c_regs *)lpss_i2c_base_address(bus);
@@ -396,6 +395,12 @@ out:
return ret;
}
+/* Global I2C bus handler, defined in include/device/i2c_simple.h */
+int platform_i2c_transfer(unsigned int bus, struct i2c_msg *msg, int count)
+{
+ return lpss_i2c_transfer(bus, msg, count < 0 ? 0 : count);
+}
+
static int lpss_i2c_set_speed_config(unsigned int bus,
const struct lpss_i2c_speed_config *config)
{