diff options
author | Peggy Chuang <PeggyChuang@ami.com.tw> | 2017-01-18 14:47:29 +0800 |
---|---|---|
committer | ChromeOS Commit Bot <chromeos-commit-bot@chromium.org> | 2017-02-08 03:27:09 +0000 |
commit | 37e63bd63ed9156aa2e560f489099bd5e4ed7f4f (patch) | |
tree | 387a25dd1ee04583ed20990cd496e6d74f765b4c | |
parent | 16d79f343b631a64f9d539f20d075f57a5e412ed (diff) | |
download | chrome-ec-37e63bd63ed9156aa2e560f489099bd5e4ed7f4f.tar.gz |
Wizpig: Adapt to new sensor stack
Given wizpig overlay is used for convertible as well as clamshell,
re-add sensor stack. It was remove in cl/409508
BUG=chrome-os-partner:62184, chrome-os-partner:62214
CQ-DEPEND=CL:435710
TEST=Test tablet mode and normal mode, switch both mode is working normal.
Test ARC++ sees the sensors with app AIDA64.
BRANCH=strago
Signed-off-by: Peggy Chuang <peggychuang@ami.com.tw>
Change-Id: I7c731fbdaceb5a95feff556c8ee74fa80b5a9654
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/429770
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Commit-Queue: Peggy Chuang <PeggyChuang@ami.com.tw>
Tested-by: Peggy Chuang <PeggyChuang@ami.com.tw>
-rw-r--r-- | board/wizpig/board.c | 113 | ||||
-rw-r--r-- | board/wizpig/board.h | 46 | ||||
-rw-r--r-- | board/wizpig/ec.tasklist | 1 |
3 files changed, 156 insertions, 4 deletions
diff --git a/board/wizpig/board.c b/board/wizpig/board.c index dedc10f774..3451fe7dd6 100644 --- a/board/wizpig/board.c +++ b/board/wizpig/board.c @@ -10,13 +10,13 @@ #include "charger.h" #include "charge_state.h" #include "driver/accel_kionix.h" -#include "driver/gyro_l3gd20h.h" #include "driver/temp_sensor/tmp432.h" #include "extpower.h" #include "gpio.h" #include "hooks.h" #include "host_command.h" #include "i2c.h" +#include "keyboard_scan.h" #include "lid_switch.h" #include "math_util.h" #include "motion_lid.h" @@ -112,6 +112,117 @@ const struct button_config buttons[] = { }; BUILD_ASSERT(ARRAY_SIZE(buttons) == CONFIG_BUTTON_COUNT); +/* Two Motion sensors */ +/* kxcj9 mutex and local/private data*/ +static struct mutex g_kxcj9_mutex[2]; +struct kionix_accel_data g_kxcj9_data[2]; + +/* Matrix to rotate accelrator into standard reference frame */ +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)} +}; + +const matrix_3x3_t lid_standard_ref = { + {FLOAT_TO_FP(1), 0, 0}, + { 0, FLOAT_TO_FP(1), 0}, + { 0, 0, FLOAT_TO_FP(1)} +}; + +struct motion_sensor_t motion_sensors[] = { + [BASE_ACCEL] = { + .name = "Base", + .active_mask = SENSOR_ACTIVE_S0_S3, + .chip = MOTIONSENSE_CHIP_KXCJ9, + .type = MOTIONSENSE_TYPE_ACCEL, + .location = MOTIONSENSE_LOC_BASE, + .drv = &kionix_accel_drv, + .mutex = &g_kxcj9_mutex[0], + .drv_data = &g_kxcj9_data[0], + .port = I2C_PORT_ACCEL, + .addr = KXCJ9_ADDR1, + .rot_standard_ref = &base_standard_ref, + .default_range = 2, /* g, enough for laptop. */ + .config = { + /* AP: by default shutdown all sensors */ + [SENSOR_CONFIG_AP] = { + .odr = 0, + .ec_rate = 0, + }, + /* EC use accel for angle detection */ + [SENSOR_CONFIG_EC_S0] = { + .odr = 10000 | ROUND_UP_FLAG, + .ec_rate = 0, + }, + /* Sensor off in S3/S5 */ + [SENSOR_CONFIG_EC_S3] = { + .odr = 0, + .ec_rate = 0 + }, + /* Sensor off in S3/S5 */ + [SENSOR_CONFIG_EC_S5] = { + .odr = 0, + .ec_rate = 0 + }, + } + }, + [LID_ACCEL] = { + .name = "Lid", + .active_mask = SENSOR_ACTIVE_S0_S3, + .chip = MOTIONSENSE_CHIP_KXCJ9, + .type = MOTIONSENSE_TYPE_ACCEL, + .location = MOTIONSENSE_LOC_LID, + .drv = &kionix_accel_drv, + .mutex = &g_kxcj9_mutex[1], + .drv_data = &g_kxcj9_data[1], + .port = I2C_PORT_ACCEL, + .addr = KXCJ9_ADDR0, + .rot_standard_ref = &lid_standard_ref, + .default_range = 2, /* g, enough for laptop. */ + .config = { + /* AP: by default shutdown all sensors */ + [SENSOR_CONFIG_AP] = { + .odr = 0, + .ec_rate = 0, + }, + /* EC use accel for angle detection */ + [SENSOR_CONFIG_EC_S0] = { + .odr = 10000 | ROUND_UP_FLAG, + .ec_rate = 0, + }, + /* Sensor off in S3/S5 */ + [SENSOR_CONFIG_EC_S3] = { + .odr = 0, + .ec_rate = 0 + }, + /* Sensor off in S3/S5 */ + [SENSOR_CONFIG_EC_S5] = { + .odr = 0, + .ec_rate = 0 + }, + }, + }, +}; +const unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors); + +#ifdef CONFIG_LID_ANGLE_UPDATE +void lid_angle_peripheral_enable(int enable) +{ + if (enable) { + keyboard_scan_enable(1, KB_SCAN_DISABLE_LID_ANGLE); + } else { + /* + * Ensure that the chipset is off before disabling the keyboard. + * When the chipset is on, the EC keeps the keyboard enabled and + * the AP decides whether to ignore input devices or not. + */ + if (!chipset_in_state(CHIPSET_STATE_ON)) + keyboard_scan_enable(0, KB_SCAN_DISABLE_LID_ANGLE); + } +} +#endif + /* init ADC ports to avoid floating state due to thermistors */ static void adc_pre_init(void) { diff --git a/board/wizpig/board.h b/board/wizpig/board.h index 8d22f2c2fe..a366715db3 100644 --- a/board/wizpig/board.h +++ b/board/wizpig/board.h @@ -8,14 +8,21 @@ #ifndef __CROS_EC_BOARD_H #define __CROS_EC_BOARD_H +/* + * By default, enable all console messages excepted HC, ACPI and event: + * The sensor stack is generating a lot of activity. + */ +#define CC_DEFAULT (CC_ALL & ~(CC_MASK(CC_EVENTS) | CC_MASK(CC_LPC))) +/* By default, set hcdebug to off */ +#undef CONFIG_HOSTCMD_DEBUG_MODE +#define CONFIG_HOSTCMD_DEBUG_MODE HCDEBUG_OFF + /* Optional features */ #define CONFIG_WATCHDOG_HELP +#define CONFIG_BOARD_VERSION #define CONFIG_CLOCK_CRYSTAL #define CONFIG_CHIPSET_BRASWELL #define CONFIG_SCI_GPIO GPIO_PCH_SCI_L - -#define CONFIG_BOARD_VERSION - #define CONFIG_KEYBOARD_COL2_INVERTED #define CONFIG_KEYBOARD_IRQ_GPIO GPIO_KBD_IRQ_L #undef CONFIG_KEYBOARD_KSO_BASE @@ -26,6 +33,8 @@ #define CONFIG_LID_SWITCH #define CONFIG_LOW_POWER_IDLE #define CONFIG_LOW_POWER_PSEUDO_G3 +#define CONFIG_MKBP_EVENT +#define CONFIG_MKBP_USE_HOST_EVENT #define CONFIG_POWER_COMMON #define CONFIG_POWER_SHUTDOWN_PAUSE_IN_S5 #define CONFIG_EXTPOWER_GPIO @@ -68,6 +77,18 @@ #define CONFIG_I2C +/* Accelerometer */ +#define CONFIG_ACCEL_KXCJ9 +#define CONFIG_CMD_ACCELS +#define CONFIG_CMD_ACCEL_INFO + +/* Depends on how fast the AP boots and typical ODRs */ +#define CONFIG_ACCEL_FIFO 512 +#define CONFIG_ACCEL_FIFO_THRES (CONFIG_ACCEL_FIFO / 3) + +#define CONFIG_LID_ANGLE +#define CONFIG_LID_ANGLE_UPDATE + /* Wireless signals */ #define WIRELESS_GPIO_WLAN GPIO_WLAN_OFF_L @@ -91,6 +112,9 @@ #define I2C_PORT_CHARGER MEC1322_I2C0_0 #define I2C_PORT_PD_MCU MEC1322_I2C1 #define I2C_PORT_TCPC MEC1322_I2C1 +#define I2C_PORT_ACCEL MEC1322_I2C2 +#define I2C_PORT_GYRO MEC1322_I2C2 + #define I2C_PORT_THERMAL MEC1322_I2C3 /* ADC signal */ @@ -99,6 +123,22 @@ enum adc_channel { ADC_CH_COUNT }; +/* Sensor index definition */ +enum sensor_id { + BASE_ACCEL = 0, + LID_ACCEL = 1, +}; + +/* + * We have not enabled the sensor FIFO on the accels, so we force the EC + * to collect at every sample. + */ +#define CONFIG_ACCEL_FORCE_MODE_MASK \ + ((1 << BASE_ACCEL) | (1 << LID_ACCEL)) + +#define CONFIG_LID_ANGLE_SENSOR_BASE BASE_ACCEL +#define CONFIG_LID_ANGLE_SENSOR_LID LID_ACCEL + /* power signal definitions */ enum power_signal { X86_ALL_SYS_PWRGD = 0, diff --git a/board/wizpig/ec.tasklist b/board/wizpig/ec.tasklist index 33240cdf02..3261d956d6 100644 --- a/board/wizpig/ec.tasklist +++ b/board/wizpig/ec.tasklist @@ -19,6 +19,7 @@ #define CONFIG_TASK_LIST \ TASK_ALWAYS(HOOKS, hook_task, NULL, LARGER_TASK_STACK_SIZE) \ TASK_ALWAYS(CHARGER, charger_task, NULL, LARGER_TASK_STACK_SIZE) \ + TASK_NOTEST(MOTIONSENSE, motion_sense_task, NULL, LARGER_TASK_STACK_SIZE) \ TASK_NOTEST(CHIPSET, chipset_task, NULL, LARGER_TASK_STACK_SIZE) \ TASK_NOTEST(KEYPROTO, keyboard_protocol_task, NULL, TASK_STACK_SIZE) \ TASK_ALWAYS(HOSTCMD, host_command_task, NULL, LARGER_TASK_STACK_SIZE) \ |