1 /*******************************************************************************
2  *
3  * Module Name: rsserial - GPIO/SerialBus resource descriptors
4  *
5  ******************************************************************************/
6 
7 /*
8  * Copyright (C) 2000 - 2020, 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.h"
45 #include "accommon.h"
46 #include "acresrc.h"
47 
48 #define _COMPONENT          ACPI_RESOURCES
49         ACPI_MODULE_NAME    ("rsserial")
50 
51 
52 /*******************************************************************************
53  *
54  * AcpiRsConvertGpio
55  *
56  ******************************************************************************/
57 
58 ACPI_RSCONVERT_INFO     AcpiRsConvertGpio[18] =
59 {
60     {ACPI_RSC_INITGET,  ACPI_RESOURCE_TYPE_GPIO,
61                         ACPI_RS_SIZE (ACPI_RESOURCE_GPIO),
62                         ACPI_RSC_TABLE_SIZE (AcpiRsConvertGpio)},
63 
64     {ACPI_RSC_INITSET,  ACPI_RESOURCE_NAME_GPIO,
65                         sizeof (AML_RESOURCE_GPIO),
66                         0},
67 
68     /*
69      * These fields are contiguous in both the source and destination:
70      * RevisionId
71      * ConnectionType
72      */
73     {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.Gpio.RevisionId),
74                         AML_OFFSET (Gpio.RevisionId),
75                         2},
76 
77     {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Gpio.ProducerConsumer),
78                         AML_OFFSET (Gpio.Flags),
79                         0},
80 
81     {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Gpio.Shareable),
82                         AML_OFFSET (Gpio.IntFlags),
83                         3},
84 
85     {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Gpio.WakeCapable),
86                         AML_OFFSET (Gpio.IntFlags),
87                         4},
88 
89     {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.Gpio.IoRestriction),
90                         AML_OFFSET (Gpio.IntFlags),
91                         0},
92 
93     {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Gpio.Triggering),
94                         AML_OFFSET (Gpio.IntFlags),
95                         0},
96 
97     {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.Gpio.Polarity),
98                         AML_OFFSET (Gpio.IntFlags),
99                         1},
100 
101     {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.Gpio.PinConfig),
102                         AML_OFFSET (Gpio.PinConfig),
103                         1},
104 
105     /*
106      * These fields are contiguous in both the source and destination:
107      * DriveStrength
108      * DebounceTimeout
109      */
110     {ACPI_RSC_MOVE16,   ACPI_RS_OFFSET (Data.Gpio.DriveStrength),
111                         AML_OFFSET (Gpio.DriveStrength),
112                         2},
113 
114     /* Pin Table */
115 
116     {ACPI_RSC_COUNT_GPIO_PIN, ACPI_RS_OFFSET (Data.Gpio.PinTableLength),
117                         AML_OFFSET (Gpio.PinTableOffset),
118                         AML_OFFSET (Gpio.ResSourceOffset)},
119 
120     {ACPI_RSC_MOVE_GPIO_PIN, ACPI_RS_OFFSET (Data.Gpio.PinTable),
121                         AML_OFFSET (Gpio.PinTableOffset),
122                         0},
123 
124     /* Resource Source */
125 
126     {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.Gpio.ResourceSource.Index),
127                         AML_OFFSET (Gpio.ResSourceIndex),
128                         1},
129 
130     {ACPI_RSC_COUNT_GPIO_RES,  ACPI_RS_OFFSET (Data.Gpio.ResourceSource.StringLength),
131                         AML_OFFSET (Gpio.ResSourceOffset),
132                         AML_OFFSET (Gpio.VendorOffset)},
133 
134     {ACPI_RSC_MOVE_GPIO_RES,   ACPI_RS_OFFSET (Data.Gpio.ResourceSource.StringPtr),
135                         AML_OFFSET (Gpio.ResSourceOffset),
136                         0},
137 
138     /* Vendor Data */
139 
140     {ACPI_RSC_COUNT_GPIO_VEN,   ACPI_RS_OFFSET (Data.Gpio.VendorLength),
141                         AML_OFFSET (Gpio.VendorLength),
142                         1},
143 
144     {ACPI_RSC_MOVE_GPIO_RES,   ACPI_RS_OFFSET (Data.Gpio.VendorData),
145                         AML_OFFSET (Gpio.VendorOffset),
146                         0},
147 };
148 
149 /*******************************************************************************
150  *
151  * AcpiRsConvertPinfunction
152  *
153  ******************************************************************************/
154 
155 ACPI_RSCONVERT_INFO     AcpiRsConvertPinFunction[13] =
156 {
157     {ACPI_RSC_INITGET,  ACPI_RESOURCE_TYPE_PIN_FUNCTION,
158                         ACPI_RS_SIZE (ACPI_RESOURCE_PIN_FUNCTION),
159                         ACPI_RSC_TABLE_SIZE (AcpiRsConvertPinFunction)},
160 
161     {ACPI_RSC_INITSET,  ACPI_RESOURCE_NAME_PIN_FUNCTION,
162                         sizeof (AML_RESOURCE_PIN_FUNCTION),
163                         0},
164 
165     {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.PinFunction.RevisionId),
166                         AML_OFFSET (PinFunction.RevisionId),
167                         1},
168 
169     {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.PinFunction.Shareable),
170                         AML_OFFSET (PinFunction.Flags),
171                         0},
172 
173     {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.PinFunction.PinConfig),
174                         AML_OFFSET (PinFunction.PinConfig),
175                         1},
176 
177     {ACPI_RSC_MOVE16,   ACPI_RS_OFFSET (Data.PinFunction.FunctionNumber),
178                         AML_OFFSET (PinFunction.FunctionNumber),
179                         2},
180 
181     /* Pin Table */
182 
183     /*
184      * It is OK to use GPIO operations here because none of them refer GPIO
185      * structures directly but instead use offsets given here.
186      */
187 
188     {ACPI_RSC_COUNT_GPIO_PIN, ACPI_RS_OFFSET (Data.PinFunction.PinTableLength),
189                         AML_OFFSET (PinFunction.PinTableOffset),
190                         AML_OFFSET (PinFunction.ResSourceOffset)},
191 
192     {ACPI_RSC_MOVE_GPIO_PIN, ACPI_RS_OFFSET (Data.PinFunction.PinTable),
193                         AML_OFFSET (PinFunction.PinTableOffset),
194                         0},
195 
196     /* Resource Source */
197 
198     {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.PinFunction.ResourceSource.Index),
199                         AML_OFFSET (PinFunction.ResSourceIndex),
200                         1},
201 
202     {ACPI_RSC_COUNT_GPIO_RES,  ACPI_RS_OFFSET (Data.PinFunction.ResourceSource.StringLength),
203                         AML_OFFSET (PinFunction.ResSourceOffset),
204                         AML_OFFSET (PinFunction.VendorOffset)},
205 
206     {ACPI_RSC_MOVE_GPIO_RES,   ACPI_RS_OFFSET (Data.PinFunction.ResourceSource.StringPtr),
207                         AML_OFFSET (PinFunction.ResSourceOffset),
208                         0},
209 
210     /* Vendor Data */
211 
212     {ACPI_RSC_COUNT_GPIO_VEN,   ACPI_RS_OFFSET (Data.PinFunction.VendorLength),
213                         AML_OFFSET (PinFunction.VendorLength),
214                         1},
215 
216     {ACPI_RSC_MOVE_GPIO_RES,   ACPI_RS_OFFSET (Data.PinFunction.VendorData),
217                         AML_OFFSET (PinFunction.VendorOffset),
218                         0},
219 };
220 
221 
222 /*******************************************************************************
223  *
224  * AcpiRsConvertI2cSerialBus
225  *
226  ******************************************************************************/
227 
228 ACPI_RSCONVERT_INFO     AcpiRsConvertI2cSerialBus[17] =
229 {
230     {ACPI_RSC_INITGET,  ACPI_RESOURCE_TYPE_SERIAL_BUS,
231                         ACPI_RS_SIZE (ACPI_RESOURCE_I2C_SERIALBUS),
232                         ACPI_RSC_TABLE_SIZE (AcpiRsConvertI2cSerialBus)},
233 
234     {ACPI_RSC_INITSET,  ACPI_RESOURCE_NAME_SERIAL_BUS,
235                         sizeof (AML_RESOURCE_I2C_SERIALBUS),
236                         0},
237 
238     {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.CommonSerialBus.RevisionId),
239                         AML_OFFSET (CommonSerialBus.RevisionId),
240                         1},
241 
242     {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.CommonSerialBus.Type),
243                         AML_OFFSET (CommonSerialBus.Type),
244                         1},
245 
246     {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.CommonSerialBus.SlaveMode),
247                         AML_OFFSET (CommonSerialBus.Flags),
248                         0},
249 
250     {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.CommonSerialBus.ProducerConsumer),
251                         AML_OFFSET (CommonSerialBus.Flags),
252                         1},
253 
254     {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.CommonSerialBus.ConnectionSharing),
255                         AML_OFFSET (CommonSerialBus.Flags),
256                         2},
257 
258     {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.CommonSerialBus.TypeRevisionId),
259                         AML_OFFSET (CommonSerialBus.TypeRevisionId),
260                         1},
261 
262     {ACPI_RSC_MOVE16,   ACPI_RS_OFFSET (Data.CommonSerialBus.TypeDataLength),
263                         AML_OFFSET (CommonSerialBus.TypeDataLength),
264                         1},
265 
266     /* Vendor data */
267 
268     {ACPI_RSC_COUNT_SERIAL_VEN, ACPI_RS_OFFSET (Data.CommonSerialBus.VendorLength),
269                         AML_OFFSET (CommonSerialBus.TypeDataLength),
270                         AML_RESOURCE_I2C_MIN_DATA_LEN},
271 
272     {ACPI_RSC_MOVE_SERIAL_VEN,  ACPI_RS_OFFSET (Data.CommonSerialBus.VendorData),
273                         0,
274                         sizeof (AML_RESOURCE_I2C_SERIALBUS)},
275 
276     /* Resource Source */
277 
278     {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.CommonSerialBus.ResourceSource.Index),
279                         AML_OFFSET (CommonSerialBus.ResSourceIndex),
280                         1},
281 
282     {ACPI_RSC_COUNT_SERIAL_RES, ACPI_RS_OFFSET (Data.CommonSerialBus.ResourceSource.StringLength),
283                         AML_OFFSET (CommonSerialBus.TypeDataLength),
284                         sizeof (AML_RESOURCE_COMMON_SERIALBUS)},
285 
286     {ACPI_RSC_MOVE_SERIAL_RES,  ACPI_RS_OFFSET (Data.CommonSerialBus.ResourceSource.StringPtr),
287                         AML_OFFSET (CommonSerialBus.TypeDataLength),
288                         sizeof (AML_RESOURCE_COMMON_SERIALBUS)},
289 
290     /* I2C bus type specific */
291 
292     {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.I2cSerialBus.AccessMode),
293                         AML_OFFSET (I2cSerialBus.TypeSpecificFlags),
294                         0},
295 
296     {ACPI_RSC_MOVE32,   ACPI_RS_OFFSET (Data.I2cSerialBus.ConnectionSpeed),
297                         AML_OFFSET (I2cSerialBus.ConnectionSpeed),
298                         1},
299 
300     {ACPI_RSC_MOVE16,   ACPI_RS_OFFSET (Data.I2cSerialBus.SlaveAddress),
301                         AML_OFFSET (I2cSerialBus.SlaveAddress),
302                         1},
303 };
304 
305 
306 /*******************************************************************************
307  *
308  * AcpiRsConvertSpiSerialBus
309  *
310  ******************************************************************************/
311 
312 ACPI_RSCONVERT_INFO     AcpiRsConvertSpiSerialBus[21] =
313 {
314     {ACPI_RSC_INITGET,  ACPI_RESOURCE_TYPE_SERIAL_BUS,
315                         ACPI_RS_SIZE (ACPI_RESOURCE_SPI_SERIALBUS),
316                         ACPI_RSC_TABLE_SIZE (AcpiRsConvertSpiSerialBus)},
317 
318     {ACPI_RSC_INITSET,  ACPI_RESOURCE_NAME_SERIAL_BUS,
319                         sizeof (AML_RESOURCE_SPI_SERIALBUS),
320                         0},
321 
322     {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.CommonSerialBus.RevisionId),
323                         AML_OFFSET (CommonSerialBus.RevisionId),
324                         1},
325 
326     {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.CommonSerialBus.Type),
327                         AML_OFFSET (CommonSerialBus.Type),
328                         1},
329 
330     {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.CommonSerialBus.SlaveMode),
331                         AML_OFFSET (CommonSerialBus.Flags),
332                         0},
333 
334     {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.CommonSerialBus.ProducerConsumer),
335                         AML_OFFSET (CommonSerialBus.Flags),
336                         1},
337 
338     {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.CommonSerialBus.ConnectionSharing),
339                         AML_OFFSET (CommonSerialBus.Flags),
340                         2},
341 
342     {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.CommonSerialBus.TypeRevisionId),
343                         AML_OFFSET (CommonSerialBus.TypeRevisionId),
344                         1},
345 
346     {ACPI_RSC_MOVE16,   ACPI_RS_OFFSET (Data.CommonSerialBus.TypeDataLength),
347                         AML_OFFSET (CommonSerialBus.TypeDataLength),
348                         1},
349 
350     /* Vendor data */
351 
352     {ACPI_RSC_COUNT_SERIAL_VEN, ACPI_RS_OFFSET (Data.CommonSerialBus.VendorLength),
353                         AML_OFFSET (CommonSerialBus.TypeDataLength),
354                         AML_RESOURCE_SPI_MIN_DATA_LEN},
355 
356     {ACPI_RSC_MOVE_SERIAL_VEN,  ACPI_RS_OFFSET (Data.CommonSerialBus.VendorData),
357                         0,
358                         sizeof (AML_RESOURCE_SPI_SERIALBUS)},
359 
360     /* Resource Source */
361 
362     {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.CommonSerialBus.ResourceSource.Index),
363                         AML_OFFSET (CommonSerialBus.ResSourceIndex),
364                         1},
365 
366     {ACPI_RSC_COUNT_SERIAL_RES, ACPI_RS_OFFSET (Data.CommonSerialBus.ResourceSource.StringLength),
367                         AML_OFFSET (CommonSerialBus.TypeDataLength),
368                         sizeof (AML_RESOURCE_COMMON_SERIALBUS)},
369 
370     {ACPI_RSC_MOVE_SERIAL_RES,  ACPI_RS_OFFSET (Data.CommonSerialBus.ResourceSource.StringPtr),
371                         AML_OFFSET (CommonSerialBus.TypeDataLength),
372                         sizeof (AML_RESOURCE_COMMON_SERIALBUS)},
373 
374     /* Spi bus type specific  */
375 
376     {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.SpiSerialBus.WireMode),
377                         AML_OFFSET (SpiSerialBus.TypeSpecificFlags),
378                         0},
379 
380     {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.SpiSerialBus.DevicePolarity),
381                         AML_OFFSET (SpiSerialBus.TypeSpecificFlags),
382                         1},
383 
384     {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.SpiSerialBus.DataBitLength),
385                         AML_OFFSET (SpiSerialBus.DataBitLength),
386                         1},
387 
388     {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.SpiSerialBus.ClockPhase),
389                         AML_OFFSET (SpiSerialBus.ClockPhase),
390                         1},
391 
392     {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.SpiSerialBus.ClockPolarity),
393                         AML_OFFSET (SpiSerialBus.ClockPolarity),
394                         1},
395 
396     {ACPI_RSC_MOVE16,   ACPI_RS_OFFSET (Data.SpiSerialBus.DeviceSelection),
397                         AML_OFFSET (SpiSerialBus.DeviceSelection),
398                         1},
399 
400     {ACPI_RSC_MOVE32,   ACPI_RS_OFFSET (Data.SpiSerialBus.ConnectionSpeed),
401                         AML_OFFSET (SpiSerialBus.ConnectionSpeed),
402                         1},
403 };
404 
405 
406 /*******************************************************************************
407  *
408  * AcpiRsConvertUartSerialBus
409  *
410  ******************************************************************************/
411 
412 ACPI_RSCONVERT_INFO     AcpiRsConvertUartSerialBus[23] =
413 {
414     {ACPI_RSC_INITGET,  ACPI_RESOURCE_TYPE_SERIAL_BUS,
415                         ACPI_RS_SIZE (ACPI_RESOURCE_UART_SERIALBUS),
416                         ACPI_RSC_TABLE_SIZE (AcpiRsConvertUartSerialBus)},
417 
418     {ACPI_RSC_INITSET,  ACPI_RESOURCE_NAME_SERIAL_BUS,
419                         sizeof (AML_RESOURCE_UART_SERIALBUS),
420                         0},
421 
422     {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.CommonSerialBus.RevisionId),
423                         AML_OFFSET (CommonSerialBus.RevisionId),
424                         1},
425 
426     {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.CommonSerialBus.Type),
427                         AML_OFFSET (CommonSerialBus.Type),
428                         1},
429 
430     {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.CommonSerialBus.SlaveMode),
431                         AML_OFFSET (CommonSerialBus.Flags),
432                         0},
433 
434     {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.CommonSerialBus.ProducerConsumer),
435                         AML_OFFSET (CommonSerialBus.Flags),
436                         1},
437 
438     {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.CommonSerialBus.ConnectionSharing),
439                         AML_OFFSET (CommonSerialBus.Flags),
440                         2},
441 
442     {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.CommonSerialBus.TypeRevisionId),
443                         AML_OFFSET (CommonSerialBus.TypeRevisionId),
444                         1},
445 
446     {ACPI_RSC_MOVE16,   ACPI_RS_OFFSET (Data.CommonSerialBus.TypeDataLength),
447                         AML_OFFSET (CommonSerialBus.TypeDataLength),
448                         1},
449 
450     /* Vendor data */
451 
452     {ACPI_RSC_COUNT_SERIAL_VEN, ACPI_RS_OFFSET (Data.CommonSerialBus.VendorLength),
453                         AML_OFFSET (CommonSerialBus.TypeDataLength),
454                         AML_RESOURCE_UART_MIN_DATA_LEN},
455 
456     {ACPI_RSC_MOVE_SERIAL_VEN,  ACPI_RS_OFFSET (Data.CommonSerialBus.VendorData),
457                         0,
458                         sizeof (AML_RESOURCE_UART_SERIALBUS)},
459 
460     /* Resource Source */
461 
462     {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.CommonSerialBus.ResourceSource.Index),
463                         AML_OFFSET (CommonSerialBus.ResSourceIndex),
464                         1},
465 
466     {ACPI_RSC_COUNT_SERIAL_RES, ACPI_RS_OFFSET (Data.CommonSerialBus.ResourceSource.StringLength),
467                         AML_OFFSET (CommonSerialBus.TypeDataLength),
468                         sizeof (AML_RESOURCE_COMMON_SERIALBUS)},
469 
470     {ACPI_RSC_MOVE_SERIAL_RES,  ACPI_RS_OFFSET (Data.CommonSerialBus.ResourceSource.StringPtr),
471                         AML_OFFSET (CommonSerialBus.TypeDataLength),
472                         sizeof (AML_RESOURCE_COMMON_SERIALBUS)},
473 
474     /* Uart bus type specific  */
475 
476     {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.UartSerialBus.FlowControl),
477                         AML_OFFSET (UartSerialBus.TypeSpecificFlags),
478                         0},
479 
480     {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.UartSerialBus.StopBits),
481                         AML_OFFSET (UartSerialBus.TypeSpecificFlags),
482                         2},
483 
484     {ACPI_RSC_3BITFLAG, ACPI_RS_OFFSET (Data.UartSerialBus.DataBits),
485                         AML_OFFSET (UartSerialBus.TypeSpecificFlags),
486                         4},
487 
488     {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.UartSerialBus.Endian),
489                         AML_OFFSET (UartSerialBus.TypeSpecificFlags),
490                         7},
491 
492     {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.UartSerialBus.Parity),
493                         AML_OFFSET (UartSerialBus.Parity),
494                         1},
495 
496     {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.UartSerialBus.LinesEnabled),
497                         AML_OFFSET (UartSerialBus.LinesEnabled),
498                         1},
499 
500     {ACPI_RSC_MOVE16,   ACPI_RS_OFFSET (Data.UartSerialBus.RxFifoSize),
501                         AML_OFFSET (UartSerialBus.RxFifoSize),
502                         1},
503 
504     {ACPI_RSC_MOVE16,   ACPI_RS_OFFSET (Data.UartSerialBus.TxFifoSize),
505                         AML_OFFSET (UartSerialBus.TxFifoSize),
506                         1},
507 
508     {ACPI_RSC_MOVE32,   ACPI_RS_OFFSET (Data.UartSerialBus.DefaultBaudRate),
509                         AML_OFFSET (UartSerialBus.DefaultBaudRate),
510                         1},
511 };
512 
513 
514 /*******************************************************************************
515  *
516  * AcpiRsConvertPinConfig
517  *
518  ******************************************************************************/
519 
520 ACPI_RSCONVERT_INFO     AcpiRsConvertPinConfig[14] =
521 {
522     {ACPI_RSC_INITGET,  ACPI_RESOURCE_TYPE_PIN_CONFIG,
523                         ACPI_RS_SIZE (ACPI_RESOURCE_PIN_CONFIG),
524                         ACPI_RSC_TABLE_SIZE (AcpiRsConvertPinConfig)},
525 
526     {ACPI_RSC_INITSET,  ACPI_RESOURCE_NAME_PIN_CONFIG,
527                         sizeof (AML_RESOURCE_PIN_CONFIG),
528                         0},
529 
530     {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.PinConfig.RevisionId),
531                         AML_OFFSET (PinConfig.RevisionId),
532                         1},
533 
534     {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.PinConfig.Shareable),
535                         AML_OFFSET (PinConfig.Flags),
536                         0},
537 
538     {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.PinConfig.ProducerConsumer),
539                         AML_OFFSET (PinConfig.Flags),
540                         1},
541 
542     {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.PinConfig.PinConfigType),
543                         AML_OFFSET (PinConfig.PinConfigType),
544                         1},
545 
546     {ACPI_RSC_MOVE32,   ACPI_RS_OFFSET (Data.PinConfig.PinConfigValue),
547                         AML_OFFSET (PinConfig.PinConfigValue),
548                         1},
549 
550     /* Pin Table */
551 
552     /*
553      * It is OK to use GPIO operations here because none of them refer GPIO
554      * structures directly but instead use offsets given here.
555      */
556 
557     {ACPI_RSC_COUNT_GPIO_PIN, ACPI_RS_OFFSET (Data.PinConfig.PinTableLength),
558                         AML_OFFSET (PinConfig.PinTableOffset),
559                         AML_OFFSET (PinConfig.ResSourceOffset)},
560 
561     {ACPI_RSC_MOVE_GPIO_PIN, ACPI_RS_OFFSET (Data.PinConfig.PinTable),
562                         AML_OFFSET (PinConfig.PinTableOffset),
563                         0},
564 
565     /* Resource Source */
566 
567     {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.PinConfig.ResourceSource.Index),
568                         AML_OFFSET (PinConfig.ResSourceIndex),
569                         1},
570 
571     {ACPI_RSC_COUNT_GPIO_RES,  ACPI_RS_OFFSET (Data.PinConfig.ResourceSource.StringLength),
572                         AML_OFFSET (PinConfig.ResSourceOffset),
573                         AML_OFFSET (PinConfig.VendorOffset)},
574 
575     {ACPI_RSC_MOVE_GPIO_RES,   ACPI_RS_OFFSET (Data.PinConfig.ResourceSource.StringPtr),
576                         AML_OFFSET (PinConfig.ResSourceOffset),
577                         0},
578 
579     /* Vendor Data */
580 
581     {ACPI_RSC_COUNT_GPIO_VEN,   ACPI_RS_OFFSET (Data.PinConfig.VendorLength),
582                         AML_OFFSET (PinConfig.VendorLength),
583                         1},
584 
585     {ACPI_RSC_MOVE_GPIO_RES,   ACPI_RS_OFFSET (Data.PinConfig.VendorData),
586                         AML_OFFSET (PinConfig.VendorOffset),
587                         0},
588 };
589 
590 /*******************************************************************************
591  *
592  * AcpiRsConvertPinGroup
593  *
594  ******************************************************************************/
595 
596 ACPI_RSCONVERT_INFO     AcpiRsConvertPinGroup[10] =
597 {
598     {ACPI_RSC_INITGET,  ACPI_RESOURCE_TYPE_PIN_GROUP,
599                         ACPI_RS_SIZE (ACPI_RESOURCE_PIN_GROUP),
600                         ACPI_RSC_TABLE_SIZE (AcpiRsConvertPinGroup)},
601 
602     {ACPI_RSC_INITSET,  ACPI_RESOURCE_NAME_PIN_GROUP,
603                         sizeof (AML_RESOURCE_PIN_GROUP),
604                         0},
605 
606     {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.PinGroup.RevisionId),
607                         AML_OFFSET (PinGroup.RevisionId),
608                         1},
609 
610     {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.PinGroup.ProducerConsumer),
611                         AML_OFFSET (PinGroup.Flags),
612                         0},
613 
614     /* Pin Table */
615 
616     /*
617      * It is OK to use GPIO operations here because none of them refer GPIO
618      * structures directly but instead use offsets given here.
619      */
620 
621     {ACPI_RSC_COUNT_GPIO_PIN, ACPI_RS_OFFSET (Data.PinGroup.PinTableLength),
622                         AML_OFFSET (PinGroup.PinTableOffset),
623                         AML_OFFSET (PinGroup.LabelOffset)},
624 
625     {ACPI_RSC_MOVE_GPIO_PIN, ACPI_RS_OFFSET (Data.PinGroup.PinTable),
626                         AML_OFFSET (PinGroup.PinTableOffset),
627                         0},
628 
629     /* Resource Label */
630 
631     {ACPI_RSC_COUNT_GPIO_RES, ACPI_RS_OFFSET (Data.PinGroup.ResourceLabel.StringLength),
632                         AML_OFFSET (PinGroup.LabelOffset),
633                         AML_OFFSET (PinGroup.VendorOffset)},
634 
635     {ACPI_RSC_MOVE_GPIO_RES, ACPI_RS_OFFSET (Data.PinGroup.ResourceLabel.StringPtr),
636                         AML_OFFSET (PinGroup.LabelOffset),
637                         0},
638 
639     /* Vendor Data */
640 
641     {ACPI_RSC_COUNT_GPIO_VEN,   ACPI_RS_OFFSET (Data.PinGroup.VendorLength),
642                         AML_OFFSET (PinGroup.VendorLength),
643                         1},
644 
645     {ACPI_RSC_MOVE_GPIO_RES,   ACPI_RS_OFFSET (Data.PinGroup.VendorData),
646                         AML_OFFSET (PinGroup.VendorOffset),
647                         0},
648 };
649 
650 /*******************************************************************************
651  *
652  * AcpiRsConvertPinGroupFunction
653  *
654  ******************************************************************************/
655 
656 ACPI_RSCONVERT_INFO     AcpiRsConvertPinGroupFunction[13] =
657 {
658     {ACPI_RSC_INITGET,  ACPI_RESOURCE_TYPE_PIN_GROUP_FUNCTION,
659                         ACPI_RS_SIZE (ACPI_RESOURCE_PIN_GROUP_FUNCTION),
660                         ACPI_RSC_TABLE_SIZE (AcpiRsConvertPinGroupFunction)},
661 
662     {ACPI_RSC_INITSET,  ACPI_RESOURCE_NAME_PIN_GROUP_FUNCTION,
663                         sizeof (AML_RESOURCE_PIN_GROUP_FUNCTION),
664                         0},
665 
666     {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.PinGroupFunction.RevisionId),
667                         AML_OFFSET (PinGroupFunction.RevisionId),
668                         1},
669 
670     {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.PinGroupFunction.Shareable),
671                         AML_OFFSET (PinGroupFunction.Flags),
672                         0},
673 
674     {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.PinGroupFunction.ProducerConsumer),
675                         AML_OFFSET (PinGroupFunction.Flags),
676                         1},
677 
678     {ACPI_RSC_MOVE16,   ACPI_RS_OFFSET (Data.PinGroupFunction.FunctionNumber),
679                         AML_OFFSET (PinGroupFunction.FunctionNumber),
680                         1},
681 
682     /* Resource Source */
683 
684     {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.PinGroupFunction.ResourceSource.Index),
685                         AML_OFFSET (PinGroupFunction.ResSourceIndex),
686                         1},
687 
688     {ACPI_RSC_COUNT_GPIO_RES,  ACPI_RS_OFFSET (Data.PinGroupFunction.ResourceSource.StringLength),
689                         AML_OFFSET (PinGroupFunction.ResSourceOffset),
690                         AML_OFFSET (PinGroupFunction.ResSourceLabelOffset)},
691 
692     {ACPI_RSC_MOVE_GPIO_RES,   ACPI_RS_OFFSET (Data.PinGroupFunction.ResourceSource.StringPtr),
693                         AML_OFFSET (PinGroupFunction.ResSourceOffset),
694                         0},
695 
696     /* Resource Source Label */
697 
698     {ACPI_RSC_COUNT_GPIO_RES,  ACPI_RS_OFFSET (Data.PinGroupFunction.ResourceSourceLabel.StringLength),
699                         AML_OFFSET (PinGroupFunction.ResSourceLabelOffset),
700                         AML_OFFSET (PinGroupFunction.VendorOffset)},
701 
702     {ACPI_RSC_MOVE_GPIO_RES,   ACPI_RS_OFFSET (Data.PinGroupFunction.ResourceSourceLabel.StringPtr),
703                         AML_OFFSET (PinGroupFunction.ResSourceLabelOffset),
704                         0},
705 
706     /* Vendor Data */
707 
708     {ACPI_RSC_COUNT_GPIO_VEN,   ACPI_RS_OFFSET (Data.PinGroupFunction.VendorLength),
709                         AML_OFFSET (PinGroupFunction.VendorLength),
710                         1},
711 
712     {ACPI_RSC_MOVE_GPIO_RES,   ACPI_RS_OFFSET (Data.PinGroupFunction.VendorData),
713                         AML_OFFSET (PinGroupFunction.VendorOffset),
714                         0},
715 };
716 
717 /*******************************************************************************
718  *
719  * AcpiRsConvertPinGroupConfig
720  *
721  ******************************************************************************/
722 
723 ACPI_RSCONVERT_INFO     AcpiRsConvertPinGroupConfig[14] =
724 {
725     {ACPI_RSC_INITGET,  ACPI_RESOURCE_TYPE_PIN_GROUP_CONFIG,
726                         ACPI_RS_SIZE (ACPI_RESOURCE_PIN_GROUP_CONFIG),
727                         ACPI_RSC_TABLE_SIZE (AcpiRsConvertPinGroupConfig)},
728 
729     {ACPI_RSC_INITSET,  ACPI_RESOURCE_NAME_PIN_GROUP_CONFIG,
730                         sizeof (AML_RESOURCE_PIN_GROUP_CONFIG),
731                         0},
732 
733     {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.PinGroupConfig.RevisionId),
734                         AML_OFFSET (PinGroupConfig.RevisionId),
735                         1},
736 
737     {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.PinGroupConfig.Shareable),
738                         AML_OFFSET (PinGroupConfig.Flags),
739                         0},
740 
741     {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.PinGroupConfig.ProducerConsumer),
742                         AML_OFFSET (PinGroupConfig.Flags),
743                         1},
744 
745     {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.PinGroupConfig.PinConfigType),
746                         AML_OFFSET (PinGroupConfig.PinConfigType),
747                         1},
748 
749     {ACPI_RSC_MOVE32,   ACPI_RS_OFFSET (Data.PinGroupConfig.PinConfigValue),
750                         AML_OFFSET (PinGroupConfig.PinConfigValue),
751                         1},
752 
753     /* Resource Source */
754 
755     {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.PinGroupConfig.ResourceSource.Index),
756                         AML_OFFSET (PinGroupConfig.ResSourceIndex),
757                         1},
758 
759     {ACPI_RSC_COUNT_GPIO_RES,  ACPI_RS_OFFSET (Data.PinGroupConfig.ResourceSource.StringLength),
760                         AML_OFFSET (PinGroupConfig.ResSourceOffset),
761                         AML_OFFSET (PinGroupConfig.ResSourceLabelOffset)},
762 
763     {ACPI_RSC_MOVE_GPIO_RES,   ACPI_RS_OFFSET (Data.PinGroupConfig.ResourceSource.StringPtr),
764                         AML_OFFSET (PinGroupConfig.ResSourceOffset),
765                         0},
766 
767     /* Resource Source Label */
768 
769     {ACPI_RSC_COUNT_GPIO_RES,  ACPI_RS_OFFSET (Data.PinGroupConfig.ResourceSourceLabel.StringLength),
770                         AML_OFFSET (PinGroupConfig.ResSourceLabelOffset),
771                         AML_OFFSET (PinGroupConfig.VendorOffset)},
772 
773     {ACPI_RSC_MOVE_GPIO_RES,   ACPI_RS_OFFSET (Data.PinGroupConfig.ResourceSourceLabel.StringPtr),
774                         AML_OFFSET (PinGroupConfig.ResSourceLabelOffset),
775                         0},
776 
777     /* Vendor Data */
778 
779     {ACPI_RSC_COUNT_GPIO_VEN,   ACPI_RS_OFFSET (Data.PinGroupConfig.VendorLength),
780                         AML_OFFSET (PinGroupConfig.VendorLength),
781                         1},
782 
783     {ACPI_RSC_MOVE_GPIO_RES,   ACPI_RS_OFFSET (Data.PinGroupConfig.VendorData),
784                         AML_OFFSET (PinGroupConfig.VendorOffset),
785                         0},
786 };
787