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