summaryrefslogtreecommitdiff
path: root/board/ezkinil/board.c
diff options
context:
space:
mode:
authorLu Zhang <lu.zhang@bitland.corp-partner.google.com>2020-02-24 16:20:42 +0800
committerCommit Bot <commit-bot@chromium.org>2020-02-26 03:27:52 +0000
commit697ff17b762f9464bf204ebdb6daa23cb26eddd3 (patch)
treea5488af72cc451da4b6475b9ff002720f80a3f2f /board/ezkinil/board.c
parent77bfd7f85e13898b0b159b7e6fb34fadc163ae5b (diff)
downloadchrome-ec-697ff17b762f9464bf204ebdb6daa23cb26eddd3.tar.gz
dalboz: Add base/lid sensor configuration
Dalboz uses LSM6DS3TR/LIS2DWL instead of BMI160/KX022 BUG=b:149968926 BRANCH=none TEST=using ec console 'accelinfo on' to see if there is sensor data output. Change-Id: If385c5554b50795702736aa8e1e3090dcb8b618a Signed-off-by: Lu Zhang <lu.zhang@bitland.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2069965 Commit-Queue: Edward Hill <ecgh@chromium.org> Tested-by: Edward Hill <ecgh@chromium.org> Reviewed-by: Edward Hill <ecgh@chromium.org>
Diffstat (limited to 'board/ezkinil/board.c')
-rw-r--r--board/ezkinil/board.c93
1 files changed, 93 insertions, 0 deletions
diff --git a/board/ezkinil/board.c b/board/ezkinil/board.c
index a177b5bc1f..08ec79df5a 100644
--- a/board/ezkinil/board.c
+++ b/board/ezkinil/board.c
@@ -7,6 +7,8 @@
#include "button.h"
#include "driver/accelgyro_bmi160.h"
+#include "driver/accel_kionix.h"
+#include "driver/accel_kx022.h"
#include "extpower.h"
#include "fan.h"
#include "fan_chip.h"
@@ -18,10 +20,101 @@
#include "pwm_chip.h"
#include "switch.h"
#include "system.h"
+#include "task.h"
#include "usb_charge.h"
#include "gpio_list.h"
+#ifdef HAS_TASK_MOTIONSENSE
+
+/* Motion sensors */
+static struct mutex g_lid_mutex;
+static struct mutex g_base_mutex;
+
+/* sensor private data */
+static struct kionix_accel_data g_kx022_data;
+static struct bmi160_drv_data_t g_bmi160_data;
+
+/* 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_KX022,
+ .type = MOTIONSENSE_TYPE_ACCEL,
+ .location = MOTIONSENSE_LOC_LID,
+ .drv = &kionix_accel_drv,
+ .mutex = &g_lid_mutex,
+ .drv_data = &g_kx022_data,
+ .port = I2C_PORT_SENSOR,
+ .i2c_spi_addr_flags = KX022_ADDR1_FLAGS,
+ .rot_standard_ref = NULL,
+ .default_range = 2, /* g, enough for laptop. */
+ .min_frequency = KX022_ACCEL_MIN_FREQ,
+ .max_frequency = KX022_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,
+ },
+ },
+ },
+
+ [BASE_ACCEL] = {
+ .name = "Base Accel",
+ .active_mask = SENSOR_ACTIVE_S0_S3,
+ .chip = MOTIONSENSE_CHIP_BMI160,
+ .type = MOTIONSENSE_TYPE_ACCEL,
+ .location = MOTIONSENSE_LOC_BASE,
+ .drv = &bmi160_drv,
+ .mutex = &g_base_mutex,
+ .drv_data = &g_bmi160_data,
+ .port = I2C_PORT_SENSOR,
+ .i2c_spi_addr_flags = BMI160_ADDR0_FLAGS,
+ .default_range = 2, /* g, enough for laptop */
+ .rot_standard_ref = NULL,
+ .min_frequency = BMI160_ACCEL_MIN_FREQ,
+ .max_frequency = BMI160_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,
+ },
+ },
+ },
+
+ [BASE_GYRO] = {
+ .name = "Base Gyro",
+ .active_mask = SENSOR_ACTIVE_S0_S3,
+ .chip = MOTIONSENSE_CHIP_BMI160,
+ .type = MOTIONSENSE_TYPE_GYRO,
+ .location = MOTIONSENSE_LOC_BASE,
+ .drv = &bmi160_drv,
+ .mutex = &g_base_mutex,
+ .drv_data = &g_bmi160_data,
+ .port = I2C_PORT_SENSOR,
+ .i2c_spi_addr_flags = BMI160_ADDR0_FLAGS,
+ .default_range = 1000, /* dps */
+ .rot_standard_ref = NULL,
+ .min_frequency = BMI160_GYRO_MIN_FREQ,
+ .max_frequency = BMI160_GYRO_MAX_FREQ,
+ },
+};
+
+unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors);
+
+#endif /* HAS_TASK_MOTIONSENSE */
+
/* These GPIOs moved. Temporarily detect and support the V0 HW. */
enum gpio_signal GPIO_PCH_PWRBTN_L = GPIO_EC_FCH_PWR_BTN_L;
enum gpio_signal GPIO_PCH_SYS_PWROK = GPIO_EC_FCH_PWROK;