summaryrefslogtreecommitdiff
path: root/baseboard/grunt
diff options
context:
space:
mode:
authorJonathan Brandmeyer <jbrandmeyer@chromium.org>2018-06-07 13:28:26 -0600
committerchrome-bot <chrome-bot@chromium.org>2018-06-18 13:54:49 -0700
commit4c0f7192f6ca544bf46aea9ba8009f560b9cc5b5 (patch)
treed3507d6aa736e56e48dcc310a36dbef732562944 /baseboard/grunt
parent12f949ce832da4b9ffd1f3111fcaa7f9103ca3ea (diff)
downloadchrome-ec-4c0f7192f6ca544bf46aea9ba8009f560b9cc5b5.tar.gz
grunt: Enable tablet mode for convertible SKUs.
BUG=b:79159777 BRANCH=none TEST=EC functional test 1.2.18 on grunt convertible. Verified that a grunt clamshell wthat does not have a populated lid accelerometer works as expected. Change-Id: Ic9059d7d8f4f353475517ad3b8ef049ed653e9e4 Signed-off-by: Jonathan Brandmeyer <jbrandmeyer@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1093255 Reviewed-by: Edward Hill <ecgh@chromium.org>
Diffstat (limited to 'baseboard/grunt')
-rw-r--r--baseboard/grunt/baseboard.c51
-rw-r--r--baseboard/grunt/baseboard.h3
2 files changed, 44 insertions, 10 deletions
diff --git a/baseboard/grunt/baseboard.c b/baseboard/grunt/baseboard.c
index 6c429a427a..c512e0c53b 100644
--- a/baseboard/grunt/baseboard.c
+++ b/baseboard/grunt/baseboard.c
@@ -47,6 +47,8 @@
#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,
@@ -309,20 +311,34 @@ static struct mutex g_lid_mutex;
static struct mutex g_base_mutex;
/*
- * Matrix to rotate accelerator into standard reference frame
+ * Matrix to rotate accelerators into the standard reference frame. The default
+ * is the identity which is correct for the reference design. Variations of
+ * Grunt may need to change it for manufacturability.
+ * For the lid:
+ * +x to the right
+ * +y up
+ * +z out of the page
*
- * TODO(teravest): Update this when we can physically test a Grunt.
+ * The principle axes of the body are aligned with the lid when the lid is in
+ * the 180 degree position (open, flat).
*/
-const matrix_3x3_t base_standard_ref = {
- { 0, FLOAT_TO_FP(-1), 0},
- { FLOAT_TO_FP(1), 0, 0},
- { 0, 0, FLOAT_TO_FP(1)}
+matrix_3x3_t base_standard_ref = {
+ { FLOAT_TO_FP(1), 0, 0},
+ { 0, FLOAT_TO_FP(1), 0},
+ { 0, 0, FLOAT_TO_FP(1)}
+};
+
+matrix_3x3_t lid_standard_ref = {
+ { FLOAT_TO_FP(1), 0, 0},
+ { 0, FLOAT_TO_FP(1), 0},
+ { 0, 0, FLOAT_TO_FP(1)}
};
/* 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",
@@ -335,7 +351,7 @@ struct motion_sensor_t motion_sensors[] = {
.drv_data = &g_kx022_data,
.port = I2C_PORT_SENSOR,
.addr = KX022_ADDR1,
- .rot_standard_ref = NULL, /* Identity matrix. */
+ .rot_standard_ref = (const matrix_3x3_t *)&lid_standard_ref,
.default_range = 2, /* g, enough for laptop. */
.min_frequency = KX022_ACCEL_MIN_FREQ,
.max_frequency = KX022_ACCEL_MAX_FREQ,
@@ -359,7 +375,7 @@ struct motion_sensor_t motion_sensors[] = {
.port = I2C_PORT_SENSOR,
.addr = BMI160_ADDR0,
.default_range = 2, /* g, enough for laptop */
- .rot_standard_ref = &base_standard_ref,
+ .rot_standard_ref = (const matrix_3x3_t *)&base_standard_ref,
.min_frequency = BMI160_ACCEL_MIN_FREQ,
.max_frequency = BMI160_ACCEL_MAX_FREQ,
.config = {
@@ -387,7 +403,7 @@ struct motion_sensor_t motion_sensors[] = {
.port = I2C_PORT_SENSOR,
.addr = BMI160_ADDR0,
.default_range = 1000, /* dps */
- .rot_standard_ref = &base_standard_ref,
+ .rot_standard_ref = (const matrix_3x3_t *)&base_standard_ref,
.min_frequency = BMI160_GYRO_MIN_FREQ,
.max_frequency = BMI160_GYRO_MAX_FREQ,
},
@@ -398,7 +414,8 @@ const unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors);
#ifndef TEST_BUILD
void lid_angle_peripheral_enable(int enable)
{
- keyboard_scan_enable(enable, KB_SCAN_DISABLE_LID_ANGLE);
+ if (board_is_convertible())
+ keyboard_scan_enable(enable, KB_SCAN_DISABLE_LID_ANGLE);
}
#endif
@@ -458,3 +475,17 @@ uint32_t system_get_sku_id(void)
sku_id = (sku_id2 << 4) | sku_id1;
return sku_id;
}
+
+/*
+ * Returns 1 for boards that are convertible into tablet mode, and zero for
+ * clamshells.
+ */
+static int board_is_convertible(void)
+{
+ return system_get_sku_id() == 6;
+}
+
+int board_is_lid_angle_tablet_mode(void)
+{
+ return board_is_convertible();
+}
diff --git a/baseboard/grunt/baseboard.h b/baseboard/grunt/baseboard.h
index 4d826061fe..a86994d4a0 100644
--- a/baseboard/grunt/baseboard.h
+++ b/baseboard/grunt/baseboard.h
@@ -140,7 +140,10 @@
#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_TABLET_MODE
+#define CONFIG_LID_ANGLE_INVALID_CHECK
#define CONFIG_LID_ANGLE_UPDATE
#define CONFIG_LID_ANGLE_SENSOR_BASE BASE_ACCEL
#define CONFIG_LID_ANGLE_SENSOR_LID LID_ACCEL