summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Brockus <dbrockus@chromium.org>2019-06-25 12:44:16 -0600
committerCommit Bot <commit-bot@chromium.org>2019-07-19 21:11:02 +0000
commitd1a18f82ed831d4e640336ff5571f5fa64bc7b36 (patch)
treec46aeb6136de1c27c66e3d5f662e9620161bef7b
parent1f14229fa7e499dfcee07d17add187598ff0a46c (diff)
downloadchrome-ec-d1a18f82ed831d4e640336ff5571f5fa64bc7b36.tar.gz
Use 7bit I2C/SPI slave addresses in EC
Opt for 7bit slave addresses in EC code. If 8bit is expected by a driver, make it local and show this in the naming. Use __7b, __7bf and __8b as name extensions for i2c/spi addresses used in the EC codebase. __7b indicates a 7bit address by itself. __7bf indicates a 7bit address with optional flags attached. __8b indicates a 8bit address by itself. Allow space for 10bit addresses, even though this is not currently being used by any of our attached devices. These extensions are for verification purposes only and will be removed in the last pass of this ticket. I want to make sure the variable names reflect the type to help eliminate future 7/8/7-flags confusion. BUG=chromium:971296 BRANCH=none TEST=make buildall -j Change-Id: I2fc3d1b52ce76184492b2aaff3060f486ca45f45 Signed-off-by: Denis Brockus <dbrockus@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1699893 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
-rw-r--r--baseboard/dragonegg/baseboard.c8
-rw-r--r--baseboard/dragonegg/baseboard.h4
-rw-r--r--baseboard/grunt/baseboard.c14
-rw-r--r--baseboard/hatch/baseboard.c4
-rw-r--r--baseboard/hatch/baseboard.h2
-rw-r--r--baseboard/kalista/baseboard.c8
-rw-r--r--baseboard/kalista/baseboard.h4
-rw-r--r--baseboard/octopus/baseboard.h4
-rw-r--r--baseboard/octopus/variant_usbc_ec_tcpcs.c8
-rw-r--r--baseboard/octopus/variant_usbc_standalone_tcpcs.c10
-rw-r--r--baseboard/zork/baseboard.c14
-rw-r--r--board/ampton/board.c10
-rw-r--r--board/arcada_ish/board.c8
-rw-r--r--board/atlas/board.c48
-rw-r--r--board/atlas/board.h8
-rw-r--r--board/bloog/board.c6
-rw-r--r--board/bobba/board.c6
-rw-r--r--board/casta/board.c11
-rw-r--r--board/chell/board.c25
-rw-r--r--board/cheza/board.c12
-rw-r--r--board/cheza/board.h2
-rw-r--r--board/coral/board.c20
-rw-r--r--board/elm/board.c15
-rw-r--r--board/elm/board.h4
-rw-r--r--board/eve/board.c42
-rw-r--r--board/eve/board.h6
-rw-r--r--board/fizz/board.c8
-rw-r--r--board/fizz/board.h4
-rw-r--r--board/flapjack/battery.c4
-rw-r--r--board/flapjack/board.c20
-rw-r--r--board/flapjack/board.h4
-rw-r--r--board/fleex/board.c6
-rw-r--r--board/fluffy/board.c16
-rw-r--r--board/garg/board.c6
-rw-r--r--board/glados/battery.c8
-rw-r--r--board/glados/board.c18
-rw-r--r--board/glados/board.h2
-rw-r--r--board/glados_pd/board.h2
-rw-r--r--board/glkrvp/battery.c6
-rw-r--r--board/glkrvp/board.c16
-rw-r--r--board/glkrvp/chg_usb_pd.c8
-rw-r--r--board/glkrvp_ite/battery.c4
-rw-r--r--board/glkrvp_ite/board.c41
-rw-r--r--board/glkrvp_ite/board.h2
-rw-r--r--board/glkrvp_ite/chg_usb_pd.c8
-rw-r--r--board/hammer/board.h2
-rw-r--r--board/hatch/board.c16
-rw-r--r--board/helios/board.c16
-rw-r--r--board/helios/board.h2
-rw-r--r--board/host/battery.c7
-rw-r--r--board/kindred/board.c16
-rw-r--r--board/kindred/board.h2
-rw-r--r--board/kohaku/board.c14
-rw-r--r--board/kukui/board.c14
-rw-r--r--board/kukui/board.h4
-rw-r--r--board/mchpevb1/battery.c8
-rw-r--r--board/mchpevb1/board.c34
-rw-r--r--board/mchpevb1/board.h2
-rw-r--r--board/meep/board.c6
-rw-r--r--board/nami/board.c22
-rw-r--r--board/nami/board.h4
-rw-r--r--board/nautilus/board.c57
-rw-r--r--board/nautilus/board.h4
-rw-r--r--board/nocturne/board.c54
-rw-r--r--board/nocturne/board.h6
-rw-r--r--board/nucleo-f411re/board.c4
-rw-r--r--board/oak/battery.c8
-rw-r--r--board/oak/board.c16
-rw-r--r--board/oak/board.h2
-rw-r--r--board/pdeval-stm32f072/board.c4
-rw-r--r--board/pdeval-stm32f072/usb_pd_policy.c2
-rw-r--r--board/phaser/board.c6
-rw-r--r--board/plankton/board.c30
-rw-r--r--board/poppy/board.c83
-rw-r--r--board/poppy/board.h8
-rw-r--r--board/rainier/board.c8
-rw-r--r--board/rammus/board.c45
-rw-r--r--board/rammus/board.h6
-rw-r--r--board/reef/board.c30
-rw-r--r--board/reef/board.h2
-rw-r--r--board/reef_it8320/board.c4
-rw-r--r--board/reef_mchp/board.c30
-rw-r--r--board/reef_mchp/board.h2
-rw-r--r--board/samus/battery.c8
-rw-r--r--board/samus/board.c56
-rw-r--r--board/samus/extpower.c4
-rw-r--r--board/samus/panel.c10
-rw-r--r--board/samus_pd/board.h2
-rw-r--r--board/scarlet/board.c6
-rw-r--r--board/scarlet/board.h2
-rw-r--r--board/servo_micro/board.c17
-rw-r--r--board/servo_v4/board.c18
-rw-r--r--board/strago/board.c8
-rw-r--r--board/sweetberry/board.c2
-rw-r--r--board/yorp/board.c6
-rw-r--r--chip/g/i2cm.c23
-rw-r--r--chip/host/i2c.c23
-rw-r--r--chip/ish/i2c.c18
-rw-r--r--chip/it83xx/i2c.c25
-rw-r--r--chip/lm4/i2c.c15
-rw-r--r--chip/mchp/i2c.c15
-rw-r--r--chip/mec1322/i2c.c14
-rw-r--r--chip/npcx/i2c.c25
-rw-r--r--chip/nrf51/i2c.c22
-rw-r--r--chip/stm32/i2c-stm32f0.c26
-rw-r--r--chip/stm32/i2c-stm32f4.c73
-rw-r--r--chip/stm32/i2c-stm32l.c13
-rw-r--r--chip/stm32/i2c-stm32l4.c17
-rw-r--r--chip/stm32/usb_power.c78
-rw-r--r--chip/stm32/usb_power.h4
-rw-r--r--common/cbi.c8
-rw-r--r--common/host_command_master.c19
-rw-r--r--common/i2c_master.c274
-rw-r--r--common/i2c_trace.c11
-rw-r--r--common/lb_common.c13
-rw-r--r--common/motion_sense.c3
-rw-r--r--common/peripheral.c7
-rw-r--r--common/usb_i2c.c9
-rw-r--r--cts/i2c/dut.c20
-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
-rw-r--r--include/battery_smart.h4
-rw-r--r--include/charge_state_v2.h2
-rw-r--r--include/config.h20
-rw-r--r--include/ec_commands.h12
-rw-r--r--include/i2c.h162
-rw-r--r--include/motion_sense.h21
-rw-r--r--include/test_util.h13
-rw-r--r--include/usb_i2c.h2
-rw-r--r--include/usb_mux.h20
-rw-r--r--include/usb_pd_tcpc.h6
-rw-r--r--include/usbc_ppc.h2
-rw-r--r--include/virtual_battery.h2
-rw-r--r--test/battery_get_params_smart.c6
-rw-r--r--test/sbs_charging_v2.c4
-rw-r--r--util/ectool.c4
255 files changed, 2424 insertions, 1879 deletions
diff --git a/baseboard/dragonegg/baseboard.c b/baseboard/dragonegg/baseboard.c
index 84a225c33a..e14013c756 100644
--- a/baseboard/dragonegg/baseboard.c
+++ b/baseboard/dragonegg/baseboard.c
@@ -158,7 +158,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
.port = I2C_PORT_USBC1C2,
- .addr = TUSB422_I2C_ADDR,
+ .addr__7bf = TUSB422_I2C_ADDR__7bf,
},
.drv = &tusb422_tcpm_drv,
/* Alert is active-low, push-pull */
@@ -171,19 +171,19 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
struct ppc_config_t ppc_chips[CONFIG_USB_PD_PORT_COUNT] = {
[USB_PD_PORT_ITE_0] = {
.i2c_port = I2C_PORT_USBC0,
- .i2c_addr = SN5S330_ADDR0,
+ .i2c_addr__7bf = SN5S330_ADDR0__7bf,
.drv = &sn5s330_drv
},
[USB_PD_PORT_ITE_1] = {
.i2c_port = I2C_PORT_USBC1C2,
- .i2c_addr = SYV682X_ADDR0,
+ .i2c_addr__7bf = SYV682X_ADDR0__7bf,
.drv = &syv682x_drv
},
[USB_PD_PORT_TUSB422_2] = {
.i2c_port = I2C_PORT_USBC1C2,
- .i2c_addr = NX20P3481_ADDR2,
+ .i2c_addr__7bf = NX20P3481_ADDR2__7bf,
.drv = &nx20p348x_drv,
},
};
diff --git a/baseboard/dragonegg/baseboard.h b/baseboard/dragonegg/baseboard.h
index d51c5c3e62..4d02166703 100644
--- a/baseboard/dragonegg/baseboard.h
+++ b/baseboard/dragonegg/baseboard.h
@@ -131,9 +131,9 @@
#define I2C_PORT_CHARGER IT83XX_I2C_CH_F /* Shared bus */
#define I2C_PORT_SENSOR IT83XX_I2C_CH_B
#define I2C_PORT_USBC0 IT83XX_I2C_CH_E
-#define I2C_PORT_USBC1C2 IT83XX_I2C_CH_C
+#define I2C_PORT_USBC1C2 IT83XX_I2C_CH_C
#define I2C_PORT_EEPROM IT83XX_I2C_CH_A
-#define I2C_ADDR_EEPROM 0xA0
+#define I2C_ADDR_EEPROM__7bf 0x50
#ifndef __ASSEMBLER__
diff --git a/baseboard/grunt/baseboard.c b/baseboard/grunt/baseboard.c
index 2ebdbc6591..592c821ca7 100644
--- a/baseboard/grunt/baseboard.c
+++ b/baseboard/grunt/baseboard.c
@@ -82,7 +82,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
.port = I2C_PORT_TCPC0,
- .addr = ANX74XX_I2C_ADDR1,
+ .addr__7bf = ANX74XX_I2C_ADDR1__7bf,
},
.drv = &anx74xx_tcpm_drv,
/* Alert is active-low, open-drain */
@@ -92,7 +92,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
.port = I2C_PORT_TCPC1,
- .addr = PS8751_I2C_ADDR1,
+ .addr__7bf = PS8751_I2C_ADDR1__7bf,
},
.drv = &ps8xxx_tcpm_drv,
/* Alert is active-low, push-pull */
@@ -133,12 +133,12 @@ struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_COUNT] = {
struct ppc_config_t ppc_chips[] = {
{
.i2c_port = I2C_PORT_TCPC0,
- .i2c_addr = SN5S330_ADDR0,
+ .i2c_addr__7bf = SN5S330_ADDR0__7bf,
.drv = &sn5s330_drv
},
{
.i2c_port = I2C_PORT_TCPC1,
- .i2c_addr = SN5S330_ADDR0,
+ .i2c_addr__7bf = SN5S330_ADDR0__7bf,
.drv = &sn5s330_drv
},
};
@@ -380,7 +380,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_lid_mutex,
.drv_data = &g_kx022_data,
.port = I2C_PORT_SENSOR,
- .addr = KX022_ADDR1,
+ .i2c_spi_addr__7bf = KX022_ADDR1__7bf,
.rot_standard_ref = (const mat33_fp_t *)&lid_standard_ref,
.default_range = 2, /* g, enough for laptop. */
.min_frequency = KX022_ACCEL_MIN_FREQ,
@@ -408,7 +408,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_base_mutex,
.drv_data = &g_bmi160_data,
.port = I2C_PORT_SENSOR,
- .addr = BMI160_ADDR0,
+ .i2c_spi_addr__7bf = BMI160_ADDR0__7bf,
.default_range = 2, /* g, enough for laptop */
.rot_standard_ref = (const mat33_fp_t *)&grunt_base_standard_ref,
.min_frequency = BMI160_ACCEL_MIN_FREQ,
@@ -436,7 +436,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_base_mutex,
.drv_data = &g_bmi160_data,
.port = I2C_PORT_SENSOR,
- .addr = BMI160_ADDR0,
+ .i2c_spi_addr__7bf = BMI160_ADDR0__7bf,
.default_range = 1000, /* dps */
.rot_standard_ref = (const mat33_fp_t *)&grunt_base_standard_ref,
.min_frequency = BMI160_GYRO_MIN_FREQ,
diff --git a/baseboard/hatch/baseboard.c b/baseboard/hatch/baseboard.c
index d76227e562..b2aa3810ed 100644
--- a/baseboard/hatch/baseboard.c
+++ b/baseboard/hatch/baseboard.c
@@ -119,13 +119,13 @@ DECLARE_HOOK(HOOK_CHIPSET_SHUTDOWN, baseboard_chipset_shutdown,
struct ppc_config_t ppc_chips[CONFIG_USB_PD_PORT_COUNT] = {
[USB_PD_PORT_TCPC_0] = {
.i2c_port = I2C_PORT_PPC0,
- .i2c_addr = SN5S330_ADDR0,
+ .i2c_addr__7bf = SN5S330_ADDR0__7bf,
.drv = &sn5s330_drv
},
[USB_PD_PORT_TCPC_1] = {
.i2c_port = I2C_PORT_TCPC1,
- .i2c_addr = SN5S330_ADDR0,
+ .i2c_addr__7bf = SN5S330_ADDR0__7bf,
.drv = &sn5s330_drv
},
};
diff --git a/baseboard/hatch/baseboard.h b/baseboard/hatch/baseboard.h
index 5c096863c1..4ad634df45 100644
--- a/baseboard/hatch/baseboard.h
+++ b/baseboard/hatch/baseboard.h
@@ -155,7 +155,7 @@
#define I2C_PORT_TCPC0 NPCX_I2C_PORT3_0
#define I2C_PORT_POWER NPCX_I2C_PORT5_0
#define I2C_PORT_EEPROM NPCX_I2C_PORT7_0
-#define I2C_ADDR_EEPROM 0xA0
+#define I2C_ADDR_EEPROM__7bf 0x50
#define I2C_PORT_BATTERY I2C_PORT_POWER
#define I2C_PORT_CHARGER I2C_PORT_POWER
diff --git a/baseboard/kalista/baseboard.c b/baseboard/kalista/baseboard.c
index f3d552c96b..20520e3f50 100644
--- a/baseboard/kalista/baseboard.c
+++ b/baseboard/kalista/baseboard.c
@@ -144,7 +144,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
.port = I2C_PORT_TCPC0,
- .addr = I2C_ADDR_TCPC0,
+ .addr__7bf = I2C_ADDR_TCPC0__7bf,
},
.drv = &ps8xxx_tcpm_drv,
},
@@ -193,7 +193,7 @@ void board_tcpc_init(void)
* TCPM_INIT will fail due to not able to access PS8751.
* Note PS8751 A3 will wake on any I2C access.
*/
- i2c_read8(I2C_PORT_TCPC0, I2C_ADDR_TCPC0, 0xA0, &reg);
+ i2c_read8__7bf(I2C_PORT_TCPC0, I2C_ADDR_TCPC0__7bf, 0xA0, &reg);
/* Enable TCPC interrupts */
gpio_enable_interrupt(GPIO_USB_C0_PD_INT_ODL);
@@ -249,10 +249,10 @@ BUILD_ASSERT(ARRAY_SIZE(thermal_params) == TEMP_SENSOR_COUNT);
/* Initialize PMIC */
#define I2C_PMIC_READ(reg, data) \
- i2c_read8(I2C_PORT_PMIC, TPS650X30_I2C_ADDR1, (reg), (data))
+ i2c_read8__7bf(I2C_PORT_PMIC, TPS650X30_I2C_ADDR1__7bf, (reg), (data))
#define I2C_PMIC_WRITE(reg, data) \
- i2c_write8(I2C_PORT_PMIC, TPS650X30_I2C_ADDR1, (reg), (data))
+ i2c_write8__7bf(I2C_PORT_PMIC, TPS650X30_I2C_ADDR1__7bf, (reg), (data))
static void board_pmic_init(void)
{
diff --git a/baseboard/kalista/baseboard.h b/baseboard/kalista/baseboard.h
index b94df35a1c..2cb8a06481 100644
--- a/baseboard/kalista/baseboard.h
+++ b/baseboard/kalista/baseboard.h
@@ -120,8 +120,8 @@
#define I2C_PORT_THERMAL NPCX_I2C_PORT3
/* I2C addresses */
-#define I2C_ADDR_TCPC0 0x16
-#define I2C_ADDR_EEPROM 0xa0
+#define I2C_ADDR_TCPC0__7bf 0x0b
+#define I2C_ADDR_EEPROM__7bf 0x50
/* Verify and jump to RW image on boot */
#define CONFIG_VBOOT_EFS
diff --git a/baseboard/octopus/baseboard.h b/baseboard/octopus/baseboard.h
index a062b021ce..05494819ff 100644
--- a/baseboard/octopus/baseboard.h
+++ b/baseboard/octopus/baseboard.h
@@ -47,7 +47,7 @@
#define I2C_PORT_EEPROM NPCX_I2C_PORT3_0
#define I2C_PORT_CHARGER NPCX_I2C_PORT4_1
#define I2C_PORT_SENSOR NPCX_I2C_PORT7_0
- #define I2C_ADDR_EEPROM 0xA0
+ #define I2C_ADDR_EEPROM__7bf 0x50
/* Enable PSL hibernate mode. */
#define CONFIG_HIBERNATE_PSL
@@ -69,7 +69,7 @@
#define I2C_PORT_USBC1 IT83XX_I2C_CH_E
#define I2C_PORT_USB_MUX I2C_PORT_USBC0 /* For MUX driver */
#define I2C_PORT_EEPROM IT83XX_I2C_CH_F
- #define I2C_ADDR_EEPROM 0xA0
+ #define I2C_ADDR_EEPROM__7bf 0x50
/* EC variant determines USB-C variant */
#define VARIANT_OCTOPUS_USBC_ITE_EC_TCPCS
diff --git a/baseboard/octopus/variant_usbc_ec_tcpcs.c b/baseboard/octopus/variant_usbc_ec_tcpcs.c
index afea880075..071c6388d3 100644
--- a/baseboard/octopus/variant_usbc_ec_tcpcs.c
+++ b/baseboard/octopus/variant_usbc_ec_tcpcs.c
@@ -68,14 +68,14 @@ static void board_it83xx_hpd_status(int port, int hpd_lvl, int hpd_irq)
struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_COUNT] = {
[USB_PD_PORT_ITE_0] = {
/* Driver uses I2C_PORT_USB_MUX as I2C port */
- .port_addr = IT5205_I2C_ADDR1,
+ .port_addr = IT5205_I2C_ADDR1__7bf,
.driver = &it5205_usb_mux_driver,
.hpd_update = &board_it83xx_hpd_status,
},
[USB_PD_PORT_ITE_1] = {
/* Use PS8751 as mux only */
.port_addr = MUX_PORT_AND_ADDR(
- I2C_PORT_USBC1, PS8751_I2C_ADDR1),
+ I2C_PORT_USBC1, PS8751_I2C_ADDR1__7bf),
.flags = USB_MUX_FLAG_NOT_TCPC,
.driver = &ps8xxx_usb_mux_driver,
.hpd_update = &ps8xxx_tcpc_update_hpd_status,
@@ -87,12 +87,12 @@ struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_COUNT] = {
struct ppc_config_t ppc_chips[CONFIG_USB_PD_PORT_COUNT] = {
[USB_PD_PORT_ITE_0] = {
.i2c_port = I2C_PORT_USBC0,
- .i2c_addr = SN5S330_ADDR0,
+ .i2c_addr__7bf = SN5S330_ADDR0__7bf,
.drv = &sn5s330_drv
},
[USB_PD_PORT_ITE_1] = {
.i2c_port = I2C_PORT_USBC1,
- .i2c_addr = SN5S330_ADDR0,
+ .i2c_addr__7bf = SN5S330_ADDR0__7bf,
.drv = &sn5s330_drv
},
};
diff --git a/baseboard/octopus/variant_usbc_standalone_tcpcs.c b/baseboard/octopus/variant_usbc_standalone_tcpcs.c
index cc47633586..c9921b8a4b 100644
--- a/baseboard/octopus/variant_usbc_standalone_tcpcs.c
+++ b/baseboard/octopus/variant_usbc_standalone_tcpcs.c
@@ -35,14 +35,14 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
.port = I2C_PORT_TCPC0,
- .addr = PS8751_I2C_ADDR1,
+ .addr__7bf = PS8751_I2C_ADDR1__7bf,
},
.drv = &ps8xxx_tcpm_drv,
#else
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
.port = I2C_PORT_TCPC0,
- .addr = AN7447_TCPC0_I2C_ADDR,
+ .addr__7bf = AN7447_TCPC0_I2C_ADDR__7bf,
},
.drv = &anx7447_tcpm_drv,
#endif
@@ -51,7 +51,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
.port = I2C_PORT_TCPC1,
- .addr = PS8751_I2C_ADDR1,
+ .addr__7bf = PS8751_I2C_ADDR1__7bf,
},
.drv = &ps8xxx_tcpm_drv,
},
@@ -91,12 +91,12 @@ struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_COUNT] = {
struct ppc_config_t ppc_chips[CONFIG_USB_PD_PORT_COUNT] = {
[USB_PD_PORT_TCPC_0] = {
.i2c_port = I2C_PORT_TCPC0,
- .i2c_addr = NX20P3483_ADDR2,
+ .i2c_addr__7bf = NX20P3483_ADDR2__7bf,
.drv = &nx20p348x_drv,
},
[USB_PD_PORT_TCPC_1] = {
.i2c_port = I2C_PORT_TCPC1,
- .i2c_addr = NX20P3483_ADDR2,
+ .i2c_addr__7bf = NX20P3483_ADDR2__7bf,
.drv = &nx20p348x_drv,
},
};
diff --git a/baseboard/zork/baseboard.c b/baseboard/zork/baseboard.c
index eca652210f..1014b1dec5 100644
--- a/baseboard/zork/baseboard.c
+++ b/baseboard/zork/baseboard.c
@@ -89,7 +89,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
.port = I2C_PORT_TCPC0,
- .addr = ANX74XX_I2C_ADDR1,
+ .addr__7bf = ANX74XX_I2C_ADDR1__7bf,
},
.drv = &anx74xx_tcpm_drv,
/* Alert is active-low, open-drain */
@@ -99,7 +99,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
.port = I2C_PORT_TCPC1,
- .addr = PS8751_I2C_ADDR1,
+ .addr__7bf = PS8751_I2C_ADDR1__7bf,
},
.drv = &ps8xxx_tcpm_drv,
/* Alert is active-low, push-pull */
@@ -140,12 +140,12 @@ struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_COUNT] = {
struct ppc_config_t ppc_chips[] = {
{
.i2c_port = I2C_PORT_TCPC0,
- .i2c_addr = SN5S330_ADDR0,
+ .i2c_addr__7bf = SN5S330_ADDR0__7bf,
.drv = &sn5s330_drv
},
{
.i2c_port = I2C_PORT_TCPC1,
- .i2c_addr = SN5S330_ADDR0,
+ .i2c_addr__7bf = SN5S330_ADDR0__7bf,
.drv = &sn5s330_drv
},
};
@@ -387,7 +387,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_lid_mutex,
.drv_data = &g_kx022_data,
.port = I2C_PORT_SENSOR,
- .addr = KX022_ADDR1,
+ .i2c_spi_addr__7bf = KX022_ADDR1__7bf,
.rot_standard_ref = (const mat33_fp_t *)&lid_standard_ref,
.default_range = 2, /* g, enough for laptop. */
.min_frequency = KX022_ACCEL_MIN_FREQ,
@@ -415,7 +415,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_base_mutex,
.drv_data = &g_bmi160_data,
.port = I2C_PORT_SENSOR,
- .addr = BMI160_ADDR0,
+ .i2c_spi_addr__7bf = BMI160_ADDR0__7bf,
.default_range = 2, /* g, enough for laptop */
.rot_standard_ref = (const mat33_fp_t *)&zork_base_standard_ref,
.min_frequency = BMI160_ACCEL_MIN_FREQ,
@@ -443,7 +443,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_base_mutex,
.drv_data = &g_bmi160_data,
.port = I2C_PORT_SENSOR,
- .addr = BMI160_ADDR0,
+ .i2c_spi_addr__7bf = BMI160_ADDR0__7bf,
.default_range = 1000, /* dps */
.rot_standard_ref = (const mat33_fp_t *)&zork_base_standard_ref,
.min_frequency = BMI160_GYRO_MIN_FREQ,
diff --git a/board/ampton/board.c b/board/ampton/board.c
index 9a9ed5c3c7..15b3af652a 100644
--- a/board/ampton/board.c
+++ b/board/ampton/board.c
@@ -72,7 +72,7 @@ struct usb_mux ampton_usb_muxes[CONFIG_USB_PD_PORT_COUNT] = {
[USB_PD_PORT_ITE_0] = {
/* Use PS8751 as mux only */
.port_addr = MUX_PORT_AND_ADDR(
- I2C_PORT_USBC0, PS8751_I2C_ADDR1),
+ I2C_PORT_USBC0, PS8751_I2C_ADDR1__7bf),
.flags = USB_MUX_FLAG_NOT_TCPC,
.driver = &ps8xxx_usb_mux_driver,
.hpd_update = &ps8xxx_tcpc_update_hpd_status,
@@ -81,7 +81,7 @@ struct usb_mux ampton_usb_muxes[CONFIG_USB_PD_PORT_COUNT] = {
[USB_PD_PORT_ITE_1] = {
/* Use PS8751 as mux only */
.port_addr = MUX_PORT_AND_ADDR(
- I2C_PORT_USBC1, PS8751_I2C_ADDR1),
+ I2C_PORT_USBC1, PS8751_I2C_ADDR1__7bf),
.flags = USB_MUX_FLAG_NOT_TCPC,
.driver = &ps8xxx_usb_mux_driver,
.hpd_update = &ps8xxx_tcpc_update_hpd_status,
@@ -188,7 +188,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_lid_mutex,
.drv_data = &g_kx022_data,
.port = I2C_PORT_SENSOR,
- .addr = KX022_ADDR1,
+ .i2c_spi_addr__7bf = KX022_ADDR1__7bf,
.rot_standard_ref = &lid_standard_ref,
.default_range = 4, /* g */
.config = {
@@ -212,7 +212,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_base_mutex,
.drv_data = &g_bmi160_data,
.port = I2C_PORT_SENSOR,
- .addr = BMI160_ADDR0,
+ .i2c_spi_addr__7bf = BMI160_ADDR0__7bf,
.rot_standard_ref = &base_standard_ref,
.default_range = 4, /* g */
.min_frequency = BMI160_ACCEL_MIN_FREQ,
@@ -240,7 +240,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_base_mutex,
.drv_data = &g_bmi160_data,
.port = I2C_PORT_SENSOR,
- .addr = BMI160_ADDR0,
+ .i2c_spi_addr__7bf = BMI160_ADDR0__7bf,
.default_range = 1000, /* dps */
.rot_standard_ref = &gyro_standard_ref,
.min_frequency = BMI160_GYRO_MIN_FREQ,
diff --git a/board/arcada_ish/board.c b/board/arcada_ish/board.c
index 911dc6a290..f18a530568 100644
--- a/board/arcada_ish/board.c
+++ b/board/arcada_ish/board.c
@@ -63,7 +63,7 @@ struct motion_sensor_t motion_sensors[] = {
.int_signal = GPIO_ACCEL_GYRO_INT_L,
.flags = MOTIONSENSE_FLAG_INT_SIGNAL,
.port = I2C_PORT_SENSOR,
- .addr = LSM6DSM_ADDR1,
+ .i2c_spi_addr__7bf = LSM6DSM_ADDR1__7bf,
.rot_standard_ref = &lid_rot_ref,
.default_range = 4, /* g */
.min_frequency = LSM6DSM_ODR_MIN_VAL,
@@ -93,7 +93,7 @@ struct motion_sensor_t motion_sensors[] = {
.int_signal = GPIO_ACCEL_GYRO_INT_L,
.flags = MOTIONSENSE_FLAG_INT_SIGNAL,
.port = I2C_PORT_SENSOR,
- .addr = LSM6DSM_ADDR1,
+ .i2c_spi_addr__7bf = LSM6DSM_ADDR1__7bf,
.default_range = 1000 | ROUND_UP_FLAG, /* dps */
.rot_standard_ref = &lid_rot_ref,
.min_frequency = LSM6DSM_ODR_MIN_VAL,
@@ -110,7 +110,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_base_mutex,
.drv_data = &g_lis2dh_data,
.port = I2C_PORT_SENSOR,
- .addr = LNG2DM_ADDR0,
+ .i2c_spi_addr__7bf = LNG2DM_ADDR0__7bf,
.rot_standard_ref = NULL, /* Identity matrix */
/* We only use 2g because its resolution is only 8-bits */
.default_range = 2, /* g */
@@ -138,7 +138,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_lid_mag_mutex,
.drv_data = LIS2MDL_ST_DATA(lis2mdl_a_data),
.port = I2C_PORT_SENSOR,
- .addr = LIS2MDL_ADDR,
+ .i2c_spi_addr__7bf = LIS2MDL_ADDR__7bf,
.default_range = 1 << 11, /* 16LSB / uT, fixed */
.rot_standard_ref = &lid_rot_ref,
.min_frequency = LIS2MDL_ODR_MIN_VAL,
diff --git a/board/atlas/board.c b/board/atlas/board.c
index c72ba963bb..3d6e52ed89 100644
--- a/board/atlas/board.c
+++ b/board/atlas/board.c
@@ -159,7 +159,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
.port = I2C_PORT_TCPC0,
- .addr = I2C_ADDR_TCPC,
+ .addr__7bf = I2C_ADDR_TCPC__7bf,
},
.drv = &ps8xxx_tcpm_drv,
/* Alert is active-low, push-pull */
@@ -170,7 +170,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
.port = I2C_PORT_TCPC1,
- .addr = I2C_ADDR_TCPC,
+ .addr__7bf = I2C_ADDR_TCPC__7bf,
},
.drv = &ps8xxx_tcpm_drv,
/* Alert is active-low, push-pull */
@@ -262,7 +262,7 @@ static void board_report_pmic_fault(const char *str)
uint32_t info;
/* RESETIRQ1 -- Bit 4: VRFAULT */
- if (i2c_read8(I2C_PORT_PMIC, I2C_ADDR_BD99992,
+ if (i2c_read8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf,
BD99992GW_REG_RESETIRQ1, &vrfault) != EC_SUCCESS)
return;
@@ -272,11 +272,11 @@ static void board_report_pmic_fault(const char *str)
/* VRFAULT has occurred, print VRFAULT status bits. */
/* PWRSTAT1 */
- i2c_read8(I2C_PORT_PMIC, I2C_ADDR_BD99992,
+ i2c_read8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf,
BD99992GW_REG_PWRSTAT1, &pwrstat1);
/* PWRSTAT2 */
- i2c_read8(I2C_PORT_PMIC, I2C_ADDR_BD99992,
+ i2c_read8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf,
BD99992GW_REG_PWRSTAT2, &pwrstat2);
CPRINTS("PMIC VRFAULT: %s", str);
@@ -284,11 +284,11 @@ static void board_report_pmic_fault(const char *str)
pwrstat2);
/* Clear all faults -- Write 1 to clear. */
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992,
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf,
BD99992GW_REG_RESETIRQ1, BIT(4));
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992,
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf,
BD99992GW_REG_PWRSTAT1, pwrstat1);
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992,
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf,
BD99992GW_REG_PWRSTAT2, pwrstat2);
/*
@@ -308,7 +308,7 @@ static void board_pmic_disable_slp_s0_vr_decay(void)
* Bits 3:2 (10) - VR set to AUTO on SLP_S0# de-assertion
* Bits 1:0 (10) - VR set to AUTO operating mode
*/
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992,
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf,
BD99992GW_REG_VCCIOCNT, 0x3a);
/*
@@ -318,7 +318,7 @@ static void board_pmic_disable_slp_s0_vr_decay(void)
* Bits 3:2 (10) - VR set to AUTO on SLP_S0# de-assertion
* Bits 1:0 (10) - VR set to AUTO operating mode
*/
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992,
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf,
BD99992GW_REG_V18ACNT, 0x2a);
/*
@@ -328,7 +328,7 @@ static void board_pmic_disable_slp_s0_vr_decay(void)
* Bits 3:2 (10) - VR set to AUTO on SLP_S0# de-assertion
* Bits 1:0 (10) - VR set to AUTO operating mode
*/
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992,
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf,
BD99992GW_REG_V085ACNT, 0x2a);
}
@@ -341,7 +341,7 @@ static void board_pmic_enable_slp_s0_vr_decay(void)
* Bits 3:2 (10) - VR set to AUTO on SLP_S0# de-assertion
* Bits 1:0 (10) - VR set to AUTO operating mode
*/
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992,
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf,
BD99992GW_REG_VCCIOCNT, 0x7a);
/*
@@ -351,7 +351,7 @@ static void board_pmic_enable_slp_s0_vr_decay(void)
* Bits 3:2 (10) - VR set to AUTO on SLP_S0# de-assertion
* Bits 1:0 (10) - VR set to AUTO operating mode
*/
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992,
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf,
BD99992GW_REG_V18ACNT, 0x6a);
/*
@@ -361,7 +361,7 @@ static void board_pmic_enable_slp_s0_vr_decay(void)
* Bits 3:2 (10) - VR set to AUTO on SLP_S0# de-assertion
* Bits 1:0 (10) - VR set to AUTO operating mode
*/
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992,
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf,
BD99992GW_REG_V085ACNT, 0x6a);
}
@@ -378,25 +378,25 @@ static void board_pmic_init(void)
board_report_pmic_fault("SYSJUMP");
/* Clear power source events */
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992,
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf,
BD99992GW_REG_PWRSRCINT, 0xff);
/* Disable power button shutdown timer */
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992,
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf,
BD99992GW_REG_PBCONFIG, 0x00);
if (system_jumped_to_this_image())
return;
/* DISCHGCNT1 - enable 100 ohm discharge on VCCIO */
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992,
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf,
BD99992GW_REG_DISCHGCNT1, 0x01);
/*
* DISCHGCNT2 - enable 100 ohm discharge on
* V5.0A, V3.3DSW, V3.3A and V1.8A
*/
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992,
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf,
BD99992GW_REG_DISCHGCNT2, 0x55);
/*
@@ -405,19 +405,19 @@ static void board_pmic_init(void)
* DISCHGCNT3 - enable 100 ohm discharge on
* V12U, V1.00A, V0.85A
*/
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992,
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf,
BD99992GW_REG_DISCHGCNT3, 0xd5);
/* DISCHGCNT4 - enable 100 ohm discharge on V33S, V18S, V100S */
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992,
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf,
BD99992GW_REG_DISCHGCNT4, 0x15);
/* VRMODECTRL - disable low-power mode for all rails */
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992,
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf,
BD99992GW_REG_VRMODECTRL, 0x1f);
/* V5ADS3CNT - boost V5A_DS3 by 2% */
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992,
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf,
BD99992GW_REG_V5ADS3CNT, 0x1a);
board_pmic_disable_slp_s0_vr_decay();
@@ -440,7 +440,7 @@ void board_hibernate(void)
system_enter_psl_mode();
/* Cut off DSW power via the ROP PMIC. */
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992,
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf,
BD99992GW_REG_SDWNCTRL, BD99992GW_SDWNCTRL_SWDN);
/* Wait for power to be cut. */
@@ -593,7 +593,7 @@ struct motion_sensor_t motion_sensors[] = {
.drv = &opt3001_drv,
.drv_data = &g_opt3001_data,
.port = I2C_PORT_SENSOR,
- .addr = OPT3001_I2C_ADDR,
+ .i2c_spi_addr__7bf = OPT3001_I2C_ADDR__7bf,
.rot_standard_ref = NULL,
.default_range = 0x2b11a1, /* from nocturne */
.min_frequency = OPT3001_LIGHT_MIN_FREQ,
diff --git a/board/atlas/board.h b/board/atlas/board.h
index b9d9ca5eae..2d27e89314 100644
--- a/board/atlas/board.h
+++ b/board/atlas/board.h
@@ -113,7 +113,7 @@
#define CONFIG_ALS
#define CONFIG_ALS_OPT3001
#define ALS_COUNT 1
-#define OPT3001_I2C_ADDR OPT3001_I2C_ADDR1
+#define OPT3001_I2C_ADDR__7bf OPT3001_I2C_ADDR1__7bf
#define CONFIG_ACCEL_FIFO 1024
#define CONFIG_ACCEL_FIFO_THRES (CONFIG_ACCEL_FIFO / 3)
#define CONFIG_ACCEL_INTERRUPTS
@@ -166,9 +166,9 @@
#define I2C_PORT_THERMAL I2C_PORT_POWER
/* I2C addresses */
-#define I2C_ADDR_TCPC 0x16
-#define I2C_ADDR_MP2949 0x40
-#define I2C_ADDR_BD99992 0x60
+#define I2C_ADDR_TCPC__7bf 0x0B
+#define I2C_ADDR_MP2949__7bf 0x20
+#define I2C_ADDR_BD99992__7bf 0x30
#ifndef __ASSEMBLER__
diff --git a/board/bloog/board.c b/board/bloog/board.c
index 6bf29ed642..f14989ad73 100644
--- a/board/bloog/board.c
+++ b/board/bloog/board.c
@@ -138,7 +138,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_lid_mutex,
.drv_data = &kx022_data,
.port = I2C_PORT_SENSOR,
- .addr = KX022_ADDR1,
+ .i2c_spi_addr__7bf = KX022_ADDR1__7bf,
.rot_standard_ref = &lid_standrd_ref,
.default_range = 2, /* g */
.config = {
@@ -166,7 +166,7 @@ struct motion_sensor_t motion_sensors[] = {
.int_signal = GPIO_BASE_SIXAXIS_INT_L,
.flags = MOTIONSENSE_FLAG_INT_SIGNAL,
.port = I2C_PORT_SENSOR,
- .addr = LSM6DSM_ADDR0,
+ .i2c_spi_addr__7bf = LSM6DSM_ADDR0__7bf,
.rot_standard_ref = &base_standard_ref,
.default_range = 2, /* g */
.min_frequency = LSM6DSM_ODR_MIN_VAL,
@@ -198,7 +198,7 @@ struct motion_sensor_t motion_sensors[] = {
.int_signal = GPIO_BASE_SIXAXIS_INT_L,
.flags = MOTIONSENSE_FLAG_INT_SIGNAL,
.port = I2C_PORT_SENSOR,
- .addr = LSM6DSM_ADDR0,
+ .i2c_spi_addr__7bf = LSM6DSM_ADDR0__7bf,
.default_range = 1000 | ROUND_UP_FLAG, /* dps */
.rot_standard_ref = &base_standard_ref,
.min_frequency = LSM6DSM_ODR_MIN_VAL,
diff --git a/board/bobba/board.c b/board/bobba/board.c
index 32b79e886e..251c545290 100644
--- a/board/bobba/board.c
+++ b/board/bobba/board.c
@@ -168,7 +168,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_lid_mutex,
.drv_data = &g_kx022_data,
.port = I2C_PORT_SENSOR,
- .addr = KX022_ADDR1,
+ .i2c_spi_addr__7bf = KX022_ADDR1__7bf,
.rot_standard_ref = NULL, /* Identity matrix. */
.default_range = 4, /* g */
.config = {
@@ -192,7 +192,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_base_mutex,
.drv_data = &g_bmi160_data,
.port = I2C_PORT_SENSOR,
- .addr = BMI160_ADDR0,
+ .i2c_spi_addr__7bf = BMI160_ADDR0__7bf,
.rot_standard_ref = &base_standard_ref,
.default_range = 4, /* g */
.min_frequency = BMI160_ACCEL_MIN_FREQ,
@@ -220,7 +220,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_base_mutex,
.drv_data = &g_bmi160_data,
.port = I2C_PORT_SENSOR,
- .addr = BMI160_ADDR0,
+ .i2c_spi_addr__7bf = BMI160_ADDR0__7bf,
.default_range = 1000, /* dps */
.rot_standard_ref = &base_standard_ref,
.min_frequency = BMI160_GYRO_MIN_FREQ,
diff --git a/board/casta/board.c b/board/casta/board.c
index 64c2d86003..ae3f61e0c1 100644
--- a/board/casta/board.c
+++ b/board/casta/board.c
@@ -95,9 +95,10 @@ BUILD_ASSERT(ARRAY_SIZE(temp_sensors) == TEMP_SENSOR_COUNT);
#define BATTERY_FREE_MIN_DELTA_US (5 * MSEC)
static timestamp_t battery_last_i2c_time;
-static int is_battery_i2c(int port, int slave_addr)
+static int is_battery_i2c__7bf(const int port, const uint16_t slave_addr__7bf)
{
- return (port == I2C_PORT_BATTERY) && (slave_addr == BATTERY_ADDR);
+ return (port == I2C_PORT_BATTERY)
+ && (slave_addr__7bf == BATTERY_ADDR__7bf);
}
static int is_battery_port(int port)
@@ -105,11 +106,11 @@ static int is_battery_port(int port)
return (port == I2C_PORT_BATTERY);
}
-void i2c_start_xfer_notify(int port, int slave_addr)
+void i2c_start_xfer_notify__7bf(const int port, const uint16_t slave_addr__7bf)
{
unsigned int time_delta_us;
- if (!is_battery_i2c(port, slave_addr))
+ if (!is_battery_i2c__7bf(port, slave_addr__7bf))
return;
time_delta_us = time_since32(battery_last_i2c_time);
@@ -119,7 +120,7 @@ void i2c_start_xfer_notify(int port, int slave_addr)
usleep(BATTERY_FREE_MIN_DELTA_US - time_delta_us);
}
-void i2c_end_xfer_notify(int port, int slave_addr)
+void i2c_end_xfer_notify__7bf(const int port, const uint16_t slave_addr__7bf)
{
/*
* The bus free time needs to be maintained from last transaction
diff --git a/board/chell/board.c b/board/chell/board.c
index 6311dc6c9c..7ecad3f1c1 100644
--- a/board/chell/board.c
+++ b/board/chell/board.c
@@ -42,7 +42,7 @@
#define CPRINTS(format, args...) cprints(CC_USBCHARGE, format, ## args)
#define CPRINTF(format, args...) cprintf(CC_USBCHARGE, format, ## args)
-#define I2C_ADDR_BD99992 0x60
+#define I2C_ADDR_BD99992__7bf 0x30
/* Exchange status with PD MCU. */
static void pd_mcu_interrupt(enum gpio_signal signal)
@@ -111,7 +111,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
.port = I2C_PORT_TCPC,
- .addr = CONFIG_TCPC_I2C_BASE_ADDR,
+ .addr__7bf = CONFIG_TCPC_I2C_BASE_ADDR__7BF,
},
.drv = &tcpci_tcpm_drv,
},
@@ -119,7 +119,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
.port = I2C_PORT_TCPC,
- .addr = CONFIG_TCPC_I2C_BASE_ADDR + 2,
+ .addr__7bf = CONFIG_TCPC_I2C_BASE_ADDR__7BF + 1,
},
.drv = &tcpci_tcpm_drv,
@@ -183,12 +183,12 @@ static int ps874x_tune_mux(int port)
struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_COUNT] = {
{
- .port_addr = 0x34,
+ .port_addr = 0x1A,
.driver = &ps874x_usb_mux_driver,
.board_init = &ps874x_tune_mux,
},
{
- .port_addr = 0x20,
+ .port_addr = 0x10,
.driver = &ps874x_usb_mux_driver,
.board_init = &ps874x_tune_mux,
}
@@ -230,7 +230,7 @@ BUILD_ASSERT(ARRAY_SIZE(temp_sensors) == TEMP_SENSOR_COUNT);
static void board_pmic_init(void)
{
/* DISCHGCNT3 - enable 100 ohm discharge on V1.00A */
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x3e, 0x04);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x3e, 0x04);
/*
* No need to re-init below settings since they are present on all MP
@@ -240,23 +240,23 @@ static void board_pmic_init(void)
return;
/* Set CSDECAYEN / VCCIO decays to 0V at assertion of SLP_S0# */
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x30, 0x4a);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x30, 0x4a);
/*
* Set V100ACNT / V1.00A Control Register:
* Nominal output = 1.0V.
*/
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x37, 0x1a);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x37, 0x1a);
/*
* Set V085ACNT / V0.85A Control Register:
* Lower power mode = 0.7V.
* Nominal output = 1.0V.
*/
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x38, 0x7a);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x38, 0x7a);
/* VRMODECTRL - enable low-power mode for VCCIO and V0.85A */
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x3b, 0x18);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x3b, 0x18);
}
DECLARE_HOOK(HOOK_INIT, board_pmic_init, HOOK_PRIO_DEFAULT);
@@ -394,7 +394,7 @@ void board_hibernate(void)
uart_flush_output();
/* Trigger PMIC shutdown. */
- if (i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x49, 0x01)) {
+ if (i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x49, 0x01)) {
/*
* If we can't tell the PMIC to shutdown, instead reset
* and don't start the AP. Hopefully we'll be able to
@@ -466,7 +466,8 @@ void chipset_set_pmic_slp_sus_l(int level)
if (!level)
msleep(25);
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x43, val);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf,
+ 0x43, val);
previous_level = level;
}
}
diff --git a/board/cheza/board.c b/board/cheza/board.c
index d13f06e61f..8f11d0150b 100644
--- a/board/cheza/board.c
+++ b/board/cheza/board.c
@@ -242,7 +242,7 @@ const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports);
struct ppc_config_t ppc_chips[] = {
{
.i2c_port = I2C_PORT_TCPC0,
- .i2c_addr = SN5S330_ADDR0,
+ .i2c_addr__7bf = SN5S330_ADDR0__7bf,
.drv = &sn5s330_drv
},
/*
@@ -261,7 +261,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
.port = I2C_PORT_TCPC0,
- .addr = 0x50,
+ .addr__7bf = 0x28,
},
.drv = &anx74xx_tcpm_drv,
.flags = TCPC_FLAGS_ALERT_OD,
@@ -270,7 +270,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
.port = I2C_PORT_TCPC1,
- .addr = 0x16,
+ .addr__7bf = 0x0B,
},
.drv = &ps8xxx_tcpm_drv,
},
@@ -649,7 +649,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_lid_mutex,
.drv_data = &g_bmi160_data,
.port = I2C_PORT_SENSOR,
- .addr = BMI160_ADDR0,
+ .i2c_spi_addr__7bf = BMI160_ADDR0__7bf,
.rot_standard_ref = &base_standard_ref,
.default_range = 4, /* g */
.min_frequency = BMI160_ACCEL_MIN_FREQ,
@@ -670,7 +670,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_lid_mutex,
.drv_data = &g_bmi160_data,
.port = I2C_PORT_SENSOR,
- .addr = BMI160_ADDR0,
+ .i2c_spi_addr__7bf = BMI160_ADDR0__7bf,
.default_range = 1000, /* dps */
.rot_standard_ref = &base_standard_ref,
.min_frequency = BMI160_GYRO_MIN_FREQ,
@@ -685,7 +685,7 @@ struct motion_sensor_t motion_sensors[] = {
.drv = &opt3001_drv,
.drv_data = &g_opt3001_data,
.port = I2C_PORT_SENSOR,
- .addr = OPT3001_I2C_ADDR,
+ .i2c_spi_addr__7bf = OPT3001_I2C_ADDR__7bf,
.rot_standard_ref = NULL,
.default_range = 0x10000, /* scale = 1; uscale = 0 */
.min_frequency = OPT3001_LIGHT_MIN_FREQ,
diff --git a/board/cheza/board.h b/board/cheza/board.h
index 983316e062..e35502fa57 100644
--- a/board/cheza/board.h
+++ b/board/cheza/board.h
@@ -138,7 +138,7 @@
#define CONFIG_ALS
#define CONFIG_ALS_OPT3001
#define ALS_COUNT 1
-#define OPT3001_I2C_ADDR OPT3001_I2C_ADDR1
+#define OPT3001_I2C_ADDR__7bf OPT3001_I2C_ADDR1__7bf
/* PD */
#define PD_POWER_SUPPLY_TURN_ON_DELAY 30000 /* us */
diff --git a/board/coral/board.c b/board/coral/board.c
index 6b0c613567..936817db76 100644
--- a/board/coral/board.c
+++ b/board/coral/board.c
@@ -174,7 +174,7 @@ struct i2c_stress_test i2c_stress_tests[] = {
#ifdef CONFIG_CMD_I2C_STRESS_TEST_TCPC
{
.port = NPCX_I2C_PORT0_0,
- .addr = ANX74XX_I2C_ADDR1,
+ .addr__7bf = ANX74XX_I2C_ADDR1__7bf,
.i2c_test = &anx74xx_i2c_stress_test_dev,
},
#endif
@@ -183,7 +183,7 @@ struct i2c_stress_test i2c_stress_tests[] = {
#ifdef CONFIG_CMD_I2C_STRESS_TEST_TCPC
{
.port = NPCX_I2C_PORT0_1,
- .addr = PS8751_I2C_ADDR1,
+ .addr__7bf = PS8751_I2C_ADDR1__7bf,
.i2c_test = &ps8xxx_i2c_stress_test_dev,
},
#endif
@@ -192,7 +192,7 @@ struct i2c_stress_test i2c_stress_tests[] = {
#ifdef CONFIG_CMD_I2C_STRESS_TEST_ACCEL
{
.port = I2C_PORT_GYRO,
- .addr = BMI160_ADDR0,
+ .addr__7bf = BMI160_ADDR0__7bf,
.i2c_test = &bmi160_i2c_stress_test_dev,
},
#endif
@@ -201,7 +201,7 @@ struct i2c_stress_test i2c_stress_tests[] = {
#ifdef CONFIG_CMD_I2C_STRESS_TEST_ACCEL
{
.port = I2C_PORT_LID_ACCEL,
- .addr = KX022_ADDR1,
+ .addr__7bf = KX022_ADDR1__7bf,
.i2c_test = &kionix_i2c_stress_test_dev,
},
#endif
@@ -226,7 +226,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
.port = NPCX_I2C_PORT0_0,
- .addr = ANX74XX_I2C_ADDR1,
+ .addr__7bf = ANX74XX_I2C_ADDR1__7bf,
},
.drv = &anx74xx_tcpm_drv,
},
@@ -234,7 +234,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
.port = NPCX_I2C_PORT0_1,
- .addr = PS8751_I2C_ADDR1,
+ .addr__7bf = PS8751_I2C_ADDR1__7bf,
},
.drv = &ps8xxx_tcpm_drv,
},
@@ -373,7 +373,7 @@ static void board_tcpc_init(void)
*
* NOTE: PS8751 A3 will wake on any I2C access.
*/
- i2c_read8(NPCX_I2C_PORT0_1, 0x10, 0xA0, &reg);
+ i2c_read8__7bf(NPCX_I2C_PORT0_1, 0x08, 0xA0, &reg);
/* Enable TCPC0 interrupt */
gpio_enable_interrupt(GPIO_USB_C0_PD_INT_ODL);
@@ -723,7 +723,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_lid_mutex,
.drv_data = &g_kx022_data,
.port = I2C_PORT_LID_ACCEL,
- .addr = KX022_ADDR1,
+ .i2c_spi_addr__7bf = KX022_ADDR1__7bf,
.rot_standard_ref = NULL, /* Identity matrix. */
.default_range = 2, /* g, enough for laptop. */
.config = {
@@ -748,7 +748,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_base_mutex,
.drv_data = &g_bmi160_data,
.port = I2C_PORT_GYRO,
- .addr = BMI160_ADDR0,
+ .i2c_spi_addr__7bf = BMI160_ADDR0__7bf,
.rot_standard_ref = &base_standard_ref,
.default_range = 2, /* g, enough for laptop. */
.config = {
@@ -775,7 +775,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_base_mutex,
.drv_data = &g_bmi160_data,
.port = I2C_PORT_GYRO,
- .addr = BMI160_ADDR0,
+ .i2c_spi_addr__7bf = BMI160_ADDR0__7bf,
.default_range = 1000, /* dps */
.rot_standard_ref = &base_standard_ref,
},
diff --git a/board/elm/board.c b/board/elm/board.c
index cdd0a0f998..3568564621 100644
--- a/board/elm/board.c
+++ b/board/elm/board.c
@@ -92,13 +92,14 @@ const struct adc_t adc_channels[] = {
};
BUILD_ASSERT(ARRAY_SIZE(adc_channels) == ADC_CH_COUNT);
-int anx7688_passthru_allowed(const struct i2c_port_t *port, uint16_t address)
+int anx7688_passthru_allowed__7bf(const struct i2c_port_t *port,
+ const uint16_t addr__7bf)
{
/* Allow access to 0x2c (TCPC) */
- if (address == 0x2c)
+ if (I2C_GET_ADDR__7b(addr__7bf) == 0x2c)
return 1;
- CPRINTF("Passthru rejected on %x", address);
+ CPRINTF("Passthru rejected on %x", I2C_GET_ADDR__7b(addr__7bf));
return 0;
}
@@ -107,7 +108,7 @@ int anx7688_passthru_allowed(const struct i2c_port_t *port, uint16_t address)
const struct i2c_port_t i2c_ports[] = {
{"battery", I2C_PORT_BATTERY, 100, GPIO_I2C0_SCL, GPIO_I2C0_SDA},
{"pd", I2C_PORT_PD_MCU, 1000, GPIO_I2C1_SCL, GPIO_I2C1_SDA,
- anx7688_passthru_allowed}
+ anx7688_passthru_allowed__7bf}
};
const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports);
@@ -125,7 +126,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
.port = I2C_PORT_TCPC,
- .addr = CONFIG_TCPC_I2C_BASE_ADDR,
+ .addr__7bf = CONFIG_TCPC_I2C_BASE_ADDR__7BF,
},
.drv = &anx7688_tcpm_drv,
},
@@ -466,7 +467,7 @@ struct motion_sensor_t motion_sensors[] = {
.drv = &kionix_accel_drv,
.mutex = &g_kx022_mutex[0],
.drv_data = &g_kx022_data[0],
- .addr = 1, /* SPI, device ID 0 */
+ .i2c_spi_addr__7bf = SLAVE_MK_SPI_ADDR__7bf(0),
.rot_standard_ref = &base_standard_ref,
.default_range = 2, /* g, enough for laptop. */
.min_frequency = KX022_ACCEL_MIN_FREQ,
@@ -489,7 +490,7 @@ struct motion_sensor_t motion_sensors[] = {
.drv = &kionix_accel_drv,
.mutex = &g_kx022_mutex[1],
.drv_data = &g_kx022_data[1],
- .addr = 3, /* SPI, device ID 1 */
+ .i2c_spi_addr__7bf = SLAVE_MK_SPI_ADDR__7bf(1),
.rot_standard_ref = &lid_standard_ref,
.default_range = 2, /* g, enough for laptop. */
.min_frequency = KX022_ACCEL_MIN_FREQ,
diff --git a/board/elm/board.h b/board/elm/board.h
index ffd54aacc6..d9e336f720 100644
--- a/board/elm/board.h
+++ b/board/elm/board.h
@@ -99,8 +99,8 @@
#define CONFIG_USB_PD_TCPM_TCPCI
#define CONFIG_USB_PD_TRY_SRC
#define CONFIG_USB_PD_VBUS_DETECT_TCPC
-#undef CONFIG_TCPC_I2C_BASE_ADDR
-#define CONFIG_TCPC_I2C_BASE_ADDR 0x58
+#undef CONFIG_TCPC_I2C_BASE_ADDR__7BF
+#define CONFIG_TCPC_I2C_BASE_ADDR__7BF 0x2C
#define CONFIG_USB_PD_ANX7688
/* UART DMA */
diff --git a/board/eve/board.c b/board/eve/board.c
index fbca0c09e3..72877fd100 100644
--- a/board/eve/board.c
+++ b/board/eve/board.c
@@ -207,7 +207,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
.port = I2C_PORT_TCPC0,
- .addr = ANX74XX_I2C_ADDR1,
+ .addr__7bf = ANX74XX_I2C_ADDR1__7bf,
},
.drv = &anx74xx_tcpm_drv,
},
@@ -215,7 +215,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
.port = I2C_PORT_TCPC1,
- .addr = ANX74XX_I2C_ADDR1,
+ .addr__7bf = ANX74XX_I2C_ADDR1__7bf,
},
.drv = &anx74xx_tcpm_drv,
},
@@ -363,7 +363,7 @@ static void board_report_pmic_fault(const char *str)
uint32_t info;
/* RESETIRQ1 -- Bit 4: VRFAULT */
- if (i2c_read8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x8, &vrfault)
+ if (i2c_read8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x8, &vrfault)
!= EC_SUCCESS)
return;
@@ -373,19 +373,19 @@ static void board_report_pmic_fault(const char *str)
/* VRFAULT has occurred, print VRFAULT status bits. */
/* PWRSTAT1 */
- i2c_read8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x16, &pwrstat1);
+ i2c_read8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x16, &pwrstat1);
/* PWRSTAT2 */
- i2c_read8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x17, &pwrstat2);
+ i2c_read8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x17, &pwrstat2);
CPRINTS("PMIC VRFAULT: %s", str);
CPRINTS("PMIC VRFAULT: PWRSTAT1=0x%02x PWRSTAT2=0x%02x", pwrstat1,
pwrstat2);
/* Clear all faults -- Write 1 to clear. */
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x8, BIT(4));
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x16, pwrstat1);
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x17, pwrstat2);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x8, BIT(4));
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x16, pwrstat1);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x17, pwrstat2);
/*
* Status of the fault registers can be checked in the OS by looking at
@@ -403,32 +403,32 @@ static void board_pmic_init(void)
return;
/* DISCHGCNT2 - enable 100 ohm discharge on V3.3A and V1.8A */
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x3d, 0x05);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x3d, 0x05);
/* DISCHGCNT3 - enable 100 ohm discharge on V1.00A */
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x3e, 0x04);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x3e, 0x04);
/* Set CSDECAYEN / VCCIO decays to 0V at assertion of SLP_S0# */
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x30, 0x7a);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x30, 0x7a);
/*
* Set V100ACNT / V1.00A Control Register:
* Nominal output = 1.0V.
*/
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x37, 0x1a);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x37, 0x1a);
/*
* Set V085ACNT / V0.85A Control Register:
* Lower power mode = 0.7V.
* Nominal output = 1.0V.
*/
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x38, 0x7a);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x38, 0x7a);
/* VRMODECTRL - disable low-power mode for all rails */
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x3b, 0x1f);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x3b, 0x1f);
/* Clear power source events */
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x04, 0xff);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x04, 0xff);
}
DECLARE_HOOK(HOOK_INIT, board_pmic_init, HOOK_PRIO_DEFAULT);
@@ -722,7 +722,7 @@ void board_hibernate(void)
/* Shut down PMIC */
CPRINTS("Triggering PMIC shutdown");
uart_flush_output();
- if (i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x49, 0x01)) {
+ if (i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x49, 0x01)) {
/*
* If we can't tell the PMIC to shutdown, instead reset
* and don't start the AP. Hopefully we'll be able to
@@ -815,7 +815,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_lid_mutex,
.drv_data = &g_kxcj9_data,
.port = I2C_PORT_LID_ACCEL,
- .addr = KXCJ9_ADDR0,
+ .i2c_spi_addr__7bf = KXCJ9_ADDR0__7bf,
.rot_standard_ref = &lid_standard_ref,
.default_range = 2, /* g, enough for laptop. */
.min_frequency = KXCJ9_ACCEL_MIN_FREQ,
@@ -842,7 +842,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_base_mutex,
.drv_data = &g_bmi160_data,
.port = I2C_PORT_GYRO,
- .addr = BMI160_ADDR0,
+ .i2c_spi_addr__7bf = BMI160_ADDR0__7bf,
.rot_standard_ref = NULL,
.default_range = 2, /* g, enough for laptop. */
.min_frequency = BMI160_ACCEL_MIN_FREQ,
@@ -876,7 +876,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_base_mutex,
.drv_data = &g_bmi160_data,
.port = I2C_PORT_GYRO,
- .addr = BMI160_ADDR0,
+ .i2c_spi_addr__7bf = BMI160_ADDR0__7bf,
.default_range = 1000, /* dps */
.rot_standard_ref = NULL,
.min_frequency = BMI160_GYRO_MIN_FREQ,
@@ -893,7 +893,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_base_mutex,
.drv_data = &g_bmi160_data,
.port = I2C_PORT_GYRO,
- .addr = BMI160_ADDR0,
+ .i2c_spi_addr__7bf = BMI160_ADDR0__7bf,
.default_range = BIT(11), /* 16LSB / uT, fixed */
.rot_standard_ref = &mag_standard_ref,
.min_frequency = BMM150_MAG_MIN_FREQ,
@@ -910,7 +910,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_lid_mutex,
.drv_data = &g_si114x_data,
.port = I2C_PORT_ALS,
- .addr = SI114X_ADDR,
+ .i2c_spi_addr__7bf = SI114X_ADDR__7bf,
.rot_standard_ref = NULL,
.default_range = 3088, /* 30.88%: int = 0 - frac = 3088/10000 */
.min_frequency = SI114X_LIGHT_MIN_FREQ,
diff --git a/board/eve/board.h b/board/eve/board.h
index 84a4dc2cef..88938e9719 100644
--- a/board/eve/board.h
+++ b/board/eve/board.h
@@ -128,7 +128,7 @@
#define CONFIG_ACCEL_INTERRUPTS
#define CONFIG_ACCELGYRO_BMI160_INT_EVENT \
TASK_EVENT_MOTION_SENSOR_INTERRUPT(BASE_ACCEL)
-#define CONFIG_ACCELGYRO_SEC_ADDR BMM150_ADDR0 /* 8-bit address */
+#define CONFIG_ACCELGYRO_SEC_ADDR__7BF BMM150_ADDR0__7bf
#define CONFIG_ACCELGYRO_BMI160_INT2_OUTPUT /* Unused */
#define CONFIG_MAG_CALIBRATE
#define CONFIG_LID_ANGLE
@@ -195,8 +195,8 @@
#define I2C_PORT_MP2949 NPCX_I2C_PORT3
/* I2C addresses */
-#define I2C_ADDR_BD99992 0x60
-#define I2C_ADDR_MP2949 0x40
+#define I2C_ADDR_BD99992__7bf 0x30
+#define I2C_ADDR_MP2949__7bf 0x20
#ifndef __ASSEMBLER__
diff --git a/board/fizz/board.c b/board/fizz/board.c
index 70ee2a70c7..405d34cbb4 100644
--- a/board/fizz/board.c
+++ b/board/fizz/board.c
@@ -179,7 +179,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
.port = NPCX_I2C_PORT0_0,
- .addr = I2C_ADDR_TCPC0,
+ .addr__7bf = I2C_ADDR_TCPC0__7bf,
},
.drv = &ps8xxx_tcpm_drv,
},
@@ -229,7 +229,7 @@ void board_tcpc_init(void)
* TCPM_INIT will fail due to not able to access PS8751.
* Note PS8751 A3 will wake on any I2C access.
*/
- i2c_read8(I2C_PORT_TCPC0, I2C_ADDR_TCPC0, 0xA0, &reg);
+ i2c_read8__7bf(I2C_PORT_TCPC0, I2C_ADDR_TCPC0__7bf, 0xA0, &reg);
/* Enable TCPC interrupts */
gpio_enable_interrupt(GPIO_USB_C0_PD_INT_ODL);
@@ -289,10 +289,10 @@ BUILD_ASSERT(ARRAY_SIZE(thermal_params) == TEMP_SENSOR_COUNT);
/* Initialize PMIC */
#define I2C_PMIC_READ(reg, data) \
- i2c_read8(I2C_PORT_PMIC, TPS650X30_I2C_ADDR1, (reg), (data))
+ i2c_read8__7bf(I2C_PORT_PMIC, TPS650X30_I2C_ADDR1__7bf, (reg), (data))
#define I2C_PMIC_WRITE(reg, data) \
- i2c_write8(I2C_PORT_PMIC, TPS650X30_I2C_ADDR1, (reg), (data))
+ i2c_write8__7bf(I2C_PORT_PMIC, TPS650X30_I2C_ADDR1__7bf, (reg), (data))
static void board_pmic_init(void)
{
diff --git a/board/fizz/board.h b/board/fizz/board.h
index 92d2ae05f1..40aa840d59 100644
--- a/board/fizz/board.h
+++ b/board/fizz/board.h
@@ -139,8 +139,8 @@
#define I2C_PORT_THERMAL NPCX_I2C_PORT3
/* I2C addresses */
-#define I2C_ADDR_TCPC0 0x16
-#define I2C_ADDR_EEPROM 0xa0
+#define I2C_ADDR_TCPC0__7bf 0x0b
+#define I2C_ADDR_EEPROM__7bf 0x50
/* Verify and jump to RW image on boot */
#define CONFIG_VBOOT_EFS
diff --git a/board/flapjack/battery.c b/board/flapjack/battery.c
index 3c3825d5cf..5bb6b07a9f 100644
--- a/board/flapjack/battery.c
+++ b/board/flapjack/battery.c
@@ -398,10 +398,10 @@ int charger_profile_override(struct charge_state_data *curr)
* Pull down WPC VBUS. Need to use raw i2c APIs because RO
* doesn't have p9221 driver. If WPC is off, this is a no-op.
*/
- if (i2c_read_offset16(I2C_PORT_WPC, P9221_R7_ADDR,
+ if (i2c_read_offset16__7bf(I2C_PORT_WPC, P9221_R7_ADDR__7bf,
P9221R7_VOUT_SET_REG, &val, 1) == EC_SUCCESS
&& val * 100 != wpc_mv)
- i2c_write_offset16(I2C_PORT_WPC, P9221_R7_ADDR,
+ i2c_write_offset16__7bf(I2C_PORT_WPC, P9221_R7_ADDR__7bf,
P9221R7_VOUT_SET_REG, wpc_mv / 100, 1);
if ((curr->batt.flags & BATT_FLAG_BAD_TEMPERATURE) ||
diff --git a/board/flapjack/board.c b/board/flapjack/board.c
index 5549e7b97e..fcbf71938c 100644
--- a/board/flapjack/board.c
+++ b/board/flapjack/board.c
@@ -138,12 +138,12 @@ static void board_setup_panel(void)
dim = sku & SKU_ID_PANEL_SIZE_MASK ? 0xc4 : 0xc8;
}
- rv |= i2c_write8(I2C_PORT_CHARGER, RT946X_ADDR, MT6370_BACKLIGHT_BLEN,
- channel);
- rv |= i2c_write8(I2C_PORT_CHARGER, RT946X_ADDR, MT6370_BACKLIGHT_BLDIM,
- dim);
- rv |= i2c_write8(I2C_PORT_CHARGER, RT946X_ADDR, MT6370_BACKLIGHT_BLPWM,
- 0xac);
+ rv |= i2c_write8__7bf(I2C_PORT_CHARGER, RT946X_ADDR__7bf,
+ MT6370_BACKLIGHT_BLEN, channel);
+ rv |= i2c_write8__7bf(I2C_PORT_CHARGER, RT946X_ADDR__7bf,
+ MT6370_BACKLIGHT_BLDIM, dim);
+ rv |= i2c_write8__7bf(I2C_PORT_CHARGER, RT946X_ADDR__7bf,
+ MT6370_BACKLIGHT_BLPWM, 0xac);
if (rv)
CPRINTS("Board setup panel failed");
}
@@ -288,7 +288,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
.port = I2C_PORT_TCPC0,
- .addr = MT6370_TCPC_I2C_ADDR,
+ .addr__7bf = MT6370_TCPC_I2C_ADDR__7bf,
},
.drv = &mt6370_tcpm_drv},
};
@@ -500,7 +500,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_lid_mutex,
.drv_data = &g_bmi160_data,
.port = I2C_PORT_ACCEL,
- .addr = BMI160_ADDR0,
+ .i2c_spi_addr__7bf = BMI160_ADDR0__7bf,
.rot_standard_ref = &lid_standard_ref,
.default_range = 4, /* g */
.min_frequency = BMI160_ACCEL_MIN_FREQ,
@@ -523,7 +523,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_lid_mutex,
.drv_data = &g_bmi160_data,
.port = I2C_PORT_ACCEL,
- .addr = BMI160_ADDR0,
+ .i2c_spi_addr__7bf = BMI160_ADDR0__7bf,
.default_range = 1000, /* dps */
.rot_standard_ref = &lid_standard_ref,
.min_frequency = BMI160_GYRO_MIN_FREQ,
@@ -538,7 +538,7 @@ struct motion_sensor_t motion_sensors[] = {
.drv = &tcs3400_drv,
.drv_data = &g_tcs3400_data,
.port = I2C_PORT_ALS,
- .addr = TCS3400_I2C_ADDR,
+ .i2c_spi_addr__7bf = TCS3400_I2C_ADDR__7bf,
.rot_standard_ref = NULL,
.default_range = 0x10000, /* scale = 1x, uscale = 0 */
.min_frequency = TCS3400_LIGHT_MIN_FREQ,
diff --git a/board/flapjack/board.h b/board/flapjack/board.h
index 693a1bb8a9..13a010f416 100644
--- a/board/flapjack/board.h
+++ b/board/flapjack/board.h
@@ -225,10 +225,10 @@
#define I2C_PORT_EEPROM 1
/* I2C addresses */
-#define I2C_ADDR_EEPROM 0xA0
+#define I2C_ADDR_EEPROM__7bf 0x50
/* Route sbs host requests to virtual battery driver */
-#define VIRTUAL_BATTERY_ADDR 0x16
+#define VIRTUAL_BATTERY_ADDR__7bf 0x0B
/* Enable Accel over SPI */
#define CONFIG_SPI_ACCEL_PORT 0 /* The first SPI master port (SPI2) */
diff --git a/board/fleex/board.c b/board/fleex/board.c
index 386d8ad61b..444d585308 100644
--- a/board/fleex/board.c
+++ b/board/fleex/board.c
@@ -133,7 +133,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_lid_mutex,
.drv_data = &g_lis2dh_data,
.port = I2C_PORT_SENSOR,
- .addr = LIS2DH_ADDR1,
+ .i2c_spi_addr__7bf = LIS2DH_ADDR1__7bf,
.rot_standard_ref = &lid_standard_ref,
.default_range = 2, /* g */
/* We only use 2g because its resolution is only 8-bits */
@@ -164,7 +164,7 @@ struct motion_sensor_t motion_sensors[] = {
.int_signal = GPIO_BASE_SIXAXIS_INT_L,
.flags = MOTIONSENSE_FLAG_INT_SIGNAL,
.port = I2C_PORT_SENSOR,
- .addr = LSM6DSM_ADDR0,
+ .i2c_spi_addr__7bf = LSM6DSM_ADDR0__7bf,
.rot_standard_ref = &base_standard_ref,
.default_range = 4, /* g */
.min_frequency = LSM6DSM_ODR_MIN_VAL,
@@ -196,7 +196,7 @@ struct motion_sensor_t motion_sensors[] = {
.int_signal = GPIO_BASE_SIXAXIS_INT_L,
.flags = MOTIONSENSE_FLAG_INT_SIGNAL,
.port = I2C_PORT_SENSOR,
- .addr = LSM6DSM_ADDR0,
+ .i2c_spi_addr__7bf = LSM6DSM_ADDR0__7bf,
.default_range = 1000 | ROUND_UP_FLAG, /* dps */
.rot_standard_ref = &base_standard_ref,
.min_frequency = LSM6DSM_ODR_MIN_VAL,
diff --git a/board/fluffy/board.c b/board/fluffy/board.c
index a409bc4a89..4631b4a851 100644
--- a/board/fluffy/board.c
+++ b/board/fluffy/board.c
@@ -113,7 +113,7 @@ DECLARE_CONSOLE_COMMAND(ccflip, command_cc_flip,
/*
* Support tca6416 I2C ioexpander.
*/
-#define GPIOX_I2C_ADDR 0x40
+#define GPIOX_I2C_ADDR__7bf 0x20
#define GPIOX_IN_PORT_A 0x0
#define GPIOX_IN_PORT_B 0x1
#define GPIOX_OUT_PORT_A 0x2
@@ -129,8 +129,10 @@ static void i2c_expander_init(void)
/*
* Setup P00, P02, P04, P10, and P12 on the I/O expander as an output.
*/
- i2c_write8(I2C_PORT_MASTER, GPIOX_I2C_ADDR, GPIOX_DIR_PORT_A, 0xea);
- i2c_write8(I2C_PORT_MASTER, GPIOX_I2C_ADDR, GPIOX_DIR_PORT_B, 0xfa);
+ i2c_write8__7bf(I2C_PORT_MASTER, GPIOX_I2C_ADDR__7bf,
+ GPIOX_DIR_PORT_A, 0xea);
+ i2c_write8__7bf(I2C_PORT_MASTER, GPIOX_I2C_ADDR__7bf,
+ GPIOX_DIR_PORT_B, 0xfa);
}
DECLARE_HOOK(HOOK_INIT, i2c_expander_init, HOOK_PRIO_INIT_I2C+1);
@@ -140,15 +142,15 @@ static void write_ioexpander(int bank, int gpio, int reg, int val)
int tmp;
/* Read output port register */
- i2c_read8(I2C_PORT_MASTER, GPIOX_I2C_ADDR, reg + bank,
- &tmp);
+ i2c_read8__7bf(I2C_PORT_MASTER, GPIOX_I2C_ADDR__7bf,
+ reg + bank, &tmp);
if (val)
tmp |= BIT(gpio);
else
tmp &= ~BIT(gpio);
/* Write back modified output port register */
- i2c_write8(I2C_PORT_MASTER, GPIOX_I2C_ADDR, reg + bank,
- tmp);
+ i2c_write8__7bf(I2C_PORT_MASTER, GPIOX_I2C_ADDR__7bf,
+ reg + bank, tmp);
}
enum led_ch {
diff --git a/board/garg/board.c b/board/garg/board.c
index 5947e23f8e..b0ec0ef955 100644
--- a/board/garg/board.c
+++ b/board/garg/board.c
@@ -154,7 +154,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_lid_mutex,
.drv_data = &g_kx022_data,
.port = I2C_PORT_SENSOR,
- .addr = KX022_ADDR1,
+ .i2c_spi_addr__7bf = KX022_ADDR1__7bf,
.rot_standard_ref = NULL, /* Identity matrix. */
.default_range = 4, /* g */
.config = {
@@ -178,7 +178,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_base_mutex,
.drv_data = &g_bmi160_data,
.port = I2C_PORT_SENSOR,
- .addr = BMI160_ADDR0,
+ .i2c_spi_addr__7bf = BMI160_ADDR0__7bf,
.rot_standard_ref = &base_standard_ref,
.default_range = 4, /* g */
.min_frequency = BMI160_ACCEL_MIN_FREQ,
@@ -206,7 +206,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_base_mutex,
.drv_data = &g_bmi160_data,
.port = I2C_PORT_SENSOR,
- .addr = BMI160_ADDR0,
+ .i2c_spi_addr__7bf = BMI160_ADDR0__7bf,
.default_range = 1000, /* dps */
.rot_standard_ref = &base_standard_ref,
.min_frequency = BMI160_GYRO_MIN_FREQ,
diff --git a/board/glados/battery.c b/board/glados/battery.c
index 016d225950..d6c702127e 100644
--- a/board/glados/battery.c
+++ b/board/glados/battery.c
@@ -47,10 +47,10 @@ int board_cut_off_battery(void)
buf[2] = PARAM_CUT_OFF_HIGH;
i2c_lock(I2C_PORT_BATTERY, 1);
- rv = i2c_xfer_unlocked(I2C_PORT_BATTERY, BATTERY_ADDR, buf, 3, NULL, 0,
- I2C_XFER_SINGLE);
- rv |= i2c_xfer_unlocked(I2C_PORT_BATTERY, BATTERY_ADDR, buf, 3, NULL, 0,
- I2C_XFER_SINGLE);
+ rv = i2c_xfer_unlocked__7bf(I2C_PORT_BATTERY, BATTERY_ADDR__7bf,
+ buf, 3, NULL, 0, I2C_XFER_SINGLE);
+ rv |= i2c_xfer_unlocked__7bf(I2C_PORT_BATTERY, BATTERY_ADDR__7bf,
+ buf, 3, NULL, 0, I2C_XFER_SINGLE);
i2c_lock(I2C_PORT_BATTERY, 0);
return rv;
diff --git a/board/glados/board.c b/board/glados/board.c
index 1521800439..c3a05289ad 100644
--- a/board/glados/board.c
+++ b/board/glados/board.c
@@ -48,7 +48,7 @@
#define CPRINTS(format, args...) cprints(CC_USBCHARGE, format, ## args)
#define CPRINTF(format, args...) cprintf(CC_USBCHARGE, format, ## args)
-#define I2C_ADDR_BD99992 0x60
+#define I2C_ADDR_BD99992__7bf 0x30
/* Exchange status with PD MCU. */
static void pd_mcu_interrupt(enum gpio_signal signal)
@@ -123,7 +123,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
.port = I2C_PORT_TCPC,
- .addr = CONFIG_TCPC_I2C_BASE_ADDR,
+ .addr__7bf = CONFIG_TCPC_I2C_BASE_ADDR__7BF,
},
.drv = &tcpci_tcpm_drv,
},
@@ -131,7 +131,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
.port = I2C_PORT_TCPC,
- .addr = CONFIG_TCPC_I2C_BASE_ADDR + 2,
+ .addr__7bf = CONFIG_TCPC_I2C_BASE_ADDR__7BF + 1,
},
.drv = &tcpci_tcpm_drv,
},
@@ -166,11 +166,11 @@ BUILD_ASSERT(ARRAY_SIZE(pi3usb9281_chips) ==
struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_COUNT] = {
{
- .port_addr = 0xa8,
+ .port_addr = 0x54,
.driver = &pi3usb30532_usb_mux_driver,
},
{
- .port_addr = 0x20,
+ .port_addr = 0x10,
.driver = &ps874x_usb_mux_driver,
}
};
@@ -213,23 +213,23 @@ static void board_pmic_init(void)
return;
/* Set CSDECAYEN / VCCIO decays to 0V at assertion of SLP_S0# */
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x30, 0x4a);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x30, 0x4a);
/*
* Set V100ACNT / V1.00A Control Register:
* Nominal output = 1.0V.
*/
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x37, 0x1a);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x37, 0x1a);
/*
* Set V085ACNT / V0.85A Control Register:
* Lower power mode = 0.7V.
* Nominal output = 1.0V.
*/
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x38, 0x7a);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x38, 0x7a);
/* VRMODECTRL - enable low-power mode for VCCIO and V0.85A */
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x3b, 0x18);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x3b, 0x18);
}
DECLARE_HOOK(HOOK_INIT, board_pmic_init, HOOK_PRIO_DEFAULT);
diff --git a/board/glados/board.h b/board/glados/board.h
index 2fa9662b0b..93c5bbd500 100644
--- a/board/glados/board.h
+++ b/board/glados/board.h
@@ -134,7 +134,7 @@
#define I2C_PORT_THERMAL I2C_PORT_PMIC
/* Ambient Light Sensor address */
-#define OPT3001_I2C_ADDR OPT3001_I2C_ADDR1
+#define OPT3001_I2C_ADDR__7bf OPT3001_I2C_ADDR1__7bf
/* Modules we want to exclude */
#undef CONFIG_CMD_HASH
diff --git a/board/glados_pd/board.h b/board/glados_pd/board.h
index 9310ee8715..0d513b6e67 100644
--- a/board/glados_pd/board.h
+++ b/board/glados_pd/board.h
@@ -97,7 +97,7 @@
/* slave address for host commands */
#ifdef HAS_TASK_HOSTCMD
-#define CONFIG_HOSTCMD_I2C_SLAVE_ADDR CONFIG_USB_PD_I2C_SLAVE_ADDR
+#define CONFIG_HOSTCMD_I2C_SLAVE_ADDR__7BF CONFIG_USB_PD_I2C_SLAVE_ADDR__7BF
#endif
#ifndef __ASSEMBLER__
diff --git a/board/glkrvp/battery.c b/board/glkrvp/battery.c
index bb49336ecf..36dec46702 100644
--- a/board/glkrvp/battery.c
+++ b/board/glkrvp/battery.c
@@ -14,10 +14,10 @@
#define CPRINTS(format, args...) cprints(CC_CHARGER, format, ## args)
#define I2C_PORT_PCA555_BATT_PRESENT_GPIO NPCX_I2C_PORT0_0
-#define I2C_ADDR_PCA555_BATT_PRESENT_GPIO 0x42
+#define I2C_ADDR_PCA555_BATT_PRESENT_GPIO__7bf 0x21
#define PCA555_BATT_PRESENT_GPIO_READ(reg, data) \
- pca9555_read(I2C_PORT_PCA555_BATT_PRESENT_GPIO, \
- I2C_ADDR_PCA555_BATT_PRESENT_GPIO, (reg), (data))
+ pca9555_read__7bf(I2C_PORT_PCA555_BATT_PRESENT_GPIO, \
+ I2C_ADDR_PCA555_BATT_PRESENT_GPIO__7bf, (reg), (data))
/* Shutdown mode parameter to write to manufacturer access register */
#define SB_SHUTDOWN_DATA 0x0010
diff --git a/board/glkrvp/board.c b/board/glkrvp/board.c
index c7445d19a3..e748373ad0 100644
--- a/board/glkrvp/board.c
+++ b/board/glkrvp/board.c
@@ -29,19 +29,19 @@
#include "gpio_list.h"
#define I2C_PORT_PCA555_PMIC_GPIO NPCX_I2C_PORT0_0
-#define I2C_ADDR_PCA555_PMIC_GPIO 0x42
+#define I2C_ADDR_PCA555_PMIC_GPIO__7bf 0x21
#define PCA555_PMIC_GPIO_WRITE(reg, data) \
- pca9555_write(I2C_PORT_PCA555_PMIC_GPIO, \
- I2C_ADDR_PCA555_PMIC_GPIO, (reg), (data))
+ pca9555_write__7bf(I2C_PORT_PCA555_PMIC_GPIO, \
+ I2C_ADDR_PCA555_PMIC_GPIO__7bf, (reg), (data))
#define PCA555_PMIC_GPIO_READ(reg, data) \
- pca9555_read(I2C_PORT_PCA555_PMIC_GPIO, \
- I2C_ADDR_PCA555_PMIC_GPIO, (reg), (data))
+ pca9555_read__7bf(I2C_PORT_PCA555_PMIC_GPIO, \
+ I2C_ADDR_PCA555_PMIC_GPIO__7bf, (reg), (data))
#define I2C_PORT_PCA555_BOARD_ID_GPIO NPCX_I2C_PORT0_0
-#define I2C_ADDR_PCA555_BOARD_ID_GPIO 0x40
+#define I2C_ADDR_PCA555_BOARD_ID_GPIO__7bf 0x20
#define PCA555_BOARD_ID_GPIO_READ(reg, data) \
- pca9555_read(I2C_PORT_PCA555_BOARD_ID_GPIO, \
- I2C_ADDR_PCA555_BOARD_ID_GPIO, (reg), (data))
+ pca9555_read__7bf(I2C_PORT_PCA555_BOARD_ID_GPIO, \
+ I2C_ADDR_PCA555_BOARD_ID_GPIO__7bf, (reg), (data))
/* I2C ports */
const struct i2c_port_t i2c_ports[] = {
diff --git a/board/glkrvp/chg_usb_pd.c b/board/glkrvp/chg_usb_pd.c
index bba185202f..fd4b1fd0e2 100644
--- a/board/glkrvp/chg_usb_pd.c
+++ b/board/glkrvp/chg_usb_pd.c
@@ -35,7 +35,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
.port = NPCX_I2C_PORT7_0,
- .addr = 0xa0,
+ .addr__7bf = 0x50,
},
.drv = &tcpci_tcpm_drv,
},
@@ -43,7 +43,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
.port = NPCX_I2C_PORT7_0,
- .addr = 0xa4,
+ .addr__7bf = 0x52,
},
.drv = &tcpci_tcpm_drv,
},
@@ -52,11 +52,11 @@ BUILD_ASSERT(ARRAY_SIZE(tcpc_config) == CONFIG_USB_PD_PORT_COUNT);
struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_COUNT] = {
{
- .port_addr = 0x20,
+ .port_addr = 0x10,
.driver = &ps874x_usb_mux_driver,
},
{
- .port_addr = 0x22,
+ .port_addr = 0x11,
.driver = &ps874x_usb_mux_driver,
},
};
diff --git a/board/glkrvp_ite/battery.c b/board/glkrvp_ite/battery.c
index d9d4bf9bf3..5665b1f557 100644
--- a/board/glkrvp_ite/battery.c
+++ b/board/glkrvp_ite/battery.c
@@ -199,8 +199,8 @@ enum battery_present battery_hw_present(void)
int data;
int rv;
- rv = pca9555_read(I2C_PORT_PCA555_PMIC_BATT_GPIO,
- I2C_ADDR_PCA555_PMIC_BATT_GPIO,
+ rv = pca9555_read__7bf(I2C_PORT_PCA555_PMIC_BATT_GPIO,
+ I2C_ADDR_PCA555_PMIC_BATT_GPIO__7bf,
PCA9555_CMD_INPUT_PORT_0, &data);
/* GPIO is low when the battery is physically present */
diff --git a/board/glkrvp_ite/board.c b/board/glkrvp_ite/board.c
index 4127a29634..9721549b14 100644
--- a/board/glkrvp_ite/board.c
+++ b/board/glkrvp_ite/board.c
@@ -31,7 +31,7 @@
#include "gpio_list.h"
#define I2C_PORT_PCA555_BOARD_ID_GPIO IT83XX_I2C_CH_C
-#define I2C_ADDR_PCA555_BOARD_ID_GPIO 0x40
+#define I2C_ADDR_PCA555_BOARD_ID_GPIO__7bf 0x20
/* I2C ports */
const struct i2c_port_t i2c_ports[] = {
@@ -55,8 +55,8 @@ void chipset_pre_init_callback(void)
{
int data;
- if (pca9555_read(I2C_PORT_PCA555_PMIC_BATT_GPIO,
- I2C_ADDR_PCA555_PMIC_BATT_GPIO,
+ if (pca9555_read__7bf(I2C_PORT_PCA555_PMIC_BATT_GPIO,
+ I2C_ADDR_PCA555_PMIC_BATT_GPIO__7bf,
PCA9555_CMD_OUTPUT_PORT_0, &data))
return;
@@ -70,16 +70,17 @@ void chipset_pre_init_callback(void)
/* Enable SOC_3P3_EN_L: Set the Output port O0.1 to low level */
data &= ~PCA9555_IO_1;
- pca9555_write(I2C_PORT_PCA555_PMIC_BATT_GPIO,
- I2C_ADDR_PCA555_PMIC_BATT_GPIO,
+ pca9555_write__7bf(I2C_PORT_PCA555_PMIC_BATT_GPIO,
+ I2C_ADDR_PCA555_PMIC_BATT_GPIO__7bf,
PCA9555_CMD_OUTPUT_PORT_0, data);
/* TODO: Find out from the spec */
msleep(10);
/* Enable PMIC_EN: Set the Output port O0.0 to high level */
- pca9555_write(I2C_PORT_PCA555_PMIC_BATT_GPIO,
- I2C_ADDR_PCA555_PMIC_BATT_GPIO, PCA9555_CMD_OUTPUT_PORT_0,
+ pca9555_write__7bf(I2C_PORT_PCA555_PMIC_BATT_GPIO,
+ I2C_ADDR_PCA555_PMIC_BATT_GPIO__7bf,
+ PCA9555_CMD_OUTPUT_PORT_0,
data | PCA9555_IO_0);
}
@@ -105,23 +106,24 @@ void chipset_do_shutdown(void)
{
int data;
- if (pca9555_read(I2C_PORT_PCA555_PMIC_BATT_GPIO,
- I2C_ADDR_PCA555_PMIC_BATT_GPIO,
+ if (pca9555_read__7bf(I2C_PORT_PCA555_PMIC_BATT_GPIO,
+ I2C_ADDR_PCA555_PMIC_BATT_GPIO__7bf,
PCA9555_CMD_OUTPUT_PORT_0, &data))
return;
/* Disable SOC_3P3_EN_L: Set the Output port O0.1 to high level */
data |= PCA9555_IO_1;
- pca9555_write(I2C_PORT_PCA555_PMIC_BATT_GPIO,
- I2C_ADDR_PCA555_PMIC_BATT_GPIO,
+ pca9555_write__7bf(I2C_PORT_PCA555_PMIC_BATT_GPIO,
+ I2C_ADDR_PCA555_PMIC_BATT_GPIO__7bf,
PCA9555_CMD_OUTPUT_PORT_0, data);
/* TODO: Find out from the spec */
msleep(10);
/* Disable PMIC_EN: Set the Output port O0.0 to low level */
- pca9555_write(I2C_PORT_PCA555_PMIC_BATT_GPIO,
- I2C_ADDR_PCA555_PMIC_BATT_GPIO, PCA9555_CMD_OUTPUT_PORT_0,
+ pca9555_write__7bf(I2C_PORT_PCA555_PMIC_BATT_GPIO,
+ I2C_ADDR_PCA555_PMIC_BATT_GPIO__7bf,
+ PCA9555_CMD_OUTPUT_PORT_0,
data & ~PCA9555_IO_0);
}
@@ -145,8 +147,9 @@ int board_get_version(void)
{
int data;
- if (pca9555_read(I2C_PORT_PCA555_BOARD_ID_GPIO,
- I2C_ADDR_PCA555_BOARD_ID_GPIO, PCA9555_CMD_INPUT_PORT_1, &data))
+ if (pca9555_read__7bf(I2C_PORT_PCA555_BOARD_ID_GPIO,
+ I2C_ADDR_PCA555_BOARD_ID_GPIO__7bf,
+ PCA9555_CMD_INPUT_PORT_1, &data))
return -1;
return data & 0x0f;
@@ -163,8 +166,8 @@ static void pmic_init(void)
* Configure Port O0.0 as Output port - PMIC_EN
* Configure Port O0.1 as Output port - SOC_3P3_EN_L
*/
- pca9555_write(I2C_PORT_PCA555_PMIC_BATT_GPIO,
- I2C_ADDR_PCA555_PMIC_BATT_GPIO,
+ pca9555_write__7bf(I2C_PORT_PCA555_PMIC_BATT_GPIO,
+ I2C_ADDR_PCA555_PMIC_BATT_GPIO__7bf,
PCA9555_CMD_CONFIGURATION_PORT_0, 0xfc);
/*
@@ -174,8 +177,8 @@ static void pmic_init(void)
* POR of PCA9555 port is input with high impedance hence explicitly
* configure the SOC_3P3_EN_L to high level.
*/
- pca9555_write(I2C_PORT_PCA555_PMIC_BATT_GPIO,
- I2C_ADDR_PCA555_PMIC_BATT_GPIO,
+ pca9555_write__7bf(I2C_PORT_PCA555_PMIC_BATT_GPIO,
+ I2C_ADDR_PCA555_PMIC_BATT_GPIO__7bf,
PCA9555_CMD_OUTPUT_PORT_0, 0xfe);
}
DECLARE_HOOK(HOOK_INIT, pmic_init, HOOK_PRIO_INIT_I2C + 1);
diff --git a/board/glkrvp_ite/board.h b/board/glkrvp_ite/board.h
index d1d3b7be7d..7c7834353c 100644
--- a/board/glkrvp_ite/board.h
+++ b/board/glkrvp_ite/board.h
@@ -115,7 +115,7 @@
#define I2C_PORT_USB_MUX IT83XX_I2C_CH_B
#define I2C_PORT_PCA555_PMIC_BATT_GPIO IT83XX_I2C_CH_C
-#define I2C_ADDR_PCA555_PMIC_BATT_GPIO 0x42
+#define I2C_ADDR_PCA555_PMIC_BATT_GPIO__7bf 0x21
/* EC exclude modules */
#undef CONFIG_ADC
diff --git a/board/glkrvp_ite/chg_usb_pd.c b/board/glkrvp_ite/chg_usb_pd.c
index 01c8f43f1e..7f3d049b29 100644
--- a/board/glkrvp_ite/chg_usb_pd.c
+++ b/board/glkrvp_ite/chg_usb_pd.c
@@ -35,7 +35,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
.port = IT83XX_I2C_CH_B,
- .addr = 0xa0,
+ .addr__7bf = 0x50,
},
.drv = &tcpci_tcpm_drv,
},
@@ -43,7 +43,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
.port = IT83XX_I2C_CH_B,
- .addr = 0xa4,
+ .addr__7bf = 0x52,
},
.drv = &tcpci_tcpm_drv,
},
@@ -52,11 +52,11 @@ BUILD_ASSERT(ARRAY_SIZE(tcpc_config) == CONFIG_USB_PD_PORT_COUNT);
struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_COUNT] = {
{
- .port_addr = 0x20,
+ .port_addr = 0x10,
.driver = &ps874x_usb_mux_driver,
},
{
- .port_addr = 0x22,
+ .port_addr = 0x11,
.driver = &ps874x_usb_mux_driver,
},
};
diff --git a/board/hammer/board.h b/board/hammer/board.h
index 7811ab7973..0e43ac877c 100644
--- a/board/hammer/board.h
+++ b/board/hammer/board.h
@@ -275,7 +275,7 @@
#define CONFIG_TOUCHPAD
#define CONFIG_TOUCHPAD_ELAN
#define CONFIG_TOUCHPAD_I2C_PORT I2C_PORT_MASTER
-#define CONFIG_TOUCHPAD_I2C_ADDR (0x15 << 1)
+#define CONFIG_TOUCHPAD_I2C_ADDR__7BF 0x15
#endif /* BOARD_WHISKERS */
#define CONFIG_CURVE25519
diff --git a/board/hatch/board.c b/board/hatch/board.c
index da1349208a..364c9e3d31 100644
--- a/board/hatch/board.c
+++ b/board/hatch/board.c
@@ -130,7 +130,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
.port = I2C_PORT_TCPC0,
- .addr = AN7447_TCPC0_I2C_ADDR,
+ .addr__7bf = AN7447_TCPC0_I2C_ADDR__7bf,
},
.drv = &anx7447_tcpm_drv,
.flags = TCPC_FLAGS_RESET_ACTIVE_HIGH,
@@ -139,7 +139,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
.port = I2C_PORT_TCPC1,
- .addr = PS8751_I2C_ADDR1,
+ .addr__7bf = PS8751_I2C_ADDR1__7bf,
},
.drv = &ps8xxx_tcpm_drv,
},
@@ -159,12 +159,12 @@ struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_COUNT] = {
const struct pi3usb2901_config_t pi3usb2901_bc12_chips[] = {
[USB_PD_PORT_TCPC_0] = {
.i2c_port = I2C_PORT_PPC0,
- .i2c_addr = PI3USB9201_I2C_ADDR_3,
+ .i2c_addr__7bf = PI3USB9201_I2C_ADDR_3__7bf,
},
[USB_PD_PORT_TCPC_1] = {
.i2c_port = I2C_PORT_TCPC1,
- .i2c_addr = PI3USB9201_I2C_ADDR_3,
+ .i2c_addr__7bf = PI3USB9201_I2C_ADDR_3__7bf,
},
};
@@ -233,7 +233,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_lid_mutex,
.drv_data = &g_bma255_data,
.port = I2C_PORT_ACCEL,
- .addr = BMA2x2_I2C_ADDR1,
+ .i2c_spi_addr__7bf = BMA2x2_I2C_ADDR1__7bf,
.rot_standard_ref = &lid_standard_ref,
.min_frequency = BMA255_ACCEL_MIN_FREQ,
.max_frequency = BMA255_ACCEL_MAX_FREQ,
@@ -260,7 +260,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_base_mutex,
.drv_data = &g_bmi160_data,
.port = I2C_PORT_ACCEL,
- .addr = BMI160_ADDR0,
+ .i2c_spi_addr__7bf = BMI160_ADDR0__7bf,
.rot_standard_ref = &base_standard_ref,
.min_frequency = BMI160_ACCEL_MIN_FREQ,
.max_frequency = BMI160_ACCEL_MAX_FREQ,
@@ -286,7 +286,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_base_mutex,
.drv_data = &g_bmi160_data,
.port = I2C_PORT_ACCEL,
- .addr = BMI160_ADDR0,
+ .i2c_spi_addr__7bf = BMI160_ADDR0__7bf,
.default_range = 1000, /* dps */
.rot_standard_ref = &base_standard_ref,
.min_frequency = BMI160_GYRO_MIN_FREQ,
@@ -302,7 +302,7 @@ struct motion_sensor_t motion_sensors[] = {
.drv = &tcs3400_drv,
.drv_data = &g_tcs3400_data,
.port = I2C_PORT_ALS,
- .addr = TCS3400_I2C_ADDR,
+ .i2c_spi_addr__7bf = TCS3400_I2C_ADDR__7bf,
.rot_standard_ref = NULL,
.default_range = 0x10000, /* scale = 1x, uscale = 0 */
.min_frequency = TCS3400_LIGHT_MIN_FREQ,
diff --git a/board/helios/board.c b/board/helios/board.c
index e40833f2a9..6a47979565 100644
--- a/board/helios/board.c
+++ b/board/helios/board.c
@@ -119,7 +119,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
.port = I2C_PORT_TCPC0,
- .addr = PS8751_I2C_ADDR1,
+ .addr__7bf = PS8751_I2C_ADDR1__7bf,
},
.drv = &ps8xxx_tcpm_drv,
},
@@ -127,7 +127,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
.port = I2C_PORT_TCPC1,
- .addr = PS8751_I2C_ADDR1,
+ .addr__7bf = PS8751_I2C_ADDR1__7bf,
},
.drv = &ps8xxx_tcpm_drv,
},
@@ -147,12 +147,12 @@ struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_COUNT] = {
const struct pi3usb2901_config_t pi3usb2901_bc12_chips[] = {
[USB_PD_PORT_TCPC_0] = {
.i2c_port = I2C_PORT_PPC0,
- .i2c_addr = PI3USB9201_I2C_ADDR_3,
+ .i2c_addr__7bf = PI3USB9201_I2C_ADDR_3__7bf,
},
[USB_PD_PORT_TCPC_1] = {
.i2c_port = I2C_PORT_TCPC1,
- .i2c_addr = PI3USB9201_I2C_ADDR_3,
+ .i2c_addr__7bf = PI3USB9201_I2C_ADDR_3__7bf,
},
};
@@ -198,7 +198,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_lid_mutex,
.drv_data = &g_bma255_data,
.port = I2C_PORT_ACCEL,
- .addr = BMA2x2_I2C_ADDR1,
+ .i2c_spi_addr__7bf = BMA2x2_I2C_ADDR1__7bf,
.rot_standard_ref = &lid_standard_ref,
.min_frequency = BMA255_ACCEL_MIN_FREQ,
.max_frequency = BMA255_ACCEL_MAX_FREQ,
@@ -225,7 +225,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_base_mutex,
.drv_data = &g_bmi160_data,
.port = I2C_PORT_ACCEL,
- .addr = BMI160_ADDR0,
+ .i2c_spi_addr__7bf = BMI160_ADDR0__7bf,
.rot_standard_ref = &base_standard_ref,
.min_frequency = BMI160_ACCEL_MIN_FREQ,
.max_frequency = BMI160_ACCEL_MAX_FREQ,
@@ -251,7 +251,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_base_mutex,
.drv_data = &g_bmi160_data,
.port = I2C_PORT_ACCEL,
- .addr = BMI160_ADDR0,
+ .i2c_spi_addr__7bf = BMI160_ADDR0__7bf,
.default_range = 1000, /* dps */
.rot_standard_ref = &base_standard_ref,
.min_frequency = BMI160_GYRO_MIN_FREQ,
@@ -267,7 +267,7 @@ struct motion_sensor_t motion_sensors[] = {
.drv = &opt3001_drv,
.drv_data = &g_opt3001_data,
.port = I2C_PORT_ACCEL,
- .addr = OPT3001_I2C_ADDR,
+ .i2c_spi_addr__7bf = OPT3001_I2C_ADDR__7bf,
.rot_standard_ref = NULL,
.default_range = 0x2b11a1,
.min_frequency = OPT3001_LIGHT_MIN_FREQ,
diff --git a/board/helios/board.h b/board/helios/board.h
index ac4e0432dd..b85299e19d 100644
--- a/board/helios/board.h
+++ b/board/helios/board.h
@@ -48,7 +48,7 @@
#define CONFIG_ALS
#define ALS_COUNT 1
#define CONFIG_ALS_OPT3001
-#define OPT3001_I2C_ADDR OPT3001_I2C_ADDR1
+#define OPT3001_I2C_ADDR__7bf OPT3001_I2C_ADDR1__7bf
/* USB Type C and USB PD defines */
#define CONFIG_USB_PD_TCPM_PS8751
diff --git a/board/host/battery.c b/board/host/battery.c
index d1d2cdc3e0..6ec74c61b4 100644
--- a/board/host/battery.c
+++ b/board/host/battery.c
@@ -14,13 +14,14 @@
static uint16_t mock_smart_battery[SB_MANUFACTURER_DATA + 1];
-int sb_i2c_xfer(int port, int slave_addr, const uint8_t *out, int out_size,
+int sb_i2c_xfer__7bf(int port, uint16_t slave_addr__7bf,
+ const uint8_t *out, int out_size,
uint8_t *in, int in_size, int flags)
{
if (out_size == 0)
return EC_SUCCESS;
- if (port != I2C_PORT_BATTERY || slave_addr != BATTERY_ADDR)
+ if (port != I2C_PORT_BATTERY || slave_addr__7bf != BATTERY_ADDR__7bf)
return EC_ERROR_INVAL;
if (out[0] >= ARRAY_SIZE(mock_smart_battery))
return EC_ERROR_UNIMPLEMENTED;
@@ -41,7 +42,7 @@ int sb_i2c_xfer(int port, int slave_addr, const uint8_t *out, int out_size,
}
return EC_SUCCESS;
}
-DECLARE_TEST_I2C_XFER(sb_i2c_xfer);
+DECLARE_TEST_I2C_XFER(sb_i2c_xfer__7bf);
int battery_time_at_rate(int rate, int *minutes)
{
diff --git a/board/kindred/board.c b/board/kindred/board.c
index 3bbfe47529..66862f706a 100644
--- a/board/kindred/board.c
+++ b/board/kindred/board.c
@@ -130,7 +130,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
.port = I2C_PORT_TCPC0,
- .addr = AN7447_TCPC0_I2C_ADDR,
+ .addr__7bf = AN7447_TCPC0_I2C_ADDR__7bf,
},
.drv = &anx7447_tcpm_drv,
.flags = TCPC_FLAGS_RESET_ACTIVE_HIGH,
@@ -139,7 +139,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
.port = I2C_PORT_TCPC1,
- .addr = PS8751_I2C_ADDR1,
+ .addr__7bf = PS8751_I2C_ADDR1__7bf,
},
.drv = &ps8xxx_tcpm_drv,
.flags = 0,
@@ -160,12 +160,12 @@ struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_COUNT] = {
const struct pi3usb2901_config_t pi3usb2901_bc12_chips[] = {
[USB_PD_PORT_TCPC_0] = {
.i2c_port = I2C_PORT_PPC0,
- .i2c_addr = PI3USB9201_I2C_ADDR_3,
+ .i2c_addr__7bf = PI3USB9201_I2C_ADDR_3__7bf,
},
[USB_PD_PORT_TCPC_1] = {
.i2c_port = I2C_PORT_TCPC1,
- .i2c_addr = PI3USB9201_I2C_ADDR_3,
+ .i2c_addr__7bf = PI3USB9201_I2C_ADDR_3__7bf,
},
};
@@ -216,7 +216,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_lid_mutex,
.drv_data = &g_bma255_data,
.port = I2C_PORT_ACCEL,
- .addr = BMA2x2_I2C_ADDR1,
+ .i2c_spi_addr__7bf = BMA2x2_I2C_ADDR1__7bf,
.rot_standard_ref = &lid_standard_ref,
.min_frequency = BMA255_ACCEL_MIN_FREQ,
.max_frequency = BMA255_ACCEL_MAX_FREQ,
@@ -243,7 +243,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_base_mutex,
.drv_data = &g_bmi160_data,
.port = I2C_PORT_ACCEL,
- .addr = BMI160_ADDR0,
+ .i2c_spi_addr__7bf = BMI160_ADDR0__7bf,
.rot_standard_ref = &base_standard_ref,
.min_frequency = BMI160_ACCEL_MIN_FREQ,
.max_frequency = BMI160_ACCEL_MAX_FREQ,
@@ -269,7 +269,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_base_mutex,
.drv_data = &g_bmi160_data,
.port = I2C_PORT_ACCEL,
- .addr = BMI160_ADDR0,
+ .i2c_spi_addr__7bf = BMI160_ADDR0__7bf,
.default_range = 1000, /* dps */
.rot_standard_ref = &base_standard_ref,
.min_frequency = BMI160_GYRO_MIN_FREQ,
@@ -285,7 +285,7 @@ struct motion_sensor_t motion_sensors[] = {
.drv = &opt3001_drv,
.drv_data = &g_opt3001_data,
.port = I2C_PORT_ACCEL,
- .addr = OPT3001_I2C_ADDR,
+ .i2c_spi_addr__7bf = OPT3001_I2C_ADDR__7bf,
.rot_standard_ref = NULL,
.default_range = 0x2b11a1,
.min_frequency = OPT3001_LIGHT_MIN_FREQ,
diff --git a/board/kindred/board.h b/board/kindred/board.h
index 057270ff28..1d327abbcf 100644
--- a/board/kindred/board.h
+++ b/board/kindred/board.h
@@ -47,7 +47,7 @@
#define CONFIG_ALS
#define ALS_COUNT 1
#define CONFIG_ALS_OPT3001
-#define OPT3001_I2C_ADDR OPT3001_I2C_ADDR1
+#define OPT3001_I2C_ADDR__7bf OPT3001_I2C_ADDR1__7bf
/* USB Type C and USB PD defines */
#define CONFIG_USB_PD_TCPM_ANX7447
diff --git a/board/kohaku/board.c b/board/kohaku/board.c
index 10b33691f3..0fa7b42ac7 100644
--- a/board/kohaku/board.c
+++ b/board/kohaku/board.c
@@ -117,7 +117,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
.port = I2C_PORT_TCPC0,
- .addr = PS8751_I2C_ADDR1,
+ .addr__7bf = PS8751_I2C_ADDR1__7bf,
},
.drv = &ps8xxx_tcpm_drv,
},
@@ -125,7 +125,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
.port = I2C_PORT_TCPC1,
- .addr = PS8751_I2C_ADDR1,
+ .addr__7bf = PS8751_I2C_ADDR1__7bf,
},
.drv = &ps8xxx_tcpm_drv,
},
@@ -224,7 +224,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_lid_mutex,
.drv_data = &g_bma255_data,
.port = I2C_PORT_ACCEL,
- .addr = BMA2x2_I2C_ADDR1,
+ .i2c_spi_addr__7bf = BMA2x2_I2C_ADDR1__7bf,
.rot_standard_ref = &lid_standard_ref,
.min_frequency = BMA255_ACCEL_MIN_FREQ,
.max_frequency = BMA255_ACCEL_MAX_FREQ,
@@ -251,7 +251,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_base_mutex,
.drv_data = &g_bmi160_data,
.port = I2C_PORT_ACCEL,
- .addr = BMI160_ADDR0,
+ .i2c_spi_addr__7bf = BMI160_ADDR0__7bf,
.rot_standard_ref = &base_standard_ref,
.min_frequency = BMI160_ACCEL_MIN_FREQ,
.max_frequency = BMI160_ACCEL_MAX_FREQ,
@@ -277,7 +277,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_base_mutex,
.drv_data = &g_bmi160_data,
.port = I2C_PORT_ACCEL,
- .addr = BMI160_ADDR0,
+ .i2c_spi_addr__7bf = BMI160_ADDR0__7bf,
.default_range = 1000, /* dps */
.rot_standard_ref = &base_standard_ref,
.min_frequency = BMI160_GYRO_MIN_FREQ,
@@ -293,7 +293,7 @@ struct motion_sensor_t motion_sensors[] = {
.drv = &bh1730_drv,
.drv_data = &g_bh1730_data,
.port = I2C_PORT_ACCEL,
- .addr = BH1730_I2C_ADDR,
+ .i2c_spi_addr__7bf = BH1730_I2C_ADDR__7bf,
.rot_standard_ref = NULL,
.default_range = 65535,
.min_frequency = 10,
@@ -327,7 +327,7 @@ struct motion_sensor_t motion_sensors[] = {
.drv = &tcs3400_drv,
.drv_data = &g_tcs3400_data,
.port = I2C_PORT_ALS,
- .addr = TCS3400_I2C_ADDR,
+ .i2c_spi_addr__7bf = TCS3400_I2C_ADDR__7bf,
.rot_standard_ref = NULL,
.default_range = 0x10000, /* scale = 1x, uscale = 0 */
.min_frequency = TCS3400_LIGHT_MIN_FREQ,
diff --git a/board/kukui/board.c b/board/kukui/board.c
index 5b44578362..95f177bf6b 100644
--- a/board/kukui/board.c
+++ b/board/kukui/board.c
@@ -80,7 +80,7 @@ const struct i2c_port_t i2c_ports[] = {
};
const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports);
-#define BC12_I2C_ADDR PI3USB9201_I2C_ADDR_3
+#define BC12_I2C_ADDR__7bf PI3USB9201_I2C_ADDR_3__7bf
/* power signal list. Must match order of enum power_signal. */
const struct power_signal_info power_signal_list[] = {
@@ -101,7 +101,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
.port = I2C_PORT_TCPC0,
- .addr = MT6370_TCPC_I2C_ADDR,
+ .addr__7bf = MT6370_TCPC_I2C_ADDR__7bf,
},
.drv = &mt6370_tcpm_drv,
},
@@ -303,7 +303,7 @@ static void board_rev_init(void)
if (board_get_version() == 2) {
/* configure PI3USB9201 to USB Path ON Mode */
- i2c_write8(I2C_PORT_BC12, BC12_I2C_ADDR,
+ i2c_write8__7bf(I2C_PORT_BC12, BC12_I2C_ADDR__7bf,
PI3USB9201_REG_CTRL_1,
(PI3USB9201_USB_PATH_ON <<
PI3USB9201_REG_CTRL_1_MODE_SHIFT));
@@ -470,7 +470,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_lid_mutex,
.drv_data = &g_bmi160_data,
.port = I2C_PORT_ACCEL,
- .addr = BMI160_ADDR0,
+ .i2c_spi_addr__7bf = BMI160_ADDR0__7bf,
.rot_standard_ref = &lid_standard_ref,
.default_range = 4, /* g */
.min_frequency = BMI160_ACCEL_MIN_FREQ,
@@ -493,7 +493,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_lid_mutex,
.drv_data = &g_bmi160_data,
.port = I2C_PORT_ACCEL,
- .addr = BMI160_ADDR0,
+ .i2c_spi_addr__7bf = BMI160_ADDR0__7bf,
.default_range = 1000, /* dps */
.rot_standard_ref = &lid_standard_ref,
.min_frequency = BMI160_GYRO_MIN_FREQ,
@@ -510,7 +510,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_lid_mutex,
.drv_data = &g_bmi160_data,
.port = I2C_PORT_ACCEL,
- .addr = BMI160_ADDR0,
+ .i2c_spi_addr__7bf = BMI160_ADDR0__7bf,
.default_range = BIT(11), /* 16LSB / uT, fixed */
.rot_standard_ref = &mag_standard_ref,
.min_frequency = BMM150_MAG_MIN_FREQ,
@@ -526,7 +526,7 @@ struct motion_sensor_t motion_sensors[] = {
.drv = &tcs3400_drv,
.drv_data = &g_tcs3400_data,
.port = I2C_PORT_ALS,
- .addr = TCS3400_I2C_ADDR,
+ .i2c_spi_addr__7bf = TCS3400_I2C_ADDR__7bf,
.rot_standard_ref = NULL,
.default_range = 0x10000, /* scale = 1x, uscale = 0 */
.min_frequency = TCS3400_LIGHT_MIN_FREQ,
diff --git a/board/kukui/board.h b/board/kukui/board.h
index e6862f6c78..95378757bc 100644
--- a/board/kukui/board.h
+++ b/board/kukui/board.h
@@ -91,7 +91,7 @@
#ifdef SECTION_IS_RW
#ifndef BOARD_KRANE
#define CONFIG_MAG_BMI160_BMM150
-#define CONFIG_ACCELGYRO_SEC_ADDR BMM150_ADDR0 /* 8-bit address */
+#define CONFIG_ACCELGYRO_SEC_ADDR__7BF BMM150_ADDR0__7bf
#define CONFIG_MAG_CALIBRATE
#endif /* !BOARD_KRANE */
#define CONFIG_ACCELGYRO_BMI160
@@ -221,7 +221,7 @@
#define I2C_PORT_ALS 1
/* Route sbs host requests to virtual battery driver */
-#define VIRTUAL_BATTERY_ADDR 0x16
+#define VIRTUAL_BATTERY_ADDR__7bf 0x0B
/* Enable Accel over SPI */
#define CONFIG_SPI_ACCEL_PORT 0 /* The first SPI master port (SPI2) */
diff --git a/board/mchpevb1/battery.c b/board/mchpevb1/battery.c
index 016d225950..d6c702127e 100644
--- a/board/mchpevb1/battery.c
+++ b/board/mchpevb1/battery.c
@@ -47,10 +47,10 @@ int board_cut_off_battery(void)
buf[2] = PARAM_CUT_OFF_HIGH;
i2c_lock(I2C_PORT_BATTERY, 1);
- rv = i2c_xfer_unlocked(I2C_PORT_BATTERY, BATTERY_ADDR, buf, 3, NULL, 0,
- I2C_XFER_SINGLE);
- rv |= i2c_xfer_unlocked(I2C_PORT_BATTERY, BATTERY_ADDR, buf, 3, NULL, 0,
- I2C_XFER_SINGLE);
+ rv = i2c_xfer_unlocked__7bf(I2C_PORT_BATTERY, BATTERY_ADDR__7bf,
+ buf, 3, NULL, 0, I2C_XFER_SINGLE);
+ rv |= i2c_xfer_unlocked__7bf(I2C_PORT_BATTERY, BATTERY_ADDR__7bf,
+ buf, 3, NULL, 0, I2C_XFER_SINGLE);
i2c_lock(I2C_PORT_BATTERY, 0);
return rv;
diff --git a/board/mchpevb1/board.c b/board/mchpevb1/board.c
index 7f4bb26c46..f11e65302b 100644
--- a/board/mchpevb1/board.c
+++ b/board/mchpevb1/board.c
@@ -66,14 +66,14 @@
/* NOTE: MEC17xx EVB + SKL RVP3 does not use BD99992 PMIC.
* RVP3 PMIC controlled by RVP3 logic.
*/
-#define I2C_ADDR_BD99992 0x60
+#define I2C_ADDR_BD99992__7bf 0x30
/*
* Maxim DS1624 I2C temperature sensor used for testing I2C.
* DS1624 contains one internal temperature sensor
* and EEPROM. It has no external temperature inputs.
*/
-#define DS1624_I2C_ADDR 0x90 /* 7-bit address is 0x48 */
+#define DS1624_I2C_ADDR__7bf (0x48 | I2C_FLAG_BIG_ENDIAN)
#define DS1624_IDX_LOCAL 0
#define DS1624_READ_TEMP16 0xAA /* read 16-bit temperature */
#define DS1624_ACCESS_CFG 0xAC /* read/write 8-bit config */
@@ -264,8 +264,13 @@ int board_i2c_p2c(int port)
#ifdef CONFIG_USB_POWER_DELIVERY
const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
- {I2C_PORT_TCPC, CONFIG_TCPC_I2C_BASE_ADDR, &tcpci_tcpm_drv},
- {I2C_PORT_TCPC, CONFIG_TCPC_I2C_BASE_ADDR + 2, &tcpci_tcpm_drv},
+ {I2C_PORT_TCPC,
+ CONFIG_TCPC_I2C_BASE_ADDR__7BF,
+ &tcpci_tcpm_drv},
+
+ {I2C_PORT_TCPC,
+ CONFIG_TCPC_I2C_BASE_ADDR__7BF + 1,
+ &tcpci_tcpm_drv},
};
#endif
@@ -384,11 +389,11 @@ BUILD_ASSERT(ARRAY_SIZE(pi3usb9281_chips) ==
struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_COUNT] = {
{
- .port_addr = 0xa8,
+ .port_addr = 0x54,
.driver = &pi3usb30532_usb_mux_driver,
},
{
- .port_addr = 0x20,
+ .port_addr = 0x10,
.driver = &ps874x_usb_mux_driver,
}
};
@@ -505,14 +510,14 @@ static void board_pmic_init(void)
/* Config DS1624 temperature sensor for continuous conversion */
cfg = 0x66;
- rv = i2c_read8(I2C_PORT_THERMAL, DS1624_I2C_ADDR,
+ rv = i2c_read8__7bf(I2C_PORT_THERMAL, DS1624_I2C_ADDR__7bf,
DS1624_ACCESS_CFG, &cfg);
trace2(0, BRD, 0, "Read DS1624 Config rv = %d cfg = 0x%02X",
rv, cfg);
if ((rv == EC_SUCCESS) && (cfg & (1u << 0))) {
/* one-shot mode switch to continuous */
- rv = i2c_write8(I2C_PORT_THERMAL, DS1624_I2C_ADDR,
+ rv = i2c_write8__7bf(I2C_PORT_THERMAL, DS1624_I2C_ADDR__7bf,
DS1624_ACCESS_CFG, 0);
trace1(0, BRD, 0, "Write DS1624 Config to 0, rv = %d", rv);
/* writes to config require 10ms until next I2C command */
@@ -521,7 +526,7 @@ static void board_pmic_init(void)
}
/* Send start command */
- rv = i2c_write8(I2C_PORT_THERMAL, DS1624_I2C_ADDR,
+ rv = i2c_write8__7bf(I2C_PORT_THERMAL, DS1624_I2C_ADDR__7bf,
DS1624_CMD_START, 1);
trace1(0, BRD, 0, "Send Start command to DS1624 rv = %d", rv);
@@ -864,8 +869,7 @@ static void ds1624_update(void)
int temp;
int rv __attribute__((unused));
- rv = i2c_read16(I2C_PORT_THERMAL,
- (DS1624_I2C_ADDR | I2C_FLAG_BIG_ENDIAN),
+ rv = i2c_read16__7bf(I2C_PORT_THERMAL, DS1624_I2C_ADDR__7bf,
DS1624_READ_TEMP16, &temp);
d = (temp & 0x7FFF) >> 8;
@@ -928,7 +932,8 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_base_mutex,
.drv_data = &g_bmi160_data,
.port = CONFIG_SPI_ACCEL_PORT,
- .addr = BMI160_SET_SPI_ADDRESS(CONFIG_SPI_ACCEL_PORT),
+ .i2c_spi_addr__7bf = SLAVE_MK_SPI_ADDR__7bf(
+ CONFIG_SPI_ACCEL_PORT),
.rot_standard_ref = NULL, /* Identity matrix. */
.default_range = 2, /* g, enough for laptop. */
.min_frequency = BMI160_ACCEL_MIN_FREQ,
@@ -952,7 +957,8 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_base_mutex,
.drv_data = &g_bmi160_data,
.port = CONFIG_SPI_ACCEL_PORT,
- .addr = BMI160_SET_SPI_ADDRESS(CONFIG_SPI_ACCEL_PORT),
+ .i2c_spi_addr__7bf = SLAVE_MK_SPI_ADDR__7bf(
+ CONFIG_SPI_ACCEL_PORT),
.default_range = 1000, /* dps */
.rot_standard_ref = NULL, /* Identity Matrix. */
.min_frequency = BMI160_GYRO_MIN_FREQ,
@@ -969,7 +975,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_lid_mutex,
.drv_data = &g_kx022_data,
.port = I2C_PORT_ACCEL,
- .addr = KX022_ADDR1,
+ .i2c_spi_addr__7bf = KX022_ADDR1__7bf,
.rot_standard_ref = NULL, /* Identity matrix. */
.default_range = 2, /* g, enough for laptop. */
.min_frequency = KX022_ACCEL_MIN_FREQ,
diff --git a/board/mchpevb1/board.h b/board/mchpevb1/board.h
index 0dbfe2bb3c..8fcaadc4bf 100644
--- a/board/mchpevb1/board.h
+++ b/board/mchpevb1/board.h
@@ -400,7 +400,7 @@
#endif
/* Ambient Light Sensor address */
-#define OPT3001_I2C_ADDR OPT3001_I2C_ADDR1
+#define OPT3001_I2C_ADDR__7bf OPT3001_I2C_ADDR1__7bf
/* Modules we want to exclude */
#undef CONFIG_CMD_HASH
diff --git a/board/meep/board.c b/board/meep/board.c
index 8c44bda737..a5e37b69ed 100644
--- a/board/meep/board.c
+++ b/board/meep/board.c
@@ -138,7 +138,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_lid_mutex,
.drv_data = &kx022_data,
.port = I2C_PORT_SENSOR,
- .addr = KX022_ADDR1,
+ .i2c_spi_addr__7bf = KX022_ADDR1__7bf,
.rot_standard_ref = &lid_standrd_ref,
.default_range = 2, /* g */
.config = {
@@ -166,7 +166,7 @@ struct motion_sensor_t motion_sensors[] = {
.int_signal = GPIO_BASE_SIXAXIS_INT_L,
.flags = MOTIONSENSE_FLAG_INT_SIGNAL,
.port = I2C_PORT_SENSOR,
- .addr = LSM6DSM_ADDR0,
+ .i2c_spi_addr__7bf = LSM6DSM_ADDR0__7bf,
.rot_standard_ref = &base_standard_ref,
.default_range = 2, /* g */
.min_frequency = LSM6DSM_ODR_MIN_VAL,
@@ -198,7 +198,7 @@ struct motion_sensor_t motion_sensors[] = {
.int_signal = GPIO_BASE_SIXAXIS_INT_L,
.flags = MOTIONSENSE_FLAG_INT_SIGNAL,
.port = I2C_PORT_SENSOR,
- .addr = LSM6DSM_ADDR0,
+ .i2c_spi_addr__7bf = LSM6DSM_ADDR0__7bf,
.default_range = 1000 | ROUND_UP_FLAG, /* dps */
.rot_standard_ref = &base_standard_ref,
.min_frequency = LSM6DSM_ODR_MIN_VAL,
diff --git a/board/nami/board.c b/board/nami/board.c
index ac66f10307..ba9bb571aa 100644
--- a/board/nami/board.c
+++ b/board/nami/board.c
@@ -233,7 +233,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
.port = NPCX_I2C_PORT0_0,
- .addr = PS8751_I2C_ADDR1,
+ .addr__7bf = PS8751_I2C_ADDR1__7bf,
},
.drv = &ps8xxx_tcpm_drv,
/* Alert is active-low, push-pull */
@@ -243,7 +243,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
.port = NPCX_I2C_PORT0_1,
- .addr = AN7447_TCPC3_I2C_ADDR,
+ .addr__7bf = AN7447_TCPC3_I2C_ADDR__7bf,
},
.drv = &anx7447_tcpm_drv,
/* Alert is active-low, push-pull */
@@ -487,9 +487,11 @@ const static struct ec_thermal_config thermal_d2 = {
};
#define I2C_PMIC_READ(reg, data) \
- i2c_read8(I2C_PORT_PMIC, TPS650X30_I2C_ADDR1, (reg), (data))
+ i2c_read8__7bf(I2C_PORT_PMIC, TPS650X30_I2C_ADDR1__7bf,\
+ (reg), (data))
#define I2C_PMIC_WRITE(reg, data) \
- i2c_write8(I2C_PORT_PMIC, TPS650X30_I2C_ADDR1, (reg), (data))
+ i2c_write8__7bf(I2C_PORT_PMIC, TPS650X30_I2C_ADDR1__7bf,\
+ (reg), (data))
static void board_pmic_init(void)
{
@@ -749,7 +751,7 @@ const struct motion_sensor_t lid_accel_1 = {
.mutex = &g_lid_mutex,
.drv_data = &g_kx022_data,
.port = I2C_PORT_ACCEL,
- .addr = KX022_ADDR1,
+ .i2c_spi_addr__7bf = KX022_ADDR1__7bf,
.rot_standard_ref = &rotation_x180_z90,
.min_frequency = KX022_ACCEL_MIN_FREQ,
.max_frequency = KX022_ACCEL_MAX_FREQ,
@@ -777,7 +779,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_lid_mutex,
.drv_data = &g_bma255_data,
.port = I2C_PORT_ACCEL,
- .addr = BMA2x2_I2C_ADDR1,
+ .i2c_spi_addr__7bf = BMA2x2_I2C_ADDR1__7bf,
.rot_standard_ref = &lid_standard_ref,
.min_frequency = BMA255_ACCEL_MIN_FREQ,
.max_frequency = BMA255_ACCEL_MAX_FREQ,
@@ -805,7 +807,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_base_mutex,
.drv_data = &g_bmi160_data,
.port = I2C_PORT_ACCEL,
- .addr = BMI160_ADDR0,
+ .i2c_spi_addr__7bf = BMI160_ADDR0__7bf,
.rot_standard_ref = &base_standard_ref,
.min_frequency = BMI160_ACCEL_MIN_FREQ,
.max_frequency = BMI160_ACCEL_MAX_FREQ,
@@ -833,7 +835,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_base_mutex,
.drv_data = &g_bmi160_data,
.port = I2C_PORT_ACCEL,
- .addr = BMI160_ADDR0,
+ .i2c_spi_addr__7bf = BMI160_ADDR0__7bf,
.default_range = 1000, /* dps */
.rot_standard_ref = &base_standard_ref,
.min_frequency = BMI160_GYRO_MIN_FREQ,
@@ -989,10 +991,10 @@ static void board_init(void)
gpio_set_level(GPIO_PCH_ACPRESENT, extpower_is_present());
/* Reduce Buck-boost mode switching frequency to reduce heat */
- if (i2c_read16(I2C_PORT_CHARGER, I2C_ADDR_CHARGER,
+ if (i2c_read16__7bf(I2C_PORT_CHARGER, I2C_ADDR_CHARGER__7bf,
ISL9238_REG_CONTROL3, &reg) == EC_SUCCESS) {
reg |= ISL9238_C3_BB_SWITCHING_PERIOD;
- if (i2c_write16(I2C_PORT_CHARGER, I2C_ADDR_CHARGER,
+ if (i2c_write16__7bf(I2C_PORT_CHARGER, I2C_ADDR_CHARGER__7bf,
ISL9238_REG_CONTROL3, reg))
CPRINTF("Failed to set isl9238\n");
}
diff --git a/board/nami/board.h b/board/nami/board.h
index 20c9628d9d..04dfef4eff 100644
--- a/board/nami/board.h
+++ b/board/nami/board.h
@@ -210,8 +210,8 @@
#define I2C_PORT_ALS NPCX_I2C_PORT3
/* I2C addresses */
-#define I2C_ADDR_MP2949 0x40
-#define I2C_ADDR_EEPROM 0xa0
+#define I2C_ADDR_MP2949__7bf 0x20
+#define I2C_ADDR_EEPROM__7bf 0x50
#ifndef __ASSEMBLER__
diff --git a/board/nautilus/board.c b/board/nautilus/board.c
index 5dc1df0328..bf89d0edad 100644
--- a/board/nautilus/board.c
+++ b/board/nautilus/board.c
@@ -151,7 +151,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
.port = NPCX_I2C_PORT0_0,
- .addr = PS8751_I2C_ADDR1,
+ .addr__7bf = PS8751_I2C_ADDR1__7bf,
},
.drv = &ps8xxx_tcpm_drv,
},
@@ -159,7 +159,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
.port = NPCX_I2C_PORT0_1,
- .addr = PS8751_I2C_ADDR1,
+ .addr__7bf = PS8751_I2C_ADDR1__7bf,
},
.drv = &ps8xxx_tcpm_drv,
},
@@ -268,7 +268,7 @@ static void board_report_pmic_fault(const char *str)
uint32_t info;
/* RESETIRQ1 -- Bit 4: VRFAULT */
- if (i2c_read8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x8, &vrfault)
+ if (i2c_read8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x8, &vrfault)
!= EC_SUCCESS)
return;
@@ -278,19 +278,19 @@ static void board_report_pmic_fault(const char *str)
/* VRFAULT has occurred, print VRFAULT status bits. */
/* PWRSTAT1 */
- i2c_read8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x16, &pwrstat1);
+ i2c_read8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x16, &pwrstat1);
/* PWRSTAT2 */
- i2c_read8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x17, &pwrstat2);
+ i2c_read8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x17, &pwrstat2);
CPRINTS("PMIC VRFAULT: %s", str);
CPRINTS("PMIC VRFAULT: PWRSTAT1=0x%02x PWRSTAT2=0x%02x", pwrstat1,
pwrstat2);
/* Clear all faults -- Write 1 to clear. */
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x8, BIT(4));
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x16, pwrstat1);
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x17, pwrstat2);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x8, BIT(4));
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x16, pwrstat1);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x17, pwrstat2);
/*
* Status of the fault registers can be checked in the OS by looking at
@@ -309,7 +309,7 @@ static void board_pmic_disable_slp_s0_vr_decay(void)
* Bits 3:2 (10) - VR set to AUTO on SLP_S0# de-assertion
* Bits 1:0 (10) - VR set to AUTO operating mode
*/
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x30, 0x3a);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x30, 0x3a);
/*
* V18ACNT:
@@ -318,7 +318,7 @@ static void board_pmic_disable_slp_s0_vr_decay(void)
* Bits 3:2 (10) - VR set to AUTO on SLP_S0# de-assertion
* Bits 1:0 (10) - VR set to AUTO operating mode
*/
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x34, 0x2a);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x34, 0x2a);
/*
* V100ACNT:
@@ -327,7 +327,7 @@ static void board_pmic_disable_slp_s0_vr_decay(void)
* Bits 3:2 (10) - VR set to AUTO on SLP_S0# de-assertion
* Bits 1:0 (10) - VR set to AUTO operating mode
*/
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x37, 0x1a);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x37, 0x1a);
/*
* V085ACNT:
@@ -336,7 +336,7 @@ static void board_pmic_disable_slp_s0_vr_decay(void)
* Bits 3:2 (10) - VR set to AUTO on SLP_S0# de-assertion
* Bits 1:0 (10) - VR set to AUTO operating mode
*/
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x38, 0x3a);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x38, 0x3a);
}
static void board_pmic_enable_slp_s0_vr_decay(void)
@@ -348,7 +348,7 @@ static void board_pmic_enable_slp_s0_vr_decay(void)
* Bits 3:2 (10) - VR set to AUTO on SLP_S0# de-assertion
* Bits 1:0 (10) - VR set to AUTO operating mode
*/
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x30, 0x7a);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x30, 0x7a);
/*
* V18ACNT:
@@ -357,7 +357,7 @@ static void board_pmic_enable_slp_s0_vr_decay(void)
* Bits 3:2 (10) - VR set to AUTO on SLP_S0# de-assertion
* Bits 1:0 (10) - VR set to AUTO operating mode
*/
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x34, 0x6a);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x34, 0x6a);
/*
* V100ACNT:
@@ -366,7 +366,7 @@ static void board_pmic_enable_slp_s0_vr_decay(void)
* Bits 3:2 (10) - VR set to AUTO on SLP_S0# de-assertion
* Bits 1:0 (10) - VR set to AUTO operating mode
*/
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x37, 0x5a);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x37, 0x5a);
/*
* V085ACNT:
@@ -375,7 +375,7 @@ static void board_pmic_enable_slp_s0_vr_decay(void)
* Bits 3:2 (10) - VR set to AUTO on SLP_S0# de-assertion
* Bits 1:0 (10) - VR set to AUTO operating mode
*/
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x38, 0x7a);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x38, 0x7a);
}
void power_board_handle_host_sleep_event(enum host_sleep_event state)
@@ -394,12 +394,12 @@ static void board_pmic_init(void)
return;
/* DISCHGCNT3 - enable 100 ohm discharge on V1.00A */
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x3e, 0x04);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x3e, 0x04);
board_pmic_disable_slp_s0_vr_decay();
/* VRMODECTRL - disable low-power mode for all rails */
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x3b, 0x1f);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x3b, 0x1f);
}
DECLARE_DEFERRED(board_pmic_init);
@@ -535,7 +535,7 @@ void board_hibernate(void)
uart_flush_output();
/* Trigger PMIC shutdown. */
- if (i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x49, 0x01)) {
+ if (i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x49, 0x01)) {
/*
* If we can't tell the PMIC to shutdown, instead reset
* and don't start the AP. Hopefully we'll be able to
@@ -611,7 +611,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_lid_mutex,
.drv_data = &g_bma255_data,
.port = I2C_PORT_ACCEL,
- .addr = BMA2x2_I2C_ADDR1,
+ .i2c_spi_addr__7bf = BMA2x2_I2C_ADDR1__7bf,
.rot_standard_ref = &lid_standard_ref,
.min_frequency = BMA255_ACCEL_MIN_FREQ,
.max_frequency = BMA255_ACCEL_MAX_FREQ,
@@ -637,7 +637,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_base_mutex,
.drv_data = &g_bmi160_data,
.port = I2C_PORT_ACCEL,
- .addr = BMI160_ADDR0,
+ .i2c_spi_addr__7bf = BMI160_ADDR0__7bf,
.rot_standard_ref = &base_standard_ref,
.min_frequency = BMI160_ACCEL_MIN_FREQ,
.max_frequency = BMI160_ACCEL_MAX_FREQ,
@@ -664,7 +664,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_base_mutex,
.drv_data = &g_bmi160_data,
.port = I2C_PORT_ACCEL,
- .addr = BMI160_ADDR0,
+ .i2c_spi_addr__7bf = BMI160_ADDR0__7bf,
.default_range = 1000, /* dps */
.rot_standard_ref = &base_standard_ref,
.min_frequency = BMI160_GYRO_MIN_FREQ,
@@ -747,16 +747,17 @@ int board_has_working_reset_flags(void)
#define BATTERY_FREE_MIN_DELTA_US (5 * MSEC)
static timestamp_t battery_last_i2c_time;
-static int is_battery_i2c(int port, int slave_addr)
+static int is_battery_i2c__7bf(const int port, const uint16_t slave_addr__7bf)
{
- return (port == I2C_PORT_BATTERY) && (slave_addr == BATTERY_ADDR);
+ return (port == I2C_PORT_BATTERY)
+ && (slave_addr__7bf == BATTERY_ADDR__7bf);
}
-void i2c_start_xfer_notify(int port, int slave_addr)
+void i2c_start_xfer_notify__7bf(const int port, const uint16_t slave_addr__7bf)
{
unsigned int time_delta_us;
- if (!is_battery_i2c(port, slave_addr))
+ if (!is_battery_i2c__7bf(port, slave_addr__7bf))
return;
time_delta_us = time_since32(battery_last_i2c_time);
@@ -766,9 +767,9 @@ void i2c_start_xfer_notify(int port, int slave_addr)
usleep(BATTERY_FREE_MIN_DELTA_US - time_delta_us);
}
-void i2c_end_xfer_notify(int port, int slave_addr)
+void i2c_end_xfer_notify__7bf(const int port, const uint16_t slave_addr__7bf)
{
- if (!is_battery_i2c(port, slave_addr))
+ if (!is_battery_i2c__7bf(port, slave_addr__7bf))
return;
battery_last_i2c_time = get_time();
diff --git a/board/nautilus/board.h b/board/nautilus/board.h
index 014f821482..ff5a4c586e 100644
--- a/board/nautilus/board.h
+++ b/board/nautilus/board.h
@@ -181,8 +181,8 @@
#define I2C_PORT_THERMAL I2C_PORT_PMIC
/* I2C addresses */
-#define I2C_ADDR_BD99992 0x60
-#define I2C_ADDR_MP2949 0x40
+#define I2C_ADDR_BD99992__7bf 0x30
+#define I2C_ADDR_MP2949__7bf 0x20
#ifndef __ASSEMBLER__
diff --git a/board/nocturne/board.c b/board/nocturne/board.c
index 8fe2a58e66..5df9e338ed 100644
--- a/board/nocturne/board.c
+++ b/board/nocturne/board.c
@@ -190,7 +190,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_lid_mutex,
.drv_data = &g_bmi160_data,
.port = I2C_PORT_ALS_GYRO,
- .addr = BMI160_ADDR0,
+ .i2c_spi_addr__7bf = BMI160_ADDR0__7bf,
.rot_standard_ref = &lid_standard_ref,
.default_range = 4, /* g */
.min_frequency = BMI160_ACCEL_MIN_FREQ,
@@ -213,7 +213,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_lid_mutex,
.drv_data = &g_bmi160_data,
.port = I2C_PORT_ALS_GYRO,
- .addr = BMI160_ADDR0,
+ .i2c_spi_addr__7bf = BMI160_ADDR0__7bf,
.rot_standard_ref = &lid_standard_ref,
.default_range = 1000, /* dps */
.min_frequency = BMI160_GYRO_MIN_FREQ,
@@ -229,7 +229,7 @@ struct motion_sensor_t motion_sensors[] = {
.drv = &opt3001_drv,
.drv_data = &g_opt3001_data,
.port = I2C_PORT_ALS_GYRO,
- .addr = OPT3001_I2C_ADDR,
+ .i2c_spi_addr__7bf = OPT3001_I2C_ADDR__7bf,
.rot_standard_ref = NULL,
/* scale = 43.4513 http://b/111528815#comment14 */
.default_range = 0x2b11a1,
@@ -287,12 +287,12 @@ DECLARE_HOOK(HOOK_CHIPSET_RESUME, enable_sensor_irqs, HOOK_PRIO_DEFAULT);
struct ppc_config_t ppc_chips[] = {
{
.i2c_port = I2C_PORT_USB_C0,
- .i2c_addr = SN5S330_ADDR0,
+ .i2c_addr__7bf = SN5S330_ADDR0__7bf,
.drv = &sn5s330_drv
},
{
.i2c_port = I2C_PORT_USB_C1,
- .i2c_addr = SN5S330_ADDR0,
+ .i2c_addr__7bf = SN5S330_ADDR0__7bf,
.drv = &sn5s330_drv,
},
};
@@ -303,7 +303,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
.port = I2C_PORT_USB_C0,
- .addr = PS8751_I2C_ADDR1,
+ .addr__7bf = PS8751_I2C_ADDR1__7bf,
},
.drv = &tcpci_tcpm_drv,
},
@@ -311,7 +311,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
.port = I2C_PORT_USB_C1,
- .addr = PS8751_I2C_ADDR1,
+ .addr__7bf = PS8751_I2C_ADDR1__7bf,
},
.drv = &tcpci_tcpm_drv,
},
@@ -342,7 +342,8 @@ DECLARE_HOOK(HOOK_CHIPSET_STARTUP, board_chipset_startup, HOOK_PRIO_DEFAULT);
static void imvp8_tune_deferred(void)
{
/* For the IMVP8, reduce the steps during decay from 3 to 1. */
- if (i2c_write16(I2C_PORT_POWER, I2C_ADDR_MP2949, 0xFA, 0x0AC5))
+ if (i2c_write16__7bf(I2C_PORT_POWER, I2C_ADDR_MP2949__7bf,
+ 0xFA, 0x0AC5))
CPRINTS("Failed to change step decay!");
}
DECLARE_DEFERRED(imvp8_tune_deferred);
@@ -400,7 +401,7 @@ void board_hibernate(void)
system_enter_psl_mode();
/* Cut off DSW power via the ROP PMIC. */
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x49, 0x1);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x49, 0x1);
/* Wait for power to be cut. */
while (1)
@@ -450,7 +451,7 @@ static void board_pmic_disable_slp_s0_vr_decay(void)
* Bits 3:2 (10) - VR set to AUTO on SLP_S0# de-assertion
* Bits 1:0 (10) - VR set to AUTO operating mode
*/
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x30, 0x3a);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x30, 0x3a);
/*
* V18ACNT:
@@ -459,7 +460,7 @@ static void board_pmic_disable_slp_s0_vr_decay(void)
* Bits 3:2 (10) - VR set to AUTO on SLP_S0# de-assertion
* Bits 1:0 (10) - VR set to AUTO operating mode
*/
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x34, 0x2a);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x34, 0x2a);
/*
* V100ACNT:
@@ -468,7 +469,7 @@ static void board_pmic_disable_slp_s0_vr_decay(void)
* Bits 3:2 (10) - VR set to AUTO on SLP_S0# de-assertion
* Bits 1:0 (10) - VR set to AUTO operating mode
*/
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x37, 0x1a);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x37, 0x1a);
/*
* V085ACNT:
@@ -477,7 +478,7 @@ static void board_pmic_disable_slp_s0_vr_decay(void)
* Bits 3:2 (10) - VR set to AUTO on SLP_S0# de-assertion
* Bits 1:0 (10) - VR set to AUTO operating mode
*/
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x38, 0x2a);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x38, 0x2a);
}
static void board_pmic_enable_slp_s0_vr_decay(void)
@@ -489,7 +490,7 @@ static void board_pmic_enable_slp_s0_vr_decay(void)
* Bits 3:2 (10) - VR set to AUTO on SLP_S0# de-assertion
* Bits 1:0 (10) - VR set to AUTO operating mode
*/
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x30, 0x7a);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x30, 0x7a);
/*
* V18ACNT:
@@ -498,7 +499,7 @@ static void board_pmic_enable_slp_s0_vr_decay(void)
* Bits 3:2 (10) - VR set to AUTO on SLP_S0# de-assertion
* Bits 1:0 (10) - VR set to AUTO operating mode
*/
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x34, 0x6a);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x34, 0x6a);
/*
* V100ACNT:
@@ -507,7 +508,7 @@ static void board_pmic_enable_slp_s0_vr_decay(void)
* Bits 3:2 (10) - VR set to AUTO on SLP_S0# de-assertion
* Bits 1:0 (10) - VR set to AUTO operating mode
*/
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x37, 0x5a);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x37, 0x5a);
/*
* V085ACNT:
@@ -516,7 +517,7 @@ static void board_pmic_enable_slp_s0_vr_decay(void)
* Bits 3:2 (10) - VR set to AUTO on SLP_S0# de-assertion
* Bits 1:0 (10) - VR set to AUTO operating mode
*/
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x38, 0x6a);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x38, 0x6a);
}
void power_board_handle_host_sleep_event(enum host_sleep_event state)
@@ -532,15 +533,16 @@ static void board_pmic_init(void)
int pgmask1;
/* Mask V5A_DS3_PG from PMIC PGMASK1. */
- if (i2c_read8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x18, &pgmask1))
+ if (i2c_read8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf,
+ 0x18, &pgmask1))
return;
pgmask1 |= BIT(2);
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x18, pgmask1);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x18, pgmask1);
board_pmic_disable_slp_s0_vr_decay();
/* Enable active discharge (100 ohms) on V33A_PCH and V1.8A. */
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x3D, 0x5);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x3D, 0x5);
}
DECLARE_HOOK(HOOK_INIT, board_pmic_init, HOOK_PRIO_DEFAULT);
@@ -631,7 +633,7 @@ static void board_report_pmic_fault(const char *str)
uint32_t info;
/* RESETIRQ1 -- Bit 4: VRFAULT */
- if (i2c_read8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x8, &vrfault)
+ if (i2c_read8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x8, &vrfault)
!= EC_SUCCESS)
return;
@@ -641,19 +643,19 @@ static void board_report_pmic_fault(const char *str)
/* VRFAULT has occurred, print VRFAULT status bits. */
/* PWRSTAT1 */
- i2c_read8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x16, &pwrstat1);
+ i2c_read8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x16, &pwrstat1);
/* PWRSTAT2 */
- i2c_read8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x17, &pwrstat2);
+ i2c_read8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x17, &pwrstat2);
CPRINTS("PMIC VRFAULT: %s", str);
CPRINTS("PMIC VRFAULT: PWRSTAT1=0x%02x PWRSTAT2=0x%02x", pwrstat1,
pwrstat2);
/* Clear all faults -- Write 1 to clear. */
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x8, BIT(4));
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x16, pwrstat1);
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x17, pwrstat2);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x8, BIT(4));
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x16, pwrstat1);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x17, pwrstat2);
/*
* Status of the fault registers can be checked in the OS by looking at
diff --git a/board/nocturne/board.h b/board/nocturne/board.h
index c1eec1d179..d678f70a3e 100644
--- a/board/nocturne/board.h
+++ b/board/nocturne/board.h
@@ -93,7 +93,7 @@
#define CONFIG_ALS
#define ALS_COUNT 1
#define CONFIG_ALS_OPT3001
-#define OPT3001_I2C_ADDR OPT3001_I2C_ADDR1
+#define OPT3001_I2C_ADDR__7bf OPT3001_I2C_ADDR1__7bf
#define CONFIG_ACCEL_FIFO 512 /* Must be a power of 2 */
/* Depends on how fast the AP boots and typical ODRs */
#define CONFIG_ACCEL_FIFO_THRES (CONFIG_ACCEL_FIFO / 3)
@@ -175,8 +175,8 @@
#define GPIO_USB_C1_SCL GPIO_EC_I2C2_USB_C1_SCL
#define GPIO_USB_C1_SDA GPIO_EC_I2C2_USB_C1_SDA
-#define I2C_ADDR_MP2949 0x40
-#define I2C_ADDR_BD99992 0x60
+#define I2C_ADDR_MP2949__7bf 0x20
+#define I2C_ADDR_BD99992__7bf 0x30
/*
* Remapping of schematic GPIO names to common GPIO names expected (hardcoded)
diff --git a/board/nucleo-f411re/board.c b/board/nucleo-f411re/board.c
index 0f7c57f1e3..d2f587321f 100644
--- a/board/nucleo-f411re/board.c
+++ b/board/nucleo-f411re/board.c
@@ -75,7 +75,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_base_mutex,
.drv_data = &g_bmi160_data,
.port = I2C_PORT_ACCEL,
- .addr = BMI160_ADDR0,
+ .i2c_spi_addr__7bf = BMI160_ADDR0__7bf,
.rot_standard_ref = NULL,
.default_range = 2, /* g, enough for laptop. */
.config = {
@@ -102,7 +102,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_base_mutex,
.drv_data = &g_bmi160_data,
.port = I2C_PORT_ACCEL,
- .addr = BMI160_ADDR0,
+ .i2c_spi_addr__7bf = BMI160_ADDR0__7bf,
.default_range = 1000, /* dps */
.rot_standard_ref = NULL,
},
diff --git a/board/oak/battery.c b/board/oak/battery.c
index a868e20bc0..25d6b6e46d 100644
--- a/board/oak/battery.c
+++ b/board/oak/battery.c
@@ -57,10 +57,10 @@ static int cutoff(void)
buf[2] = PARAM_CUT_OFF_HIGH;
i2c_lock(I2C_PORT_BATTERY, 1);
- rv = i2c_xfer_unlocked(I2C_PORT_BATTERY, BATTERY_ADDR, buf, 3, NULL, 0,
- I2C_XFER_SINGLE);
- rv |= i2c_xfer_unlocked(I2C_PORT_BATTERY, BATTERY_ADDR, buf, 3, NULL, 0,
- I2C_XFER_SINGLE);
+ rv = i2c_xfer_unlocked__7bf(I2C_PORT_BATTERY, BATTERY_ADDR__7bf,
+ buf, 3, NULL, 0, I2C_XFER_SINGLE);
+ rv |= i2c_xfer_unlocked__7bf(I2C_PORT_BATTERY, BATTERY_ADDR__7bf,
+ buf, 3, NULL, 0, I2C_XFER_SINGLE);
i2c_lock(I2C_PORT_BATTERY, 0);
return rv;
diff --git a/board/oak/board.c b/board/oak/board.c
index 4e7d317a4b..2f0046fac6 100644
--- a/board/oak/board.c
+++ b/board/oak/board.c
@@ -117,7 +117,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
.port = I2C_PORT_TCPC,
- .addr = CONFIG_TCPC_I2C_BASE_ADDR,
+ .addr__7bf = CONFIG_TCPC_I2C_BASE_ADDR__7BF,
},
.drv = &tcpci_tcpm_drv,
},
@@ -125,7 +125,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
.port = I2C_PORT_TCPC,
- .addr = CONFIG_TCPC_I2C_BASE_ADDR + 2,
+ .addr__7bf = CONFIG_TCPC_I2C_BASE_ADDR__7BF + 1,
},
.drv = &tcpci_tcpm_drv,
},
@@ -176,17 +176,17 @@ BUILD_ASSERT(ARRAY_SIZE(als) == ALS_COUNT);
struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_COUNT] = {
{
- .port_addr = 0x54 << 1,
+ .port_addr = 0x54,
.driver = &pi3usb30532_usb_mux_driver,
},
#if (BOARD_REV <= OAK_REV4)
{
- .port_addr = 0x55 << 1,
+ .port_addr = 0x55,
.driver = &pi3usb30532_usb_mux_driver,
},
#else
{
- .port_addr = 0x20,
+ .port_addr = 0x10,
.driver = &ps874x_usb_mux_driver,
},
#endif
@@ -647,7 +647,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_base_mutex,
.drv_data = &g_bmi160_data,
.port = I2C_PORT_ACCEL,
- .addr = 1,
+ .i2c_spi_addr__7bf = SLAVE_MK_SPI_ADDR__7bf(0),
.rot_standard_ref = &base_standard_ref,
.default_range = 2, /* g, enough for laptop. */
.min_frequency = BMI160_ACCEL_MIN_FREQ,
@@ -671,7 +671,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_base_mutex,
.drv_data = &g_bmi160_data,
.port = I2C_PORT_ACCEL,
- .addr = 1,
+ .i2c_spi_addr__7bf = SLAVE_MK_SPI_ADDR__7bf(0),
.default_range = 1000, /* dps */
.rot_standard_ref = &base_standard_ref,
.min_frequency = BMI160_GYRO_MIN_FREQ,
@@ -689,7 +689,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_lid_mutex,
.drv_data = &g_kx022_data,
.port = I2C_PORT_ACCEL,
- .addr = KX022_ADDR1,
+ .i2c_spi_addr__7bf = KX022_ADDR1__7bf,
.rot_standard_ref = NULL, /* Identity matrix. */
.default_range = 2, /* g, enough for laptop. */
.min_frequency = KX022_ACCEL_MIN_FREQ,
diff --git a/board/oak/board.h b/board/oak/board.h
index b8ebe7c8e6..bc1e71c98f 100644
--- a/board/oak/board.h
+++ b/board/oak/board.h
@@ -160,7 +160,7 @@
#define CONFIG_SPI_ACCEL_PORT 0 /* First SPI master port (SPI2) */
/* Ambient Light Sensor address */
-#define OPT3001_I2C_ADDR OPT3001_I2C_ADDR1
+#define OPT3001_I2C_ADDR__7bf OPT3001_I2C_ADDR1__7bf
/* Timer selection */
#define TIM_CLOCK32 2
diff --git a/board/pdeval-stm32f072/board.c b/board/pdeval-stm32f072/board.c
index 5a632ced06..e2e6bc63b6 100644
--- a/board/pdeval-stm32f072/board.c
+++ b/board/pdeval-stm32f072/board.c
@@ -4,8 +4,8 @@
*/
/* STM32F072-discovery board based USB PD evaluation configuration */
-#include "anx7447.h"
#include "common.h"
+#include "anx7447.h"
#include "ec_version.h"
#include "gpio.h"
#include "hooks.h"
@@ -62,7 +62,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
.port = I2C_PORT_TCPC,
- .addr = AN7447_TCPC3_I2C_ADDR,
+ .addr__7bf = AN7447_TCPC3_I2C_ADDR__7bf,
},
.drv = &anx7447_tcpm_drv,
},
diff --git a/board/pdeval-stm32f072/usb_pd_policy.c b/board/pdeval-stm32f072/usb_pd_policy.c
index 86062725fe..283483d566 100644
--- a/board/pdeval-stm32f072/usb_pd_policy.c
+++ b/board/pdeval-stm32f072/usb_pd_policy.c
@@ -3,8 +3,8 @@
* found in the LICENSE file.
*/
-#include "anx7447.h"
#include "common.h"
+#include "anx7447.h"
#include "console.h"
#include "gpio.h"
#include "hooks.h"
diff --git a/board/phaser/board.c b/board/phaser/board.c
index 68d5bbd633..353eeed9e5 100644
--- a/board/phaser/board.c
+++ b/board/phaser/board.c
@@ -120,7 +120,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_lid_mutex,
.drv_data = &g_lis2dh_data,
.port = I2C_PORT_SENSOR,
- .addr = LIS2DH_ADDR1,
+ .i2c_spi_addr__7bf = LIS2DH_ADDR1__7bf,
.rot_standard_ref = &standard_rot_ref,
/* We only use 2g because its resolution is only 8-bits */
.default_range = 2, /* g */
@@ -151,7 +151,7 @@ struct motion_sensor_t motion_sensors[] = {
.int_signal = GPIO_BASE_SIXAXIS_INT_L,
.flags = MOTIONSENSE_FLAG_INT_SIGNAL,
.port = I2C_PORT_SENSOR,
- .addr = LSM6DSM_ADDR0,
+ .i2c_spi_addr__7bf = LSM6DSM_ADDR0__7bf,
.rot_standard_ref = &standard_rot_ref,
.default_range = 4, /* g */
.min_frequency = LSM6DSM_ODR_MIN_VAL,
@@ -183,7 +183,7 @@ struct motion_sensor_t motion_sensors[] = {
.int_signal = GPIO_BASE_SIXAXIS_INT_L,
.flags = MOTIONSENSE_FLAG_INT_SIGNAL,
.port = I2C_PORT_SENSOR,
- .addr = LSM6DSM_ADDR0,
+ .i2c_spi_addr__7bf = LSM6DSM_ADDR0__7bf,
.default_range = 1000 | ROUND_UP_FLAG, /* dps */
.rot_standard_ref = &standard_rot_ref,
.min_frequency = LSM6DSM_ODR_MIN_VAL,
diff --git a/board/plankton/board.c b/board/plankton/board.c
index 925a036c7f..886e8776ef 100644
--- a/board/plankton/board.c
+++ b/board/plankton/board.c
@@ -467,7 +467,7 @@ const struct i2c_port_t i2c_ports[] = {
const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports);
/* 8-bit address */
-#define SN75DP130_I2C_ADDR 0x5c
+#define SN75DP130_I2C_ADDR__7bf 0x2e
/*
* Pin number for active-high reset from PCA9534 to CMOS pull-down to
* SN75DP130's RSTN (active-low)
@@ -476,7 +476,8 @@ const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports);
static int sn75dp130_i2c_write(uint8_t index, uint8_t value)
{
- return i2c_write8(I2C_PORT_MASTER, SN75DP130_I2C_ADDR, index, value);
+ return i2c_write8__7bf(I2C_PORT_MASTER, SN75DP130_I2C_ADDR__7bf,
+ index, value);
}
/**
@@ -489,15 +490,17 @@ static int sn75dp130_reset(void)
{
int rv;
- rv = pca9534_config_pin(I2C_PORT_MASTER, 0x40, REDRIVER_RST_PIN,
- PCA9534_OUTPUT);
+ rv = pca9534_config_pin__7bf(I2C_PORT_MASTER, 0x20,
+ REDRIVER_RST_PIN, PCA9534_OUTPUT);
/* Assert (its active high) */
- rv |= pca9534_set_level(I2C_PORT_MASTER, 0x40, REDRIVER_RST_PIN, 1);
+ rv |= pca9534_set_level__7bf(I2C_PORT_MASTER, 0x20,
+ REDRIVER_RST_PIN, 1);
/* datasheet recommends > 100usec */
usleep(200);
/* De-assert */
- rv |= pca9534_set_level(I2C_PORT_MASTER, 0x40, REDRIVER_RST_PIN, 0);
+ rv |= pca9534_set_level__7bf(I2C_PORT_MASTER, 0x20,
+ REDRIVER_RST_PIN, 0);
/* datasheet recommends > 400msec */
usleep(450 * MSEC);
return rv;
@@ -593,10 +596,12 @@ int board_in_hub_mode(void)
int ret;
int level;
- ret = pca9534_config_pin(I2C_PORT_MASTER, 0x40, 6, PCA9534_INPUT);
+ ret = pca9534_config_pin__7bf(I2C_PORT_MASTER, 0x20,
+ 6, PCA9534_INPUT);
if (ret)
return -1;
- ret = pca9534_get_level(I2C_PORT_MASTER, 0x40, 6, &level);
+ ret = pca9534_get_level__7bf(I2C_PORT_MASTER, 0x20,
+ 6, &level);
if (ret)
return -1;
return level;
@@ -606,14 +611,17 @@ static int board_usb_hub_reset(void)
{
int ret;
- ret = pca9534_config_pin(I2C_PORT_MASTER, 0x40, 7, PCA9534_OUTPUT);
+ ret = pca9534_config_pin__7bf(I2C_PORT_MASTER, 0x20,
+ 7, PCA9534_OUTPUT);
if (ret)
return ret;
- ret = pca9534_set_level(I2C_PORT_MASTER, 0x40, 7, 0);
+ ret = pca9534_set_level__7bf(I2C_PORT_MASTER, 0x20,
+ 7, 0);
if (ret)
return ret;
usleep(100 * MSEC);
- return pca9534_set_level(I2C_PORT_MASTER, 0x40, 7, 1);
+ return pca9534_set_level__7bf(I2C_PORT_MASTER, 0x20,
+ 7, 1);
}
void board_maybe_reset_usb_hub(void)
diff --git a/board/poppy/board.c b/board/poppy/board.c
index cc26a6206d..90e56b6fa8 100644
--- a/board/poppy/board.c
+++ b/board/poppy/board.c
@@ -193,7 +193,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
.port = NPCX_I2C_PORT0_0,
- .addr = ANX74XX_I2C_ADDR1,
+ .addr__7bf = ANX74XX_I2C_ADDR1__7bf,
},
.drv = &anx74xx_tcpm_drv,
},
@@ -201,7 +201,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
.port = NPCX_I2C_PORT0_0,
- .addr = PS8751_I2C_ADDR1,
+ .addr__7bf = PS8751_I2C_ADDR1__7bf,
},
.drv = &ps8xxx_tcpm_drv,
},
@@ -291,7 +291,7 @@ void board_tcpc_init(void)
*
* NOTE: PS8751 A3 will wake on any I2C access.
*/
- i2c_read8(NPCX_I2C_PORT0_1, 0x10, 0xA0, &reg);
+ i2c_read8__7bf(NPCX_I2C_PORT0_1, 0x08, 0xA0, &reg);
/* Enable TCPC interrupts */
gpio_enable_interrupt(GPIO_USB_C0_PD_INT_ODL);
@@ -358,7 +358,7 @@ static void board_report_pmic_fault(const char *str)
uint32_t info;
/* RESETIRQ1 -- Bit 4: VRFAULT */
- if (i2c_read8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x8, &vrfault)
+ if (i2c_read8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x8, &vrfault)
!= EC_SUCCESS)
return;
@@ -368,19 +368,19 @@ static void board_report_pmic_fault(const char *str)
/* VRFAULT has occurred, print VRFAULT status bits. */
/* PWRSTAT1 */
- i2c_read8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x16, &pwrstat1);
+ i2c_read8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x16, &pwrstat1);
/* PWRSTAT2 */
- i2c_read8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x17, &pwrstat2);
+ i2c_read8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x17, &pwrstat2);
CPRINTS("PMIC VRFAULT: %s", str);
CPRINTS("PMIC VRFAULT: PWRSTAT1=0x%02x PWRSTAT2=0x%02x", pwrstat1,
pwrstat2);
/* Clear all faults -- Write 1 to clear. */
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x8, BIT(4));
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x16, pwrstat1);
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x17, pwrstat2);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x8, BIT(4));
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x16, pwrstat1);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x17, pwrstat2);
/*
* Status of the fault registers can be checked in the OS by looking at
@@ -399,7 +399,7 @@ static void board_pmic_disable_slp_s0_vr_decay(void)
* Bits 3:2 (10) - VR set to AUTO on SLP_S0# de-assertion
* Bits 1:0 (10) - VR set to AUTO operating mode
*/
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x30, 0x3a);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x30, 0x3a);
/*
* V18ACNT:
@@ -408,7 +408,7 @@ static void board_pmic_disable_slp_s0_vr_decay(void)
* Bits 3:2 (10) - VR set to AUTO on SLP_S0# de-assertion
* Bits 1:0 (10) - VR set to AUTO operating mode
*/
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x34, 0x2a);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x34, 0x2a);
/*
* V100ACNT:
@@ -417,7 +417,7 @@ static void board_pmic_disable_slp_s0_vr_decay(void)
* Bits 3:2 (10) - VR set to AUTO on SLP_S0# de-assertion
* Bits 1:0 (10) - VR set to AUTO operating mode
*/
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x37, 0x1a);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x37, 0x1a);
/*
* V085ACNT:
@@ -426,7 +426,7 @@ static void board_pmic_disable_slp_s0_vr_decay(void)
* Bits 3:2 (10) - VR set to AUTO on SLP_S0# de-assertion
* Bits 1:0 (10) - VR set to AUTO operating mode
*/
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x38, 0x3a);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x38, 0x3a);
}
static void board_pmic_enable_slp_s0_vr_decay(void)
@@ -438,7 +438,7 @@ static void board_pmic_enable_slp_s0_vr_decay(void)
* Bits 3:2 (10) - VR set to AUTO on SLP_S0# de-assertion
* Bits 1:0 (10) - VR set to AUTO operating mode
*/
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x30, 0x7a);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x30, 0x7a);
/*
* V18ACNT:
@@ -447,7 +447,7 @@ static void board_pmic_enable_slp_s0_vr_decay(void)
* Bits 3:2 (10) - VR set to AUTO on SLP_S0# de-assertion
* Bits 1:0 (10) - VR set to AUTO operating mode
*/
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x34, 0x6a);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x34, 0x6a);
/*
* V100ACNT:
@@ -456,7 +456,7 @@ static void board_pmic_enable_slp_s0_vr_decay(void)
* Bits 3:2 (10) - VR set to AUTO on SLP_S0# de-assertion
* Bits 1:0 (10) - VR set to AUTO operating mode
*/
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x37, 0x5a);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x37, 0x5a);
/*
* V085ACNT:
@@ -465,7 +465,7 @@ static void board_pmic_enable_slp_s0_vr_decay(void)
* Bits 3:2 (10) - VR set to AUTO on SLP_S0# de-assertion
* Bits 1:0 (10) - VR set to AUTO operating mode
*/
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x38, 0x7a);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x38, 0x7a);
}
void power_board_handle_host_sleep_event(enum host_sleep_event state)
@@ -484,15 +484,15 @@ static void board_pmic_init(void)
return;
/* DISCHGCNT3 - enable 100 ohm discharge on V1.00A */
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x3e, 0x04);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x3e, 0x04);
board_pmic_disable_slp_s0_vr_decay();
/* VRMODECTRL - disable low-power mode for all rails */
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x3b, 0x1f);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x3b, 0x1f);
/* Disable power button shutdown timer. */
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x14, 0x00);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x14, 0x00);
}
DECLARE_DEFERRED(board_pmic_init);
@@ -652,23 +652,24 @@ void board_set_charge_limit(int port, int supplier, int charge_ma,
void board_hibernate(void)
{
- CPRINTS("Triggering PMIC shutdown.");
- uart_flush_output();
-
- /* Trigger PMIC shutdown. */
- if (i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x49, 0x01)) {
- /*
- * If we can't tell the PMIC to shutdown, instead reset
- * and don't start the AP. Hopefully we'll be able to
- * communicate with the PMIC next time.
- */
- CPRINTS("PMIC i2c failed.");
- system_reset(SYSTEM_RESET_LEAVE_AP_OFF);
- }
-
- /* Await shutdown. */
- while (1)
- ;
+ CPRINTS("Triggering PMIC shutdown.");
+ uart_flush_output();
+
+ /* Trigger PMIC shutdown. */
+ if (i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf,
+ 0x49, 0x01)) {
+ /*
+ * If we can't tell the PMIC to shutdown, instead reset
+ * and don't start the AP. Hopefully we'll be able to
+ * communicate with the PMIC next time.
+ */
+ CPRINTS("PMIC i2c failed.");
+ system_reset(SYSTEM_RESET_LEAVE_AP_OFF);
+ }
+
+ /* Await shutdown. */
+ while (1)
+ ;
}
int board_get_version(void)
@@ -750,7 +751,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_lid_mutex,
.drv_data = &g_bmi160_data,
.port = I2C_PORT_GYRO,
- .addr = BMI160_ADDR0,
+ .i2c_spi_addr__7bf = BMI160_ADDR0__7bf,
.rot_standard_ref = &lid_standard_ref,
.default_range = 2, /* g, enough for laptop. */
.min_frequency = BMI160_ACCEL_MIN_FREQ,
@@ -774,7 +775,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_lid_mutex,
.drv_data = &g_bmi160_data,
.port = I2C_PORT_GYRO,
- .addr = BMI160_ADDR0,
+ .i2c_spi_addr__7bf = BMI160_ADDR0__7bf,
.default_range = 1000, /* dps */
.rot_standard_ref = &lid_standard_ref,
.min_frequency = BMI160_GYRO_MIN_FREQ,
@@ -791,7 +792,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_lid_mutex,
.drv_data = &g_bmi160_data,
.port = I2C_PORT_GYRO,
- .addr = BMI160_ADDR0,
+ .i2c_spi_addr__7bf = BMI160_ADDR0__7bf,
.default_range = BIT(11), /* 16LSB / uT, fixed */
.rot_standard_ref = &mag_standard_ref,
.min_frequency = BMM150_MAG_MIN_FREQ,
@@ -806,7 +807,7 @@ struct motion_sensor_t motion_sensors[] = {
.drv = &opt3001_drv,
.drv_data = &g_opt3001_data,
.port = I2C_PORT_ALS,
- .addr = OPT3001_I2C_ADDR,
+ .i2c_spi_addr__7bf = OPT3001_I2C_ADDR__7bf,
.rot_standard_ref = NULL,
.default_range = 0x10000, /* scale = 1; uscale = 0 */
.min_frequency = OPT3001_LIGHT_MIN_FREQ,
diff --git a/board/poppy/board.h b/board/poppy/board.h
index 39e0f1796f..fc8a7c255c 100644
--- a/board/poppy/board.h
+++ b/board/poppy/board.h
@@ -115,7 +115,7 @@
#define CONFIG_ALS
#define CONFIG_ALS_OPT3001
#define ALS_COUNT 1
-#define OPT3001_I2C_ADDR OPT3001_I2C_ADDR1
+#define OPT3001_I2C_ADDR__7bf OPT3001_I2C_ADDR1__7bf
#define CONFIG_TEMP_SENSOR
#define CONFIG_TEMP_SENSOR_BD99992GW
#define CONFIG_THERMISTOR_NCP15WB
@@ -128,7 +128,7 @@
#define CONFIG_ACCEL_INTERRUPTS
#define CONFIG_ACCELGYRO_BMI160_INT_EVENT \
TASK_EVENT_MOTION_SENSOR_INTERRUPT(LID_ACCEL)
-#define CONFIG_ACCELGYRO_SEC_ADDR BMM150_ADDR0 /* 8-bit address */
+#define CONFIG_ACCELGYRO_SEC_ADDR__7BF BMM150_ADDR0__7bf
#define CONFIG_MAG_CALIBRATE
/* Lower maximal ODR to 100Hz */
#define CONFIG_EC_MAX_SENSOR_FREQ_MILLIHZ 100000
@@ -192,8 +192,8 @@
#define I2C_PORT_THERMAL I2C_PORT_PMIC
/* I2C addresses */
-#define I2C_ADDR_BD99992 0x60
-#define I2C_ADDR_MP2949 0x40
+#define I2C_ADDR_BD99992__7bf 0x30
+#define I2C_ADDR_MP2949__7bf 0x20
#ifndef __ASSEMBLER__
diff --git a/board/rainier/board.c b/board/rainier/board.c
index 890aa8be80..8173414bf7 100644
--- a/board/rainier/board.c
+++ b/board/rainier/board.c
@@ -131,7 +131,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
.port = I2C_PORT_TCPC0,
- .addr = FUSB302_I2C_SLAVE_ADDR,
+ .addr__7bf = FUSB302_I2C_SLAVE_ADDR__7bf,
},
.drv = &fusb302_tcpm_drv,
},
@@ -377,7 +377,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_base_mutex,
.drv_data = &g_bmi160_data,
.port = CONFIG_SPI_ACCEL_PORT,
- .addr = BMI160_SET_SPI_ADDRESS(CONFIG_SPI_ACCEL_PORT),
+ .i2c_spi_addr__7bf = SLAVE_MK_SPI_ADDR__7bf(CONFIG_SPI_ACCEL_PORT),
.rot_standard_ref = &base_standard_ref,
.default_range = 2, /* g, enough for laptop. */
.min_frequency = BMI160_ACCEL_MIN_FREQ,
@@ -400,7 +400,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_base_mutex,
.drv_data = &g_bmi160_data,
.port = CONFIG_SPI_ACCEL_PORT,
- .addr = BMI160_SET_SPI_ADDRESS(CONFIG_SPI_ACCEL_PORT),
+ .i2c_spi_addr__7bf = SLAVE_MK_SPI_ADDR__7bf(CONFIG_SPI_ACCEL_PORT),
.default_range = 1000, /* dps */
.rot_standard_ref = &base_standard_ref,
.min_frequency = BMI160_GYRO_MIN_FREQ,
@@ -422,7 +422,7 @@ struct motion_sensor_t motion_sensors[] = {
.drv = &bmp280_drv,
.drv_data = &bmp280_drv_data,
.port = CONFIG_SPI_ACCEL_PORT,
- .addr = BMI160_SET_SPI_ADDRESS(CONFIG_SPI_ACCEL_PORT),
+ .i2c_spi_addr__7bf = SLAVE_MK_SPI_ADDR__7bf(CONFIG_SPI_ACCEL_PORT),
.default_range = BIT(18), /* 1bit = 4 Pa, 16bit ~= 2600 hPa */
.min_frequency = BMP280_BARO_MIN_FREQ,
.max_frequency = BMP280_BARO_MAX_FREQ,
diff --git a/board/rammus/board.c b/board/rammus/board.c
index 1596407718..82af7a2667 100644
--- a/board/rammus/board.c
+++ b/board/rammus/board.c
@@ -151,7 +151,7 @@ struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
.port = I2C_PORT_TCPC1,
- .addr = PS8751_I2C_ADDR1,
+ .addr__7bf = PS8751_I2C_ADDR1__7bf,
},
.drv = &ps8xxx_tcpm_drv,
},
@@ -159,7 +159,8 @@ struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
.port = I2C_PORT_TCPC0,
- .addr = AN7447_TCPC3_I2C_ADDR, /* Verified on v1.1 */
+ /* Verified on v1.1 */
+ .addr__7bf = AN7447_TCPC3_I2C_ADDR__7bf,
},
.drv = &anx7447_tcpm_drv,
},
@@ -297,7 +298,7 @@ static void board_report_pmic_fault(const char *str)
uint32_t info;
/* RESETIRQ1 -- Bit 4: VRFAULT */
- if (i2c_read8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x8, &vrfault)
+ if (i2c_read8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x8, &vrfault)
!= EC_SUCCESS)
return;
@@ -307,19 +308,19 @@ static void board_report_pmic_fault(const char *str)
/* VRFAULT has occurred, print VRFAULT status bits. */
/* PWRSTAT1 */
- i2c_read8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x16, &pwrstat1);
+ i2c_read8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x16, &pwrstat1);
/* PWRSTAT2 */
- i2c_read8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x17, &pwrstat2);
+ i2c_read8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x17, &pwrstat2);
CPRINTS("PMIC VRFAULT: %s", str);
CPRINTS("PMIC VRFAULT: PWRSTAT1=0x%02x PWRSTAT2=0x%02x", pwrstat1,
pwrstat2);
/* Clear all faults -- Write 1 to clear. */
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x8, BIT(4));
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x16, pwrstat1);
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x17, pwrstat2);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x8, BIT(4));
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x16, pwrstat1);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x17, pwrstat2);
/*
* Status of the fault registers can be checked in the OS by looking at
@@ -338,7 +339,7 @@ static void board_pmic_disable_slp_s0_vr_decay(void)
* Bits 3:2 (10) - VR set to AUTO on SLP_S0# de-assertion
* Bits 1:0 (10) - VR set to AUTO operating mode
*/
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x30, 0x3a);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x30, 0x3a);
/*
* V18ACNT:
@@ -347,7 +348,7 @@ static void board_pmic_disable_slp_s0_vr_decay(void)
* Bits 3:2 (10) - VR set to AUTO on SLP_S0# de-assertion
* Bits 1:0 (10) - VR set to AUTO operating mode
*/
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x34, 0x2a);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x34, 0x2a);
/*
* V085ACNT:
@@ -356,7 +357,7 @@ static void board_pmic_disable_slp_s0_vr_decay(void)
* Bits 3:2 (10) - VR set to AUTO on SLP_S0# de-assertion
* Bits 1:0 (10) - VR set to AUTO operating mode
*/
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x38, 0x3a);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x38, 0x3a);
}
static void board_pmic_enable_slp_s0_vr_decay(void)
@@ -368,7 +369,7 @@ static void board_pmic_enable_slp_s0_vr_decay(void)
* Bits 3:2 (10) - VR set to AUTO on SLP_S0# de-assertion
* Bits 1:0 (10) - VR set to AUTO operating mode
*/
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x30, 0x7a);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x30, 0x7a);
/*
* V18ACNT:
@@ -377,7 +378,7 @@ static void board_pmic_enable_slp_s0_vr_decay(void)
* Bits 3:2 (10) - VR set to AUTO on SLP_S0# de-assertion
* Bits 1:0 (10) - VR set to AUTO operating mode
*/
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x34, 0x6a);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x34, 0x6a);
/*
* V085ACNT:
@@ -386,7 +387,7 @@ static void board_pmic_enable_slp_s0_vr_decay(void)
* Bits 3:2 (10) - VR set to AUTO on SLP_S0# de-assertion
* Bits 1:0 (10) - VR set to AUTO operating mode
*/
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x38, 0x7a);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x38, 0x7a);
}
void power_board_handle_host_sleep_event(enum host_sleep_event state)
@@ -408,16 +409,16 @@ static void board_pmic_init(void)
* DISCHGCNT2 - enable 100 ohm discharge on
* V5A_DS3/V33A_DSW/V33A_PCH/V1.8A
*/
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x3d, 0x55);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x3d, 0x55);
/* DISCHGCNT3 - enable 100 ohm discharge on V1.8U_25U/V1.00A */
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x3e, 0x44);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x3e, 0x44);
/* DISCHGCNT4 - enable 100 ohm discharge on v1.8S */
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x3f, 0x04);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x3f, 0x04);
board_pmic_disable_slp_s0_vr_decay();
/* VRMODECTRL - disable low-power mode for all rails */
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x3b, 0x1f);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x3b, 0x1f);
}
DECLARE_DEFERRED(board_pmic_init);
@@ -543,7 +544,7 @@ void board_hibernate(void)
uart_flush_output();
/* Trigger PMIC shutdown. */
- if (i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x49, 0x01)) {
+ if (i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x49, 0x01)) {
/*
* If we can't tell the PMIC to shutdown, instead reset
* and don't start the AP. Hopefully we'll be able to
@@ -601,7 +602,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_lid_mutex,
.drv_data = &g_bma255_data,
.port = I2C_PORT_ACCEL,
- .addr = BMA2x2_I2C_ADDR1,
+ .i2c_spi_addr__7bf = BMA2x2_I2C_ADDR1__7bf,
.rot_standard_ref = &lid_standard_ref,
.min_frequency = BMA255_ACCEL_MIN_FREQ,
.max_frequency = BMA255_ACCEL_MAX_FREQ,
@@ -629,7 +630,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_base_mutex,
.drv_data = &g_bmi160_data,
.port = I2C_PORT_ACCEL,
- .addr = BMI160_ADDR0,
+ .i2c_spi_addr__7bf = BMI160_ADDR0__7bf,
.rot_standard_ref = &base_standard_ref,
.min_frequency = BMI160_ACCEL_MIN_FREQ,
.max_frequency = BMI160_ACCEL_MAX_FREQ,
@@ -657,7 +658,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_base_mutex,
.drv_data = &g_bmi160_data,
.port = I2C_PORT_ACCEL,
- .addr = BMI160_ADDR0,
+ .i2c_spi_addr__7bf = BMI160_ADDR0__7bf,
.default_range = 1000, /* dps */
.rot_standard_ref = &base_standard_ref,
.min_frequency = BMI160_GYRO_MIN_FREQ,
diff --git a/board/rammus/board.h b/board/rammus/board.h
index 8c36ca46b9..5d577be79d 100644
--- a/board/rammus/board.h
+++ b/board/rammus/board.h
@@ -187,9 +187,9 @@
#define I2C_PORT_THERMAL I2C_PORT_PMIC
/* I2C addresses */
-#define I2C_ADDR_BD99992 0x60
-#define I2C_ADDR_MP2949 0x40
-#define I2C_ADDR_EEPROM 0xa0
+#define I2C_ADDR_BD99992__7bf 0x30
+#define I2C_ADDR_MP2949__7bf 0x20
+#define I2C_ADDR_EEPROM__7bf 0x50
/* Rename GPIOs */
#define GPIO_PCH_SLP_S0_L GPIO_SLP_S0_L
diff --git a/board/reef/board.c b/board/reef/board.c
index 2189146e34..ea9e8e9e43 100644
--- a/board/reef/board.c
+++ b/board/reef/board.c
@@ -167,7 +167,7 @@ struct i2c_stress_test i2c_stress_tests[] = {
#ifdef CONFIG_CMD_I2C_STRESS_TEST_TCPC
{
.port = NPCX_I2C_PORT0_0,
- .addr = ANX74XX_I2C_ADDR1,
+ .addr__7bf = ANX74XX_I2C_ADDR1__7bf,
.i2c_test = &anx74xx_i2c_stress_test_dev,
},
#endif
@@ -176,7 +176,7 @@ struct i2c_stress_test i2c_stress_tests[] = {
#ifdef CONFIG_CMD_I2C_STRESS_TEST_TCPC
{
.port = NPCX_I2C_PORT0_1,
- .addr = PS8751_I2C_ADDR1,
+ .addr__7bf = PS8751_I2C_ADDR1__7bf,
.i2c_test = &ps8xxx_i2c_stress_test_dev,
},
#endif
@@ -185,7 +185,7 @@ struct i2c_stress_test i2c_stress_tests[] = {
#ifdef CONFIG_CMD_I2C_STRESS_TEST_ACCEL
{
.port = I2C_PORT_GYRO,
- .addr = BMI160_ADDR0,
+ .addr__7bf = BMI160_ADDR0__7bf,
.i2c_test = &bmi160_i2c_stress_test_dev,
},
#endif
@@ -194,19 +194,19 @@ struct i2c_stress_test i2c_stress_tests[] = {
#ifdef CONFIG_CMD_I2C_STRESS_TEST_ACCEL
{
.port = I2C_PORT_BARO,
- .addr = BMP280_I2C_ADDRESS1,
+ .addr__7bf = BMP280_I2C_ADDRESS1__7bf,
.i2c_test = &bmp280_i2c_stress_test_dev,
},
{
.port = I2C_PORT_LID_ACCEL,
- .addr = KX022_ADDR1,
+ .addr__7bf = KX022_ADDR1__7bf,
.i2c_test = &kionix_i2c_stress_test_dev,
},
#endif
#ifdef CONFIG_CMD_I2C_STRESS_TEST_ALS
{
.port = I2C_PORT_ALS,
- .addr = OPT3001_I2C_ADDR1,
+ .addr__7bf = OPT3001_I2C_ADDR1__7bf,
.i2c_test = &opt3001_i2c_stress_test_dev,
},
#endif
@@ -231,7 +231,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
.port = NPCX_I2C_PORT0_0,
- .addr = ANX74XX_I2C_ADDR1,
+ .addr__7bf = ANX74XX_I2C_ADDR1__7bf,
},
.drv = &anx74xx_tcpm_drv,
},
@@ -239,7 +239,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
.port = NPCX_I2C_PORT0_1,
- .addr = PS8751_I2C_ADDR1,
+ .addr__7bf = PS8751_I2C_ADDR1__7bf,
},
.drv = &ps8xxx_tcpm_drv,
},
@@ -367,7 +367,7 @@ void board_tcpc_init(void)
*
* NOTE: PS8751 A3 will wake on any I2C access.
*/
- i2c_read8(NPCX_I2C_PORT0_1, 0x10, 0xA0, &reg);
+ i2c_read8__7bf(NPCX_I2C_PORT0_1, 0x08, 0xA0, &reg);
/* Enable TCPC0 interrupt */
gpio_enable_interrupt(GPIO_USB_C0_PD_INT_ODL);
@@ -715,7 +715,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_lid_mutex,
.drv_data = &g_kx022_data,
.port = I2C_PORT_LID_ACCEL,
- .addr = KX022_ADDR1,
+ .i2c_spi_addr__7bf = KX022_ADDR1__7bf,
.rot_standard_ref = NULL, /* Identity matrix. */
.default_range = 2, /* g, enough for laptop. */
.min_frequency = KX022_ACCEL_MIN_FREQ,
@@ -742,7 +742,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_base_mutex,
.drv_data = &g_bmi160_data,
.port = I2C_PORT_GYRO,
- .addr = BMI160_ADDR0,
+ .i2c_spi_addr__7bf = BMI160_ADDR0__7bf,
.rot_standard_ref = &base_standard_ref,
.default_range = 2, /* g, enough for laptop. */
.min_frequency = BMI160_ACCEL_MIN_FREQ,
@@ -771,7 +771,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_base_mutex,
.drv_data = &g_bmi160_data,
.port = I2C_PORT_GYRO,
- .addr = BMI160_ADDR0,
+ .i2c_spi_addr__7bf = BMI160_ADDR0__7bf,
.default_range = 1000, /* dps */
.rot_standard_ref = &base_standard_ref,
.min_frequency = BMI160_GYRO_MIN_FREQ,
@@ -787,7 +787,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_base_mutex,
.drv_data = &g_bmi160_data,
.port = I2C_PORT_GYRO,
- .addr = BMI160_ADDR0,
+ .i2c_spi_addr__7bf = BMI160_ADDR0__7bf,
.default_range = BIT(11), /* 16LSB / uT, fixed */
.rot_standard_ref = &mag_standard_ref,
.min_frequency = BMM150_MAG_MIN_FREQ,
@@ -802,7 +802,7 @@ struct motion_sensor_t motion_sensors[] = {
.drv = &bmp280_drv,
.drv_data = &bmp280_drv_data,
.port = I2C_PORT_BARO,
- .addr = BMP280_I2C_ADDRESS1,
+ .i2c_spi_addr__7bf = BMP280_I2C_ADDRESS1__7bf,
.default_range = BIT(18), /* 1bit = 4 Pa, 16bit ~= 2600 hPa */
.min_frequency = BMP280_BARO_MIN_FREQ,
.max_frequency = BMP280_BARO_MAX_FREQ,
@@ -816,7 +816,7 @@ struct motion_sensor_t motion_sensors[] = {
.drv = &opt3001_drv,
.drv_data = &g_opt3001_data,
.port = I2C_PORT_ALS,
- .addr = OPT3001_I2C_ADDR1,
+ .i2c_spi_addr__7bf = OPT3001_I2C_ADDR1__7bf,
.rot_standard_ref = NULL,
.default_range = 0x10000, /* scale = 1; uscale = 0 */
.min_frequency = OPT3001_LIGHT_MIN_FREQ,
diff --git a/board/reef/board.h b/board/reef/board.h
index 5dd0a3bf06..245ccaf7e4 100644
--- a/board/reef/board.h
+++ b/board/reef/board.h
@@ -196,7 +196,7 @@
#define CONFIG_ACCELGYRO_BMI160_INT_EVENT \
TASK_EVENT_MOTION_SENSOR_INTERRUPT(BASE_ACCEL)
#define CONFIG_MAG_BMI160_BMM150
-#define CONFIG_ACCELGYRO_SEC_ADDR BMM150_ADDR0 /* 8-bit address */
+#define CONFIG_ACCELGYRO_SEC_ADDR__7BF BMM150_ADDR0__7bf
#define CONFIG_MAG_CALIBRATE
#define CONFIG_ACCEL_KX022
#define CONFIG_ALS_OPT3001
diff --git a/board/reef_it8320/board.c b/board/reef_it8320/board.c
index 6174e7e24b..82c094095c 100644
--- a/board/reef_it8320/board.c
+++ b/board/reef_it8320/board.c
@@ -161,12 +161,12 @@ static void it83xx_tcpc_update_hpd_status(int port, int hpd_lvl, int hpd_irq)
struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_COUNT] = {
{
- .port_addr = 0xa8,
+ .port_addr = 0x54,
.driver = &pi3usb30532_usb_mux_driver,
.hpd_update = &it83xx_tcpc_update_hpd_status,
},
{
- .port_addr = 0x20,
+ .port_addr = 0x10,
.driver = &ps874x_usb_mux_driver,
.hpd_update = &it83xx_tcpc_update_hpd_status,
},
diff --git a/board/reef_mchp/board.c b/board/reef_mchp/board.c
index b66b5eaa27..206d6dd1d0 100644
--- a/board/reef_mchp/board.c
+++ b/board/reef_mchp/board.c
@@ -283,7 +283,7 @@ struct i2c_stress_test i2c_stress_tests[] = {
#ifdef CONFIG_CMD_I2C_STRESS_TEST_TCPC
{
.port = MCHP_I2C_PORT0,
- .addr = 0x50,
+ .addr__7bf = 0x28,
.i2c_test = &anx74xx_i2c_stress_test_dev,
},
#endif
@@ -291,33 +291,33 @@ struct i2c_stress_test i2c_stress_tests[] = {
#ifdef CONFIG_CMD_I2C_STRESS_TEST_TCPC
{
.port = MCHP_I2C_PORT2,
- .addr = 0x16,
+ .addr__7bf = 0x0B,
.i2c_test = &ps8xxx_i2c_stress_test_dev,
},
#endif
#ifdef CONFIG_CMD_I2C_STRESS_TEST_ACCEL
{
.port = I2C_PORT_GYRO,
- .addr = BMI160_ADDR0,
+ .addr__7bf = BMI160_ADDR0__7bf,
.i2c_test = &bmi160_i2c_stress_test_dev,
},
#endif
#ifdef CONFIG_CMD_I2C_STRESS_TEST_ACCEL
{
.port = I2C_PORT_BARO,
- .addr = BMP280_I2C_ADDRESS1,
+ .addr__7bf = BMP280_I2C_ADDRESS1__7bf,
.i2c_test = &bmp280_i2c_stress_test_dev,
},
{
.port = I2C_PORT_LID_ACCEL,
- .addr = KX022_ADDR1,
+ .addr__7bf = KX022_ADDR1__7bf,
.i2c_test = &kionix_i2c_stress_test_dev,
},
#endif
#ifdef CONFIG_CMD_I2C_STRESS_TEST_ALS
{
.port = I2C_PORT_ALS,
- .addr = OPT3001_I2C_ADDR1,
+ .addr__7bf = OPT3001_I2C_ADDR1__7bf,
.i2c_test = &opt3001_i2c_stress_test_dev,
},
#endif
@@ -342,7 +342,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
.port = MCHP_I2C_PORT0,
- .addr = 0x50,
+ .addr__7bf = 0x28,
},
.drv = &anx74xx_tcpm_drv,
},
@@ -350,7 +350,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
.port = MCHP_I2C_PORT2,
- .addr = 0x16,
+ .addr__7bf = 0x0B,
},
.drv = &ps8xxx_tcpm_drv,
},
@@ -513,7 +513,7 @@ void board_tcpc_init(void)
* address 0x10. Is this another attempt at waking PS8751
* from DRP low power idle mode?
*/
- i2c_read8(MCHP_I2C_PORT2, 0x10, 0xA0, &reg);
+ i2c_read8__7bf(MCHP_I2C_PORT2, 0x08, 0xA0, &reg);
/* Enable TCPC0 interrupt */
gpio_enable_interrupt(GPIO_USB_C0_PD_INT_ODL);
@@ -961,7 +961,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_lid_mutex,
.drv_data = &g_kx022_data,
.port = I2C_PORT_LID_ACCEL,
- .addr = KX022_ADDR1,
+ .i2c_spi_addr__7bf = KX022_ADDR1__7bf,
.rot_standard_ref = NULL, /* Identity matrix. */
.default_range = 2, /* g, enough for laptop. */
.min_frequency = KX022_ACCEL_MIN_FREQ,
@@ -988,7 +988,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_base_mutex,
.drv_data = &g_bmi160_data,
.port = I2C_PORT_GYRO,
- .addr = BMI160_ADDR0,
+ .i2c_spi_addr__7bf = BMI160_ADDR0__7bf,
.rot_standard_ref = &base_standard_ref,
.default_range = 2, /* g, enough for laptop. */
.min_frequency = BMI160_ACCEL_MIN_FREQ,
@@ -1017,7 +1017,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_base_mutex,
.drv_data = &g_bmi160_data,
.port = I2C_PORT_GYRO,
- .addr = BMI160_ADDR0,
+ .i2c_spi_addr__7bf = BMI160_ADDR0__7bf,
.default_range = 1000, /* dps */
.rot_standard_ref = &base_standard_ref,
.min_frequency = BMI160_GYRO_MIN_FREQ,
@@ -1033,7 +1033,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_base_mutex,
.drv_data = &g_bmi160_data,
.port = I2C_PORT_GYRO,
- .addr = BMI160_ADDR0,
+ .i2c_spi_addr__7bf = BMI160_ADDR0__7bf,
.default_range = BIT(11), /* 16LSB / uT, fixed */
.rot_standard_ref = &mag_standard_ref,
.min_frequency = BMM150_MAG_MIN_FREQ,
@@ -1048,7 +1048,7 @@ struct motion_sensor_t motion_sensors[] = {
.drv = &bmp280_drv,
.drv_data = &bmp280_drv_data,
.port = I2C_PORT_BARO,
- .addr = BMP280_I2C_ADDRESS1,
+ .i2c_spi_addr__7bf = BMP280_I2C_ADDRESS1__7bf,
.default_range = BIT(18), /* 1bit = 4 Pa, 16bit ~= 2600 hPa */
.min_frequency = BMP280_BARO_MIN_FREQ,
.max_frequency = BMP280_BARO_MAX_FREQ,
@@ -1062,7 +1062,7 @@ struct motion_sensor_t motion_sensors[] = {
.drv = &opt3001_drv,
.drv_data = &g_opt3001_data,
.port = I2C_PORT_ALS,
- .addr = OPT3001_I2C_ADDR1,
+ .i2c_spi_addr__7bf = OPT3001_I2C_ADDR1__7bf,
.rot_standard_ref = NULL,
.default_range = 0x10000, /* scale = 1; uscale = 0 */
.min_frequency = OPT3001_LIGHT_MIN_FREQ,
diff --git a/board/reef_mchp/board.h b/board/reef_mchp/board.h
index dabdabb587..7c4189e4b5 100644
--- a/board/reef_mchp/board.h
+++ b/board/reef_mchp/board.h
@@ -203,7 +203,7 @@
#define CONFIG_ACCELGYRO_BMI160_INT_EVENT \
TASK_EVENT_MOTION_SENSOR_INTERRUPT(BASE_ACCEL)
#define CONFIG_MAG_BMI160_BMM150
-#define CONFIG_ACCELGYRO_SEC_ADDR BMM150_ADDR0 /* 8-bit address */
+#define CONFIG_ACCELGYRO_SEC_ADDR__7BF BMM150_ADDR0__7bf
#define CONFIG_MAG_CALIBRATE
#define CONFIG_ACCEL_KX022
#define CONFIG_ALS_OPT3001
diff --git a/board/samus/battery.c b/board/samus/battery.c
index dcbd4f0964..e21f51e3b5 100644
--- a/board/samus/battery.c
+++ b/board/samus/battery.c
@@ -290,10 +290,10 @@ int board_cut_off_battery(void)
buf[2] = PARAM_CUT_OFF_HIGH;
i2c_lock(I2C_PORT_BATTERY, 1);
- rv = i2c_xfer_unlocked(I2C_PORT_BATTERY, BATTERY_ADDR, buf, 3, NULL, 0,
- I2C_XFER_SINGLE);
- rv |= i2c_xfer_unlocked(I2C_PORT_BATTERY, BATTERY_ADDR, buf, 3, NULL, 0,
- I2C_XFER_SINGLE);
+ rv = i2c_xfer_unlocked__7bf(I2C_PORT_BATTERY, BATTERY_ADDR__7bf,
+ buf, 3, NULL, 0, I2C_XFER_SINGLE);
+ rv |= i2c_xfer_unlocked__7bf(I2C_PORT_BATTERY, BATTERY_ADDR__7bf,
+ buf, 3, NULL, 0, I2C_XFER_SINGLE);
i2c_lock(I2C_PORT_BATTERY, 0);
return rv;
diff --git a/board/samus/board.c b/board/samus/board.c
index 2804799994..323789a7a3 100644
--- a/board/samus/board.c
+++ b/board/samus/board.c
@@ -132,29 +132,35 @@ const struct i2c_port_t i2c_ports[] = {
};
const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports);
-#define TEMP_U40_REG_ADDR ((0x40 << 1) | I2C_FLAG_BIG_ENDIAN)
-#define TEMP_U41_REG_ADDR ((0x44 << 1) | I2C_FLAG_BIG_ENDIAN)
-#define TEMP_U42_REG_ADDR ((0x41 << 1) | I2C_FLAG_BIG_ENDIAN)
-#define TEMP_U43_REG_ADDR ((0x45 << 1) | I2C_FLAG_BIG_ENDIAN)
-#define TEMP_U115_REG_ADDR ((0x42 << 1) | I2C_FLAG_BIG_ENDIAN)
-#define TEMP_U116_REG_ADDR ((0x43 << 1) | I2C_FLAG_BIG_ENDIAN)
-
-#define TEMP_U40_ADDR TMP006_ADDR(I2C_PORT_THERMAL, TEMP_U40_REG_ADDR)
-#define TEMP_U41_ADDR TMP006_ADDR(I2C_PORT_THERMAL, TEMP_U41_REG_ADDR)
-#define TEMP_U42_ADDR TMP006_ADDR(I2C_PORT_THERMAL, TEMP_U42_REG_ADDR)
-#define TEMP_U43_ADDR TMP006_ADDR(I2C_PORT_THERMAL, TEMP_U43_REG_ADDR)
-#define TEMP_U115_ADDR TMP006_ADDR(I2C_PORT_THERMAL, TEMP_U115_REG_ADDR)
-#define TEMP_U116_ADDR TMP006_ADDR(I2C_PORT_THERMAL, TEMP_U116_REG_ADDR)
-
-const struct tmp006_t tmp006_sensors[TMP006_COUNT] = {
- {"Charger", TEMP_U40_ADDR},
- {"CPU", TEMP_U41_ADDR},
- {"Left C", TEMP_U42_ADDR},
- {"Right C", TEMP_U43_ADDR},
- {"Right D", TEMP_U115_ADDR},
- {"Left D", TEMP_U116_ADDR},
+#define TEMP_U40_REG_ADDR__7bf (0x40 | I2C_FLAG_BIG_ENDIAN)
+#define TEMP_U41_REG_ADDR__7bf (0x44 | I2C_FLAG_BIG_ENDIAN)
+#define TEMP_U42_REG_ADDR__7bf (0x41 | I2C_FLAG_BIG_ENDIAN)
+#define TEMP_U43_REG_ADDR__7bf (0x45 | I2C_FLAG_BIG_ENDIAN)
+#define TEMP_U115_REG_ADDR__7bf (0x42 | I2C_FLAG_BIG_ENDIAN)
+#define TEMP_U116_REG_ADDR__7bf (0x43 | I2C_FLAG_BIG_ENDIAN)
+
+#define TEMP_U40_ADDR__7bf TMP006_ADDR__7bf(I2C_PORT_THERMAL,\
+ TEMP_U40_REG_ADDR__7bf)
+#define TEMP_U41_ADDR__7bf TMP006_ADDR__7bf(I2C_PORT_THERMAL,\
+ TEMP_U41_REG_ADDR__7bf)
+#define TEMP_U42_ADDR__7bf TMP006_ADDR__7bf(I2C_PORT_THERMAL,\
+ TEMP_U42_REG_ADDR__7bf)
+#define TEMP_U43_ADDR__7bf TMP006_ADDR__7bf(I2C_PORT_THERMAL,\
+ TEMP_U43_REG_ADDR__7bf)
+#define TEMP_U115_ADDR__7bf TMP006_ADDR__7bf(I2C_PORT_THERMAL,\
+ TEMP_U115_REG_ADDR__7bf)
+#define TEMP_U116_ADDR__7bf TMP006_ADDR__7bf(I2C_PORT_THERMAL,\
+ TEMP_U116_REG_ADDR__7bf)
+
+const struct tmp006_t tmp006_sensors__7bf[TMP006_COUNT] = {
+ {"Charger", TEMP_U40_ADDR__7bf},
+ {"CPU", TEMP_U41_ADDR__7bf},
+ {"Left C", TEMP_U42_ADDR__7bf},
+ {"Right C", TEMP_U43_ADDR__7bf},
+ {"Right D", TEMP_U115_ADDR__7bf},
+ {"Left D", TEMP_U116_ADDR__7bf},
};
-BUILD_ASSERT(ARRAY_SIZE(tmp006_sensors) == TMP006_COUNT);
+BUILD_ASSERT(ARRAY_SIZE(tmp006_sensors__7bf) == TMP006_COUNT);
/* Temperature sensors data; must be in same order as enum temp_sensor_id. */
const struct temp_sensor_t temp_sensors[] = {
@@ -326,7 +332,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_base_mutex,
.drv_data = &g_saved_data[0],
.port = I2C_PORT_ACCEL,
- .addr = LSM6DS0_ADDR1,
+ .i2c_spi_addr__7bf = LSM6DS0_ADDR1__7bf,
.rot_standard_ref = &base_standard_ref,
.default_range = 2, /* g, enough for laptop. */
.min_frequency = LSM6DS0_ACCEL_MIN_FREQ,
@@ -358,7 +364,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_lid_mutex,
.drv_data = &g_kxcj9_data,
.port = I2C_PORT_ACCEL,
- .addr = KXCJ9_ADDR0,
+ .i2c_spi_addr__7bf = KXCJ9_ADDR0__7bf,
.rot_standard_ref = &lid_standard_ref,
.default_range = 2, /* g, enough for laptop. */
.min_frequency = KXCJ9_ACCEL_MIN_FREQ,
@@ -381,7 +387,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_base_mutex,
.drv_data = &g_saved_data[1],
.port = I2C_PORT_ACCEL,
- .addr = LSM6DS0_ADDR1,
+ .i2c_spi_addr__7bf = LSM6DS0_ADDR1__7bf,
.rot_standard_ref = NULL,
.default_range = 2000, /* g, enough for laptop. */
.min_frequency = LSM6DS0_GYRO_MIN_FREQ,
diff --git a/board/samus/extpower.c b/board/samus/extpower.c
index 9307463cbf..cddb4a76e1 100644
--- a/board/samus/extpower.c
+++ b/board/samus/extpower.c
@@ -159,7 +159,7 @@ static void allow_max_request(void)
int prochot_status;
if (charge_circuit_state == CHARGE_CIRCUIT_WEDGED) {
/* Read PROCHOT status register to clear it */
- i2c_read8(I2C_PORT_CHARGER, BQ24773_ADDR,
+ i2c_read8__7bf(I2C_PORT_CHARGER, BQ24773_ADDR__7bf,
BQ24773_PROCHOT_STATUS, &prochot_status);
charge_circuit_state = CHARGE_CIRCUIT_OK;
}
@@ -301,7 +301,7 @@ static void check_charge_wedged(void)
if (charge_circuit_state == CHARGE_CIRCUIT_OK) {
/* Check PROCHOT warning */
- rv = i2c_read8(I2C_PORT_CHARGER, BQ24773_ADDR,
+ rv = i2c_read8__7bf(I2C_PORT_CHARGER, BQ24773_ADDR__7bf,
BQ24773_PROCHOT_STATUS, &prochot_status);
if (rv)
prochot_status = 0;
diff --git a/board/samus/panel.c b/board/samus/panel.c
index ccb43f1fcb..0c60b2a492 100644
--- a/board/samus/panel.c
+++ b/board/samus/panel.c
@@ -15,7 +15,7 @@
#define CPRINTS(format, args...) cprints(CC_I2C, format, ## args)
-#define I2C_ADDR_BACKLIGHT ((0x2C << 1) | I2C_FLAG_BIG_ENDIAN)
+#define I2C_ADDR_BACKLIGHT__7bf (0x2C | I2C_FLAG_BIG_ENDIAN)
#define I2C_RETRIES 3
#define I2C_RETRY_DELAY (5*MSEC)
@@ -61,7 +61,8 @@ static int lp8555_read_with_retry(int reg, int *data)
int i, rv;
for (i = 0; i < I2C_RETRIES; i++) {
- rv = i2c_read8(I2C_PORT_BACKLIGHT, I2C_ADDR_BACKLIGHT,
+ rv = i2c_read8__7bf(I2C_PORT_BACKLIGHT,
+ I2C_ADDR_BACKLIGHT__7bf,
reg, data);
if (rv == EC_SUCCESS)
return EC_SUCCESS;
@@ -78,8 +79,9 @@ static int lp8555_write_with_retry(int reg, int data)
int i, rv;
for (i = 0; i < I2C_RETRIES; i++) {
- rv = i2c_write8(I2C_PORT_BACKLIGHT, I2C_ADDR_BACKLIGHT,
- reg, data);
+ rv = i2c_write8__7bf(I2C_PORT_BACKLIGHT,
+ I2C_ADDR_BACKLIGHT__7bf,
+ reg, data);
if (rv == EC_SUCCESS)
return EC_SUCCESS;
usleep(I2C_RETRY_DELAY);
diff --git a/board/samus_pd/board.h b/board/samus_pd/board.h
index 649feb3fd3..032e0bf0f2 100644
--- a/board/samus_pd/board.h
+++ b/board/samus_pd/board.h
@@ -89,7 +89,7 @@
/* slave address for host commands */
#ifdef HAS_TASK_HOSTCMD
-#define CONFIG_HOSTCMD_I2C_SLAVE_ADDR CONFIG_USB_PD_I2C_SLAVE_ADDR
+#define CONFIG_HOSTCMD_I2C_SLAVE_ADDR__7BF CONFIG_USB_PD_I2C_SLAVE_ADDR__7BF
#endif
#ifndef __ASSEMBLER__
diff --git a/board/scarlet/board.c b/board/scarlet/board.c
index 4e100b3ed7..061e2d62dc 100644
--- a/board/scarlet/board.c
+++ b/board/scarlet/board.c
@@ -127,7 +127,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
.port = I2C_PORT_TCPC0,
- .addr = FUSB302_I2C_SLAVE_ADDR,
+ .addr__7bf = FUSB302_I2C_SLAVE_ADDR__7bf,
},
.drv = &fusb302_tcpm_drv,
},
@@ -401,7 +401,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_base_mutex,
.drv_data = &g_bmi160_data,
.port = CONFIG_SPI_ACCEL_PORT,
- .addr = BMI160_SET_SPI_ADDRESS(CONFIG_SPI_ACCEL_PORT),
+ .i2c_spi_addr__7bf = SLAVE_MK_SPI_ADDR__7bf(CONFIG_SPI_ACCEL_PORT),
.rot_standard_ref = &base_standard_ref,
.default_range = 4, /* g */
.min_frequency = BMI160_ACCEL_MIN_FREQ,
@@ -424,7 +424,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_base_mutex,
.drv_data = &g_bmi160_data,
.port = CONFIG_SPI_ACCEL_PORT,
- .addr = BMI160_SET_SPI_ADDRESS(CONFIG_SPI_ACCEL_PORT),
+ .i2c_spi_addr__7bf = SLAVE_MK_SPI_ADDR__7bf(CONFIG_SPI_ACCEL_PORT),
.default_range = 1000, /* dps */
.rot_standard_ref = &base_standard_ref,
.min_frequency = BMI160_GYRO_MIN_FREQ,
diff --git a/board/scarlet/board.h b/board/scarlet/board.h
index 5cd82e573c..a9bc49fdc9 100644
--- a/board/scarlet/board.h
+++ b/board/scarlet/board.h
@@ -174,7 +174,7 @@
#define I2C_PORT_TCPC0 1
/* Route sbs host requests to virtual battery driver */
-#define VIRTUAL_BATTERY_ADDR 0x16
+#define VIRTUAL_BATTERY_ADDR__7bf 0x0B
/* Enable Accel over SPI */
#define CONFIG_SPI_ACCEL_PORT 0 /* The first SPI master port (SPI2) */
diff --git a/board/servo_micro/board.c b/board/servo_micro/board.c
index e717d6207b..b5384ba8ca 100644
--- a/board/servo_micro/board.c
+++ b/board/servo_micro/board.c
@@ -248,8 +248,8 @@ DECLARE_CONSOLE_COMMAND(baud, command_uart_baud,
* enable_ite_dfu stops working, or does not work on a new ITE EC chip revision.
*/
-#define ITE_DFU_I2C_CMD_ADDR 0xB4 /* 7 bit form is 0x5A */
-#define ITE_DFU_I2C_DATA_ADDR 0x6A /* 7 bit form is 0x35 */
+#define ITE_DFU_I2C_CMD_ADDR__7bf 0x5A
+#define ITE_DFU_I2C_DATA_ADDR__7bf 0x35
#define SMCLK_WAVEFORM_PERIOD_HZ (100 * KHz)
#define SMDAT_WAVEFORM_PERIOD_HZ (200 * KHz)
@@ -287,14 +287,17 @@ static int ite_i2c_read_register(uint8_t register_offset, uint8_t *output)
*/
int ret;
/* Tell the ITE EC which register we want to read. */
- ret = i2c_xfer_unlocked(I2C_PORT_MASTER, ITE_DFU_I2C_CMD_ADDR,
- &register_offset, sizeof(register_offset),
- NULL, 0, I2C_XFER_SINGLE);
+ ret = i2c_xfer_unlocked__7bf(I2C_PORT_MASTER,
+ ITE_DFU_I2C_CMD_ADDR__7bf,
+ &register_offset, sizeof(register_offset),
+ NULL, 0, I2C_XFER_SINGLE);
if (ret != EC_SUCCESS)
return ret;
/* Read in the 1 byte register value. */
- ret = i2c_xfer_unlocked(I2C_PORT_MASTER, ITE_DFU_I2C_DATA_ADDR, NULL, 0,
- output, sizeof(*output), I2C_XFER_SINGLE);
+ ret = i2c_xfer_unlocked__7bf(I2C_PORT_MASTER,
+ ITE_DFU_I2C_DATA_ADDR__7bf,
+ NULL, 0,
+ output, sizeof(*output), I2C_XFER_SINGLE);
return ret;
}
diff --git a/board/servo_v4/board.c b/board/servo_v4/board.c
index 405c90c7aa..b26d86abf6 100644
--- a/board/servo_v4/board.c
+++ b/board/servo_v4/board.c
@@ -211,7 +211,7 @@ int usb_i2c_board_is_enabled(void) { return 1; }
/*
* Support tca6416 I2C ioexpander.
*/
-#define GPIOX_I2C_ADDR 0x40
+#define GPIOX_I2C_ADDR__7bf 0x20
#define GPIOX_IN_PORT_A 0x0
#define GPIOX_IN_PORT_B 0x1
#define GPIOX_OUT_PORT_A 0x2
@@ -226,13 +226,13 @@ static void write_ioexpander(int bank, int gpio, int val)
int tmp;
/* Read output port register */
- i2c_read8(1, GPIOX_I2C_ADDR, GPIOX_OUT_PORT_A + bank, &tmp);
+ i2c_read8__7bf(1, GPIOX_I2C_ADDR__7bf, GPIOX_OUT_PORT_A + bank, &tmp);
if (val)
tmp |= BIT(gpio);
else
tmp &= ~BIT(gpio);
/* Write back modified output port register */
- i2c_write8(1, GPIOX_I2C_ADDR, GPIOX_OUT_PORT_A + bank, tmp);
+ i2c_write8__7bf(1, GPIOX_I2C_ADDR__7bf, GPIOX_OUT_PORT_A + bank, tmp);
}
/* Read a single GPIO input on the tca6416 I2C ioexpander. */
@@ -242,7 +242,7 @@ static int read_ioexpander_bit(int bank, int bit)
int mask = 1 << bit;
/* Read input port register */
- i2c_read8(1, GPIOX_I2C_ADDR, GPIOX_IN_PORT_A + bank, &tmp);
+ i2c_read8__7bf(1, GPIOX_I2C_ADDR__7bf, GPIOX_IN_PORT_A + bank, &tmp);
return (tmp & mask) >> bit;
}
@@ -271,15 +271,15 @@ static void init_usb3_port(void)
static void init_ioexpander(void)
{
/* Write all GPIO to output 0 */
- i2c_write8(1, GPIOX_I2C_ADDR, GPIOX_OUT_PORT_A, 0x0);
- i2c_write8(1, GPIOX_I2C_ADDR, GPIOX_OUT_PORT_B, 0x0);
+ i2c_write8__7bf(1, GPIOX_I2C_ADDR__7bf, GPIOX_OUT_PORT_A, 0x0);
+ i2c_write8__7bf(1, GPIOX_I2C_ADDR__7bf, GPIOX_OUT_PORT_B, 0x0);
/*
* Write GPIO direction: strap resistors to input,
* all others to output.
*/
- i2c_write8(1, GPIOX_I2C_ADDR, GPIOX_DIR_PORT_A, 0x0);
- i2c_write8(1, GPIOX_I2C_ADDR, GPIOX_DIR_PORT_B, 0x18);
+ i2c_write8__7bf(1, GPIOX_I2C_ADDR__7bf, GPIOX_DIR_PORT_A, 0x0);
+ i2c_write8__7bf(1, GPIOX_I2C_ADDR__7bf, GPIOX_DIR_PORT_B, 0x18);
}
/*
@@ -429,7 +429,7 @@ static void board_init(void)
* Write USB3 Mode to PS8742 USB/DP Mux.
* 0x0:disable 0x20:enable.
*/
- i2c_write8(1, 0x20, 0x0, 0x0);
+ i2c_write8__7bf(1, 0x10, 0x0, 0x0);
/* Enable uservo USB by default. */
init_ioexpander();
diff --git a/board/strago/board.c b/board/strago/board.c
index 45761a5a8a..8764c4a84b 100644
--- a/board/strago/board.c
+++ b/board/strago/board.c
@@ -110,7 +110,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
.port = I2C_PORT_TCPC,
- .addr = CONFIG_TCPC_I2C_BASE_ADDR,
+ .addr__7bf = CONFIG_TCPC_I2C_BASE_ADDR__7BF,
},
.drv = &tcpci_tcpm_drv,
},
@@ -141,7 +141,7 @@ BUILD_ASSERT(ARRAY_SIZE(pi3usb9281_chips) ==
struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_COUNT] = {
{
- .port_addr = 0xaa,
+ .port_addr = 0x55,
.driver = &pi3usb30532_usb_mux_driver,
},
};
@@ -213,7 +213,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_kxcj9_mutex[0],
.drv_data = &g_kxcj9_data[0],
.port = I2C_PORT_ACCEL,
- .addr = KXCJ9_ADDR1,
+ .i2c_spi_addr__7bf = KXCJ9_ADDR1__7bf,
.rot_standard_ref = &base_standard_ref,
.default_range = 2, /* g, enough for laptop. */
.min_frequency = KXCJ9_ACCEL_MIN_FREQ,
@@ -236,7 +236,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_kxcj9_mutex[1],
.drv_data = &g_kxcj9_data[1],
.port = I2C_PORT_ACCEL,
- .addr = KXCJ9_ADDR0,
+ .i2c_spi_addr__7bf = KXCJ9_ADDR0__7bf,
.rot_standard_ref = &lid_standard_ref,
.default_range = 2, /* g, enough for laptop. */
.min_frequency = KXCJ9_ACCEL_MIN_FREQ,
diff --git a/board/sweetberry/board.c b/board/sweetberry/board.c
index 66b21a81b9..943cb1c1ae 100644
--- a/board/sweetberry/board.c
+++ b/board/sweetberry/board.c
@@ -121,6 +121,6 @@ static void board_init(void)
uint8_t tmp;
/* i2c 0 has a tendancy to get wedged. TODO(nsanders): why? */
- i2c_xfer(0, 0, NULL, 0, &tmp, 1);
+ i2c_xfer__7bf(0, 0, NULL, 0, &tmp, 1);
}
DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT);
diff --git a/board/yorp/board.c b/board/yorp/board.c
index 65653ac168..409914c898 100644
--- a/board/yorp/board.c
+++ b/board/yorp/board.c
@@ -119,7 +119,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_lid_mutex,
.drv_data = &g_kx022_data,
.port = I2C_PORT_SENSOR,
- .addr = KX022_ADDR1,
+ .i2c_spi_addr__7bf = KX022_ADDR1__7bf,
.rot_standard_ref = NULL, /* Identity matrix. */
.default_range = 4, /* g */
.config = {
@@ -147,7 +147,7 @@ struct motion_sensor_t motion_sensors[] = {
.int_signal = GPIO_BASE_SIXAXIS_INT_L,
.flags = MOTIONSENSE_FLAG_INT_SIGNAL,
.port = I2C_PORT_SENSOR,
- .addr = LSM6DSM_ADDR0,
+ .i2c_spi_addr__7bf = LSM6DSM_ADDR0__7bf,
.rot_standard_ref = &base_standard_ref,
.default_range = 4, /* g */
.min_frequency = LSM6DSM_ODR_MIN_VAL,
@@ -179,7 +179,7 @@ struct motion_sensor_t motion_sensors[] = {
.int_signal = GPIO_BASE_SIXAXIS_INT_L,
.flags = MOTIONSENSE_FLAG_INT_SIGNAL,
.port = I2C_PORT_SENSOR,
- .addr = LSM6DSM_ADDR0,
+ .i2c_spi_addr__7bf = LSM6DSM_ADDR0__7bf,
.default_range = 1000 | ROUND_UP_FLAG, /* dps */
.rot_standard_ref = &base_standard_ref,
.min_frequency = LSM6DSM_ODR_MIN_VAL,
diff --git a/chip/g/i2cm.c b/chip/g/i2cm.c
index b1a3135723..a7b8f9ad7e 100644
--- a/chip/g/i2cm.c
+++ b/chip/g/i2cm.c
@@ -247,7 +247,7 @@ static int i2cm_poll_for_complete(int port)
return EC_ERROR_TIMEOUT;
}
-static uint32_t i2cm_create_inst(int slave_addr, int is_write,
+static uint32_t i2cm_create_inst__7bf(int slave_addr__7bf, int is_write,
size_t size, uint32_t flags)
{
uint32_t inst = 0;
@@ -258,12 +258,7 @@ static uint32_t i2cm_create_inst(int slave_addr, int is_write,
* to be included.
*/
inst |= INST_START;
-
- /*
- * Calls to chip_i2c_xfer assume an 8 bit slave address. Need
- * to shift right by 1 bit.
- */
- inst |= INST_DEVADDRVAL(slave_addr >> 1);
+ inst |= INST_DEVADDRVAL(I2C_GET_ADDR__7b(slave_addr__7bf));
inst |= INST_RWDEVADDR;
}
@@ -281,8 +276,9 @@ static uint32_t i2cm_create_inst(int slave_addr, int is_write,
return inst;
}
-static int i2cm_execute_sequence(int port, int slave_addr, const uint8_t *out,
- int out_size, uint8_t *in, int in_size,
+static int i2cm_execute_sequence__7bf(int port, int slave_addr__7bf,
+ const uint8_t *out, int out_size,
+ uint8_t *in, int in_size,
int flags)
{
int rv;
@@ -313,7 +309,7 @@ static int i2cm_execute_sequence(int port, int slave_addr, const uint8_t *out,
seq_flags &= ~I2C_XFER_STOP;
/* Build sequence instruction */
- inst = i2cm_create_inst(slave_addr, is_write,
+ inst = i2cm_create_inst__7bf(slave_addr__7bf, is_write,
batch_size, seq_flags);
/* If this is a write - copy data into the FIFO. */
@@ -357,7 +353,8 @@ static int i2cm_execute_sequence(int port, int slave_addr, const uint8_t *out,
/* Perform an i2c transaction. */
-int chip_i2c_xfer(int port, int slave_addr, const uint8_t *out, int out_size,
+int chip_i2c_xfer__7bf(const int port, const uint16_t slave_addr__7bf,
+ const uint8_t *out, int out_size,
uint8_t *in, int in_size, int flags)
{
int rv;
@@ -379,14 +376,14 @@ int chip_i2c_xfer(int port, int slave_addr, const uint8_t *out, int out_size,
if (out_size) {
/* Process write before read. */
- rv = i2cm_execute_sequence(port, slave_addr, out,
+ rv = i2cm_execute_sequence__7bf(port, slave_addr__7bf, out,
out_size, NULL, 0, flags);
if (rv != EC_SUCCESS)
return rv;
}
if (in_size)
- rv = i2cm_execute_sequence(port, slave_addr,
+ rv = i2cm_execute_sequence__7bf(port, slave_addr__7bf,
NULL, 0, in, in_size, flags);
return rv;
diff --git a/chip/host/i2c.c b/chip/host/i2c.c
index 72960c789d..af80926223 100644
--- a/chip/host/i2c.c
+++ b/chip/host/i2c.c
@@ -14,7 +14,7 @@
struct i2c_dev {
int port;
- int slave_addr;
+ uint16_t slave_addr__7bf;
int valid;
};
@@ -28,7 +28,7 @@ static void detach_init(void)
}
DECLARE_HOOK(HOOK_INIT, detach_init, HOOK_PRIO_FIRST);
-int test_detach_i2c(int port, int slave_addr)
+int test_detach_i2c__7bf(const int port, const uint16_t slave_addr__7bf)
{
int i;
@@ -40,20 +40,20 @@ int test_detach_i2c(int port, int slave_addr)
return EC_ERROR_OVERFLOW;
detached_devs[i].port = port;
- detached_devs[i].slave_addr = slave_addr;
+ detached_devs[i].slave_addr__7bf = slave_addr__7bf;
detached_devs[i].valid = 1;
return EC_SUCCESS;
}
-int test_attach_i2c(int port, int slave_addr)
+int test_attach_i2c__7bf(const int port, const uint16_t slave_addr__7bf)
{
int i;
for (i = 0; i < MAX_DETACHED_DEV_COUNT; ++i)
if (detached_devs[i].valid &&
detached_devs[i].port == port &&
- detached_devs[i].slave_addr == slave_addr)
+ detached_devs[i].slave_addr__7bf == slave_addr__7bf)
break;
if (i == MAX_DETACHED_DEV_COUNT)
@@ -63,28 +63,31 @@ int test_attach_i2c(int port, int slave_addr)
return EC_SUCCESS;
}
-static int test_check_detached(int port, int slave_addr)
+static int test_check_detached__7bf(const int port,
+ const uint16_t slave_addr__7bf)
{
int i;
for (i = 0; i < MAX_DETACHED_DEV_COUNT; ++i)
if (detached_devs[i].valid &&
detached_devs[i].port == port &&
- detached_devs[i].slave_addr == slave_addr)
+ detached_devs[i].slave_addr__7bf == slave_addr__7bf)
return 1;
return 0;
}
-int chip_i2c_xfer(int port, int slave_addr, const uint8_t *out, int out_size,
+int chip_i2c_xfer__7bf(const int port, const uint16_t slave_addr__7bf,
+ const uint8_t *out, int out_size,
uint8_t *in, int in_size, int flags)
{
const struct test_i2c_xfer *p;
int rv;
- if (test_check_detached(port, slave_addr))
+ if (test_check_detached__7bf(port, slave_addr__7bf))
return EC_ERROR_UNKNOWN;
for (p = __test_i2c_xfer; p < __test_i2c_xfer_end; ++p) {
- rv = p->routine(port, slave_addr, out, out_size,
+ rv = p->routine__7bf(port, slave_addr__7bf,
+ out, out_size,
in, in_size, flags);
if (rv != EC_ERROR_INVAL)
return rv;
diff --git a/chip/ish/i2c.c b/chip/ish/i2c.c
index 07da8638d2..fa3aca627a 100644
--- a/chip/ish/i2c.c
+++ b/chip/ish/i2c.c
@@ -150,22 +150,19 @@ static void i2c_intr_switch(uint32_t *base, int mode)
}
}
-static void i2c_init_transaction(struct i2c_context *ctx,
- uint8_t slave_addr, uint8_t flags)
+static void i2c_init_transaction__7b(struct i2c_context *ctx,
+ uint16_t slave_addr__7b, uint8_t flags)
{
uint32_t con_value;
uint32_t *base = ctx->base;
struct i2c_bus_info *bus_info = &board_config[ctx->bus];
uint32_t clk_in_val = clk_in[bus_freq[ctx->bus]];
- /* Convert 8-bit slave addrees to 7-bit for driver expectation*/
- slave_addr >>= 1;
-
/* disable interrupts */
i2c_intr_switch(base, DISABLE_INT);
i2c_mmio_write(base, IC_ENABLE, IC_ENABLE_DISABLE);
- i2c_mmio_write(base, IC_TAR, (slave_addr << IC_TAR_OFFSET) |
+ i2c_mmio_write(base, IC_TAR, (slave_addr__7b << IC_TAR_OFFSET) |
TAR_SPECIAL_VAL | IC_10BITADDR_MASTER_VAL);
/* set Clock SCL Count */
@@ -289,7 +286,8 @@ static void i2c_write_read_commands(uint32_t *base, uint8_t len, int more_data,
}
}
-int chip_i2c_xfer(int port, int slave_addr, const uint8_t *out, int out_size,
+int chip_i2c_xfer__7bf(const int port, const uint16_t slave_addr__7bf,
+ const uint8_t *out, int out_size,
uint8_t *in, int in_size, int flags)
{
int i;
@@ -297,7 +295,7 @@ int chip_i2c_xfer(int port, int slave_addr, const uint8_t *out, int out_size,
uint64_t expire_ts;
struct i2c_context *ctx;
ssize_t curr_index = 0;
-
+ uint16_t addr__7b = I2C_GET_ADDR__7b(slave_addr__7bf);
int begin_indx;
uint8_t repeat_start = 0;
@@ -311,7 +309,7 @@ int chip_i2c_xfer(int port, int slave_addr, const uint8_t *out, int out_size,
* Address cannot be any of the reserved address locations:
* 0x00 to 0x07 or 0x78 to 0x7f.
*/
- if (slave_addr <= 0x0F || (slave_addr >= 0xF0 && slave_addr <= 0xFF))
+ if (addr__7b <= 0x07 || (addr__7b >= 0x78 && addr__7b <= 0x7F))
return EC_ERROR_INVAL;
/* assume that if both out_size and in_size are not zero,
@@ -325,7 +323,7 @@ int chip_i2c_xfer(int port, int slave_addr, const uint8_t *out, int out_size,
total_len = in_size + out_size;
- i2c_init_transaction(ctx, slave_addr, repeat_start);
+ i2c_init_transaction__7b(ctx, addr__7b, repeat_start);
/* Write W data */
if (out_size)
diff --git a/chip/it83xx/i2c.c b/chip/it83xx/i2c.c
index 48d13d5fdd..6383b773d2 100644
--- a/chip/it83xx/i2c.c
+++ b/chip/it83xx/i2c.c
@@ -194,7 +194,7 @@ struct i2c_port_data {
int widx; /* Index into output data */
int ridx; /* Index into input data */
int err; /* Error code, if any */
- uint8_t addr; /* address of device */
+ uint8_t addr__8b; /* address of device */
uint32_t timeout_us; /* Transaction timeout, or 0 to use default */
uint8_t freq; /* Frequency setting */
@@ -274,7 +274,7 @@ static void i2c_w2r_change_direction(int p)
}
static void i2c_pio_trans_data(int p, enum enhanced_i2c_transfer_direct direct,
- uint8_t data, int first_byte)
+ uint8_t data, int first_byte)
{
struct i2c_port_data *pd = pdata + p;
int p_ch;
@@ -319,7 +319,7 @@ static int i2c_tran_write(int p)
* bit0, Direction of the host transfer.
* bit[1:7}, Address of the targeted slave.
*/
- IT83XX_SMB_TRASLA(p) = pd->addr;
+ IT83XX_SMB_TRASLA(p) = pd->addr__8b;
/* Send first byte */
IT83XX_SMB_HOBDB(p) = *(pd->out++);
pd->widx++;
@@ -379,7 +379,7 @@ static int i2c_tran_read(int p)
* bit0, Direction of the host transfer.
* bit[1:7}, Address of the targeted slave.
*/
- IT83XX_SMB_TRASLA(p) = pd->addr | 0x01;
+ IT83XX_SMB_TRASLA(p) = pd->addr__8b | 0x01;
/* clear start flag */
pd->flags &= ~I2C_XFER_START;
/*
@@ -468,7 +468,7 @@ static int enhanced_i2c_tran_write(int p)
pd->flags &= ~I2C_XFER_START;
enhanced_i2c_start(p);
/* Send ID */
- i2c_pio_trans_data(p, TX_DIRECT, pd->addr, 1);
+ i2c_pio_trans_data(p, TX_DIRECT, pd->addr__8b, 1);
} else {
/* Host has completed the transmission of a byte */
if (pd->widx < pd->out_size) {
@@ -488,7 +488,8 @@ static int enhanced_i2c_tran_write(int p)
/* Write to read protocol */
pd->i2ccs = I2C_CH_REPEAT_START;
/* Repeat Start */
- i2c_pio_trans_data(p, RX_DIRECT, pd->addr, 1);
+ i2c_pio_trans_data(p, RX_DIRECT,
+ pd->addr__8b, 1);
} else {
if (pd->flags & I2C_XFER_STOP) {
IT83XX_I2C_CTR(p_ch) = E_FINISH;
@@ -520,7 +521,7 @@ static int enhanced_i2c_tran_read(int p)
/* Direct read */
pd->i2ccs = I2C_CH_WAIT_READ;
/* Send ID */
- i2c_pio_trans_data(p, RX_DIRECT, pd->addr, 1);
+ i2c_pio_trans_data(p, RX_DIRECT, pd->addr__8b, 1);
} else {
if (pd->i2ccs) {
if (pd->i2ccs == I2C_CH_REPEAT_START) {
@@ -537,7 +538,8 @@ static int enhanced_i2c_tran_read(int p)
/* Write to read */
pd->i2ccs = I2C_CH_WAIT_READ;
/* Send ID */
- i2c_pio_trans_data(p, RX_DIRECT, pd->addr, 1);
+ i2c_pio_trans_data(p, RX_DIRECT,
+ pd->addr__8b, 1);
task_enable_irq(i2c_ctrl_regs[p].irq);
}
} else {
@@ -639,8 +641,9 @@ int i2c_is_busy(int port)
return (IT83XX_I2C_STR(p_ch) & E_HOSTA_BB);
}
-int chip_i2c_xfer(int port, int slave_addr, const uint8_t *out, int out_size,
- uint8_t *in, int in_size, int flags)
+int chip_i2c_xfer__7bf(int port, uint16_t slave_addr__7bf,
+ const uint8_t *out, int out_size,
+ uint8_t *in, int in_size, int flags)
{
struct i2c_port_data *pd = pdata + port;
uint32_t events = 0;
@@ -662,7 +665,7 @@ int chip_i2c_xfer(int port, int slave_addr, const uint8_t *out, int out_size,
pd->widx = 0;
pd->ridx = 0;
pd->err = 0;
- pd->addr = slave_addr;
+ pd->addr__8b = I2C_GET_ADDR__7b(slave_addr__7bf) << 1;
/* Make sure we're in a good state to start */
if ((flags & I2C_XFER_START) && (i2c_is_busy(port)
diff --git a/chip/lm4/i2c.c b/chip/lm4/i2c.c
index 6e88d9ee5b..f831997e68 100644
--- a/chip/lm4/i2c.c
+++ b/chip/lm4/i2c.c
@@ -165,7 +165,8 @@ int i2c_do_work(int port)
return 0;
}
-int chip_i2c_xfer(int port, int slave_addr, const uint8_t *out, int out_size,
+int chip_i2c_xfer__7bf(const int port, const uint16_t slave_addr__7bf,
+ const uint8_t *out, int out_size,
uint8_t *in, int in_size, int flags)
{
struct i2c_port_data *pd = pdata + port;
@@ -191,11 +192,11 @@ int chip_i2c_xfer(int port, int slave_addr, const uint8_t *out, int out_size,
uint32_t tpr = LM4_I2C_MTPR(port);
CPRINTS("I2C%d Addr:%02X bad status 0x%02x, SCL=%d, SDA=%d",
- port,
- slave_addr,
- reg_mcs,
- i2c_get_line_levels(port) & I2C_LINE_SCL_HIGH,
- i2c_get_line_levels(port) & I2C_LINE_SDA_HIGH);
+ port,
+ I2C_GET_ADDR__7b(slave_addr__7bf),
+ reg_mcs,
+ i2c_get_line_levels(port) & I2C_LINE_SCL_HIGH,
+ i2c_get_line_levels(port) & I2C_LINE_SDA_HIGH);
/* Attempt to unwedge the port. */
i2c_unwedge(port);
@@ -218,7 +219,7 @@ int chip_i2c_xfer(int port, int slave_addr, const uint8_t *out, int out_size,
}
/* Set slave address for transmit */
- LM4_I2C_MSA(port) = slave_addr & 0xff;
+ LM4_I2C_MSA(port) = (I2C_GET_ADDR__7b(slave_addr__7bf) << 1) & 0xff;
/* Enable interrupts */
pd->task_waiting = task_get_current();
diff --git a/chip/mchp/i2c.c b/chip/mchp/i2c.c
index 489d374195..96a0914a4b 100644
--- a/chip/mchp/i2c.c
+++ b/chip/mchp/i2c.c
@@ -132,7 +132,7 @@ static struct {
uint32_t i2c_complete; /* ISR write */
uint32_t flags;
uint8_t port;
- uint8_t slv_addr;
+ uint8_t slv_addr__8b;
uint8_t ctrl;
uint8_t hwsts;
uint8_t hwsts2;
@@ -545,7 +545,7 @@ static int i2c_mtx(int ctrl)
cdata[ctrl].flags |= (1ul << 1);
if (cdata[ctrl].xflags & I2C_XFER_START) {
cdata[ctrl].flags |= (1ul << 2);
- MCHP_I2C_DATA(ctrl) = cdata[ctrl].slv_addr;
+ MCHP_I2C_DATA(ctrl) = cdata[ctrl].slv_addr__8b;
/* Clock out the slave address, sending START bit */
MCHP_I2C_CTRL(ctrl) = CTRL_PIN | CTRL_ESO | CTRL_ENI |
CTRL_ACK | CTRL_STA;
@@ -629,7 +629,7 @@ static int i2c_mrx_start(int ctrl)
/* Repeated-START then address */
MCHP_I2C_CTRL(ctrl) = u8;
}
- MCHP_I2C_DATA(ctrl) = cdata[ctrl].slv_addr | 0x01;
+ MCHP_I2C_DATA(ctrl) = cdata[ctrl].slv_addr__8b | 0x01;
if (cdata[ctrl].transaction_state == I2C_TRANSACTION_STOPPED) {
cdata[ctrl].flags |= (1ul << 6);
/* address then START */
@@ -716,8 +716,9 @@ static int i2c_mrx_data(int ctrl)
/*
* Called from common/i2c_master
*/
-int chip_i2c_xfer(int port, int slave_addr, const uint8_t *out,
- int out_size, uint8_t *in, int in_size, int flags)
+int chip_i2c_xfer__7bf(int port, uint16_t slave_addr__7bf,
+ const uint8_t *out, int out_size,
+ uint8_t *in, int in_size, int flags)
{
int ctrl;
int ret_done;
@@ -739,8 +740,8 @@ int chip_i2c_xfer(int port, int slave_addr, const uint8_t *out,
cdata[ctrl].hwsts2 = 0;
cdata[ctrl].hwsts3 = 0;
cdata[ctrl].hwsts4 = 0;
- cdata[ctrl].port = (uint8_t)(port & 0xff);
- cdata[ctrl].slv_addr = (uint8_t)(slave_addr & 0xff);
+ cdata[ctrl].port = port & 0xff;
+ cdata[ctrl].slv_addr__8b = I2C_GET_ADDR__7b(slave_addr__7bf) << 1;
cdata[ctrl].out_size = out_size;
cdata[ctrl].outp = out;
cdata[ctrl].in_size = in_size;
diff --git a/chip/mec1322/i2c.c b/chip/mec1322/i2c.c
index d5c3692b3f..4920070432 100644
--- a/chip/mec1322/i2c.c
+++ b/chip/mec1322/i2c.c
@@ -236,7 +236,9 @@ static inline void push_in_buf(uint8_t **in, uint8_t val, int skip)
}
}
-int chip_i2c_xfer(int port, int slave_addr, const uint8_t *out, int out_size,
+int chip_i2c_xfer__7bf(const int port,
+ const uint16_t slave_addr__7bf,
+ const uint8_t *out, int out_size,
uint8_t *in, int in_size, int flags)
{
int i;
@@ -284,7 +286,9 @@ int chip_i2c_xfer(int port, int slave_addr, const uint8_t *out, int out_size,
if (out_size) {
if (send_start) {
- MEC1322_I2C_DATA(controller) = (uint8_t)slave_addr;
+ MEC1322_I2C_DATA(controller) =
+ (uint8_t)(I2C_GET_ADDR__7b(slave_addr__7bf)
+ << 1);
/* Clock out the slave address, sending START bit */
MEC1322_I2C_CTRL(controller) = CTRL_PIN | CTRL_ESO |
@@ -327,8 +331,10 @@ int chip_i2c_xfer(int port, int slave_addr, const uint8_t *out, int out_size,
CTRL_ACK |
CTRL_ENI;
- MEC1322_I2C_DATA(controller) = (uint8_t)slave_addr
- | 0x01;
+ MEC1322_I2C_DATA(controller) =
+ (uint8_t)(I2C_GET_ADDR__7b(slave_addr__7bf)
+ << 1)
+ | 0x01;
/* New transaction case, clock out slave address. */
if (cdata[controller].transaction_state ==
diff --git a/chip/npcx/i2c.c b/chip/npcx/i2c.c
index 0b99f24270..23023abf1d 100644
--- a/chip/npcx/i2c.c
+++ b/chip/npcx/i2c.c
@@ -84,7 +84,7 @@ struct i2c_status {
uint16_t sz_txbuf; /* Size of Tx buffer in bytes */
uint16_t sz_rxbuf; /* Size of rx buffer in bytes */
uint16_t idx_buf; /* Current index of Tx/Rx buffer */
- uint8_t slave_addr;/* Target slave address */
+ uint8_t slave_addr__7bf;/* Target slave address */
enum smb_oper_state_t oper_state;/* Smbus operation state */
enum smb_error err_code; /* Error code */
int task_waiting; /* Task waiting on controller */
@@ -344,10 +344,10 @@ void i2c_done(int controller)
static void i2c_handle_sda_irq(int controller)
{
volatile struct i2c_status *p_status = i2c_stsobjs + controller;
+ uint8_t addr__8b = I2C_GET_ADDR__7b(p_status->slave_addr__7bf) << 1;
/* 1 Issue Start is successful ie. write address byte */
if (p_status->oper_state == SMB_MASTER_START
|| p_status->oper_state == SMB_REPEAT_START) {
- uint8_t addr = p_status->slave_addr;
/* Prepare address byte */
if (p_status->sz_txbuf == 0) {/* Receive mode */
p_status->oper_state = SMB_READ_OPER;
@@ -360,12 +360,12 @@ static void i2c_handle_sda_irq(int controller)
I2C_STALL(controller);
/* Write the address to the bus R bit*/
- I2C_WRITE_BYTE(controller, (addr | 0x1));
+ I2C_WRITE_BYTE(controller, (addr__8b | 0x1));
CPRINTS("-ARR-0x%02x", addr);
} else {/* Transmit mode */
p_status->oper_state = SMB_WRITE_OPER;
/* Write the address to the bus W bit*/
- I2C_WRITE_BYTE(controller, addr);
+ I2C_WRITE_BYTE(controller, addr__8b);
CPRINTS("-ARW-0x%02x", addr);
}
/* Completed handling START condition */
@@ -380,7 +380,6 @@ static void i2c_handle_sda_irq(int controller)
i2c_done(controller);
/* need to restart & send slave address immediately */
else {
- uint8_t addr_byte = p_status->slave_addr;
/*
* Prepare address byte
* and start to receive bytes
@@ -405,7 +404,8 @@ static void i2c_handle_sda_irq(int controller)
CPUTS("-GNA");
}
/* Write the address to the bus R bit*/
- I2C_WRITE_BYTE(controller, (addr_byte | 0x1));
+ I2C_WRITE_BYTE(controller,
+ (addr__8b | 0x1));
CPUTS("-ARR");
}
}
@@ -609,7 +609,9 @@ void i2c_set_timeout(int port, uint32_t timeout)
timeout ? timeout : I2C_TIMEOUT_DEFAULT_US;
}
-int chip_i2c_xfer(int port, int slave_addr, const uint8_t *out, int out_size,
+int chip_i2c_xfer__7bf(const int port,
+ const uint16_t slave_addr__7bf,
+ const uint8_t *out, int out_size,
uint8_t *in, int in_size, int flags)
{
volatile struct i2c_status *p_status;
@@ -637,13 +639,8 @@ int chip_i2c_xfer(int port, int slave_addr, const uint8_t *out, int out_size,
p_status->sz_txbuf = out_size;
p_status->rx_buf = in;
p_status->sz_rxbuf = in_size;
-#if I2C_7BITS_ADDR
- /* Set slave address from 7-bits to 8-bits */
- p_status->slave_addr = (slave_addr<<1);
-#else
- /* Set slave address (8-bits) */
- p_status->slave_addr = slave_addr;
-#endif
+ p_status->slave_addr__7bf = slave_addr__7bf;
+
/* Reset index & error */
p_status->idx_buf = 0;
p_status->err_code = SMB_OK;
diff --git a/chip/nrf51/i2c.c b/chip/nrf51/i2c.c
index 440506511b..7f4903ee1b 100644
--- a/chip/nrf51/i2c.c
+++ b/chip/nrf51/i2c.c
@@ -141,13 +141,13 @@ static void handle_i2c_error(int port, int rv)
i2c_recover(port);
}
-static int i2c_master_write(int port, int slave_addr, const uint8_t *data,
- int size, int stop)
+static int i2c_master_write__7bf(const int port, const uint16_t slave_addr__7bf,
+ const uint8_t *data, int size, int stop)
{
int bytes_sent;
int timeout = I2C_TIMEOUT;
- NRF51_TWI_ADDRESS(port) = slave_addr >> 1;
+ NRF51_TWI_ADDRESS__7b(port) = I2C_GET_ADDR__7b(slave_addr__7bf);
/* Clear the sent bit */
NRF51_TWI_TXDSENT(port) = 0;
@@ -187,12 +187,13 @@ static int i2c_master_write(int port, int slave_addr, const uint8_t *data,
return EC_SUCCESS;
}
-static int i2c_master_read(int port, int slave_addr, uint8_t *data, int size)
+static int i2c_master_read__7bf(const int port, const uint16_t slave__addr__7bf,
+ uint8_t *data, int size)
{
int curr_byte;
int timeout = I2C_TIMEOUT;
- NRF51_TWI_ADDRESS(port) = slave_addr >> 1;
+ NRF51_TWI_ADDRESS__7b(port) = I2C_GET_ADDR__7b(slave_addr__7bf);
if (size == 1) /* Last byte: stop after this one. */
NRF51_PPI_TEP(i2c_ppi_chan[port]) =
@@ -252,7 +253,8 @@ static int i2c_master_read(int port, int slave_addr, uint8_t *data, int size)
return EC_SUCCESS;
}
-int chip_i2c_xfer(int port, int slave_addr, const uint8_t *out, int out_bytes,
+int chip_i2c_xfer__7bf(const int port, const uint16_t slave_addr__7bf,
+ const uint8_t *out, int out_bytes,
uint8_t *in, int in_bytes, int flags)
{
int rv = EC_SUCCESS;
@@ -261,10 +263,12 @@ int chip_i2c_xfer(int port, int slave_addr, const uint8_t *out, int out_bytes,
ASSERT(in || !in_bytes);
if (out_bytes)
- rv = i2c_master_write(port, slave_addr, out, out_bytes,
- in_bytes ? 0 : 1);
+ rv = i2c_master_write__7bf(port, slave_addr__7bf,
+ out, out_bytes,
+ in_bytes ? 0 : 1);
if (rv == EC_SUCCESS && in_bytes)
- rv = i2c_master_read(port, slave_addr, in, in_bytes);
+ rv = i2c_master_read__7bf(port, slave_addr__7bf,
+ in, in_bytes);
handle_i2c_error(port, rv);
diff --git a/chip/stm32/i2c-stm32f0.c b/chip/stm32/i2c-stm32f0.c
index 9a63fbaf5b..e2aa3f8af9 100644
--- a/chip/stm32/i2c-stm32f0.c
+++ b/chip/stm32/i2c-stm32f0.c
@@ -27,7 +27,7 @@
/* Transmit timeout in microseconds */
#define I2C_TX_TIMEOUT_MASTER (10 * MSEC)
-#ifdef CONFIG_HOSTCMD_I2C_SLAVE_ADDR
+#ifdef CONFIG_HOSTCMD_I2C_SLAVE_ADDR__7BF
#if (I2C_PORT_EC == STM32_I2C1_PORT)
#define IRQ_SLAVE STM32_IRQ_I2C1
#else
@@ -146,7 +146,7 @@ static void i2c_init_port(const struct i2c_port_t *p)
STM32_RCC_APB1ENR |= 1 << (21 + port);
if (port == STM32_I2C1_PORT) {
-#if defined(CONFIG_HOSTCMD_I2C_SLAVE_ADDR) && \
+#if defined(CONFIG_HOSTCMD_I2C_SLAVE_ADDR__7BF) && \
defined(CONFIG_LOW_POWER_IDLE) && \
(I2C_PORT_EC == STM32_I2C1_PORT)
/*
@@ -189,7 +189,7 @@ defined(CONFIG_LOW_POWER_IDLE) && \
}
/*****************************************************************************/
-#ifdef CONFIG_HOSTCMD_I2C_SLAVE_ADDR
+#ifdef CONFIG_HOSTCMD_I2C_SLAVE_ADDR__7BF
/* Host command slave */
/*
* Buffer for received host command packets (including prefix byte on request,
@@ -426,9 +426,11 @@ DECLARE_IRQ(IRQ_SLAVE, i2c2_event_interrupt, 2);
/*****************************************************************************/
/* Interface */
-int chip_i2c_xfer(int port, int slave_addr, const uint8_t *out, int out_bytes,
+int chip_i2c_xfer__7bf(const int port, const uint16_t slave_addr__7bf,
+ const uint8_t *out, int out_bytes,
uint8_t *in, int in_bytes, int flags)
{
+ int addr__8b = I2C_GET_ADDR__7b(slave_addr__7bf) << 1;
int rv = EC_SUCCESS;
int i;
int xfer_start = flags & I2C_XFER_START;
@@ -436,7 +438,7 @@ int chip_i2c_xfer(int port, int slave_addr, const uint8_t *out, int out_bytes,
#if defined(CONFIG_I2C_SCL_GATE_ADDR) && defined(CONFIG_I2C_SCL_GATE_PORT)
if (port == CONFIG_I2C_SCL_GATE_PORT &&
- slave_addr == CONFIG_I2C_SCL_GATE_ADDR)
+ slave_addr__7bf == CONFIG_I2C_SCL_GATE_ADDR__7BF)
gpio_set_level(CONFIG_I2C_SCL_GATE_GPIO, 1);
#endif
@@ -457,7 +459,7 @@ int chip_i2c_xfer(int port, int slave_addr, const uint8_t *out, int out_bytes,
* NBYTES again. if we are starting, then set START bit.
*/
STM32_I2C_CR2(port) = ((out_bytes & 0xFF) << 16)
- | slave_addr
+ | addr__8b
| ((in_bytes == 0 && xfer_stop) ?
STM32_I2C_CR2_AUTOEND : 0)
| ((in_bytes == 0 && !xfer_stop) ?
@@ -486,7 +488,7 @@ int chip_i2c_xfer(int port, int slave_addr, const uint8_t *out, int out_bytes,
* set START bit to send (re)start and begin read transaction.
*/
STM32_I2C_CR2(port) = ((in_bytes & 0xFF) << 16)
- | STM32_I2C_CR2_RD_WRN | slave_addr
+ | STM32_I2C_CR2_RD_WRN | addr__8b
| (xfer_stop ? STM32_I2C_CR2_AUTOEND : 0)
| (!xfer_stop ? STM32_I2C_CR2_RELOAD : 0)
| (out_bytes || xfer_start ? STM32_I2C_CR2_START : 0);
@@ -543,7 +545,7 @@ xfer_exit:
#ifdef CONFIG_I2C_SCL_GATE_ADDR
if (port == CONFIG_I2C_SCL_GATE_PORT &&
- slave_addr == CONFIG_I2C_SCL_GATE_ADDR)
+ slave_addr__7bf == CONFIG_I2C_SCL_GATE_ADDR__7BF)
gpio_set_level(CONFIG_I2C_SCL_GATE_GPIO, 0);
#endif
@@ -586,7 +588,7 @@ static void i2c_init(void)
for (i = 0; i < i2c_ports_used; i++, p++)
i2c_init_port(p);
-#ifdef CONFIG_HOSTCMD_I2C_SLAVE_ADDR
+#ifdef CONFIG_HOSTCMD_I2C_SLAVE_ADDR__7BF
STM32_I2C_CR1(I2C_PORT_EC) |= STM32_I2C_CR1_RXIE | STM32_I2C_CR1_ERRIE
| STM32_I2C_CR1_ADDRIE | STM32_I2C_CR1_STOPIE
| STM32_I2C_CR1_NACKIE;
@@ -598,13 +600,15 @@ static void i2c_init(void)
*/
STM32_I2C_CR1(I2C_PORT_EC) |= STM32_I2C_CR1_WUPEN;
#endif
- STM32_I2C_OAR1(I2C_PORT_EC) = 0x8000 | CONFIG_HOSTCMD_I2C_SLAVE_ADDR;
+ STM32_I2C_OAR1(I2C_PORT_EC) = 0x8000
+ | (I2C_GET_ADDR__7b(CONFIG_HOSTCMD_I2C_SLAVE_ADDR__7BF) << 1);
#ifdef TCPCI_I2C_SLAVE
/*
* Configure TCPC address with OA2[1] masked so that we respond
* to CONFIG_TCPC_I2C_BASE_ADDR and CONFIG_TCPC_I2C_BASE_ADDR + 2.
*/
- STM32_I2C_OAR2(I2C_PORT_EC) = 0x8100 | CONFIG_TCPC_I2C_BASE_ADDR;
+ STM32_I2C_OAR2(I2C_PORT_EC) = 0x8100
+ | (I2C_GET_ADDR__7b(CONFIG_TCPC_I2C_BASE_ADDR__7BF) << 1);
#endif
task_enable_irq(IRQ_SLAVE);
#endif
diff --git a/chip/stm32/i2c-stm32f4.c b/chip/stm32/i2c-stm32f4.c
index ee6460936c..6b774e829b 100644
--- a/chip/stm32/i2c-stm32f4.c
+++ b/chip/stm32/i2c-stm32f4.c
@@ -25,7 +25,7 @@
/* Transmit timeout in microseconds */
#define I2C_TX_TIMEOUT_MASTER (10 * MSEC)
-#ifdef CONFIG_HOSTCMD_I2C_SLAVE_ADDR
+#ifdef CONFIG_HOSTCMD_I2C_SLAVE_ADDR__7BF
#if (I2C_PORT_EC == STM32_I2C1_PORT)
#define IRQ_SLAVE_EV STM32_IRQ_I2C1_EV
#define IRQ_SLAVE_ER STM32_IRQ_I2C1_ER
@@ -171,7 +171,7 @@ static int wait_sr1(int port, int mask)
*
* @return Non-zero if error.
*/
-static int send_start(int port, int slave_addr)
+static int send_start__8b(const int port, const uint16_t slave_addr__8b)
{
int rv;
@@ -182,7 +182,7 @@ static int send_start(int port, int slave_addr)
return I2C_ERROR_FAILED_START;
/* Write slave address */
- STM32_I2C_DR(port) = slave_addr & 0xff;
+ STM32_I2C_DR(port) = slave_addr__8b;
rv = wait_sr1_poll(port, STM32_I2C_SR1_ADDR, SET, 1);
if (rv)
return rv;
@@ -263,7 +263,8 @@ static int wait_fmpi2c_isr(int port, int mask)
*
* @return Non-zero if error.
*/
-static int send_fmpi2c_start(int port, int slave_addr, int size, int is_read)
+static int send_fmpi2c_start__8b(const int port, const uint16_t slave_addr__8b,
+ int size, int is_read)
{
uint32_t reg;
@@ -273,7 +274,7 @@ static int send_fmpi2c_start(int port, int slave_addr, int size, int is_read)
FMPI2C_CR2_RELOAD | FMPI2C_CR2_AUTOEND |
FMPI2C_CR2_RD_WRN | FMPI2C_CR2_START | FMPI2C_CR2_STOP);
reg |= FMPI2C_CR2_START | FMPI2C_CR2_AUTOEND |
- FMPI2C_CR2_SADD(slave_addr) | FMPI2C_CR2_SIZE(size) |
+ slave_addr__8b | FMPI2C_CR2_SIZE(size) |
(is_read ? FMPI2C_CR2_RD_WRN : 0);
STM32_FMPI2C_CR2(port) = reg;
@@ -400,8 +401,9 @@ static void fmpi2c_clear_regs(int port)
*
* @return EC_SUCCESS on success.
*/
-static int chip_fmpi2c_xfer(int port, int slave_addr, const uint8_t *out,
- int out_bytes, uint8_t *in, int in_bytes, int flags)
+static int chip_fmpi2c_xfer__8b(const int port, const uint16_t slave_addr__8b,
+ const uint8_t *out, int out_bytes,
+ uint8_t *in, int in_bytes, int flags)
{
int started = (flags & I2C_XFER_START) ? 0 : 1;
int rv = EC_SUCCESS;
@@ -420,8 +422,8 @@ static int chip_fmpi2c_xfer(int port, int slave_addr, const uint8_t *out,
/* No out bytes and no in bytes means just check for active */
if (out_bytes || !in_bytes) {
- rv = send_fmpi2c_start(
- port, slave_addr, out_bytes, FMPI2C_WRITE);
+ rv = send_fmpi2c_start__8b(
+ port, slave_addr__8b, out_bytes, FMPI2C_WRITE);
if (rv)
goto xfer_exit;
@@ -446,8 +448,8 @@ static int chip_fmpi2c_xfer(int port, int slave_addr, const uint8_t *out,
dma_start_rx(dma, in_bytes, in);
i2c_dma_enable_tc_interrupt(dma->channel, port);
- rv_start = send_fmpi2c_start(
- port, slave_addr, in_bytes, FMPI2C_READ);
+ rv_start = send_fmpi2c_start__8b(
+ port, slave_addr__8b, in_bytes, FMPI2C_READ);
if (rv_start)
goto xfer_exit;
@@ -551,9 +553,11 @@ static void i2c_clear_regs(int port)
*/
/* Perform an i2c transaction. */
-int chip_i2c_xfer(int port, int slave_addr, const uint8_t *out, int out_bytes,
+int chip_i2c_xfer__7bf(const int port, const uint16_t slave_addr__7bf,
+ const uint8_t *out, int out_bytes,
uint8_t *in, int in_bytes, int flags)
{
+ int addr__8b = I2C_GET_ADDR__7b(slave_addr__7bf) << 1;
int started = (flags & I2C_XFER_START) ? 0 : 1;
int rv = EC_SUCCESS;
int i;
@@ -564,15 +568,16 @@ int chip_i2c_xfer(int port, int slave_addr, const uint8_t *out, int out_bytes,
ASSERT(!started);
if (p->port == STM32F4_FMPI2C_PORT) {
- return chip_fmpi2c_xfer(port, slave_addr, out, out_bytes,
- in, in_bytes, flags);
+ return chip_fmpi2c_xfer__8b(port, addr__8b,
+ out, out_bytes,
+ in, in_bytes, flags);
}
i2c_clear_regs(port);
/* No out bytes and no in bytes means just check for active */
if (out_bytes || !in_bytes) {
- rv = send_start(port, slave_addr);
+ rv = send_start__8b(port, addr__8b);
if (rv)
goto xfer_exit;
@@ -611,7 +616,7 @@ int chip_i2c_xfer(int port, int slave_addr, const uint8_t *out, int out_bytes,
STM32_I2C_CR2(port) |= STM32_I2C_CR2_LAST;
STM32_I2C_CR2(port) |= STM32_I2C_CR2_DMAEN;
- rv_start = send_start(port, slave_addr | 0x01);
+ rv_start = send_start__8b(port, addr__8b | 0x01);
if ((in_bytes == 1) && (flags & I2C_XFER_STOP))
STM32_I2C_CR1(port) |= STM32_I2C_CR1_STOP;
@@ -755,7 +760,7 @@ DECLARE_HOOK(HOOK_FREQ_CHANGE, i2c_freq_change_hook, HOOK_PRIO_DEFAULT);
/*****************************************************************************/
/* Slave */
-#ifdef CONFIG_HOSTCMD_I2C_SLAVE_ADDR
+#ifdef CONFIG_HOSTCMD_I2C_SLAVE_ADDR__7BF
/* Host command slave */
/*
* Buffer for received host command packets (including prefix byte on request,
@@ -834,7 +839,7 @@ static void i2c_process_command(void)
host_packet_receive(&i2c_packet);
}
-#ifdef CONFIG_BOARD_I2C_SLAVE_ADDR
+#ifdef CONFIG_BOARD_I2C_SLAVE_ADDR__7BF
static void i2c_send_board_response(int len)
{
/* host_buffer data range, beyond this length, will return 0xec */
@@ -858,7 +863,7 @@ static void i2c_event_handler(int port)
volatile uint32_t i2c_sr2;
volatile uint32_t i2c_sr1;
static int rx_pending, buf_idx;
- static uint16_t addr;
+ static uint16_t addr__8b;
volatile uint32_t dummy __attribute__((unused));
@@ -883,15 +888,15 @@ static void i2c_event_handler(int port)
/* Transfer matched our slave address */
if (i2c_sr1 & STM32_I2C_SR1_ADDR) {
- addr = ((i2c_sr2 & STM32_I2C_SR2_DUALF) ?
+ addr__8b = ((i2c_sr2 & STM32_I2C_SR2_DUALF) ?
STM32_I2C_OAR2(port) : STM32_I2C_OAR1(port)) & 0xfe;
if (i2c_sr2 & STM32_I2C_SR2_TRA) {
/* Transmitter slave */
i2c_sr1 |= STM32_I2C_SR1_TXE;
-#ifdef CONFIG_BOARD_I2C_SLAVE_ADDR
+#ifdef CONFIG_BOARD_I2C_SLAVE_ADDR__7BF
if (!rx_pending && !tx_pending) {
tx_pending = 1;
- i2c_process_board_command(1, addr, 0);
+ i2c_process_board_command(1, addr__8b, 0);
}
#endif
} else {
@@ -926,9 +931,11 @@ static void i2c_event_handler(int port)
host_i2c_resp_port = port;
/* Disable buffer interrupt */
STM32_I2C_CR2(port) &= ~STM32_I2C_CR2_ITBUFEN;
-#ifdef CONFIG_BOARD_I2C_SLAVE_ADDR
- if (addr == CONFIG_BOARD_I2C_SLAVE_ADDR)
- i2c_process_board_command(1, addr,
+#ifdef CONFIG_BOARD_I2C_SLAVE_ADDR__7BF
+ if ((addr__8b >> 1) ==
+ I2C_GET_ADDR__7b(
+ CONFIG_BOARD_I2C_SLAVE_ADDR__7BF))
+ i2c_process_board_command(1, addr__8b,
buf_idx);
else
#endif
@@ -950,9 +957,11 @@ static void i2c_event_handler(int port)
/* Disable buffer interrupt */
STM32_I2C_CR2(port) &= ~STM32_I2C_CR2_ITBUFEN;
-#ifdef CONFIG_BOARD_I2C_SLAVE_ADDR
- if (rx_pending && addr == CONFIG_BOARD_I2C_SLAVE_ADDR)
- i2c_process_board_command(0, addr, buf_idx);
+#ifdef CONFIG_BOARD_I2C_SLAVE_ADDR__7BF
+ if (rx_pending &&
+ (addr__8b >> 1) ==
+ I2C_GET_ADDR__7b(CONFIG_BOARD_I2C_SLAVE_ADDR__7BF))
+ i2c_process_board_command(0, addr__8b, buf_idx);
#endif
rx_pending = 0;
tx_pending = 0;
@@ -987,7 +996,7 @@ static void i2c_init(void)
i2c_init_port(p);
-#ifdef CONFIG_HOSTCMD_I2C_SLAVE_ADDR
+#ifdef CONFIG_HOSTCMD_I2C_SLAVE_ADDR__7BF
/* Enable ACK */
STM32_I2C_CR1(I2C_PORT_EC) |= STM32_I2C_CR1_ACK;
/* Enable interrupts */
@@ -995,10 +1004,10 @@ static void i2c_init(void)
| STM32_I2C_CR2_ITERREN;
/* Setup host command slave */
STM32_I2C_OAR1(I2C_PORT_EC) = STM32_I2C_OAR1_B14
- | CONFIG_HOSTCMD_I2C_SLAVE_ADDR;
-#ifdef CONFIG_BOARD_I2C_SLAVE_ADDR
+ | (I2C_GET_ADDR__7b(CONFIG_HOSTCMD_I2C_SLAVE_ADDR__7BF) << 1);
+#ifdef CONFIG_BOARD_I2C_SLAVE_ADDR__7BF
STM32_I2C_OAR2(I2C_PORT_EC) = STM32_I2C_OAR2_ENDUAL
- | CONFIG_BOARD_I2C_SLAVE_ADDR;
+ | (I2C_GET_ADDR__7b(CONFIG_BOARD_I2C_SLAVE_ADDR__7BF) << 1);
#endif
task_enable_irq(IRQ_SLAVE_EV);
task_enable_irq(IRQ_SLAVE_ER);
diff --git a/chip/stm32/i2c-stm32l.c b/chip/stm32/i2c-stm32l.c
index 42fe3513a9..d56d78d8eb 100644
--- a/chip/stm32/i2c-stm32l.c
+++ b/chip/stm32/i2c-stm32l.c
@@ -98,7 +98,7 @@ static int wait_sr1(int port, int mask)
*
* @return Non-zero if error.
*/
-static int send_start(int port, int slave_addr)
+static int send_start__8b(int port, uint16_t slave_addr__8b)
{
int rv;
@@ -110,7 +110,7 @@ static int send_start(int port, int slave_addr)
return I2C_ERROR_FAILED_START;
/* Write slave address */
- STM32_I2C_DR(port) = slave_addr & 0xff;
+ STM32_I2C_DR(port) = slave_addr__8b & 0xff;
rv = wait_sr1(port, STM32_I2C_SR1_ADDR);
if (rv)
return rv;
@@ -164,9 +164,12 @@ static void i2c_init_port(const struct i2c_port_t *p)
/*****************************************************************************/
/* Interface */
-int chip_i2c_xfer(int port, int slave_addr, const uint8_t *out, int out_bytes,
+int chip_i2c_xfer__7bf(const int port,
+ const uint16_t slave_addr__7bf,
+ const uint8_t *out, int out_bytes,
uint8_t *in, int in_bytes, int flags)
{
+ int addr__8b == I2C_GET_ADDR__7b(slave_addr__7bf) << 1;
int started = (flags & I2C_XFER_START) ? 0 : 1;
int rv = EC_SUCCESS;
int i;
@@ -193,7 +196,7 @@ int chip_i2c_xfer(int port, int slave_addr, const uint8_t *out, int out_bytes,
/* No out bytes and no in bytes means just check for active */
if (out_bytes || !in_bytes) {
if (!started) {
- rv = send_start(port, slave_addr);
+ rv = send_start__8b(port, addr__8b);
if (rv)
goto xfer_exit;
}
@@ -225,7 +228,7 @@ int chip_i2c_xfer(int port, int slave_addr, const uint8_t *out, int out_bytes,
STM32_I2C_CR1(port) |= STM32_I2C_CR1_ACK;
if (!started) {
- rv = send_start(port, slave_addr | 0x01);
+ rv = send_start__8b(port, addr__8b | 0x01);
if (rv)
goto xfer_exit;
}
diff --git a/chip/stm32/i2c-stm32l4.c b/chip/stm32/i2c-stm32l4.c
index 06836dd547..e263394880 100644
--- a/chip/stm32/i2c-stm32l4.c
+++ b/chip/stm32/i2c-stm32l4.c
@@ -26,7 +26,7 @@
/* Transmit timeout in microseconds */
#define I2C_TX_TIMEOUT_MASTER (10 * MSEC)
-#ifdef CONFIG_HOSTCMD_I2C_SLAVE_ADDR
+#ifdef CONFIG_HOSTCMD_I2C_SLAVE_ADDR__7BF
#define I2C_SLAVE_ERROR_CODE 0xec
#if (I2C_PORT_EC == STM32_I2C1_PORT)
#define IRQ_SLAVE STM32_IRQ_I2C1
@@ -177,7 +177,7 @@ static void i2c_init_port(const struct i2c_port_t *p)
/*****************************************************************************/
-#ifdef CONFIG_HOSTCMD_I2C_SLAVE_ADDR
+#ifdef CONFIG_HOSTCMD_I2C_SLAVE_ADDR__7BF
static void i2c_event_handler(int port)
{
@@ -303,9 +303,11 @@ DECLARE_IRQ(IRQ_SLAVE, i2c_event_interrupt, 2);
/*****************************************************************************/
/* Interface */
-int chip_i2c_xfer(int port, int slave_addr, const uint8_t *out, int out_bytes,
+int chip_i2c_xfer__7bf(const int port, const uint16_t slave_addr__7bf,
+ const uint8_t *out, int out_bytes,
uint8_t *in, int in_bytes, int flags)
{
+ int addr__8b = I2C_GET_ADDR__7b(slave_addr__7bf) << 1;
int rv = EC_SUCCESS;
int i;
int xfer_start = flags & I2C_XFER_START;
@@ -328,7 +330,7 @@ int chip_i2c_xfer(int port, int slave_addr, const uint8_t *out, int out_bytes,
* NBYTES again. if we are starting, then set START bit.
*/
STM32_I2C_CR2(port) = ((out_bytes & 0xFF) << 16)
- | slave_addr
+ | addr__8b
| ((in_bytes == 0 && xfer_stop) ?
STM32_I2C_CR2_AUTOEND : 0)
| ((in_bytes == 0 && !xfer_stop) ?
@@ -357,7 +359,7 @@ int chip_i2c_xfer(int port, int slave_addr, const uint8_t *out, int out_bytes,
* set START bit to send (re)start and begin read transaction.
*/
STM32_I2C_CR2(port) = ((in_bytes & 0xFF) << 16)
- | STM32_I2C_CR2_RD_WRN | slave_addr
+ | STM32_I2C_CR2_RD_WRN | addr__8b
| (xfer_stop ? STM32_I2C_CR2_AUTOEND : 0)
| (!xfer_stop ? STM32_I2C_CR2_RELOAD : 0)
| (out_bytes || xfer_start ? STM32_I2C_CR2_START : 0);
@@ -451,11 +453,12 @@ static void i2c_init(void)
for (i = 0; i < i2c_ports_used; i++, p++)
i2c_init_port(p);
-#ifdef CONFIG_HOSTCMD_I2C_SLAVE_ADDR
+#ifdef CONFIG_HOSTCMD_I2C_SLAVE_ADDR__7BF
STM32_I2C_CR1(I2C_PORT_EC) |= STM32_I2C_CR1_RXIE | STM32_I2C_CR1_ERRIE
| STM32_I2C_CR1_ADDRIE | STM32_I2C_CR1_STOPIE
| STM32_I2C_CR1_NACKIE;
- STM32_I2C_OAR1(I2C_PORT_EC) = 0x8000 | CONFIG_HOSTCMD_I2C_SLAVE_ADDR;
+ STM32_I2C_OAR1(I2C_PORT_EC) = 0x8000
+ | (I2C_GET_ADDR__7b(CONFIG_HOSTCMD_I2C_SLAVE_ADDR__7BF) << 1);
task_enable_irq(IRQ_SLAVE);
#endif
}
diff --git a/chip/stm32/usb_power.c b/chip/stm32/usb_power.c
index 7e4206e83b..4cf8bac99e 100644
--- a/chip/stm32/usb_power.c
+++ b/chip/stm32/usb_power.c
@@ -249,7 +249,7 @@ static int usb_power_state_addina(struct usb_power_config const *config,
ina = state->ina_cfg + state->ina_count;
ina->port = cmd->addina.port;
- ina->addr = (cmd->addina.addr) << 1; /* 7 to 8 bit addr. */
+ ina->addr__7bf = cmd->addina.addr__7bf;
ina->rs = cmd->addina.rs;
ina->type = cmd->addina.type;
@@ -270,7 +270,7 @@ static int usb_power_state_addina(struct usb_power_config const *config,
struct usb_power_ina_cfg *tmp = state->ina_cfg + i;
if ((tmp->port == ina->port) &&
- (tmp->addr == ina->addr)) {
+ (tmp->addr__7bf == ina->addr__7bf)) {
ina->shared = 1;
tmp->shared = 1;
}
@@ -406,42 +406,46 @@ int reg_type_mapping(enum usb_power_ina_type ina_type)
}
}
-uint16_t ina2xx_readagain(uint8_t port, uint8_t addr)
+uint16_t ina2xx_readagain__7bf(uint8_t port, uint16_t slave_addr__7bf)
{
int res;
uint16_t val;
- res = i2c_xfer(port, addr, NULL, 0, (uint8_t *)&val, sizeof(uint16_t));
+ res = i2c_xfer__7bf(port, slave_addr__7bf,
+ NULL, 0, (uint8_t *)&val, sizeof(uint16_t));
if (res) {
CPRINTS("INA2XX I2C readagain failed p:%d a:%02x",
- (int)port, (int)addr);
+ (int)port, (int)I2C_GET_ADDR__7b(slave_addr__7bf));
return 0x0bad;
}
return (val >> 8) | ((val & 0xff) << 8);
}
-uint16_t ina2xx_read(uint8_t port, uint8_t addr, uint8_t reg)
+uint16_t ina2xx_read__7bf(uint8_t port, uint16_t slave_addr__7bf,
+ uint8_t reg)
{
int res;
int val;
- res = i2c_read16(port, addr, reg, &val);
+ res = i2c_read16__7bf(port, slave_addr__7bf, reg, &val);
if (res) {
CPRINTS("INA2XX I2C read failed p:%d a:%02x, r:%02x",
- (int)port, (int)addr, (int)reg);
+ (int)port, (int)I2C_GET_ADDR__7b(slave_addr__7bf),
+ (int)reg);
return 0x0bad;
}
return (val >> 8) | ((val & 0xff) << 8);
}
-int ina2xx_write(uint8_t port, uint8_t addr, uint8_t reg, uint16_t val)
+int ina2xx_write__7bf(uint8_t port, uint16_t slave_addr__7bf,
+ uint8_t reg, uint16_t val)
{
int res;
uint16_t be_val = (val >> 8) | ((val & 0xff) << 8);
- res = i2c_write16(port, addr, reg, be_val);
+ res = i2c_write16__7bf(port, slave_addr__7bf, reg, be_val);
if (res)
CPRINTS("INA2XX I2C write failed");
return res;
@@ -505,10 +509,13 @@ static int usb_power_init_inas(struct usb_power_config const *config)
{
int conf, cal;
- conf = ina2xx_read(ina->port, ina->addr, INA231_REG_CONF);
- cal = ina2xx_read(ina->port, ina->addr, INA231_REG_CAL);
+ conf = ina2xx_read__7bf(ina->port, ina->addr__7bf,
+ INA231_REG_CONF);
+ cal = ina2xx_read__7bf(ina->port, ina->addr__7bf,
+ INA231_REG_CAL);
CPRINTS("[CAP] %d (%d,0x%02x): conf:%x, cal:%x",
- i, ina->port, ina->addr, conf, cal);
+ i, ina->port, I2C_GET_ADDR__7b(ina->addr__7bf),
+ conf, cal);
}
#endif
/*
@@ -529,7 +536,8 @@ static int usb_power_init_inas(struct usb_power_config const *config)
if (ina->scale == 0)
return -1;
value = (5120000 * 100) / (ina->scale * ina->rs);
- ret = ina2xx_write(ina->port, ina->addr, INA231_REG_CAL, value);
+ ret = ina2xx_write__7bf(ina->port, ina->addr__7bf,
+ INA231_REG_CAL, value);
if (ret != EC_SUCCESS) {
CPRINTS("[CAP] usb_power_init_inas CAL FAIL: %d", ret);
return ret;
@@ -538,7 +546,8 @@ static int usb_power_init_inas(struct usb_power_config const *config)
{
int actual;
- actual = ina2xx_read(ina->port, ina->addr, INA231_REG_CAL);
+ actual = ina2xx_read__7bf(ina->port, ina->addr__7bf,
+ INA231_REG_CAL);
CPRINTS("[CAP] scale: %d uA/div, %d uW/div, cal:%x act:%x",
ina->scale / 100, ina->scale*25/100, value, actual);
}
@@ -548,8 +557,8 @@ static int usb_power_init_inas(struct usb_power_config const *config)
INA231_CONF_SHUNT_TIME(shunt_time) |
INA231_CONF_BUS_TIME(shunt_time) |
INA231_CONF_AVG(avg);
- ret = ina2xx_write(
- ina->port, ina->addr, INA231_REG_CONF, value);
+ ret = ina2xx_write__7bf(ina->port, ina->addr__7bf,
+ INA231_REG_CONF, value);
if (ret != EC_SUCCESS) {
CPRINTS("[CAP] usb_power_init_inas CONF FAIL: %d", ret);
return ret;
@@ -558,26 +567,31 @@ static int usb_power_init_inas(struct usb_power_config const *config)
{
int actual;
- actual = ina2xx_read(ina->port, ina->addr, INA231_REG_CONF);
+ actual = ina2xx_read__7bf(ina->port, ina->addr__7bf,
+ INA231_REG_CONF);
CPRINTS("[CAP] %d (%d,0x%02x): conf:%x, act:%x",
- i, ina->port, ina->addr, value, actual);
+ i, ina->port, I2C_GET_ADDR__7b(ina->addr__7bf),
+ value, actual);
}
#endif
#ifdef USB_POWER_VERBOSE
{
int busv_mv =
- (ina2xx_read(ina->port, ina->addr, INA231_REG_BUSV)
+ (ina2xx_read__7bf(ina->port, ina->addr__7bf,
+ INA231_REG_BUSV)
* 125) / 100;
CPRINTS("[CAP] %d (%d,0x%02x): busv:%dmv",
- i, ina->port, ina->addr, busv_mv);
+ i, ina->port, I2C_GET_ADDR__7b(ina->addr__7bf),
+ busv_mv);
}
#endif
/* Initialize read from power register. This register address
* will be cached and all ina2xx_readagain() calls will read
* from the same address.
*/
- ina2xx_read(ina->port, ina->addr, reg_type_mapping(ina->type));
+ ina2xx_read__7bf(ina->port, ina->addr__7bf,
+ reg_type_mapping(ina->type));
#ifdef USB_POWER_VERBOSE
CPRINTS("[CAP] %d (%d,0x%02x): type:%d", (int)(ina->type));
#endif
@@ -635,10 +649,11 @@ static int usb_power_get_samples(struct usb_power_config const *config)
* transaction.
*/
if (ina->shared)
- regval = ina2xx_read(ina->port, ina->addr,
+ regval = ina2xx_read__7bf(ina->port, ina->addr__7bf,
reg_type_mapping(ina->type));
else
- regval = ina2xx_readagain(ina->port, ina->addr);
+ regval = ina2xx_readagain__7bf(ina->port,
+ ina->addr__7bf);
r->power[i] = regval;
#ifdef USB_POWER_VERBOSE
{
@@ -647,10 +662,14 @@ static int usb_power_get_samples(struct usb_power_config const *config)
int voltage;
int bvoltage;
- voltage = ina2xx_read(ina->port, ina->addr, INA231_REG_RSHV);
- bvoltage = ina2xx_read(ina->port, ina->addr, INA231_REG_BUSV);
- current = ina2xx_read(ina->port, ina->addr, INA231_REG_CURR);
- power = ina2xx_read(ina->port, ina->addr, INA231_REG_PWR);
+ voltage = ina2xx_read__7bf(ina->port, ina->addr__7bf,
+ INA231_REG_RSHV);
+ bvoltage = ina2xx_read__7bf(ina->port, ina->addr__7bf,
+ INA231_REG_BUSV);
+ current = ina2xx_read__7bf(ina->port, ina->addr__7bf,
+ INA231_REG_CURR);
+ power = ina2xx_read__7bf(ina->port, ina->addr__7bf,
+ INA231_REG_PWR);
{
int uV = ((int)voltage * 25) / 10;
int mV = ((int)bvoltage * 125) / 100;
@@ -659,7 +678,8 @@ static int usb_power_get_samples(struct usb_power_config const *config)
int uW = (((int)power * ina->scale*25)/100);
CPRINTS("[CAP] %d (%d,0x%02x): %dmV / %dmO = %dmA",
- i, ina->port, ina->addr, uV/1000, ina->rs, uA/1000);
+ i, ina->port, I2C_GET_ADDR__7b(ina->addr__7bf),
+ uV/1000, ina->rs, uA/1000);
CPRINTS("[CAP] %duV %dmV %duA %dCuA "
"%duW v:%04x, b:%04x, p:%04x",
uV, mV, uA, CuA, uW, voltage, bvoltage, power);
diff --git a/chip/stm32/usb_power.h b/chip/stm32/usb_power.h
index ff76603e63..f2f1426691 100644
--- a/chip/stm32/usb_power.h
+++ b/chip/stm32/usb_power.h
@@ -138,7 +138,7 @@ struct usb_power_ina_cfg {
/* i2c bus. TODO(nsanders): specify what kind of index. */
int port;
/* 7-bit i2c addr */
- int addr;
+ uint16_t addr__7bf;
/* Base voltage. mV */
int mv;
@@ -243,7 +243,7 @@ struct __attribute__ ((__packed__)) usb_power_command_addina {
uint16_t command;
uint8_t port;
uint8_t type;
- uint8_t addr;
+ uint16_t addr__7bf;
uint8_t extra;
uint32_t rs;
};
diff --git a/common/cbi.c b/common/cbi.c
index d8feee3189..69c3298d42 100644
--- a/common/cbi.c
+++ b/common/cbi.c
@@ -88,8 +88,8 @@ static struct cbi_header * const head = (struct cbi_header *)cbi;
static int read_eeprom(uint8_t offset, uint8_t *in, int in_size)
{
- return i2c_read_block(I2C_PORT_EEPROM, I2C_ADDR_EEPROM, offset,
- in, in_size);
+ return i2c_read_block__7bf(I2C_PORT_EEPROM, I2C_ADDR_EEPROM__7bf,
+ offset, in, in_size);
}
/*
@@ -244,8 +244,8 @@ static int write_board_info(void)
while (rest > 0) {
int size = MIN(EEPROM_PAGE_WRITE_SIZE, rest);
int rv;
- rv = i2c_write_block(I2C_PORT_EEPROM, I2C_ADDR_EEPROM,
- p - cbi, p, size);
+ rv = i2c_write_block__7bf(I2C_PORT_EEPROM, I2C_ADDR_EEPROM__7bf,
+ p - cbi, p, size);
if (rv) {
CPRINTS("Failed to write for %d", rv);
return rv;
diff --git a/common/host_command_master.c b/common/host_command_master.c
index 3786ecc235..57223f2346 100644
--- a/common/host_command_master.c
+++ b/common/host_command_master.c
@@ -81,9 +81,10 @@ static int pd_host_command_internal(int command, int version,
*/
i2c_lock(I2C_PORT_PD_MCU, 1);
i2c_set_timeout(I2C_PORT_PD_MCU, PD_HOST_COMMAND_TIMEOUT_US);
- ret = i2c_xfer_unlocked(I2C_PORT_PD_MCU, CONFIG_USB_PD_I2C_SLAVE_ADDR,
- &req_buf[0], outsize + sizeof(rq) + 1, &resp_buf[0],
- 2, I2C_XFER_START);
+ ret = i2c_xfer_unlocked__7bf(I2C_PORT_PD_MCU,
+ CONFIG_USB_PD_I2C_SLAVE_ADDR__7BF,
+ &req_buf[0], outsize + sizeof(rq) + 1,
+ &resp_buf[0], 2, I2C_XFER_START);
i2c_set_timeout(I2C_PORT_PD_MCU, 0);
if (ret) {
i2c_lock(I2C_PORT_PD_MCU, 0);
@@ -95,8 +96,9 @@ static int pd_host_command_internal(int command, int version,
if (resp_len > (insize + sizeof(rs))) {
/* Do a dummy read to generate stop condition */
- i2c_xfer_unlocked(I2C_PORT_PD_MCU, CONFIG_USB_PD_I2C_SLAVE_ADDR,
- 0, 0, &resp_buf[2], 1, I2C_XFER_STOP);
+ i2c_xfer_unlocked__7bf(I2C_PORT_PD_MCU,
+ CONFIG_USB_PD_I2C_SLAVE_ADDR__7BF,
+ 0, 0, &resp_buf[2], 1, I2C_XFER_STOP);
i2c_lock(I2C_PORT_PD_MCU, 0);
CPRINTS("response size is too large %d > %d",
resp_len, insize + sizeof(rs));
@@ -104,9 +106,10 @@ static int pd_host_command_internal(int command, int version,
}
/* Receive remaining data */
- ret = i2c_xfer_unlocked(I2C_PORT_PD_MCU, CONFIG_USB_PD_I2C_SLAVE_ADDR,
- 0, 0,
- &resp_buf[2], resp_len, I2C_XFER_STOP);
+ ret = i2c_xfer_unlocked__7bf(I2C_PORT_PD_MCU,
+ CONFIG_USB_PD_I2C_SLAVE_ADDR__7BF,
+ 0, 0,
+ &resp_buf[2], resp_len, I2C_XFER_STOP);
i2c_lock(I2C_PORT_PD_MCU, 0);
if (ret) {
CPRINTS("i2c transaction 2 failed: %d", ret);
diff --git a/common/i2c_master.c b/common/i2c_master.c
index 2efd6e9450..bfb9e01c3c 100644
--- a/common/i2c_master.c
+++ b/common/i2c_master.c
@@ -57,7 +57,7 @@ static int i2c_port_is_locked(int port)
}
-const struct i2c_port_t *get_i2c_port(int port)
+const struct i2c_port_t *get_i2c_port(const int port)
{
int i;
@@ -70,26 +70,29 @@ const struct i2c_port_t *get_i2c_port(int port)
return NULL;
}
-static int chip_i2c_xfer_with_notify(int port, int slave_addr,
+static int chip_i2c_xfer_with_notify__7bf(const int port,
+ const uint16_t slave_addr__7bf,
const uint8_t *out, int out_size,
uint8_t *in, int in_size, int flags)
{
int ret;
if (IS_ENABLED(CONFIG_I2C_DEBUG))
- i2c_trace_notify(port, slave_addr, 0, out, out_size);
+ i2c_trace_notify__7bf(port, slave_addr__7bf,
+ 0, out, out_size);
if (IS_ENABLED(CONFIG_I2C_XFER_BOARD_CALLBACK))
- i2c_start_xfer_notify(port, slave_addr);
+ i2c_start_xfer_notify__7bf(port, slave_addr__7bf);
- ret = chip_i2c_xfer(port, slave_addr, out, out_size, in, in_size,
- flags);
+ ret = chip_i2c_xfer__7bf(port, slave_addr__7bf,
+ out, out_size, in, in_size, flags);
if (IS_ENABLED(CONFIG_I2C_XFER_BOARD_CALLBACK))
- i2c_end_xfer_notify(port, slave_addr);
+ i2c_end_xfer_notify__7bf(port, slave_addr__7bf);
if (IS_ENABLED(CONFIG_I2C_DEBUG))
- i2c_trace_notify(port, slave_addr, 1, in, in_size);
+ i2c_trace_notify__7bf(port, slave_addr__7bf,
+ 1, in, in_size);
return ret;
}
@@ -99,8 +102,10 @@ static int chip_i2c_xfer_with_notify(int port, int slave_addr,
* Internal function that splits reading into multiple chip_i2c_xfer() calls
* if in_size exceeds CONFIG_I2C_CHIP_MAX_READ_SIZE.
*/
-static int i2c_xfer_no_retry(int port, int slave_addr, const uint8_t *out,
- int out_size, uint8_t *in, int in_size, int flags)
+static int i2c_xfer_no_retry__7bf(const int port,
+ const uint16_t slave_addr__7bf,
+ const uint8_t *out, int out_size,
+ uint8_t *in, int in_size, int flags)
{
int ret;
int out_flags = flags & I2C_XFER_START;
@@ -108,13 +113,15 @@ static int i2c_xfer_no_retry(int port, int slave_addr, const uint8_t *out,
in_size -= in_chunk_size;
out_flags |= !in_size ? (flags & I2C_XFER_STOP) : 0;
- ret = chip_i2c_xfer_with_notify(port, slave_addr, out, out_size, in,
+ ret = chip_i2c_xfer_with_notify__7bf(port, slave_addr__7bf,
+ out, out_size, in,
in_chunk_size, out_flags);
in += in_chunk_size;
while (in_size && ret == EC_SUCCESS) {
in_chunk_size = MIN(in_size, CONFIG_I2C_CHIP_MAX_READ_SIZE);
in_size -= in_chunk_size;
- ret = chip_i2c_xfer_with_notify(port, slave_addr, NULL, 0, in,
+ ret = chip_i2c_xfer_with_notify__7bf(port, slave_addr__7bf,
+ NULL, 0, in,
in_chunk_size, !in_size ? (flags & I2C_XFER_STOP) : 0);
in += in_chunk_size;
}
@@ -122,7 +129,8 @@ static int i2c_xfer_no_retry(int port, int slave_addr, const uint8_t *out,
}
#endif /* CONFIG_I2C_XFER_LARGE_READ */
-int i2c_xfer_unlocked(int port, int slave_addr,
+int i2c_xfer_unlocked__7bf(const int port,
+ const uint16_t slave_addr__7bf,
const uint8_t *out, int out_size,
uint8_t *in, int in_size, int flags)
{
@@ -136,11 +144,13 @@ int i2c_xfer_unlocked(int port, int slave_addr,
for (i = 0; i <= CONFIG_I2C_NACK_RETRY_COUNT; i++) {
#ifdef CONFIG_I2C_XFER_LARGE_READ
- ret = i2c_xfer_no_retry(port, slave_addr, out, out_size, in,
- in_size, flags);
+ ret = i2c_xfer_no_retry__7bf(port, slave_addr__7bf,
+ out, out_size, in,
+ in_size, flags);
#else
- ret = chip_i2c_xfer_with_notify(port, slave_addr, out, out_size,
- in, in_size, flags);
+ ret = chip_i2c_xfer_with_notify__7bf(port, slave_addr__7bf,
+ out, out_size,
+ in, in_size, flags);
#endif /* CONFIG_I2C_XFER_LARGE_READ */
if (ret != EC_ERROR_BUSY)
break;
@@ -148,14 +158,17 @@ int i2c_xfer_unlocked(int port, int slave_addr,
return ret;
}
-int i2c_xfer(int port, int slave_addr, const uint8_t *out, int out_size,
+int i2c_xfer__7bf(const int port,
+ const uint16_t slave_addr__7bf,
+ const uint8_t *out, int out_size,
uint8_t *in, int in_size)
{
int rv;
i2c_lock(port, 1);
- rv = i2c_xfer_unlocked(port, slave_addr, out, out_size, in, in_size,
- I2C_XFER_SINGLE);
+ rv = i2c_xfer_unlocked__7bf(port, slave_addr__7bf,
+ out, out_size, in, in_size,
+ I2C_XFER_SINGLE);
i2c_lock(port, 0);
return rv;
@@ -204,19 +217,22 @@ void i2c_prepare_sysjump(void)
mutex_lock(port_mutex + i);
}
-int i2c_read32(int port, int slave_addr, int offset, int *data)
+int i2c_read32__7bf(const int port,
+ const uint16_t slave_addr__7bf,
+ int offset, int *data)
{
int rv;
uint8_t reg, buf[sizeof(uint32_t)];
reg = offset & 0xff;
/* I2C read 32-bit word: transmit 8-bit offset, and read 32bits */
- rv = i2c_xfer(port, slave_addr, &reg, 1, buf, sizeof(uint32_t));
+ rv = i2c_xfer__7bf(port, slave_addr__7bf,
+ &reg, 1, buf, sizeof(uint32_t));
if (rv)
return rv;
- if (slave_addr & I2C_FLAG_BIG_ENDIAN)
+ if (I2C_IS_BIG_ENDIAN(slave_addr__7bf))
*data = ((int)buf[0] << 24) | ((int)buf[1] << 16) |
((int)buf[0] << 8) | buf[1];
else
@@ -226,13 +242,15 @@ int i2c_read32(int port, int slave_addr, int offset, int *data)
return EC_SUCCESS;
}
-int i2c_write32(int port, int slave_addr, int offset, int data)
+int i2c_write32__7bf(const int port,
+ const uint16_t slave_addr__7bf,
+ int offset, int data)
{
uint8_t buf[1 + sizeof(uint32_t)];
buf[0] = offset & 0xff;
- if (slave_addr & I2C_FLAG_BIG_ENDIAN) {
+ if (I2C_IS_BIG_ENDIAN(slave_addr__7bf)) {
buf[1] = (data >> 24) & 0xff;
buf[2] = (data >> 16) & 0xff;
buf[3] = (data >> 8) & 0xff;
@@ -244,23 +262,26 @@ int i2c_write32(int port, int slave_addr, int offset, int data)
buf[4] = (data >> 24) & 0xff;
}
- return i2c_xfer(port, slave_addr, buf, sizeof(uint32_t) + 1,
- NULL, 0);
+ return i2c_xfer__7bf(port, slave_addr__7bf,
+ buf, sizeof(uint32_t) + 1, NULL, 0);
}
-int i2c_read16(int port, int slave_addr, int offset, int *data)
+int i2c_read16__7bf(const int port,
+ const uint16_t slave_addr__7bf,
+ int offset, int *data)
{
int rv;
uint8_t reg, buf[sizeof(uint16_t)];
reg = offset & 0xff;
/* I2C read 16-bit word: transmit 8-bit offset, and read 16bits */
- rv = i2c_xfer(port, slave_addr, &reg, 1, buf, sizeof(uint16_t));
+ rv = i2c_xfer__7bf(port, slave_addr__7bf,
+ &reg, 1, buf, sizeof(uint16_t));
if (rv)
return rv;
- if (slave_addr & I2C_FLAG_BIG_ENDIAN)
+ if (I2C_IS_BIG_ENDIAN(slave_addr__7bf))
*data = ((int)buf[0] << 8) | buf[1];
else
*data = ((int)buf[1] << 8) | buf[0];
@@ -268,13 +289,15 @@ int i2c_read16(int port, int slave_addr, int offset, int *data)
return EC_SUCCESS;
}
-int i2c_write16(int port, int slave_addr, int offset, int data)
+int i2c_write16__7bf(const int port,
+ const uint16_t slave_addr__7bf,
+ int offset, int data)
{
uint8_t buf[1 + sizeof(uint16_t)];
buf[0] = offset & 0xff;
- if (slave_addr & I2C_FLAG_BIG_ENDIAN) {
+ if (I2C_IS_BIG_ENDIAN(slave_addr__7bf)) {
buf[1] = (data >> 8) & 0xff;
buf[2] = data & 0xff;
} else {
@@ -282,10 +305,13 @@ int i2c_write16(int port, int slave_addr, int offset, int data)
buf[2] = (data >> 8) & 0xff;
}
- return i2c_xfer(port, slave_addr, buf, 1 + sizeof(uint16_t), NULL, 0);
+ return i2c_xfer__7bf(port, slave_addr__7bf,
+ buf, 1 + sizeof(uint16_t), NULL, 0);
}
-int i2c_read8(int port, int slave_addr, int offset, int *data)
+int i2c_read8__7bf(const int port,
+ const uint16_t slave_addr__7bf,
+ int offset, int *data)
{
int rv;
uint8_t reg = offset;
@@ -293,25 +319,28 @@ int i2c_read8(int port, int slave_addr, int offset, int *data)
reg = offset;
- rv = i2c_xfer(port, slave_addr, &reg, 1, &buf, 1);
+ rv = i2c_xfer__7bf(port, slave_addr__7bf, &reg, 1, &buf, 1);
if (!rv)
*data = buf;
return rv;
}
-int i2c_write8(int port, int slave_addr, int offset, int data)
+int i2c_write8__7bf(const int port,
+ const uint16_t slave_addr__7bf,
+ int offset, int data)
{
uint8_t buf[2];
buf[0] = offset;
buf[1] = data;
- return i2c_xfer(port, slave_addr, buf, 2, 0, 0);
+ return i2c_xfer__7bf(port, slave_addr__7bf, buf, 2, 0, 0);
}
-int i2c_read_offset16(int port, int slave_addr, uint16_t offset, int *data,
- int len)
+int i2c_read_offset16__7bf(const int port,
+ const uint16_t slave_addr__7bf,
+ uint16_t offset, int *data, int len)
{
int rv;
uint8_t buf[sizeof(uint16_t)], addr[sizeof(uint16_t)];
@@ -323,7 +352,7 @@ int i2c_read_offset16(int port, int slave_addr, uint16_t offset, int *data,
addr[1] = offset & 0xff;
/* I2C read 16-bit word: transmit 16-bit offset, and read buffer */
- rv = i2c_xfer(port, slave_addr, addr, 2, buf, len);
+ rv = i2c_xfer__7bf(port, slave_addr__7bf, addr, 2, buf, len);
if (rv)
return rv;
@@ -331,7 +360,7 @@ int i2c_read_offset16(int port, int slave_addr, uint16_t offset, int *data,
if (len == 1) {
*data = buf[0];
} else {
- if (slave_addr & I2C_FLAG_BIG_ENDIAN)
+ if (I2C_IS_BIG_ENDIAN(slave_addr__7bf))
*data = ((int)buf[0] << 8) | buf[1];
else
*data = ((int)buf[1] << 8) | buf[0];
@@ -340,8 +369,9 @@ int i2c_read_offset16(int port, int slave_addr, uint16_t offset, int *data,
return EC_SUCCESS;
}
-int i2c_write_offset16(int port, int slave_addr, uint16_t offset, int data,
- int len)
+int i2c_write_offset16__7bf(const int port,
+ const uint16_t slave_addr__7bf,
+ uint16_t offset, int data, int len)
{
uint8_t buf[2 + sizeof(uint16_t)];
@@ -354,7 +384,7 @@ int i2c_write_offset16(int port, int slave_addr, uint16_t offset, int data,
if (len == 1) {
buf[2] = data & 0xff;
} else {
- if (slave_addr & I2C_FLAG_BIG_ENDIAN) {
+ if (I2C_IS_BIG_ENDIAN(slave_addr__7bf)) {
buf[2] = (data >> 8) & 0xff;
buf[3] = data & 0xff;
} else {
@@ -363,22 +393,24 @@ int i2c_write_offset16(int port, int slave_addr, uint16_t offset, int data,
}
}
- return i2c_xfer(port, slave_addr, buf, 2 + len, NULL, 0);
+ return i2c_xfer__7bf(port, slave_addr__7bf, buf, 2 + len, NULL, 0);
}
-int i2c_read_offset16_block(int port, int slave_addr, uint16_t offset,
- uint8_t *data, int len)
+int i2c_read_offset16_block__7bf(const int port,
+ const uint16_t slave_addr__7bf,
+ uint16_t offset, uint8_t *data, int len)
{
uint8_t addr[sizeof(uint16_t)];
addr[0] = (offset >> 8) & 0xff;
addr[1] = offset & 0xff;
- return i2c_xfer(port, slave_addr, addr, 2, data, len);
+ return i2c_xfer__7bf(port, slave_addr__7bf, addr, 2, data, len);
}
-int i2c_write_offset16_block(int port, int slave_addr, uint16_t offset,
- const uint8_t *data, int len)
+int i2c_write_offset16_block__7bf(const int port,
+ const uint16_t slave_addr__7bf,
+ uint16_t offset, const uint8_t *data, int len)
{
int rv;
uint8_t addr[sizeof(uint16_t)];
@@ -391,18 +423,19 @@ int i2c_write_offset16_block(int port, int slave_addr, uint16_t offset,
* appending the destination address with the data array.
*/
i2c_lock(port, 1);
- rv = i2c_xfer_unlocked(port, slave_addr, addr, 2, NULL, 0,
+ rv = i2c_xfer_unlocked__7bf(port, slave_addr__7bf, addr, 2, NULL, 0,
I2C_XFER_START);
if (!rv)
- rv = i2c_xfer_unlocked(port, slave_addr, data, len, NULL, 0,
- I2C_XFER_STOP);
+ rv = i2c_xfer_unlocked__7bf(port, slave_addr__7bf,
+ data, len, NULL, 0, I2C_XFER_STOP);
i2c_lock(port, 0);
return rv;
}
-int i2c_read_string(int port, int slave_addr, int offset, uint8_t *data,
- int len)
+int i2c_read_string__7bf(const int port,
+ const uint16_t slave_addr__7bf,
+ int offset, uint8_t *data, int len)
{
int rv;
uint8_t reg, block_length;
@@ -414,16 +447,16 @@ int i2c_read_string(int port, int slave_addr, int offset, uint8_t *data,
* Send device reg space offset, and read back block length. Keep this
* session open without a stop.
*/
- rv = i2c_xfer_unlocked(port, slave_addr, &reg, 1, &block_length, 1,
- I2C_XFER_START);
+ rv = i2c_xfer_unlocked__7bf(port, slave_addr__7bf,
+ &reg, 1, &block_length, 1, I2C_XFER_START);
if (rv)
goto exit;
if (len && block_length > (len - 1))
block_length = len - 1;
- rv = i2c_xfer_unlocked(port, slave_addr, 0, 0, data, block_length,
- I2C_XFER_STOP);
+ rv = i2c_xfer_unlocked__7bf(port, slave_addr__7bf,
+ 0, 0, data, block_length, I2C_XFER_STOP);
data[block_length] = 0;
exit:
@@ -431,18 +464,20 @@ exit:
return rv;
}
-int i2c_read_block(int port, int slave_addr, int offset, uint8_t *data,
- int len)
+int i2c_read_block__7bf(const int port,
+ const uint16_t slave_addr__7bf,
+ int offset, uint8_t *data, int len)
{
int rv;
uint8_t reg_address = offset;
- rv = i2c_xfer(port, slave_addr, &reg_address, 1, data, len);
+ rv = i2c_xfer__7bf(port, slave_addr__7bf, &reg_address, 1, data, len);
return rv;
}
-int i2c_write_block(int port, int slave_addr, int offset, const uint8_t *data,
- int len)
+int i2c_write_block__7bf(const int port,
+ const uint16_t slave_addr__7bf,
+ int offset, const uint8_t *data, int len)
{
int rv;
uint8_t reg_address = offset;
@@ -452,11 +487,11 @@ int i2c_write_block(int port, int slave_addr, int offset, const uint8_t *data,
* appending the destination address with the data array.
*/
i2c_lock(port, 1);
- rv = i2c_xfer_unlocked(port, slave_addr, &reg_address, 1, NULL, 0,
- I2C_XFER_START);
+ rv = i2c_xfer_unlocked__7bf(port, slave_addr__7bf,
+ &reg_address, 1, NULL, 0, I2C_XFER_START);
if (!rv) {
- rv = i2c_xfer_unlocked(port, slave_addr, data, len, NULL, 0,
- I2C_XFER_STOP);
+ rv = i2c_xfer_unlocked__7bf(port, slave_addr__7bf,
+ data, len, NULL, 0, I2C_XFER_STOP);
}
i2c_lock(port, 0);
@@ -712,7 +747,7 @@ static int check_i2c_params(const struct host_cmd_handler_args *args)
/* Loop and process messages */;
for (msgnum = 0, msg = params->msg; msgnum < params->num_msgs;
msgnum++, msg++) {
- unsigned int addr_flags = msg->addr_flags;
+ unsigned int addr_flags = msg->addr_flags__7bf;
PTHRUPRINTS("port=%d, %s, addr=0x%x(7-bit), len=%d",
params->port,
@@ -769,10 +804,10 @@ static int i2c_command_passthru(struct host_cmd_handler_args *args)
if (ret)
return ret;
- if (port_protected[params->port] && i2c_port->passthru_allowed) {
+ if (port_protected[params->port] && i2c_port->passthru_allowed__7bf) {
for (i = 0; i < params->num_msgs; i++) {
- if (!i2c_port->passthru_allowed(i2c_port,
- params->msg[i].addr_flags & EC_I2C_ADDR_MASK))
+ if (!i2c_port->passthru_allowed__7bf(i2c_port,
+ params->msg[i].addr_flags__7bf))
return EC_RES_ACCESS_DENIED;
}
}
@@ -785,13 +820,15 @@ static int i2c_command_passthru(struct host_cmd_handler_args *args)
for (resp->num_msgs = 0, msg = params->msg;
resp->num_msgs < params->num_msgs;
resp->num_msgs++, msg++) {
- /* EC uses 8-bit slave address */
- unsigned int addr = (msg->addr_flags & EC_I2C_ADDR_MASK) << 1;
int xferflags = I2C_XFER_START;
int read_len = 0, write_len = 0;
int rv = 1;
- if (msg->addr_flags & EC_I2C_FLAG_READ)
+ /* Have to remove the EC flags from the address flags */
+ uint16_t addr__7bf = msg->addr_flags__7bf & EC_I2C_ADDR_MASK;
+
+
+ if (msg->addr_flags__7bf & EC_I2C_FLAG_READ)
read_len = msg->len;
else
write_len = msg->len;
@@ -800,9 +837,9 @@ static int i2c_command_passthru(struct host_cmd_handler_args *args)
if (resp->num_msgs == params->num_msgs - 1)
xferflags |= I2C_XFER_STOP;
-#if defined(VIRTUAL_BATTERY_ADDR) && defined(I2C_PORT_VIRTUAL_BATTERY)
+#if defined(VIRTUAL_BATTERY_ADDR__7bf) && defined(I2C_PORT_VIRTUAL_BATTERY)
if (params->port == I2C_PORT_VIRTUAL_BATTERY &&
- VIRTUAL_BATTERY_ADDR == addr) {
+ VIRTUAL_BATTERY_ADDR__7bf == addr__7bf) {
if (virtual_battery_handler(resp, in_len, &rv,
xferflags, read_len,
write_len, out))
@@ -811,7 +848,8 @@ static int i2c_command_passthru(struct host_cmd_handler_args *args)
#endif
/* Transfer next message */
PTHRUPRINTS("xfer port=%x addr=0x%x rlen=%d flags=0x%x",
- params->port, addr, read_len, xferflags);
+ params->port, addr__7bf,
+ read_len, xferflags);
if (write_len) {
PTHRUPRINTF(" out:");
for (i = 0; i < write_len; i++)
@@ -829,7 +867,8 @@ static int i2c_command_passthru(struct host_cmd_handler_args *args)
#endif
if (!port_is_locked)
i2c_lock(params->port, (port_is_locked = 1));
- rv = i2c_xfer_unlocked(params->port, addr,
+ rv = i2c_xfer_unlocked__7bf(params->port,
+ addr__7bf,
out, write_len,
&resp->data[in_len], read_len,
xferflags);
@@ -885,7 +924,7 @@ static void i2c_passthru_protect_tcpc_ports(void)
for (i = 0; i < CONFIG_USB_PD_PORT_COUNT; i++) {
/* TCPC tunnel not configured. No need to protect anything */
- if (!tcpc_config[i].i2c_info.addr)
+ if (!I2C_GET_ADDR__7b(tcpc_config[i].i2c_info.addr__7bf))
continue;
i2c_passthru_protect_port(tcpc_config[i].i2c_info.port);
}
@@ -976,30 +1015,31 @@ DECLARE_CONSOLE_COMMAND(i2cprotect, command_i2cprotect,
#ifdef CONFIG_CMD_I2C_SCAN
static void scan_bus(int port, const char *desc)
{
- int a;
+ int level;
uint8_t tmp;
+ uint16_t addr__7bf;
ccprintf("Scanning %d %s", port, desc);
i2c_lock(port, 1);
/* Don't scan a busy port, since reads will just fail / time out */
- a = i2c_get_line_levels(port);
- if (a != I2C_LINE_IDLE) {
+ level = i2c_get_line_levels(port);
+ if (level != I2C_LINE_IDLE) {
ccprintf(": port busy (SDA=%d, SCL=%d)",
- (a & I2C_LINE_SDA_HIGH) ? 1 : 0,
- (a & I2C_LINE_SCL_HIGH) ? 1 : 0);
+ (level & I2C_LINE_SDA_HIGH) ? 1 : 0,
+ (level & I2C_LINE_SCL_HIGH) ? 1 : 0);
goto scan_bus_exit;
}
- for (a = 0; a < 0x100; a += 2) {
+ for (addr__7bf = 0; addr__7bf <= 0xEF; ++addr__7bf) {
watchdog_reload(); /* Otherwise a full scan trips watchdog */
ccputs(".");
/* Do a single read */
- if (!i2c_xfer_unlocked(port, a, NULL, 0, &tmp, 1,
- I2C_XFER_SINGLE))
- ccprintf("\n 0x%02x", a);
+ if (!i2c_xfer_unlocked__7bf(port, addr__7bf,
+ NULL, 0, &tmp, 1, I2C_XFER_SINGLE))
+ ccprintf("\n 0x%02x", addr__7bf);
}
scan_bus_exit:
@@ -1034,7 +1074,8 @@ DECLARE_CONSOLE_COMMAND(i2cscan, command_scan,
#ifdef CONFIG_CMD_I2C_XFER
static int command_i2cxfer(int argc, char **argv)
{
- int port, slave_addr;
+ int port;
+ uint16_t addr__7bf;
uint16_t offset = 0;
uint8_t offset_size = 0;
int v = 0;
@@ -1049,7 +1090,7 @@ static int command_i2cxfer(int argc, char **argv)
if (*e)
return EC_ERROR_PARAM2;
- slave_addr = strtoi(argv[3], &e, 0);
+ addr__7bf = strtoi(argv[3], &e, 0);
if (*e)
return EC_ERROR_PARAM3;
@@ -1068,18 +1109,22 @@ static int command_i2cxfer(int argc, char **argv)
if (strcasecmp(argv[1], "r") == 0) {
/* 8-bit read */
if (offset_size == 2)
- rv = i2c_read_offset16(port, slave_addr, offset, &v, 1);
+ rv = i2c_read_offset16__7bf(port, addr__7bf,
+ offset, &v, 1);
else
- rv = i2c_read8(port, slave_addr, offset, &v);
+ rv = i2c_read8__7bf(port, addr__7bf,
+ offset, &v);
if (!rv)
ccprintf("0x%02x [%d]\n", v, v);
} else if (strcasecmp(argv[1], "r16") == 0) {
/* 16-bit read */
if (offset_size == 2)
- rv = i2c_read_offset16(port, slave_addr, offset, &v, 2);
+ rv = i2c_read_offset16__7bf(port, addr__7bf,
+ offset, &v, 2);
else
- rv = i2c_read16(port, slave_addr, offset, &v);
+ rv = i2c_read16__7bf(port, addr__7bf,
+ offset, &v);
if (!rv)
ccprintf("0x%04x [%d]\n", v, v);
@@ -1088,7 +1133,8 @@ static int command_i2cxfer(int argc, char **argv)
if (argc < 6 || v < 0 || v > sizeof(data))
return EC_ERROR_PARAM5;
- rv = i2c_xfer(port, slave_addr, (uint8_t *)&offset, 1, data, v);
+ rv = i2c_xfer__7bf(port, addr__7bf,
+ (uint8_t *)&offset, 1, data, v);
if (!rv)
ccprintf("Data: %.*h\n", v, data);
@@ -1098,18 +1144,22 @@ static int command_i2cxfer(int argc, char **argv)
if (argc < 6)
return EC_ERROR_PARAM5;
if (offset_size == 2)
- rv = i2c_write_offset16(port, slave_addr, offset, v, 1);
+ rv = i2c_write_offset16__7bf(port, addr__7bf,
+ offset, v, 1);
else
- rv = i2c_write8(port, slave_addr, offset, v);
+ rv = i2c_write8__7bf(port, addr__7bf,
+ offset, v);
} else if (strcasecmp(argv[1], "w16") == 0) {
/* 16-bit write */
if (argc < 6)
return EC_ERROR_PARAM5;
if (offset_size == 2)
- rv = i2c_write_offset16(port, slave_addr, offset, v, 2);
+ rv = i2c_write_offset16__7bf(port, addr__7bf,
+ offset, v, 2);
else
- rv = i2c_write16(port, slave_addr, offset, v);
+ rv = i2c_write16__7bf(port, addr__7bf,
+ offset, v);
} else {
return EC_ERROR_PARAM1;
@@ -1149,7 +1199,6 @@ static int command_i2ctest(int argc, char **argv)
int i, j, rv;
uint32_t rand;
int data, data_verify;
- int port, addr;
int count = 10000;
int udelay = 100;
int test_dev = i2c_test_dev_used;
@@ -1177,6 +1226,9 @@ static int command_i2ctest(int argc, char **argv)
}
for (i = 0; i < count; i++) {
+ int port;
+ uint16_t addr__7bf;
+
if (!(i % 1000))
ccprintf("running test %d\n", i);
@@ -1186,7 +1238,7 @@ static int command_i2ctest(int argc, char **argv)
}
port = i2c_stress_tests[test_dev].port;
- addr = i2c_stress_tests[test_dev].addr;
+ addr__7bf = i2c_stress_tests[test_dev].addr__7bf;
i2c_s_test = i2c_stress_tests[test_dev].i2c_test;
reg_s_info = &i2c_s_test->reg_info;
test_s_results = &i2c_s_test->test_results;
@@ -1194,8 +1246,8 @@ static int command_i2ctest(int argc, char **argv)
rand = get_time().val;
if (rand & 0x1) {
/* read */
- rv = i2c_s_test->i2c_read ?
- i2c_s_test->i2c_read(port, addr,
+ rv = i2c_s_test->i2c_read__7bf ?
+ i2c_s_test->i2c_read__7bf(port, addr__7bf,
reg_s_info->read_reg, &data) :
i2c_s_test->i2c_read_dev(
reg_s_info->read_reg, &data);
@@ -1211,8 +1263,8 @@ static int command_i2ctest(int argc, char **argv)
*/
/* Read the write register */
- rv = i2c_s_test->i2c_read ?
- i2c_s_test->i2c_read(port, addr,
+ rv = i2c_s_test->i2c_read__7bf ?
+ i2c_s_test->i2c_read__7bf(port, addr__7bf,
reg_s_info->read_reg, &data) :
i2c_s_test->i2c_read_dev(
reg_s_info->read_reg, &data);
@@ -1226,8 +1278,9 @@ static int command_i2ctest(int argc, char **argv)
j = I2C_STRESS_TEST_DATA_VERIFY_RETRY_COUNT;
do {
/* Write same value back */
- rv = i2c_s_test->i2c_write ?
- i2c_s_test->i2c_write(port, addr,
+ rv = i2c_s_test->i2c_write__7bf ?
+ i2c_s_test->i2c_write__7bf(port,
+ addr__7bf,
reg_s_info->write_reg, data) :
i2c_s_test->i2c_write_dev(
reg_s_info->write_reg, data);
@@ -1240,8 +1293,9 @@ static int command_i2ctest(int argc, char **argv)
test_s_results->write_success++;
/* Read back to verify the data */
- rv = i2c_s_test->i2c_read ?
- i2c_s_test->i2c_read(port, addr,
+ rv = i2c_s_test->i2c_read__7bf ?
+ i2c_s_test->i2c_read__7bf(port,
+ addr__7bf,
reg_s_info->read_reg, &data_verify) :
i2c_s_test->i2c_read_dev(
reg_s_info->read_reg, &data_verify);
diff --git a/common/i2c_trace.c b/common/i2c_trace.c
index 52603c7244..ff237ed582 100644
--- a/common/i2c_trace.c
+++ b/common/i2c_trace.c
@@ -23,16 +23,17 @@ struct i2c_trace_range {
static struct i2c_trace_range trace_entries[8];
-void i2c_trace_notify(int port, int slave_addr, int direction,
- const uint8_t *data, size_t size)
+void i2c_trace_notify__7bf(int port, uint16_t slave_addr__7bf,
+ int direction, const uint8_t *data, size_t size)
{
size_t i;
+ uint16_t addr__7b = I2C_GET_ADDR__7b(slave_addr__7bf);
for (i = 0; i < ARRAY_SIZE(trace_entries); i++)
if (trace_entries[i].enabled
&& trace_entries[i].port == port
- && trace_entries[i].slave_addr_lo <= slave_addr
- && trace_entries[i].slave_addr_hi >= slave_addr)
+ && trace_entries[i].slave_addr_lo <= addr__7b
+ && trace_entries[i].slave_addr_hi >= addr__7b)
goto trace_enabled;
return;
@@ -40,7 +41,7 @@ trace_enabled:
CPRINTF("i2c: %s %d:0x%X ",
direction ? "read" : "write",
port,
- slave_addr);
+ addr__7b);
for (i = 0; i < size; i++)
CPRINTF("%02X ", data[i]);
CPRINTF("\n");
diff --git a/common/lb_common.c b/common/lb_common.c
index 208015482c..1e37245558 100644
--- a/common/lb_common.c
+++ b/common/lb_common.c
@@ -111,7 +111,7 @@
/* Since there's absolutely nothing we can do about it if an I2C access
* isn't working, we're completely ignoring any failures. */
-static const uint8_t i2c_addr[] = { 0x54, 0x56 };
+static const uint16_t i2c_addr__7bf[] = { 0x2A, 0x2B };
static inline void controller_write(int ctrl_num, uint8_t reg, uint8_t val)
{
@@ -119,9 +119,10 @@ static inline void controller_write(int ctrl_num, uint8_t reg, uint8_t val)
buf[0] = reg;
buf[1] = val;
- ctrl_num = ctrl_num % ARRAY_SIZE(i2c_addr);
- i2c_xfer_unlocked(I2C_PORT_LIGHTBAR, i2c_addr[ctrl_num], buf, 2, 0, 0,
- I2C_XFER_SINGLE);
+ ctrl_num = ctrl_num % ARRAY_SIZE(i2c_addr__7bf);
+ i2c_xfer_unlocked__7bf(I2C_PORT_LIGHTBAR, i2c_addr__7bf[ctrl_num],
+ buf, 2, 0, 0,
+ I2C_XFER_SINGLE);
}
static inline uint8_t controller_read(int ctrl_num, uint8_t reg)
@@ -129,8 +130,8 @@ static inline uint8_t controller_read(int ctrl_num, uint8_t reg)
uint8_t buf[1];
int rv;
- ctrl_num = ctrl_num % ARRAY_SIZE(i2c_addr);
- rv = i2c_xfer_unlocked(I2C_PORT_LIGHTBAR, i2c_addr[ctrl_num],
+ ctrl_num = ctrl_num % ARRAY_SIZE(i2c_addr__7bf);
+ rv = i2c_xfer_unlocked__7bf(I2C_PORT_LIGHTBAR, i2c_addr__7bf[ctrl_num],
&reg, 1, buf, 1, I2C_XFER_SINGLE);
return rv ? 0 : buf[0];
}
diff --git a/common/motion_sense.c b/common/motion_sense.c
index 169bc3a6d9..033e490517 100644
--- a/common/motion_sense.c
+++ b/common/motion_sense.c
@@ -2062,7 +2062,8 @@ static int command_display_accel_info(int argc, char **argv)
ccprintf("type: %d\n", motion_sensors[i].type);
ccprintf("location: %d\n", motion_sensors[i].location);
ccprintf("port: %d\n", motion_sensors[i].port);
- ccprintf("addr: %d\n", motion_sensors[i].addr);
+ ccprintf("addr: %d\n", I2C_GET_ADDR__7b(motion_sensors[i]
+ .i2c_spi_addr__7bf));
ccprintf("range: %d\n", motion_sensors[i].default_range);
ccprintf("min_freq: %d\n", motion_sensors[i].min_frequency);
ccprintf("max_freq: %d\n", motion_sensors[i].max_frequency);
diff --git a/common/peripheral.c b/common/peripheral.c
index 301165e34e..eafd5d6f49 100644
--- a/common/peripheral.c
+++ b/common/peripheral.c
@@ -22,8 +22,7 @@ static int hc_locate_chip(struct host_cmd_handler_args *args)
return EC_RES_OVERFLOW;
resp->bus_type = EC_BUS_TYPE_I2C;
resp->i2c_info.port = I2C_PORT_EEPROM;
- /* Convert from 8-bit address to 7-bit address */
- resp->i2c_info.addr = I2C_ADDR_EEPROM >> 1;
+ resp->i2c_info.addr__7bf = I2C_ADDR_EEPROM__7bf;
#else
/* Lookup type is supported, but not present on system. */
return EC_RES_UNAVAILABLE;
@@ -37,8 +36,8 @@ static int hc_locate_chip(struct host_cmd_handler_args *args)
if (resp->bus_type == EC_BUS_TYPE_I2C) {
resp->i2c_info.port =
tcpc_config[params->index].i2c_info.port;
- resp->i2c_info.addr =
- tcpc_config[params->index].i2c_info.addr >> 1;
+ resp->i2c_info.addr__7bf =
+ tcpc_config[params->index].i2c_info.addr__7bf;
}
#ifdef CONFIG_INTEL_VIRTUAL_MUX
resp->reserved = tcpc_config[params->index].usb23;
diff --git a/common/usb_i2c.c b/common/usb_i2c.c
index 50537ce82e..375419dfcc 100644
--- a/common/usb_i2c.c
+++ b/common/usb_i2c.c
@@ -106,9 +106,7 @@ static void usb_i2c_execute(struct usb_i2c_config const *config)
/* Payload is ready to execute. */
uint32_t count = usb_i2c_read_packet(config);
int portindex = (config->buffer[0] >> 0) & 0xf;
- /* Convert 7-bit slave address to chromium EC 8-bit address. */
- uint8_t slave_addr = (config->buffer[0] >> 7) & 0xfe;
-
+ uint16_t addr__7bf = (config->buffer[0] >> 8) & 0x7f;
int write_count = ((config->buffer[0] << 4) & 0xf00) |
((config->buffer[1] >> 0) & 0xff);
int read_count = (config->buffer[1] >> 8) & 0xff;
@@ -135,7 +133,7 @@ static void usb_i2c_execute(struct usb_i2c_config const *config)
config->buffer[0] = USB_I2C_READ_COUNT_INVALID;
} else if (portindex >= i2c_ports_used) {
config->buffer[0] = USB_I2C_PORT_INVALID;
- } else if (slave_addr == USB_I2C_CMD_ADDR) {
+ } else if (addr__7bf == USB_I2C_CMD_ADDR__7bf) {
/*
* This is a non-i2c command, invoke the handler if it has
* been registered, if not - report the appropriate error.
@@ -156,8 +154,7 @@ static void usb_i2c_execute(struct usb_i2c_config const *config)
* knows about. It should behave closer to
* EC_CMD_I2C_PASSTHRU, which can protect ports and ranges.
*/
- ret = i2c_xfer(i2c_ports[portindex].port,
- slave_addr,
+ ret = i2c_xfer__7bf(i2c_ports[portindex].port, addr__7bf,
(uint8_t *)(config->buffer + 2) + offset,
write_count,
(uint8_t *)(config->buffer + 2),
diff --git a/cts/i2c/dut.c b/cts/i2c/dut.c
index e4a87f440e..033aca7ffc 100644
--- a/cts/i2c/dut.c
+++ b/cts/i2c/dut.c
@@ -13,25 +13,28 @@
#include "uart.h"
#include "watchdog.h"
-#define TH_ADDR 0x3c
+#define TH_ADDR__7bf 0x1e
enum cts_rc write8_test(void)
{
- if (i2c_write8(i2c_ports[0].port, TH_ADDR, WRITE8_OFF, WRITE8_DATA))
+ if (i2c_write8__7bf(i2c_ports[0].port, TH_ADDR__7bf,
+ WRITE8_OFF, WRITE8_DATA))
return CTS_RC_FAILURE;
return CTS_RC_SUCCESS;
}
enum cts_rc write16_test(void)
{
- if (i2c_write16(i2c_ports[0].port, TH_ADDR, WRITE16_OFF, WRITE16_DATA))
+ if (i2c_write16__7bf(i2c_ports[0].port, TH_ADDR__7bf,
+ WRITE16_OFF, WRITE16_DATA))
return CTS_RC_FAILURE;
return CTS_RC_SUCCESS;
}
enum cts_rc write32_test(void)
{
- if (i2c_write32(i2c_ports[0].port, TH_ADDR, WRITE32_OFF, WRITE32_DATA))
+ if (i2c_write32__7bf(i2c_ports[0].port, TH_ADDR__7bf,
+ WRITE32_OFF, WRITE32_DATA))
return CTS_RC_FAILURE;
return CTS_RC_SUCCESS;
}
@@ -40,7 +43,8 @@ enum cts_rc read8_test(void)
{
int data;
- if (i2c_read8(i2c_ports[0].port, TH_ADDR, READ8_OFF, &data))
+ if (i2c_read8__7bf(i2c_ports[0].port, TH_ADDR__7bf,
+ READ8_OFF, &data))
return CTS_RC_FAILURE;
if (data != READ8_DATA) {
CPRINTL("Expecting 0x%x but read 0x%x", READ8_DATA, data);
@@ -54,7 +58,8 @@ enum cts_rc read16_test(void)
{
int data;
- if (i2c_read16(i2c_ports[0].port, TH_ADDR, READ16_OFF, &data))
+ if (i2c_read16__7bf(i2c_ports[0].port, TH_ADDR__7bf,
+ READ16_OFF, &data))
return CTS_RC_FAILURE;
if (data != READ16_DATA) {
CPRINTL("Expecting 0x%x but read 0x%x", READ16_DATA, data);
@@ -68,7 +73,8 @@ enum cts_rc read32_test(void)
{
int data;
- if (i2c_read32(i2c_ports[0].port, TH_ADDR, READ32_OFF, &data))
+ if (i2c_read32__7bf(i2c_ports[0].port, TH_ADDR__7bf,
+ READ32_OFF, &data))
return CTS_RC_FAILURE;
if (data != READ32_DATA) {
CPRINTL("Read 0x%x expecting 0x%x", data, READ32_DATA);
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
diff --git a/include/battery_smart.h b/include/battery_smart.h
index ceec42719c..84b80fd162 100644
--- a/include/battery_smart.h
+++ b/include/battery_smart.h
@@ -11,8 +11,8 @@
#include "common.h"
/* Smart battery and charger I2C address */
-#define BATTERY_ADDR 0x16
-#define CHARGER_ADDR 0x12
+#define BATTERY_ADDR__7bf (0x0B)
+#define CHARGER_ADDR__7bf (0x09)
/* Charger functions */
#define SB_CHARGER_SPEC_INFO 0x11
diff --git a/include/charge_state_v2.h b/include/charge_state_v2.h
index f44fd3d8f7..1a7f698cc4 100644
--- a/include/charge_state_v2.h
+++ b/include/charge_state_v2.h
@@ -14,7 +14,7 @@
#define __CROS_EC_CHARGE_STATE_V2_H
#if defined(CONFIG_I2C_VIRTUAL_BATTERY) && defined(CONFIG_BATTERY_SMART)
-#define VIRTUAL_BATTERY_ADDR BATTERY_ADDR
+#define VIRTUAL_BATTERY_ADDR__7bf BATTERY_ADDR__7bf
#endif
/*
* The values exported by charge_get_state() and charge_get_flags() are used
diff --git a/include/config.h b/include/config.h
index a798f0eac1..95258abd54 100644
--- a/include/config.h
+++ b/include/config.h
@@ -139,7 +139,7 @@
#undef CONFIG_KX022_ORIENTATION_SENSOR
/* Define the i2c address of the sensor behind the main sensor, if present. */
-#undef CONFIG_ACCELGYRO_SEC_ADDR
+#undef CONFIG_ACCELGYRO_SEC_ADDR__7BF
/*
* Define if either CONFIG_BMI160_ORIENTATION_SUPPORT or
@@ -601,7 +601,7 @@
#undef CONFIG_BOARD_VERSION_GPIO
/* EC responses to a board defined I2C slave address */
-#undef CONFIG_BOARD_I2C_SLAVE_ADDR
+#undef CONFIG_BOARD_I2C_SLAVE_ADDR__7BF
/*
* The board is unable to distinguish EC reset from power-on so it should treat
@@ -2030,7 +2030,7 @@
* For ECs where the host command interface is I2C, slave
* address which the EC will respond to.
*/
-#undef CONFIG_HOSTCMD_I2C_SLAVE_ADDR
+#undef CONFIG_HOSTCMD_I2C_SLAVE_ADDR__7BF
/*
* Accept EC host commands over the SPI slave (SPS) interface.
@@ -2199,7 +2199,7 @@
* transaction is done, the pin is set back to low.
*/
#undef CONFIG_I2C_SCL_GATE_PORT
-#undef CONFIG_I2C_SCL_GATE_ADDR
+#undef CONFIG_I2C_SCL_GATE_ADDR__7BF
#undef CONFIG_I2C_SCL_GATE_GPIO
/*
@@ -3411,9 +3411,9 @@
/* Enable Elan driver */
#undef CONFIG_TOUCHPAD_ELAN
-/* Set I2C port and address (8-bit) */
+/* Set I2C port and address (7-bit) */
#undef CONFIG_TOUCHPAD_I2C_PORT
-#undef CONFIG_TOUCHPAD_I2C_ADDR
+#undef CONFIG_TOUCHPAD_I2C_ADDR__7BF
/*
* Enable touchpad FW update over USB update protocol, and define touchpad
@@ -3624,7 +3624,7 @@
#undef CONFIG_USB_PD_IDENTITY_SW_VERS
/* USB PD MCU slave address for host commands */
-#define CONFIG_USB_PD_I2C_SLAVE_ADDR 0x3c
+#define CONFIG_USB_PD_I2C_SLAVE_ADDR__7BF 0x1E
/* Define if using internal comparator for PD receive */
#undef CONFIG_USB_PD_INTERNAL_COMP
@@ -3736,7 +3736,7 @@
#undef CONFIG_USB_PD_VBUS_MEASURE_NOT_PRESENT
/* Define the type-c port controller I2C base address. */
-#define CONFIG_TCPC_I2C_BASE_ADDR 0x9c
+#define CONFIG_TCPC_I2C_BASE_ADDR__7BF 0x4E
/* Use this option to enable Try.SRC mode for Dual Role devices */
#undef CONFIG_USB_PD_TRY_SRC
@@ -4713,7 +4713,7 @@
#if defined(CONFIG_MAG_BMI160_LIS2MDL) || \
defined(CONFIG_MAG_LSM6DSM_LIS2MDL)
#define CONFIG_MAG_LIS2MDL
-#ifndef CONFIG_ACCELGYRO_SEC_ADDR
+#ifndef CONFIG_ACCELGYRO_SEC_ADDR__7BF
#error "The i2c address of the magnetometer is not set."
#endif
#endif
@@ -4722,7 +4722,7 @@
#if defined(CONFIG_MAG_BMI160_BMM150) || \
defined(CONFIG_MAG_LSM6DSM_BMM150)
#define CONFIG_MAG_BMM150
-#ifndef CONFIG_ACCELGYRO_SEC_ADDR
+#ifndef CONFIG_ACCELGYRO_SEC_ADDR__7BF
#error "The i2c address of the magnetometer is not set."
#endif
#endif
diff --git a/include/ec_commands.h b/include/ec_commands.h
index 5e78cae51c..fb1523b479 100644
--- a/include/ec_commands.h
+++ b/include/ec_commands.h
@@ -4008,7 +4008,10 @@ struct ec_response_power_info {
#define EC_I2C_STATUS_ERROR (EC_I2C_STATUS_NAK | EC_I2C_STATUS_TIMEOUT)
struct ec_params_i2c_passthru_msg {
- uint16_t addr_flags; /* I2C slave address (7 or 10 bits) and flags */
+ union {
+ uint16_t addr_flags; /* I2C slave address and flags */
+ uint16_t addr_flags__7bf; /* remove before final merge */
+ };
uint16_t len; /* Number of bytes to read or write */
} __ec_align2;
@@ -5402,8 +5405,11 @@ enum ec_bus_type {
};
struct ec_i2c_info {
- uint16_t port; /* Physical port for device */
- uint16_t addr; /* 7-bit (or 10-bit) address */
+ uint16_t port; /* Physical port for device */
+ union {
+ uint16_t addr_flags; /* 7-bit (or 10-bit) address */
+ uint16_t addr__7bf; /* remove before final merge */
+ };
};
struct ec_params_locate_chip {
diff --git a/include/i2c.h b/include/i2c.h
index 566ae7b402..1281b8280d 100644
--- a/include/i2c.h
+++ b/include/i2c.h
@@ -13,8 +13,35 @@
#include "host_command.h"
#include "stddef.h"
-/* Flags for slave address field, in addition to the 8-bit address */
-#define I2C_FLAG_BIG_ENDIAN 0x100 /* 16 byte values are MSB-first */
+/*
+ * I2C Slave Address encoding
+ *
+ * EC will favor 7bit I2C/SPI address encoding. The variable/define
+ * naming should follow the pattern, if it is just the 7 bit address
+ * then end the variable as "addr". This can be addr, i2c_addr,
+ * slave_addr, etc. If the 7 bit address contains flags for BIG
+ * ENDIAN or overloading the address to be a SPI address, then it
+ * will be customary to end the variable as "addr_flags". This can
+ * be addr_flags, i2c_addr_flags, slave_addr_flags, etc.
+ *
+ * Some of the drivers use an 8bit left shifted 7bit address. Since
+ * this is driver specific, it will be up to the driver to make this
+ * clear. I suggest, since this is a very small amount of usage, that
+ * ending the variable as "addr__8bit" would make this clear.
+ *
+ * NOTE: Slave addresses are always 16 bit values. The least significant
+ * 10 bits are available as an address. More significant bits are
+ * used here and in motion_sense to give specific meaning to the
+ * address that is pertinent to its use.
+ */
+#define I2C_ADDR_MASK 0x03FF
+#define I2C_FLAG_BIG_ENDIAN BIT(14)
+/* BIT(15) SPI_FLAG - used in motion_sense to overload address */
+#define I2C_FLAG_ADDR_IS_SPI BIT(15)
+
+#define I2C_GET_ADDR(x) (I2C_GET_ADDR__7b(x))
+#define I2C_GET_ADDR__7b(x__7bf) ((x__7bf) & I2C_ADDR_MASK)
+#define I2C_IS_BIG_ENDIAN(x__7bf) ((x__7bf) & I2C_FLAG_BIG_ENDIAN)
/*
* Max data size for a version 3 request/response packet. This is
@@ -35,7 +62,16 @@ enum i2c_freq {
struct i2c_info_t {
uint16_t port; /* Physical port for device */
- uint16_t addr; /* 8-bit (or 11-bit) address */
+
+ /*
+ * union is temporary to accommodate ec_tools
+ * and will be reduced to the non-__7bf version
+ * before the final merge
+ */
+ union {
+ uint16_t addr_flags;
+ uint16_t addr__7bf;
+ };
};
/* Data structure to define I2C port configuration. */
@@ -47,8 +83,8 @@ struct i2c_port_t {
enum gpio_signal sda; /* Port SDA GPIO line */
/* When bus is protected, returns true if passthru allowed for address.
* If the function is not defined, the default value is true. */
- int (*passthru_allowed)(const struct i2c_port_t *port,
- uint16_t address);
+ int (*passthru_allowed__7bf)(const struct i2c_port_t *port,
+ uint16_t addr__7bf);
};
extern const struct i2c_port_t i2c_ports[];
@@ -72,17 +108,19 @@ struct i2c_test_results {
struct i2c_stress_test_dev {
struct i2c_test_reg_info reg_info;
struct i2c_test_results test_results;
- int (*i2c_read)(const int port, const int addr,
- const int reg, int *data);
- int (*i2c_write)(const int port, const int addr,
- const int reg, int data);
+ int (*i2c_read__7bf)(const int port,
+ const uint16_t slave_addr__7bf,
+ const int reg, int *data);
+ int (*i2c_write__7bf)(const int port,
+ const uint16_t slave_addr__7bf,
+ const int reg, int data);
int (*i2c_read_dev)(const int reg, int *data);
int (*i2c_write_dev)(const int reg, int data);
};
struct i2c_stress_test {
int port;
- int addr;
+ uint16_t addr__7bf;
struct i2c_stress_test_dev *i2c_test;
};
@@ -109,7 +147,9 @@ extern const int i2c_test_dev_used;
* @param in_size Number of bytes to receive
* @return EC_SUCCESS, or non-zero if error.
*/
-int i2c_xfer(int port, int slave_addr, const uint8_t *out, int out_size,
+int i2c_xfer__7bf(const int port,
+ const uint16_t slave_addr__7bf,
+ const uint8_t *out, int out_size,
uint8_t *in, int in_size);
/**
@@ -118,7 +158,8 @@ int i2c_xfer(int port, int slave_addr, const uint8_t *out, int out_size,
*
* @param flags Flags (see I2C_XFER_* above)
*/
-int i2c_xfer_unlocked(int port, int slave_addr,
+int i2c_xfer_unlocked__7bf(const int port,
+ const uint16_t slave_addr__7bf,
const uint8_t *out, int out_size,
uint8_t *in, int in_size, int flags);
@@ -142,7 +183,9 @@ int i2c_xfer_unlocked(int port, int slave_addr,
* @param flags Flags (see I2C_XFER_* above)
* @return EC_SUCCESS, or non-zero if error.
*/
-int chip_i2c_xfer(int port, int slave_addr, const uint8_t *out, int out_size,
+int chip_i2c_xfer__7bf(const int port,
+ const uint16_t slave_addr__7bf,
+ const uint8_t *out, int out_size,
uint8_t *in, int in_size, int flags);
/**
@@ -236,68 +279,84 @@ void i2c_prepare_sysjump(void);
void i2c_set_timeout(int port, uint32_t timeout);
/**
- * Read a 32-bit register from the slave at 8-bit slave address <slaveaddr>, at
+ * Read a 32-bit register from the slave at 7-bit slave address <slaveaddr>, at
* the specified 8-bit <offset> in the slave's address space.
*/
-int i2c_read32(int port, int slave_addr, int offset, int *data);
+int i2c_read32__7bf(const int port,
+ const uint16_t slave_addr__7bf,
+ int offset, int *data);
/**
- * Write a 32-bit register to the slave at 8-bit slave address <slaveaddr>, at
+ * Write a 32-bit register to the slave at 7-bit slave address <slaveaddr>, at
* the specified 8-bit <offset> in the slave's address space.
*/
-int i2c_write32(int port, int slave_addr, int offset, int data);
+int i2c_write32__7bf(const int port,
+ const uint16_t slave_addr__7bf,
+ int offset, int data);
/**
- * Read a 16-bit register from the slave at 8-bit slave address <slaveaddr>, at
+ * Read a 16-bit register from the slave at 7-bit slave address <slaveaddr>, at
* the specified 8-bit <offset> in the slave's address space.
*/
-int i2c_read16(int port, int slave_addr, int offset, int *data);
+int i2c_read16__7bf(const int port,
+ const uint16_t slave_addr__7bf,
+ int offset, int *data);
/**
- * Write a 16-bit register to the slave at 8-bit slave address <slaveaddr>, at
+ * Write a 16-bit register to the slave at 7-bit slave address <slaveaddr>, at
* the specified 8-bit <offset> in the slave's address space.
*/
-int i2c_write16(int port, int slave_addr, int offset, int data);
+int i2c_write16__7bf(const int port,
+ const uint16_t slave_addr__7bf,
+ int offset, int data);
/**
- * Read an 8-bit register from the slave at 8-bit slave address <slaveaddr>, at
+ * Read an 8-bit register from the slave at 7-bit slave address <slaveaddr>, at
* the specified 8-bit <offset> in the slave's address space.
*/
-int i2c_read8(int port, int slave_addr, int offset, int *data);
+int i2c_read8__7bf(const int port,
+ const uint16_t slave_addr__7bf,
+ int offset, int *data);
/**
- * Write an 8-bit register to the slave at 8-bit slave address <slaveaddr>, at
+ * Write an 8-bit register to the slave at 7-bit slave address <slaveaddr>, at
* the specified 8-bit <offset> in the slave's address space.
*/
-int i2c_write8(int port, int slave_addr, int offset, int data);
+int i2c_write8__7bf(const int port,
+ const uint16_t slave_addr__7bf,
+ int offset, int data);
/**
- * Read one or two bytes data from the slave at 8-bit slave address
+ * Read one or two bytes data from the slave at 7-bit slave address
* * <slaveaddr>, at 16-bit <offset> in the slave's address space.
*/
-int i2c_read_offset16(int port, int slave_addr, uint16_t offset, int *data,
- int len);
+int i2c_read_offset16__7bf(const int port,
+ const uint16_t slave_addr__7bf,
+ uint16_t offset, int *data, int len);
/**
- * Write one or two bytes data to the slave at 8-bit slave address
+ * Write one or two bytes data to the slave at 7-bit slave address
* <slaveaddr>, at 16-bit <offset> in the slave's address space.
*/
-int i2c_write_offset16(int port, int slave_addr, uint16_t offset, int data,
- int len);
+int i2c_write_offset16__7bf(const int port,
+ const uint16_t slave_addr__7bf,
+ uint16_t offset, int data, int len);
/**
- * Read <len> bytes block data from the slave at 8-bit slave address
+ * Read <len> bytes block data from the slave at 7-bit slave address
* * <slaveaddr>, at 16-bit <offset> in the slave's address space.
*/
-int i2c_read_offset16_block(int port, int slave_addr, uint16_t offset,
- uint8_t *data, int len);
+int i2c_read_offset16_block__7bf(const int port,
+ const uint16_t slave_addr__7bf,
+ uint16_t offset, uint8_t *data, int len);
/**
- * Write <len> bytes block data to the slave at 8-bit slave address
+ * Write <len> bytes block data to the slave at 7-bit slave address
* <slaveaddr>, at 16-bit <offset> in the slave's address space.
*/
-int i2c_write_offset16_block(int port, int slave_addr, uint16_t offset,
- const uint8_t *data, int len);
+int i2c_write_offset16_block__7bf(const int port,
+ const uint16_t slave_addr__7bf,
+ uint16_t offset, const uint8_t *data, int len);
/**
* @return non-zero if i2c bus is busy
@@ -324,24 +383,27 @@ int i2c_unwedge(int port);
* always written into the output buffer.
* <len> == 0 : buffer size > 255
*/
-int i2c_read_string(int port, int slave_addr, int offset, uint8_t *data,
- int len);
+int i2c_read_string__7bf(const int port,
+ const uint16_t slave_addr__7bf,
+ int offset, uint8_t *data, int len);
/**
- * Read a data block of <len> 8-bit transfers from the slave at 8-bit slave
+ * Read a data block of <len> 8-bit transfers from the slave at 7-bit slave
* address <slaveaddr>, at the specified 8-bit <offset> in the slave's address
* space.
*/
-int i2c_read_block(int port, int slave_addr, int offset, uint8_t *data,
- int len);
+int i2c_read_block__7bf(const int port,
+ const uint16_t slave_addr__7bf,
+ int offset, uint8_t *data, int len);
/**
- * Write a data block of <len> 8-bit transfers to the slave at 8-bit slave
+ * Write a data block of <len> 8-bit transfers to the slave at 7-bit slave
* address <slaveaddr>, at the specified 8-bit <offset> in the slave's address
* space.
*/
-int i2c_write_block(int port, int slave_addr, int offset, const uint8_t *data,
- int len);
+int i2c_write_block__7bf(const int port,
+ const uint16_t slave_addr__7bf,
+ int offset, const uint8_t *data, int len);
/**
* Convert port number to controller number, for multi-port controllers.
@@ -414,7 +476,8 @@ int board_is_i2c_port_powered(int port);
* @param slave_addr: Slave device address
*
*/
-void i2c_start_xfer_notify(int port, int slave_addr);
+void i2c_start_xfer_notify__7bf(const int port,
+ const uint16_t slave_addr__7bf);
/**
* Function to allow board to take any action after an i2c transaction on a
@@ -425,7 +488,8 @@ void i2c_start_xfer_notify(int port, int slave_addr);
* @param slave_addr: Slave device address
*
*/
-void i2c_end_xfer_notify(int port, int slave_addr);
+void i2c_end_xfer_notify__7bf(const int port,
+ const uint16_t slave_addr__7bf);
/**
* Defined in common/i2c_trace.c, used by i2c master to notify tracing
@@ -438,7 +502,7 @@ void i2c_end_xfer_notify(int port, int slave_addr);
* @param data: pointer to data read or written
* @param size: size of data read or written
*/
-void i2c_trace_notify(int port, int slave_addr, int direction,
- const uint8_t *data, size_t size);
+void i2c_trace_notify__7bf(int port, uint16_t slave_addr__7bf,
+ int direction, const uint8_t *data, size_t size);
#endif /* __CROS_EC_I2C_H */
diff --git a/include/motion_sense.h b/include/motion_sense.h
index 34da3f9ea5..0e9f79e422 100644
--- a/include/motion_sense.h
+++ b/include/motion_sense.h
@@ -12,6 +12,7 @@
#include "common.h"
#include "ec_commands.h"
#include "gpio.h"
+#include "i2c.h"
#include "math_util.h"
#include "queue.h"
#include "timer.h"
@@ -81,6 +82,24 @@ enum sensor_config {
#endif
/*
+ * I2C/SPI Slave Address encoding for motion sensors
+ * - The generic defines, I2C_ADDR_MASK and I2C_IS_BIG_ENDIAN_MASK
+ * are defined in i2c.h.
+ * - Motion sensors support some sensors on the SPI bus, so this
+ * overloads the I2C Address to use a single bit to indicate
+ * it is a SPI address instead of an I2C. Since SPI does not
+ * use slave addressing, it is up to the driver to use this
+ * field as it sees fit
+ */
+#define SLAVE_MK_I2C_ADDR__7bf(x__7b) (x__7b)
+#define SLAVE_MK_SPI_ADDR__7bf(x__7b) ((x__7b) | I2C_FLAG_ADDR_IS_SPI)
+
+#define SLAVE_GET_I2C_ADDR__7b(x__7bf) (I2C_GET_ADDR__7b(x__7bf))
+#define SLAVE_GET_SPI_ADDR__7b(x__7bf) ((x__7bf) & I2C_ADDR_MASK)
+
+#define SLAVE_IS_SPI(x__7bf) ((x__7bf) & I2C_FLAG_ADDR_IS_SPI)
+
+/*
* Define the frequency to use in max_frequency based on the maximal frequency
* the sensor support and what the EC can provide.
* Return a frequency the sensor supports.
@@ -131,7 +150,7 @@ struct motion_sensor_t {
/* i2c port */
uint8_t port;
/* i2c address or SPI slave logic GPIO. */
- uint8_t addr;
+ uint16_t i2c_spi_addr__7bf;
/*
* Various flags, see MOTIONSENSE_FLAG_*
diff --git a/include/test_util.h b/include/test_util.h
index 098700d67b..a812817b8f 100644
--- a/include/test_util.h
+++ b/include/test_util.h
@@ -218,20 +218,21 @@ void test_reboot_to_next_step(enum test_state_t step);
struct test_i2c_read_string_dev {
/* I2C string read handler */
- int (*routine)(int port, int slave_addr, int offset, uint8_t *data,
- int len);
+ int (*routine__7bf)(const int port, const uint16_t i2c_addr__7bf,
+ int offset, uint8_t *data, int len);
};
struct test_i2c_xfer {
/* I2C xfer handler */
- int (*routine)(int port, int slave_addr,
+ int (*routine__7bf)(const int port, const uint16_t i2c_addr__7bf,
const uint8_t *out, int out_size,
uint8_t *in, int in_size, int flags);
};
struct test_i2c_write_dev {
/* I2C write handler */
- int (*routine)(int port, int slave_addr, int offset, int data);
+ int (*routine__7bf)(const int port, const uint16_t i2c_addr__7bf,
+ int offset, int data);
};
/**
@@ -258,7 +259,7 @@ struct test_i2c_write_dev {
* @return EC_SUCCESS if detached; EC_ERROR_OVERFLOW if too many devices are
* detached.
*/
-int test_detach_i2c(int port, int slave_addr);
+int test_detach_i2c__7bf(const int port, const uint16_t slave_addr__7bf);
/*
* Re-attach an I2C device.
@@ -268,6 +269,6 @@ int test_detach_i2c(int port, int slave_addr);
* @return EC_SUCCESS if re-attached; EC_ERROR_INVAL if the specified device
* is not a detached device.
*/
-int test_attach_i2c(int port, int slave_addr);
+int test_attach_i2c__7bf(const int port, const uint16_t slave_addr__7bf);
#endif /* __CROS_EC_TEST_UTIL_H */
diff --git a/include/usb_i2c.h b/include/usb_i2c.h
index 2f09076eb9..629f495b69 100644
--- a/include/usb_i2c.h
+++ b/include/usb_i2c.h
@@ -218,7 +218,7 @@ int usb_i2c_board_is_enabled(void);
* Special i2c address to use when the client is required to execute some
* command which does not directly involve the i2c master driver.
*/
-#define USB_I2C_CMD_ADDR 0xf0
+#define USB_I2C_CMD_ADDR__7bf 0x78
/*
* Function to call to register a handler for commands sent to the special i2c
diff --git a/include/usb_mux.h b/include/usb_mux.h
index ff2704d2b6..94e2d6dbac 100644
--- a/include/usb_mux.h
+++ b/include/usb_mux.h
@@ -27,7 +27,7 @@ typedef uint8_t mux_state_t;
*/
#define MUX_PORT_AND_ADDR(port, addr) ((port << 8) | (addr & 0xFF))
#define MUX_PORT(port) (usb_muxes[port].port_addr >> 8)
-#define MUX_ADDR(port) (usb_muxes[port].port_addr & 0xFF)
+#define MUX_ADDR__7bf(port) (usb_muxes[port].port_addr & 0xFF)
/* Mux state attributes */
/* TODO: Directly use USB_PD_MUX_* everywhere and remove these 3 defines */
@@ -143,29 +143,31 @@ extern struct usb_mux usb_muxes[];
static inline int mux_write(int port, int reg, int val)
{
return usb_muxes[port].flags & USB_MUX_FLAG_NOT_TCPC
- ? i2c_write8(MUX_PORT(port), MUX_ADDR(port), reg, val)
- : tcpc_write(port, reg, val);
+ ? i2c_write8__7bf(MUX_PORT(port), MUX_ADDR__7bf(port), reg, val)
+ : tcpc_write(port, reg, val);
}
static inline int mux_read(int port, int reg, int *val)
{
return usb_muxes[port].flags & USB_MUX_FLAG_NOT_TCPC
- ? i2c_read8(MUX_PORT(port), MUX_ADDR(port), reg, val)
- : tcpc_read(port, reg, val);
+ ? i2c_read8__7bf(MUX_PORT(port), MUX_ADDR__7bf(port), reg, val)
+ : tcpc_read(port, reg, val);
}
static inline int mux_write16(int port, int reg, int val)
{
return usb_muxes[port].flags & USB_MUX_FLAG_NOT_TCPC
- ? i2c_write16(MUX_PORT(port), MUX_ADDR(port), reg, val)
- : tcpc_write16(port, reg, val);
+ ? i2c_write16__7bf(MUX_PORT(port), MUX_ADDR__7bf(port),
+ reg, val)
+ : tcpc_write16(port, reg, val);
}
static inline int mux_read16(int port, int reg, int *val)
{
return usb_muxes[port].flags & USB_MUX_FLAG_NOT_TCPC
- ? i2c_read16(MUX_PORT(port), MUX_ADDR(port), reg, val)
- : tcpc_read16(port, reg, val);
+ ? i2c_read16__7bf(MUX_PORT(port), MUX_ADDR__7bf(port),
+ reg, val)
+ : tcpc_read16(port, reg, val);
}
#endif /* CONFIG_USB_PD_TCPM_MUX */
diff --git a/include/usb_pd_tcpc.h b/include/usb_pd_tcpc.h
index f5785921a4..ba911f00ad 100644
--- a/include/usb_pd_tcpc.h
+++ b/include/usb_pd_tcpc.h
@@ -18,9 +18,11 @@
#ifdef TCPCI_I2C_SLAVE
/* Convert TCPC address to type-C port number */
-#define TCPC_ADDR_TO_PORT(addr) (((addr) - CONFIG_TCPC_I2C_BASE_ADDR) >> 1)
+#define TCPC_ADDR_TO_PORT(addr) ((addr) \
+ - I2C_GET_ADDR__7b(CONFIG_TCPC_I2C_BASE_ADDR__7BF))
/* Check if the i2c address belongs to TCPC */
-#define ADDR_IS_TCPC(addr) (((addr) & 0xfc) == CONFIG_TCPC_I2C_BASE_ADDR)
+#define ADDR_IS_TCPC(addr) (((addr) & 0x7E) \
+ == I2C_GET_ADDR__7b(CONFIG_TCPC_I2C_BASE_ADDR__7BF))
#endif
/**
diff --git a/include/usbc_ppc.h b/include/usbc_ppc.h
index fbd4385afc..3e74f37956 100644
--- a/include/usbc_ppc.h
+++ b/include/usbc_ppc.h
@@ -141,7 +141,7 @@ struct ppc_drv {
struct ppc_config_t {
int i2c_port;
- int i2c_addr;
+ uint16_t i2c_addr__7bf;
const struct ppc_drv *drv;
};
diff --git a/include/virtual_battery.h b/include/virtual_battery.h
index c686a76172..99fb30e03b 100644
--- a/include/virtual_battery.h
+++ b/include/virtual_battery.h
@@ -7,7 +7,7 @@
#define __CROS_EC_VIRTUAL_BATTERY_H
#if defined(CONFIG_I2C_VIRTUAL_BATTERY) && defined(CONFIG_BATTERY_SMART)
-#define VIRTUAL_BATTERY_ADDR BATTERY_ADDR
+#define VIRTUAL_BATTERY_ADDR__7bf BATTERY_ADDR__7bf
#endif
/**
diff --git a/test/battery_get_params_smart.c b/test/battery_get_params_smart.c
index 9a1eeda825..5ee62d3682 100644
--- a/test/battery_get_params_smart.c
+++ b/test/battery_get_params_smart.c
@@ -40,12 +40,14 @@ int sb_read(int cmd, int *param)
if (read_count >= fail_on_first && read_count <= fail_on_last)
return EC_ERROR_UNKNOWN;
- return i2c_read16(I2C_PORT_BATTERY, BATTERY_ADDR, cmd, param);
+ return i2c_read16__7bf(I2C_PORT_BATTERY, BATTERY_ADDR__7bf,
+ cmd, param);
}
int sb_write(int cmd, int param)
{
write_count++;
- return i2c_write16(I2C_PORT_BATTERY, BATTERY_ADDR, cmd, param);
+ return i2c_write16__7bf(I2C_PORT_BATTERY, BATTERY_ADDR__7bf,
+ cmd, param);
}
diff --git a/test/sbs_charging_v2.c b/test/sbs_charging_v2.c
index 06af4b4f00..7270173997 100644
--- a/test/sbs_charging_v2.c
+++ b/test/sbs_charging_v2.c
@@ -180,7 +180,7 @@ static int test_charge_state(void)
/* Detach battery, charging error */
ccprintf("[CHARGING TEST] Detach battery\n");
- TEST_ASSERT(test_detach_i2c(I2C_PORT_BATTERY, BATTERY_ADDR) ==
+ TEST_ASSERT(test_detach_i2c__7bf(I2C_PORT_BATTERY, BATTERY_ADDR__7bf) ==
EC_SUCCESS);
msleep(BATTERY_DETACH_DELAY);
state = wait_charging_state();
@@ -188,7 +188,7 @@ static int test_charge_state(void)
/* Attach battery again, charging */
ccprintf("[CHARGING TEST] Attach battery\n");
- test_attach_i2c(I2C_PORT_BATTERY, BATTERY_ADDR);
+ test_attach_i2c__7bf(I2C_PORT_BATTERY, BATTERY_ADDR__7bf);
/* And changing full capacity should trigger a host event */
ev_clear(EC_HOST_EVENT_BATTERY);
sb_write(SB_FULL_CHARGE_CAPACITY, 0xeff0);
diff --git a/util/ectool.c b/util/ectool.c
index 6b2b834742..fa08cb7917 100644
--- a/util/ectool.c
+++ b/util/ectool.c
@@ -25,6 +25,7 @@
#include "ec_flash.h"
#include "ec_version.h"
#include "ectool.h"
+#include "i2c.h"
#include "lightbar.h"
#include "lock/gec_lock.h"
#include "misc_util.h"
@@ -6341,7 +6342,8 @@ int cmd_locate_chip(int argc, char *argv[])
* (firmware_ECCbiEeprom) still passes. It may silently skip the test.
*/
printf("Bus: %s; Port: %d; Address: 0x%02x (7-bit format)\n",
- bus_type[r.bus_type], r.i2c_info.port, r.i2c_info.addr);
+ bus_type[r.bus_type], r.i2c_info.port,
+ I2C_GET_ADDR(r.i2c_info.addr_flags));
printf("reserved: 0x%x\n", r.reserved);