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