1/*
2 * Copyright (C) 2007-2009 coresystems GmbH
3 * Copyright (C) 2016 Bin Meng <bmeng.cn@gmail.com>
4 *
5 * Modified from coreboot src/soc/intel/baytrail/acpi/irqlinks.asl
6 *
7 * SPDX-License-Identifier:	GPL-2.0+
8 */
9
10/*
11 * Intel chipset PIRQ routing control ASL description
12 *
13 * The programming interface is common to most Intel chipsets. But the PRTx
14 * registers may be mapped to different blocks. Some chipsets map them to LPC
15 * device (00:1f:00) PCI configuration space (like TunnelCreek, Quark), while
16 * some newer Atom SoCs (like BayTrail, Braswell) map them to Intel Legacy
17 * Block (ILB) memory space.
18 *
19 * This file defines 8 PCI IRQ link devices which corresponds to 8 PIRQ lines
20 * PIRQ A/B/C/D/E/F/G/H. To incorperate this file, the PRTx registers must be
21 * defined somewhere else in the platform's ASL files.
22 */
23
24Device (LNKA)
25{
26	Name(_HID, EISAID("PNP0C0F"))
27	Name(_UID, 1)
28
29	/* Disable method */
30	Method(_DIS, 0, Serialized)
31	{
32		Store(0x80, PRTA)
33	}
34
35	/* Possible Resource Settings for this Link */
36	Name(_PRS, ResourceTemplate()
37	{
38		IRQ(Level, ActiveLow, Shared) { 5, 6, 7, 10, 11, 12, 14, 15 }
39	})
40
41	/* Current Resource Settings for this link */
42	Method(_CRS, 0, Serialized)
43	{
44		Name(RTLA, ResourceTemplate()
45		{
46			IRQ(Level, ActiveLow, Shared) {}
47		})
48		CreateWordField(RTLA, 1, IRQ0)
49
50		/* Clear the WordField */
51		Store(Zero, IRQ0)
52
53		/* Set the bit from PRTA */
54		ShiftLeft(1, And(PRTA, 0x0f), IRQ0)
55
56		Return (RTLA)
57	}
58
59	/* Set Resource Setting for this IRQ link */
60	Method(_SRS, 1, Serialized)
61	{
62		CreateWordField(Arg0, 1, IRQ0)
63
64		/* Which bit is set? */
65		FindSetRightBit(IRQ0, Local0)
66
67		Decrement(Local0)
68		Store(Local0, PRTA)
69	}
70
71	/* Status */
72	Method(_STA, 0, Serialized)
73	{
74		If (And(PRTA, 0x80)) {
75			Return (STA_DISABLED)
76		} Else {
77			Return (STA_INVISIBLE)
78		}
79	}
80}
81
82Device (LNKB)
83{
84	Name(_HID, EISAID("PNP0C0F"))
85	Name(_UID, 2)
86
87	/* Disable method */
88	Method(_DIS, 0, Serialized)
89	{
90		Store(0x80, PRTB)
91	}
92
93	/* Possible Resource Settings for this Link */
94	Name(_PRS, ResourceTemplate()
95	{
96		IRQ(Level, ActiveLow, Shared) { 5, 6, 7, 10, 11, 12, 14, 15 }
97	})
98
99	/* Current Resource Settings for this link */
100	Method(_CRS, 0, Serialized)
101	{
102		Name(RTLB, ResourceTemplate()
103		{
104			IRQ(Level, ActiveLow, Shared) {}
105		})
106		CreateWordField(RTLB, 1, IRQ0)
107
108		/* Clear the WordField */
109		Store(Zero, IRQ0)
110
111		/* Set the bit from PRTB */
112		ShiftLeft(1, And(PRTB, 0x0f), IRQ0)
113
114		Return (RTLB)
115	}
116
117	/* Set Resource Setting for this IRQ link */
118	Method(_SRS, 1, Serialized)
119	{
120		CreateWordField(Arg0, 1, IRQ0)
121
122		/* Which bit is set? */
123		FindSetRightBit(IRQ0, Local0)
124
125		Decrement(Local0)
126		Store(Local0, PRTB)
127	}
128
129	/* Status */
130	Method(_STA, 0, Serialized)
131	{
132		If (And(PRTB, 0x80)) {
133			Return (STA_DISABLED)
134		} Else {
135			Return (STA_INVISIBLE)
136		}
137	}
138}
139
140Device (LNKC)
141{
142	Name(_HID, EISAID("PNP0C0F"))
143	Name(_UID, 3)
144
145	/* Disable method */
146	Method(_DIS, 0, Serialized)
147	{
148		Store(0x80, PRTC)
149	}
150
151	/* Possible Resource Settings for this Link */
152	Name(_PRS, ResourceTemplate()
153	{
154		IRQ(Level, ActiveLow, Shared) { 5, 6, 7, 10, 11, 12, 14, 15 }
155	})
156
157	/* Current Resource Settings for this link */
158	Method(_CRS, 0, Serialized)
159	{
160		Name(RTLC, ResourceTemplate()
161		{
162			IRQ(Level, ActiveLow, Shared) {}
163		})
164		CreateWordField(RTLC, 1, IRQ0)
165
166		/* Clear the WordField */
167		Store(Zero, IRQ0)
168
169		/* Set the bit from PRTC */
170		ShiftLeft(1, And(PRTC, 0x0f), IRQ0)
171
172		Return (RTLC)
173	}
174
175	/* Set Resource Setting for this IRQ link */
176	Method(_SRS, 1, Serialized)
177	{
178		CreateWordField(Arg0, 1, IRQ0)
179
180		/* Which bit is set? */
181		FindSetRightBit(IRQ0, Local0)
182
183		Decrement(Local0)
184		Store(Local0, PRTC)
185	}
186
187	/* Status */
188	Method(_STA, 0, Serialized)
189	{
190		If (And(PRTC, 0x80)) {
191			Return (STA_DISABLED)
192		} Else {
193			Return (STA_INVISIBLE)
194		}
195	}
196}
197
198Device (LNKD)
199{
200	Name(_HID, EISAID("PNP0C0F"))
201	Name(_UID, 4)
202
203	/* Disable method */
204	Method(_DIS, 0, Serialized)
205	{
206		Store(0x80, PRTD)
207	}
208
209	/* Possible Resource Settings for this Link */
210	Name(_PRS, ResourceTemplate()
211	{
212		IRQ(Level, ActiveLow, Shared) { 5, 6, 7, 10, 11, 12, 14, 15 }
213	})
214
215	/* Current Resource Settings for this link */
216	Method(_CRS, 0, Serialized)
217	{
218		Name(RTLD, ResourceTemplate()
219		{
220			IRQ(Level, ActiveLow, Shared) {}
221		})
222		CreateWordField(RTLD, 1, IRQ0)
223
224		/* Clear the WordField */
225		Store(Zero, IRQ0)
226
227		/* Set the bit from PRTD */
228		ShiftLeft(1, And(PRTD, 0x0f), IRQ0)
229
230		Return (RTLD)
231	}
232
233	/* Set Resource Setting for this IRQ link */
234	Method(_SRS, 1, Serialized)
235	{
236		CreateWordField(Arg0, 1, IRQ0)
237
238		/* Which bit is set? */
239		FindSetRightBit(IRQ0, Local0)
240
241		Decrement(Local0)
242		Store(Local0, PRTD)
243	}
244
245	/* Status */
246	Method(_STA, 0, Serialized)
247	{
248		If (And(PRTD, 0x80)) {
249			Return (STA_DISABLED)
250		} Else {
251			Return (STA_INVISIBLE)
252		}
253	}
254}
255
256Device (LNKE)
257{
258	Name(_HID, EISAID("PNP0C0F"))
259	Name(_UID, 5)
260
261	/* Disable method */
262	Method(_DIS, 0, Serialized)
263	{
264		Store(0x80, PRTE)
265	}
266
267	/* Possible Resource Settings for this Link */
268	Name(_PRS, ResourceTemplate()
269	{
270		IRQ(Level, ActiveLow, Shared) { 5, 6, 7, 10, 11, 12, 14, 15 }
271	})
272
273	/* Current Resource Settings for this link */
274	Method(_CRS, 0, Serialized)
275	{
276		Name(RTLE, ResourceTemplate()
277		{
278			IRQ(Level, ActiveLow, Shared) {}
279		})
280		CreateWordField(RTLE, 1, IRQ0)
281
282		/* Clear the WordField */
283		Store(Zero, IRQ0)
284
285		/* Set the bit from PRTE */
286		ShiftLeft(1, And(PRTE, 0x0f), IRQ0)
287
288		Return (RTLE)
289	}
290
291	/* Set Resource Setting for this IRQ link */
292	Method(_SRS, 1, Serialized)
293	{
294		CreateWordField(Arg0, 1, IRQ0)
295
296		/* Which bit is set? */
297		FindSetRightBit(IRQ0, Local0)
298
299		Decrement(Local0)
300		Store(Local0, PRTE)
301	}
302
303	/* Status */
304	Method(_STA, 0, Serialized)
305	{
306		If (And(PRTE, 0x80)) {
307			Return (STA_DISABLED)
308		} Else {
309			Return (STA_INVISIBLE)
310		}
311	}
312}
313
314Device (LNKF)
315{
316	Name(_HID, EISAID("PNP0C0F"))
317	Name(_UID, 6)
318
319	/* Disable method */
320	Method(_DIS, 0, Serialized)
321	{
322		Store(0x80, PRTF)
323	}
324
325	/* Possible Resource Settings for this Link */
326	Name(_PRS, ResourceTemplate()
327	{
328		IRQ(Level, ActiveLow, Shared) { 5, 6, 7, 10, 11, 12, 14, 15 }
329	})
330
331	/* Current Resource Settings for this link */
332	Method(_CRS, 0, Serialized)
333	{
334		Name(RTLF, ResourceTemplate()
335		{
336			IRQ(Level, ActiveLow, Shared) {}
337		})
338		CreateWordField(RTLF, 1, IRQ0)
339
340		/* Clear the WordField */
341		Store(Zero, IRQ0)
342
343		/* Set the bit from PRTF */
344		ShiftLeft(1, And(PRTF, 0x0f), IRQ0)
345
346		Return (RTLF)
347	}
348
349	/* Set Resource Setting for this IRQ link */
350	Method(_SRS, 1, Serialized)
351	{
352		CreateWordField(Arg0, 1, IRQ0)
353
354		/* Which bit is set? */
355		FindSetRightBit(IRQ0, Local0)
356
357		Decrement(Local0)
358		Store(Local0, PRTF)
359	}
360
361	/* Status */
362	Method(_STA, 0, Serialized)
363	{
364		If (And(PRTF, 0x80)) {
365			Return (STA_DISABLED)
366		} Else {
367			Return (STA_INVISIBLE)
368		}
369	}
370}
371
372Device (LNKG)
373{
374	Name(_HID, EISAID("PNP0C0F"))
375	Name(_UID, 7)
376
377	/* Disable method */
378	Method(_DIS, 0, Serialized)
379	{
380		Store(0x80, PRTG)
381	}
382
383	/* Possible Resource Settings for this Link */
384	Name(_PRS, ResourceTemplate()
385	{
386		IRQ(Level, ActiveLow, Shared) { 5, 6, 7, 10, 11, 12, 14, 15 }
387	})
388
389	/* Current Resource Settings for this link */
390	Method(_CRS, 0, Serialized)
391	{
392		Name(RTLG, ResourceTemplate()
393		{
394			IRQ(Level, ActiveLow, Shared) {}
395		})
396		CreateWordField(RTLG, 1, IRQ0)
397
398		/* Clear the WordField */
399		Store(Zero, IRQ0)
400
401		/* Set the bit from PRTG */
402		ShiftLeft(1, And(PRTG, 0x0f), IRQ0)
403
404		Return (RTLG)
405	}
406
407	/* Set Resource Setting for this IRQ link */
408	Method(_SRS, 1, Serialized)
409	{
410		CreateWordField(Arg0, 1, IRQ0)
411
412		/* Which bit is set? */
413		FindSetRightBit(IRQ0, Local0)
414
415		Decrement(Local0)
416		Store(Local0, PRTG)
417	}
418
419	/* Status */
420	Method(_STA, 0, Serialized)
421	{
422		If (And(PRTG, 0x80)) {
423			Return (STA_DISABLED)
424		} Else {
425			Return (STA_INVISIBLE)
426		}
427	}
428}
429
430Device (LNKH)
431{
432	Name(_HID, EISAID("PNP0C0F"))
433	Name(_UID, 8)
434
435	/* Disable method */
436	Method(_DIS, 0, Serialized)
437	{
438		Store(0x80, PRTH)
439	}
440
441	/* Possible Resource Settings for this Link */
442	Name(_PRS, ResourceTemplate()
443	{
444		IRQ(Level, ActiveLow, Shared) { 5, 6, 7, 10, 11, 12, 14, 15 }
445	})
446
447	/* Current Resource Settings for this link */
448	Method(_CRS, 0, Serialized)
449	{
450		Name(RTLH, ResourceTemplate()
451		{
452			IRQ(Level, ActiveLow, Shared) {}
453		})
454		CreateWordField(RTLH, 1, IRQ0)
455
456		/* Clear the WordField */
457		Store(Zero, IRQ0)
458
459		/* Set the bit from PRTH */
460		ShiftLeft(1, And(PRTH, 0x0f), IRQ0)
461
462		Return (RTLH)
463	}
464
465	/* Set Resource Setting for this IRQ link */
466	Method(_SRS, 1, Serialized)
467	{
468		CreateWordField(Arg0, 1, IRQ0)
469
470		/* Which bit is set? */
471		FindSetRightBit(IRQ0, Local0)
472
473		Decrement(Local0)
474		Store(Local0, PRTH)
475	}
476
477	/* Status */
478	Method(_STA, 0, Serialized)
479	{
480		If (And(PRTH, 0x80)) {
481			Return (STA_DISABLED)
482		} Else {
483			Return (STA_INVISIBLE)
484		}
485	}
486}
487