diff options
-rw-r--r-- | baseboard/octopus/baseboard.h | 4 | ||||
-rw-r--r-- | board/ampton/board.c | 2 | ||||
-rw-r--r-- | board/ampton/gpio.inc | 2 | ||||
-rw-r--r-- | board/bip/gpio.inc | 2 | ||||
-rw-r--r-- | board/bobba/board.c | 2 | ||||
-rw-r--r-- | board/bobba/gpio.inc | 2 | ||||
-rw-r--r-- | board/fleex/board.c | 2 | ||||
-rw-r--r-- | board/fleex/gpio.inc | 2 | ||||
-rw-r--r-- | board/hammer/board.h | 4 | ||||
-rw-r--r-- | board/hammer/gpio.inc | 2 | ||||
-rw-r--r-- | board/meep/board.c | 2 | ||||
-rw-r--r-- | board/meep/gpio.inc | 2 | ||||
-rw-r--r-- | board/nami/board.h | 4 | ||||
-rw-r--r-- | board/nami/gpio.inc | 2 | ||||
-rw-r--r-- | board/phaser/board.c | 2 | ||||
-rw-r--r-- | board/phaser/gpio.inc | 2 | ||||
-rw-r--r-- | board/rammus/board.h | 4 | ||||
-rw-r--r-- | board/rammus/gpio.inc | 2 | ||||
-rw-r--r-- | board/yorp/gpio.inc | 2 | ||||
-rw-r--r-- | common/tablet_mode.c | 60 | ||||
-rw-r--r-- | include/config.h | 7 | ||||
-rw-r--r-- | include/tablet_mode.h | 14 |
22 files changed, 72 insertions, 55 deletions
diff --git a/baseboard/octopus/baseboard.h b/baseboard/octopus/baseboard.h index 07e77b7013..39ece2d121 100644 --- a/baseboard/octopus/baseboard.h +++ b/baseboard/octopus/baseboard.h @@ -263,8 +263,8 @@ /* Common Sensor Defines */ #define CONFIG_TABLET_MODE -#define CONFIG_TABLET_SWITCH -#define TABLET_MODE_GPIO_L GPIO_TABLET_MODE_L +#define CONFIG_HALL_SENSOR +#define HALL_SENSOR_GPIO_L GPIO_TABLET_MODE_L /* * Slew rate on the PP1800_SENSOR load switch requires a short delay on startup. */ diff --git a/board/ampton/board.c b/board/ampton/board.c index b2cfa271f3..7f4b7b07b3 100644 --- a/board/ampton/board.c +++ b/board/ampton/board.c @@ -218,7 +218,7 @@ static void board_update_sensor_config_from_sku(void) gpio_enable_interrupt(GPIO_BASE_SIXAXIS_INT_L); } else { motion_sensor_count = 0; - tablet_disable_switch(); + hall_sensor_disable(); /* Base accel is not stuffed, don't allow line to float */ gpio_set_flags(GPIO_BASE_SIXAXIS_INT_L, diff --git a/board/ampton/gpio.inc b/board/ampton/gpio.inc index 35dce20867..a6c293eee2 100644 --- a/board/ampton/gpio.inc +++ b/board/ampton/gpio.inc @@ -38,7 +38,7 @@ GPIO_INT(ESPI_RESET_L, PIN(D, 2), GPIO_INT_FALLING | GPIO_SEL_1P8V, espi_reset #endif /* Other interrupts */ -GPIO_INT(TABLET_MODE_L, PIN(H, 4), GPIO_INT_BOTH, tablet_mode_isr) +GPIO_INT(TABLET_MODE_L, PIN(H, 4), GPIO_INT_BOTH, hall_sensor_isr) GPIO_INT(EC_VOLDN_BTN_ODL, PIN(D, 6), GPIO_INT_BOTH, button_interrupt) GPIO_INT(EC_VOLUP_BTN_ODL, PIN(D, 5), GPIO_INT_BOTH, button_interrupt) GPIO_INT(BASE_SIXAXIS_INT_L, PIN(J, 2), GPIO_INT_FALLING | GPIO_SEL_1P8V, bmi160_interrupt) diff --git a/board/bip/gpio.inc b/board/bip/gpio.inc index 5bfba55484..80da333636 100644 --- a/board/bip/gpio.inc +++ b/board/bip/gpio.inc @@ -38,7 +38,7 @@ GPIO_INT(ESPI_RESET_L, PIN(D, 2), GPIO_INT_FALLING | GPIO_SEL_1P8V, espi_reset #endif /* Other interrupts */ -GPIO_INT(TABLET_MODE_L, PIN(H, 4), GPIO_INT_BOTH, tablet_mode_isr) +GPIO_INT(TABLET_MODE_L, PIN(H, 4), GPIO_INT_BOTH, hall_sensor_isr) GPIO(PCH_PLTRST_L, PIN(E, 3), GPIO_INPUT) /* PLT_RST_L: Platform Reset from SoC */ GPIO(SYS_RESET_L, PIN(B, 6), GPIO_ODR_HIGH) /* SYS_RST_ODL */ diff --git a/board/bobba/board.c b/board/bobba/board.c index 10ca4a526e..8bd95b5f01 100644 --- a/board/bobba/board.c +++ b/board/bobba/board.c @@ -257,7 +257,7 @@ static void board_update_sensor_config_from_sku(void) gpio_enable_interrupt(GPIO_BASE_SIXAXIS_INT_L); } else { motion_sensor_count = 0; - tablet_disable_switch(); + hall_sensor_disable(); /* Base accel is not stuffed, don't allow line to float */ gpio_set_flags(GPIO_BASE_SIXAXIS_INT_L, GPIO_INPUT | GPIO_PULL_DOWN); diff --git a/board/bobba/gpio.inc b/board/bobba/gpio.inc index ae2208e0dc..463323b2dd 100644 --- a/board/bobba/gpio.inc +++ b/board/bobba/gpio.inc @@ -33,7 +33,7 @@ GPIO_INT(ALL_SYS_PGOOD, PIN(F, 4), GPIO_INT_BOTH, power_signal_interrupt) /* PM /* Other interrupts */ GPIO_INT(WP_L, PIN(A, 1), GPIO_INT_BOTH, switch_interrupt) /* EC_WP_ODL */ -GPIO_INT(TABLET_MODE_L, PIN(8, 6), GPIO_INT_BOTH, tablet_mode_isr) +GPIO_INT(TABLET_MODE_L, PIN(8, 6), GPIO_INT_BOTH, hall_sensor_isr) GPIO_INT(EC_VOLUP_BTN_ODL, PIN(7, 5), GPIO_INT_BOTH, button_interrupt) GPIO_INT(EC_VOLDN_BTN_ODL, PIN(4, 0), GPIO_INT_BOTH, button_interrupt) diff --git a/board/fleex/board.c b/board/fleex/board.c index 3b6490e7d3..c1d0f16bd6 100644 --- a/board/fleex/board.c +++ b/board/fleex/board.c @@ -214,7 +214,7 @@ static void board_update_sensor_config_from_sku(void) gpio_enable_interrupt(GPIO_BASE_SIXAXIS_INT_L); } else { motion_sensor_count = 0; - tablet_disable_switch(); + hall_sensor_disable(); /* Base accel is not stuffed, don't allow line to float */ gpio_set_flags(GPIO_BASE_SIXAXIS_INT_L, GPIO_INPUT | GPIO_PULL_DOWN); diff --git a/board/fleex/gpio.inc b/board/fleex/gpio.inc index c5bbafa38d..3a15fdc2fb 100644 --- a/board/fleex/gpio.inc +++ b/board/fleex/gpio.inc @@ -37,7 +37,7 @@ GPIO_INT(ALL_SYS_PGOOD, PIN(F, 4), GPIO_INT_BOTH, power_signal_interrupt) /* PM /* Other interrupts */ GPIO_INT(WP_L, PIN(A, 1), GPIO_INT_BOTH, switch_interrupt) /* EC_WP_ODL */ -GPIO_INT(TABLET_MODE_L, PIN(8, 6), GPIO_INT_BOTH, tablet_mode_isr) +GPIO_INT(TABLET_MODE_L, PIN(8, 6), GPIO_INT_BOTH, hall_sensor_isr) GPIO_INT(BASE_SIXAXIS_INT_L, PIN(5, 6), GPIO_INT_FALLING | GPIO_SEL_1P8V, lsm6dsm_interrupt) GPIO(LID_ACCEL_INT_L, PIN(5, 0), GPIO_INPUT | GPIO_SEL_1P8V) diff --git a/board/hammer/board.h b/board/hammer/board.h index 7cdaf66570..7811ab7973 100644 --- a/board/hammer/board.h +++ b/board/hammer/board.h @@ -251,8 +251,8 @@ #ifdef BOARD_WHISKERS #define CONFIG_LED_DRIVER_LM3630A #define CONFIG_TABLET_MODE -#define CONFIG_TABLET_SWITCH -#define TABLET_MODE_GPIO_L GPIO_TABLET_MODE_L +#define CONFIG_HALL_SENSOR +#define HALL_SENSOR_GPIO_L GPIO_TABLET_MODE_L #define CONFIG_KEYBOARD_TABLET_MODE_SWITCH /* Enable control of SPI over USB */ #define CONFIG_USB_SPI diff --git a/board/hammer/gpio.inc b/board/hammer/gpio.inc index 019d9399d8..34c0838612 100644 --- a/board/hammer/gpio.inc +++ b/board/hammer/gpio.inc @@ -11,7 +11,7 @@ #ifdef SECTION_IS_RW GPIO_INT(TOUCHPAD_INT, PIN(B, 8), GPIO_INT_FALLING, touchpad_interrupt) #ifdef BOARD_WHISKERS -GPIO_INT(TABLET_MODE_L, PIN(B, 11), GPIO_PULL_UP | GPIO_INT_BOTH, tablet_mode_isr) +GPIO_INT(TABLET_MODE_L, PIN(B, 11), GPIO_PULL_UP | GPIO_INT_BOTH, hall_sensor_isr) #endif /* BOARD_WHISKERS */ #endif /* SECTION_IS_RW */ diff --git a/board/meep/board.c b/board/meep/board.c index 24f1ac4d55..85831cd85e 100644 --- a/board/meep/board.c +++ b/board/meep/board.c @@ -260,7 +260,7 @@ static void board_update_sensor_config_from_sku(void) gpio_enable_interrupt(GPIO_BASE_SIXAXIS_INT_L); } else { motion_sensor_count = 0; - tablet_disable_switch(); + hall_sensor_disable(); /* Base accel is not stuffed, don't allow line to float */ gpio_set_flags(GPIO_BASE_SIXAXIS_INT_L, GPIO_INPUT | GPIO_PULL_DOWN); diff --git a/board/meep/gpio.inc b/board/meep/gpio.inc index 2d2946a5d8..c61e4e807b 100644 --- a/board/meep/gpio.inc +++ b/board/meep/gpio.inc @@ -40,7 +40,7 @@ GPIO_INT(ALL_SYS_PGOOD, PIN(F, 4), GPIO_INT_BOTH, power_signal_interrupt) /* PM /* Other interrupts */ GPIO_INT(WP_L, PIN(A, 1), GPIO_INT_BOTH, switch_interrupt) /* EC_WP_ODL */ -GPIO_INT(TABLET_MODE_L, PIN(8, 6), GPIO_INT_BOTH, tablet_mode_isr) +GPIO_INT(TABLET_MODE_L, PIN(8, 6), GPIO_INT_BOTH, hall_sensor_isr) GPIO_INT(BASE_SIXAXIS_INT_L, PIN(5, 6), GPIO_INT_FALLING | GPIO_SEL_1P8V, lsm6dsm_interrupt) GPIO(LID_ACCEL_INT_L, PIN(5, 0), GPIO_INPUT | GPIO_SEL_1P8V) diff --git a/board/nami/board.h b/board/nami/board.h index bc656a3fd9..c68fd5834f 100644 --- a/board/nami/board.h +++ b/board/nami/board.h @@ -156,8 +156,8 @@ #define CONFIG_TABLET_MODE #define CONFIG_TABLET_MODE_SWITCH -#define CONFIG_TABLET_SWITCH -#define TABLET_MODE_GPIO_L GPIO_TABLET_MODE_L +#define CONFIG_HALL_SENSOR +#define HALL_SENSOR_GPIO_L GPIO_TABLET_MODE_L /* USB */ #define CONFIG_USB_CHARGER diff --git a/board/nami/gpio.inc b/board/nami/gpio.inc index 546e5aaf56..d4daa8e6a1 100644 --- a/board/nami/gpio.inc +++ b/board/nami/gpio.inc @@ -34,7 +34,7 @@ GPIO_INT(USB_C1_VBUS_WAKE_L, PIN(C, 5), GPIO_INT_BOTH | GPIO_PULL_UP,vbus1_evt) GPIO_INT(USB_C0_BC12_INT_L, PIN(D, 2), GPIO_INT_FALLING, usb0_evt) GPIO_INT(USB_C1_BC12_INT_L, PIN(D, 3), GPIO_INT_FALLING, usb1_evt) GPIO_INT(ACCELGYRO3_INT_L, PIN(3, 6), GPIO_INT_FALLING | GPIO_PULL_UP, bmi160_interrupt) -GPIO_INT(TABLET_MODE_L, PIN(7, 2), GPIO_INT_BOTH, tablet_mode_isr) +GPIO_INT(TABLET_MODE_L, PIN(7, 2), GPIO_INT_BOTH, hall_sensor_isr) GPIO(ENABLE_BACKLIGHT_L, PIN(6, 7), GPIO_OUT_LOW) /* LCD backlight */ GPIO(PP3300_DX_WLAN, PIN(B, 1), GPIO_OUT_LOW) /* Enable WLAN 3.3V Power */ diff --git a/board/phaser/board.c b/board/phaser/board.c index 4a525bb949..e2953fd895 100644 --- a/board/phaser/board.c +++ b/board/phaser/board.c @@ -215,7 +215,7 @@ static void board_update_sensor_config_from_sku(void) gpio_enable_interrupt(GPIO_BASE_SIXAXIS_INT_L); } else { motion_sensor_count = 0; - tablet_disable_switch(); + hall_sensor_disable(); /* Base accel is not stuffed, don't allow line to float */ gpio_set_flags(GPIO_BASE_SIXAXIS_INT_L, GPIO_INPUT | GPIO_PULL_DOWN); diff --git a/board/phaser/gpio.inc b/board/phaser/gpio.inc index 855b0baf82..db42d6c259 100644 --- a/board/phaser/gpio.inc +++ b/board/phaser/gpio.inc @@ -40,7 +40,7 @@ GPIO_INT(ALL_SYS_PGOOD, PIN(F, 4), GPIO_INT_BOTH, power_signal_interrupt) /* PM /* Other interrupts */ GPIO_INT(WP_L, PIN(A, 1), GPIO_INT_BOTH, switch_interrupt) /* EC_WP_ODL */ -GPIO_INT(TABLET_MODE_L, PIN(8, 6), GPIO_INT_BOTH, tablet_mode_isr) +GPIO_INT(TABLET_MODE_L, PIN(8, 6), GPIO_INT_BOTH, hall_sensor_isr) GPIO_INT(BASE_SIXAXIS_INT_L, PIN(5, 6), GPIO_INT_FALLING | GPIO_SEL_1P8V, lsm6dsm_interrupt) GPIO(LID_ACCEL_INT_L, PIN(5, 0), GPIO_INPUT | GPIO_SEL_1P8V) diff --git a/board/rammus/board.h b/board/rammus/board.h index 3dfd3e703a..22686ba34e 100644 --- a/board/rammus/board.h +++ b/board/rammus/board.h @@ -136,8 +136,8 @@ #define CONFIG_TABLET_MODE #define CONFIG_TABLET_MODE_SWITCH -#define CONFIG_TABLET_SWITCH -#define TABLET_MODE_GPIO_L GPIO_TABLET_MODE +#define CONFIG_HALL_SENSOR +#define HALL_SENSOR_GPIO_L GPIO_TABLET_MODE /* USB */ #define CONFIG_USB_CHARGER diff --git a/board/rammus/gpio.inc b/board/rammus/gpio.inc index b3f6e6ac97..9176414cfc 100644 --- a/board/rammus/gpio.inc +++ b/board/rammus/gpio.inc @@ -27,7 +27,7 @@ GPIO_INT(USB_C1_VBUS_DET_L, PIN(9, 7), GPIO_INT_BOTH | GPIO_PULL_UP, vbus1_ GPIO_INT(USB_C0_BC12_INT_L, PIN(D, 3), GPIO_INT_FALLING, usb0_evt) GPIO_INT(USB_C1_BC12_INT_L, PIN(3, 3), GPIO_INT_FALLING, usb1_evt) GPIO_INT(BASE_SIXAXIS_INT_L, PIN(7, 3), GPIO_INT_FALLING | GPIO_SEL_1P8V, bmi160_interrupt) -GPIO_INT(TABLET_MODE, PIN(C, 6), GPIO_INT_BOTH, tablet_mode_isr) +GPIO_INT(TABLET_MODE, PIN(C, 6), GPIO_INT_BOTH, hall_sensor_isr) GPIO(EN_PP3300_TRACKPAD, PIN(4, 5), GPIO_OUT_LOW) /* Enable TouchPad */ GPIO(PCH_RTCRST, PIN(8, 2), GPIO_OUT_LOW) /* RTCRST# to SOC */ diff --git a/board/yorp/gpio.inc b/board/yorp/gpio.inc index 1f5e230623..b944997a93 100644 --- a/board/yorp/gpio.inc +++ b/board/yorp/gpio.inc @@ -38,7 +38,7 @@ GPIO_INT(ALL_SYS_PGOOD, PIN(F, 4), GPIO_INT_BOTH, power_signal_interrupt) /* PM /* Other interrupts */ GPIO_INT(WP_L, PIN(A, 1), GPIO_INT_BOTH, switch_interrupt) /* EC_WP_ODL */ -GPIO_INT(TABLET_MODE_L, PIN(8, 6), GPIO_INT_BOTH, tablet_mode_isr) +GPIO_INT(TABLET_MODE_L, PIN(8, 6), GPIO_INT_BOTH, hall_sensor_isr) GPIO_INT(BASE_SIXAXIS_INT_L, PIN(5, 6), GPIO_INT_FALLING | GPIO_SEL_1P8V, lsm6dsm_interrupt) GPIO(LID_ACCEL_INT_L, PIN(5, 0), GPIO_INPUT | GPIO_SEL_1P8V) diff --git a/common/tablet_mode.c b/common/tablet_mode.c index 5185895ce4..e9667dfbcc 100644 --- a/common/tablet_mode.c +++ b/common/tablet_mode.c @@ -39,52 +39,66 @@ void tablet_set_mode(int mode) } /* This ifdef can be removed once we clean up past projects which do own init */ -#ifdef CONFIG_TABLET_SWITCH -#ifndef TABLET_MODE_GPIO_L -#error TABLET_MODE_GPIO_L must be defined +#ifdef CONFIG_HALL_SENSOR +#ifndef HALL_SENSOR_GPIO_L +#error HALL_SENSOR_GPIO_L must be defined #endif -static void tablet_mode_debounce(void) +static void hall_sensor_interrupt_debounce(void) { - /* We won't reach here on boards without a dedicated tablet switch */ - tablet_set_mode(!gpio_get_level(TABLET_MODE_GPIO_L)); + int flipped_360_mode = !gpio_get_level(HALL_SENSOR_GPIO_L); + + /* + * 1. Peripherals are disabled only when lid reaches 360 position (It's + * probably already disabled by motion_sense task). We deliberately do + * not enable peripherals when the lid is leaving 360 position. Instead, + * we let motion sense task enable it once it is reaches laptop zone + * (180 or less). + * 2. Similarly, tablet mode is set here when lid reaches 360 + * position. It should already be set by motion lid driver. We + * deliberately do not clear tablet mode when lid is leaving 360 + * position(if motion lid driver is used). Instead, we let motion lid + * driver to clear it when lid goes into laptop zone. + */ + +#ifdef CONFIG_LID_ANGLE + if (flipped_360_mode) +#endif /* CONFIG_LID_ANGLE */ + tablet_set_mode(flipped_360_mode); #ifdef CONFIG_LID_ANGLE_UPDATE - /* Then, we disable peripherals only when the lid reaches 360 position. - * (It's probably already disabled by motion_sense_task.) - * We deliberately do not enable peripherals when the lid is leaving - * 360 position. Instead, we let motion_sense_task enable it once it - * reaches laptop zone (180 or less). */ - if (tablet_mode) + if (flipped_360_mode) lid_angle_peripheral_enable(0); #endif /* CONFIG_LID_ANGLE_UPDATE */ } -DECLARE_DEFERRED(tablet_mode_debounce); +DECLARE_DEFERRED(hall_sensor_interrupt_debounce); -#define TABLET_DEBOUNCE_US (30 * MSEC) /* Debounce time for tablet switch */ +/* Debounce time for hall sensor interrupt */ +#define HALL_SENSOR_DEBOUNCE_US (30 * MSEC) -void tablet_mode_isr(enum gpio_signal signal) +void hall_sensor_isr(enum gpio_signal signal) { - hook_call_deferred(&tablet_mode_debounce_data, TABLET_DEBOUNCE_US); + hook_call_deferred(&hall_sensor_interrupt_debounce_data, + HALL_SENSOR_DEBOUNCE_US); } -static void tablet_mode_init(void) +static void hall_sensor_init(void) { /* If this sub-system was disabled before initializing, honor that. */ if (disabled) return; - gpio_enable_interrupt(TABLET_MODE_GPIO_L); + gpio_enable_interrupt(HALL_SENSOR_GPIO_L); /* Ensure tablet mode is initialized according to the hardware state * so that the cached state reflects reality. */ - tablet_mode_debounce(); + hall_sensor_interrupt_debounce(); } -DECLARE_HOOK(HOOK_INIT, tablet_mode_init, HOOK_PRIO_DEFAULT); +DECLARE_HOOK(HOOK_INIT, hall_sensor_init, HOOK_PRIO_DEFAULT); -void tablet_disable_switch(void) +void hall_sensor_disable(void) { - gpio_disable_interrupt(TABLET_MODE_GPIO_L); + gpio_disable_interrupt(HALL_SENSOR_GPIO_L); /* Cancel any pending debounce calls */ - hook_call_deferred(&tablet_mode_debounce_data, -1); + hook_call_deferred(&hall_sensor_interrupt_debounce_data, -1); tablet_set_mode(0); disabled = 1; } diff --git a/include/config.h b/include/config.h index 4df4b61217..1e7b9b3a09 100644 --- a/include/config.h +++ b/include/config.h @@ -2877,10 +2877,11 @@ #undef CONFIG_TABLET_MODE_SWITCH /* - * Add a physical switch to indicate when we are in tablet mode. - * Define TABLET_MODE_GPIO_L and direct its interrupt hander to tablet_mode_isr + * Config to identify what devices have hall sensor. If a board selects + * this config, it also needs to provide HALL_SENSOR_GPIO_L and direct its + * interrupt to hall_sensor_isr. */ -#undef CONFIG_TABLET_SWITCH +#undef CONFIG_HALL_SENSOR /* * Add a virtual switch to indicate when detachable device has diff --git a/include/tablet_mode.h b/include/tablet_mode.h index 34616a74a3..df42356e3f 100644 --- a/include/tablet_mode.h +++ b/include/tablet_mode.h @@ -12,19 +12,21 @@ int tablet_get_mode(void); void tablet_set_mode(int mode); /** - * Interrupt service routine for tablet switch. + * Interrupt service routine for hall sensor. * - * TABLET_MODE_GPIO_L must be defined. + * HALL_SENSOR_GPIO_L must be defined. * * @param signal: GPIO signal */ -void tablet_mode_isr(enum gpio_signal signal); +void hall_sensor_isr(enum gpio_signal signal); /** - * Disables the tablet mode switch sub-system and turns off tablet mode. This is - * useful for clamshell devices. + * Disables the interrupt on GPIO connected to hall sensor. Additionally, it + * disables the tablet mode switch sub-system and turns off tablet mode. This is + * useful when the same firmware is shared between convertible and clamshell + * devices to turn off hall sensor and tablet mode detection on clamshell. */ -void tablet_disable_switch(void); +void hall_sensor_disable(void); #else |