Ronald G. Minnich | 3faa2c7 | 2013-02-20 15:46:46 -0800 | [diff] [blame] | 1 | /* |
| 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 <console/console.h> |
| 21 | #include <string.h> |
| 22 | #include <vendorcode/google/chromeos/chromeos.h> |
| 23 | #include <arch/io.h> |
| 24 | |
| 25 | #include <device/device.h> |
| 26 | |
| 27 | #define ACTIVE_LOW 0 |
| 28 | #define ACTIVE_HIGH 1 |
| 29 | #define WP_GPIO 6 |
| 30 | #define DEVMODE_GPIO 54 |
| 31 | #define FORCE_RECOVERY_MODE 0 |
| 32 | #define FORCE_DEVELOPER_MODE 0 |
| 33 | |
| 34 | #include <boot/coreboot_tables.h> |
| 35 | #include <arch/coreboot_tables.h> |
| 36 | |
Ronald G. Minnich | eeb3632 | 2013-02-27 10:12:03 -0800 | [diff] [blame^] | 37 | #define GPIO_COUNT 6 |
Ronald G. Minnich | 3faa2c7 | 2013-02-20 15:46:46 -0800 | [diff] [blame] | 38 | |
| 39 | void fill_lb_gpios(struct lb_gpios *gpios) |
| 40 | { |
| 41 | |
| 42 | gpios->size = sizeof(*gpios) + (GPIO_COUNT * sizeof(struct lb_gpio)); |
| 43 | gpios->count = GPIO_COUNT; |
| 44 | |
| 45 | /* Write Protect: virtual GPIO active Low */ |
| 46 | gpios->gpios[0].port = -1; |
| 47 | gpios->gpios[0].polarity = ACTIVE_LOW; |
| 48 | gpios->gpios[0].value = 1; |
| 49 | strncpy((char *)gpios->gpios[0].name,"write protect", |
| 50 | GPIO_MAX_NAME_LENGTH); |
| 51 | |
| 52 | /* Recovery: virtual GPIO active high */ |
| 53 | gpios->gpios[1].port = -1; |
| 54 | gpios->gpios[1].polarity = ACTIVE_HIGH; |
| 55 | gpios->gpios[1].value = 0; |
| 56 | strncpy((char *)gpios->gpios[1].name,"recovery", GPIO_MAX_NAME_LENGTH); |
| 57 | |
Ronald G. Minnich | eeb3632 | 2013-02-27 10:12:03 -0800 | [diff] [blame^] | 58 | /* Lid: the "switch" comes from the EC */ |
Ronald G. Minnich | 3faa2c7 | 2013-02-20 15:46:46 -0800 | [diff] [blame] | 59 | gpios->gpios[2].port = -1; |
| 60 | gpios->gpios[2].polarity = ACTIVE_HIGH; |
Ronald G. Minnich | eeb3632 | 2013-02-27 10:12:03 -0800 | [diff] [blame^] | 61 | gpios->gpios[2].value = 0; |
| 62 | strncpy((char *)gpios->gpios[2].name,"lid", GPIO_MAX_NAME_LENGTH); |
| 63 | |
| 64 | /* Power: hardcoded as not pressed */ |
| 65 | gpios->gpios[3].port = -1; |
| 66 | gpios->gpios[3].polarity = ACTIVE_HIGH; |
| 67 | gpios->gpios[3].value = 0; |
| 68 | strncpy((char *)gpios->gpios[3].name,"power", GPIO_MAX_NAME_LENGTH); |
| 69 | |
| 70 | /* Developer: virtual GPIO active high */ |
| 71 | gpios->gpios[4].port = -1; |
| 72 | gpios->gpios[4].polarity = ACTIVE_HIGH; |
| 73 | gpios->gpios[4].value = 0; |
| 74 | strncpy((char *)gpios->gpios[4].name,"developer", |
Ronald G. Minnich | 3faa2c7 | 2013-02-20 15:46:46 -0800 | [diff] [blame] | 75 | GPIO_MAX_NAME_LENGTH); |
| 76 | |
| 77 | /* Was VGA Option ROM loaded? */ |
Ronald G. Minnich | eeb3632 | 2013-02-27 10:12:03 -0800 | [diff] [blame^] | 78 | gpios->gpios[5].port = -1; /* Indicate that this is a pseudo GPIO */ |
| 79 | gpios->gpios[5].polarity = ACTIVE_HIGH; |
| 80 | gpios->gpios[5].value = 0; |
| 81 | strncpy((char *)gpios->gpios[5].name,"oprom", GPIO_MAX_NAME_LENGTH); |
Ronald G. Minnich | 3faa2c7 | 2013-02-20 15:46:46 -0800 | [diff] [blame] | 82 | |
| 83 | printk(BIOS_ERR, "Added %d GPIOS size %d\n", GPIO_COUNT, gpios->size); |
| 84 | |
| 85 | } |
| 86 | |
| 87 | int get_developer_mode_switch(void) |
| 88 | { |
| 89 | int dev_mode = 0; |
| 90 | |
| 91 | printk(BIOS_DEBUG,"FORCING DEVELOPER MODE.\n"); |
| 92 | |
| 93 | dev_mode = 1; |
| 94 | printk(BIOS_DEBUG,"DEVELOPER MODE FROM GPIO %d: %x\n",DEVMODE_GPIO, |
| 95 | dev_mode); |
| 96 | |
| 97 | return dev_mode; |
| 98 | } |
| 99 | |
| 100 | int get_recovery_mode_switch(void) |
| 101 | { |
| 102 | int ec_rec_mode = 0; |
| 103 | |
| 104 | return ec_rec_mode; |
| 105 | } |
| 106 | |
| 107 | int get_recovery_mode_from_vbnv(void) |
| 108 | { |
| 109 | return 1; |
| 110 | } |