diff options
author | Sam Hurst <shurst@google.com> | 2021-10-22 18:44:53 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-10-27 04:01:02 +0000 |
commit | 25bc0d1cc657960ee6a92cebdecd7439ba5744d5 (patch) | |
tree | 20fcc48877606b385149b899af24c16569b502d6 | |
parent | 46d74f2eec23825ca2e22e924548aed1e4858ecc (diff) | |
download | chrome-ec-25bc0d1cc657960ee6a92cebdecd7439ba5744d5.tar.gz |
SERVO_V4P1: Use IO-Expander driver specific flags
The TCA64XXA driver controls both the tca6416a and
tca6424a io-expanders, so the IO-Expander driver
specific flags are used to distinguish between the
two.
BUG=b:203907721
BRANCH=none
TEST=ServoV4p1 flags are not clobbered and IO-Expanders are working
Signed-off-by: Sam Hurst <shurst@google.org>
Change-Id: I89335845f035aa18d39762cda8ede732e99df3ee
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3239015
Tested-by: Sam Hurst <shurst@google.com>
Commit-Queue: caveh jalali <caveh@chromium.org>
Reviewed-by: Keith Short <keithshort@chromium.org>
-rw-r--r-- | board/servo_v4p1/board.c | 4 | ||||
-rw-r--r-- | driver/ioexpander/tca64xxa.c | 10 | ||||
-rw-r--r-- | driver/ioexpander/tca64xxa.h | 7 |
3 files changed, 13 insertions, 8 deletions
diff --git a/board/servo_v4p1/board.c b/board/servo_v4p1/board.c index d8616ce340..d9d48a42ce 100644 --- a/board/servo_v4p1/board.c +++ b/board/servo_v4p1/board.c @@ -525,13 +525,13 @@ struct ioexpander_config_t ioex_config[] = { .drv = &tca64xxa_ioexpander_drv, .i2c_host_port = TCA6416A_PORT, .i2c_addr_flags = TCA6416A_ADDR, - .flags = TCA64XXA_FLAG_VER_TCA6416A + .flags = IOEX_FLAGS_TCA64XXA_FLAG_VER_TCA6416A }, [1] = { .drv = &tca64xxa_ioexpander_drv, .i2c_host_port = TCA6424A_PORT, .i2c_addr_flags = TCA6424A_ADDR, - .flags = TCA64XXA_FLAG_VER_TCA6424A + .flags = IOEX_FLAGS_TCA64XXA_FLAG_VER_TCA6424A } }; diff --git a/driver/ioexpander/tca64xxa.c b/driver/ioexpander/tca64xxa.c index 9a70ceec11..5bbaf92521 100644 --- a/driver/ioexpander/tca64xxa.c +++ b/driver/ioexpander/tca64xxa.c @@ -25,7 +25,8 @@ static int tca64xxa_write_byte(int ioex, int port, int reg, uint8_t val) { const struct ioexpander_config_t *ioex_p = &ioex_config[ioex]; - const int reg_addr = TCA64XXA_PORT_ID(port, reg, ioex_p->flags); + const int reg_addr = TCA64XXA_PORT_ID(port, reg, + (ioex_p->flags & IOEX_FLAGS_TCA64XXA_FLAG_VER_TCA6416A) ? 2:4); return i2c_write8(ioex_p->i2c_host_port, ioex_p->i2c_addr_flags, @@ -36,7 +37,8 @@ static int tca64xxa_write_byte(int ioex, int port, int reg, uint8_t val) static int tca64xxa_read_byte(int ioex, int port, int reg, int *val) { const struct ioexpander_config_t *ioex_p = &ioex_config[ioex]; - const int reg_addr = TCA64XXA_PORT_ID(port, reg, ioex_p->flags); + const int reg_addr = TCA64XXA_PORT_ID(port, reg, + (ioex_p->flags & IOEX_FLAGS_TCA64XXA_FLAG_VER_TCA6416A) ? 2:4); return i2c_read8(ioex_p->i2c_host_port, ioex_p->i2c_addr_flags, @@ -87,9 +89,9 @@ static int tca64xxa_init(int ioex) const struct ioexpander_config_t *ioex_p = &ioex_config[ioex]; int portsCount; - if (ioex_p->flags & TCA64XXA_FLAG_VER_TCA6416A) + if (ioex_p->flags & IOEX_FLAGS_TCA64XXA_FLAG_VER_TCA6416A) portsCount = 2; - else if (ioex_p->flags & TCA64XXA_FLAG_VER_TCA6424A) + else if (ioex_p->flags & IOEX_FLAGS_TCA64XXA_FLAG_VER_TCA6424A) portsCount = 3; else return EC_ERROR_UNIMPLEMENTED; diff --git a/driver/ioexpander/tca64xxa.h b/driver/ioexpander/tca64xxa.h index 8c3448f804..2d2e6e36bc 100644 --- a/driver/ioexpander/tca64xxa.h +++ b/driver/ioexpander/tca64xxa.h @@ -6,8 +6,11 @@ #ifndef __CROS_EC_DRIVER_IOEXPANDER_TCA64XXA_H_ #define __CROS_EC_DRIVER_IOEXPANDER_TCA64XXA_H_ -#define TCA64XXA_FLAG_VER_TCA6416A 2 -#define TCA64XXA_FLAG_VER_TCA6424A 4 +/* io-expander driver specific flag bit for tca6416a */ +#define IOEX_FLAGS_TCA64XXA_FLAG_VER_TCA6416A IOEX_FLAGS_CUSTOM_BIT(24) +/* io-expander driver specific flag bit for tca6424a */ +#define IOEX_FLAGS_TCA64XXA_FLAG_VER_TCA6424A IOEX_FLAGS_CUSTOM_BIT(25) + #define TCA64XXA_FLAG_VER_MASK GENMASK(2, 1) #define TCA64XXA_FLAG_VER_OFFSET 0 |