blob: e0f5fafbb02a3ba70c1c2e8eaea0788ebf3797fd [file] [log] [blame]
Angel Pons60ec3652020-04-03 01:22:13 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Stefan Reinauer6651da32012-04-27 23:16:30 +02002
Kyösti Mälkkiab728092014-05-03 16:47:52 +03003#include <bootmode.h>
Kyösti Mälkki17887d02019-07-23 19:08:01 +03004#include <boot/coreboot_tables.h>
Stefan Reinauer6651da32012-04-27 23:16:30 +02005#include <device/device.h>
Stefan Reinauer6651da32012-04-27 23:16:30 +02006#include <southbridge/intel/bd82x6x/pch.h>
Patrick Rudolphe8e66f42016-02-06 17:42:42 +01007#include <southbridge/intel/common/gpio.h>
Aaron Durbinb0f81512016-07-25 21:31:41 -05008#include <vendorcode/google/chromeos/chromeos.h>
Stefan Reinauer6651da32012-04-27 23:16:30 +02009
Stefan Reinauer6651da32012-04-27 23:16:30 +020010void fill_lb_gpios(struct lb_gpios *gpios)
11{
Joel Kitching2e1f6552019-03-23 12:41:04 +080012 struct lb_gpio chromeos_gpios[] = {
Joel Kitching2e1f6552019-03-23 12:41:04 +080013 /* Recovery: GPIO22 */
Matt Delco2cb39962019-04-30 14:59:43 -070014 {22, ACTIVE_LOW, !get_recovery_mode_switch(), "presence"},
Stefan Reinauer6651da32012-04-27 23:16:30 +020015
Joel Kitching2e1f6552019-03-23 12:41:04 +080016 /* Hard code the lid switch GPIO to open. */
17 {-1, ACTIVE_HIGH, 1, "lid"},
Stefan Reinauer6651da32012-04-27 23:16:30 +020018
Joel Kitching2e1f6552019-03-23 12:41:04 +080019 /* Power Button */
20 {-1, ACTIVE_HIGH, 0, "power"},
Stefan Reinauer6651da32012-04-27 23:16:30 +020021
Joel Kitching2e1f6552019-03-23 12:41:04 +080022 /* 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 Reinauer6651da32012-04-27 23:16:30 +020026}
Stefan Reinauer6651da32012-04-27 23:16:30 +020027
Stefan Reinauer6651da32012-04-27 23:16:30 +020028int get_recovery_mode_switch(void)
29{
Gabe Blackf40a2592012-03-29 18:04:56 -070030 /* Recovery: GPIO22, active low */
Patrick Rudolphe8e66f42016-02-06 17:42:42 +010031 return !get_gpio(22);
Stefan Reinauer6651da32012-04-27 23:16:30 +020032}
Aaron Durbinb0f81512016-07-25 21:31:41 -050033
Joel Kitching2e1f6552019-03-23 12:41:04 +080034int get_write_protect_state(void)
35{
36 /* Write protect is active low, so invert it here */
37 return !get_gpio(48);
38}
39
Aaron Durbinb0f81512016-07-25 21:31:41 -050040static const struct cros_gpio cros_gpios[] = {
41 CROS_GPIO_REC_AL(22, CROS_GPIO_DEVICE_NAME),
Aaron Durbinb0f81512016-07-25 21:31:41 -050042 CROS_GPIO_WP_AL(48, CROS_GPIO_DEVICE_NAME),
43};
44
45void mainboard_chromeos_acpi_generate(void)
46{
47 chromeos_acpi_gpio_generate(cros_gpios, ARRAY_SIZE(cros_gpios));
48}