Nico Huber | ae7c968 | 2013-05-23 18:13:23 +0200 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2011 Christoph Grenz <christophg+cb@grenz-bonn.de> |
| 5 | * Copyright (C) 2013 secunet Security Networks AG |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by |
| 9 | * the Free Software Foundation; version 2 of the License. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this program; if not, write to the Free Software |
| 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 19 | */ |
| 20 | |
| 21 | /* ======== General PnP configuration functions ======= */ |
| 22 | |
| 23 | /* |
| 24 | * Controlled by the following preprocessor defines: |
| 25 | * PNP_ENTER_MAGIC_1ST If defined, specifies the first magic byte |
| 26 | * used to enter config mode. |
| 27 | * PNP_ENTER_MAGIC_2ND If defined, specifies the second magic byte |
| 28 | * used to enter config mode. |
| 29 | * PNP_ENTER_MAGIC_3RD If defined, specifies the third magic byte |
| 30 | * used to enter config mode. |
| 31 | * PNP_EXIT_MAGIC_1ST If defined, specifies the first magic byte |
| 32 | * used to exit config mode. |
| 33 | */ |
| 34 | |
| 35 | |
| 36 | /* |
| 37 | * Mutex for accesses to the configuration ports (prolog and |
| 38 | * epilog commands are used, so synchronization is useful) |
| 39 | */ |
| 40 | Mutex(CONFIG_MODE_MUTEX, 1) |
| 41 | |
| 42 | /* |
| 43 | * Enter configuration mode (and aquire mutex) |
| 44 | * Method must be run before accesssing the configuration region. |
| 45 | * Parameter is the LDN which should be accessed. Values >= 0xFF mean |
| 46 | * no LDN switch should be done. |
| 47 | */ |
| 48 | Method (ENTER_CONFIG_MODE, 1) |
| 49 | { |
| 50 | Acquire (CONFIG_MODE_MUTEX, 0xFFFF) |
| 51 | #ifdef PNP_ENTER_MAGIC_1ST |
| 52 | Store (PNP_ENTER_MAGIC_1ST, PNP_ADDR_REG) |
| 53 | #ifdef PNP_ENTER_MAGIC_2ND |
| 54 | Store (PNP_ENTER_MAGIC_2ND, PNP_ADDR_REG) |
| 55 | #ifdef PNP_ENTER_MAGIC_3RD |
| 56 | Store (PNP_ENTER_MAGIC_3RD, PNP_ADDR_REG) |
| 57 | #endif |
| 58 | #endif |
| 59 | #endif |
| 60 | If (LLess(Arg0, PNP_NO_LDN_CHANGE)) { |
| 61 | Store(Arg0, PNP_LOGICAL_DEVICE) |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | /* |
| 66 | * Exit configuration mode (i.e. release mutex) |
| 67 | * Method must be run after accessing the configuration region. |
| 68 | */ |
| 69 | Method (EXIT_CONFIG_MODE) |
| 70 | { |
| 71 | #ifdef PNP_EXIT_MAGIC_1ST |
| 72 | Store (PNP_EXIT_MAGIC_1ST, PNP_ADDR_REG) |
| 73 | #endif |
| 74 | Release (CONFIG_MODE_MUTEX) |
| 75 | } |
| 76 | |
| 77 | /* |
| 78 | * Just change the LDN. Make sure that you are in config mode (or |
| 79 | * have otherwise acquired CONFIG_MODE_MUTEX), when calling. |
| 80 | */ |
| 81 | Method (SWITCH_LDN, 1) |
| 82 | { |
| 83 | Store(Arg0, PNP_LOGICAL_DEVICE) |
| 84 | } |