summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Huang <david.huang@quanta.corp-partner.google.com>2021-08-16 15:18:40 +0800
committerCommit Bot <commit-bot@chromium.org>2021-08-23 23:55:28 +0000
commit14d1cd8c83e7b6f1329688ad76dbb35b07f40654 (patch)
treec1ca17e1956f6113d39d57d2810e59f35b37a7ac
parentbb5e2a541f5188b0ac773846fc08cbea4571fdb6 (diff)
downloadchrome-ec-14d1cd8c83e7b6f1329688ad76dbb35b07f40654.tar.gz
kano: change lid accel and base accel/gyro
Change Lid accel to kx022 and base accel/gyro to icm40608. BUG=b:192370253 BRANCH=brya TEST=make buildall -j succeeded. Signed-off-by: David Huang <david.huang@quanta.corp-partner.google.com> Change-Id: I034c2da62d1671294b4ce81536a0254a67c63240 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3098118 Reviewed-by: caveh jalali <caveh@chromium.org> Reviewed-by: Boris Mittelberg <bmbm@google.com> Commit-Queue: Boris Mittelberg <bmbm@google.com>
-rw-r--r--board/kano/board.c2
-rw-r--r--board/kano/board.h13
-rw-r--r--board/kano/generated-gpio.inc3
-rw-r--r--board/kano/sensors.c70
4 files changed, 44 insertions, 44 deletions
diff --git a/board/kano/board.c b/board/kano/board.c
index 3701d5bfbf..07dfc2cd5a 100644
--- a/board/kano/board.c
+++ b/board/kano/board.c
@@ -13,8 +13,6 @@
#include "gpio.h"
#include "gpio_signal.h"
#include "hooks.h"
-#include "driver/accel_lis2dw12.h"
-#include "driver/accelgyro_lsm6dso.h"
#include "fw_config.h"
#include "hooks.h"
#include "lid_switch.h"
diff --git a/board/kano/board.h b/board/kano/board.h
index 8c6164df54..2f1103ae09 100644
--- a/board/kano/board.h
+++ b/board/kano/board.h
@@ -39,8 +39,9 @@
#define CONFIG_LED_PWM_LOW_BATT_COLOR EC_LED_COLOR_AMBER
/* Sensors */
-#define CONFIG_ACCELGYRO_LSM6DSO /* Base accel */
-#define CONFIG_ACCEL_LSM6DSO_INT_EVENT \
+#define CONFIG_ACCELGYRO_ICM426XX /* Base accel */
+#define CONFIG_ACCELGYRO_ICM_COMM_I2C
+#define CONFIG_ACCELGYRO_ICM426XX_INT_EVENT \
TASK_EVENT_MOTION_SENSOR_INTERRUPT(BASE_ACCEL)
/* Enable sensor fifo, must also define the _SIZE and _THRES */
@@ -55,12 +56,10 @@
/* Lid accel */
#define CONFIG_LID_ANGLE
+#define CONFIG_LID_ANGLE_UPDATE
#define CONFIG_LID_ANGLE_SENSOR_BASE BASE_ACCEL
#define CONFIG_LID_ANGLE_SENSOR_LID LID_ACCEL
-#define CONFIG_ACCEL_LIS2DWL
-#define CONFIG_ACCEL_LIS2DW_AS_BASE
-#define CONFIG_ACCEL_LIS2DW12_INT_EVENT \
- TASK_EVENT_MOTION_SENSOR_INTERRUPT(LID_ACCEL)
+#define CONFIG_ACCEL_KX022
#define CONFIG_ACCEL_INTERRUPTS
@@ -241,6 +240,8 @@ enum mft_channel {
MFT_CH_COUNT
};
+void motion_interrupt(enum gpio_signal signal);
+
#endif /* !__ASSEMBLER__ */
#endif /* __CROS_EC_BOARD_H */
diff --git a/board/kano/generated-gpio.inc b/board/kano/generated-gpio.inc
index 0b741188e9..d65d64feca 100644
--- a/board/kano/generated-gpio.inc
+++ b/board/kano/generated-gpio.inc
@@ -4,8 +4,7 @@
/* INTERRUPT GPIOs: */
GPIO_INT(ACOK_OD, PIN(0, 0), GPIO_INT_BOTH | GPIO_HIB_WAKE_HIGH, extpower_interrupt)
-GPIO_INT(EC_ACCEL_INT_R_L, PIN(8, 1), GPIO_SEL_1P8V | GPIO_INT_FALLING, lis2dw12_interrupt)
-GPIO_INT(EC_IMU_INT_R_L, PIN(5, 6), GPIO_SEL_1P8V | GPIO_INT_FALLING, lsm6dso_interrupt)
+GPIO_INT(EC_IMU_INT_R_L, PIN(5, 6), GPIO_SEL_1P8V | GPIO_INT_FALLING, motion_interrupt)
GPIO_INT(EC_PROCHOT_IN_L, PIN(F, 0), GPIO_INT_BOTH, throttle_ap_prochot_input_interrupt)
GPIO_INT(EC_VOLDN_BTN_ODL, PIN(9, 3), GPIO_INT_BOTH | GPIO_PULL_UP, button_interrupt)
GPIO_INT(EC_VOLUP_BTN_ODL, PIN(9, 7), GPIO_INT_BOTH | GPIO_PULL_UP, button_interrupt)
diff --git a/board/kano/sensors.c b/board/kano/sensors.c
index 4a90179cf4..f49c356a6f 100644
--- a/board/kano/sensors.c
+++ b/board/kano/sensors.c
@@ -6,8 +6,9 @@
#include "common.h"
#include "accelgyro.h"
#include "adc_chip.h"
-#include "driver/accel_lis2dw12.h"
-#include "driver/accelgyro_lsm6dso.h"
+#include "driver/accelgyro_icm426xx.h"
+#include "driver/accelgyro_icm_common.h"
+#include "driver/accel_kionix.h"
#include "hooks.h"
#include "motion_sense.h"
#include "temp_sensor.h"
@@ -42,41 +43,41 @@ BUILD_ASSERT(ARRAY_SIZE(adc_channels) == ADC_CH_COUNT);
K_MUTEX_DEFINE(g_lid_accel_mutex);
K_MUTEX_DEFINE(g_base_accel_mutex);
-static struct stprivate_data g_lis2dw12_data;
-static struct lsm6dso_data lsm6dso_data;
+static struct kionix_accel_data g_kx022_data;
+static struct icm_drv_data_t g_icm426xx_data;
-/* TODO(b/184779333): calibrate the orientation matrix on later board stage */
+/*
+ * TODO:(b/197200940): Verify lid and base orientation
+ * matrix on proto board.
+ */
static const mat33_fp_t lid_standard_ref = {
- { 0, FLOAT_TO_FP(1), 0},
- { FLOAT_TO_FP(1), 0, 0},
+ { FLOAT_TO_FP(-1), 0, 0},
+ { 0, FLOAT_TO_FP(-1), 0},
{ 0, 0, FLOAT_TO_FP(-1)}
};
-
-/* TODO(b/184779743): verify orientation matrix */
static const mat33_fp_t base_standard_ref = {
{ FLOAT_TO_FP(1), 0, 0},
- { 0, FLOAT_TO_FP(-1), 0},
- { 0, 0, FLOAT_TO_FP(-1)}
+ { 0, FLOAT_TO_FP(1), 0},
+ { 0, 0, FLOAT_TO_FP(1)}
};
struct motion_sensor_t motion_sensors[] = {
[LID_ACCEL] = {
.name = "Lid Accel",
.active_mask = SENSOR_ACTIVE_S0_S3,
- .chip = MOTIONSENSE_CHIP_LIS2DW12,
+ .chip = MOTIONSENSE_CHIP_KX022,
.type = MOTIONSENSE_TYPE_ACCEL,
.location = MOTIONSENSE_LOC_LID,
- .drv = &lis2dw12_drv,
+ .drv = &kionix_accel_drv,
.mutex = &g_lid_accel_mutex,
- .drv_data = &g_lis2dw12_data,
- .int_signal = GPIO_EC_ACCEL_INT_R_L,
+ .drv_data = &g_kx022_data,
.port = I2C_PORT_SENSOR,
- .i2c_spi_addr_flags = LIS2DW12_ADDR0,
+ .i2c_spi_addr_flags = KX022_ADDR0_FLAGS,
.flags = MOTIONSENSE_FLAG_INT_SIGNAL,
.rot_standard_ref = &lid_standard_ref, /* identity matrix */
.default_range = 2, /* g */
- .min_frequency = LIS2DW12_ODR_MIN_VAL,
- .max_frequency = LIS2DW12_ODR_MAX_VAL,
+ .min_frequency = KX022_ACCEL_MIN_FREQ,
+ .max_frequency = KX022_ACCEL_MAX_FREQ,
.config = {
/* EC use accel for angle detection */
[SENSOR_CONFIG_EC_S0] = {
@@ -92,21 +93,20 @@ struct motion_sensor_t motion_sensors[] = {
[BASE_ACCEL] = {
.name = "Base Accel",
.active_mask = SENSOR_ACTIVE_S0_S3,
- .chip = MOTIONSENSE_CHIP_LSM6DSO,
+ .chip = MOTIONSENSE_CHIP_ICM426XX,
.type = MOTIONSENSE_TYPE_ACCEL,
.location = MOTIONSENSE_LOC_BASE,
- .drv = &lsm6dso_drv,
+ .drv = &icm426xx_drv,
.mutex = &g_base_accel_mutex,
- .drv_data = LSM6DSO_ST_DATA(lsm6dso_data,
- MOTIONSENSE_TYPE_ACCEL),
+ .drv_data = &g_icm426xx_data,
.int_signal = GPIO_EC_IMU_INT_R_L,
.flags = MOTIONSENSE_FLAG_INT_SIGNAL,
.port = I2C_PORT_SENSOR,
- .i2c_spi_addr_flags = LSM6DSO_ADDR0_FLAGS,
+ .i2c_spi_addr_flags = ICM426XX_ADDR0_FLAGS,
.rot_standard_ref = &base_standard_ref,
.default_range = 4, /* g */
- .min_frequency = LSM6DSO_ODR_MIN_VAL,
- .max_frequency = LSM6DSO_ODR_MAX_VAL,
+ .min_frequency = ICM426XX_ACCEL_MIN_FREQ,
+ .max_frequency = ICM426XX_ACCEL_MAX_FREQ,
.config = {
[SENSOR_CONFIG_EC_S0] = {
.odr = 13000 | ROUND_UP_FLAG,
@@ -122,21 +122,20 @@ struct motion_sensor_t motion_sensors[] = {
[BASE_GYRO] = {
.name = "Base Gyro",
.active_mask = SENSOR_ACTIVE_S0_S3,
- .chip = MOTIONSENSE_CHIP_LSM6DSO,
+ .chip = MOTIONSENSE_CHIP_ICM426XX,
.type = MOTIONSENSE_TYPE_GYRO,
.location = MOTIONSENSE_LOC_BASE,
- .drv = &lsm6dso_drv,
+ .drv = &icm426xx_drv,
.mutex = &g_base_accel_mutex,
- .drv_data = LSM6DSO_ST_DATA(lsm6dso_data,
- MOTIONSENSE_TYPE_GYRO),
+ .drv_data = &g_icm426xx_data,
.int_signal = GPIO_EC_IMU_INT_R_L,
.flags = MOTIONSENSE_FLAG_INT_SIGNAL,
.port = I2C_PORT_SENSOR,
- .i2c_spi_addr_flags = LSM6DSO_ADDR0_FLAGS,
+ .i2c_spi_addr_flags = ICM426XX_ADDR0_FLAGS,
.default_range = 1000 | ROUND_UP_FLAG, /* dps */
.rot_standard_ref = &base_standard_ref,
- .min_frequency = LSM6DSO_ODR_MIN_VAL,
- .max_frequency = LSM6DSO_ODR_MAX_VAL,
+ .min_frequency = ICM426XX_GYRO_MIN_FREQ,
+ .max_frequency = ICM426XX_GYRO_MAX_FREQ,
.config = {
[SENSOR_CONFIG_EC_S0] = {
.odr = 13000 | ROUND_UP_FLAG,
@@ -153,13 +152,16 @@ const unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors);
static void baseboard_sensors_init(void)
{
- /* Enable gpio interrupt for lid accel sensor */
- gpio_enable_interrupt(GPIO_EC_ACCEL_INT_R_L);
/* Enable gpio interrupt for base accelgyro sensor */
gpio_enable_interrupt(GPIO_EC_IMU_INT_R_L);
}
DECLARE_HOOK(HOOK_INIT, baseboard_sensors_init, HOOK_PRIO_INIT_I2C + 1);
+void motion_interrupt(enum gpio_signal signal)
+{
+ icm426xx_interrupt(signal);
+}
+
/* Temperature sensor configuration */
const struct temp_sensor_t temp_sensors[] = {
[TEMP_SENSOR_1_DDR_SOC] = {