blob: cf9579ed9c1d4e72ff3229b1e21a33dd4c480dd6 [file] [log] [blame]
Furquan Shaikh06cd9032016-12-14 12:10:21 -08001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2016 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.
14 */
15
Furquan Shaikh82010832017-04-10 21:27:21 -070016#include <arch/acpi.h>
Furquan Shaikh374d1ff2017-04-14 15:44:15 -070017#include <baseboard/variants.h>
Furquan Shaikh06cd9032016-12-14 12:10:21 -080018#include <gpio.h>
19#include <rules.h>
20#include <soc/gpio.h>
21#include <vendorcode/google/chromeos/chromeos.h>
22
Furquan Shaikh76c392d2017-04-13 14:15:56 -070023#include <variant/gpio.h>
Furquan Shaikh06cd9032016-12-14 12:10:21 -080024
25#if ENV_RAMSTAGE
26#include <boot/coreboot_tables.h>
27
28void fill_lb_gpios(struct lb_gpios *gpios)
29{
30 struct lb_gpio chromeos_gpios[] = {
31 {-1, ACTIVE_HIGH, get_write_protect_state(), "write protect"},
32 {-1, ACTIVE_HIGH, get_recovery_mode_switch(), "recovery"},
Furquan Shaikh06cd9032016-12-14 12:10:21 -080033 {-1, ACTIVE_HIGH, get_lid_switch(), "lid"},
34 {-1, ACTIVE_HIGH, 0, "power"},
35 {-1, ACTIVE_HIGH, gfx_get_init_done(), "oprom"},
36 {GPIO_EC_IN_RW, ACTIVE_HIGH, gpio_get(GPIO_EC_IN_RW),
37 "EC in RW"},
38 };
39 lb_add_gpios(gpios, chromeos_gpios, ARRAY_SIZE(chromeos_gpios));
40}
41#endif /* ENV_RAMSTAGE */
42
43int get_write_protect_state(void)
44{
45 /* Read PCH_WP GPIO. */
46 return gpio_get(GPIO_PCH_WP);
47}
48
Furquan Shaikh06cd9032016-12-14 12:10:21 -080049void mainboard_chromeos_acpi_generate(void)
50{
Furquan Shaikh374d1ff2017-04-14 15:44:15 -070051 const struct cros_gpio *gpios;
52 size_t num;
53
54 gpios = variant_cros_gpios(&num);
55 chromeos_acpi_gpio_generate(gpios, num);
Furquan Shaikh06cd9032016-12-14 12:10:21 -080056}