summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Chen <ben.chen2@quanta.corp-partner.google.com>2021-04-15 16:53:14 +0800
committerCommit Bot <commit-bot@chromium.org>2021-04-26 15:58:18 +0000
commitb24954fc10e8b24e0c1a9c6534f53ed42d0ed75f (patch)
treeae9601c9da83ef20c9d0a2fbbe3de4556300e7d9
parent0e0bfc9d105030c288685f0c09b66dbbb02eb078 (diff)
downloadchrome-ec-b24954fc10e8b24e0c1a9c6534f53ed42d0ed75f.tar.gz
voema: support kx022/bma255 with ssfc bits map
config kx022 or bma255 motion sensor by ssfc bits map, and rename volteer ssfc bits map. BUG=b:178447173 BRANCH=main TEST=Using ectool 'motionsense' verified lid angle now goes from 0 to 360 and swtiches to tablet mode after crossing 200 threshold on re-work kx022/bma255 DUT. Change-Id: I2901b0cc980e50324eb4f20d073c5f3a4c3f80e3 Signed-off-by: Ben Chen <ben.chen2@quanta.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2825719 Reviewed-by: Keith Short <keithshort@chromium.org> (cherry picked from commit 05884b519cd040f2dce139dc533b1e82008f92a9) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2850306 Tested-by: David Wu <david_wu@quanta.corp-partner.google.com> Auto-Submit: David Wu <david_wu@quanta.corp-partner.google.com> Reviewed-by: Zhuohao Lee <zhuohao@chromium.org> Commit-Queue: Zhuohao Lee <zhuohao@chromium.org>
-rw-r--r--baseboard/volteer/cbi_ssfc.h9
-rw-r--r--board/voema/board.h1
-rw-r--r--board/voema/sensors.c73
-rw-r--r--board/voxel/sensors.c8
4 files changed, 81 insertions, 10 deletions
diff --git a/baseboard/volteer/cbi_ssfc.h b/baseboard/volteer/cbi_ssfc.h
index 1583d74729..3039f3040c 100644
--- a/baseboard/volteer/cbi_ssfc.h
+++ b/baseboard/volteer/cbi_ssfc.h
@@ -17,8 +17,9 @@
*/
enum ec_ssfc_base_sensor {
SSFC_SENSOR_BASE_DEFAULT = 0,
- SSFC_SENSOR_BMI160 = 1,
- SSFC_SENSOR_ICM426XX = 2
+ SSFC_SENSOR_BASE_BMI160 = 1,
+ SSFC_SENSOR_BASE_ICM426XX = 2,
+ SSFC_SENSOR_BASE_KX022 = 3
};
/*
@@ -26,8 +27,8 @@ enum ec_ssfc_base_sensor {
*/
enum ec_ssfc_lid_sensor {
SSFC_SENSOR_LID_DEFAULT = 0,
- SSFC_SENSOR_BMA255 = 1,
- SSFC_SENSOR_KX022 = 2
+ SSFC_SENSOR_LID_BMA255 = 1,
+ SSFC_SENSOR_LID_KX022 = 2
};
/*
diff --git a/board/voema/board.h b/board/voema/board.h
index b2d401f69a..19a5ed83a0 100644
--- a/board/voema/board.h
+++ b/board/voema/board.h
@@ -35,6 +35,7 @@
/* Sensors */
/* BMA253 accelerometer in base */
#define CONFIG_ACCEL_BMA255
+#define CONFIG_ACCEL_KX022
/* TCS3400 ALS */
#define CONFIG_ALS
diff --git a/board/voema/sensors.c b/board/voema/sensors.c
index 818cda1a79..9328685a5f 100644
--- a/board/voema/sensors.c
+++ b/board/voema/sensors.c
@@ -6,7 +6,9 @@
/* Volteer family-specific sensor configuration */
#include "common.h"
#include "accelgyro.h"
+#include "cbi_ssfc.h"
#include "driver/accel_bma2x2.h"
+#include "driver/accel_kionix.h"
#include "driver/als_tcs3400.h"
#include "driver/sync.h"
#include "keyboard_scan.h"
@@ -25,6 +27,9 @@ static struct mutex g_base_mutex;
static struct accelgyro_saved_data_t g_bma253_base_data;
static struct accelgyro_saved_data_t g_bma253_lid_data;
+static struct kionix_accel_data g_kx022_base_data;
+static struct kionix_accel_data g_kx022_lid_data;
+
/* TCS3400 private data */
static struct als_drv_data_t g_tcs3400_data = {
.als_cal.scale = 1,
@@ -92,6 +97,60 @@ 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_lid_data,
+ .port = I2C_PORT_SENSOR,
+ .i2c_spi_addr_flags = KX022_ADDR0_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 kx022_basse_accel = {
+ .name = "Base Accel",
+ .active_mask = SENSOR_ACTIVE_S0_S3,
+ .chip = MOTIONSENSE_CHIP_KX022,
+ .type = MOTIONSENSE_TYPE_ACCEL,
+ .location = MOTIONSENSE_LOC_BASE,
+ .drv = &kionix_accel_drv,
+ .mutex = &g_lid_accel_mutex,
+ .drv_data = &g_kx022_base_data,
+ .port = I2C_PORT_SENSOR,
+ .i2c_spi_addr_flags = KX022_ADDR1_FLAGS,
+ .rot_standard_ref = &base_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",
@@ -193,10 +252,20 @@ BUILD_ASSERT(ARRAY_SIZE(motion_als_sensors) == ALS_COUNT);
static void baseboard_sensors_init(void)
{
- /* Note - BMA253 interrupt unused by EC */
-
/* Enable interrupt for the TCS3400 color light sensor */
gpio_enable_interrupt(GPIO_EC_ALS_RGB_INT_L);
+
+ if (get_cbi_ssfc_base_sensor() == SSFC_SENSOR_BASE_KX022) {
+ motion_sensors[BASE_ACCEL] = kx022_basse_accel;
+ ccprints("BASE_ACCEL is KX022");
+ } else
+ ccprints("BASE_ACCEL is BMA253");
+
+ 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");
}
DECLARE_HOOK(HOOK_INIT, baseboard_sensors_init, HOOK_PRIO_DEFAULT);
diff --git a/board/voxel/sensors.c b/board/voxel/sensors.c
index 1f93cb7c07..bc472f28df 100644
--- a/board/voxel/sensors.c
+++ b/board/voxel/sensors.c
@@ -207,14 +207,14 @@ unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors);
static void board_sensors_init(void)
{
if (ec_cfg_has_tabletmode()) {
- if (get_cbi_ssfc_base_sensor() == SSFC_SENSOR_ICM426XX) {
+ if (get_cbi_ssfc_base_sensor() == SSFC_SENSOR_BASE_ICM426XX) {
motion_sensors[BASE_ACCEL] = icm426xx_base_accel;
motion_sensors[BASE_GYRO] = icm426xx_base_gyro;
ccprints("BASE GYRO is ICM426XX");
} else
ccprints("BASE GYRO is BMI160");
- if (get_cbi_ssfc_lid_sensor() == SSFC_SENSOR_KX022) {
+ if (get_cbi_ssfc_lid_sensor() == SSFC_SENSOR_LID_KX022) {
motion_sensors[LID_ACCEL] = kx022_lid_accel;
ccprints("LID_ACCEL is KX022");
} else
@@ -236,10 +236,10 @@ DECLARE_HOOK(HOOK_INIT, board_sensors_init, HOOK_PRIO_DEFAULT);
void motion_interrupt(enum gpio_signal signal)
{
switch (get_cbi_ssfc_base_sensor()) {
- case SSFC_SENSOR_ICM426XX:
+ case SSFC_SENSOR_BASE_ICM426XX:
icm426xx_interrupt(signal);
break;
- case SSFC_SENSOR_BMI160:
+ case SSFC_SENSOR_BASE_BMI160:
default:
bmi160_interrupt(signal);
break;