| 1 |
|
| 2 |
|
| 3 |
#include <acpi/acpi.h> |
| 4 |
#include <acpi/acpigen.h> |
| 5 |
#include <acpi/acpigen_pci.h> |
| 6 |
#include <amdblocks/amd_pci_util.h> |
| 7 |
#include <arch/ioapic.h> |
| 8 |
#include <device/device.h> |
| 9 |
|
| 10 |
|
| 11 |
#define FCH_IOAPIC_INTERRUPTS 24 |
| 12 |
#define GNB_GSI_BASE FCH_IOAPIC_INTERRUPTS |
| 13 |
|
| 14 |
static void acpigen_write_PRT_GSI(const struct pci_routing_info *routing_info) |
| 15 |
{ |
| 16 |
unsigned int irq; |
| 17 |
|
| 18 |
acpigen_write_package(4); |
| 19 |
for (unsigned int i = 0; i < 4; ++i) { |
| 20 |
irq = pci_calculate_irq(routing_info, i); |
| 21 |
|
| 22 |
acpigen_write_PRT_GSI_entry( |
| 23 |
0, |
| 24 |
i, |
| 25 |
GNB_GSI_BASE + irq); |
| 26 |
} |
| 27 |
acpigen_pop_len(); |
| 28 |
} |
| 29 |
|
| 30 |
static void acpigen_write_PRT_PIC(const struct pci_routing_info *routing_info) |
| 31 |
{ |
| 32 |
unsigned int irq; |
| 33 |
char link_template[] = "\\_SB.INTX"; |
| 34 |
|
| 35 |
acpigen_write_package(4); |
| 36 |
for (unsigned int i = 0; i < 4; ++i) { |
| 37 |
irq = pci_calculate_irq(routing_info, i); |
| 38 |
|
| 39 |
link_template[8] = 'A' + (irq % 8); |
| 40 |
|
| 41 |
acpigen_write_PRT_source_entry( |
| 42 |
0, |
| 43 |
i, |
| 44 |
link_template , |
| 45 |
0 ); |
| 46 |
} |
| 47 |
acpigen_pop_len(); |
| 48 |
} |
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
|
| 130 |
void acpigen_write_pci_GNB_PRT(const struct device *dev) |
| 131 |
{ |
| 132 |
const struct pci_routing_info *routing_info = |
| 133 |
get_pci_routing_info(dev->path.pci.devfn); |
| 134 |
|
| 135 |
if (!routing_info) |
| 136 |
return; |
| 137 |
|
| 138 |
acpigen_write_method("_PRT", 0); |
| 139 |
|
| 140 |
|
| 141 |
acpigen_write_if(); |
| 142 |
acpigen_emit_namestring("PICM"); |
| 143 |
|
| 144 |
|
| 145 |
acpigen_emit_byte(RETURN_OP); |
| 146 |
acpigen_write_PRT_GSI(routing_info); |
| 147 |
|
| 148 |
|
| 149 |
acpigen_write_else(); |
| 150 |
|
| 151 |
|
| 152 |
acpigen_emit_byte(RETURN_OP); |
| 153 |
acpigen_write_PRT_PIC(routing_info); |
| 154 |
|
| 155 |
acpigen_pop_len(); |
| 156 |
|
| 157 |
acpigen_pop_len(); |
| 158 |
} |
| 159 |
|
| 160 |
|
| 161 |
|
| 162 |
|
| 163 |
|
| 164 |
|
| 165 |
|
| 166 |
|
| 167 |
|
| 168 |
|
| 169 |
|
| 170 |
|
| 171 |
|
| 172 |
|
| 173 |
|
| 174 |
|
| 175 |
|
| 176 |
|
| 177 |
|
| 178 |
|
| 179 |
|
| 180 |
|
| 181 |
|
| 182 |
|
| 183 |
|
| 184 |
|
| 185 |
|
| 186 |
|
| 187 |
|
| 188 |
|
| 189 |
|
| 190 |
|
| 191 |
|
| 192 |
|
| 193 |
|
| 194 |
|
| 195 |
|
| 196 |
|
| 197 |
void acpigen_write_pci_FCH_PRT(const struct device *dev) |
| 198 |
{ |
| 199 |
const struct pci_routing_info *routing_info = |
| 200 |
get_pci_routing_info(dev->path.pci.devfn); |
| 201 |
|
| 202 |
if (!routing_info) |
| 203 |
return; |
| 204 |
|
| 205 |
acpigen_write_name("_PRT"); |
| 206 |
acpigen_write_PRT_PIC(routing_info); |
| 207 |
} |