blob: 3472b1c4b4767e9d6e48812ae5111e4d6f7feb9e [file] [log] [blame]
Aaron Durbinc625d092013-10-04 16:00:07 -05001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2013 Google Inc.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
Aaron Durbinc625d092013-10-04 16:00:07 -050014 */
15
Furquan Shaikh0325dc62016-07-25 13:02:36 -070016#include <bootmode.h>
Kyösti Mälkki9c5a9bb2019-08-17 05:28:38 +030017#include <boot/coreboot_tables.h>
Julius Werner18ea2d32014-10-07 16:42:17 -070018#include <soc/gpio.h>
Aaron Durbinb0f81512016-07-25 21:31:41 -050019#include <vendorcode/google/chromeos/chromeos.h>
Aaron Durbinc625d092013-10-04 16:00:07 -050020
Aaron Durbin063c8732013-10-28 11:24:53 -050021/* The WP status pin lives on GPIO_SSUS_6 which is pad 36 in the SUS well. */
22#define WP_STATUS_PAD 36
Aaron Durbinc625d092013-10-04 16:00:07 -050023
Aaron Durbinc625d092013-10-04 16:00:07 -050024void fill_lb_gpios(struct lb_gpios *gpios)
25{
Julius Wernerc445b4f2016-03-31 17:27:05 -070026 struct lb_gpio chromeos_gpios[] = {
27 {-1, ACTIVE_HIGH, get_write_protect_state(), "write protect"},
Julius Wernerc445b4f2016-03-31 17:27:05 -070028 {-1, ACTIVE_HIGH, get_lid_switch(), "lid"},
29 {-1, ACTIVE_HIGH, 0, "power"},
30 {-1, ACTIVE_HIGH, gfx_get_init_done(), "oprom"},
31 };
32 lb_add_gpios(gpios, chromeos_gpios, ARRAY_SIZE(chromeos_gpios));
Aaron Durbinc625d092013-10-04 16:00:07 -050033}
Aaron Durbinc625d092013-10-04 16:00:07 -050034
Aaron Durbinc625d092013-10-04 16:00:07 -050035int get_write_protect_state(void)
36{
Aaron Durbin4177db52014-02-05 14:55:26 -060037 /*
38 * The vboot loader queries this function in romstage. The GPIOs have
39 * not been set up yet as that configuration is done in ramstage. The
40 * hardware defaults to an input but there is a 20K pulldown. Externally
41 * there is a 10K pullup. Disable the internal pull in romstage so that
42 * there isn't any ambiguity in the reading.
43 */
Kyösti Mälkki2dba2942019-08-18 18:30:40 +030044 if (ENV_ROMSTAGE)
45 ssus_disable_internal_pull(WP_STATUS_PAD);
Aaron Durbin4177db52014-02-05 14:55:26 -060046
Aaron Durbin063c8732013-10-28 11:24:53 -050047 /* WP is enabled when the pin is reading high. */
48 return ssus_get_gpio(WP_STATUS_PAD);
Aaron Durbinc625d092013-10-04 16:00:07 -050049}
Aaron Durbinb0f81512016-07-25 21:31:41 -050050
51static const struct cros_gpio cros_gpios[] = {
52 CROS_GPIO_REC_AL(CROS_GPIO_VIRTUAL, CROS_GPIO_DEVICE_NAME),
53 CROS_GPIO_WP_AH(0x2006, CROS_GPIO_DEVICE_NAME),
54};
55
56void mainboard_chromeos_acpi_generate(void)
57{
58 chromeos_acpi_gpio_generate(cros_gpios, ARRAY_SIZE(cros_gpios));
59}