summaryrefslogtreecommitdiff
path: root/board/woomax
diff options
context:
space:
mode:
authorMichael5 Chen1 <michael5_chen1@pegatron.corp-partner.google.com>2021-08-12 14:40:41 +0800
committerCommit Bot <commit-bot@chromium.org>2021-08-13 01:55:44 +0000
commitde26838f8958b258d84ad2f2dbda790d6fdce1ce (patch)
tree8e7b5d8426576fa61db36d8f607a180d027abdf6 /board/woomax
parentcd2c7157c0ed8a1968e3f176bf836349e12100b0 (diff)
downloadchrome-ec-de26838f8958b258d84ad2f2dbda790d6fdce1ce.tar.gz
woomax: gyro sensor add 2nd source icm40608
gyro sensor add 2nd source icm-40608 BUG=b:196286186 BRANCH=zork TEST=make BOARD=woomax 1. Set CBI SSFC 0x03 and using command "watch ectool motionsense lid_angle" for sensor icm-40608. 2. Using command "watch ectool motionsense lid_angle" for BMI160. Signed-off-by: Michael5 Chen1 <michael5_chen1@pegatron.corp-partner.google.com> Change-Id: I8db74d6e42858f0e7c6f5c60b22f811c6ab0d190 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3088971 Reviewed-by: Jacky Wang <jacky5_wang@pegatron.corp-partner.google.com> Reviewed-by: Denis Brockus <dbrockus@chromium.org>
Diffstat (limited to 'board/woomax')
-rw-r--r--board/woomax/board.c74
-rw-r--r--board/woomax/board.h4
-rw-r--r--board/woomax/gpio.inc2
3 files changed, 79 insertions, 1 deletions
diff --git a/board/woomax/board.c b/board/woomax/board.c
index 5971cde9d4..11a7c9c969 100644
--- a/board/woomax/board.c
+++ b/board/woomax/board.c
@@ -9,8 +9,11 @@
#include "adc_chip.h"
#include "button.h"
#include "cbi_ec_fw_config.h"
+#include "cbi_ssfc.h"
#include "cros_board_info.h"
#include "driver/accelgyro_bmi_common.h"
+#include "driver/accelgyro_icm_common.h"
+#include "driver/accelgyro_icm426xx.h"
#include "driver/accel_kionix.h"
#include "driver/accel_kx022.h"
#include "driver/retimer/pi3dpx1207.h"
@@ -52,6 +55,7 @@ static struct mutex g_base_mutex;
/* sensor private data */
static struct kionix_accel_data g_kx022_data;
static struct bmi_drv_data_t g_bmi160_data;
+static struct icm_drv_data_t g_icm426xx_data;
/* Rotation matrix for the lid accelerometer */
static const mat33_fp_t lid_standard_ref = {
@@ -66,7 +70,58 @@ static const mat33_fp_t base_standard_ref = {
{ 0, 0, FLOAT_TO_FP(-1)},
};
+static const mat33_fp_t base_standard_ref_icm = {
+ { FLOAT_TO_FP(1), 0, 0},
+ { 0, FLOAT_TO_FP(-1), 0},
+ { 0, 0, FLOAT_TO_FP(-1)},
+};
+
/* TODO(gcc >= 5.0) Remove the casts to const pointer at rot_standard_ref */
+struct motion_sensor_t icm426xx_base_accel = {
+ .name = "Base Accel",
+ .active_mask = SENSOR_ACTIVE_S0_S3,
+ .chip = MOTIONSENSE_CHIP_ICM426XX,
+ .type = MOTIONSENSE_TYPE_ACCEL,
+ .location = MOTIONSENSE_LOC_BASE,
+ .drv = &icm426xx_drv,
+ .mutex = &g_base_mutex,
+ .drv_data = &g_icm426xx_data,
+ .port = I2C_PORT_SENSOR,
+ .i2c_spi_addr_flags = ICM426XX_ADDR0_FLAGS,
+ .default_range = 4, /* g, to meet CDD 7.3.1/C-1-4 reqs. */
+ .rot_standard_ref = &base_standard_ref_icm,
+ .min_frequency = ICM426XX_ACCEL_MIN_FREQ,
+ .max_frequency = ICM426XX_ACCEL_MAX_FREQ,
+ .config = {
+ /* EC use accel for angle detection */
+ [SENSOR_CONFIG_EC_S0] = {
+ .odr = 10000 | ROUND_UP_FLAG,
+ .ec_rate = 100,
+ },
+ /* EC use accel for angle detection */
+ [SENSOR_CONFIG_EC_S3] = {
+ .odr = 10000 | ROUND_UP_FLAG,
+ },
+ },
+};
+
+struct motion_sensor_t icm426xx_base_gyro = {
+ .name = "Base Gyro",
+ .active_mask = SENSOR_ACTIVE_S0_S3,
+ .chip = MOTIONSENSE_CHIP_ICM426XX,
+ .type = MOTIONSENSE_TYPE_GYRO,
+ .location = MOTIONSENSE_LOC_BASE,
+ .drv = &icm426xx_drv,
+ .mutex = &g_base_mutex,
+ .drv_data = &g_icm426xx_data,
+ .port = I2C_PORT_SENSOR,
+ .i2c_spi_addr_flags = ICM426XX_ADDR0_FLAGS,
+ .default_range = 1000, /* dps */
+ .rot_standard_ref = &base_standard_ref_icm,
+ .min_frequency = ICM426XX_GYRO_MIN_FREQ,
+ .max_frequency = ICM426XX_GYRO_MAX_FREQ,
+};
+
struct motion_sensor_t motion_sensors[] = {
[LID_ACCEL] = {
.name = "Lid Accel",
@@ -144,6 +199,24 @@ struct motion_sensor_t motion_sensors[] = {
unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors);
+static void setup_base_gyro_config(void)
+{
+ if (get_cbi_ssfc_base_sensor() == SSFC_BASE_GYRO_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");
+}
+
+void motion_interrupt(enum gpio_signal signal)
+{
+ if (get_cbi_ssfc_base_sensor() == SSFC_BASE_GYRO_ICM426XX)
+ icm426xx_interrupt(signal);
+ else
+ bmi160_interrupt(signal);
+}
+
const struct power_signal_info power_signal_list[] = {
[X86_SLP_S3_N] = {
.gpio = GPIO_PCH_SLP_S3_L,
@@ -582,6 +655,7 @@ static void setup_fw_config(void)
if (ec_config_has_hdmi_retimer_pi3hdx1204())
gpio_enable_interrupt(GPIO_DP1_HPD_EC_IN);
+ setup_base_gyro_config();
setup_mux();
}
/* Use HOOK_PRIO_INIT_I2C + 2 to be after ioex_init(). */
diff --git a/board/woomax/board.h b/board/woomax/board.h
index 47754c46d7..d81c82f181 100644
--- a/board/woomax/board.h
+++ b/board/woomax/board.h
@@ -21,6 +21,9 @@
#define CONFIG_ACCELGYRO_BMI160
#define CONFIG_ACCELGYRO_BMI160_INT_EVENT \
TASK_EVENT_MOTION_SENSOR_INTERRUPT(BASE_ACCEL)
+#define CONFIG_ACCELGYRO_ICM426XX
+#define CONFIG_ACCELGYRO_ICM426XX_INT_EVENT \
+ TASK_EVENT_MOTION_SENSOR_INTERRUPT(BASE_ACCEL)
#define CONFIG_ACCEL_INTERRUPTS
#define CONFIG_ACCEL_KX022
#define CONFIG_CMD_ACCELS
@@ -206,6 +209,7 @@ extern const struct usb_mux usbc1_ps8802;
extern const struct usb_mux usbc1_ps8818;
extern struct usb_mux usbc1_amd_fp5_usb_mux;
void hdmi_hpd_interrupt(enum gpio_signal signal);
+void motion_interrupt(enum gpio_signal signal);
#endif /* !__ASSEMBLER__ */
diff --git a/board/woomax/gpio.inc b/board/woomax/gpio.inc
index b377291f74..ade15d3d4a 100644
--- a/board/woomax/gpio.inc
+++ b/board/woomax/gpio.inc
@@ -24,7 +24,7 @@ GPIO_INT(ACOK_OD, PIN(0, 0), GPIO_INT_BOTH | GPIO_HIB_WAKE_HIGH, extpower_inter
GPIO_INT(EC_WP_L, PIN(5, 0), GPIO_INT_BOTH, switch_interrupt)
GPIO_INT(VOLDN_BTN_ODL, PIN(A, 6), GPIO_INT_BOTH | GPIO_PULL_UP, button_interrupt)
GPIO_INT(VOLUP_BTN_ODL, PIN(9, 5), GPIO_INT_BOTH | GPIO_PULL_UP, button_interrupt)
-GPIO_INT(6AXIS_INT_L, PIN(A, 0), GPIO_INT_FALLING | GPIO_PULL_UP, bmi160_interrupt)
+GPIO_INT(6AXIS_INT_L, PIN(A, 0), GPIO_INT_FALLING | GPIO_PULL_UP, motion_interrupt)
GPIO_INT(TABLET_MODE_L, PIN(4, 4), GPIO_INT_BOTH, gmr_tablet_switch_isr)
GPIO_INT(DP1_HPD_EC_IN, PIN(7, 5), GPIO_INT_BOTH, hdmi_hpd_interrupt)