1 // SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
2 /*******************************************************************************
4 * Module Name: rsirq - IRQ resource descriptors
6 ******************************************************************************/
12 #define _COMPONENT ACPI_RESOURCES
13 ACPI_MODULE_NAME("rsirq")
15 /*******************************************************************************
19 ******************************************************************************/
20 struct acpi_rsconvert_info acpi_rs_get_irq
[9] = {
21 {ACPI_RSC_INITGET
, ACPI_RESOURCE_TYPE_IRQ
,
22 ACPI_RS_SIZE(struct acpi_resource_irq
),
23 ACPI_RSC_TABLE_SIZE(acpi_rs_get_irq
)},
25 /* Get the IRQ mask (bytes 1:2) */
27 {ACPI_RSC_BITMASK16
, ACPI_RS_OFFSET(data
.irq
.interrupts
[0]),
28 AML_OFFSET(irq
.irq_mask
),
29 ACPI_RS_OFFSET(data
.irq
.interrupt_count
)},
31 /* Set default flags (others are zero) */
33 {ACPI_RSC_SET8
, ACPI_RS_OFFSET(data
.irq
.triggering
),
37 /* Get the descriptor length (2 or 3 for IRQ descriptor) */
39 {ACPI_RSC_2BITFLAG
, ACPI_RS_OFFSET(data
.irq
.descriptor_length
),
40 AML_OFFSET(irq
.descriptor_type
),
43 /* All done if no flag byte present in descriptor */
45 {ACPI_RSC_EXIT_NE
, ACPI_RSC_COMPARE_AML_LENGTH
, 0, 3},
47 /* Get flags: Triggering[0], Polarity[3], Sharing[4], Wake[5] */
49 {ACPI_RSC_1BITFLAG
, ACPI_RS_OFFSET(data
.irq
.triggering
),
50 AML_OFFSET(irq
.flags
),
53 {ACPI_RSC_1BITFLAG
, ACPI_RS_OFFSET(data
.irq
.polarity
),
54 AML_OFFSET(irq
.flags
),
57 {ACPI_RSC_1BITFLAG
, ACPI_RS_OFFSET(data
.irq
.sharable
),
58 AML_OFFSET(irq
.flags
),
61 {ACPI_RSC_1BITFLAG
, ACPI_RS_OFFSET(data
.irq
.wake_capable
),
62 AML_OFFSET(irq
.flags
),
66 /*******************************************************************************
70 ******************************************************************************/
72 struct acpi_rsconvert_info acpi_rs_set_irq
[14] = {
73 /* Start with a default descriptor of length 3 */
75 {ACPI_RSC_INITSET
, ACPI_RESOURCE_NAME_IRQ
,
76 sizeof(struct aml_resource_irq
),
77 ACPI_RSC_TABLE_SIZE(acpi_rs_set_irq
)},
79 /* Convert interrupt list to 16-bit IRQ bitmask */
81 {ACPI_RSC_BITMASK16
, ACPI_RS_OFFSET(data
.irq
.interrupts
[0]),
82 AML_OFFSET(irq
.irq_mask
),
83 ACPI_RS_OFFSET(data
.irq
.interrupt_count
)},
85 /* Set flags: Triggering[0], Polarity[3], Sharing[4], Wake[5] */
87 {ACPI_RSC_1BITFLAG
, ACPI_RS_OFFSET(data
.irq
.triggering
),
88 AML_OFFSET(irq
.flags
),
91 {ACPI_RSC_1BITFLAG
, ACPI_RS_OFFSET(data
.irq
.polarity
),
92 AML_OFFSET(irq
.flags
),
95 {ACPI_RSC_1BITFLAG
, ACPI_RS_OFFSET(data
.irq
.sharable
),
96 AML_OFFSET(irq
.flags
),
99 {ACPI_RSC_1BITFLAG
, ACPI_RS_OFFSET(data
.irq
.wake_capable
),
100 AML_OFFSET(irq
.flags
),
104 * All done if the output descriptor length is required to be 3
105 * (i.e., optimization to 2 bytes cannot be attempted)
107 {ACPI_RSC_EXIT_EQ
, ACPI_RSC_COMPARE_VALUE
,
108 ACPI_RS_OFFSET(data
.irq
.descriptor_length
),
111 /* Set length to 2 bytes (no flags byte) */
113 {ACPI_RSC_LENGTH
, 0, 0, sizeof(struct aml_resource_irq_noflags
)},
116 * All done if the output descriptor length is required to be 2.
118 * TBD: Perhaps we should check for error if input flags are not
119 * compatible with a 2-byte descriptor.
121 {ACPI_RSC_EXIT_EQ
, ACPI_RSC_COMPARE_VALUE
,
122 ACPI_RS_OFFSET(data
.irq
.descriptor_length
),
125 /* Reset length to 3 bytes (descriptor with flags byte) */
127 {ACPI_RSC_LENGTH
, 0, 0, sizeof(struct aml_resource_irq
)},
130 * Check if the flags byte is necessary. Not needed if the flags are:
131 * ACPI_EDGE_SENSITIVE, ACPI_ACTIVE_HIGH, ACPI_EXCLUSIVE
133 {ACPI_RSC_EXIT_NE
, ACPI_RSC_COMPARE_VALUE
,
134 ACPI_RS_OFFSET(data
.irq
.triggering
),
135 ACPI_EDGE_SENSITIVE
},
137 {ACPI_RSC_EXIT_NE
, ACPI_RSC_COMPARE_VALUE
,
138 ACPI_RS_OFFSET(data
.irq
.polarity
),
141 {ACPI_RSC_EXIT_NE
, ACPI_RSC_COMPARE_VALUE
,
142 ACPI_RS_OFFSET(data
.irq
.sharable
),
145 /* We can optimize to a 2-byte irq_no_flags() descriptor */
147 {ACPI_RSC_LENGTH
, 0, 0, sizeof(struct aml_resource_irq_noflags
)}
150 /*******************************************************************************
152 * acpi_rs_convert_ext_irq
154 ******************************************************************************/
156 struct acpi_rsconvert_info acpi_rs_convert_ext_irq
[10] = {
157 {ACPI_RSC_INITGET
, ACPI_RESOURCE_TYPE_EXTENDED_IRQ
,
158 ACPI_RS_SIZE(struct acpi_resource_extended_irq
),
159 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_ext_irq
)},
161 {ACPI_RSC_INITSET
, ACPI_RESOURCE_NAME_EXTENDED_IRQ
,
162 sizeof(struct aml_resource_extended_irq
),
166 * Flags: Producer/Consumer[0], Triggering[1], Polarity[2],
167 * Sharing[3], Wake[4]
169 {ACPI_RSC_1BITFLAG
, ACPI_RS_OFFSET(data
.extended_irq
.producer_consumer
),
170 AML_OFFSET(extended_irq
.flags
),
173 {ACPI_RSC_1BITFLAG
, ACPI_RS_OFFSET(data
.extended_irq
.triggering
),
174 AML_OFFSET(extended_irq
.flags
),
177 {ACPI_RSC_1BITFLAG
, ACPI_RS_OFFSET(data
.extended_irq
.polarity
),
178 AML_OFFSET(extended_irq
.flags
),
181 {ACPI_RSC_1BITFLAG
, ACPI_RS_OFFSET(data
.extended_irq
.sharable
),
182 AML_OFFSET(extended_irq
.flags
),
185 {ACPI_RSC_1BITFLAG
, ACPI_RS_OFFSET(data
.extended_irq
.wake_capable
),
186 AML_OFFSET(extended_irq
.flags
),
189 /* IRQ Table length (Byte4) */
191 {ACPI_RSC_COUNT
, ACPI_RS_OFFSET(data
.extended_irq
.interrupt_count
),
192 AML_OFFSET(extended_irq
.interrupt_count
),
195 /* Copy every IRQ in the table, each is 32 bits */
197 {ACPI_RSC_MOVE32
, ACPI_RS_OFFSET(data
.extended_irq
.interrupts
[0]),
198 AML_OFFSET(extended_irq
.interrupts
[0]),
201 /* Optional resource_source (Index and String) */
203 {ACPI_RSC_SOURCEX
, ACPI_RS_OFFSET(data
.extended_irq
.resource_source
),
204 ACPI_RS_OFFSET(data
.extended_irq
.interrupts
[0]),
205 sizeof(struct aml_resource_extended_irq
)}
208 /*******************************************************************************
210 * acpi_rs_convert_dma
212 ******************************************************************************/
214 struct acpi_rsconvert_info acpi_rs_convert_dma
[6] = {
215 {ACPI_RSC_INITGET
, ACPI_RESOURCE_TYPE_DMA
,
216 ACPI_RS_SIZE(struct acpi_resource_dma
),
217 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_dma
)},
219 {ACPI_RSC_INITSET
, ACPI_RESOURCE_NAME_DMA
,
220 sizeof(struct aml_resource_dma
),
223 /* Flags: transfer preference, bus mastering, channel speed */
225 {ACPI_RSC_2BITFLAG
, ACPI_RS_OFFSET(data
.dma
.transfer
),
226 AML_OFFSET(dma
.flags
),
229 {ACPI_RSC_1BITFLAG
, ACPI_RS_OFFSET(data
.dma
.bus_master
),
230 AML_OFFSET(dma
.flags
),
233 {ACPI_RSC_2BITFLAG
, ACPI_RS_OFFSET(data
.dma
.type
),
234 AML_OFFSET(dma
.flags
),
237 /* DMA channel mask bits */
239 {ACPI_RSC_BITMASK
, ACPI_RS_OFFSET(data
.dma
.channels
[0]),
240 AML_OFFSET(dma
.dma_channel_mask
),
241 ACPI_RS_OFFSET(data
.dma
.channel_count
)}
244 /*******************************************************************************
246 * acpi_rs_convert_fixed_dma
248 ******************************************************************************/
250 struct acpi_rsconvert_info acpi_rs_convert_fixed_dma
[4] = {
251 {ACPI_RSC_INITGET
, ACPI_RESOURCE_TYPE_FIXED_DMA
,
252 ACPI_RS_SIZE(struct acpi_resource_fixed_dma
),
253 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_fixed_dma
)},
255 {ACPI_RSC_INITSET
, ACPI_RESOURCE_NAME_FIXED_DMA
,
256 sizeof(struct aml_resource_fixed_dma
),
260 * These fields are contiguous in both the source and destination:
264 {ACPI_RSC_MOVE16
, ACPI_RS_OFFSET(data
.fixed_dma
.request_lines
),
265 AML_OFFSET(fixed_dma
.request_lines
),
268 {ACPI_RSC_MOVE8
, ACPI_RS_OFFSET(data
.fixed_dma
.width
),
269 AML_OFFSET(fixed_dma
.width
),