Aaron Durbin | c625d09 | 2013-10-04 16:00:07 -0500 | [diff] [blame] | 1 | /* |
| 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 Durbin | c625d09 | 2013-10-04 16:00:07 -0500 | [diff] [blame] | 14 | */ |
| 15 | |
Furquan Shaikh | 0325dc6 | 2016-07-25 13:02:36 -0700 | [diff] [blame] | 16 | #include <bootmode.h> |
Kyösti Mälkki | 9c5a9bb | 2019-08-17 05:28:38 +0300 | [diff] [blame^] | 17 | #include <boot/coreboot_tables.h> |
Julius Werner | 18ea2d3 | 2014-10-07 16:42:17 -0700 | [diff] [blame] | 18 | #include <soc/gpio.h> |
Aaron Durbin | b0f8151 | 2016-07-25 21:31:41 -0500 | [diff] [blame] | 19 | #include <vendorcode/google/chromeos/chromeos.h> |
Aaron Durbin | c625d09 | 2013-10-04 16:00:07 -0500 | [diff] [blame] | 20 | |
Aaron Durbin | 063c873 | 2013-10-28 11:24:53 -0500 | [diff] [blame] | 21 | /* The WP status pin lives on GPIO_SSUS_6 which is pad 36 in the SUS well. */ |
| 22 | #define WP_STATUS_PAD 36 |
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 | void fill_lb_gpios(struct lb_gpios *gpios) |
| 25 | { |
Julius Werner | c445b4f | 2016-03-31 17:27:05 -0700 | [diff] [blame] | 26 | struct lb_gpio chromeos_gpios[] = { |
| 27 | {-1, ACTIVE_HIGH, get_write_protect_state(), "write protect"}, |
Julius Werner | c445b4f | 2016-03-31 17:27:05 -0700 | [diff] [blame] | 28 | {-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 Durbin | c625d09 | 2013-10-04 16:00:07 -0500 | [diff] [blame] | 33 | } |
Aaron Durbin | c625d09 | 2013-10-04 16:00:07 -0500 | [diff] [blame] | 34 | |
Aaron Durbin | c625d09 | 2013-10-04 16:00:07 -0500 | [diff] [blame] | 35 | int get_write_protect_state(void) |
| 36 | { |
Aaron Durbin | 4177db5 | 2014-02-05 14:55:26 -0600 | [diff] [blame] | 37 | /* |
| 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 | */ |
| 44 | #if defined(__PRE_RAM__) |
| 45 | ssus_disable_internal_pull(WP_STATUS_PAD); |
| 46 | #endif |
| 47 | |
Aaron Durbin | 063c873 | 2013-10-28 11:24:53 -0500 | [diff] [blame] | 48 | /* WP is enabled when the pin is reading high. */ |
| 49 | return ssus_get_gpio(WP_STATUS_PAD); |
Aaron Durbin | c625d09 | 2013-10-04 16:00:07 -0500 | [diff] [blame] | 50 | } |
Aaron Durbin | b0f8151 | 2016-07-25 21:31:41 -0500 | [diff] [blame] | 51 | |
| 52 | static const struct cros_gpio cros_gpios[] = { |
| 53 | CROS_GPIO_REC_AL(CROS_GPIO_VIRTUAL, CROS_GPIO_DEVICE_NAME), |
| 54 | CROS_GPIO_WP_AH(0x2006, CROS_GPIO_DEVICE_NAME), |
| 55 | }; |
| 56 | |
| 57 | void mainboard_chromeos_acpi_generate(void) |
| 58 | { |
| 59 | chromeos_acpi_gpio_generate(cros_gpios, ARRAY_SIZE(cros_gpios)); |
| 60 | } |