tree: drop last paragraph of GPL copyright header
[coreboot.git] / src / mainboard / asus / kfsn4-dre / acpi / pm_ctrl.asl
blob4cf8503687234863ddb1564607aca69391b17763
1 /*
2  * This file is part of the coreboot project.
3  *
4  * Copyright (C) 2015 Timothy Pearson <tpearson@raptorengineeringinc.com>, Raptor Engineering
5  * Copyright (C) 2010 - 2012 Advanced Micro Devices, Inc.
6  * Copyright (C) 2004 Nick Barker <Nick.Barker9@btinternet.com>
7  * Copyright (C) 2007, 2008 Rudolf Marek <r.marek@assembler.cz>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; version 2 of the License.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  */
20  * WARNING: Sleep/Wake is a work in progress and is still somewhat flaky!
21  */
23         /* SuperIO control port */
24         Name (SPIO, 0x2E)
26         /* SuperIO control map */
27         OperationRegion (SPIM, SystemIO, SPIO, 0x02)
28                 Field (SPIM, ByteAcc, NoLock, Preserve) {
29                 INDX, 8,
30                 DATA, 8
31         }
33         /* SuperIO control registers */
34         IndexField (INDX, DATA, ByteAcc, NoLock, Preserve) {
35                 Offset (0x07),
36                 CR07, 8,                /* Logical device number */
37                 Offset (0x2C),
38                 CR2C, 8,                /* GPIO3 multiplexed pin selection */
39                 Offset (0x30),
40                 CR30, 8,                /* Logical device activation control register */
41                 Offset (0xE0),
42                 CRE0, 8,                /* Wake control register */
43                 Offset (0xE6),
44                 CRE6, 8,                /* Mouse wake event configuration register */
45                 Offset (0xF1),
46                 CRF1, 8,                /* GPIO3 data register */
47                 Offset (0xF3),
48                 CRF3, 8,                /* SUSLED mode register */
49                 Offset (0xF6),
50                 CRF6, 8,                /* SMI/PME event generation control register */
51                 Offset (0xF9),
52                 CRF9, 8,                /* ACPI PME configuration register */
53         }
55         /* Southbridge control ports */
56         /* Both are offsets from PM base address (0x2000) */
57         Name (SBC1, 0x2090)     /* Offset 0x90 */
58         Name (SBC2, 0x2400)     /* Offset 0x400 */
60         /* Southbridge control maps */
61         OperationRegion (SBM1, SystemIO, SBC1, 0x10)
62                 Field (SBM1, ByteAcc, NoLock, Preserve) {
63                 S1CT, 2,
64                 Offset (0x04),
65                 S3CT, 2,
66                 Offset (0x08),
67                 S4CT, 2,
68                 Offset (0x0C),
69                 S5CT, 2,
70         }
71         OperationRegion (SBM2, SystemIO, SBC2, 0x08)
72                 Field (SBM2, ByteAcc, NoLock, Preserve) {
73                 , 15,
74                 PS1S, 1,
75                 , 31,
76                 PS1E, 1,
77         }
79         /* Wake status package */
80         Name(WKST,Package(){Zero, Zero})
82         /*
83         *  \_WAK System Wake method
84         *
85         *       Entry:
86         *               Arg0=The value of the sleeping state S1=1, S2=2
87         *
88         *       Exit:
89         *               Return package of 2 DWords
90         *               Dword 1 - Status
91         *                       0x00000000      wake succeeded
92         *                       0x00000001      Wake was signaled but failed due to lack of power
93         *                       0x00000002      Wake was signaled but failed due to thermal condition
94         *               Dword 2 - Power Supply state
95         *                       if non-zero the effective S-state the power supply entered
96         */
97         Method(\_WAK, 1) {
98                 /* Set up LEDs */
99                 /* Access SuperIO GPIO3/GPIO4 device */
100                 Store(0x87, INDX)
101                 Store(0x87, INDX)
102                 Store(0x09, CR07)
104                 /* Set GPIO3 pin 64 (power LED) to GP37 mode */
105                 And(CR2C, 0xF3, Local0)
106                 Or(Local0, 0x04, CR2C)
108                 /* Set power LED to steady on */
109                 Or(CRF1, 0x80, CRF1)
111                 /* Restore default SuperIO access */
112                 Store(0xAA, INDX)
114                 /* Configure SuperIO for wake */
115                 /* Access SuperIO ACPI device */
116                 Store(0x87, INDX)
117                 Store(0x87, INDX)
118                 Store(0x0A, CR07)
120                 if (LEqual(Arg0, One))  /* Resuming from power state S1 */
121                 {
122                         /* Set power management to SMI mode and disable SMI events */
123                         And(CRF9, 0xFA, CRF9)
125                         /* Deactivate the ACPI device */
126                         Store(Zero, CR30)
128                         /* Disable PS/2 SMI/PME events */
129                         And(CRF6, 0xCF, CRF6)
130                 }
131                 if (Lor(LEqual(Arg0, 0x03), LEqual(Arg0, 0x04)))        /* Resuming from power state S3 or S4 */
132                 {
133                         /* Disable PS/2 wake */
134                         And(CRE0, 0x1D, CRE0)
135                         And(CRE6, 0x7F, CRE6)
136                 }
138                 /* Restore default SuperIO access */
139                 Store(0xAA, INDX)
141                 /* Configure southbridge for wake */
142                 Store(Zero, PS1E)
143                 Store(0x02, S1CT)
144                 Store(0x02, S3CT)
145                 Store(0x02, S4CT)
146                 Store(0x02, S5CT)
147                 Notify(\_SB.PWRB, 0x02)                 /* NOTIFY_DEVICE_WAKE */
149                 Return(WKST)
150         } /* End Method(\_WAK) */
152         /*
153         * \_PTS - Prepare to Sleep method
154         *
155         *       Entry:
156         *               Arg0=The value of the sleeping state S1=1, S2=2, etc
157         *
158         * Exit:
159         *               -none-
160         *
161         * The _PTS control method is executed at the beginning of the sleep process
162         * for S1-S5. The sleeping value is passed to the _PTS control method.   This
163         * control method may be executed a relatively long time before entering the
164         * sleep state and the OS may abort the operation without notification to
165         * the ACPI driver.  This method cannot modify the configuration or power
166         * state of any device in the system.
167         */
168         Method(\_PTS, 1) {
169                 /* Set up LEDs */
170                 if (LEqual(Arg0, One))  /* Power state S1 requested */
171                 {
172                         /* Access SuperIO GPIO3/GPIO4 device */
173                         Store(0x87, INDX)
174                         Store(0x87, INDX)
175                         Store(0x09, CR07)
177                         /* Set GPIO3 pin 64 (power LED) to SUSLED mode */
178                         And(CR2C, 0xF3, CR2C)
180                         /* Set suspend LED to 1Hz toggle pulse with 50% duty cycle */
181                         Or(CRF3, 0x80, CRF3)
183                         /* Restore default SuperIO access */
184                         Store(0xAA, INDX)
185                 }
187                 /* Configure SuperIO for sleep */
188                 /* Access SuperIO ACPI device */
189                 Store(0x87, INDX)
190                 Store(0x87, INDX)
191                 Store(0x0A, CR07)
193                 /* Disable PS/2 wakeup and connect PANSW_IN to PANSW_OUT */
194                 And(CRE0, 0x1F, CRE0)
196                 if (LEqual(Arg0, One))  /* Power state S1 requested */
197                 {
198                         /* Set power management to PME mode and enable PME events */
199                         Or(CRF9, 0x05, CRF9)
201                         /* Activate the ACPI device */
202                         Store(One, CR30)
204                         /* Enable PS/2 keyboard SMI/PME events */
205                         And(CRF6, 0xEF, CRF6)
207                         /* Enable PS/2 keyboard wake */
208                         Or(CRE0, 0x40, CRE0)
210                         /* Enable PS/2 mouse SMI/PME events */
211                         And(CRF6, 0xDF, CRF6)
213                         /* Enable PS/2 mouse wake  */
214                         Or(CRE0, 0x20, CRE0)
215                 }
216                 else {
217                         /* Enable PS/2 keyboard wake on any keypress */
218                         Or(CRE0, 0x41, CRE0)
220                         /* Enable PS/2 mouse wake on any click  */
221                         Or(CRE0, 0x22, CRE0)
222                         Or(CRE6, 0x80, CRE6)
223                 }
225                 /* Restore default SuperIO access */
226                 Store(0xAA, INDX)
228                 /* Configure southbridge for sleep */
229                 Store(One, PS1S)
230                 Store(One, PS1E)
232                 /* On older chips, clear PciExpWakeDisEn */
233                 /*if (LLessEqual(\_SB.SBRI, 0x13)) {
234                 *       Store(0,\_SB.PWDE)
235                 *}
236                 */
238                 /* Clear wake status structure. */
239                 Store(0, Index(WKST,0))
240                 Store(0, Index(WKST,1))
241         } /* End Method(\_PTS) */