summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--board/ampton/board.c51
-rw-r--r--board/ampton/board.h1
-rw-r--r--board/ampton/gpio.inc3
-rw-r--r--driver/accel_bma2x2.h2
4 files changed, 44 insertions, 13 deletions
diff --git a/board/ampton/board.c b/board/ampton/board.c
index b6b7372d3d..0ed538f728 100644
--- a/board/ampton/board.c
+++ b/board/ampton/board.c
@@ -11,6 +11,7 @@
#include "charge_state.h"
#include "common.h"
#include "cros_board_info.h"
+#include "driver/accel_bma2x2.h"
#include "driver/accel_kionix.h"
#include "driver/accelgyro_bmi160.h"
#include "driver/ppc/sn5s330.h"
@@ -176,6 +177,38 @@ const mat33_fp_t gyro_standard_ref = {
static struct kionix_accel_data g_kx022_data;
static struct bmi160_drv_data_t g_bmi160_data;
+/* BMA253 private data */
+static struct accelgyro_saved_data_t g_bma253_data;
+
+static const struct motion_sensor_t motion_sensor_bma253 = {
+ .name = "Lid Accel",
+ .active_mask = SENSOR_ACTIVE_S0_S3,
+ .chip = MOTIONSENSE_CHIP_BMA255,
+ .type = MOTIONSENSE_TYPE_ACCEL,
+ .location = MOTIONSENSE_LOC_LID,
+ .drv = &bma2x2_accel_drv,
+ .mutex = &g_lid_mutex,
+ .drv_data = &g_bma253_data,
+ .port = I2C_PORT_SENSOR,
+ .addr = BMA2x2_I2C_ADDR2,
+ .rot_standard_ref = &lid_standard_ref,
+ .min_frequency = BMA255_ACCEL_MIN_FREQ,
+ .max_frequency = BMA255_ACCEL_MAX_FREQ,
+ .default_range = 2, /* g */
+ .config = {
+ /* EC use accel for angle detection */
+ [SENSOR_CONFIG_EC_S0] = {
+ .odr = 10000 | ROUND_UP_FLAG,
+ .ec_rate = 0,
+ },
+ /* Sensor on in S3 */
+ [SENSOR_CONFIG_EC_S3] = {
+ .odr = 10000 | ROUND_UP_FLAG,
+ .ec_rate = 0,
+ },
+ },
+};
+
/* Drivers */
struct motion_sensor_t motion_sensors[] = {
[LID_ACCEL] = {
@@ -268,11 +301,11 @@ static int board_is_convertible(void)
/* SKU IDs of Ampton & unprovisioned: 1, 2, 3, 4, 255 */
return sku_id == 1 || sku_id == 2 || sku_id == 3 || sku_id == 4
|| sku_id == 255;
-}
+ }
-static int board_with_ar_cam(void)
+static int board_with_sensor_bma253(void)
{
- /* SKU ID of Ampton with AR Cam: 3, 4 */
+ /* SKU ID 3 and 4 of Ampton with BMA253 */
return sku_id == 3 || sku_id == 4;
}
@@ -280,6 +313,10 @@ static void board_update_sensor_config_from_sku(void)
{
if (board_is_convertible()) {
motion_sensor_count = ARRAY_SIZE(motion_sensors);
+
+ if (board_with_sensor_bma253())
+ motion_sensors[LID_ACCEL] = motion_sensor_bma253;
+
/* Enable Base Accel interrupt */
gpio_enable_interrupt(GPIO_BASE_SIXAXIS_INT_L);
} else {
@@ -290,14 +327,6 @@ static void board_update_sensor_config_from_sku(void)
gpio_set_flags(GPIO_BASE_SIXAXIS_INT_L,
GPIO_INPUT | GPIO_PULL_DOWN);
}
-
- if (board_with_ar_cam()) {
- /* Enable interrupt from camera */
- gpio_enable_interrupt(GPIO_WFCAM_VSYNC);
- } else {
- /* Camera isn't stuffed, don't allow line to float */
- gpio_set_flags(GPIO_WFCAM_VSYNC, GPIO_INPUT | GPIO_PULL_DOWN);
- }
}
static void board_customize_usbc_mux(uint32_t board_version)
diff --git a/board/ampton/board.h b/board/ampton/board.h
index e8e253a1ef..80a7ad0f03 100644
--- a/board/ampton/board.h
+++ b/board/ampton/board.h
@@ -31,6 +31,7 @@
#define CONFIG_STEINHART_HART_3V3_13K7_47K_4050B
#define CONFIG_TEMP_SENSOR_POWER_GPIO GPIO_EN_PP3300
+#define CONFIG_ACCEL_BMA255 /* Lid accel */
#define CONFIG_ACCEL_KX022 /* Lid accel */
#define CONFIG_ACCELGYRO_BMI160 /* Base accel */
#define CONFIG_SYNC /* Camera VSYNC */
diff --git a/board/ampton/gpio.inc b/board/ampton/gpio.inc
index 5e388e8f3e..f9ce3c6b5c 100644
--- a/board/ampton/gpio.inc
+++ b/board/ampton/gpio.inc
@@ -42,7 +42,6 @@ GPIO_INT(TABLET_MODE_L, PIN(H, 4), GPIO_INT_BOTH, hall_sensor_isr)
GPIO_INT(EC_VOLDN_BTN_ODL, PIN(D, 6), GPIO_INT_BOTH, button_interrupt)
GPIO_INT(EC_VOLUP_BTN_ODL, PIN(D, 5), GPIO_INT_BOTH, button_interrupt)
GPIO_INT(BASE_SIXAXIS_INT_L, PIN(J, 2), GPIO_INT_FALLING | GPIO_SEL_1P8V, bmi160_interrupt)
-GPIO_INT(WFCAM_VSYNC, PIN(D, 4), GPIO_INT_RISING, sync_interrupt)
GPIO(LID_ACCEL_INT_L, PIN(J, 3), GPIO_INPUT | GPIO_SEL_1P8V)
GPIO(PCH_PLTRST_L, PIN(E, 3), GPIO_INPUT) /* PLT_RST_L: Platform Reset from SoC */
@@ -114,6 +113,8 @@ GPIO(BAT_LED_WHITE, PIN(A, 3), GPIO_OUT_LOW) /* LED_2_EC */
/* MKBP event synchronization */
GPIO(EC_INT_L, PIN(E, 6), GPIO_ODR_HIGH)
+GPIO(WFCAM_VSYNC, PIN(D, 4), GPIO_INPUT | GPIO_PULL_DOWN)
+
UNIMPLEMENTED(KB_BL_PWR_EN)
/* NC pins, enable internal pull-down to avoid floating state. */
diff --git a/driver/accel_bma2x2.h b/driver/accel_bma2x2.h
index dbb8347c94..800b034d17 100644
--- a/driver/accel_bma2x2.h
+++ b/driver/accel_bma2x2.h
@@ -23,7 +23,7 @@ extern const struct accelgyro_drv bma2x2_accel_drv;
* BMA222E
*/
#define BMA2x2_I2C_ADDR1 0x30
-#define BMA2x2_I2C_ADDR2 0x19
+#define BMA2x2_I2C_ADDR2 0x32
/* The following definition of I2C address is used for the following sensors
* BMC150