summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--baseboard/guybrush/baseboard.h1
-rw-r--r--board/guybrush/board.c37
-rw-r--r--board/guybrush/board.h2
3 files changed, 40 insertions, 0 deletions
diff --git a/baseboard/guybrush/baseboard.h b/baseboard/guybrush/baseboard.h
index 77e22c433b..3b87a99b48 100644
--- a/baseboard/guybrush/baseboard.h
+++ b/baseboard/guybrush/baseboard.h
@@ -321,6 +321,7 @@ enum temp_sensor_id {
enum sensor_id {
BASE_ACCEL = 0,
BASE_GYRO,
+ LID_ACCEL,
SENSOR_COUNT,
};
diff --git a/board/guybrush/board.c b/board/guybrush/board.c
index 3cbef96449..09406e481c 100644
--- a/board/guybrush/board.c
+++ b/board/guybrush/board.c
@@ -9,6 +9,7 @@
#include "common.h"
#include "driver/accelgyro_bmi_common.h"
#include "driver/accelgyro_bmi160.h"
+#include "driver/accel_bma422.h"
#include "driver/retimer/ps8811.h"
#include "driver/retimer/ps8818.h"
#include "extpower.h"
@@ -26,10 +27,12 @@
#include "gpio_list.h" /* Must come after other header files. */
/* Lid Sensor mutex */
+static struct mutex g_lid_mutex;
static struct mutex g_base_mutex;
/* Lid accel private data */
static struct bmi_drv_data_t g_bmi160_data;
+static struct accelgyro_saved_data_t g_bma422_data;
/* Matrix to rotate accelrator into standard reference frame */
const mat33_fp_t base_standard_ref = {
@@ -38,6 +41,12 @@ const mat33_fp_t base_standard_ref = {
{ 0, 0, FLOAT_TO_FP(1)}
};
+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)}
+};
+
struct motion_sensor_t motion_sensors[] = {
[BASE_ACCEL] = {
.name = "Base Accel",
@@ -67,6 +76,34 @@ struct motion_sensor_t motion_sensors[] = {
},
},
},
+ [LID_ACCEL] = {
+ .name = "Lid Accel",
+ .active_mask = SENSOR_ACTIVE_S0_S3,
+ .chip = MOTIONSENSE_CHIP_BMA422,
+ .type = MOTIONSENSE_TYPE_ACCEL,
+ .location = MOTIONSENSE_LOC_LID,
+ .drv = &bma4_accel_drv,
+ .mutex = &g_lid_mutex,
+ .drv_data = &g_bma422_data,
+ .port = I2C_PORT_SENSOR,
+ .i2c_spi_addr_flags = BMA4_I2C_ADDR_PRIMARY,
+ .rot_standard_ref = &lid_standard_ref,
+ .min_frequency = BMA4_ACCEL_MIN_FREQ,
+ .max_frequency = BMA4_ACCEL_MAX_FREQ,
+ .default_range = 2, /* g, enough for laptop. */
+ .config = {
+ /* EC use accel for angle detection */
+ [SENSOR_CONFIG_EC_S0] = {
+ .odr = 10000 | ROUND_UP_FLAG,
+ .ec_rate = 100 * MSEC,
+ },
+ /* Sensor on in S3 */
+ [SENSOR_CONFIG_EC_S3] = {
+ .odr = 10000 | ROUND_UP_FLAG,
+ .ec_rate = 0,
+ },
+ },
+ },
[BASE_GYRO] = {
.name = "Base Gyro",
.active_mask = SENSOR_ACTIVE_S0_S3,
diff --git a/board/guybrush/board.h b/board/guybrush/board.h
index a52db07a10..5c6bc9bbcb 100644
--- a/board/guybrush/board.h
+++ b/board/guybrush/board.h
@@ -20,6 +20,8 @@
#define CONFIG_ACCELGYRO_BMI160_INT_EVENT \
TASK_EVENT_MOTION_SENSOR_INTERRUPT(BASE_ACCEL)
#define CONFIG_ACCEL_INTERRUPTS
+#define CONFIG_ACCEL_BMA4XX
+
/* Base accel uses fifo */
#define CONFIG_ACCEL_FIFO
#define CONFIG_ACCEL_FIFO_SIZE 256 /* Must be a power of 2 */