blob: f17e2782f8fdf1c33e27d836c3d0321b11c09f18 [file] [log] [blame]
T Michael Turneyb97e6f72021-03-18 09:16:44 -07001/* SPDX-License-Identifier: GPL-2.0-only */
2
3#include <boot/coreboot_tables.h>
4#include <bootmode.h>
5#include "board.h"
Grzegorz Bernacki7758b472023-06-14 12:01:32 +00006#include <drivers/tpm/cr50.h>
T Michael Turneyb97e6f72021-03-18 09:16:44 -07007
8void setup_chromeos_gpios(void)
9{
Shelley Chen35384612022-01-05 17:15:31 -080010 if (CONFIG(EC_GOOGLE_CHROMEEC)) {
11 gpio_input_pullup(GPIO_EC_IN_RW);
12 gpio_input_pullup(GPIO_AP_EC_INT);
13 }
14 if (CONFIG(MAINBOARD_HAS_TPM2))
15 gpio_input_irq(GPIO_H1_AP_INT, IRQ_TYPE_RISING_EDGE, GPIO_PULL_UP);
16
Shaik Sajida Bhanucd1257a2021-01-19 20:14:48 +053017 gpio_input_pullup(GPIO_SD_CD_L);
Shelley Chenffebd492021-09-28 12:42:11 -070018
19 if (CONFIG(HEROBRINE_HAS_FINGERPRINT)) {
20 gpio_output(GPIO_FPMCU_BOOT0, 0);
21 gpio_output(GPIO_FP_RST_L, 0);
22 gpio_output(GPIO_EN_FP_RAILS, 0);
23 }
Srinivasa Rao Mandadapu2360d7c2021-08-27 19:31:34 +053024 gpio_output(GPIO_AMP_ENABLE, 0);
T Michael Turneyb97e6f72021-03-18 09:16:44 -070025}
26
27void fill_lb_gpios(struct lb_gpios *gpios)
28{
Shelley Chen35384612022-01-05 17:15:31 -080029 const struct lb_gpio chromeos_gpios[] = {
Shaik Sajida Bhanucd1257a2021-01-19 20:14:48 +053030 {GPIO_SD_CD_L.addr, ACTIVE_LOW, gpio_get(GPIO_SD_CD_L),
31 "SD card detect"},
Srinivasa Rao Mandadapu2360d7c2021-08-27 19:31:34 +053032 {GPIO_AMP_ENABLE.addr, ACTIVE_HIGH, gpio_get(GPIO_AMP_ENABLE),
33 "speaker enable"},
Shelley Chen35384612022-01-05 17:15:31 -080034#if CONFIG(EC_GOOGLE_CHROMEEC)
35 {GPIO_EC_IN_RW.addr, ACTIVE_LOW, gpio_get(GPIO_EC_IN_RW),
36 "EC in RW"},
37 {GPIO_AP_EC_INT.addr, ACTIVE_LOW, gpio_get(GPIO_AP_EC_INT),
38 "EC interrupt"},
39#endif
40#if CONFIG(MAINBOARD_HAS_TPM2)
41 {GPIO_H1_AP_INT.addr, ACTIVE_HIGH, gpio_get(GPIO_H1_AP_INT),
42 "TPM interrupt"},
43#endif
Shaik Sajida Bhanucd1257a2021-01-19 20:14:48 +053044 };
T Michael Turneyb97e6f72021-03-18 09:16:44 -070045
Shaik Sajida Bhanucd1257a2021-01-19 20:14:48 +053046 lb_add_gpios(gpios, chromeos_gpios, ARRAY_SIZE(chromeos_gpios));
T Michael Turneyb97e6f72021-03-18 09:16:44 -070047}
Hsuan-ting Chen642508a2021-10-27 10:59:41 +000048
49int get_ec_is_trusted(void)
50{
Shelley Chen35384612022-01-05 17:15:31 -080051 /* EC is trusted if not in RW. This is active low. */
52 if (CONFIG(EC_GOOGLE_CHROMEEC))
53 return !!gpio_get(GPIO_EC_IN_RW);
54 else /* If no EC, always return true */
55 return 1;
56}
57
Grzegorz Bernacki7758b472023-06-14 12:01:32 +000058int cr50_plat_irq_status(void)
Shelley Chen35384612022-01-05 17:15:31 -080059{
60 return gpio_irq_status(GPIO_H1_AP_INT);
Hsuan-ting Chen642508a2021-10-27 10:59:41 +000061}