summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael5 Chen1 <michael5_chen1@pegatron.corp-partner.google.com>2021-05-25 10:44:55 +0800
committerCommit Bot <commit-bot@chromium.org>2021-05-31 10:06:01 +0000
commit4319470ce35f471681c776df2f65dbce9efa71f2 (patch)
tree3a2f434f047d08f7814a4db9d980fab29a541dd6
parente726bc35b41ae6be47f1e56ec9e4eb5ccb31ef60 (diff)
downloadchrome-ec-4319470ce35f471681c776df2f65dbce9efa71f2.tar.gz
delbin: gyro sensor add 2nd source KX022
Gyro sensor add 2nd source KX022. BUG=b:187138428 BRANCH=volteer TEST=manual 1. Set CBI SSFC 0x10 and using command "ectool motionsense" for sensor kxo22. 2. Using command "ectool motionsense" for sensor BMA253. Signed-off-by: Michael5 Chen1 <michael5_chen1@pegatron.corp-partner.google.com> Change-Id: I82f67e3fa3ad5285db58a7cc0f98aaf112e6898f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2910570 Tested-by: Zhuohao Lee <zhuohao@chromium.org> Reviewed-by: Zhuohao Lee <zhuohao@chromium.org> Commit-Queue: Zhuohao Lee <zhuohao@chromium.org>
-rw-r--r--board/delbin/board.h1
-rw-r--r--board/delbin/sensors.c39
2 files changed, 38 insertions, 2 deletions
diff --git a/board/delbin/board.h b/board/delbin/board.h
index 59af4d864a..699abccf68 100644
--- a/board/delbin/board.h
+++ b/board/delbin/board.h
@@ -45,6 +45,7 @@
/* Sensors */
/* BMA253 accelerometer in base */
#define CONFIG_ACCEL_BMA255
+#define CONFIG_ACCEL_KX022
/* BMI260 accel/gyro in base */
#define CONFIG_ACCELGYRO_BMI260
diff --git a/board/delbin/sensors.c b/board/delbin/sensors.c
index d5413769d5..a2b2eb47e4 100644
--- a/board/delbin/sensors.c
+++ b/board/delbin/sensors.c
@@ -6,7 +6,10 @@
/* Volteer family-specific sensor configuration */
#include "common.h"
#include "accelgyro.h"
+#include "cbi_ec_fw_config.h"
+#include "cbi_ssfc.h"
#include "driver/accel_bma2x2.h"
+#include "driver/accel_kionix.h"
#include "driver/accelgyro_bmi_common.h"
#include "driver/accelgyro_bmi260.h"
#include "keyboard_scan.h"
@@ -23,6 +26,7 @@ static struct mutex g_base_mutex;
/* BMA253 private data */
static struct accelgyro_saved_data_t g_bma253_data;
+static struct kionix_accel_data g_kx022_data;
/* BMI260 private data */
static struct bmi_drv_data_t g_bmi260_data;
@@ -40,6 +44,33 @@ const mat33_fp_t base_standard_ref = {
{ 0, 0, FLOAT_TO_FP(1)}
};
+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_accel_mutex,
+ .drv_data = &g_kx022_data,
+ .port = I2C_PORT_ACCEL,
+ .i2c_spi_addr_flags = KX022_ADDR1_FLAGS,
+ .rot_standard_ref = &lid_standard_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,
+ },
+ },
+};
+
struct motion_sensor_t motion_sensors[] = {
[LID_ACCEL] = {
.name = "Lid Accel",
@@ -117,9 +148,13 @@ unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors);
static void baseboard_sensors_init(void)
{
- /* Note - BMA253 interrupt unused by EC */
+ if (get_cbi_ssfc_lid_sensor() == SSFC_SENSOR_LID_KX022) {
+ motion_sensors[LID_ACCEL] = kx022_lid_accel;
+ ccprints("LID_ACCEL is KX022");
+ } else
+ ccprints("LID_ACCEL is BMA253");
- /* Enable interrupt for the BMI260 accel/gyro sensor */
+ /* Enable interrupt for the accel/gyro sensor */
gpio_enable_interrupt(GPIO_EC_IMU_INT_L);
}
DECLARE_HOOK(HOOK_INIT, baseboard_sensors_init, HOOK_PRIO_DEFAULT);