1/*******************************************************************************
2 *
3 * Module Name: rsserial - GPIO/SerialBus resource descriptors
4 *
5 ******************************************************************************/
6
7/******************************************************************************
8 *
9 * 1. Copyright Notice
10 *
11 * Some or all of this work - Copyright (c) 1999 - 2017, Intel Corp.
12 * All rights reserved.
13 *
14 * 2. License
15 *
16 * 2.1. This is your license from Intel Corp. under its intellectual property
17 * rights. You may have additional license terms from the party that provided
18 * you this software, covering your right to use that party's intellectual
19 * property rights.
20 *
21 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
22 * copy of the source code appearing in this file ("Covered Code") an
23 * irrevocable, perpetual, worldwide license under Intel's copyrights in the
24 * base code distributed originally by Intel ("Original Intel Code") to copy,
25 * make derivatives, distribute, use and display any portion of the Covered
26 * Code in any form, with the right to sublicense such rights; and
27 *
28 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
29 * license (with the right to sublicense), under only those claims of Intel
30 * patents that are infringed by the Original Intel Code, to make, use, sell,
31 * offer to sell, and import the Covered Code and derivative works thereof
32 * solely to the minimum extent necessary to exercise the above copyright
33 * license, and in no event shall the patent license extend to any additions
34 * to or modifications of the Original Intel Code. No other license or right
35 * is granted directly or by implication, estoppel or otherwise;
36 *
37 * The above copyright and patent license is granted only if the following
38 * conditions are met:
39 *
40 * 3. Conditions
41 *
42 * 3.1. Redistribution of Source with Rights to Further Distribute Source.
43 * Redistribution of source code of any substantial portion of the Covered
44 * Code or modification with rights to further distribute source must include
45 * the above Copyright Notice, the above License, this list of Conditions,
46 * and the following Disclaimer and Export Compliance provision. In addition,
47 * Licensee must cause all Covered Code to which Licensee contributes to
48 * contain a file documenting the changes Licensee made to create that Covered
49 * Code and the date of any change. Licensee must include in that file the
50 * documentation of any changes made by any predecessor Licensee. Licensee
51 * must include a prominent statement that the modification is derived,
52 * directly or indirectly, from Original Intel Code.
53 *
54 * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
55 * Redistribution of source code of any substantial portion of the Covered
56 * Code or modification without rights to further distribute source must
57 * include the following Disclaimer and Export Compliance provision in the
58 * documentation and/or other materials provided with distribution. In
59 * addition, Licensee may not authorize further sublicense of source of any
60 * portion of the Covered Code, and must include terms to the effect that the
61 * license from Licensee to its licensee is limited to the intellectual
62 * property embodied in the software Licensee provides to its licensee, and
63 * not to intellectual property embodied in modifications its licensee may
64 * make.
65 *
66 * 3.3. Redistribution of Executable. Redistribution in executable form of any
67 * substantial portion of the Covered Code or modification must reproduce the
68 * above Copyright Notice, and the following Disclaimer and Export Compliance
69 * provision in the documentation and/or other materials provided with the
70 * distribution.
71 *
72 * 3.4. Intel retains all right, title, and interest in and to the Original
73 * Intel Code.
74 *
75 * 3.5. Neither the name Intel nor any other trademark owned or controlled by
76 * Intel shall be used in advertising or otherwise to promote the sale, use or
77 * other dealings in products derived from or relating to the Covered Code
78 * without prior written authorization from Intel.
79 *
80 * 4. Disclaimer and Export Compliance
81 *
82 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
83 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
84 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
85 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
86 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
87 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
88 * PARTICULAR PURPOSE.
89 *
90 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
91 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
92 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
93 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
94 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
95 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
96 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
97 * LIMITED REMEDY.
98 *
99 * 4.3. Licensee shall not export, either directly or indirectly, any of this
100 * software or system incorporating such software without first obtaining any
101 * required license or other approval from the U. S. Department of Commerce or
102 * any other agency or department of the United States Government. In the
103 * event Licensee exports any such software from the United States or
104 * re-exports any such software from a foreign destination, Licensee shall
105 * ensure that the distribution and export/re-export of the software is in
106 * compliance with all laws, regulations, orders, or other restrictions of the
107 * U.S. Export Administration Regulations. Licensee agrees that neither it nor
108 * any of its subsidiaries will export/re-export any technical data, process,
109 * software, or service, directly or indirectly, to any country for which the
110 * United States government or any agency thereof requires an export license,
111 * other governmental approval, or letter of assurance, without first obtaining
112 * such license, approval or letter.
113 *
114 *****************************************************************************
115 *
116 * Alternatively, you may choose to be licensed under the terms of the
117 * following license:
118 *
119 * Redistribution and use in source and binary forms, with or without
120 * modification, are permitted provided that the following conditions
121 * are met:
122 * 1. Redistributions of source code must retain the above copyright
123 *    notice, this list of conditions, and the following disclaimer,
124 *    without modification.
125 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
126 *    substantially similar to the "NO WARRANTY" disclaimer below
127 *    ("Disclaimer") and any redistribution must be conditioned upon
128 *    including a substantially similar Disclaimer requirement for further
129 *    binary redistribution.
130 * 3. Neither the names of the above-listed copyright holders nor the names
131 *    of any contributors may be used to endorse or promote products derived
132 *    from this software without specific prior written permission.
133 *
134 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
135 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
136 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
137 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
138 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
139 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
140 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
141 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
142 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
143 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
144 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
145 *
146 * Alternatively, you may choose to be licensed under the terms of the
147 * GNU General Public License ("GPL") version 2 as published by the Free
148 * Software Foundation.
149 *
150 *****************************************************************************/
151
152#include <contrib/dev/acpica/include/acpi.h>
153#include <contrib/dev/acpica/include/accommon.h>
154#include <contrib/dev/acpica/include/acresrc.h>
155
156#define _COMPONENT          ACPI_RESOURCES
157        ACPI_MODULE_NAME    ("rsserial")
158
159
160/*******************************************************************************
161 *
162 * AcpiRsConvertGpio
163 *
164 ******************************************************************************/
165
166ACPI_RSCONVERT_INFO     AcpiRsConvertGpio[18] =
167{
168    {ACPI_RSC_INITGET,  ACPI_RESOURCE_TYPE_GPIO,
169                        ACPI_RS_SIZE (ACPI_RESOURCE_GPIO),
170                        ACPI_RSC_TABLE_SIZE (AcpiRsConvertGpio)},
171
172    {ACPI_RSC_INITSET,  ACPI_RESOURCE_NAME_GPIO,
173                        sizeof (AML_RESOURCE_GPIO),
174                        0},
175
176    /*
177     * These fields are contiguous in both the source and destination:
178     * RevisionId
179     * ConnectionType
180     */
181    {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.Gpio.RevisionId),
182                        AML_OFFSET (Gpio.RevisionId),
183                        2},
184
185    {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Gpio.ProducerConsumer),
186                        AML_OFFSET (Gpio.Flags),
187                        0},
188
189    {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Gpio.Sharable),
190                        AML_OFFSET (Gpio.IntFlags),
191                        3},
192
193    {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Gpio.WakeCapable),
194                        AML_OFFSET (Gpio.IntFlags),
195                        4},
196
197    {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.Gpio.IoRestriction),
198                        AML_OFFSET (Gpio.IntFlags),
199                        0},
200
201    {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Gpio.Triggering),
202                        AML_OFFSET (Gpio.IntFlags),
203                        0},
204
205    {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.Gpio.Polarity),
206                        AML_OFFSET (Gpio.IntFlags),
207                        1},
208
209    {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.Gpio.PinConfig),
210                        AML_OFFSET (Gpio.PinConfig),
211                        1},
212
213    /*
214     * These fields are contiguous in both the source and destination:
215     * DriveStrength
216     * DebounceTimeout
217     */
218    {ACPI_RSC_MOVE16,   ACPI_RS_OFFSET (Data.Gpio.DriveStrength),
219                        AML_OFFSET (Gpio.DriveStrength),
220                        2},
221
222    /* Pin Table */
223
224    {ACPI_RSC_COUNT_GPIO_PIN, ACPI_RS_OFFSET (Data.Gpio.PinTableLength),
225                        AML_OFFSET (Gpio.PinTableOffset),
226                        AML_OFFSET (Gpio.ResSourceOffset)},
227
228    {ACPI_RSC_MOVE_GPIO_PIN, ACPI_RS_OFFSET (Data.Gpio.PinTable),
229                        AML_OFFSET (Gpio.PinTableOffset),
230                        0},
231
232    /* Resource Source */
233
234    {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.Gpio.ResourceSource.Index),
235                        AML_OFFSET (Gpio.ResSourceIndex),
236                        1},
237
238    {ACPI_RSC_COUNT_GPIO_RES,  ACPI_RS_OFFSET (Data.Gpio.ResourceSource.StringLength),
239                        AML_OFFSET (Gpio.ResSourceOffset),
240                        AML_OFFSET (Gpio.VendorOffset)},
241
242    {ACPI_RSC_MOVE_GPIO_RES,   ACPI_RS_OFFSET (Data.Gpio.ResourceSource.StringPtr),
243                        AML_OFFSET (Gpio.ResSourceOffset),
244                        0},
245
246    /* Vendor Data */
247
248    {ACPI_RSC_COUNT_GPIO_VEN,   ACPI_RS_OFFSET (Data.Gpio.VendorLength),
249                        AML_OFFSET (Gpio.VendorLength),
250                        1},
251
252    {ACPI_RSC_MOVE_GPIO_RES,   ACPI_RS_OFFSET (Data.Gpio.VendorData),
253                        AML_OFFSET (Gpio.VendorOffset),
254                        0},
255};
256
257/*******************************************************************************
258 *
259 * AcpiRsConvertPinfunction
260 *
261 ******************************************************************************/
262
263ACPI_RSCONVERT_INFO     AcpiRsConvertPinFunction[13] =
264{
265    {ACPI_RSC_INITGET,  ACPI_RESOURCE_TYPE_PIN_FUNCTION,
266                        ACPI_RS_SIZE (ACPI_RESOURCE_PIN_FUNCTION),
267                        ACPI_RSC_TABLE_SIZE (AcpiRsConvertPinFunction)},
268
269    {ACPI_RSC_INITSET,  ACPI_RESOURCE_NAME_PIN_FUNCTION,
270                        sizeof (AML_RESOURCE_PIN_FUNCTION),
271                        0},
272
273    {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.PinFunction.RevisionId),
274                        AML_OFFSET (PinFunction.RevisionId),
275                        1},
276
277    {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.PinFunction.Sharable),
278                        AML_OFFSET (PinFunction.Flags),
279                        0},
280
281    {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.PinFunction.PinConfig),
282                        AML_OFFSET (PinFunction.PinConfig),
283                        1},
284
285    {ACPI_RSC_MOVE16,   ACPI_RS_OFFSET (Data.PinFunction.FunctionNumber),
286                        AML_OFFSET (PinFunction.FunctionNumber),
287                        2},
288
289    /* Pin Table */
290
291    /*
292     * It is OK to use GPIO operations here because none of them refer GPIO
293     * structures directly but instead use offsets given here.
294     */
295
296    {ACPI_RSC_COUNT_GPIO_PIN, ACPI_RS_OFFSET (Data.PinFunction.PinTableLength),
297                        AML_OFFSET (PinFunction.PinTableOffset),
298                        AML_OFFSET (PinFunction.ResSourceOffset)},
299
300    {ACPI_RSC_MOVE_GPIO_PIN, ACPI_RS_OFFSET (Data.PinFunction.PinTable),
301                        AML_OFFSET (PinFunction.PinTableOffset),
302                        0},
303
304    /* Resource Source */
305
306    {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.PinFunction.ResourceSource.Index),
307                        AML_OFFSET (PinFunction.ResSourceIndex),
308                        1},
309
310    {ACPI_RSC_COUNT_GPIO_RES,  ACPI_RS_OFFSET (Data.PinFunction.ResourceSource.StringLength),
311                        AML_OFFSET (PinFunction.ResSourceOffset),
312                        AML_OFFSET (PinFunction.VendorOffset)},
313
314    {ACPI_RSC_MOVE_GPIO_RES,   ACPI_RS_OFFSET (Data.PinFunction.ResourceSource.StringPtr),
315                        AML_OFFSET (PinFunction.ResSourceOffset),
316                        0},
317
318    /* Vendor Data */
319
320    {ACPI_RSC_COUNT_GPIO_VEN,   ACPI_RS_OFFSET (Data.PinFunction.VendorLength),
321                        AML_OFFSET (PinFunction.VendorLength),
322                        1},
323
324    {ACPI_RSC_MOVE_GPIO_RES,   ACPI_RS_OFFSET (Data.PinFunction.VendorData),
325                        AML_OFFSET (PinFunction.VendorOffset),
326                        0},
327};
328
329
330/*******************************************************************************
331 *
332 * AcpiRsConvertI2cSerialBus
333 *
334 ******************************************************************************/
335
336ACPI_RSCONVERT_INFO     AcpiRsConvertI2cSerialBus[17] =
337{
338    {ACPI_RSC_INITGET,  ACPI_RESOURCE_TYPE_SERIAL_BUS,
339                        ACPI_RS_SIZE (ACPI_RESOURCE_I2C_SERIALBUS),
340                        ACPI_RSC_TABLE_SIZE (AcpiRsConvertI2cSerialBus)},
341
342    {ACPI_RSC_INITSET,  ACPI_RESOURCE_NAME_SERIAL_BUS,
343                        sizeof (AML_RESOURCE_I2C_SERIALBUS),
344                        0},
345
346    {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.CommonSerialBus.RevisionId),
347                        AML_OFFSET (CommonSerialBus.RevisionId),
348                        1},
349
350    {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.CommonSerialBus.Type),
351                        AML_OFFSET (CommonSerialBus.Type),
352                        1},
353
354    {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.CommonSerialBus.SlaveMode),
355                        AML_OFFSET (CommonSerialBus.Flags),
356                        0},
357
358    {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.CommonSerialBus.ProducerConsumer),
359                        AML_OFFSET (CommonSerialBus.Flags),
360                        1},
361
362    {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.CommonSerialBus.ConnectionSharing),
363                        AML_OFFSET (CommonSerialBus.Flags),
364                        2},
365
366    {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.CommonSerialBus.TypeRevisionId),
367                        AML_OFFSET (CommonSerialBus.TypeRevisionId),
368                        1},
369
370    {ACPI_RSC_MOVE16,   ACPI_RS_OFFSET (Data.CommonSerialBus.TypeDataLength),
371                        AML_OFFSET (CommonSerialBus.TypeDataLength),
372                        1},
373
374    /* Vendor data */
375
376    {ACPI_RSC_COUNT_SERIAL_VEN, ACPI_RS_OFFSET (Data.CommonSerialBus.VendorLength),
377                        AML_OFFSET (CommonSerialBus.TypeDataLength),
378                        AML_RESOURCE_I2C_MIN_DATA_LEN},
379
380    {ACPI_RSC_MOVE_SERIAL_VEN,  ACPI_RS_OFFSET (Data.CommonSerialBus.VendorData),
381                        0,
382                        sizeof (AML_RESOURCE_I2C_SERIALBUS)},
383
384    /* Resource Source */
385
386    {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.CommonSerialBus.ResourceSource.Index),
387                        AML_OFFSET (CommonSerialBus.ResSourceIndex),
388                        1},
389
390    {ACPI_RSC_COUNT_SERIAL_RES, ACPI_RS_OFFSET (Data.CommonSerialBus.ResourceSource.StringLength),
391                        AML_OFFSET (CommonSerialBus.TypeDataLength),
392                        sizeof (AML_RESOURCE_COMMON_SERIALBUS)},
393
394    {ACPI_RSC_MOVE_SERIAL_RES,  ACPI_RS_OFFSET (Data.CommonSerialBus.ResourceSource.StringPtr),
395                        AML_OFFSET (CommonSerialBus.TypeDataLength),
396                        sizeof (AML_RESOURCE_COMMON_SERIALBUS)},
397
398    /* I2C bus type specific */
399
400    {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.I2cSerialBus.AccessMode),
401                        AML_OFFSET (I2cSerialBus.TypeSpecificFlags),
402                        0},
403
404    {ACPI_RSC_MOVE32,   ACPI_RS_OFFSET (Data.I2cSerialBus.ConnectionSpeed),
405                        AML_OFFSET (I2cSerialBus.ConnectionSpeed),
406                        1},
407
408    {ACPI_RSC_MOVE16,   ACPI_RS_OFFSET (Data.I2cSerialBus.SlaveAddress),
409                        AML_OFFSET (I2cSerialBus.SlaveAddress),
410                        1},
411};
412
413
414/*******************************************************************************
415 *
416 * AcpiRsConvertSpiSerialBus
417 *
418 ******************************************************************************/
419
420ACPI_RSCONVERT_INFO     AcpiRsConvertSpiSerialBus[21] =
421{
422    {ACPI_RSC_INITGET,  ACPI_RESOURCE_TYPE_SERIAL_BUS,
423                        ACPI_RS_SIZE (ACPI_RESOURCE_SPI_SERIALBUS),
424                        ACPI_RSC_TABLE_SIZE (AcpiRsConvertSpiSerialBus)},
425
426    {ACPI_RSC_INITSET,  ACPI_RESOURCE_NAME_SERIAL_BUS,
427                        sizeof (AML_RESOURCE_SPI_SERIALBUS),
428                        0},
429
430    {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.CommonSerialBus.RevisionId),
431                        AML_OFFSET (CommonSerialBus.RevisionId),
432                        1},
433
434    {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.CommonSerialBus.Type),
435                        AML_OFFSET (CommonSerialBus.Type),
436                        1},
437
438    {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.CommonSerialBus.SlaveMode),
439                        AML_OFFSET (CommonSerialBus.Flags),
440                        0},
441
442    {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.CommonSerialBus.ProducerConsumer),
443                        AML_OFFSET (CommonSerialBus.Flags),
444                        1},
445
446    {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.CommonSerialBus.ConnectionSharing),
447                        AML_OFFSET (CommonSerialBus.Flags),
448                        2},
449
450    {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.CommonSerialBus.TypeRevisionId),
451                        AML_OFFSET (CommonSerialBus.TypeRevisionId),
452                        1},
453
454    {ACPI_RSC_MOVE16,   ACPI_RS_OFFSET (Data.CommonSerialBus.TypeDataLength),
455                        AML_OFFSET (CommonSerialBus.TypeDataLength),
456                        1},
457
458    /* Vendor data */
459
460    {ACPI_RSC_COUNT_SERIAL_VEN, ACPI_RS_OFFSET (Data.CommonSerialBus.VendorLength),
461                        AML_OFFSET (CommonSerialBus.TypeDataLength),
462                        AML_RESOURCE_SPI_MIN_DATA_LEN},
463
464    {ACPI_RSC_MOVE_SERIAL_VEN,  ACPI_RS_OFFSET (Data.CommonSerialBus.VendorData),
465                        0,
466                        sizeof (AML_RESOURCE_SPI_SERIALBUS)},
467
468    /* Resource Source */
469
470    {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.CommonSerialBus.ResourceSource.Index),
471                        AML_OFFSET (CommonSerialBus.ResSourceIndex),
472                        1},
473
474    {ACPI_RSC_COUNT_SERIAL_RES, ACPI_RS_OFFSET (Data.CommonSerialBus.ResourceSource.StringLength),
475                        AML_OFFSET (CommonSerialBus.TypeDataLength),
476                        sizeof (AML_RESOURCE_COMMON_SERIALBUS)},
477
478    {ACPI_RSC_MOVE_SERIAL_RES,  ACPI_RS_OFFSET (Data.CommonSerialBus.ResourceSource.StringPtr),
479                        AML_OFFSET (CommonSerialBus.TypeDataLength),
480                        sizeof (AML_RESOURCE_COMMON_SERIALBUS)},
481
482    /* Spi bus type specific  */
483
484    {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.SpiSerialBus.WireMode),
485                        AML_OFFSET (SpiSerialBus.TypeSpecificFlags),
486                        0},
487
488    {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.SpiSerialBus.DevicePolarity),
489                        AML_OFFSET (SpiSerialBus.TypeSpecificFlags),
490                        1},
491
492    {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.SpiSerialBus.DataBitLength),
493                        AML_OFFSET (SpiSerialBus.DataBitLength),
494                        1},
495
496    {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.SpiSerialBus.ClockPhase),
497                        AML_OFFSET (SpiSerialBus.ClockPhase),
498                        1},
499
500    {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.SpiSerialBus.ClockPolarity),
501                        AML_OFFSET (SpiSerialBus.ClockPolarity),
502                        1},
503
504    {ACPI_RSC_MOVE16,   ACPI_RS_OFFSET (Data.SpiSerialBus.DeviceSelection),
505                        AML_OFFSET (SpiSerialBus.DeviceSelection),
506                        1},
507
508    {ACPI_RSC_MOVE32,   ACPI_RS_OFFSET (Data.SpiSerialBus.ConnectionSpeed),
509                        AML_OFFSET (SpiSerialBus.ConnectionSpeed),
510                        1},
511};
512
513
514/*******************************************************************************
515 *
516 * AcpiRsConvertUartSerialBus
517 *
518 ******************************************************************************/
519
520ACPI_RSCONVERT_INFO     AcpiRsConvertUartSerialBus[23] =
521{
522    {ACPI_RSC_INITGET,  ACPI_RESOURCE_TYPE_SERIAL_BUS,
523                        ACPI_RS_SIZE (ACPI_RESOURCE_UART_SERIALBUS),
524                        ACPI_RSC_TABLE_SIZE (AcpiRsConvertUartSerialBus)},
525
526    {ACPI_RSC_INITSET,  ACPI_RESOURCE_NAME_SERIAL_BUS,
527                        sizeof (AML_RESOURCE_UART_SERIALBUS),
528                        0},
529
530    {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.CommonSerialBus.RevisionId),
531                        AML_OFFSET (CommonSerialBus.RevisionId),
532                        1},
533
534    {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.CommonSerialBus.Type),
535                        AML_OFFSET (CommonSerialBus.Type),
536                        1},
537
538    {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.CommonSerialBus.SlaveMode),
539                        AML_OFFSET (CommonSerialBus.Flags),
540                        0},
541
542    {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.CommonSerialBus.ProducerConsumer),
543                        AML_OFFSET (CommonSerialBus.Flags),
544                        1},
545
546    {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.CommonSerialBus.ConnectionSharing),
547                        AML_OFFSET (CommonSerialBus.Flags),
548                        2},
549
550    {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.CommonSerialBus.TypeRevisionId),
551                        AML_OFFSET (CommonSerialBus.TypeRevisionId),
552                        1},
553
554    {ACPI_RSC_MOVE16,   ACPI_RS_OFFSET (Data.CommonSerialBus.TypeDataLength),
555                        AML_OFFSET (CommonSerialBus.TypeDataLength),
556                        1},
557
558    /* Vendor data */
559
560    {ACPI_RSC_COUNT_SERIAL_VEN, ACPI_RS_OFFSET (Data.CommonSerialBus.VendorLength),
561                        AML_OFFSET (CommonSerialBus.TypeDataLength),
562                        AML_RESOURCE_UART_MIN_DATA_LEN},
563
564    {ACPI_RSC_MOVE_SERIAL_VEN,  ACPI_RS_OFFSET (Data.CommonSerialBus.VendorData),
565                        0,
566                        sizeof (AML_RESOURCE_UART_SERIALBUS)},
567
568    /* Resource Source */
569
570    {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.CommonSerialBus.ResourceSource.Index),
571                        AML_OFFSET (CommonSerialBus.ResSourceIndex),
572                        1},
573
574    {ACPI_RSC_COUNT_SERIAL_RES, ACPI_RS_OFFSET (Data.CommonSerialBus.ResourceSource.StringLength),
575                        AML_OFFSET (CommonSerialBus.TypeDataLength),
576                        sizeof (AML_RESOURCE_COMMON_SERIALBUS)},
577
578    {ACPI_RSC_MOVE_SERIAL_RES,  ACPI_RS_OFFSET (Data.CommonSerialBus.ResourceSource.StringPtr),
579                        AML_OFFSET (CommonSerialBus.TypeDataLength),
580                        sizeof (AML_RESOURCE_COMMON_SERIALBUS)},
581
582    /* Uart bus type specific  */
583
584    {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.UartSerialBus.FlowControl),
585                        AML_OFFSET (UartSerialBus.TypeSpecificFlags),
586                        0},
587
588    {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.UartSerialBus.StopBits),
589                        AML_OFFSET (UartSerialBus.TypeSpecificFlags),
590                        2},
591
592    {ACPI_RSC_3BITFLAG, ACPI_RS_OFFSET (Data.UartSerialBus.DataBits),
593                        AML_OFFSET (UartSerialBus.TypeSpecificFlags),
594                        4},
595
596    {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.UartSerialBus.Endian),
597                        AML_OFFSET (UartSerialBus.TypeSpecificFlags),
598                        7},
599
600    {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.UartSerialBus.Parity),
601                        AML_OFFSET (UartSerialBus.Parity),
602                        1},
603
604    {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.UartSerialBus.LinesEnabled),
605                        AML_OFFSET (UartSerialBus.LinesEnabled),
606                        1},
607
608    {ACPI_RSC_MOVE16,   ACPI_RS_OFFSET (Data.UartSerialBus.RxFifoSize),
609                        AML_OFFSET (UartSerialBus.RxFifoSize),
610                        1},
611
612    {ACPI_RSC_MOVE16,   ACPI_RS_OFFSET (Data.UartSerialBus.TxFifoSize),
613                        AML_OFFSET (UartSerialBus.TxFifoSize),
614                        1},
615
616    {ACPI_RSC_MOVE32,   ACPI_RS_OFFSET (Data.UartSerialBus.DefaultBaudRate),
617                        AML_OFFSET (UartSerialBus.DefaultBaudRate),
618                        1},
619};
620
621
622/*******************************************************************************
623 *
624 * AcpiRsConvertPinConfig
625 *
626 ******************************************************************************/
627
628ACPI_RSCONVERT_INFO     AcpiRsConvertPinConfig[14] =
629{
630    {ACPI_RSC_INITGET,  ACPI_RESOURCE_TYPE_PIN_CONFIG,
631                        ACPI_RS_SIZE (ACPI_RESOURCE_PIN_CONFIG),
632                        ACPI_RSC_TABLE_SIZE (AcpiRsConvertPinConfig)},
633
634    {ACPI_RSC_INITSET,  ACPI_RESOURCE_NAME_PIN_CONFIG,
635                        sizeof (AML_RESOURCE_PIN_CONFIG),
636                        0},
637
638    {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.PinConfig.RevisionId),
639                        AML_OFFSET (PinConfig.RevisionId),
640                        1},
641
642    {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.PinConfig.Sharable),
643                        AML_OFFSET (PinConfig.Flags),
644                        0},
645
646    {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.PinConfig.ProducerConsumer),
647                        AML_OFFSET (PinConfig.Flags),
648                        1},
649
650    {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.PinConfig.PinConfigType),
651                        AML_OFFSET (PinConfig.PinConfigType),
652                        1},
653
654    {ACPI_RSC_MOVE32,   ACPI_RS_OFFSET (Data.PinConfig.PinConfigValue),
655                        AML_OFFSET (PinConfig.PinConfigValue),
656                        1},
657
658    /* Pin Table */
659
660    /*
661     * It is OK to use GPIO operations here because none of them refer GPIO
662     * structures directly but instead use offsets given here.
663     */
664
665    {ACPI_RSC_COUNT_GPIO_PIN, ACPI_RS_OFFSET (Data.PinConfig.PinTableLength),
666                        AML_OFFSET (PinConfig.PinTableOffset),
667                        AML_OFFSET (PinConfig.ResSourceOffset)},
668
669    {ACPI_RSC_MOVE_GPIO_PIN, ACPI_RS_OFFSET (Data.PinConfig.PinTable),
670                        AML_OFFSET (PinConfig.PinTableOffset),
671                        0},
672
673    /* Resource Source */
674
675    {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.PinConfig.ResourceSource.Index),
676                        AML_OFFSET (PinConfig.ResSourceIndex),
677                        1},
678
679    {ACPI_RSC_COUNT_GPIO_RES,  ACPI_RS_OFFSET (Data.PinConfig.ResourceSource.StringLength),
680                        AML_OFFSET (PinConfig.ResSourceOffset),
681                        AML_OFFSET (PinConfig.VendorOffset)},
682
683    {ACPI_RSC_MOVE_GPIO_RES,   ACPI_RS_OFFSET (Data.PinConfig.ResourceSource.StringPtr),
684                        AML_OFFSET (PinConfig.ResSourceOffset),
685                        0},
686
687    /* Vendor Data */
688
689    {ACPI_RSC_COUNT_GPIO_VEN,   ACPI_RS_OFFSET (Data.PinConfig.VendorLength),
690                        AML_OFFSET (PinConfig.VendorLength),
691                        1},
692
693    {ACPI_RSC_MOVE_GPIO_RES,   ACPI_RS_OFFSET (Data.PinConfig.VendorData),
694                        AML_OFFSET (PinConfig.VendorOffset),
695                        0},
696};
697
698/*******************************************************************************
699 *
700 * AcpiRsConvertPinGroup
701 *
702 ******************************************************************************/
703
704ACPI_RSCONVERT_INFO     AcpiRsConvertPinGroup[10] =
705{
706    {ACPI_RSC_INITGET,  ACPI_RESOURCE_TYPE_PIN_GROUP,
707                        ACPI_RS_SIZE (ACPI_RESOURCE_PIN_GROUP),
708                        ACPI_RSC_TABLE_SIZE (AcpiRsConvertPinGroup)},
709
710    {ACPI_RSC_INITSET,  ACPI_RESOURCE_NAME_PIN_GROUP,
711                        sizeof (AML_RESOURCE_PIN_GROUP),
712                        0},
713
714    {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.PinGroup.RevisionId),
715                        AML_OFFSET (PinGroup.RevisionId),
716                        1},
717
718    {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.PinGroup.ProducerConsumer),
719                        AML_OFFSET (PinGroup.Flags),
720                        0},
721
722    /* Pin Table */
723
724    /*
725     * It is OK to use GPIO operations here because none of them refer GPIO
726     * structures directly but instead use offsets given here.
727     */
728
729    {ACPI_RSC_COUNT_GPIO_PIN, ACPI_RS_OFFSET (Data.PinGroup.PinTableLength),
730                        AML_OFFSET (PinGroup.PinTableOffset),
731                        AML_OFFSET (PinGroup.LabelOffset)},
732
733    {ACPI_RSC_MOVE_GPIO_PIN, ACPI_RS_OFFSET (Data.PinGroup.PinTable),
734                        AML_OFFSET (PinGroup.PinTableOffset),
735                        0},
736
737    /* Resource Label */
738
739    {ACPI_RSC_COUNT_GPIO_RES, ACPI_RS_OFFSET (Data.PinGroup.ResourceLabel.StringLength),
740                        AML_OFFSET (PinGroup.LabelOffset),
741                        AML_OFFSET (PinGroup.VendorOffset)},
742
743    {ACPI_RSC_MOVE_GPIO_RES, ACPI_RS_OFFSET (Data.PinGroup.ResourceLabel.StringPtr),
744                        AML_OFFSET (PinGroup.LabelOffset),
745                        0},
746
747    /* Vendor Data */
748
749    {ACPI_RSC_COUNT_GPIO_VEN,   ACPI_RS_OFFSET (Data.PinGroup.VendorLength),
750                        AML_OFFSET (PinGroup.VendorLength),
751                        1},
752
753    {ACPI_RSC_MOVE_GPIO_RES,   ACPI_RS_OFFSET (Data.PinGroup.VendorData),
754                        AML_OFFSET (PinGroup.VendorOffset),
755                        0},
756};
757
758/*******************************************************************************
759 *
760 * AcpiRsConvertPinGroupFunction
761 *
762 ******************************************************************************/
763
764ACPI_RSCONVERT_INFO     AcpiRsConvertPinGroupFunction[13] =
765{
766    {ACPI_RSC_INITGET,  ACPI_RESOURCE_TYPE_PIN_GROUP_FUNCTION,
767                        ACPI_RS_SIZE (ACPI_RESOURCE_PIN_GROUP_FUNCTION),
768                        ACPI_RSC_TABLE_SIZE (AcpiRsConvertPinGroupFunction)},
769
770    {ACPI_RSC_INITSET,  ACPI_RESOURCE_NAME_PIN_GROUP_FUNCTION,
771                        sizeof (AML_RESOURCE_PIN_GROUP_FUNCTION),
772                        0},
773
774    {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.PinGroupFunction.RevisionId),
775                        AML_OFFSET (PinGroupFunction.RevisionId),
776                        1},
777
778    {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.PinGroupFunction.Sharable),
779                        AML_OFFSET (PinGroupFunction.Flags),
780                        0},
781
782    {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.PinGroupFunction.ProducerConsumer),
783                        AML_OFFSET (PinGroupFunction.Flags),
784                        1},
785
786    {ACPI_RSC_MOVE16,   ACPI_RS_OFFSET (Data.PinGroupFunction.FunctionNumber),
787                        AML_OFFSET (PinGroupFunction.FunctionNumber),
788                        1},
789
790    /* Resource Source */
791
792    {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.PinGroupFunction.ResourceSource.Index),
793                        AML_OFFSET (PinGroupFunction.ResSourceIndex),
794                        1},
795
796    {ACPI_RSC_COUNT_GPIO_RES,  ACPI_RS_OFFSET (Data.PinGroupFunction.ResourceSource.StringLength),
797                        AML_OFFSET (PinGroupFunction.ResSourceOffset),
798                        AML_OFFSET (PinGroupFunction.ResSourceLabelOffset)},
799
800    {ACPI_RSC_MOVE_GPIO_RES,   ACPI_RS_OFFSET (Data.PinGroupFunction.ResourceSource.StringPtr),
801                        AML_OFFSET (PinGroupFunction.ResSourceOffset),
802                        0},
803
804    /* Resource Source Label */
805
806    {ACPI_RSC_COUNT_GPIO_RES,  ACPI_RS_OFFSET (Data.PinGroupFunction.ResourceSourceLabel.StringLength),
807                        AML_OFFSET (PinGroupFunction.ResSourceLabelOffset),
808                        AML_OFFSET (PinGroupFunction.VendorOffset)},
809
810    {ACPI_RSC_MOVE_GPIO_RES,   ACPI_RS_OFFSET (Data.PinGroupFunction.ResourceSourceLabel.StringPtr),
811                        AML_OFFSET (PinGroupFunction.ResSourceLabelOffset),
812                        0},
813
814    /* Vendor Data */
815
816    {ACPI_RSC_COUNT_GPIO_VEN,   ACPI_RS_OFFSET (Data.PinGroupFunction.VendorLength),
817                        AML_OFFSET (PinGroupFunction.VendorLength),
818                        1},
819
820    {ACPI_RSC_MOVE_GPIO_RES,   ACPI_RS_OFFSET (Data.PinGroupFunction.VendorData),
821                        AML_OFFSET (PinGroupFunction.VendorOffset),
822                        0},
823};
824
825/*******************************************************************************
826 *
827 * AcpiRsConvertPinGroupConfig
828 *
829 ******************************************************************************/
830
831ACPI_RSCONVERT_INFO     AcpiRsConvertPinGroupConfig[14] =
832{
833    {ACPI_RSC_INITGET,  ACPI_RESOURCE_TYPE_PIN_GROUP_CONFIG,
834                        ACPI_RS_SIZE (ACPI_RESOURCE_PIN_GROUP_CONFIG),
835                        ACPI_RSC_TABLE_SIZE (AcpiRsConvertPinGroupConfig)},
836
837    {ACPI_RSC_INITSET,  ACPI_RESOURCE_NAME_PIN_GROUP_CONFIG,
838                        sizeof (AML_RESOURCE_PIN_GROUP_CONFIG),
839                        0},
840
841    {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.PinGroupConfig.RevisionId),
842                        AML_OFFSET (PinGroupConfig.RevisionId),
843                        1},
844
845    {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.PinGroupConfig.Sharable),
846                        AML_OFFSET (PinGroupConfig.Flags),
847                        0},
848
849    {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.PinGroupConfig.ProducerConsumer),
850                        AML_OFFSET (PinGroupConfig.Flags),
851                        1},
852
853    {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.PinGroupConfig.PinConfigType),
854                        AML_OFFSET (PinGroupConfig.PinConfigType),
855                        1},
856
857    {ACPI_RSC_MOVE32,   ACPI_RS_OFFSET (Data.PinGroupConfig.PinConfigValue),
858                        AML_OFFSET (PinGroupConfig.PinConfigValue),
859                        1},
860
861    /* Resource Source */
862
863    {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.PinGroupConfig.ResourceSource.Index),
864                        AML_OFFSET (PinGroupConfig.ResSourceIndex),
865                        1},
866
867    {ACPI_RSC_COUNT_GPIO_RES,  ACPI_RS_OFFSET (Data.PinGroupConfig.ResourceSource.StringLength),
868                        AML_OFFSET (PinGroupConfig.ResSourceOffset),
869                        AML_OFFSET (PinGroupConfig.ResSourceLabelOffset)},
870
871    {ACPI_RSC_MOVE_GPIO_RES,   ACPI_RS_OFFSET (Data.PinGroupConfig.ResourceSource.StringPtr),
872                        AML_OFFSET (PinGroupConfig.ResSourceOffset),
873                        0},
874
875    /* Resource Source Label */
876
877    {ACPI_RSC_COUNT_GPIO_RES,  ACPI_RS_OFFSET (Data.PinGroupConfig.ResourceSourceLabel.StringLength),
878                        AML_OFFSET (PinGroupConfig.ResSourceLabelOffset),
879                        AML_OFFSET (PinGroupConfig.VendorOffset)},
880
881    {ACPI_RSC_MOVE_GPIO_RES,   ACPI_RS_OFFSET (Data.PinGroupConfig.ResourceSourceLabel.StringPtr),
882                        AML_OFFSET (PinGroupConfig.ResSourceLabelOffset),
883                        0},
884
885    /* Vendor Data */
886
887    {ACPI_RSC_COUNT_GPIO_VEN,   ACPI_RS_OFFSET (Data.PinGroupConfig.VendorLength),
888                        AML_OFFSET (PinGroupConfig.VendorLength),
889                        1},
890
891    {ACPI_RSC_MOVE_GPIO_RES,   ACPI_RS_OFFSET (Data.PinGroupConfig.VendorData),
892                        AML_OFFSET (PinGroupConfig.VendorOffset),
893                        0},
894};
895