Angel Pons | 11ba353 | 2020-04-05 13:21:58 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Tristan Shieh | cfd8929 | 2018-05-31 09:22:53 +0800 | [diff] [blame] | 2 | |
| 3 | #include <bootmode.h> |
| 4 | #include <boot/coreboot_tables.h> |
Grzegorz Bernacki | 7758b47 | 2023-06-14 12:01:32 +0000 | [diff] [blame^] | 5 | #include <drivers/tpm/cr50.h> |
Tristan Shieh | fdcc0b3 | 2018-08-21 10:33:10 +0800 | [diff] [blame] | 6 | #include <gpio.h> |
| 7 | |
| 8 | #include "gpio.h" |
| 9 | |
| 10 | void setup_chromeos_gpios(void) |
| 11 | { |
Hung-Te Lin | 5c1fadb | 2019-04-17 11:03:20 +0800 | [diff] [blame] | 12 | gpio_input(GPIO_WP); |
Tristan Shieh | 1f64e6a | 2018-09-13 19:28:15 +0800 | [diff] [blame] | 13 | gpio_input_pullup(EC_IN_RW); |
Tristan Shieh | fdcc0b3 | 2018-08-21 10:33:10 +0800 | [diff] [blame] | 14 | gpio_input_pullup(EC_IRQ); |
You-Cheng Syu | 482eec0 | 2019-03-29 16:00:09 +0800 | [diff] [blame] | 15 | gpio_input_pullup(CR50_IRQ); |
Tristan Shieh | d053f39 | 2019-01-30 09:45:52 +0800 | [diff] [blame] | 16 | gpio_output(GPIO_RESET, 0); |
Jiaxin Yu | 30bc9f4 | 2019-04-23 20:45:50 +0800 | [diff] [blame] | 17 | gpio_output(GPIO_EN_SPK_AMP, 0); |
Tristan Shieh | fdcc0b3 | 2018-08-21 10:33:10 +0800 | [diff] [blame] | 18 | } |
Tristan Shieh | cfd8929 | 2018-05-31 09:22:53 +0800 | [diff] [blame] | 19 | |
| 20 | void fill_lb_gpios(struct lb_gpios *gpios) |
| 21 | { |
Tristan Shieh | fdcc0b3 | 2018-08-21 10:33:10 +0800 | [diff] [blame] | 22 | struct lb_gpio chromeos_gpios[] = { |
Tristan Shieh | 1f64e6a | 2018-09-13 19:28:15 +0800 | [diff] [blame] | 23 | {EC_IN_RW.id, ACTIVE_HIGH, -1, "EC in RW"}, |
Tristan Shieh | fdcc0b3 | 2018-08-21 10:33:10 +0800 | [diff] [blame] | 24 | {EC_IRQ.id, ACTIVE_LOW, -1, "EC interrupt"}, |
Tristan Shieh | 0688ab8 | 2018-10-19 17:29:23 +0800 | [diff] [blame] | 25 | {CR50_IRQ.id, ACTIVE_HIGH, -1, "TPM interrupt"}, |
Hung-Te Lin | 4b3269e | 2020-12-10 21:54:24 +0800 | [diff] [blame] | 26 | {GPIO_EN_SPK_AMP.id, ACTIVE_HIGH, -1, CONFIG_SPEAKER_GPIO_NAME}, |
Tristan Shieh | fdcc0b3 | 2018-08-21 10:33:10 +0800 | [diff] [blame] | 27 | }; |
| 28 | lb_add_gpios(gpios, chromeos_gpios, ARRAY_SIZE(chromeos_gpios)); |
Tristan Shieh | cfd8929 | 2018-05-31 09:22:53 +0800 | [diff] [blame] | 29 | } |
| 30 | |
Tristan Shieh | cfd8929 | 2018-05-31 09:22:53 +0800 | [diff] [blame] | 31 | int get_write_protect_state(void) |
| 32 | { |
Hung-Te Lin | 5c1fadb | 2019-04-17 11:03:20 +0800 | [diff] [blame] | 33 | return !gpio_get(GPIO_WP); |
Tristan Shieh | cfd8929 | 2018-05-31 09:22:53 +0800 | [diff] [blame] | 34 | } |
Tristan Shieh | 0688ab8 | 2018-10-19 17:29:23 +0800 | [diff] [blame] | 35 | |
Grzegorz Bernacki | 7758b47 | 2023-06-14 12:01:32 +0000 | [diff] [blame^] | 36 | int cr50_plat_irq_status(void) |
Tristan Shieh | 0688ab8 | 2018-10-19 17:29:23 +0800 | [diff] [blame] | 37 | { |
| 38 | return gpio_eint_poll(CR50_IRQ); |
| 39 | } |
Hsuan-ting Chen | 642508a | 2021-10-27 10:59:41 +0000 | [diff] [blame] | 40 | |
| 41 | int get_ec_is_trusted(void) |
| 42 | { |
| 43 | /* EC is trusted if not in RW. */ |
| 44 | return !gpio_get(EC_IN_RW); |
| 45 | } |