xref: /titanic_52/usr/src/uts/intel/io/acpica/resources/rsserial.c (revision 385cc6b4ad1792caef3f84eb61eed3f27085801f)
1 /*******************************************************************************
2  *
3  * Module Name: rsserial - GPIO/SerialBus resource descriptors
4  *
5  ******************************************************************************/
6 
7 /*
8  * Copyright (C) 2000 - 2016, 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.Sharable),
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  *
152  * AcpiRsConvertI2cSerialBus
153  *
154  ******************************************************************************/
155 
156 ACPI_RSCONVERT_INFO     AcpiRsConvertI2cSerialBus[17] =
157 {
158     {ACPI_RSC_INITGET,  ACPI_RESOURCE_TYPE_SERIAL_BUS,
159                         ACPI_RS_SIZE (ACPI_RESOURCE_I2C_SERIALBUS),
160                         ACPI_RSC_TABLE_SIZE (AcpiRsConvertI2cSerialBus)},
161 
162     {ACPI_RSC_INITSET,  ACPI_RESOURCE_NAME_SERIAL_BUS,
163                         sizeof (AML_RESOURCE_I2C_SERIALBUS),
164                         0},
165 
166     {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.CommonSerialBus.RevisionId),
167                         AML_OFFSET (CommonSerialBus.RevisionId),
168                         1},
169 
170     {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.CommonSerialBus.Type),
171                         AML_OFFSET (CommonSerialBus.Type),
172                         1},
173 
174     {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.CommonSerialBus.SlaveMode),
175                         AML_OFFSET (CommonSerialBus.Flags),
176                         0},
177 
178     {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.CommonSerialBus.ProducerConsumer),
179                         AML_OFFSET (CommonSerialBus.Flags),
180                         1},
181 
182     {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.CommonSerialBus.ConnectionSharing),
183                         AML_OFFSET (CommonSerialBus.Flags),
184                         2},
185 
186     {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.CommonSerialBus.TypeRevisionId),
187                         AML_OFFSET (CommonSerialBus.TypeRevisionId),
188                         1},
189 
190     {ACPI_RSC_MOVE16,   ACPI_RS_OFFSET (Data.CommonSerialBus.TypeDataLength),
191                         AML_OFFSET (CommonSerialBus.TypeDataLength),
192                         1},
193 
194     /* Vendor data */
195 
196     {ACPI_RSC_COUNT_SERIAL_VEN, ACPI_RS_OFFSET (Data.CommonSerialBus.VendorLength),
197                         AML_OFFSET (CommonSerialBus.TypeDataLength),
198                         AML_RESOURCE_I2C_MIN_DATA_LEN},
199 
200     {ACPI_RSC_MOVE_SERIAL_VEN,  ACPI_RS_OFFSET (Data.CommonSerialBus.VendorData),
201                         0,
202                         sizeof (AML_RESOURCE_I2C_SERIALBUS)},
203 
204     /* Resource Source */
205 
206     {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.CommonSerialBus.ResourceSource.Index),
207                         AML_OFFSET (CommonSerialBus.ResSourceIndex),
208                         1},
209 
210     {ACPI_RSC_COUNT_SERIAL_RES, ACPI_RS_OFFSET (Data.CommonSerialBus.ResourceSource.StringLength),
211                         AML_OFFSET (CommonSerialBus.TypeDataLength),
212                         sizeof (AML_RESOURCE_COMMON_SERIALBUS)},
213 
214     {ACPI_RSC_MOVE_SERIAL_RES,  ACPI_RS_OFFSET (Data.CommonSerialBus.ResourceSource.StringPtr),
215                         AML_OFFSET (CommonSerialBus.TypeDataLength),
216                         sizeof (AML_RESOURCE_COMMON_SERIALBUS)},
217 
218     /* I2C bus type specific */
219 
220     {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.I2cSerialBus.AccessMode),
221                         AML_OFFSET (I2cSerialBus.TypeSpecificFlags),
222                         0},
223 
224     {ACPI_RSC_MOVE32,   ACPI_RS_OFFSET (Data.I2cSerialBus.ConnectionSpeed),
225                         AML_OFFSET (I2cSerialBus.ConnectionSpeed),
226                         1},
227 
228     {ACPI_RSC_MOVE16,   ACPI_RS_OFFSET (Data.I2cSerialBus.SlaveAddress),
229                         AML_OFFSET (I2cSerialBus.SlaveAddress),
230                         1},
231 };
232 
233 
234 /*******************************************************************************
235  *
236  * AcpiRsConvertSpiSerialBus
237  *
238  ******************************************************************************/
239 
240 ACPI_RSCONVERT_INFO     AcpiRsConvertSpiSerialBus[21] =
241 {
242     {ACPI_RSC_INITGET,  ACPI_RESOURCE_TYPE_SERIAL_BUS,
243                         ACPI_RS_SIZE (ACPI_RESOURCE_SPI_SERIALBUS),
244                         ACPI_RSC_TABLE_SIZE (AcpiRsConvertSpiSerialBus)},
245 
246     {ACPI_RSC_INITSET,  ACPI_RESOURCE_NAME_SERIAL_BUS,
247                         sizeof (AML_RESOURCE_SPI_SERIALBUS),
248                         0},
249 
250     {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.CommonSerialBus.RevisionId),
251                         AML_OFFSET (CommonSerialBus.RevisionId),
252                         1},
253 
254     {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.CommonSerialBus.Type),
255                         AML_OFFSET (CommonSerialBus.Type),
256                         1},
257 
258     {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.CommonSerialBus.SlaveMode),
259                         AML_OFFSET (CommonSerialBus.Flags),
260                         0},
261 
262     {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.CommonSerialBus.ProducerConsumer),
263                         AML_OFFSET (CommonSerialBus.Flags),
264                         1},
265 
266     {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.CommonSerialBus.ConnectionSharing),
267                         AML_OFFSET (CommonSerialBus.Flags),
268                         2},
269 
270     {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.CommonSerialBus.TypeRevisionId),
271                         AML_OFFSET (CommonSerialBus.TypeRevisionId),
272                         1},
273 
274     {ACPI_RSC_MOVE16,   ACPI_RS_OFFSET (Data.CommonSerialBus.TypeDataLength),
275                         AML_OFFSET (CommonSerialBus.TypeDataLength),
276                         1},
277 
278     /* Vendor data */
279 
280     {ACPI_RSC_COUNT_SERIAL_VEN, ACPI_RS_OFFSET (Data.CommonSerialBus.VendorLength),
281                         AML_OFFSET (CommonSerialBus.TypeDataLength),
282                         AML_RESOURCE_SPI_MIN_DATA_LEN},
283 
284     {ACPI_RSC_MOVE_SERIAL_VEN,  ACPI_RS_OFFSET (Data.CommonSerialBus.VendorData),
285                         0,
286                         sizeof (AML_RESOURCE_SPI_SERIALBUS)},
287 
288     /* Resource Source */
289 
290     {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.CommonSerialBus.ResourceSource.Index),
291                         AML_OFFSET (CommonSerialBus.ResSourceIndex),
292                         1},
293 
294     {ACPI_RSC_COUNT_SERIAL_RES, ACPI_RS_OFFSET (Data.CommonSerialBus.ResourceSource.StringLength),
295                         AML_OFFSET (CommonSerialBus.TypeDataLength),
296                         sizeof (AML_RESOURCE_COMMON_SERIALBUS)},
297 
298     {ACPI_RSC_MOVE_SERIAL_RES,  ACPI_RS_OFFSET (Data.CommonSerialBus.ResourceSource.StringPtr),
299                         AML_OFFSET (CommonSerialBus.TypeDataLength),
300                         sizeof (AML_RESOURCE_COMMON_SERIALBUS)},
301 
302     /* Spi bus type specific  */
303 
304     {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.SpiSerialBus.WireMode),
305                         AML_OFFSET (SpiSerialBus.TypeSpecificFlags),
306                         0},
307 
308     {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.SpiSerialBus.DevicePolarity),
309                         AML_OFFSET (SpiSerialBus.TypeSpecificFlags),
310                         1},
311 
312     {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.SpiSerialBus.DataBitLength),
313                         AML_OFFSET (SpiSerialBus.DataBitLength),
314                         1},
315 
316     {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.SpiSerialBus.ClockPhase),
317                         AML_OFFSET (SpiSerialBus.ClockPhase),
318                         1},
319 
320     {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.SpiSerialBus.ClockPolarity),
321                         AML_OFFSET (SpiSerialBus.ClockPolarity),
322                         1},
323 
324     {ACPI_RSC_MOVE16,   ACPI_RS_OFFSET (Data.SpiSerialBus.DeviceSelection),
325                         AML_OFFSET (SpiSerialBus.DeviceSelection),
326                         1},
327 
328     {ACPI_RSC_MOVE32,   ACPI_RS_OFFSET (Data.SpiSerialBus.ConnectionSpeed),
329                         AML_OFFSET (SpiSerialBus.ConnectionSpeed),
330                         1},
331 };
332 
333 
334 /*******************************************************************************
335  *
336  * AcpiRsConvertUartSerialBus
337  *
338  ******************************************************************************/
339 
340 ACPI_RSCONVERT_INFO     AcpiRsConvertUartSerialBus[23] =
341 {
342     {ACPI_RSC_INITGET,  ACPI_RESOURCE_TYPE_SERIAL_BUS,
343                         ACPI_RS_SIZE (ACPI_RESOURCE_UART_SERIALBUS),
344                         ACPI_RSC_TABLE_SIZE (AcpiRsConvertUartSerialBus)},
345 
346     {ACPI_RSC_INITSET,  ACPI_RESOURCE_NAME_SERIAL_BUS,
347                         sizeof (AML_RESOURCE_UART_SERIALBUS),
348                         0},
349 
350     {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.CommonSerialBus.RevisionId),
351                         AML_OFFSET (CommonSerialBus.RevisionId),
352                         1},
353 
354     {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.CommonSerialBus.Type),
355                         AML_OFFSET (CommonSerialBus.Type),
356                         1},
357 
358     {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.CommonSerialBus.SlaveMode),
359                         AML_OFFSET (CommonSerialBus.Flags),
360                         0},
361 
362     {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.CommonSerialBus.ProducerConsumer),
363                         AML_OFFSET (CommonSerialBus.Flags),
364                         1},
365 
366     {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.CommonSerialBus.ConnectionSharing),
367                         AML_OFFSET (CommonSerialBus.Flags),
368                         2},
369 
370     {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.CommonSerialBus.TypeRevisionId),
371                         AML_OFFSET (CommonSerialBus.TypeRevisionId),
372                         1},
373 
374     {ACPI_RSC_MOVE16,   ACPI_RS_OFFSET (Data.CommonSerialBus.TypeDataLength),
375                         AML_OFFSET (CommonSerialBus.TypeDataLength),
376                         1},
377 
378     /* Vendor data */
379 
380     {ACPI_RSC_COUNT_SERIAL_VEN, ACPI_RS_OFFSET (Data.CommonSerialBus.VendorLength),
381                         AML_OFFSET (CommonSerialBus.TypeDataLength),
382                         AML_RESOURCE_UART_MIN_DATA_LEN},
383 
384     {ACPI_RSC_MOVE_SERIAL_VEN,  ACPI_RS_OFFSET (Data.CommonSerialBus.VendorData),
385                         0,
386                         sizeof (AML_RESOURCE_UART_SERIALBUS)},
387 
388     /* Resource Source */
389 
390     {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.CommonSerialBus.ResourceSource.Index),
391                         AML_OFFSET (CommonSerialBus.ResSourceIndex),
392                         1},
393 
394     {ACPI_RSC_COUNT_SERIAL_RES, ACPI_RS_OFFSET (Data.CommonSerialBus.ResourceSource.StringLength),
395                         AML_OFFSET (CommonSerialBus.TypeDataLength),
396                         sizeof (AML_RESOURCE_COMMON_SERIALBUS)},
397 
398     {ACPI_RSC_MOVE_SERIAL_RES,  ACPI_RS_OFFSET (Data.CommonSerialBus.ResourceSource.StringPtr),
399                         AML_OFFSET (CommonSerialBus.TypeDataLength),
400                         sizeof (AML_RESOURCE_COMMON_SERIALBUS)},
401 
402     /* Uart bus type specific  */
403 
404     {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.UartSerialBus.FlowControl),
405                         AML_OFFSET (UartSerialBus.TypeSpecificFlags),
406                         0},
407 
408     {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.UartSerialBus.StopBits),
409                         AML_OFFSET (UartSerialBus.TypeSpecificFlags),
410                         2},
411 
412     {ACPI_RSC_3BITFLAG, ACPI_RS_OFFSET (Data.UartSerialBus.DataBits),
413                         AML_OFFSET (UartSerialBus.TypeSpecificFlags),
414                         4},
415 
416     {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.UartSerialBus.Endian),
417                         AML_OFFSET (UartSerialBus.TypeSpecificFlags),
418                         7},
419 
420     {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.UartSerialBus.Parity),
421                         AML_OFFSET (UartSerialBus.Parity),
422                         1},
423 
424     {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.UartSerialBus.LinesEnabled),
425                         AML_OFFSET (UartSerialBus.LinesEnabled),
426                         1},
427 
428     {ACPI_RSC_MOVE16,   ACPI_RS_OFFSET (Data.UartSerialBus.RxFifoSize),
429                         AML_OFFSET (UartSerialBus.RxFifoSize),
430                         1},
431 
432     {ACPI_RSC_MOVE16,   ACPI_RS_OFFSET (Data.UartSerialBus.TxFifoSize),
433                         AML_OFFSET (UartSerialBus.TxFifoSize),
434                         1},
435 
436     {ACPI_RSC_MOVE32,   ACPI_RS_OFFSET (Data.UartSerialBus.DefaultBaudRate),
437                         AML_OFFSET (UartSerialBus.DefaultBaudRate),
438                         1},
439 };
440