blob: 862f4a411c0c7646764bf2fd839d3c66247769d9 [file] [log] [blame]
Duncan Laurieafad0562013-01-14 08:50:03 -08001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2012 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.
Duncan Laurieafad0562013-01-14 08:50:03 -080014 */
15
16#include <string.h>
Kyösti Mälkki16455892014-04-28 23:41:06 +030017#include <bootmode.h>
Duncan Laurieafad0562013-01-14 08:50:03 -080018#include <arch/io.h>
Duncan Laurieafad0562013-01-14 08:50:03 -080019#include <device/device.h>
20#include <device/pci.h>
Julius Werner4ee4bd52014-10-20 13:46:39 -070021#include <soc/gpio.h>
Aaron Durbinb0f81512016-07-25 21:31:41 -050022#include <vendorcode/google/chromeos/chromeos.h>
Duncan Laurieafad0562013-01-14 08:50:03 -080023
Aaron Durbin93a66652013-03-19 15:25:46 -050024/* Compile-time settings for developer and recovery mode. */
25#define DEV_MODE_SETTING 1
26#define REC_MODE_SETTING 0
27
Duncan Laurieafad0562013-01-14 08:50:03 -080028#ifndef __PRE_RAM__
29#include <boot/coreboot_tables.h>
Duncan Laurieafad0562013-01-14 08:50:03 -080030
Duncan Laurieafad0562013-01-14 08:50:03 -080031void fill_lb_gpios(struct lb_gpios *gpios)
32{
Julius Wernerc445b4f2016-03-31 17:27:05 -070033 struct lb_gpio chromeos_gpios[] = {
34 {-1, ACTIVE_HIGH, 0, "write protect"},
35 {-1, ACTIVE_HIGH, REC_MODE_SETTING, "recovery"},
36 {-1, ACTIVE_HIGH, DEV_MODE_SETTING, "developer"},
37 {-1, ACTIVE_HIGH, 1, "lid"}, // force open
38 {-1, ACTIVE_HIGH, 0, "power"},
39 {-1, ACTIVE_HIGH, gfx_get_init_done(), "oprom"},
40 };
41 lb_add_gpios(gpios, chromeos_gpios, ARRAY_SIZE(chromeos_gpios));
Duncan Laurieafad0562013-01-14 08:50:03 -080042}
43#endif
44
45int get_developer_mode_switch(void)
46{
Aaron Durbin93a66652013-03-19 15:25:46 -050047 return DEV_MODE_SETTING;
Duncan Laurieafad0562013-01-14 08:50:03 -080048}
49
50int get_recovery_mode_switch(void)
51{
Aaron Durbin93a66652013-03-19 15:25:46 -050052 return REC_MODE_SETTING;
Duncan Laurieafad0562013-01-14 08:50:03 -080053}
Aaron Durbin0df4de92013-03-01 17:38:59 -060054
55int get_write_protect_state(void)
56{
57 return 0;
58}
Aaron Durbinb0f81512016-07-25 21:31:41 -050059
60static const struct cros_gpio cros_gpios[] = {
61 CROS_GPIO_REC_AL(CROS_GPIO_VIRTUAL, CROS_GPIO_DEVICE_NAME),
62 CROS_GPIO_DEV_AL(CROS_GPIO_VIRTUAL, CROS_GPIO_DEVICE_NAME),
63 CROS_GPIO_WP_AL(CROS_GPIO_VIRTUAL, CROS_GPIO_DEVICE_NAME),
64};
65
66void mainboard_chromeos_acpi_generate(void)
67{
68 chromeos_acpi_gpio_generate(cros_gpios, ARRAY_SIZE(cros_gpios));
69}