blob: 3d2bd4592fa6d98290ef04cf740238934be61549 [file] [log] [blame]
Angel Pons47f26db2020-04-05 13:22:34 +02001/* SPDX-License-Identifier: GPL-2.0-only */
2/* This file is part of the coreboot project. */
Aaron Durbinc625d092013-10-04 16:00:07 -05003
Furquan Shaikh0325dc62016-07-25 13:02:36 -07004#include <bootmode.h>
Kyösti Mälkki9c5a9bb2019-08-17 05:28:38 +03005#include <boot/coreboot_tables.h>
Julius Werner18ea2d32014-10-07 16:42:17 -07006#include <soc/gpio.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
Aaron Durbinc625d092013-10-04 16:00:07 -050012void fill_lb_gpios(struct lb_gpios *gpios)
13{
Julius Wernerc445b4f2016-03-31 17:27:05 -070014 struct lb_gpio chromeos_gpios[] = {
Julius Wernerc445b4f2016-03-31 17:27:05 -070015 {-1, ACTIVE_HIGH, get_lid_switch(), "lid"},
16 {-1, ACTIVE_HIGH, 0, "power"},
17 {-1, ACTIVE_HIGH, gfx_get_init_done(), "oprom"},
18 };
19 lb_add_gpios(gpios, chromeos_gpios, ARRAY_SIZE(chromeos_gpios));
Aaron Durbinc625d092013-10-04 16:00:07 -050020}
Aaron Durbinc625d092013-10-04 16:00:07 -050021
Aaron Durbinc625d092013-10-04 16:00:07 -050022int get_write_protect_state(void)
23{
Aaron Durbin4177db52014-02-05 14:55:26 -060024 /*
25 * The vboot loader queries this function in romstage. The GPIOs have
26 * not been set up yet as that configuration is done in ramstage. The
27 * hardware defaults to an input but there is a 20K pulldown. Externally
28 * there is a 10K pullup. Disable the internal pull in romstage so that
29 * there isn't any ambiguity in the reading.
30 */
Kyösti Mälkki2dba2942019-08-18 18:30:40 +030031 if (ENV_ROMSTAGE)
32 ssus_disable_internal_pull(WP_STATUS_PAD);
Aaron Durbin4177db52014-02-05 14:55:26 -060033
Aaron Durbin063c8732013-10-28 11:24:53 -050034 /* WP is enabled when the pin is reading high. */
35 return ssus_get_gpio(WP_STATUS_PAD);
Aaron Durbinc625d092013-10-04 16:00:07 -050036}
Aaron Durbinb0f81512016-07-25 21:31:41 -050037
38static const struct cros_gpio cros_gpios[] = {
39 CROS_GPIO_REC_AL(CROS_GPIO_VIRTUAL, CROS_GPIO_DEVICE_NAME),
40 CROS_GPIO_WP_AH(0x2006, CROS_GPIO_DEVICE_NAME),
41};
42
43void mainboard_chromeos_acpi_generate(void)
44{
45 chromeos_acpi_gpio_generate(cros_gpios, ARRAY_SIZE(cros_gpios));
46}