diff options
author | Denis Brockus <dbrockus@chromium.org> | 2019-06-25 12:44:16 -0600 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2019-07-19 21:11:02 +0000 |
commit | d1a18f82ed831d4e640336ff5571f5fa64bc7b36 (patch) | |
tree | c46aeb6136de1c27c66e3d5f662e9620161bef7b /driver/charger | |
parent | 1f14229fa7e499dfcee07d17add187598ff0a46c (diff) | |
download | chrome-ec-d1a18f82ed831d4e640336ff5571f5fa64bc7b36.tar.gz |
Use 7bit I2C/SPI slave addresses in EC
Opt for 7bit slave addresses in EC code. If 8bit is
expected by a driver, make it local and show this in
the naming.
Use __7b, __7bf and __8b as name extensions for i2c/spi
addresses used in the EC codebase. __7b indicates a
7bit address by itself. __7bf indicates a 7bit address
with optional flags attached. __8b indicates a 8bit
address by itself.
Allow space for 10bit addresses, even though this is
not currently being used by any of our attached
devices.
These extensions are for verification purposes only and
will be removed in the last pass of this ticket. I want
to make sure the variable names reflect the type to help
eliminate future 7/8/7-flags confusion.
BUG=chromium:971296
BRANCH=none
TEST=make buildall -j
Change-Id: I2fc3d1b52ce76184492b2aaff3060f486ca45f45
Signed-off-by: Denis Brockus <dbrockus@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1699893
Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
Diffstat (limited to 'driver/charger')
-rw-r--r-- | driver/charger/bd9995x.c | 10 | ||||
-rw-r--r-- | driver/charger/bd9995x.h | 4 | ||||
-rw-r--r-- | driver/charger/bq24192.h | 2 | ||||
-rw-r--r-- | driver/charger/bq24715.c | 6 | ||||
-rw-r--r-- | driver/charger/bq24773.h | 20 | ||||
-rw-r--r-- | driver/charger/bq25703.h | 2 | ||||
-rw-r--r-- | driver/charger/bq25710.c | 7 | ||||
-rw-r--r-- | driver/charger/bq25710.h | 2 | ||||
-rw-r--r-- | driver/charger/bq2589x.h | 6 | ||||
-rw-r--r-- | driver/charger/isl923x.c | 27 | ||||
-rw-r--r-- | driver/charger/isl923x.h | 4 | ||||
-rw-r--r-- | driver/charger/isl9241.h | 4 | ||||
-rw-r--r-- | driver/charger/rt946x.c | 7 | ||||
-rw-r--r-- | driver/charger/rt946x.h | 6 | ||||
-rw-r--r-- | driver/charger/sy21612.c | 7 | ||||
-rw-r--r-- | driver/charger/sy21612.h | 4 |
16 files changed, 66 insertions, 52 deletions
diff --git a/driver/charger/bd9995x.c b/driver/charger/bd9995x.c index 1eba3e9aa6..e9d2e601a1 100644 --- a/driver/charger/bd9995x.c +++ b/driver/charger/bd9995x.c @@ -131,7 +131,7 @@ static inline int ch_raw_read16(int cmd, int *param, /* Map the Charge command code to appropriate region */ mutex_lock(&bd9995x_map_mutex); if (charger_map_cmd != map_cmd) { - rv = i2c_write16(I2C_PORT_CHARGER, I2C_ADDR_CHARGER, + rv = i2c_write16__7bf(I2C_PORT_CHARGER, I2C_ADDR_CHARGER__7bf, BD9995X_CMD_MAP_SET, map_cmd); if (rv) { charger_map_cmd = BD9995X_INVALID_COMMAND; @@ -141,7 +141,8 @@ static inline int ch_raw_read16(int cmd, int *param, charger_map_cmd = map_cmd; } - rv = i2c_read16(I2C_PORT_CHARGER, I2C_ADDR_CHARGER, cmd, param); + rv = i2c_read16__7bf(I2C_PORT_CHARGER, I2C_ADDR_CHARGER__7bf, + cmd, param); bd9995x_read_cleanup: mutex_unlock(&bd9995x_map_mutex); @@ -157,7 +158,7 @@ static inline int ch_raw_write16(int cmd, int param, /* Map the Charge command code to appropriate region */ mutex_lock(&bd9995x_map_mutex); if (charger_map_cmd != map_cmd) { - rv = i2c_write16(I2C_PORT_CHARGER, I2C_ADDR_CHARGER, + rv = i2c_write16__7bf(I2C_PORT_CHARGER, I2C_ADDR_CHARGER__7bf, BD9995X_CMD_MAP_SET, map_cmd); if (rv) { charger_map_cmd = BD9995X_INVALID_COMMAND; @@ -167,7 +168,8 @@ static inline int ch_raw_write16(int cmd, int param, charger_map_cmd = map_cmd; } - rv = i2c_write16(I2C_PORT_CHARGER, I2C_ADDR_CHARGER, cmd, param); + rv = i2c_write16__7bf(I2C_PORT_CHARGER, I2C_ADDR_CHARGER__7bf, + cmd, param); bd9995x_write_cleanup: mutex_unlock(&bd9995x_map_mutex); diff --git a/driver/charger/bd9995x.h b/driver/charger/bd9995x.h index 6719fd8661..6a946835bc 100644 --- a/driver/charger/bd9995x.h +++ b/driver/charger/bd9995x.h @@ -8,8 +8,8 @@ #ifndef __CROS_EC_BD9995X_H #define __CROS_EC_BD9995X_H -#define BD9995X_ADDR 0x12 /* 7bit address 0001_001 */ -#define I2C_ADDR_CHARGER BD9995X_ADDR +#define BD9995X_ADDR__7bf 0x09 +#define I2C_ADDR_CHARGER__7bf BD9995X_ADDR__7bf #define BD9995X_CHARGER_NAME "bd9995x" #define BD99955_CHIP_ID 0x221 diff --git a/driver/charger/bq24192.h b/driver/charger/bq24192.h index 0bde4483c3..188cb24942 100644 --- a/driver/charger/bq24192.h +++ b/driver/charger/bq24192.h @@ -8,7 +8,7 @@ #ifndef __CROS_EC_BQ24192_H #define __CROS_EC_BQ24192_H -#define BQ24192_ADDR 0xd6 +#define BQ24192_ADDR__7bf 0x6b /* Registers */ #define BQ24192_REG_INPUT_CTRL 0x0 diff --git a/driver/charger/bq24715.c b/driver/charger/bq24715.c index 4fe49599f6..bd38ed5f95 100644 --- a/driver/charger/bq24715.c +++ b/driver/charger/bq24715.c @@ -37,12 +37,14 @@ static const struct charger_info bq24725_charger_info = { static inline int sbc_read(int cmd, int *param) { - return i2c_read16(I2C_PORT_CHARGER, CHARGER_ADDR, cmd, param); + return i2c_read16__7bf(I2C_PORT_CHARGER, CHARGER_ADDR__7bf, + cmd, param); } static inline int sbc_write(int cmd, int param) { - return i2c_write16(I2C_PORT_CHARGER, CHARGER_ADDR, cmd, param); + return i2c_write16__7bf(I2C_PORT_CHARGER, CHARGER_ADDR__7bf, + cmd, param); } int charger_set_input_current(int input_current) diff --git a/driver/charger/bq24773.h b/driver/charger/bq24773.h index 52c7c47873..0191da9ac4 100644 --- a/driver/charger/bq24773.h +++ b/driver/charger/bq24773.h @@ -12,8 +12,8 @@ #include "i2c.h" /* I2C address */ -#define BQ24770_ADDR (0x12) -#define BQ24773_ADDR (0x6a << 1) +#define BQ24770_ADDR__7bf 0x09 +#define BQ24773_ADDR__7bf 0x6a /* Chip specific commands */ #define BQ24770_CHARGE_OPTION0 0x12 @@ -72,7 +72,7 @@ #ifdef CONFIG_CHARGER_BQ24770 #define CHARGER_NAME "bq24770" - #define I2C_ADDR_CHARGER BQ24770_ADDR + #define I2C_ADDR_CHARGER__7bf BQ24770_ADDR__7bf #define REG_CHARGE_OPTION0 BQ24770_CHARGE_OPTION0 #define REG_CHARGE_OPTION1 BQ24770_CHARGE_OPTION1 @@ -88,7 +88,7 @@ #elif defined(CONFIG_CHARGER_BQ24773) #define CHARGER_NAME "bq24773" - #define I2C_ADDR_CHARGER BQ24773_ADDR + #define I2C_ADDR_CHARGER__7bf BQ24773_ADDR__7bf #define REG_CHARGE_OPTION0 BQ24773_CHARGE_OPTION0 #define REG_CHARGE_OPTION1 BQ24773_CHARGE_OPTION1 @@ -105,23 +105,27 @@ #ifdef CONFIG_CHARGER_BQ24773 static inline int raw_read8(int offset, int *value) { - return i2c_read8(I2C_PORT_CHARGER, I2C_ADDR_CHARGER, offset, value); + return i2c_read8__7bf(I2C_PORT_CHARGER, I2C_ADDR_CHARGER__7bf, + offset, value); } static inline int raw_write8(int offset, int value) { - return i2c_write8(I2C_PORT_CHARGER, I2C_ADDR_CHARGER, offset, value); + return i2c_write8__7bf(I2C_PORT_CHARGER, I2C_ADDR_CHARGER__7bf, + offset, value); } #endif static inline int raw_read16(int offset, int *value) { - return i2c_read16(I2C_PORT_CHARGER, I2C_ADDR_CHARGER, offset, value); + return i2c_read16__7bf(I2C_PORT_CHARGER, I2C_ADDR_CHARGER__7bf, + offset, value); } static inline int raw_write16(int offset, int value) { - return i2c_write16(I2C_PORT_CHARGER, I2C_ADDR_CHARGER, offset, value); + return i2c_write16__7bf(I2C_PORT_CHARGER, I2C_ADDR_CHARGER__7bf, + offset, value); } #endif /* __CROS_EC_BQ24773_H */ diff --git a/driver/charger/bq25703.h b/driver/charger/bq25703.h index 54d64a81c7..c568285e5c 100644 --- a/driver/charger/bq25703.h +++ b/driver/charger/bq25703.h @@ -9,7 +9,7 @@ #define __CROS_EC_BQ25703_H /* I2C Interface */ -#define BQ25703_I2C_ADDR1 0xD6 +#define BQ25703_I2C_ADDR1__7bf 0x6B /* * BC1.2 minimum voltage threshold for BQ25703. diff --git a/driver/charger/bq25710.c b/driver/charger/bq25710.c index 5700a0325b..3f9f03b805 100644 --- a/driver/charger/bq25710.c +++ b/driver/charger/bq25710.c @@ -62,13 +62,14 @@ static const struct charger_info bq25710_charger_info = { static inline int raw_read16(int offset, int *value) { - return i2c_read16(I2C_PORT_CHARGER, BQ25710_SMBUS_ADDR1, offset, value); + return i2c_read16__7bf(I2C_PORT_CHARGER, BQ25710_SMBUS_ADDR1__7bf, + offset, value); } static inline int raw_write16(int offset, int value) { - return i2c_write16(I2C_PORT_CHARGER, BQ25710_SMBUS_ADDR1, offset, - value); + return i2c_write16__7bf(I2C_PORT_CHARGER, BQ25710_SMBUS_ADDR1__7bf, + offset, value); } #if defined(CONFIG_CHARGE_RAMP_HW) || \ diff --git a/driver/charger/bq25710.h b/driver/charger/bq25710.h index 448e24bad0..a4861e50ca 100644 --- a/driver/charger/bq25710.h +++ b/driver/charger/bq25710.h @@ -9,7 +9,7 @@ #define __CROS_EC_BQ25710_H /* SMBUS Interface */ -#define BQ25710_SMBUS_ADDR1 0x12 +#define BQ25710_SMBUS_ADDR1__7bf 0x09 #define BQ25710_BC12_MIN_VOLTAGE_MV 1408 diff --git a/driver/charger/bq2589x.h b/driver/charger/bq2589x.h index c13d34ec7d..38dd944dd4 100644 --- a/driver/charger/bq2589x.h +++ b/driver/charger/bq2589x.h @@ -99,13 +99,13 @@ /* Variant-specific configuration */ #if defined(CONFIG_CHARGER_BQ25890) #define BQ2589X_DEVICE_ID BQ25890_DEVICE_ID -#define BQ2589X_ADDR (0x6A << 1) +#define BQ2589X_ADDR__7bf (0x6A) #elif defined(CONFIG_CHARGER_BQ25895) #define BQ2589X_DEVICE_ID BQ25895_DEVICE_ID -#define BQ2589X_ADDR (0x6A << 1) +#define BQ2589X_ADDR__7bf (0x6A) #elif defined(CONFIG_CHARGER_BQ25892) #define BQ2589X_DEVICE_ID BQ25892_DEVICE_ID -#define BQ2589X_ADDR (0x6B << 1) +#define BQ2589X_ADDR__7bf (0x6B) #else #error BQ2589X unknown variant #endif diff --git a/driver/charger/isl923x.c b/driver/charger/isl923x.c index 80385bebcd..a2d6e08977 100644 --- a/driver/charger/isl923x.c +++ b/driver/charger/isl923x.c @@ -56,17 +56,20 @@ static const struct charger_info isl9237_charger_info = { static inline int raw_read8(int offset, int *value) { - return i2c_read8(I2C_PORT_CHARGER, I2C_ADDR_CHARGER, offset, value); + return i2c_read8__7bf(I2C_PORT_CHARGER, I2C_ADDR_CHARGER__7bf, + offset, value); } static inline int raw_read16(int offset, int *value) { - return i2c_read16(I2C_PORT_CHARGER, I2C_ADDR_CHARGER, offset, value); + return i2c_read16__7bf(I2C_PORT_CHARGER, I2C_ADDR_CHARGER__7bf, + offset, value); } static inline int raw_write16(int offset, int value) { - return i2c_write16(I2C_PORT_CHARGER, I2C_ADDR_CHARGER, offset, value); + return i2c_write16__7bf(I2C_PORT_CHARGER, I2C_ADDR_CHARGER__7bf, + offset, value); } static int isl9237_set_current(uint16_t current) @@ -572,8 +575,8 @@ static int print_amon_bmon(enum amon_bmon amon, int direction, int adc, curr, reg, ret; #ifdef CONFIG_CHARGER_ISL9238 - ret = i2c_read16(I2C_PORT_CHARGER, I2C_ADDR_CHARGER, - ISL9238_REG_CONTROL3, ®); + ret = i2c_read16__7bf(I2C_PORT_CHARGER, I2C_ADDR_CHARGER__7bf, + ISL9238_REG_CONTROL3, ®); if (ret) return ret; @@ -582,15 +585,15 @@ static int print_amon_bmon(enum amon_bmon amon, int direction, reg |= ISL9238_C3_AMON_BMON_DIRECTION; else reg &= ~ISL9238_C3_AMON_BMON_DIRECTION; - ret = i2c_write16(I2C_PORT_CHARGER, I2C_ADDR_CHARGER, - ISL9238_REG_CONTROL3, reg); + ret = i2c_write16__7bf(I2C_PORT_CHARGER, I2C_ADDR_CHARGER__7bf, + ISL9238_REG_CONTROL3, reg); if (ret) return ret; #endif mutex_lock(&control1_mutex); - ret = i2c_read16(I2C_PORT_CHARGER, I2C_ADDR_CHARGER, + ret = i2c_read16__7bf(I2C_PORT_CHARGER, I2C_ADDR_CHARGER__7bf, ISL923X_REG_CONTROL1, ®); if (!ret) { /* Switch between AMON/BMON */ @@ -601,8 +604,8 @@ static int print_amon_bmon(enum amon_bmon amon, int direction, /* Enable monitor */ reg &= ~ISL923X_C1_DISABLE_MON; - ret = i2c_write16(I2C_PORT_CHARGER, I2C_ADDR_CHARGER, - ISL923X_REG_CONTROL1, reg); + ret = i2c_write16__7bf(I2C_PORT_CHARGER, I2C_ADDR_CHARGER__7bf, + ISL923X_REG_CONTROL1, reg); } mutex_unlock(&control1_mutex); @@ -686,8 +689,8 @@ static void dump_reg_range(int low, int high) for (reg = low; reg <= high; reg++) { CPRINTF("[%Xh] = ", reg); - rv = i2c_read16(I2C_PORT_CHARGER, I2C_ADDR_CHARGER, reg, - ®val); + rv = i2c_read16__7bf(I2C_PORT_CHARGER, I2C_ADDR_CHARGER__7bf, + reg, ®val); if (!rv) CPRINTF("0x%04x\n", regval); else diff --git a/driver/charger/isl923x.h b/driver/charger/isl923x.h index 4623b679b7..09a627d251 100644 --- a/driver/charger/isl923x.h +++ b/driver/charger/isl923x.h @@ -8,7 +8,7 @@ #ifndef __CROS_EC_ISL923X_H #define __CROS_EC_ISL923X_H -#define ISL923X_ADDR 0x12 /* 7bit address 0001001 */ +#define ISL923X_ADDR__7bf (0x09) /* Registers */ #define ISL923X_REG_CHG_CURRENT 0x14 @@ -304,7 +304,7 @@ enum isl9237_fsm_state { #define INPUT_I_MIN 4 #define INPUT_I_STEP 4 -#define I2C_ADDR_CHARGER ISL923X_ADDR +#define I2C_ADDR_CHARGER__7bf ISL923X_ADDR__7bf #endif /* __CROS_EC_ISL923X_H */ /** diff --git a/driver/charger/isl9241.h b/driver/charger/isl9241.h index f2d4f1493d..e145abc610 100644 --- a/driver/charger/isl9241.h +++ b/driver/charger/isl9241.h @@ -8,8 +8,8 @@ #ifndef __CROS_EC_ISL9241_H #define __CROS_EC_ISL9241_H -#define ISL9241_ADDR 0x12 /* 7bit address 0001001 */ -#define I2C_ADDR_CHARGER ISL9241_ADDR +#define ISL9241_ADDR__7bf 0x09 +#define I2C_ADDR_CHARGER__7bf ISL9241_ADDR__7bf #define CHARGER_NAME "ISL9241" #define CHARGE_V_MAX 18304 diff --git a/driver/charger/rt946x.c b/driver/charger/rt946x.c index 2915ba5155..4b7b9d13c6 100644 --- a/driver/charger/rt946x.c +++ b/driver/charger/rt946x.c @@ -145,17 +145,18 @@ static const uint16_t rt946x_boost_current[] = { static int rt946x_read8(int reg, int *val) { - return i2c_read8(I2C_PORT_CHARGER, RT946X_ADDR, reg, val); + return i2c_read8__7bf(I2C_PORT_CHARGER, RT946X_ADDR__7bf, reg, val); } static int rt946x_write8(int reg, int val) { - return i2c_write8(I2C_PORT_CHARGER, RT946X_ADDR, reg, val); + return i2c_write8__7bf(I2C_PORT_CHARGER, RT946X_ADDR__7bf, reg, val); } static int rt946x_block_write(int reg, const uint8_t *val, int len) { - return i2c_write_block(I2C_PORT_CHARGER, RT946X_ADDR, reg, val, len); + return i2c_write_block__7bf(I2C_PORT_CHARGER, RT946X_ADDR__7bf, + reg, val, len); } static int rt946x_update_bits(int reg, int mask, int val) diff --git a/driver/charger/rt946x.h b/driver/charger/rt946x.h index d9ec30a596..c5132702be 100644 --- a/driver/charger/rt946x.h +++ b/driver/charger/rt946x.h @@ -583,15 +583,15 @@ #if defined(CONFIG_CHARGER_RT9466) #define RT946X_CHARGER_NAME "rt9466" #define RT946X_VENDOR_ID 0x80 - #define RT946X_ADDR (0x53 << 1) + #define RT946X_ADDR__7bf 0x53 #elif defined(CONFIG_CHARGER_RT9467) #define RT946X_CHARGER_NAME "rt9467" #define RT946X_VENDOR_ID 0x90 - #define RT946X_ADDR (0x5B << 1) + #define RT946X_ADDR__7bf 0x5B #elif defined(CONFIG_CHARGER_MT6370) #define RT946X_CHARGER_NAME "mt6370" #define RT946X_VENDOR_ID 0xE0 - #define RT946X_ADDR (0x34 << 1) + #define RT946X_ADDR__7bf 0x34 #else #error "No suitable charger option defined" #endif diff --git a/driver/charger/sy21612.c b/driver/charger/sy21612.c index 378c8891a3..0ec3a570e3 100644 --- a/driver/charger/sy21612.c +++ b/driver/charger/sy21612.c @@ -22,7 +22,7 @@ static int sy21612_clear_set_reg(int reg, int clear, int set) { int val, old_val, rv; - rv = i2c_read8(I2C_PORT_SY21612, SY21612_ADDR, reg, &old_val); + rv = i2c_read8__7bf(I2C_PORT_SY21612, SY21612_ADDR__7bf, reg, &old_val); if (rv) return rv; @@ -31,14 +31,15 @@ static int sy21612_clear_set_reg(int reg, int clear, int set) val |= set; if (val != old_val || clear || set) - rv = i2c_write8(I2C_PORT_SY21612, SY21612_ADDR, reg, val); + rv = i2c_write8__7bf(I2C_PORT_SY21612, SY21612_ADDR__7bf, + reg, val); return rv; } static int sy21612_read(int reg, int *val) { - return i2c_read8(I2C_PORT_SY21612, SY21612_ADDR, reg, val); + return i2c_read8__7bf(I2C_PORT_SY21612, SY21612_ADDR__7bf, reg, val); } int sy21612_enable_regulator(int enable) diff --git a/driver/charger/sy21612.h b/driver/charger/sy21612.h index d685406fcf..8b72966223 100644 --- a/driver/charger/sy21612.h +++ b/driver/charger/sy21612.h @@ -10,8 +10,8 @@ #include "gpio.h" -#ifndef SY21612_ADDR -#define SY21612_ADDR 0xe2 /* 7bit address 1110_010 */ +#ifndef SY21612_ADDR__7bf +#define SY21612_ADDR__7bf 0x71 #endif enum sy21612_switching_freq { |