2 * Copyright (C) 2013 Google Inc.
3 * Copyright (C) 2014 Sage Electronics Engineering, LLC.
4 * Copyright (C) 2016 Bin Meng <bmeng.cn@gmail.com>
6 * Modified from coreboot src/soc/intel/baytrail/include/soc/irq_helper.h
8 * SPDX-License-Identifier: GPL-2.0+
12 * This file intentionally gets included multiple times, to set pic and apic
13 * modes, so should not have guard statements added.
17 * This file will use irqroute.asl and irqroute.h to generate the ACPI IRQ
18 * routing for the platform being compiled.
20 * This method uses #defines in irqroute.h along with the macros contained
21 * in this file to generate an IRQ routing for each PCI device in the system.
24 #undef PCI_DEV_PIRQ_ROUTES
25 #undef PCI_DEV_PIRQ_ROUTE
27 #undef PCIE_BRIDGE_DEV
29 #undef ROOTPORT_METHODS
30 #undef ROOTPORT_IRQ_ROUTES
35 #define ACPI_DEV_IRQ(dev_, pin_, pin_name_) \
36 Package() { ## dev_ ## ffff, pin_, \_SB.PCI0.LPCB.LNK ## pin_name_, 0 }
38 #define RP_IRQ_ROUTES(prefix_, func_, a_, b_, c_, d_) \
39 Name(prefix_ ## func_ ## P, Package() \
41 ACPI_DEV_IRQ(0x0000, 0, a_), \
42 ACPI_DEV_IRQ(0x0000, 1, b_), \
43 ACPI_DEV_IRQ(0x0000, 2, c_), \
44 ACPI_DEV_IRQ(0x0000, 3, d_), \
47 /* define as blank so ROOTPORT_METHODS only gets inserted once */
48 #define ROOTPORT_METHODS(prefix_, dev_)
50 #else /* defined(PIC_MODE) */
52 #define ACPI_DEV_IRQ(dev_, pin_, pin_name_) \
53 Package() { ## dev_ ## ffff, pin_, 0, PIRQ ## pin_name_ ## _APIC_IRQ }
55 #define RP_IRQ_ROUTES(prefix_, func_, a_, b_, c_, d_) \
56 Name(prefix_ ## func_ ## A, Package() \
58 ACPI_DEV_IRQ(0x0000, 0, a_), \
59 ACPI_DEV_IRQ(0x0000, 1, b_), \
60 ACPI_DEV_IRQ(0x0000, 2, c_), \
61 ACPI_DEV_IRQ(0x0000, 3, d_), \
64 #define ROOTPORT_METHODS(prefix_, dev_) \
65 RP_METHOD(prefix_, dev_, 0) \
66 RP_METHOD(prefix_, dev_, 1) \
67 RP_METHOD(prefix_, dev_, 2) \
68 RP_METHOD(prefix_, dev_, 3) \
69 RP_METHOD(prefix_, dev_, 4) \
70 RP_METHOD(prefix_, dev_, 5) \
71 RP_METHOD(prefix_, dev_, 6) \
72 RP_METHOD(prefix_, dev_, 7)
74 #endif /* defined(PIC_MODE) */
76 #define PCI_DEV_PIRQ_ROUTE(dev_, a_, b_, c_, d_) \
77 ACPI_DEV_IRQ(dev_, 0, a_), \
78 ACPI_DEV_IRQ(dev_, 1, b_), \
79 ACPI_DEV_IRQ(dev_, 2, c_), \
80 ACPI_DEV_IRQ(dev_, 3, d_)
82 #define PCIE_BRIDGE_DEV(prefix_, dev_, a_, b_, c_, d_) \
83 ROOTPORT_IRQ_ROUTES(prefix_, a_, b_, c_, d_) \
84 ROOTPORT_METHODS(prefix_, dev_)
86 #define ROOTPORT_IRQ_ROUTES(prefix_, a_, b_, c_, d_) \
87 RP_IRQ_ROUTES(prefix_, 0, a_, b_, c_, d_) \
88 RP_IRQ_ROUTES(prefix_, 1, b_, c_, d_, a_) \
89 RP_IRQ_ROUTES(prefix_, 2, c_, d_, a_, b_) \
90 RP_IRQ_ROUTES(prefix_, 3, d_, a_, b_, c_) \
91 RP_IRQ_ROUTES(prefix_, 4, a_, b_, c_, d_) \
92 RP_IRQ_ROUTES(prefix_, 5, b_, c_, d_, a_) \
93 RP_IRQ_ROUTES(prefix_, 6, c_, d_, a_, b_) \
94 RP_IRQ_ROUTES(prefix_, 7, d_, a_, b_, c_)
96 #define RP_METHOD(prefix_, dev_, func_)\
97 Device (prefix_ ## 0 ## func_) \
99 Name(_ADR, dev_ ## 000 ## func_) \
100 Name(_PRW, Package() { 0, 0 }) \
103 Return (prefix_ ## func_ ## A) \
105 Return (prefix_ ## func_ ## P) \
110 /* SoC specific PIRQ route configuration */
111 #include "irqroute.h"