summaryrefslogtreecommitdiff
path: root/driver
diff options
context:
space:
mode:
Diffstat (limited to 'driver')
-rw-r--r--driver/accel_bma2x2.c54
-rw-r--r--driver/accel_bma2x2.h8
-rw-r--r--driver/accel_kionix.c98
-rw-r--r--driver/accel_kionix.h3
-rw-r--r--driver/accel_kx022.h4
-rw-r--r--driver/accel_kxcj9.h4
-rw-r--r--driver/accel_lis2dh.c34
-rw-r--r--driver/accel_lis2dh.h8
-rw-r--r--driver/accelgyro_bmi160.c377
-rw-r--r--driver/accelgyro_bmi160.h16
-rw-r--r--driver/accelgyro_lsm6ds0.c47
-rw-r--r--driver/accelgyro_lsm6ds0.h4
-rw-r--r--driver/accelgyro_lsm6dsm.c82
-rw-r--r--driver/accelgyro_lsm6dsm.h6
-rw-r--r--driver/accelgyro_lsm6dso.c38
-rw-r--r--driver/accelgyro_lsm6dso.h6
-rw-r--r--driver/als_al3010.h6
-rw-r--r--driver/als_bh1730.c14
-rw-r--r--driver/als_bh1730.h2
-rw-r--r--driver/als_isl29035.c10
-rw-r--r--driver/als_opt3001.c46
-rw-r--r--driver/als_opt3001.h8
-rw-r--r--driver/als_si114x.c92
-rw-r--r--driver/als_si114x.h2
-rw-r--r--driver/als_tcs3400.c9
-rw-r--r--driver/als_tcs3400.h2
-rw-r--r--driver/baro_bmp280.c17
-rw-r--r--driver/baro_bmp280.h5
-rw-r--r--driver/battery/bq27541.c2
-rw-r--r--driver/battery/bq27621_g1.c2
-rw-r--r--driver/battery/max17055.c6
-rw-r--r--driver/battery/max17055.h2
-rw-r--r--driver/battery/mm8013.c5
-rw-r--r--driver/battery/mm8013.h2
-rw-r--r--driver/battery/smart.c17
-rw-r--r--driver/bc12/pi3usb9201.c8
-rw-r--r--driver/bc12/pi3usb9201.h12
-rw-r--r--driver/bc12/pi3usb9281.c10
-rw-r--r--driver/charger/bd9995x.c10
-rw-r--r--driver/charger/bd9995x.h4
-rw-r--r--driver/charger/bq24192.h2
-rw-r--r--driver/charger/bq24715.c6
-rw-r--r--driver/charger/bq24773.h20
-rw-r--r--driver/charger/bq25703.h2
-rw-r--r--driver/charger/bq25710.c7
-rw-r--r--driver/charger/bq25710.h2
-rw-r--r--driver/charger/bq2589x.h6
-rw-r--r--driver/charger/isl923x.c27
-rw-r--r--driver/charger/isl923x.h4
-rw-r--r--driver/charger/isl9241.h4
-rw-r--r--driver/charger/rt946x.c7
-rw-r--r--driver/charger/rt946x.h6
-rw-r--r--driver/charger/sy21612.c7
-rw-r--r--driver/charger/sy21612.h4
-rw-r--r--driver/gyro_l3gd20h.h4
-rw-r--r--driver/ina2xx.c12
-rw-r--r--driver/ioexpander_pca9534.c30
-rw-r--r--driver/ioexpander_pca9534.h9
-rw-r--r--driver/ioexpander_pca9555.h12
-rw-r--r--driver/led/lm3509.c6
-rw-r--r--driver/led/lm3509.h3
-rw-r--r--driver/led/lm3630a.c10
-rw-r--r--driver/led/lp5562.c4
-rw-r--r--driver/led/max695x.h4
-rw-r--r--driver/led/oz554.c5
-rw-r--r--driver/mag_bmm150.c49
-rw-r--r--driver/mag_bmm150.h8
-rw-r--r--driver/mag_lis2mdl.c30
-rw-r--r--driver/mag_lis2mdl.h2
-rw-r--r--driver/pmic_tps650x30.h6
-rw-r--r--driver/ppc/nx20p348x.c8
-rw-r--r--driver/ppc/nx20p348x.h18
-rw-r--r--driver/ppc/sn5s330.c92
-rw-r--r--driver/ppc/sn5s330.h10
-rw-r--r--driver/ppc/syv682x.c12
-rw-r--r--driver/ppc/syv682x.h10
-rw-r--r--driver/regulator_ir357x.c4
-rw-r--r--driver/sensorhub_lsm6dsm.c87
-rw-r--r--driver/sensorhub_lsm6dsm.h17
-rw-r--r--driver/stm_mems_common.c22
-rw-r--r--driver/stm_mems_common.h24
-rw-r--r--driver/tcpm/anx7447.c42
-rw-r--r--driver/tcpm/anx7447.h20
-rw-r--r--driver/tcpm/anx74xx.c4
-rw-r--r--driver/tcpm/anx74xx.h8
-rw-r--r--driver/tcpm/anx7688.c6
-rw-r--r--driver/tcpm/fusb302.h8
-rw-r--r--driver/tcpm/mt6370.c4
-rw-r--r--driver/tcpm/mt6370.h2
-rw-r--r--driver/tcpm/nct38xx.h18
-rw-r--r--driver/tcpm/ps8xxx.c4
-rw-r--r--driver/tcpm/ps8xxx.h8
-rw-r--r--driver/tcpm/tcpci.c36
-rw-r--r--driver/tcpm/tcpm.h46
-rw-r--r--driver/tcpm/tusb422.h2
-rw-r--r--driver/temp_sensor/adt7481.c6
-rw-r--r--driver/temp_sensor/adt7481.h2
-rw-r--r--driver/temp_sensor/bd99992gw.c6
-rw-r--r--driver/temp_sensor/bd99992gw.h2
-rw-r--r--driver/temp_sensor/f75303.c3
-rw-r--r--driver/temp_sensor/f75303.h2
-rw-r--r--driver/temp_sensor/g78x.c6
-rw-r--r--driver/temp_sensor/g78x.h2
-rw-r--r--driver/temp_sensor/sb_tsi.c3
-rw-r--r--driver/temp_sensor/sb_tsi.h2
-rw-r--r--driver/temp_sensor/tmp006.c32
-rw-r--r--driver/temp_sensor/tmp006.h10
-rw-r--r--driver/temp_sensor/tmp112.c6
-rw-r--r--driver/temp_sensor/tmp112.h2
-rw-r--r--driver/temp_sensor/tmp411.h2
-rw-r--r--driver/temp_sensor/tmp432.c6
-rw-r--r--driver/temp_sensor/tmp432.h2
-rw-r--r--driver/temp_sensor/tmp468.c6
-rw-r--r--driver/temp_sensor/tmp468.h2
-rw-r--r--driver/touchpad_elan.c23
-rw-r--r--driver/usb_mux/it5205.c4
-rw-r--r--driver/usb_mux/it5205.h4
-rw-r--r--driver/usb_mux/pi3usb30532.c8
-rw-r--r--driver/usb_mux/ps874x.c8
-rw-r--r--driver/wpc/p9221.c20
-rw-r--r--driver/wpc/p9221.h2
121 files changed, 1179 insertions, 884 deletions
diff --git a/driver/accel_bma2x2.c b/driver/accel_bma2x2.c
index c1e9eb4d63..5253783623 100644
--- a/driver/accel_bma2x2.c
+++ b/driver/accel_bma2x2.c
@@ -28,19 +28,19 @@
/**
* Read register from accelerometer.
*/
-static inline int raw_read8(const int port, const int addr, const int reg,
- int *data_ptr)
+static inline int raw_read8__7bf(const int port, const uint16_t i2c_addr__7bf,
+ const int reg, int *data_ptr)
{
- return i2c_read8(port, addr, reg, data_ptr);
+ return i2c_read8__7bf(port, i2c_addr__7bf, reg, data_ptr);
}
/**
* Write register from accelerometer.
*/
-static inline int raw_write8(const int port, const int addr, const int reg,
- int data)
+static inline int raw_write8__7bf(const int port, const uint16_t i2c_addr__7bf,
+ const int reg, int data)
{
- return i2c_write8(port, addr, reg, data);
+ return i2c_write8__7bf(port, i2c_addr__7bf, reg, data);
}
static int set_range(const struct motion_sensor_t *s, int range, int rnd)
@@ -55,14 +55,15 @@ static int set_range(const struct motion_sensor_t *s, int range, int rnd)
mutex_lock(s->mutex);
/* Determine the new value of control reg and attempt to write it. */
- ret = raw_read8(s->port, s->addr, BMA2x2_RANGE_SELECT_ADDR,
- &range_reg_val);
+ ret = raw_read8__7bf(s->port, s->i2c_spi_addr__7bf,
+ BMA2x2_RANGE_SELECT_ADDR, &range_reg_val);
if (ret != EC_SUCCESS) {
mutex_unlock(s->mutex);
return ret;
}
reg_val = (range_reg_val & ~BMA2x2_RANGE_SELECT_MSK) | range_val;
- ret = raw_write8(s->port, s->addr, BMA2x2_RANGE_SELECT_ADDR, reg_val);
+ ret = raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ BMA2x2_RANGE_SELECT_ADDR, reg_val);
/* If successfully written, then save the range. */
if (ret == EC_SUCCESS)
@@ -97,14 +98,16 @@ static int set_data_rate(const struct motion_sensor_t *s, int rate, int rnd)
mutex_lock(s->mutex);
/* Determine the new value of control reg and attempt to write it. */
- ret = raw_read8(s->port, s->addr, BMA2x2_BW_SELECT_ADDR, &odr_reg_val);
+ ret = raw_read8__7bf(s->port, s->i2c_spi_addr__7bf,
+ BMA2x2_BW_SELECT_ADDR, &odr_reg_val);
if (ret != EC_SUCCESS) {
mutex_unlock(s->mutex);
return ret;
}
reg_val = (odr_reg_val & ~BMA2x2_BW_MSK) | odr_val;
/* Set output data rate. */
- ret = raw_write8(s->port, s->addr, BMA2x2_BW_SELECT_ADDR, reg_val);
+ ret = raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ BMA2x2_BW_SELECT_ADDR, reg_val);
/* If successfully written, then save the new data rate. */
if (ret == EC_SUCCESS)
@@ -129,7 +132,7 @@ static int set_offset(const struct motion_sensor_t *s, const int16_t *offset,
/* temperature is ignored */
/* Offset from host is in 1/1024g, 1/128g internally. */
for (i = X; i <= Z; i++) {
- ret = raw_write8(s->port, s->addr,
+ ret = raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
BMA2x2_OFFSET_X_AXIS_ADDR + i, offset[i] / 8);
if (ret)
return ret;
@@ -143,8 +146,8 @@ static int get_offset(const struct motion_sensor_t *s, int16_t *offset,
int i, val, ret;
for (i = X; i <= Z; i++) {
- ret = raw_read8(s->port, s->addr, BMA2x2_OFFSET_X_AXIS_ADDR + i,
- &val);
+ ret = raw_read8__7bf(s->port, s->i2c_spi_addr__7bf,
+ BMA2x2_OFFSET_X_AXIS_ADDR + i, &val);
if (ret)
return ret;
offset[i] = (int8_t)val * 8;
@@ -160,7 +163,8 @@ static int read(const struct motion_sensor_t *s, intv3_t v)
/* Read 6 bytes starting at X_AXIS_LSB. */
mutex_lock(s->mutex);
- ret = i2c_read_block(s->port, s->addr, BMA2x2_X_AXIS_LSB_ADDR, acc, 6);
+ ret = i2c_read_block__7bf(s->port, s->i2c_spi_addr__7bf,
+ BMA2x2_X_AXIS_LSB_ADDR, acc, 6);
mutex_unlock(s->mutex);
if (ret != EC_SUCCESS)
@@ -189,7 +193,8 @@ static int perform_calib(const struct motion_sensor_t *s)
int ret, val, status, rate, range, i;
timestamp_t deadline;
- ret = raw_read8(s->port, s->addr, BMA2x2_OFFSET_CTRL_ADDR, &val);
+ ret = raw_read8__7bf(s->port, s->i2c_spi_addr__7bf,
+ BMA2x2_OFFSET_CTRL_ADDR, &val);
if (ret)
return ret;
if (!(val & BMA2x2_OFFSET_CAL_READY))
@@ -213,11 +218,13 @@ static int perform_calib(const struct motion_sensor_t *s)
val = ((BMA2x2_OFC_TARGET_0G << BMA2x2_OFC_TARGET_AXIS(X)) |
(BMA2x2_OFC_TARGET_0G << BMA2x2_OFC_TARGET_AXIS(Y)) |
(val << BMA2x2_OFC_TARGET_AXIS(Z)));
- raw_write8(s->port, s->addr, BMA2x2_OFC_SETTING_ADDR, val);
+ raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ BMA2x2_OFC_SETTING_ADDR, val);
for (i = X; i <= Z; i++) {
val = (i + 1) << BMA2x2_OFFSET_TRIGGER_OFF;
- raw_write8(s->port, s->addr, BMA2x2_OFFSET_CTRL_ADDR, val);
+ raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ BMA2x2_OFFSET_CTRL_ADDR, val);
/*
* The sensor needs 16 samples. At 100Hz/10ms, it needs 160ms to
* complete. Set 400ms to have some margin.
@@ -229,7 +236,7 @@ static int perform_calib(const struct motion_sensor_t *s)
goto end_perform_calib;
}
msleep(50);
- ret = raw_read8(s->port, s->addr,
+ ret = raw_read8__7bf(s->port, s->i2c_spi_addr__7bf,
BMA2x2_OFFSET_CTRL_ADDR, &status);
if (ret != EC_SUCCESS)
goto end_perform_calib;
@@ -246,7 +253,8 @@ static int init(const struct motion_sensor_t *s)
{
int ret = 0, tries = 0, val, reg, reset_field;
- ret = raw_read8(s->port, s->addr, BMA2x2_CHIP_ID_ADDR, &val);
+ ret = raw_read8__7bf(s->port, s->i2c_spi_addr__7bf,
+ BMA2x2_CHIP_ID_ADDR, &val);
if (ret)
return EC_ERROR_UNKNOWN;
@@ -259,13 +267,13 @@ static int init(const struct motion_sensor_t *s)
mutex_lock(s->mutex);
- ret = raw_read8(s->port, s->addr, reg, &val);
+ ret = raw_read8__7bf(s->port, s->i2c_spi_addr__7bf, reg, &val);
if (ret != EC_SUCCESS) {
mutex_unlock(s->mutex);
return ret;
}
val |= reset_field;
- ret = raw_write8(s->port, s->addr, reg, val);
+ ret = raw_write8__7bf(s->port, s->i2c_spi_addr__7bf, reg, val);
if (ret != EC_SUCCESS) {
mutex_unlock(s->mutex);
return ret;
@@ -273,7 +281,7 @@ static int init(const struct motion_sensor_t *s)
/* The SRST will be cleared when reset is complete. */
do {
- ret = raw_read8(s->port, s->addr, reg, &val);
+ ret = raw_read8__7bf(s->port, s->i2c_spi_addr__7bf, reg, &val);
/* Reset complete. */
if ((ret == EC_SUCCESS) && !(val & reset_field))
diff --git a/driver/accel_bma2x2.h b/driver/accel_bma2x2.h
index 09a4ea2452..ecd3deac23 100644
--- a/driver/accel_bma2x2.h
+++ b/driver/accel_bma2x2.h
@@ -22,16 +22,16 @@ extern const struct accelgyro_drv bma2x2_accel_drv;
* BMA250E
* BMA222E
*/
-#define BMA2x2_I2C_ADDR1 0x30
-#define BMA2x2_I2C_ADDR2 0x19
+#define BMA2x2_I2C_ADDR1__7bf 0x18
+#define BMA2x2_I2C_ADDR2__7bf 0x19
/* The following definition of I2C address is used for the following sensors
* BMC150
* BMC056
* BMC156
*/
-#define BMA2x2_I2C_ADDR3 0x10
-#define BMA2x2_I2C_ADDR4 0x11
+#define BMA2x2_I2C_ADDR3__7bf 0x10
+#define BMA2x2_I2C_ADDR4__7bf 0x11
/*** Chip-specific registers ***/
/* REGISTER ADDRESS DEFINITIONS */
diff --git a/driver/accel_kionix.c b/driver/accel_kionix.c
index d486d4bcd5..4e1f5bb4fc 100644
--- a/driver/accel_kionix.c
+++ b/driver/accel_kionix.c
@@ -133,24 +133,27 @@ static int find_param_index(const int eng_val, const int round_up,
/**
* Read register from accelerometer.
*/
-static int raw_read8(const int port, const int addr, const int reg,
- int *data_ptr)
+static int raw_read8__7bf(const int port,
+ const uint16_t i2c_spi_addr__7bf,
+ const int reg, int *data_ptr)
{
int rv = EC_ERROR_INVAL;
- if (KIONIX_IS_SPI(addr)) {
+ if (SLAVE_IS_SPI(i2c_spi_addr__7bf)) {
#ifdef CONFIG_SPI_ACCEL_PORT
uint8_t val;
uint8_t cmd = 0x80 | reg;
- rv = spi_transaction(&spi_devices[KIONIX_SPI_ADDRESS(addr)],
- &cmd, 1, &val, 1);
+ rv = spi_transaction(
+ &spi_devices[SLAVE_GET_SPI_ADDR__7b(i2c_spi_addr__7bf)],
+ &cmd, 1, &val, 1);
if (rv == EC_SUCCESS)
*data_ptr = val;
#endif
} else {
- rv = i2c_read8(port, addr, reg, data_ptr);
+ rv = i2c_read8__7bf(port, i2c_spi_addr__7bf,
+ reg, data_ptr);
}
return rv;
}
@@ -158,36 +161,43 @@ static int raw_read8(const int port, const int addr, const int reg,
/**
* Write register from accelerometer.
*/
-static int raw_write8(const int port, const int addr, const int reg, int data)
+static int raw_write8__7bf(const int port,
+ const uint16_t i2c_spi_addr__7bf,
+ const int reg, int data)
{
int rv = EC_ERROR_INVAL;
- if (KIONIX_IS_SPI(addr)) {
+ if (SLAVE_IS_SPI(i2c_spi_addr__7bf)) {
#ifdef CONFIG_SPI_ACCEL_PORT
uint8_t cmd[2] = { reg, data };
- rv = spi_transaction(&spi_devices[KIONIX_SPI_ADDRESS(addr)],
- cmd, 2, NULL, 0);
+ rv = spi_transaction(
+ &spi_devices[SLAVE_GET_SPI_ADDR__7b(i2c_spi_addr__7bf)],
+ cmd, 2, NULL, 0);
#endif
} else {
- rv = i2c_write8(port, addr, reg, data);
+ rv = i2c_write8__7bf(port, i2c_spi_addr__7bf,
+ reg, data);
}
return rv;
}
-static int raw_read_multi(const int port, int addr, uint8_t reg,
- uint8_t *rxdata, int rxlen)
+static int raw_read_multi__7bf(const int port,
+ const uint16_t i2c_spi_addr__7bf,
+ uint8_t reg, uint8_t *rxdata, int rxlen)
{
int rv = EC_ERROR_INVAL;
- if (KIONIX_IS_SPI(addr)) {
+ if (SLAVE_IS_SPI(i2c_spi_addr__7bf)) {
#ifdef CONFIG_SPI_ACCEL_PORT
reg |= 0x80;
- rv = spi_transaction(&spi_devices[KIONIX_SPI_ADDRESS(addr)],
- &reg, 1, rxdata, rxlen);
+ rv = spi_transaction(
+ &spi_devices[SLAVE_GET_SPI_ADDR__7b(i2c_spi_addr__7bf)],
+ &reg, 1, rxdata, rxlen);
#endif
} else {
- rv = i2c_read_block(port, addr, reg, rxdata, rxlen);
+ rv = i2c_read_block__7bf(port, i2c_spi_addr__7bf,
+ reg, rxdata, rxlen);
}
return rv;
}
@@ -215,13 +225,15 @@ static int disable_sensor(const struct motion_sensor_t *s, int *reg_val)
* so that we can restore it later.
*/
for (i = 0; i < SENSOR_ENABLE_ATTEMPTS; i++) {
- ret = raw_read8(s->port, s->addr, reg, reg_val);
+ ret = raw_read8__7bf(s->port, s->i2c_spi_addr__7bf,
+ reg, reg_val);
if (ret != EC_SUCCESS)
continue;
*reg_val &= ~pc1_field;
- ret = raw_write8(s->port, s->addr, reg, *reg_val);
+ ret = raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ reg, *reg_val);
if (ret == EC_SUCCESS)
return EC_SUCCESS;
}
@@ -246,7 +258,8 @@ static int enable_sensor(const struct motion_sensor_t *s, int reg_val)
pc1_field = KIONIX_PC1_FIELD(V(s));
for (i = 0; i < SENSOR_ENABLE_ATTEMPTS; i++) {
- ret = raw_read8(s->port, s->addr, reg, &reg_val);
+ ret = raw_read8__7bf(s->port, s->i2c_spi_addr__7bf,
+ reg, &reg_val);
if (ret != EC_SUCCESS)
continue;
@@ -257,8 +270,8 @@ static int enable_sensor(const struct motion_sensor_t *s, int reg_val)
#endif
/* Enable accelerometer based on reg_val value. */
- ret = raw_write8(s->port, s->addr, reg,
- reg_val | pc1_field);
+ ret = raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ reg, reg_val | pc1_field);
/* On first success, we are done. */
if (ret == EC_SUCCESS)
@@ -292,7 +305,8 @@ static int set_value(const struct motion_sensor_t *s, int reg, int val,
/* Determine new value of control reg and attempt to write it. */
reg_val_new = (reg_val & ~field) | val;
- ret = raw_write8(s->port, s->addr, reg, reg_val_new);
+ ret = raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ reg, reg_val_new);
/* If successfully written, then save the range. */
if (ret == EC_SUCCESS)
@@ -433,7 +447,7 @@ static int check_orientation_locked(const struct motion_sensor_t *s)
int orientation, raw_orientation;
int ret;
- ret = raw_read8(s->port, s->addr,
+ ret = raw_read8__7bf(s->port, s->i2c_spi_addr__7bf,
KX022_TSCP, &raw_orientation);
if (ret != EC_SUCCESS)
return ret;
@@ -459,7 +473,7 @@ static int read(const struct motion_sensor_t *s, intv3_t v)
/* Read 6 bytes starting at XOUT_L. */
reg = KIONIX_XOUT_L(V(s));
mutex_lock(s->mutex);
- ret = raw_read_multi(s->port, s->addr, reg, acc, 6);
+ ret = raw_read_multi__7bf(s->port, s->i2c_spi_addr__7bf, reg, acc, 6);
#ifdef CONFIG_KX022_ORIENTATION_SENSOR
if ((s->location == MOTIONSENSE_LOC_LID) && (V(s) == 0) &&
(ret == EC_SUCCESS))
@@ -518,7 +532,8 @@ static int init(const struct motion_sensor_t *s)
do {
msleep(1);
/* Read WHO_AM_I to be sure the device has booted */
- ret = raw_read8(s->port, s->addr, reg, &val);
+ ret = raw_read8__7bf(s->port, s->i2c_spi_addr__7bf,
+ reg, &val);
if (ret == EC_SUCCESS)
break;
@@ -531,16 +546,22 @@ static int init(const struct motion_sensor_t *s)
} else {
/* Write 0x00 to the internal register for KX022 */
reg = KX022_INTERNAL;
- ret = raw_write8(s->port, s->addr, reg, 0x0);
+ ret = raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ reg, 0x0);
if (ret != EC_SUCCESS) {
/*
* For I2C communication, if ACK was not received
* from the first address, resend the command using
* the second address.
*/
- if (!KIONIX_IS_SPI(s->addr)) {
- ret = raw_write8(s->port, s->addr & ~4, reg,
- 0x0);
+ if (!SLAVE_IS_SPI(s->i2c_spi_addr__7bf)) {
+ const uint16_t i2c_alt_addr__7bf =
+ I2C_GET_ADDR__7b(
+ s->i2c_spi_addr__7bf)
+ & ~2;
+ ret = raw_write8__7bf(s->port,
+ i2c_alt_addr__7bf,
+ reg, 0x0);
}
}
}
@@ -557,21 +578,21 @@ static int init(const struct motion_sensor_t *s)
ret = disable_sensor(s, &val);
if (ret != EC_SUCCESS)
goto reset_failed;
- ret = raw_read8(s->port, s->addr, reg, &val);
+ ret = raw_read8__7bf(s->port, s->i2c_spi_addr__7bf, reg, &val);
if (ret != EC_SUCCESS)
goto reset_failed;
val |= reset_field;
} else {
/* Write 0 to CTRL2 for KX022 */
- ret = raw_write8(s->port, s->addr, reg, 0x0);
+ ret = raw_write8__7bf(s->port, s->i2c_spi_addr__7bf, reg, 0x0);
if (ret != EC_SUCCESS)
goto reset_failed;
val = reset_field;
}
- ret = raw_write8(s->port, s->addr, reg, val);
+ ret = raw_write8__7bf(s->port, s->i2c_spi_addr__7bf, reg, val);
if (ret != EC_SUCCESS)
goto reset_failed;
@@ -581,7 +602,8 @@ static int init(const struct motion_sensor_t *s)
do {
msleep(1);
- ret = raw_read8(s->port, s->addr, reg, &val);
+ ret = raw_read8__7bf(s->port, s->i2c_spi_addr__7bf,
+ reg, &val);
/* Reset complete. */
if ((ret == EC_SUCCESS) && !(val & reset_field))
break;
@@ -596,7 +618,7 @@ static int init(const struct motion_sensor_t *s)
msleep(2);
reg = KX022_COTR;
- ret = raw_read8(s->port, s->addr, reg, &val);
+ ret = raw_read8__7bf(s->port, s->i2c_spi_addr__7bf, reg, &val);
if (val != KX022_COTR_VAL_DEFAULT) {
CPRINTF("[%s: the software reset failed]\n", s->name);
ret = EC_ERROR_HW_INTERNAL;
@@ -605,7 +627,7 @@ static int init(const struct motion_sensor_t *s)
}
reg = KIONIX_WHO_AM_I(V(s));
- ret = raw_read8(s->port, s->addr, reg, &val);
+ ret = raw_read8__7bf(s->port, s->i2c_spi_addr__7bf, reg, &val);
if (ret != EC_SUCCESS || val != KIONIX_WHO_AM_I_VAL(V(s))) {
ret = EC_ERROR_HW_INTERNAL;
goto reset_failed;
@@ -648,7 +670,7 @@ struct i2c_stress_test_dev kionix_i2c_stress_test_dev = {
.read_val = KIONIX_WHO_AM_I_VAL(V(s)),
.write_reg = KIONIX_ODR_REG(V(s)),
},
- .i2c_read = &raw_read8,
- .i2c_write = &raw_write8,
+ .i2c_read__7bf = &raw_read8__7bf,
+ .i2c_write__7bf = &raw_write8__7bf,
};
#endif /* CONFIG_CMD_I2C_STRESS_TEST_ACCEL */
diff --git a/driver/accel_kionix.h b/driver/accel_kionix.h
index b6dfa08b48..2491c5d39d 100644
--- a/driver/accel_kionix.h
+++ b/driver/accel_kionix.h
@@ -47,9 +47,6 @@ extern const struct accelgyro_drv kionix_accel_drv;
* | SPI device ID | 1 |
* +-------------------------------+---+
*/
-#define KIONIX_IS_SPI(_addr) ((_addr) & 1)
-#define KIONIX_SPI_ADDRESS(_addr) ((_addr) >> 1)
-
#define KIONIX_CTRL1_REG(v) (KX022_CNTL1 + \
(v) * (KXCJ9_CTRL1 - KX022_CNTL1))
#define KIONIX_CTRL2_REG(v) (KX022_CNTL2 + \
diff --git a/driver/accel_kx022.h b/driver/accel_kx022.h
index c6f02edcb0..f47d077b39 100644
--- a/driver/accel_kx022.h
+++ b/driver/accel_kx022.h
@@ -12,8 +12,8 @@
* 7-bit address is 001111Xb. Where 'X' is determined
* by the voltage on the ADDR pin.
*/
-#define KX022_ADDR0 0x3c
-#define KX022_ADDR1 0x3e
+#define KX022_ADDR0__7bf (0x1e)
+#define KX022_ADDR1__7bf (0x1f)
#define KX022_WHO_AM_I_VAL 0x14
/* Chip-specific registers */
diff --git a/driver/accel_kxcj9.h b/driver/accel_kxcj9.h
index 02b0fba06b..4efad87682 100644
--- a/driver/accel_kxcj9.h
+++ b/driver/accel_kxcj9.h
@@ -14,8 +14,8 @@
* 7-bit address is 000111Xb. Where 'X' is determined
* by the voltage on the ADDR pin.
*/
-#define KXCJ9_ADDR0 0x1c
-#define KXCJ9_ADDR1 0x1e
+#define KXCJ9_ADDR0__7bf 0x0E
+#define KXCJ9_ADDR1__7bf 0x0D
#define KXCJ9_WHO_AM_I_VAL 0x0A
/* Chip-specific registers */
diff --git a/driver/accel_lis2dh.c b/driver/accel_lis2dh.c
index 9c982d9ac0..6ef840b291 100644
--- a/driver/accel_lis2dh.c
+++ b/driver/accel_lis2dh.c
@@ -122,7 +122,8 @@ static int is_data_ready(const struct motion_sensor_t *s, int *ready)
{
int ret, tmp;
- ret = st_raw_read8(s->port, s->addr, LIS2DH_STATUS_REG, &tmp);
+ ret = st_raw_read8__7bf(s->port, s->i2c_spi_addr__7bf,
+ LIS2DH_STATUS_REG, &tmp);
if (ret != EC_SUCCESS) {
CPRINTS("%s type:0x%X RS Error", s->name, s->type);
return ret;
@@ -154,8 +155,8 @@ static int read(const struct motion_sensor_t *s, intv3_t v)
}
/* Read output data bytes starting at LIS2DH_OUT_X_L_ADDR */
- ret = st_raw_read_n(s->port, s->addr, LIS2DH_OUT_X_L_ADDR, raw,
- OUT_XYZ_SIZE);
+ ret = st_raw_read_n__7bf(s->port, s->i2c_spi_addr__7bf,
+ LIS2DH_OUT_X_L_ADDR, raw, OUT_XYZ_SIZE);
if (ret != EC_SUCCESS) {
CPRINTS("%s type:0x%X RD XYZ Error", s->name, s->type);
return ret;
@@ -180,7 +181,8 @@ static int init(const struct motion_sensor_t *s)
* complete boot procedure.
*/
do {
- ret = st_raw_read8(s->port, s->addr, LIS2DH_WHO_AM_I_REG, &tmp);
+ ret = st_raw_read8__7bf(s->port, s->i2c_spi_addr__7bf,
+ LIS2DH_WHO_AM_I_REG, &tmp);
if (ret != EC_SUCCESS) {
udelay(10);
count--;
@@ -201,34 +203,34 @@ static int init(const struct motion_sensor_t *s)
* register must be restored to it's default.
*/
/* Enable all accel axes data and clear old settings */
- ret = st_raw_write8(s->port, s->addr, LIS2DH_CTRL1_ADDR,
- LIS2DH_ENABLE_ALL_AXES);
+ ret = st_raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ LIS2DH_CTRL1_ADDR, LIS2DH_ENABLE_ALL_AXES);
if (ret != EC_SUCCESS)
goto err_unlock;
- ret = st_raw_write8(s->port, s->addr, LIS2DH_CTRL2_ADDR,
- LIS2DH_CTRL2_RESET_VAL);
+ ret = st_raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ LIS2DH_CTRL2_ADDR, LIS2DH_CTRL2_RESET_VAL);
if (ret != EC_SUCCESS)
goto err_unlock;
- ret = st_raw_write8(s->port, s->addr, LIS2DH_CTRL3_ADDR,
- LIS2DH_CTRL3_RESET_VAL);
+ ret = st_raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ LIS2DH_CTRL3_ADDR, LIS2DH_CTRL3_RESET_VAL);
if (ret != EC_SUCCESS)
goto err_unlock;
/* Enable BDU */
- ret = st_raw_write8(s->port, s->addr, LIS2DH_CTRL4_ADDR,
- LIS2DH_BDU_MASK);
+ ret = st_raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ LIS2DH_CTRL4_ADDR, LIS2DH_BDU_MASK);
if (ret != EC_SUCCESS)
goto err_unlock;
- ret = st_raw_write8(s->port, s->addr, LIS2DH_CTRL5_ADDR,
- LIS2DH_CTRL5_RESET_VAL);
+ ret = st_raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ LIS2DH_CTRL5_ADDR, LIS2DH_CTRL5_RESET_VAL);
if (ret != EC_SUCCESS)
goto err_unlock;
- ret = st_raw_write8(s->port, s->addr, LIS2DH_CTRL6_ADDR,
- LIS2DH_CTRL6_RESET_VAL);
+ ret = st_raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ LIS2DH_CTRL6_ADDR, LIS2DH_CTRL6_RESET_VAL);
if (ret != EC_SUCCESS)
goto err_unlock;
diff --git a/driver/accel_lis2dh.h b/driver/accel_lis2dh.h
index 691cca6865..ac5193d388 100644
--- a/driver/accel_lis2dh.h
+++ b/driver/accel_lis2dh.h
@@ -16,8 +16,8 @@
* 8-bit address is 0011 00XW b. Where 'X' is determined
* by the voltage on the ADDR pin, and 'W' is read write bit
*/
-#define LIS2DH_ADDR0 0x30
-#define LIS2DH_ADDR1 0x32
+#define LIS2DH_ADDR0__7bf 0x18
+#define LIS2DH_ADDR1__7bf 0x19
/*
* LNG2DM:
@@ -25,8 +25,8 @@
* 8-bit address is 0101 00XW b. Where 'X' is determined
* by the voltage on the ADDR pin, and 'W' is read write bit
*/
-#define LNG2DM_ADDR0 0x50
-#define LNG2DM_ADDR1 0x52
+#define LNG2DM_ADDR0__7bf 0x28
+#define LNG2DM_ADDR1__7bf 0x29
/* Who Am I */
#define LIS2DH_WHO_AM_I_REG 0x0f
diff --git a/driver/accelgyro_bmi160.c b/driver/accelgyro_bmi160.c
index d06d3f7d99..da9fe2c375 100644
--- a/driver/accelgyro_bmi160.c
+++ b/driver/accelgyro_bmi160.c
@@ -144,21 +144,23 @@ static inline int spi_raw_read(const int addr, const uint8_t reg,
/**
* Read 8bit register from accelerometer.
*/
-static int raw_read8(const int port, const int addr, const int reg,
- int *data_ptr)
+static int raw_read8__7bf(const int port,
+ const uint16_t i2c_spi_addr__7bf,
+ const int reg, int *data_ptr)
{
int rv = -EC_ERROR_PARAM1;
- if (BMI160_IS_SPI(addr)) {
+ if (SLAVE_IS_SPI(i2c_spi_addr__7bf)) {
#ifdef CONFIG_SPI_ACCEL_PORT
uint8_t val;
- rv = spi_raw_read(BMI160_SPI_ADDRESS(addr), reg, &val, 1);
+ rv = spi_raw_read(SLAVE_GET_SPI_ADDR__7b(i2c_spi_addr__7bf),
+ reg, &val, 1);
if (rv == EC_SUCCESS)
*data_ptr = val;
#endif
} else {
#ifdef I2C_PORT_ACCEL
- rv = i2c_read8(port, BMI160_I2C_ADDRESS(addr),
+ rv = i2c_read8__7bf(port, i2c_spi_addr__7bf,
reg, data_ptr);
#endif
}
@@ -168,20 +170,22 @@ static int raw_read8(const int port, const int addr, const int reg,
/**
* Write 8bit register from accelerometer.
*/
-static int raw_write8(const int port, const int addr, const int reg,
- int data)
+static int raw_write8__7bf(const int port,
+ const uint16_t i2c_spi_addr__7bf,
+ const int reg, int data)
{
int rv = -EC_ERROR_PARAM1;
- if (BMI160_IS_SPI(addr)) {
+ if (SLAVE_IS_SPI(i2c_spi_addr__7bf)) {
#ifdef CONFIG_SPI_ACCEL_PORT
uint8_t cmd[2] = { reg, data };
- rv = spi_transaction(&spi_devices[BMI160_SPI_ADDRESS(addr)],
- cmd, 2, NULL, 0);
+ rv = spi_transaction(
+ &spi_devices[SLAVE_GET_SPI_ADDR__7b(i2c_spi_addr__7bf)],
+ cmd, 2, NULL, 0);
#endif
} else {
#ifdef I2C_PORT_ACCEL
- rv = i2c_write8(port, BMI160_I2C_ADDRESS(addr),
+ rv = i2c_write8__7bf(port, i2c_spi_addr__7bf,
reg, data);
#endif
}
@@ -199,18 +203,19 @@ static int raw_write8(const int port, const int addr, const int reg,
/**
* Read 32bit register from accelerometer.
*/
-static int raw_read32(const int port, const int addr, const uint8_t reg,
- int *data_ptr)
+static int raw_read32__7bf(const int port,
+ const uint16_t i2c_spi_addr__7bf,
+ const uint8_t reg, int *data_ptr)
{
int rv = -EC_ERROR_PARAM1;
- if (BMI160_IS_SPI(addr)) {
+ if (SLAVE_IS_SPI(i2c_spi_addr__7bf)) {
#ifdef CONFIG_SPI_ACCEL_PORT
- rv = spi_raw_read(BMI160_SPI_ADDRESS(addr), reg,
- (uint8_t *)data_ptr, 4);
+ rv = spi_raw_read(SLAVE_GET_SPI_ADDR__7b(i2c_spi_addr__7bf),
+ reg, (uint8_t *)data_ptr, 4);
#endif
} else {
#ifdef I2C_PORT_ACCEL
- rv = i2c_read32(port, BMI160_I2C_ADDRESS(addr),
+ rv = i2c_read32__7bf(port, i2c_spi_addr__7bf,
reg, data_ptr);
#endif
}
@@ -221,19 +226,21 @@ static int raw_read32(const int port, const int addr, const uint8_t reg,
/**
* Read n bytes from accelerometer.
*/
-static int raw_read_n(const int port, const int addr, const uint8_t reg,
- uint8_t *data_ptr, const int len)
+static int raw_read_n__7bf(const int port,
+ const uint16_t i2c_spi_addr__7bf,
+ const uint8_t reg, uint8_t *data_ptr, const int len)
{
int rv = -EC_ERROR_PARAM1;
- if (BMI160_IS_SPI(addr)) {
+ if (SLAVE_IS_SPI(i2c_spi_addr__7bf)) {
#ifdef CONFIG_SPI_ACCEL_PORT
- rv = spi_raw_read(BMI160_SPI_ADDRESS(addr), reg, data_ptr, len);
+ rv = spi_raw_read(SLAVE_GET_SPI_ADDR__7b(i2c_spi_addr__7bf),
+ reg, data_ptr, len);
#endif
} else {
#ifdef I2C_PORT_ACCEL
- rv = i2c_read_block(port, BMI160_I2C_ADDRESS(addr), reg,
- data_ptr, len);
+ rv = i2c_read_block__7bf(port, i2c_spi_addr__7bf,
+ reg, data_ptr, len);
#endif
}
return rv;
@@ -246,11 +253,13 @@ static int raw_read_n(const int port, const int addr, const uint8_t reg,
* 1: manual access, we can issue i2c to the compass
* 0: data access: BMI160 gather data periodically from the compass.
*/
-static int bmi160_sec_access_ctrl(const int port, const int addr,
+static int bmi160_sec_access_ctrl__7bf(const int port,
+ const uint16_t i2c_spi_addr__7bf,
const int enable)
{
int mag_if_ctrl;
- raw_read8(port, addr, BMI160_MAG_IF_1, &mag_if_ctrl);
+ raw_read8__7bf(port, i2c_spi_addr__7bf,
+ BMI160_MAG_IF_1, &mag_if_ctrl);
if (enable) {
mag_if_ctrl |= BMI160_MAG_MANUAL_EN;
mag_if_ctrl &= ~BMI160_MAG_READ_BURST_MASK;
@@ -260,30 +269,37 @@ static int bmi160_sec_access_ctrl(const int port, const int addr,
mag_if_ctrl &= ~BMI160_MAG_READ_BURST_MASK;
mag_if_ctrl |= BMI160_MAG_READ_BURST_8;
}
- return raw_write8(port, addr, BMI160_MAG_IF_1, mag_if_ctrl);
+ return raw_write8__7bf(port, i2c_spi_addr__7bf,
+ BMI160_MAG_IF_1, mag_if_ctrl);
}
/**
* Read register from compass.
* Assuming we are in manual access mode, read compass i2c register.
*/
-int bmi160_sec_raw_read8(const int port, const int addr, const uint8_t reg,
- int *data_ptr)
+int bmi160_sec_raw_read8__7bf(const int port,
+ const uint16_t i2c_spi_addr__7bf,
+ const uint8_t reg, int *data_ptr)
{
/* Only read 1 bytes */
- raw_write8(port, addr, BMI160_MAG_I2C_READ_ADDR, reg);
- return raw_read8(port, addr, BMI160_MAG_I2C_READ_DATA, data_ptr);
+ raw_write8__7bf(port, i2c_spi_addr__7bf,
+ BMI160_MAG_I2C_READ_ADDR, reg);
+ return raw_read8__7bf(port, i2c_spi_addr__7bf,
+ BMI160_MAG_I2C_READ_DATA, data_ptr);
}
/**
* Write register from compass.
* Assuming we are in manual access mode, write to compass i2c register.
*/
-int bmi160_sec_raw_write8(const int port, const int addr, const uint8_t reg,
- int data)
+int bmi160_sec_raw_write8__7bf(const int port,
+ const uint16_t i2c_spi_addr__7bf,
+ const uint8_t reg, int data)
{
- raw_write8(port, addr, BMI160_MAG_I2C_WRITE_DATA, data);
- return raw_write8(port, addr, BMI160_MAG_I2C_WRITE_ADDR, reg);
+ raw_write8__7bf(port, i2c_spi_addr__7bf,
+ BMI160_MAG_I2C_WRITE_DATA, data);
+ return raw_write8__7bf(port, i2c_spi_addr__7bf,
+ BMI160_MAG_I2C_WRITE_ADDR, reg);
}
#endif
@@ -295,17 +311,21 @@ static int enable_fifo(const struct motion_sensor_t *s, int enable)
if (enable) {
/* FIFO start collecting events */
- ret = raw_read8(s->port, s->addr, BMI160_FIFO_CONFIG_1, &val);
+ ret = raw_read8__7bf(s->port, s->i2c_spi_addr__7bf,
+ BMI160_FIFO_CONFIG_1, &val);
val |= BMI160_FIFO_SENSOR_EN(s->type);
- ret = raw_write8(s->port, s->addr, BMI160_FIFO_CONFIG_1, val);
+ ret = raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ BMI160_FIFO_CONFIG_1, val);
if (ret == EC_SUCCESS)
data->flags |= 1 << (s->type + BMI160_FIFO_FLAG_OFFSET);
} else {
/* FIFO stop collecting events */
- ret = raw_read8(s->port, s->addr, BMI160_FIFO_CONFIG_1, &val);
+ ret = raw_read8__7bf(s->port, s->i2c_spi_addr__7bf,
+ BMI160_FIFO_CONFIG_1, &val);
val &= ~BMI160_FIFO_SENSOR_EN(s->type);
- ret = raw_write8(s->port, s->addr, BMI160_FIFO_CONFIG_1, val);
+ ret = raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ BMI160_FIFO_CONFIG_1, val);
if (ret == EC_SUCCESS)
data->flags &=
~(1 << (s->type + BMI160_FIFO_FLAG_OFFSET));
@@ -332,7 +352,8 @@ static int set_range(const struct motion_sensor_t *s,
ranges = get_range_table(s->type, &range_tbl_size);
reg_val = get_reg_val(range, rnd, ranges, range_tbl_size);
- ret = raw_write8(s->port, s->addr, ctrl_reg, reg_val);
+ ret = raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ ctrl_reg, reg_val);
/* Now that we have set the range, update the driver's value. */
if (ret == EC_SUCCESS)
data->range = get_engineering_val(reg_val, ranges,
@@ -369,7 +390,8 @@ static int set_data_rate(const struct motion_sensor_t *s,
enable_fifo(s, 0);
#endif
/* go to suspend mode */
- ret = raw_write8(s->port, s->addr, BMI160_CMD_REG,
+ ret = raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ BMI160_CMD_REG,
BMI160_CMD_MODE_SUSPEND(s->type));
msleep(3);
data->odr = 0;
@@ -380,7 +402,8 @@ static int set_data_rate(const struct motion_sensor_t *s,
return ret;
} else if (data->odr == 0) {
/* back from suspend mode. */
- ret = raw_write8(s->port, s->addr, BMI160_CMD_REG,
+ ret = raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ BMI160_CMD_REG,
BMI160_CMD_MODE_NORMAL(s->type));
msleep(wakeup_time[s->type]);
}
@@ -421,12 +444,12 @@ static int set_data_rate(const struct motion_sensor_t *s,
*/
mutex_lock(s->mutex);
- ret = raw_read8(s->port, s->addr, ctrl_reg, &val);
+ ret = raw_read8__7bf(s->port, s->i2c_spi_addr__7bf, ctrl_reg, &val);
if (ret != EC_SUCCESS)
goto accel_cleanup;
val = (val & ~BMI160_ODR_MASK) | reg_val;
- ret = raw_write8(s->port, s->addr, ctrl_reg, val);
+ ret = raw_write8__7bf(s->port, s->i2c_spi_addr__7bf, ctrl_reg, val);
if (ret != EC_SUCCESS)
goto accel_cleanup;
@@ -483,8 +506,8 @@ static int get_offset(const struct motion_sensor_t *s,
* range selected for the accelerometer.
*/
for (i = X; i <= Z; i++) {
- raw_read8(s->port, s->addr, BMI160_OFFSET_ACC70 + i,
- &val);
+ raw_read8__7bf(s->port, s->i2c_spi_addr__7bf,
+ BMI160_OFFSET_ACC70 + i, &val);
if (val > 0x7f)
val = -256 + val;
v[i] = val * BMI160_OFFSET_ACC_MULTI_MG /
@@ -493,7 +516,8 @@ static int get_offset(const struct motion_sensor_t *s,
break;
case MOTIONSENSE_TYPE_GYRO:
/* Read the MSB first */
- raw_read8(s->port, s->addr, BMI160_OFFSET_EN_GYR98, &val98);
+ raw_read8__7bf(s->port, s->i2c_spi_addr__7bf,
+ BMI160_OFFSET_EN_GYR98, &val98);
/*
* The offset of the gyroscope off_gyr_[xyz] is a 10 bit
* two-complement number in units of 0.061 °/s.
@@ -501,8 +525,8 @@ static int get_offset(const struct motion_sensor_t *s,
* -31.25 °/s to +31.25 °/s
*/
for (i = X; i <= Z; i++) {
- raw_read8(s->port, s->addr, BMI160_OFFSET_GYR70 + i,
- &val);
+ raw_read8__7bf(s->port, s->i2c_spi_addr__7bf,
+ BMI160_OFFSET_GYR70 + i, &val);
val |= ((val98 >> (2 * i)) & 0x3) << 8;
if (val > 0x1ff)
val = -1024 + val;
@@ -537,7 +561,8 @@ static int set_offset(const struct motion_sensor_t *s,
rotate_inv(v, *s->rot_standard_ref, v);
- ret = raw_read8(s->port, s->addr, BMI160_OFFSET_EN_GYR98, &val98);
+ ret = raw_read8__7bf(s->port, s->i2c_spi_addr__7bf,
+ BMI160_OFFSET_EN_GYR98, &val98);
if (ret != 0)
return ret;
@@ -552,10 +577,11 @@ static int set_offset(const struct motion_sensor_t *s,
val = -128;
if (val < 0)
val = 256 + val;
- raw_write8(s->port, s->addr, BMI160_OFFSET_ACC70 + i,
- val);
+ raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ BMI160_OFFSET_ACC70 + i, val);
}
- ret = raw_write8(s->port, s->addr, BMI160_OFFSET_EN_GYR98,
+ ret = raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ BMI160_OFFSET_EN_GYR98,
val98 | BMI160_OFFSET_ACC_EN);
break;
case MOTIONSENSE_TYPE_GYRO:
@@ -568,12 +594,13 @@ static int set_offset(const struct motion_sensor_t *s,
val = -512;
if (val < 0)
val = 1024 + val;
- raw_write8(s->port, s->addr, BMI160_OFFSET_GYR70 + i,
- val & 0xFF);
+ raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ BMI160_OFFSET_GYR70 + i, val & 0xFF);
val98 &= ~(0x3 << (2 * i));
val98 |= (val >> 8) << (2 * i);
}
- ret = raw_write8(s->port, s->addr, BMI160_OFFSET_EN_GYR98,
+ ret = raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ BMI160_OFFSET_EN_GYR98,
val98 | BMI160_OFFSET_GYRO_EN);
break;
#ifdef CONFIG_MAG_BMI160_BMM150
@@ -644,9 +671,10 @@ static int perform_calib(const struct motion_sensor_t *s)
ret = EC_RES_INVALID_PARAM;
goto end_perform_calib;
}
- ret = raw_write8(s->port, s->addr, BMI160_FOC_CONF, val);
- ret = raw_write8(s->port, s->addr, BMI160_CMD_REG,
- BMI160_CMD_START_FOC);
+ ret = raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ BMI160_FOC_CONF, val);
+ ret = raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ BMI160_CMD_REG, BMI160_CMD_START_FOC);
deadline.val = get_time().val + 400 * MSEC;
do {
if (timestamp_expired(deadline, NULL)) {
@@ -654,15 +682,17 @@ static int perform_calib(const struct motion_sensor_t *s)
goto end_perform_calib;
}
msleep(50);
- ret = raw_read8(s->port, s->addr, BMI160_STATUS, &status);
+ ret = raw_read8__7bf(s->port, s->i2c_spi_addr__7bf,
+ BMI160_STATUS, &status);
if (ret != EC_SUCCESS)
goto end_perform_calib;
} while ((status & BMI160_FOC_RDY) == 0);
/* Calibration is successful, and loaded, use the result */
- ret = raw_read8(s->port, s->addr, BMI160_OFFSET_EN_GYR98, &val);
- ret = raw_write8(s->port, s->addr, BMI160_OFFSET_EN_GYR98,
- val | en_flag);
+ ret = raw_read8__7bf(s->port, s->i2c_spi_addr__7bf,
+ BMI160_OFFSET_EN_GYR98, &val);
+ ret = raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ BMI160_OFFSET_EN_GYR98, val | en_flag);
end_perform_calib:
set_data_rate(s, rate, 0);
return ret;
@@ -715,7 +745,8 @@ int manage_activity(const struct motion_sensor_t *s,
return ret;
if (enable) {
/* We should use parameters from caller */
- raw_write8(s->port, s->addr, BMI160_INT_MOTION_3,
+ raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ BMI160_INT_MOTION_3,
BMI160_MOTION_PROOF_TIME(
CONFIG_GESTURE_SIGMO_PROOF_MS) <<
BMI160_MOTION_PROOF_OFF |
@@ -723,7 +754,8 @@ int manage_activity(const struct motion_sensor_t *s,
CONFIG_GESTURE_SIGMO_SKIP_MS) <<
BMI160_MOTION_SKIP_OFF |
BMI160_MOTION_SIG_MOT_SEL);
- raw_write8(s->port, s->addr, BMI160_INT_MOTION_1,
+ raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ BMI160_INT_MOTION_1,
BMI160_MOTION_TH(s,
CONFIG_GESTURE_SIGMO_THRES_MG));
tmp |= BMI160_INT_ANYMO_X_EN |
@@ -734,7 +766,8 @@ int manage_activity(const struct motion_sensor_t *s,
BMI160_INT_ANYMO_Y_EN |
BMI160_INT_ANYMO_Z_EN);
}
- ret = raw_write8(s->port, s->addr, BMI160_INT_EN_0, tmp);
+ ret = raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ BMI160_INT_EN_0, tmp);
if (ret)
ret = EC_RES_UNAVAILABLE;
break;
@@ -744,14 +777,16 @@ int manage_activity(const struct motion_sensor_t *s,
case MOTIONSENSE_ACTIVITY_DOUBLE_TAP: {
int tmp;
/* Set double tap interrupt */
- ret = raw_read8(s->port, s->addr, BMI160_INT_EN_0, &tmp);
+ ret = raw_read8__7bf(s->port, s->i2c_spi_addr__7bf,
+ BMI160_INT_EN_0, &tmp);
if (ret)
return ret;
if (enable)
tmp |= BMI160_INT_D_TAP_EN;
else
tmp &= ~BMI160_INT_D_TAP_EN;
- ret = raw_write8(s->port, s->addr, BMI160_INT_EN_0, tmp);
+ ret = raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ BMI160_INT_EN_0, tmp);
if (ret)
ret = EC_RES_UNAVAILABLE;
break;
@@ -888,13 +923,14 @@ static int load_fifo(struct motion_sensor_t *s, uint32_t last_ts)
* Flush potential left over:
* When sensor is resumed, we won't read old data.
*/
- raw_write8(s->port, s->addr, BMI160_CMD_REG,
- BMI160_CMD_FIFO_FLUSH);
+ raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ BMI160_CMD_REG, BMI160_CMD_FIFO_FLUSH);
return EC_SUCCESS;
}
- raw_read_n(s->port, s->addr, BMI160_FIFO_LENGTH_0,
- (uint8_t *)&length, sizeof(length));
+ raw_read_n__7bf(s->port, s->i2c_spi_addr__7bf,
+ BMI160_FIFO_LENGTH_0,
+ (uint8_t *)&length, sizeof(length));
length &= BMI160_FIFO_LENGTH_MASK;
/*
@@ -914,8 +950,8 @@ static int load_fifo(struct motion_sensor_t *s, uint32_t last_ts)
length = MIN(length, sizeof(bmi160_buffer));
- raw_read_n(s->port, s->addr, BMI160_FIFO_DATA, bmi160_buffer,
- length);
+ raw_read_n__7bf(s->port, s->i2c_spi_addr__7bf,
+ BMI160_FIFO_DATA, bmi160_buffer, length);
beginning = *(uint32_t *)bmi160_buffer;
ep = bmi160_buffer + length;
/*
@@ -959,7 +995,7 @@ static int load_fifo(struct motion_sensor_t *s, uint32_t last_ts)
default:
CPRINTS("Unknown header: 0x%02x @ %d",
hdr, bp - bmi160_buffer);
- raw_write8(s->port, s->addr,
+ raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
BMI160_CMD_REG,
BMI160_CMD_FIFO_FLUSH);
return EC_ERROR_NOT_HANDLED;
@@ -1023,36 +1059,45 @@ static int config_interrupt(const struct motion_sensor_t *s)
return EC_SUCCESS;
mutex_lock(s->mutex);
- raw_write8(s->port, s->addr, BMI160_CMD_REG, BMI160_CMD_FIFO_FLUSH);
- raw_write8(s->port, s->addr, BMI160_CMD_REG, BMI160_CMD_INT_RESET);
+ raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ BMI160_CMD_REG, BMI160_CMD_FIFO_FLUSH);
+ raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ BMI160_CMD_REG, BMI160_CMD_INT_RESET);
#ifdef CONFIG_GESTURE_SENSOR_BATTERY_TAP
- raw_write8(s->port, s->addr, BMI160_INT_TAP_0,
- BMI160_TAP_DUR(s, CONFIG_GESTURE_TAP_MAX_INTERSTICE_T));
- ret = raw_write8(s->port, s->addr, BMI160_INT_TAP_1,
- BMI160_TAP_TH(s, CONFIG_GESTURE_TAP_THRES_MG));
+ raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ BMI160_INT_TAP_0,
+ BMI160_TAP_DUR(s, CONFIG_GESTURE_TAP_MAX_INTERSTICE_T));
+ ret = raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ BMI160_INT_TAP_1,
+ BMI160_TAP_TH(s, CONFIG_GESTURE_TAP_THRES_MG));
#endif
#ifdef CONFIG_BMI160_ORIENTATION_SENSOR
/* only use orientation sensor on the lid sensor */
if (s->location == MOTIONSENSE_LOC_LID) {
- ret = raw_write8(s->port, s->addr, BMI160_INT_ORIENT_0,
- BMI160_INT_ORIENT_0_INIT_VAL);
- ret = raw_write8(s->port, s->addr, BMI160_INT_ORIENT_1,
- BMI160_INT_ORIENT_1_INIT_VAL);
+ ret = raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ BMI160_INT_ORIENT_0,
+ BMI160_INT_ORIENT_0_INIT_VAL);
+ ret = raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ BMI160_INT_ORIENT_1,
+ BMI160_INT_ORIENT_1_INIT_VAL);
}
#endif
#ifdef CONFIG_ACCELGYRO_BMI160_INT2_OUTPUT
- ret = raw_write8(s->port, s->addr, BMI160_INT_LATCH, BMI160_LATCH_5MS);
+ ret = raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ BMI160_INT_LATCH, BMI160_LATCH_5MS);
#else
/* Also, configure int2 as an external input. */
- ret = raw_write8(s->port, s->addr, BMI160_INT_LATCH,
- BMI160_INT2_INPUT_EN | BMI160_LATCH_5MS);
+ ret = raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ BMI160_INT_LATCH,
+ BMI160_INT2_INPUT_EN | BMI160_LATCH_5MS);
#endif
/* configure int1 as an interrupt */
- ret = raw_write8(s->port, s->addr, BMI160_INT_OUT_CTRL,
- BMI160_INT_CTRL(1, OUTPUT_EN));
+ ret = raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ BMI160_INT_OUT_CTRL,
+ BMI160_INT_CTRL(1, OUTPUT_EN));
/* Map activity interrupt to int 1 */
tmp = 0;
@@ -1067,29 +1112,36 @@ static int config_interrupt(const struct motion_sensor_t *s)
if (s->location == MOTIONSENSE_LOC_LID)
tmp |= BMI160_INT_ORIENT;
#endif
- ret = raw_write8(s->port, s->addr, BMI160_INT_MAP_REG(1), tmp);
+ ret = raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ BMI160_INT_MAP_REG(1), tmp);
#ifdef CONFIG_ACCEL_FIFO
/* map fifo water mark to int 1 */
- ret = raw_write8(s->port, s->addr, BMI160_INT_FIFO_MAP,
- BMI160_INT_MAP(1, FWM) |
- BMI160_INT_MAP(1, FFULL));
+ ret = raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ BMI160_INT_FIFO_MAP,
+ BMI160_INT_MAP(1, FWM) |
+ BMI160_INT_MAP(1, FFULL));
/* configure fifo watermark to int whenever there's any data in there */
- ret = raw_write8(s->port, s->addr, BMI160_FIFO_CONFIG_0, 1);
+ ret = raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ BMI160_FIFO_CONFIG_0, 1);
#ifdef CONFIG_ACCELGYRO_BMI160_INT2_OUTPUT
- ret = raw_write8(s->port, s->addr, BMI160_FIFO_CONFIG_1,
- BMI160_FIFO_HEADER_EN);
+ ret = raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ BMI160_FIFO_CONFIG_1,
+ BMI160_FIFO_HEADER_EN);
#else
- ret = raw_write8(s->port, s->addr, BMI160_FIFO_CONFIG_1,
- BMI160_FIFO_TAG_INT2_EN |
- BMI160_FIFO_HEADER_EN);
+ ret = raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ BMI160_FIFO_CONFIG_1,
+ BMI160_FIFO_TAG_INT2_EN |
+ BMI160_FIFO_HEADER_EN);
#endif
/* Set fifo*/
- ret = raw_read8(s->port, s->addr, BMI160_INT_EN_1, &tmp);
+ ret = raw_read8__7bf(s->port, s->i2c_spi_addr__7bf,
+ BMI160_INT_EN_1, &tmp);
tmp |= BMI160_INT_FWM_EN | BMI160_INT_FFUL_EN;
- ret = raw_write8(s->port, s->addr, BMI160_INT_EN_1, tmp);
+ ret = raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ BMI160_INT_EN_1, tmp);
#endif
mutex_unlock(s->mutex);
return ret;
@@ -1148,8 +1200,8 @@ static int irq_handler(struct motion_sensor_t *s, uint32_t *event)
return EC_ERROR_NOT_HANDLED;
do {
- rv = raw_read32(s->port, s->addr, BMI160_INT_STATUS_0,
- &interrupt);
+ rv = raw_read32__7bf(s->port, s->i2c_spi_addr__7bf,
+ BMI160_INT_STATUS_0, &interrupt);
/*
* Bail out of this loop there was an error reading the register
*/
@@ -1185,7 +1237,8 @@ static int read(const struct motion_sensor_t *s, intv3_t v)
uint8_t data[6];
int ret, status = 0;
- ret = raw_read8(s->port, s->addr, BMI160_STATUS, &status);
+ ret = raw_read8__7bf(s->port, s->i2c_spi_addr__7bf,
+ BMI160_STATUS, &status);
if (ret != EC_SUCCESS)
return ret;
@@ -1201,7 +1254,8 @@ static int read(const struct motion_sensor_t *s, intv3_t v)
}
/* Read 6 bytes starting at xyz_reg */
- ret = raw_read_n(s->port, s->addr, get_xyz_reg(s->type), data, 6);
+ ret = raw_read_n__7bf(s->port, s->i2c_spi_addr__7bf,
+ get_xyz_reg(s->type), data, 6);
if (ret != EC_SUCCESS) {
CPRINTS("%s: type:0x%X RD XYZ Error %d", s->name, s->type, ret);
@@ -1216,21 +1270,23 @@ static int init(const struct motion_sensor_t *s)
int ret = 0, tmp, i;
struct accelgyro_saved_data_t *saved_data = BMI160_GET_SAVED_DATA(s);
- ret = raw_read8(s->port, s->addr, BMI160_CHIP_ID, &tmp);
+ ret = raw_read8__7bf(s->port, s->i2c_spi_addr__7bf,
+ BMI160_CHIP_ID, &tmp);
if (ret)
return EC_ERROR_UNKNOWN;
if (tmp != BMI160_CHIP_ID_MAJOR && tmp != BMI168_CHIP_ID_MAJOR) {
/* The device may be lock on paging mode. Try to unlock it. */
- raw_write8(s->port, s->addr, BMI160_CMD_REG,
- BMI160_CMD_EXT_MODE_EN_B0);
- raw_write8(s->port, s->addr, BMI160_CMD_REG,
- BMI160_CMD_EXT_MODE_EN_B1);
- raw_write8(s->port, s->addr, BMI160_CMD_REG,
- BMI160_CMD_EXT_MODE_EN_B2);
- raw_write8(s->port, s->addr, BMI160_CMD_EXT_MODE_ADDR,
- BMI160_CMD_PAGING_EN);
- raw_write8(s->port, s->addr, BMI160_CMD_EXT_MODE_ADDR, 0);
+ raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ BMI160_CMD_REG, BMI160_CMD_EXT_MODE_EN_B0);
+ raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ BMI160_CMD_REG, BMI160_CMD_EXT_MODE_EN_B1);
+ raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ BMI160_CMD_REG, BMI160_CMD_EXT_MODE_EN_B2);
+ raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ BMI160_CMD_EXT_MODE_ADDR, BMI160_CMD_PAGING_EN);
+ raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ BMI160_CMD_EXT_MODE_ADDR, 0);
return EC_ERROR_ACCESS_DENIED;
}
@@ -1239,8 +1295,8 @@ static int init(const struct motion_sensor_t *s)
struct bmi160_drv_data_t *data = BMI160_GET_DATA(s);
/* Reset the chip to be in a good state */
- raw_write8(s->port, s->addr, BMI160_CMD_REG,
- BMI160_CMD_SOFT_RESET);
+ raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ BMI160_CMD_REG, BMI160_CMD_SOFT_RESET);
msleep(1);
data->flags &= ~(BMI160_FLAG_SEC_I2C_ENABLED |
(BMI160_FIFO_ALL_MASK <<
@@ -1258,7 +1314,8 @@ static int init(const struct motion_sensor_t *s)
#endif
#endif
/* To avoid gyro wakeup */
- raw_write8(s->port, s->addr, BMI160_PMU_TRIGGER, 0);
+ raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ BMI160_PMU_TRIGGER, 0);
}
#ifdef CONFIG_BMI160_SEC_I2C
@@ -1269,8 +1326,8 @@ static int init(const struct motion_sensor_t *s)
* To be able to configure the real magnetometer, we must set
* the BMI160 magnetometer part (a pass through) in normal mode.
*/
- raw_write8(s->port, s->addr, BMI160_CMD_REG,
- BMI160_CMD_MODE_NORMAL(s->type));
+ raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ BMI160_CMD_REG, BMI160_CMD_MODE_NORMAL(s->type));
msleep(wakeup_time[s->type]);
if ((data->flags & BMI160_FLAG_SEC_I2C_ENABLED) == 0) {
@@ -1283,48 +1340,57 @@ static int init(const struct motion_sensor_t *s)
*
* Magic command sequences
*/
- raw_write8(s->port, s->addr, BMI160_CMD_REG,
- BMI160_CMD_EXT_MODE_EN_B0);
- raw_write8(s->port, s->addr, BMI160_CMD_REG,
- BMI160_CMD_EXT_MODE_EN_B1);
- raw_write8(s->port, s->addr, BMI160_CMD_REG,
- BMI160_CMD_EXT_MODE_EN_B2);
+ raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ BMI160_CMD_REG, BMI160_CMD_EXT_MODE_EN_B0);
+ raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ BMI160_CMD_REG, BMI160_CMD_EXT_MODE_EN_B1);
+ raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ BMI160_CMD_REG, BMI160_CMD_EXT_MODE_EN_B2);
/*
* Change the register page to target mode, to change
* the internal pull ups of the secondary interface.
*/
- raw_read8(s->port, s->addr, BMI160_CMD_EXT_MODE_ADDR,
- &ext_page_reg);
- raw_write8(s->port, s->addr, BMI160_CMD_EXT_MODE_ADDR,
- ext_page_reg | BMI160_CMD_TARGET_PAGE);
- raw_read8(s->port, s->addr, BMI160_CMD_EXT_MODE_ADDR,
- &ext_page_reg);
- raw_write8(s->port, s->addr, BMI160_CMD_EXT_MODE_ADDR,
- ext_page_reg | BMI160_CMD_PAGING_EN);
- raw_read8(s->port, s->addr, BMI160_COM_C_TRIM_ADDR,
- &pullup_reg);
- raw_write8(s->port, s->addr, BMI160_COM_C_TRIM_ADDR,
- pullup_reg | BMI160_COM_C_TRIM);
- raw_read8(s->port, s->addr, BMI160_CMD_EXT_MODE_ADDR,
- &ext_page_reg);
- raw_write8(s->port, s->addr, BMI160_CMD_EXT_MODE_ADDR,
- ext_page_reg & ~BMI160_CMD_TARGET_PAGE);
- raw_read8(s->port, s->addr, BMI160_CMD_EXT_MODE_ADDR,
- &ext_page_reg);
+ raw_read8__7bf(s->port, s->i2c_spi_addr__7bf,
+ BMI160_CMD_EXT_MODE_ADDR, &ext_page_reg);
+ raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ BMI160_CMD_EXT_MODE_ADDR,
+ ext_page_reg | BMI160_CMD_TARGET_PAGE);
+ raw_read8__7bf(s->port, s->i2c_spi_addr__7bf,
+ BMI160_CMD_EXT_MODE_ADDR, &ext_page_reg);
+ raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ BMI160_CMD_EXT_MODE_ADDR,
+ ext_page_reg | BMI160_CMD_PAGING_EN);
+ raw_read8__7bf(s->port, s->i2c_spi_addr__7bf,
+ BMI160_COM_C_TRIM_ADDR, &pullup_reg);
+ raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ BMI160_COM_C_TRIM_ADDR,
+ pullup_reg | BMI160_COM_C_TRIM);
+ raw_read8__7bf(s->port, s->i2c_spi_addr__7bf,
+ BMI160_CMD_EXT_MODE_ADDR, &ext_page_reg);
+ raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ BMI160_CMD_EXT_MODE_ADDR,
+ ext_page_reg & ~BMI160_CMD_TARGET_PAGE);
+ raw_read8__7bf(s->port, s->i2c_spi_addr__7bf,
+ BMI160_CMD_EXT_MODE_ADDR, &ext_page_reg);
/* Set the i2c address of the compass */
- ret = raw_write8(s->port, s->addr, BMI160_MAG_IF_0,
- CONFIG_ACCELGYRO_SEC_ADDR);
+ ret = raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ BMI160_MAG_IF_0,
+ I2C_GET_ADDR__7b(
+ CONFIG_ACCELGYRO_SEC_ADDR__7BF)
+ << 1);
/* Enable the secondary interface as I2C */
- ret = raw_write8(s->port, s->addr, BMI160_IF_CONF,
- BMI160_IF_MODE_AUTO_I2C << BMI160_IF_MODE_OFF);
+ ret = raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ BMI160_IF_CONF,
+ BMI160_IF_MODE_AUTO_I2C <<
+ BMI160_IF_MODE_OFF);
data->flags |= BMI160_FLAG_SEC_I2C_ENABLED;
}
- bmi160_sec_access_ctrl(s->port, s->addr, 1);
+ bmi160_sec_access_ctrl__7bf(s->port, s->i2c_spi_addr__7bf, 1);
ret = bmm150_init(s);
if (ret)
@@ -1332,13 +1398,13 @@ static int init(const struct motion_sensor_t *s)
return ret;
/* Leave the address for reading the data */
- raw_write8(s->port, s->addr, BMI160_MAG_I2C_READ_ADDR,
- BMM150_BASE_DATA);
+ raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ BMI160_MAG_I2C_READ_ADDR, BMM150_BASE_DATA);
/*
* Put back the secondary interface in normal mode.
* BMI160 will poll based on the configure ODR.
*/
- bmi160_sec_access_ctrl(s->port, s->addr, 0);
+ bmi160_sec_access_ctrl__7bf(s->port, s->i2c_spi_addr__7bf, 0);
/*
* Clean interrupt event that may have occurred while the
@@ -1396,8 +1462,8 @@ struct i2c_stress_test_dev bmi160_i2c_stress_test_dev = {
.read_val = BMI160_CHIP_ID_MAJOR,
.write_reg = BMI160_PMU_TRIGGER,
},
- .i2c_read = &raw_read8,
- .i2c_write = &raw_write8,
+ .i2c_read__7bf = &raw_read8__7bf,
+ .i2c_write__7bf = &raw_write8__7bf,
};
#endif /* CONFIG_CMD_I2C_STRESS_TEST_ACCEL */
@@ -1407,7 +1473,8 @@ int bmi160_get_sensor_temp(int idx, int *temp_ptr)
int16_t temp;
int ret;
- ret = raw_read_n(s->port, s->addr, BMI160_TEMPERATURE_0,
+ ret = raw_read_n__7bf(s->port, s->i2c_spi_addr__7bf,
+ BMI160_TEMPERATURE_0,
(uint8_t *)&temp, sizeof(temp));
if (ret || temp == BMI160_INVALID_TEMP)
diff --git a/driver/accelgyro_bmi160.h b/driver/accelgyro_bmi160.h
index 428338b080..4f9cc61b84 100644
--- a/driver/accelgyro_bmi160.h
+++ b/driver/accelgyro_bmi160.h
@@ -22,14 +22,10 @@
* | SPI device ID | 1 |
* +-------------------------------+---+
*/
-#define BMI160_SET_SPI_ADDRESS(_addr) (((_addr) << 1) | 1)
-#define BMI160_IS_SPI(_addr) ((_addr) & 1)
-#define BMI160_SPI_ADDRESS(_addr) ((_addr) >> 1)
-#define BMI160_I2C_ADDRESS(_addr) (_addr)
/* I2C addresses */
-#define BMI160_ADDR0 0xd0
-#define BMI160_ADDR1 0xd2
+#define BMI160_ADDR0__7bf 0x68
+#define BMI160_ADDR1__7bf 0x69
#define BMI160_CHIP_ID 0x00
#define BMI160_CHIP_ID_MAJOR 0xd1
@@ -490,10 +486,10 @@ void bmi160_interrupt(enum gpio_signal signal);
#ifdef CONFIG_BMI160_SEC_I2C
/* Functions to access the secondary device through the accel/gyro. */
-int bmi160_sec_raw_read8(const int port, const int addr, const uint8_t reg,
- int *data_ptr);
-int bmi160_sec_raw_write8(const int port, const int addr, const uint8_t reg,
- int data);
+int bmi160_sec_raw_read8__7bf(const int port, const uint16_t addr__7bf,
+ const uint8_t reg, int *data_ptr);
+int bmi160_sec_raw_write8__7bf(const int port, const uint16_t addr__7bf,
+ const uint8_t reg, int data);
#endif
#ifdef CONFIG_CMD_I2C_STRESS_TEST_ACCEL
diff --git a/driver/accelgyro_lsm6ds0.c b/driver/accelgyro_lsm6ds0.c
index 664fcc7e88..19ed4fa272 100644
--- a/driver/accelgyro_lsm6ds0.c
+++ b/driver/accelgyro_lsm6ds0.c
@@ -151,19 +151,19 @@ static int get_engineering_val(const int reg_val,
/**
* Read register from accelerometer.
*/
-static inline int raw_read8(const int port, const int addr, const int reg,
- int *data_ptr)
+static inline int raw_read8__7bf(const int port, const uint16_t i2c_addr__7bf,
+ const int reg, int *data_ptr)
{
- return i2c_read8(port, addr, reg, data_ptr);
+ return i2c_read8__7bf(port, i2c_addr__7bf, reg, data_ptr);
}
/**
* Write register from accelerometer.
*/
-static inline int raw_write8(const int port, const int addr, const int reg,
- int data)
+static inline int raw_write8__7bf(const int port, const uint16_t i2c_addr__7bf,
+ const int reg, int data)
{
- return i2c_write8(port, addr, reg, data);
+ return i2c_write8__7bf(port, i2c_addr__7bf, reg, data);
}
static int set_range(const struct motion_sensor_t *s,
@@ -186,12 +186,14 @@ static int set_range(const struct motion_sensor_t *s,
*/
mutex_lock(s->mutex);
- ret = raw_read8(s->port, s->addr, ctrl_reg, &ctrl_val);
+ ret = raw_read8__7bf(s->port, s->i2c_spi_addr__7bf,
+ ctrl_reg, &ctrl_val);
if (ret != EC_SUCCESS)
goto accel_cleanup;
ctrl_val = (ctrl_val & ~LSM6DS0_RANGE_MASK) | reg_val;
- ret = raw_write8(s->port, s->addr, ctrl_reg, ctrl_val);
+ ret = raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ ctrl_reg, ctrl_val);
/* Now that we have set the range, update the driver's value. */
if (ret == EC_SUCCESS)
@@ -234,12 +236,12 @@ static int set_data_rate(const struct motion_sensor_t *s,
*/
mutex_lock(s->mutex);
- ret = raw_read8(s->port, s->addr, ctrl_reg, &val);
+ ret = raw_read8__7bf(s->port, s->i2c_spi_addr__7bf, ctrl_reg, &val);
if (ret != EC_SUCCESS)
goto accel_cleanup;
val = (val & ~LSM6DS0_ODR_MASK) | reg_val;
- ret = raw_write8(s->port, s->addr, ctrl_reg, val);
+ ret = raw_write8__7bf(s->port, s->i2c_spi_addr__7bf, ctrl_reg, val);
/* Now that we have set the odr, update the driver's value. */
if (ret == EC_SUCCESS)
@@ -254,14 +256,16 @@ static int set_data_rate(const struct motion_sensor_t *s,
* Table 48 Gyroscope high-pass filter cutoff frequency
*/
if (MOTIONSENSE_TYPE_GYRO == s->type) {
- ret = raw_read8(s->port, s->addr, LSM6DS0_CTRL_REG3_G, &val);
+ ret = raw_read8__7bf(s->port, s->i2c_spi_addr__7bf,
+ LSM6DS0_CTRL_REG3_G, &val);
if (ret != EC_SUCCESS)
goto accel_cleanup;
val &= ~(0x3 << 4); /* clear bit [5:4] */
val = (rate > 119000) ?
(val | (1<<7)) /* set high-power mode */ :
(val & ~(1<<7)); /* set low-power mode */
- ret = raw_write8(s->port, s->addr, LSM6DS0_CTRL_REG3_G, val);
+ ret = raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ LSM6DS0_CTRL_REG3_G, val);
}
accel_cleanup:
@@ -304,7 +308,8 @@ static int is_data_ready(const struct motion_sensor_t *s, int *ready)
{
int ret, tmp;
- ret = raw_read8(s->port, s->addr, LSM6DS0_STATUS_REG, &tmp);
+ ret = raw_read8__7bf(s->port, s->i2c_spi_addr__7bf,
+ LSM6DS0_STATUS_REG, &tmp);
if (ret != EC_SUCCESS) {
CPRINTS("%s type:0x%X RS Error", s->name, s->type);
@@ -344,7 +349,8 @@ static int read(const struct motion_sensor_t *s, intv3_t v)
xyz_reg = get_xyz_reg(s->type);
/* Read 6 bytes starting at xyz_reg */
- ret = i2c_read_block(s->port, s->addr, xyz_reg, raw, 6);
+ ret = i2c_read_block__7bf(s->port, s->i2c_spi_addr__7bf,
+ xyz_reg, raw, 6);
if (ret != EC_SUCCESS) {
CPRINTS("%s type:0x%X RD XYZ Error",
@@ -369,7 +375,8 @@ static int init(const struct motion_sensor_t *s)
{
int ret = 0, tmp;
- ret = raw_read8(s->port, s->addr, LSM6DS0_WHO_AM_I_REG, &tmp);
+ ret = raw_read8__7bf(s->port, s->i2c_spi_addr__7bf,
+ LSM6DS0_WHO_AM_I_REG, &tmp);
if (ret)
return EC_ERROR_UNKNOWN;
@@ -391,21 +398,23 @@ static int init(const struct motion_sensor_t *s)
if (MOTIONSENSE_TYPE_ACCEL == s->type) {
mutex_lock(s->mutex);
- ret = raw_read8(s->port, s->addr, LSM6DS0_CTRL_REG8, &tmp);
+ ret = raw_read8__7bf(s->port, s->i2c_spi_addr__7bf,
+ LSM6DS0_CTRL_REG8, &tmp);
if (ret) {
mutex_unlock(s->mutex);
return EC_ERROR_UNKNOWN;
}
tmp |= (1 | LSM6DS0_BDU_ENABLE);
- ret = raw_write8(s->port, s->addr, LSM6DS0_CTRL_REG8, tmp);
+ ret = raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ LSM6DS0_CTRL_REG8, tmp);
mutex_unlock(s->mutex);
if (ret)
return ret;
/* Power Down Gyro */
- ret = raw_write8(s->port, s->addr,
- LSM6DS0_CTRL_REG1_G, 0x0);
+ ret = raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ LSM6DS0_CTRL_REG1_G, 0x0);
if (ret)
return ret;
}
diff --git a/driver/accelgyro_lsm6ds0.h b/driver/accelgyro_lsm6ds0.h
index ff8a36818d..4724dac168 100644
--- a/driver/accelgyro_lsm6ds0.h
+++ b/driver/accelgyro_lsm6ds0.h
@@ -15,8 +15,8 @@
* 7-bit address is 110101Xb. Where 'X' is determined
* by the voltage on the ADDR pin.
*/
-#define LSM6DS0_ADDR0 0xd4
-#define LSM6DS0_ADDR1 0xd6
+#define LSM6DS0_ADDR0__7bf 0x6a
+#define LSM6DS0_ADDR1__7bf 0x6b
/* who am I */
#define LSM6DS0_WHO_AM_I 0x68
diff --git a/driver/accelgyro_lsm6dsm.c b/driver/accelgyro_lsm6dsm.c
index b4ba92a0e8..aa60013f33 100644
--- a/driver/accelgyro_lsm6dsm.c
+++ b/driver/accelgyro_lsm6dsm.c
@@ -106,23 +106,24 @@ static int config_interrupt(const struct motion_sensor_t *accel)
int ret = EC_SUCCESS;
int int1_ctrl_val;
- ret = st_raw_read8(accel->port, accel->addr, LSM6DSM_INT1_CTRL,
- &int1_ctrl_val);
+ ret = st_raw_read8__7bf(accel->port, accel->i2c_spi_addr__7bf,
+ LSM6DSM_INT1_CTRL, &int1_ctrl_val);
if (ret != EC_SUCCESS)
return ret;
#ifdef CONFIG_ACCEL_FIFO
/* As soon as one sample is ready, trigger an interrupt. */
- ret = st_raw_write8(accel->port, accel->addr, LSM6DSM_FIFO_CTRL1_ADDR,
- OUT_XYZ_SIZE / sizeof(uint16_t));
+ ret = st_raw_write8__7bf(accel->port, accel->i2c_spi_addr__7bf,
+ LSM6DSM_FIFO_CTRL1_ADDR,
+ OUT_XYZ_SIZE / sizeof(uint16_t));
if (ret != EC_SUCCESS)
return ret;
int1_ctrl_val |= LSM6DSM_INT_FIFO_TH | LSM6DSM_INT_FIFO_OVR |
LSM6DSM_INT_FIFO_FULL;
#endif /* CONFIG_ACCEL_FIFO */
- return st_raw_write8(
- accel->port, accel->addr, LSM6DSM_INT1_CTRL, int1_ctrl_val);
+ return st_raw_write8__7bf(accel->port, accel->i2c_spi_addr__7bf,
+ LSM6DSM_INT1_CTRL, int1_ctrl_val);
}
@@ -134,7 +135,7 @@ static int config_interrupt(const struct motion_sensor_t *accel)
*/
static int fifo_disable(const struct motion_sensor_t *accel)
{
- return st_raw_write8(accel->port, accel->addr,
+ return st_raw_write8__7bf(accel->port, accel->i2c_spi_addr__7bf,
LSM6DSM_FIFO_CTRL5_ADDR, 0x00);
}
@@ -194,8 +195,8 @@ static int fifo_enable(const struct motion_sensor_t *accel)
/* FIFO ODR must be set before the decimation factors */
odr_reg_val = LSM6DSM_ODR_TO_REG(max_odr) <<
LSM6DSM_FIFO_CTRL5_ODR_OFF;
- err = st_raw_write8(accel->port, accel->addr, LSM6DSM_FIFO_CTRL5_ADDR,
- odr_reg_val);
+ err = st_raw_write8__7bf(accel->port, accel->i2c_spi_addr__7bf,
+ LSM6DSM_FIFO_CTRL5_ADDR, odr_reg_val);
/* Scan all sensors configuration to calculate FIFO decimator. */
private->config.total_samples_in_pattern = 0;
@@ -212,12 +213,14 @@ static int fifo_enable(const struct motion_sensor_t *accel)
private->config.samples_in_pattern[i] = 0;
}
}
- st_raw_write8(accel->port, accel->addr, LSM6DSM_FIFO_CTRL3_ADDR,
+ st_raw_write8__7bf(accel->port, accel->i2c_spi_addr__7bf,
+ LSM6DSM_FIFO_CTRL3_ADDR,
(decimators[FIFO_DEV_GYRO] << LSM6DSM_FIFO_DEC_G_OFF) |
(decimators[FIFO_DEV_ACCEL] << LSM6DSM_FIFO_DEC_XL_OFF));
#ifdef CONFIG_LSM6DSM_SEC_I2C
- st_raw_write8(accel->port, accel->addr, LSM6DSM_FIFO_CTRL4_ADDR,
- decimators[FIFO_DEV_MAG]);
+ st_raw_write8__7bf(accel->port, accel->i2c_spi_addr__7bf,
+ LSM6DSM_FIFO_CTRL4_ADDR,
+ decimators[FIFO_DEV_MAG]);
/*
* FIFO ODR is limited by odr of gyro or accel.
@@ -252,7 +255,8 @@ static int fifo_enable(const struct motion_sensor_t *accel)
* After ODR and decimation values are set, continuous mode can be
* enabled
*/
- err = st_raw_write8(accel->port, accel->addr, LSM6DSM_FIFO_CTRL5_ADDR,
+ err = st_raw_write8__7bf(accel->port, accel->i2c_spi_addr__7bf,
+ LSM6DSM_FIFO_CTRL5_ADDR,
odr_reg_val | LSM6DSM_FIFO_MODE_CONTINUOUS_VAL);
if (err != EC_SUCCESS)
return err;
@@ -392,7 +396,7 @@ static int load_fifo(struct motion_sensor_t *s, const struct fstatus *fsts,
length = left;
/* Read data and copy in buffer. */
- err = st_raw_read_n_noinc(s->port, s->addr,
+ err = st_raw_read_n_noinc__7bf(s->port, s->i2c_spi_addr__7bf,
LSM6DSM_FIFO_DATA_ADDR,
fifo, length);
*last_fifo_read_ts = __hw_clock_source_read();
@@ -423,9 +427,9 @@ static int is_fifo_empty(struct motion_sensor_t *s, struct fstatus *fsts)
if (s->flags & MOTIONSENSE_FLAG_INT_SIGNAL)
return gpio_get_level(s->int_signal);
CPRINTS("Interrupt signal not set for %s", s->name);
- res = st_raw_read_n_noinc(s->port, s->addr,
- LSM6DSM_FIFO_STS1_ADDR,
- (int8_t *)fsts, sizeof(*fsts));
+ res = st_raw_read_n_noinc__7bf(s->port, s->i2c_spi_addr__7bf,
+ LSM6DSM_FIFO_STS1_ADDR,
+ (int8_t *)fsts, sizeof(*fsts));
/* If we failed to read the FIFO size assume empty. */
if (res != EC_SUCCESS)
return 1;
@@ -471,9 +475,9 @@ static int irq_handler(struct motion_sensor_t *s, uint32_t *event)
last_interrupt_timestamp;
/* Read how many data pattern on FIFO to read and pattern. */
- ret = st_raw_read_n_noinc(s->port, s->addr,
- LSM6DSM_FIFO_STS1_ADDR,
- (uint8_t *)&fsts, sizeof(fsts));
+ ret = st_raw_read_n_noinc__7bf(s->port, s->i2c_spi_addr__7bf,
+ LSM6DSM_FIFO_STS1_ADDR,
+ (uint8_t *)&fsts, sizeof(fsts));
if (ret != EC_SUCCESS)
return ret;
last_fifo_read_ts = __hw_clock_source_read();
@@ -651,7 +655,8 @@ static int is_data_ready(const struct motion_sensor_t *s, int *ready)
{
int ret, tmp;
- ret = st_raw_read8(s->port, s->addr, LSM6DSM_STATUS_REG, &tmp);
+ ret = st_raw_read8__7bf(s->port, s->i2c_spi_addr__7bf,
+ LSM6DSM_STATUS_REG, &tmp);
if (ret != EC_SUCCESS) {
CPRINTS("%s type:0x%X RS Error", s->name, s->type);
return ret;
@@ -694,8 +699,8 @@ static int read(const struct motion_sensor_t *s, intv3_t v)
xyz_reg = get_xyz_reg(s->type);
/* Read data bytes starting at xyz_reg. */
- ret = st_raw_read_n_noinc(s->port, s->addr, xyz_reg, raw,
- OUT_XYZ_SIZE);
+ ret = st_raw_read_n_noinc__7bf(s->port, s->i2c_spi_addr__7bf,
+ xyz_reg, raw, OUT_XYZ_SIZE);
if (ret != EC_SUCCESS)
return ret;
@@ -710,7 +715,8 @@ static int init(const struct motion_sensor_t *s)
struct stprivate_data *data = s->drv_data;
uint8_t ctrl_reg, reg_val = 0;
- ret = st_raw_read8(s->port, s->addr, LSM6DSM_WHO_AM_I_REG, &tmp);
+ ret = st_raw_read8__7bf(s->port, s->i2c_spi_addr__7bf,
+ LSM6DSM_WHO_AM_I_REG, &tmp);
if (ret != EC_SUCCESS)
return EC_ERROR_UNKNOWN;
@@ -735,18 +741,20 @@ static int init(const struct motion_sensor_t *s)
ctrl_reg = LSM6DSM_ODR_REG(MOTIONSENSE_TYPE_ACCEL);
/* Power OFF gyro. */
- ret = st_raw_write8(s->port, s->addr, LSM6DSM_CTRL2_ADDR, 0);
+ ret = st_raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ LSM6DSM_CTRL2_ADDR, 0);
if (ret != EC_SUCCESS)
goto err_unlock;
/* Power ON Accel. */
- ret = st_raw_write8(s->port, s->addr, ctrl_reg, reg_val);
+ ret = st_raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ ctrl_reg, reg_val);
if (ret != EC_SUCCESS)
goto err_unlock;
/* Software reset. */
- ret = st_raw_write8(s->port, s->addr, LSM6DSM_CTRL3_ADDR,
- LSM6DSM_SW_RESET);
+ ret = st_raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ LSM6DSM_CTRL3_ADDR, LSM6DSM_SW_RESET);
if (ret != EC_SUCCESS)
goto err_unlock;
@@ -759,12 +767,13 @@ static int init(const struct motion_sensor_t *s)
*/
/* Power ON Accel. */
- ret = st_raw_write8(s->port, s->addr, ctrl_reg, reg_val);
+ ret = st_raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ ctrl_reg, reg_val);
if (ret != EC_SUCCESS)
goto err_unlock;
- ret = st_raw_write8(s->port, s->addr, LSM6DSM_CTRL3_ADDR,
- LSM6DSM_BOOT);
+ ret = st_raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ LSM6DSM_CTRL3_ADDR, LSM6DSM_BOOT);
if (ret != EC_SUCCESS)
goto err_unlock;
@@ -775,7 +784,8 @@ static int init(const struct motion_sensor_t *s)
msleep(15);
/* Power OFF Accel. */
- ret = st_raw_write8(s->port, s->addr, ctrl_reg, 0);
+ ret = st_raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ ctrl_reg, 0);
if (ret != EC_SUCCESS)
goto err_unlock;
#endif
@@ -784,9 +794,11 @@ static int init(const struct motion_sensor_t *s)
* Output data not updated until have been read.
* Prefer interrupt to be active low.
*/
- ret = st_raw_write8(s->port, s->addr, LSM6DSM_CTRL3_ADDR,
- LSM6DSM_BDU | LSM6DSM_H_L_ACTIVE |
- LSM6DSM_IF_INC);
+ ret = st_raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ LSM6DSM_CTRL3_ADDR,
+ LSM6DSM_BDU
+ | LSM6DSM_H_L_ACTIVE
+ | LSM6DSM_IF_INC);
if (ret != EC_SUCCESS)
goto err_unlock;
diff --git a/driver/accelgyro_lsm6dsm.h b/driver/accelgyro_lsm6dsm.h
index 3d4e2645f1..a23298f11b 100644
--- a/driver/accelgyro_lsm6dsm.h
+++ b/driver/accelgyro_lsm6dsm.h
@@ -13,14 +13,12 @@
#include "mag_bmm150.h"
#include "mag_lis2mdl.h"
-#define LSM6DSM_I2C_ADDR(__x) (__x << 1)
-
/*
* 7-bit address is 110101xb. Where 'x' is determined
* by the voltage on the ADDR pin
*/
-#define LSM6DSM_ADDR0 LSM6DSM_I2C_ADDR(0x6a)
-#define LSM6DSM_ADDR1 LSM6DSM_I2C_ADDR(0x6b)
+#define LSM6DSM_ADDR0__7bf 0x6a
+#define LSM6DSM_ADDR1__7bf 0x6b
/* COMMON DEFINE FOR ACCEL-GYRO SENSORS */
#define LSM6DSM_EN_BIT 0x01
diff --git a/driver/accelgyro_lsm6dso.c b/driver/accelgyro_lsm6dso.c
index 9517712138..f7d44e0e93 100644
--- a/driver/accelgyro_lsm6dso.c
+++ b/driver/accelgyro_lsm6dso.c
@@ -55,8 +55,8 @@ static int config_interrupt(const struct motion_sensor_t *s)
#ifdef CONFIG_ACCEL_FIFO
int int1_ctrl_val;
- ret = st_raw_read8(s->port, s->addr, LSM6DSO_INT1_CTRL,
- &int1_ctrl_val);
+ ret = st_raw_read8__7bf(s->port, s->i2c_spi_addr__7bf,
+ LSM6DSO_INT1_CTRL, &int1_ctrl_val);
if (ret != EC_SUCCESS)
return ret;
@@ -67,15 +67,16 @@ static int config_interrupt(const struct motion_sensor_t *s)
* number or samples still present in FIFO exceeds the configured
* threshold.
*/
- ret = st_raw_write8(s->port, s->addr, LSM6DSO_FIFO_CTRL1_ADDR, 1);
+ ret = st_raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ LSM6DSO_FIFO_CTRL1_ADDR, 1);
if (ret != EC_SUCCESS)
return ret;
int1_ctrl_val |= LSM6DSO_INT_FIFO_TH | LSM6DSO_INT_FIFO_OVR |
LSM6DSO_INT_FIFO_FULL;
- ret = st_raw_write8(s->port, s->addr, LSM6DSO_INT1_CTRL,
- int1_ctrl_val);
+ ret = st_raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ LSM6DSO_INT1_CTRL, int1_ctrl_val);
#endif /* CONFIG_ACCEL_FIFO */
return ret;
@@ -88,7 +89,8 @@ static int config_interrupt(const struct motion_sensor_t *s)
*/
static int fifo_disable(const struct motion_sensor_t *s)
{
- return st_raw_write8(s->port, s->addr, LSM6DSO_FIFO_CTRL4_ADDR,
+ return st_raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ LSM6DSO_FIFO_CTRL4_ADDR,
LSM6DSO_FIFO_MODE_BYPASS_VAL);
}
@@ -100,7 +102,8 @@ static int fifo_disable(const struct motion_sensor_t *s)
*/
static int fifo_enable(const struct motion_sensor_t *s)
{
- return st_raw_write8(s->port, s->addr, LSM6DSO_FIFO_CTRL4_ADDR,
+ return st_raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ LSM6DSO_FIFO_CTRL4_ADDR,
LSM6DSO_FIFO_MODE_CONTINUOUS_VAL);
}
@@ -168,7 +171,7 @@ static inline int load_fifo(struct motion_sensor_t *s,
fifo_len = fifo_depth * LSM6DSO_FIFO_SAMPLE_SIZE;
while (read_len < fifo_len) {
word_len = GENERIC_MIN(fifo_len - read_len, sizeof(fifo));
- err = st_raw_read_n_noinc(s->port, s->addr,
+ err = st_raw_read_n_noinc__7bf(s->port, s->i2c_spi_addr__7bf,
LSM6DSO_FIFO_DATA_ADDR_TAG,
fifo, word_len);
if (err != EC_SUCCESS)
@@ -244,7 +247,7 @@ static int irq_handler(struct motion_sensor_t *s, uint32_t *event)
#ifdef CONFIG_ACCEL_FIFO
/* Read how many data patterns on FIFO to read. */
- ret = st_raw_read_n_noinc(s->port, s->addr,
+ ret = st_raw_read_n_noinc__7bf(s->port, s->i2c_spi_addr__7bf,
LSM6DSO_FIFO_STS1_ADDR,
(uint8_t *)&fsts, sizeof(fsts));
if (ret != EC_SUCCESS)
@@ -366,7 +369,8 @@ static int is_data_ready(const struct motion_sensor_t *s, int *ready)
{
int ret, tmp;
- ret = st_raw_read8(s->port, s->addr, LSM6DSO_STATUS_REG, &tmp);
+ ret = st_raw_read8__7bf(s->port, s->i2c_spi_addr__7bf,
+ LSM6DSO_STATUS_REG, &tmp);
if (ret != EC_SUCCESS) {
CPRINTS("%s type:0x%X RS Error", s->name, s->type);
@@ -411,8 +415,8 @@ static int read(const struct motion_sensor_t *s, intv3_t v)
xyz_reg = get_xyz_reg(s->type);
/* Read data bytes starting at xyz_reg. */
- ret = st_raw_read_n_noinc(s->port, s->addr, xyz_reg, raw,
- OUT_XYZ_SIZE);
+ ret = st_raw_read_n_noinc__7bf(s->port, s->i2c_spi_addr__7bf,
+ xyz_reg, raw, OUT_XYZ_SIZE);
if (ret != EC_SUCCESS)
return ret;
@@ -427,7 +431,8 @@ static int init(const struct motion_sensor_t *s)
int ret = 0, tmp;
struct stprivate_data *data = LSM6DSO_GET_DATA(s);
- ret = st_raw_read8(s->port, s->addr, LSM6DSO_WHO_AM_I_REG, &tmp);
+ ret = st_raw_read8__7bf(s->port, s->i2c_spi_addr__7bf,
+ LSM6DSO_WHO_AM_I_REG, &tmp);
if (ret != EC_SUCCESS)
return EC_ERROR_UNKNOWN;
@@ -445,8 +450,8 @@ static int init(const struct motion_sensor_t *s)
mutex_lock(s->mutex);
/* Software reset. */
- ret = st_raw_write8(s->port, s->addr, LSM6DSO_CTRL3_ADDR,
- LSM6DSO_SW_RESET);
+ ret = st_raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ LSM6DSO_CTRL3_ADDR, LSM6DSO_SW_RESET);
if (ret != EC_SUCCESS)
goto err_unlock;
@@ -454,7 +459,8 @@ static int init(const struct motion_sensor_t *s)
* Output data not updated until have been read.
* Prefer interrupt to be active low.
*/
- ret = st_raw_write8(s->port, s->addr, LSM6DSO_CTRL3_ADDR,
+ ret = st_raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ LSM6DSO_CTRL3_ADDR,
LSM6DSO_BDU | LSM6DSO_IF_INC);
if (ret != EC_SUCCESS)
goto err_unlock;
diff --git a/driver/accelgyro_lsm6dso.h b/driver/accelgyro_lsm6dso.h
index 7748c7fe94..4d59fd1a07 100644
--- a/driver/accelgyro_lsm6dso.h
+++ b/driver/accelgyro_lsm6dso.h
@@ -10,14 +10,12 @@
#include "stm_mems_common.h"
-#define LSM6DSO_I2C_ADDR(__x) (__x << 1)
-
/*
* 7-bit address is 110101xb. Where 'x' is determined
* by the voltage on the ADDR pin
*/
-#define LSM6DSO_ADDR0 LSM6DSO_I2C_ADDR(0x6a)
-#define LSM6DSO_ADDR1 LSM6DSO_I2C_ADDR(0x6b)
+#define LSM6DSO_ADDR0__7bf 0x6a
+#define LSM6DSO_ADDR1__7bf 0x6b
/* Access to embedded sensor hub register bank */
#define LSM6DSO_FUNC_CFG_ACC_ADDR 0x01
diff --git a/driver/als_al3010.h b/driver/als_al3010.h
index eb06762883..f4de75ed0e 100644
--- a/driver/als_al3010.h
+++ b/driver/als_al3010.h
@@ -9,9 +9,9 @@
#define __CROS_EC_ALS_AL3010_H
/* I2C interface */
-#define AL3010_I2C_ADDR1 (0x1C << 1)
-#define AL3010_I2C_ADDR2 (0x1D << 1)
-#define AL3010_I2C_ADDR3 (0x1E << 1)
+#define AL3010_I2C_ADDR1__7bf (0x1C)
+#define AL3010_I2C_ADDR2__7bf (0x1D)
+#define AL3010_I2C_ADDR3__7bf (0x1E)
/* AL3010 registers */
#define AL3010_REG_SYSTEM 0x00
diff --git a/driver/als_bh1730.c b/driver/als_bh1730.c
index 0f96680471..4b0b50e0a1 100644
--- a/driver/als_bh1730.c
+++ b/driver/als_bh1730.c
@@ -62,7 +62,8 @@ static int bh1730_read_lux(const struct motion_sensor_t *s, intv3_t v)
int data0_1;
/* read data0 and data1 from sensor */
- ret = i2c_read32(s->port, s->addr, BH1730_DATA0LOW, &data0_1);
+ ret = i2c_read32__7bf(s->port, s->i2c_spi_addr__7bf,
+ BH1730_DATA0LOW, &data0_1);
if (ret != EC_SUCCESS) {
CPRINTF("bh1730_read_lux - fail %d\n", ret);
return ret;
@@ -136,9 +137,10 @@ static int bh1730_init(const struct motion_sensor_t *s)
int ret;
/* power and measurement bit high */
- ret = i2c_write8(s->port, s->addr,
+ ret = i2c_write8__7bf(s->port, s->i2c_spi_addr__7bf,
BH1730_CONTROL,
- BH1730_CONTROL_POWER_ENABLE|BH1730_CONTROL_ADC_EN_ENABLE);
+ BH1730_CONTROL_POWER_ENABLE
+ | BH1730_CONTROL_ADC_EN_ENABLE);
if (ret != EC_SUCCESS) {
CPRINTF("bh1730_init_sensor - enable fail %d\n", ret);
@@ -146,13 +148,15 @@ static int bh1730_init(const struct motion_sensor_t *s)
}
/* set timing */
- ret = i2c_write8(s->port, s->addr, BH1730_TIMING, BH1730_CONF_ITIME);
+ ret = i2c_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ BH1730_TIMING, BH1730_CONF_ITIME);
if (ret != EC_SUCCESS) {
CPRINTF("bh1730_init_sensor - time fail %d\n", ret);
return ret;
}
/* set ADC gain */
- ret = i2c_write8(s->port, s->addr, BH1730_GAIN, BH1730_CONF_GAIN);
+ ret = i2c_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ BH1730_GAIN, BH1730_CONF_GAIN);
if (ret != EC_SUCCESS) {
CPRINTF("bh1730_init_sensor - gain fail %d\n", ret);
diff --git a/driver/als_bh1730.h b/driver/als_bh1730.h
index 3cd8757822..f729d3edaa 100644
--- a/driver/als_bh1730.h
+++ b/driver/als_bh1730.h
@@ -9,7 +9,7 @@
#define __CROS_EC_ALS_BH1730_H
/* I2C interface */
-#define BH1730_I2C_ADDR (0x29 << 1)
+#define BH1730_I2C_ADDR__7bf 0x29
/* BH1730 registers */
#define BH1730_CONTROL 0x80
diff --git a/driver/als_isl29035.c b/driver/als_isl29035.c
index b2a4a67c9c..341489979f 100644
--- a/driver/als_isl29035.c
+++ b/driver/als_isl29035.c
@@ -9,7 +9,7 @@
#include "i2c.h"
/* I2C interface */
-#define ILS29035_I2C_ADDR 0x88
+#define ILS29035_I2C_ADDR__7bf 0x44
#define ILS29035_REG_COMMAND_I 0
#define ILS29035_REG_COMMAND_II 1
#define ILS29035_REG_DATA_LSB 2
@@ -27,8 +27,8 @@ int isl29035_init(void)
* zero, but it makes the hook/update code cleaner (we don't want to
* wait 90ms to read on demand while processing hook callbacks).
*/
- return i2c_write8(I2C_PORT_ALS, ILS29035_I2C_ADDR,
- ILS29035_REG_COMMAND_I, 0xa0);
+ return i2c_write8__7bf(I2C_PORT_ALS, ILS29035_I2C_ADDR__7bf,
+ ILS29035_REG_COMMAND_I, 0xa0);
}
int isl29035_read_lux(int *lux, int af)
@@ -43,13 +43,13 @@ int isl29035_read_lux(int *lux, int af)
*/
/* Read lsb */
- rv = i2c_read8(I2C_PORT_ALS, ILS29035_I2C_ADDR,
+ rv = i2c_read8__7bf(I2C_PORT_ALS, ILS29035_I2C_ADDR__7bf,
ILS29035_REG_DATA_LSB, &lsb);
if (rv)
return rv;
/* Read msb */
- rv = i2c_read8(I2C_PORT_ALS, ILS29035_I2C_ADDR,
+ rv = i2c_read8__7bf(I2C_PORT_ALS, ILS29035_I2C_ADDR__7bf,
ILS29035_REG_DATA_MSB, &msb);
if (rv)
return rv;
diff --git a/driver/als_opt3001.c b/driver/als_opt3001.c
index fd5dded45d..42a06bfdcc 100644
--- a/driver/als_opt3001.c
+++ b/driver/als_opt3001.c
@@ -17,7 +17,8 @@ static int opt3001_i2c_read(const int reg, int *data_ptr)
{
int ret;
- ret = i2c_read16(I2C_PORT_ALS, OPT3001_I2C_ADDR, reg, data_ptr);
+ ret = i2c_read16__7bf(I2C_PORT_ALS, OPT3001_I2C_ADDR__7bf,
+ reg, data_ptr);
if (!ret)
*data_ptr = ((*data_ptr << 8) & 0xFF00) |
((*data_ptr >> 8) & 0x00FF);
@@ -31,7 +32,8 @@ static int opt3001_i2c_read(const int reg, int *data_ptr)
static int opt3001_i2c_write(const int reg, int data)
{
data = ((data << 8) & 0xFF00) | ((data >> 8) & 0x00FF);
- return i2c_write16(I2C_PORT_ALS, OPT3001_I2C_ADDR, reg, data);
+ return i2c_write16__7bf(I2C_PORT_ALS, OPT3001_I2C_ADDR__7bf,
+ reg, data);
}
/**
@@ -108,12 +110,14 @@ struct i2c_stress_test_dev opt3001_i2c_stress_test_dev = {
/**
* Read register from OPT3001 light sensor.
*/
-static int opt3001_i2c_read(const int port, const int addr, const int reg,
- int *data_ptr)
+static int opt3001_i2c_read__7bf(const int port,
+ const uint16_t i2c_addr__7bf,
+ const int reg, int *data_ptr)
{
int ret;
- ret = i2c_read16(port, addr, reg, data_ptr);
+ ret = i2c_read16__7bf(port, i2c_addr__7bf,
+ reg, data_ptr);
if (!ret)
*data_ptr = ((*data_ptr << 8) & 0xFF00) |
((*data_ptr >> 8) & 0x00FF);
@@ -124,11 +128,13 @@ static int opt3001_i2c_read(const int port, const int addr, const int reg,
/**
* Write register to OPT3001 light sensor.
*/
-static int opt3001_i2c_write(const int port, const int addr, const int reg,
- int data)
+static int opt3001_i2c_write__7bf(const int port,
+ const uint16_t i2c_addr__7bf,
+ const int reg, int data)
{
data = ((data << 8) & 0xFF00) | ((data >> 8) & 0x00FF);
- return i2c_write16(port, addr, reg, data);
+ return i2c_write16__7bf(port, i2c_addr__7bf,
+ reg, data);
}
/**
@@ -140,7 +146,8 @@ int opt3001_read_lux(const struct motion_sensor_t *s, intv3_t v)
int ret;
int data;
- ret = opt3001_i2c_read(s->port, s->addr, OPT3001_REG_RESULT, &data);
+ ret = opt3001_i2c_read__7bf(s->port, s->i2c_spi_addr__7bf,
+ OPT3001_REG_RESULT, &data);
if (ret)
return ret;
@@ -211,13 +218,15 @@ static int opt3001_set_data_rate(const struct motion_sensor_t *s,
if (rate > 1000)
rate = 1000;
}
- rv = opt3001_i2c_read(s->port, s->addr, OPT3001_REG_CONFIGURE, &reg);
+ rv = opt3001_i2c_read__7bf(s->port, s->i2c_spi_addr__7bf,
+ OPT3001_REG_CONFIGURE, &reg);
if (rv)
return rv;
- rv = opt3001_i2c_write(s->port, s->addr, OPT3001_REG_CONFIGURE,
+ rv = opt3001_i2c_write__7bf(s->port, s->i2c_spi_addr__7bf,
+ OPT3001_REG_CONFIGURE,
(reg & OPT3001_MODE_MASK) |
- (mode << OPT3001_MODE_OFFSET));
+ (mode << OPT3001_MODE_OFFSET));
if (rv)
return rv;
@@ -262,13 +271,15 @@ static int opt3001_init(const struct motion_sensor_t *s)
int data;
int ret;
- ret = opt3001_i2c_read(s->port, s->addr, OPT3001_REG_MAN_ID, &data);
+ ret = opt3001_i2c_read__7bf(s->port, s->i2c_spi_addr__7bf,
+ OPT3001_REG_MAN_ID, &data);
if (ret)
return ret;
if (data != OPT3001_MANUFACTURER_ID)
return EC_ERROR_ACCESS_DENIED;
- ret = opt3001_i2c_read(s->port, s->addr, OPT3001_REG_DEV_ID, &data);
+ ret = opt3001_i2c_read__7bf(s->port, s->i2c_spi_addr__7bf,
+ OPT3001_REG_DEV_ID, &data);
if (ret)
return ret;
if (data != OPT3001_DEVICE_ID)
@@ -279,7 +290,8 @@ static int opt3001_init(const struct motion_sensor_t *s)
* [11] : 1b Conversion time 800ms
* [4] : 1b Latched window-style comparison operation
*/
- opt3001_i2c_write(s->port, s->addr, OPT3001_REG_CONFIGURE, 0xC810);
+ opt3001_i2c_write__7bf(s->port, s->i2c_spi_addr__7bf,
+ OPT3001_REG_CONFIGURE, 0xC810);
opt3001_set_range(s, s->default_range, 0);
@@ -304,8 +316,8 @@ struct i2c_stress_test_dev opt3001_i2c_stress_test_dev = {
.read_val = OPT3001_DEVICE_ID,
.write_reg = OPT3001_REG_INT_LIMIT_LSB,
},
- .i2c_read = &opt3001_i2c_read,
- .i2c_write = &opt3001_i2c_write,
+ .i2c_read__7bf = &opt3001_i2c_read__7bf,
+ .i2c_write__7bf = &opt3001_i2c_write__7bf,
};
#endif /* CONFIG_CMD_I2C_STRESS_TEST_ALS */
#endif /* HAS_TASK_ALS */
diff --git a/driver/als_opt3001.h b/driver/als_opt3001.h
index d2d2737e20..34d129b5a5 100644
--- a/driver/als_opt3001.h
+++ b/driver/als_opt3001.h
@@ -9,10 +9,10 @@
#define __CROS_EC_ALS_OPT3001_H
/* I2C interface */
-#define OPT3001_I2C_ADDR1 (0x44 << 1)
-#define OPT3001_I2C_ADDR2 (0x45 << 1)
-#define OPT3001_I2C_ADDR3 (0x46 << 1)
-#define OPT3001_I2C_ADDR4 (0x47 << 1)
+#define OPT3001_I2C_ADDR1__7bf 0x44
+#define OPT3001_I2C_ADDR2__7bf 0x45
+#define OPT3001_I2C_ADDR3__7bf 0x46
+#define OPT3001_I2C_ADDR4__7bf 0x47
/* OPT3001 registers */
#define OPT3001_REG_RESULT 0x00
diff --git a/driver/als_si114x.c b/driver/als_si114x.c
index b51cf8cfc6..f0b3165e67 100644
--- a/driver/als_si114x.c
+++ b/driver/als_si114x.c
@@ -27,28 +27,28 @@ static int init(const struct motion_sensor_t *s);
/**
* Read 8bit register from device.
*/
-static inline int raw_read8(const int port, const int addr, const int reg,
- int *data_ptr)
+static inline int raw_read8__7bf(const int port, const uint16_t i2c_addr__7bf,
+ const int reg, int *data_ptr)
{
- return i2c_read8(port, addr, reg, data_ptr);
+ return i2c_read8__7bf(port, i2c_addr__7bf, reg, data_ptr);
}
/**
* Write 8bit register from device.
*/
-static inline int raw_write8(const int port, const int addr, const int reg,
- int data)
+static inline int raw_write8__7bf(const int port, const uint16_t i2c_addr__7bf,
+ const int reg, int data)
{
- return i2c_write8(port, addr, reg, data);
+ return i2c_write8__7bf(port, i2c_addr__7bf, reg, data);
}
/**
* Read 16bit register from device.
*/
-static inline int raw_read16(const int port, const int addr, const int reg,
- int *data_ptr)
+static inline int raw_read16__7bf(const int port, const uint16_t i2c_addr__7bf,
+ const int reg, int *data_ptr)
{
- return i2c_read16(port, addr, reg, data_ptr);
+ return i2c_read16__7bf(port, i2c_addr__7bf, reg, data_ptr);
}
/* helper function to operate on parameter values: op can be query/set/or/and */
@@ -62,17 +62,19 @@ static int si114x_param_op(const struct motion_sensor_t *s,
mutex_lock(s->mutex);
if (op != SI114X_CMD_PARAM_QUERY) {
- ret = raw_write8(s->port, s->addr, SI114X_REG_PARAM_WR, *value);
+ ret = raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ SI114X_REG_PARAM_WR, *value);
if (ret != EC_SUCCESS)
goto error;
}
- ret = raw_write8(s->port, s->addr, SI114X_REG_COMMAND,
- op | (param & 0x1F));
+ ret = raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ SI114X_REG_COMMAND, op | (param & 0x1F));
if (ret != EC_SUCCESS)
goto error;
- ret = raw_read8(s->port, s->addr, SI114X_REG_PARAM_RD, value);
+ ret = raw_read8__7bf(s->port, s->i2c_spi_addr__7bf,
+ SI114X_REG_PARAM_RD, value);
if (ret != EC_SUCCESS)
goto error;
@@ -96,7 +98,7 @@ static int si114x_read_results(struct motion_sensor_t *s, int nb)
/* Read ALX result */
for (i = 0; i < nb; i++) {
- ret = raw_read16(s->port, s->addr,
+ ret = raw_read16__7bf(s->port, s->i2c_spi_addr__7bf,
type_data->base_data_reg + i * 2,
&val);
if (ret)
@@ -196,7 +198,8 @@ static int irq_handler(struct motion_sensor_t *s, uint32_t *event)
if (!(*event & CONFIG_ALS_SI114X_INT_EVENT))
return EC_ERROR_NOT_HANDLED;
- ret = raw_read8(s->port, s->addr, SI114X_REG_IRQ_STATUS, &val);
+ ret = raw_read8__7bf(s->port, s->i2c_spi_addr__7bf,
+ SI114X_REG_IRQ_STATUS, &val);
if (ret)
return ret;
@@ -204,7 +207,8 @@ static int irq_handler(struct motion_sensor_t *s, uint32_t *event)
return EC_ERROR_INVAL;
/* clearing IRQ */
- ret = raw_write8(s->port, s->addr, SI114X_REG_IRQ_STATUS,
+ ret = raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ SI114X_REG_IRQ_STATUS,
val & type_data->irq_flags);
if (ret != EC_SUCCESS)
CPRINTS("clearing irq failed");
@@ -216,8 +220,9 @@ static int irq_handler(struct motion_sensor_t *s, uint32_t *event)
ret = si114x_read_results(s, 1);
/* Fire pending requests */
if (data->state == SI114X_ALS_IN_PROGRESS_PS_PENDING) {
- ret = raw_write8(s->port, s->addr, SI114X_REG_COMMAND,
- SI114X_CMD_PS_FORCE);
+ ret = raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ SI114X_REG_COMMAND,
+ SI114X_CMD_PS_FORCE);
data->state = SI114X_PS_IN_PROGRESS;
} else {
data->state = SI114X_IDLE;
@@ -228,8 +233,9 @@ static int irq_handler(struct motion_sensor_t *s, uint32_t *event)
/* Read PS results */
ret = si114x_read_results(s, SI114X_NUM_LEDS);
if (data->state == SI114X_PS_IN_PROGRESS_ALS_PENDING) {
- ret = raw_write8(s->port, s->addr, SI114X_REG_COMMAND,
- SI114X_CMD_ALS_FORCE);
+ ret = raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ SI114X_REG_COMMAND,
+ SI114X_CMD_ALS_FORCE);
data->state = SI114X_ALS_IN_PROGRESS;
} else {
data->state = SI114X_IDLE;
@@ -282,7 +288,8 @@ static int read(const struct motion_sensor_t *s, intv3_t v)
CPRINTS("Invalid sensor type");
return EC_ERROR_INVAL;
}
- ret = raw_write8(s->port, s->addr, SI114X_REG_COMMAND, cmd);
+ ret = raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ SI114X_REG_COMMAND, cmd);
#ifdef CONFIG_ALS_SI114X_POLLING
hook_call_deferred(&si114x_read_deferred_data,
SI114x_POLLING_DELAY);
@@ -370,63 +377,68 @@ static int si114x_initialize(const struct motion_sensor_t *s)
int ret, val;
/* send reset command */
- ret = raw_write8(s->port, s->addr, SI114X_REG_COMMAND,
- SI114X_CMD_RESET);
+ ret = raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ SI114X_REG_COMMAND, SI114X_CMD_RESET);
if (ret != EC_SUCCESS)
return ret;
msleep(20);
/* hardware key, magic value */
- ret = raw_write8(s->port, s->addr, SI114X_REG_HW_KEY, 0x17);
+ ret = raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ SI114X_REG_HW_KEY, 0x17);
if (ret != EC_SUCCESS)
return ret;
msleep(20);
/* interrupt configuration, interrupt output enable */
- ret = raw_write8(s->port, s->addr, SI114X_REG_INT_CFG,
- SI114X_INT_CFG_OE);
+ ret = raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ SI114X_REG_INT_CFG, SI114X_INT_CFG_OE);
if (ret != EC_SUCCESS)
return ret;
/* enable interrupt for certain activities */
- ret = raw_write8(s->port, s->addr, SI114X_REG_IRQ_ENABLE,
- SI114X_PS3_IE | SI114X_PS2_IE | SI114X_PS1_IE |
- SI114X_ALS_INT0_IE);
+ ret = raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ SI114X_REG_IRQ_ENABLE,
+ SI114X_PS3_IE | SI114X_PS2_IE | SI114X_PS1_IE |
+ SI114X_ALS_INT0_IE);
if (ret != EC_SUCCESS)
return ret;
/* Only forced mode */
- ret = raw_write8(s->port, s->addr, SI114X_REG_MEAS_RATE, 0);
+ ret = raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ SI114X_REG_MEAS_RATE, 0);
if (ret != EC_SUCCESS)
return ret;
/* measure ALS every time device wakes up */
- ret = raw_write8(s->port, s->addr, SI114X_REG_ALS_RATE, 0);
+ ret = raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ SI114X_REG_ALS_RATE, 0);
if (ret != EC_SUCCESS)
return ret;
/* measure proximity every time device wakes up */
- ret = raw_write8(s->port, s->addr, SI114X_REG_PS_RATE, 0);
+ ret = raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ SI114X_REG_PS_RATE, 0);
if (ret != EC_SUCCESS)
return ret;
/* set LED currents to maximum */
switch (SI114X_NUM_LEDS) {
case 3:
- ret = raw_write8(s->port, s->addr,
- SI114X_REG_PS_LED3, 0x0f);
+ ret = raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ SI114X_REG_PS_LED3, 0x0f);
if (ret != EC_SUCCESS)
return ret;
- ret = raw_write8(s->port, s->addr,
- SI114X_REG_PS_LED21, 0xff);
+ ret = raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ SI114X_REG_PS_LED21, 0xff);
break;
case 2:
- ret = raw_write8(s->port, s->addr,
- SI114X_REG_PS_LED21, 0xff);
+ ret = raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ SI114X_REG_PS_LED21, 0xff);
break;
case 1:
- ret = raw_write8(s->port, s->addr,
- SI114X_REG_PS_LED21, 0x0f);
+ ret = raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ SI114X_REG_PS_LED21, 0x0f);
break;
}
if (ret != EC_SUCCESS)
diff --git a/driver/als_si114x.h b/driver/als_si114x.h
index d3fcf1d64a..8f7f3530d4 100644
--- a/driver/als_si114x.h
+++ b/driver/als_si114x.h
@@ -22,7 +22,7 @@
#ifndef __CROS_EC_ALS_SI114X_H
#define __CROS_EC_ALS_SI114X_H
-#define SI114X_ADDR (0x5a << 1)
+#define SI114X_ADDR__7bf 0x5a
#define SI114X_REG_PART_ID 0x00
#define SI114X_SI1141_ID 0x41
diff --git a/driver/als_tcs3400.c b/driver/als_tcs3400.c
index 61b16bb355..8544f51a4b 100644
--- a/driver/als_tcs3400.c
+++ b/driver/als_tcs3400.c
@@ -24,13 +24,13 @@ static volatile uint32_t last_interrupt_timestamp;
static inline int tcs3400_i2c_read8(const struct motion_sensor_t *s,
int reg, int *data)
{
- return i2c_read8(s->port, s->addr, reg, data);
+ return i2c_read8__7bf(s->port, s->i2c_spi_addr__7bf, reg, data);
}
static inline int tcs3400_i2c_write8(const struct motion_sensor_t *s,
int reg, int data)
{
- return i2c_write8(s->port, s->addr, reg, data);
+ return i2c_write8__7bf(s->port, s->i2c_spi_addr__7bf, reg, data);
}
static void tcs3400_read_deferred(void)
@@ -113,8 +113,9 @@ static int tcs3400_post_events(struct motion_sensor_t *s, uint32_t last_ts)
} while (!(data & TCS_I2C_STATUS_RGBC_VALID));
/* Read the light registers */
- ret = i2c_read_block(s->port, s->addr, TCS_DATA_START_LOCATION,
- light_data, sizeof(light_data));
+ ret = i2c_read_block__7bf(s->port, s->i2c_spi_addr__7bf,
+ TCS_DATA_START_LOCATION,
+ light_data, sizeof(light_data));
if (ret)
return ret;
diff --git a/driver/als_tcs3400.h b/driver/als_tcs3400.h
index 7e5f062d17..bfe1f0e5ab 100644
--- a/driver/als_tcs3400.h
+++ b/driver/als_tcs3400.h
@@ -9,7 +9,7 @@
#define __CROS_EC_ALS_TCS3400_H
/* I2C Interface */
-#define TCS3400_I2C_ADDR 0x72
+#define TCS3400_I2C_ADDR__7bf 0x39
/* ID for TCS34001 and TCS34005 */
#define TCS340015_DEVICE_ID 0x90
diff --git a/driver/baro_bmp280.c b/driver/baro_bmp280.c
index b622535819..10d1c4b91a 100644
--- a/driver/baro_bmp280.c
+++ b/driver/baro_bmp280.c
@@ -98,7 +98,7 @@ static int bmp280_get_calib_param(const struct motion_sensor_t *s)
uint8_t a_data_u8[BMP280_CALIB_DATA_SIZE] = {0};
struct bmp280_drv_data_t *data = BMP280_GET_DATA(s);
- ret = i2c_read_block(s->port, s->addr,
+ ret = i2c_read_block__7bf(s->port, s->i2c_spi_addr__7bf,
BMP280_TEMPERATURE_CALIB_DIG_T1_LSB_REG,
a_data_u8, BMP280_CALIB_DATA_SIZE);
@@ -129,7 +129,7 @@ static int bmp280_read_uncomp_pressure(const struct motion_sensor_t *s,
int ret;
uint8_t a_data_u8[BMP280_PRESSURE_DATA_SIZE] = {0};
- ret = i2c_read_block(s->port, s->addr,
+ ret = i2c_read_block__7bf(s->port, s->i2c_spi_addr__7bf,
BMP280_PRESSURE_MSB_REG,
a_data_u8, BMP280_PRESSURE_DATA_SIZE);
@@ -218,13 +218,13 @@ static int bmp280_set_standby_durn(const struct motion_sensor_t *s,
{
int ret, val;
- ret = i2c_read8(s->port, s->addr,
+ ret = i2c_read8__7bf(s->port, s->i2c_spi_addr__7bf,
BMP280_CONFIG_REG, &val);
if (ret == EC_SUCCESS) {
val = (val & 0xE0) | ((durn << 5) & 0xE0);
/* write the standby duration*/
- ret = i2c_write8(s->port, s->addr,
+ ret = i2c_write8__7bf(s->port, s->i2c_spi_addr__7bf,
BMP280_CONFIG_REG, val);
}
@@ -239,7 +239,8 @@ static int bmp280_set_power_mode(const struct motion_sensor_t *s,
val = (BMP280_OVERSAMP_TEMP << 5) +
(BMP280_OVERSAMP_PRES << 2) + power_mode;
- return i2c_write8(s->port, s->addr, BMP280_CTRL_MEAS_REG, val);
+ return i2c_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ BMP280_CTRL_MEAS_REG, val);
}
static int bmp280_set_range(const struct motion_sensor_t *s,
@@ -277,7 +278,7 @@ static int bmp280_init(const struct motion_sensor_t *s)
return EC_ERROR_INVAL;
/* Read chip id */
- ret = i2c_read8(s->port, s->addr,
+ ret = i2c_read8__7bf(s->port, s->i2c_spi_addr__7bf,
BMP280_CHIP_ID_REG, &val);
if (ret)
return ret;
@@ -383,7 +384,7 @@ struct i2c_stress_test_dev bmp280_i2c_stress_test_dev = {
.read_val = BMP280_CHIP_ID,
.write_reg = BMP280_CONFIG_REG,
},
- .i2c_read = &i2c_read8,
- .i2c_write = &i2c_write8,
+ .i2c_read__7bf = &i2c_read8__7bf,
+ .i2c_write__7bf = &i2c_write8__7bf,
};
#endif /* CONFIG_CMD_I2C_STRESS_TEST_ACCEL */
diff --git a/driver/baro_bmp280.h b/driver/baro_bmp280.h
index a3cb919a7c..f5070bd71d 100644
--- a/driver/baro_bmp280.h
+++ b/driver/baro_bmp280.h
@@ -74,8 +74,9 @@
* Bit 1 of 7-bit address: 0 - If SDO is connected to GND
* Bit 1 of 7-bit address: 1 - If SDO is connected to Vddio
*/
-#define BMP280_I2C_ADDRESS1 ((0x76) << 1)
-#define BMP280_I2C_ADDRESS2 ((0x77) << 1)
+#define BMP280_I2C_ADDRESS1__7bf 0x76
+#define BMP280_I2C_ADDRESS2__7bf 0x77
+
/*
* CHIP ID
*/
diff --git a/driver/battery/bq27541.c b/driver/battery/bq27541.c
index 2645597ec7..c41914f4e8 100644
--- a/driver/battery/bq27541.c
+++ b/driver/battery/bq27541.c
@@ -12,7 +12,7 @@
#include "i2c.h"
#include "util.h"
-#define BQ27541_ADDR 0xaa
+#define BQ27541_ADDR__7bf 0x55
#define BQ27541_TYPE_ID 0x0541
#define BQ27741_TYPE_ID 0x0741
#define BQ27742_TYPE_ID 0x0742
diff --git a/driver/battery/bq27621_g1.c b/driver/battery/bq27621_g1.c
index 5e7f0c8df9..76d020f6df 100644
--- a/driver/battery/bq27621_g1.c
+++ b/driver/battery/bq27621_g1.c
@@ -13,7 +13,7 @@
#include "util.h"
#include "timer.h"
-#define BQ27621_ADDR 0xaa
+#define BQ27621_ADDR__7bf 0x55
#define BQ27621_TYPE_ID 0x0621
#define REG_CTRL 0x00
diff --git a/driver/battery/max17055.c b/driver/battery/max17055.c
index 28a2ba1038..90ceb12214 100644
--- a/driver/battery/max17055.c
+++ b/driver/battery/max17055.c
@@ -66,12 +66,14 @@ static int fake_state_of_charge = -1;
static int max17055_read(int offset, int *data)
{
- return i2c_read16(I2C_PORT_BATTERY, MAX17055_ADDR, offset, data);
+ return i2c_read16__7bf(I2C_PORT_BATTERY, MAX17055_ADDR__7bf,
+ offset, data);
}
static int max17055_write(int offset, int data)
{
- return i2c_write16(I2C_PORT_BATTERY, MAX17055_ADDR, offset, data);
+ return i2c_write16__7bf(I2C_PORT_BATTERY, MAX17055_ADDR__7bf,
+ offset, data);
}
/* Return 1 if the device id is correct. */
diff --git a/driver/battery/max17055.h b/driver/battery/max17055.h
index bdee9ca948..ce10b8ebf0 100644
--- a/driver/battery/max17055.h
+++ b/driver/battery/max17055.h
@@ -8,7 +8,7 @@
#ifndef __CROS_EC_MAX17055_H
#define __CROS_EC_MAX17055_H
-#define MAX17055_ADDR 0x6c
+#define MAX17055_ADDR__7bf 0x36
#define MAX17055_DEVICE_ID 0x4010
#define MAX17055_OCV_TABLE_SIZE 48
diff --git a/driver/battery/mm8013.c b/driver/battery/mm8013.c
index 012f3a25bd..87926553db 100644
--- a/driver/battery/mm8013.c
+++ b/driver/battery/mm8013.c
@@ -23,7 +23,7 @@ static int mm8013_read16(int offset, int *data)
int rv;
*data = 0;
- rv = i2c_read16(I2C_PORT_BATTERY, MM8013_ADDR, offset, data);
+ rv = i2c_read16__7bf(I2C_PORT_BATTERY, MM8013_ADDR__7bf, offset, data);
usleep(I2C_WAIT_TIME);
if (rv)
return rv;
@@ -34,7 +34,8 @@ static int mm8013_read_block(int offset, uint8_t *data, int len)
{
int rv;
- rv = i2c_read_block(I2C_PORT_BATTERY, MM8013_ADDR, offset, data, len);
+ rv = i2c_read_block__7bf(I2C_PORT_BATTERY, MM8013_ADDR__7bf,
+ offset, data, len);
usleep(I2C_WAIT_TIME);
if (rv)
return rv;
diff --git a/driver/battery/mm8013.h b/driver/battery/mm8013.h
index 4dedfbd4a3..5acdcdff68 100644
--- a/driver/battery/mm8013.h
+++ b/driver/battery/mm8013.h
@@ -8,7 +8,7 @@
#ifndef __CROS_EC_MM8013_H
#define __CROS_EC_MM8013_H
-#define MM8013_ADDR 0xaa
+#define MM8013_ADDR__7bf 0x55
#define REG_TEMPERATURE 0x06
#define REG_VOLTAGE 0x08
diff --git a/driver/battery/smart.c b/driver/battery/smart.c
index e42ebc726a..ced1e7cfc3 100644
--- a/driver/battery/smart.c
+++ b/driver/battery/smart.c
@@ -30,7 +30,9 @@ test_mockable int sb_read(int cmd, int *param)
if (battery_is_cut_off())
return EC_RES_ACCESS_DENIED;
#endif
- return i2c_read16(I2C_PORT_BATTERY, BATTERY_ADDR, cmd, param);
+
+ return i2c_read16__7bf(I2C_PORT_BATTERY, BATTERY_ADDR__7bf,
+ cmd, param);
}
test_mockable int sb_write(int cmd, int param)
@@ -42,7 +44,9 @@ test_mockable int sb_write(int cmd, int param)
if (battery_is_cut_off())
return EC_RES_ACCESS_DENIED;
#endif
- return i2c_write16(I2C_PORT_BATTERY, BATTERY_ADDR, cmd, param);
+
+ return i2c_write16__7bf(I2C_PORT_BATTERY, BATTERY_ADDR__7bf,
+ cmd, param);
}
int sb_read_string(int offset, uint8_t *data, int len)
@@ -54,8 +58,9 @@ int sb_read_string(int offset, uint8_t *data, int len)
if (battery_is_cut_off())
return EC_RES_ACCESS_DENIED;
#endif
- return i2c_read_string(I2C_PORT_BATTERY, BATTERY_ADDR,
- offset, data, len);
+
+ return i2c_read_string__7bf(I2C_PORT_BATTERY, BATTERY_ADDR__7bf,
+ offset, data, len);
}
int sb_read_mfgacc(int cmd, int block, uint8_t *data, int len)
@@ -99,8 +104,8 @@ int sb_write_block(int reg, const uint8_t *val, int len)
#endif
/* TODO: implement smbus_write_block. */
- return i2c_write_block(I2C_PORT_BATTERY, BATTERY_ADDR, reg, val, len);
-
+ return i2c_write_block__7bf(I2C_PORT_BATTERY, BATTERY_ADDR__7bf,
+ reg, val, len);
}
int battery_get_mode(int *mode)
diff --git a/driver/bc12/pi3usb9201.c b/driver/bc12/pi3usb9201.c
index ba4ab9e496..2fdb9719a5 100644
--- a/driver/bc12/pi3usb9201.c
+++ b/driver/bc12/pi3usb9201.c
@@ -62,15 +62,15 @@ static const struct bc12_status bc12_chg_limits[] = {
static inline int raw_read8(int port, int offset, int *value)
{
- return i2c_read8(pi3usb2901_bc12_chips[port].i2c_port,
- pi3usb2901_bc12_chips[port].i2c_addr,
+ return i2c_read8__7bf(pi3usb2901_bc12_chips[port].i2c_port,
+ pi3usb2901_bc12_chips[port].i2c_addr__7bf,
offset, value);
}
static inline int raw_write8(int port, int offset, int value)
{
- return i2c_write8(pi3usb2901_bc12_chips[port].i2c_port,
- pi3usb2901_bc12_chips[port].i2c_addr,
+ return i2c_write8__7bf(pi3usb2901_bc12_chips[port].i2c_port,
+ pi3usb2901_bc12_chips[port].i2c_addr__7bf,
offset, value);
}
diff --git a/driver/bc12/pi3usb9201.h b/driver/bc12/pi3usb9201.h
index 1e60e63c47..ba379ffff3 100644
--- a/driver/bc12/pi3usb9201.h
+++ b/driver/bc12/pi3usb9201.h
@@ -5,11 +5,11 @@
/* PI3USB9201 USB BC 1.2 Charger Detector driver definitions */
-/* 8-bit I2C address */
-#define PI3USB9201_I2C_ADDR_0 0xB8
-#define PI3USB9201_I2C_ADDR_1 0xBA
-#define PI3USB9201_I2C_ADDR_2 0xBC
-#define PI3USB9201_I2C_ADDR_3 0xBE
+/* I2C address */
+#define PI3USB9201_I2C_ADDR_0__7bf 0x5C
+#define PI3USB9201_I2C_ADDR_1__7bf 0x5D
+#define PI3USB9201_I2C_ADDR_2__7bf 0x5E
+#define PI3USB9201_I2C_ADDR_3__7bf 0x5F
#define PI3USB9201_REG_CTRL_1 0x0
#define PI3USB9201_REG_CTRL_2 0x1
@@ -33,7 +33,7 @@
struct pi3usb2901_config_t {
const int i2c_port;
- const int i2c_addr;
+ const int i2c_addr__7bf;
};
enum pi3usb9201_mode {
diff --git a/driver/bc12/pi3usb9281.c b/driver/bc12/pi3usb9281.c
index eba326ac3b..8d88d5a1e8 100644
--- a/driver/bc12/pi3usb9281.c
+++ b/driver/bc12/pi3usb9281.c
@@ -23,8 +23,8 @@
#define CPUTS(outstr) cputs(CC_USBCHARGE, outstr)
#define CPRINTS(format, args...) cprints(CC_USBCHARGE, format, ## args)
-/* 8-bit I2C address */
-#define PI3USB9281_I2C_ADDR (0x25 << 1)
+/* I2C address */
+#define PI3USB9281_I2C_ADDR__7bf (0x25)
/* Delay values */
#define PI3USB9281_SW_RESET_DELAY 20
@@ -69,7 +69,8 @@ static uint8_t pi3usb9281_do_read(int port, uint8_t reg, int with_lock)
if (with_lock)
select_chip(port);
- res = i2c_read8(chip->i2c_port, PI3USB9281_I2C_ADDR, reg, &val);
+ res = i2c_read8__7bf(chip->i2c_port, PI3USB9281_I2C_ADDR__7bf,
+ reg, &val);
if (with_lock)
unselect_chip(port);
@@ -99,7 +100,8 @@ static int pi3usb9281_do_write(
if (with_lock)
select_chip(port);
- res = i2c_write8(chip->i2c_port, PI3USB9281_I2C_ADDR, reg, val);
+ res = i2c_write8__7bf(chip->i2c_port, PI3USB9281_I2C_ADDR__7bf,
+ reg, val);
if (with_lock)
unselect_chip(port);
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, &reg);
+ ret = i2c_read16__7bf(I2C_PORT_CHARGER, I2C_ADDR_CHARGER__7bf,
+ ISL9238_REG_CONTROL3, &reg);
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, &reg);
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,
- &regval);
+ rv = i2c_read16__7bf(I2C_PORT_CHARGER, I2C_ADDR_CHARGER__7bf,
+ reg, &regval);
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 {
diff --git a/driver/gyro_l3gd20h.h b/driver/gyro_l3gd20h.h
index 1864c5afac..e7684688d1 100644
--- a/driver/gyro_l3gd20h.h
+++ b/driver/gyro_l3gd20h.h
@@ -15,8 +15,8 @@
* 7-bit address is 110101Xb. Where 'X' is determined
* by the voltage on the ADDR pin.
*/
-#define L3GD20_ADDR0 0xd4
-#define L3GD20_ADDR1 0xd6
+#define L3GD20_ADDR0__7bf 0x6a
+#define L3GD20_ADDR1__7bf 0x6b
/* who am I */
#define L3GD20_WHO_AM_I 0xd7
diff --git a/driver/ina2xx.c b/driver/ina2xx.c
index 70dd5ecc75..a50d5f800e 100644
--- a/driver/ina2xx.c
+++ b/driver/ina2xx.c
@@ -16,16 +16,16 @@
/* Console output macros */
#define CPRINTS(format, args...) cprints(CC_USBCHARGE, format, ## args)
-/* 8-bit I2C base address */
-#define INA2XX_I2C_ADDR (0x40 << 1)
+/* I2C base address */
+#define INA2XX_I2C_ADDR__7bf 0x40
uint16_t ina2xx_read(uint8_t idx, uint8_t reg)
{
int res;
int val;
- uint8_t addr = INA2XX_I2C_ADDR | (idx << 1);
- res = i2c_read16(I2C_PORT_MASTER, addr, reg, &val);
+ res = i2c_read16__7bf(I2C_PORT_MASTER, INA2XX_I2C_ADDR__7bf | idx,
+ reg, &val);
if (res) {
CPRINTS("INA2XX I2C read failed");
return 0x0bad;
@@ -36,10 +36,10 @@ uint16_t ina2xx_read(uint8_t idx, uint8_t reg)
int ina2xx_write(uint8_t idx, uint8_t reg, uint16_t val)
{
int res;
- uint8_t addr = INA2XX_I2C_ADDR | (idx << 1);
uint16_t be_val = (val >> 8) | ((val & 0xff) << 8);
- res = i2c_write16(I2C_PORT_MASTER, addr, reg, be_val);
+ res = i2c_write16__7bf(I2C_PORT_MASTER, INA2XX_I2C_ADDR__7bf | idx,
+ reg, be_val);
if (res)
CPRINTS("INA2XX I2C write failed");
return res;
diff --git a/driver/ioexpander_pca9534.c b/driver/ioexpander_pca9534.c
index be22e7918d..4eddd5adab 100644
--- a/driver/ioexpander_pca9534.c
+++ b/driver/ioexpander_pca9534.c
@@ -8,37 +8,45 @@
#include "i2c.h"
#include "ioexpander_pca9534.h"
-static int pca9534_pin_read(int port, int addr, int reg, int pin, int *val)
+static int pca9534_pin_read__7bf(const int port, const uint16_t addr__7bf,
+ int reg, int pin, int *val)
{
int ret;
- ret = i2c_read8(port, addr, reg, val);
+ ret = i2c_read8__7bf(port, addr__7bf, reg, val);
*val = (*val & BIT(pin)) ? 1 : 0;
return ret;
}
-static int pca9534_pin_write(int port, int addr, int reg, int pin, int val)
+static int pca9534_pin_write__7bf(const int port, const uint16_t addr__7bf,
+ int reg, int pin, int val)
{
int ret, v;
- ret = i2c_read8(port, addr, reg, &v);
+ ret = i2c_read8__7bf(port, addr__7bf, reg, &v);
if (ret != EC_SUCCESS)
return ret;
v &= ~BIT(pin);
if (val)
v |= 1 << pin;
- return i2c_write8(port, addr, reg, v);
+ return i2c_write8__7bf(port, addr__7bf, reg, v);
}
-int pca9534_get_level(int port, int addr, int pin, int *level)
+int pca9534_get_level__7bf(const int port, const uint16_t addr__7bf,
+ int pin, int *level)
{
- return pca9534_pin_read(port, addr, PCA9534_REG_INPUT, pin, level);
+ return pca9534_pin_read__7bf(port, addr__7bf,
+ PCA9534_REG_INPUT, pin, level);
}
-int pca9534_set_level(int port, int addr, int pin, int level)
+int pca9534_set_level__7bf(const int port, const uint16_t addr__7bf,
+ int pin, int level)
{
- return pca9534_pin_write(port, addr, PCA9534_REG_OUTPUT, pin, level);
+ return pca9534_pin_write__7bf(port, addr__7bf,
+ PCA9534_REG_OUTPUT, pin, level);
}
-int pca9534_config_pin(int port, int addr, int pin, int is_input)
+int pca9534_config_pin__7bf(const int port, const uint16_t addr__7bf,
+ int pin, int is_input)
{
- return pca9534_pin_write(port, addr, PCA9534_REG_CONFIG, pin, is_input);
+ return pca9534_pin_write__7bf(port, addr__7bf,
+ PCA9534_REG_CONFIG, pin, is_input);
}
diff --git a/driver/ioexpander_pca9534.h b/driver/ioexpander_pca9534.h
index 9c8959b096..7e5ce79c8d 100644
--- a/driver/ioexpander_pca9534.h
+++ b/driver/ioexpander_pca9534.h
@@ -26,7 +26,8 @@
*
* @return EC_SUCCESS, or EC_ERROR_* on error.
*/
-int pca9534_get_level(int port, int addr, int pin, int *level);
+int pca9534_get_level__7bf(const int port, const uint16_t addr__7bf,
+ int pin, int *level);
/*
* Set output level. This function has no effect if the pin is
@@ -39,7 +40,8 @@ int pca9534_get_level(int port, int addr, int pin, int *level);
*
* @return EC_SUCCESS, or EC_ERROR_* on error.
*/
-int pca9534_set_level(int port, int addr, int pin, int level);
+int pca9534_set_level__7bf(const int port, const uint16_t addr__7bf,
+ int pin, int level);
/*
* Config a pin as input or output.
@@ -51,6 +53,7 @@ int pca9534_set_level(int port, int addr, int pin, int level);
*
* @return EC_SUCCESS, or EC_ERROR_* on error.
*/
-int pca9534_config_pin(int port, int addr, int pin, int is_input);
+int pca9534_config_pin__7bf(const int port, const uint16_t addr__7bf,
+ int pin, int is_input);
#endif /* __CROS_EC_IOEXPANDER_PCA9534_H */
diff --git a/driver/ioexpander_pca9555.h b/driver/ioexpander_pca9555.h
index 874f24356a..49a626d068 100644
--- a/driver/ioexpander_pca9555.h
+++ b/driver/ioexpander_pca9555.h
@@ -28,14 +28,18 @@
#define PCA9555_IO_6 BIT(6)
#define PCA9555_IO_7 BIT(7)
-static inline int pca9555_read(int port, int addr, int reg, int *data_ptr)
+static inline int pca9555_read__7bf(const int port,
+ const uint16_t i2c_addr__7bf,
+ int reg, int *data_ptr)
{
- return i2c_read8(port, addr, reg, data_ptr);
+ return i2c_read8__7bf(port, i2c_addr__7bf, reg, data_ptr);
}
-static inline int pca9555_write(int port, int addr, int reg, int data)
+static inline int pca9555_write__7bf(const int port,
+ const uint16_t i2c_addr__7bf,
+ int reg, int data)
{
- return i2c_write8(port, addr, reg, data);
+ return i2c_write8__7bf(port, i2c_addr__7bf, reg, data);
}
#endif /* __CROS_EC_IOEXPANDER_PCA9555_H */
diff --git a/driver/led/lm3509.c b/driver/led/lm3509.c
index 0f44681659..c940dd69e2 100644
--- a/driver/led/lm3509.c
+++ b/driver/led/lm3509.c
@@ -12,12 +12,14 @@
static inline int lm3509_write(uint8_t reg, uint8_t val)
{
- return i2c_write8(I2C_PORT_KBLIGHT, LM3509_I2C_ADDR, reg, val);
+ return i2c_write8__7bf(I2C_PORT_KBLIGHT, LM3509_I2C_ADDR__7bf,
+ reg, val);
}
static inline int lm3509_read(uint8_t reg, int *val)
{
- return i2c_read8(I2C_PORT_KBLIGHT, LM3509_I2C_ADDR, reg, val);
+ return i2c_read8__7bf(I2C_PORT_KBLIGHT, LM3509_I2C_ADDR__7bf,
+ reg, val);
}
/* Brightness level (0.0 to 100.0%) to brightness register conversion table */
diff --git a/driver/led/lm3509.h b/driver/led/lm3509.h
index 8318197a8e..fce0c993dc 100644
--- a/driver/led/lm3509.h
+++ b/driver/led/lm3509.h
@@ -8,8 +8,7 @@
#ifndef __CROS_EC_LM3509_H
#define __CROS_EC_LM3509_H
-/* 8-bit I2C address */
-#define LM3509_I2C_ADDR 0x6C
+#define LM3509_I2C_ADDR__7bf 0x36
/*
* General purpose register
diff --git a/driver/led/lm3630a.c b/driver/led/lm3630a.c
index 5515771ffa..10f850b09d 100644
--- a/driver/led/lm3630a.c
+++ b/driver/led/lm3630a.c
@@ -11,17 +11,19 @@
#include "timer.h"
-/* 8-bit I2C address */
-#define LM3630A_I2C_ADDR (0x36 << 1)
+/* I2C address */
+#define LM3630A_I2C_ADDR__7bf 0x36
static inline int lm3630a_write(uint8_t reg, uint8_t val)
{
- return i2c_write8(I2C_PORT_KBLIGHT, LM3630A_I2C_ADDR, reg, val);
+ return i2c_write8__7bf(I2C_PORT_KBLIGHT, LM3630A_I2C_ADDR__7bf,
+ reg, val);
}
static inline int lm3630a_read(uint8_t reg, int *val)
{
- return i2c_read8(I2C_PORT_KBLIGHT, LM3630A_I2C_ADDR, reg, val);
+ return i2c_read8__7bf(I2C_PORT_KBLIGHT, LM3630A_I2C_ADDR__7bf,
+ reg, val);
}
static void deferred_lm3630a_poweron(void)
diff --git a/driver/led/lp5562.c b/driver/led/lp5562.c
index 4a72c914bb..966aff5e58 100644
--- a/driver/led/lp5562.c
+++ b/driver/led/lp5562.c
@@ -11,8 +11,8 @@
#include "timer.h"
#include "util.h"
-/* 8-bit I2C address */
-#define LP5562_I2C_ADDR (0x30 << 1)
+/* I2C address */
+#define LP5562_I2C_ADDR__7bf (0x30)
inline int lp5562_write(uint8_t reg, uint8_t val)
{
diff --git a/driver/led/max695x.h b/driver/led/max695x.h
index d7e6d26bbf..4bead04194 100644
--- a/driver/led/max695x.h
+++ b/driver/led/max695x.h
@@ -9,8 +9,8 @@
#define __CROS_EC_MAX656X_H
/* I2C interface */
-#define MAX695X_I2C_ADDR1 (0x38 << 1)
-#define MAX695X_I2C_ADDR2 (0x39 << 1)
+#define MAX695X_I2C_ADDR1__7bf (0x38)
+#define MAX695X_I2C_ADDR2__7bf (0x39)
/* Decode mode register */
#define MAX695X_REG_DECODE_MODE 0x01
diff --git a/driver/led/oz554.c b/driver/led/oz554.c
index 7ceb6bdfa9..6369e064a3 100644
--- a/driver/led/oz554.c
+++ b/driver/led/oz554.c
@@ -16,7 +16,7 @@
#define CPRINTS(format, args...) cprints(CC_I2C, format, ## args)
#define CPRINTF(format, args...) cprintf(CC_I2C, format, ## args)
-#define I2C_ADDR_OZ554 0x62
+#define I2C_ADDR_OZ554__7bf 0x31
struct oz554_value {
uint8_t offset;
@@ -80,7 +80,8 @@ static void set_oz554_reg(void)
int i;
for (i = 0; i < oz554_conf_size; ++i) {
- int rv = i2c_write8(I2C_PORT_BACKLIGHT, I2C_ADDR_OZ554,
+ int rv = i2c_write8__7bf(I2C_PORT_BACKLIGHT,
+ I2C_ADDR_OZ554__7bf,
oz554_conf[i].offset, oz554_conf[i].data);
if (rv) {
CPRINTS("Write OZ554 register %d failed rv=%d" , i, rv);
diff --git a/driver/mag_bmm150.c b/driver/mag_bmm150.c
index 9598d85105..30555cbe56 100644
--- a/driver/mag_bmm150.c
+++ b/driver/mag_bmm150.c
@@ -19,8 +19,8 @@
#ifdef CONFIG_MAG_BMI160_BMM150
#include "driver/accelgyro_bmi160.h"
-#define raw_mag_read8 bmi160_sec_raw_read8
-#define raw_mag_write8 bmi160_sec_raw_write8
+#define raw_mag_read8__7bf bmi160_sec_raw_read8__7bf
+#define raw_mag_write8__7bf bmi160_sec_raw_write8__7bf
#else
#error "Not implemented"
#endif
@@ -73,9 +73,9 @@
#define BMI150_READ_16BIT_COM_REG(store_, addr_) do { \
int val; \
- raw_mag_read8(s->port, s->addr, (addr_), &val); \
+ raw_mag_read8__7bf(s->port, s->i2c_spi_addr__7bf, (addr_), &val); \
store_ = val; \
- raw_mag_read8(s->port, s->addr, (addr_) + 1, &val); \
+ raw_mag_read8__7bf(s->port, s->i2c_spi_addr__7bf, (addr_) + 1, &val); \
store_ |= (val << 8); \
} while (0)
@@ -88,10 +88,12 @@ int bmm150_init(const struct motion_sensor_t *s)
struct mag_cal_t *moc = BMM150_CAL(s);
/* Set the compass from Suspend to Sleep */
- ret = raw_mag_write8(s->port, s->addr, BMM150_PWR_CTRL, BMM150_PWR_ON);
+ ret = raw_mag_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ BMM150_PWR_CTRL, BMM150_PWR_ON);
msleep(4);
/* Now we can read the device id */
- ret = raw_mag_read8(s->port, s->addr, BMM150_CHIP_ID, &val);
+ ret = raw_mag_read8__7bf(s->port, s->i2c_spi_addr__7bf,
+ BMM150_CHIP_ID, &val);
if (ret)
return EC_ERROR_UNKNOWN;
@@ -99,21 +101,27 @@ int bmm150_init(const struct motion_sensor_t *s)
return EC_ERROR_ACCESS_DENIED;
/* Read the private registers for compensation */
- ret = raw_mag_read8(s->port, s->addr, BMM150_REGA_DIG_X1, &val);
+ ret = raw_mag_read8__7bf(s->port, s->i2c_spi_addr__7bf,
+ BMM150_REGA_DIG_X1, &val);
if (ret)
return EC_ERROR_UNKNOWN;
regs->dig1[X] = val;
- raw_mag_read8(s->port, s->addr, BMM150_REGA_DIG_Y1, &val);
+ raw_mag_read8__7bf(s->port, s->i2c_spi_addr__7bf,
+ BMM150_REGA_DIG_Y1, &val);
regs->dig1[Y] = val;
- raw_mag_read8(s->port, s->addr, BMM150_REGA_DIG_X2, &val);
+ raw_mag_read8__7bf(s->port, s->i2c_spi_addr__7bf,
+ BMM150_REGA_DIG_X2, &val);
regs->dig2[X] = val;
- raw_mag_read8(s->port, s->addr, BMM150_REGA_DIG_Y2, &val);
+ raw_mag_read8__7bf(s->port, s->i2c_spi_addr__7bf,
+ BMM150_REGA_DIG_Y2, &val);
regs->dig2[Y] = val;
- raw_mag_read8(s->port, s->addr, BMM150_REGA_DIG_XY1, &val);
+ raw_mag_read8__7bf(s->port, s->i2c_spi_addr__7bf,
+ BMM150_REGA_DIG_XY1, &val);
regs->dig_xy1 = val;
- raw_mag_read8(s->port, s->addr, BMM150_REGA_DIG_XY2, &val);
+ raw_mag_read8__7bf(s->port, s->i2c_spi_addr__7bf,
+ BMM150_REGA_DIG_XY2, &val);
regs->dig_xy2 = val;
BMI150_READ_16BIT_COM_REG(regs->dig_z1, BMM150_REGA_DIG_Z1_LSB);
@@ -124,15 +132,20 @@ int bmm150_init(const struct motion_sensor_t *s)
/* Set the repetition in "Regular Preset" */
- raw_mag_write8(s->port, s->addr, BMM150_REPXY, BMM150_REP(SPECIAL, XY));
- raw_mag_write8(s->port, s->addr, BMM150_REPZ, BMM150_REP(SPECIAL, Z));
- ret = raw_mag_read8(s->port, s->addr, BMM150_REPXY, &val);
- ret = raw_mag_read8(s->port, s->addr, BMM150_REPZ, &val);
+ raw_mag_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ BMM150_REPXY, BMM150_REP(SPECIAL, XY));
+ raw_mag_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ BMM150_REPZ, BMM150_REP(SPECIAL, Z));
+ ret = raw_mag_read8__7bf(s->port, s->i2c_spi_addr__7bf,
+ BMM150_REPXY, &val);
+ ret = raw_mag_read8__7bf(s->port, s->i2c_spi_addr__7bf,
+ BMM150_REPZ, &val);
/*
* Set the compass forced mode, to sleep after each measure.
*/
- ret = raw_mag_write8(s->port, s->addr, BMM150_OP_CTRL,
- BMM150_OP_MODE_FORCED << BMM150_OP_MODE_OFFSET);
+ ret = raw_mag_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ BMM150_OP_CTRL,
+ BMM150_OP_MODE_FORCED << BMM150_OP_MODE_OFFSET);
init_mag_cal(moc);
moc->radius = 0.0f;
diff --git a/driver/mag_bmm150.h b/driver/mag_bmm150.h
index a504b1a20a..e9b3ce660b 100644
--- a/driver/mag_bmm150.h
+++ b/driver/mag_bmm150.h
@@ -11,10 +11,10 @@
#include "accelgyro.h"
#include "mag_cal.h"
-#define BMM150_ADDR0 0x20
-#define BMM150_ADDR1 0x22
-#define BMM150_ADDR2 0x24
-#define BMM150_ADDR3 0x26
+#define BMM150_ADDR0__7bf 0x10
+#define BMM150_ADDR1__7bf 0x11
+#define BMM150_ADDR2__7bf 0x12
+#define BMM150_ADDR3__7bf 0x13
#define BMM150_CHIP_ID 0x40
#define BMM150_CHIP_ID_MAJOR 0x32
diff --git a/driver/mag_lis2mdl.c b/driver/mag_lis2mdl.c
index 40725c180d..348577adfd 100644
--- a/driver/mag_lis2mdl.c
+++ b/driver/mag_lis2mdl.c
@@ -146,25 +146,25 @@ int lis2mdl_thru_lsm6dsm_init(const struct motion_sensor_t *s)
mutex_lock(s->mutex);
/* Magnetometer in cascade mode */
- ret = sensorhub_check_and_rst(
+ ret = sensorhub_check_and_rst__7bf(
LSM6DSM_MAIN_SENSOR(s),
- CONFIG_ACCELGYRO_SEC_ADDR,
+ CONFIG_ACCELGYRO_SEC_ADDR__7BF,
LIS2MDL_WHO_AM_I_REG, LIS2MDL_WHO_AM_I,
LIS2MDL_CFG_REG_A_ADDR, LIS2MDL_FLAG_SW_RESET);
if (ret != EC_SUCCESS)
goto err_unlock;
- ret = sensorhub_config_ext_reg(
+ ret = sensorhub_config_ext_reg__7bf(
LSM6DSM_MAIN_SENSOR(s),
- CONFIG_ACCELGYRO_SEC_ADDR,
+ CONFIG_ACCELGYRO_SEC_ADDR__7BF,
LIS2MDL_CFG_REG_A_ADDR,
LIS2MDL_ODR_50HZ | LIS2MDL_MODE_CONT);
if (ret != EC_SUCCESS)
goto err_unlock;
- ret = sensorhub_config_slv0_read(
+ ret = sensorhub_config_slv0_read__7bf(
LSM6DSM_MAIN_SENSOR(s),
- CONFIG_ACCELGYRO_SEC_ADDR,
+ CONFIG_ACCELGYRO_SEC_ADDR__7BF,
LIS2MDL_OUT_REG, OUT_XYZ_SIZE);
if (ret != EC_SUCCESS)
goto err_unlock;
@@ -200,7 +200,8 @@ static int lis2mdl_is_data_ready(const struct motion_sensor_t *s, int *ready)
{
int ret, tmp;
- ret = st_raw_read8(s->port, s->addr, LIS2MDL_STATUS_REG, &tmp);
+ ret = st_raw_read8__7bf(s->port, s->i2c_spi_addr__7bf,
+ LIS2MDL_STATUS_REG, &tmp);
if (ret != EC_SUCCESS) {
*ready = 0;
return ret;
@@ -241,8 +242,8 @@ int lis2mdl_read(const struct motion_sensor_t *s, intv3_t v)
}
mutex_lock(s->mutex);
- ret = st_raw_read_n(s->port, s->addr, LIS2MDL_OUT_REG, raw,
- OUT_XYZ_SIZE);
+ ret = st_raw_read_n__7bf(s->port, s->i2c_spi_addr__7bf,
+ LIS2MDL_OUT_REG, raw, OUT_XYZ_SIZE);
mutex_unlock(s->mutex);
if (ret == EC_SUCCESS) {
lis2mdl_normalize(s, v, raw);
@@ -262,8 +263,8 @@ int lis2mdl_init(const struct motion_sensor_t *s)
/* Check who am I value */
do {
- ret = st_raw_read8(s->port, LIS2MDL_ADDR, LIS2MDL_WHO_AM_I_REG,
- &who_am_i);
+ ret = st_raw_read8__7bf(s->port, LIS2MDL_ADDR__7bf,
+ LIS2MDL_WHO_AM_I_REG, &who_am_i);
if (ret != EC_SUCCESS) {
/* Make sure we wait for the chip to start up. Sleep 1ms
* and try again.
@@ -282,7 +283,8 @@ int lis2mdl_init(const struct motion_sensor_t *s)
mutex_lock(s->mutex);
/* Reset the sensor */
- ret = st_raw_write8(s->port, LIS2MDL_ADDR, LIS2MDL_CFG_REG_A_ADDR,
+ ret = st_raw_write8__7bf(s->port, LIS2MDL_ADDR__7bf,
+ LIS2MDL_CFG_REG_A_ADDR,
LIS2MDL_FLAG_SW_RESET);
if (ret != EC_SUCCESS)
goto lis2mdl_init_error;
@@ -361,13 +363,13 @@ int lis2mdl_set_data_rate(const struct motion_sensor_t *s, int rate, int rnd)
mutex_lock(s->mutex);
if (rate <= 0) {
- ret = st_raw_write8(s->port, LIS2MDL_ADDR,
+ ret = st_raw_write8__7bf(s->port, LIS2MDL_ADDR__7bf,
LIS2MDL_CFG_REG_A_ADDR,
LIS2MDL_FLAG_SW_RESET);
} else {
/* Add continuous and temp compensation flags */
reg_val |= LIS2MDL_MODE_CONT | LIS2MDL_FLAG_TEMP_COMPENSATION;
- ret = st_raw_write8(s->port, LIS2MDL_ADDR,
+ ret = st_raw_write8__7bf(s->port, LIS2MDL_ADDR__7bf,
LIS2MDL_CFG_REG_A_ADDR, reg_val);
}
diff --git a/driver/mag_lis2mdl.h b/driver/mag_lis2mdl.h
index f87b4e1f91..e0c2f1652d 100644
--- a/driver/mag_lis2mdl.h
+++ b/driver/mag_lis2mdl.h
@@ -16,7 +16,7 @@
* 8-bit address is 0011110Wb where the last bit represents whether the
* operation is a read or a write.
*/
-#define LIS2MDL_ADDR 0x3c
+#define LIS2MDL_ADDR__7bf 0x1e
#define LIS2MDL_STARTUP_MS 10
diff --git a/driver/pmic_tps650x30.h b/driver/pmic_tps650x30.h
index 861f1d8d14..c3d3691385 100644
--- a/driver/pmic_tps650x30.h
+++ b/driver/pmic_tps650x30.h
@@ -9,9 +9,9 @@
#define __CROS_EC_PMIC_TPS650X30_H
/* I2C interface */
-#define TPS650X30_I2C_ADDR1 (0x30 << 1)
-#define TPS650X30_I2C_ADDR2 (0x32 << 1)
-#define TPS650X30_I2C_ADDR3 (0x34 << 1)
+#define TPS650X30_I2C_ADDR1__7bf 0x30
+#define TPS650X30_I2C_ADDR2__7bf 0x32
+#define TPS650X30_I2C_ADDR3__7bf 0x34
/* TPS650X30 registers */
#define TPS650X30_REG_VENDORID 0x00
diff --git a/driver/ppc/nx20p348x.c b/driver/ppc/nx20p348x.c
index aae4e18f56..fc234539de 100644
--- a/driver/ppc/nx20p348x.c
+++ b/driver/ppc/nx20p348x.c
@@ -32,16 +32,16 @@ static uint8_t flags[CONFIG_USB_PD_PORT_COUNT];
static int read_reg(uint8_t port, int reg, int *regval)
{
- return i2c_read8(ppc_chips[port].i2c_port,
- ppc_chips[port].i2c_addr,
+ return i2c_read8__7bf(ppc_chips[port].i2c_port,
+ ppc_chips[port].i2c_addr__7bf,
reg,
regval);
}
static int write_reg(uint8_t port, int reg, int regval)
{
- return i2c_write8(ppc_chips[port].i2c_port,
- ppc_chips[port].i2c_addr,
+ return i2c_write8__7bf(ppc_chips[port].i2c_port,
+ ppc_chips[port].i2c_addr__7bf,
reg,
regval);
}
diff --git a/driver/ppc/nx20p348x.h b/driver/ppc/nx20p348x.h
index 531842d766..a04868c732 100644
--- a/driver/ppc/nx20p348x.h
+++ b/driver/ppc/nx20p348x.h
@@ -8,15 +8,15 @@
#ifndef __CROS_EC_NX20P348X_H
#define __CROS_EC_NX20P348X_H
-#define NX20P3483_ADDR0 0xE0
-#define NX20P3483_ADDR1 0xE2
-#define NX20P3483_ADDR2 0xE4
-#define NX20P3483_ADDR3 0xE6
-
-#define NX20P3481_ADDR0 0xE8
-#define NX20P3481_ADDR1 0xEA
-#define NX20P3481_ADDR2 0xEC
-#define NX20P3481_ADDR3 0xEE
+#define NX20P3483_ADDR0__7bf (0x70)
+#define NX20P3483_ADDR1__7bf (0x71)
+#define NX20P3483_ADDR2__7bf (0x72)
+#define NX20P3483_ADDR3__7bf (0x73)
+
+#define NX20P3481_ADDR0__7bf (0x74)
+#define NX20P3481_ADDR1__7bf (0x75)
+#define NX20P3481_ADDR2__7bf (0x76)
+#define NX20P3481_ADDR3__7bf (0x77)
/*
* This PPC hard-codes the over voltage protect of Vbus at 6.8V in dead-battery
diff --git a/driver/ppc/sn5s330.c b/driver/ppc/sn5s330.c
index 98c2641440..5cfbace742 100644
--- a/driver/ppc/sn5s330.c
+++ b/driver/ppc/sn5s330.c
@@ -31,16 +31,16 @@ static int source_enabled[CONFIG_USB_PD_PORT_COUNT];
static int read_reg(uint8_t port, int reg, int *regval)
{
- return i2c_read8(ppc_chips[port].i2c_port,
- ppc_chips[port].i2c_addr,
+ return i2c_read8__7bf(ppc_chips[port].i2c_port,
+ ppc_chips[port].i2c_addr__7bf,
reg,
regval);
}
static int write_reg(uint8_t port, int reg, int regval)
{
- return i2c_write8(ppc_chips[port].i2c_port,
- ppc_chips[port].i2c_addr,
+ return i2c_write8__7bf(ppc_chips[port].i2c_port,
+ ppc_chips[port].i2c_addr__7bf,
reg,
regval);
}
@@ -78,12 +78,12 @@ static int sn5s330_dump(int port)
int i;
int data;
const int i2c_port = ppc_chips[port].i2c_port;
- const int i2c_addr = ppc_chips[port].i2c_addr;
+ const uint16_t i2c_addr__7bf = ppc_chips[port].i2c_addr__7bf;
/* Flush after every set otherwise console buffer may get full. */
for (i = SN5S330_FUNC_SET1; i <= SN5S330_FUNC_SET12; i++) {
- i2c_read8(i2c_port, i2c_addr, i, &data);
+ i2c_read8__7bf(i2c_port, i2c_addr__7bf, i, &data);
ccprintf("FUNC_SET%d [%02Xh] = 0x%02x\n",
i - SN5S330_FUNC_SET1 + 1,
i,
@@ -93,7 +93,7 @@ static int sn5s330_dump(int port)
cflush();
for (i = SN5S330_INT_STATUS_REG1; i <= SN5S330_INT_STATUS_REG4; i++) {
- i2c_read8(i2c_port, i2c_addr, i, &data);
+ i2c_read8__7bf(i2c_port, i2c_addr__7bf, i, &data);
ccprintf("INT_STATUS_REG%d [%02Xh] = 0x%02x\n",
i - SN5S330_INT_STATUS_REG1 + 1,
i,
@@ -104,7 +104,7 @@ static int sn5s330_dump(int port)
for (i = SN5S330_INT_TRIP_RISE_REG1; i <= SN5S330_INT_TRIP_RISE_REG3;
i++) {
- i2c_read8(i2c_port, i2c_addr, i, &data);
+ i2c_read8__7bf(i2c_port, i2c_addr__7bf, i, &data);
ccprintf("INT_TRIP_RISE_REG%d [%02Xh] = 0x%02x\n",
i - SN5S330_INT_TRIP_RISE_REG1 + 1,
i,
@@ -115,7 +115,7 @@ static int sn5s330_dump(int port)
for (i = SN5S330_INT_TRIP_FALL_REG1; i <= SN5S330_INT_TRIP_FALL_REG3;
i++) {
- i2c_read8(i2c_port, i2c_addr, i, &data);
+ i2c_read8__7bf(i2c_port, i2c_addr__7bf, i, &data);
ccprintf("INT_TRIP_FALL_REG%d [%02Xh] = 0x%02x\n",
i - SN5S330_INT_TRIP_FALL_REG1 + 1,
i,
@@ -126,7 +126,7 @@ static int sn5s330_dump(int port)
for (i = SN5S330_INT_MASK_RISE_REG1; i <= SN5S330_INT_MASK_RISE_REG3;
i++) {
- i2c_read8(i2c_port, i2c_addr, i, &data);
+ i2c_read8__7bf(i2c_port, i2c_addr__7bf, i, &data);
ccprintf("INT_MASK_RISE_REG%d [%02Xh] = 0x%02x\n",
i - SN5S330_INT_MASK_RISE_REG1 + 1,
i,
@@ -137,7 +137,7 @@ static int sn5s330_dump(int port)
for (i = SN5S330_INT_MASK_FALL_REG1; i <= SN5S330_INT_MASK_FALL_REG3;
i++) {
- i2c_read8(i2c_port, i2c_addr, i, &data);
+ i2c_read8__7bf(i2c_port, i2c_addr__7bf, i, &data);
ccprintf("INT_MASK_FALL_REG%d [%02Xh] = 0x%02x\n",
i - SN5S330_INT_MASK_FALL_REG1 + 1,
i,
@@ -184,7 +184,7 @@ static int sn5s330_init(int port)
int retries;
int reg;
const int i2c_port = ppc_chips[port].i2c_port;
- const int i2c_addr = ppc_chips[port].i2c_addr;
+ const uint16_t i2c_addr__7bf = ppc_chips[port].i2c_addr__7bf;
#ifdef CONFIG_USB_PD_MAX_SINGLE_SOURCE_CURRENT
/* Set the sourcing current limit value. */
@@ -211,8 +211,8 @@ static int sn5s330_init(int port)
*/
retries = 0;
do {
- status = i2c_write8(i2c_port, i2c_addr, SN5S330_FUNC_SET1,
- regval);
+ status = i2c_write8__7bf(i2c_port, i2c_addr__7bf,
+ SN5S330_FUNC_SET1, regval);
if (status) {
CPRINTS("ppc p%d: Failed to set FUNC_SET1! Retrying..",
port);
@@ -225,21 +225,24 @@ static int sn5s330_init(int port)
/* Set Vbus OVP threshold to ~22.325V. */
regval = 0x37;
- status = i2c_write8(i2c_port, i2c_addr, SN5S330_FUNC_SET5, regval);
+ status = i2c_write8__7bf(i2c_port, i2c_addr__7bf,
+ SN5S330_FUNC_SET5, regval);
if (status) {
CPRINTS("ppc p%d: Failed to set FUNC_SET5!", port);
return status;
}
/* Set Vbus UVP threshold to ~2.75V. */
- status = i2c_read8(i2c_port, i2c_addr, SN5S330_FUNC_SET6, &regval);
+ status = i2c_read8__7bf(i2c_port, i2c_addr__7bf,
+ SN5S330_FUNC_SET6, &regval);
if (status) {
CPRINTS("ppc p%d: Failed to read FUNC_SET6!", port);
return status;
}
regval &= ~0x3F;
regval |= 1;
- status = i2c_write8(i2c_port, i2c_addr, SN5S330_FUNC_SET6, regval);
+ status = i2c_write8__7bf(i2c_port, i2c_addr__7bf,
+ SN5S330_FUNC_SET6, regval);
if (status) {
CPRINTS("ppc p%d: Failed to write FUNC_SET6!", port);
return status;
@@ -247,7 +250,8 @@ static int sn5s330_init(int port)
/* Enable SBU Fets and set PP2 current limit to ~3A. */
regval = SN5S330_SBU_EN | 0x8;
- status = i2c_write8(i2c_port, i2c_addr, SN5S330_FUNC_SET2, regval);
+ status = i2c_write8__7bf(i2c_port, i2c_addr__7bf,
+ SN5S330_FUNC_SET2, regval);
if (status) {
CPRINTS("ppc p%d: Failed to set FUNC_SET2!", port);
return status;
@@ -266,7 +270,8 @@ static int sn5s330_init(int port)
* low voltage protection).
*/
regval = SN5S330_OVP_EN_CC | SN5S330_PP2_CONFIG | SN5S330_CONFIG_UVP;
- status = i2c_write8(i2c_port, i2c_addr, SN5S330_FUNC_SET9, regval);
+ status = i2c_write8__7bf(i2c_port, i2c_addr__7bf,
+ SN5S330_FUNC_SET9, regval);
if (status) {
CPRINTS("ppc p%d: Failed to set FUNC_SET9!", port);
return status;
@@ -274,8 +279,8 @@ static int sn5s330_init(int port)
/* Set analog current limit delay to 200 us for both PP1 & PP2. */
regval = (PPX_ILIM_DEGLITCH_0_US_200 << 3) | PPX_ILIM_DEGLITCH_0_US_200;
- status = i2c_write8(i2c_port, i2c_addr, SN5S330_FUNC_SET11,
- regval);
+ status = i2c_write8__7bf(i2c_port, i2c_addr__7bf,
+ SN5S330_FUNC_SET11, regval);
if (status) {
CPRINTS("ppc p%d: Failed to set FUNC_SET11", port);
return status;
@@ -288,14 +293,16 @@ static int sn5s330_init(int port)
* reset default (20 us).
*/
regval = 0;
- status = i2c_read8(i2c_port, i2c_addr, SN5S330_FUNC_SET8, &regval);
+ status = i2c_read8__7bf(i2c_port, i2c_addr__7bf,
+ SN5S330_FUNC_SET8, &regval);
if (status) {
CPRINTS("ppc p%d: Failed to read FUNC_SET8!", port);
return status;
}
regval &= ~SN5S330_VCONN_DEGLITCH_MASK;
regval |= SN5S330_VCONN_DEGLITCH_640_US;
- status = i2c_write8(i2c_port, i2c_addr, SN5S330_FUNC_SET8, regval);
+ status = i2c_write8__7bf(i2c_port, i2c_addr__7bf,
+ SN5S330_FUNC_SET8, regval);
if (status) {
CPRINTS("ppc p%d: Failed to set FUNC_SET8!", port);
return status;
@@ -347,8 +354,8 @@ static int sn5s330_init(int port)
* is checked below.
*/
regval = SN5S330_DIG_RES | SN5S330_VSAFE0V_MASK;
- status = i2c_write8(i2c_port, i2c_addr, SN5S330_INT_STATUS_REG4,
- regval);
+ status = i2c_write8__7bf(i2c_port, i2c_addr__7bf,
+ SN5S330_INT_STATUS_REG4, regval);
if (status) {
CPRINTS("ppc p%d: Failed to write INT_STATUS_REG4!", port);
return status;
@@ -365,30 +372,30 @@ static int sn5s330_init(int port)
*/
regval = ~SN5S330_ILIM_PP1_MASK;
- status = i2c_write8(i2c_port, i2c_addr, SN5S330_INT_MASK_RISE_REG1,
- regval);
+ status = i2c_write8__7bf(i2c_port, i2c_addr__7bf,
+ SN5S330_INT_MASK_RISE_REG1, regval);
if (status) {
CPRINTS("ppc p%d: Failed to write INT_MASK_RISE1!", port);
return status;
}
- status = i2c_write8(i2c_port, i2c_addr, SN5S330_INT_MASK_FALL_REG1,
- regval);
+ status = i2c_write8__7bf(i2c_port, i2c_addr__7bf,
+ SN5S330_INT_MASK_FALL_REG1, regval);
if (status) {
CPRINTS("ppc p%d: Failed to write INT_MASK_FALL1!", port);
return status;
}
/* Now mask all the other interrupts. */
- status = i2c_write8(i2c_port, i2c_addr, SN5S330_INT_MASK_RISE_REG2,
- 0xFF);
+ status = i2c_write8__7bf(i2c_port, i2c_addr__7bf,
+ SN5S330_INT_MASK_RISE_REG2, 0xFF);
if (status) {
CPRINTS("ppc p%d: Failed to write INT_MASK_RISE2!", port);
return status;
}
- status = i2c_write8(i2c_port, i2c_addr, SN5S330_INT_MASK_FALL_REG2,
- 0xFF);
+ status = i2c_write8__7bf(i2c_port, i2c_addr__7bf,
+ SN5S330_INT_MASK_FALL_REG2, 0xFF);
if (status) {
CPRINTS("ppc p%d: Failed to write INT_MASK_FALL2!", port);
return status;
@@ -401,15 +408,15 @@ static int sn5s330_init(int port)
regval = 0xFF;
#endif /* CONFIG_USB_PD_VBUS_DETECT_PPC && CONFIG_USB_CHARGER */
- status = i2c_write8(i2c_port, i2c_addr, SN5S330_INT_MASK_RISE_REG3,
- regval);
+ status = i2c_write8__7bf(i2c_port, i2c_addr__7bf,
+ SN5S330_INT_MASK_RISE_REG3, regval);
if (status) {
CPRINTS("ppc p%d: Failed to write INT_MASK_RISE3!", port);
return status;
}
- status = i2c_write8(i2c_port, i2c_addr, SN5S330_INT_MASK_FALL_REG3,
- regval);
+ status = i2c_write8__7bf(i2c_port, i2c_addr__7bf,
+ SN5S330_INT_MASK_FALL_REG3, regval);
if (status) {
CPRINTS("ppc p%d: Failed to write INT_MASK_FALL3!", port);
return status;
@@ -419,7 +426,8 @@ static int sn5s330_init(int port)
for (reg = SN5S330_INT_TRIP_RISE_REG1;
reg <= SN5S330_INT_TRIP_FALL_REG3;
reg++) {
- status = i2c_write8(i2c_port, i2c_addr, reg, 0xFF);
+ status = i2c_write8__7bf(i2c_port, i2c_addr__7bf,
+ reg, 0xFF);
if (status) {
CPRINTS("ppc p%d: Failed to write reg 0x%2x!", port);
return status;
@@ -431,8 +439,8 @@ static int sn5s330_init(int port)
* For PP2, check to see if we booted in dead battery mode. If we
* booted in dead battery mode, the PP2 FET will already be enabled.
*/
- status = i2c_read8(i2c_port, i2c_addr, SN5S330_INT_STATUS_REG4,
- &regval);
+ status = i2c_read8__7bf(i2c_port, i2c_addr__7bf,
+ SN5S330_INT_STATUS_REG4, &regval);
if (status) {
CPRINTS("ppc p%d: Failed to read INT_STATUS_REG4!", port);
return status;
@@ -443,8 +451,8 @@ static int sn5s330_init(int port)
* Clear the bit by writing 1 and keep vSafe0V_MASK
* unchanged.
*/
- i2c_write8(i2c_port, i2c_addr, SN5S330_INT_STATUS_REG4,
- regval);
+ i2c_write8__7bf(i2c_port, i2c_addr__7bf,
+ SN5S330_INT_STATUS_REG4, regval);
/* Turn on PP2 FET. */
status = sn5s330_pp_fet_enable(port, SN5S330_PP2, 1);
diff --git a/driver/ppc/sn5s330.h b/driver/ppc/sn5s330.h
index 6c79aa46ed..95f8fb4ac7 100644
--- a/driver/ppc/sn5s330.h
+++ b/driver/ppc/sn5s330.h
@@ -12,7 +12,7 @@
struct sn5s330_config {
uint8_t i2c_port;
- uint8_t i2c_addr;
+ uint8_t i2c_addr__7bf;
};
extern const struct sn5s330_config sn5s330_chips[];
@@ -25,10 +25,10 @@ enum sn5s330_pp_idx {
SN5S330_PP_COUNT,
};
-#define SN5S330_ADDR0 0x80
-#define SN5S330_ADDR1 0x82
-#define SN5S330_ADDR2 0x84
-#define SN5S330_ADDR3 0x86
+#define SN5S330_ADDR0__7bf (0x40)
+#define SN5S330_ADDR1__7bf (0x41)
+#define SN5S330_ADDR2__7bf (0x42)
+#define SN5S330_ADDR3__7bf (0x43)
#define SN5S330_FUNC_SET1 0x50
#define SN5S330_FUNC_SET2 0x51
diff --git a/driver/ppc/syv682x.c b/driver/ppc/syv682x.c
index 24a8b9a3ee..a8f5c146bb 100644
--- a/driver/ppc/syv682x.c
+++ b/driver/ppc/syv682x.c
@@ -23,16 +23,16 @@ static uint8_t flags[CONFIG_USB_PD_PORT_COUNT];
static int read_reg(uint8_t port, int reg, int *regval)
{
- return i2c_read8(ppc_chips[port].i2c_port,
- ppc_chips[port].i2c_addr,
+ return i2c_read8__7bf(ppc_chips[port].i2c_port,
+ ppc_chips[port].i2c_addr__7bf,
reg,
regval);
}
static int write_reg(uint8_t port, int reg, int regval)
{
- return i2c_write8(ppc_chips[port].i2c_port,
- ppc_chips[port].i2c_addr,
+ return i2c_write8__7bf(ppc_chips[port].i2c_port,
+ ppc_chips[port].i2c_addr__7bf,
reg,
regval);
}
@@ -258,11 +258,11 @@ static int syv682x_dump(int port)
int data;
int rv;
const int i2c_port = ppc_chips[port].i2c_port;
- const int i2c_addr = ppc_chips[port].i2c_addr;
+ const int i2c_addr__7bf = ppc_chips[port].i2c_addr__7bf;
for (reg_addr = SYV682X_STATUS_REG; reg_addr <= SYV682X_CONTROL_4_REG;
reg_addr++) {
- rv = i2c_read8(i2c_port, i2c_addr, reg_addr, &data);
+ rv = i2c_read8__7bf(i2c_port, i2c_addr__7bf, reg_addr, &data);
if (rv)
ccprintf("ppc_syv682[p%d]: Failed to read reg 0x%02x\n",
port, reg_addr);
diff --git a/driver/ppc/syv682x.h b/driver/ppc/syv682x.h
index 98bb67d522..f355fe1cf9 100644
--- a/driver/ppc/syv682x.h
+++ b/driver/ppc/syv682x.h
@@ -8,11 +8,11 @@
#ifndef __CROS_EC_SYV682X_H
#define __CROS_EC_SYV682X_H
-/* 8 bit I2C addresses */
-#define SYV682X_ADDR0 0x80
-#define SYV682X_ADDR1 0x82
-#define SYV682X_ADDR2 0x84
-#define SYV682x_ADDR3 0x86
+/* I2C addresses */
+#define SYV682X_ADDR0__7bf 0x40
+#define SYV682X_ADDR1__7bf 0x41
+#define SYV682X_ADDR2__7bf 0x42
+#define SYV682x_ADDR3__7bf 0x43
/* SYV682x register addresses */
#define SYV682X_STATUS_REG 0x00
diff --git a/driver/regulator_ir357x.c b/driver/regulator_ir357x.c
index d2aaeccd99..0e88eeaf37 100644
--- a/driver/regulator_ir357x.c
+++ b/driver/regulator_ir357x.c
@@ -16,8 +16,8 @@
#define CPUTS(outstr) cputs(CC_CHIPSET, outstr)
#define CPRINTF(format, args...) cprintf(CC_CHIPSET, format, ## args)
-/* 8-bit I2C address */
-#define IR357x_I2C_ADDR (0x8 << 1)
+/* I2C address */
+#define IR357x_I2C_ADDR__7bf (0x8)
struct ir_setting {
uint8_t reg;
diff --git a/driver/sensorhub_lsm6dsm.c b/driver/sensorhub_lsm6dsm.c
index f663f5a5ae..711294fb98 100644
--- a/driver/sensorhub_lsm6dsm.c
+++ b/driver/sensorhub_lsm6dsm.c
@@ -21,12 +21,12 @@ static int set_reg_bit_field(const struct motion_sensor_t *s,
int tmp;
int ret;
- ret = st_raw_read8(s->port, s->addr, reg, &tmp);
+ ret = st_raw_read8__7bf(s->port, s->i2c_spi_addr__7bf, reg, &tmp);
if (ret != EC_SUCCESS)
return ret;
tmp |= bit_field;
- return st_raw_write8(s->port, s->addr, reg, tmp);
+ return st_raw_write8__7bf(s->port, s->i2c_spi_addr__7bf, reg, tmp);
}
static int clear_reg_bit_field(const struct motion_sensor_t *s,
@@ -35,12 +35,12 @@ static int clear_reg_bit_field(const struct motion_sensor_t *s,
int tmp;
int ret;
- ret = st_raw_read8(s->port, s->addr, reg, &tmp);
+ ret = st_raw_read8__7bf(s->port, s->i2c_spi_addr__7bf, reg, &tmp);
if (ret != EC_SUCCESS)
return ret;
tmp &= ~(bit_field);
- return st_raw_write8(s->port, s->addr, reg, tmp);
+ return st_raw_write8__7bf(s->port, s->i2c_spi_addr__7bf, reg, tmp);
}
static inline int enable_sensorhub_func(const struct motion_sensor_t *s)
@@ -89,7 +89,8 @@ static inline int disable_aux_i2c_master(const struct motion_sensor_t *s)
static inline int restore_master_cfg(const struct motion_sensor_t *s,
int cache)
{
- return st_raw_write8(s->port, s->addr, LSM6DSM_MASTER_CFG_ADDR, cache);
+ return st_raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ LSM6DSM_MASTER_CFG_ADDR, cache);
}
static int enable_i2c_pass_through(const struct motion_sensor_t *s,
@@ -97,7 +98,8 @@ static int enable_i2c_pass_through(const struct motion_sensor_t *s,
{
int ret;
- ret = st_raw_read8(s->port, s->addr, LSM6DSM_MASTER_CFG_ADDR, cache);
+ ret = st_raw_read8__7bf(s->port, s->i2c_spi_addr__7bf,
+ LSM6DSM_MASTER_CFG_ADDR, cache);
if (ret != EC_SUCCESS) {
CPRINTF("%s: %s type:0x%x MCR error ret: %d\n",
__func__, s->name, s->type, ret);
@@ -109,8 +111,9 @@ static int enable_i2c_pass_through(const struct motion_sensor_t *s,
* Wait is for any pending bus activity(probably read) to settle down
* so that there is no bus contention.
*/
- ret = st_raw_write8(s->port, s->addr, LSM6DSM_MASTER_CFG_ADDR,
- *cache | LSM6DSM_EXT_TRIGGER_EN);
+ ret = st_raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ LSM6DSM_MASTER_CFG_ADDR,
+ *cache | LSM6DSM_EXT_TRIGGER_EN);
if (ret != EC_SUCCESS) {
CPRINTF("%s: %s type:0x%x MCETEN error ret: %d\n",
__func__, s->name, s->type, ret);
@@ -118,8 +121,10 @@ static int enable_i2c_pass_through(const struct motion_sensor_t *s,
}
msleep(10);
- ret = st_raw_write8(s->port, s->addr, LSM6DSM_MASTER_CFG_ADDR,
- *cache & ~(LSM6DSM_EXT_TRIGGER_EN | LSM6DSM_I2C_MASTER_ON));
+ ret = st_raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ LSM6DSM_MASTER_CFG_ADDR,
+ *cache & ~(LSM6DSM_EXT_TRIGGER_EN
+ | LSM6DSM_I2C_MASTER_ON));
if (ret != EC_SUCCESS) {
CPRINTF("%s: %s type:0x%x MCC error ret: %d\n",
__func__, s->name, s->type, ret);
@@ -127,7 +132,7 @@ static int enable_i2c_pass_through(const struct motion_sensor_t *s,
return ret;
}
- return st_raw_write8(s->port, s->addr,
+ return st_raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
LSM6DSM_MASTER_CFG_ADDR, LSM6DSM_I2C_PASS_THRU_MODE);
}
@@ -136,37 +141,43 @@ static inline int power_down_accel(const struct motion_sensor_t *s,
{
int ret;
- ret = st_raw_read8(s->port, s->addr, LSM6DSM_CTRL1_ADDR, cache);
+ ret = st_raw_read8__7bf(s->port, s->i2c_spi_addr__7bf,
+ LSM6DSM_CTRL1_ADDR, cache);
if (ret != EC_SUCCESS) {
CPRINTF("%s: %s type:0x%x CTRL1R error ret: %d\n",
__func__, s->name, s->type, ret);
return ret;
}
- return st_raw_write8(s->port, s->addr, LSM6DSM_CTRL1_ADDR,
- *cache & ~LSM6DSM_XL_ODR_MASK);
+ return st_raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ LSM6DSM_CTRL1_ADDR,
+ *cache & ~LSM6DSM_XL_ODR_MASK);
}
static inline int restore_ctrl1(const struct motion_sensor_t *s, int cache)
{
- return st_raw_write8(s->port, s->addr,
- LSM6DSM_CTRL1_ADDR, cache);
+ return st_raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ LSM6DSM_CTRL1_ADDR, cache);
}
-static int config_slv0_read(const struct motion_sensor_t *s, uint8_t addr,
- uint8_t reg, uint8_t len)
+static int config_slv0_read__7bf(const struct motion_sensor_t *s,
+ const uint16_t slv_addr__7bf,
+ uint16_t reg, uint8_t len)
{
int ret;
+ uint16_t addr__8b = I2C_GET_ADDR__7b(slv_addr__7bf) << 1;
- ret = st_raw_write8(s->port, s->addr, LSM6DSM_SLV0_ADD_ADDR,
- (addr | LSM6DSM_SLV0_RD_BIT));
+ ret = st_raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ LSM6DSM_SLV0_ADD_ADDR,
+ (addr__8b | LSM6DSM_SLV0_RD_BIT));
if (ret != EC_SUCCESS) {
CPRINTF("%s: %s type:0x%x SA error ret: %d\n",
__func__, s->name, s->type, ret);
return ret;
}
- ret = st_raw_write8(s->port, s->addr, LSM6DSM_SLV0_SUBADD_ADDR, reg);
+ ret = st_raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ LSM6DSM_SLV0_SUBADD_ADDR, reg);
if (ret != EC_SUCCESS) {
CPRINTF("%s: %s type:0x%x RA error ret: %d\n",
__func__, s->name, s->type, ret);
@@ -177,8 +188,9 @@ static int config_slv0_read(const struct motion_sensor_t *s, uint8_t addr,
* No decimation for external sensor 0,
* Number of sensors connected to external sensor hub 1
*/
- ret = st_raw_write8(s->port, s->addr, LSM6DSM_SLV0_CONFIG_ADDR,
- (len & LSM6DSM_SLV0_NUM_OPS_MASK));
+ ret = st_raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ LSM6DSM_SLV0_CONFIG_ADDR,
+ (len & LSM6DSM_SLV0_NUM_OPS_MASK));
if (ret != EC_SUCCESS) {
CPRINTF("%s: %s type:0x%x CFG error ret: %d\n",
__func__, s->name, s->type, ret);
@@ -188,8 +200,9 @@ static int config_slv0_read(const struct motion_sensor_t *s, uint8_t addr,
return EC_SUCCESS;
}
-int sensorhub_config_ext_reg(const struct motion_sensor_t *s,
- uint8_t slv_addr, uint8_t reg, uint8_t val)
+int sensorhub_config_ext_reg__7bf(const struct motion_sensor_t *s,
+ const uint16_t slv_addr__7bf,
+ uint8_t reg, uint8_t val)
{
int ret;
int tmp;
@@ -201,13 +214,13 @@ int sensorhub_config_ext_reg(const struct motion_sensor_t *s,
return ret;
}
- ret = st_raw_write8(s->port, slv_addr, reg, val);
+ ret = st_raw_write8__7bf(s->port, slv_addr__7bf, reg, val);
restore_master_cfg(s, tmp);
return ret;
}
-int sensorhub_config_slv0_read(const struct motion_sensor_t *s,
- uint8_t slv_addr, uint8_t reg, int len)
+int sensorhub_config_slv0_read__7bf(const struct motion_sensor_t *s,
+ uint16_t slv_addr__7bf, uint8_t reg, int len)
{
int tmp_xl_cfg;
int ret;
@@ -232,7 +245,7 @@ int sensorhub_config_slv0_read(const struct motion_sensor_t *s,
goto out_restore_ctrl1;
}
- ret = config_slv0_read(s, slv_addr, reg, len);
+ ret = config_slv0_read__7bf(s, slv_addr__7bf, reg, len);
disable_ereg_bank_acc(s);
if (ret != EC_SUCCESS) {
CPRINTF("%s: %s type:0x%x CS0R error ret: %d\n",
@@ -267,8 +280,9 @@ int sensorhub_slv0_data_read(const struct motion_sensor_t *s, uint8_t *raw)
* register as soon as the accel is in power-up mode. So return the
* contents of that register.
*/
- ret = st_raw_read_n_noinc(s->port, s->addr, LSM6DSM_SENSORHUB1_REG,
- raw, OUT_XYZ_SIZE);
+ ret = st_raw_read_n_noinc__7bf(s->port, s->i2c_spi_addr__7bf,
+ LSM6DSM_SENSORHUB1_REG,
+ raw, OUT_XYZ_SIZE);
if (ret != EC_SUCCESS) {
CPRINTF("%s: %s type:0x%x SH1R error ret: %d\n",
__func__, s->name, s->type, ret);
@@ -277,9 +291,10 @@ int sensorhub_slv0_data_read(const struct motion_sensor_t *s, uint8_t *raw)
return EC_SUCCESS;
}
-int sensorhub_check_and_rst(const struct motion_sensor_t *s, uint8_t slv_addr,
- uint8_t whoami_reg, uint8_t whoami_val,
- uint8_t rst_reg, uint8_t rst_val)
+int sensorhub_check_and_rst__7bf(const struct motion_sensor_t *s,
+ const uint16_t slv_addr__7bf,
+ uint8_t whoami_reg, uint8_t whoami_val,
+ uint8_t rst_reg, uint8_t rst_val)
{
int ret, tmp;
int tmp_master_cfg;
@@ -291,7 +306,7 @@ int sensorhub_check_and_rst(const struct motion_sensor_t *s, uint8_t slv_addr,
return ret;
}
- ret = st_raw_read8(s->port, slv_addr, whoami_reg, &tmp);
+ ret = st_raw_read8__7bf(s->port, slv_addr__7bf, whoami_reg, &tmp);
if (ret != EC_SUCCESS) {
CPRINTF("%s: %s type:0x%x WAIR error ret: %d\n",
__func__, s->name, s->type, ret);
@@ -305,7 +320,7 @@ int sensorhub_check_and_rst(const struct motion_sensor_t *s, uint8_t slv_addr,
goto err_restore_master_cfg;
}
- ret = st_raw_write8(s->port, slv_addr, rst_reg, rst_val);
+ ret = st_raw_write8__7bf(s->port, slv_addr__7bf, rst_reg, rst_val);
err_restore_master_cfg:
restore_master_cfg(s, tmp_master_cfg);
return ret;
diff --git a/driver/sensorhub_lsm6dsm.h b/driver/sensorhub_lsm6dsm.h
index a86ca6f9c3..0eaef61c32 100644
--- a/driver/sensorhub_lsm6dsm.h
+++ b/driver/sensorhub_lsm6dsm.h
@@ -24,8 +24,9 @@
* @param val Value to be written into the external sensor register.
* @return EC_SUCCESS on success, EC error codes on failure.
*/
-int sensorhub_config_ext_reg(const struct motion_sensor_t *s,
- uint8_t slv_addr, uint8_t reg, uint8_t val);
+int sensorhub_config_ext_reg__7bf(const struct motion_sensor_t *s,
+ const uint16_t slv_addr__7bf,
+ uint8_t reg, uint8_t val);
/**
* Configure the sensor hub to read data from a specific register of an
@@ -37,8 +38,9 @@ int sensorhub_config_ext_reg(const struct motion_sensor_t *s,
* @param len Length of data to be read.
* @return EC_SUCCESS on success, EC error codes on failure.
*/
-int sensorhub_config_slv0_read(const struct motion_sensor_t *s,
- uint8_t slv_addr, uint8_t reg, int len);
+int sensorhub_config_slv0_read__7bf(const struct motion_sensor_t *s,
+ const uint16_t slv_addr__7bf,
+ uint8_t reg, int len);
/**
* Reads the data from the register bank that is associated with the slave0
@@ -62,7 +64,8 @@ int sensorhub_slv0_data_read(const struct motion_sensor_t *s, uint8_t *raw);
* @param rst_val Value to be written to the reset register.
* @return EC_SUCCESS on success, EC error codes on failure.
*/
-int sensorhub_check_and_rst(const struct motion_sensor_t *s, uint8_t slv_addr,
- uint8_t whoami_reg, uint8_t whoami_val,
- uint8_t rst_reg, uint8_t rst_val);
+int sensorhub_check_and_rst__7bf(const struct motion_sensor_t *s,
+ const uint16_t slv_addr__7bf,
+ uint8_t whoami_reg, uint8_t whoami_val,
+ uint8_t rst_reg, uint8_t rst_val);
#endif /* __CROS_EC_SENSORHUB_LSM6DSM_H */
diff --git a/driver/stm_mems_common.c b/driver/stm_mems_common.c
index 00784fc1fc..9341308fb5 100644
--- a/driver/stm_mems_common.c
+++ b/driver/stm_mems_common.c
@@ -11,21 +11,25 @@
/**
* st_raw_read_n - Read n bytes for read
*/
-int st_raw_read_n(const int port, const int addr, const uint8_t reg,
- uint8_t *data_ptr, const int len)
+int st_raw_read_n__7bf(const int port,
+ const uint16_t i2c_addr__7bf,
+ const uint8_t reg, uint8_t *data_ptr, const int len)
{
/* TODO: Implement SPI interface support */
- return i2c_read_block(port, addr, reg | 0x80, data_ptr, len);
+ return i2c_read_block__7bf(port, i2c_addr__7bf,
+ reg | 0x80, data_ptr, len);
}
/**
* st_raw_read_n_noinc - Read n bytes for read (no auto inc address)
*/
-int st_raw_read_n_noinc(const int port, const int addr, const uint8_t reg,
- uint8_t *data_ptr, const int len)
+int st_raw_read_n_noinc__7bf(const int port,
+ const uint16_t i2c_addr__7bf,
+ const uint8_t reg, uint8_t *data_ptr, const int len)
{
/* TODO: Implement SPI interface support */
- return i2c_read_block(port, addr, reg, data_ptr, len);
+ return i2c_read_block__7bf(port, i2c_addr__7bf,
+ reg, data_ptr, len);
}
/**
@@ -41,7 +45,8 @@ int st_write_data_with_mask(const struct motion_sensor_t *s, int reg,
int err;
int new_data = 0x00, old_data = 0x00;
- err = st_raw_read8(s->port, s->addr, reg, &old_data);
+ err = st_raw_read8__7bf(s->port, s->i2c_spi_addr__7bf,
+ reg, &old_data);
if (err != EC_SUCCESS)
return err;
@@ -51,7 +56,8 @@ int st_write_data_with_mask(const struct motion_sensor_t *s, int reg,
if (new_data == old_data)
return EC_SUCCESS;
- return st_raw_write8(s->port, s->addr, reg, new_data);
+ return st_raw_write8__7bf(s->port, s->i2c_spi_addr__7bf,
+ reg, new_data);
}
/**
diff --git a/driver/stm_mems_common.h b/driver/stm_mems_common.h
index e2211480aa..39d718cf1b 100644
--- a/driver/stm_mems_common.h
+++ b/driver/stm_mems_common.h
@@ -34,34 +34,38 @@
/**
* Read single register
*/
-static inline int st_raw_read8(const int port, const int addr, const int reg,
- int *data_ptr)
+static inline int st_raw_read8__7bf(const int port,
+ const uint16_t i2c_spi_addr__7bf,
+ const int reg, int *data_ptr)
{
/* TODO: Implement SPI interface support */
- return i2c_read8(port, addr, reg, data_ptr);
+ return i2c_read8__7bf(port, i2c_spi_addr__7bf, reg, data_ptr);
}
/**
* Write single register
*/
-static inline int st_raw_write8(const int port, const int addr, const int reg,
- int data)
+static inline int st_raw_write8__7bf(const int port,
+ const uint16_t i2c_spi_addr__7bf,
+ const int reg, int data)
{
/* TODO: Implement SPI interface support */
- return i2c_write8(port, addr, reg, data);
+ return i2c_write8__7bf(port, i2c_spi_addr__7bf, reg, data);
}
/**
* st_raw_read_n - Read n bytes for read
*/
-int st_raw_read_n(const int port, const int addr, const uint8_t reg,
- uint8_t *data_ptr, const int len);
+int st_raw_read_n__7bf(const int port,
+ const uint16_t i2c_spi_addr__7bf,
+ const uint8_t reg, uint8_t *data_ptr, const int len);
/**
* st_raw_read_n_noinc - Read n bytes for read (no auto inc address)
*/
-int st_raw_read_n_noinc(const int port, const int addr, const uint8_t reg,
- uint8_t *data_ptr, const int len);
+int st_raw_read_n_noinc__7bf(const int port,
+ const uint16_t i2c_spi_addr__7bf,
+ const uint8_t reg, uint8_t *data_ptr, const int len);
/**
* st_write_data_with_mask - Write register with mask
diff --git a/driver/tcpm/anx7447.c b/driver/tcpm/anx7447.c
index 0a3c98c6ac..7883f72717 100644
--- a/driver/tcpm/anx7447.c
+++ b/driver/tcpm/anx7447.c
@@ -5,6 +5,7 @@
/* ANX7447 port manager */
+#include "common.h"
#include "anx7447.h"
#include "console.h"
#include "hooks.h"
@@ -40,7 +41,7 @@
(((anx7447_get_vbus_voltage(port))) > vsafe0v_max)
struct anx_state {
- int i2c_slave_addr;
+ uint16_t i2c_slave_addr__7bf;
};
struct anx_usb_mux {
@@ -63,18 +64,18 @@ static struct anx_usb_mux mux[CONFIG_USB_PD_PORT_COUNT];
* anx7447_reg_write() and anx7447_reg_read() are implemented here to access
* ANX7447 SPI slave address.
*/
-const struct anx7447_i2c_addr anx7447_i2c_addrs[] = {
- {AN7447_TCPC0_I2C_ADDR, AN7447_SPI0_I2C_ADDR},
- {AN7447_TCPC1_I2C_ADDR, AN7447_SPI1_I2C_ADDR},
- {AN7447_TCPC2_I2C_ADDR, AN7447_SPI2_I2C_ADDR},
- {AN7447_TCPC3_I2C_ADDR, AN7447_SPI3_I2C_ADDR}
+const struct anx7447_i2c_addr anx7447_i2c_addrs__7bf[] = {
+ {AN7447_TCPC0_I2C_ADDR__7bf, AN7447_SPI0_I2C_ADDR__7bf},
+ {AN7447_TCPC1_I2C_ADDR__7bf, AN7447_SPI1_I2C_ADDR__7bf},
+ {AN7447_TCPC2_I2C_ADDR__7bf, AN7447_SPI2_I2C_ADDR__7bf},
+ {AN7447_TCPC3_I2C_ADDR__7bf, AN7447_SPI3_I2C_ADDR__7bf}
};
static inline int anx7447_reg_write(int port, int reg, int val)
{
- int rv = i2c_write8(tcpc_config[port].i2c_info.port,
- anx[port].i2c_slave_addr,
- reg, val);
+ int rv = i2c_write8__7bf(tcpc_config[port].i2c_info.port,
+ anx[port].i2c_slave_addr__7bf,
+ reg, val);
#ifdef CONFIG_USB_PD_TCPC_LOW_POWER
pd_device_accessed(port);
#endif
@@ -83,9 +84,9 @@ static inline int anx7447_reg_write(int port, int reg, int val)
static inline int anx7447_reg_read(int port, int reg, int *val)
{
- int rv = i2c_read8(tcpc_config[port].i2c_info.port,
- anx[port].i2c_slave_addr,
- reg, val);
+ int rv = i2c_read8__7bf(tcpc_config[port].i2c_info.port,
+ anx[port].i2c_slave_addr__7bf,
+ reg, val);
#ifdef CONFIG_USB_PD_TCPC_LOW_POWER
pd_device_accessed(port);
#endif
@@ -290,17 +291,20 @@ static int anx7447_init(int port)
* find corresponding anx7447 SPI slave address according to
* specified TCPC slave address
*/
- for (i = 0; i < ARRAY_SIZE(anx7447_i2c_addrs); i++) {
- if (tcpc_config[port].i2c_info.addr ==
- anx7447_i2c_addrs[i].tcpc_slave_addr) {
- anx[port].i2c_slave_addr =
- anx7447_i2c_addrs[i].spi_slave_addr;
+ for (i = 0; i < ARRAY_SIZE(anx7447_i2c_addrs__7bf); i++) {
+ if (I2C_GET_ADDR__7b(
+ tcpc_config[port].i2c_info.addr__7bf) ==
+ I2C_GET_ADDR__7b(
+ anx7447_i2c_addrs__7bf[i].tcpc_slave_addr__7bf)) {
+ anx[port].i2c_slave_addr__7bf =
+ anx7447_i2c_addrs__7bf[i].spi_slave_addr__7bf;
break;
}
}
- if (!anx[port].i2c_slave_addr) {
+ if (!I2C_GET_ADDR__7b(anx[port].i2c_slave_addr__7bf)) {
ccprintf("TCPC I2C slave addr 0x%x is invalid for ANX7447\n",
- tcpc_config[port].i2c_info.addr);
+ I2C_GET_ADDR__7b(tcpc_config[port]
+ .i2c_info.addr__7bf));
return EC_ERROR_UNKNOWN;
}
diff --git a/driver/tcpm/anx7447.h b/driver/tcpm/anx7447.h
index 093d74238a..32958f0007 100644
--- a/driver/tcpm/anx7447.h
+++ b/driver/tcpm/anx7447.h
@@ -91,19 +91,19 @@
/* End of defines used for CONFIG_USB_PD_TCPM_ANX7447_OCM_ERASE_COMMAND */
struct anx7447_i2c_addr {
- int tcpc_slave_addr;
- int spi_slave_addr;
+ uint16_t tcpc_slave_addr__7bf;
+ uint16_t spi_slave_addr__7bf;
};
-#define AN7447_TCPC0_I2C_ADDR 0x58
-#define AN7447_TCPC1_I2C_ADDR 0x56
-#define AN7447_TCPC2_I2C_ADDR 0x54
-#define AN7447_TCPC3_I2C_ADDR 0x52
+#define AN7447_TCPC0_I2C_ADDR__7bf (0x2C)
+#define AN7447_TCPC1_I2C_ADDR__7bf (0x2B)
+#define AN7447_TCPC2_I2C_ADDR__7bf (0x2A)
+#define AN7447_TCPC3_I2C_ADDR__7bf (0x29)
-#define AN7447_SPI0_I2C_ADDR 0x7E
-#define AN7447_SPI1_I2C_ADDR 0x6E
-#define AN7447_SPI2_I2C_ADDR 0x64
-#define AN7447_SPI3_I2C_ADDR 0x62
+#define AN7447_SPI0_I2C_ADDR__7bf (0x3F)
+#define AN7447_SPI1_I2C_ADDR__7bf (0x37)
+#define AN7447_SPI2_I2C_ADDR__7bf (0x32)
+#define AN7447_SPI3_I2C_ADDR__7bf (0x31)
/*
* Time TEST_R must be held high for a reset
diff --git a/driver/tcpm/anx74xx.c b/driver/tcpm/anx74xx.c
index 274e668960..8973a34213 100644
--- a/driver/tcpm/anx74xx.c
+++ b/driver/tcpm/anx74xx.c
@@ -1173,7 +1173,7 @@ struct i2c_stress_test_dev anx74xx_i2c_stress_test_dev = {
.read_val = ANX74XX_VENDOR_ID & 0xFF,
.write_reg = ANX74XX_REG_CC_SOFTWARE_CTRL,
},
- .i2c_read = &tcpc_i2c_read,
- .i2c_write = &tcpc_i2c_write,
+ .i2c_read__7bf = &tcpc_i2c_read__7bf,
+ .i2c_write__7bf = &tcpc_i2c_write__7bf,
};
#endif /* CONFIG_CMD_I2C_STRESS_TEST_TCPC */
diff --git a/driver/tcpm/anx74xx.h b/driver/tcpm/anx74xx.h
index 18708d38b4..39762129a7 100644
--- a/driver/tcpm/anx74xx.h
+++ b/driver/tcpm/anx74xx.h
@@ -11,10 +11,10 @@
#define __CROS_EC_USB_PD_TCPM_ANX74XX_H
/* I2C interface */
-#define ANX74XX_I2C_ADDR1 0x50
-#define ANX74XX_I2C_ADDR2 0x72
-#define ANX74XX_I2C_ADDR3 0x7C
-#define ANX74XX_I2C_ADDR4 0x80
+#define ANX74XX_I2C_ADDR1__7bf 0x28
+#define ANX74XX_I2C_ADDR2__7bf 0x39
+#define ANX74XX_I2C_ADDR3__7bf 0x3E
+#define ANX74XX_I2C_ADDR4__7bf 0x40
#define ANX74XX_REG_IRQ_POL_LOW 0x00
#define ANX74XX_REG_IRQ_POL_HIGH 0x02
diff --git a/driver/tcpm/anx7688.c b/driver/tcpm/anx7688.c
index bac65892de..4ea0602483 100644
--- a/driver/tcpm/anx7688.c
+++ b/driver/tcpm/anx7688.c
@@ -21,7 +21,7 @@
#define ANX7688_REG_HPD_IRQ BIT(1)
#define ANX7688_REG_HPD_ENABLE BIT(2)
-#define ANX7688_USBC_ADDR 0x50
+#define ANX7688_USBC_ADDR__7bf 0x28
#define ANX7688_REG_RAMCTRL 0xe7
#define ANX7688_REG_RAMCTRL_BOOT_DONE BIT(6)
@@ -39,7 +39,7 @@ static int anx7688_init(int port)
* 100ms to follow cts.
*/
while (1) {
- rv = i2c_read8(I2C_PORT_TCPC, ANX7688_USBC_ADDR,
+ rv = i2c_read8__7bf(I2C_PORT_TCPC, ANX7688_USBC_ADDR__7bf,
ANX7688_REG_RAMCTRL, &mask);
if (rv == EC_SUCCESS && (mask & ANX7688_REG_RAMCTRL_BOOT_DONE))
@@ -174,7 +174,7 @@ static int anx7688_tcpm_get_vbus_level(int port)
* Therefore, we use a proprietary register to read the unfiltered VBus
* value. See crosbug.com/p/55221 .
*/
- i2c_read8(I2C_PORT_TCPC, 0x50, 0x40, &reg);
+ i2c_read8__7bf(I2C_PORT_TCPC, 0x28, 0x40, &reg);
return ((reg & 0x10) ? 1 : 0);
}
#endif
diff --git a/driver/tcpm/fusb302.h b/driver/tcpm/fusb302.h
index 6236e47439..edf1feb8dd 100644
--- a/driver/tcpm/fusb302.h
+++ b/driver/tcpm/fusb302.h
@@ -16,13 +16,13 @@
/* I2C slave address varies by part number */
/* FUSB302BUCX / FUSB302BMPX */
-#define FUSB302_I2C_SLAVE_ADDR 0x44
+#define FUSB302_I2C_SLAVE_ADDR__7bf 0x22
/* FUSB302B01MPX */
-#define FUSB302_I2C_SLAVE_ADDR_B01 0x46
+#define FUSB302_I2C_SLAVE_ADDR_B01__7bf 0x23
/* FUSB302B10MPX */
-#define FUSB302_I2C_SLAVE_ADDR_B10 0x48
+#define FUSB302_I2C_SLAVE_ADDR_B10__7bf 0x24
/* FUSB302B11MPX */
-#define FUSB302_I2C_SLAVE_ADDR_B11 0x4A
+#define FUSB302_I2C_SLAVE_ADDR_B11__7bf 0x25
/* Default retry count for transmitting */
#define PD_RETRY_COUNT 3
diff --git a/driver/tcpm/mt6370.c b/driver/tcpm/mt6370.c
index dc6c86d2c4..473e2a1881 100644
--- a/driver/tcpm/mt6370.c
+++ b/driver/tcpm/mt6370.c
@@ -22,8 +22,8 @@
/* i2c_write function which won't wake TCPC from low power mode. */
static int mt6370_i2c_write8(int port, int reg, int val)
{
- return i2c_write8(tcpc_config[port].i2c_info.port,
- tcpc_config[port].i2c_info.addr, reg, val);
+ return i2c_write8__7bf(tcpc_config[port].i2c_info.port,
+ tcpc_config[port].i2c_info.addr__7bf, reg, val);
}
static int mt6370_init(int port)
diff --git a/driver/tcpm/mt6370.h b/driver/tcpm/mt6370.h
index 1d30d27f8f..166009d9a4 100644
--- a/driver/tcpm/mt6370.h
+++ b/driver/tcpm/mt6370.h
@@ -48,7 +48,7 @@
#define MT6370_REG_UNLOCK_PW2 0xF0
#define MT6370_REG_UNLOCK_PW1 0xF1
-#define MT6370_TCPC_I2C_ADDR 0x9C
+#define MT6370_TCPC_I2C_ADDR__7bf 0x4E
/*
* MT6370_REG_PHY_CTRL1 0x80
diff --git a/driver/tcpm/nct38xx.h b/driver/tcpm/nct38xx.h
index 367a30d17a..1357d47bab 100644
--- a/driver/tcpm/nct38xx.h
+++ b/driver/tcpm/nct38xx.h
@@ -10,15 +10,15 @@
#define __CROS_EC_USB_PD_TCPM_NCT38XX_H
/* I2C interface */
-#define NCT38xx_I2C_ADDR1_1 0xE0
-#define NCT38xx_I2C_ADDR1_2 0xE2
-#define NCT38xx_I2C_ADDR1_3 0xE4
-#define NCT38xx_I2C_ADDR1_4 0xE6
-
-#define NCT38xx_I2C_ADDR2_1 0xE8
-#define NCT38xx_I2C_ADDR2_2 0xEA
-#define NCT38xx_I2C_ADDR2_3 0xEC
-#define NCT38xx_I2C_ADDR2_4 0xEE
+#define NCT38xx_I2C_ADDR1_1__7bf 0x70
+#define NCT38xx_I2C_ADDR1_2__7bf 0x71
+#define NCT38xx_I2C_ADDR1_3__7bf 0x72
+#define NCT38xx_I2C_ADDR1_4__7bf 0x73
+
+#define NCT38xx_I2C_ADDR2_1__7bf 0x74
+#define NCT38xx_I2C_ADDR2_2__7bf 0x75
+#define NCT38xx_I2C_ADDR2_3__7bf 0x76
+#define NCT38xx_I2C_ADDR2_4__7bf 0x77
#define NCT38XX_REG_VENDOR_ID_L 0x00
#define NCT38XX_REG_VENDOR_ID_H 0x01
diff --git a/driver/tcpm/ps8xxx.c b/driver/tcpm/ps8xxx.c
index 1ffb18a2c3..6e49e8429d 100644
--- a/driver/tcpm/ps8xxx.c
+++ b/driver/tcpm/ps8xxx.c
@@ -202,8 +202,8 @@ struct i2c_stress_test_dev ps8xxx_i2c_stress_test_dev = {
.read_val = PS8XXX_VENDOR_ID & 0xFF,
.write_reg = MUX_IN_HPD_ASSERTION_REG,
},
- .i2c_read = &tcpc_i2c_read,
- .i2c_write = &tcpc_i2c_write,
+ .i2c_read__7bf = &tcpc_i2c_read__7bf,
+ .i2c_write__7bf = &tcpc_i2c_write__7bf,
};
#endif /* CONFIG_CMD_I2C_STRESS_TEST_TCPC */
diff --git a/driver/tcpm/ps8xxx.h b/driver/tcpm/ps8xxx.h
index f69bb3e11a..143ab67649 100644
--- a/driver/tcpm/ps8xxx.h
+++ b/driver/tcpm/ps8xxx.h
@@ -9,10 +9,10 @@
#define __CROS_EC_USB_PD_TCPM_PS8XXX_H
/* I2C interface */
-#define PS8751_I2C_ADDR1 0x16
-#define PS8751_I2C_ADDR2 0x36
-#define PS8751_I2C_ADDR3 0x56
-#define PS8751_I2C_ADDR4 0x96
+#define PS8751_I2C_ADDR1__7bf (0x0B)
+#define PS8751_I2C_ADDR2__7bf (0x1B)
+#define PS8751_I2C_ADDR3__7bf (0x2B)
+#define PS8751_I2C_ADDR4__7bf (0x4B)
/* Minimum Delay for reset assertion */
#define PS8XXX_RESET_DELAY_MS 1
diff --git a/driver/tcpm/tcpci.c b/driver/tcpm/tcpci.c
index 2e6f2a6fca..6765ce7bdc 100644
--- a/driver/tcpm/tcpci.c
+++ b/driver/tcpm/tcpci.c
@@ -40,8 +40,9 @@ int tcpc_write(int port, int reg, int val)
pd_wait_exit_low_power(port);
- rv = i2c_write8(tcpc_config[port].i2c_info.port,
- tcpc_config[port].i2c_info.addr, reg, val);
+ rv = i2c_write8__7bf(tcpc_config[port].i2c_info.port,
+ tcpc_config[port].i2c_info.addr__7bf,
+ reg, val);
pd_device_accessed(port);
return rv;
@@ -53,8 +54,9 @@ int tcpc_write16(int port, int reg, int val)
pd_wait_exit_low_power(port);
- rv = i2c_write16(tcpc_config[port].i2c_info.port,
- tcpc_config[port].i2c_info.addr, reg, val);
+ rv = i2c_write16__7bf(tcpc_config[port].i2c_info.port,
+ tcpc_config[port].i2c_info.addr__7bf,
+ reg, val);
pd_device_accessed(port);
return rv;
@@ -66,8 +68,9 @@ int tcpc_read(int port, int reg, int *val)
pd_wait_exit_low_power(port);
- rv = i2c_read8(tcpc_config[port].i2c_info.port,
- tcpc_config[port].i2c_info.addr, reg, val);
+ rv = i2c_read8__7bf(tcpc_config[port].i2c_info.port,
+ tcpc_config[port].i2c_info.addr__7bf,
+ reg, val);
pd_device_accessed(port);
return rv;
@@ -79,8 +82,9 @@ int tcpc_read16(int port, int reg, int *val)
pd_wait_exit_low_power(port);
- rv = i2c_read16(tcpc_config[port].i2c_info.port,
- tcpc_config[port].i2c_info.addr, reg, val);
+ rv = i2c_read16__7bf(tcpc_config[port].i2c_info.port,
+ tcpc_config[port].i2c_info.addr__7bf,
+ reg, val);
pd_device_accessed(port);
return rv;
@@ -92,8 +96,9 @@ int tcpc_read_block(int port, int reg, uint8_t *in, int size)
pd_wait_exit_low_power(port);
- rv = i2c_read_block(tcpc_config[port].i2c_info.port,
- tcpc_config[port].i2c_info.addr, reg, in, size);
+ rv = i2c_read_block__7bf(tcpc_config[port].i2c_info.port,
+ tcpc_config[port].i2c_info.addr__7bf,
+ reg, in, size);
pd_device_accessed(port);
return rv;
@@ -105,8 +110,9 @@ int tcpc_write_block(int port, int reg, const uint8_t *out, int size)
pd_wait_exit_low_power(port);
- rv = i2c_write_block(tcpc_config[port].i2c_info.port,
- tcpc_config[port].i2c_info.addr, reg, out, size);
+ rv = i2c_write_block__7bf(tcpc_config[port].i2c_info.port,
+ tcpc_config[port].i2c_info.addr__7bf,
+ reg, out, size);
pd_device_accessed(port);
return rv;
@@ -131,9 +137,9 @@ int tcpc_xfer_unlocked(int port, const uint8_t *out, int out_size,
pd_wait_exit_low_power(port);
- rv = i2c_xfer_unlocked(tcpc_config[port].i2c_info.port,
- tcpc_config[port].i2c_info.addr, out,
- out_size, in, in_size, flags);
+ rv = i2c_xfer_unlocked__7bf(tcpc_config[port].i2c_info.port,
+ tcpc_config[port].i2c_info.addr__7bf,
+ out, out_size, in, in_size, flags);
pd_device_accessed(port);
return rv;
diff --git a/driver/tcpm/tcpm.h b/driver/tcpm/tcpm.h
index e5fec627c5..fb67eb315b 100644
--- a/driver/tcpm/tcpm.h
+++ b/driver/tcpm/tcpm.h
@@ -27,55 +27,61 @@
#ifndef CONFIG_USB_PD_TCPC_LOW_POWER
static inline int tcpc_write(int port, int reg, int val)
{
- return i2c_write8(tcpc_config[port].i2c_info.port,
- tcpc_config[port].i2c_info.addr, reg, val);
+ return i2c_write8__7bf(tcpc_config[port].i2c_info.port,
+ tcpc_config[port].i2c_info.addr__7bf,
+ reg, val);
}
static inline int tcpc_write16(int port, int reg, int val)
{
- return i2c_write16(tcpc_config[port].i2c_info.port,
- tcpc_config[port].i2c_info.addr, reg, val);
+ return i2c_write16__7bf(tcpc_config[port].i2c_info.port,
+ tcpc_config[port].i2c_info.addr__7bf,
+ reg, val);
}
static inline int tcpc_read(int port, int reg, int *val)
{
- return i2c_read8(tcpc_config[port].i2c_info.port,
- tcpc_config[port].i2c_info.addr, reg, val);
+ return i2c_read8__7bf(tcpc_config[port].i2c_info.port,
+ tcpc_config[port].i2c_info.addr__7bf,
+ reg, val);
}
static inline int tcpc_read16(int port, int reg, int *val)
{
- return i2c_read16(tcpc_config[port].i2c_info.port,
- tcpc_config[port].i2c_info.addr, reg, val);
+ return i2c_read16__7bf(tcpc_config[port].i2c_info.port,
+ tcpc_config[port].i2c_info.addr__7bf,
+ reg, val);
}
static inline int tcpc_xfer(int port, const uint8_t *out, int out_size,
uint8_t *in, int in_size)
{
- return i2c_xfer(tcpc_config[port].i2c_info.port,
- tcpc_config[port].i2c_info.addr, out, out_size, in,
- in_size);
+ return i2c_xfer__7bf(tcpc_config[port].i2c_info.port,
+ tcpc_config[port].i2c_info.addr__7bf,
+ out, out_size, in, in_size);
}
static inline int tcpc_xfer_unlocked(int port, const uint8_t *out, int out_size,
uint8_t *in, int in_size, int flags)
{
- return i2c_xfer_unlocked(tcpc_config[port].i2c_info.port,
- tcpc_config[port].i2c_info.addr, out, out_size, in,
- in_size, flags);
+ return i2c_xfer_unlocked__7bf(tcpc_config[port].i2c_info.port,
+ tcpc_config[port].i2c_info.addr__7bf,
+ out, out_size, in, in_size, flags);
}
static inline int tcpc_read_block(int port, int reg, uint8_t *in, int size)
{
- return i2c_read_block(tcpc_config[port].i2c_info.port,
- tcpc_config[port].i2c_info.addr, reg, in, size);
+ return i2c_read_block__7bf(tcpc_config[port].i2c_info.port,
+ tcpc_config[port].i2c_info.addr__7bf,
+ reg, in, size);
}
static inline int tcpc_write_block(int port, int reg,
const uint8_t *out, int size)
{
- return i2c_write_block(tcpc_config[port].i2c_info.port,
- tcpc_config[port].i2c_info.addr, reg, out, size);
+ return i2c_write_block__7bf(tcpc_config[port].i2c_info.port,
+ tcpc_config[port].i2c_info.addr__7bf,
+ reg, out, size);
}
#else /* !CONFIG_USB_PD_TCPC_LOW_POWER */
@@ -219,13 +225,13 @@ static inline int tcpm_enter_low_power_mode(int port)
#endif
#ifdef CONFIG_CMD_I2C_STRESS_TEST_TCPC
-static inline int tcpc_i2c_read(const int port, const int addr,
+static inline int tcpc_i2c_read__7bf(const int port, const uint16_t addr__7bf,
const int reg, int *data)
{
return tcpc_read(port, reg, data);
}
-static inline int tcpc_i2c_write(const int port, const int addr,
+static inline int tcpc_i2c_write__7bf(const int port, const uint16_t addr__7bf,
const int reg, int data)
{
return tcpc_write(port, reg, data);
diff --git a/driver/tcpm/tusb422.h b/driver/tcpm/tusb422.h
index 2a01eb4725..524886801c 100644
--- a/driver/tcpm/tusb422.h
+++ b/driver/tcpm/tusb422.h
@@ -9,7 +9,7 @@
#define __CROS_EC_USB_PD_TCPM_TUSB422_H
/* I2C interface */
-#define TUSB422_I2C_ADDR 0x40
+#define TUSB422_I2C_ADDR__7bf 0x20
extern const struct tcpm_drv tusb422_tcpm_drv;
diff --git a/driver/temp_sensor/adt7481.c b/driver/temp_sensor/adt7481.c
index 22d7cc5f9a..c724e958e1 100644
--- a/driver/temp_sensor/adt7481.c
+++ b/driver/temp_sensor/adt7481.c
@@ -34,12 +34,14 @@ static int has_power(void)
static int raw_read8(const int offset, int *data_ptr)
{
- return i2c_read8(I2C_PORT_THERMAL, ADT7481_I2C_ADDR, offset, data_ptr);
+ return i2c_read8__7bf(I2C_PORT_THERMAL, ADT7481_I2C_ADDR__7bf,
+ offset, data_ptr);
}
static int raw_write8(const int offset, int data)
{
- return i2c_write8(I2C_PORT_THERMAL, ADT7481_I2C_ADDR, offset, data);
+ return i2c_write8__7bf(I2C_PORT_THERMAL, ADT7481_I2C_ADDR__7bf,
+ offset, data);
}
static int get_temp(const int offset, int *temp_ptr)
diff --git a/driver/temp_sensor/adt7481.h b/driver/temp_sensor/adt7481.h
index 45da88560e..17f3c20056 100644
--- a/driver/temp_sensor/adt7481.h
+++ b/driver/temp_sensor/adt7481.h
@@ -8,7 +8,7 @@
#ifndef __CROS_EC_ADT7481_H
#define __CROS_EC_ADT7481_H
-#define ADT7481_I2C_ADDR 0x96 /* 7-bit address is 0x4B */
+#define ADT7481_I2C_ADDR__7bf 0x4B
#define ADT7481_IDX_LOCAL 0
#define ADT7481_IDX_REMOTE1 1
diff --git a/driver/temp_sensor/bd99992gw.c b/driver/temp_sensor/bd99992gw.c
index 291ce32479..9ccbde6d8e 100644
--- a/driver/temp_sensor/bd99992gw.c
+++ b/driver/temp_sensor/bd99992gw.c
@@ -39,7 +39,8 @@ static enum bd99992gw_adc_channel
static int raw_read8(const int offset, int *data_ptr)
{
int ret;
- ret = i2c_read8(I2C_PORT_THERMAL, BD99992GW_I2C_ADDR, offset, data_ptr);
+ ret = i2c_read8__7bf(I2C_PORT_THERMAL, BD99992GW_I2C_ADDR__7bf,
+ offset, data_ptr);
if (ret != EC_SUCCESS)
CPRINTS("bd99992gw read fail %d", ret);
return ret;
@@ -48,7 +49,8 @@ static int raw_read8(const int offset, int *data_ptr)
static int raw_write8(const int offset, int data)
{
int ret;
- ret = i2c_write8(I2C_PORT_THERMAL, BD99992GW_I2C_ADDR, offset, data);
+ ret = i2c_write8__7bf(I2C_PORT_THERMAL, BD99992GW_I2C_ADDR__7bf,
+ offset, data);
if (ret != EC_SUCCESS)
CPRINTS("bd99992gw write fail %d", ret);
return ret;
diff --git a/driver/temp_sensor/bd99992gw.h b/driver/temp_sensor/bd99992gw.h
index 7db3990e07..1d5aff7287 100644
--- a/driver/temp_sensor/bd99992gw.h
+++ b/driver/temp_sensor/bd99992gw.h
@@ -8,7 +8,7 @@
#ifndef __CROS_EC_TEMP_SENSOR_BD99992GW_H
#define __CROS_EC_TEMP_SENSOR_BD99992GW_H
-#define BD99992GW_I2C_ADDR 0x60
+#define BD99992GW_I2C_ADDR__7bf 0x30
/* ADC channels */
enum bd99992gw_adc_channel {
diff --git a/driver/temp_sensor/f75303.c b/driver/temp_sensor/f75303.c
index e2a324f0fb..794d2e865a 100644
--- a/driver/temp_sensor/f75303.c
+++ b/driver/temp_sensor/f75303.c
@@ -20,7 +20,8 @@ static int8_t fake_temp[F75303_IDX_COUNT] = {-1, -1, -1};
*/
static int raw_read8(const int offset, int *data)
{
- return i2c_read8(I2C_PORT_THERMAL, F75303_I2C_ADDR, offset, data);
+ return i2c_read8__7bf(I2C_PORT_THERMAL, F75303_I2C_ADDR__7bf,
+ offset, data);
}
static int get_temp(const int offset, int *temp)
diff --git a/driver/temp_sensor/f75303.h b/driver/temp_sensor/f75303.h
index ada32e75e7..ea2dcdbd79 100644
--- a/driver/temp_sensor/f75303.h
+++ b/driver/temp_sensor/f75303.h
@@ -8,7 +8,7 @@
#ifndef __CROS_EC_F75303_H
#define __CROS_EC_F75303_H
-#define F75303_I2C_ADDR 0x9A /* 7-bit address is 0x4C */
+#define F75303_I2C_ADDR__7bf 0x4C
enum f75303_index {
F75303_IDX_LOCAL = 0,
diff --git a/driver/temp_sensor/g78x.c b/driver/temp_sensor/g78x.c
index 948569da1c..0a71556b27 100644
--- a/driver/temp_sensor/g78x.c
+++ b/driver/temp_sensor/g78x.c
@@ -35,13 +35,15 @@ static int has_power(void)
static int raw_read8(const int offset, int *data_ptr)
{
- return i2c_read8(I2C_PORT_THERMAL, G78X_I2C_ADDR, offset, data_ptr);
+ return i2c_read8__7bf(I2C_PORT_THERMAL, G78X_I2C_ADDR__7bf,
+ offset, data_ptr);
}
#ifdef CONFIG_CMD_TEMP_SENSOR
static int raw_write8(const int offset, int data)
{
- return i2c_write8(I2C_PORT_THERMAL, G78X_I2C_ADDR, offset, data);
+ return i2c_write8__7bf(I2C_PORT_THERMAL, G78X_I2C_ADDR__7bf,
+ offset, data);
}
#endif
diff --git a/driver/temp_sensor/g78x.h b/driver/temp_sensor/g78x.h
index 2ef75f1da9..6d656610d9 100644
--- a/driver/temp_sensor/g78x.h
+++ b/driver/temp_sensor/g78x.h
@@ -12,7 +12,7 @@
#error Cannot support both G781 and G782 together!
#endif
-#define G78X_I2C_ADDR 0x98 /* 7-bit address is 0x4C */
+#define G78X_I2C_ADDR__7bf 0x4C
#define G78X_IDX_INTERNAL 0
#define G78X_IDX_EXTERNAL1 1
diff --git a/driver/temp_sensor/sb_tsi.c b/driver/temp_sensor/sb_tsi.c
index 9cf42d983f..3de816e1dc 100644
--- a/driver/temp_sensor/sb_tsi.c
+++ b/driver/temp_sensor/sb_tsi.c
@@ -19,7 +19,8 @@
static int raw_read8(const int offset, int *data_ptr)
{
- return i2c_read8(I2C_PORT_THERMAL, SB_TSI_I2C_ADDR, offset, data_ptr);
+ return i2c_read8__7bf(I2C_PORT_THERMAL, SB_TSI_I2C_ADDR__7bf,
+ offset, data_ptr);
}
int sb_tsi_get_val(int idx, int *temp_ptr)
diff --git a/driver/temp_sensor/sb_tsi.h b/driver/temp_sensor/sb_tsi.h
index 3ae11c5dbd..afed1d206f 100644
--- a/driver/temp_sensor/sb_tsi.h
+++ b/driver/temp_sensor/sb_tsi.h
@@ -11,7 +11,7 @@
#ifndef __CROS_EC_SB_TSI_H
#define __CROS_EC_SB_TSI_H
-#define SB_TSI_I2C_ADDR 0x98 /* 7-bit address is 0x4C */
+#define SB_TSI_I2C_ADDR__7bf 0x4C
/* G781 register */
#define SB_TSI_TEMP_H 0x01
diff --git a/driver/temp_sensor/tmp006.c b/driver/temp_sensor/tmp006.c
index b33ab67a6c..b615dbd4cc 100644
--- a/driver/temp_sensor/tmp006.c
+++ b/driver/temp_sensor/tmp006.c
@@ -86,7 +86,7 @@ static void tmp006_poll_sensor(int sensor_id)
{
struct tmp006_data_t *tdata = tmp006_data + sensor_id;
int t, v, rv;
- int addr = tmp006_sensors[sensor_id].addr;
+ int addr__7bf = tmp006_sensors__7bf[sensor_id].addr__7bf;
/* Invalidate the filter history if there is any error */
if (tdata->fail) {
@@ -104,7 +104,8 @@ static void tmp006_poll_sensor(int sensor_id)
* data ready; otherwise, we read garbage data.
*/
if (tdata->fail & (FAIL_POWER | FAIL_INIT)) {
- rv = i2c_read16(TMP006_PORT(addr), TMP006_REG(addr),
+ rv = i2c_read16__7bf(TMP006_PORT(addr__7bf),
+ TMP006_REG__7bf(addr__7bf),
TMP006_REG_CONFIG, &v);
if (rv) {
tdata->fail |= FAIL_I2C;
@@ -116,14 +117,16 @@ static void tmp006_poll_sensor(int sensor_id)
}
}
- rv = i2c_read16(TMP006_PORT(addr), TMP006_REG(addr),
+ rv = i2c_read16__7bf(TMP006_PORT(addr__7bf),
+ TMP006_REG__7bf(addr__7bf),
TMP006_REG_TDIE, &t);
if (rv) {
tdata->fail |= FAIL_I2C;
return;
}
- rv = i2c_read16(TMP006_PORT(addr), TMP006_REG(addr),
+ rv = i2c_read16__7bf(TMP006_PORT(addr__7bf),
+ TMP006_REG__7bf(addr__7bf),
TMP006_REG_VOBJ, &v);
if (rv) {
tdata->fail |= FAIL_I2C;
@@ -370,37 +373,42 @@ static int tmp006_print(int idx)
int traw, t;
int rv;
int d;
- int addr = tmp006_sensors[idx].addr;
+ int addr__7bf = tmp006_sensors__7bf[idx].addr__7bf;
- ccprintf("Debug data from %s:\n", tmp006_sensors[idx].name);
+ ccprintf("Debug data from %s:\n", tmp006_sensors__7bf[idx].name);
if (!tmp006_has_power(idx)) {
ccputs("Sensor powered off.\n");
return EC_ERROR_UNKNOWN;
}
- rv = i2c_read16(TMP006_PORT(addr), TMP006_REG(addr),
+ rv = i2c_read16__7bf(TMP006_PORT(addr__7bf),
+ TMP006_REG__7bf(addr__7bf),
TMP006_REG_MANUFACTURER_ID, &d);
if (rv)
return rv;
ccprintf(" Manufacturer ID: 0x%04x\n", d);
- rv = i2c_read16(TMP006_PORT(addr), TMP006_REG(addr),
+ rv = i2c_read16__7bf(TMP006_PORT(addr__7bf),
+ TMP006_REG__7bf(addr__7bf),
TMP006_REG_DEVICE_ID, &d);
ccprintf(" Device ID: 0x%04x\n", d);
- rv = i2c_read16(TMP006_PORT(addr), TMP006_REG(addr),
+ rv = i2c_read16__7bf(TMP006_PORT(addr__7bf),
+ TMP006_REG__7bf(addr__7bf),
TMP006_REG_CONFIG, &d);
ccprintf(" Config: 0x%04x\n", d);
- rv = i2c_read16(TMP006_PORT(addr), TMP006_REG(addr),
+ rv = i2c_read16__7bf(TMP006_PORT(addr__7bf),
+ TMP006_REG__7bf(addr__7bf),
TMP006_REG_VOBJ, &vraw);
v = ((int)vraw * 15625) / 100;
ccprintf(" Voltage: 0x%04x = %d nV\n", vraw, v);
- rv = i2c_read16(TMP006_PORT(addr), TMP006_REG(addr),
+ rv = i2c_read16__7bf(TMP006_PORT(addr__7bf),
+ TMP006_REG__7bf(addr__7bf),
TMP006_REG_TDIE, &traw);
t = (int)traw;
ccprintf(" Temperature: 0x%04x = %d.%02d C\n",
@@ -455,7 +463,7 @@ static int command_t6cal(int argc, char **argv)
tdata = tmp006_data + i;
ccprintf("%d %-11s"
"%7de-17 %7de-8 %7de-10 %7de-12\n",
- i, tmp006_sensors[i].name,
+ i, tmp006_sensors__7bf[i].name,
(int)(tdata->s0 * 1e17f),
(int)(tdata->b0 * 1e8f),
(int)(tdata->b1 * 1e10f),
diff --git a/driver/temp_sensor/tmp006.h b/driver/temp_sensor/tmp006.h
index 28204829a2..98f8e31ee0 100644
--- a/driver/temp_sensor/tmp006.h
+++ b/driver/temp_sensor/tmp006.h
@@ -16,17 +16,17 @@
#define TMP006_REG_DEVICE_ID 0xff
/* I2C address components */
-#define TMP006_ADDR(PORT,REG) ((PORT << 16) + REG)
-#define TMP006_PORT(ADDR) (ADDR >> 16)
-#define TMP006_REG(ADDR) (ADDR & 0xffff)
+#define TMP006_ADDR__7bf(PORT, REG) ((PORT << 16) + REG)
+#define TMP006_PORT(ADDR__7bf) (ADDR__7bf >> 16)
+#define TMP006_REG__7bf(ADDR__7bf) (ADDR__7bf & 0xffff)
struct tmp006_t {
const char *name;
- int addr; /* I2C address formed by TMP006_ADDR macro. */
+ int addr__7bf; /* I2C address formed by TMP006_ADDR macro. */
};
/* Names and addresses of the sensors we have */
-extern const struct tmp006_t tmp006_sensors[];
+extern const struct tmp006_t tmp006_sensors__7bf[];
/**
* Get the last polled value of a sensor.
diff --git a/driver/temp_sensor/tmp112.c b/driver/temp_sensor/tmp112.c
index f61cf23784..b80fc4bb61 100644
--- a/driver/temp_sensor/tmp112.c
+++ b/driver/temp_sensor/tmp112.c
@@ -20,12 +20,14 @@ static int temp_val_local;
static int raw_read16(const int offset, int *data_ptr)
{
- return i2c_read16(I2C_PORT_THERMAL, TMP112_I2C_ADDR, offset, data_ptr);
+ return i2c_read16__7bf(I2C_PORT_THERMAL, TMP112_I2C_ADDR__7bf,
+ offset, data_ptr);
}
static int raw_write16(const int offset, int data)
{
- return i2c_write16(I2C_PORT_THERMAL, TMP112_I2C_ADDR, offset, data);
+ return i2c_write16__7bf(I2C_PORT_THERMAL, TMP112_I2C_ADDR__7bf,
+ offset, data);
}
static int get_temp(int *temp_ptr)
diff --git a/driver/temp_sensor/tmp112.h b/driver/temp_sensor/tmp112.h
index 63bf4bfab4..f1c5725741 100644
--- a/driver/temp_sensor/tmp112.h
+++ b/driver/temp_sensor/tmp112.h
@@ -8,7 +8,7 @@
#include "i2c.h"
-#define TMP112_I2C_ADDR 0x90 | I2C_FLAG_BIG_ENDIAN
+#define TMP112_I2C_ADDR__7bf (0x48 | I2C_FLAG_BIG_ENDIAN)
#define TMP112_REG_TEMP 0x00
#define TMP112_REG_CONF 0x01
diff --git a/driver/temp_sensor/tmp411.h b/driver/temp_sensor/tmp411.h
index e5fd37b5c8..6e15f52c3e 100644
--- a/driver/temp_sensor/tmp411.h
+++ b/driver/temp_sensor/tmp411.h
@@ -8,7 +8,7 @@
#ifndef __CROS_EC_TMP411_H
#define __CROS_EC_TMP411_H
-#define TMP411_I2C_ADDR 0x98 /* 7-bit address is 0x4C */
+#define TMP411_I2C_ADDR__7bf 0x4C
#define TMP411_IDX_LOCAL 0
#define TMP411_IDX_REMOTE1 1
diff --git a/driver/temp_sensor/tmp432.c b/driver/temp_sensor/tmp432.c
index c0e04a84ad..6325547ace 100644
--- a/driver/temp_sensor/tmp432.c
+++ b/driver/temp_sensor/tmp432.c
@@ -35,12 +35,14 @@ static int has_power(void)
static int raw_read8(const int offset, int *data_ptr)
{
- return i2c_read8(I2C_PORT_THERMAL, TMP432_I2C_ADDR, offset, data_ptr);
+ return i2c_read8__7bf(I2C_PORT_THERMAL, TMP432_I2C_ADDR__7bf,
+ offset, data_ptr);
}
static int raw_write8(const int offset, int data)
{
- return i2c_write8(I2C_PORT_THERMAL, TMP432_I2C_ADDR, offset, data);
+ return i2c_write8__7bf(I2C_PORT_THERMAL, TMP432_I2C_ADDR__7bf,
+ offset, data);
}
static int get_temp(const int offset, int *temp_ptr)
diff --git a/driver/temp_sensor/tmp432.h b/driver/temp_sensor/tmp432.h
index bcdc83d926..638cde91e1 100644
--- a/driver/temp_sensor/tmp432.h
+++ b/driver/temp_sensor/tmp432.h
@@ -8,7 +8,7 @@
#ifndef __CROS_EC_TMP432_H
#define __CROS_EC_TMP432_H
-#define TMP432_I2C_ADDR 0x98 /* 7-bit address is 0x4C */
+#define TMP432_I2C_ADDR__7bf 0x4C
#define TMP432_IDX_LOCAL 0
#define TMP432_IDX_REMOTE1 1
diff --git a/driver/temp_sensor/tmp468.c b/driver/temp_sensor/tmp468.c
index 09a3faa80e..444a1d5dc8 100644
--- a/driver/temp_sensor/tmp468.c
+++ b/driver/temp_sensor/tmp468.c
@@ -27,12 +27,14 @@ static int has_power(void)
static int raw_read16(const int offset, int *data_ptr)
{
- return i2c_read16(I2C_PORT_THERMAL, TMP468_I2C_ADDR, offset, data_ptr);
+ return i2c_read16__7bf(I2C_PORT_THERMAL, TMP468_I2C_ADDR__7bf,
+ offset, data_ptr);
}
static int raw_write16(const int offset, int data_ptr)
{
- return i2c_write16(I2C_PORT_THERMAL, TMP468_I2C_ADDR, offset, data_ptr);
+ return i2c_write16__7bf(I2C_PORT_THERMAL, TMP468_I2C_ADDR__7bf,
+ offset, data_ptr);
}
static int tmp468_shutdown(uint8_t want_shutdown)
diff --git a/driver/temp_sensor/tmp468.h b/driver/temp_sensor/tmp468.h
index 70d772f097..f8f4337d8a 100644
--- a/driver/temp_sensor/tmp468.h
+++ b/driver/temp_sensor/tmp468.h
@@ -8,7 +8,7 @@
#ifndef __CROS_EC_TMP468_H
#define __CROS_EC_TMP468_H
-#define TMP468_I2C_ADDR (0x90 | I2C_FLAG_BIG_ENDIAN)
+#define TMP468_I2C_ADDR__7bf (0x48 | I2C_FLAG_BIG_ENDIAN)
#define TMP468_SHIFT1 7
#define TMP468_LOCAL 0x00
diff --git a/driver/touchpad_elan.c b/driver/touchpad_elan.c
index 10a2038158..247c85894f 100644
--- a/driver/touchpad_elan.c
+++ b/driver/touchpad_elan.c
@@ -115,8 +115,9 @@ static int elan_tp_read_cmd(uint16_t reg, uint16_t *val)
buf[0] = reg;
buf[1] = reg >> 8;
- return i2c_xfer(CONFIG_TOUCHPAD_I2C_PORT, CONFIG_TOUCHPAD_I2C_ADDR,
- buf, sizeof(buf), (uint8_t *)val, sizeof(*val));
+ return i2c_xfer__7bf(CONFIG_TOUCHPAD_I2C_PORT,
+ CONFIG_TOUCHPAD_I2C_ADDR__7BF,
+ buf, sizeof(buf), (uint8_t *)val, sizeof(*val));
}
static int elan_tp_write_cmd(uint16_t reg, uint16_t val)
@@ -128,8 +129,9 @@ static int elan_tp_write_cmd(uint16_t reg, uint16_t val)
buf[2] = val;
buf[3] = val >> 8;
- return i2c_xfer(CONFIG_TOUCHPAD_I2C_PORT, CONFIG_TOUCHPAD_I2C_ADDR,
- buf, sizeof(buf), NULL, 0);
+ return i2c_xfer__7bf(CONFIG_TOUCHPAD_I2C_PORT,
+ CONFIG_TOUCHPAD_I2C_ADDR__7BF,
+ buf, sizeof(buf), NULL, 0);
}
/* Power is on by default. */
@@ -189,7 +191,8 @@ static int elan_tp_read_report(void)
/* Compute and save timestamp early in case another interrupt comes. */
timestamp = irq_ts / USB_HID_TOUCHPAD_TIMESTAMP_UNIT;
- rv = i2c_xfer(CONFIG_TOUCHPAD_I2C_PORT, CONFIG_TOUCHPAD_I2C_ADDR,
+ rv = i2c_xfer__7bf(CONFIG_TOUCHPAD_I2C_PORT,
+ CONFIG_TOUCHPAD_I2C_ADDR__7BF,
NULL, 0, tp_buf, ETP_I2C_REPORT_LEN);
if (rv) {
@@ -277,7 +280,8 @@ static void elan_tp_init(void)
elan_tp_write_cmd(ETP_I2C_STAND_CMD, ETP_I2C_RESET);
msleep(100);
- rv = i2c_xfer(CONFIG_TOUCHPAD_I2C_PORT, CONFIG_TOUCHPAD_I2C_ADDR,
+ rv = i2c_xfer__7bf(CONFIG_TOUCHPAD_I2C_PORT,
+ CONFIG_TOUCHPAD_I2C_ADDR__7BF,
NULL, 0, val, sizeof(val));
CPRINTS("reset rv %d buf=%04x", rv, *((uint16_t *)val));
@@ -467,7 +471,8 @@ static int touchpad_update_page(const uint8_t *data)
page_store[FW_PAGE_SIZE + 2 + 0] = checksum & 0xff;
page_store[FW_PAGE_SIZE + 2 + 1] = (checksum >> 8) & 0xff;
- rv = i2c_xfer(CONFIG_TOUCHPAD_I2C_PORT, CONFIG_TOUCHPAD_I2C_ADDR,
+ rv = i2c_xfer__7bf(CONFIG_TOUCHPAD_I2C_PORT,
+ CONFIG_TOUCHPAD_I2C_ADDR__7BF,
page_store, sizeof(page_store), NULL, 0);
if (rv)
return rv;
@@ -631,8 +636,8 @@ int touchpad_debug(const uint8_t *param, unsigned int param_size,
memset(buffer, 0, buffer_size);
}
- rv = i2c_xfer(CONFIG_TOUCHPAD_I2C_PORT,
- CONFIG_TOUCHPAD_I2C_ADDR,
+ rv = i2c_xfer__7bf(CONFIG_TOUCHPAD_I2C_PORT,
+ CONFIG_TOUCHPAD_I2C_ADDR__7BF,
&param[offset], write_length,
buffer, read_length);
diff --git a/driver/usb_mux/it5205.c b/driver/usb_mux/it5205.c
index 9a6f71dade..745a341591 100644
--- a/driver/usb_mux/it5205.c
+++ b/driver/usb_mux/it5205.c
@@ -16,12 +16,12 @@
static int it5205_read(int port, uint8_t reg, int *val)
{
- return i2c_read8(I2C_PORT_USB_MUX, MUX_ADDR(port), reg, val);
+ return i2c_read8__7bf(I2C_PORT_USB_MUX, MUX_ADDR__7bf(port), reg, val);
}
static int it5205_write(int port, uint8_t reg, uint8_t val)
{
- return i2c_write8(I2C_PORT_USB_MUX, MUX_ADDR(port), reg, val);
+ return i2c_write8__7bf(I2C_PORT_USB_MUX, MUX_ADDR__7bf(port), reg, val);
}
struct mux_chip_id_t {
diff --git a/driver/usb_mux/it5205.h b/driver/usb_mux/it5205.h
index b81b33cac3..02d389ad36 100644
--- a/driver/usb_mux/it5205.h
+++ b/driver/usb_mux/it5205.h
@@ -9,8 +9,8 @@
#define __CROS_EC_IT5205_H
/* I2C interface */
-#define IT5205_I2C_ADDR1 (0x48 << 1)
-#define IT5205_I2C_ADDR2 (0x58 << 1)
+#define IT5205_I2C_ADDR1__7bf (0x48)
+#define IT5205_I2C_ADDR2__7bf (0x58)
/* Chip ID registers */
#define IT5205_REG_CHIP_ID3 0x4
diff --git a/driver/usb_mux/pi3usb30532.c b/driver/usb_mux/pi3usb30532.c
index 54d6f49fe7..24f9cbd095 100644
--- a/driver/usb_mux/pi3usb30532.c
+++ b/driver/usb_mux/pi3usb30532.c
@@ -20,7 +20,9 @@ static int pi3usb30532_read(int port, uint8_t reg, uint8_t *val)
* Second byte read will be vendor ID.
* Third byte read will be selection control.
*/
- res = i2c_read16(I2C_PORT_USB_MUX, MUX_ADDR(port), 0, &read);
+ res = i2c_read16__7bf(I2C_PORT_USB_MUX,
+ MUX_ADDR__7bf(port),
+ 0, &read);
if (res)
return res;
@@ -37,7 +39,9 @@ static int pi3usb30532_write(int port, uint8_t reg, uint8_t val)
if (reg != PI3USB30532_REG_CONTROL)
return EC_ERROR_UNKNOWN;
- return i2c_write8(I2C_PORT_USB_MUX, MUX_ADDR(port), 0, val);
+ return i2c_write8__7bf(I2C_PORT_USB_MUX,
+ MUX_ADDR__7bf(port),
+ 0, val);
}
static int pi3usb30532_reset(int port)
diff --git a/driver/usb_mux/ps874x.c b/driver/usb_mux/ps874x.c
index bf00553d28..73bb39bce5 100644
--- a/driver/usb_mux/ps874x.c
+++ b/driver/usb_mux/ps874x.c
@@ -13,12 +13,16 @@
static inline int ps874x_read(int port, uint8_t reg, int *val)
{
- return i2c_read8(I2C_PORT_USB_MUX, MUX_ADDR(port), reg, val);
+ return i2c_read8__7bf(I2C_PORT_USB_MUX,
+ MUX_ADDR__7bf(port),
+ reg, val);
}
static inline int ps874x_write(int port, uint8_t reg, uint8_t val)
{
- return i2c_write8(I2C_PORT_USB_MUX, MUX_ADDR(port), reg, val);
+ return i2c_write8__7bf(I2C_PORT_USB_MUX,
+ MUX_ADDR__7bf(port),
+ reg, val);
}
static int ps874x_init(int port)
diff --git a/driver/wpc/p9221.c b/driver/wpc/p9221.c
index 2678173ea6..948734aba1 100644
--- a/driver/wpc/p9221.c
+++ b/driver/wpc/p9221.c
@@ -98,34 +98,38 @@ static int p9221_reg_is_8_bit(uint16_t reg)
static int p9221_read8(uint16_t reg, int *val)
{
- return i2c_read_offset16(wpc->i2c_port, P9221_R7_ADDR, reg, val, 1);
+ return i2c_read_offset16__7bf(wpc->i2c_port, P9221_R7_ADDR__7bf,
+ reg, val, 1);
}
static int p9221_write8(uint16_t reg, int val)
{
- return i2c_write_offset16(wpc->i2c_port, P9221_R7_ADDR, reg, val, 1);
+ return i2c_write_offset16__7bf(wpc->i2c_port, P9221_R7_ADDR__7bf,
+ reg, val, 1);
}
static int p9221_read16(uint16_t reg, int *val)
{
- return i2c_read_offset16(wpc->i2c_port, P9221_R7_ADDR, reg, val, 2);
+ return i2c_read_offset16__7bf(wpc->i2c_port, P9221_R7_ADDR__7bf,
+ reg, val, 2);
}
static int p9221_write16(uint16_t reg, int val)
{
- return i2c_write_offset16(wpc->i2c_port, P9221_R7_ADDR, reg, val, 2);
+ return i2c_write_offset16__7bf(wpc->i2c_port, P9221_R7_ADDR__7bf,
+ reg, val, 2);
}
static int p9221_block_read(uint16_t reg, uint8_t *data, int len)
{
- return i2c_read_offset16_block(wpc->i2c_port, P9221_R7_ADDR, reg, data,
- len);
+ return i2c_read_offset16_block__7bf(wpc->i2c_port, P9221_R7_ADDR__7bf,
+ reg, data, len);
}
static int p9221_block_write(uint16_t reg, uint8_t *data, int len)
{
- return i2c_write_offset16_block(wpc->i2c_port, P9221_R7_ADDR, reg, data,
- len);
+ return i2c_write_offset16_block__7bf(wpc->i2c_port, P9221_R7_ADDR__7bf,
+ reg, data, len);
}
static int p9221_set_cmd_reg(uint8_t cmd)
diff --git a/driver/wpc/p9221.h b/driver/wpc/p9221.h
index 7c5156c833..b590a5c1c7 100644
--- a/driver/wpc/p9221.h
+++ b/driver/wpc/p9221.h
@@ -19,7 +19,7 @@
/* ========== Variant-specific configuration ============ */
-#define P9221_R7_ADDR (0x61 << 1)
+#define P9221_R7_ADDR__7bf 0x61
/*
* P9221 common registers