Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /****************************************************************************** |
| 2 | * |
| 3 | * Module Name: amlresrc.h - AML resource descriptors |
| 4 | * |
| 5 | *****************************************************************************/ |
| 6 | |
| 7 | /* |
Bob Moore | 7735ca0 | 2017-02-08 11:00:08 +0800 | [diff] [blame] | 8 | * Copyright (C) 2000 - 2017, Intel Corp. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | |
Bob Moore | 61686124 | 2006-03-17 16:44:00 -0500 | [diff] [blame] | 44 | /* acpisrc:struct_defs -- for acpisrc conversion */ |
| 45 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 46 | #ifndef __AMLRESRC_H |
| 47 | #define __AMLRESRC_H |
| 48 | |
Bob Moore | 61686124 | 2006-03-17 16:44:00 -0500 | [diff] [blame] | 49 | /* |
| 50 | * Resource descriptor tags, as defined in the ACPI specification. |
| 51 | * Used to symbolically reference fields within a descriptor. |
| 52 | */ |
Bob Moore | 8313524 | 2006-10-03 00:00:00 -0400 | [diff] [blame] | 53 | #define ACPI_RESTAG_ADDRESS "_ADR" |
| 54 | #define ACPI_RESTAG_ALIGNMENT "_ALN" |
| 55 | #define ACPI_RESTAG_ADDRESSSPACE "_ASI" |
| 56 | #define ACPI_RESTAG_ACCESSSIZE "_ASZ" |
| 57 | #define ACPI_RESTAG_TYPESPECIFICATTRIBUTES "_ATT" |
| 58 | #define ACPI_RESTAG_BASEADDRESS "_BAS" |
| 59 | #define ACPI_RESTAG_BUSMASTER "_BM_" /* Master(1), Slave(0) */ |
Lin Ming | e0fe0a8 | 2011-11-16 14:38:13 +0800 | [diff] [blame] | 60 | #define ACPI_RESTAG_DEBOUNCETIME "_DBT" |
Bob Moore | 8313524 | 2006-10-03 00:00:00 -0400 | [diff] [blame] | 61 | #define ACPI_RESTAG_DECODE "_DEC" |
Lin Ming | e0fe0a8 | 2011-11-16 14:38:13 +0800 | [diff] [blame] | 62 | #define ACPI_RESTAG_DEVICEPOLARITY "_DPL" |
Bob Moore | 8313524 | 2006-10-03 00:00:00 -0400 | [diff] [blame] | 63 | #define ACPI_RESTAG_DMA "_DMA" |
| 64 | #define ACPI_RESTAG_DMATYPE "_TYP" /* Compatible(0), A(1), B(2), F(3) */ |
Lin Ming | e0fe0a8 | 2011-11-16 14:38:13 +0800 | [diff] [blame] | 65 | #define ACPI_RESTAG_DRIVESTRENGTH "_DRS" |
| 66 | #define ACPI_RESTAG_ENDIANNESS "_END" |
| 67 | #define ACPI_RESTAG_FLOWCONTROL "_FLC" |
Mika Westerberg | 2b72693 | 2017-06-05 16:39:14 +0800 | [diff] [blame] | 68 | #define ACPI_RESTAG_FUNCTION "_FUN" |
Bob Moore | 8313524 | 2006-10-03 00:00:00 -0400 | [diff] [blame] | 69 | #define ACPI_RESTAG_GRANULARITY "_GRA" |
| 70 | #define ACPI_RESTAG_INTERRUPT "_INT" |
Bob Moore | 958dd24 | 2006-05-12 17:12:00 -0400 | [diff] [blame] | 71 | #define ACPI_RESTAG_INTERRUPTLEVEL "_LL_" /* active_lo(1), active_hi(0) */ |
| 72 | #define ACPI_RESTAG_INTERRUPTSHARE "_SHR" /* Shareable(1), no_share(0) */ |
Bob Moore | 8313524 | 2006-10-03 00:00:00 -0400 | [diff] [blame] | 73 | #define ACPI_RESTAG_INTERRUPTTYPE "_HE_" /* Edge(1), Level(0) */ |
Lin Ming | e0fe0a8 | 2011-11-16 14:38:13 +0800 | [diff] [blame] | 74 | #define ACPI_RESTAG_IORESTRICTION "_IOR" |
Bob Moore | 8313524 | 2006-10-03 00:00:00 -0400 | [diff] [blame] | 75 | #define ACPI_RESTAG_LENGTH "_LEN" |
Lin Ming | e0fe0a8 | 2011-11-16 14:38:13 +0800 | [diff] [blame] | 76 | #define ACPI_RESTAG_LINE "_LIN" |
Bob Moore | 8313524 | 2006-10-03 00:00:00 -0400 | [diff] [blame] | 77 | #define ACPI_RESTAG_MEMATTRIBUTES "_MTP" /* Memory(0), Reserved(1), ACPI(2), NVS(3) */ |
Bob Moore | 958dd24 | 2006-05-12 17:12:00 -0400 | [diff] [blame] | 78 | #define ACPI_RESTAG_MEMTYPE "_MEM" /* non_cache(0), Cacheable(1) Cache+combine(2), Cache+prefetch(3) */ |
Bob Moore | 8313524 | 2006-10-03 00:00:00 -0400 | [diff] [blame] | 79 | #define ACPI_RESTAG_MAXADDR "_MAX" |
| 80 | #define ACPI_RESTAG_MINADDR "_MIN" |
| 81 | #define ACPI_RESTAG_MAXTYPE "_MAF" |
| 82 | #define ACPI_RESTAG_MINTYPE "_MIF" |
Lin Ming | e0fe0a8 | 2011-11-16 14:38:13 +0800 | [diff] [blame] | 83 | #define ACPI_RESTAG_MODE "_MOD" |
| 84 | #define ACPI_RESTAG_PARITY "_PAR" |
| 85 | #define ACPI_RESTAG_PHASE "_PHA" |
| 86 | #define ACPI_RESTAG_PIN "_PIN" |
| 87 | #define ACPI_RESTAG_PINCONFIG "_PPI" |
Mika Westerberg | 97028ce | 2017-06-05 16:39:19 +0800 | [diff] [blame] | 88 | #define ACPI_RESTAG_PINCONFIG_TYPE "_TYP" |
| 89 | #define ACPI_RESTAG_PINCONFIG_VALUE "_VAL" |
Lin Ming | e0fe0a8 | 2011-11-16 14:38:13 +0800 | [diff] [blame] | 90 | #define ACPI_RESTAG_POLARITY "_POL" |
Bob Moore | 8313524 | 2006-10-03 00:00:00 -0400 | [diff] [blame] | 91 | #define ACPI_RESTAG_REGISTERBITOFFSET "_RBO" |
| 92 | #define ACPI_RESTAG_REGISTERBITWIDTH "_RBW" |
| 93 | #define ACPI_RESTAG_RANGETYPE "_RNG" |
Bob Moore | 958dd24 | 2006-05-12 17:12:00 -0400 | [diff] [blame] | 94 | #define ACPI_RESTAG_READWRITETYPE "_RW_" /* read_only(0), Writeable (1) */ |
Lin Ming | e0fe0a8 | 2011-11-16 14:38:13 +0800 | [diff] [blame] | 95 | #define ACPI_RESTAG_LENGTH_RX "_RXL" |
| 96 | #define ACPI_RESTAG_LENGTH_TX "_TXL" |
| 97 | #define ACPI_RESTAG_SLAVEMODE "_SLV" |
| 98 | #define ACPI_RESTAG_SPEED "_SPE" |
| 99 | #define ACPI_RESTAG_STOPBITS "_STB" |
Bob Moore | 8313524 | 2006-10-03 00:00:00 -0400 | [diff] [blame] | 100 | #define ACPI_RESTAG_TRANSLATION "_TRA" |
| 101 | #define ACPI_RESTAG_TRANSTYPE "_TRS" /* Sparse(1), Dense(0) */ |
| 102 | #define ACPI_RESTAG_TYPE "_TTP" /* Translation(1), Static (0) */ |
Bob Moore | ba494be | 2012-07-12 09:40:10 +0800 | [diff] [blame] | 103 | #define ACPI_RESTAG_XFERTYPE "_SIZ" /* 8(0), 8And16(1), 16(2) */ |
Lin Ming | e0fe0a8 | 2011-11-16 14:38:13 +0800 | [diff] [blame] | 104 | #define ACPI_RESTAG_VENDORDATA "_VEN" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 105 | |
| 106 | /* Default sizes for "small" resource descriptors */ |
| 107 | |
| 108 | #define ASL_RDESC_IRQ_SIZE 0x02 |
| 109 | #define ASL_RDESC_DMA_SIZE 0x02 |
| 110 | #define ASL_RDESC_ST_DEPEND_SIZE 0x00 |
| 111 | #define ASL_RDESC_END_DEPEND_SIZE 0x00 |
| 112 | #define ASL_RDESC_IO_SIZE 0x07 |
| 113 | #define ASL_RDESC_FIXED_IO_SIZE 0x03 |
Lin Ming | e0fe0a8 | 2011-11-16 14:38:13 +0800 | [diff] [blame] | 114 | #define ASL_RDESC_FIXED_DMA_SIZE 0x05 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 115 | #define ASL_RDESC_END_TAG_SIZE 0x01 |
| 116 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 117 | struct asl_resource_node { |
| 118 | u32 buffer_length; |
| 119 | void *buffer; |
| 120 | struct asl_resource_node *next; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 121 | }; |
| 122 | |
Bob Moore | f2d348f | 2014-10-10 10:40:11 +0800 | [diff] [blame] | 123 | struct asl_resource_info { |
| 124 | union acpi_parse_object *descriptor_type_op; /* Resource descriptor parse node */ |
| 125 | union acpi_parse_object *mapping_op; /* Used for mapfile support */ |
| 126 | u32 current_byte_offset; /* Offset in resource template */ |
| 127 | }; |
| 128 | |
Bob Moore | 96db255 | 2005-11-02 00:00:00 -0500 | [diff] [blame] | 129 | /* Macros used to generate AML resource length fields */ |
| 130 | |
| 131 | #define ACPI_AML_SIZE_LARGE(r) (sizeof (r) - sizeof (struct aml_resource_large_header)) |
| 132 | #define ACPI_AML_SIZE_SMALL(r) (sizeof (r) - sizeof (struct aml_resource_small_header)) |
| 133 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 134 | /* |
| 135 | * Resource descriptors defined in the ACPI specification. |
| 136 | * |
| 137 | * Packing/alignment must be BYTE because these descriptors |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 138 | * are used to overlay the raw AML byte stream. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 139 | */ |
| 140 | #pragma pack(1) |
| 141 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 142 | /* |
| 143 | * SMALL descriptors |
| 144 | */ |
| 145 | #define AML_RESOURCE_SMALL_HEADER_COMMON \ |
Bob Moore | 61686124 | 2006-03-17 16:44:00 -0500 | [diff] [blame] | 146 | u8 descriptor_type; |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 147 | |
| 148 | struct aml_resource_small_header { |
| 149 | AML_RESOURCE_SMALL_HEADER_COMMON}; |
| 150 | |
| 151 | struct aml_resource_irq { |
| 152 | AML_RESOURCE_SMALL_HEADER_COMMON u16 irq_mask; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 153 | u8 flags; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 154 | }; |
| 155 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 156 | struct aml_resource_irq_noflags { |
| 157 | AML_RESOURCE_SMALL_HEADER_COMMON u16 irq_mask; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 158 | }; |
| 159 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 160 | struct aml_resource_dma { |
| 161 | AML_RESOURCE_SMALL_HEADER_COMMON u8 dma_channel_mask; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 162 | u8 flags; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 163 | }; |
| 164 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 165 | struct aml_resource_start_dependent { |
| 166 | AML_RESOURCE_SMALL_HEADER_COMMON u8 flags; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 167 | }; |
| 168 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 169 | struct aml_resource_start_dependent_noprio { |
| 170 | AML_RESOURCE_SMALL_HEADER_COMMON}; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 171 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 172 | struct aml_resource_end_dependent { |
| 173 | AML_RESOURCE_SMALL_HEADER_COMMON}; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 174 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 175 | struct aml_resource_io { |
Bob Moore | 0897831 | 2005-10-21 00:00:00 -0400 | [diff] [blame] | 176 | AML_RESOURCE_SMALL_HEADER_COMMON u8 flags; |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 177 | u16 minimum; |
| 178 | u16 maximum; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 179 | u8 alignment; |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 180 | u8 address_length; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 181 | }; |
| 182 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 183 | struct aml_resource_fixed_io { |
| 184 | AML_RESOURCE_SMALL_HEADER_COMMON u16 address; |
| 185 | u8 address_length; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 186 | }; |
| 187 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 188 | struct aml_resource_vendor_small { |
| 189 | AML_RESOURCE_SMALL_HEADER_COMMON}; |
| 190 | |
| 191 | struct aml_resource_end_tag { |
| 192 | AML_RESOURCE_SMALL_HEADER_COMMON u8 checksum; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 193 | }; |
| 194 | |
Lin Ming | e0fe0a8 | 2011-11-16 14:38:13 +0800 | [diff] [blame] | 195 | struct aml_resource_fixed_dma { |
| 196 | AML_RESOURCE_SMALL_HEADER_COMMON u16 request_lines; |
| 197 | u16 channels; |
| 198 | u8 width; |
| 199 | }; |
| 200 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 201 | /* |
| 202 | * LARGE descriptors |
| 203 | */ |
| 204 | #define AML_RESOURCE_LARGE_HEADER_COMMON \ |
Bob Moore | 61686124 | 2006-03-17 16:44:00 -0500 | [diff] [blame] | 205 | u8 descriptor_type;\ |
| 206 | u16 resource_length; |
Robert Moore | bda663d | 2005-09-16 16:51:15 -0400 | [diff] [blame] | 207 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 208 | struct aml_resource_large_header { |
| 209 | AML_RESOURCE_LARGE_HEADER_COMMON}; |
Robert Moore | bda663d | 2005-09-16 16:51:15 -0400 | [diff] [blame] | 210 | |
Lv Zheng | 739dcbb | 2012-12-20 01:07:26 +0000 | [diff] [blame] | 211 | /* General Flags for address space resource descriptors */ |
| 212 | |
| 213 | #define ACPI_RESOURCE_FLAG_DEC 2 |
| 214 | #define ACPI_RESOURCE_FLAG_MIF 4 |
| 215 | #define ACPI_RESOURCE_FLAG_MAF 8 |
| 216 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 217 | struct aml_resource_memory24 { |
Bob Moore | 0897831 | 2005-10-21 00:00:00 -0400 | [diff] [blame] | 218 | AML_RESOURCE_LARGE_HEADER_COMMON u8 flags; |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 219 | u16 minimum; |
| 220 | u16 maximum; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 221 | u16 alignment; |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 222 | u16 address_length; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 223 | }; |
| 224 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 225 | struct aml_resource_vendor_large { |
| 226 | AML_RESOURCE_LARGE_HEADER_COMMON}; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 227 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 228 | struct aml_resource_memory32 { |
Bob Moore | 0897831 | 2005-10-21 00:00:00 -0400 | [diff] [blame] | 229 | AML_RESOURCE_LARGE_HEADER_COMMON u8 flags; |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 230 | u32 minimum; |
| 231 | u32 maximum; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 232 | u32 alignment; |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 233 | u32 address_length; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 234 | }; |
| 235 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 236 | struct aml_resource_fixed_memory32 { |
Bob Moore | 0897831 | 2005-10-21 00:00:00 -0400 | [diff] [blame] | 237 | AML_RESOURCE_LARGE_HEADER_COMMON u8 flags; |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 238 | u32 address; |
| 239 | u32 address_length; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 240 | }; |
| 241 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 242 | #define AML_RESOURCE_ADDRESS_COMMON \ |
Bob Moore | 61686124 | 2006-03-17 16:44:00 -0500 | [diff] [blame] | 243 | u8 resource_type; \ |
| 244 | u8 flags; \ |
| 245 | u8 specific_flags; |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 246 | |
| 247 | struct aml_resource_address { |
| 248 | AML_RESOURCE_LARGE_HEADER_COMMON AML_RESOURCE_ADDRESS_COMMON}; |
| 249 | |
| 250 | struct aml_resource_extended_address64 { |
| 251 | AML_RESOURCE_LARGE_HEADER_COMMON |
Bob Moore | ba494be | 2012-07-12 09:40:10 +0800 | [diff] [blame] | 252 | AML_RESOURCE_ADDRESS_COMMON u8 revision_ID; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 253 | u8 reserved; |
| 254 | u64 granularity; |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 255 | u64 minimum; |
| 256 | u64 maximum; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 257 | u64 translation_offset; |
| 258 | u64 address_length; |
Bob Moore | 0897831 | 2005-10-21 00:00:00 -0400 | [diff] [blame] | 259 | u64 type_specific; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 260 | }; |
| 261 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 262 | #define AML_RESOURCE_EXTENDED_ADDRESS_REVISION 1 /* ACPI 3.0 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 263 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 264 | struct aml_resource_address64 { |
| 265 | AML_RESOURCE_LARGE_HEADER_COMMON |
| 266 | AML_RESOURCE_ADDRESS_COMMON u64 granularity; |
| 267 | u64 minimum; |
| 268 | u64 maximum; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 269 | u64 translation_offset; |
| 270 | u64 address_length; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 271 | }; |
| 272 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 273 | struct aml_resource_address32 { |
| 274 | AML_RESOURCE_LARGE_HEADER_COMMON |
| 275 | AML_RESOURCE_ADDRESS_COMMON u32 granularity; |
| 276 | u32 minimum; |
| 277 | u32 maximum; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 278 | u32 translation_offset; |
| 279 | u32 address_length; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 280 | }; |
| 281 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 282 | struct aml_resource_address16 { |
| 283 | AML_RESOURCE_LARGE_HEADER_COMMON |
| 284 | AML_RESOURCE_ADDRESS_COMMON u16 granularity; |
| 285 | u16 minimum; |
| 286 | u16 maximum; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 287 | u16 translation_offset; |
| 288 | u16 address_length; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 289 | }; |
| 290 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 291 | struct aml_resource_extended_irq { |
| 292 | AML_RESOURCE_LARGE_HEADER_COMMON u8 flags; |
Bob Moore | 0897831 | 2005-10-21 00:00:00 -0400 | [diff] [blame] | 293 | u8 interrupt_count; |
| 294 | u32 interrupts[1]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 295 | /* res_source_index, res_source optional fields follow */ |
| 296 | }; |
| 297 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 298 | struct aml_resource_generic_register { |
| 299 | AML_RESOURCE_LARGE_HEADER_COMMON u8 address_space_id; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 300 | u8 bit_width; |
| 301 | u8 bit_offset; |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 302 | u8 access_size; /* ACPI 3.0, was previously Reserved */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 303 | u64 address; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 304 | }; |
| 305 | |
Lin Ming | e0fe0a8 | 2011-11-16 14:38:13 +0800 | [diff] [blame] | 306 | /* Common descriptor for gpio_int and gpio_io (ACPI 5.0) */ |
| 307 | |
| 308 | struct aml_resource_gpio { |
| 309 | AML_RESOURCE_LARGE_HEADER_COMMON u8 revision_id; |
| 310 | u8 connection_type; |
| 311 | u16 flags; |
| 312 | u16 int_flags; |
| 313 | u8 pin_config; |
| 314 | u16 drive_strength; |
| 315 | u16 debounce_timeout; |
| 316 | u16 pin_table_offset; |
| 317 | u8 res_source_index; |
| 318 | u16 res_source_offset; |
| 319 | u16 vendor_offset; |
| 320 | u16 vendor_length; |
| 321 | /* |
| 322 | * Optional fields follow immediately: |
| 323 | * 1) PIN list (Words) |
| 324 | * 2) Resource Source String |
| 325 | * 3) Vendor Data bytes |
| 326 | */ |
| 327 | }; |
| 328 | |
| 329 | #define AML_RESOURCE_GPIO_REVISION 1 /* ACPI 5.0 */ |
| 330 | |
| 331 | /* Values for connection_type above */ |
| 332 | |
| 333 | #define AML_RESOURCE_GPIO_TYPE_INT 0 |
| 334 | #define AML_RESOURCE_GPIO_TYPE_IO 1 |
| 335 | #define AML_RESOURCE_MAX_GPIOTYPE 1 |
| 336 | |
| 337 | /* Common preamble for all serial descriptors (ACPI 5.0) */ |
| 338 | |
| 339 | #define AML_RESOURCE_SERIAL_COMMON \ |
| 340 | u8 revision_id; \ |
| 341 | u8 res_source_index; \ |
| 342 | u8 type; \ |
| 343 | u8 flags; \ |
| 344 | u16 type_specific_flags; \ |
| 345 | u8 type_revision_id; \ |
| 346 | u16 type_data_length; \ |
| 347 | |
| 348 | /* Values for the type field above */ |
| 349 | |
| 350 | #define AML_RESOURCE_I2C_SERIALBUSTYPE 1 |
| 351 | #define AML_RESOURCE_SPI_SERIALBUSTYPE 2 |
| 352 | #define AML_RESOURCE_UART_SERIALBUSTYPE 3 |
| 353 | #define AML_RESOURCE_MAX_SERIALBUSTYPE 3 |
| 354 | #define AML_RESOURCE_VENDOR_SERIALBUSTYPE 192 /* Vendor defined is 0xC0-0xFF (NOT SUPPORTED) */ |
| 355 | |
| 356 | struct aml_resource_common_serialbus { |
| 357 | AML_RESOURCE_LARGE_HEADER_COMMON AML_RESOURCE_SERIAL_COMMON}; |
| 358 | |
| 359 | struct aml_resource_i2c_serialbus { |
| 360 | AML_RESOURCE_LARGE_HEADER_COMMON |
| 361 | AML_RESOURCE_SERIAL_COMMON u32 connection_speed; |
| 362 | u16 slave_address; |
| 363 | /* |
| 364 | * Optional fields follow immediately: |
| 365 | * 1) Vendor Data bytes |
| 366 | * 2) Resource Source String |
| 367 | */ |
| 368 | }; |
| 369 | |
| 370 | #define AML_RESOURCE_I2C_REVISION 1 /* ACPI 5.0 */ |
| 371 | #define AML_RESOURCE_I2C_TYPE_REVISION 1 /* ACPI 5.0 */ |
| 372 | #define AML_RESOURCE_I2C_MIN_DATA_LEN 6 |
| 373 | |
| 374 | struct aml_resource_spi_serialbus { |
| 375 | AML_RESOURCE_LARGE_HEADER_COMMON |
| 376 | AML_RESOURCE_SERIAL_COMMON u32 connection_speed; |
| 377 | u8 data_bit_length; |
| 378 | u8 clock_phase; |
| 379 | u8 clock_polarity; |
| 380 | u16 device_selection; |
| 381 | /* |
| 382 | * Optional fields follow immediately: |
| 383 | * 1) Vendor Data bytes |
| 384 | * 2) Resource Source String |
| 385 | */ |
| 386 | }; |
| 387 | |
| 388 | #define AML_RESOURCE_SPI_REVISION 1 /* ACPI 5.0 */ |
| 389 | #define AML_RESOURCE_SPI_TYPE_REVISION 1 /* ACPI 5.0 */ |
| 390 | #define AML_RESOURCE_SPI_MIN_DATA_LEN 9 |
| 391 | |
| 392 | struct aml_resource_uart_serialbus { |
| 393 | AML_RESOURCE_LARGE_HEADER_COMMON |
| 394 | AML_RESOURCE_SERIAL_COMMON u32 default_baud_rate; |
| 395 | u16 rx_fifo_size; |
| 396 | u16 tx_fifo_size; |
| 397 | u8 parity; |
| 398 | u8 lines_enabled; |
| 399 | /* |
| 400 | * Optional fields follow immediately: |
| 401 | * 1) Vendor Data bytes |
| 402 | * 2) Resource Source String |
| 403 | */ |
| 404 | }; |
| 405 | |
| 406 | #define AML_RESOURCE_UART_REVISION 1 /* ACPI 5.0 */ |
| 407 | #define AML_RESOURCE_UART_TYPE_REVISION 1 /* ACPI 5.0 */ |
| 408 | #define AML_RESOURCE_UART_MIN_DATA_LEN 10 |
| 409 | |
Mika Westerberg | 2b72693 | 2017-06-05 16:39:14 +0800 | [diff] [blame] | 410 | struct aml_resource_pin_function { |
| 411 | AML_RESOURCE_LARGE_HEADER_COMMON u8 revision_id; |
| 412 | u16 flags; |
| 413 | u8 pin_config; |
| 414 | u16 function_number; |
| 415 | u16 pin_table_offset; |
| 416 | u8 res_source_index; |
| 417 | u16 res_source_offset; |
| 418 | u16 vendor_offset; |
| 419 | u16 vendor_length; |
| 420 | /* |
| 421 | * Optional fields follow immediately: |
| 422 | * 1) PIN list (Words) |
| 423 | * 2) Resource Source String |
| 424 | * 3) Vendor Data bytes |
| 425 | */ |
| 426 | }; |
| 427 | |
| 428 | #define AML_RESOURCE_PIN_FUNCTION_REVISION 1 /* ACPI 6.2 */ |
| 429 | |
Mika Westerberg | 97028ce | 2017-06-05 16:39:19 +0800 | [diff] [blame] | 430 | struct aml_resource_pin_config { |
| 431 | AML_RESOURCE_LARGE_HEADER_COMMON u8 revision_id; |
| 432 | u16 flags; |
| 433 | u8 pin_config_type; |
| 434 | u32 pin_config_value; |
| 435 | u16 pin_table_offset; |
| 436 | u8 res_source_index; |
| 437 | u16 res_source_offset; |
| 438 | u16 vendor_offset; |
| 439 | u16 vendor_length; |
| 440 | /* |
| 441 | * Optional fields follow immediately: |
| 442 | * 1) PIN list (Words) |
| 443 | * 2) Resource Source String |
| 444 | * 3) Vendor Data bytes |
| 445 | */ |
| 446 | }; |
| 447 | |
| 448 | #define AML_RESOURCE_PIN_CONFIG_REVISION 1 /* ACPI 6.2 */ |
| 449 | |
Mika Westerberg | fdaa098 | 2017-06-05 16:39:25 +0800 | [diff] [blame] | 450 | struct aml_resource_pin_group { |
| 451 | AML_RESOURCE_LARGE_HEADER_COMMON u8 revision_id; |
| 452 | u16 flags; |
| 453 | u16 pin_table_offset; |
| 454 | u16 label_offset; |
| 455 | u16 vendor_offset; |
| 456 | u16 vendor_length; |
| 457 | /* |
| 458 | * Optional fields follow immediately: |
| 459 | * 1) PIN list (Words) |
| 460 | * 2) Resource Label String |
| 461 | * 3) Vendor Data bytes |
| 462 | */ |
| 463 | }; |
| 464 | |
| 465 | #define AML_RESOURCE_PIN_GROUP_REVISION 1 /* ACPI 6.2 */ |
| 466 | |
Mika Westerberg | f8a6c86 | 2017-06-05 16:39:31 +0800 | [diff] [blame] | 467 | struct aml_resource_pin_group_function { |
| 468 | AML_RESOURCE_LARGE_HEADER_COMMON u8 revision_id; |
| 469 | u16 flags; |
| 470 | u16 function_number; |
| 471 | u8 res_source_index; |
| 472 | u16 res_source_offset; |
| 473 | u16 res_source_label_offset; |
| 474 | u16 vendor_offset; |
| 475 | u16 vendor_length; |
| 476 | /* |
| 477 | * Optional fields follow immediately: |
| 478 | * 1) Resource Source String |
| 479 | * 2) Resource Source Label String |
| 480 | * 3) Vendor Data bytes |
| 481 | */ |
| 482 | }; |
| 483 | |
| 484 | #define AML_RESOURCE_PIN_GROUP_FUNCTION_REVISION 1 /* ACPI 6.2 */ |
| 485 | |
Mika Westerberg | 044b723 | 2017-06-05 16:39:37 +0800 | [diff] [blame] | 486 | struct aml_resource_pin_group_config { |
| 487 | AML_RESOURCE_LARGE_HEADER_COMMON u8 revision_id; |
| 488 | u16 flags; |
| 489 | u8 pin_config_type; |
| 490 | u32 pin_config_value; |
| 491 | u8 res_source_index; |
| 492 | u16 res_source_offset; |
| 493 | u16 res_source_label_offset; |
| 494 | u16 vendor_offset; |
| 495 | u16 vendor_length; |
| 496 | /* |
| 497 | * Optional fields follow immediately: |
| 498 | * 1) Resource Source String |
| 499 | * 2) Resource Source Label String |
| 500 | * 3) Vendor Data bytes |
| 501 | */ |
| 502 | }; |
| 503 | |
| 504 | #define AML_RESOURCE_PIN_GROUP_CONFIG_REVISION 1 /* ACPI 6.2 */ |
| 505 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 506 | /* restore default alignment */ |
| 507 | |
| 508 | #pragma pack() |
| 509 | |
| 510 | /* Union of all resource descriptors, so we can allocate the worst case */ |
| 511 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 512 | union aml_resource { |
| 513 | /* Descriptor headers */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 514 | |
Bob Moore | 8313524 | 2006-10-03 00:00:00 -0400 | [diff] [blame] | 515 | u8 descriptor_type; |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 516 | struct aml_resource_small_header small_header; |
| 517 | struct aml_resource_large_header large_header; |
| 518 | |
| 519 | /* Small resource descriptors */ |
| 520 | |
| 521 | struct aml_resource_irq irq; |
| 522 | struct aml_resource_dma dma; |
| 523 | struct aml_resource_start_dependent start_dpf; |
| 524 | struct aml_resource_end_dependent end_dpf; |
| 525 | struct aml_resource_io io; |
| 526 | struct aml_resource_fixed_io fixed_io; |
Lin Ming | e0fe0a8 | 2011-11-16 14:38:13 +0800 | [diff] [blame] | 527 | struct aml_resource_fixed_dma fixed_dma; |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 528 | struct aml_resource_vendor_small vendor_small; |
| 529 | struct aml_resource_end_tag end_tag; |
| 530 | |
| 531 | /* Large resource descriptors */ |
| 532 | |
| 533 | struct aml_resource_memory24 memory24; |
| 534 | struct aml_resource_generic_register generic_reg; |
| 535 | struct aml_resource_vendor_large vendor_large; |
| 536 | struct aml_resource_memory32 memory32; |
| 537 | struct aml_resource_fixed_memory32 fixed_memory32; |
| 538 | struct aml_resource_address16 address16; |
| 539 | struct aml_resource_address32 address32; |
| 540 | struct aml_resource_address64 address64; |
| 541 | struct aml_resource_extended_address64 ext_address64; |
| 542 | struct aml_resource_extended_irq extended_irq; |
Lin Ming | e0fe0a8 | 2011-11-16 14:38:13 +0800 | [diff] [blame] | 543 | struct aml_resource_gpio gpio; |
| 544 | struct aml_resource_i2c_serialbus i2c_serial_bus; |
| 545 | struct aml_resource_spi_serialbus spi_serial_bus; |
| 546 | struct aml_resource_uart_serialbus uart_serial_bus; |
| 547 | struct aml_resource_common_serialbus common_serial_bus; |
Mika Westerberg | 2b72693 | 2017-06-05 16:39:14 +0800 | [diff] [blame] | 548 | struct aml_resource_pin_function pin_function; |
Mika Westerberg | 97028ce | 2017-06-05 16:39:19 +0800 | [diff] [blame] | 549 | struct aml_resource_pin_config pin_config; |
Mika Westerberg | fdaa098 | 2017-06-05 16:39:25 +0800 | [diff] [blame] | 550 | struct aml_resource_pin_group pin_group; |
Mika Westerberg | f8a6c86 | 2017-06-05 16:39:31 +0800 | [diff] [blame] | 551 | struct aml_resource_pin_group_function pin_group_function; |
Mika Westerberg | 044b723 | 2017-06-05 16:39:37 +0800 | [diff] [blame] | 552 | struct aml_resource_pin_group_config pin_group_config; |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 553 | |
| 554 | /* Utility overlays */ |
| 555 | |
| 556 | struct aml_resource_address address; |
Bob Moore | 958dd24 | 2006-05-12 17:12:00 -0400 | [diff] [blame] | 557 | u32 dword_item; |
| 558 | u16 word_item; |
| 559 | u8 byte_item; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 560 | }; |
| 561 | |
Bob Moore | f2d348f | 2014-10-10 10:40:11 +0800 | [diff] [blame] | 562 | /* Interfaces used by both the disassembler and compiler */ |
| 563 | |
| 564 | void |
| 565 | mp_save_gpio_info(union acpi_parse_object *op, |
| 566 | union aml_resource *resource, |
| 567 | u32 pin_count, u16 *pin_list, char *device_name); |
| 568 | |
| 569 | void |
| 570 | mp_save_serial_info(union acpi_parse_object *op, |
| 571 | union aml_resource *resource, char *device_name); |
| 572 | |
| 573 | char *mp_get_hid_from_parse_tree(struct acpi_namespace_node *hid_node); |
| 574 | |
| 575 | char *mp_get_hid_via_namestring(char *device_name); |
| 576 | |
| 577 | char *mp_get_connection_info(union acpi_parse_object *op, |
| 578 | u32 pin_index, |
| 579 | struct acpi_namespace_node **target_node, |
| 580 | char **target_name); |
| 581 | |
| 582 | char *mp_get_parent_device_hid(union acpi_parse_object *op, |
| 583 | struct acpi_namespace_node **target_node, |
| 584 | char **parent_device_name); |
| 585 | |
| 586 | char *mp_get_ddn_value(char *device_name); |
| 587 | |
| 588 | char *mp_get_hid_value(struct acpi_namespace_node *device_node); |
| 589 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 590 | #endif |