summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacky Wang <jacky5_wang@pegatron.corp-partner.google.com>2021-06-10 15:29:13 +0800
committerCommit Bot <commit-bot@chromium.org>2021-06-11 21:24:50 +0000
commit6c92e8efa30f7cfb78b39f60a7bc30804b409ed9 (patch)
tree196346b1474e022b84b8a7c5dfabd003b8a1fb80
parentff835e2d116959e8b1a618bf1110f8cbde59ffa1 (diff)
downloadchrome-ec-6c92e8efa30f7cfb78b39f60a7bc30804b409ed9.tar.gz
copano: gyro sensor add 2nd source KX022
Gyro sensor add 2nd source KX022. BUG=b:190644307 BRANCH=firmware-volteer-13672.B TEST=make BOARD=copano 1. Set CBI SSFC 0x10 and using command "ectool motionsense" for sensor kxo22. 2. Using command "ectool motionsense" for sensor BMA253. Signed-off-by: Jacky Wang <jacky5_wang@pegatron.corp-partner.google.com> Change-Id: I73a5b915dcb67df58780a01873f81fe5719299d0 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2952286 Reviewed-by: Zhuohao Lee <zhuohao@chromium.org>
-rw-r--r--board/copano/board.h1
-rw-r--r--board/copano/sensors.c39
2 files changed, 38 insertions, 2 deletions
diff --git a/board/copano/board.h b/board/copano/board.h
index 43e194dca9..07d63ede3f 100644
--- a/board/copano/board.h
+++ b/board/copano/board.h
@@ -41,6 +41,7 @@
/* Sensors */
/* BMA253 accelerometer in base */
#define CONFIG_ACCEL_BMA255
+#define CONFIG_ACCEL_KX022
/* BMI160 accel/gyro in base */
#define CONFIG_ACCELGYRO_BMI160
diff --git a/board/copano/sensors.c b/board/copano/sensors.c
index ba667f755c..2f26911576 100644
--- a/board/copano/sensors.c
+++ b/board/copano/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_bmi160.h"
#include "driver/sync.h"
@@ -24,6 +27,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;
/* BMI160 private data */
static struct bmi_drv_data_t g_bmi160_data;
@@ -41,6 +45,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",
@@ -118,9 +149,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 BMI160 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);