diff options
Diffstat (limited to 'common/i2c.c')
-rw-r--r-- | common/i2c.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/common/i2c.c b/common/i2c.c index 05d7f1a703..800922adea 100644 --- a/common/i2c.c +++ b/common/i2c.c @@ -26,10 +26,20 @@ #define CPUTS(outstr) cputs(CC_I2C, outstr) #define CPRINTS(format, args...) cprints(CC_I2C, format, ## args) -static struct mutex port_mutex[I2C_PORT_COUNT]; +/* Only chips with multi-port controllers will define I2C_CONTROLER_COUNT */ +#ifndef I2C_CONTROLLER_COUNT +#define I2C_CONTROLLER_COUNT I2C_PORT_COUNT +#endif + +static struct mutex port_mutex[I2C_CONTROLLER_COUNT]; void i2c_lock(int port, int lock) { +#ifdef CONFIG_I2C_MULTI_PORT_CONTROLLER + /* Lock the controller, not the port */ + port = i2c_port_to_controller(port); + ASSERT(port != -1); +#endif if (lock) { /* Don't allow deep sleep when I2C port is locked */ disable_sleep(SLEEP_MASK_I2C); |