summaryrefslogtreecommitdiff
path: root/board/asurada/board.c
diff options
context:
space:
mode:
authorTing Shen <phoenixshen@google.com>2020-06-03 14:13:53 +0800
committerCommit Bot <commit-bot@chromium.org>2020-06-05 11:24:35 +0000
commitdbdcf83655d83f0b6809fd47d9aaf0c667e2c812 (patch)
tree38657e20d7bf992171da37980126cb54309ca938 /board/asurada/board.c
parent2645ebbbd4aac058bf43c6102d366a50b4c1b364 (diff)
downloadchrome-ec-dbdcf83655d83f0b6809fd47d9aaf0c667e2c812.tar.gz
asurada: enable lid sensor LIS2DWL
BUG=b:150341271 TEST=1) `accelread 3` prints reasonable numbers. And the orientation is aligned with base IMU. 2) Combined with CL:2230218, `accelinfo on` to verify interrupt works. BRANCH=none Signed-off-by: Ting Shen <phoenixshen@google.com> Change-Id: Idb7177ebdb819704f4fa74c02ffdbf1a0031a377 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2215758 Reviewed-by: Eric Yilun Lin <yllin@chromium.org> Commit-Queue: Ting Shen <phoenixshen@chromium.org> Tested-by: Ting Shen <phoenixshen@chromium.org>
Diffstat (limited to 'board/asurada/board.c')
-rw-r--r--board/asurada/board.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/board/asurada/board.c b/board/asurada/board.c
index ebba48c30a..6db0d18ae2 100644
--- a/board/asurada/board.c
+++ b/board/asurada/board.c
@@ -12,6 +12,7 @@
#include "chipset.h"
#include "common.h"
#include "console.h"
+#include "driver/accel_lis2dw12.h"
#include "driver/accelgyro_bmi_common.h"
#include "driver/charger/isl923x.h"
#include "driver/ppc/syv682x.h"
@@ -102,6 +103,7 @@ static void board_init(void)
/* Enable motion sensor interrupt */
gpio_enable_interrupt(GPIO_BASE_IMU_INT_L);
+ gpio_enable_interrupt(GPIO_LID_ACCEL_INT_L);
}
DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT);
@@ -376,8 +378,10 @@ __override uint8_t board_get_usb_pd_port_count(void)
/* Sensor */
static struct mutex g_base_mutex;
+static struct mutex g_lid_mutex;
static struct bmi_drv_data_t g_bmi160_data;
+static struct stprivate_data g_lis2dwl_data;
/* Matrix to rotate accelerometer into standard reference frame */
static const mat33_fp_t base_standard_ref = {
@@ -460,5 +464,33 @@ struct motion_sensor_t motion_sensors[] = {
.min_frequency = BMM150_MAG_MIN_FREQ,
.max_frequency = BMM150_MAG_MAX_FREQ(SPECIAL),
},
+ [LID_ACCEL] = {
+ .name = "Lid Accel",
+ .active_mask = SENSOR_ACTIVE_S0_S3,
+ .chip = MOTIONSENSE_CHIP_LIS2DWL,
+ .type = MOTIONSENSE_TYPE_ACCEL,
+ .location = MOTIONSENSE_LOC_LID,
+ .drv = &lis2dw12_drv,
+ .mutex = &g_lid_mutex,
+ .drv_data = &g_lis2dwl_data,
+ .int_signal = GPIO_LID_ACCEL_INT_L,
+ .port = I2C_PORT_ACCEL,
+ .i2c_spi_addr_flags = LIS2DWL_ADDR1_FLAGS,
+ .flags = MOTIONSENSE_FLAG_INT_SIGNAL,
+ .rot_standard_ref = NULL, /* identity matrix */
+ .default_range = 2, /* g */
+ .min_frequency = LIS2DW12_ODR_MIN_VAL,
+ .max_frequency = LIS2DW12_ODR_MAX_VAL,
+ .config = {
+ /* EC use accel for angle detection */
+ [SENSOR_CONFIG_EC_S0] = {
+ .odr = 12500 | ROUND_UP_FLAG,
+ },
+ /* Sensor on for lid angle detection */
+ [SENSOR_CONFIG_EC_S3] = {
+ .odr = 10000 | ROUND_UP_FLAG,
+ },
+ },
+ },
};
const unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors);