diff options
author | Ikjoon Jang <ikjn@chromium.org> | 2019-09-26 06:00:01 +0000 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2019-09-26 17:00:15 +0000 |
commit | d7d7224a85160389d235cfd3ba2dca9b8ae47c8c (patch) | |
tree | 11f4fe985e7499c10e6354a0a3be5212640d48bb | |
parent | 1906434c4e62fac6792b6b81874810495be49b2e (diff) | |
download | chrome-ec-d7d7224a85160389d235cfd3ba2dca9b8ae47c8c.tar.gz |
Revert "baseboard/kukui: use BASE_STATE_SWITCH instead"
This reverts commit 92b3e86b23b59ebec3e59132cae2b32288fcf1b4.
Reason for revert: Kernel side driver not yet prepared.
BUG=b:141518464
TEST=Booting, entering tablet mode
Original change's description:
> baseboard/kukui: use BASE_STATE_SWITCH instead
>
> tablet mode will also depend on BASE_ATTACHED_SWITCH.
>
> TEST=see EC sends BASE_ATTACHED event when keyboard attach/detach
> BUG=b:140608847
> BRANCH=none
>
> Change-Id: Ib7d9bd0e8cf0efb5d0a3808f4649e0d9eb69b6d8
> Signed-off-by: Yilun Lin <yllin@chromium.org>
> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1806178
> Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
Change-Id: Ic05a7a4d9b237bff15379d2d10167521e5613d62
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1826105
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Ikjoon Jang <ikjn@chromium.org>
Commit-Queue: Nicolas Boichat <drinkcat@chromium.org>
Commit-Queue: Ikjoon Jang <ikjn@chromium.org>
Tested-by: Nicolas Boichat <drinkcat@chromium.org>
-rw-r--r-- | baseboard/kukui/base_detect_kukui.c | 78 | ||||
-rw-r--r-- | baseboard/kukui/baseboard.h | 6 |
2 files changed, 30 insertions, 54 deletions
diff --git a/baseboard/kukui/base_detect_kukui.c b/baseboard/kukui/base_detect_kukui.c index 3a6333b7cc..f72988543f 100644 --- a/baseboard/kukui/base_detect_kukui.c +++ b/baseboard/kukui/base_detect_kukui.c @@ -4,12 +4,12 @@ */ #include "adc.h" -#include "base_state.h" #include "board.h" #include "charge_manager.h" #include "console.h" #include "gpio.h" #include "hooks.h" +#include "tablet_mode.h" #include "timer.h" #include "usb_pd.h" #include "util.h" @@ -95,8 +95,32 @@ static void enable_power_supply(int enable) static void base_detect_deferred(void); DECLARE_DEFERRED(base_detect_deferred); -static void base_set_device_type(enum kukui_pogo_device_type device_type) +static void base_detect_deferred(void) { + uint64_t time_now = get_time().val; + int mv; + enum kukui_pogo_device_type device_type; + + if (base_detect_debounce_time > time_now) { + hook_call_deferred(&base_detect_deferred_data, + base_detect_debounce_time - time_now); + return; + } + + /* + * Disable interrupt first to prevent it triggered by value + * changed from 1 to disabled state(=0). + */ + gpio_disable_interrupt(GPIO_POGO_ADC_INT_L); + gpio_set_flags(GPIO_POGO_ADC_INT_L, GPIO_ANALOG); + mv = adc_read_channel(ADC_POGO_ADC_INT_L); + /* restore the pin function */ + gpio_set_flags(GPIO_POGO_ADC_INT_L, GPIO_INT_BOTH); + gpio_enable_interrupt(GPIO_POGO_ADC_INT_L); + + device_type = get_device_type(mv); + CPRINTS("POGO: adc=%d, device_type=%d", mv, device_type); + switch (device_type) { case DEVICE_TYPE_ERROR: case DEVICE_TYPE_UNKNOWN: @@ -107,21 +131,21 @@ static void base_set_device_type(enum kukui_pogo_device_type device_type) case DEVICE_TYPE_DETACHED: enable_power_supply(0); enable_charge(0); - base_set_state(0); + tablet_set_mode(1); break; #ifdef VARIANT_KUKUI_POGO_DOCK case DEVICE_TYPE_DOCK: enable_power_supply(0); enable_charge(1); - base_set_state(1); + tablet_set_mode(1); break; #endif case DEVICE_TYPE_KEYBOARD: enable_charge(0); enable_power_supply(1); - base_set_state(1); + tablet_set_mode(0); break; case DEVICE_TYPE_COUNT: @@ -130,35 +154,6 @@ static void base_set_device_type(enum kukui_pogo_device_type device_type) } } -static void base_detect_deferred(void) -{ - uint64_t time_now = get_time().val; - int mv; - enum kukui_pogo_device_type device_type; - - if (base_detect_debounce_time > time_now) { - hook_call_deferred(&base_detect_deferred_data, - base_detect_debounce_time - time_now); - return; - } - - /* - * Disable interrupt first to prevent it triggered by value - * changed from 1 to disabled state(=0). - */ - gpio_disable_interrupt(GPIO_POGO_ADC_INT_L); - gpio_set_flags(GPIO_POGO_ADC_INT_L, GPIO_ANALOG); - mv = adc_read_channel(ADC_POGO_ADC_INT_L); - /* restore the pin function */ - gpio_set_flags(GPIO_POGO_ADC_INT_L, GPIO_INT_BOTH); - gpio_enable_interrupt(GPIO_POGO_ADC_INT_L); - - device_type = get_device_type(mv); - CPRINTS("POGO: adc=%d, device_type=%d", mv, device_type); - - base_set_device_type(device_type); -} - void pogo_adc_interrupt(enum gpio_signal signal) { uint64_t time_now = get_time().val; @@ -177,21 +172,6 @@ static void base_init(void) } DECLARE_HOOK(HOOK_INIT, base_init, HOOK_PRIO_INIT_ADC + 1); -void base_force_state(int state) -{ - if (state != 1 && state != 0) { - gpio_enable_interrupt(GPIO_POGO_ADC_INT_L); - base_init(); - CPRINTS("BD forced reset"); - return; - } - - gpio_disable_interrupt(GPIO_POGO_ADC_INT_L); - base_set_device_type(state == 1 ? DEVICE_TYPE_KEYBOARD : - DEVICE_TYPE_DETACHED); - CPRINTS("BD forced %sconnected", state == 1 ? "" : "dis"); -} - #ifdef VARIANT_KUKUI_POGO_DOCK static void board_pogo_charge_init(void) { diff --git a/baseboard/kukui/baseboard.h b/baseboard/kukui/baseboard.h index 4b6467462c..3bd6862426 100644 --- a/baseboard/kukui/baseboard.h +++ b/baseboard/kukui/baseboard.h @@ -71,11 +71,6 @@ #define DEDICATED_CHARGE_PORT 1 #endif /* VARIANT_KUKUI_POGO_DOCK */ -#ifdef VARIANT_KUKUI_POGO_KEYBOARD -#define CONFIG_DETACHABLE_BASE -#define CONFIG_BASE_ATTACHED_SWITCH -#endif - /* * Define this flag if board controls dp mux via gpio pins USB_C0_DP_OE_L and * USB_C0_DP_POLARITY. @@ -158,6 +153,7 @@ /* To be able to indicate the device is in tablet mode. */ #define CONFIG_TABLET_MODE +#define CONFIG_TABLET_MODE_SWITCH #define GPIO_LID_OPEN GPIO_HALL_INT_L #ifndef VARIANT_KUKUI_NO_SENSORS |