summaryrefslogtreecommitdiff
path: root/board/samus
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 /board/samus
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 'board/samus')
-rw-r--r--board/samus/battery.c8
-rw-r--r--board/samus/board.c56
-rw-r--r--board/samus/extpower.c4
-rw-r--r--board/samus/panel.c10
4 files changed, 43 insertions, 35 deletions
diff --git a/board/samus/battery.c b/board/samus/battery.c
index dcbd4f0964..e21f51e3b5 100644
--- a/board/samus/battery.c
+++ b/board/samus/battery.c
@@ -290,10 +290,10 @@ int board_cut_off_battery(void)
buf[2] = PARAM_CUT_OFF_HIGH;
i2c_lock(I2C_PORT_BATTERY, 1);
- rv = i2c_xfer_unlocked(I2C_PORT_BATTERY, BATTERY_ADDR, buf, 3, NULL, 0,
- I2C_XFER_SINGLE);
- rv |= i2c_xfer_unlocked(I2C_PORT_BATTERY, BATTERY_ADDR, buf, 3, NULL, 0,
- I2C_XFER_SINGLE);
+ rv = i2c_xfer_unlocked__7bf(I2C_PORT_BATTERY, BATTERY_ADDR__7bf,
+ buf, 3, NULL, 0, I2C_XFER_SINGLE);
+ rv |= i2c_xfer_unlocked__7bf(I2C_PORT_BATTERY, BATTERY_ADDR__7bf,
+ buf, 3, NULL, 0, I2C_XFER_SINGLE);
i2c_lock(I2C_PORT_BATTERY, 0);
return rv;
diff --git a/board/samus/board.c b/board/samus/board.c
index 2804799994..323789a7a3 100644
--- a/board/samus/board.c
+++ b/board/samus/board.c
@@ -132,29 +132,35 @@ const struct i2c_port_t i2c_ports[] = {
};
const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports);
-#define TEMP_U40_REG_ADDR ((0x40 << 1) | I2C_FLAG_BIG_ENDIAN)
-#define TEMP_U41_REG_ADDR ((0x44 << 1) | I2C_FLAG_BIG_ENDIAN)
-#define TEMP_U42_REG_ADDR ((0x41 << 1) | I2C_FLAG_BIG_ENDIAN)
-#define TEMP_U43_REG_ADDR ((0x45 << 1) | I2C_FLAG_BIG_ENDIAN)
-#define TEMP_U115_REG_ADDR ((0x42 << 1) | I2C_FLAG_BIG_ENDIAN)
-#define TEMP_U116_REG_ADDR ((0x43 << 1) | I2C_FLAG_BIG_ENDIAN)
-
-#define TEMP_U40_ADDR TMP006_ADDR(I2C_PORT_THERMAL, TEMP_U40_REG_ADDR)
-#define TEMP_U41_ADDR TMP006_ADDR(I2C_PORT_THERMAL, TEMP_U41_REG_ADDR)
-#define TEMP_U42_ADDR TMP006_ADDR(I2C_PORT_THERMAL, TEMP_U42_REG_ADDR)
-#define TEMP_U43_ADDR TMP006_ADDR(I2C_PORT_THERMAL, TEMP_U43_REG_ADDR)
-#define TEMP_U115_ADDR TMP006_ADDR(I2C_PORT_THERMAL, TEMP_U115_REG_ADDR)
-#define TEMP_U116_ADDR TMP006_ADDR(I2C_PORT_THERMAL, TEMP_U116_REG_ADDR)
-
-const struct tmp006_t tmp006_sensors[TMP006_COUNT] = {
- {"Charger", TEMP_U40_ADDR},
- {"CPU", TEMP_U41_ADDR},
- {"Left C", TEMP_U42_ADDR},
- {"Right C", TEMP_U43_ADDR},
- {"Right D", TEMP_U115_ADDR},
- {"Left D", TEMP_U116_ADDR},
+#define TEMP_U40_REG_ADDR__7bf (0x40 | I2C_FLAG_BIG_ENDIAN)
+#define TEMP_U41_REG_ADDR__7bf (0x44 | I2C_FLAG_BIG_ENDIAN)
+#define TEMP_U42_REG_ADDR__7bf (0x41 | I2C_FLAG_BIG_ENDIAN)
+#define TEMP_U43_REG_ADDR__7bf (0x45 | I2C_FLAG_BIG_ENDIAN)
+#define TEMP_U115_REG_ADDR__7bf (0x42 | I2C_FLAG_BIG_ENDIAN)
+#define TEMP_U116_REG_ADDR__7bf (0x43 | I2C_FLAG_BIG_ENDIAN)
+
+#define TEMP_U40_ADDR__7bf TMP006_ADDR__7bf(I2C_PORT_THERMAL,\
+ TEMP_U40_REG_ADDR__7bf)
+#define TEMP_U41_ADDR__7bf TMP006_ADDR__7bf(I2C_PORT_THERMAL,\
+ TEMP_U41_REG_ADDR__7bf)
+#define TEMP_U42_ADDR__7bf TMP006_ADDR__7bf(I2C_PORT_THERMAL,\
+ TEMP_U42_REG_ADDR__7bf)
+#define TEMP_U43_ADDR__7bf TMP006_ADDR__7bf(I2C_PORT_THERMAL,\
+ TEMP_U43_REG_ADDR__7bf)
+#define TEMP_U115_ADDR__7bf TMP006_ADDR__7bf(I2C_PORT_THERMAL,\
+ TEMP_U115_REG_ADDR__7bf)
+#define TEMP_U116_ADDR__7bf TMP006_ADDR__7bf(I2C_PORT_THERMAL,\
+ TEMP_U116_REG_ADDR__7bf)
+
+const struct tmp006_t tmp006_sensors__7bf[TMP006_COUNT] = {
+ {"Charger", TEMP_U40_ADDR__7bf},
+ {"CPU", TEMP_U41_ADDR__7bf},
+ {"Left C", TEMP_U42_ADDR__7bf},
+ {"Right C", TEMP_U43_ADDR__7bf},
+ {"Right D", TEMP_U115_ADDR__7bf},
+ {"Left D", TEMP_U116_ADDR__7bf},
};
-BUILD_ASSERT(ARRAY_SIZE(tmp006_sensors) == TMP006_COUNT);
+BUILD_ASSERT(ARRAY_SIZE(tmp006_sensors__7bf) == TMP006_COUNT);
/* Temperature sensors data; must be in same order as enum temp_sensor_id. */
const struct temp_sensor_t temp_sensors[] = {
@@ -326,7 +332,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_base_mutex,
.drv_data = &g_saved_data[0],
.port = I2C_PORT_ACCEL,
- .addr = LSM6DS0_ADDR1,
+ .i2c_spi_addr__7bf = LSM6DS0_ADDR1__7bf,
.rot_standard_ref = &base_standard_ref,
.default_range = 2, /* g, enough for laptop. */
.min_frequency = LSM6DS0_ACCEL_MIN_FREQ,
@@ -358,7 +364,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_lid_mutex,
.drv_data = &g_kxcj9_data,
.port = I2C_PORT_ACCEL,
- .addr = KXCJ9_ADDR0,
+ .i2c_spi_addr__7bf = KXCJ9_ADDR0__7bf,
.rot_standard_ref = &lid_standard_ref,
.default_range = 2, /* g, enough for laptop. */
.min_frequency = KXCJ9_ACCEL_MIN_FREQ,
@@ -381,7 +387,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_base_mutex,
.drv_data = &g_saved_data[1],
.port = I2C_PORT_ACCEL,
- .addr = LSM6DS0_ADDR1,
+ .i2c_spi_addr__7bf = LSM6DS0_ADDR1__7bf,
.rot_standard_ref = NULL,
.default_range = 2000, /* g, enough for laptop. */
.min_frequency = LSM6DS0_GYRO_MIN_FREQ,
diff --git a/board/samus/extpower.c b/board/samus/extpower.c
index 9307463cbf..cddb4a76e1 100644
--- a/board/samus/extpower.c
+++ b/board/samus/extpower.c
@@ -159,7 +159,7 @@ static void allow_max_request(void)
int prochot_status;
if (charge_circuit_state == CHARGE_CIRCUIT_WEDGED) {
/* Read PROCHOT status register to clear it */
- i2c_read8(I2C_PORT_CHARGER, BQ24773_ADDR,
+ i2c_read8__7bf(I2C_PORT_CHARGER, BQ24773_ADDR__7bf,
BQ24773_PROCHOT_STATUS, &prochot_status);
charge_circuit_state = CHARGE_CIRCUIT_OK;
}
@@ -301,7 +301,7 @@ static void check_charge_wedged(void)
if (charge_circuit_state == CHARGE_CIRCUIT_OK) {
/* Check PROCHOT warning */
- rv = i2c_read8(I2C_PORT_CHARGER, BQ24773_ADDR,
+ rv = i2c_read8__7bf(I2C_PORT_CHARGER, BQ24773_ADDR__7bf,
BQ24773_PROCHOT_STATUS, &prochot_status);
if (rv)
prochot_status = 0;
diff --git a/board/samus/panel.c b/board/samus/panel.c
index ccb43f1fcb..0c60b2a492 100644
--- a/board/samus/panel.c
+++ b/board/samus/panel.c
@@ -15,7 +15,7 @@
#define CPRINTS(format, args...) cprints(CC_I2C, format, ## args)
-#define I2C_ADDR_BACKLIGHT ((0x2C << 1) | I2C_FLAG_BIG_ENDIAN)
+#define I2C_ADDR_BACKLIGHT__7bf (0x2C | I2C_FLAG_BIG_ENDIAN)
#define I2C_RETRIES 3
#define I2C_RETRY_DELAY (5*MSEC)
@@ -61,7 +61,8 @@ static int lp8555_read_with_retry(int reg, int *data)
int i, rv;
for (i = 0; i < I2C_RETRIES; i++) {
- rv = i2c_read8(I2C_PORT_BACKLIGHT, I2C_ADDR_BACKLIGHT,
+ rv = i2c_read8__7bf(I2C_PORT_BACKLIGHT,
+ I2C_ADDR_BACKLIGHT__7bf,
reg, data);
if (rv == EC_SUCCESS)
return EC_SUCCESS;
@@ -78,8 +79,9 @@ static int lp8555_write_with_retry(int reg, int data)
int i, rv;
for (i = 0; i < I2C_RETRIES; i++) {
- rv = i2c_write8(I2C_PORT_BACKLIGHT, I2C_ADDR_BACKLIGHT,
- reg, data);
+ rv = i2c_write8__7bf(I2C_PORT_BACKLIGHT,
+ I2C_ADDR_BACKLIGHT__7bf,
+ reg, data);
if (rv == EC_SUCCESS)
return EC_SUCCESS;
usleep(I2C_RETRY_DELAY);