diff options
author | Scott Collyer <scollyer@google.com> | 2021-03-25 19:47:14 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-04-10 21:48:43 +0000 |
commit | 62aa709f472b6a4021ccb3396701b2a2036caea7 (patch) | |
tree | 29b73d765523ef973c0015fcfa67d34abe661ff6 /board | |
parent | 8113e3d1f538039477ec4b1461031da770931055 (diff) | |
download | chrome-ec-62aa709f472b6a4021ccb3396701b2a2036caea7.tar.gz |
honeybuns: Add power button support
This CL adds support for the power button including a new task to
allow for power sequencing delays.
The power button is used for two purposes. First, to turn the dock on
or off, and second, to allow for a user set preference of the MF for
DP 2 or 4 lane selection. If the dock is off, the dock will be turned
on as soon as the short press timer expires. If the dock is already
on, then a short press action is only recognized on the release so a
long press will only change the MF preference.
BUG=b:164157329
BRANCH=quiche
TEST=manaual
short press -> turns dock on off as expected
long press -> toggles MF preference and flashes LED
Signed-off-by: Scott Collyer <scollyer@google.com>
Change-Id: I8519c072a7f10657c369344ead6149fc7d31bb36
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2718268
Tested-by: Scott Collyer <scollyer@chromium.org>
Reviewed-by: Sam Hurst <shurst@google.com>
Commit-Queue: Scott Collyer <scollyer@chromium.org>
Diffstat (limited to 'board')
-rw-r--r-- | board/gingerbread/board.c | 40 | ||||
-rw-r--r-- | board/gingerbread/board.h | 20 | ||||
-rw-r--r-- | board/gingerbread/ec.tasklist | 1 | ||||
-rw-r--r-- | board/gingerbread/gpio.inc | 6 | ||||
-rw-r--r-- | board/quiche/board.c | 44 | ||||
-rw-r--r-- | board/quiche/board.h | 20 | ||||
-rw-r--r-- | board/quiche/ec.tasklist | 1 | ||||
-rw-r--r-- | board/quiche/gpio.inc | 2 |
8 files changed, 113 insertions, 21 deletions
diff --git a/board/gingerbread/board.c b/board/gingerbread/board.c index d20b09b067..a3cc78598f 100644 --- a/board/gingerbread/board.c +++ b/board/gingerbread/board.c @@ -78,6 +78,11 @@ void hpd_interrupt(enum gpio_signal signal) { usb_pd_hpd_edge_event(signal); } + +static void board_pwr_btn_interrupt(enum gpio_signal signal) +{ + baseboard_power_button_evt(gpio_get_level(signal)); +} #endif /* SECTION_IS_RW */ #include "gpio_list.h" /* Must come after other header files. */ @@ -91,7 +96,7 @@ const struct power_seq board_power_seq[] = { {GPIO_EN_AC_JACK, 1, 20}, {GPIO_EN_PP5000_A, 1, 31}, {GPIO_EN_PP3300_A, 1, 35}, - {GPIO_STATUS_LED1, 0, 100}, + {GPIO_EC_STATUS_LED1, 0, 100}, {GPIO_EN_BB, 1, 30}, {GPIO_EN_PP1100_A, 1, 30}, {GPIO_EN_PP1000_A, 1, 20}, @@ -110,7 +115,7 @@ const struct power_seq board_power_seq[] = { {GPIO_DEMUX_DP_HDMI_PD_N, 1, 10}, {GPIO_DEMUX_DUAL_DP_MODE, 1, 10}, {GPIO_DEMUX_DP_HDMI_MODE, 1, 1}, - {GPIO_STATUS_LED2, 0, 100}, + {GPIO_EC_STATUS_LED2, 0, 100}, }; const size_t board_power_seq_count = ARRAY_SIZE(board_power_seq); @@ -130,6 +135,7 @@ const void *const usb_strings[] = { BUILD_ASSERT(ARRAY_SIZE(usb_strings) == USB_STR_COUNT); #ifndef SECTION_IS_RW +/* USB-C PPC Configuration */ struct ppc_config_t ppc_chips[] = { [USB_PD_PORT_HOST] = { .i2c_port = I2C_PORT_I2C3, @@ -218,7 +224,7 @@ void board_reset_pd_mcu(void) /* Power Delivery and charging functions */ -void board_tcpc_init(void) +void board_enable_usbc_interrupts(void) { board_reset_pd_mcu(); @@ -232,6 +238,28 @@ void board_tcpc_init(void) gpio_enable_interrupt(GPIO_DDI_MST_IN_HPD); } + +/* Power Delivery and charging functions */ +void board_disable_usbc_interrupts(void) +{ + /* Disable PPC interrupts. */ + gpio_disable_interrupt(GPIO_HOST_USBC_PPC_INT_ODL); + + /* Disable TCPC interrupts. */ + gpio_disable_interrupt(GPIO_USBC_DP_MUX_ALERT_ODL); + + /* Disable HPD interrupt */ + gpio_disable_interrupt(GPIO_DDI_MST_IN_HPD); + +} + +void board_tcpc_init(void) +{ + board_reset_pd_mcu(); + + /* Enable board usbc interrupts */ + board_enable_usbc_interrupts(); +} DECLARE_HOOK(HOOK_INIT, board_tcpc_init, HOOK_PRIO_INIT_I2C + 2); enum pd_dual_role_states board_tc_get_initial_drp_mode(int port) @@ -284,17 +312,17 @@ static void board_debug_gpio_2_pulse(void) } DECLARE_DEFERRED(board_debug_gpio_2_pulse); -void board_debug_gpio(int trigger, int enable, int pulse_usec) +void board_debug_gpio(enum debug_gpio trigger, int level, int pulse_usec) { switch (trigger) { case TRIGGER_1: - gpio_set_level(GPIO_TRIGGER_1, enable); + gpio_set_level(GPIO_TRIGGER_1, level); if (pulse_usec) hook_call_deferred(&board_debug_gpio_1_pulse_data, pulse_usec); break; case TRIGGER_2: - gpio_set_level(GPIO_TRIGGER_2, enable); + gpio_set_level(GPIO_TRIGGER_2, level); if (pulse_usec) hook_call_deferred(&board_debug_gpio_2_pulse_data, pulse_usec); diff --git a/board/gingerbread/board.h b/board/gingerbread/board.h index 21883367d0..d0b2994d31 100644 --- a/board/gingerbread/board.h +++ b/board/gingerbread/board.h @@ -68,7 +68,25 @@ enum debug_gpio { TRIGGER_2, }; -void board_debug_gpio(int trigger, int enable, int pulse_usec); +/* + * Function used to control GPIO signals as a timing marker. This is intended to + * be used for development/debugging purposes. + * + * @param trigger GPIO debug signal selection + * @param level desired level of the debug gpio signal + * @param pulse_usec pulse width if non-zero + */ +void board_debug_gpio(enum debug_gpio trigger, int level, int pulse_usec); + +/* + * Function called in power on case to enable usbc related interrupts + */ +void board_enable_usbc_interrupts(void); + +/* + * Function called in power off case to disable usbc related interrupts + */ +void board_disable_usbc_interrupts(void); #endif /* !__ASSEMBLER__ */ diff --git a/board/gingerbread/ec.tasklist b/board/gingerbread/ec.tasklist index a7c0eb9b2c..cc36bf5a74 100644 --- a/board/gingerbread/ec.tasklist +++ b/board/gingerbread/ec.tasklist @@ -11,6 +11,7 @@ TASK_ALWAYS_RO(RWSIG, rwsig_task, NULL, 1280) \ TASK_ALWAYS(HOOKS, hook_task, NULL, LARGER_TASK_STACK_SIZE) \ TASK_ALWAYS(CONSOLE, console_task, NULL, VENTI_TASK_STACK_SIZE) \ + TASK_ALWAYS_RW(POWER_BUTTON, power_button_task, NULL, LARGER_TASK_STACK_SIZE) \ TASK_ALWAYS_RW(PD_C0, pd_task, NULL, VENTI_TASK_STACK_SIZE) \ TASK_ALWAYS_RW(PD_C1, pd_task, NULL, VENTI_TASK_STACK_SIZE) \ TASK_ALWAYS_RW(PD_INT_C1, pd_interrupt_handler_task, 1, LARGER_TASK_STACK_SIZE) \ diff --git a/board/gingerbread/gpio.inc b/board/gingerbread/gpio.inc index 0c54a9800d..9d2e3df5d9 100644 --- a/board/gingerbread/gpio.inc +++ b/board/gingerbread/gpio.inc @@ -12,10 +12,10 @@ GPIO_INT(HOST_USBC_PPC_INT_ODL, PIN(C, 1), GPIO_INT_FALLING | GPIO_PULL_UP, ppc_interrupt) GPIO_INT(USBC_DP_MUX_ALERT_ODL, PIN(C, 12), GPIO_INT_FALLING | GPIO_PULL_UP, tcpc_alert_event) GPIO_INT(DDI_MST_IN_HPD, PIN(C, 14), GPIO_INT_BOTH, hpd_interrupt) +GPIO_INT(PWR_BTN, PIN(A, 0), GPIO_INT_BOTH, board_pwr_btn_interrupt) #endif /* Power sequencing signals */ -GPIO(PWR_BTN, PIN(A, 0), GPIO_INPUT) GPIO(EN_AC_JACK, PIN(A, 1), GPIO_OUT_LOW) GPIO(EN_BB, PIN(C, 0), GPIO_OUT_LOW) GPIO(EN_PP3300_A, PIN(C, 10), GPIO_OUT_LOW) @@ -25,8 +25,8 @@ GPIO(EN_PP1100_A, PIN(C, 4), GPIO_OUT_LOW) GPIO(EN_PP1000_A, PIN(C, 5), GPIO_OUT_LOW) GPIO(EN_PP1050_A, PIN(C, 6), GPIO_OUT_LOW) GPIO(EN_PP5000_HSPORT, PIN(C, 7), GPIO_OUT_LOW) -GPIO(STATUS_LED1, PIN(A, 2), GPIO_OUT_HIGH) -GPIO(STATUS_LED2, PIN(B, 12), GPIO_OUT_HIGH) +GPIO(EC_STATUS_LED1, PIN(A, 2), GPIO_OUT_HIGH) +GPIO(EC_STATUS_LED2, PIN(B, 12), GPIO_OUT_HIGH) /* MST Hub signals */ GPIO(MST_LP_CTL_L, PIN(B, 9), GPIO_OUT_LOW) diff --git a/board/quiche/board.c b/board/quiche/board.c index 05fc76d132..782d5ef243 100644 --- a/board/quiche/board.c +++ b/board/quiche/board.c @@ -97,6 +97,11 @@ static void board_uf_manage_vbus_interrupt(enum gpio_signal signal) { hook_call_deferred(&board_uf_manage_vbus_data, 0); } + +static void board_pwr_btn_interrupt(enum gpio_signal signal) +{ + baseboard_power_button_evt(gpio_get_level(signal)); +} #endif /* SECTION_IS_RW */ #include "gpio_list.h" /* Must come after other header files. */ @@ -243,18 +248,39 @@ void board_reset_pd_mcu(void) msleep(PS8805_FW_INIT_DELAY_MS); } -void board_tcpc_init(void) +void board_enable_usbc_interrupts(void) { - board_reset_pd_mcu(); - - /* Enable PPC interrupts. */ + /* Enable C0 PPC interrupt */ gpio_enable_interrupt(GPIO_HOST_USBC_PPC_INT_ODL); + /* Enable C1 PPC interrupt */ gpio_enable_interrupt(GPIO_USBC_DP_PPC_INT_ODL); - /* Enable HPD interrupt */ + /* Enable C0 HPD interrupt */ gpio_enable_interrupt(GPIO_DDI_MST_IN_HPD); - /* Enable TCPC interrupts. */ + /* Enable C1 TCPC interrupt */ gpio_enable_interrupt(GPIO_USBC_DP_MUX_ALERT_ODL); } + +void board_disable_usbc_interrupts(void) +{ + /* Disable C0 PPC interrupt */ + gpio_disable_interrupt(GPIO_HOST_USBC_PPC_INT_ODL); + /* Disable C1 PPC interrupt */ + gpio_disable_interrupt(GPIO_USBC_DP_PPC_INT_ODL); + /* Disable C0 HPD interrupt */ + gpio_disable_interrupt(GPIO_DDI_MST_IN_HPD); + /* Disable C1 TCPC interrupt */ + gpio_disable_interrupt(GPIO_USBC_DP_MUX_ALERT_ODL); + /* Disable VBUS control interrupt for C2 */ + gpio_disable_interrupt(GPIO_USBC_UF_MUX_VBUS_EN); +} + +void board_tcpc_init(void) +{ + board_reset_pd_mcu(); + + /* Enable board usbc interrupts */ + board_enable_usbc_interrupts(); +} DECLARE_HOOK(HOOK_INIT, board_tcpc_init, HOOK_PRIO_INIT_I2C + 2); enum pd_dual_role_states board_tc_get_initial_drp_mode(int port) @@ -343,17 +369,17 @@ static void board_debug_gpio_2_pulse(void) } DECLARE_DEFERRED(board_debug_gpio_2_pulse); -void board_debug_gpio(int trigger, int enable, int pulse_usec) +void board_debug_gpio(enum debug_gpio trigger, int level, int pulse_usec) { switch (trigger) { case TRIGGER_1: - gpio_set_level(GPIO_TRIGGER_1, enable); + gpio_set_level(GPIO_TRIGGER_1, level); if (pulse_usec) hook_call_deferred(&board_debug_gpio_1_pulse_data, pulse_usec); break; case TRIGGER_2: - gpio_set_level(GPIO_TRIGGER_2, enable); + gpio_set_level(GPIO_TRIGGER_2, level); if (pulse_usec) hook_call_deferred(&board_debug_gpio_2_pulse_data, pulse_usec); diff --git a/board/quiche/board.h b/board/quiche/board.h index 0de8572604..ad9d57d271 100644 --- a/board/quiche/board.h +++ b/board/quiche/board.h @@ -57,7 +57,25 @@ enum debug_gpio { TRIGGER_2, }; -void board_debug_gpio(int trigger, int enable, int pulse_usec); +/* + * Function used to control GPIO signals as a timing marker. This is intended to + * be used for development/debugging purposes. + * + * @param trigger GPIO debug signal selection + * @param level desired level of the debug gpio signal + * @param pulse_usec pulse width if non-zero + */ +void board_debug_gpio(enum debug_gpio trigger, int level, int pulse_usec); + +/* + * Function called in power on case to enable usbc related interrupts + */ +void board_enable_usbc_interrupts(void); + +/* + * Function called in power off case to disable usbc related interrupts + */ +void board_disable_usbc_interrupts(void); #endif /* !__ASSEMBLER__ */ diff --git a/board/quiche/ec.tasklist b/board/quiche/ec.tasklist index a7c0eb9b2c..cc36bf5a74 100644 --- a/board/quiche/ec.tasklist +++ b/board/quiche/ec.tasklist @@ -11,6 +11,7 @@ TASK_ALWAYS_RO(RWSIG, rwsig_task, NULL, 1280) \ TASK_ALWAYS(HOOKS, hook_task, NULL, LARGER_TASK_STACK_SIZE) \ TASK_ALWAYS(CONSOLE, console_task, NULL, VENTI_TASK_STACK_SIZE) \ + TASK_ALWAYS_RW(POWER_BUTTON, power_button_task, NULL, LARGER_TASK_STACK_SIZE) \ TASK_ALWAYS_RW(PD_C0, pd_task, NULL, VENTI_TASK_STACK_SIZE) \ TASK_ALWAYS_RW(PD_C1, pd_task, NULL, VENTI_TASK_STACK_SIZE) \ TASK_ALWAYS_RW(PD_INT_C1, pd_interrupt_handler_task, 1, LARGER_TASK_STACK_SIZE) \ diff --git a/board/quiche/gpio.inc b/board/quiche/gpio.inc index 76b1dfb90e..d47f54db74 100644 --- a/board/quiche/gpio.inc +++ b/board/quiche/gpio.inc @@ -14,10 +14,10 @@ GPIO_INT(USBC_DP_MUX_ALERT_ODL, PIN(B, 1), GPIO_INT_FALLING | GPIO_PULL_U GPIO_INT(USBC_DP_PPC_INT_ODL, PIN(E, 7), GPIO_INT_FALLING | GPIO_PULL_UP, ppc_interrupt) GPIO_INT(DDI_MST_IN_HPD, PIN(C, 14), GPIO_INT_BOTH, hpd_interrupt) GPIO_INT(USBC_UF_MUX_VBUS_EN, PIN(C, 12), GPIO_INT_BOTH, board_uf_manage_vbus_interrupt) +GPIO_INT(PWR_BTN, PIN(A, 0), GPIO_INT_BOTH, board_pwr_btn_interrupt) #endif /* Power sequencing signals */ -GPIO(PWR_BTN, PIN(A, 0), GPIO_INPUT) GPIO(EN_AC_JACK, PIN(A, 1), GPIO_OUT_LOW) GPIO(EN_BB, PIN(A, 8), GPIO_OUT_LOW) GPIO(EN_PP3300_B, PIN(B, 2), GPIO_OUT_LOW) |