Reset EC config on Fn+Esc during power on

This commit is contained in:
Tim Crawford 2020-09-25 07:44:00 -06:00 committed by Jeremy Soller
parent 46ca5e0a12
commit 9afec7af27
5 changed files with 25 additions and 0 deletions

View File

@ -3,8 +3,16 @@
#include <board/config.h>
#include <board/battery.h>
#include <board/kbscan.h>
#include <common/debug.h>
/**
* Test if the EC should reset its configuration.
*/
bool config_should_reset(void) {
return kbscan_fn_held && kbscan_esc_held;
}
/**
* Reset the EC configuration data.
*/

View File

@ -3,6 +3,9 @@
#ifndef _BOARD_CONFIG_H
#define _BOARD_CONFIG_H
#include <stdbool.h>
bool config_should_reset(void);
void config_reset(void);
#endif // _BOARD_CONFIG_H

View File

@ -7,6 +7,10 @@
#include <ec/kbscan.h>
// EC config reset key combo: Fn+Esc
extern bool kbscan_fn_held;
extern bool kbscan_esc_held;
extern bool kbscan_enabled;
// ms between repeating key

View File

@ -18,6 +18,9 @@
#define KM_NKEY 0
#endif // KM_NKEY
bool kbscan_fn_held = false;
bool kbscan_esc_held = false;
bool kbscan_enabled = false;
uint16_t kbscan_repeat_period = 91;
uint16_t kbscan_repeat_delay = 500;
@ -182,12 +185,16 @@ bool kbscan_press(uint16_t key, bool pressed, uint8_t * layer) {
case (KT_NORMAL):
if (kbscan_enabled) {
kbc_scancode(&KBC, key, pressed);
if ((key & 0xFF) == K_ESC)
kbscan_esc_held = pressed;
}
break;
case (KT_FN):
if (layer != NULL) {
if (pressed) *layer = 1;
else *layer = 0;
kbscan_fn_held = pressed;
} else {
// In the case no layer can be set, reset bit
return false;

View File

@ -5,6 +5,7 @@
#include <board/acpi.h>
#include <board/battery.h>
#include <board/board.h>
#include <board/config.h>
#include <board/gpio.h>
#include <board/kbled.h>
#include <board/lid.h>
@ -405,6 +406,8 @@ void power_event(void) {
// Enable S5 power if necessary, before sending PWR_BTN
update_power_state();
if (power_state == POWER_STATE_DS5) {
if (config_should_reset())
config_reset();
power_on_s5();
}
}