blob: 13e7f4c38f192f3f2cde8069eb2d5084ed7b4934 [file] [log] [blame]
Angel Pons11ba3532020-04-05 13:21:58 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Tristan Shiehcfd89292018-05-31 09:22:53 +08002
3#include <bootmode.h>
4#include <boot/coreboot_tables.h>
Grzegorz Bernacki7758b472023-06-14 12:01:32 +00005#include <drivers/tpm/cr50.h>
Tristan Shiehfdcc0b32018-08-21 10:33:10 +08006#include <gpio.h>
7
8#include "gpio.h"
9
10void setup_chromeos_gpios(void)
11{
Hung-Te Lin5c1fadb2019-04-17 11:03:20 +080012 gpio_input(GPIO_WP);
Tristan Shieh1f64e6a2018-09-13 19:28:15 +080013 gpio_input_pullup(EC_IN_RW);
Tristan Shiehfdcc0b32018-08-21 10:33:10 +080014 gpio_input_pullup(EC_IRQ);
You-Cheng Syu482eec02019-03-29 16:00:09 +080015 gpio_input_pullup(CR50_IRQ);
Tristan Shiehd053f392019-01-30 09:45:52 +080016 gpio_output(GPIO_RESET, 0);
Jiaxin Yu30bc9f42019-04-23 20:45:50 +080017 gpio_output(GPIO_EN_SPK_AMP, 0);
Tristan Shiehfdcc0b32018-08-21 10:33:10 +080018}
Tristan Shiehcfd89292018-05-31 09:22:53 +080019
20void fill_lb_gpios(struct lb_gpios *gpios)
21{
Tristan Shiehfdcc0b32018-08-21 10:33:10 +080022 struct lb_gpio chromeos_gpios[] = {
Tristan Shieh1f64e6a2018-09-13 19:28:15 +080023 {EC_IN_RW.id, ACTIVE_HIGH, -1, "EC in RW"},
Tristan Shiehfdcc0b32018-08-21 10:33:10 +080024 {EC_IRQ.id, ACTIVE_LOW, -1, "EC interrupt"},
Tristan Shieh0688ab82018-10-19 17:29:23 +080025 {CR50_IRQ.id, ACTIVE_HIGH, -1, "TPM interrupt"},
Hung-Te Lin4b3269e2020-12-10 21:54:24 +080026 {GPIO_EN_SPK_AMP.id, ACTIVE_HIGH, -1, CONFIG_SPEAKER_GPIO_NAME},
Tristan Shiehfdcc0b32018-08-21 10:33:10 +080027 };
28 lb_add_gpios(gpios, chromeos_gpios, ARRAY_SIZE(chromeos_gpios));
Tristan Shiehcfd89292018-05-31 09:22:53 +080029}
30
Tristan Shiehcfd89292018-05-31 09:22:53 +080031int get_write_protect_state(void)
32{
Hung-Te Lin5c1fadb2019-04-17 11:03:20 +080033 return !gpio_get(GPIO_WP);
Tristan Shiehcfd89292018-05-31 09:22:53 +080034}
Tristan Shieh0688ab82018-10-19 17:29:23 +080035
Grzegorz Bernacki7758b472023-06-14 12:01:32 +000036int cr50_plat_irq_status(void)
Tristan Shieh0688ab82018-10-19 17:29:23 +080037{
38 return gpio_eint_poll(CR50_IRQ);
39}
Hsuan-ting Chen642508a2021-10-27 10:59:41 +000040
41int get_ec_is_trusted(void)
42{
43 /* EC is trusted if not in RW. */
44 return !gpio_get(EC_IN_RW);
45}