Duncan Laurie | afad056 | 2013-01-14 08:50:03 -0800 | [diff] [blame] | 1 | /* |
| 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 Laurie | afad056 | 2013-01-14 08:50:03 -0800 | [diff] [blame] | 23 | #include <device/device.h> |
| 24 | #include <device/pci.h> |
Duncan Laurie | afad056 | 2013-01-14 08:50:03 -0800 | [diff] [blame] | 25 | #include <southbridge/intel/lynxpoint/pch.h> |
| 26 | |
Aaron Durbin | 93a6665 | 2013-03-19 15:25:46 -0500 | [diff] [blame^] | 27 | /* Compile-time settings for developer and recovery mode. */ |
| 28 | #define DEV_MODE_SETTING 1 |
| 29 | #define REC_MODE_SETTING 0 |
| 30 | |
Duncan Laurie | afad056 | 2013-01-14 08:50:03 -0800 | [diff] [blame] | 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 | |
| 39 | static 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 | |
| 52 | void 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 Durbin | 93a6665 | 2013-03-19 15:25:46 -0500 | [diff] [blame^] | 61 | fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "recovery", REC_MODE_SETTING); |
| 62 | fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "developer", DEV_MODE_SETTING); |
Duncan Laurie | afad056 | 2013-01-14 08:50:03 -0800 | [diff] [blame] | 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 | |
| 69 | int get_developer_mode_switch(void) |
| 70 | { |
Aaron Durbin | 93a6665 | 2013-03-19 15:25:46 -0500 | [diff] [blame^] | 71 | return DEV_MODE_SETTING; |
Duncan Laurie | afad056 | 2013-01-14 08:50:03 -0800 | [diff] [blame] | 72 | } |
| 73 | |
| 74 | int get_recovery_mode_switch(void) |
| 75 | { |
Aaron Durbin | 93a6665 | 2013-03-19 15:25:46 -0500 | [diff] [blame^] | 76 | return REC_MODE_SETTING; |
Duncan Laurie | afad056 | 2013-01-14 08:50:03 -0800 | [diff] [blame] | 77 | } |
Aaron Durbin | 0df4de9 | 2013-03-01 17:38:59 -0600 | [diff] [blame] | 78 | |
| 79 | int get_write_protect_state(void) |
| 80 | { |
| 81 | return 0; |
| 82 | } |
| 83 | |