1 /*******************************************************************************
2  *
3  * Module Name: rsserial - GPIO/SerialBus resource descriptors
4  *
5  ******************************************************************************/
6 
7 /*
8  * Copyright (C) 2000 - 2022, 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 MERCHANTABILITY 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  * AcpiRsConvertCsi2SerialBus
225  *
226  ******************************************************************************/
227 
228 ACPI_RSCONVERT_INFO     AcpiRsConvertCsi2SerialBus[14] =
229 {
230     {ACPI_RSC_INITGET,  ACPI_RESOURCE_TYPE_SERIAL_BUS,
231                         ACPI_RS_SIZE (ACPI_RESOURCE_CSI2_SERIALBUS),
232                         ACPI_RSC_TABLE_SIZE (AcpiRsConvertCsi2SerialBus)},
233 
234     {ACPI_RSC_INITSET,  ACPI_RESOURCE_NAME_SERIAL_BUS,
235                         sizeof (AML_RESOURCE_CSI2_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.Csi2SerialBus.Type),
243                         AML_OFFSET (Csi2SerialBus.Type),
244                         1},
245 
246     {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Csi2SerialBus.ProducerConsumer),
247                         AML_OFFSET (Csi2SerialBus.Flags),
248                         1},
249 
250     {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Csi2SerialBus.SlaveMode),
251                         AML_OFFSET (Csi2SerialBus.Flags),
252                         0},
253 
254     {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.Csi2SerialBus.PhyType),
255                         AML_OFFSET (Csi2SerialBus.TypeSpecificFlags),
256                         0},
257 
258     {ACPI_RSC_6BITFLAG, ACPI_RS_OFFSET (Data.Csi2SerialBus.LocalPortInstance),
259                         AML_OFFSET (Csi2SerialBus.TypeSpecificFlags),
260                         2},
261 
262     {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.Csi2SerialBus.TypeRevisionId),
263                         AML_OFFSET (Csi2SerialBus.TypeRevisionId),
264                         1},
265 
266     /* Vendor data */
267 
268     {ACPI_RSC_COUNT_SERIAL_VEN, ACPI_RS_OFFSET (Data.Csi2SerialBus.VendorLength),
269                         AML_OFFSET (Csi2SerialBus.TypeDataLength),
270                         AML_RESOURCE_CSI2_MIN_DATA_LEN},
271 
272     {ACPI_RSC_MOVE_SERIAL_VEN,  ACPI_RS_OFFSET (Data.Csi2SerialBus.VendorData),
273                         0,
274                         sizeof (AML_RESOURCE_CSI2_SERIALBUS)},
275 
276     /* Resource Source */
277 
278     {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.Csi2SerialBus.ResourceSource.Index),
279                         AML_OFFSET (Csi2SerialBus.ResSourceIndex),
280                         1},
281 
282     {ACPI_RSC_COUNT_SERIAL_RES, ACPI_RS_OFFSET (Data.Csi2SerialBus.ResourceSource.StringLength),
283                         AML_OFFSET (Csi2SerialBus.TypeDataLength),
284                         sizeof (AML_RESOURCE_CSI2_SERIALBUS)},
285 
286     {ACPI_RSC_MOVE_SERIAL_RES,  ACPI_RS_OFFSET (Data.Csi2SerialBus.ResourceSource.StringPtr),
287                         AML_OFFSET (Csi2SerialBus.TypeDataLength),
288                         sizeof (AML_RESOURCE_CSI2_SERIALBUS)},
289 };
290 
291 
292 /*******************************************************************************
293  *
294  * AcpiRsConvertI2cSerialBus
295  *
296  ******************************************************************************/
297 
298 ACPI_RSCONVERT_INFO     AcpiRsConvertI2cSerialBus[17] =
299 {
300     {ACPI_RSC_INITGET,  ACPI_RESOURCE_TYPE_SERIAL_BUS,
301                         ACPI_RS_SIZE (ACPI_RESOURCE_I2C_SERIALBUS),
302                         ACPI_RSC_TABLE_SIZE (AcpiRsConvertI2cSerialBus)},
303 
304     {ACPI_RSC_INITSET,  ACPI_RESOURCE_NAME_SERIAL_BUS,
305                         sizeof (AML_RESOURCE_I2C_SERIALBUS),
306                         0},
307 
308     {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.CommonSerialBus.RevisionId),
309                         AML_OFFSET (CommonSerialBus.RevisionId),
310                         1},
311 
312     {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.CommonSerialBus.Type),
313                         AML_OFFSET (CommonSerialBus.Type),
314                         1},
315 
316     {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.CommonSerialBus.SlaveMode),
317                         AML_OFFSET (CommonSerialBus.Flags),
318                         0},
319 
320     {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.CommonSerialBus.ProducerConsumer),
321                         AML_OFFSET (CommonSerialBus.Flags),
322                         1},
323 
324     {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.CommonSerialBus.ConnectionSharing),
325                         AML_OFFSET (CommonSerialBus.Flags),
326                         2},
327 
328     {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.CommonSerialBus.TypeRevisionId),
329                         AML_OFFSET (CommonSerialBus.TypeRevisionId),
330                         1},
331 
332     {ACPI_RSC_MOVE16,   ACPI_RS_OFFSET (Data.CommonSerialBus.TypeDataLength),
333                         AML_OFFSET (CommonSerialBus.TypeDataLength),
334                         1},
335 
336     /* Vendor data */
337 
338     {ACPI_RSC_COUNT_SERIAL_VEN, ACPI_RS_OFFSET (Data.CommonSerialBus.VendorLength),
339                         AML_OFFSET (CommonSerialBus.TypeDataLength),
340                         AML_RESOURCE_I2C_MIN_DATA_LEN},
341 
342     {ACPI_RSC_MOVE_SERIAL_VEN,  ACPI_RS_OFFSET (Data.CommonSerialBus.VendorData),
343                         0,
344                         sizeof (AML_RESOURCE_I2C_SERIALBUS)},
345 
346     /* Resource Source */
347 
348     {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.CommonSerialBus.ResourceSource.Index),
349                         AML_OFFSET (CommonSerialBus.ResSourceIndex),
350                         1},
351 
352     {ACPI_RSC_COUNT_SERIAL_RES, ACPI_RS_OFFSET (Data.CommonSerialBus.ResourceSource.StringLength),
353                         AML_OFFSET (CommonSerialBus.TypeDataLength),
354                         sizeof (AML_RESOURCE_COMMON_SERIALBUS)},
355 
356     {ACPI_RSC_MOVE_SERIAL_RES,  ACPI_RS_OFFSET (Data.CommonSerialBus.ResourceSource.StringPtr),
357                         AML_OFFSET (CommonSerialBus.TypeDataLength),
358                         sizeof (AML_RESOURCE_COMMON_SERIALBUS)},
359 
360     /* I2C bus type specific */
361 
362     {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.I2cSerialBus.AccessMode),
363                         AML_OFFSET (I2cSerialBus.TypeSpecificFlags),
364                         0},
365 
366     {ACPI_RSC_MOVE32,   ACPI_RS_OFFSET (Data.I2cSerialBus.ConnectionSpeed),
367                         AML_OFFSET (I2cSerialBus.ConnectionSpeed),
368                         1},
369 
370     {ACPI_RSC_MOVE16,   ACPI_RS_OFFSET (Data.I2cSerialBus.SlaveAddress),
371                         AML_OFFSET (I2cSerialBus.SlaveAddress),
372                         1},
373 };
374 
375 
376 /*******************************************************************************
377  *
378  * AcpiRsConvertSpiSerialBus
379  *
380  ******************************************************************************/
381 
382 ACPI_RSCONVERT_INFO     AcpiRsConvertSpiSerialBus[21] =
383 {
384     {ACPI_RSC_INITGET,  ACPI_RESOURCE_TYPE_SERIAL_BUS,
385                         ACPI_RS_SIZE (ACPI_RESOURCE_SPI_SERIALBUS),
386                         ACPI_RSC_TABLE_SIZE (AcpiRsConvertSpiSerialBus)},
387 
388     {ACPI_RSC_INITSET,  ACPI_RESOURCE_NAME_SERIAL_BUS,
389                         sizeof (AML_RESOURCE_SPI_SERIALBUS),
390                         0},
391 
392     {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.CommonSerialBus.RevisionId),
393                         AML_OFFSET (CommonSerialBus.RevisionId),
394                         1},
395 
396     {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.CommonSerialBus.Type),
397                         AML_OFFSET (CommonSerialBus.Type),
398                         1},
399 
400     {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.CommonSerialBus.SlaveMode),
401                         AML_OFFSET (CommonSerialBus.Flags),
402                         0},
403 
404     {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.CommonSerialBus.ProducerConsumer),
405                         AML_OFFSET (CommonSerialBus.Flags),
406                         1},
407 
408     {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.CommonSerialBus.ConnectionSharing),
409                         AML_OFFSET (CommonSerialBus.Flags),
410                         2},
411 
412     {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.CommonSerialBus.TypeRevisionId),
413                         AML_OFFSET (CommonSerialBus.TypeRevisionId),
414                         1},
415 
416     {ACPI_RSC_MOVE16,   ACPI_RS_OFFSET (Data.CommonSerialBus.TypeDataLength),
417                         AML_OFFSET (CommonSerialBus.TypeDataLength),
418                         1},
419 
420     /* Vendor data */
421 
422     {ACPI_RSC_COUNT_SERIAL_VEN, ACPI_RS_OFFSET (Data.CommonSerialBus.VendorLength),
423                         AML_OFFSET (CommonSerialBus.TypeDataLength),
424                         AML_RESOURCE_SPI_MIN_DATA_LEN},
425 
426     {ACPI_RSC_MOVE_SERIAL_VEN,  ACPI_RS_OFFSET (Data.CommonSerialBus.VendorData),
427                         0,
428                         sizeof (AML_RESOURCE_SPI_SERIALBUS)},
429 
430     /* Resource Source */
431 
432     {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.CommonSerialBus.ResourceSource.Index),
433                         AML_OFFSET (CommonSerialBus.ResSourceIndex),
434                         1},
435 
436     {ACPI_RSC_COUNT_SERIAL_RES, ACPI_RS_OFFSET (Data.CommonSerialBus.ResourceSource.StringLength),
437                         AML_OFFSET (CommonSerialBus.TypeDataLength),
438                         sizeof (AML_RESOURCE_COMMON_SERIALBUS)},
439 
440     {ACPI_RSC_MOVE_SERIAL_RES,  ACPI_RS_OFFSET (Data.CommonSerialBus.ResourceSource.StringPtr),
441                         AML_OFFSET (CommonSerialBus.TypeDataLength),
442                         sizeof (AML_RESOURCE_COMMON_SERIALBUS)},
443 
444     /* Spi bus type specific  */
445 
446     {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.SpiSerialBus.WireMode),
447                         AML_OFFSET (SpiSerialBus.TypeSpecificFlags),
448                         0},
449 
450     {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.SpiSerialBus.DevicePolarity),
451                         AML_OFFSET (SpiSerialBus.TypeSpecificFlags),
452                         1},
453 
454     {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.SpiSerialBus.DataBitLength),
455                         AML_OFFSET (SpiSerialBus.DataBitLength),
456                         1},
457 
458     {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.SpiSerialBus.ClockPhase),
459                         AML_OFFSET (SpiSerialBus.ClockPhase),
460                         1},
461 
462     {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.SpiSerialBus.ClockPolarity),
463                         AML_OFFSET (SpiSerialBus.ClockPolarity),
464                         1},
465 
466     {ACPI_RSC_MOVE16,   ACPI_RS_OFFSET (Data.SpiSerialBus.DeviceSelection),
467                         AML_OFFSET (SpiSerialBus.DeviceSelection),
468                         1},
469 
470     {ACPI_RSC_MOVE32,   ACPI_RS_OFFSET (Data.SpiSerialBus.ConnectionSpeed),
471                         AML_OFFSET (SpiSerialBus.ConnectionSpeed),
472                         1},
473 };
474 
475 
476 /*******************************************************************************
477  *
478  * AcpiRsConvertUartSerialBus
479  *
480  ******************************************************************************/
481 
482 ACPI_RSCONVERT_INFO     AcpiRsConvertUartSerialBus[23] =
483 {
484     {ACPI_RSC_INITGET,  ACPI_RESOURCE_TYPE_SERIAL_BUS,
485                         ACPI_RS_SIZE (ACPI_RESOURCE_UART_SERIALBUS),
486                         ACPI_RSC_TABLE_SIZE (AcpiRsConvertUartSerialBus)},
487 
488     {ACPI_RSC_INITSET,  ACPI_RESOURCE_NAME_SERIAL_BUS,
489                         sizeof (AML_RESOURCE_UART_SERIALBUS),
490                         0},
491 
492     {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.CommonSerialBus.RevisionId),
493                         AML_OFFSET (CommonSerialBus.RevisionId),
494                         1},
495 
496     {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.CommonSerialBus.Type),
497                         AML_OFFSET (CommonSerialBus.Type),
498                         1},
499 
500     {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.CommonSerialBus.SlaveMode),
501                         AML_OFFSET (CommonSerialBus.Flags),
502                         0},
503 
504     {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.CommonSerialBus.ProducerConsumer),
505                         AML_OFFSET (CommonSerialBus.Flags),
506                         1},
507 
508     {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.CommonSerialBus.ConnectionSharing),
509                         AML_OFFSET (CommonSerialBus.Flags),
510                         2},
511 
512     {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.CommonSerialBus.TypeRevisionId),
513                         AML_OFFSET (CommonSerialBus.TypeRevisionId),
514                         1},
515 
516     {ACPI_RSC_MOVE16,   ACPI_RS_OFFSET (Data.CommonSerialBus.TypeDataLength),
517                         AML_OFFSET (CommonSerialBus.TypeDataLength),
518                         1},
519 
520     /* Vendor data */
521 
522     {ACPI_RSC_COUNT_SERIAL_VEN, ACPI_RS_OFFSET (Data.CommonSerialBus.VendorLength),
523                         AML_OFFSET (CommonSerialBus.TypeDataLength),
524                         AML_RESOURCE_UART_MIN_DATA_LEN},
525 
526     {ACPI_RSC_MOVE_SERIAL_VEN,  ACPI_RS_OFFSET (Data.CommonSerialBus.VendorData),
527                         0,
528                         sizeof (AML_RESOURCE_UART_SERIALBUS)},
529 
530     /* Resource Source */
531 
532     {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.CommonSerialBus.ResourceSource.Index),
533                         AML_OFFSET (CommonSerialBus.ResSourceIndex),
534                         1},
535 
536     {ACPI_RSC_COUNT_SERIAL_RES, ACPI_RS_OFFSET (Data.CommonSerialBus.ResourceSource.StringLength),
537                         AML_OFFSET (CommonSerialBus.TypeDataLength),
538                         sizeof (AML_RESOURCE_COMMON_SERIALBUS)},
539 
540     {ACPI_RSC_MOVE_SERIAL_RES,  ACPI_RS_OFFSET (Data.CommonSerialBus.ResourceSource.StringPtr),
541                         AML_OFFSET (CommonSerialBus.TypeDataLength),
542                         sizeof (AML_RESOURCE_COMMON_SERIALBUS)},
543 
544     /* Uart bus type specific  */
545 
546     {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.UartSerialBus.FlowControl),
547                         AML_OFFSET (UartSerialBus.TypeSpecificFlags),
548                         0},
549 
550     {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.UartSerialBus.StopBits),
551                         AML_OFFSET (UartSerialBus.TypeSpecificFlags),
552                         2},
553 
554     {ACPI_RSC_3BITFLAG, ACPI_RS_OFFSET (Data.UartSerialBus.DataBits),
555                         AML_OFFSET (UartSerialBus.TypeSpecificFlags),
556                         4},
557 
558     {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.UartSerialBus.Endian),
559                         AML_OFFSET (UartSerialBus.TypeSpecificFlags),
560                         7},
561 
562     {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.UartSerialBus.Parity),
563                         AML_OFFSET (UartSerialBus.Parity),
564                         1},
565 
566     {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.UartSerialBus.LinesEnabled),
567                         AML_OFFSET (UartSerialBus.LinesEnabled),
568                         1},
569 
570     {ACPI_RSC_MOVE16,   ACPI_RS_OFFSET (Data.UartSerialBus.RxFifoSize),
571                         AML_OFFSET (UartSerialBus.RxFifoSize),
572                         1},
573 
574     {ACPI_RSC_MOVE16,   ACPI_RS_OFFSET (Data.UartSerialBus.TxFifoSize),
575                         AML_OFFSET (UartSerialBus.TxFifoSize),
576                         1},
577 
578     {ACPI_RSC_MOVE32,   ACPI_RS_OFFSET (Data.UartSerialBus.DefaultBaudRate),
579                         AML_OFFSET (UartSerialBus.DefaultBaudRate),
580                         1},
581 };
582 
583 
584 /*******************************************************************************
585  *
586  * AcpiRsConvertPinConfig
587  *
588  ******************************************************************************/
589 
590 ACPI_RSCONVERT_INFO     AcpiRsConvertPinConfig[14] =
591 {
592     {ACPI_RSC_INITGET,  ACPI_RESOURCE_TYPE_PIN_CONFIG,
593                         ACPI_RS_SIZE (ACPI_RESOURCE_PIN_CONFIG),
594                         ACPI_RSC_TABLE_SIZE (AcpiRsConvertPinConfig)},
595 
596     {ACPI_RSC_INITSET,  ACPI_RESOURCE_NAME_PIN_CONFIG,
597                         sizeof (AML_RESOURCE_PIN_CONFIG),
598                         0},
599 
600     {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.PinConfig.RevisionId),
601                         AML_OFFSET (PinConfig.RevisionId),
602                         1},
603 
604     {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.PinConfig.Shareable),
605                         AML_OFFSET (PinConfig.Flags),
606                         0},
607 
608     {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.PinConfig.ProducerConsumer),
609                         AML_OFFSET (PinConfig.Flags),
610                         1},
611 
612     {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.PinConfig.PinConfigType),
613                         AML_OFFSET (PinConfig.PinConfigType),
614                         1},
615 
616     {ACPI_RSC_MOVE32,   ACPI_RS_OFFSET (Data.PinConfig.PinConfigValue),
617                         AML_OFFSET (PinConfig.PinConfigValue),
618                         1},
619 
620     /* Pin Table */
621 
622     /*
623      * It is OK to use GPIO operations here because none of them refer GPIO
624      * structures directly but instead use offsets given here.
625      */
626 
627     {ACPI_RSC_COUNT_GPIO_PIN, ACPI_RS_OFFSET (Data.PinConfig.PinTableLength),
628                         AML_OFFSET (PinConfig.PinTableOffset),
629                         AML_OFFSET (PinConfig.ResSourceOffset)},
630 
631     {ACPI_RSC_MOVE_GPIO_PIN, ACPI_RS_OFFSET (Data.PinConfig.PinTable),
632                         AML_OFFSET (PinConfig.PinTableOffset),
633                         0},
634 
635     /* Resource Source */
636 
637     {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.PinConfig.ResourceSource.Index),
638                         AML_OFFSET (PinConfig.ResSourceIndex),
639                         1},
640 
641     {ACPI_RSC_COUNT_GPIO_RES,  ACPI_RS_OFFSET (Data.PinConfig.ResourceSource.StringLength),
642                         AML_OFFSET (PinConfig.ResSourceOffset),
643                         AML_OFFSET (PinConfig.VendorOffset)},
644 
645     {ACPI_RSC_MOVE_GPIO_RES,   ACPI_RS_OFFSET (Data.PinConfig.ResourceSource.StringPtr),
646                         AML_OFFSET (PinConfig.ResSourceOffset),
647                         0},
648 
649     /* Vendor Data */
650 
651     {ACPI_RSC_COUNT_GPIO_VEN,   ACPI_RS_OFFSET (Data.PinConfig.VendorLength),
652                         AML_OFFSET (PinConfig.VendorLength),
653                         1},
654 
655     {ACPI_RSC_MOVE_GPIO_RES,   ACPI_RS_OFFSET (Data.PinConfig.VendorData),
656                         AML_OFFSET (PinConfig.VendorOffset),
657                         0},
658 };
659 
660 /*******************************************************************************
661  *
662  * AcpiRsConvertPinGroup
663  *
664  ******************************************************************************/
665 
666 ACPI_RSCONVERT_INFO     AcpiRsConvertPinGroup[10] =
667 {
668     {ACPI_RSC_INITGET,  ACPI_RESOURCE_TYPE_PIN_GROUP,
669                         ACPI_RS_SIZE (ACPI_RESOURCE_PIN_GROUP),
670                         ACPI_RSC_TABLE_SIZE (AcpiRsConvertPinGroup)},
671 
672     {ACPI_RSC_INITSET,  ACPI_RESOURCE_NAME_PIN_GROUP,
673                         sizeof (AML_RESOURCE_PIN_GROUP),
674                         0},
675 
676     {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.PinGroup.RevisionId),
677                         AML_OFFSET (PinGroup.RevisionId),
678                         1},
679 
680     {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.PinGroup.ProducerConsumer),
681                         AML_OFFSET (PinGroup.Flags),
682                         0},
683 
684     /* Pin Table */
685 
686     /*
687      * It is OK to use GPIO operations here because none of them refer GPIO
688      * structures directly but instead use offsets given here.
689      */
690 
691     {ACPI_RSC_COUNT_GPIO_PIN, ACPI_RS_OFFSET (Data.PinGroup.PinTableLength),
692                         AML_OFFSET (PinGroup.PinTableOffset),
693                         AML_OFFSET (PinGroup.LabelOffset)},
694 
695     {ACPI_RSC_MOVE_GPIO_PIN, ACPI_RS_OFFSET (Data.PinGroup.PinTable),
696                         AML_OFFSET (PinGroup.PinTableOffset),
697                         0},
698 
699     /* Resource Label */
700 
701     {ACPI_RSC_COUNT_GPIO_RES, ACPI_RS_OFFSET (Data.PinGroup.ResourceLabel.StringLength),
702                         AML_OFFSET (PinGroup.LabelOffset),
703                         AML_OFFSET (PinGroup.VendorOffset)},
704 
705     {ACPI_RSC_MOVE_GPIO_RES, ACPI_RS_OFFSET (Data.PinGroup.ResourceLabel.StringPtr),
706                         AML_OFFSET (PinGroup.LabelOffset),
707                         0},
708 
709     /* Vendor Data */
710 
711     {ACPI_RSC_COUNT_GPIO_VEN,   ACPI_RS_OFFSET (Data.PinGroup.VendorLength),
712                         AML_OFFSET (PinGroup.VendorLength),
713                         1},
714 
715     {ACPI_RSC_MOVE_GPIO_RES,   ACPI_RS_OFFSET (Data.PinGroup.VendorData),
716                         AML_OFFSET (PinGroup.VendorOffset),
717                         0},
718 };
719 
720 /*******************************************************************************
721  *
722  * AcpiRsConvertPinGroupFunction
723  *
724  ******************************************************************************/
725 
726 ACPI_RSCONVERT_INFO     AcpiRsConvertPinGroupFunction[13] =
727 {
728     {ACPI_RSC_INITGET,  ACPI_RESOURCE_TYPE_PIN_GROUP_FUNCTION,
729                         ACPI_RS_SIZE (ACPI_RESOURCE_PIN_GROUP_FUNCTION),
730                         ACPI_RSC_TABLE_SIZE (AcpiRsConvertPinGroupFunction)},
731 
732     {ACPI_RSC_INITSET,  ACPI_RESOURCE_NAME_PIN_GROUP_FUNCTION,
733                         sizeof (AML_RESOURCE_PIN_GROUP_FUNCTION),
734                         0},
735 
736     {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.PinGroupFunction.RevisionId),
737                         AML_OFFSET (PinGroupFunction.RevisionId),
738                         1},
739 
740     {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.PinGroupFunction.Shareable),
741                         AML_OFFSET (PinGroupFunction.Flags),
742                         0},
743 
744     {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.PinGroupFunction.ProducerConsumer),
745                         AML_OFFSET (PinGroupFunction.Flags),
746                         1},
747 
748     {ACPI_RSC_MOVE16,   ACPI_RS_OFFSET (Data.PinGroupFunction.FunctionNumber),
749                         AML_OFFSET (PinGroupFunction.FunctionNumber),
750                         1},
751 
752     /* Resource Source */
753 
754     {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.PinGroupFunction.ResourceSource.Index),
755                         AML_OFFSET (PinGroupFunction.ResSourceIndex),
756                         1},
757 
758     {ACPI_RSC_COUNT_GPIO_RES,  ACPI_RS_OFFSET (Data.PinGroupFunction.ResourceSource.StringLength),
759                         AML_OFFSET (PinGroupFunction.ResSourceOffset),
760                         AML_OFFSET (PinGroupFunction.ResSourceLabelOffset)},
761 
762     {ACPI_RSC_MOVE_GPIO_RES,   ACPI_RS_OFFSET (Data.PinGroupFunction.ResourceSource.StringPtr),
763                         AML_OFFSET (PinGroupFunction.ResSourceOffset),
764                         0},
765 
766     /* Resource Source Label */
767 
768     {ACPI_RSC_COUNT_GPIO_RES,  ACPI_RS_OFFSET (Data.PinGroupFunction.ResourceSourceLabel.StringLength),
769                         AML_OFFSET (PinGroupFunction.ResSourceLabelOffset),
770                         AML_OFFSET (PinGroupFunction.VendorOffset)},
771 
772     {ACPI_RSC_MOVE_GPIO_RES,   ACPI_RS_OFFSET (Data.PinGroupFunction.ResourceSourceLabel.StringPtr),
773                         AML_OFFSET (PinGroupFunction.ResSourceLabelOffset),
774                         0},
775 
776     /* Vendor Data */
777 
778     {ACPI_RSC_COUNT_GPIO_VEN,   ACPI_RS_OFFSET (Data.PinGroupFunction.VendorLength),
779                         AML_OFFSET (PinGroupFunction.VendorLength),
780                         1},
781 
782     {ACPI_RSC_MOVE_GPIO_RES,   ACPI_RS_OFFSET (Data.PinGroupFunction.VendorData),
783                         AML_OFFSET (PinGroupFunction.VendorOffset),
784                         0},
785 };
786 
787 /*******************************************************************************
788  *
789  * AcpiRsConvertPinGroupConfig
790  *
791  ******************************************************************************/
792 
793 ACPI_RSCONVERT_INFO     AcpiRsConvertPinGroupConfig[14] =
794 {
795     {ACPI_RSC_INITGET,  ACPI_RESOURCE_TYPE_PIN_GROUP_CONFIG,
796                         ACPI_RS_SIZE (ACPI_RESOURCE_PIN_GROUP_CONFIG),
797                         ACPI_RSC_TABLE_SIZE (AcpiRsConvertPinGroupConfig)},
798 
799     {ACPI_RSC_INITSET,  ACPI_RESOURCE_NAME_PIN_GROUP_CONFIG,
800                         sizeof (AML_RESOURCE_PIN_GROUP_CONFIG),
801                         0},
802 
803     {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.PinGroupConfig.RevisionId),
804                         AML_OFFSET (PinGroupConfig.RevisionId),
805                         1},
806 
807     {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.PinGroupConfig.Shareable),
808                         AML_OFFSET (PinGroupConfig.Flags),
809                         0},
810 
811     {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.PinGroupConfig.ProducerConsumer),
812                         AML_OFFSET (PinGroupConfig.Flags),
813                         1},
814 
815     {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.PinGroupConfig.PinConfigType),
816                         AML_OFFSET (PinGroupConfig.PinConfigType),
817                         1},
818 
819     {ACPI_RSC_MOVE32,   ACPI_RS_OFFSET (Data.PinGroupConfig.PinConfigValue),
820                         AML_OFFSET (PinGroupConfig.PinConfigValue),
821                         1},
822 
823     /* Resource Source */
824 
825     {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.PinGroupConfig.ResourceSource.Index),
826                         AML_OFFSET (PinGroupConfig.ResSourceIndex),
827                         1},
828 
829     {ACPI_RSC_COUNT_GPIO_RES,  ACPI_RS_OFFSET (Data.PinGroupConfig.ResourceSource.StringLength),
830                         AML_OFFSET (PinGroupConfig.ResSourceOffset),
831                         AML_OFFSET (PinGroupConfig.ResSourceLabelOffset)},
832 
833     {ACPI_RSC_MOVE_GPIO_RES,   ACPI_RS_OFFSET (Data.PinGroupConfig.ResourceSource.StringPtr),
834                         AML_OFFSET (PinGroupConfig.ResSourceOffset),
835                         0},
836 
837     /* Resource Source Label */
838 
839     {ACPI_RSC_COUNT_GPIO_RES,  ACPI_RS_OFFSET (Data.PinGroupConfig.ResourceSourceLabel.StringLength),
840                         AML_OFFSET (PinGroupConfig.ResSourceLabelOffset),
841                         AML_OFFSET (PinGroupConfig.VendorOffset)},
842 
843     {ACPI_RSC_MOVE_GPIO_RES,   ACPI_RS_OFFSET (Data.PinGroupConfig.ResourceSourceLabel.StringPtr),
844                         AML_OFFSET (PinGroupConfig.ResSourceLabelOffset),
845                         0},
846 
847     /* Vendor Data */
848 
849     {ACPI_RSC_COUNT_GPIO_VEN,   ACPI_RS_OFFSET (Data.PinGroupConfig.VendorLength),
850                         AML_OFFSET (PinGroupConfig.VendorLength),
851                         1},
852 
853     {ACPI_RSC_MOVE_GPIO_RES,   ACPI_RS_OFFSET (Data.PinGroupConfig.VendorData),
854                         AML_OFFSET (PinGroupConfig.VendorOffset),
855                         0},
856 };
857