1 /******************************************************************************* 2 * 3 * Module Name: rsserial - GPIO/SerialBus resource descriptors 4 * 5 ******************************************************************************/ 6 7 /* 8 * Copyright (C) 2000 - 2013, 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 #define __RSIRQ_C__ 45 46 #include <contrib/dev/acpica/include/acpi.h> 47 #include <contrib/dev/acpica/include/accommon.h> 48 #include <contrib/dev/acpica/include/acresrc.h> 49 50 #define _COMPONENT ACPI_RESOURCES 51 ACPI_MODULE_NAME ("rsserial") 52 53 54 /******************************************************************************* 55 * 56 * AcpiRsConvertGpio 57 * 58 ******************************************************************************/ 59 60 ACPI_RSCONVERT_INFO AcpiRsConvertGpio[18] = 61 { 62 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_GPIO, 63 ACPI_RS_SIZE (ACPI_RESOURCE_GPIO), 64 ACPI_RSC_TABLE_SIZE (AcpiRsConvertGpio)}, 65 66 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_GPIO, 67 sizeof (AML_RESOURCE_GPIO), 68 0}, 69 70 /* 71 * These fields are contiguous in both the source and destination: 72 * RevisionId 73 * ConnectionType 74 */ 75 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.Gpio.RevisionId), 76 AML_OFFSET (Gpio.RevisionId), 77 2}, 78 79 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Gpio.ProducerConsumer), 80 AML_OFFSET (Gpio.Flags), 81 0}, 82 83 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Gpio.Sharable), 84 AML_OFFSET (Gpio.IntFlags), 85 3}, 86 87 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Gpio.WakeCapable), 88 AML_OFFSET (Gpio.IntFlags), 89 4}, 90 91 {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.Gpio.IoRestriction), 92 AML_OFFSET (Gpio.IntFlags), 93 0}, 94 95 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Gpio.Triggering), 96 AML_OFFSET (Gpio.IntFlags), 97 0}, 98 99 {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.Gpio.Polarity), 100 AML_OFFSET (Gpio.IntFlags), 101 1}, 102 103 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.Gpio.PinConfig), 104 AML_OFFSET (Gpio.PinConfig), 105 1}, 106 107 /* 108 * These fields are contiguous in both the source and destination: 109 * DriveStrength 110 * DebounceTimeout 111 */ 112 {ACPI_RSC_MOVE16, ACPI_RS_OFFSET (Data.Gpio.DriveStrength), 113 AML_OFFSET (Gpio.DriveStrength), 114 2}, 115 116 /* Pin Table */ 117 118 {ACPI_RSC_COUNT_GPIO_PIN, ACPI_RS_OFFSET (Data.Gpio.PinTableLength), 119 AML_OFFSET (Gpio.PinTableOffset), 120 AML_OFFSET (Gpio.ResSourceOffset)}, 121 122 {ACPI_RSC_MOVE_GPIO_PIN, ACPI_RS_OFFSET (Data.Gpio.PinTable), 123 AML_OFFSET (Gpio.PinTableOffset), 124 0}, 125 126 /* Resource Source */ 127 128 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.Gpio.ResourceSource.Index), 129 AML_OFFSET (Gpio.ResSourceIndex), 130 1}, 131 132 {ACPI_RSC_COUNT_GPIO_RES, ACPI_RS_OFFSET (Data.Gpio.ResourceSource.StringLength), 133 AML_OFFSET (Gpio.ResSourceOffset), 134 AML_OFFSET (Gpio.VendorOffset)}, 135 136 {ACPI_RSC_MOVE_GPIO_RES, ACPI_RS_OFFSET (Data.Gpio.ResourceSource.StringPtr), 137 AML_OFFSET (Gpio.ResSourceOffset), 138 0}, 139 140 /* Vendor Data */ 141 142 {ACPI_RSC_COUNT_GPIO_VEN, ACPI_RS_OFFSET (Data.Gpio.VendorLength), 143 AML_OFFSET (Gpio.VendorLength), 144 1}, 145 146 {ACPI_RSC_MOVE_GPIO_RES, ACPI_RS_OFFSET (Data.Gpio.VendorData), 147 AML_OFFSET (Gpio.VendorOffset), 148 0}, 149 }; 150 151 152 /******************************************************************************* 153 * 154 * AcpiRsConvertI2cSerialBus 155 * 156 ******************************************************************************/ 157 158 ACPI_RSCONVERT_INFO AcpiRsConvertI2cSerialBus[16] = 159 { 160 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_SERIAL_BUS, 161 ACPI_RS_SIZE (ACPI_RESOURCE_I2C_SERIALBUS), 162 ACPI_RSC_TABLE_SIZE (AcpiRsConvertI2cSerialBus)}, 163 164 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_SERIAL_BUS, 165 sizeof (AML_RESOURCE_I2C_SERIALBUS), 166 0}, 167 168 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.CommonSerialBus.RevisionId), 169 AML_OFFSET (CommonSerialBus.RevisionId), 170 1}, 171 172 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.CommonSerialBus.Type), 173 AML_OFFSET (CommonSerialBus.Type), 174 1}, 175 176 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.CommonSerialBus.SlaveMode), 177 AML_OFFSET (CommonSerialBus.Flags), 178 0}, 179 180 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.CommonSerialBus.ProducerConsumer), 181 AML_OFFSET (CommonSerialBus.Flags), 182 1}, 183 184 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.CommonSerialBus.TypeRevisionId), 185 AML_OFFSET (CommonSerialBus.TypeRevisionId), 186 1}, 187 188 {ACPI_RSC_MOVE16, ACPI_RS_OFFSET (Data.CommonSerialBus.TypeDataLength), 189 AML_OFFSET (CommonSerialBus.TypeDataLength), 190 1}, 191 192 /* Vendor data */ 193 194 {ACPI_RSC_COUNT_SERIAL_VEN, ACPI_RS_OFFSET (Data.CommonSerialBus.VendorLength), 195 AML_OFFSET (CommonSerialBus.TypeDataLength), 196 AML_RESOURCE_I2C_MIN_DATA_LEN}, 197 198 {ACPI_RSC_MOVE_SERIAL_VEN, ACPI_RS_OFFSET (Data.CommonSerialBus.VendorData), 199 0, 200 sizeof (AML_RESOURCE_I2C_SERIALBUS)}, 201 202 /* Resource Source */ 203 204 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.CommonSerialBus.ResourceSource.Index), 205 AML_OFFSET (CommonSerialBus.ResSourceIndex), 206 1}, 207 208 {ACPI_RSC_COUNT_SERIAL_RES, ACPI_RS_OFFSET (Data.CommonSerialBus.ResourceSource.StringLength), 209 AML_OFFSET (CommonSerialBus.TypeDataLength), 210 sizeof (AML_RESOURCE_COMMON_SERIALBUS)}, 211 212 {ACPI_RSC_MOVE_SERIAL_RES, ACPI_RS_OFFSET (Data.CommonSerialBus.ResourceSource.StringPtr), 213 AML_OFFSET (CommonSerialBus.TypeDataLength), 214 sizeof (AML_RESOURCE_COMMON_SERIALBUS)}, 215 216 /* I2C bus type specific */ 217 218 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.I2cSerialBus.AccessMode), 219 AML_OFFSET (I2cSerialBus.TypeSpecificFlags), 220 0}, 221 222 {ACPI_RSC_MOVE32, ACPI_RS_OFFSET (Data.I2cSerialBus.ConnectionSpeed), 223 AML_OFFSET (I2cSerialBus.ConnectionSpeed), 224 1}, 225 226 {ACPI_RSC_MOVE16, ACPI_RS_OFFSET (Data.I2cSerialBus.SlaveAddress), 227 AML_OFFSET (I2cSerialBus.SlaveAddress), 228 1}, 229 }; 230 231 232 /******************************************************************************* 233 * 234 * AcpiRsConvertSpiSerialBus 235 * 236 ******************************************************************************/ 237 238 ACPI_RSCONVERT_INFO AcpiRsConvertSpiSerialBus[20] = 239 { 240 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_SERIAL_BUS, 241 ACPI_RS_SIZE (ACPI_RESOURCE_SPI_SERIALBUS), 242 ACPI_RSC_TABLE_SIZE (AcpiRsConvertSpiSerialBus)}, 243 244 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_SERIAL_BUS, 245 sizeof (AML_RESOURCE_SPI_SERIALBUS), 246 0}, 247 248 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.CommonSerialBus.RevisionId), 249 AML_OFFSET (CommonSerialBus.RevisionId), 250 1}, 251 252 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.CommonSerialBus.Type), 253 AML_OFFSET (CommonSerialBus.Type), 254 1}, 255 256 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.CommonSerialBus.SlaveMode), 257 AML_OFFSET (CommonSerialBus.Flags), 258 0}, 259 260 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.CommonSerialBus.ProducerConsumer), 261 AML_OFFSET (CommonSerialBus.Flags), 262 1}, 263 264 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.CommonSerialBus.TypeRevisionId), 265 AML_OFFSET (CommonSerialBus.TypeRevisionId), 266 1}, 267 268 {ACPI_RSC_MOVE16, ACPI_RS_OFFSET (Data.CommonSerialBus.TypeDataLength), 269 AML_OFFSET (CommonSerialBus.TypeDataLength), 270 1}, 271 272 /* Vendor data */ 273 274 {ACPI_RSC_COUNT_SERIAL_VEN, ACPI_RS_OFFSET (Data.CommonSerialBus.VendorLength), 275 AML_OFFSET (CommonSerialBus.TypeDataLength), 276 AML_RESOURCE_SPI_MIN_DATA_LEN}, 277 278 {ACPI_RSC_MOVE_SERIAL_VEN, ACPI_RS_OFFSET (Data.CommonSerialBus.VendorData), 279 0, 280 sizeof (AML_RESOURCE_SPI_SERIALBUS)}, 281 282 /* Resource Source */ 283 284 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.CommonSerialBus.ResourceSource.Index), 285 AML_OFFSET (CommonSerialBus.ResSourceIndex), 286 1}, 287 288 {ACPI_RSC_COUNT_SERIAL_RES, ACPI_RS_OFFSET (Data.CommonSerialBus.ResourceSource.StringLength), 289 AML_OFFSET (CommonSerialBus.TypeDataLength), 290 sizeof (AML_RESOURCE_COMMON_SERIALBUS)}, 291 292 {ACPI_RSC_MOVE_SERIAL_RES, ACPI_RS_OFFSET (Data.CommonSerialBus.ResourceSource.StringPtr), 293 AML_OFFSET (CommonSerialBus.TypeDataLength), 294 sizeof (AML_RESOURCE_COMMON_SERIALBUS)}, 295 296 /* Spi bus type specific */ 297 298 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.SpiSerialBus.WireMode), 299 AML_OFFSET (SpiSerialBus.TypeSpecificFlags), 300 0}, 301 302 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.SpiSerialBus.DevicePolarity), 303 AML_OFFSET (SpiSerialBus.TypeSpecificFlags), 304 1}, 305 306 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.SpiSerialBus.DataBitLength), 307 AML_OFFSET (SpiSerialBus.DataBitLength), 308 1}, 309 310 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.SpiSerialBus.ClockPhase), 311 AML_OFFSET (SpiSerialBus.ClockPhase), 312 1}, 313 314 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.SpiSerialBus.ClockPolarity), 315 AML_OFFSET (SpiSerialBus.ClockPolarity), 316 1}, 317 318 {ACPI_RSC_MOVE16, ACPI_RS_OFFSET (Data.SpiSerialBus.DeviceSelection), 319 AML_OFFSET (SpiSerialBus.DeviceSelection), 320 1}, 321 322 {ACPI_RSC_MOVE32, ACPI_RS_OFFSET (Data.SpiSerialBus.ConnectionSpeed), 323 AML_OFFSET (SpiSerialBus.ConnectionSpeed), 324 1}, 325 }; 326 327 328 /******************************************************************************* 329 * 330 * AcpiRsConvertUartSerialBus 331 * 332 ******************************************************************************/ 333 334 ACPI_RSCONVERT_INFO AcpiRsConvertUartSerialBus[22] = 335 { 336 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_SERIAL_BUS, 337 ACPI_RS_SIZE (ACPI_RESOURCE_UART_SERIALBUS), 338 ACPI_RSC_TABLE_SIZE (AcpiRsConvertUartSerialBus)}, 339 340 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_SERIAL_BUS, 341 sizeof (AML_RESOURCE_UART_SERIALBUS), 342 0}, 343 344 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.CommonSerialBus.RevisionId), 345 AML_OFFSET (CommonSerialBus.RevisionId), 346 1}, 347 348 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.CommonSerialBus.Type), 349 AML_OFFSET (CommonSerialBus.Type), 350 1}, 351 352 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.CommonSerialBus.SlaveMode), 353 AML_OFFSET (CommonSerialBus.Flags), 354 0}, 355 356 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.CommonSerialBus.ProducerConsumer), 357 AML_OFFSET (CommonSerialBus.Flags), 358 1}, 359 360 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.CommonSerialBus.TypeRevisionId), 361 AML_OFFSET (CommonSerialBus.TypeRevisionId), 362 1}, 363 364 {ACPI_RSC_MOVE16, ACPI_RS_OFFSET (Data.CommonSerialBus.TypeDataLength), 365 AML_OFFSET (CommonSerialBus.TypeDataLength), 366 1}, 367 368 /* Vendor data */ 369 370 {ACPI_RSC_COUNT_SERIAL_VEN, ACPI_RS_OFFSET (Data.CommonSerialBus.VendorLength), 371 AML_OFFSET (CommonSerialBus.TypeDataLength), 372 AML_RESOURCE_UART_MIN_DATA_LEN}, 373 374 {ACPI_RSC_MOVE_SERIAL_VEN, ACPI_RS_OFFSET (Data.CommonSerialBus.VendorData), 375 0, 376 sizeof (AML_RESOURCE_UART_SERIALBUS)}, 377 378 /* Resource Source */ 379 380 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.CommonSerialBus.ResourceSource.Index), 381 AML_OFFSET (CommonSerialBus.ResSourceIndex), 382 1}, 383 384 {ACPI_RSC_COUNT_SERIAL_RES, ACPI_RS_OFFSET (Data.CommonSerialBus.ResourceSource.StringLength), 385 AML_OFFSET (CommonSerialBus.TypeDataLength), 386 sizeof (AML_RESOURCE_COMMON_SERIALBUS)}, 387 388 {ACPI_RSC_MOVE_SERIAL_RES, ACPI_RS_OFFSET (Data.CommonSerialBus.ResourceSource.StringPtr), 389 AML_OFFSET (CommonSerialBus.TypeDataLength), 390 sizeof (AML_RESOURCE_COMMON_SERIALBUS)}, 391 392 /* Uart bus type specific */ 393 394 {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.UartSerialBus.FlowControl), 395 AML_OFFSET (UartSerialBus.TypeSpecificFlags), 396 0}, 397 398 {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.UartSerialBus.StopBits), 399 AML_OFFSET (UartSerialBus.TypeSpecificFlags), 400 2}, 401 402 {ACPI_RSC_3BITFLAG, ACPI_RS_OFFSET (Data.UartSerialBus.DataBits), 403 AML_OFFSET (UartSerialBus.TypeSpecificFlags), 404 4}, 405 406 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.UartSerialBus.Endian), 407 AML_OFFSET (UartSerialBus.TypeSpecificFlags), 408 7}, 409 410 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.UartSerialBus.Parity), 411 AML_OFFSET (UartSerialBus.Parity), 412 1}, 413 414 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.UartSerialBus.LinesEnabled), 415 AML_OFFSET (UartSerialBus.LinesEnabled), 416 1}, 417 418 {ACPI_RSC_MOVE16, ACPI_RS_OFFSET (Data.UartSerialBus.RxFifoSize), 419 AML_OFFSET (UartSerialBus.RxFifoSize), 420 1}, 421 422 {ACPI_RSC_MOVE16, ACPI_RS_OFFSET (Data.UartSerialBus.TxFifoSize), 423 AML_OFFSET (UartSerialBus.TxFifoSize), 424 1}, 425 426 {ACPI_RSC_MOVE32, ACPI_RS_OFFSET (Data.UartSerialBus.DefaultBaudRate), 427 AML_OFFSET (UartSerialBus.DefaultBaudRate), 428 1}, 429 }; 430