summaryrefslogtreecommitdiff
path: root/board/volteer_ish
diff options
context:
space:
mode:
authorli feng <li1.feng@intel.com>2019-12-16 18:02:20 -0800
committerCommit Bot <commit-bot@chromium.org>2020-01-11 02:39:26 +0000
commit55a94823a9e772a64fed8ae18c6fb7c46a0aa02c (patch)
tree5fb0363bca13ef4ef27f449637a1b23f93c1a8cb /board/volteer_ish
parent43d35e28ae67077797b0f6bc4cfd6afe2ce0e70a (diff)
downloadchrome-ec-55a94823a9e772a64fed8ae18c6fb7c46a0aa02c.tar.gz
volteer ish: enable lid accelerometer.
Lid accelerometer is BMA253, driver accel_bma2x2.c is used. Reference to this CL: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1965647 BMA253 uses polling mode since it doesn't have hardware FIFO. IMU BMI260 will be enabled when driver is available. b:146144827 is tracking this. BUG=b:145946347 BRANCH=none TEST=Verified host iio device has lid accel, can read name/location/x, y, z raw data, etc. Change-Id: I5581c33e7245448604ac964f9df0559f2e0327b2 Signed-off-by: li feng <li1.feng@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1983458 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
Diffstat (limited to 'board/volteer_ish')
-rw-r--r--board/volteer_ish/board.c24
-rw-r--r--board/volteer_ish/board.h16
2 files changed, 39 insertions, 1 deletions
diff --git a/board/volteer_ish/board.c b/board/volteer_ish/board.c
index f888ff60fe..7882708653 100644
--- a/board/volteer_ish/board.c
+++ b/board/volteer_ish/board.c
@@ -28,10 +28,32 @@ const struct i2c_port_t i2c_ports[] = {
};
const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports);
+/* Sensor config */
+static struct mutex g_lid_mutex;
+
+/* sensor private data */
+static struct accelgyro_saved_data_t g_bma253_data;
+
/* Drivers */
+/* TODO(b/146144170): Implement rotation matrix once sensor moves to lid */
struct motion_sensor_t motion_sensors[] = {
+ [LID_ACCEL] = {
+ .name = "Lid Accel",
+ .active_mask = SENSOR_ACTIVE_S0_S3,
+ .chip = MOTIONSENSE_CHIP_BMA255,
+ .type = MOTIONSENSE_TYPE_ACCEL,
+ .location = MOTIONSENSE_LOC_LID,
+ .drv = &bma2x2_accel_drv,
+ .mutex = &g_lid_mutex,
+ .drv_data = &g_bma253_data,
+ .port = I2C_PORT_SENSOR,
+ .i2c_spi_addr_flags = BMA2x2_I2C_ADDR1_FLAGS,
+ .rot_standard_ref = NULL, /* Update when matrix available */
+ .min_frequency = BMA255_ACCEL_MIN_FREQ,
+ .max_frequency = BMA255_ACCEL_MAX_FREQ,
+ .default_range = 2, /* g, to support tablet mode */
+ },
};
-
const unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors);
int chipset_in_state(int state_mask)
diff --git a/board/volteer_ish/board.h b/board/volteer_ish/board.h
index 3adfcb07c5..b290d70b19 100644
--- a/board/volteer_ish/board.h
+++ b/board/volteer_ish/board.h
@@ -31,12 +31,27 @@
#define CONFIG_I2C
#define CONFIG_I2C_MASTER
+/* BMA253 Lid accel */
+#define CONFIG_ACCEL_BMA255
+
/* Host command over HECI */
#define CONFIG_HOSTCMD_HECI
#define CONFIG_MKBP_EVENT
#define CONFIG_MKBP_USE_HECI
+#define CONFIG_ACCEL_INTERRUPTS
+
+/* Enable sensor fifo, must also define the _SIZE and _THRES */
+#define CONFIG_ACCEL_FIFO
+/* FIFO size is in power of 2. */
+#define CONFIG_ACCEL_FIFO_SIZE 512
+/* Depends on how fast the AP boots and typical ODRs */
+#define CONFIG_ACCEL_FIFO_THRES (CONFIG_ACCEL_FIFO_SIZE / 3)
+
+/* Sensors without hardware FIFO are in forced mode */
+#define CONFIG_ACCEL_FORCE_MODE_MASK (BIT(LID_ACCEL))
+
/* I2C ports */
#define I2C_PORT_SENSOR ISH_I2C1
#define CONFIG_CMD_I2C_XFER
@@ -74,6 +89,7 @@
/* Motion sensors */
enum sensor_id {
+ LID_ACCEL,
SENSOR_COUNT
};