summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormike <mike5@huaqin.corp-partner.google.com>2021-07-19 11:23:27 +0800
committerCommit Bot <commit-bot@chromium.org>2021-07-21 03:24:14 +0000
commite9c269858b0a6dea237df5dd97be60fa2c16d469 (patch)
treee5f26ab2046d102ff38abceb416b473889878c71
parent0300ef969203bc462090496b0d14e7e839fc3921 (diff)
downloadchrome-ec-e9c269858b0a6dea237df5dd97be60fa2c16d469.tar.gz
storo: add 2nd accel source KX022
Add 2nd lid accel source KX022 BUG=b:188373186 BRANCH=dedede TEST=make BOARD=storo 1. Set CBI SSFC 0x11 and use command "ectool motionsense" for sensor kx022 2. test factory test pass Signed-off-by: mike <mike5@huaqin.corp-partner.google.com> Change-Id: Ibba58d53cf6fbfa35ba0c8e7fe73d4ebfdb9e7c8 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3037288 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Commit-Queue: Aseda Aboagye <aaboagye@chromium.org>
-rw-r--r--board/storo/board.c42
-rw-r--r--board/storo/board.h1
2 files changed, 43 insertions, 0 deletions
diff --git a/board/storo/board.c b/board/storo/board.c
index d4c36d5456..66cf1b1a63 100644
--- a/board/storo/board.c
+++ b/board/storo/board.c
@@ -15,6 +15,7 @@
#include "charger.h"
#include "driver/accel_lis2dw12.h"
#include "driver/accel_bma2x2.h"
+#include "driver/accel_kionix.h"
#include "driver/accelgyro_bmi_common.h"
#include "driver/accelgyro_icm_common.h"
#include "driver/accelgyro_icm42607.h"
@@ -664,6 +665,40 @@ struct motion_sensor_t lis2dwl_lid_accel = {
},
};
+static const mat33_fp_t lid_KX022_ref = {
+ { 0, FLOAT_TO_FP(1), 0},
+ { FLOAT_TO_FP(1), 0, 0},
+ { 0, 0, FLOAT_TO_FP(-1)}
+};
+
+static struct kionix_accel_data g_kx022_data;
+struct motion_sensor_t kx022_lid_accel = {
+ .name = "Lid Accel",
+ .active_mask = SENSOR_ACTIVE_S0_S3,
+ .chip = MOTIONSENSE_CHIP_KX022,
+ .type = MOTIONSENSE_TYPE_ACCEL,
+ .location = MOTIONSENSE_LOC_LID,
+ .drv = &kionix_accel_drv,
+ .mutex = &g_lid_mutex,
+ .drv_data = &g_kx022_data,
+ .port = I2C_PORT_ACCEL,
+ .i2c_spi_addr_flags = KX022_ADDR1_FLAGS,
+ .rot_standard_ref = &lid_KX022_ref,
+ .min_frequency = KX022_ACCEL_MIN_FREQ,
+ .max_frequency = KX022_ACCEL_MAX_FREQ,
+ .default_range = 2, /* g, to support tablet mode */
+ .config = {
+ /* EC use accel for angle detection */
+ [SENSOR_CONFIG_EC_S0] = {
+ .odr = 10000 | ROUND_UP_FLAG,
+ },
+ /* EC use accel for angle detection */
+ [SENSOR_CONFIG_EC_S3] = {
+ .odr = 10000 | ROUND_UP_FLAG,
+ },
+ },
+};
+
static struct icm_drv_data_t g_icm42607_data;
const mat33_fp_t based_ref_icm42607 = {
{ FLOAT_TO_FP(1), 0, 0},
@@ -762,6 +797,10 @@ void board_init(void)
if (get_cbi_ssfc_lid_sensor() == SSFC_SENSOR_LIS2DWL) {
motion_sensors[LID_ACCEL] = lis2dwl_lid_accel;
CPRINTF("LID_ACCEL is LIS2DWL");
+ } else if (get_cbi_ssfc_lid_sensor() ==
+ SSFC_SENSOR_KX022) {
+ motion_sensors[LID_ACCEL] = kx022_lid_accel;
+ CPRINTF("LID_ACCEL is KX022");
} else {
CPRINTF("LID_ACCEL is BMA253");
}
@@ -787,6 +826,9 @@ void board_init(void)
if (get_cbi_ssfc_lid_sensor() == SSFC_SENSOR_LIS2DWL) {
motion_sensors[LID_ACCEL] = lis2dwl_lid_accel;
CPRINTF("LID_ACCEL is LIS2DWL");
+ } else if (get_cbi_ssfc_lid_sensor() == SSFC_SENSOR_KX022) {
+ motion_sensors[LID_ACCEL] = kx022_lid_accel;
+ CPRINTF("LID_ACCEL is KX022");
} else {
CPRINTF("LID_ACCEL is BMA253");
}
diff --git a/board/storo/board.h b/board/storo/board.h
index 428ba7173c..a89bde6fcf 100644
--- a/board/storo/board.h
+++ b/board/storo/board.h
@@ -47,6 +47,7 @@
#define CONFIG_ACCEL_BMA255 /* Lid accel */
#define CONFIG_ACCEL_LIS2DWL
+#define CONFIG_ACCEL_KX022
#define CONFIG_ACCELGYRO_BMI160 /* Base accel */
#define CONFIG_ACCELGYRO_ICM42607