Debian Codegraph @

src/superio/acpi/pnp_config.asl

raw
1 /* SPDX-License-Identifier: GPL-2.0-only */
2
3 /* ======== General PnP configuration functions ======= */
4
5 /*
6 * Controlled by the following preprocessor defines:
7 * PNP_ENTER_MAGIC_1ST If defined, specifies the first magic byte
8 * used to enter config mode.
9 * PNP_ENTER_MAGIC_2ND If defined, specifies the second magic byte
10 * used to enter config mode.
11 * PNP_ENTER_MAGIC_3RD If defined, specifies the third magic byte
12 * used to enter config mode.
13 * PNP_ENTER_MAGIC_4TH If defined, specifies the fourth magic byte
14 * used to enter config mode.
15 * PNP_EXIT_MAGIC_1ST If defined, specifies the first magic byte
16 * used to exit config mode.
17 * PNP_EXIT_SPECIAL_REG If defined, specifies a special register plus
18 * PNP_EXIT_SPECIAL_VAL a value to be written there to exit config mode.
19 */
20
21
22 /*
23 * Mutex for accesses to the configuration ports (prolog and
24 * epilog commands are used, so synchronization is useful)
25 */
26 Mutex(CONF_MODE_MUTEX, 1)
27
28 /*
29 * Enter configuration mode (and acquire mutex)
30 * Method must be run before accessing the configuration region.
31 * Parameter is the LDN which should be accessed. Values >= 0xFF mean
32 * no LDN switch should be done.
33 */
34 Method (ENTER_CONFIG_MODE, 1)
35 {
36 Acquire (CONF_MODE_MUTEX, 0xFFFF)
37 #ifdef PNP_ENTER_MAGIC_1ST
38 PNP_ADDR_REG = PNP_ENTER_MAGIC_1ST
39 #ifdef PNP_ENTER_MAGIC_2ND
40 PNP_ADDR_REG = PNP_ENTER_MAGIC_2ND
41 #ifdef PNP_ENTER_MAGIC_3RD
42 PNP_ADDR_REG = PNP_ENTER_MAGIC_3RD
43 #ifdef PNP_ENTER_MAGIC_4TH
44 PNP_ADDR_REG = PNP_ENTER_MAGIC_4TH
45 #endif
46 #endif
47 #endif
48 #endif
49 If (Arg0 < PNP_NO_LDN_CHANGE) {
50 PNP_LOGICAL_DEVICE = Arg0
51 }
52 }
53
54 /*
55 * Exit configuration mode (i.e. release mutex)
56 * Method must be run after accessing the configuration region.
57 */
58 Method (EXIT_CONFIG_MODE)
59 {
60 #ifdef PNP_EXIT_MAGIC_1ST
61 PNP_ADDR_REG = PNP_EXIT_MAGIC_1ST
62 #endif
63 #if defined(PNP_EXIT_SPECIAL_REG) && defined(PNP_EXIT_SPECIAL_VAL)
64 PNP_EXIT_SPECIAL_REG = PNP_EXIT_SPECIAL_VAL
65 #endif
66 Release (CONF_MODE_MUTEX)
67 }
68
69 /*
70 * Just change the LDN. Make sure that you are in config mode (or
71 * have otherwise acquired CONF_MODE_MUTEX), when calling.
72 */
73 Method (SWITCH_LDN, 1)
74 {
75 PNP_LOGICAL_DEVICE = Arg0
76 }