Angel Pons | 47f26db | 2020-04-05 13:22:34 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Aaron Durbin | c625d09 | 2013-10-04 16:00:07 -0500 | [diff] [blame] | 2 | |
Furquan Shaikh | 0325dc6 | 2016-07-25 13:02:36 -0700 | [diff] [blame] | 3 | #include <bootmode.h> |
Kyösti Mälkki | 9c5a9bb | 2019-08-17 05:28:38 +0300 | [diff] [blame] | 4 | #include <boot/coreboot_tables.h> |
Julius Werner | 18ea2d3 | 2014-10-07 16:42:17 -0700 | [diff] [blame] | 5 | #include <soc/gpio.h> |
Kyösti Mälkki | 9a3bde0 | 2021-11-06 16:13:15 +0200 | [diff] [blame] | 6 | #include <types.h> |
Aaron Durbin | b0f8151 | 2016-07-25 21:31:41 -0500 | [diff] [blame] | 7 | #include <vendorcode/google/chromeos/chromeos.h> |
Aaron Durbin | c625d09 | 2013-10-04 16:00:07 -0500 | [diff] [blame] | 8 | |
Aaron Durbin | 063c873 | 2013-10-28 11:24:53 -0500 | [diff] [blame] | 9 | /* The WP status pin lives on GPIO_SSUS_6 which is pad 36 in the SUS well. */ |
| 10 | #define WP_STATUS_PAD 36 |
Aaron Durbin | c625d09 | 2013-10-04 16:00:07 -0500 | [diff] [blame] | 11 | |
Hsuan-ting Chen | 642508a | 2021-10-27 10:59:41 +0000 | [diff] [blame] | 12 | /* The EC_IN_RW lives on SCGPIO59 */ |
| 13 | #define EC_IN_RW_PAD 59 |
| 14 | |
Aaron Durbin | c625d09 | 2013-10-04 16:00:07 -0500 | [diff] [blame] | 15 | void fill_lb_gpios(struct lb_gpios *gpios) |
| 16 | { |
Julius Werner | c445b4f | 2016-03-31 17:27:05 -0700 | [diff] [blame] | 17 | struct lb_gpio chromeos_gpios[] = { |
Julius Werner | c445b4f | 2016-03-31 17:27:05 -0700 | [diff] [blame] | 18 | {-1, ACTIVE_HIGH, get_lid_switch(), "lid"}, |
| 19 | {-1, ACTIVE_HIGH, 0, "power"}, |
| 20 | {-1, ACTIVE_HIGH, gfx_get_init_done(), "oprom"}, |
| 21 | }; |
| 22 | lb_add_gpios(gpios, chromeos_gpios, ARRAY_SIZE(chromeos_gpios)); |
Aaron Durbin | c625d09 | 2013-10-04 16:00:07 -0500 | [diff] [blame] | 23 | } |
Aaron Durbin | c625d09 | 2013-10-04 16:00:07 -0500 | [diff] [blame] | 24 | |
Aaron Durbin | c625d09 | 2013-10-04 16:00:07 -0500 | [diff] [blame] | 25 | int get_write_protect_state(void) |
| 26 | { |
Aaron Durbin | 4177db5 | 2014-02-05 14:55:26 -0600 | [diff] [blame] | 27 | /* |
| 28 | * The vboot loader queries this function in romstage. The GPIOs have |
| 29 | * not been set up yet as that configuration is done in ramstage. The |
| 30 | * hardware defaults to an input but there is a 20K pulldown. Externally |
| 31 | * there is a 10K pullup. Disable the internal pull in romstage so that |
| 32 | * there isn't any ambiguity in the reading. |
| 33 | */ |
Kyösti Mälkki | 2dba294 | 2019-08-18 18:30:40 +0300 | [diff] [blame] | 34 | if (ENV_ROMSTAGE) |
| 35 | ssus_disable_internal_pull(WP_STATUS_PAD); |
Aaron Durbin | 4177db5 | 2014-02-05 14:55:26 -0600 | [diff] [blame] | 36 | |
Aaron Durbin | 063c873 | 2013-10-28 11:24:53 -0500 | [diff] [blame] | 37 | /* WP is enabled when the pin is reading high. */ |
| 38 | return ssus_get_gpio(WP_STATUS_PAD); |
Aaron Durbin | c625d09 | 2013-10-04 16:00:07 -0500 | [diff] [blame] | 39 | } |
Aaron Durbin | b0f8151 | 2016-07-25 21:31:41 -0500 | [diff] [blame] | 40 | |
| 41 | static const struct cros_gpio cros_gpios[] = { |
| 42 | CROS_GPIO_REC_AL(CROS_GPIO_VIRTUAL, CROS_GPIO_DEVICE_NAME), |
| 43 | CROS_GPIO_WP_AH(0x2006, CROS_GPIO_DEVICE_NAME), |
| 44 | }; |
Kyösti Mälkki | 4ff218a | 2021-11-02 13:03:06 +0200 | [diff] [blame^] | 45 | DECLARE_CROS_GPIOS(cros_gpios); |
Hsuan-ting Chen | 642508a | 2021-10-27 10:59:41 +0000 | [diff] [blame] | 46 | |
| 47 | int get_ec_is_trusted(void) |
| 48 | { |
| 49 | /* EC is trusted if not in RW. */ |
| 50 | return !score_get_gpio(EC_IN_RW_PAD); |
| 51 | } |