1/** @file
2
3Copyright (c) 2013-2015 Intel Corporation.
4
5This program and the accompanying materials
6are licensed and made available under the terms and conditions of the BSD License
7which accompanies this distribution.  The full text of the license may be found at
8http://opensource.org/licenses/bsd-license.php
9
10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13**/
14
15
16// Interrupts can be DEB8=all except 13,8,6,2,1,0
17
18#ifndef PCIIRQ_ASI
19#define PCIIRQ_ASI
20
21OperationRegion(PRR0, PCI_Config, 0x60, 0x08)
22Field(PRR0, ANYACC, NOLOCK, PRESERVE)
23{
24    PIRA, 8,
25    PIRB, 8,
26    PIRC, 8,
27    PIRD, 8,
28    PIRE, 8,
29    PIRF, 8,
30    PIRG, 8,
31    PIRH, 8
32}
33
34Device(LNKA)            // PCI IRQ link A
35{
36    Name(_HID,EISAID("PNP0C0F"))
37
38    Name(_UID, 1)
39
40    Method(_STA,0,NotSerialized)
41    {
42        If(And(PIRA, 0x80))
43        {
44          Return(0x9)
45        }
46        Else
47        {
48          Return(0xB)
49        }    // Don't display
50    }
51
52    Method(_DIS,0,NotSerialized)
53    {
54        Or(PIRA, 0x80, PIRA)
55    }
56
57    Method(_CRS,0,Serialized)
58    {
59        Name(BUF0,
60            ResourceTemplate()
61            {IRQ(Level,ActiveLow,Shared){0}})
62
63                                // Define references to buffer elements
64        CreateWordField (BUF0, 0x01, IRQW)  // IRQ low
65                                // Write current settings into IRQ descriptor
66        If (And(PIRA, 0x80))
67        {
68            Store(Zero, Local0)
69        }
70        Else
71        {
72            Store(One,Local0)
73        }
74                                                    // Shift 1 by value in register 70
75        ShiftLeft(Local0,And(PIRA,0x0F),IRQW)       // Save in buffer
76        Return(BUF0)                                // Return Buf0
77    }                                               // End of _CRS method
78
79    Name(_PRS,
80        ResourceTemplate()
81        {IRQ(Level,ActiveLow,Shared){12,11,10,9,7,5,4,3}})
82
83    Method(_SRS,1,NotSerialized)
84    {
85        CreateWordField (ARG0, 0x01, IRQW)  // IRQ low
86
87        FindSetRightBit(IRQW,Local0)          // Set IRQ
88        If (LNotEqual(IRQW,Zero))
89        {
90            And(Local0, 0x7F,Local0)
91            Decrement(Local0)
92        }
93        Else
94        {
95            Or(Local0, 0x80,Local0)
96        }
97        store(Local0, PIRA)
98    }                                                  // End of _SRS Method
99}
100
101Device(LNKB)            // PCI IRQ link B
102{
103    Name(_HID,EISAID("PNP0C0F"))
104
105    Name(_UID, 2)
106
107    Method(_STA,0,NotSerialized)
108    {
109        If(And(PIRB, 0x80))
110        {
111          Return(0x9)
112        }
113        Else
114        {
115          Return(0xB)
116        }    // Don't display
117    }
118
119    Method(_DIS,0,NotSerialized)
120    {
121        Or(PIRB, 0x80,PIRB)
122    }
123
124    Method(_CRS,0,Serialized)
125    {
126        Name(BUF0,
127            ResourceTemplate()
128            {IRQ(Level,ActiveLow,Shared){0}})
129                                            // Define references to buffer elements
130        CreateWordField (BUF0, 0x01, IRQW)  // IRQ low
131                                            // Write current settings into IRQ descriptor
132        If (And(PIRB, 0x80))
133        {
134            Store(Zero, Local0)
135        }
136        Else
137        {
138                Store(One,Local0)
139        }
140                                               // Shift 1 by value in register 70
141        ShiftLeft(Local0,And(PIRB,0x0F),IRQW)  // Save in buffer
142        Return(BUF0)                           // Return Buf0
143    }                                          // End of _CRS method
144
145    Name(_PRS,
146        ResourceTemplate()
147        {IRQ(Level,ActiveLow,Shared){12,11,10,9,7,5,4,3}})
148
149    Method(_SRS,1,NotSerialized)
150    {
151        CreateWordField (ARG0, 0x01, IRQW)      // IRQ low
152
153        FindSetRightBit(IRQW,Local0)            // Set IRQ
154        If (LNotEqual(IRQW,Zero))
155        {
156            And(Local0, 0x7F,Local0)
157            Decrement(Local0)
158        }
159        Else
160        {
161            Or(Local0, 0x80,Local0)
162        }
163        Store(Local0, PIRB)
164    }                                           // End of _SRS Method
165}
166
167Device(LNKC)                                    // PCI IRQ link C
168{
169    Name(_HID,EISAID("PNP0C0F"))
170
171    Name(_UID, 3)
172
173    Method(_STA,0,NotSerialized)
174    {
175        If(And(PIRC, 0x80))
176        {
177          Return(0x9)
178        }
179        Else
180        {
181          Return(0xB)
182        }    // Don't display
183    }
184
185    Method(_DIS,0,NotSerialized)
186    {
187        Or(PIRC, 0x80,PIRC)
188    }
189
190    Method(_CRS,0,Serialized)
191    {
192        Name(BUF0,
193            ResourceTemplate()
194            {IRQ(Level,ActiveLow,Shared){0}})
195                                            // Define references to buffer elements
196        CreateWordField (BUF0, 0x01, IRQW)  // IRQ low
197                                            // Write current settings into IRQ descriptor
198        If (And(PIRC, 0x80))
199        {
200            Store(Zero, Local0)
201        }
202        Else
203        {
204            Store(One,Local0)
205        }                                      // Shift 1 by value in register 70
206        ShiftLeft(Local0,And(PIRC,0x0F),IRQW)  // Save in buffer
207        Return(BUF0)                           // Return Buf0
208    }                                          // End of _CRS method
209
210    Name(_PRS,
211        ResourceTemplate()
212        {IRQ(Level,ActiveLow,Shared){12,11,10,9,7,5,4,3}})
213
214    Method(_SRS,1,NotSerialized)
215    {
216        CreateWordField (ARG0, 0x01, IRQW)  // IRQ low
217
218        FindSetRightBit(IRQW,Local0)        // Set IRQ
219        If (LNotEqual(IRQW,Zero))
220        {
221            And(Local0, 0x7F,Local0)
222            Decrement(Local0)
223        }
224        Else {
225            Or(Local0, 0x80,Local0)
226        }
227        Store(Local0, PIRC)
228    }                                               // End of _SRS Method
229}
230
231Device(LNKD)                                        // PCI IRQ link D
232{
233    Name(_HID,EISAID("PNP0C0F"))
234
235    Name(_UID, 4)
236
237    Method(_STA,0,NotSerialized)
238    {
239        If(And(PIRD, 0x80))
240        {
241          Return(0x9)
242        }
243        Else
244        {
245          Return(0xB)
246        }    // Don't display
247    }
248
249    Method(_DIS,0,NotSerialized)
250    {
251        Or(PIRD, 0x80,PIRD)
252    }
253
254    Method(_CRS,0,Serialized)
255    {
256        Name(BUF0,
257            ResourceTemplate()
258            {IRQ(Level,ActiveLow,Shared){0}})
259        // Define references to buffer elements
260        CreateWordField (BUF0, 0x01, IRQW)  // IRQ low
261        // Write current settings into IRQ descriptor
262        If (And(PIRD, 0x80))
263        {
264            Store(Zero, Local0)
265        }
266        Else
267        {
268            Store(One,Local0)
269        }  // Shift 1 by value in register 70
270        ShiftLeft(Local0,And(PIRD,0x0F),IRQW)  // Save in buffer
271        Return(BUF0)        // Return Buf0
272    }                  // End of _CRS method
273
274    Name(_PRS,
275        ResourceTemplate()
276        {IRQ(Level,ActiveLow,Shared){12,11,10,9,7,5,4,3}})
277
278    Method(_SRS,1,NotSerialized)
279    {
280        CreateWordField (ARG0, 0x01, IRQW)  // IRQ low
281
282        FindSetRightBit(IRQW,Local0)// Set IRQ
283        If (LNotEqual(IRQW,Zero))
284        {
285            And(Local0, 0x7F,Local0)
286            Decrement(Local0)
287        }
288        Else
289        {
290            Or(Local0, 0x80,Local0)
291        }
292        Store(Local0, PIRD)
293    }                  // End of _SRS Method
294}
295
296Device(LNKE)           // PCI IRQ link E
297{
298    Name(_HID,EISAID("PNP0C0F"))
299
300    Name(_UID, 5)
301
302    Method(_STA,0,NotSerialized)
303    {
304        If(And(PIRE, 0x80))
305        {
306          Return(0x9)
307        }
308        Else
309        {
310          Return(0xB)
311        }    // Don't display
312    }
313
314    Method(_DIS,0,NotSerialized)
315    {
316        Or(PIRE, 0x80, PIRE)
317    }
318
319    Method(_CRS,0,Serialized)
320    {
321        Name(BUF0,
322            ResourceTemplate()
323            {IRQ(Level,ActiveLow,Shared){0}})
324
325                                // Define references to buffer elements
326        CreateWordField (BUF0, 0x01, IRQW)  // IRQ low
327                                // Write current settings into IRQ descriptor
328        If (And(PIRE, 0x80))
329        {
330            Store(Zero, Local0)
331        }
332        Else
333        {
334            Store(One,Local0)
335        }
336                                                    // Shift 1 by value in register 70
337        ShiftLeft(Local0,And(PIRE,0x0F),IRQW)       // Save in buffer
338        Return(BUF0)                                // Return Buf0
339    }                                               // End of _CRS method
340
341    Name(_PRS,
342        ResourceTemplate()
343        {IRQ(Level,ActiveLow,Shared){12,11,10,9,7,5,4,3}})
344
345    Method(_SRS,1,NotSerialized)
346    {
347        CreateWordField (ARG0, 0x01, IRQW)  // IRQ low
348
349        FindSetRightBit(IRQW,Local0)          // Set IRQ
350        If (LNotEqual(IRQW,Zero))
351        {
352            And(Local0, 0x7F,Local0)
353            Decrement(Local0)
354        }
355        Else
356        {
357            Or(Local0, 0x80,Local0)
358        }
359        store(Local0, PIRE)
360    }                                                  // End of _SRS Method
361}
362
363Device(LNKF)            // PCI IRQ link F
364{
365    Name(_HID,EISAID("PNP0C0F"))
366
367    Name(_UID, 6)
368
369    Method(_STA,0,NotSerialized)
370    {
371        If(And(PIRF, 0x80))
372        {
373          Return(0x9)
374        }
375        Else
376        {
377          Return(0xB)
378        }    // Don't display
379    }
380
381    Method(_DIS,0,NotSerialized)
382    {
383        Or(PIRB, 0x80,PIRF)
384    }
385
386    Method(_CRS,0,Serialized)
387    {
388        Name(BUF0,
389            ResourceTemplate()
390            {IRQ(Level,ActiveLow,Shared){0}})
391                                            // Define references to buffer elements
392        CreateWordField (BUF0, 0x01, IRQW)  // IRQ low
393                                            // Write current settings into IRQ descriptor
394        If (And(PIRF, 0x80))
395        {
396            Store(Zero, Local0)
397        }
398        Else
399        {
400                Store(One,Local0)
401        }
402                                               // Shift 1 by value in register 70
403        ShiftLeft(Local0,And(PIRF,0x0F),IRQW)  // Save in buffer
404        Return(BUF0)                           // Return Buf0
405    }                                          // End of _CRS method
406
407    Name(_PRS,
408        ResourceTemplate()
409        {IRQ(Level,ActiveLow,Shared){12,11,10,9,7,5,4,3}})
410
411    Method(_SRS,1,NotSerialized)
412    {
413        CreateWordField (ARG0, 0x01, IRQW)      // IRQ low
414
415        FindSetRightBit(IRQW,Local0)            // Set IRQ
416        If (LNotEqual(IRQW,Zero))
417        {
418            And(Local0, 0x7F,Local0)
419            Decrement(Local0)
420        }
421        Else
422        {
423            Or(Local0, 0x80,Local0)
424        }
425        Store(Local0, PIRF)
426    }                                                   // End of _SRS Method
427}
428
429Device(LNKG)                                            // PCI IRQ link G
430{
431    Name(_HID,EISAID("PNP0C0F"))
432
433    Name(_UID, 7)
434
435    Method(_STA,0,NotSerialized)
436    {
437        If(And(PIRG, 0x80))
438        {
439          Return(0x9)
440        }
441        Else
442        {
443          Return(0xB)
444        }    // Don't display
445    }
446
447    Method(_DIS,0,NotSerialized)
448    {
449        Or(PIRG, 0x80,PIRG)
450    }
451
452    Method(_CRS,0,Serialized)
453    {
454        Name(BUF0,
455            ResourceTemplate()
456            {IRQ(Level,ActiveLow,Shared){0}})
457                                            // Define references to buffer elements
458        CreateWordField (BUF0, 0x01, IRQW)  // IRQ low
459                                            // Write current settings into IRQ descriptor
460        If (And(PIRG, 0x80))
461        {
462            Store(Zero, Local0)
463        }
464        Else
465        {
466            Store(One,Local0)
467        }                                      // Shift 1 by value in register 70
468        ShiftLeft(Local0,And(PIRG,0x0F),IRQW)  // Save in buffer
469        Return(BUF0)                           // Return Buf0
470    }                                          // End of _CRS method
471
472    Name(_PRS,
473        ResourceTemplate()
474        {IRQ(Level,ActiveLow,Shared){12,11,10,9,7,5,4,3}})
475
476    Method(_SRS,1,NotSerialized)
477    {
478        CreateWordField (ARG0, 0x01, IRQW)  // IRQ low
479
480        FindSetRightBit(IRQW,Local0)          // Set IRQ
481        If (LNotEqual(IRQW,Zero))
482        {
483            And(Local0, 0x7F,Local0)
484            Decrement(Local0)
485        }
486        Else {
487            Or(Local0, 0x80,Local0)
488        }
489        Store(Local0, PIRG)
490    }                                               // End of _SRS Method
491}
492
493Device(LNKH)                                        // PCI IRQ link H
494{
495    Name(_HID,EISAID("PNP0C0F"))
496
497    Name(_UID, 8)
498
499    Method(_STA,0,NotSerialized)
500    {
501        If(And(PIRH, 0x80))
502        {
503          Return(0x9)
504        }
505        Else
506        {
507          Return(0xB)
508        }    // Don't display
509    }
510
511    Method(_DIS,0,NotSerialized)
512    {
513        Or(PIRH, 0x80,PIRH)
514    }
515
516    Method(_CRS,0,Serialized)
517    {
518        Name(BUF0,
519            ResourceTemplate()
520            {IRQ(Level,ActiveLow,Shared){0}})
521        // Define references to buffer elements
522        CreateWordField (BUF0, 0x01, IRQW)  // IRQ low
523        // Write current settings into IRQ descriptor
524        If (And(PIRH, 0x80))
525        {
526            Store(Zero, Local0)
527        }
528        Else
529        {
530            Store(One,Local0)
531        }  // Shift 1 by value in register 70
532        ShiftLeft(Local0,And(PIRH,0x0F),IRQW)  // Save in buffer
533        Return(BUF0)   // Return Buf0
534    }                  // End of _CRS method
535
536    Name(_PRS,
537        ResourceTemplate()
538        {IRQ(Level,ActiveLow,Shared){12,11,10,9,7,5,4,3}})
539
540    Method(_SRS,1,NotSerialized)
541    {
542        CreateWordField (ARG0, 0x01, IRQW)  // IRQ low
543
544        FindSetRightBit(IRQW,Local0)// Set IRQ
545        If (LNotEqual(IRQW,Zero))
546        {
547            And(Local0, 0x7F,Local0)
548            Decrement(Local0)
549        }
550        Else
551        {
552            Or(Local0, 0x80,Local0)
553        }
554        Store(Local0, PIRH)
555    }                  // End of _SRS Method
556}
557
558#endif
559