blob: 8c6749b4d466ed797c3c5696e49b5fa40053586e [file] [log] [blame]
Angel Ponsfeedf232020-04-05 13:22:01 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Stefan Reinauer49428d82013-02-21 15:48:37 -08002
Kyösti Mälkkiab728092014-05-03 16:47:52 +03003#include <bootmode.h>
Kyösti Mälkki9c5a9bb2019-08-17 05:28:38 +03004#include <boot/coreboot_tables.h>
Stefan Reinauer49428d82013-02-21 15:48:37 -08005#include <southbridge/intel/bd82x6x/pch.h>
Patrick Rudolphe8e66f42016-02-06 17:42:42 +01006#include <southbridge/intel/common/gpio.h>
Kyösti Mälkki9a3bde02021-11-06 16:13:15 +02007#include <types.h>
Aaron Durbinb0f81512016-07-25 21:31:41 -05008#include <vendorcode/google/chromeos/chromeos.h>
Kyösti Mälkki4bcc2752021-11-05 22:02:26 +02009#include "onboard.h"
Stefan Reinauer49428d82013-02-21 15:48:37 -080010
Hsuan-ting Chen642508a2021-10-27 10:59:41 +000011#define GPIO_EC_IN_RW 21
12
Stefan Reinauer49428d82013-02-21 15:48:37 -080013void fill_lb_gpios(struct lb_gpios *gpios)
14{
Joel Kitching2e1f6552019-03-23 12:41:04 +080015 struct lb_gpio chromeos_gpios[] = {
Joel Kitching2e1f6552019-03-23 12:41:04 +080016 /* Lid: the "switch" comes from the EC */
17 {-1, ACTIVE_HIGH, get_lid_switch(), "lid"},
Stefan Reinauer49428d82013-02-21 15:48:37 -080018
Joel Kitching2e1f6552019-03-23 12:41:04 +080019 /* Power Button: hard-coded as not pressed; we'll detect later
20 * presses via SMI. */
21 {-1, ACTIVE_HIGH, 0, "power"},
Stefan Reinauer49428d82013-02-21 15:48:37 -080022
Joel Kitching2e1f6552019-03-23 12:41:04 +080023 /* Did we load the VGA Option ROM? */
24 /* -1 indicates that this is a pseudo GPIO */
25 {-1, ACTIVE_HIGH, gfx_get_init_done(), "oprom"},
26 };
27 lb_add_gpios(gpios, chromeos_gpios, ARRAY_SIZE(chromeos_gpios));
Stefan Reinauer49428d82013-02-21 15:48:37 -080028}
Stefan Reinauer49428d82013-02-21 15:48:37 -080029
Patrick Georgi2f31ef12015-06-30 12:49:50 +020030int get_write_protect_state(void)
31{
Kyösti Mälkki4bcc2752021-11-05 22:02:26 +020032 return get_gpio(GPIO_SPI_WP);
Patrick Georgi2f31ef12015-06-30 12:49:50 +020033}
34
Aaron Durbinb0f81512016-07-25 21:31:41 -050035static const struct cros_gpio cros_gpios[] = {
Kyösti Mälkki4bcc2752021-11-05 22:02:26 +020036 CROS_GPIO_REC_AL(GPIO_REC_MODE, CROS_GPIO_DEVICE_NAME),
37 CROS_GPIO_WP_AH(GPIO_SPI_WP, CROS_GPIO_DEVICE_NAME),
Aaron Durbinb0f81512016-07-25 21:31:41 -050038};
Kyösti Mälkki4ff218a2021-11-02 13:03:06 +020039DECLARE_CROS_GPIOS(cros_gpios);
Hsuan-ting Chen642508a2021-10-27 10:59:41 +000040
41int get_ec_is_trusted(void)
42{
43 /* EC is trusted if not in RW. */
44 return !get_gpio(GPIO_EC_IN_RW);
45}