blob: 08db7e2b28dbcfe2742a22e56e99103e8037f792 [file] [log] [blame]
Karthikeyan Ramasubramanianb9042cb2020-08-20 16:04:58 -06001/* SPDX-License-Identifier: GPL-2.0-or-later */
2
3#include <arch/cache.h>
4#include <arch/io.h>
5#include <cf9_reset.h>
6#include <console/console.h>
7#include <drivers/spi/tpm/tpm.h>
8#include <ec/google/chromeec/ec.h>
9#include <halt.h>
10#include <intelblocks/cse.h>
11#include <security/tpm/tss.h>
John Zhaof90e3b92020-08-25 10:21:01 -070012#include <vb2_api.h>
Karthikeyan Ramasubramanianb9042cb2020-08-20 16:04:58 -060013
14void cse_board_reset(void)
15{
John Zhaof90e3b92020-08-25 10:21:01 -070016 int ret;
Karthikeyan Ramasubramanianb9042cb2020-08-20 16:04:58 -060017 struct cr50_firmware_version version;
18
Jes B. Klinkec6b041a12022-04-19 14:00:33 -070019 if (CONFIG(TPM2) && CONFIG(TPM_GOOGLE_CR50)) {
Jes Klinke5c805192020-10-14 13:24:32 -070020 /* Initialize TPM and get the cr50 firmware version. */
21 ret = tlcl_lib_init();
22 if (ret != VB2_SUCCESS) {
23 printk(BIOS_ERR, "tlcl_lib_init() failed: 0x%x\n", ret);
24 return;
25 }
26
27 cr50_get_firmware_version(&version);
28
29 /*
30 * Cr50 firmware versions 0.[3|4].20 or newer support strap
31 * config 0xe where PLTRST from AP is connected to cr50's
32 * PLTRST# signal. So return immediately and trigger a global
33 * reset.
34 */
35 if (version.epoch != 0 || version.major > 4 ||
36 (version.major >= 3 && version.minor >= 20))
37 return;
John Zhaof90e3b92020-08-25 10:21:01 -070038 }
Jes B. Klinkec6b041a12022-04-19 14:00:33 -070039 if (CONFIG(TPM_GOOGLE_TI50)) {
40 /* All versions of Ti50 firmware support the above PLTRST wiring. */
41 return;
42 }
John Zhaof90e3b92020-08-25 10:21:01 -070043
Karthikeyan Ramasubramanianb9042cb2020-08-20 16:04:58 -060044 printk(BIOS_INFO, "Initiating request to EC to trigger cold reset\n");
45 /*
46 * Clean the data cache and set the full reset bit, so that when EC toggles
47 * SYS_RESET# pin, AP makes a trip to S5 and then to S0.
48 */
49 dcache_clean_all();
50 outb(FULL_RST, RST_CNT);
51 if (!google_chromeec_ap_reset())
52 halt();
53}