blob: 2e0256983aa60b7edf6ee5a21ad1e5896a8e0902 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*******************************************************************************
2 *
3 * Module Name: rsirq - IRQ resource descriptors
4 *
5 ******************************************************************************/
6
7/*
Len Brown75a44ce2008-04-23 23:00:13 -04008 * Copyright (C) 2000 - 2008, Intel Corp.
Linus Torvalds1da177e2005-04-16 15:20:36 -07009 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
Linus Torvalds1da177e2005-04-16 15:20:36 -070044#include <acpi/acpi.h>
Len Browne2f7a772009-01-09 00:30:03 -050045#include "accommon.h"
46#include "acresrc.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070047
48#define _COMPONENT ACPI_RESOURCES
Len Brown4be44fc2005-08-05 00:44:28 -040049ACPI_MODULE_NAME("rsirq")
Linus Torvalds1da177e2005-04-16 15:20:36 -070050
51/*******************************************************************************
52 *
Bob Moore08978312005-10-21 00:00:00 -040053 * acpi_rs_get_irq
Linus Torvalds1da177e2005-04-16 15:20:36 -070054 *
55 ******************************************************************************/
Bob Moore1d5b2852008-04-10 19:06:43 +040056struct acpi_rsconvert_info acpi_rs_get_irq[8] = {
Bob Moore08978312005-10-21 00:00:00 -040057 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_IRQ,
58 ACPI_RS_SIZE(struct acpi_resource_irq),
59 ACPI_RSC_TABLE_SIZE(acpi_rs_get_irq)},
Linus Torvalds1da177e2005-04-16 15:20:36 -070060
Bob Moore50eca3e2005-09-30 19:03:00 -040061 /* Get the IRQ mask (bytes 1:2) */
Linus Torvalds1da177e2005-04-16 15:20:36 -070062
Bob Moore08978312005-10-21 00:00:00 -040063 {ACPI_RSC_BITMASK16, ACPI_RS_OFFSET(data.irq.interrupts[0]),
64 AML_OFFSET(irq.irq_mask),
65 ACPI_RS_OFFSET(data.irq.interrupt_count)},
Robert Moore44f6c012005-04-18 22:49:35 -040066
Bob Moore08978312005-10-21 00:00:00 -040067 /* Set default flags (others are zero) */
Linus Torvalds1da177e2005-04-16 15:20:36 -070068
Bob Moore08978312005-10-21 00:00:00 -040069 {ACPI_RSC_SET8, ACPI_RS_OFFSET(data.irq.triggering),
70 ACPI_EDGE_SENSITIVE,
71 1},
Linus Torvalds1da177e2005-04-16 15:20:36 -070072
Bob Moore1d5b2852008-04-10 19:06:43 +040073 /* Get the descriptor length (2 or 3 for IRQ descriptor) */
74
75 {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET(data.irq.descriptor_length),
76 AML_OFFSET(irq.descriptor_type),
77 0},
78
Bob Moore08978312005-10-21 00:00:00 -040079 /* All done if no flag byte present in descriptor */
Linus Torvalds1da177e2005-04-16 15:20:36 -070080
Bob Moore08978312005-10-21 00:00:00 -040081 {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_AML_LENGTH, 0, 3},
Robert Moore44f6c012005-04-18 22:49:35 -040082
Bob Moore08978312005-10-21 00:00:00 -040083 /* Get flags: Triggering[0], Polarity[3], Sharing[4] */
Linus Torvalds1da177e2005-04-16 15:20:36 -070084
Bob Moore08978312005-10-21 00:00:00 -040085 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.irq.triggering),
86 AML_OFFSET(irq.flags),
87 0},
Robert Moore44f6c012005-04-18 22:49:35 -040088
Bob Moore08978312005-10-21 00:00:00 -040089 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.irq.polarity),
90 AML_OFFSET(irq.flags),
91 3},
Robert Moore44f6c012005-04-18 22:49:35 -040092
Bob Moore08978312005-10-21 00:00:00 -040093 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.irq.sharable),
94 AML_OFFSET(irq.flags),
95 4}
96};
Linus Torvalds1da177e2005-04-16 15:20:36 -070097
Linus Torvalds1da177e2005-04-16 15:20:36 -070098/*******************************************************************************
99 *
Bob Moore08978312005-10-21 00:00:00 -0400100 * acpi_rs_set_irq
Linus Torvalds1da177e2005-04-16 15:20:36 -0700101 *
102 ******************************************************************************/
103
Bob Moore1d5b2852008-04-10 19:06:43 +0400104struct acpi_rsconvert_info acpi_rs_set_irq[13] = {
105 /* Start with a default descriptor of length 3 */
106
Bob Moore08978312005-10-21 00:00:00 -0400107 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_IRQ,
108 sizeof(struct aml_resource_irq),
109 ACPI_RSC_TABLE_SIZE(acpi_rs_set_irq)},
Bob Moore50eca3e2005-09-30 19:03:00 -0400110
111 /* Convert interrupt list to 16-bit IRQ bitmask */
112
Bob Moore08978312005-10-21 00:00:00 -0400113 {ACPI_RSC_BITMASK16, ACPI_RS_OFFSET(data.irq.interrupts[0]),
114 AML_OFFSET(irq.irq_mask),
115 ACPI_RS_OFFSET(data.irq.interrupt_count)},
Bob Moore50eca3e2005-09-30 19:03:00 -0400116
Bob Moore1d5b2852008-04-10 19:06:43 +0400117 /* Set the flags byte */
Bob Moore50eca3e2005-09-30 19:03:00 -0400118
Bob Moore08978312005-10-21 00:00:00 -0400119 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.irq.triggering),
120 AML_OFFSET(irq.flags),
121 0},
Linus Torvalds1da177e2005-04-16 15:20:36 -0700122
Bob Moore08978312005-10-21 00:00:00 -0400123 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.irq.polarity),
124 AML_OFFSET(irq.flags),
125 3},
126
127 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.irq.sharable),
128 AML_OFFSET(irq.flags),
129 4},
Bob Moore1d5b2852008-04-10 19:06:43 +0400130
131 /*
132 * All done if the output descriptor length is required to be 3
133 * (i.e., optimization to 2 bytes cannot be attempted)
134 */
135 {ACPI_RSC_EXIT_EQ, ACPI_RSC_COMPARE_VALUE,
136 ACPI_RS_OFFSET(data.irq.descriptor_length),
137 3},
138
139 /* Set length to 2 bytes (no flags byte) */
140
141 {ACPI_RSC_LENGTH, 0, 0, sizeof(struct aml_resource_irq_noflags)},
142
143 /*
144 * All done if the output descriptor length is required to be 2.
145 *
146 * TBD: Perhaps we should check for error if input flags are not
147 * compatible with a 2-byte descriptor.
148 */
149 {ACPI_RSC_EXIT_EQ, ACPI_RSC_COMPARE_VALUE,
150 ACPI_RS_OFFSET(data.irq.descriptor_length),
151 2},
152
153 /* Reset length to 3 bytes (descriptor with flags byte) */
154
155 {ACPI_RSC_LENGTH, 0, 0, sizeof(struct aml_resource_irq)},
156
Linus Torvalds1da177e2005-04-16 15:20:36 -0700157 /*
Bob Moore08978312005-10-21 00:00:00 -0400158 * Check if the flags byte is necessary. Not needed if the flags are:
159 * ACPI_EDGE_SENSITIVE, ACPI_ACTIVE_HIGH, ACPI_EXCLUSIVE
Linus Torvalds1da177e2005-04-16 15:20:36 -0700160 */
Bob Moore08978312005-10-21 00:00:00 -0400161 {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_VALUE,
162 ACPI_RS_OFFSET(data.irq.triggering),
163 ACPI_EDGE_SENSITIVE},
Bob Moore50eca3e2005-09-30 19:03:00 -0400164
Bob Moore08978312005-10-21 00:00:00 -0400165 {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_VALUE,
166 ACPI_RS_OFFSET(data.irq.polarity),
167 ACPI_ACTIVE_HIGH},
Linus Torvalds1da177e2005-04-16 15:20:36 -0700168
Bob Moore08978312005-10-21 00:00:00 -0400169 {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_VALUE,
170 ACPI_RS_OFFSET(data.irq.sharable),
171 ACPI_EXCLUSIVE},
Linus Torvalds1da177e2005-04-16 15:20:36 -0700172
Bob Moore1d5b2852008-04-10 19:06:43 +0400173 /* We can optimize to a 2-byte irq_no_flags() descriptor */
Robert Moore44f6c012005-04-18 22:49:35 -0400174
Bob Moore08978312005-10-21 00:00:00 -0400175 {ACPI_RSC_LENGTH, 0, 0, sizeof(struct aml_resource_irq_noflags)}
176};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700177
Linus Torvalds1da177e2005-04-16 15:20:36 -0700178/*******************************************************************************
179 *
Bob Moore08978312005-10-21 00:00:00 -0400180 * acpi_rs_convert_ext_irq
Linus Torvalds1da177e2005-04-16 15:20:36 -0700181 *
182 ******************************************************************************/
183
Bob Moore08978312005-10-21 00:00:00 -0400184struct acpi_rsconvert_info acpi_rs_convert_ext_irq[9] = {
185 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_EXTENDED_IRQ,
186 ACPI_RS_SIZE(struct acpi_resource_extended_irq),
187 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_ext_irq)},
Linus Torvalds1da177e2005-04-16 15:20:36 -0700188
Bob Moore08978312005-10-21 00:00:00 -0400189 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_EXTENDED_IRQ,
190 sizeof(struct aml_resource_extended_irq),
191 0},
Linus Torvalds1da177e2005-04-16 15:20:36 -0700192
Bob Moore08978312005-10-21 00:00:00 -0400193 /* Flag bits */
Robert Moore44f6c012005-04-18 22:49:35 -0400194
Bob Moore08978312005-10-21 00:00:00 -0400195 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.extended_irq.producer_consumer),
196 AML_OFFSET(extended_irq.flags),
197 0},
Linus Torvalds1da177e2005-04-16 15:20:36 -0700198
Bob Moore08978312005-10-21 00:00:00 -0400199 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.extended_irq.triggering),
200 AML_OFFSET(extended_irq.flags),
201 1},
Linus Torvalds1da177e2005-04-16 15:20:36 -0700202
Bob Moore08978312005-10-21 00:00:00 -0400203 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.extended_irq.polarity),
204 AML_OFFSET(extended_irq.flags),
205 2},
Robert Moore44f6c012005-04-18 22:49:35 -0400206
Bob Moore08978312005-10-21 00:00:00 -0400207 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.extended_irq.sharable),
208 AML_OFFSET(extended_irq.flags),
209 3},
Bob Moore50eca3e2005-09-30 19:03:00 -0400210
Bob Moore08978312005-10-21 00:00:00 -0400211 /* IRQ Table length (Byte4) */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700212
Bob Moore08978312005-10-21 00:00:00 -0400213 {ACPI_RSC_COUNT, ACPI_RS_OFFSET(data.extended_irq.interrupt_count),
214 AML_OFFSET(extended_irq.interrupt_count),
215 sizeof(u32)}
216 ,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700217
Bob Moore08978312005-10-21 00:00:00 -0400218 /* Copy every IRQ in the table, each is 32 bits */
Robert Moore44f6c012005-04-18 22:49:35 -0400219
Bob Moore08978312005-10-21 00:00:00 -0400220 {ACPI_RSC_MOVE32, ACPI_RS_OFFSET(data.extended_irq.interrupts[0]),
221 AML_OFFSET(extended_irq.interrupts[0]),
222 0}
223 ,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700224
Bob Moore08978312005-10-21 00:00:00 -0400225 /* Optional resource_source (Index and String) */
Robert Moore44f6c012005-04-18 22:49:35 -0400226
Bob Moore08978312005-10-21 00:00:00 -0400227 {ACPI_RSC_SOURCEX, ACPI_RS_OFFSET(data.extended_irq.resource_source),
228 ACPI_RS_OFFSET(data.extended_irq.interrupts[0]),
229 sizeof(struct aml_resource_extended_irq)}
230};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700231
Linus Torvalds1da177e2005-04-16 15:20:36 -0700232/*******************************************************************************
233 *
Bob Moore08978312005-10-21 00:00:00 -0400234 * acpi_rs_convert_dma
Linus Torvalds1da177e2005-04-16 15:20:36 -0700235 *
236 ******************************************************************************/
237
Bob Moore08978312005-10-21 00:00:00 -0400238struct acpi_rsconvert_info acpi_rs_convert_dma[6] = {
239 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_DMA,
240 ACPI_RS_SIZE(struct acpi_resource_dma),
241 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_dma)},
Linus Torvalds1da177e2005-04-16 15:20:36 -0700242
Bob Moore08978312005-10-21 00:00:00 -0400243 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_DMA,
244 sizeof(struct aml_resource_dma),
245 0},
Linus Torvalds1da177e2005-04-16 15:20:36 -0700246
Bob Moore08978312005-10-21 00:00:00 -0400247 /* Flags: transfer preference, bus mastering, channel speed */
Robert Moore44f6c012005-04-18 22:49:35 -0400248
Bob Moore08978312005-10-21 00:00:00 -0400249 {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET(data.dma.transfer),
250 AML_OFFSET(dma.flags),
251 0},
Linus Torvalds1da177e2005-04-16 15:20:36 -0700252
Bob Moore08978312005-10-21 00:00:00 -0400253 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.dma.bus_master),
254 AML_OFFSET(dma.flags),
255 2},
Linus Torvalds1da177e2005-04-16 15:20:36 -0700256
Bob Moore08978312005-10-21 00:00:00 -0400257 {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET(data.dma.type),
258 AML_OFFSET(dma.flags),
259 5},
Robert Moore44f6c012005-04-18 22:49:35 -0400260
Bob Moore08978312005-10-21 00:00:00 -0400261 /* DMA channel mask bits */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700262
Bob Moore08978312005-10-21 00:00:00 -0400263 {ACPI_RSC_BITMASK, ACPI_RS_OFFSET(data.dma.channels[0]),
264 AML_OFFSET(dma.dma_channel_mask),
265 ACPI_RS_OFFSET(data.dma.channel_count)}
266};