Merge master.kernel.org:/pub/scm/linux/kernel/git/sfrench/cifs-2.6
[linux-2.6] / drivers / acpi / resources / rsirq.c
1 /*******************************************************************************
2  *
3  * Module Name: rsirq - IRQ resource descriptors
4  *
5  ******************************************************************************/
6
7 /*
8  * Copyright (C) 2000 - 2007, R. Byron Moore
9  * 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
44 #include <acpi/acpi.h>
45 #include <acpi/acresrc.h>
46
47 #define _COMPONENT          ACPI_RESOURCES
48 ACPI_MODULE_NAME("rsirq")
49
50 /*******************************************************************************
51  *
52  * acpi_rs_get_irq
53  *
54  ******************************************************************************/
55 struct acpi_rsconvert_info acpi_rs_get_irq[7] = {
56         {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_IRQ,
57          ACPI_RS_SIZE(struct acpi_resource_irq),
58          ACPI_RSC_TABLE_SIZE(acpi_rs_get_irq)},
59
60         /* Get the IRQ mask (bytes 1:2) */
61
62         {ACPI_RSC_BITMASK16, ACPI_RS_OFFSET(data.irq.interrupts[0]),
63          AML_OFFSET(irq.irq_mask),
64          ACPI_RS_OFFSET(data.irq.interrupt_count)},
65
66         /* Set default flags (others are zero) */
67
68         {ACPI_RSC_SET8, ACPI_RS_OFFSET(data.irq.triggering),
69          ACPI_EDGE_SENSITIVE,
70          1},
71
72         /* All done if no flag byte present in descriptor */
73
74         {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_AML_LENGTH, 0, 3},
75
76         /* Get flags: Triggering[0], Polarity[3], Sharing[4] */
77
78         {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.irq.triggering),
79          AML_OFFSET(irq.flags),
80          0},
81
82         {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.irq.polarity),
83          AML_OFFSET(irq.flags),
84          3},
85
86         {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.irq.sharable),
87          AML_OFFSET(irq.flags),
88          4}
89 };
90
91 /*******************************************************************************
92  *
93  * acpi_rs_set_irq
94  *
95  ******************************************************************************/
96
97 struct acpi_rsconvert_info acpi_rs_set_irq[9] = {
98         {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_IRQ,
99          sizeof(struct aml_resource_irq),
100          ACPI_RSC_TABLE_SIZE(acpi_rs_set_irq)},
101
102         /* Convert interrupt list to 16-bit IRQ bitmask */
103
104         {ACPI_RSC_BITMASK16, ACPI_RS_OFFSET(data.irq.interrupts[0]),
105          AML_OFFSET(irq.irq_mask),
106          ACPI_RS_OFFSET(data.irq.interrupt_count)},
107
108         /* Set the flags byte by default */
109
110         {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.irq.triggering),
111          AML_OFFSET(irq.flags),
112          0},
113
114         {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.irq.polarity),
115          AML_OFFSET(irq.flags),
116          3},
117
118         {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.irq.sharable),
119          AML_OFFSET(irq.flags),
120          4},
121         /*
122          * Check if the flags byte is necessary. Not needed if the flags are:
123          * ACPI_EDGE_SENSITIVE, ACPI_ACTIVE_HIGH, ACPI_EXCLUSIVE
124          */
125         {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_VALUE,
126          ACPI_RS_OFFSET(data.irq.triggering),
127          ACPI_EDGE_SENSITIVE},
128
129         {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_VALUE,
130          ACPI_RS_OFFSET(data.irq.polarity),
131          ACPI_ACTIVE_HIGH},
132
133         {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_VALUE,
134          ACPI_RS_OFFSET(data.irq.sharable),
135          ACPI_EXCLUSIVE},
136
137         /* irq_no_flags() descriptor can be used */
138
139         {ACPI_RSC_LENGTH, 0, 0, sizeof(struct aml_resource_irq_noflags)}
140 };
141
142 /*******************************************************************************
143  *
144  * acpi_rs_convert_ext_irq
145  *
146  ******************************************************************************/
147
148 struct acpi_rsconvert_info acpi_rs_convert_ext_irq[9] = {
149         {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_EXTENDED_IRQ,
150          ACPI_RS_SIZE(struct acpi_resource_extended_irq),
151          ACPI_RSC_TABLE_SIZE(acpi_rs_convert_ext_irq)},
152
153         {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_EXTENDED_IRQ,
154          sizeof(struct aml_resource_extended_irq),
155          0},
156
157         /* Flag bits */
158
159         {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.extended_irq.producer_consumer),
160          AML_OFFSET(extended_irq.flags),
161          0},
162
163         {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.extended_irq.triggering),
164          AML_OFFSET(extended_irq.flags),
165          1},
166
167         {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.extended_irq.polarity),
168          AML_OFFSET(extended_irq.flags),
169          2},
170
171         {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.extended_irq.sharable),
172          AML_OFFSET(extended_irq.flags),
173          3},
174
175         /* IRQ Table length (Byte4) */
176
177         {ACPI_RSC_COUNT, ACPI_RS_OFFSET(data.extended_irq.interrupt_count),
178          AML_OFFSET(extended_irq.interrupt_count),
179          sizeof(u32)}
180         ,
181
182         /* Copy every IRQ in the table, each is 32 bits */
183
184         {ACPI_RSC_MOVE32, ACPI_RS_OFFSET(data.extended_irq.interrupts[0]),
185          AML_OFFSET(extended_irq.interrupts[0]),
186          0}
187         ,
188
189         /* Optional resource_source (Index and String) */
190
191         {ACPI_RSC_SOURCEX, ACPI_RS_OFFSET(data.extended_irq.resource_source),
192          ACPI_RS_OFFSET(data.extended_irq.interrupts[0]),
193          sizeof(struct aml_resource_extended_irq)}
194 };
195
196 /*******************************************************************************
197  *
198  * acpi_rs_convert_dma
199  *
200  ******************************************************************************/
201
202 struct acpi_rsconvert_info acpi_rs_convert_dma[6] = {
203         {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_DMA,
204          ACPI_RS_SIZE(struct acpi_resource_dma),
205          ACPI_RSC_TABLE_SIZE(acpi_rs_convert_dma)},
206
207         {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_DMA,
208          sizeof(struct aml_resource_dma),
209          0},
210
211         /* Flags: transfer preference, bus mastering, channel speed */
212
213         {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET(data.dma.transfer),
214          AML_OFFSET(dma.flags),
215          0},
216
217         {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.dma.bus_master),
218          AML_OFFSET(dma.flags),
219          2},
220
221         {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET(data.dma.type),
222          AML_OFFSET(dma.flags),
223          5},
224
225         /* DMA channel mask bits */
226
227         {ACPI_RSC_BITMASK, ACPI_RS_OFFSET(data.dma.channels[0]),
228          AML_OFFSET(dma.dma_channel_mask),
229          ACPI_RS_OFFSET(data.dma.channel_count)}
230 };