aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/acpica
diff options
context:
space:
mode:
authorLin Ming <ming.m.lin@intel.com>2011-11-16 01:38:13 -0500
committerLen Brown <len.brown@intel.com>2012-01-17 03:36:30 -0500
commite0fe0a8d4ed5474261d0ee1452f5d9ae77236958 (patch)
treecec332ccaab7fa0dd03cbc87ea1212f7182c2309 /drivers/acpi/acpica
parent2da120b6847f85c406f9afa13853e2755684389e (diff)
ACPI 5.0: Support for all new resource descriptors
FixedDMA, GPIO descriptors, SerialBus descriptors Signed-off-by: Lin Ming <ming.m.lin@intel.com> Signed-off-by: Bob Moore <robert.moore@intel.com> Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/acpi/acpica')
-rw-r--r--drivers/acpi/acpica/Makefile2
-rw-r--r--drivers/acpi/acpica/aclocal.h6
-rw-r--r--drivers/acpi/acpica/acresrc.h109
-rw-r--r--drivers/acpi/acpica/acutils.h1
-rw-r--r--drivers/acpi/acpica/amlresrc.h136
-rw-r--r--drivers/acpi/acpica/rscalc.c87
-rw-r--r--drivers/acpi/acpica/rscreate.c3
-rw-r--r--drivers/acpi/acpica/rsdump.c194
-rw-r--r--drivers/acpi/acpica/rsinfo.c56
-rw-r--r--drivers/acpi/acpica/rsirq.c31
-rw-r--r--drivers/acpi/acpica/rslist.c75
-rw-r--r--drivers/acpi/acpica/rsmisc.c267
-rw-r--r--drivers/acpi/acpica/rsserial.c441
-rw-r--r--drivers/acpi/acpica/rsutils.c4
-rw-r--r--drivers/acpi/acpica/utresrc.c276
15 files changed, 1573 insertions, 115 deletions
diff --git a/drivers/acpi/acpica/Makefile b/drivers/acpi/acpica/Makefile
index 1bd466113dc8..b0af3b83eda8 100644
--- a/drivers/acpi/acpica/Makefile
+++ b/drivers/acpi/acpica/Makefile
@@ -36,7 +36,7 @@ acpi-y += psargs.o psparse.o psloop.o pstree.o pswalk.o \
36 psopcode.o psscope.o psutils.o psxface.o 36 psopcode.o psscope.o psutils.o psxface.o
37 37
38acpi-y += rsaddr.o rscreate.o rsinfo.o rsio.o rslist.o rsmisc.o rsxface.o \ 38acpi-y += rsaddr.o rscreate.o rsinfo.o rsio.o rslist.o rsmisc.o rsxface.o \
39 rscalc.o rsirq.o rsmemory.o rsutils.o 39 rscalc.o rsirq.o rsmemory.o rsutils.o rsserial.o
40 40
41acpi-$(ACPI_FUTURE_USAGE) += rsdump.o 41acpi-$(ACPI_FUTURE_USAGE) += rsdump.o
42 42
diff --git a/drivers/acpi/acpica/aclocal.h b/drivers/acpi/acpica/aclocal.h
index 52c4ebddbcf1..60aee56acc5b 100644
--- a/drivers/acpi/acpica/aclocal.h
+++ b/drivers/acpi/acpica/aclocal.h
@@ -955,7 +955,7 @@ struct acpi_port_info {
955#define ACPI_RESOURCE_NAME_END_DEPENDENT 0x38 955#define ACPI_RESOURCE_NAME_END_DEPENDENT 0x38
956#define ACPI_RESOURCE_NAME_IO 0x40 956#define ACPI_RESOURCE_NAME_IO 0x40
957#define ACPI_RESOURCE_NAME_FIXED_IO 0x48 957#define ACPI_RESOURCE_NAME_FIXED_IO 0x48
958#define ACPI_RESOURCE_NAME_RESERVED_S1 0x50 958#define ACPI_RESOURCE_NAME_FIXED_DMA 0x50
959#define ACPI_RESOURCE_NAME_RESERVED_S2 0x58 959#define ACPI_RESOURCE_NAME_RESERVED_S2 0x58
960#define ACPI_RESOURCE_NAME_RESERVED_S3 0x60 960#define ACPI_RESOURCE_NAME_RESERVED_S3 0x60
961#define ACPI_RESOURCE_NAME_RESERVED_S4 0x68 961#define ACPI_RESOURCE_NAME_RESERVED_S4 0x68
@@ -977,7 +977,9 @@ struct acpi_port_info {
977#define ACPI_RESOURCE_NAME_EXTENDED_IRQ 0x89 977#define ACPI_RESOURCE_NAME_EXTENDED_IRQ 0x89
978#define ACPI_RESOURCE_NAME_ADDRESS64 0x8A 978#define ACPI_RESOURCE_NAME_ADDRESS64 0x8A
979#define ACPI_RESOURCE_NAME_EXTENDED_ADDRESS64 0x8B 979#define ACPI_RESOURCE_NAME_EXTENDED_ADDRESS64 0x8B
980#define ACPI_RESOURCE_NAME_LARGE_MAX 0x8B 980#define ACPI_RESOURCE_NAME_GPIO 0x8C
981#define ACPI_RESOURCE_NAME_SERIAL_BUS 0x8E
982#define ACPI_RESOURCE_NAME_LARGE_MAX 0x8E
981 983
982/***************************************************************************** 984/*****************************************************************************
983 * 985 *
diff --git a/drivers/acpi/acpica/acresrc.h b/drivers/acpi/acpica/acresrc.h
index f08b55b7f3a0..05721b023f88 100644
--- a/drivers/acpi/acpica/acresrc.h
+++ b/drivers/acpi/acpica/acresrc.h
@@ -73,28 +73,40 @@ typedef const struct acpi_rsconvert_info {
73 73
74/* Resource conversion opcodes */ 74/* Resource conversion opcodes */
75 75
76#define ACPI_RSC_INITGET 0 76typedef enum {
77#define ACPI_RSC_INITSET 1 77 ACPI_RSC_INITGET = 0,
78#define ACPI_RSC_FLAGINIT 2 78 ACPI_RSC_INITSET,
79#define ACPI_RSC_1BITFLAG 3 79 ACPI_RSC_FLAGINIT,
80#define ACPI_RSC_2BITFLAG 4 80 ACPI_RSC_1BITFLAG,
81#define ACPI_RSC_COUNT 5 81 ACPI_RSC_2BITFLAG,
82#define ACPI_RSC_COUNT16 6 82 ACPI_RSC_3BITFLAG,
83#define ACPI_RSC_LENGTH 7 83 ACPI_RSC_ADDRESS,
84#define ACPI_RSC_MOVE8 8 84 ACPI_RSC_BITMASK,
85#define ACPI_RSC_MOVE16 9 85 ACPI_RSC_BITMASK16,
86#define ACPI_RSC_MOVE32 10 86 ACPI_RSC_COUNT,
87#define ACPI_RSC_MOVE64 11 87 ACPI_RSC_COUNT16,
88#define ACPI_RSC_SET8 12 88 ACPI_RSC_COUNT_GPIO_PIN,
89#define ACPI_RSC_DATA8 13 89 ACPI_RSC_COUNT_GPIO_RES,
90#define ACPI_RSC_ADDRESS 14 90 ACPI_RSC_COUNT_GPIO_VEN,
91#define ACPI_RSC_SOURCE 15 91 ACPI_RSC_COUNT_SERIAL_RES,
92#define ACPI_RSC_SOURCEX 16 92 ACPI_RSC_COUNT_SERIAL_VEN,
93#define ACPI_RSC_BITMASK 17 93 ACPI_RSC_DATA8,
94#define ACPI_RSC_BITMASK16 18 94 ACPI_RSC_EXIT_EQ,
95#define ACPI_RSC_EXIT_NE 19 95 ACPI_RSC_EXIT_LE,
96#define ACPI_RSC_EXIT_LE 20 96 ACPI_RSC_EXIT_NE,
97#define ACPI_RSC_EXIT_EQ 21 97 ACPI_RSC_LENGTH,
98 ACPI_RSC_MOVE_GPIO_PIN,
99 ACPI_RSC_MOVE_GPIO_RES,
100 ACPI_RSC_MOVE_SERIAL_RES,
101 ACPI_RSC_MOVE_SERIAL_VEN,
102 ACPI_RSC_MOVE8,
103 ACPI_RSC_MOVE16,
104 ACPI_RSC_MOVE32,
105 ACPI_RSC_MOVE64,
106 ACPI_RSC_SET8,
107 ACPI_RSC_SOURCE,
108 ACPI_RSC_SOURCEX
109} ACPI_RSCONVERT_OPCODES;
98 110
99/* Resource Conversion sub-opcodes */ 111/* Resource Conversion sub-opcodes */
100 112
@@ -106,6 +118,9 @@ typedef const struct acpi_rsconvert_info {
106#define ACPI_RS_OFFSET(f) (u8) ACPI_OFFSET (struct acpi_resource,f) 118#define ACPI_RS_OFFSET(f) (u8) ACPI_OFFSET (struct acpi_resource,f)
107#define AML_OFFSET(f) (u8) ACPI_OFFSET (union aml_resource,f) 119#define AML_OFFSET(f) (u8) ACPI_OFFSET (union aml_resource,f)
108 120
121/*
122 * Individual entry for the resource dump tables
123 */
109typedef const struct acpi_rsdump_info { 124typedef const struct acpi_rsdump_info {
110 u8 opcode; 125 u8 opcode;
111 u8 offset; 126 u8 offset;
@@ -116,20 +131,25 @@ typedef const struct acpi_rsdump_info {
116 131
117/* Values for the Opcode field above */ 132/* Values for the Opcode field above */
118 133
119#define ACPI_RSD_TITLE 0 134typedef enum {
120#define ACPI_RSD_LITERAL 1 135 ACPI_RSD_TITLE = 0,
121#define ACPI_RSD_STRING 2 136 ACPI_RSD_1BITFLAG,
122#define ACPI_RSD_UINT8 3 137 ACPI_RSD_2BITFLAG,
123#define ACPI_RSD_UINT16 4 138 ACPI_RSD_3BITFLAG,
124#define ACPI_RSD_UINT32 5 139 ACPI_RSD_ADDRESS,
125#define ACPI_RSD_UINT64 6 140 ACPI_RSD_DWORDLIST,
126#define ACPI_RSD_1BITFLAG 7 141 ACPI_RSD_LITERAL,
127#define ACPI_RSD_2BITFLAG 8 142 ACPI_RSD_LONGLIST,
128#define ACPI_RSD_SHORTLIST 9 143 ACPI_RSD_SHORTLIST,
129#define ACPI_RSD_LONGLIST 10 144 ACPI_RSD_SHORTLISTX,
130#define ACPI_RSD_DWORDLIST 11 145 ACPI_RSD_SOURCE,
131#define ACPI_RSD_ADDRESS 12 146 ACPI_RSD_STRING,
132#define ACPI_RSD_SOURCE 13 147 ACPI_RSD_UINT8,
148 ACPI_RSD_UINT16,
149 ACPI_RSD_UINT32,
150 ACPI_RSD_UINT64,
151 ACPI_RSD_WORDLIST
152} ACPI_RSDUMP_OPCODES;
133 153
134/* restore default alignment */ 154/* restore default alignment */
135 155
@@ -138,13 +158,18 @@ typedef const struct acpi_rsdump_info {
138/* Resource tables indexed by internal resource type */ 158/* Resource tables indexed by internal resource type */
139 159
140extern const u8 acpi_gbl_aml_resource_sizes[]; 160extern const u8 acpi_gbl_aml_resource_sizes[];
161extern const u8 acpi_gbl_aml_resource_serial_bus_sizes[];
141extern struct acpi_rsconvert_info *acpi_gbl_set_resource_dispatch[]; 162extern struct acpi_rsconvert_info *acpi_gbl_set_resource_dispatch[];
142 163
143/* Resource tables indexed by raw AML resource descriptor type */ 164/* Resource tables indexed by raw AML resource descriptor type */
144 165
145extern const u8 acpi_gbl_resource_struct_sizes[]; 166extern const u8 acpi_gbl_resource_struct_sizes[];
167extern const u8 acpi_gbl_resource_struct_serial_bus_sizes[];
146extern struct acpi_rsconvert_info *acpi_gbl_get_resource_dispatch[]; 168extern struct acpi_rsconvert_info *acpi_gbl_get_resource_dispatch[];
147 169
170extern struct acpi_rsconvert_info
171 *acpi_gbl_convert_resource_serial_bus_dispatch[];
172
148struct acpi_vendor_walk_info { 173struct acpi_vendor_walk_info {
149 struct acpi_vendor_uuid *uuid; 174 struct acpi_vendor_uuid *uuid;
150 struct acpi_buffer *buffer; 175 struct acpi_buffer *buffer;
@@ -293,6 +318,11 @@ extern struct acpi_rsconvert_info acpi_rs_convert_address16[];
293extern struct acpi_rsconvert_info acpi_rs_convert_ext_irq[]; 318extern struct acpi_rsconvert_info acpi_rs_convert_ext_irq[];
294extern struct acpi_rsconvert_info acpi_rs_convert_address64[]; 319extern struct acpi_rsconvert_info acpi_rs_convert_address64[];
295extern struct acpi_rsconvert_info acpi_rs_convert_ext_address64[]; 320extern struct acpi_rsconvert_info acpi_rs_convert_ext_address64[];
321extern struct acpi_rsconvert_info acpi_rs_convert_gpio[];
322extern struct acpi_rsconvert_info acpi_rs_convert_fixed_dma[];
323extern struct acpi_rsconvert_info acpi_rs_convert_i2c_serial_bus[];
324extern struct acpi_rsconvert_info acpi_rs_convert_spi_serial_bus[];
325extern struct acpi_rsconvert_info acpi_rs_convert_uart_serial_bus[];
296 326
297/* These resources require separate get/set tables */ 327/* These resources require separate get/set tables */
298 328
@@ -310,6 +340,7 @@ extern struct acpi_rsconvert_info acpi_rs_set_vendor[];
310 * rsinfo 340 * rsinfo
311 */ 341 */
312extern struct acpi_rsdump_info *acpi_gbl_dump_resource_dispatch[]; 342extern struct acpi_rsdump_info *acpi_gbl_dump_resource_dispatch[];
343extern struct acpi_rsdump_info *acpi_gbl_dump_serial_bus_dispatch[];
313 344
314/* 345/*
315 * rsdump 346 * rsdump
@@ -331,6 +362,12 @@ extern struct acpi_rsdump_info acpi_rs_dump_address64[];
331extern struct acpi_rsdump_info acpi_rs_dump_ext_address64[]; 362extern struct acpi_rsdump_info acpi_rs_dump_ext_address64[];
332extern struct acpi_rsdump_info acpi_rs_dump_ext_irq[]; 363extern struct acpi_rsdump_info acpi_rs_dump_ext_irq[];
333extern struct acpi_rsdump_info acpi_rs_dump_generic_reg[]; 364extern struct acpi_rsdump_info acpi_rs_dump_generic_reg[];
365extern struct acpi_rsdump_info acpi_rs_dump_gpio[];
366extern struct acpi_rsdump_info acpi_rs_dump_fixed_dma[];
367extern struct acpi_rsdump_info acpi_rs_dump_common_serial_bus[];
368extern struct acpi_rsdump_info acpi_rs_dump_i2c_serial_bus[];
369extern struct acpi_rsdump_info acpi_rs_dump_spi_serial_bus[];
370extern struct acpi_rsdump_info acpi_rs_dump_uart_serial_bus[];
334#endif 371#endif
335 372
336#endif /* __ACRESRC_H__ */ 373#endif /* __ACRESRC_H__ */
diff --git a/drivers/acpi/acpica/acutils.h b/drivers/acpi/acpica/acutils.h
index 99c140d8e348..ab95d452f87d 100644
--- a/drivers/acpi/acpica/acutils.h
+++ b/drivers/acpi/acpica/acutils.h
@@ -45,6 +45,7 @@
45#define _ACUTILS_H 45#define _ACUTILS_H
46 46
47extern const u8 acpi_gbl_resource_aml_sizes[]; 47extern const u8 acpi_gbl_resource_aml_sizes[];
48extern const u8 acpi_gbl_resource_aml_serial_bus_sizes[];
48 49
49/* Strings used by the disassembler and debugger resource dump routines */ 50/* Strings used by the disassembler and debugger resource dump routines */
50 51
diff --git a/drivers/acpi/acpica/amlresrc.h b/drivers/acpi/acpica/amlresrc.h
index 59122cde247c..d4c30511aca9 100644
--- a/drivers/acpi/acpica/amlresrc.h
+++ b/drivers/acpi/acpica/amlresrc.h
@@ -58,29 +58,48 @@
58#define ACPI_RESTAG_TYPESPECIFICATTRIBUTES "_ATT" 58#define ACPI_RESTAG_TYPESPECIFICATTRIBUTES "_ATT"
59#define ACPI_RESTAG_BASEADDRESS "_BAS" 59#define ACPI_RESTAG_BASEADDRESS "_BAS"
60#define ACPI_RESTAG_BUSMASTER "_BM_" /* Master(1), Slave(0) */ 60#define ACPI_RESTAG_BUSMASTER "_BM_" /* Master(1), Slave(0) */
61#define ACPI_RESTAG_DEBOUNCETIME "_DBT"
61#define ACPI_RESTAG_DECODE "_DEC" 62#define ACPI_RESTAG_DECODE "_DEC"
63#define ACPI_RESTAG_DEVICEPOLARITY "_DPL"
62#define ACPI_RESTAG_DMA "_DMA" 64#define ACPI_RESTAG_DMA "_DMA"
63#define ACPI_RESTAG_DMATYPE "_TYP" /* Compatible(0), A(1), B(2), F(3) */ 65#define ACPI_RESTAG_DMATYPE "_TYP" /* Compatible(0), A(1), B(2), F(3) */
66#define ACPI_RESTAG_DRIVESTRENGTH "_DRS"
67#define ACPI_RESTAG_ENDIANNESS "_END"
68#define ACPI_RESTAG_FLOWCONTROL "_FLC"
64#define ACPI_RESTAG_GRANULARITY "_GRA" 69#define ACPI_RESTAG_GRANULARITY "_GRA"
65#define ACPI_RESTAG_INTERRUPT "_INT" 70#define ACPI_RESTAG_INTERRUPT "_INT"
66#define ACPI_RESTAG_INTERRUPTLEVEL "_LL_" /* active_lo(1), active_hi(0) */ 71#define ACPI_RESTAG_INTERRUPTLEVEL "_LL_" /* active_lo(1), active_hi(0) */
67#define ACPI_RESTAG_INTERRUPTSHARE "_SHR" /* Shareable(1), no_share(0) */ 72#define ACPI_RESTAG_INTERRUPTSHARE "_SHR" /* Shareable(1), no_share(0) */
68#define ACPI_RESTAG_INTERRUPTTYPE "_HE_" /* Edge(1), Level(0) */ 73#define ACPI_RESTAG_INTERRUPTTYPE "_HE_" /* Edge(1), Level(0) */
74#define ACPI_RESTAG_IORESTRICTION "_IOR"
69#define ACPI_RESTAG_LENGTH "_LEN" 75#define ACPI_RESTAG_LENGTH "_LEN"
76#define ACPI_RESTAG_LINE "_LIN"
70#define ACPI_RESTAG_MEMATTRIBUTES "_MTP" /* Memory(0), Reserved(1), ACPI(2), NVS(3) */ 77#define ACPI_RESTAG_MEMATTRIBUTES "_MTP" /* Memory(0), Reserved(1), ACPI(2), NVS(3) */
71#define ACPI_RESTAG_MEMTYPE "_MEM" /* non_cache(0), Cacheable(1) Cache+combine(2), Cache+prefetch(3) */ 78#define ACPI_RESTAG_MEMTYPE "_MEM" /* non_cache(0), Cacheable(1) Cache+combine(2), Cache+prefetch(3) */
72#define ACPI_RESTAG_MAXADDR "_MAX" 79#define ACPI_RESTAG_MAXADDR "_MAX"
73#define ACPI_RESTAG_MINADDR "_MIN" 80#define ACPI_RESTAG_MINADDR "_MIN"
74#define ACPI_RESTAG_MAXTYPE "_MAF" 81#define ACPI_RESTAG_MAXTYPE "_MAF"
75#define ACPI_RESTAG_MINTYPE "_MIF" 82#define ACPI_RESTAG_MINTYPE "_MIF"
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"
88#define ACPI_RESTAG_POLARITY "_POL"
76#define ACPI_RESTAG_REGISTERBITOFFSET "_RBO" 89#define ACPI_RESTAG_REGISTERBITOFFSET "_RBO"
77#define ACPI_RESTAG_REGISTERBITWIDTH "_RBW" 90#define ACPI_RESTAG_REGISTERBITWIDTH "_RBW"
78#define ACPI_RESTAG_RANGETYPE "_RNG" 91#define ACPI_RESTAG_RANGETYPE "_RNG"
79#define ACPI_RESTAG_READWRITETYPE "_RW_" /* read_only(0), Writeable (1) */ 92#define ACPI_RESTAG_READWRITETYPE "_RW_" /* read_only(0), Writeable (1) */
93#define ACPI_RESTAG_LENGTH_RX "_RXL"
94#define ACPI_RESTAG_LENGTH_TX "_TXL"
95#define ACPI_RESTAG_SLAVEMODE "_SLV"
96#define ACPI_RESTAG_SPEED "_SPE"
97#define ACPI_RESTAG_STOPBITS "_STB"
80#define ACPI_RESTAG_TRANSLATION "_TRA" 98#define ACPI_RESTAG_TRANSLATION "_TRA"
81#define ACPI_RESTAG_TRANSTYPE "_TRS" /* Sparse(1), Dense(0) */ 99#define ACPI_RESTAG_TRANSTYPE "_TRS" /* Sparse(1), Dense(0) */
82#define ACPI_RESTAG_TYPE "_TTP" /* Translation(1), Static (0) */ 100#define ACPI_RESTAG_TYPE "_TTP" /* Translation(1), Static (0) */
83#define ACPI_RESTAG_XFERTYPE "_SIZ" /* 8(0), 8_and16(1), 16(2) */ 101#define ACPI_RESTAG_XFERTYPE "_SIZ" /* 8(0), 8_and16(1), 16(2) */
102#define ACPI_RESTAG_VENDORDATA "_VEN"
84 103
85/* Default sizes for "small" resource descriptors */ 104/* Default sizes for "small" resource descriptors */
86 105
@@ -90,6 +109,7 @@
90#define ASL_RDESC_END_DEPEND_SIZE 0x00 109#define ASL_RDESC_END_DEPEND_SIZE 0x00
91#define ASL_RDESC_IO_SIZE 0x07 110#define ASL_RDESC_IO_SIZE 0x07
92#define ASL_RDESC_FIXED_IO_SIZE 0x03 111#define ASL_RDESC_FIXED_IO_SIZE 0x03
112#define ASL_RDESC_FIXED_DMA_SIZE 0x05
93#define ASL_RDESC_END_TAG_SIZE 0x01 113#define ASL_RDESC_END_TAG_SIZE 0x01
94 114
95struct asl_resource_node { 115struct asl_resource_node {
@@ -164,6 +184,12 @@ struct aml_resource_end_tag {
164 AML_RESOURCE_SMALL_HEADER_COMMON u8 checksum; 184 AML_RESOURCE_SMALL_HEADER_COMMON u8 checksum;
165}; 185};
166 186
187struct aml_resource_fixed_dma {
188 AML_RESOURCE_SMALL_HEADER_COMMON u16 request_lines;
189 u16 channels;
190 u8 width;
191};
192
167/* 193/*
168 * LARGE descriptors 194 * LARGE descriptors
169 */ 195 */
@@ -263,6 +289,110 @@ struct aml_resource_generic_register {
263 u64 address; 289 u64 address;
264}; 290};
265 291
292/* Common descriptor for gpio_int and gpio_io (ACPI 5.0) */
293
294struct aml_resource_gpio {
295 AML_RESOURCE_LARGE_HEADER_COMMON u8 revision_id;
296 u8 connection_type;
297 u16 flags;
298 u16 int_flags;
299 u8 pin_config;
300 u16 drive_strength;
301 u16 debounce_timeout;
302 u16 pin_table_offset;
303 u8 res_source_index;
304 u16 res_source_offset;
305 u16 vendor_offset;
306 u16 vendor_length;
307 /*
308 * Optional fields follow immediately:
309 * 1) PIN list (Words)
310 * 2) Resource Source String
311 * 3) Vendor Data bytes
312 */
313};
314
315#define AML_RESOURCE_GPIO_REVISION 1 /* ACPI 5.0 */
316
317/* Values for connection_type above */
318
319#define AML_RESOURCE_GPIO_TYPE_INT 0
320#define AML_RESOURCE_GPIO_TYPE_IO 1
321#define AML_RESOURCE_MAX_GPIOTYPE 1
322
323/* Common preamble for all serial descriptors (ACPI 5.0) */
324
325#define AML_RESOURCE_SERIAL_COMMON \
326 u8 revision_id; \
327 u8 res_source_index; \
328 u8 type; \
329 u8 flags; \
330 u16 type_specific_flags; \
331 u8 type_revision_id; \
332 u16 type_data_length; \
333
334/* Values for the type field above */
335
336#define AML_RESOURCE_I2C_SERIALBUSTYPE 1
337#define AML_RESOURCE_SPI_SERIALBUSTYPE 2
338#define AML_RESOURCE_UART_SERIALBUSTYPE 3
339#define AML_RESOURCE_MAX_SERIALBUSTYPE 3
340#define AML_RESOURCE_VENDOR_SERIALBUSTYPE 192 /* Vendor defined is 0xC0-0xFF (NOT SUPPORTED) */
341
342struct aml_resource_common_serialbus {
343AML_RESOURCE_LARGE_HEADER_COMMON AML_RESOURCE_SERIAL_COMMON};
344
345struct aml_resource_i2c_serialbus {
346 AML_RESOURCE_LARGE_HEADER_COMMON
347 AML_RESOURCE_SERIAL_COMMON u32 connection_speed;
348 u16 slave_address;
349 /*
350 * Optional fields follow immediately:
351 * 1) Vendor Data bytes
352 * 2) Resource Source String
353 */
354};
355
356#define AML_RESOURCE_I2C_REVISION 1 /* ACPI 5.0 */
357#define AML_RESOURCE_I2C_TYPE_REVISION 1 /* ACPI 5.0 */
358#define AML_RESOURCE_I2C_MIN_DATA_LEN 6
359
360struct aml_resource_spi_serialbus {
361 AML_RESOURCE_LARGE_HEADER_COMMON
362 AML_RESOURCE_SERIAL_COMMON u32 connection_speed;
363 u8 data_bit_length;
364 u8 clock_phase;
365 u8 clock_polarity;
366 u16 device_selection;
367 /*
368 * Optional fields follow immediately:
369 * 1) Vendor Data bytes
370 * 2) Resource Source String
371 */
372};
373
374#define AML_RESOURCE_SPI_REVISION 1 /* ACPI 5.0 */
375#define AML_RESOURCE_SPI_TYPE_REVISION 1 /* ACPI 5.0 */
376#define AML_RESOURCE_SPI_MIN_DATA_LEN 9
377
378struct aml_resource_uart_serialbus {
379 AML_RESOURCE_LARGE_HEADER_COMMON
380 AML_RESOURCE_SERIAL_COMMON u32 default_baud_rate;
381 u16 rx_fifo_size;
382 u16 tx_fifo_size;
383 u8 parity;
384 u8 lines_enabled;
385 /*
386 * Optional fields follow immediately:
387 * 1) Vendor Data bytes
388 * 2) Resource Source String
389 */
390};
391
392#define AML_RESOURCE_UART_REVISION 1 /* ACPI 5.0 */
393#define AML_RESOURCE_UART_TYPE_REVISION 1 /* ACPI 5.0 */
394#define AML_RESOURCE_UART_MIN_DATA_LEN 10
395
266/* restore default alignment */ 396/* restore default alignment */
267 397
268#pragma pack() 398#pragma pack()
@@ -284,6 +414,7 @@ union aml_resource {
284 struct aml_resource_end_dependent end_dpf; 414 struct aml_resource_end_dependent end_dpf;
285 struct aml_resource_io io; 415 struct aml_resource_io io;
286 struct aml_resource_fixed_io fixed_io; 416 struct aml_resource_fixed_io fixed_io;
417 struct aml_resource_fixed_dma fixed_dma;
287 struct aml_resource_vendor_small vendor_small; 418 struct aml_resource_vendor_small vendor_small;
288 struct aml_resource_end_tag end_tag; 419 struct aml_resource_end_tag end_tag;
289 420
@@ -299,6 +430,11 @@ union aml_resource {
299 struct aml_resource_address64 address64; 430 struct aml_resource_address64 address64;
300 struct aml_resource_extended_address64 ext_address64; 431 struct aml_resource_extended_address64 ext_address64;
301 struct aml_resource_extended_irq extended_irq; 432 struct aml_resource_extended_irq extended_irq;
433 struct aml_resource_gpio gpio;
434 struct aml_resource_i2c_serialbus i2c_serial_bus;
435 struct aml_resource_spi_serialbus spi_serial_bus;
436 struct aml_resource_uart_serialbus uart_serial_bus;
437 struct aml_resource_common_serialbus common_serial_bus;
302 438
303 /* Utility overlays */ 439 /* Utility overlays */
304 440
diff --git a/drivers/acpi/acpica/rscalc.c b/drivers/acpi/acpica/rscalc.c
index 3a8a89ec2ca4..3a29b4dd4453 100644
--- a/drivers/acpi/acpica/rscalc.c
+++ b/drivers/acpi/acpica/rscalc.c
@@ -313,6 +313,38 @@ acpi_rs_get_aml_length(struct acpi_resource * resource, acpi_size * size_needed)
313 resource_source)); 313 resource_source));
314 break; 314 break;
315 315
316 case ACPI_RESOURCE_TYPE_GPIO:
317
318 total_size =
319 (acpi_rs_length) (total_size +
320 (resource->data.gpio.
321 pin_table_length * 2) +
322 resource->data.gpio.
323 resource_source.string_length +
324 resource->data.gpio.
325 vendor_length);
326
327 break;
328
329 case ACPI_RESOURCE_TYPE_SERIAL_BUS:
330
331 total_size =
332 acpi_gbl_aml_resource_serial_bus_sizes[resource->
333 data.
334 common_serial_bus.
335 type];
336
337 total_size = (acpi_rs_length) (total_size +
338 resource->data.
339 i2c_serial_bus.
340 resource_source.
341 string_length +
342 resource->data.
343 i2c_serial_bus.
344 vendor_length);
345
346 break;
347
316 default: 348 default:
317 break; 349 break;
318 } 350 }
@@ -362,10 +394,11 @@ acpi_rs_get_list_length(u8 * aml_buffer,
362 u32 extra_struct_bytes; 394 u32 extra_struct_bytes;
363 u8 resource_index; 395 u8 resource_index;
364 u8 minimum_aml_resource_length; 396 u8 minimum_aml_resource_length;
397 union aml_resource *aml_resource;
365 398
366 ACPI_FUNCTION_TRACE(rs_get_list_length); 399 ACPI_FUNCTION_TRACE(rs_get_list_length);
367 400
368 *size_needed = 0; 401 *size_needed = ACPI_RS_SIZE_MIN; /* Minimum size is one end_tag */
369 end_aml = aml_buffer + aml_buffer_length; 402 end_aml = aml_buffer + aml_buffer_length;
370 403
371 /* Walk the list of AML resource descriptors */ 404 /* Walk the list of AML resource descriptors */
@@ -376,9 +409,15 @@ acpi_rs_get_list_length(u8 * aml_buffer,
376 409
377 status = acpi_ut_validate_resource(aml_buffer, &resource_index); 410 status = acpi_ut_validate_resource(aml_buffer, &resource_index);
378 if (ACPI_FAILURE(status)) { 411 if (ACPI_FAILURE(status)) {
412 /*
413 * Exit on failure. Cannot continue because the descriptor length
414 * may be bogus also.
415 */
379 return_ACPI_STATUS(status); 416 return_ACPI_STATUS(status);
380 } 417 }
381 418
419 aml_resource = (void *)aml_buffer;
420
382 /* Get the resource length and base (minimum) AML size */ 421 /* Get the resource length and base (minimum) AML size */
383 422
384 resource_length = acpi_ut_get_resource_length(aml_buffer); 423 resource_length = acpi_ut_get_resource_length(aml_buffer);
@@ -422,10 +461,8 @@ acpi_rs_get_list_length(u8 * aml_buffer,
422 461
423 case ACPI_RESOURCE_NAME_END_TAG: 462 case ACPI_RESOURCE_NAME_END_TAG:
424 /* 463 /*
425 * End Tag: 464 * End Tag: This is the normal exit
426 * This is the normal exit, add size of end_tag
427 */ 465 */
428 *size_needed += ACPI_RS_SIZE_MIN;
429 return_ACPI_STATUS(AE_OK); 466 return_ACPI_STATUS(AE_OK);
430 467
431 case ACPI_RESOURCE_NAME_ADDRESS32: 468 case ACPI_RESOURCE_NAME_ADDRESS32:
@@ -457,6 +494,33 @@ acpi_rs_get_list_length(u8 * aml_buffer,
457 minimum_aml_resource_length); 494 minimum_aml_resource_length);
458 break; 495 break;
459 496
497 case ACPI_RESOURCE_NAME_GPIO:
498
499 /* Vendor data is optional */
500
501 if (aml_resource->gpio.vendor_length) {
502 extra_struct_bytes +=
503 aml_resource->gpio.vendor_offset -
504 aml_resource->gpio.pin_table_offset +
505 aml_resource->gpio.vendor_length;
506 } else {
507 extra_struct_bytes +=
508 aml_resource->large_header.resource_length +
509 sizeof(struct aml_resource_large_header) -
510 aml_resource->gpio.pin_table_offset;
511 }
512 break;
513
514 case ACPI_RESOURCE_NAME_SERIAL_BUS:
515
516 minimum_aml_resource_length =
517 acpi_gbl_resource_aml_serial_bus_sizes
518 [aml_resource->common_serial_bus.type];
519 extra_struct_bytes +=
520 aml_resource->common_serial_bus.resource_length -
521 minimum_aml_resource_length;
522 break;
523
460 default: 524 default:
461 break; 525 break;
462 } 526 }
@@ -467,9 +531,18 @@ acpi_rs_get_list_length(u8 * aml_buffer,
467 * Important: Round the size up for the appropriate alignment. This 531 * Important: Round the size up for the appropriate alignment. This
468 * is a requirement on IA64. 532 * is a requirement on IA64.
469 */ 533 */
470 buffer_size = acpi_gbl_resource_struct_sizes[resource_index] + 534 if (acpi_ut_get_resource_type(aml_buffer) ==
471 extra_struct_bytes; 535 ACPI_RESOURCE_NAME_SERIAL_BUS) {
472 buffer_size = (u32) ACPI_ROUND_UP_TO_NATIVE_WORD(buffer_size); 536 buffer_size =
537 acpi_gbl_resource_struct_serial_bus_sizes
538 [aml_resource->common_serial_bus.type] +
539 extra_struct_bytes;
540 } else {
541 buffer_size =
542 acpi_gbl_resource_struct_sizes[resource_index] +
543 extra_struct_bytes;
544 }
545 buffer_size = (u32)ACPI_ROUND_UP_TO_NATIVE_WORD(buffer_size);
473 546
474 *size_needed += buffer_size; 547 *size_needed += buffer_size;
475 548
diff --git a/drivers/acpi/acpica/rscreate.c b/drivers/acpi/acpica/rscreate.c
index 4ce6e1147e80..f61285d5edc3 100644
--- a/drivers/acpi/acpica/rscreate.c
+++ b/drivers/acpi/acpica/rscreate.c
@@ -66,9 +66,10 @@ ACPI_MODULE_NAME("rscreate")
66 * of device resources. 66 * of device resources.
67 * 67 *
68 ******************************************************************************/ 68 ******************************************************************************/
69
69acpi_status 70acpi_status
70acpi_rs_create_resource_list(union acpi_operand_object *aml_buffer, 71acpi_rs_create_resource_list(union acpi_operand_object *aml_buffer,
71 struct acpi_buffer *output_buffer) 72 struct acpi_buffer * output_buffer)
72{ 73{
73 74
74 acpi_status status; 75 acpi_status status;
diff --git a/drivers/acpi/acpica/rsdump.c b/drivers/acpi/acpica/rsdump.c
index 33db7520c74b..9969985bf2b7 100644
--- a/drivers/acpi/acpica/rsdump.c
+++ b/drivers/acpi/acpica/rsdump.c
@@ -61,11 +61,13 @@ static void acpi_rs_out_integer64(char *title, u64 value);
61 61
62static void acpi_rs_out_title(char *title); 62static void acpi_rs_out_title(char *title);
63 63
64static void acpi_rs_dump_byte_list(u16 length, u8 * data); 64static void acpi_rs_dump_byte_list(u16 length, u8 *data);
65 65
66static void acpi_rs_dump_dword_list(u8 length, u32 * data); 66static void acpi_rs_dump_word_list(u16 length, u16 *data);
67 67
68static void acpi_rs_dump_short_byte_list(u8 length, u8 * data); 68static void acpi_rs_dump_dword_list(u8 length, u32 *data);
69
70static void acpi_rs_dump_short_byte_list(u8 length, u8 *data);
69 71
70static void 72static void
71acpi_rs_dump_resource_source(struct acpi_resource_source *resource_source); 73acpi_rs_dump_resource_source(struct acpi_resource_source *resource_source);
@@ -309,6 +311,125 @@ struct acpi_rsdump_info acpi_rs_dump_generic_reg[6] = {
309 {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(generic_reg.address), "Address", NULL} 311 {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(generic_reg.address), "Address", NULL}
310}; 312};
311 313
314struct acpi_rsdump_info acpi_rs_dump_gpio[16] = {
315 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_gpio), "GPIO", NULL},
316 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(gpio.revision_id), "RevisionId", NULL},
317 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(gpio.connection_type),
318 "ConnectionType", acpi_gbl_ct_decode},
319 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(gpio.producer_consumer),
320 "ProducerConsumer", acpi_gbl_consume_decode},
321 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(gpio.pin_config), "PinConfig",
322 acpi_gbl_ppc_decode},
323 {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(gpio.sharable), "Sharable",
324 acpi_gbl_shr_decode},
325 {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(gpio.io_restriction),
326 "IoRestriction", acpi_gbl_ior_decode},
327 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(gpio.triggering), "Triggering",
328 acpi_gbl_he_decode},
329 {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(gpio.polarity), "Polarity",
330 acpi_gbl_ll_decode},
331 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(gpio.drive_strength), "DriveStrength",
332 NULL},
333 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(gpio.debounce_timeout),
334 "DebounceTimeout", NULL},
335 {ACPI_RSD_SOURCE, ACPI_RSD_OFFSET(gpio.resource_source),
336 "ResourceSource", NULL},
337 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(gpio.pin_table_length),
338 "PinTableLength", NULL},
339 {ACPI_RSD_WORDLIST, ACPI_RSD_OFFSET(gpio.pin_table), "PinTable", NULL},
340 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(gpio.vendor_length), "VendorLength",
341 NULL},
342 {ACPI_RSD_SHORTLISTX, ACPI_RSD_OFFSET(gpio.vendor_data), "VendorData",
343 NULL},
344};
345
346struct acpi_rsdump_info acpi_rs_dump_fixed_dma[4] = {
347 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_fixed_dma),
348 "FixedDma", NULL},
349 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(fixed_dma.request_lines),
350 "RequestLines", NULL},
351 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(fixed_dma.channels), "Channels",
352 NULL},
353 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(fixed_dma.width), "TransferWidth",
354 acpi_gbl_dts_decode},
355};
356
357#define ACPI_RS_DUMP_COMMON_SERIAL_BUS \
358 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET (common_serial_bus.revision_id), "RevisionId", NULL}, \
359 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET (common_serial_bus.type), "Type", acpi_gbl_sbt_decode}, \
360 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (common_serial_bus.producer_consumer), "ProducerConsumer", acpi_gbl_consume_decode}, \
361 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (common_serial_bus.slave_mode), "SlaveMode", acpi_gbl_sm_decode}, \
362 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET (common_serial_bus.type_revision_id), "TypeRevisionId", NULL}, \
363 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (common_serial_bus.type_data_length), "TypeDataLength", NULL}, \
364 {ACPI_RSD_SOURCE, ACPI_RSD_OFFSET (common_serial_bus.resource_source), "ResourceSource", NULL}, \
365 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (common_serial_bus.vendor_length), "VendorLength", NULL}, \
366 {ACPI_RSD_SHORTLISTX,ACPI_RSD_OFFSET (common_serial_bus.vendor_data), "VendorData", NULL},
367
368struct acpi_rsdump_info acpi_rs_dump_common_serial_bus[10] = {
369 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_common_serial_bus),
370 "Common Serial Bus", NULL},
371 ACPI_RS_DUMP_COMMON_SERIAL_BUS
372};
373
374struct acpi_rsdump_info acpi_rs_dump_i2c_serial_bus[13] = {
375 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_i2c_serial_bus),
376 "I2C Serial Bus", NULL},
377 ACPI_RS_DUMP_COMMON_SERIAL_BUS {ACPI_RSD_1BITFLAG,
378 ACPI_RSD_OFFSET(i2c_serial_bus.
379 access_mode),
380 "AccessMode", acpi_gbl_am_decode},
381 {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(i2c_serial_bus.connection_speed),
382 "ConnectionSpeed", NULL},
383 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(i2c_serial_bus.slave_address),
384 "SlaveAddress", NULL},
385};
386
387struct acpi_rsdump_info acpi_rs_dump_spi_serial_bus[17] = {
388 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_spi_serial_bus),
389 "Spi Serial Bus", NULL},
390 ACPI_RS_DUMP_COMMON_SERIAL_BUS {ACPI_RSD_1BITFLAG,
391 ACPI_RSD_OFFSET(spi_serial_bus.
392 wire_mode), "WireMode",
393 acpi_gbl_wm_decode},
394 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(spi_serial_bus.device_polarity),
395 "DevicePolarity", acpi_gbl_dp_decode},
396 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(spi_serial_bus.data_bit_length),
397 "DataBitLength", NULL},
398 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(spi_serial_bus.clock_phase),
399 "ClockPhase", acpi_gbl_cph_decode},
400 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(spi_serial_bus.clock_polarity),
401 "ClockPolarity", acpi_gbl_cpo_decode},
402 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(spi_serial_bus.device_selection),
403 "DeviceSelection", NULL},
404 {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(spi_serial_bus.connection_speed),
405 "ConnectionSpeed", NULL},
406};
407
408struct acpi_rsdump_info acpi_rs_dump_uart_serial_bus[19] = {
409 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_uart_serial_bus),
410 "Uart Serial Bus", NULL},
411 ACPI_RS_DUMP_COMMON_SERIAL_BUS {ACPI_RSD_2BITFLAG,
412 ACPI_RSD_OFFSET(uart_serial_bus.
413 flow_control),
414 "FlowControl", acpi_gbl_fc_decode},
415 {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(uart_serial_bus.stop_bits),
416 "StopBits", acpi_gbl_sb_decode},
417 {ACPI_RSD_3BITFLAG, ACPI_RSD_OFFSET(uart_serial_bus.data_bits),
418 "DataBits", acpi_gbl_bpb_decode},
419 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(uart_serial_bus.endian), "Endian",
420 acpi_gbl_ed_decode},
421 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(uart_serial_bus.parity), "Parity",
422 acpi_gbl_pt_decode},
423 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(uart_serial_bus.lines_enabled),
424 "LinesEnabled", NULL},
425 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(uart_serial_bus.rx_fifo_size),
426 "RxFifoSize", NULL},
427 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(uart_serial_bus.tx_fifo_size),
428 "TxFifoSize", NULL},
429 {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(uart_serial_bus.default_baud_rate),
430 "ConnectionSpeed", NULL},
431};
432
312/* 433/*
313 * Tables used for common address descriptor flag fields 434 * Tables used for common address descriptor flag fields
314 */ 435 */
@@ -413,7 +534,14 @@ acpi_rs_dump_descriptor(void *resource, struct acpi_rsdump_info *table)
413 /* Data items, 8/16/32/64 bit */ 534 /* Data items, 8/16/32/64 bit */
414 535
415 case ACPI_RSD_UINT8: 536 case ACPI_RSD_UINT8:
416 acpi_rs_out_integer8(name, ACPI_GET8(target)); 537 if (table->pointer) {
538 acpi_rs_out_string(name, ACPI_CAST_PTR(char,
539 table->
540 pointer
541 [*target]));
542 } else {
543 acpi_rs_out_integer8(name, ACPI_GET8(target));
544 }
417 break; 545 break;
418 546
419 case ACPI_RSD_UINT16: 547 case ACPI_RSD_UINT16:
@@ -444,6 +572,13 @@ acpi_rs_dump_descriptor(void *resource, struct acpi_rsdump_info *table)
444 0x03])); 572 0x03]));
445 break; 573 break;
446 574
575 case ACPI_RSD_3BITFLAG:
576 acpi_rs_out_string(name, ACPI_CAST_PTR(char,
577 table->
578 pointer[*target &
579 0x07]));
580 break;
581
447 case ACPI_RSD_SHORTLIST: 582 case ACPI_RSD_SHORTLIST:
448 /* 583 /*
449 * Short byte list (single line output) for DMA and IRQ resources 584 * Short byte list (single line output) for DMA and IRQ resources
@@ -456,6 +591,20 @@ acpi_rs_dump_descriptor(void *resource, struct acpi_rsdump_info *table)
456 } 591 }
457 break; 592 break;
458 593
594 case ACPI_RSD_SHORTLISTX:
595 /*
596 * Short byte list (single line output) for GPIO vendor data
597 * Note: The list length is obtained from the previous table entry
598 */
599 if (previous_target) {
600 acpi_rs_out_title(name);
601 acpi_rs_dump_short_byte_list(*previous_target,
602 *
603 (ACPI_CAST_INDIRECT_PTR
604 (u8, target)));
605 }
606 break;
607
459 case ACPI_RSD_LONGLIST: 608 case ACPI_RSD_LONGLIST:
460 /* 609 /*
461 * Long byte list for Vendor resource data 610 * Long byte list for Vendor resource data
@@ -480,6 +629,18 @@ acpi_rs_dump_descriptor(void *resource, struct acpi_rsdump_info *table)
480 } 629 }
481 break; 630 break;
482 631
632 case ACPI_RSD_WORDLIST:
633 /*
634 * Word list for GPIO Pin Table
635 * Note: The list length is obtained from the previous table entry
636 */
637 if (previous_target) {
638 acpi_rs_dump_word_list(*previous_target,
639 *(ACPI_CAST_INDIRECT_PTR
640 (u16, target)));
641 }
642 break;
643
483 case ACPI_RSD_ADDRESS: 644 case ACPI_RSD_ADDRESS:
484 /* 645 /*
485 * Common flags for all Address resources 646 * Common flags for all Address resources
@@ -627,14 +788,20 @@ void acpi_rs_dump_resource_list(struct acpi_resource *resource_list)
627 788
628 /* Dump the resource descriptor */ 789 /* Dump the resource descriptor */
629 790
630 acpi_rs_dump_descriptor(&resource_list->data, 791 if (type == ACPI_RESOURCE_TYPE_SERIAL_BUS) {
631 acpi_gbl_dump_resource_dispatch[type]); 792 acpi_rs_dump_descriptor(&resource_list->data,
793 acpi_gbl_dump_serial_bus_dispatch
794 [resource_list->data.
795 common_serial_bus.type]);
796 } else {
797 acpi_rs_dump_descriptor(&resource_list->data,
798 acpi_gbl_dump_resource_dispatch
799 [type]);
800 }
632 801
633 /* Point to the next resource structure */ 802 /* Point to the next resource structure */
634 803
635 resource_list = 804 resource_list = ACPI_NEXT_RESOURCE(resource_list);
636 ACPI_ADD_PTR(struct acpi_resource, resource_list,
637 resource_list->length);
638 805
639 /* Exit when END_TAG descriptor is reached */ 806 /* Exit when END_TAG descriptor is reached */
640 807
@@ -768,4 +935,13 @@ static void acpi_rs_dump_dword_list(u8 length, u32 * data)
768 } 935 }
769} 936}
770 937
938static void acpi_rs_dump_word_list(u16 length, u16 *data)
939{
940 u16 i;
941
942 for (i = 0; i < length; i++) {
943 acpi_os_printf("%25s%2.2X : %4.4X\n", "Word", i, data[i]);
944 }
945}
946
771#endif 947#endif
diff --git a/drivers/acpi/acpica/rsinfo.c b/drivers/acpi/acpica/rsinfo.c
index f9ea60872aa4..e5489bf475fa 100644
--- a/drivers/acpi/acpica/rsinfo.c
+++ b/drivers/acpi/acpica/rsinfo.c
@@ -76,7 +76,10 @@ struct acpi_rsconvert_info *acpi_gbl_set_resource_dispatch[] = {
76 acpi_rs_convert_address64, /* 0x0D, ACPI_RESOURCE_TYPE_ADDRESS64 */ 76 acpi_rs_convert_address64, /* 0x0D, ACPI_RESOURCE_TYPE_ADDRESS64 */
77 acpi_rs_convert_ext_address64, /* 0x0E, ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64 */ 77 acpi_rs_convert_ext_address64, /* 0x0E, ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64 */
78 acpi_rs_convert_ext_irq, /* 0x0F, ACPI_RESOURCE_TYPE_EXTENDED_IRQ */ 78 acpi_rs_convert_ext_irq, /* 0x0F, ACPI_RESOURCE_TYPE_EXTENDED_IRQ */
79 acpi_rs_convert_generic_reg /* 0x10, ACPI_RESOURCE_TYPE_GENERIC_REGISTER */ 79 acpi_rs_convert_generic_reg, /* 0x10, ACPI_RESOURCE_TYPE_GENERIC_REGISTER */
80 acpi_rs_convert_gpio, /* 0x11, ACPI_RESOURCE_TYPE_GPIO */
81 acpi_rs_convert_fixed_dma, /* 0x12, ACPI_RESOURCE_TYPE_FIXED_DMA */
82 NULL, /* 0x13, ACPI_RESOURCE_TYPE_SERIAL_BUS - Use subtype table below */
80}; 83};
81 84
82/* Dispatch tables for AML-to-resource (Get Resource) conversion functions */ 85/* Dispatch tables for AML-to-resource (Get Resource) conversion functions */
@@ -94,7 +97,7 @@ struct acpi_rsconvert_info *acpi_gbl_get_resource_dispatch[] = {
94 acpi_rs_convert_end_dpf, /* 0x07, ACPI_RESOURCE_NAME_END_DEPENDENT */ 97 acpi_rs_convert_end_dpf, /* 0x07, ACPI_RESOURCE_NAME_END_DEPENDENT */
95 acpi_rs_convert_io, /* 0x08, ACPI_RESOURCE_NAME_IO */ 98 acpi_rs_convert_io, /* 0x08, ACPI_RESOURCE_NAME_IO */
96 acpi_rs_convert_fixed_io, /* 0x09, ACPI_RESOURCE_NAME_FIXED_IO */ 99 acpi_rs_convert_fixed_io, /* 0x09, ACPI_RESOURCE_NAME_FIXED_IO */
97 NULL, /* 0x0A, Reserved */ 100 acpi_rs_convert_fixed_dma, /* 0x0A, ACPI_RESOURCE_NAME_FIXED_DMA */
98 NULL, /* 0x0B, Reserved */ 101 NULL, /* 0x0B, Reserved */
99 NULL, /* 0x0C, Reserved */ 102 NULL, /* 0x0C, Reserved */
100 NULL, /* 0x0D, Reserved */ 103 NULL, /* 0x0D, Reserved */
@@ -114,7 +117,19 @@ struct acpi_rsconvert_info *acpi_gbl_get_resource_dispatch[] = {
114 acpi_rs_convert_address16, /* 0x08, ACPI_RESOURCE_NAME_ADDRESS16 */ 117 acpi_rs_convert_address16, /* 0x08, ACPI_RESOURCE_NAME_ADDRESS16 */
115 acpi_rs_convert_ext_irq, /* 0x09, ACPI_RESOURCE_NAME_EXTENDED_IRQ */ 118 acpi_rs_convert_ext_irq, /* 0x09, ACPI_RESOURCE_NAME_EXTENDED_IRQ */
116 acpi_rs_convert_address64, /* 0x0A, ACPI_RESOURCE_NAME_ADDRESS64 */ 119 acpi_rs_convert_address64, /* 0x0A, ACPI_RESOURCE_NAME_ADDRESS64 */
117 acpi_rs_convert_ext_address64 /* 0x0B, ACPI_RESOURCE_NAME_EXTENDED_ADDRESS64 */ 120 acpi_rs_convert_ext_address64, /* 0x0B, ACPI_RESOURCE_NAME_EXTENDED_ADDRESS64 */
121 acpi_rs_convert_gpio, /* 0x0C, ACPI_RESOURCE_NAME_GPIO */
122 NULL, /* 0x0D, Reserved */
123 NULL, /* 0x0E, ACPI_RESOURCE_NAME_SERIAL_BUS - Use subtype table below */
124};
125
126/* Subtype table for serial_bus -- I2C, SPI, and UART */
127
128struct acpi_rsconvert_info *acpi_gbl_convert_resource_serial_bus_dispatch[] = {
129 NULL,
130 acpi_rs_convert_i2c_serial_bus,
131 acpi_rs_convert_spi_serial_bus,
132 acpi_rs_convert_uart_serial_bus,
118}; 133};
119 134
120#ifdef ACPI_FUTURE_USAGE 135#ifdef ACPI_FUTURE_USAGE
@@ -140,6 +155,16 @@ struct acpi_rsdump_info *acpi_gbl_dump_resource_dispatch[] = {
140 acpi_rs_dump_ext_address64, /* ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64 */ 155 acpi_rs_dump_ext_address64, /* ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64 */
141 acpi_rs_dump_ext_irq, /* ACPI_RESOURCE_TYPE_EXTENDED_IRQ */ 156 acpi_rs_dump_ext_irq, /* ACPI_RESOURCE_TYPE_EXTENDED_IRQ */
142 acpi_rs_dump_generic_reg, /* ACPI_RESOURCE_TYPE_GENERIC_REGISTER */ 157 acpi_rs_dump_generic_reg, /* ACPI_RESOURCE_TYPE_GENERIC_REGISTER */
158 acpi_rs_dump_gpio, /* ACPI_RESOURCE_TYPE_GPIO */
159 acpi_rs_dump_fixed_dma, /* ACPI_RESOURCE_TYPE_FIXED_DMA */
160 NULL, /* ACPI_RESOURCE_TYPE_SERIAL_BUS */
161};
162
163struct acpi_rsdump_info *acpi_gbl_dump_serial_bus_dispatch[] = {
164 NULL,
165 acpi_rs_dump_i2c_serial_bus, /* AML_RESOURCE_I2C_BUS_TYPE */
166 acpi_rs_dump_spi_serial_bus, /* AML_RESOURCE_SPI_BUS_TYPE */
167 acpi_rs_dump_uart_serial_bus, /* AML_RESOURCE_UART_BUS_TYPE */
143}; 168};
144#endif 169#endif
145 170
@@ -166,7 +191,10 @@ const u8 acpi_gbl_aml_resource_sizes[] = {
166 sizeof(struct aml_resource_address64), /* ACPI_RESOURCE_TYPE_ADDRESS64 */ 191 sizeof(struct aml_resource_address64), /* ACPI_RESOURCE_TYPE_ADDRESS64 */
167 sizeof(struct aml_resource_extended_address64), /*ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64 */ 192 sizeof(struct aml_resource_extended_address64), /*ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64 */
168 sizeof(struct aml_resource_extended_irq), /* ACPI_RESOURCE_TYPE_EXTENDED_IRQ */ 193 sizeof(struct aml_resource_extended_irq), /* ACPI_RESOURCE_TYPE_EXTENDED_IRQ */
169 sizeof(struct aml_resource_generic_register) /* ACPI_RESOURCE_TYPE_GENERIC_REGISTER */ 194 sizeof(struct aml_resource_generic_register), /* ACPI_RESOURCE_TYPE_GENERIC_REGISTER */
195 sizeof(struct aml_resource_gpio), /* ACPI_RESOURCE_TYPE_GPIO */
196 sizeof(struct aml_resource_fixed_dma), /* ACPI_RESOURCE_TYPE_FIXED_DMA */
197 sizeof(struct aml_resource_common_serialbus), /* ACPI_RESOURCE_TYPE_SERIAL_BUS */
170}; 198};
171 199
172const u8 acpi_gbl_resource_struct_sizes[] = { 200const u8 acpi_gbl_resource_struct_sizes[] = {
@@ -182,7 +210,7 @@ const u8 acpi_gbl_resource_struct_sizes[] = {
182 ACPI_RS_SIZE_MIN, 210 ACPI_RS_SIZE_MIN,
183 ACPI_RS_SIZE(struct acpi_resource_io), 211 ACPI_RS_SIZE(struct acpi_resource_io),
184 ACPI_RS_SIZE(struct acpi_resource_fixed_io), 212 ACPI_RS_SIZE(struct acpi_resource_fixed_io),
185 0, 213 ACPI_RS_SIZE(struct acpi_resource_fixed_dma),
186 0, 214 0,
187 0, 215 0,
188 0, 216 0,
@@ -202,5 +230,21 @@ const u8 acpi_gbl_resource_struct_sizes[] = {
202 ACPI_RS_SIZE(struct acpi_resource_address16), 230 ACPI_RS_SIZE(struct acpi_resource_address16),
203 ACPI_RS_SIZE(struct acpi_resource_extended_irq), 231 ACPI_RS_SIZE(struct acpi_resource_extended_irq),
204 ACPI_RS_SIZE(struct acpi_resource_address64), 232 ACPI_RS_SIZE(struct acpi_resource_address64),
205 ACPI_RS_SIZE(struct acpi_resource_extended_address64) 233 ACPI_RS_SIZE(struct acpi_resource_extended_address64),
234 ACPI_RS_SIZE(struct acpi_resource_gpio),
235 ACPI_RS_SIZE(struct acpi_resource_common_serialbus)
236};
237
238const u8 acpi_gbl_aml_resource_serial_bus_sizes[] = {
239 0,
240 sizeof(struct aml_resource_i2c_serialbus),
241 sizeof(struct aml_resource_spi_serialbus),
242 sizeof(struct aml_resource_uart_serialbus),
243};
244
245const u8 acpi_gbl_resource_struct_serial_bus_sizes[] = {
246 0,
247 ACPI_RS_SIZE(struct acpi_resource_i2c_serialbus),
248 ACPI_RS_SIZE(struct acpi_resource_spi_serialbus),
249 ACPI_RS_SIZE(struct acpi_resource_uart_serialbus),
206}; 250};
diff --git a/drivers/acpi/acpica/rsirq.c b/drivers/acpi/acpica/rsirq.c
index 50b8ad211167..3ac9d4a08fcf 100644
--- a/drivers/acpi/acpica/rsirq.c
+++ b/drivers/acpi/acpica/rsirq.c
@@ -264,3 +264,34 @@ struct acpi_rsconvert_info acpi_rs_convert_dma[6] = {
264 AML_OFFSET(dma.dma_channel_mask), 264 AML_OFFSET(dma.dma_channel_mask),
265 ACPI_RS_OFFSET(data.dma.channel_count)} 265 ACPI_RS_OFFSET(data.dma.channel_count)}
266}; 266};
267
268/*******************************************************************************
269 *
270 * acpi_rs_convert_fixed_dma
271 *
272 ******************************************************************************/
273
274struct acpi_rsconvert_info acpi_rs_convert_fixed_dma[4] = {
275 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_FIXED_DMA,
276 ACPI_RS_SIZE(struct acpi_resource_fixed_dma),
277 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_fixed_dma)},
278
279 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_FIXED_DMA,
280 sizeof(struct aml_resource_fixed_dma),
281 0},
282
283 /*
284 * These fields are contiguous in both the source and destination:
285 * request_lines
286 * Channels
287 */
288
289 {ACPI_RSC_MOVE16, ACPI_RS_OFFSET(data.fixed_dma.request_lines),
290 AML_OFFSET(fixed_dma.request_lines),
291 2},
292
293 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.fixed_dma.width),
294 AML_OFFSET(fixed_dma.width),
295 1},
296
297};
diff --git a/drivers/acpi/acpica/rslist.c b/drivers/acpi/acpica/rslist.c
index 1bfcef736c50..c44635136598 100644
--- a/drivers/acpi/acpica/rslist.c
+++ b/drivers/acpi/acpica/rslist.c
@@ -70,6 +70,8 @@ acpi_rs_convert_aml_to_resources(u8 * aml,
70 struct acpi_resource **resource_ptr = 70 struct acpi_resource **resource_ptr =
71 ACPI_CAST_INDIRECT_PTR(struct acpi_resource, context); 71 ACPI_CAST_INDIRECT_PTR(struct acpi_resource, context);
72 struct acpi_resource *resource; 72 struct acpi_resource *resource;
73 union aml_resource *aml_resource;
74 struct acpi_rsconvert_info *conversion_table;
73 acpi_status status; 75 acpi_status status;
74 76
75 ACPI_FUNCTION_TRACE(rs_convert_aml_to_resources); 77 ACPI_FUNCTION_TRACE(rs_convert_aml_to_resources);
@@ -84,14 +86,37 @@ acpi_rs_convert_aml_to_resources(u8 * aml,
84 "Misaligned resource pointer %p", resource)); 86 "Misaligned resource pointer %p", resource));
85 } 87 }
86 88
89 /* Get the appropriate conversion info table */
90
91 aml_resource = ACPI_CAST_PTR(union aml_resource, aml);
92 if (acpi_ut_get_resource_type(aml) == ACPI_RESOURCE_NAME_SERIAL_BUS) {
93 if (aml_resource->common_serial_bus.type >
94 AML_RESOURCE_MAX_SERIALBUSTYPE) {
95 conversion_table = NULL;
96 } else {
97 /* This is an I2C, SPI, or UART serial_bus descriptor */
98
99 conversion_table =
100 acpi_gbl_convert_resource_serial_bus_dispatch
101 [aml_resource->common_serial_bus.type];
102 }
103 } else {
104 conversion_table =
105 acpi_gbl_get_resource_dispatch[resource_index];
106 }
107
108 if (!conversion_table) {
109 ACPI_ERROR((AE_INFO,
110 "Invalid/unsupported resource descriptor: Type 0x%2.2X",
111 resource_index));
112 return (AE_AML_INVALID_RESOURCE_TYPE);
113 }
114
87 /* Convert the AML byte stream resource to a local resource struct */ 115 /* Convert the AML byte stream resource to a local resource struct */
88 116
89 status = 117 status =
90 acpi_rs_convert_aml_to_resource(resource, 118 acpi_rs_convert_aml_to_resource(resource, aml_resource,
91 ACPI_CAST_PTR(union aml_resource, 119 conversion_table);
92 aml),
93 acpi_gbl_get_resource_dispatch
94 [resource_index]);
95 if (ACPI_FAILURE(status)) { 120 if (ACPI_FAILURE(status)) {
96 ACPI_EXCEPTION((AE_INFO, status, 121 ACPI_EXCEPTION((AE_INFO, status,
97 "Could not convert AML resource (Type 0x%X)", 122 "Could not convert AML resource (Type 0x%X)",
@@ -106,7 +131,7 @@ acpi_rs_convert_aml_to_resources(u8 * aml,
106 131
107 /* Point to the next structure in the output buffer */ 132 /* Point to the next structure in the output buffer */
108 133
109 *resource_ptr = ACPI_ADD_PTR(void, resource, resource->length); 134 *resource_ptr = ACPI_NEXT_RESOURCE(resource);
110 return_ACPI_STATUS(AE_OK); 135 return_ACPI_STATUS(AE_OK);
111} 136}
112 137
@@ -135,6 +160,7 @@ acpi_rs_convert_resources_to_aml(struct acpi_resource *resource,
135{ 160{
136 u8 *aml = output_buffer; 161 u8 *aml = output_buffer;
137 u8 *end_aml = output_buffer + aml_size_needed; 162 u8 *end_aml = output_buffer + aml_size_needed;
163 struct acpi_rsconvert_info *conversion_table;
138 acpi_status status; 164 acpi_status status;
139 165
140 ACPI_FUNCTION_TRACE(rs_convert_resources_to_aml); 166 ACPI_FUNCTION_TRACE(rs_convert_resources_to_aml);
@@ -154,11 +180,34 @@ acpi_rs_convert_resources_to_aml(struct acpi_resource *resource,
154 180
155 /* Perform the conversion */ 181 /* Perform the conversion */
156 182
157 status = acpi_rs_convert_resource_to_aml(resource, ACPI_CAST_PTR(union 183 if (resource->type == ACPI_RESOURCE_TYPE_SERIAL_BUS) {
158 aml_resource, 184 if (resource->data.common_serial_bus.type >
159 aml), 185 AML_RESOURCE_MAX_SERIALBUSTYPE) {
160 acpi_gbl_set_resource_dispatch 186 conversion_table = NULL;
161 [resource->type]); 187 } else {
188 /* This is an I2C, SPI, or UART serial_bus descriptor */
189
190 conversion_table =
191 acpi_gbl_convert_resource_serial_bus_dispatch
192 [resource->data.common_serial_bus.type];
193 }
194 } else {
195 conversion_table =
196 acpi_gbl_set_resource_dispatch[resource->type];
197 }
198
199 if (!conversion_table) {
200 ACPI_ERROR((AE_INFO,
201 "Invalid/unsupported resource descriptor: Type 0x%2.2X",
202 resource->type));
203 return (AE_AML_INVALID_RESOURCE_TYPE);
204 }
205
206 status = acpi_rs_convert_resource_to_aml(resource,
207 ACPI_CAST_PTR(union
208 aml_resource,
209 aml),
210 conversion_table);
162 if (ACPI_FAILURE(status)) { 211 if (ACPI_FAILURE(status)) {
163 ACPI_EXCEPTION((AE_INFO, status, 212 ACPI_EXCEPTION((AE_INFO, status,
164 "Could not convert resource (type 0x%X) to AML", 213 "Could not convert resource (type 0x%X) to AML",
@@ -192,9 +241,7 @@ acpi_rs_convert_resources_to_aml(struct acpi_resource *resource,
192 241
193 /* Point to the next input resource descriptor */ 242 /* Point to the next input resource descriptor */
194 243
195 resource = 244 resource = ACPI_NEXT_RESOURCE(resource);
196 ACPI_ADD_PTR(struct acpi_resource, resource,
197 resource->length);
198 } 245 }
199 246
200 /* Completed buffer, but did not find an end_tag resource descriptor */ 247 /* Completed buffer, but did not find an end_tag resource descriptor */
diff --git a/drivers/acpi/acpica/rsmisc.c b/drivers/acpi/acpica/rsmisc.c
index 410264b22a29..af3dc63163b6 100644
--- a/drivers/acpi/acpica/rsmisc.c
+++ b/drivers/acpi/acpica/rsmisc.c
@@ -83,6 +83,10 @@ acpi_rs_convert_aml_to_resource(struct acpi_resource *resource,
83 83
84 ACPI_FUNCTION_TRACE(rs_convert_aml_to_resource); 84 ACPI_FUNCTION_TRACE(rs_convert_aml_to_resource);
85 85
86 if (!info) {
87 return_ACPI_STATUS(AE_BAD_PARAMETER);
88 }
89
86 if (((acpi_size) resource) & 0x3) { 90 if (((acpi_size) resource) & 0x3) {
87 91
88 /* Each internal resource struct is expected to be 32-bit aligned */ 92 /* Each internal resource struct is expected to be 32-bit aligned */
@@ -101,7 +105,6 @@ acpi_rs_convert_aml_to_resource(struct acpi_resource *resource,
101 * table length (# of table entries) 105 * table length (# of table entries)
102 */ 106 */
103 count = INIT_TABLE_LENGTH(info); 107 count = INIT_TABLE_LENGTH(info);
104
105 while (count) { 108 while (count) {
106 /* 109 /*
107 * Source is the external AML byte stream buffer, 110 * Source is the external AML byte stream buffer,
@@ -145,6 +148,14 @@ acpi_rs_convert_aml_to_resource(struct acpi_resource *resource,
145 ((ACPI_GET8(source) >> info->value) & 0x03); 148 ((ACPI_GET8(source) >> info->value) & 0x03);
146 break; 149 break;
147 150
151 case ACPI_RSC_3BITFLAG:
152 /*
153 * Mask and shift the flag bits
154 */
155 ACPI_SET8(destination) = (u8)
156 ((ACPI_GET8(source) >> info->value) & 0x07);
157 break;
158
148 case ACPI_RSC_COUNT: 159 case ACPI_RSC_COUNT:
149 160
150 item_count = ACPI_GET8(source); 161 item_count = ACPI_GET8(source);
@@ -163,6 +174,69 @@ acpi_rs_convert_aml_to_resource(struct acpi_resource *resource,
163 (info->value * (item_count - 1)); 174 (info->value * (item_count - 1));
164 break; 175 break;
165 176
177 case ACPI_RSC_COUNT_GPIO_PIN:
178
179 target = ACPI_ADD_PTR(void, aml, info->value);
180 item_count = ACPI_GET16(target) - ACPI_GET16(source);
181
182 resource->length = resource->length + item_count;
183 item_count = item_count / 2;
184 ACPI_SET16(destination) = item_count;
185 break;
186
187 case ACPI_RSC_COUNT_GPIO_VEN:
188
189 item_count = ACPI_GET8(source);
190 ACPI_SET8(destination) = (u8)item_count;
191
192 resource->length = resource->length +
193 (info->value * item_count);
194 break;
195
196 case ACPI_RSC_COUNT_GPIO_RES:
197
198 /*
199 * Vendor data is optional (length/offset may both be zero)
200 * Examine vendor data length field first
201 */
202 target = ACPI_ADD_PTR(void, aml, (info->value + 2));
203 if (ACPI_GET16(target)) {
204
205 /* Use vendor offset to get resource source length */
206
207 target = ACPI_ADD_PTR(void, aml, info->value);
208 item_count =
209 ACPI_GET16(target) - ACPI_GET16(source);
210 } else {
211 /* No vendor data to worry about */
212
213 item_count = aml->large_header.resource_length +
214 sizeof(struct aml_resource_large_header) -
215 ACPI_GET16(source);
216 }
217
218 resource->length = resource->length + item_count;
219 ACPI_SET16(destination) = item_count;
220 break;
221
222 case ACPI_RSC_COUNT_SERIAL_VEN:
223
224 item_count = ACPI_GET16(source) - info->value;
225
226 resource->length = resource->length + item_count;
227 ACPI_SET16(destination) = item_count;
228 break;
229
230 case ACPI_RSC_COUNT_SERIAL_RES:
231
232 item_count = (aml_resource_length +
233 sizeof(struct aml_resource_large_header))
234 - ACPI_GET16(source) - info->value;
235
236 resource->length = resource->length + item_count;
237 ACPI_SET16(destination) = item_count;
238 break;
239
166 case ACPI_RSC_LENGTH: 240 case ACPI_RSC_LENGTH:
167 241
168 resource->length = resource->length + info->value; 242 resource->length = resource->length + info->value;
@@ -183,6 +257,72 @@ acpi_rs_convert_aml_to_resource(struct acpi_resource *resource,
183 info->opcode); 257 info->opcode);
184 break; 258 break;
185 259
260 case ACPI_RSC_MOVE_GPIO_PIN:
261
262 /* Generate and set the PIN data pointer */
263
264 target = (char *)ACPI_ADD_PTR(void, resource,
265 (resource->length -
266 item_count * 2));
267 *(u16 **)destination = ACPI_CAST_PTR(u16, target);
268
269 /* Copy the PIN data */
270
271 source = ACPI_ADD_PTR(void, aml, ACPI_GET16(source));
272 acpi_rs_move_data(target, source, item_count,
273 info->opcode);
274 break;
275
276 case ACPI_RSC_MOVE_GPIO_RES:
277
278 /* Generate and set the resource_source string pointer */
279
280 target = (char *)ACPI_ADD_PTR(void, resource,
281 (resource->length -
282 item_count));
283 *(u8 **)destination = ACPI_CAST_PTR(u8, target);
284
285 /* Copy the resource_source string */
286
287 source = ACPI_ADD_PTR(void, aml, ACPI_GET16(source));
288 acpi_rs_move_data(target, source, item_count,
289 info->opcode);
290 break;
291
292 case ACPI_RSC_MOVE_SERIAL_VEN:
293
294 /* Generate and set the Vendor Data pointer */
295
296 target = (char *)ACPI_ADD_PTR(void, resource,
297 (resource->length -
298 item_count));
299 *(u8 **)destination = ACPI_CAST_PTR(u8, target);
300
301 /* Copy the Vendor Data */
302
303 source = ACPI_ADD_PTR(void, aml, info->value);
304 acpi_rs_move_data(target, source, item_count,
305 info->opcode);
306 break;
307
308 case ACPI_RSC_MOVE_SERIAL_RES:
309
310 /* Generate and set the resource_source string pointer */
311
312 target = (char *)ACPI_ADD_PTR(void, resource,
313 (resource->length -
314 item_count));
315 *(u8 **)destination = ACPI_CAST_PTR(u8, target);
316
317 /* Copy the resource_source string */
318
319 source =
320 ACPI_ADD_PTR(void, aml,
321 (ACPI_GET16(source) + info->value));
322 acpi_rs_move_data(target, source, item_count,
323 info->opcode);
324 break;
325
186 case ACPI_RSC_SET8: 326 case ACPI_RSC_SET8:
187 327
188 ACPI_MEMSET(destination, info->aml_offset, info->value); 328 ACPI_MEMSET(destination, info->aml_offset, info->value);
@@ -219,13 +359,18 @@ acpi_rs_convert_aml_to_resource(struct acpi_resource *resource,
219 * Optional resource_source (Index and String). This is the more 359 * Optional resource_source (Index and String). This is the more
220 * complicated case used by the Interrupt() macro 360 * complicated case used by the Interrupt() macro
221 */ 361 */
222 target = 362 target = ACPI_ADD_PTR(char, resource,
223 ACPI_ADD_PTR(char, resource, 363 info->aml_offset +
224 info->aml_offset + (item_count * 4)); 364 (item_count * 4));
225 365
226 resource->length += 366 resource->length +=
227 acpi_rs_get_resource_source(aml_resource_length, 367 acpi_rs_get_resource_source(aml_resource_length,
228 (acpi_rs_length) (((item_count - 1) * sizeof(u32)) + info->value), destination, aml, target); 368 (acpi_rs_length)
369 (((item_count -
370 1) * sizeof(u32)) +
371 info->value),
372 destination, aml,
373 target);
229 break; 374 break;
230 375
231 case ACPI_RSC_BITMASK: 376 case ACPI_RSC_BITMASK:
@@ -327,6 +472,7 @@ acpi_rs_convert_resource_to_aml(struct acpi_resource *resource,
327{ 472{
328 void *source = NULL; 473 void *source = NULL;
329 void *destination; 474 void *destination;
475 char *target;
330 acpi_rsdesc_size aml_length = 0; 476 acpi_rsdesc_size aml_length = 0;
331 u8 count; 477 u8 count;
332 u16 temp16 = 0; 478 u16 temp16 = 0;
@@ -334,6 +480,10 @@ acpi_rs_convert_resource_to_aml(struct acpi_resource *resource,
334 480
335 ACPI_FUNCTION_TRACE(rs_convert_resource_to_aml); 481 ACPI_FUNCTION_TRACE(rs_convert_resource_to_aml);
336 482
483 if (!info) {
484 return_ACPI_STATUS(AE_BAD_PARAMETER);
485 }
486
337 /* 487 /*
338 * First table entry must be ACPI_RSC_INITxxx and must contain the 488 * First table entry must be ACPI_RSC_INITxxx and must contain the
339 * table length (# of table entries) 489 * table length (# of table entries)
@@ -383,6 +533,14 @@ acpi_rs_convert_resource_to_aml(struct acpi_resource *resource,
383 ((ACPI_GET8(source) & 0x03) << info->value); 533 ((ACPI_GET8(source) & 0x03) << info->value);
384 break; 534 break;
385 535
536 case ACPI_RSC_3BITFLAG:
537 /*
538 * Mask and shift the flag bits
539 */
540 ACPI_SET8(destination) |= (u8)
541 ((ACPI_GET8(source) & 0x07) << info->value);
542 break;
543
386 case ACPI_RSC_COUNT: 544 case ACPI_RSC_COUNT:
387 545
388 item_count = ACPI_GET8(source); 546 item_count = ACPI_GET8(source);
@@ -400,6 +558,63 @@ acpi_rs_convert_resource_to_aml(struct acpi_resource *resource,
400 acpi_rs_set_resource_length(aml_length, aml); 558 acpi_rs_set_resource_length(aml_length, aml);
401 break; 559 break;
402 560
561 case ACPI_RSC_COUNT_GPIO_PIN:
562
563 item_count = ACPI_GET16(source);
564 ACPI_SET16(destination) = (u16)aml_length;
565
566 aml_length = (u16)(aml_length + item_count * 2);
567 target = ACPI_ADD_PTR(void, aml, info->value);
568 ACPI_SET16(target) = (u16)aml_length;
569 acpi_rs_set_resource_length(aml_length, aml);
570 break;
571
572 case ACPI_RSC_COUNT_GPIO_VEN:
573
574 item_count = ACPI_GET16(source);
575 ACPI_SET16(destination) = (u16)item_count;
576
577 aml_length =
578 (u16)(aml_length + (info->value * item_count));
579 acpi_rs_set_resource_length(aml_length, aml);
580 break;
581
582 case ACPI_RSC_COUNT_GPIO_RES:
583
584 /* Set resource source string length */
585
586 item_count = ACPI_GET16(source);
587 ACPI_SET16(destination) = (u16)aml_length;
588
589 /* Compute offset for the Vendor Data */
590
591 aml_length = (u16)(aml_length + item_count);
592 target = ACPI_ADD_PTR(void, aml, info->value);
593
594 /* Set vendor offset only if there is vendor data */
595
596 if (resource->data.gpio.vendor_length) {
597 ACPI_SET16(target) = (u16)aml_length;
598 }
599
600 acpi_rs_set_resource_length(aml_length, aml);
601 break;
602
603 case ACPI_RSC_COUNT_SERIAL_VEN:
604
605 item_count = ACPI_GET16(source);
606 ACPI_SET16(destination) = item_count + info->value;
607 aml_length = (u16)(aml_length + item_count);
608 acpi_rs_set_resource_length(aml_length, aml);
609 break;
610
611 case ACPI_RSC_COUNT_SERIAL_RES:
612
613 item_count = ACPI_GET16(source);
614 aml_length = (u16)(aml_length + item_count);
615 acpi_rs_set_resource_length(aml_length, aml);
616 break;
617
403 case ACPI_RSC_LENGTH: 618 case ACPI_RSC_LENGTH:
404 619
405 acpi_rs_set_resource_length(info->value, aml); 620 acpi_rs_set_resource_length(info->value, aml);
@@ -417,6 +632,48 @@ acpi_rs_convert_resource_to_aml(struct acpi_resource *resource,
417 info->opcode); 632 info->opcode);
418 break; 633 break;
419 634
635 case ACPI_RSC_MOVE_GPIO_PIN:
636
637 destination = (char *)ACPI_ADD_PTR(void, aml,
638 ACPI_GET16
639 (destination));
640 source = *(u16 **)source;
641 acpi_rs_move_data(destination, source, item_count,
642 info->opcode);
643 break;
644
645 case ACPI_RSC_MOVE_GPIO_RES:
646
647 /* Used for both resource_source string and vendor_data */
648
649 destination = (char *)ACPI_ADD_PTR(void, aml,
650 ACPI_GET16
651 (destination));
652 source = *(u8 **)source;
653 acpi_rs_move_data(destination, source, item_count,
654 info->opcode);
655 break;
656
657 case ACPI_RSC_MOVE_SERIAL_VEN:
658
659 destination = (char *)ACPI_ADD_PTR(void, aml,
660 (aml_length -
661 item_count));
662 source = *(u8 **)source;
663 acpi_rs_move_data(destination, source, item_count,
664 info->opcode);
665 break;
666
667 case ACPI_RSC_MOVE_SERIAL_RES:
668
669 destination = (char *)ACPI_ADD_PTR(void, aml,
670 (aml_length -
671 item_count));
672 source = *(u8 **)source;
673 acpi_rs_move_data(destination, source, item_count,
674 info->opcode);
675 break;
676
420 case ACPI_RSC_ADDRESS: 677 case ACPI_RSC_ADDRESS:
421 678
422 /* Set the Resource Type, General Flags, and Type-Specific Flags */ 679 /* Set the Resource Type, General Flags, and Type-Specific Flags */
diff --git a/drivers/acpi/acpica/rsserial.c b/drivers/acpi/acpica/rsserial.c
new file mode 100644
index 000000000000..d0b8e121843a
--- /dev/null
+++ b/drivers/acpi/acpica/rsserial.c
@@ -0,0 +1,441 @@
1/*******************************************************************************
2 *
3 * Module Name: rsserial - GPIO/serial_bus resource descriptors
4 *
5 ******************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2011, Intel Corp.
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 "accommon.h"
46#include "acresrc.h"
47
48#define _COMPONENT ACPI_RESOURCES
49ACPI_MODULE_NAME("rsserial")
50
51/*******************************************************************************
52 *
53 * acpi_rs_convert_gpio
54 *
55 ******************************************************************************/
56struct acpi_rsconvert_info acpi_rs_convert_gpio[17] = {
57 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_GPIO,
58 ACPI_RS_SIZE(struct acpi_resource_gpio),
59 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_gpio)},
60
61 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_GPIO,
62 sizeof(struct aml_resource_gpio),
63 0},
64
65 /*
66 * These fields are contiguous in both the source and destination:
67 * revision_id
68 * connection_type
69 */
70 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.gpio.revision_id),
71 AML_OFFSET(gpio.revision_id),
72 2},
73
74 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.gpio.producer_consumer),
75 AML_OFFSET(gpio.flags),
76 0},
77
78 {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET(data.gpio.sharable),
79 AML_OFFSET(gpio.int_flags),
80 3},
81
82 {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET(data.gpio.io_restriction),
83 AML_OFFSET(gpio.int_flags),
84 0},
85
86 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.gpio.triggering),
87 AML_OFFSET(gpio.int_flags),
88 0},
89
90 {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET(data.gpio.polarity),
91 AML_OFFSET(gpio.int_flags),
92 1},
93
94 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.gpio.pin_config),
95 AML_OFFSET(gpio.pin_config),
96 1},
97
98 /*
99 * These fields are contiguous in both the source and destination:
100 * drive_strength
101 * debounce_timeout
102 */
103 {ACPI_RSC_MOVE16, ACPI_RS_OFFSET(data.gpio.drive_strength),
104 AML_OFFSET(gpio.drive_strength),
105 2},
106
107 /* Pin Table */
108
109 {ACPI_RSC_COUNT_GPIO_PIN, ACPI_RS_OFFSET(data.gpio.pin_table_length),
110 AML_OFFSET(gpio.pin_table_offset),
111 AML_OFFSET(gpio.res_source_offset)},
112
113 {ACPI_RSC_MOVE_GPIO_PIN, ACPI_RS_OFFSET(data.gpio.pin_table),
114 AML_OFFSET(gpio.pin_table_offset),
115 0},
116
117 /* Resource Source */
118
119 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.gpio.resource_source.index),
120 AML_OFFSET(gpio.res_source_index),
121 1},
122
123 {ACPI_RSC_COUNT_GPIO_RES,
124 ACPI_RS_OFFSET(data.gpio.resource_source.string_length),
125 AML_OFFSET(gpio.res_source_offset),
126 AML_OFFSET(gpio.vendor_offset)},
127
128 {ACPI_RSC_MOVE_GPIO_RES,
129 ACPI_RS_OFFSET(data.gpio.resource_source.string_ptr),
130 AML_OFFSET(gpio.res_source_offset),
131 0},
132
133 /* Vendor Data */
134
135 {ACPI_RSC_COUNT_GPIO_VEN, ACPI_RS_OFFSET(data.gpio.vendor_length),
136 AML_OFFSET(gpio.vendor_length),
137 1},
138
139 {ACPI_RSC_MOVE_GPIO_RES, ACPI_RS_OFFSET(data.gpio.vendor_data),
140 AML_OFFSET(gpio.vendor_offset),
141 0},
142};
143
144/*******************************************************************************
145 *
146 * acpi_rs_convert_i2c_serial_bus
147 *
148 ******************************************************************************/
149
150struct acpi_rsconvert_info acpi_rs_convert_i2c_serial_bus[16] = {
151 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_SERIAL_BUS,
152 ACPI_RS_SIZE(struct acpi_resource_i2c_serialbus),
153 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_i2c_serial_bus)},
154
155 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_SERIAL_BUS,
156 sizeof(struct aml_resource_i2c_serialbus),
157 0},
158
159 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.common_serial_bus.revision_id),
160 AML_OFFSET(common_serial_bus.revision_id),
161 1},
162
163 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.common_serial_bus.type),
164 AML_OFFSET(common_serial_bus.type),
165 1},
166
167 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.common_serial_bus.slave_mode),
168 AML_OFFSET(common_serial_bus.flags),
169 0},
170
171 {ACPI_RSC_1BITFLAG,
172 ACPI_RS_OFFSET(data.common_serial_bus.producer_consumer),
173 AML_OFFSET(common_serial_bus.flags),
174 1},
175
176 {ACPI_RSC_MOVE8,
177 ACPI_RS_OFFSET(data.common_serial_bus.type_revision_id),
178 AML_OFFSET(common_serial_bus.type_revision_id),
179 1},
180
181 {ACPI_RSC_MOVE16,
182 ACPI_RS_OFFSET(data.common_serial_bus.type_data_length),
183 AML_OFFSET(common_serial_bus.type_data_length),
184 1},
185
186 /* Vendor data */
187
188 {ACPI_RSC_COUNT_SERIAL_VEN,
189 ACPI_RS_OFFSET(data.common_serial_bus.vendor_length),
190 AML_OFFSET(common_serial_bus.type_data_length),
191 AML_RESOURCE_I2C_MIN_DATA_LEN},
192
193 {ACPI_RSC_MOVE_SERIAL_VEN,
194 ACPI_RS_OFFSET(data.common_serial_bus.vendor_data),
195 0,
196 sizeof(struct aml_resource_i2c_serialbus)},
197
198 /* Resource Source */
199
200 {ACPI_RSC_MOVE8,
201 ACPI_RS_OFFSET(data.common_serial_bus.resource_source.index),
202 AML_OFFSET(common_serial_bus.res_source_index),
203 1},
204
205 {ACPI_RSC_COUNT_SERIAL_RES,
206 ACPI_RS_OFFSET(data.common_serial_bus.resource_source.string_length),
207 AML_OFFSET(common_serial_bus.type_data_length),
208 sizeof(struct aml_resource_common_serialbus)},
209
210 {ACPI_RSC_MOVE_SERIAL_RES,
211 ACPI_RS_OFFSET(data.common_serial_bus.resource_source.string_ptr),
212 AML_OFFSET(common_serial_bus.type_data_length),
213 sizeof(struct aml_resource_common_serialbus)},
214
215 /* I2C bus type specific */
216
217 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.i2c_serial_bus.access_mode),
218 AML_OFFSET(i2c_serial_bus.type_specific_flags),
219 0},
220
221 {ACPI_RSC_MOVE32, ACPI_RS_OFFSET(data.i2c_serial_bus.connection_speed),
222 AML_OFFSET(i2c_serial_bus.connection_speed),
223 1},
224
225 {ACPI_RSC_MOVE16, ACPI_RS_OFFSET(data.i2c_serial_bus.slave_address),
226 AML_OFFSET(i2c_serial_bus.slave_address),
227 1},
228};
229
230/*******************************************************************************
231 *
232 * acpi_rs_convert_spi_serial_bus
233 *
234 ******************************************************************************/
235
236struct acpi_rsconvert_info acpi_rs_convert_spi_serial_bus[20] = {
237 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_SERIAL_BUS,
238 ACPI_RS_SIZE(struct acpi_resource_spi_serialbus),
239 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_spi_serial_bus)},
240
241 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_SERIAL_BUS,
242 sizeof(struct aml_resource_spi_serialbus),
243 0},
244
245 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.common_serial_bus.revision_id),
246 AML_OFFSET(common_serial_bus.revision_id),
247 1},
248
249 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.common_serial_bus.type),
250 AML_OFFSET(common_serial_bus.type),
251 1},
252
253 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.common_serial_bus.slave_mode),
254 AML_OFFSET(common_serial_bus.flags),
255 0},
256
257 {ACPI_RSC_1BITFLAG,
258 ACPI_RS_OFFSET(data.common_serial_bus.producer_consumer),
259 AML_OFFSET(common_serial_bus.flags),
260 1},
261
262 {ACPI_RSC_MOVE8,
263 ACPI_RS_OFFSET(data.common_serial_bus.type_revision_id),
264 AML_OFFSET(common_serial_bus.type_revision_id),
265 1},
266
267 {ACPI_RSC_MOVE16,
268 ACPI_RS_OFFSET(data.common_serial_bus.type_data_length),
269 AML_OFFSET(common_serial_bus.type_data_length),
270 1},
271
272 /* Vendor data */
273
274 {ACPI_RSC_COUNT_SERIAL_VEN,
275 ACPI_RS_OFFSET(data.common_serial_bus.vendor_length),
276 AML_OFFSET(common_serial_bus.type_data_length),
277 AML_RESOURCE_SPI_MIN_DATA_LEN},
278
279 {ACPI_RSC_MOVE_SERIAL_VEN,
280 ACPI_RS_OFFSET(data.common_serial_bus.vendor_data),
281 0,
282 sizeof(struct aml_resource_spi_serialbus)},
283
284 /* Resource Source */
285
286 {ACPI_RSC_MOVE8,
287 ACPI_RS_OFFSET(data.common_serial_bus.resource_source.index),
288 AML_OFFSET(common_serial_bus.res_source_index),
289 1},
290
291 {ACPI_RSC_COUNT_SERIAL_RES,
292 ACPI_RS_OFFSET(data.common_serial_bus.resource_source.string_length),
293 AML_OFFSET(common_serial_bus.type_data_length),
294 sizeof(struct aml_resource_common_serialbus)},
295
296 {ACPI_RSC_MOVE_SERIAL_RES,
297 ACPI_RS_OFFSET(data.common_serial_bus.resource_source.string_ptr),
298 AML_OFFSET(common_serial_bus.type_data_length),
299 sizeof(struct aml_resource_common_serialbus)},
300
301 /* Spi bus type specific */
302
303 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.spi_serial_bus.wire_mode),
304 AML_OFFSET(spi_serial_bus.type_specific_flags),
305 0},
306
307 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.spi_serial_bus.device_polarity),
308 AML_OFFSET(spi_serial_bus.type_specific_flags),
309 1},
310
311 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.spi_serial_bus.data_bit_length),
312 AML_OFFSET(spi_serial_bus.data_bit_length),
313 1},
314
315 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.spi_serial_bus.clock_phase),
316 AML_OFFSET(spi_serial_bus.clock_phase),
317 1},
318
319 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.spi_serial_bus.clock_polarity),
320 AML_OFFSET(spi_serial_bus.clock_polarity),
321 1},
322
323 {ACPI_RSC_MOVE16, ACPI_RS_OFFSET(data.spi_serial_bus.device_selection),
324 AML_OFFSET(spi_serial_bus.device_selection),
325 1},
326
327 {ACPI_RSC_MOVE32, ACPI_RS_OFFSET(data.spi_serial_bus.connection_speed),
328 AML_OFFSET(spi_serial_bus.connection_speed),
329 1},
330};
331
332/*******************************************************************************
333 *
334 * acpi_rs_convert_uart_serial_bus
335 *
336 ******************************************************************************/
337
338struct acpi_rsconvert_info acpi_rs_convert_uart_serial_bus[22] = {
339 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_SERIAL_BUS,
340 ACPI_RS_SIZE(struct acpi_resource_uart_serialbus),
341 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_uart_serial_bus)},
342
343 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_SERIAL_BUS,
344 sizeof(struct aml_resource_uart_serialbus),
345 0},
346
347 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.common_serial_bus.revision_id),
348 AML_OFFSET(common_serial_bus.revision_id),
349 1},
350
351 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.common_serial_bus.type),
352 AML_OFFSET(common_serial_bus.type),
353 1},
354
355 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.common_serial_bus.slave_mode),
356 AML_OFFSET(common_serial_bus.flags),
357 0},
358
359 {ACPI_RSC_1BITFLAG,
360 ACPI_RS_OFFSET(data.common_serial_bus.producer_consumer),
361 AML_OFFSET(common_serial_bus.flags),
362 1},
363
364 {ACPI_RSC_MOVE8,
365 ACPI_RS_OFFSET(data.common_serial_bus.type_revision_id),
366 AML_OFFSET(common_serial_bus.type_revision_id),
367 1},
368
369 {ACPI_RSC_MOVE16,
370 ACPI_RS_OFFSET(data.common_serial_bus.type_data_length),
371 AML_OFFSET(common_serial_bus.type_data_length),
372 1},
373
374 /* Vendor data */
375
376 {ACPI_RSC_COUNT_SERIAL_VEN,
377 ACPI_RS_OFFSET(data.common_serial_bus.vendor_length),
378 AML_OFFSET(common_serial_bus.type_data_length),
379 AML_RESOURCE_UART_MIN_DATA_LEN},
380
381 {ACPI_RSC_MOVE_SERIAL_VEN,
382 ACPI_RS_OFFSET(data.common_serial_bus.vendor_data),
383 0,
384 sizeof(struct aml_resource_uart_serialbus)},
385
386 /* Resource Source */
387
388 {ACPI_RSC_MOVE8,
389 ACPI_RS_OFFSET(data.common_serial_bus.resource_source.index),
390 AML_OFFSET(common_serial_bus.res_source_index),
391 1},
392
393 {ACPI_RSC_COUNT_SERIAL_RES,
394 ACPI_RS_OFFSET(data.common_serial_bus.resource_source.string_length),
395 AML_OFFSET(common_serial_bus.type_data_length),
396 sizeof(struct aml_resource_common_serialbus)},
397
398 {ACPI_RSC_MOVE_SERIAL_RES,
399 ACPI_RS_OFFSET(data.common_serial_bus.resource_source.string_ptr),
400 AML_OFFSET(common_serial_bus.type_data_length),
401 sizeof(struct aml_resource_common_serialbus)},
402
403 /* Uart bus type specific */
404
405 {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET(data.uart_serial_bus.flow_control),
406 AML_OFFSET(uart_serial_bus.type_specific_flags),
407 0},
408
409 {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET(data.uart_serial_bus.stop_bits),
410 AML_OFFSET(uart_serial_bus.type_specific_flags),
411 2},
412
413 {ACPI_RSC_3BITFLAG, ACPI_RS_OFFSET(data.uart_serial_bus.data_bits),
414 AML_OFFSET(uart_serial_bus.type_specific_flags),
415 4},
416
417 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.uart_serial_bus.endian),
418 AML_OFFSET(uart_serial_bus.type_specific_flags),
419 7},
420
421 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.uart_serial_bus.parity),
422 AML_OFFSET(uart_serial_bus.parity),
423 1},
424
425 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.uart_serial_bus.lines_enabled),
426 AML_OFFSET(uart_serial_bus.lines_enabled),
427 1},
428
429 {ACPI_RSC_MOVE16, ACPI_RS_OFFSET(data.uart_serial_bus.rx_fifo_size),
430 AML_OFFSET(uart_serial_bus.rx_fifo_size),
431 1},
432
433 {ACPI_RSC_MOVE16, ACPI_RS_OFFSET(data.uart_serial_bus.tx_fifo_size),
434 AML_OFFSET(uart_serial_bus.tx_fifo_size),
435 1},
436
437 {ACPI_RSC_MOVE32,
438 ACPI_RS_OFFSET(data.uart_serial_bus.default_baud_rate),
439 AML_OFFSET(uart_serial_bus.default_baud_rate),
440 1},
441};
diff --git a/drivers/acpi/acpica/rsutils.c b/drivers/acpi/acpica/rsutils.c
index 231811e56939..4409db8209d7 100644
--- a/drivers/acpi/acpica/rsutils.c
+++ b/drivers/acpi/acpica/rsutils.c
@@ -144,6 +144,9 @@ acpi_rs_move_data(void *destination, void *source, u16 item_count, u8 move_type)
144 * since there are no alignment or endian issues 144 * since there are no alignment or endian issues
145 */ 145 */
146 case ACPI_RSC_MOVE8: 146 case ACPI_RSC_MOVE8:
147 case ACPI_RSC_MOVE_GPIO_RES:
148 case ACPI_RSC_MOVE_SERIAL_VEN:
149 case ACPI_RSC_MOVE_SERIAL_RES:
147 ACPI_MEMCPY(destination, source, item_count); 150 ACPI_MEMCPY(destination, source, item_count);
148 return; 151 return;
149 152
@@ -153,6 +156,7 @@ acpi_rs_move_data(void *destination, void *source, u16 item_count, u8 move_type)
153 * misaligned memory transfers 156 * misaligned memory transfers
154 */ 157 */
155 case ACPI_RSC_MOVE16: 158 case ACPI_RSC_MOVE16:
159 case ACPI_RSC_MOVE_GPIO_PIN:
156 ACPI_MOVE_16_TO_16(&ACPI_CAST_PTR(u16, destination)[i], 160 ACPI_MOVE_16_TO_16(&ACPI_CAST_PTR(u16, destination)[i],
157 &ACPI_CAST_PTR(u16, source)[i]); 161 &ACPI_CAST_PTR(u16, source)[i]);
158 break; 162 break;
diff --git a/drivers/acpi/acpica/utresrc.c b/drivers/acpi/acpica/utresrc.c
index 6ffd3a8bdaa5..cd7fbbf57f30 100644
--- a/drivers/acpi/acpica/utresrc.c
+++ b/drivers/acpi/acpica/utresrc.c
@@ -43,7 +43,7 @@
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include "accommon.h" 45#include "accommon.h"
46#include "amlresrc.h" 46#include "acresrc.h"
47 47
48#define _COMPONENT ACPI_UTILITIES 48#define _COMPONENT ACPI_UTILITIES
49ACPI_MODULE_NAME("utresrc") 49ACPI_MODULE_NAME("utresrc")
@@ -154,6 +154,138 @@ const char *acpi_gbl_typ_decode[] = {
154 "TypeF" 154 "TypeF"
155}; 155};
156 156
157const char *acpi_gbl_ppc_decode[] = {
158 "PullDefault",
159 "PullUp",
160 "PullDown",
161 "PullNone"
162};
163
164const char *acpi_gbl_ior_decode[] = {
165 "IoRestrictionNone",
166 "IoRestrictionInputOnly",
167 "IoRestrictionOutputOnly",
168 "IoRestrictionNoneAndPreserve"
169};
170
171const char *acpi_gbl_dts_decode[] = {
172 "Width8bit",
173 "Width16bit",
174 "Width32bit",
175 "Width64bit",
176 "Width128bit",
177 "Width256bit",
178};
179
180/* GPIO connection type */
181
182const char *acpi_gbl_ct_decode[] = {
183 "Interrupt",
184 "I/O"
185};
186
187/* Serial bus type */
188
189const char *acpi_gbl_sbt_decode[] = {
190 "/* UNKNOWN serial bus type */",
191 "I2C",
192 "SPI",
193 "UART"
194};
195
196/* I2C serial bus access mode */
197
198const char *acpi_gbl_am_decode[] = {
199 "AddressingMode7Bit",
200 "AddressingMode10Bit"
201};
202
203/* I2C serial bus slave mode */
204
205const char *acpi_gbl_sm_decode[] = {
206 "ControllerInitiated",
207 "DeviceInitiated"
208};
209
210/* SPI serial bus wire mode */
211
212const char *acpi_gbl_wm_decode[] = {
213 "FourWireMode",
214 "ThreeWireMode"
215};
216
217/* SPI serial clock phase */
218
219const char *acpi_gbl_cph_decode[] = {
220 "ClockPhaseFirst",
221 "ClockPhaseSecond"
222};
223
224/* SPI serial bus clock polarity */
225
226const char *acpi_gbl_cpo_decode[] = {
227 "ClockPolarityLow",
228 "ClockPolarityHigh"
229};
230
231/* SPI serial bus device polarity */
232
233const char *acpi_gbl_dp_decode[] = {
234 "PolarityLow",
235 "PolarityHigh"
236};
237
238/* UART serial bus endian */
239
240const char *acpi_gbl_ed_decode[] = {
241 "LittleEndian",
242 "BigEndian"
243};
244
245/* UART serial bus bits per byte */
246
247const char *acpi_gbl_bpb_decode[] = {
248 "DataBitsFive",
249 "DataBitsSix",
250 "DataBitsSeven",
251 "DataBitsEight",
252 "DataBitsNine",
253 "/* UNKNOWN Bits per byte */",
254 "/* UNKNOWN Bits per byte */",
255 "/* UNKNOWN Bits per byte */"
256};
257
258/* UART serial bus stop bits */
259
260const char *acpi_gbl_sb_decode[] = {
261 "StopBitsNone",
262 "StopBitsOne",
263 "StopBitsOnePlusHalf",
264 "StopBitsTwo"
265};
266
267/* UART serial bus flow control */
268
269const char *acpi_gbl_fc_decode[] = {
270 "FlowControlNone",
271 "FlowControlHardware",
272 "FlowControlXON",
273 "/* UNKNOWN flow control keyword */"
274};
275
276/* UART serial bus parity type */
277
278const char *acpi_gbl_pt_decode[] = {
279 "ParityTypeNone",
280 "ParityTypeEven",
281 "ParityTypeOdd",
282 "ParityTypeMark",
283 "ParityTypeSpace",
284 "/* UNKNOWN parity keyword */",
285 "/* UNKNOWN parity keyword */",
286 "/* UNKNOWN parity keyword */"
287};
288
157#endif 289#endif
158 290
159/* 291/*
@@ -173,7 +305,7 @@ const u8 acpi_gbl_resource_aml_sizes[] = {
173 ACPI_AML_SIZE_SMALL(struct aml_resource_end_dependent), 305 ACPI_AML_SIZE_SMALL(struct aml_resource_end_dependent),
174 ACPI_AML_SIZE_SMALL(struct aml_resource_io), 306 ACPI_AML_SIZE_SMALL(struct aml_resource_io),
175 ACPI_AML_SIZE_SMALL(struct aml_resource_fixed_io), 307 ACPI_AML_SIZE_SMALL(struct aml_resource_fixed_io),
176 0, 308 ACPI_AML_SIZE_SMALL(struct aml_resource_fixed_dma),
177 0, 309 0,
178 0, 310 0,
179 0, 311 0,
@@ -193,7 +325,17 @@ const u8 acpi_gbl_resource_aml_sizes[] = {
193 ACPI_AML_SIZE_LARGE(struct aml_resource_address16), 325 ACPI_AML_SIZE_LARGE(struct aml_resource_address16),
194 ACPI_AML_SIZE_LARGE(struct aml_resource_extended_irq), 326 ACPI_AML_SIZE_LARGE(struct aml_resource_extended_irq),
195 ACPI_AML_SIZE_LARGE(struct aml_resource_address64), 327 ACPI_AML_SIZE_LARGE(struct aml_resource_address64),
196 ACPI_AML_SIZE_LARGE(struct aml_resource_extended_address64) 328 ACPI_AML_SIZE_LARGE(struct aml_resource_extended_address64),
329 ACPI_AML_SIZE_LARGE(struct aml_resource_gpio),
330 0,
331 ACPI_AML_SIZE_LARGE(struct aml_resource_common_serialbus),
332};
333
334const u8 acpi_gbl_resource_aml_serial_bus_sizes[] = {
335 0,
336 ACPI_AML_SIZE_LARGE(struct aml_resource_i2c_serialbus),
337 ACPI_AML_SIZE_LARGE(struct aml_resource_spi_serialbus),
338 ACPI_AML_SIZE_LARGE(struct aml_resource_uart_serialbus),
197}; 339};
198 340
199/* 341/*
@@ -209,35 +351,49 @@ static const u8 acpi_gbl_resource_types[] = {
209 0, 351 0,
210 0, 352 0,
211 0, 353 0,
212 ACPI_SMALL_VARIABLE_LENGTH, 354 ACPI_SMALL_VARIABLE_LENGTH, /* 04 IRQ */
213 ACPI_FIXED_LENGTH, 355 ACPI_FIXED_LENGTH, /* 05 DMA */
214 ACPI_SMALL_VARIABLE_LENGTH, 356 ACPI_SMALL_VARIABLE_LENGTH, /* 06 start_dependent_functions */
215 ACPI_FIXED_LENGTH, 357 ACPI_FIXED_LENGTH, /* 07 end_dependent_functions */
216 ACPI_FIXED_LENGTH, 358 ACPI_FIXED_LENGTH, /* 08 IO */
217 ACPI_FIXED_LENGTH, 359 ACPI_FIXED_LENGTH, /* 09 fixed_iO */
218 0, 360 ACPI_FIXED_LENGTH, /* 0_a fixed_dMA */
219 0, 361 0,
220 0, 362 0,
221 0, 363 0,
222 ACPI_VARIABLE_LENGTH, 364 ACPI_VARIABLE_LENGTH, /* 0_e vendor_short */
223 ACPI_FIXED_LENGTH, 365 ACPI_FIXED_LENGTH, /* 0_f end_tag */
224 366
225 /* Large descriptors */ 367 /* Large descriptors */
226 368
227 0, 369 0,
228 ACPI_FIXED_LENGTH, 370 ACPI_FIXED_LENGTH, /* 01 Memory24 */
229 ACPI_FIXED_LENGTH, 371 ACPI_FIXED_LENGTH, /* 02 generic_register */
230 0, 372 0,
231 ACPI_VARIABLE_LENGTH, 373 ACPI_VARIABLE_LENGTH, /* 04 vendor_long */
232 ACPI_FIXED_LENGTH, 374 ACPI_FIXED_LENGTH, /* 05 Memory32 */
233 ACPI_FIXED_LENGTH, 375 ACPI_FIXED_LENGTH, /* 06 memory32_fixed */
234 ACPI_VARIABLE_LENGTH, 376 ACPI_VARIABLE_LENGTH, /* 07 Dword* address */
235 ACPI_VARIABLE_LENGTH, 377 ACPI_VARIABLE_LENGTH, /* 08 Word* address */
236 ACPI_VARIABLE_LENGTH, 378 ACPI_VARIABLE_LENGTH, /* 09 extended_iRQ */
237 ACPI_VARIABLE_LENGTH, 379 ACPI_VARIABLE_LENGTH, /* 0_a Qword* address */
238 ACPI_FIXED_LENGTH 380 ACPI_FIXED_LENGTH, /* 0_b Extended* address */
381 ACPI_VARIABLE_LENGTH, /* 0_c Gpio* */
382 0,
383 ACPI_VARIABLE_LENGTH /* 0_e *serial_bus */
239}; 384};
240 385
386/*
387 * For the i_aSL compiler/disassembler, we don't want any error messages
388 * because the disassembler uses the resource validation code to determine
389 * if Buffer objects are actually Resource Templates.
390 */
391#ifdef ACPI_ASL_COMPILER
392#define ACPI_RESOURCE_ERROR(plist)
393#else
394#define ACPI_RESOURCE_ERROR(plist) ACPI_ERROR(plist)
395#endif
396
241/******************************************************************************* 397/*******************************************************************************
242 * 398 *
243 * FUNCTION: acpi_ut_walk_aml_resources 399 * FUNCTION: acpi_ut_walk_aml_resources
@@ -265,6 +421,7 @@ acpi_ut_walk_aml_resources(u8 * aml,
265 u8 resource_index; 421 u8 resource_index;
266 u32 length; 422 u32 length;
267 u32 offset = 0; 423 u32 offset = 0;
424 u8 end_tag[2] = { 0x79, 0x00 };
268 425
269 ACPI_FUNCTION_TRACE(ut_walk_aml_resources); 426 ACPI_FUNCTION_TRACE(ut_walk_aml_resources);
270 427
@@ -286,6 +443,10 @@ acpi_ut_walk_aml_resources(u8 * aml,
286 443
287 status = acpi_ut_validate_resource(aml, &resource_index); 444 status = acpi_ut_validate_resource(aml, &resource_index);
288 if (ACPI_FAILURE(status)) { 445 if (ACPI_FAILURE(status)) {
446 /*
447 * Exit on failure. Cannot continue because the descriptor length
448 * may be bogus also.
449 */
289 return_ACPI_STATUS(status); 450 return_ACPI_STATUS(status);
290 } 451 }
291 452
@@ -300,7 +461,7 @@ acpi_ut_walk_aml_resources(u8 * aml,
300 user_function(aml, length, offset, resource_index, 461 user_function(aml, length, offset, resource_index,
301 context); 462 context);
302 if (ACPI_FAILURE(status)) { 463 if (ACPI_FAILURE(status)) {
303 return (status); 464 return_ACPI_STATUS(status);
304 } 465 }
305 } 466 }
306 467
@@ -333,7 +494,19 @@ acpi_ut_walk_aml_resources(u8 * aml,
333 494
334 /* Did not find an end_tag descriptor */ 495 /* Did not find an end_tag descriptor */
335 496
336 return (AE_AML_NO_RESOURCE_END_TAG); 497 if (user_function) {
498
499 /* Insert an end_tag anyway. acpi_rs_get_list_length always leaves room */
500
501 (void)acpi_ut_validate_resource(end_tag, &resource_index);
502 status =
503 user_function(end_tag, 2, offset, resource_index, context);
504 if (ACPI_FAILURE(status)) {
505 return_ACPI_STATUS(status);
506 }
507 }
508
509 return_ACPI_STATUS(AE_AML_NO_RESOURCE_END_TAG);
337} 510}
338 511
339/******************************************************************************* 512/*******************************************************************************
@@ -354,6 +527,7 @@ acpi_ut_walk_aml_resources(u8 * aml,
354 527
355acpi_status acpi_ut_validate_resource(void *aml, u8 * return_index) 528acpi_status acpi_ut_validate_resource(void *aml, u8 * return_index)
356{ 529{
530 union aml_resource *aml_resource;
357 u8 resource_type; 531 u8 resource_type;
358 u8 resource_index; 532 u8 resource_index;
359 acpi_rs_length resource_length; 533 acpi_rs_length resource_length;
@@ -375,7 +549,7 @@ acpi_status acpi_ut_validate_resource(void *aml, u8 * return_index)
375 /* Verify the large resource type (name) against the max */ 549 /* Verify the large resource type (name) against the max */
376 550
377 if (resource_type > ACPI_RESOURCE_NAME_LARGE_MAX) { 551 if (resource_type > ACPI_RESOURCE_NAME_LARGE_MAX) {
378 return (AE_AML_INVALID_RESOURCE_TYPE); 552 goto invalid_resource;
379 } 553 }
380 554
381 /* 555 /*
@@ -392,15 +566,17 @@ acpi_status acpi_ut_validate_resource(void *aml, u8 * return_index)
392 ((resource_type & ACPI_RESOURCE_NAME_SMALL_MASK) >> 3); 566 ((resource_type & ACPI_RESOURCE_NAME_SMALL_MASK) >> 3);
393 } 567 }
394 568
395 /* Check validity of the resource type, zero indicates name is invalid */ 569 /*
396 570 * Check validity of the resource type, via acpi_gbl_resource_types. Zero
571 * indicates an invalid resource.
572 */
397 if (!acpi_gbl_resource_types[resource_index]) { 573 if (!acpi_gbl_resource_types[resource_index]) {
398 return (AE_AML_INVALID_RESOURCE_TYPE); 574 goto invalid_resource;
399 } 575 }
400 576
401 /* 577 /*
402 * 2) Validate the resource_length field. This ensures that the length 578 * Validate the resource_length field. This ensures that the length
403 * is at least reasonable, and guarantees that it is non-zero. 579 * is at least reasonable, and guarantees that it is non-zero.
404 */ 580 */
405 resource_length = acpi_ut_get_resource_length(aml); 581 resource_length = acpi_ut_get_resource_length(aml);
406 minimum_resource_length = acpi_gbl_resource_aml_sizes[resource_index]; 582 minimum_resource_length = acpi_gbl_resource_aml_sizes[resource_index];
@@ -413,7 +589,7 @@ acpi_status acpi_ut_validate_resource(void *aml, u8 * return_index)
413 /* Fixed length resource, length must match exactly */ 589 /* Fixed length resource, length must match exactly */
414 590
415 if (resource_length != minimum_resource_length) { 591 if (resource_length != minimum_resource_length) {
416 return (AE_AML_BAD_RESOURCE_LENGTH); 592 goto bad_resource_length;
417 } 593 }
418 break; 594 break;
419 595
@@ -422,7 +598,7 @@ acpi_status acpi_ut_validate_resource(void *aml, u8 * return_index)
422 /* Variable length resource, length must be at least the minimum */ 598 /* Variable length resource, length must be at least the minimum */
423 599
424 if (resource_length < minimum_resource_length) { 600 if (resource_length < minimum_resource_length) {
425 return (AE_AML_BAD_RESOURCE_LENGTH); 601 goto bad_resource_length;
426 } 602 }
427 break; 603 break;
428 604
@@ -432,7 +608,7 @@ acpi_status acpi_ut_validate_resource(void *aml, u8 * return_index)
432 608
433 if ((resource_length > minimum_resource_length) || 609 if ((resource_length > minimum_resource_length) ||
434 (resource_length < (minimum_resource_length - 1))) { 610 (resource_length < (minimum_resource_length - 1))) {
435 return (AE_AML_BAD_RESOURCE_LENGTH); 611 goto bad_resource_length;
436 } 612 }
437 break; 613 break;
438 614
@@ -440,7 +616,23 @@ acpi_status acpi_ut_validate_resource(void *aml, u8 * return_index)
440 616
441 /* Shouldn't happen (because of validation earlier), but be sure */ 617 /* Shouldn't happen (because of validation earlier), but be sure */
442 618
443 return (AE_AML_INVALID_RESOURCE_TYPE); 619 goto invalid_resource;
620 }
621
622 aml_resource = ACPI_CAST_PTR(union aml_resource, aml);
623 if (resource_type == ACPI_RESOURCE_NAME_SERIAL_BUS) {
624
625 /* Validate the bus_type field */
626
627 if ((aml_resource->common_serial_bus.type == 0) ||
628 (aml_resource->common_serial_bus.type >
629 AML_RESOURCE_MAX_SERIALBUSTYPE)) {
630 ACPI_RESOURCE_ERROR((AE_INFO,
631 "Invalid/unsupported SerialBus resource descriptor: BusType 0x%2.2X",
632 aml_resource->common_serial_bus.
633 type));
634 return (AE_AML_INVALID_RESOURCE_TYPE);
635 }
444 } 636 }
445 637
446 /* Optionally return the resource table index */ 638 /* Optionally return the resource table index */
@@ -450,6 +642,22 @@ acpi_status acpi_ut_validate_resource(void *aml, u8 * return_index)
450 } 642 }
451 643
452 return (AE_OK); 644 return (AE_OK);
645
646 invalid_resource:
647
648 ACPI_RESOURCE_ERROR((AE_INFO,
649 "Invalid/unsupported resource descriptor: Type 0x%2.2X",
650 resource_type));
651 return (AE_AML_INVALID_RESOURCE_TYPE);
652
653 bad_resource_length:
654
655 ACPI_RESOURCE_ERROR((AE_INFO,
656 "Invalid resource descriptor length: Type "
657 "0x%2.2X, Length 0x%4.4X, MinLength 0x%4.4X",
658 resource_type, resource_length,
659 minimum_resource_length));
660 return (AE_AML_BAD_RESOURCE_LENGTH);
453} 661}
454 662
455/******************************************************************************* 663/*******************************************************************************