Ezkinil: Using fw_config to choose base accelgyro driver
Add new ec_cfg_base_gyro_sensor_type "BASE_GYRO_ICM426XX = 3" for support ICM-426XX on ezkinil. BUG=b:175169469 BRANCH=zork TEST=Write fw_config bit15-11 to 011b on the Ezkinil DUT with ICM chip. Check the motion function is workable. Signed-off-by: Sue Chen <sue.chen@quanta.corp-partner.google.com> Change-Id: If72746a1b7b44714aa39f7d48fd94d0c63d4f876 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2581122 Reviewed-by: Edward Hill <ecgh@chromium.org>
This commit is contained in:
parent
0172656723
commit
04f7c1ed1b
|
@ -60,6 +60,7 @@ enum ec_cfg_base_gyro_sensor_type {
|
|||
BASE_GYRO_NONE = 0,
|
||||
BASE_GYRO_BMI160 = 1,
|
||||
BASE_GYRO_LSM6DSM = 2,
|
||||
BASE_GYRO_ICM426XX = 3,
|
||||
};
|
||||
#define EC_CFG_BASE_GYRO_SENSOR_L 11
|
||||
#define EC_CFG_BASE_GYRO_SENSOR_H 13
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
#include "charge_state_v2.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/ppc/aoz1380.h"
|
||||
|
@ -39,10 +41,10 @@
|
|||
|
||||
#include "gpio_list.h"
|
||||
|
||||
#ifdef HAS_TASK_MOTIONSENSE
|
||||
|
||||
static int board_ver;
|
||||
|
||||
#ifdef HAS_TASK_MOTIONSENSE
|
||||
|
||||
/* Motion sensors */
|
||||
static struct mutex g_lid_mutex;
|
||||
static struct mutex g_base_mutex;
|
||||
|
@ -50,6 +52,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;
|
||||
|
||||
/* Matrix to rotate accelrator into standard reference frame */
|
||||
const mat33_fp_t base_standard_ref = {
|
||||
|
@ -141,6 +144,51 @@ struct motion_sensor_t motion_sensors[] = {
|
|||
|
||||
unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors);
|
||||
|
||||
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 = 2, /* g, enough for laptop */
|
||||
.rot_standard_ref = &base_standard_ref,
|
||||
.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,
|
||||
.min_frequency = ICM426XX_GYRO_MIN_FREQ,
|
||||
.max_frequency = ICM426XX_GYRO_MAX_FREQ,
|
||||
};
|
||||
|
||||
#endif /* HAS_TASK_MOTIONSENSE */
|
||||
|
||||
const struct power_signal_info power_signal_list[] = {
|
||||
|
@ -234,6 +282,37 @@ const struct usb_mux usbc0_sbu_mux = {
|
|||
.driver = &usbc0_sbu_mux_driver,
|
||||
};
|
||||
|
||||
/*****************************************************************************
|
||||
* Base Gyro Sensor dynamic configuration
|
||||
*/
|
||||
|
||||
static int base_gyro_config;
|
||||
|
||||
static void setup_base_gyro_config(void)
|
||||
{
|
||||
base_gyro_config = ec_config_has_base_gyro_sensor();
|
||||
|
||||
if (base_gyro_config == BASE_GYRO_ICM426XX) {
|
||||
motion_sensors[BASE_ACCEL] = icm426xx_base_accel;
|
||||
motion_sensors[BASE_GYRO] = icm426xx_base_gyro;
|
||||
ccprints("BASE GYRO is ICM426XX");
|
||||
} else if (base_gyro_config == BASE_GYRO_BMI160)
|
||||
ccprints("BASE GYRO is BMI160");
|
||||
}
|
||||
|
||||
void motion_interrupt(enum gpio_signal signal)
|
||||
{
|
||||
switch (base_gyro_config) {
|
||||
case BASE_GYRO_ICM426XX:
|
||||
icm426xx_interrupt(signal);
|
||||
break;
|
||||
case BASE_GYRO_BMI160:
|
||||
default:
|
||||
bmi160_interrupt(signal);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
* USB-C MUX/Retimer dynamic configuration
|
||||
*/
|
||||
|
@ -420,6 +499,8 @@ static void setup_fw_config(void)
|
|||
else
|
||||
gpio_enable_interrupt(GPIO_DP1_HPD_EC_IN);
|
||||
}
|
||||
|
||||
setup_base_gyro_config();
|
||||
}
|
||||
/* Use HOOK_PRIO_INIT_I2C + 2 to be after ioex_init(). */
|
||||
DECLARE_HOOK(HOOK_INIT, setup_fw_config, HOOK_PRIO_INIT_I2C + 2);
|
||||
|
|
|
@ -15,6 +15,9 @@
|
|||
#define CONFIG_FAN_RPM_CUSTOM
|
||||
|
||||
/* Motion sensing drivers */
|
||||
#define CONFIG_ACCELGYRO_ICM426XX
|
||||
#define CONFIG_ACCELGYRO_ICM426XX_INT_EVENT \
|
||||
TASK_EVENT_MOTION_SENSOR_INTERRUPT(BASE_ACCEL)
|
||||
#define CONFIG_ACCELGYRO_BMI160
|
||||
#define CONFIG_ACCELGYRO_BMI160_INT_EVENT \
|
||||
TASK_EVENT_MOTION_SENSOR_INTERRUPT(BASE_ACCEL)
|
||||
|
@ -203,6 +206,7 @@ extern const struct usb_mux usbc1_tusb544;
|
|||
extern const struct usb_mux usbc1_ps8743;
|
||||
extern struct usb_mux usbc1_amd_fp5_usb_mux;
|
||||
|
||||
void motion_interrupt(enum gpio_signal signal);
|
||||
void hdmi_hpd_interrupt(enum gpio_signal signal);
|
||||
void hdmi_hpd_interrupt_v2(enum ioex_signal signal);
|
||||
|
||||
|
|
|
@ -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(DP1_HPD_EC_IN, PIN(7, 5), GPIO_INT_BOTH, hdmi_hpd_interrupt)
|
||||
|
||||
/* GPIO_INT_BOTH is required for PSL wake from hibernate, but we don't need an interrupt handler. */
|
||||
|
|
Loading…
Reference in New Issue