Linux 2.6.17.7
[linux/fpc-iii.git] / drivers / acpi / resources / rsirq.c
blob1fa63bc2e36f54dac2a03766a0dfc33fef2e094d
1 /*******************************************************************************
3 * Module Name: rsirq - IRQ resource descriptors
5 ******************************************************************************/
7 /*
8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved.
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.
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.
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.
44 #include <acpi/acpi.h>
45 #include <acpi/acresrc.h>
47 #define _COMPONENT ACPI_RESOURCES
48 ACPI_MODULE_NAME("rsirq")
50 /*******************************************************************************
52 * acpi_rs_get_irq
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)},
60 /* Get the IRQ mask (bytes 1:2) */
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)},
66 /* Set default flags (others are zero) */
68 {ACPI_RSC_SET8, ACPI_RS_OFFSET(data.irq.triggering),
69 ACPI_EDGE_SENSITIVE,
70 1},
72 /* All done if no flag byte present in descriptor */
74 {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_AML_LENGTH, 0, 3},
76 /* Get flags: Triggering[0], Polarity[3], Sharing[4] */
78 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.irq.triggering),
79 AML_OFFSET(irq.flags),
80 0},
82 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.irq.polarity),
83 AML_OFFSET(irq.flags),
84 3},
86 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.irq.sharable),
87 AML_OFFSET(irq.flags),
91 /*******************************************************************************
93 * acpi_rs_set_irq
95 ******************************************************************************/
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)},
102 /* Convert interrupt list to 16-bit IRQ bitmask */
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)},
108 /* Set the flags byte by default */
110 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.irq.triggering),
111 AML_OFFSET(irq.flags),
114 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.irq.polarity),
115 AML_OFFSET(irq.flags),
118 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.irq.sharable),
119 AML_OFFSET(irq.flags),
122 * Check if the flags byte is necessary. Not needed if the flags are:
123 * ACPI_EDGE_SENSITIVE, ACPI_ACTIVE_HIGH, ACPI_EXCLUSIVE
125 {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_VALUE,
126 ACPI_RS_OFFSET(data.irq.triggering),
127 ACPI_EDGE_SENSITIVE},
129 {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_VALUE,
130 ACPI_RS_OFFSET(data.irq.polarity),
131 ACPI_ACTIVE_HIGH},
133 {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_VALUE,
134 ACPI_RS_OFFSET(data.irq.sharable),
135 ACPI_EXCLUSIVE},
137 /* irq_no_flags() descriptor can be used */
139 {ACPI_RSC_LENGTH, 0, 0, sizeof(struct aml_resource_irq_noflags)}
142 /*******************************************************************************
144 * acpi_rs_convert_ext_irq
146 ******************************************************************************/
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)},
153 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_EXTENDED_IRQ,
154 sizeof(struct aml_resource_extended_irq),
157 /* Flag bits */
159 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.extended_irq.producer_consumer),
160 AML_OFFSET(extended_irq.flags),
163 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.extended_irq.triggering),
164 AML_OFFSET(extended_irq.flags),
167 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.extended_irq.polarity),
168 AML_OFFSET(extended_irq.flags),
171 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.extended_irq.sharable),
172 AML_OFFSET(extended_irq.flags),
175 /* IRQ Table length (Byte4) */
177 {ACPI_RSC_COUNT, ACPI_RS_OFFSET(data.extended_irq.interrupt_count),
178 AML_OFFSET(extended_irq.interrupt_count),
179 sizeof(u32)}
182 /* Copy every IRQ in the table, each is 32 bits */
184 {ACPI_RSC_MOVE32, ACPI_RS_OFFSET(data.extended_irq.interrupts[0]),
185 AML_OFFSET(extended_irq.interrupts[0]),
189 /* Optional resource_source (Index and String) */
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)}
196 /*******************************************************************************
198 * acpi_rs_convert_dma
200 ******************************************************************************/
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)},
207 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_DMA,
208 sizeof(struct aml_resource_dma),
211 /* Flags: transfer preference, bus mastering, channel speed */
213 {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET(data.dma.transfer),
214 AML_OFFSET(dma.flags),
217 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.dma.bus_master),
218 AML_OFFSET(dma.flags),
221 {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET(data.dma.type),
222 AML_OFFSET(dma.flags),
225 /* DMA channel mask bits */
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)}