Back to home page

OSCL-LXR

 
 

    


0001 .. SPDX-License-Identifier: GPL-2.0
0002 
0003 =============================
0004 ACPI Based Device Enumeration
0005 =============================
0006 
0007 ACPI 5 introduced a set of new resources (UartTSerialBus, I2cSerialBus,
0008 SpiSerialBus, GpioIo and GpioInt) which can be used in enumerating slave
0009 devices behind serial bus controllers.
0010 
0011 In addition we are starting to see peripherals integrated in the
0012 SoC/Chipset to appear only in ACPI namespace. These are typically devices
0013 that are accessed through memory-mapped registers.
0014 
0015 In order to support this and re-use the existing drivers as much as
0016 possible we decided to do following:
0017 
0018   - Devices that have no bus connector resource are represented as
0019     platform devices.
0020 
0021   - Devices behind real busses where there is a connector resource
0022     are represented as struct spi_device or struct i2c_device. Note
0023     that standard UARTs are not busses so there is no struct uart_device,
0024     although some of them may be represented by sturct serdev_device.
0025 
0026 As both ACPI and Device Tree represent a tree of devices (and their
0027 resources) this implementation follows the Device Tree way as much as
0028 possible.
0029 
0030 The ACPI implementation enumerates devices behind busses (platform, SPI,
0031 I2C, and in some cases UART), creates the physical devices and binds them
0032 to their ACPI handle in the ACPI namespace.
0033 
0034 This means that when ACPI_HANDLE(dev) returns non-NULL the device was
0035 enumerated from ACPI namespace. This handle can be used to extract other
0036 device-specific configuration. There is an example of this below.
0037 
0038 Platform bus support
0039 ====================
0040 
0041 Since we are using platform devices to represent devices that are not
0042 connected to any physical bus we only need to implement a platform driver
0043 for the device and add supported ACPI IDs. If this same IP-block is used on
0044 some other non-ACPI platform, the driver might work out of the box or needs
0045 some minor changes.
0046 
0047 Adding ACPI support for an existing driver should be pretty
0048 straightforward. Here is the simplest example::
0049 
0050         static const struct acpi_device_id mydrv_acpi_match[] = {
0051                 /* ACPI IDs here */
0052                 { }
0053         };
0054         MODULE_DEVICE_TABLE(acpi, mydrv_acpi_match);
0055 
0056         static struct platform_driver my_driver = {
0057                 ...
0058                 .driver = {
0059                         .acpi_match_table = mydrv_acpi_match,
0060                 },
0061         };
0062 
0063 If the driver needs to perform more complex initialization like getting and
0064 configuring GPIOs it can get its ACPI handle and extract this information
0065 from ACPI tables.
0066 
0067 DMA support
0068 ===========
0069 
0070 DMA controllers enumerated via ACPI should be registered in the system to
0071 provide generic access to their resources. For example, a driver that would
0072 like to be accessible to slave devices via generic API call
0073 dma_request_chan() must register itself at the end of the probe function like
0074 this::
0075 
0076         err = devm_acpi_dma_controller_register(dev, xlate_func, dw);
0077         /* Handle the error if it's not a case of !CONFIG_ACPI */
0078 
0079 and implement custom xlate function if needed (usually acpi_dma_simple_xlate()
0080 is enough) which converts the FixedDMA resource provided by struct
0081 acpi_dma_spec into the corresponding DMA channel. A piece of code for that case
0082 could look like::
0083 
0084         #ifdef CONFIG_ACPI
0085         struct filter_args {
0086                 /* Provide necessary information for the filter_func */
0087                 ...
0088         };
0089 
0090         static bool filter_func(struct dma_chan *chan, void *param)
0091         {
0092                 /* Choose the proper channel */
0093                 ...
0094         }
0095 
0096         static struct dma_chan *xlate_func(struct acpi_dma_spec *dma_spec,
0097                         struct acpi_dma *adma)
0098         {
0099                 dma_cap_mask_t cap;
0100                 struct filter_args args;
0101 
0102                 /* Prepare arguments for filter_func */
0103                 ...
0104                 return dma_request_channel(cap, filter_func, &args);
0105         }
0106         #else
0107         static struct dma_chan *xlate_func(struct acpi_dma_spec *dma_spec,
0108                         struct acpi_dma *adma)
0109         {
0110                 return NULL;
0111         }
0112         #endif
0113 
0114 dma_request_chan() will call xlate_func() for each registered DMA controller.
0115 In the xlate function the proper channel must be chosen based on
0116 information in struct acpi_dma_spec and the properties of the controller
0117 provided by struct acpi_dma.
0118 
0119 Clients must call dma_request_chan() with the string parameter that corresponds
0120 to a specific FixedDMA resource. By default "tx" means the first entry of the
0121 FixedDMA resource array, "rx" means the second entry. The table below shows a
0122 layout::
0123 
0124         Device (I2C0)
0125         {
0126                 ...
0127                 Method (_CRS, 0, NotSerialized)
0128                 {
0129                         Name (DBUF, ResourceTemplate ()
0130                         {
0131                                 FixedDMA (0x0018, 0x0004, Width32bit, _Y48)
0132                                 FixedDMA (0x0019, 0x0005, Width32bit, )
0133                         })
0134                 ...
0135                 }
0136         }
0137 
0138 So, the FixedDMA with request line 0x0018 is "tx" and next one is "rx" in
0139 this example.
0140 
0141 In robust cases the client unfortunately needs to call
0142 acpi_dma_request_slave_chan_by_index() directly and therefore choose the
0143 specific FixedDMA resource by its index.
0144 
0145 Named Interrupts
0146 ================
0147 
0148 Drivers enumerated via ACPI can have names to interrupts in the ACPI table
0149 which can be used to get the IRQ number in the driver.
0150 
0151 The interrupt name can be listed in _DSD as 'interrupt-names'. The names
0152 should be listed as an array of strings which will map to the Interrupt()
0153 resource in the ACPI table corresponding to its index.
0154 
0155 The table below shows an example of its usage::
0156 
0157     Device (DEV0) {
0158         ...
0159         Name (_CRS, ResourceTemplate() {
0160             ...
0161             Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) {
0162                 0x20,
0163                 0x24
0164             }
0165         })
0166 
0167         Name (_DSD, Package () {
0168             ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
0169             Package () {
0170                 Package () { "interrupt-names", Package () { "default", "alert" } },
0171             }
0172         ...
0173         })
0174     }
0175 
0176 The interrupt name 'default' will correspond to 0x20 in Interrupt()
0177 resource and 'alert' to 0x24. Note that only the Interrupt() resource
0178 is mapped and not GpioInt() or similar.
0179 
0180 The driver can call the function - fwnode_irq_get_byname() with the fwnode
0181 and interrupt name as arguments to get the corresponding IRQ number.
0182 
0183 SPI serial bus support
0184 ======================
0185 
0186 Slave devices behind SPI bus have SpiSerialBus resource attached to them.
0187 This is extracted automatically by the SPI core and the slave devices are
0188 enumerated once spi_register_master() is called by the bus driver.
0189 
0190 Here is what the ACPI namespace for a SPI slave might look like::
0191 
0192         Device (EEP0)
0193         {
0194                 Name (_ADR, 1)
0195                 Name (_CID, Package () {
0196                         "ATML0025",
0197                         "AT25",
0198                 })
0199                 ...
0200                 Method (_CRS, 0, NotSerialized)
0201                 {
0202                         SPISerialBus(1, PolarityLow, FourWireMode, 8,
0203                                 ControllerInitiated, 1000000, ClockPolarityLow,
0204                                 ClockPhaseFirst, "\\_SB.PCI0.SPI1",)
0205                 }
0206                 ...
0207 
0208 The SPI device drivers only need to add ACPI IDs in a similar way than with
0209 the platform device drivers. Below is an example where we add ACPI support
0210 to at25 SPI eeprom driver (this is meant for the above ACPI snippet)::
0211 
0212         static const struct acpi_device_id at25_acpi_match[] = {
0213                 { "AT25", 0 },
0214                 { }
0215         };
0216         MODULE_DEVICE_TABLE(acpi, at25_acpi_match);
0217 
0218         static struct spi_driver at25_driver = {
0219                 .driver = {
0220                         ...
0221                         .acpi_match_table = at25_acpi_match,
0222                 },
0223         };
0224 
0225 Note that this driver actually needs more information like page size of the
0226 eeprom, etc. This information can be passed via _DSD method like::
0227 
0228         Device (EEP0)
0229         {
0230                 ...
0231                 Name (_DSD, Package ()
0232                 {
0233                         ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
0234                         Package ()
0235                         {
0236                                 Package () { "size", 1024 },
0237                                 Package () { "pagesize", 32 },
0238                                 Package () { "address-width", 16 },
0239                         }
0240                 })
0241         }
0242 
0243 Then the at25 SPI driver can get this configuration by calling device property
0244 APIs during ->probe() phase like::
0245 
0246         err = device_property_read_u32(dev, "size", &size);
0247         if (err)
0248                 ...error handling...
0249 
0250         err = device_property_read_u32(dev, "pagesize", &page_size);
0251         if (err)
0252                 ...error handling...
0253 
0254         err = device_property_read_u32(dev, "address-width", &addr_width);
0255         if (err)
0256                 ...error handling...
0257 
0258 I2C serial bus support
0259 ======================
0260 
0261 The slaves behind I2C bus controller only need to add the ACPI IDs like
0262 with the platform and SPI drivers. The I2C core automatically enumerates
0263 any slave devices behind the controller device once the adapter is
0264 registered.
0265 
0266 Below is an example of how to add ACPI support to the existing mpu3050
0267 input driver::
0268 
0269         static const struct acpi_device_id mpu3050_acpi_match[] = {
0270                 { "MPU3050", 0 },
0271                 { }
0272         };
0273         MODULE_DEVICE_TABLE(acpi, mpu3050_acpi_match);
0274 
0275         static struct i2c_driver mpu3050_i2c_driver = {
0276                 .driver = {
0277                         .name   = "mpu3050",
0278                         .pm     = &mpu3050_pm,
0279                         .of_match_table = mpu3050_of_match,
0280                         .acpi_match_table = mpu3050_acpi_match,
0281                 },
0282                 .probe          = mpu3050_probe,
0283                 .remove         = mpu3050_remove,
0284                 .id_table       = mpu3050_ids,
0285         };
0286         module_i2c_driver(mpu3050_i2c_driver);
0287 
0288 Reference to PWM device
0289 =======================
0290 
0291 Sometimes a device can be a consumer of PWM channel. Obviously OS would like
0292 to know which one. To provide this mapping the special property has been
0293 introduced, i.e.::
0294 
0295     Device (DEV)
0296     {
0297         Name (_DSD, Package ()
0298         {
0299             ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
0300             Package () {
0301                 Package () { "compatible", Package () { "pwm-leds" } },
0302                 Package () { "label", "alarm-led" },
0303                 Package () { "pwms",
0304                     Package () {
0305                         "\\_SB.PCI0.PWM",  // <PWM device reference>
0306                         0,                 // <PWM index>
0307                         600000000,         // <PWM period>
0308                         0,                 // <PWM flags>
0309                     }
0310                 }
0311             }
0312         })
0313         ...
0314     }
0315 
0316 In the above example the PWM-based LED driver references to the PWM channel 0
0317 of \_SB.PCI0.PWM device with initial period setting equal to 600 ms (note that
0318 value is given in nanoseconds).
0319 
0320 GPIO support
0321 ============
0322 
0323 ACPI 5 introduced two new resources to describe GPIO connections: GpioIo
0324 and GpioInt. These resources can be used to pass GPIO numbers used by
0325 the device to the driver. ACPI 5.1 extended this with _DSD (Device
0326 Specific Data) which made it possible to name the GPIOs among other things.
0327 
0328 For example::
0329 
0330         Device (DEV)
0331         {
0332                 Method (_CRS, 0, NotSerialized)
0333                 {
0334                         Name (SBUF, ResourceTemplate()
0335                         {
0336                                 // Used to power on/off the device
0337                                 GpioIo (Exclusive, PullNone, 0, 0, IoRestrictionOutputOnly,
0338                                         "\\_SB.PCI0.GPI0", 0, ResourceConsumer) { 85 }
0339 
0340                                 // Interrupt for the device
0341                                 GpioInt (Edge, ActiveHigh, ExclusiveAndWake, PullNone, 0,
0342                                          "\\_SB.PCI0.GPI0", 0, ResourceConsumer) { 88 }
0343                         }
0344 
0345                         Return (SBUF)
0346                 }
0347 
0348                 // ACPI 5.1 _DSD used for naming the GPIOs
0349                 Name (_DSD, Package ()
0350                 {
0351                         ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
0352                         Package ()
0353                         {
0354                                 Package () { "power-gpios", Package () { ^DEV, 0, 0, 0 } },
0355                                 Package () { "irq-gpios", Package () { ^DEV, 1, 0, 0 } },
0356                         }
0357                 })
0358                 ...
0359         }
0360 
0361 These GPIO numbers are controller relative and path "\\_SB.PCI0.GPI0"
0362 specifies the path to the controller. In order to use these GPIOs in Linux
0363 we need to translate them to the corresponding Linux GPIO descriptors.
0364 
0365 There is a standard GPIO API for that and is documented in
0366 Documentation/admin-guide/gpio/.
0367 
0368 In the above example we can get the corresponding two GPIO descriptors with
0369 a code like this::
0370 
0371         #include <linux/gpio/consumer.h>
0372         ...
0373 
0374         struct gpio_desc *irq_desc, *power_desc;
0375 
0376         irq_desc = gpiod_get(dev, "irq");
0377         if (IS_ERR(irq_desc))
0378                 /* handle error */
0379 
0380         power_desc = gpiod_get(dev, "power");
0381         if (IS_ERR(power_desc))
0382                 /* handle error */
0383 
0384         /* Now we can use the GPIO descriptors */
0385 
0386 There are also devm_* versions of these functions which release the
0387 descriptors once the device is released.
0388 
0389 See Documentation/firmware-guide/acpi/gpio-properties.rst for more information
0390 about the _DSD binding related to GPIOs.
0391 
0392 RS-485 support
0393 ==============
0394 
0395 ACPI _DSD (Device Specific Data) can be used to describe RS-485 capability
0396 of UART.
0397 
0398 For example::
0399 
0400         Device (DEV)
0401         {
0402                 ...
0403 
0404                 // ACPI 5.1 _DSD used for RS-485 capabilities
0405                 Name (_DSD, Package ()
0406                 {
0407                         ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
0408                         Package ()
0409                         {
0410                                 Package () {"rs485-rts-active-low", Zero},
0411                                 Package () {"rs485-rx-active-high", Zero},
0412                                 Package () {"rs485-rx-during-tx", Zero},
0413                         }
0414                 })
0415                 ...
0416 
0417 MFD devices
0418 ===========
0419 
0420 The MFD devices register their children as platform devices. For the child
0421 devices there needs to be an ACPI handle that they can use to reference
0422 parts of the ACPI namespace that relate to them. In the Linux MFD subsystem
0423 we provide two ways:
0424 
0425   - The children share the parent ACPI handle.
0426   - The MFD cell can specify the ACPI id of the device.
0427 
0428 For the first case, the MFD drivers do not need to do anything. The
0429 resulting child platform device will have its ACPI_COMPANION() set to point
0430 to the parent device.
0431 
0432 If the ACPI namespace has a device that we can match using an ACPI id or ACPI
0433 adr, the cell should be set like::
0434 
0435         static struct mfd_cell_acpi_match my_subdevice_cell_acpi_match = {
0436                 .pnpid = "XYZ0001",
0437                 .adr = 0,
0438         };
0439 
0440         static struct mfd_cell my_subdevice_cell = {
0441                 .name = "my_subdevice",
0442                 /* set the resources relative to the parent */
0443                 .acpi_match = &my_subdevice_cell_acpi_match,
0444         };
0445 
0446 The ACPI id "XYZ0001" is then used to lookup an ACPI device directly under
0447 the MFD device and if found, that ACPI companion device is bound to the
0448 resulting child platform device.
0449 
0450 Device Tree namespace link device ID
0451 ====================================
0452 
0453 The Device Tree protocol uses device identification based on the "compatible"
0454 property whose value is a string or an array of strings recognized as device
0455 identifiers by drivers and the driver core.  The set of all those strings may be
0456 regarded as a device identification namespace analogous to the ACPI/PNP device
0457 ID namespace.  Consequently, in principle it should not be necessary to allocate
0458 a new (and arguably redundant) ACPI/PNP device ID for a devices with an existing
0459 identification string in the Device Tree (DT) namespace, especially if that ID
0460 is only needed to indicate that a given device is compatible with another one,
0461 presumably having a matching driver in the kernel already.
0462 
0463 In ACPI, the device identification object called _CID (Compatible ID) is used to
0464 list the IDs of devices the given one is compatible with, but those IDs must
0465 belong to one of the namespaces prescribed by the ACPI specification (see
0466 Section 6.1.2 of ACPI 6.0 for details) and the DT namespace is not one of them.
0467 Moreover, the specification mandates that either a _HID or an _ADR identification
0468 object be present for all ACPI objects representing devices (Section 6.1 of ACPI
0469 6.0).  For non-enumerable bus types that object must be _HID and its value must
0470 be a device ID from one of the namespaces prescribed by the specification too.
0471 
0472 The special DT namespace link device ID, PRP0001, provides a means to use the
0473 existing DT-compatible device identification in ACPI and to satisfy the above
0474 requirements following from the ACPI specification at the same time.  Namely,
0475 if PRP0001 is returned by _HID, the ACPI subsystem will look for the
0476 "compatible" property in the device object's _DSD and will use the value of that
0477 property to identify the corresponding device in analogy with the original DT
0478 device identification algorithm.  If the "compatible" property is not present
0479 or its value is not valid, the device will not be enumerated by the ACPI
0480 subsystem.  Otherwise, it will be enumerated automatically as a platform device
0481 (except when an I2C or SPI link from the device to its parent is present, in
0482 which case the ACPI core will leave the device enumeration to the parent's
0483 driver) and the identification strings from the "compatible" property value will
0484 be used to find a driver for the device along with the device IDs listed by _CID
0485 (if present).
0486 
0487 Analogously, if PRP0001 is present in the list of device IDs returned by _CID,
0488 the identification strings listed by the "compatible" property value (if present
0489 and valid) will be used to look for a driver matching the device, but in that
0490 case their relative priority with respect to the other device IDs listed by
0491 _HID and _CID depends on the position of PRP0001 in the _CID return package.
0492 Specifically, the device IDs returned by _HID and preceding PRP0001 in the _CID
0493 return package will be checked first.  Also in that case the bus type the device
0494 will be enumerated to depends on the device ID returned by _HID.
0495 
0496 For example, the following ACPI sample might be used to enumerate an lm75-type
0497 I2C temperature sensor and match it to the driver using the Device Tree
0498 namespace link::
0499 
0500         Device (TMP0)
0501         {
0502                 Name (_HID, "PRP0001")
0503                 Name (_DSD, Package () {
0504                         ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
0505                         Package () {
0506                                 Package () { "compatible", "ti,tmp75" },
0507                         }
0508                 })
0509                 Method (_CRS, 0, Serialized)
0510                 {
0511                         Name (SBUF, ResourceTemplate ()
0512                         {
0513                                 I2cSerialBusV2 (0x48, ControllerInitiated,
0514                                         400000, AddressingMode7Bit,
0515                                         "\\_SB.PCI0.I2C1", 0x00,
0516                                         ResourceConsumer, , Exclusive,)
0517                         })
0518                         Return (SBUF)
0519                 }
0520         }
0521 
0522 It is valid to define device objects with a _HID returning PRP0001 and without
0523 the "compatible" property in the _DSD or a _CID as long as one of their
0524 ancestors provides a _DSD with a valid "compatible" property.  Such device
0525 objects are then simply regarded as additional "blocks" providing hierarchical
0526 configuration information to the driver of the composite ancestor device.
0527 
0528 However, PRP0001 can only be returned from either _HID or _CID of a device
0529 object if all of the properties returned by the _DSD associated with it (either
0530 the _DSD of the device object itself or the _DSD of its ancestor in the
0531 "composite device" case described above) can be used in the ACPI environment.
0532 Otherwise, the _DSD itself is regarded as invalid and therefore the "compatible"
0533 property returned by it is meaningless.
0534 
0535 Refer to Documentation/firmware-guide/acpi/DSD-properties-rules.rst for more
0536 information.
0537 
0538 PCI hierarchy representation
0539 ============================
0540 
0541 Sometimes could be useful to enumerate a PCI device, knowing its position on the
0542 PCI bus.
0543 
0544 For example, some systems use PCI devices soldered directly on the mother board,
0545 in a fixed position (ethernet, Wi-Fi, serial ports, etc.). In this conditions it
0546 is possible to refer to these PCI devices knowing their position on the PCI bus
0547 topology.
0548 
0549 To identify a PCI device, a complete hierarchical description is required, from
0550 the chipset root port to the final device, through all the intermediate
0551 bridges/switches of the board.
0552 
0553 For example, let us assume to have a system with a PCIe serial port, an
0554 Exar XR17V3521, soldered on the main board. This UART chip also includes
0555 16 GPIOs and we want to add the property ``gpio-line-names`` [1] to these pins.
0556 In this case, the ``lspci`` output for this component is::
0557 
0558         07:00.0 Serial controller: Exar Corp. XR17V3521 Dual PCIe UART (rev 03)
0559 
0560 The complete ``lspci`` output (manually reduced in length) is::
0561 
0562         00:00.0 Host bridge: Intel Corp... Host Bridge (rev 0d)
0563         ...
0564         00:13.0 PCI bridge: Intel Corp... PCI Express Port A #1 (rev fd)
0565         00:13.1 PCI bridge: Intel Corp... PCI Express Port A #2 (rev fd)
0566         00:13.2 PCI bridge: Intel Corp... PCI Express Port A #3 (rev fd)
0567         00:14.0 PCI bridge: Intel Corp... PCI Express Port B #1 (rev fd)
0568         00:14.1 PCI bridge: Intel Corp... PCI Express Port B #2 (rev fd)
0569         ...
0570         05:00.0 PCI bridge: Pericom Semiconductor Device 2404 (rev 05)
0571         06:01.0 PCI bridge: Pericom Semiconductor Device 2404 (rev 05)
0572         06:02.0 PCI bridge: Pericom Semiconductor Device 2404 (rev 05)
0573         06:03.0 PCI bridge: Pericom Semiconductor Device 2404 (rev 05)
0574         07:00.0 Serial controller: Exar Corp. XR17V3521 Dual PCIe UART (rev 03) <-- Exar
0575         ...
0576 
0577 The bus topology is::
0578 
0579         -[0000:00]-+-00.0
0580                    ...
0581                    +-13.0-[01]----00.0
0582                    +-13.1-[02]----00.0
0583                    +-13.2-[03]--
0584                    +-14.0-[04]----00.0
0585                    +-14.1-[05-09]----00.0-[06-09]--+-01.0-[07]----00.0 <-- Exar
0586                    |                               +-02.0-[08]----00.0
0587                    |                               \-03.0-[09]--
0588                    ...
0589                    \-1f.1
0590 
0591 To describe this Exar device on the PCI bus, we must start from the ACPI name
0592 of the chipset bridge (also called "root port") with address::
0593 
0594         Bus: 0 - Device: 14 - Function: 1
0595 
0596 To find this information is necessary disassemble the BIOS ACPI tables, in
0597 particular the DSDT (see also [2])::
0598 
0599         mkdir ~/tables/
0600         cd ~/tables/
0601         acpidump > acpidump
0602         acpixtract -a acpidump
0603         iasl -e ssdt?.* -d dsdt.dat
0604 
0605 Now, in the dsdt.dsl, we have to search the device whose address is related to
0606 0x14 (device) and 0x01 (function). In this case we can find the following
0607 device::
0608 
0609         Scope (_SB.PCI0)
0610         {
0611         ... other definitions follow ...
0612                 Device (RP02)
0613                 {
0614                         Method (_ADR, 0, NotSerialized)  // _ADR: Address
0615                         {
0616                                 If ((RPA2 != Zero))
0617                                 {
0618                                         Return (RPA2) /* \RPA2 */
0619                                 }
0620                                 Else
0621                                 {
0622                                         Return (0x00140001)
0623                                 }
0624                         }
0625         ... other definitions follow ...
0626 
0627 and the _ADR method [3] returns exactly the device/function couple that
0628 we are looking for. With this information and analyzing the above ``lspci``
0629 output (both the devices list and the devices tree), we can write the following
0630 ACPI description for the Exar PCIe UART, also adding the list of its GPIO line
0631 names::
0632 
0633         Scope (_SB.PCI0.RP02)
0634         {
0635                 Device (BRG1) //Bridge
0636                 {
0637                         Name (_ADR, 0x0000)
0638 
0639                         Device (BRG2) //Bridge
0640                         {
0641                                 Name (_ADR, 0x00010000)
0642 
0643                                 Device (EXAR)
0644                                 {
0645                                         Name (_ADR, 0x0000)
0646 
0647                                         Name (_DSD, Package ()
0648                                         {
0649                                                 ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
0650                                                 Package ()
0651                                                 {
0652                                                         Package ()
0653                                                         {
0654                                                                 "gpio-line-names",
0655                                                                 Package ()
0656                                                                 {
0657                                                                         "mode_232",
0658                                                                         "mode_422",
0659                                                                         "mode_485",
0660                                                                         "misc_1",
0661                                                                         "misc_2",
0662                                                                         "misc_3",
0663                                                                         "",
0664                                                                         "",
0665                                                                         "aux_1",
0666                                                                         "aux_2",
0667                                                                         "aux_3",
0668                                                                 }
0669                                                         }
0670                                                 }
0671                                         })
0672                                 }
0673                         }
0674                 }
0675         }
0676 
0677 The location "_SB.PCI0.RP02" is obtained by the above investigation in the
0678 dsdt.dsl table, whereas the device names "BRG1", "BRG2" and "EXAR" are
0679 created analyzing the position of the Exar UART in the PCI bus topology.
0680 
0681 References
0682 ==========
0683 
0684 [1] Documentation/firmware-guide/acpi/gpio-properties.rst
0685 
0686 [2] Documentation/admin-guide/acpi/initrd_table_override.rst
0687 
0688 [3] ACPI Specifications, Version 6.3 - Paragraph 6.1.1 _ADR Address)
0689     https://uefi.org/sites/default/files/resources/ACPI_6_3_May16.pdf,
0690     referenced 2020-11-18