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. |
Nico Huber | 21707cc | 2016-09-30 11:51:04 +0200 | [diff] [blame] | 27 | * PNP_ENTER_MAGIC_4TH If defined, specifies the fourth magic byte |
| 28 | * used to enter config mode. |
Nico Huber | ae7c968 | 2013-05-23 18:13:23 +0200 | [diff] [blame] | 29 | * PNP_EXIT_MAGIC_1ST If defined, specifies the first magic byte |
| 30 | * used to exit config mode. |
Nico Huber | 21707cc | 2016-09-30 11:51:04 +0200 | [diff] [blame] | 31 | * PNP_EXIT_SPECIAL_REG If defined, specifies a special register plus |
| 32 | * PNP_EXIT_SPECIAL_VAL a value to be written there to exit config mode. |
Nico Huber | ae7c968 | 2013-05-23 18:13:23 +0200 | [diff] [blame] | 33 | */ |
| 34 | |
| 35 | |
| 36 | /* |
| 37 | * Mutex for accesses to the configuration ports (prolog and |
| 38 | * epilog commands are used, so synchronization is useful) |
| 39 | */ |
Elyes HAOUAS | 251514d | 2019-01-23 11:36:44 +0100 | [diff] [blame] | 40 | Mutex(CONF_MODE_MUTEX, 1) |
Nico Huber | ae7c968 | 2013-05-23 18:13:23 +0200 | [diff] [blame] | 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 | { |
Elyes HAOUAS | 251514d | 2019-01-23 11:36:44 +0100 | [diff] [blame] | 50 | Acquire (CONF_MODE_MUTEX, 0xFFFF) |
Nico Huber | ae7c968 | 2013-05-23 18:13:23 +0200 | [diff] [blame] | 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) |
Nico Huber | 21707cc | 2016-09-30 11:51:04 +0200 | [diff] [blame] | 57 | #ifdef PNP_ENTER_MAGIC_4TH |
| 58 | Store (PNP_ENTER_MAGIC_4TH, PNP_ADDR_REG) |
| 59 | #endif |
Nico Huber | ae7c968 | 2013-05-23 18:13:23 +0200 | [diff] [blame] | 60 | #endif |
| 61 | #endif |
| 62 | #endif |
| 63 | If (LLess(Arg0, PNP_NO_LDN_CHANGE)) { |
| 64 | Store(Arg0, PNP_LOGICAL_DEVICE) |
| 65 | } |
| 66 | } |
| 67 | |
| 68 | /* |
| 69 | * Exit configuration mode (i.e. release mutex) |
| 70 | * Method must be run after accessing the configuration region. |
| 71 | */ |
| 72 | Method (EXIT_CONFIG_MODE) |
| 73 | { |
| 74 | #ifdef PNP_EXIT_MAGIC_1ST |
| 75 | Store (PNP_EXIT_MAGIC_1ST, PNP_ADDR_REG) |
| 76 | #endif |
Nico Huber | 21707cc | 2016-09-30 11:51:04 +0200 | [diff] [blame] | 77 | #if defined(PNP_EXIT_SPECIAL_REG) && defined(PNP_EXIT_SPECIAL_VAL) |
| 78 | Store (PNP_EXIT_SPECIAL_VAL, PNP_EXIT_SPECIAL_REG) |
| 79 | #endif |
Elyes HAOUAS | 251514d | 2019-01-23 11:36:44 +0100 | [diff] [blame] | 80 | Release (CONF_MODE_MUTEX) |
Nico Huber | ae7c968 | 2013-05-23 18:13:23 +0200 | [diff] [blame] | 81 | } |
| 82 | |
| 83 | /* |
| 84 | * Just change the LDN. Make sure that you are in config mode (or |
Elyes HAOUAS | 251514d | 2019-01-23 11:36:44 +0100 | [diff] [blame] | 85 | * have otherwise acquired CONF_MODE_MUTEX), when calling. |
Nico Huber | ae7c968 | 2013-05-23 18:13:23 +0200 | [diff] [blame] | 86 | */ |
| 87 | Method (SWITCH_LDN, 1) |
| 88 | { |
| 89 | Store(Arg0, PNP_LOGICAL_DEVICE) |
| 90 | } |