blob: 2681b3a495d0b2282b431906dc11f8a7cd0bc5ef [file] [log] [blame]
Aaron Durbinc625d092013-10-04 16:00:07 -05001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2013 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 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
20#include <string.h>
21#include <vendorcode/google/chromeos/chromeos.h>
22#include <arch/io.h>
23#include <device/device.h>
24#include <device/pci.h>
25
26/* Compile-time settings for developer and recovery mode. */
27#define DEV_MODE_SETTING 1
28#define REC_MODE_SETTING 0
29
30#ifndef __PRE_RAM__
31#include <boot/coreboot_tables.h>
32
33#define GPIO_COUNT 6
34#define ACTIVE_LOW 0
35#define ACTIVE_HIGH 1
36
37static void fill_lb_gpio(struct lb_gpio *gpio, int polarity,
38 const char *name, int force)
39{
40 memset(gpio, 0, sizeof(*gpio));
41 gpio->port = -1;
42 gpio->polarity = polarity;
43 if (force >= 0)
44 gpio->value = force;
45 strncpy((char *)gpio->name, name, GPIO_MAX_NAME_LENGTH);
46}
47
48void fill_lb_gpios(struct lb_gpios *gpios)
49{
50 struct lb_gpio *gpio;
51
52 gpios->size = sizeof(*gpios) + (GPIO_COUNT * sizeof(struct lb_gpio));
53 gpios->count = GPIO_COUNT;
54
55 gpio = gpios->gpios;
56 fill_lb_gpio(gpio++, ACTIVE_HIGH, "write protect", 0);
57 fill_lb_gpio(gpio++, ACTIVE_HIGH, "recovery", REC_MODE_SETTING);
58 fill_lb_gpio(gpio++, ACTIVE_HIGH, "developer", DEV_MODE_SETTING);
59 fill_lb_gpio(gpio++, ACTIVE_HIGH, "lid", 1); // force open
60 fill_lb_gpio(gpio++, ACTIVE_HIGH, "power", 0);
61 fill_lb_gpio(gpio++, ACTIVE_HIGH, "oprom", oprom_is_loaded);
62}
63#endif
64
65int get_developer_mode_switch(void)
66{
67 return DEV_MODE_SETTING;
68}
69
70int get_recovery_mode_switch(void)
71{
72 return REC_MODE_SETTING;
73}
74
75int get_write_protect_state(void)
76{
77 return 0;
78}
79