summaryrefslogtreecommitdiff
path: root/board/shuboz
diff options
context:
space:
mode:
authorJacky Wang <jacky5_wang@pegatron.corp-partner.google.com>2021-01-26 18:07:27 +0800
committerCommit Bot <commit-bot@chromium.org>2021-01-26 19:28:25 +0000
commit1e14f4669113703fb496406e6a58602bc17a4001 (patch)
tree32c653cfe92c6c49f4f8f0a1e0925813bdcbdd85 /board/shuboz
parente21734eeef64b74eca8497965a5b76e7b5dbdc37 (diff)
downloadchrome-ec-1e14f4669113703fb496406e6a58602bc17a4001.tar.gz
Jelboz360: Config the G-sensor setting
1. Base on schematics, modify the motion sensor related setting to BMI160 and KX022. 2. Modify base rotation matrix depend on schematics. BUG=b:178451001 BRANCH=firmware-zork-13434.B TEST=make BOARD=shuboz 1. Using "ectool motionsense" check x/y/z value. 2. Using "ectool motionsense lid_angle" check angle. Signed-off-by: Jacky Wang <jacky5_wang@pegatron.corp-partner.google.com> Change-Id: I6f07e6795b6a28a805270250a0ef78babf4a5d75 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2649886 Tested-by: Michael5 Chen <michael5_chen1@pegatron.corp-partner.google.com> Reviewed-by: Edward Hill <ecgh@chromium.org> Reviewed-by: Michael5 Chen <michael5_chen1@pegatron.corp-partner.google.com> Commit-Queue: Edward Hill <ecgh@chromium.org>
Diffstat (limited to 'board/shuboz')
-rw-r--r--board/shuboz/board.c72
-rw-r--r--board/shuboz/board.h6
-rw-r--r--board/shuboz/gpio.inc2
3 files changed, 41 insertions, 39 deletions
diff --git a/board/shuboz/board.c b/board/shuboz/board.c
index ea7029c03d..d4bb011729 100644
--- a/board/shuboz/board.c
+++ b/board/shuboz/board.c
@@ -6,8 +6,9 @@
#include "battery_smart.h"
#include "button.h"
#include "cros_board_info.h"
-#include "driver/accel_lis2dw12.h"
-#include "driver/accelgyro_lsm6dsm.h"
+#include "driver/accelgyro_bmi_common.h"
+#include "driver/accel_kionix.h"
+#include "driver/accel_kx022.h"
#include "driver/bc12/pi3usb9201.h"
#include "driver/ppc/aoz1380.h"
#include "driver/ppc/nx20p348x.h"
@@ -49,37 +50,44 @@ static struct mutex g_lid_mutex;
static struct mutex g_base_mutex;
/* sensor private data */
-static struct stprivate_data g_lis2dwl_data;
-static struct lsm6dsm_data g_lsm6dsm_data = LSM6DSM_DATA;
+static struct kionix_accel_data g_kx022_data;
+static struct bmi_drv_data_t g_bmi160_data;
/* Matrix to rotate accelrator into standard reference frame */
+static const mat33_fp_t lid_standard_ref = {
+ { FLOAT_TO_FP(-1), 0, 0 },
+ { 0, FLOAT_TO_FP(-1), 0 },
+ { 0, 0, FLOAT_TO_FP(-1) },
+};
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)}
+ { FLOAT_TO_FP(1), 0, 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 motion_sensors[] = {
[LID_ACCEL] = {
.name = "Lid Accel",
.active_mask = SENSOR_ACTIVE_S0_S3,
- .chip = MOTIONSENSE_CHIP_LIS2DWL,
+ .chip = MOTIONSENSE_CHIP_KX022,
.type = MOTIONSENSE_TYPE_ACCEL,
.location = MOTIONSENSE_LOC_LID,
- .drv = &lis2dw12_drv,
+ .drv = &kionix_accel_drv,
.mutex = &g_lid_mutex,
- .drv_data = &g_lis2dwl_data,
+ .drv_data = &g_kx022_data,
.port = I2C_PORT_SENSOR,
- .i2c_spi_addr_flags = LIS2DWL_ADDR1_FLAGS,
- .rot_standard_ref = NULL,
+ .i2c_spi_addr_flags = KX022_ADDR0_FLAGS,
+ .rot_standard_ref = &lid_standard_ref,
.default_range = 2, /* g, enough for laptop. */
- .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] = {
- .odr = 12500 | ROUND_UP_FLAG,
+ .odr = 10000 | ROUND_UP_FLAG,
+ .ec_rate = 100,
},
/* Sensor on for lid angle detection */
[SENSOR_CONFIG_EC_S3] = {
@@ -91,31 +99,28 @@ struct motion_sensor_t motion_sensors[] = {
[BASE_ACCEL] = {
.name = "Base Accel",
.active_mask = SENSOR_ACTIVE_S0_S3,
- .chip = MOTIONSENSE_CHIP_LSM6DSM,
+ .chip = MOTIONSENSE_CHIP_BMI160,
.type = MOTIONSENSE_TYPE_ACCEL,
.location = MOTIONSENSE_LOC_BASE,
- .drv = &lsm6dsm_drv,
+ .drv = &bmi160_drv,
.mutex = &g_base_mutex,
- .drv_data = LSM6DSM_ST_DATA(g_lsm6dsm_data,
- MOTIONSENSE_TYPE_ACCEL),
+ .drv_data = &g_bmi160_data,
.int_signal = GPIO_6AXIS_INT_L,
- .flags = MOTIONSENSE_FLAG_INT_SIGNAL,
.port = I2C_PORT_SENSOR,
- .i2c_spi_addr_flags = LSM6DSM_ADDR0_FLAGS,
- .default_range = 4, /* g, enough for laptop */
+ .i2c_spi_addr_flags = BMI160_ADDR0_FLAGS,
+ .default_range = 2, /* g, enough for laptop */
.rot_standard_ref = &base_standard_ref,
- .min_frequency = LSM6DSM_ODR_MIN_VAL,
- .max_frequency = LSM6DSM_ODR_MAX_VAL,
+ .min_frequency = BMI_ACCEL_MIN_FREQ,
+ .max_frequency = BMI_ACCEL_MAX_FREQ,
.config = {
/* EC use accel for angle detection */
[SENSOR_CONFIG_EC_S0] = {
- .odr = 13000 | ROUND_UP_FLAG,
+ .odr = 10000 | ROUND_UP_FLAG,
.ec_rate = 100 * MSEC,
},
/* Sensor on for angle detection */
[SENSOR_CONFIG_EC_S3] = {
.odr = 10000 | ROUND_UP_FLAG,
- .ec_rate = 100 * MSEC,
},
},
},
@@ -123,21 +128,18 @@ struct motion_sensor_t motion_sensors[] = {
[BASE_GYRO] = {
.name = "Base Gyro",
.active_mask = SENSOR_ACTIVE_S0_S3,
- .chip = MOTIONSENSE_CHIP_LSM6DSM,
+ .chip = MOTIONSENSE_CHIP_BMI160,
.type = MOTIONSENSE_TYPE_GYRO,
.location = MOTIONSENSE_LOC_BASE,
- .drv = &lsm6dsm_drv,
+ .drv = &bmi160_drv,
.mutex = &g_base_mutex,
- .drv_data = LSM6DSM_ST_DATA(g_lsm6dsm_data,
- MOTIONSENSE_TYPE_GYRO),
- .int_signal = GPIO_6AXIS_INT_L,
- .flags = MOTIONSENSE_FLAG_INT_SIGNAL,
+ .drv_data = &g_bmi160_data,
.port = I2C_PORT_SENSOR,
- .i2c_spi_addr_flags = LSM6DSM_ADDR0_FLAGS,
- .default_range = 1000 | ROUND_UP_FLAG, /* dps */
+ .i2c_spi_addr_flags = BMI160_ADDR0_FLAGS,
+ .default_range = 1000, /* dps */
.rot_standard_ref = &base_standard_ref,
- .min_frequency = LSM6DSM_ODR_MIN_VAL,
- .max_frequency = LSM6DSM_ODR_MAX_VAL,
+ .min_frequency = BMI_GYRO_MIN_FREQ,
+ .max_frequency = BMI_GYRO_MAX_FREQ,
},
};
diff --git a/board/shuboz/board.h b/board/shuboz/board.h
index ccbc7e2f06..bc029b5cd2 100644
--- a/board/shuboz/board.h
+++ b/board/shuboz/board.h
@@ -29,10 +29,10 @@
#define CONFIG_LED_ONOFF_STATES_BAT_LOW 10
/* Motion sensing drivers */
-#define CONFIG_ACCELGYRO_LSM6DSM
-#define CONFIG_ACCEL_LSM6DSM_INT_EVENT \
+#define CONFIG_ACCELGYRO_BMI160
+#define CONFIG_ACCELGYRO_BMI160_INT_EVENT \
TASK_EVENT_MOTION_SENSOR_INTERRUPT(BASE_ACCEL)
-#define CONFIG_ACCEL_LIS2DWL
+#define CONFIG_ACCEL_KX022
#define CONFIG_ACCEL_INTERRUPTS
#define CONFIG_CMD_ACCELS
#define CONFIG_CMD_ACCEL_INFO
diff --git a/board/shuboz/gpio.inc b/board/shuboz/gpio.inc
index 30ea179291..e0d05ea78b 100644
--- a/board/shuboz/gpio.inc
+++ b/board/shuboz/gpio.inc
@@ -25,7 +25,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, lsm6dsm_interrupt)
+GPIO_INT(6AXIS_INT_L, PIN(A, 0), GPIO_INT_FALLING | GPIO_PULL_UP, bmi160_interrupt)
/* GPIO_INT_BOTH is required for PSL wake from hibernate, but we don't need an interrupt handler. */
GPIO(EC_RST_ODL, PIN(0, 2), GPIO_INT_BOTH | GPIO_HIB_WAKE_HIGH)