blob: 385791d15964eff93a80d74857e7881213135126 [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.
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>
Duncan Laurieafad0562013-01-14 08:50:03 -080023#include <device/device.h>
24#include <device/pci.h>
Duncan Laurieafad0562013-01-14 08:50:03 -080025#include <southbridge/intel/lynxpoint/pch.h>
26
Aaron Durbin93a66652013-03-19 15:25:46 -050027/* Compile-time settings for developer and recovery mode. */
28#define DEV_MODE_SETTING 1
29#define REC_MODE_SETTING 0
30
Duncan Laurieafad0562013-01-14 08:50:03 -080031#ifndef __PRE_RAM__
32#include <boot/coreboot_tables.h>
33#include <arch/coreboot_tables.h>
34
35#define GPIO_COUNT 6
36#define ACTIVE_LOW 0
37#define ACTIVE_HIGH 1
38
39static void fill_lb_gpio(struct lb_gpio *gpio, int num,
40 int polarity, const char *name, int force)
41{
42 memset(gpio, 0, sizeof(*gpio));
43 gpio->port = num;
44 gpio->polarity = polarity;
45 if (force >= 0)
46 gpio->value = force;
47 else if (num >= 0)
48 gpio->value = get_gpio(num);
49 strncpy((char *)gpio->name, name, GPIO_MAX_NAME_LENGTH);
50}
51
52void fill_lb_gpios(struct lb_gpios *gpios)
53{
54 struct lb_gpio *gpio;
55
56 gpios->size = sizeof(*gpios) + (GPIO_COUNT * sizeof(struct lb_gpio));
57 gpios->count = GPIO_COUNT;
58
59 gpio = gpios->gpios;
60 fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "write protect", 0);
Aaron Durbin93a66652013-03-19 15:25:46 -050061 fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "recovery", REC_MODE_SETTING);
62 fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "developer", DEV_MODE_SETTING);
Duncan Laurieafad0562013-01-14 08:50:03 -080063 fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "lid", 1); // force open
64 fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "power", 0);
65 fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "oprom", oprom_is_loaded);
66}
67#endif
68
69int get_developer_mode_switch(void)
70{
Aaron Durbin93a66652013-03-19 15:25:46 -050071 return DEV_MODE_SETTING;
Duncan Laurieafad0562013-01-14 08:50:03 -080072}
73
74int get_recovery_mode_switch(void)
75{
Aaron Durbin93a66652013-03-19 15:25:46 -050076 return REC_MODE_SETTING;
Duncan Laurieafad0562013-01-14 08:50:03 -080077}
Aaron Durbin0df4de92013-03-01 17:38:59 -060078
79int get_write_protect_state(void)
80{
81 return 0;
82}
83