blob: 50497f07aaf1ddfb5a0ff2d65a4af79ed2d12311 [file] [log] [blame]
Angel Pons47f26db2020-04-05 13:22:34 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Aaron Durbinc625d092013-10-04 16:00:07 -05002
Furquan Shaikh0325dc62016-07-25 13:02:36 -07003#include <bootmode.h>
Kyösti Mälkki9c5a9bb2019-08-17 05:28:38 +03004#include <boot/coreboot_tables.h>
Julius Werner18ea2d32014-10-07 16:42:17 -07005#include <soc/gpio.h>
Kyösti Mälkki9a3bde02021-11-06 16:13:15 +02006#include <types.h>
Aaron Durbinb0f81512016-07-25 21:31:41 -05007#include <vendorcode/google/chromeos/chromeos.h>
Aaron Durbinc625d092013-10-04 16:00:07 -05008
Aaron Durbin063c8732013-10-28 11:24:53 -05009/* The WP status pin lives on GPIO_SSUS_6 which is pad 36 in the SUS well. */
10#define WP_STATUS_PAD 36
Aaron Durbinc625d092013-10-04 16:00:07 -050011
Hsuan-ting Chen642508a2021-10-27 10:59:41 +000012/* The EC_IN_RW lives on SCGPIO59 */
13#define EC_IN_RW_PAD 59
14
Aaron Durbinc625d092013-10-04 16:00:07 -050015void fill_lb_gpios(struct lb_gpios *gpios)
16{
Julius Wernerc445b4f2016-03-31 17:27:05 -070017 struct lb_gpio chromeos_gpios[] = {
Julius Wernerc445b4f2016-03-31 17:27:05 -070018 {-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 Durbinc625d092013-10-04 16:00:07 -050023}
Aaron Durbinc625d092013-10-04 16:00:07 -050024
Aaron Durbinc625d092013-10-04 16:00:07 -050025int get_write_protect_state(void)
26{
Aaron Durbin4177db52014-02-05 14:55:26 -060027 /*
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 */
Arthur Heymansab5a9f92023-11-06 15:49:24 +010034 if (ENV_ROMSTAGE_OR_BEFORE)
Kyösti Mälkki2dba2942019-08-18 18:30:40 +030035 ssus_disable_internal_pull(WP_STATUS_PAD);
Aaron Durbin4177db52014-02-05 14:55:26 -060036
Aaron Durbin063c8732013-10-28 11:24:53 -050037 /* WP is enabled when the pin is reading high. */
38 return ssus_get_gpio(WP_STATUS_PAD);
Aaron Durbinc625d092013-10-04 16:00:07 -050039}
Aaron Durbinb0f81512016-07-25 21:31:41 -050040
41static 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älkki4ff218a2021-11-02 13:03:06 +020045DECLARE_CROS_GPIOS(cros_gpios);
Hsuan-ting Chen642508a2021-10-27 10:59:41 +000046
47int get_ec_is_trusted(void)
48{
49 /* EC is trusted if not in RW. */
50 return !score_get_gpio(EC_IN_RW_PAD);
51}