Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /******************************************************************************* |
| 2 | * |
| 3 | * Module Name: rsirq - IRQ resource descriptors |
| 4 | * |
| 5 | ******************************************************************************/ |
| 6 | |
| 7 | /* |
| 8 | * Copyright (C) 2000 - 2005, 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 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | #include <acpi/acpi.h> |
| 45 | #include <acpi/acresrc.h> |
| 46 | |
| 47 | #define _COMPONENT ACPI_RESOURCES |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 48 | ACPI_MODULE_NAME("rsirq") |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | |
| 50 | /******************************************************************************* |
| 51 | * |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 52 | * FUNCTION: acpi_rs_get_irq |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 | * |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 54 | * PARAMETERS: Aml - Pointer to the AML resource descriptor |
| 55 | * aml_resource_length - Length of the resource from the AML header |
| 56 | * Resource - Where the internal resource is returned |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 57 | * |
| 58 | * RETURN: Status |
| 59 | * |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 60 | * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding |
| 61 | * internal resource descriptor, simplifying bitflags and handling |
| 62 | * alignment and endian issues if necessary. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 63 | * |
| 64 | ******************************************************************************/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 65 | acpi_status |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 66 | acpi_rs_get_irq(union aml_resource *aml, |
| 67 | u16 aml_resource_length, struct acpi_resource *resource) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 68 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 69 | u16 temp16 = 0; |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 70 | u32 interrupt_count = 0; |
| 71 | u32 i; |
| 72 | u32 resource_length; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 73 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 74 | ACPI_FUNCTION_TRACE("rs_get_irq"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 75 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 76 | /* Get the IRQ mask (bytes 1:2) */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 77 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 78 | ACPI_MOVE_16_TO_16(&temp16, &aml->irq.irq_mask); |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 79 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 80 | /* Decode the IRQ bits (up to 16 possible) */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 81 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 82 | for (i = 0; i < 16; i++) { |
| 83 | if ((temp16 >> i) & 0x01) { |
| 84 | resource->data.irq.interrupts[interrupt_count] = i; |
| 85 | interrupt_count++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 86 | } |
| 87 | } |
| 88 | |
| 89 | /* Zero interrupts is valid */ |
| 90 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 91 | resource_length = 0; |
| 92 | resource->data.irq.interrupt_count = interrupt_count; |
| 93 | if (interrupt_count > 0) { |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 94 | /* Calculate the structure size based upon the number of interrupts */ |
| 95 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 96 | resource_length = (u32) (interrupt_count - 1) * 4; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 97 | } |
| 98 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 99 | /* Get Flags (Byte 3) if it is used */ |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 100 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 101 | if (aml_resource_length == 3) { |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 102 | /* Check for HE, LL interrupts */ |
| 103 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 104 | switch (aml->irq.flags & 0x09) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 105 | case 0x01: /* HE */ |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 106 | resource->data.irq.triggering = ACPI_EDGE_SENSITIVE; |
| 107 | resource->data.irq.polarity = ACPI_ACTIVE_HIGH; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 108 | break; |
| 109 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 110 | case 0x08: /* LL */ |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 111 | resource->data.irq.triggering = ACPI_LEVEL_SENSITIVE; |
| 112 | resource->data.irq.polarity = ACPI_ACTIVE_LOW; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 113 | break; |
| 114 | |
| 115 | default: |
| 116 | /* |
| 117 | * Only _LL and _HE polarity/trigger interrupts |
| 118 | * are allowed (ACPI spec, section "IRQ Format") |
| 119 | * so 0x00 and 0x09 are illegal. |
| 120 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 121 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, |
| 122 | "Invalid interrupt polarity/trigger in resource list, %X\n", |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 123 | aml->irq.flags)); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 124 | return_ACPI_STATUS(AE_BAD_DATA); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 125 | } |
| 126 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 127 | /* Get Sharing flag */ |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 128 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 129 | resource->data.irq.sharable = (aml->irq.flags >> 3) & 0x01; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 130 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 131 | /* |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 132 | * Default configuration: assume Edge Sensitive, Active High, |
| 133 | * Non-Sharable as per the ACPI Specification |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 134 | */ |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 135 | resource->data.irq.triggering = ACPI_EDGE_SENSITIVE; |
| 136 | resource->data.irq.polarity = ACPI_ACTIVE_HIGH; |
| 137 | resource->data.irq.sharable = ACPI_EXCLUSIVE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 138 | } |
| 139 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 140 | /* Complete the resource header */ |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 141 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 142 | resource->type = ACPI_RESOURCE_TYPE_IRQ; |
| 143 | resource->length = |
| 144 | resource_length + ACPI_SIZEOF_RESOURCE(struct acpi_resource_irq); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 145 | return_ACPI_STATUS(AE_OK); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 146 | } |
| 147 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 148 | /******************************************************************************* |
| 149 | * |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 150 | * FUNCTION: acpi_rs_set_irq |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 151 | * |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 152 | * PARAMETERS: Resource - Pointer to the resource descriptor |
| 153 | * Aml - Where the AML descriptor is returned |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 154 | * |
| 155 | * RETURN: Status |
| 156 | * |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 157 | * DESCRIPTION: Convert an internal resource descriptor to the corresponding |
| 158 | * external AML resource descriptor. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 159 | * |
| 160 | ******************************************************************************/ |
| 161 | |
| 162 | acpi_status |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 163 | acpi_rs_set_irq(struct acpi_resource *resource, union aml_resource *aml) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 164 | { |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 165 | acpi_size descriptor_length; |
| 166 | u16 irq_mask; |
| 167 | u8 i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 168 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 169 | ACPI_FUNCTION_TRACE("rs_set_irq"); |
| 170 | |
| 171 | /* Convert interrupt list to 16-bit IRQ bitmask */ |
| 172 | |
| 173 | irq_mask = 0; |
| 174 | for (i = 0; i < resource->data.irq.interrupt_count; i++) { |
| 175 | irq_mask |= (1 << resource->data.irq.interrupts[i]); |
| 176 | } |
| 177 | |
| 178 | /* Set the interrupt mask */ |
| 179 | |
| 180 | ACPI_MOVE_16_TO_16(&aml->irq.irq_mask, &irq_mask); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 181 | |
| 182 | /* |
| 183 | * The descriptor field is set based upon whether a third byte is |
| 184 | * needed to contain the IRQ Information. |
| 185 | */ |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 186 | if ((resource->data.irq.triggering == ACPI_EDGE_SENSITIVE) && |
| 187 | (resource->data.irq.polarity == ACPI_ACTIVE_HIGH) && |
| 188 | (resource->data.irq.sharable == ACPI_EXCLUSIVE)) { |
| 189 | /* irq_no_flags() descriptor can be used */ |
| 190 | |
| 191 | descriptor_length = sizeof(struct aml_resource_irq_noflags); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 192 | } else { |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 193 | /* Irq() descriptor must be used */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 194 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 195 | descriptor_length = sizeof(struct aml_resource_irq); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 196 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 197 | /* Set the IRQ Info byte */ |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 198 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 199 | aml->irq.flags = (u8) |
| 200 | ((resource->data.irq.sharable & 0x01) << 4); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 201 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 202 | if (ACPI_LEVEL_SENSITIVE == resource->data.irq.triggering && |
| 203 | ACPI_ACTIVE_LOW == resource->data.irq.polarity) { |
| 204 | aml->irq.flags |= 0x08; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 205 | } else { |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 206 | aml->irq.flags |= 0x01; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 207 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 208 | } |
| 209 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 210 | /* Complete the AML descriptor header */ |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 211 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 212 | acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_IRQ, descriptor_length, |
| 213 | aml); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 214 | return_ACPI_STATUS(AE_OK); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 215 | } |
| 216 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 217 | /******************************************************************************* |
| 218 | * |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 219 | * FUNCTION: acpi_rs_get_ext_irq |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 220 | * |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 221 | * PARAMETERS: Aml - Pointer to the AML resource descriptor |
| 222 | * aml_resource_length - Length of the resource from the AML header |
| 223 | * Resource - Where the internal resource is returned |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 224 | * |
| 225 | * RETURN: Status |
| 226 | * |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 227 | * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding |
| 228 | * internal resource descriptor, simplifying bitflags and handling |
| 229 | * alignment and endian issues if necessary. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 230 | * |
| 231 | ******************************************************************************/ |
| 232 | |
| 233 | acpi_status |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 234 | acpi_rs_get_ext_irq(union aml_resource *aml, |
| 235 | u16 aml_resource_length, struct acpi_resource *resource) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 236 | { |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 237 | char *out_resource_string; |
| 238 | u8 temp8; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 239 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 240 | ACPI_FUNCTION_TRACE("rs_get_ext_irq"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 241 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 242 | /* Get the flag bits */ |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 243 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 244 | temp8 = aml->extended_irq.flags; |
| 245 | resource->data.extended_irq.producer_consumer = temp8 & 0x01; |
| 246 | resource->data.extended_irq.polarity = (temp8 >> 2) & 0x01; |
| 247 | resource->data.extended_irq.sharable = (temp8 >> 3) & 0x01; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 248 | |
| 249 | /* |
| 250 | * Check for Interrupt Mode |
| 251 | * |
| 252 | * The definition of an Extended IRQ changed between ACPI spec v1.0b |
| 253 | * and ACPI spec 2.0 (section 6.4.3.6 in both). |
| 254 | * |
| 255 | * - Edge/Level are defined opposite in the table vs the headers |
| 256 | */ |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 257 | resource->data.extended_irq.triggering = |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 258 | (temp8 & 0x2) ? ACPI_EDGE_SENSITIVE : ACPI_LEVEL_SENSITIVE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 259 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 260 | /* Get the IRQ Table length (Byte4) */ |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 261 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 262 | temp8 = aml->extended_irq.table_length; |
| 263 | resource->data.extended_irq.interrupt_count = temp8; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 264 | if (temp8 < 1) { |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 265 | /* Must have at least one IRQ */ |
| 266 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 267 | return_ACPI_STATUS(AE_AML_BAD_RESOURCE_LENGTH); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 268 | } |
| 269 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 270 | /* |
| 271 | * Add any additional structure size to properly calculate |
| 272 | * the next pointer at the end of this function |
| 273 | */ |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 274 | resource->length = (temp8 - 1) * 4; |
| 275 | out_resource_string = ACPI_CAST_PTR(char, |
| 276 | (&resource->data.extended_irq. |
| 277 | interrupts[0] + temp8)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 278 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 279 | /* Get every IRQ in the table, each is 32 bits */ |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 280 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 281 | acpi_rs_move_data(resource->data.extended_irq.interrupts, |
| 282 | aml->extended_irq.interrupt_number, |
| 283 | (u16) temp8, ACPI_MOVE_TYPE_32_TO_32); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 284 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 285 | /* Get the optional resource_source (index and string) */ |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 286 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 287 | resource->length += |
| 288 | acpi_rs_get_resource_source(aml_resource_length, |
| 289 | (acpi_size) resource->length + |
| 290 | sizeof(struct |
| 291 | aml_resource_extended_irq), |
| 292 | &resource->data.extended_irq. |
| 293 | resource_source, aml, |
| 294 | out_resource_string); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 295 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 296 | /* Complete the resource header */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 297 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 298 | resource->type = ACPI_RESOURCE_TYPE_EXTENDED_IRQ; |
| 299 | resource->length += |
| 300 | ACPI_SIZEOF_RESOURCE(struct acpi_resource_extended_irq); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 301 | return_ACPI_STATUS(AE_OK); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 302 | } |
| 303 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 304 | /******************************************************************************* |
| 305 | * |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 306 | * FUNCTION: acpi_rs_set_ext_irq |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 307 | * |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 308 | * PARAMETERS: Resource - Pointer to the resource descriptor |
| 309 | * Aml - Where the AML descriptor is returned |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 310 | * |
| 311 | * RETURN: Status |
| 312 | * |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 313 | * DESCRIPTION: Convert an internal resource descriptor to the corresponding |
| 314 | * external AML resource descriptor. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 315 | * |
| 316 | ******************************************************************************/ |
| 317 | |
| 318 | acpi_status |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 319 | acpi_rs_set_ext_irq(struct acpi_resource *resource, union aml_resource *aml) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 320 | { |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 321 | acpi_size descriptor_length; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 322 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 323 | ACPI_FUNCTION_TRACE("rs_set_ext_irq"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 324 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 325 | /* Set the Interrupt vector flags */ |
| 326 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 327 | aml->extended_irq.flags = (u8) |
| 328 | ((resource->data.extended_irq.producer_consumer & 0x01) | |
| 329 | ((resource->data.extended_irq.sharable & 0x01) << 3) | |
| 330 | ((resource->data.extended_irq.polarity & 0x1) << 2)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 331 | |
| 332 | /* |
| 333 | * Set the Interrupt Mode |
| 334 | * |
| 335 | * The definition of an Extended IRQ changed between ACPI spec v1.0b |
| 336 | * and ACPI spec 2.0 (section 6.4.3.6 in both). This code does not |
| 337 | * implement the more restrictive definition of 1.0b |
| 338 | * |
| 339 | * - Edge/Level are defined opposite in the table vs the headers |
| 340 | */ |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 341 | if (resource->data.extended_irq.triggering == ACPI_EDGE_SENSITIVE) { |
| 342 | aml->extended_irq.flags |= 0x02; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 343 | } |
| 344 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 345 | /* Set the Interrupt table length */ |
| 346 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 347 | aml->extended_irq.table_length = (u8) |
| 348 | resource->data.extended_irq.interrupt_count; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 349 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 350 | descriptor_length = (sizeof(struct aml_resource_extended_irq) - 4) + |
| 351 | ((acpi_size) resource->data.extended_irq.interrupt_count * |
| 352 | sizeof(u32)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 353 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 354 | /* Set each interrupt value */ |
| 355 | |
| 356 | acpi_rs_move_data(aml->extended_irq.interrupt_number, |
| 357 | resource->data.extended_irq.interrupts, |
| 358 | (u16) resource->data.extended_irq.interrupt_count, |
| 359 | ACPI_MOVE_TYPE_32_TO_32); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 360 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 361 | /* Resource Source Index and Resource Source are optional */ |
| 362 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 363 | descriptor_length = acpi_rs_set_resource_source(aml, descriptor_length, |
| 364 | &resource->data. |
| 365 | extended_irq. |
| 366 | resource_source); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 367 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 368 | /* Complete the AML descriptor header */ |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 369 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 370 | acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_EXTENDED_IRQ, |
| 371 | descriptor_length, aml); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 372 | return_ACPI_STATUS(AE_OK); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 373 | } |