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. |
Duncan Laurie | afad056 | 2013-01-14 08:50:03 -0800 | [diff] [blame] | 14 | */ |
| 15 | |
| 16 | #include <string.h> |
Kyösti Mälkki | 1645589 | 2014-04-28 23:41:06 +0300 | [diff] [blame] | 17 | #include <bootmode.h> |
Duncan Laurie | afad056 | 2013-01-14 08:50:03 -0800 | [diff] [blame] | 18 | #include <arch/io.h> |
Duncan Laurie | afad056 | 2013-01-14 08:50:03 -0800 | [diff] [blame] | 19 | #include <device/device.h> |
| 20 | #include <device/pci.h> |
Julius Werner | 4ee4bd5 | 2014-10-20 13:46:39 -0700 | [diff] [blame] | 21 | #include <soc/gpio.h> |
Aaron Durbin | b0f8151 | 2016-07-25 21:31:41 -0500 | [diff] [blame] | 22 | #include <vendorcode/google/chromeos/chromeos.h> |
Duncan Laurie | afad056 | 2013-01-14 08:50:03 -0800 | [diff] [blame] | 23 | |
Aaron Durbin | 93a6665 | 2013-03-19 15:25:46 -0500 | [diff] [blame] | 24 | /* Compile-time settings for developer and recovery mode. */ |
| 25 | #define DEV_MODE_SETTING 1 |
| 26 | #define REC_MODE_SETTING 0 |
| 27 | |
Duncan Laurie | afad056 | 2013-01-14 08:50:03 -0800 | [diff] [blame] | 28 | #ifndef __PRE_RAM__ |
| 29 | #include <boot/coreboot_tables.h> |
Duncan Laurie | afad056 | 2013-01-14 08:50:03 -0800 | [diff] [blame] | 30 | |
Duncan Laurie | afad056 | 2013-01-14 08:50:03 -0800 | [diff] [blame] | 31 | void fill_lb_gpios(struct lb_gpios *gpios) |
| 32 | { |
Julius Werner | c445b4f | 2016-03-31 17:27:05 -0700 | [diff] [blame] | 33 | struct lb_gpio chromeos_gpios[] = { |
| 34 | {-1, ACTIVE_HIGH, 0, "write protect"}, |
| 35 | {-1, ACTIVE_HIGH, REC_MODE_SETTING, "recovery"}, |
| 36 | {-1, ACTIVE_HIGH, DEV_MODE_SETTING, "developer"}, |
| 37 | {-1, ACTIVE_HIGH, 1, "lid"}, // force open |
| 38 | {-1, ACTIVE_HIGH, 0, "power"}, |
| 39 | {-1, ACTIVE_HIGH, gfx_get_init_done(), "oprom"}, |
| 40 | }; |
| 41 | lb_add_gpios(gpios, chromeos_gpios, ARRAY_SIZE(chromeos_gpios)); |
Duncan Laurie | afad056 | 2013-01-14 08:50:03 -0800 | [diff] [blame] | 42 | } |
| 43 | #endif |
| 44 | |
| 45 | int get_developer_mode_switch(void) |
| 46 | { |
Aaron Durbin | 93a6665 | 2013-03-19 15:25:46 -0500 | [diff] [blame] | 47 | return DEV_MODE_SETTING; |
Duncan Laurie | afad056 | 2013-01-14 08:50:03 -0800 | [diff] [blame] | 48 | } |
| 49 | |
| 50 | int get_recovery_mode_switch(void) |
| 51 | { |
Aaron Durbin | 93a6665 | 2013-03-19 15:25:46 -0500 | [diff] [blame] | 52 | return REC_MODE_SETTING; |
Duncan Laurie | afad056 | 2013-01-14 08:50:03 -0800 | [diff] [blame] | 53 | } |
Aaron Durbin | 0df4de9 | 2013-03-01 17:38:59 -0600 | [diff] [blame] | 54 | |
| 55 | int get_write_protect_state(void) |
| 56 | { |
| 57 | return 0; |
| 58 | } |
Aaron Durbin | b0f8151 | 2016-07-25 21:31:41 -0500 | [diff] [blame] | 59 | |
| 60 | static const struct cros_gpio cros_gpios[] = { |
| 61 | CROS_GPIO_REC_AL(CROS_GPIO_VIRTUAL, CROS_GPIO_DEVICE_NAME), |
| 62 | CROS_GPIO_DEV_AL(CROS_GPIO_VIRTUAL, CROS_GPIO_DEVICE_NAME), |
| 63 | CROS_GPIO_WP_AL(CROS_GPIO_VIRTUAL, CROS_GPIO_DEVICE_NAME), |
| 64 | }; |
| 65 | |
| 66 | void mainboard_chromeos_acpi_generate(void) |
| 67 | { |
| 68 | chromeos_acpi_gpio_generate(cros_gpios, ARRAY_SIZE(cros_gpios)); |
| 69 | } |