summaryrefslogtreecommitdiff
path: root/chip/g
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 /chip/g
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 'chip/g')
-rw-r--r--chip/g/i2cm.c23
1 files changed, 10 insertions, 13 deletions
diff --git a/chip/g/i2cm.c b/chip/g/i2cm.c
index b1a3135723..a7b8f9ad7e 100644
--- a/chip/g/i2cm.c
+++ b/chip/g/i2cm.c
@@ -247,7 +247,7 @@ static int i2cm_poll_for_complete(int port)
return EC_ERROR_TIMEOUT;
}
-static uint32_t i2cm_create_inst(int slave_addr, int is_write,
+static uint32_t i2cm_create_inst__7bf(int slave_addr__7bf, int is_write,
size_t size, uint32_t flags)
{
uint32_t inst = 0;
@@ -258,12 +258,7 @@ static uint32_t i2cm_create_inst(int slave_addr, int is_write,
* to be included.
*/
inst |= INST_START;
-
- /*
- * Calls to chip_i2c_xfer assume an 8 bit slave address. Need
- * to shift right by 1 bit.
- */
- inst |= INST_DEVADDRVAL(slave_addr >> 1);
+ inst |= INST_DEVADDRVAL(I2C_GET_ADDR__7b(slave_addr__7bf));
inst |= INST_RWDEVADDR;
}
@@ -281,8 +276,9 @@ static uint32_t i2cm_create_inst(int slave_addr, int is_write,
return inst;
}
-static int i2cm_execute_sequence(int port, int slave_addr, const uint8_t *out,
- int out_size, uint8_t *in, int in_size,
+static int i2cm_execute_sequence__7bf(int port, int slave_addr__7bf,
+ const uint8_t *out, int out_size,
+ uint8_t *in, int in_size,
int flags)
{
int rv;
@@ -313,7 +309,7 @@ static int i2cm_execute_sequence(int port, int slave_addr, const uint8_t *out,
seq_flags &= ~I2C_XFER_STOP;
/* Build sequence instruction */
- inst = i2cm_create_inst(slave_addr, is_write,
+ inst = i2cm_create_inst__7bf(slave_addr__7bf, is_write,
batch_size, seq_flags);
/* If this is a write - copy data into the FIFO. */
@@ -357,7 +353,8 @@ static int i2cm_execute_sequence(int port, int slave_addr, const uint8_t *out,
/* Perform an i2c transaction. */
-int chip_i2c_xfer(int port, int slave_addr, const uint8_t *out, int out_size,
+int chip_i2c_xfer__7bf(const int port, const uint16_t slave_addr__7bf,
+ const uint8_t *out, int out_size,
uint8_t *in, int in_size, int flags)
{
int rv;
@@ -379,14 +376,14 @@ int chip_i2c_xfer(int port, int slave_addr, const uint8_t *out, int out_size,
if (out_size) {
/* Process write before read. */
- rv = i2cm_execute_sequence(port, slave_addr, out,
+ rv = i2cm_execute_sequence__7bf(port, slave_addr__7bf, out,
out_size, NULL, 0, flags);
if (rv != EC_SUCCESS)
return rv;
}
if (in_size)
- rv = i2cm_execute_sequence(port, slave_addr,
+ rv = i2cm_execute_sequence__7bf(port, slave_addr__7bf,
NULL, 0, in, in_size, flags);
return rv;