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. |
Nico Huber | ae7c968 | 2013-05-23 18:13:23 +0200 | [diff] [blame] | 15 | */ |
| 16 | |
| 17 | /* ======== General PnP configuration functions ======= */ |
| 18 | |
| 19 | /* |
| 20 | * Controlled by the following preprocessor defines: |
| 21 | * PNP_ENTER_MAGIC_1ST If defined, specifies the first magic byte |
| 22 | * used to enter config mode. |
| 23 | * PNP_ENTER_MAGIC_2ND If defined, specifies the second magic byte |
| 24 | * used to enter config mode. |
| 25 | * PNP_ENTER_MAGIC_3RD If defined, specifies the third magic byte |
| 26 | * used to enter config mode. |
| 27 | * PNP_EXIT_MAGIC_1ST If defined, specifies the first magic byte |
| 28 | * used to exit config mode. |
| 29 | */ |
| 30 | |
| 31 | |
| 32 | /* |
| 33 | * Mutex for accesses to the configuration ports (prolog and |
| 34 | * epilog commands are used, so synchronization is useful) |
| 35 | */ |
| 36 | Mutex(CONFIG_MODE_MUTEX, 1) |
| 37 | |
| 38 | /* |
| 39 | * Enter configuration mode (and aquire mutex) |
| 40 | * Method must be run before accesssing the configuration region. |
| 41 | * Parameter is the LDN which should be accessed. Values >= 0xFF mean |
| 42 | * no LDN switch should be done. |
| 43 | */ |
| 44 | Method (ENTER_CONFIG_MODE, 1) |
| 45 | { |
| 46 | Acquire (CONFIG_MODE_MUTEX, 0xFFFF) |
| 47 | #ifdef PNP_ENTER_MAGIC_1ST |
| 48 | Store (PNP_ENTER_MAGIC_1ST, PNP_ADDR_REG) |
| 49 | #ifdef PNP_ENTER_MAGIC_2ND |
| 50 | Store (PNP_ENTER_MAGIC_2ND, PNP_ADDR_REG) |
| 51 | #ifdef PNP_ENTER_MAGIC_3RD |
| 52 | Store (PNP_ENTER_MAGIC_3RD, PNP_ADDR_REG) |
| 53 | #endif |
| 54 | #endif |
| 55 | #endif |
| 56 | If (LLess(Arg0, PNP_NO_LDN_CHANGE)) { |
| 57 | Store(Arg0, PNP_LOGICAL_DEVICE) |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | /* |
| 62 | * Exit configuration mode (i.e. release mutex) |
| 63 | * Method must be run after accessing the configuration region. |
| 64 | */ |
| 65 | Method (EXIT_CONFIG_MODE) |
| 66 | { |
| 67 | #ifdef PNP_EXIT_MAGIC_1ST |
| 68 | Store (PNP_EXIT_MAGIC_1ST, PNP_ADDR_REG) |
| 69 | #endif |
| 70 | Release (CONFIG_MODE_MUTEX) |
| 71 | } |
| 72 | |
| 73 | /* |
| 74 | * Just change the LDN. Make sure that you are in config mode (or |
| 75 | * have otherwise acquired CONFIG_MODE_MUTEX), when calling. |
| 76 | */ |
| 77 | Method (SWITCH_LDN, 1) |
| 78 | { |
| 79 | Store(Arg0, PNP_LOGICAL_DEVICE) |
| 80 | } |