blob: 6e404f48bbab1199bf390a629c36ed99cb0927a0 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
Bin Meng6c9f9442016-05-07 07:46:31 -07002/*
3 * Copyright (C) 2013 Google Inc.
4 * Copyright (C) 2014 Sage Electronics Engineering, LLC.
5 * Copyright (C) 2016 Bin Meng <bmeng.cn@gmail.com>
6 *
7 * Modified from coreboot src/soc/intel/baytrail/include/soc/irq_helper.h
Bin Meng6c9f9442016-05-07 07:46:31 -07008 */
9
10/*
11 * This file intentionally gets included multiple times, to set pic and apic
12 * modes, so should not have guard statements added.
13 */
14
15/*
16 * This file will use irqroute.asl and irqroute.h to generate the ACPI IRQ
17 * routing for the platform being compiled.
18 *
19 * This method uses #defines in irqroute.h along with the macros contained
20 * in this file to generate an IRQ routing for each PCI device in the system.
21 */
22
23#undef PCI_DEV_PIRQ_ROUTES
24#undef PCI_DEV_PIRQ_ROUTE
25#undef ACPI_DEV_IRQ
26#undef PCIE_BRIDGE_DEV
27#undef RP_IRQ_ROUTES
28#undef ROOTPORT_METHODS
29#undef ROOTPORT_IRQ_ROUTES
30#undef RP_METHOD
31
32#if defined(PIC_MODE)
33
34#define ACPI_DEV_IRQ(dev_, pin_, pin_name_) \
35 Package() { ## dev_ ## ffff, pin_, \_SB.PCI0.LPCB.LNK ## pin_name_, 0 }
36
37#define RP_IRQ_ROUTES(prefix_, func_, a_, b_, c_, d_) \
38Name(prefix_ ## func_ ## P, Package() \
39{ \
40 ACPI_DEV_IRQ(0x0000, 0, a_), \
41 ACPI_DEV_IRQ(0x0000, 1, b_), \
42 ACPI_DEV_IRQ(0x0000, 2, c_), \
43 ACPI_DEV_IRQ(0x0000, 3, d_), \
44})
45
46/* define as blank so ROOTPORT_METHODS only gets inserted once */
47#define ROOTPORT_METHODS(prefix_, dev_)
48
49#else /* defined(PIC_MODE) */
50
51#define ACPI_DEV_IRQ(dev_, pin_, pin_name_) \
52 Package() { ## dev_ ## ffff, pin_, 0, PIRQ ## pin_name_ ## _APIC_IRQ }
53
54#define RP_IRQ_ROUTES(prefix_, func_, a_, b_, c_, d_) \
55Name(prefix_ ## func_ ## A, Package() \
56{ \
57 ACPI_DEV_IRQ(0x0000, 0, a_), \
58 ACPI_DEV_IRQ(0x0000, 1, b_), \
59 ACPI_DEV_IRQ(0x0000, 2, c_), \
60 ACPI_DEV_IRQ(0x0000, 3, d_), \
61})
62
63#define ROOTPORT_METHODS(prefix_, dev_) \
64 RP_METHOD(prefix_, dev_, 0) \
65 RP_METHOD(prefix_, dev_, 1) \
66 RP_METHOD(prefix_, dev_, 2) \
67 RP_METHOD(prefix_, dev_, 3) \
68 RP_METHOD(prefix_, dev_, 4) \
69 RP_METHOD(prefix_, dev_, 5) \
70 RP_METHOD(prefix_, dev_, 6) \
71 RP_METHOD(prefix_, dev_, 7)
72
73#endif /* defined(PIC_MODE) */
74
75#define PCI_DEV_PIRQ_ROUTE(dev_, a_, b_, c_, d_) \
76 ACPI_DEV_IRQ(dev_, 0, a_), \
77 ACPI_DEV_IRQ(dev_, 1, b_), \
78 ACPI_DEV_IRQ(dev_, 2, c_), \
79 ACPI_DEV_IRQ(dev_, 3, d_)
80
81#define PCIE_BRIDGE_DEV(prefix_, dev_, a_, b_, c_, d_) \
82 ROOTPORT_IRQ_ROUTES(prefix_, a_, b_, c_, d_) \
83 ROOTPORT_METHODS(prefix_, dev_)
84
85#define ROOTPORT_IRQ_ROUTES(prefix_, a_, b_, c_, d_) \
86 RP_IRQ_ROUTES(prefix_, 0, a_, b_, c_, d_) \
87 RP_IRQ_ROUTES(prefix_, 1, b_, c_, d_, a_) \
88 RP_IRQ_ROUTES(prefix_, 2, c_, d_, a_, b_) \
89 RP_IRQ_ROUTES(prefix_, 3, d_, a_, b_, c_) \
90 RP_IRQ_ROUTES(prefix_, 4, a_, b_, c_, d_) \
91 RP_IRQ_ROUTES(prefix_, 5, b_, c_, d_, a_) \
92 RP_IRQ_ROUTES(prefix_, 6, c_, d_, a_, b_) \
93 RP_IRQ_ROUTES(prefix_, 7, d_, a_, b_, c_)
94
95#define RP_METHOD(prefix_, dev_, func_)\
96Device (prefix_ ## 0 ## func_) \
97{ \
98 Name(_ADR, dev_ ## 000 ## func_) \
99 Name(_PRW, Package() { 0, 0 }) \
100 Method(_PRT) { \
101 If (PICM) { \
102 Return (prefix_ ## func_ ## A) \
103 } Else { \
104 Return (prefix_ ## func_ ## P) \
105 } \
106 } \
107}
108
109/* SoC specific PIRQ route configuration */
Bin Meng15d4c412016-05-25 19:19:07 -0700110#include <asm/arch/acpi/irqroute.h>