blob: abebb6e933eec7f2e5ec08f4bfc4105f9017f618 [file] [log] [blame]
Nico Huberae7c9682013-05-23 18:13:23 +02001/*
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 Huberae7c9682013-05-23 18:13:23 +020015 */
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 Huber21707cc2016-09-30 11:51:04 +020027 * PNP_ENTER_MAGIC_4TH If defined, specifies the fourth magic byte
28 * used to enter config mode.
Nico Huberae7c9682013-05-23 18:13:23 +020029 * PNP_EXIT_MAGIC_1ST If defined, specifies the first magic byte
30 * used to exit config mode.
Nico Huber21707cc2016-09-30 11:51:04 +020031 * 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 Huberae7c9682013-05-23 18:13:23 +020033 */
34
35
36/*
37 * Mutex for accesses to the configuration ports (prolog and
38 * epilog commands are used, so synchronization is useful)
39 */
Elyes HAOUAS251514d2019-01-23 11:36:44 +010040Mutex(CONF_MODE_MUTEX, 1)
Nico Huberae7c9682013-05-23 18:13:23 +020041
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 */
48Method (ENTER_CONFIG_MODE, 1)
49{
Elyes HAOUAS251514d2019-01-23 11:36:44 +010050 Acquire (CONF_MODE_MUTEX, 0xFFFF)
Nico Huberae7c9682013-05-23 18:13:23 +020051#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 Huber21707cc2016-09-30 11:51:04 +020057#ifdef PNP_ENTER_MAGIC_4TH
58 Store (PNP_ENTER_MAGIC_4TH, PNP_ADDR_REG)
59#endif
Nico Huberae7c9682013-05-23 18:13:23 +020060#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 */
72Method (EXIT_CONFIG_MODE)
73{
74#ifdef PNP_EXIT_MAGIC_1ST
75 Store (PNP_EXIT_MAGIC_1ST, PNP_ADDR_REG)
76#endif
Nico Huber21707cc2016-09-30 11:51:04 +020077#if defined(PNP_EXIT_SPECIAL_REG) && defined(PNP_EXIT_SPECIAL_VAL)
78 Store (PNP_EXIT_SPECIAL_VAL, PNP_EXIT_SPECIAL_REG)
79#endif
Elyes HAOUAS251514d2019-01-23 11:36:44 +010080 Release (CONF_MODE_MUTEX)
Nico Huberae7c9682013-05-23 18:13:23 +020081}
82
83/*
84 * Just change the LDN. Make sure that you are in config mode (or
Elyes HAOUAS251514d2019-01-23 11:36:44 +010085 * have otherwise acquired CONF_MODE_MUTEX), when calling.
Nico Huberae7c9682013-05-23 18:13:23 +020086 */
87Method (SWITCH_LDN, 1)
88{
89 Store(Arg0, PNP_LOGICAL_DEVICE)
90}