summaryrefslogtreecommitdiff
path: root/common/lb_common.c
diff options
context:
space:
mode:
authorDenis Brockus <dbrockus@chromium.org>2019-06-25 12:44:16 -0600
committerCommit Bot <commit-bot@chromium.org>2019-07-19 21:11:02 +0000
commitd1a18f82ed831d4e640336ff5571f5fa64bc7b36 (patch)
treec46aeb6136de1c27c66e3d5f662e9620161bef7b /common/lb_common.c
parent1f14229fa7e499dfcee07d17add187598ff0a46c (diff)
downloadchrome-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 'common/lb_common.c')
-rw-r--r--common/lb_common.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/common/lb_common.c b/common/lb_common.c
index 208015482c..1e37245558 100644
--- a/common/lb_common.c
+++ b/common/lb_common.c
@@ -111,7 +111,7 @@
/* Since there's absolutely nothing we can do about it if an I2C access
* isn't working, we're completely ignoring any failures. */
-static const uint8_t i2c_addr[] = { 0x54, 0x56 };
+static const uint16_t i2c_addr__7bf[] = { 0x2A, 0x2B };
static inline void controller_write(int ctrl_num, uint8_t reg, uint8_t val)
{
@@ -119,9 +119,10 @@ static inline void controller_write(int ctrl_num, uint8_t reg, uint8_t val)
buf[0] = reg;
buf[1] = val;
- ctrl_num = ctrl_num % ARRAY_SIZE(i2c_addr);
- i2c_xfer_unlocked(I2C_PORT_LIGHTBAR, i2c_addr[ctrl_num], buf, 2, 0, 0,
- I2C_XFER_SINGLE);
+ ctrl_num = ctrl_num % ARRAY_SIZE(i2c_addr__7bf);
+ i2c_xfer_unlocked__7bf(I2C_PORT_LIGHTBAR, i2c_addr__7bf[ctrl_num],
+ buf, 2, 0, 0,
+ I2C_XFER_SINGLE);
}
static inline uint8_t controller_read(int ctrl_num, uint8_t reg)
@@ -129,8 +130,8 @@ static inline uint8_t controller_read(int ctrl_num, uint8_t reg)
uint8_t buf[1];
int rv;
- ctrl_num = ctrl_num % ARRAY_SIZE(i2c_addr);
- rv = i2c_xfer_unlocked(I2C_PORT_LIGHTBAR, i2c_addr[ctrl_num],
+ ctrl_num = ctrl_num % ARRAY_SIZE(i2c_addr__7bf);
+ rv = i2c_xfer_unlocked__7bf(I2C_PORT_LIGHTBAR, i2c_addr__7bf[ctrl_num],
&reg, 1, buf, 1, I2C_XFER_SINGLE);
return rv ? 0 : buf[0];
}