summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGwendal Grignou <gwendal@chromium.org>2018-11-30 16:23:40 -0800
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2019-02-11 04:44:55 +0000
commit14a5d41c6d1e82f47ed1545e703b23843b0eab18 (patch)
treed1400edd67fc6a1038ed17c0c0ff688194f320bb
parent216c0db7975c236c38f54de40a6330f0afec3694 (diff)
downloadchrome-ec-14a5d41c6d1e82f47ed1545e703b23843b0eab18.tar.gz
config: Add magnetometer definitions
Add all possible supported or soon-to-be supported configuration of magnetometer behind accelerometers. Use a more generic variable to indicate the i2c address of the secondary device. BUG=b:110143516,b:115587004 BRANCH=none TEST=compile Change-Id: Ic00c413f2ec5fa0e6bf1c98861daa02f00769a65 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1361989 Commit-Ready: Karthikeyan Ramasubramanian <kramasub@chromium.org> Tested-by: Justin TerAvest <teravest@chromium.org> Reviewed-by: Karthikeyan Ramasubramanian <kramasub@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org> (cherry picked from commit ab7fad125320bb719c7bfae952ffa9b8589113ee) Reviewed-on: https://chromium-review.googlesource.com/c/1460281 Reviewed-by: Justin TerAvest <teravest@chromium.org> Commit-Queue: Justin TerAvest <teravest@chromium.org> Trybot-Ready: Justin TerAvest <teravest@chromium.org>
-rw-r--r--board/eve/board.h2
-rw-r--r--board/kukui/board.h2
-rw-r--r--board/poppy/board.h2
-rw-r--r--board/reef/board.h2
-rw-r--r--board/reef_mchp/board.h2
-rw-r--r--driver/accelgyro_bmi160.c2
-rw-r--r--include/config.h72
7 files changed, 69 insertions, 15 deletions
diff --git a/board/eve/board.h b/board/eve/board.h
index ea276e5873..98f1429fac 100644
--- a/board/eve/board.h
+++ b/board/eve/board.h
@@ -126,7 +126,7 @@
#define CONFIG_MAG_BMI160_BMM150
#define CONFIG_ACCEL_INTERRUPTS
#define CONFIG_ACCELGYRO_BMI160_INT_EVENT TASK_EVENT_CUSTOM(4)
-#define BMI160_SEC_ADDR BMM150_ADDR0 /* 8-bit address */
+#define CONFIG_ACCELGYRO_SEC_ADDR BMM150_ADDR0 /* 8-bit address */
#define CONFIG_MAG_CALIBRATE
#define CONFIG_LID_ANGLE
#define CONFIG_LID_ANGLE_UPDATE
diff --git a/board/kukui/board.h b/board/kukui/board.h
index 784d8fa83e..1a79d5118b 100644
--- a/board/kukui/board.h
+++ b/board/kukui/board.h
@@ -92,7 +92,7 @@
/* Motion Sensors */
#ifdef SECTION_IS_RW
#define CONFIG_MAG_BMI160_BMM150
-#define BMI160_SEC_ADDR BMM150_ADDR0 /* 8-bit address */
+#define CONFIG_ACCELGYRO_SEC_ADDR BMM150_ADDR0 /* 8-bit address */
#define CONFIG_MAG_CALIBRATE
#define CONFIG_ACCELGYRO_BMI160
#define CONFIG_ACCEL_INTERRUPTS
diff --git a/board/poppy/board.h b/board/poppy/board.h
index c7beac8fcf..cf030f0c91 100644
--- a/board/poppy/board.h
+++ b/board/poppy/board.h
@@ -127,7 +127,7 @@
#define CONFIG_MAG_BMI160_BMM150
#define CONFIG_ACCEL_INTERRUPTS
#define CONFIG_ACCELGYRO_BMI160_INT_EVENT TASK_EVENT_CUSTOM(4)
-#define BMI160_SEC_ADDR BMM150_ADDR0 /* 8-bit address */
+#define CONFIG_ACCELGYRO_SEC_ADDR BMM150_ADDR0 /* 8-bit address */
#define CONFIG_MAG_CALIBRATE
/* Lower maximal ODR to 100Hz */
#define CONFIG_EC_MAX_SENSOR_FREQ_MILLIHZ 100000
diff --git a/board/reef/board.h b/board/reef/board.h
index 3c4577ef2b..83facd8c04 100644
--- a/board/reef/board.h
+++ b/board/reef/board.h
@@ -195,7 +195,7 @@
#define CONFIG_ACCEL_INTERRUPTS
#define CONFIG_ACCELGYRO_BMI160_INT_EVENT TASK_EVENT_CUSTOM(4)
#define CONFIG_MAG_BMI160_BMM150
-#define BMI160_SEC_ADDR BMM150_ADDR0 /* 8-bit address */
+#define CONFIG_ACCELGYRO_SEC_ADDR BMM150_ADDR0 /* 8-bit address */
#define CONFIG_MAG_CALIBRATE
#define CONFIG_ACCEL_KX022
#define CONFIG_ALS_OPT3001
diff --git a/board/reef_mchp/board.h b/board/reef_mchp/board.h
index 1177268f20..7b6cdfbbe8 100644
--- a/board/reef_mchp/board.h
+++ b/board/reef_mchp/board.h
@@ -202,7 +202,7 @@
#define CONFIG_ACCEL_INTERRUPTS
#define CONFIG_ACCELGYRO_BMI160_INT_EVENT TASK_EVENT_CUSTOM(4)
#define CONFIG_MAG_BMI160_BMM150
-#define BMI160_SEC_ADDR BMM150_ADDR0 /* 8-bit address */
+#define CONFIG_ACCELGYRO_SEC_ADDR BMM150_ADDR0 /* 8-bit address */
#define CONFIG_MAG_CALIBRATE
#define CONFIG_ACCEL_KX022
#define CONFIG_ALS_OPT3001
diff --git a/driver/accelgyro_bmi160.c b/driver/accelgyro_bmi160.c
index f573a463e4..00e46ce705 100644
--- a/driver/accelgyro_bmi160.c
+++ b/driver/accelgyro_bmi160.c
@@ -1279,7 +1279,7 @@ static int init(const struct motion_sensor_t *s)
/* Set the i2c address of the compass */
ret = raw_write8(s->port, s->addr, BMI160_MAG_IF_0,
- BMI160_SEC_ADDR);
+ CONFIG_ACCELGYRO_SEC_ADDR);
/* Enable the secondary interface as I2C */
ret = raw_write8(s->port, s->addr, BMI160_IF_CONF,
diff --git a/include/config.h b/include/config.h
index 9a693a0dbc..40726e1885 100644
--- a/include/config.h
+++ b/include/config.h
@@ -75,18 +75,46 @@
#undef CONFIG_ACCEL_LIS2DH
#undef CONFIG_ACCEL_LIS2DE
#undef CONFIG_ACCEL_LIS2D_COMMON
-#undef CONFIG_ACCELGYRO_LSM6DS0
#undef CONFIG_ACCELGYRO_BMI160
+#undef CONFIG_ACCELGYRO_LSM6DS0
#undef CONFIG_ACCELGYRO_LSM6DSM
-#undef CONFIG_MAG_LIS2MDL
+/* Add sensorhub function for LSM6DSM, required if 2nd device attached. */
#undef CONFIG_SENSORHUB_LSM6DSM
+/* Specify type of Magnetometer attached. */
+#undef CONFIG_MAG_LIS2MDL
+#undef CONFIG_MAG_BMM150
+
+/* Presence of a Bosh Sensortec BMM150 magnetometer behind a BMI160. */
+#undef CONFIG_MAG_BMI160_BMM150
+
+/* Presence of a Bosh Sensortec BMM150 magnetometer behind a LSM6DSM. */
+#undef CONFIG_MAG_LSM6DSM_BMM150
+
+/* Presence of a ST LIS2MDL magnetometer behind a BMI160. */
+#undef CONFIG_MAG_BMI160_LIS2MDL
+
+/* Presence of a ST LIS2MDL magnetometer behind a LSM6DSM. */
+#undef CONFIG_MAG_LSM6DSM_LIS2MDL
+
+/* Specify barometer attached */
+#undef CONFIG_BARO_BMP280
+
+/* When set, it indicates a secondary sensor is attached behind a BMI160. */
+#undef CONFIG_BMI160_SEC_I2C
+
+/* When set, it indicates a secondary sensor is attached behind a LSM6DSM/L. */
+#undef CONFIG_LSM6DSM_SEC_I2C
+
/* Support for BMI160 hardware orientation sensor */
#undef CONFIG_BMI160_ORIENTATION_SENSOR
/* Support for KIONIX KX022 hardware orientation sensor */
#undef CONFIG_KX022_ORIENTATION_SENSOR
+/* Define the i2c address of the sensor behind the main sensor, if present. */
+#undef CONFIG_ACCELGYRO_SEC_ADDR
+
/*
* Define if either CONFIG_BMI160_ORIENTATION_SUPPORT or
* CONFIG_KX022_ORIENTATION_SUPPORT is set.
@@ -96,9 +124,6 @@
/* Support the orientation gesture */
#undef CONFIG_GESTURE_ORIENTATION
-/* Specify barometer attached */
-#undef CONFIG_BARO_BMP280
-
/*
* Use the old standard reference frame for accelerometers. The old
* reference frame is:
@@ -2390,9 +2415,6 @@
/* Include code to do online compass calibration */
#undef CONFIG_MAG_CALIBRATE
-/* Presence of a Bosh Sensortec BMM150 magnetometer behind a BMI160. */
-#undef CONFIG_MAG_BMI160_BMM150
-
/* Microchip LPC enable debug messages */
#undef CONFIG_MCHP_DEBUG_LPC
@@ -4130,10 +4152,42 @@
#endif
/* Enable BMI160 secondary port if needed. */
-#ifdef CONFIG_MAG_BMI160_BMM150
+#if defined(CONFIG_MAG_BMI160_BMM150) || \
+ defined(CONFIG_MAG_BMI160_LIS2MDL)
#define CONFIG_BMI160_SEC_I2C
#endif
+/* Enable LSM2MDL secondary port if needed. */
+#if defined(CONFIG_MAG_LSM6DSM_BMM150) || \
+ defined(CONFIG_MAG_LSM6DSM_LIS2MDL)
+#define CONFIG_LSM6DSM_SEC_I2C
+#endif
+
+/* Load LIS2MDL driver if needed */
+#if defined(CONFIG_MAG_BMI160_LIS2MDL) || \
+ defined(CONFIG_MAG_LSM6DSM_LIS2MDL)
+#define CONFIG_MAG_LIS2MDL
+#ifndef CONFIG_ACCELGYRO_SEC_ADDR
+#error "The i2c address of the magnetometer is not set."
+#endif
+#endif
+
+/* Load BMM150 driver if needed */
+#if defined(CONFIG_MAG_BMI160_BMM150) || \
+ defined(CONFIG_MAG_LSM6DSM_BMM150)
+#define CONFIG_MAG_BMM150
+#ifndef CONFIG_ACCELGYRO_SEC_ADDR
+#error "The i2c address of the magnetometer is not set."
+#endif
+#endif
+
+/* Verify sensorhub is enabled */
+#ifdef CONFIG_MAG_LSM6DSM_LIS2MDL
+#ifndef CONFIG_SENSORHUB_LSM6DSM
+#error "Enable SENSORHUB_LSM6DSM."
+#endif
+#endif
+
/*
* TODO(crbug.com/888109): Makes sure RDP as PSTATE is only enabled where it
* makes sense.