summaryrefslogtreecommitdiff
path: root/src/vendorcode/google/chromeos/cse_board_reset.c
blob: 65e09aeedb8889283d8930e910de0d13d9ad2a11 (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
/* SPDX-License-Identifier: GPL-2.0-or-later */

#include <arch/cache.h>
#include <arch/io.h>
#include <cf9_reset.h>
#include <console/console.h>
#include <drivers/spi/tpm/tpm.h>
#include <ec/google/chromeec/ec.h>
#include <halt.h>
#include <intelblocks/cse.h>
#include <security/tpm/tss.h>
#include <vb2_api.h>

void cse_board_reset(void)
{
	int ret;
	struct cr50_firmware_version version;

	/* Initialize TPM and get the cr50 firmware version. */
	ret = tlcl_lib_init();
	if (ret != VB2_SUCCESS) {
		printk(BIOS_ERR, "tlcl_lib_init() failed: 0x%x\n", ret);
		return;
	}

	cr50_get_firmware_version(&version);

	/*
	 * Cr50 firmware versions 0.[3|4].20 or newer support strap config 0xe where PLTRST from
	 * AP is connected to cr50's PLTRST# signal. So return immediately and trigger a
	 * global reset.
	 */
	if (version.epoch != 0 || version.major > 4 ||
			(version.major >= 3 && version.minor >= 20))
		return;

	printk(BIOS_INFO, "Initiating request to EC to trigger cold reset\n");
	/*
	 * Clean the data cache and set the full reset bit, so that when EC toggles
	 * SYS_RESET# pin, AP makes a trip to S5 and then to S0.
	 */
	dcache_clean_all();
	outb(FULL_RST, RST_CNT);
	if (!google_chromeec_ap_reset())
		halt();
}