summaryrefslogtreecommitdiff
path: root/driver/mag_lis2mdl.c
diff options
context:
space:
mode:
authorDenis Brockus <dbrockus@chromium.org>2019-06-25 12:44:16 -0600
committerCommit Bot <commit-bot@chromium.org>2019-07-19 21:11:02 +0000
commitd1a18f82ed831d4e640336ff5571f5fa64bc7b36 (patch)
treec46aeb6136de1c27c66e3d5f662e9620161bef7b /driver/mag_lis2mdl.c
parent1f14229fa7e499dfcee07d17add187598ff0a46c (diff)
downloadchrome-ec-d1a18f82ed831d4e640336ff5571f5fa64bc7b36.tar.gz
Use 7bit I2C/SPI slave addresses in EC
Opt for 7bit slave addresses in EC code. If 8bit is expected by a driver, make it local and show this in the naming. Use __7b, __7bf and __8b as name extensions for i2c/spi addresses used in the EC codebase. __7b indicates a 7bit address by itself. __7bf indicates a 7bit address with optional flags attached. __8b indicates a 8bit address by itself. Allow space for 10bit addresses, even though this is not currently being used by any of our attached devices. These extensions are for verification purposes only and will be removed in the last pass of this ticket. I want to make sure the variable names reflect the type to help eliminate future 7/8/7-flags confusion. BUG=chromium:971296 BRANCH=none TEST=make buildall -j Change-Id: I2fc3d1b52ce76184492b2aaff3060f486ca45f45 Signed-off-by: Denis Brockus <dbrockus@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1699893 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
Diffstat (limited to 'driver/mag_lis2mdl.c')
-rw-r--r--driver/mag_lis2mdl.c30
1 files changed, 16 insertions, 14 deletions
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);
}