blob: 1864754e8898503844d945dc81fafae44e6f815e [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>
23#ifdef __PRE_RAM__
24#include <arch/romcc_io.h>
25#else
26#include <device/device.h>
27#include <device/pci.h>
28#endif
29#include <southbridge/intel/lynxpoint/pch.h>
30
31#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);
61 fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "recovery", 0); // force off
62 fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "developer", 1); // force on
63 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{
71 return 1; // force on
72}
73
74int get_recovery_mode_switch(void)
75{
76 return 0; // force off
77}