tree: drop last paragraph of GPL copyright header
[coreboot.git] / src / northbridge / amd / amdk8 / thermal_mixin.asl
blob97bc7604700931cc7914ef9bf8a337d8c2e8a03f
1 /*
2  * This file is part of the coreboot project.
3  *
4  * Copyright (C) 2011 Christoph Grenz <christophg+cb@grenz-bonn.de>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; version 2 of the License.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  */
17  * include this file into a mainboards DSDT inside the PCI device
18  * "K8 Miscellaneous Control" and it will expose the temperature
19  * sensors of the processor as thermal zones.
20  *
21  * If, for example, the K8 Misc. Control device is on 0:18.3, include the
22  * following inside the PCI0 device:
23  *
24  * Device(K8MC) {
25  *   Name (_ADR, 0x00180003)
26  *   #include northbridge/amd/amdk8/thermal_mixin.asl
27  * }
28  *
29  * Note: as only the current temperature and the trip temperature for
30  * "Software Thermal Control" are available in the PCI registers, but the
31  * linux driver for thermal zones needs a critical temperature value, a
32  * reasonable critical temperature is calculated by simply adding 6°C to
33  * the trip temperature.
34  *
35  * The used registers are documented in the "BIOS and Kernel Developer's
36  * Guide for AMD NPT Family 0Fh Processors"
37  * http://support.amd.com/us/Processor_TechDocs/32559.pdf
38  *
39  */
41 #ifndef K8TEMP_CRITICAL_ADD
42 # define K8TEMP_CRITICAL_ADD 6
43 #endif
45 OperationRegion(K8TR, PCI_Config, 0xE4, 0x4)
46 Field(K8TR, DWordAcc, NoLock, Preserve) {
47         ,     1,
48         THTP, 1, /* Temperature sensor trip occured */
49         CORE, 1, /* Select Core */
50         TTS0, 1, /* Temperature sensor trip on CPU1 (or single core CPU0) */
51         TTS1, 1, /* Temperature sensor trip on CPU0 */
52         TTEN, 1, /* Temperature sensor trip enabled */
53         PLAC, 1, /* Select Sensor */
54         ,     1,
55         DOFF, 6, /* Diode offset (signed 6bit-Integer) in °C */
56         TFRC, 2, /* Temperature fractions */
57         TVAL, 8, /* Temperature value in °C biased by -49 */
58         TJOF, 5,
59         ,     2,
60         SWTT, 1, /* Induce a thermtrip event (for diagnostic purposes) */
63 OperationRegion(K8ST, PCI_Config, 0x70, 0x1)
64 Field(K8ST, ByteAcc, NoLock, Preserve) {
65         TMAX, 5, /* Maximum temperature for software thermal control, in °C, biased by 52 */
68 /* Calculates temperature in tenths Kelvin from given TVAL and TFRC values */
69 Method(K8PT, 2) {
70         Divide(Multiply(Arg1, 5), 2, , Local0)
71         Return (Add(Multiply(Add(Arg0, 224),10), Local0))
74 /* Calculates the diode offset from a DOFF value */
75 Method(K8PO, 1) {
76         If (And(Arg0, 0x20))
77         {
78                 Return (Multiply(Subtract(Xor(Arg0, 0x3F), 1), 10))
79         }
80         Else {
81                 Return (Multiply(Arg0, 10))
82         }
85 ThermalZone (K8T0) {
86         Name(_HID, EisaId("PNP0C11"))
87         Name(_UID, "k8-0")
88         Name(_STR, Unicode("K8 compatible CPU Core 1 Thermal Sensor 1"))
90         Method(_STA) {
91                 Store(CORE, Local0)
92                 Store(PLAC, Local1)
94                 Store(Zero, CORE)
95                 Store(Zero, PLAC)
96                 If (LOr(PLAC, CORE)) {
97                         Store(Local0, CORE)
98                         Store(Local1, PLAC)
99                         Return (0x00)
100                 }
102                 If (LOr(LNot(TVAL), LEqual(TVAL, 0xFF))) {
103                         Return (0x00)
104                 }
106                 Store(Local0, CORE)
107                 Store(Local1, PLAC)
108                 Return (0x0F)
109         }
111         Method(_TMP) {
112                 Store(CORE, Local0)
113                 Store(PLAC, Local1)
115                 Store(Zero, CORE)
116                 Store(Zero, PLAC)
118                 Store (K8PT(TVAL, TFRC), Local2)
119                 Add (K8PO(DOFF), Local2, Local2)
120                 Store(Local0, CORE)
121                 Store(Local1, PLAC)
123                 Return (Local2)
124         }
126         Method(_CRT) {
127                 Add(TMAX, 325, Local0)
128                 Add(Local0, K8TEMP_CRITICAL_ADD, Local0)
129                 Return (Multiply(Local0, 10))
130         }
133 ThermalZone (K8T1) {
134         Name(_HID, EisaId("PNP0C11"))
135         Name(_UID, "k8-1")
136         Name(_STR, Unicode("K8 compatible CPU Core 1 Thermal Sensor 2"))
138         Name(_TZD, Package () {\_PR.CP00})
140         Method(_STA) {
141                 Store(CORE, Local0)
142                 Store(PLAC, Local1)
144                 Store(Zero, CORE)
145                 Store(Zero, PLAC)
146                 If (LOr(PLAC, CORE)) {
147                         Store(Local0, CORE)
148                         Store(Local1, PLAC)
149                         Return (0x00)
150                 }
152                 Store(One, PLAC)
153                 If (LOr(LNot(TVAL), LEqual(TVAL, 0xFF))) {
154                         Return (0x00)
155                 }
157                 Store(Local0, CORE)
158                 Store(Local1, PLAC)
159                 Return (0x0F)
160         }
162         Method(_TMP) {
163                 Store(CORE, Local0)
164                 Store(PLAC, Local1)
166                 Store(Zero, CORE)
167                 Store(One, PLAC)
169                 Store (K8PT(TVAL, TFRC), Local2)
170                 Add (K8PO(DOFF), Local2, Local2)
171                 Store(Local0, CORE)
172                 Store(Local1, PLAC)
174                 Return (Local2)
175         }
177         Method(_CRT) {
178                 Add(TMAX, 325, Local0)
179                 Add(Local0, K8TEMP_CRITICAL_ADD, Local0)
180                 Return (Multiply(Local0, 10))
181         }
184 ThermalZone (K8T2) {
185         Name(_HID, EisaId("PNP0C11"))
186         Name(_UID, "k8-2")
187         Name(_STR, Unicode("K8 compatible CPU Core 2 Thermal Sensor 1"))
189         Name(_TZD, Package () {\_PR.CP00})
191         Method(_STA) {
192                 Store(CORE, Local0)
193                 Store(PLAC, Local1)
195                 Store(Zero, CORE)
196                 Store(Zero, PLAC)
197                 If (LOr(PLAC, CORE)) {
198                         Store(Local0, CORE)
199                         Store(Local1, PLAC)
200                         Return (0x00)
201                 }
203                 Store(One, CORE)
204                 If (LOr(LNot(TVAL), LEqual(TVAL, 0xFF))) {
205                         Return (0x00)
206                 }
208                 Store(Local0, CORE)
209                 Store(Local1, PLAC)
210                 Return (0x0F)
211         }
213         Method(_TMP) {
214                 Store(CORE, Local0)
215                 Store(PLAC, Local1)
217                 Store(One, CORE)
218                 Store(Zero, PLAC)
220                 Store (K8PT(TVAL, TFRC), Local2)
221                 Add (K8PO(DOFF), Local2, Local2)
222                 Store(Local0, CORE)
223                 Store(Local1, PLAC)
225                 Return (Local2)
226         }
228         Method(_CRT) {
229                 Add(TMAX, 325, Local0)
230                 Add(Local0, K8TEMP_CRITICAL_ADD, Local0)
231                 Return (Multiply(Local0, 10))
232         }
235 ThermalZone (K8T3) {
236         Name(_HID, EisaId("PNP0C11"))
237         Name(_UID, "k8-3")
238         Name(_STR, Unicode("K8 compatible CPU Core 2 Thermal Sensor 2"))
240         Name(_TZD, Package () {\_PR.CP00})
242         Method(_STA) {
243                 Store(CORE, Local0)
244                 Store(PLAC, Local1)
246                 Store(Zero, CORE)
247                 Store(Zero, PLAC)
248                 If (LOr(PLAC, CORE)) {
249                         Store(Local0, CORE)
250                         Store(Local1, PLAC)
251                         Return (0x00)
252                 }
254                 Store(One, CORE)
255                 Store(One, PLAC)
256                 If (LOr(LNot(TVAL), LEqual(TVAL, 0xFF))) {
257                         Return (0x00)
258                 }
260                 Store(Local0, CORE)
261                 Store(Local1, PLAC)
262                 Return (0x0F)
263         }
265         Method(_TMP) {
266                 Store(CORE, Local0)
267                 Store(PLAC, Local1)
269                 Store(One, CORE)
270                 Store(One, PLAC)
272                 Store (K8PT(TVAL, TFRC), Local2)
273                 Add (K8PO(DOFF), Local2, Local2)
274                 Store(Local0, CORE)
275                 Store(Local1, PLAC)
277                 Return (Local2)
278         }
280         Method(_CRT) {
281                 Add(TMAX, 325, Local0)
282                 Add(Local0, K8TEMP_CRITICAL_ADD, Local0)
283                 Return (Multiply(Local0, 10))
284         }