summaryrefslogtreecommitdiff
path: root/ReferenceCode/AcpiTables/Dptf/AcpiTables/B0d4CtdpPolicy.asl
blob: 553612f0e2f20b2bfe4a766936031eec549d3f2e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
/*++
  This file contains an 'Intel Peripheral Driver' and uniquely  
  identified as "Intel Reference Module" and is                 
  licensed for Intel CPUs and chipsets under the terms of your  
  license agreement with Intel or your vendor.  This file may   
  be modified by the user, subject to additional terms of the   
  license agreement                                             
--*/

/*++

Copyright (c) 1999 - 2013Intel Corporation. All rights reserved
This software and associated documentation (if any) is furnished
under a license and may only be used or copied in accordance
with the terms of the license. Except as permitted by such
license, no part of this software or documentation may be
reproduced, stored in a retrieval system, or transmitted in any
form or by any means without the express written consent of
Intel Corporation.

Module Name:

  B0d4CtdpPolicy.asl

Abstract:

  Intel ACPI Reference Code for Intel Configurable TDP

--*/


Scope(\_SB.IETM)
{
   Name (CTSP, Package ()
    {
    //
    // ConfigTDP Policy
    //
      ToUUID("E145970A-E4C1-4d73-900E-C9C5A69DD067")
    })
}

