summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce <Bruce.Wan@quantatw.com>2017-02-14 17:58:03 +0800
committerchrome-bot <chrome-bot@chromium.org>2017-02-18 00:39:28 -0800
commit08928c1f76f932f259c5dd5db7e007992e7e8887 (patch)
tree0fe52df5f5d99e1948c1b89694b32a75c6d63591
parent9761bf2ba1919c9270bd50118c14fbb0945f9d36 (diff)
downloadchrome-ec-08928c1f76f932f259c5dd5db7e007992e7e8887.tar.gz
snappy: support lid accel matrix by board version.
As the new form-factor has the lid accelerometer on the reversed side facing the B-cover, the matrix setting depending on board version; in such matter, it should be able to compatible with old version of boards. We create a new hook function for board specific tweaks, this is because since the commit of 0c57824 ("reef: Re-factor PP5000 and PP3300 enable/disable"), the board_init() is no longer a good place for tweaks, because ADC read should come after adc_init(); such that, new hook ensures robust ADC reading which is the source of board version. Also, we fix an arithmetic error for version-3 workaround, i.e. patch the commit of ca99f38 ("snappy: BMI160 is powered down on board v3 and older in S3"), else it could trigger unexpected EC panic like this: [89.770776 chipset -> S3] [89.771222 power state 2 = S3, in 0x006d] [89.772428 I2C unwedge failed, SCL is being held low] [89.773775 TCPC p0 Low Power Mode] [89.812962 Reset i2c 01 fail!] ...snip... [91.816415 Unexpected i2c state machine! 1] Time: 0x00000000057a7d9c us, 91.913628 s Deadline: 0x00000000057a8a1d -> 0.003201 s from now ...snip... Rebooting... --- UART initialized after reboot --- [Reset cause: soft] ...snip... BUG=chrome-os-partner:62676 BRANCH=reef TEST=check the DVT1 and DVT2 unit rotate normally. Change-Id: Ic53e67e0c97e57056587adb6b260e81c0f99437a Signed-off-by: Bruce.Wan <Bruce.Wan@quantatw.com> Reviewed-on: https://chromium-review.googlesource.com/442252 Commit-Ready: Chen Wisley <wisley.chen@quantatw.com> Tested-by: Bruce Wan <Bruce.Wan@quantatw.com> Tested-by: Harry Pan <harry.pan@intel.com> Reviewed-by: Aaron Durbin <adurbin@chromium.org>
-rw-r--r--board/snappy/board.c45
1 files changed, 35 insertions, 10 deletions
diff --git a/board/snappy/board.c b/board/snappy/board.c
index 1a40b5a49a..9eb9af564a 100644
--- a/board/snappy/board.c
+++ b/board/snappy/board.c
@@ -506,14 +506,6 @@ static void board_init(void)
/* Enable Gyro interrupts */
gpio_enable_interrupt(GPIO_BASE_SIXAXIS_INT_L);
-
- /* Set the sensors in the right powermode */
- if (system_get_board_version() <= BOARD_VERSION_3) {
- int i;
-
- for (i = BASE_ACCEL; i <= BASE_MAG; ++i)
- motion_sensors[i].active_mask = SENSOR_ACTIVE_S0;
- }
}
/* PP3300 needs to be enabled before TCPC init hooks */
DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_FIRST);
@@ -792,7 +784,13 @@ const matrix_3x3_t base_standard_ref = {
{ 0, 0, FLOAT_TO_FP(-1)}
};
-const matrix_3x3_t lid_standard_ref = {
+const matrix_3x3_t lid_a_cover_facing_ref = {
+ { FLOAT_TO_FP(1), 0, 0},
+ { 0, FLOAT_TO_FP(1), 0},
+ { 0, 0, FLOAT_TO_FP(1)}
+};
+
+const matrix_3x3_t lid_b_cover_facing_ref = {
{ FLOAT_TO_FP(1), 0, 0},
{ 0, FLOAT_TO_FP(-1), 0},
{ 0, 0, FLOAT_TO_FP(-1)}
@@ -815,7 +813,7 @@ struct motion_sensor_t motion_sensors[] = {
.drv_data = &g_kx022_data,
.port = I2C_PORT_LID_ACCEL,
.addr = KX022_ADDR1,
- .rot_standard_ref = &lid_standard_ref, /* Identity matrix. */
+ .rot_standard_ref = &lid_a_cover_facing_ref, /* Identity matrix. */
.default_range = 2, /* g, enough for laptop. */
.config = {
/* AP: by default use EC settings */
@@ -1093,3 +1091,30 @@ const int keyboard_factory_scan_pins[][2] = {
const int keyboard_factory_scan_pins_used =
ARRAY_SIZE(keyboard_factory_scan_pins);
#endif
+
+static void board_init_late(void)
+{
+ int version = system_get_board_version();
+
+ /* Set the sensors in the right powermode */
+ if (version <= BOARD_VERSION_4) {
+ int i;
+
+ for (i = BASE_ACCEL; i <= BASE_MAG; ++i)
+ motion_sensors[i].active_mask = SENSOR_ACTIVE_S0;
+ }
+
+ /*
+ * New form-factor aligns w/ electro, lid accelerometer
+ * faces to B-cover.
+ */
+ if (version < BOARD_VERSION_6)
+ motion_sensors[LID_ACCEL].rot_standard_ref =
+ &lid_b_cover_facing_ref;
+}
+/*
+ * We need robust ADC read, that is the source of board version;
+ * in order to apply board specific tweaks, so eusure this hook
+ * comes after adc_init().
+ */
+DECLARE_HOOK(HOOK_INIT, board_init_late, HOOK_PRIO_INIT_ADC + 1);