• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <ec/acpi/ec.h>
4 #include <bootmode.h>
5 #include <timer.h>
6 #include <delay.h>
7 
8 #include "h8.h"
9 
10 /**
11  * HACK: Use Fn-Key as recovery mode switch.
12  * Wait for sense register ready and read Fn-Key state.
13  */
get_recovery_mode_switch(void)14 int get_recovery_mode_switch(void)
15 {
16 	struct stopwatch sw;
17 
18 	if (!CONFIG(H8_FN_KEY_AS_VBOOT_RECOVERY_SW))
19 		return 0;
20 
21 	/* Tests showed that it takes:
22 	 *  - 700msec on Lenovo T500 from AC power on
23 	 *  - less than 150msec on Lenovo T520 from AC power on
24 	 */
25 	stopwatch_init_msecs_expire(&sw, 1000);
26 	while (!stopwatch_expired(&sw) && !h8_get_sense_ready())
27 		mdelay(1);
28 
29 	if (!h8_get_sense_ready())
30 		return 0;
31 
32 	return h8_get_fn_key();
33 }
34 
35 /**
36  * Only used if CONFIG(CHROMEOS) is set.
37  * Always zero as the #WP pin of the flash is tied high.
38  */
get_write_protect_state(void)39 int get_write_protect_state(void)
40 {
41 	return 0;
42 }
43