Scope(\_SB.PCI0.B0D4)
{
    // TDPL (Thermal Design Power List)
    //
    // Returns the list of all supported Configurable TDP points available for the participant device.
    //
    // Arguments: (0)
    //   None
    // Return Value:
    //   Package () // Zeroth TDP State
    //   {
    //     TDPPower, // DWordConst
    //     Frequency, // DWordConst
    //     TDPControl, // DWordConst
    //     FrequencyControl, // DWordConst
    //     Reserved1, // DWordConst
    //   },
    //     .
    //     .
    //     .
    //   Package () // Last TDP State
    //   {
    //     TDPPower, // DWordConst
    //     Frequency, // DWordConst
    //     TDPControl, // DWordConst
    //     FrequencyControl, // DWordConst
    //     Reserved1, // DWordConst
    //   }
    //	
    Method(TDPL,,,,PkgObj)
    {
        Name(AAAA,0) // PACKAGE_POWER_SKU
        Name(BBBB,0) // CONFIG_TDP_LEVEL1 
        Name(CCCC,0) // CONFIG_TDP_LEVEL2
        Name(PPUU,0)  // PACKAGE_POWER_SKU_UNIT

        Store(CTNL, Local0)  // CONFIG_TDP_NUM_LEVELS
        If(LOr(LEqual(Local0,1),LEqual(Local0,2))){ // check for CTDP support
          Store(\_PR.CLVL,Local0)  // use PPM supplied value for CTDP level
        }
        Else{
          Return(Package (){0}) // no CTDP support
        }

        If(LEqual(CLCK,1)){  // check the CONFIG_TDP_LOCK bit 
          Store(1,Local0)
        }

        Store(CPNU(\_PR.PL10,1),AAAA)  // convert Custom 0 Power Limit1 to milliwatts
        Store(CPNU(\_PR.PL11,1),BBBB)  // convert Custom 1 Power Limit1 to milliwatts
        Store(CPNU(\_PR.PL12,1),CCCC)  // convert Custom 2 Power Limit1 to milliwatts

        //
        // Define a package of packages that contain 5 DWords.
        //
        Name (TMP1, Package (1){
            Package (){0x80000000,0x80000000,0x80000000,0x80000000,0x80000000}
        })
        Name (TMP2, Package (2){
            Package (){0x80000000,0x80000000,0x80000000,0x80000000,0x80000000},
            Package (){0x80000000,0x80000000,0x80000000,0x80000000,0x80000000}
        })
        Name (TMP3, Package (3){
            Package (){0x80000000,0x80000000,0x80000000,0x80000000,0x80000000},
            Package (){0x80000000,0x80000000,0x80000000,0x80000000,0x80000000},
            Package (){0x80000000,0x80000000,0x80000000,0x80000000,0x80000000}
        })

        //
        // if 3 TDP's, use PL0, PL1 and PL2 values
        //
        If(LEqual(Local0,3)){
          If (LGreater(AAAA,BBBB)){
            If (LGreater(AAAA,CCCC)){
              If (LGreater(BBBB,CCCC)){
                // abc
                Store(0,Local3)
                Store(0,LEV0)
                Store(1,Local4)
                Store(1,LEV1)
                Store(2,Local5)
                Store(2,LEV2)
                }Else{
                // acb
                Store(0,Local3)
                Store(0,LEV0)
                Store(1,Local5)
                Store(2,LEV1)
                Store(2,Local4)
                Store(1,LEV2)
              }
            }Else{
              // cab
              Store(0,Local5)
              Store(2,LEV0)
              Store(1,Local3)
              Store(0,LEV1)
              Store(2,Local4)
              Store(1,LEV2)
            }
          }Else{  // b > a here
            If(LGreater(BBBB,CCCC)){
              If(LGreater(AAAA,CCCC)){
                // bac
                Store(0,Local4)
                Store(1,LEV0)
                Store(1,Local3)
                Store(0,LEV1)
                Store(2,Local5)
                Store(2,LEV2)
              }Else{
                // bca
                Store(0,Local4)
                Store(1,LEV0)
                Store(1,Local5)
                Store(2,LEV1)
                Store(2,Local3)
                Store(0,LEV2)
              }
            }Else{
              // cba
              Store(0,Local5)
              Store(2,LEV0)
              Store(1,Local4)
              Store(1,LEV1)
              Store(2,Local3)
              Store(0,LEV2)
            }
          }

          // copy for PL0
          Store(Add(\_PR.TAR0,1),Local1)
          Multiply(Local1,100,Local2)
          Store(AAAA,Index(DeRefOf(Index(TMP3, Local3)),0))
          Store(Local2,Index(DeRefOf(Index(TMP3, Local3)),1))
          Store(\_PR.CTC0,Index(DeRefOf(Index(TMP3, Local3)),2))
          Store(Local1,Index(DeRefOf(Index(TMP3, Local3)),3))
          Store(0,Index(DeRefOf(Index(TMP3, Local3)),4))

          // copy for PL1
          Store(Add(\_PR.TAR1,1),Local1)
          Multiply(Local1,100,Local2)
          Store(BBBB,Index(DeRefOf(Index(TMP3, Local4)),0))
          Store(Local2,Index(DeRefOf(Index(TMP3, Local4)),1))
          Store(\_PR.CTC1,Index(DeRefOf(Index(TMP3, Local4)),2))
          Store(Local1,Index(DeRefOf(Index(TMP3, Local4)),3))
          Store(0,Index(DeRefOf(Index(TMP3, Local4)),4))

          // copy for PL2
          Store(Add(\_PR.TAR2,1),Local1)
          Multiply(Local1,100,Local2)
          Store(CCCC,Index(DeRefOf(Index(TMP3, Local5)),0))
          Store(Local2,Index(DeRefOf(Index(TMP3, Local5)),1))
          Store(\_PR.CTC2,Index(DeRefOf(Index(TMP3, Local5)),2))
          Store(Local1,Index(DeRefOf(Index(TMP3, Local5)),3))
          Store(0,Index(DeRefOf(Index(TMP3, Local5)),4))

          Return(TMP3)
        }

        //
        // if 2 TDP's, use PL0 and PL1 values
        //
        If(LEqual(Local0,2)){
          If(LGreater(AAAA,BBBB)){
            Store(0,Local3) // store PL0 in Zeroth package
            Store(1,Local4) // store PL1 in next package
            Store(0,LEV0)
            Store(1,LEV1)
            Store(0,LEV2) // level 2 is not used so put 0 for safety 
          }Else{
            Store(0,Local4) // store PL1 in Zeroth package
            Store(1,Local3) // store PL0 in next package
            Store(1,LEV0)
            Store(0,LEV1)
            Store(0,LEV2) // level 2 is not used so put 0 for safety 
          }

          // copy for PL0
          Store(Add(\_PR.TAR0,1),Local1)
          Multiply(Local1,100,Local2)
          Store(AAAA,Index(DeRefOf(Index(TMP2, Local3)),0))
          Store(Local2,Index(DeRefOf(Index(TMP2, Local3)),1))
          Store(\_PR.CTC0,Index(DeRefOf(Index(TMP2, Local3)),2))
          Store(Local1,Index(DeRefOf(Index(TMP2, Local3)),3))
          Store(0,Index(DeRefOf(Index(TMP2, Local3)),4))

          // copy for PL1
          Store(Add(\_PR.TAR1,1),Local1)
          Multiply(Local1,100,Local2)
          Store(BBBB,Index(DeRefOf(Index(TMP2, Local4)),0))
          Store(Local2,Index(DeRefOf(Index(TMP2, Local4)),1))
          Store(\_PR.CTC1,Index(DeRefOf(Index(TMP2, Local4)),2))
          Store(Local1,Index(DeRefOf(Index(TMP2, Local4)),3))
          Store(0,Index(DeRefOf(Index(TMP2, Local4)),4))

          Return(TMP2)
        }

        //
        // if 1 TDP, return one PL based on boot index
        //
        If(LEqual(Local0,1)){
          Switch(ToInteger(\_PR.CBMI)){
            case(0){
              // copy for PL0
              Store(Add(\_PR.TAR0,1),Local1)
              Multiply(Local1,100,Local2)
              Store(AAAA,Index(DeRefOf(Index(TMP1, 0)),0))
              Store(Local2,Index(DeRefOf(Index(TMP1, 0)),1))
              Store(\_PR.CTC0,Index(DeRefOf(Index(TMP1, 0)),2))
              Store(Local1,Index(DeRefOf(Index(TMP1, 0)),3))
              Store(0,Index(DeRefOf(Index(TMP1, 0)),4))
              Store(0,LEV0)
              Store(0,LEV1)
              Store(0,LEV2)
            }
  
            case(1){
              // copy for PL1
              Store(Add(\_PR.TAR1,1),Local1)
              Multiply(Local1,100,Local2)
              Store(BBBB,Index(DeRefOf(Index(TMP1, 0)),0))
              Store(Local2,Index(DeRefOf(Index(TMP1, 0)),1))
              Store(\_PR.CTC1,Index(DeRefOf(Index(TMP1, 0)),2))
              Store(Local1,Index(DeRefOf(Index(TMP1, 0)),3))
              Store(0,Index(DeRefOf(Index(TMP1, 0)),4))
              Store(1,LEV0)
              Store(1,LEV1)
              Store(1,LEV2)
            }
    
            case(2){
              // copy for PL2
              Store(Add(\_PR.TAR2,1),Local1)
              Multiply(Local1,100,Local2)
              Store(CCCC,Index(DeRefOf(Index(TMP1, 0)),0))
              Store(Local2,Index(DeRefOf(Index(TMP1, 0)),1))
              Store(\_PR.CTC2,Index(DeRefOf(Index(TMP1, 0)),2))
              Store(Local1,Index(DeRefOf(Index(TMP1, 0)),3))
              Store(0,Index(DeRefOf(Index(TMP1, 0)),4))
              Store(2,LEV0)
              Store(2,LEV1)
              Store(2,LEV2)
            }
          }

          Return(TMP1)
        }

        Return(0) // we should never get here, this eliminates a compiler warning
    } // End of TDPL object

    //
    // Returns the max TDP configurable for the platform.
    //
    Name(MAXT,0)

    // TDPC (Thermal Design Power Capabilities)
    //
    // The TDPC object evaluates to an integer that identifies the maximum usable TDP point
    // from the table returned by the TDPL object at any given time.
    //
    // Arguments: (0)
    //   None
    // Return Value:
    //   This value is the zero based index into the TDPL object's entries.
    //
    Method(TDPC)  // For CRB, please return 0. 
    {
      Return(MAXT)    // Return valid TDP point.
    }//end Method(TDPC)

    Name(LEV0,0)
    Name(LEV1,0)
    Name(LEV2,0)

    // STDP (Set current operating TDP Point)
    //
    // The STDP object communicates to the platform BIOS the current operating TDP point whenever it is changed due to any reason.
    // In response to this object evaluation, the platform BIOS modifies the packages returned in PPCC object and notifies the driver of
    // a change in power limit capabilities as appropriate. 
    // 
    // Arguments: (1)
    //   Arg0 = Config TDP level selected
    //     0 = Highest Level values from MSR
    //     1 = Middle Level values from MSR
    //     2 = Lowest Level values from MSR
    //     3 = reserved 
    // Return Value:
    //   None
    //
    // Currently we are using hard coded values for the PPCC values.  
    // A future reference code release will use PPCC values from the PPM reference code. 
    // This will allow PPCC values to be selected from SETUP options.
    //
    Method(STDP,1,Serialized)
    {
      If (LGreaterEqual(Arg0,\_PR.CLVL)){ // bounds check the input
        Return() // invalid input
      }

      //
      // translate requested index value to the correct PL using the sorted TDPL value.
      //
      Switch (ToInteger(Arg0)){
        Case (0) {
          Store(LEV0,Local0)
        }
        Case (1) {
          Store(LEV1,Local0)
        }
        Case (2) {
          Store(LEV2,Local0)
        }
      }

      Switch (ToInteger(Local0)){
        Case (0) {
          CPL0() // copy PL0 values to PPCC
        }
        Case (1) {
          CPL1() // copy PL1 values to PPCC
        }
        Case (2) {
          CPL2() // copy PL2 values to PPCC
        }
      }

      Notify (\_SB.PCI0.B0D4, 0x83)    // Send a Power Capabilities Changed notification to self
    }//end Method(STDP)

}//end Scope(\_SB.PCI0.B0D4)