Angel Pons | 60ec365 | 2020-04-03 01:22:13 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Stefan Reinauer | 6651da3 | 2012-04-27 23:16:30 +0200 | [diff] [blame] | 2 | |
Kyösti Mälkki | ab72809 | 2014-05-03 16:47:52 +0300 | [diff] [blame] | 3 | #include <bootmode.h> |
Kyösti Mälkki | 17887d0 | 2019-07-23 19:08:01 +0300 | [diff] [blame] | 4 | #include <boot/coreboot_tables.h> |
Stefan Reinauer | 6651da3 | 2012-04-27 23:16:30 +0200 | [diff] [blame] | 5 | #include <device/device.h> |
Stefan Reinauer | 6651da3 | 2012-04-27 23:16:30 +0200 | [diff] [blame] | 6 | #include <southbridge/intel/bd82x6x/pch.h> |
Patrick Rudolph | e8e66f4 | 2016-02-06 17:42:42 +0100 | [diff] [blame] | 7 | #include <southbridge/intel/common/gpio.h> |
Aaron Durbin | b0f8151 | 2016-07-25 21:31:41 -0500 | [diff] [blame] | 8 | #include <vendorcode/google/chromeos/chromeos.h> |
Stefan Reinauer | 6651da3 | 2012-04-27 23:16:30 +0200 | [diff] [blame] | 9 | |
Stefan Reinauer | 6651da3 | 2012-04-27 23:16:30 +0200 | [diff] [blame] | 10 | void fill_lb_gpios(struct lb_gpios *gpios) |
| 11 | { |
Joel Kitching | 2e1f655 | 2019-03-23 12:41:04 +0800 | [diff] [blame] | 12 | struct lb_gpio chromeos_gpios[] = { |
Joel Kitching | 2e1f655 | 2019-03-23 12:41:04 +0800 | [diff] [blame] | 13 | /* Recovery: GPIO22 */ |
Matt Delco | 2cb3996 | 2019-04-30 14:59:43 -0700 | [diff] [blame] | 14 | {22, ACTIVE_LOW, !get_recovery_mode_switch(), "presence"}, |
Stefan Reinauer | 6651da3 | 2012-04-27 23:16:30 +0200 | [diff] [blame] | 15 | |
Joel Kitching | 2e1f655 | 2019-03-23 12:41:04 +0800 | [diff] [blame] | 16 | /* Hard code the lid switch GPIO to open. */ |
| 17 | {-1, ACTIVE_HIGH, 1, "lid"}, |
Stefan Reinauer | 6651da3 | 2012-04-27 23:16:30 +0200 | [diff] [blame] | 18 | |
Joel Kitching | 2e1f655 | 2019-03-23 12:41:04 +0800 | [diff] [blame] | 19 | /* Power Button */ |
| 20 | {-1, ACTIVE_HIGH, 0, "power"}, |
Stefan Reinauer | 6651da3 | 2012-04-27 23:16:30 +0200 | [diff] [blame] | 21 | |
Joel Kitching | 2e1f655 | 2019-03-23 12:41:04 +0800 | [diff] [blame] | 22 | /* Did we load the VGA option ROM? */ |
| 23 | {-1, ACTIVE_HIGH, gfx_get_init_done(), "oprom"}, |
| 24 | }; |
| 25 | lb_add_gpios(gpios, chromeos_gpios, ARRAY_SIZE(chromeos_gpios)); |
Stefan Reinauer | 6651da3 | 2012-04-27 23:16:30 +0200 | [diff] [blame] | 26 | } |
Stefan Reinauer | 6651da3 | 2012-04-27 23:16:30 +0200 | [diff] [blame] | 27 | |
Stefan Reinauer | 6651da3 | 2012-04-27 23:16:30 +0200 | [diff] [blame] | 28 | int get_recovery_mode_switch(void) |
| 29 | { |
Gabe Black | f40a259 | 2012-03-29 18:04:56 -0700 | [diff] [blame] | 30 | /* Recovery: GPIO22, active low */ |
Patrick Rudolph | e8e66f4 | 2016-02-06 17:42:42 +0100 | [diff] [blame] | 31 | return !get_gpio(22); |
Stefan Reinauer | 6651da3 | 2012-04-27 23:16:30 +0200 | [diff] [blame] | 32 | } |
Aaron Durbin | b0f8151 | 2016-07-25 21:31:41 -0500 | [diff] [blame] | 33 | |
Joel Kitching | 2e1f655 | 2019-03-23 12:41:04 +0800 | [diff] [blame] | 34 | int get_write_protect_state(void) |
| 35 | { |
| 36 | /* Write protect is active low, so invert it here */ |
| 37 | return !get_gpio(48); |
| 38 | } |
| 39 | |
Aaron Durbin | b0f8151 | 2016-07-25 21:31:41 -0500 | [diff] [blame] | 40 | static const struct cros_gpio cros_gpios[] = { |
| 41 | CROS_GPIO_REC_AL(22, CROS_GPIO_DEVICE_NAME), |
Aaron Durbin | b0f8151 | 2016-07-25 21:31:41 -0500 | [diff] [blame] | 42 | CROS_GPIO_WP_AL(48, CROS_GPIO_DEVICE_NAME), |
| 43 | }; |
| 44 | |
| 45 | void mainboard_chromeos_acpi_generate(void) |
| 46 | { |
| 47 | chromeos_acpi_gpio_generate(cros_gpios, ARRAY_SIZE(cros_gpios)); |
| 48 | } |