summaryrefslogtreecommitdiff
path: root/src/ec/lenovo/h8/vboot.c
blob: 28ce6af6170962f86e9a9ad1852391526a53b935 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/*
 * This file is part of the coreboot project.
 *
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; version 2 of the License.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */

#include <ec/acpi/ec.h>
#include <bootmode.h>
#include <timer.h>
#include <delay.h>

#include "h8.h"

/**
 * HACK: Use Fn-Key as recovery mode switch.
 * Wait for sense register ready and read Fn-Key state.
 */
int get_recovery_mode_switch(void)
{
	struct stopwatch sw;

	if (!CONFIG(H8_FN_KEY_AS_VBOOT_RECOVERY_SW))
		return 0;

	/* Tests showed that it takes:
	 *  - 700msec on Lenovo T500 from AC power on
	 *  - less than 150msec on Lenovo T520 from AC power on
	 */
	stopwatch_init_msecs_expire(&sw, 1000);
	while (!stopwatch_expired(&sw) && !h8_get_sense_ready())
		mdelay(1);

	if (!h8_get_sense_ready())
		return 0;

	return h8_get_fn_key();
}

/**
 * Only used if CONFIG_CHROMEOS is set.
 * Always zero as the #WP pin of the flash is tied high.
 */
int get_write_protect_state(void)
{
	return 0;
}