summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Hill <ecgh@chromium.org>2018-12-04 12:28:16 -0700
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2018-12-07 18:05:27 +0000
commitd24066f9db7f903f81405f8f78c323b7d1e716ff (patch)
treec2c97767cd9294d7823778b453e976834947398a
parentaa08bf00dfdf60f7882f4bc8bcd76b568c86057b (diff)
downloadchrome-ec-d24066f9db7f903f81405f8f78c323b7d1e716ff.tar.gz
aleena/kasumi: Add support for motion sensors
Adjust Grunt baseboard to allow for per-sku support for motion sensors. Use this to enable motion sensors for SKU 82 (Kasumi360). Only enable the interrupt if the sensor is present. BUG=b:119795894 BRANCH=grunt TEST=Kasumi360 `ectool motionsense lid_angle` shows correct angles. Change-Id: Icb34359d7ac4cd894776e134c2c1fb7032741f03 Signed-off-by: Edward Hill <ecgh@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/1362634 Reviewed-by: Ryan Zhang <ryan.zhang@quanta.corp-partner.google.com> Reviewed-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Ryan Zhang <ryan.zhang@quanta.corp-partner.google.com> Tested-by: Ryan Zhang <ryan.zhang@quanta.corp-partner.google.com>
-rw-r--r--baseboard/grunt/baseboard.c28
-rw-r--r--baseboard/grunt/baseboard.h2
-rw-r--r--board/aleena/board.c13
-rw-r--r--board/aleena/board.h18
-rw-r--r--board/aleena/ec.tasklist1
-rw-r--r--board/aleena/gpio.inc1
-rw-r--r--board/careena/board.c5
-rw-r--r--board/delan/board.c5
-rw-r--r--board/grunt/board.c3
-rw-r--r--board/liara/board.c5
10 files changed, 50 insertions, 31 deletions
diff --git a/baseboard/grunt/baseboard.c b/baseboard/grunt/baseboard.c
index 579b7758c5..032ae55076 100644
--- a/baseboard/grunt/baseboard.c
+++ b/baseboard/grunt/baseboard.c
@@ -49,8 +49,6 @@
#define CPRINTS(format, args...) cprints(CC_USBCHARGE, format, ## args)
#define CPRINTF(format, args...) cprintf(CC_USBCHARGE, format, ## args)
-static int board_is_convertible(void);
-
const enum gpio_signal hibernate_wake_pins[] = {
GPIO_LID_OPEN,
GPIO_AC_PRESENT,
@@ -348,6 +346,8 @@ const struct temp_sensor_t temp_sensors[] = {
};
BUILD_ASSERT(ARRAY_SIZE(temp_sensors) == TEMP_SENSOR_COUNT);
+#ifdef HAS_TASK_MOTIONSENSE
+
/* Motion sensors */
static struct mutex g_lid_mutex;
static struct mutex g_base_mutex;
@@ -441,6 +441,8 @@ struct motion_sensor_t motion_sensors[] = {
unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors);
+#endif /* HAS_TASK_MOTIONSENSE */
+
#ifndef TEST_BUILD
void lid_angle_peripheral_enable(int enable)
{
@@ -532,6 +534,10 @@ static void cbi_init(void)
}
#endif
+#ifdef HAS_TASK_MOTIONSENSE
+ board_update_sensor_config_from_sku();
+#endif
+
ccprints("Board Version: %d (0x%x)", board_version, board_version);
ccprints("SKU: %d (0x%x)", sku_id, sku_id);
}
@@ -555,9 +561,11 @@ int board_get_version(void)
* Returns 1 for boards that are convertible into tablet mode, and zero for
* clamshells.
*/
-static int board_is_convertible(void)
+int board_is_convertible(void)
{
- return system_get_sku_id() == 6;
+ /* Grunt: 6 */
+ /* Kasumi360: 82 */
+ return (sku_id == 6 || sku_id == 82);
}
int board_is_lid_angle_tablet_mode(void)
@@ -567,16 +575,12 @@ int board_is_lid_angle_tablet_mode(void)
uint32_t board_override_feature_flags0(uint32_t flags0)
{
- uint32_t sku = system_get_sku_id();
-
/*
- * We always compile in backlight support for grunt baseboard,
- * but only some models come with the hardware. Therefore,
- * check if the current device is one of them and return
- * the default value - with backlight here.
+ * Remove keyboard backlight feature for devices that don't support it.
*/
- if (sku == 16 || sku == 17 || sku == 20 || sku == 21 || sku == 32
- || sku == 33)
+ if (sku_id == 16 || sku_id == 17 ||
+ sku_id == 20 || sku_id == 21 ||
+ sku_id == 32 || sku_id == 33)
return (flags0 & ~EC_FEATURE_MASK_0(EC_FEATURE_PWM_KEYB));
else
return flags0;
diff --git a/baseboard/grunt/baseboard.h b/baseboard/grunt/baseboard.h
index 066ee26394..d96d98e903 100644
--- a/baseboard/grunt/baseboard.h
+++ b/baseboard/grunt/baseboard.h
@@ -255,6 +255,8 @@ void board_reset_pd_mcu(void);
void tcpc_alert_event(enum gpio_signal signal);
int board_get_version(void);
+int board_is_convertible(void);
+void board_update_sensor_config_from_sku(void);
#endif /* !__ASSEMBLER__ */
diff --git a/board/aleena/board.c b/board/aleena/board.c
index e10d0da223..5ba79d81fa 100644
--- a/board/aleena/board.c
+++ b/board/aleena/board.c
@@ -14,6 +14,7 @@
#include "common.h"
#include "compile_time_macros.h"
#include "console.h"
+#include "driver/accelgyro_bmi160.h"
#include "driver/led/lm3630a.h"
#include "driver/ppc/sn5s330.h"
#include "driver/tcpm/anx74xx.h"
@@ -102,10 +103,18 @@ const struct pwm_t pwm_channels[] = {
};
BUILD_ASSERT(ARRAY_SIZE(pwm_channels) == PWM_CH_COUNT);
-static void board_init(void)
+void board_update_sensor_config_from_sku(void)
{
+ if (board_is_convertible()) {
+ /* Enable Gyro interrupts */
+ gpio_enable_interrupt(GPIO_6AXIS_INT_L);
+ } else {
+ motion_sensor_count = 0;
+ /* Gyro is not present, don't allow line to float */
+ gpio_set_flags(GPIO_6AXIS_INT_L,
+ GPIO_INPUT | GPIO_PULL_DOWN);
+ }
}
-DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT);
void board_overcurrent_event(int port)
{
diff --git a/board/aleena/board.h b/board/aleena/board.h
index a32ec2ffd2..aeb75404a6 100644
--- a/board/aleena/board.h
+++ b/board/aleena/board.h
@@ -29,6 +29,24 @@
/* KB backlight driver */
#define CONFIG_LED_DRIVER_LM3630A
+/* Motion sensing drivers */
+#define CONFIG_ACCELGYRO_BMI160
+#define CONFIG_ACCELGYRO_BMI160_INT_EVENT TASK_EVENT_CUSTOM(4)
+#define CONFIG_ACCEL_INTERRUPTS
+#define CONFIG_ACCEL_KX022
+#define CONFIG_CMD_ACCELS
+#define CONFIG_CMD_ACCEL_INFO
+#define CONFIG_TABLET_MODE
+#define CONFIG_LID_ANGLE
+#define CONFIG_LID_ANGLE_UPDATE
+#define CONFIG_LID_ANGLE_SENSOR_BASE BASE_ACCEL
+#define CONFIG_LID_ANGLE_SENSOR_LID LID_ACCEL
+/*
+ * Slew rate on the PP1800_SENSOR load switch requires a short delay on startup.
+ */
+#undef CONFIG_MOTION_SENSE_RESUME_DELAY_US
+#define CONFIG_MOTION_SENSE_RESUME_DELAY_US (10 * MSEC)
+
#ifndef __ASSEMBLER__
enum pwm_channel {
diff --git a/board/aleena/ec.tasklist b/board/aleena/ec.tasklist
index 67453cd670..97711213a1 100644
--- a/board/aleena/ec.tasklist
+++ b/board/aleena/ec.tasklist
@@ -25,6 +25,7 @@
TASK_ALWAYS(USB_CHG_P0, usb_charger_task, 0, TASK_STACK_SIZE) \
TASK_ALWAYS(USB_CHG_P1, usb_charger_task, 1, TASK_STACK_SIZE) \
TASK_ALWAYS(CHARGER, charger_task, NULL, VENTI_TASK_STACK_SIZE) \
+ TASK_ALWAYS(MOTIONSENSE, motion_sense_task, NULL, VENTI_TASK_STACK_SIZE) \
TASK_NOTEST(CHIPSET, chipset_task, NULL, VENTI_TASK_STACK_SIZE) \
TASK_NOTEST(KEYPROTO, keyboard_protocol_task, NULL, TASK_STACK_SIZE) \
TASK_NOTEST(PDCMD, pd_command_task, NULL, LARGER_TASK_STACK_SIZE) \
diff --git a/board/aleena/gpio.inc b/board/aleena/gpio.inc
index 085aa9a1d6..1256ecb6cb 100644
--- a/board/aleena/gpio.inc
+++ b/board/aleena/gpio.inc
@@ -23,6 +23,7 @@ GPIO_INT(WP_L, PIN(A, 1), GPIO_INT_BOTH, switch_interrupt)
GPIO_INT(VOLUME_DOWN_L, PIN(7, 0), GPIO_INT_BOTH | GPIO_PULL_UP, button_interrupt)
GPIO_INT(VOLUME_UP_L, PIN(7, 5), GPIO_INT_BOTH | GPIO_PULL_UP, button_interrupt)
GPIO_INT(USB_C0_CABLE_DET, PIN(3, 7), GPIO_INT_RISING, anx74xx_cable_det_interrupt)
+GPIO_INT(6AXIS_INT_L, PIN(8, 6), GPIO_INT_FALLING | GPIO_SEL_1P8V, bmi160_interrupt)
GPIO(EN_PWR_A, PIN(E, 2), GPIO_OUT_LOW) /* Enable Power */
GPIO(EN_PP1800_SENSOR, PIN(6, 7), GPIO_OUT_LOW) /* Enable Power */
diff --git a/board/careena/board.c b/board/careena/board.c
index 495b4a9cae..380a936fd1 100644
--- a/board/careena/board.c
+++ b/board/careena/board.c
@@ -101,11 +101,6 @@ const struct pwm_t pwm_channels[] = {
};
BUILD_ASSERT(ARRAY_SIZE(pwm_channels) == PWM_CH_COUNT);
-static void board_init(void)
-{
-}
-DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT);
-
void board_overcurrent_event(int port)
{
enum gpio_signal signal = (port == 0) ? GPIO_USB_C0_OC_L
diff --git a/board/delan/board.c b/board/delan/board.c
index 0c0924e8bd..f5b5f5b2dd 100644
--- a/board/delan/board.c
+++ b/board/delan/board.c
@@ -114,11 +114,6 @@ const struct pwm_t pwm_channels[] = {
};
BUILD_ASSERT(ARRAY_SIZE(pwm_channels) == PWM_CH_COUNT);
-static void board_init(void)
-{
-}
-DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT);
-
void board_overcurrent_event(int port)
{
enum gpio_signal signal = (port == 0) ? GPIO_USB_C0_OC_L
diff --git a/board/grunt/board.c b/board/grunt/board.c
index 3477666679..f60e3be18a 100644
--- a/board/grunt/board.c
+++ b/board/grunt/board.c
@@ -118,12 +118,11 @@ const struct pwm_t pwm_channels[] = {
};
BUILD_ASSERT(ARRAY_SIZE(pwm_channels) == PWM_CH_COUNT);
-static void board_init(void)
+void board_update_sensor_config_from_sku(void)
{
/* Enable Gyro interrupts */
gpio_enable_interrupt(GPIO_6AXIS_INT_L);
}
-DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT);
void board_overcurrent_event(int port)
{
diff --git a/board/liara/board.c b/board/liara/board.c
index 5a7cbdf23e..0e8a9abb5e 100644
--- a/board/liara/board.c
+++ b/board/liara/board.c
@@ -114,11 +114,6 @@ const struct pwm_t pwm_channels[] = {
};
BUILD_ASSERT(ARRAY_SIZE(pwm_channels) == PWM_CH_COUNT);
-static void board_init(void)
-{
-}
-DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT);
-
void board_overcurrent_event(int port)
{
enum gpio_signal signal = (port == 0) ? GPIO_USB_C0_OC_L