diff options
-rw-r--r-- | board/snappy/board.c | 45 |
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); |