summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Ma <magf@bitland.corp-partner.google.com>2018-06-26 09:04:18 +0800
committerchrome-bot <chrome-bot@chromium.org>2018-06-29 01:09:09 -0700
commit47a1c1a0427400d5a0f5def8f69fcb70bbb4f4e7 (patch)
tree8dc2eaa597b2ad2703673dd9b9e191c6a4d1f3ce
parentc12fe99d58b37278016567b245b154345a17a61f (diff)
downloadchrome-ec-stabilize-nocturne.10828.B.tar.gz
phaser: enable tablet mode and lid anglestabilize-nocturne.10828.B
Enable CONFIG_DYNAMIC_MOTION_SENSOR_COUNT so that clamshell skus and convertible skus get different sensor number. Enable lid angle function to make peripherals get correct state on convertible skus. Enable tablet mode for convertible skus as well. Signed-off-by: Paul Ma <magf@bitland.corp-partner.google.com> BRANCH=none BUG=b:110604678 TEST=boot phaser360 sku, test keyboard function when hinge is at 135, 180, 270, 360 degree. test tablet mode when 360 degree. Change-Id: I8f15a2d3ea3ae7d0cf5d60333e079d1ffd8e906b Reviewed-on: https://chromium-review.googlesource.com/1114667 Commit-Ready: Paul Ma <magf@bitland.corp-partner.google.com> Tested-by: Paul Ma <magf@bitland.corp-partner.google.com> Reviewed-by: Jett Rink <jettrink@chromium.org>
-rw-r--r--board/phaser/board.c50
-rw-r--r--board/phaser/board.h6
-rw-r--r--board/phaser/gpio.inc4
3 files changed, 54 insertions, 6 deletions
diff --git a/board/phaser/board.c b/board/phaser/board.c
index d4a5fb00ae..092c30c40a 100644
--- a/board/phaser/board.c
+++ b/board/phaser/board.c
@@ -19,16 +19,20 @@
#include "extpower.h"
#include "gpio.h"
#include "hooks.h"
+#include "keyboard_scan.h"
#include "lid_switch.h"
#include "power.h"
#include "power_button.h"
#include "switch.h"
#include "task.h"
+#include "tablet_mode.h"
#include "tcpci.h"
#include "temp_sensor.h"
#include "thermistor.h"
#include "util.h"
+static uint16_t sku_id;
+
static void tcpc_alert_event(enum gpio_signal signal)
{
if ((signal == GPIO_USB_C1_MUX_INT_ODL) &&
@@ -120,8 +124,6 @@ static struct lsm6dsm_data lsm6dsm_g_data;
static struct lsm6dsm_data lsm6dsm_a_data;
/* Drivers */
-/* lis2de only has a i2c address difference, so we use lis2dh driver */
-/* but use a different address */
struct motion_sensor_t motion_sensors[] = {
[LID_ACCEL] = {
.name = "Lid Accel",
@@ -197,7 +199,32 @@ struct motion_sensor_t motion_sensors[] = {
},
};
-const unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors);
+unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors);
+
+static int board_is_convertible(void)
+{
+ return (sku_id > 0 && sku_id <= 6) || sku_id == 255;
+}
+
+static void board_set_motion_sensor_count(void)
+{
+ if (board_is_convertible())
+ motion_sensor_count = ARRAY_SIZE(motion_sensors);
+ else
+ motion_sensor_count = 0;
+}
+
+static void cbi_init(void)
+{
+ uint32_t val;
+
+ if (cbi_get_sku_id(&val) == EC_SUCCESS)
+ sku_id = val;
+ ccprints("SKU: 0x%04x", sku_id);
+
+ board_set_motion_sensor_count();
+}
+DECLARE_HOOK(HOOK_INIT, cbi_init, HOOK_PRIO_INIT_I2C + 1);
/* Initialize board. */
static void board_init(void)
@@ -206,3 +233,20 @@ static void board_init(void)
gpio_enable_interrupt(GPIO_BASE_SIXAXIS_INT_L);
}
DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT);
+
+#ifndef TEST_BUILD
+/* This callback disables keyboard when convertibles are fully open */
+void lid_angle_peripheral_enable(int enable)
+{
+ /*
+ * If the lid is in tablet position via other sensors,
+ * ignore the lid angle, which might be faulty then
+ * disable keyboard.
+ */
+ if (tablet_get_mode())
+ enable = 0;
+
+ if (board_is_convertible())
+ keyboard_scan_enable(enable, KB_SCAN_DISABLE_LID_ANGLE);
+}
+#endif
diff --git a/board/phaser/board.h b/board/phaser/board.h
index c8c866b703..17f3ab37e7 100644
--- a/board/phaser/board.h
+++ b/board/phaser/board.h
@@ -36,8 +36,14 @@
#define CONFIG_ACCEL_FORCE_MODE_MASK (1 << LID_ACCEL)
#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
+#define CONFIG_DYNAMIC_MOTION_SENSOR_COUNT
+
+#define CONFIG_TABLET_MODE
+#define CONFIG_TABLET_SWITCH
+#define TABLET_MODE_GPIO_L GPIO_TABLET_MODE_L
/* Interrupt and fifo are only used for base accelerometer
* and the lid sensor is polled real-time (in forced mode).
diff --git a/board/phaser/gpio.inc b/board/phaser/gpio.inc
index 295fa5866a..6601822897 100644
--- a/board/phaser/gpio.inc
+++ b/board/phaser/gpio.inc
@@ -35,13 +35,11 @@ GPIO_INT(ALL_SYS_PGOOD, PIN(F, 4), GPIO_INT_BOTH, power_signal_interrupt) /* PM
/* Other interrupts */
GPIO_INT(WP_L, PIN(A, 1), GPIO_INT_BOTH, switch_interrupt) /* EC_WP_ODL */
+GPIO_INT(TABLET_MODE_L, PIN(8, 6), GPIO_INT_BOTH, tablet_mode_isr)
GPIO_INT(BASE_SIXAXIS_INT_L, PIN(5, 6), GPIO_INT_FALLING | GPIO_SEL_1P8V, lsm6dsm_interrupt)
GPIO(LID_ACCEL_INT_L, PIN(5, 0), GPIO_INPUT | GPIO_SEL_1P8V)
-/* TODO: Convert to GPIO_INT with tablet_mode_isr */
-GPIO(TABLET_MODE_L, PIN(8, 6), GPIO_INPUT)
-
/* Define PCH_SLP_S0_L after all interrupts if CONFIG_POWER_S0IX not defined. */
#ifndef CONFIG_POWER_S0IX
GPIO(PCH_SLP_S0_L, PIN(A, 4), GPIO_INPUT) /* SLP_S0_L */