diff options
author | Vincent Palatin <vpalatin@chromium.org> | 2016-10-21 14:50:39 -0700 |
---|---|---|
committer | ChromeOS Commit Bot <chromeos-commit-bot@chromium.org> | 2016-10-25 15:22:50 +0000 |
commit | c8998f8b34c1a6fce4772b75e943e5742436e8f4 (patch) | |
tree | 5a9db7c26b547aeba9107d5f6009457a4041d3b0 | |
parent | 611d341ff029be82c2f5e66a89481dddaf1ce2ee (diff) | |
download | chrome-ec-c8998f8b34c1a6fce4772b75e943e5742436e8f4.tar.gz |
caroline: Add ARC++ sensor support
Add ARC++ sensor support by defining a FIFO and reordering sensor array.
Signed-off-by: Vincent Palatin <vpalatin@chromium.org>
BUG=chrome-os-partner:57993
BRANCH=glados
TEST=With AIDA64, check sensors report information.
Check that the lid angle is calculated properly both by EC
(with 'ectool motionsense lid_angle') and Chrome (switch to Tablet mode
over 180 degrees and rotate the screen properly).
Change-Id: Ib6f2d04487e40db8053157ffa3ee673fe21aedc3
Reviewed-on: https://chromium-review.googlesource.com/402848
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Trybot-Ready: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
-rw-r--r-- | board/caroline/board.c | 100 | ||||
-rw-r--r-- | board/caroline/board.h | 57 | ||||
-rw-r--r-- | board/caroline/gpio.inc | 4 |
3 files changed, 90 insertions, 71 deletions
diff --git a/board/caroline/board.c b/board/caroline/board.c index 8aa46599b2..c9e8210136 100644 --- a/board/caroline/board.c +++ b/board/caroline/board.c @@ -82,11 +82,6 @@ void usb1_evt(enum gpio_signal signal) task_set_event(TASK_ID_USB_CHG_P1, USB_CHG_EVENT_BC12, 0); } -void tablet_mode_interrupt(enum gpio_signal signal) -{ - host_set_single_event(EC_HOST_EVENT_MODE_CHANGE); -} - #include "gpio_list.h" /* power signal list. Must match order of enum power_signal. */ @@ -266,6 +261,9 @@ static void board_init(void) gpio_enable_interrupt(GPIO_USB_C0_BC12_INT_L); gpio_enable_interrupt(GPIO_USB_C1_BC12_INT_L); + /* Enable interrupts from BMI160 sensor. */ + gpio_enable_interrupt(GPIO_ACCEL3_INT); + /* Provide AC status to the PCH */ gpio_set_level(GPIO_PCH_ACOK, extpower_is_present()); } @@ -472,16 +470,45 @@ const matrix_3x3_t lid_standard_ref = { }; struct motion_sensor_t motion_sensors[] = { - /* - * Note: bmi160: supports accelerometer and gyro sensor - * Requirement: accelerometer sensor must init before gyro sensor - * DO NOT change the order of the following table because the shared - * memory addresses are fixed. Changing the order will cause kernel - * driver read wrong data. - */ + [LID_ACCEL] = { + .name = "Lid Accel", + .active_mask = SENSOR_ACTIVE_S0_S3, + .chip = MOTIONSENSE_CHIP_BMA255, + .type = MOTIONSENSE_TYPE_ACCEL, + .location = MOTIONSENSE_LOC_LID, + .drv = &bma2x2_accel_drv, + .mutex = &g_lid_mutex, + .drv_data = &g_bma255_data, + .addr = BMA2x2_I2C_ADDR1, + .rot_standard_ref = &lid_standard_ref, + .default_range = 8, /* g, to support tablet mode */ + .config = { + /* AP: by default use EC settings */ + [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 = 100 * MSEC, + }, + /* Sensor on in S3 */ + [SENSOR_CONFIG_EC_S3] = { + .odr = 10000 | ROUND_UP_FLAG, + .ec_rate = 100 * MSEC, + }, + /* Sensor off in S5 */ + [SENSOR_CONFIG_EC_S5] = { + .odr = 0, + .ec_rate = 0, + }, + }, + }, + [BASE_ACCEL] = { .name = "Base Accel", - .active_mask = SENSOR_ACTIVE_S0, + .active_mask = SENSOR_ACTIVE_S0_S3, .chip = MOTIONSENSE_CHIP_BMI160, .type = MOTIONSENSE_TYPE_ACCEL, .location = MOTIONSENSE_LOC_BASE, @@ -490,7 +517,7 @@ struct motion_sensor_t motion_sensors[] = { .drv_data = &g_bmi160_data, .addr = BMI160_ADDR0, .rot_standard_ref = &base_standard_ref, - .default_range = 2, /* g, enough for laptop. */ + .default_range = 8, /* g, to support tablet mode */ .config = { /* AP: by default use EC settings */ [SENSOR_CONFIG_AP] = { @@ -502,21 +529,22 @@ struct motion_sensor_t motion_sensors[] = { .odr = 10000 | ROUND_UP_FLAG, .ec_rate = 100 * MSEC, }, - /* Sensor off in S3/S5 */ + /* Sensor on in S3 */ [SENSOR_CONFIG_EC_S3] = { - .odr = 0, - .ec_rate = 0 + .odr = 10000 | ROUND_UP_FLAG, + .ec_rate = 100 * MSEC, }, - /* Sensor off in S3/S5 */ + /* Sensor off in S5 */ [SENSOR_CONFIG_EC_S5] = { .odr = 0, .ec_rate = 0 }, }, }, + [BASE_GYRO] = { .name = "Base Gyro", - .active_mask = SENSOR_ACTIVE_S0, + .active_mask = SENSOR_ACTIVE_S0_S3, .chip = MOTIONSENSE_CHIP_BMI160, .type = MOTIONSENSE_TYPE_GYRO, .location = MOTIONSENSE_LOC_BASE, @@ -549,40 +577,6 @@ struct motion_sensor_t motion_sensors[] = { }, }, }, - [LID_ACCEL] = { - .name = "Lid Accel", - .active_mask = SENSOR_ACTIVE_S0, - .chip = MOTIONSENSE_CHIP_BMA255, - .type = MOTIONSENSE_TYPE_ACCEL, - .location = MOTIONSENSE_LOC_LID, - .drv = &bma2x2_accel_drv, - .mutex = &g_lid_mutex, - .drv_data = &g_bma255_data, - .addr = BMA2x2_I2C_ADDR1, - .rot_standard_ref = &lid_standard_ref, - .default_range = 2, /* g, enough for laptop. */ - .config = { - /* AP: by default use EC settings */ - [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, - }, - /* unused */ - [SENSOR_CONFIG_EC_S3] = { - .odr = 0, - .ec_rate = 0, - }, - [SENSOR_CONFIG_EC_S5] = { - .odr = 0, - .ec_rate = 0, - }, - }, - }, }; const unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors); #endif /* HAS_TASK_MOTIONSENSE */ diff --git a/board/caroline/board.h b/board/caroline/board.h index 85a081337c..ad27a28994 100644 --- a/board/caroline/board.h +++ b/board/caroline/board.h @@ -8,11 +8,15 @@ #ifndef __CROS_EC_BOARD_H #define __CROS_EC_BOARD_H +/* + * By default, enable all console messages except 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))) +#undef CONFIG_HOSTCMD_DEBUG_MODE +#define CONFIG_HOSTCMD_DEBUG_MODE HCDEBUG_OFF + /* Optional features */ -#define CONFIG_ACCEL_BMA255 -#define CONFIG_ACCELGYRO_BMI160 -#define CONFIG_ACCEL_INTERRUPTS -#define CONFIG_ACCELGYRO_BMI160_INT_EVENT TASK_EVENT_CUSTOM(4) #define CONFIG_ADC #define CONFIG_BATTERY_CUT_OFF #undef CONFIG_BATTERY_LEVEL_NEAR_FULL @@ -52,11 +56,6 @@ #define CONFIG_KEYBOARD_COL2_INVERTED #define CONFIG_KEYBOARD_PROTOCOL_8042 #define CONFIG_LED_COMMON -#define CONFIG_LID_ANGLE -#define CONFIG_LID_ANGLE_INVALID_CHECK -#define CONFIG_LID_ANGLE_TABLET_MODE -#define CONFIG_LID_ANGLE_SENSOR_BASE BASE_ACCEL -#define CONFIG_LID_ANGLE_SENSOR_LID LID_ACCEL #define CONFIG_LID_SWITCH #define CONFIG_LOW_POWER_IDLE #define CONFIG_LTO @@ -136,12 +135,27 @@ /* Thermal sensors read through PMIC ADC interface */ #define I2C_PORT_THERMAL I2C_PORT_PMIC -/* Ambient Light Sensor address */ -#define OPT3001_I2C_ADDR OPT3001_I2C_ADDR1 +/* Sensors */ +#define CONFIG_MKBP_EVENT +#define CONFIG_MKBP_USE_HOST_EVENT +#define CONFIG_ACCELGYRO_BMI160 +#define CONFIG_ACCELGYRO_BMI160_INT_EVENT TASK_EVENT_CUSTOM(4) +#define CONFIG_ACCELGYRO_BMI160_INT2_OUTPUT +#define CONFIG_ACCEL_BMA255 +#define CONFIG_ACCEL_INTERRUPTS +#define CONFIG_LID_ANGLE +#define CONFIG_LID_ANGLE_SENSOR_BASE BASE_ACCEL +#define CONFIG_LID_ANGLE_SENSOR_LID LID_ACCEL +#define CONFIG_LID_ANGLE_UPDATE +#define CONFIG_LID_ANGLE_TABLET_MODE +#define CONFIG_LID_ANGLE_INVALID_CHECK +/* FIFO size is in power of 2. */ +#define CONFIG_ACCEL_FIFO 256 + +/* Depends on how fast the AP boots and typical ODRs */ +#define CONFIG_ACCEL_FIFO_THRES (CONFIG_ACCEL_FIFO / 3) /* Modules we want to exclude */ -#undef CONFIG_CMD_ACCEL_INFO -#undef CONFIG_CMD_ACCELS #undef CONFIG_CMD_APTHROTTLE #undef CONFIG_CMD_BATTFAKE #undef CONFIG_CMD_HASH @@ -149,8 +163,11 @@ #undef CONFIG_CMD_I2C_XFER #undef CONFIG_CMD_IDLE_STATS #undef CONFIG_CMD_POWERINDEBUG +#undef CONFIG_CMD_SLEEPMASK +#undef CONFIG_CMD_SYSJUMP #undef CONFIG_CMD_TEMP_SENSOR #undef CONFIG_CMD_TIMERINFO +#undef CONFIG_CMD_WAITMS #undef CONFIG_CONSOLE_CMDHELP #undef CONFIG_CONSOLE_HISTORY #undef CONFIG_PECI @@ -185,11 +202,16 @@ enum power_signal { POWER_SIGNAL_COUNT }; -/* Motion sensors */ +/* + * Motion sensors: + * When reading through IO memory is set up, the first 2 entries must be + * accelerometers, then gyroscope. + * For BMI160, accel and gyro sensors must be next to each other. + */ enum sensor_id { - BASE_ACCEL = 0, + LID_ACCEL = 0, + BASE_ACCEL, BASE_GYRO, - LID_ACCEL, }; enum temp_sensor_id { @@ -232,6 +254,9 @@ int board_get_version(void); /* Reset RTC */ void board_rtc_reset(void); +/* Sensors without hardware FIFO are in forced mode */ +#define CONFIG_ACCEL_FORCE_MODE_MASK (1 << LID_ACCEL) + #endif /* !__ASSEMBLER__ */ #endif /* __CROS_EC_BOARD_H */ diff --git a/board/caroline/gpio.inc b/board/caroline/gpio.inc index 4c798c8ba5..8f8d3abfeb 100644 --- a/board/caroline/gpio.inc +++ b/board/caroline/gpio.inc @@ -27,7 +27,7 @@ GPIO_INT(USB_C1_BC12_INT_L, PIN(145), GPIO_INT_FALLING, usb1_evt) GPIO_INT(PMIC_DPWROK, PIN(133), GPIO_INT_BOTH, power_signal_interrupt) /* UART input */ GPIO_INT(UART0_RX, PIN(162), GPIO_INT_BOTH_DSLEEP | GPIO_PULL_UP, uart_deepsleep_interrupt) -GPIO_INT(ACCEL4_INT, PIN(157), GPIO_INT_FALLING, bmi160_interrupt) +GPIO_INT(ACCEL3_INT, PIN(147), GPIO_INT_FALLING, bmi160_interrupt) #ifdef CONFIG_POWER_S0IX GPIO(PCH_SLP_S0_L, PIN(211), GPIO_INPUT) @@ -66,7 +66,7 @@ GPIO(PCH_ACOK, PIN(110), GPIO_OUT_LOW) GPIO(TRACKPAD_INT_L, PIN(127), GPIO_INPUT) /* Interrupts from accelerometer / gyro -- not yet implemented */ GPIO(ACCEL1_INT, PIN(161), GPIO_INPUT) -GPIO(ACCEL3_INT, PIN(147), GPIO_INPUT) +GPIO(ACCEL4_INT, PIN(157), GPIO_INPUT) GPIO(WLAN_OFF_L, PIN(132), GPIO_OUT_LOW) /* RCIN# line to PCH for 8042 emulation */ GPIO(PCH_RCIN_L, PIN(135), GPIO_ODR_HIGH) |