~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/Documentation/firmware-guide/acpi/enumeration.rst

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /Documentation/firmware-guide/acpi/enumeration.rst (Version linux-6.12-rc7) and /Documentation/firmware-guide/acpi/enumeration.rst (Version linux-5.12.19)


  1 .. SPDX-License-Identifier: GPL-2.0                 1 .. SPDX-License-Identifier: GPL-2.0
  2                                                     2 
  3 =============================                       3 =============================
  4 ACPI Based Device Enumeration                       4 ACPI Based Device Enumeration
  5 =============================                       5 =============================
  6                                                     6 
  7 ACPI 5 introduced a set of new resources (Uart      7 ACPI 5 introduced a set of new resources (UartTSerialBus, I2cSerialBus,
  8 SpiSerialBus, GpioIo and GpioInt) which can be      8 SpiSerialBus, GpioIo and GpioInt) which can be used in enumerating slave
  9 devices behind serial bus controllers.              9 devices behind serial bus controllers.
 10                                                    10 
 11 In addition we are starting to see peripherals     11 In addition we are starting to see peripherals integrated in the
 12 SoC/Chipset to appear only in ACPI namespace.      12 SoC/Chipset to appear only in ACPI namespace. These are typically devices
 13 that are accessed through memory-mapped regist     13 that are accessed through memory-mapped registers.
 14                                                    14 
 15 In order to support this and re-use the existi     15 In order to support this and re-use the existing drivers as much as
 16 possible we decided to do following:               16 possible we decided to do following:
 17                                                    17 
 18   - Devices that have no bus connector resourc     18   - Devices that have no bus connector resource are represented as
 19     platform devices.                              19     platform devices.
 20                                                    20 
 21   - Devices behind real busses where there is      21   - Devices behind real busses where there is a connector resource
 22     are represented as struct spi_device or st !!  22     are represented as struct spi_device or struct i2c_device
 23     that standard UARTs are not busses so ther !!  23     (standard UARTs are not busses so there is no struct uart_device).
 24     although some of them may be represented b << 
 25                                                    24 
 26 As both ACPI and Device Tree represent a tree      25 As both ACPI and Device Tree represent a tree of devices (and their
 27 resources) this implementation follows the Dev     26 resources) this implementation follows the Device Tree way as much as
 28 possible.                                          27 possible.
 29                                                    28 
 30 The ACPI implementation enumerates devices beh !!  29 The ACPI implementation enumerates devices behind busses (platform, SPI and
 31 I2C, and in some cases UART), creates the phys !!  30 I2C), creates the physical devices and binds them to their ACPI handle in
 32 to their ACPI handle in the ACPI namespace.    !!  31 the ACPI namespace.
 33                                                    32 
 34 This means that when ACPI_HANDLE(dev) returns      33 This means that when ACPI_HANDLE(dev) returns non-NULL the device was
 35 enumerated from ACPI namespace. This handle ca     34 enumerated from ACPI namespace. This handle can be used to extract other
 36 device-specific configuration. There is an exa     35 device-specific configuration. There is an example of this below.
 37                                                    36 
 38 Platform bus support                               37 Platform bus support
 39 ====================                               38 ====================
 40                                                    39 
 41 Since we are using platform devices to represe     40 Since we are using platform devices to represent devices that are not
 42 connected to any physical bus we only need to      41 connected to any physical bus we only need to implement a platform driver
 43 for the device and add supported ACPI IDs. If      42 for the device and add supported ACPI IDs. If this same IP-block is used on
 44 some other non-ACPI platform, the driver might     43 some other non-ACPI platform, the driver might work out of the box or needs
 45 some minor changes.                                44 some minor changes.
 46                                                    45 
 47 Adding ACPI support for an existing driver sho     46 Adding ACPI support for an existing driver should be pretty
 48 straightforward. Here is the simplest example:     47 straightforward. Here is the simplest example::
 49                                                    48 
                                                   >>  49         #ifdef CONFIG_ACPI
 50         static const struct acpi_device_id myd     50         static const struct acpi_device_id mydrv_acpi_match[] = {
 51                 /* ACPI IDs here */                51                 /* ACPI IDs here */
 52                 { }                                52                 { }
 53         };                                         53         };
 54         MODULE_DEVICE_TABLE(acpi, mydrv_acpi_m     54         MODULE_DEVICE_TABLE(acpi, mydrv_acpi_match);
                                                   >>  55         #endif
 55                                                    56 
 56         static struct platform_driver my_drive     57         static struct platform_driver my_driver = {
 57                 ...                                58                 ...
 58                 .driver = {                        59                 .driver = {
 59                         .acpi_match_table = my !!  60                         .acpi_match_table = ACPI_PTR(mydrv_acpi_match),
 60                 },                                 61                 },
 61         };                                         62         };
 62                                                    63 
 63 If the driver needs to perform more complex in     64 If the driver needs to perform more complex initialization like getting and
 64 configuring GPIOs it can get its ACPI handle a     65 configuring GPIOs it can get its ACPI handle and extract this information
 65 from ACPI tables.                                  66 from ACPI tables.
 66                                                    67 
 67 ACPI device objects                            << 
 68 ===================                            << 
 69                                                << 
 70 Generally speaking, there are two categories o << 
 71 ACPI is used as an interface between the platf << 
 72 that can be discovered and enumerated natively << 
 73 the specific bus that they are on (for example << 
 74 without the platform firmware assistance, and  << 
 75 by the platform firmware so that they can be d << 
 76 known to the platform firmware, regardless of  << 
 77 there can be a corresponding ACPI device objec << 
 78 case the Linux kernel will create a struct acp << 
 79 that device.                                   << 
 80                                                << 
 81 Those struct acpi_device objects are never use << 
 82 discoverable devices, because they are represe << 
 83 objects (for example, struct pci_dev for PCI d << 
 84 device drivers (the corresponding struct acpi_ << 
 85 an additional source of information on the con << 
 86 Moreover, the core ACPI device enumeration cod << 
 87 objects for the majority of devices that are d << 
 88 help of the platform firmware and those platfo << 
 89 by platform drivers in direct analogy with the << 
 90 case.  Therefore it is logically inconsistent  << 
 91 drivers to struct acpi_device objects, includi << 
 92 discovered with the help of the platform firmw << 
 93                                                << 
 94 Historically, ACPI drivers that bound directly << 
 95 were implemented for some devices enumerated w << 
 96 firmware, but this is not recommended for any  << 
 97 platform device objects are created for those  << 
 98 exceptions that are not relevant here) and so  << 
 99 for handling them, even though the correspondi << 
100 only source of device configuration informatio << 
101                                                << 
102 For every device having a corresponding struct << 
103 to it is returned by the ACPI_COMPANION() macr << 
104 get to the device configuration information st << 
105 this way.  Accordingly, struct acpi_device can << 
106 interface between the kernel and the ACPI Name << 
107 other types (for example, struct pci_dev or st << 
108 for interacting with the rest of the system.   << 
109                                                << 
110 DMA support                                        68 DMA support
111 ===========                                        69 ===========
112                                                    70 
113 DMA controllers enumerated via ACPI should be      71 DMA controllers enumerated via ACPI should be registered in the system to
114 provide generic access to their resources. For     72 provide generic access to their resources. For example, a driver that would
115 like to be accessible to slave devices via gen     73 like to be accessible to slave devices via generic API call
116 dma_request_chan() must register itself at the     74 dma_request_chan() must register itself at the end of the probe function like
117 this::                                             75 this::
118                                                    76 
119         err = devm_acpi_dma_controller_registe     77         err = devm_acpi_dma_controller_register(dev, xlate_func, dw);
120         /* Handle the error if it's not a case     78         /* Handle the error if it's not a case of !CONFIG_ACPI */
121                                                    79 
122 and implement custom xlate function if needed      80 and implement custom xlate function if needed (usually acpi_dma_simple_xlate()
123 is enough) which converts the FixedDMA resourc     81 is enough) which converts the FixedDMA resource provided by struct
124 acpi_dma_spec into the corresponding DMA chann     82 acpi_dma_spec into the corresponding DMA channel. A piece of code for that case
125 could look like::                                  83 could look like::
126                                                    84 
127         #ifdef CONFIG_ACPI                         85         #ifdef CONFIG_ACPI
128         struct filter_args {                       86         struct filter_args {
129                 /* Provide necessary informati     87                 /* Provide necessary information for the filter_func */
130                 ...                                88                 ...
131         };                                         89         };
132                                                    90 
133         static bool filter_func(struct dma_cha     91         static bool filter_func(struct dma_chan *chan, void *param)
134         {                                          92         {
135                 /* Choose the proper channel *     93                 /* Choose the proper channel */
136                 ...                                94                 ...
137         }                                          95         }
138                                                    96 
139         static struct dma_chan *xlate_func(str     97         static struct dma_chan *xlate_func(struct acpi_dma_spec *dma_spec,
140                         struct acpi_dma *adma)     98                         struct acpi_dma *adma)
141         {                                          99         {
142                 dma_cap_mask_t cap;               100                 dma_cap_mask_t cap;
143                 struct filter_args args;          101                 struct filter_args args;
144                                                   102 
145                 /* Prepare arguments for filte    103                 /* Prepare arguments for filter_func */
146                 ...                               104                 ...
147                 return dma_request_channel(cap    105                 return dma_request_channel(cap, filter_func, &args);
148         }                                         106         }
149         #else                                     107         #else
150         static struct dma_chan *xlate_func(str    108         static struct dma_chan *xlate_func(struct acpi_dma_spec *dma_spec,
151                         struct acpi_dma *adma)    109                         struct acpi_dma *adma)
152         {                                         110         {
153                 return NULL;                      111                 return NULL;
154         }                                         112         }
155         #endif                                    113         #endif
156                                                   114 
157 dma_request_chan() will call xlate_func() for     115 dma_request_chan() will call xlate_func() for each registered DMA controller.
158 In the xlate function the proper channel must     116 In the xlate function the proper channel must be chosen based on
159 information in struct acpi_dma_spec and the pr    117 information in struct acpi_dma_spec and the properties of the controller
160 provided by struct acpi_dma.                      118 provided by struct acpi_dma.
161                                                   119 
162 Clients must call dma_request_chan() with the     120 Clients must call dma_request_chan() with the string parameter that corresponds
163 to a specific FixedDMA resource. By default "t    121 to a specific FixedDMA resource. By default "tx" means the first entry of the
164 FixedDMA resource array, "rx" means the second    122 FixedDMA resource array, "rx" means the second entry. The table below shows a
165 layout::                                          123 layout::
166                                                   124 
167         Device (I2C0)                             125         Device (I2C0)
168         {                                         126         {
169                 ...                               127                 ...
170                 Method (_CRS, 0, NotSerialized    128                 Method (_CRS, 0, NotSerialized)
171                 {                                 129                 {
172                         Name (DBUF, ResourceTe    130                         Name (DBUF, ResourceTemplate ()
173                         {                         131                         {
174                                 FixedDMA (0x00    132                                 FixedDMA (0x0018, 0x0004, Width32bit, _Y48)
175                                 FixedDMA (0x00    133                                 FixedDMA (0x0019, 0x0005, Width32bit, )
176                         })                        134                         })
177                 ...                               135                 ...
178                 }                                 136                 }
179         }                                         137         }
180                                                   138 
181 So, the FixedDMA with request line 0x0018 is "    139 So, the FixedDMA with request line 0x0018 is "tx" and next one is "rx" in
182 this example.                                     140 this example.
183                                                   141 
184 In robust cases the client unfortunately needs    142 In robust cases the client unfortunately needs to call
185 acpi_dma_request_slave_chan_by_index() directl    143 acpi_dma_request_slave_chan_by_index() directly and therefore choose the
186 specific FixedDMA resource by its index.          144 specific FixedDMA resource by its index.
187                                                   145 
188 Named Interrupts                               << 
189 ================                               << 
190                                                << 
191 Drivers enumerated via ACPI can have names to  << 
192 which can be used to get the IRQ number in the << 
193                                                << 
194 The interrupt name can be listed in _DSD as 'i << 
195 should be listed as an array of strings which  << 
196 resource in the ACPI table corresponding to it << 
197                                                << 
198 The table below shows an example of its usage: << 
199                                                << 
200     Device (DEV0) {                            << 
201         ...                                    << 
202         Name (_CRS, ResourceTemplate() {       << 
203             ...                                << 
204             Interrupt (ResourceConsumer, Level << 
205                 0x20,                          << 
206                 0x24                           << 
207             }                                  << 
208         })                                     << 
209                                                << 
210         Name (_DSD, Package () {               << 
211             ToUUID("daffd814-6eba-4d8c-8a91-bc << 
212             Package () {                       << 
213                 Package () { "interrupt-names" << 
214             }                                  << 
215         ...                                    << 
216         })                                     << 
217     }                                          << 
218                                                << 
219 The interrupt name 'default' will correspond t << 
220 resource and 'alert' to 0x24. Note that only t << 
221 is mapped and not GpioInt() or similar.        << 
222                                                << 
223 The driver can call the function - fwnode_irq_ << 
224 and interrupt name as arguments to get the cor << 
225                                                << 
226 SPI serial bus support                            146 SPI serial bus support
227 ======================                            147 ======================
228                                                   148 
229 Slave devices behind SPI bus have SpiSerialBus    149 Slave devices behind SPI bus have SpiSerialBus resource attached to them.
230 This is extracted automatically by the SPI cor    150 This is extracted automatically by the SPI core and the slave devices are
231 enumerated once spi_register_master() is calle    151 enumerated once spi_register_master() is called by the bus driver.
232                                                   152 
233 Here is what the ACPI namespace for a SPI slav    153 Here is what the ACPI namespace for a SPI slave might look like::
234                                                   154 
235         Device (EEP0)                             155         Device (EEP0)
236         {                                         156         {
237                 Name (_ADR, 1)                    157                 Name (_ADR, 1)
238                 Name (_CID, Package () {       !! 158                 Name (_CID, Package() {
239                         "ATML0025",               159                         "ATML0025",
240                         "AT25",                   160                         "AT25",
241                 })                                161                 })
242                 ...                               162                 ...
243                 Method (_CRS, 0, NotSerialized    163                 Method (_CRS, 0, NotSerialized)
244                 {                                 164                 {
245                         SPISerialBus(1, Polari    165                         SPISerialBus(1, PolarityLow, FourWireMode, 8,
246                                 ControllerInit    166                                 ControllerInitiated, 1000000, ClockPolarityLow,
247                                 ClockPhaseFirs    167                                 ClockPhaseFirst, "\\_SB.PCI0.SPI1",)
248                 }                                 168                 }
249                 ...                               169                 ...
250                                                   170 
251 The SPI device drivers only need to add ACPI I !! 171 The SPI device drivers only need to add ACPI IDs in a similar way than with
252 the platform device drivers. Below is an examp    172 the platform device drivers. Below is an example where we add ACPI support
253 to at25 SPI eeprom driver (this is meant for t    173 to at25 SPI eeprom driver (this is meant for the above ACPI snippet)::
254                                                   174 
                                                   >> 175         #ifdef CONFIG_ACPI
255         static const struct acpi_device_id at2    176         static const struct acpi_device_id at25_acpi_match[] = {
256                 { "AT25", 0 },                    177                 { "AT25", 0 },
257                 { }                            !! 178                 { },
258         };                                        179         };
259         MODULE_DEVICE_TABLE(acpi, at25_acpi_ma    180         MODULE_DEVICE_TABLE(acpi, at25_acpi_match);
                                                   >> 181         #endif
260                                                   182 
261         static struct spi_driver at25_driver =    183         static struct spi_driver at25_driver = {
262                 .driver = {                       184                 .driver = {
263                         ...                       185                         ...
264                         .acpi_match_table = at !! 186                         .acpi_match_table = ACPI_PTR(at25_acpi_match),
265                 },                                187                 },
266         };                                        188         };
267                                                   189 
268 Note that this driver actually needs more info    190 Note that this driver actually needs more information like page size of the
269 eeprom, etc. This information can be passed vi !! 191 eeprom etc. but at the time writing this there is no standard way of
                                                   >> 192 passing those. One idea is to return this in _DSM method like::
270                                                   193 
271         Device (EEP0)                             194         Device (EEP0)
272         {                                         195         {
273                 ...                               196                 ...
274                 Name (_DSD, Package ()         !! 197                 Method (_DSM, 4, NotSerialized)
275                 {                                 198                 {
276                         ToUUID("daffd814-6eba- !! 199                         Store (Package (6)
277                         Package ()             << 
278                         {                         200                         {
279                                 Package () { " !! 201                                 "byte-len", 1024,
280                                 Package () { " !! 202                                 "addr-mode", 2,
281                                 Package () { " !! 203                                 "page-size, 32
282                         }                      !! 204                         }, Local0)
283                 })                             !! 205 
284         }                                      !! 206                         // Check UUIDs etc.
                                                   >> 207 
                                                   >> 208                         Return (Local0)
                                                   >> 209                 }
                                                   >> 210 
                                                   >> 211 Then the at25 SPI driver can get this configuration by calling _DSM on its
                                                   >> 212 ACPI handle like::
285                                                   213 
286 Then the at25 SPI driver can get this configur !! 214         struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL };
287 APIs during ->probe() phase like::             !! 215         struct acpi_object_list input;
                                                   >> 216         acpi_status status;
288                                                   217 
289         err = device_property_read_u32(dev, "s !! 218         /* Fill in the input buffer */
290         if (err)                               !! 219 
291                 ...error handling...           !! 220         status = acpi_evaluate_object(ACPI_HANDLE(&spi->dev), "_DSM",
292                                                !! 221                                       &input, &output);
293         err = device_property_read_u32(dev, "p !! 222         if (ACPI_FAILURE(status))
294         if (err)                               !! 223                 /* Handle the error */
295                 ...error handling...           !! 224 
296                                                !! 225         /* Extract the data here */
297         err = device_property_read_u32(dev, "a !! 226 
298         if (err)                               !! 227         kfree(output.pointer);
299                 ...error handling...           << 
300                                                   228 
301 I2C serial bus support                            229 I2C serial bus support
302 ======================                            230 ======================
303                                                   231 
304 The slaves behind I2C bus controller only need    232 The slaves behind I2C bus controller only need to add the ACPI IDs like
305 with the platform and SPI drivers. The I2C cor    233 with the platform and SPI drivers. The I2C core automatically enumerates
306 any slave devices behind the controller device    234 any slave devices behind the controller device once the adapter is
307 registered.                                       235 registered.
308                                                   236 
309 Below is an example of how to add ACPI support    237 Below is an example of how to add ACPI support to the existing mpu3050
310 input driver::                                    238 input driver::
311                                                   239 
                                                   >> 240         #ifdef CONFIG_ACPI
312         static const struct acpi_device_id mpu    241         static const struct acpi_device_id mpu3050_acpi_match[] = {
313                 { "MPU3050", 0 },                 242                 { "MPU3050", 0 },
314                 { }                            !! 243                 { },
315         };                                        244         };
316         MODULE_DEVICE_TABLE(acpi, mpu3050_acpi    245         MODULE_DEVICE_TABLE(acpi, mpu3050_acpi_match);
                                                   >> 246         #endif
317                                                   247 
318         static struct i2c_driver mpu3050_i2c_d    248         static struct i2c_driver mpu3050_i2c_driver = {
319                 .driver = {                       249                 .driver = {
320                         .name   = "mpu3050",      250                         .name   = "mpu3050",
                                                   >> 251                         .owner  = THIS_MODULE,
321                         .pm     = &mpu3050_pm,    252                         .pm     = &mpu3050_pm,
322                         .of_match_table = mpu3    253                         .of_match_table = mpu3050_of_match,
323                         .acpi_match_table = mp !! 254                         .acpi_match_table = ACPI_PTR(mpu3050_acpi_match),
324                 },                                255                 },
325                 .probe          = mpu3050_prob    256                 .probe          = mpu3050_probe,
326                 .remove         = mpu3050_remo    257                 .remove         = mpu3050_remove,
327                 .id_table       = mpu3050_ids,    258                 .id_table       = mpu3050_ids,
328         };                                        259         };
329         module_i2c_driver(mpu3050_i2c_driver); << 
330                                                << 
331 Reference to PWM device                        << 
332 =======================                        << 
333                                                << 
334 Sometimes a device can be a consumer of PWM ch << 
335 to know which one. To provide this mapping the << 
336 introduced, i.e.::                             << 
337                                                << 
338     Device (DEV)                               << 
339     {                                          << 
340         Name (_DSD, Package ()                 << 
341         {                                      << 
342             ToUUID("daffd814-6eba-4d8c-8a91-bc << 
343             Package () {                       << 
344                 Package () { "compatible", Pac << 
345                 Package () { "label", "alarm-l << 
346                 Package () { "pwms",           << 
347                     Package () {               << 
348                         "\\_SB.PCI0.PWM",  //  << 
349                         0,                 //  << 
350                         600000000,         //  << 
351                         0,                 //  << 
352                     }                          << 
353                 }                              << 
354             }                                  << 
355         })                                     << 
356         ...                                    << 
357     }                                          << 
358                                                << 
359 In the above example the PWM-based LED driver  << 
360 of \_SB.PCI0.PWM device with initial period se << 
361 value is given in nanoseconds).                << 
362                                                   260 
363 GPIO support                                      261 GPIO support
364 ============                                      262 ============
365                                                   263 
366 ACPI 5 introduced two new resources to describ    264 ACPI 5 introduced two new resources to describe GPIO connections: GpioIo
367 and GpioInt. These resources can be used to pa    265 and GpioInt. These resources can be used to pass GPIO numbers used by
368 the device to the driver. ACPI 5.1 extended th    266 the device to the driver. ACPI 5.1 extended this with _DSD (Device
369 Specific Data) which made it possible to name     267 Specific Data) which made it possible to name the GPIOs among other things.
370                                                   268 
371 For example::                                     269 For example::
372                                                   270 
373         Device (DEV)                              271         Device (DEV)
374         {                                         272         {
375                 Method (_CRS, 0, NotSerialized    273                 Method (_CRS, 0, NotSerialized)
376                 {                                 274                 {
377                         Name (SBUF, ResourceTe    275                         Name (SBUF, ResourceTemplate()
378                         {                         276                         {
                                                   >> 277                                 ...
379                                 // Used to pow    278                                 // Used to power on/off the device
380                                 GpioIo (Exclus !! 279                                 GpioIo (Exclusive, PullDefault, 0x0000, 0x0000,
381                                         "\\_SB !! 280                                         IoRestrictionOutputOnly, "\\_SB.PCI0.GPI0",
                                                   >> 281                                         0x00, ResourceConsumer,,)
                                                   >> 282                                 {
                                                   >> 283                                         // Pin List
                                                   >> 284                                         0x0055
                                                   >> 285                                 }
382                                                   286 
383                                 // Interrupt f    287                                 // Interrupt for the device
384                                 GpioInt (Edge, !! 288                                 GpioInt (Edge, ActiveHigh, ExclusiveAndWake, PullNone,
385                                          "\\_S !! 289                                         0x0000, "\\_SB.PCI0.GPI0", 0x00, ResourceConsumer,,)
                                                   >> 290                                 {
                                                   >> 291                                         // Pin list
                                                   >> 292                                         0x0058
                                                   >> 293                                 }
                                                   >> 294 
                                                   >> 295                                 ...
                                                   >> 296 
386                         }                         297                         }
387                                                   298 
388                         Return (SBUF)             299                         Return (SBUF)
389                 }                                 300                 }
390                                                   301 
391                 // ACPI 5.1 _DSD used for nami    302                 // ACPI 5.1 _DSD used for naming the GPIOs
392                 Name (_DSD, Package ()            303                 Name (_DSD, Package ()
393                 {                                 304                 {
394                         ToUUID("daffd814-6eba-    305                         ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
395                         Package ()                306                         Package ()
396                         {                         307                         {
397                                 Package () { " !! 308                                 Package () {"power-gpios", Package() {^DEV, 0, 0, 0 }},
398                                 Package () { " !! 309                                 Package () {"irq-gpios", Package() {^DEV, 1, 0, 0 }},
399                         }                         310                         }
400                 })                                311                 })
401                 ...                               312                 ...
402         }                                      << 
403                                                   313 
404 These GPIO numbers are controller relative and    314 These GPIO numbers are controller relative and path "\\_SB.PCI0.GPI0"
405 specifies the path to the controller. In order    315 specifies the path to the controller. In order to use these GPIOs in Linux
406 we need to translate them to the corresponding    316 we need to translate them to the corresponding Linux GPIO descriptors.
407                                                   317 
408 There is a standard GPIO API for that and it i !! 318 There is a standard GPIO API for that and is documented in
409 Documentation/admin-guide/gpio/.                  319 Documentation/admin-guide/gpio/.
410                                                   320 
411 In the above example we can get the correspond    321 In the above example we can get the corresponding two GPIO descriptors with
412 a code like this::                                322 a code like this::
413                                                   323 
414         #include <linux/gpio/consumer.h>          324         #include <linux/gpio/consumer.h>
415         ...                                       325         ...
416                                                   326 
417         struct gpio_desc *irq_desc, *power_des    327         struct gpio_desc *irq_desc, *power_desc;
418                                                   328 
419         irq_desc = gpiod_get(dev, "irq");         329         irq_desc = gpiod_get(dev, "irq");
420         if (IS_ERR(irq_desc))                     330         if (IS_ERR(irq_desc))
421                 /* handle error */                331                 /* handle error */
422                                                   332 
423         power_desc = gpiod_get(dev, "power");     333         power_desc = gpiod_get(dev, "power");
424         if (IS_ERR(power_desc))                   334         if (IS_ERR(power_desc))
425                 /* handle error */                335                 /* handle error */
426                                                   336 
427         /* Now we can use the GPIO descriptors    337         /* Now we can use the GPIO descriptors */
428                                                   338 
429 There are also devm_* versions of these functi    339 There are also devm_* versions of these functions which release the
430 descriptors once the device is released.          340 descriptors once the device is released.
431                                                   341 
432 See Documentation/firmware-guide/acpi/gpio-pro !! 342 See Documentation/firmware-guide/acpi/gpio-properties.rst for more information about the
433 about the _DSD binding related to GPIOs.       !! 343 _DSD binding related to GPIOs.
434                                                << 
435 RS-485 support                                 << 
436 ==============                                 << 
437                                                << 
438 ACPI _DSD (Device Specific Data) can be used t << 
439 of UART.                                       << 
440                                                << 
441 For example::                                  << 
442                                                << 
443         Device (DEV)                           << 
444         {                                      << 
445                 ...                            << 
446                                                << 
447                 // ACPI 5.1 _DSD used for RS-4 << 
448                 Name (_DSD, Package ()         << 
449                 {                              << 
450                         ToUUID("daffd814-6eba- << 
451                         Package ()             << 
452                         {                      << 
453                                 Package () {"r << 
454                                 Package () {"r << 
455                                 Package () {"r << 
456                         }                      << 
457                 })                             << 
458                 ...                            << 
459                                                   344 
460 MFD devices                                       345 MFD devices
461 ===========                                       346 ===========
462                                                   347 
463 The MFD devices register their children as pla    348 The MFD devices register their children as platform devices. For the child
464 devices there needs to be an ACPI handle that     349 devices there needs to be an ACPI handle that they can use to reference
465 parts of the ACPI namespace that relate to the    350 parts of the ACPI namespace that relate to them. In the Linux MFD subsystem
466 we provide two ways:                              351 we provide two ways:
467                                                   352 
468   - The children share the parent ACPI handle.    353   - The children share the parent ACPI handle.
469   - The MFD cell can specify the ACPI id of th    354   - The MFD cell can specify the ACPI id of the device.
470                                                   355 
471 For the first case, the MFD drivers do not nee    356 For the first case, the MFD drivers do not need to do anything. The
472 resulting child platform device will have its     357 resulting child platform device will have its ACPI_COMPANION() set to point
473 to the parent device.                             358 to the parent device.
474                                                   359 
475 If the ACPI namespace has a device that we can    360 If the ACPI namespace has a device that we can match using an ACPI id or ACPI
476 adr, the cell should be set like::                361 adr, the cell should be set like::
477                                                   362 
478         static struct mfd_cell_acpi_match my_s    363         static struct mfd_cell_acpi_match my_subdevice_cell_acpi_match = {
479                 .pnpid = "XYZ0001",               364                 .pnpid = "XYZ0001",
480                 .adr = 0,                         365                 .adr = 0,
481         };                                        366         };
482                                                   367 
483         static struct mfd_cell my_subdevice_ce    368         static struct mfd_cell my_subdevice_cell = {
484                 .name = "my_subdevice",           369                 .name = "my_subdevice",
485                 /* set the resources relative     370                 /* set the resources relative to the parent */
486                 .acpi_match = &my_subdevice_ce    371                 .acpi_match = &my_subdevice_cell_acpi_match,
487         };                                        372         };
488                                                   373 
489 The ACPI id "XYZ0001" is then used to lookup a    374 The ACPI id "XYZ0001" is then used to lookup an ACPI device directly under
490 the MFD device and if found, that ACPI compani    375 the MFD device and if found, that ACPI companion device is bound to the
491 resulting child platform device.                  376 resulting child platform device.
492                                                   377 
493 Device Tree namespace link device ID              378 Device Tree namespace link device ID
494 ====================================              379 ====================================
495                                                   380 
496 The Device Tree protocol uses device identific    381 The Device Tree protocol uses device identification based on the "compatible"
497 property whose value is a string or an array o    382 property whose value is a string or an array of strings recognized as device
498 identifiers by drivers and the driver core.  T    383 identifiers by drivers and the driver core.  The set of all those strings may be
499 regarded as a device identification namespace     384 regarded as a device identification namespace analogous to the ACPI/PNP device
500 ID namespace.  Consequently, in principle it s    385 ID namespace.  Consequently, in principle it should not be necessary to allocate
501 a new (and arguably redundant) ACPI/PNP device    386 a new (and arguably redundant) ACPI/PNP device ID for a devices with an existing
502 identification string in the Device Tree (DT)     387 identification string in the Device Tree (DT) namespace, especially if that ID
503 is only needed to indicate that a given device    388 is only needed to indicate that a given device is compatible with another one,
504 presumably having a matching driver in the ker    389 presumably having a matching driver in the kernel already.
505                                                   390 
506 In ACPI, the device identification object call    391 In ACPI, the device identification object called _CID (Compatible ID) is used to
507 list the IDs of devices the given one is compa    392 list the IDs of devices the given one is compatible with, but those IDs must
508 belong to one of the namespaces prescribed by     393 belong to one of the namespaces prescribed by the ACPI specification (see
509 Section 6.1.2 of ACPI 6.0 for details) and the    394 Section 6.1.2 of ACPI 6.0 for details) and the DT namespace is not one of them.
510 Moreover, the specification mandates that eith    395 Moreover, the specification mandates that either a _HID or an _ADR identification
511 object be present for all ACPI objects represe    396 object be present for all ACPI objects representing devices (Section 6.1 of ACPI
512 6.0).  For non-enumerable bus types that objec    397 6.0).  For non-enumerable bus types that object must be _HID and its value must
513 be a device ID from one of the namespaces pres    398 be a device ID from one of the namespaces prescribed by the specification too.
514                                                   399 
515 The special DT namespace link device ID, PRP00    400 The special DT namespace link device ID, PRP0001, provides a means to use the
516 existing DT-compatible device identification i    401 existing DT-compatible device identification in ACPI and to satisfy the above
517 requirements following from the ACPI specifica    402 requirements following from the ACPI specification at the same time.  Namely,
518 if PRP0001 is returned by _HID, the ACPI subsy    403 if PRP0001 is returned by _HID, the ACPI subsystem will look for the
519 "compatible" property in the device object's _    404 "compatible" property in the device object's _DSD and will use the value of that
520 property to identify the corresponding device     405 property to identify the corresponding device in analogy with the original DT
521 device identification algorithm.  If the "comp    406 device identification algorithm.  If the "compatible" property is not present
522 or its value is not valid, the device will not    407 or its value is not valid, the device will not be enumerated by the ACPI
523 subsystem.  Otherwise, it will be enumerated a    408 subsystem.  Otherwise, it will be enumerated automatically as a platform device
524 (except when an I2C or SPI link from the devic    409 (except when an I2C or SPI link from the device to its parent is present, in
525 which case the ACPI core will leave the device    410 which case the ACPI core will leave the device enumeration to the parent's
526 driver) and the identification strings from th    411 driver) and the identification strings from the "compatible" property value will
527 be used to find a driver for the device along     412 be used to find a driver for the device along with the device IDs listed by _CID
528 (if present).                                     413 (if present).
529                                                   414 
530 Analogously, if PRP0001 is present in the list    415 Analogously, if PRP0001 is present in the list of device IDs returned by _CID,
531 the identification strings listed by the "comp    416 the identification strings listed by the "compatible" property value (if present
532 and valid) will be used to look for a driver m    417 and valid) will be used to look for a driver matching the device, but in that
533 case their relative priority with respect to t    418 case their relative priority with respect to the other device IDs listed by
534 _HID and _CID depends on the position of PRP00    419 _HID and _CID depends on the position of PRP0001 in the _CID return package.
535 Specifically, the device IDs returned by _HID     420 Specifically, the device IDs returned by _HID and preceding PRP0001 in the _CID
536 return package will be checked first.  Also in    421 return package will be checked first.  Also in that case the bus type the device
537 will be enumerated to depends on the device ID    422 will be enumerated to depends on the device ID returned by _HID.
538                                                   423 
539 For example, the following ACPI sample might b    424 For example, the following ACPI sample might be used to enumerate an lm75-type
540 I2C temperature sensor and match it to the dri    425 I2C temperature sensor and match it to the driver using the Device Tree
541 namespace link::                                  426 namespace link::
542                                                   427 
543         Device (TMP0)                             428         Device (TMP0)
544         {                                         429         {
545                 Name (_HID, "PRP0001")            430                 Name (_HID, "PRP0001")
546                 Name (_DSD, Package () {       !! 431                 Name (_DSD, Package() {
547                         ToUUID("daffd814-6eba-    432                         ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
548                         Package () {              433                         Package () {
549                                 Package () { " !! 434                                 Package (2) { "compatible", "ti,tmp75" },
550                         }                         435                         }
551                 })                                436                 })
552                 Method (_CRS, 0, Serialized)      437                 Method (_CRS, 0, Serialized)
553                 {                                 438                 {
554                         Name (SBUF, ResourceTe    439                         Name (SBUF, ResourceTemplate ()
555                         {                         440                         {
556                                 I2cSerialBusV2    441                                 I2cSerialBusV2 (0x48, ControllerInitiated,
557                                         400000    442                                         400000, AddressingMode7Bit,
558                                         "\\_SB    443                                         "\\_SB.PCI0.I2C1", 0x00,
559                                         Resour    444                                         ResourceConsumer, , Exclusive,)
560                         })                        445                         })
561                         Return (SBUF)             446                         Return (SBUF)
562                 }                                 447                 }
563         }                                         448         }
564                                                   449 
565 It is valid to define device objects with a _H    450 It is valid to define device objects with a _HID returning PRP0001 and without
566 the "compatible" property in the _DSD or a _CI    451 the "compatible" property in the _DSD or a _CID as long as one of their
567 ancestors provides a _DSD with a valid "compat    452 ancestors provides a _DSD with a valid "compatible" property.  Such device
568 objects are then simply regarded as additional    453 objects are then simply regarded as additional "blocks" providing hierarchical
569 configuration information to the driver of the    454 configuration information to the driver of the composite ancestor device.
570                                                   455 
571 However, PRP0001 can only be returned from eit    456 However, PRP0001 can only be returned from either _HID or _CID of a device
572 object if all of the properties returned by th    457 object if all of the properties returned by the _DSD associated with it (either
573 the _DSD of the device object itself or the _D    458 the _DSD of the device object itself or the _DSD of its ancestor in the
574 "composite device" case described above) can b    459 "composite device" case described above) can be used in the ACPI environment.
575 Otherwise, the _DSD itself is regarded as inva    460 Otherwise, the _DSD itself is regarded as invalid and therefore the "compatible"
576 property returned by it is meaningless.           461 property returned by it is meaningless.
577                                                   462 
578 Refer to Documentation/firmware-guide/acpi/DSD !! 463 Refer to :doc:`DSD-properties-rules` for more information.
579 information.                                   << 
580                                                   464 
581 PCI hierarchy representation                      465 PCI hierarchy representation
582 ============================                      466 ============================
583                                                   467 
584 Sometimes it could be useful to enumerate a PC !! 468 Sometimes could be useful to enumerate a PCI device, knowing its position on the
585 the PCI bus.                                   !! 469 PCI bus.
586                                                   470 
587 For example, some systems use PCI devices sold    471 For example, some systems use PCI devices soldered directly on the mother board,
588 in a fixed position (ethernet, Wi-Fi, serial p    472 in a fixed position (ethernet, Wi-Fi, serial ports, etc.). In this conditions it
589 is possible to refer to these PCI devices know    473 is possible to refer to these PCI devices knowing their position on the PCI bus
590 topology.                                         474 topology.
591                                                   475 
592 To identify a PCI device, a complete hierarchi    476 To identify a PCI device, a complete hierarchical description is required, from
593 the chipset root port to the final device, thr    477 the chipset root port to the final device, through all the intermediate
594 bridges/switches of the board.                    478 bridges/switches of the board.
595                                                   479 
596 For example, let's assume we have a system wit !! 480 For example, let us assume to have a system with a PCIe serial port, an
597 Exar XR17V3521, soldered on the main board. Th    481 Exar XR17V3521, soldered on the main board. This UART chip also includes
598 16 GPIOs and we want to add the property ``gpi !! 482 16 GPIOs and we want to add the property ``gpio-line-names`` [1] to these pins.
599 In this case, the ``lspci`` output for this co    483 In this case, the ``lspci`` output for this component is::
600                                                   484 
601         07:00.0 Serial controller: Exar Corp.     485         07:00.0 Serial controller: Exar Corp. XR17V3521 Dual PCIe UART (rev 03)
602                                                   486 
603 The complete ``lspci`` output (manually reduce    487 The complete ``lspci`` output (manually reduced in length) is::
604                                                   488 
605         00:00.0 Host bridge: Intel Corp... Hos    489         00:00.0 Host bridge: Intel Corp... Host Bridge (rev 0d)
606         ...                                       490         ...
607         00:13.0 PCI bridge: Intel Corp... PCI     491         00:13.0 PCI bridge: Intel Corp... PCI Express Port A #1 (rev fd)
608         00:13.1 PCI bridge: Intel Corp... PCI     492         00:13.1 PCI bridge: Intel Corp... PCI Express Port A #2 (rev fd)
609         00:13.2 PCI bridge: Intel Corp... PCI     493         00:13.2 PCI bridge: Intel Corp... PCI Express Port A #3 (rev fd)
610         00:14.0 PCI bridge: Intel Corp... PCI     494         00:14.0 PCI bridge: Intel Corp... PCI Express Port B #1 (rev fd)
611         00:14.1 PCI bridge: Intel Corp... PCI     495         00:14.1 PCI bridge: Intel Corp... PCI Express Port B #2 (rev fd)
612         ...                                       496         ...
613         05:00.0 PCI bridge: Pericom Semiconduc    497         05:00.0 PCI bridge: Pericom Semiconductor Device 2404 (rev 05)
614         06:01.0 PCI bridge: Pericom Semiconduc    498         06:01.0 PCI bridge: Pericom Semiconductor Device 2404 (rev 05)
615         06:02.0 PCI bridge: Pericom Semiconduc    499         06:02.0 PCI bridge: Pericom Semiconductor Device 2404 (rev 05)
616         06:03.0 PCI bridge: Pericom Semiconduc    500         06:03.0 PCI bridge: Pericom Semiconductor Device 2404 (rev 05)
617         07:00.0 Serial controller: Exar Corp.     501         07:00.0 Serial controller: Exar Corp. XR17V3521 Dual PCIe UART (rev 03) <-- Exar
618         ...                                       502         ...
619                                                   503 
620 The bus topology is::                             504 The bus topology is::
621                                                   505 
622         -[0000:00]-+-00.0                         506         -[0000:00]-+-00.0
623                    ...                            507                    ...
624                    +-13.0-[01]----00.0            508                    +-13.0-[01]----00.0
625                    +-13.1-[02]----00.0            509                    +-13.1-[02]----00.0
626                    +-13.2-[03]--                  510                    +-13.2-[03]--
627                    +-14.0-[04]----00.0            511                    +-14.0-[04]----00.0
628                    +-14.1-[05-09]----00.0-[06-    512                    +-14.1-[05-09]----00.0-[06-09]--+-01.0-[07]----00.0 <-- Exar
629                    |                              513                    |                               +-02.0-[08]----00.0
630                    |                              514                    |                               \-03.0-[09]--
631                    ...                            515                    ...
632                    \-1f.1                         516                    \-1f.1
633                                                   517 
634 To describe this Exar device on the PCI bus, w    518 To describe this Exar device on the PCI bus, we must start from the ACPI name
635 of the chipset bridge (also called "root port"    519 of the chipset bridge (also called "root port") with address::
636                                                   520 
637         Bus: 0 - Device: 14 - Function: 1         521         Bus: 0 - Device: 14 - Function: 1
638                                                   522 
639 To find this information, it is necessary to d !! 523 To find this information is necessary disassemble the BIOS ACPI tables, in
640 in particular the DSDT (see also [2]_)::       !! 524 particular the DSDT (see also [2])::
641                                                   525 
642         mkdir ~/tables/                           526         mkdir ~/tables/
643         cd ~/tables/                              527         cd ~/tables/
644         acpidump > acpidump                       528         acpidump > acpidump
645         acpixtract -a acpidump                    529         acpixtract -a acpidump
646         iasl -e ssdt?.* -d dsdt.dat               530         iasl -e ssdt?.* -d dsdt.dat
647                                                   531 
648 Now, in the dsdt.dsl, we have to search the de    532 Now, in the dsdt.dsl, we have to search the device whose address is related to
649 0x14 (device) and 0x01 (function). In this cas    533 0x14 (device) and 0x01 (function). In this case we can find the following
650 device::                                          534 device::
651                                                   535 
652         Scope (_SB.PCI0)                          536         Scope (_SB.PCI0)
653         {                                         537         {
654         ... other definitions follow ...          538         ... other definitions follow ...
655                 Device (RP02)                     539                 Device (RP02)
656                 {                                 540                 {
657                         Method (_ADR, 0, NotSe    541                         Method (_ADR, 0, NotSerialized)  // _ADR: Address
658                         {                         542                         {
659                                 If ((RPA2 != Z    543                                 If ((RPA2 != Zero))
660                                 {                 544                                 {
661                                         Return    545                                         Return (RPA2) /* \RPA2 */
662                                 }                 546                                 }
663                                 Else              547                                 Else
664                                 {                 548                                 {
665                                         Return    549                                         Return (0x00140001)
666                                 }                 550                                 }
667                         }                         551                         }
668         ... other definitions follow ...          552         ... other definitions follow ...
669                                                   553 
670 and the _ADR method [3]_ returns exactly the d !! 554 and the _ADR method [3] returns exactly the device/function couple that
671 we are looking for. With this information and     555 we are looking for. With this information and analyzing the above ``lspci``
672 output (both the devices list and the devices     556 output (both the devices list and the devices tree), we can write the following
673 ACPI description for the Exar PCIe UART, also     557 ACPI description for the Exar PCIe UART, also adding the list of its GPIO line
674 names::                                           558 names::
675                                                   559 
676         Scope (_SB.PCI0.RP02)                     560         Scope (_SB.PCI0.RP02)
677         {                                         561         {
678                 Device (BRG1) //Bridge            562                 Device (BRG1) //Bridge
679                 {                                 563                 {
680                         Name (_ADR, 0x0000)       564                         Name (_ADR, 0x0000)
681                                                   565 
682                         Device (BRG2) //Bridge    566                         Device (BRG2) //Bridge
683                         {                         567                         {
684                                 Name (_ADR, 0x    568                                 Name (_ADR, 0x00010000)
685                                                   569 
686                                 Device (EXAR)     570                                 Device (EXAR)
687                                 {                 571                                 {
688                                         Name (    572                                         Name (_ADR, 0x0000)
689                                                   573 
690                                         Name (    574                                         Name (_DSD, Package ()
691                                         {         575                                         {
692                                                   576                                                 ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
693                                                   577                                                 Package ()
694                                                   578                                                 {
695                                                   579                                                         Package ()
696                                                   580                                                         {
697                                                   581                                                                 "gpio-line-names",
698                                                   582                                                                 Package ()
699                                                   583                                                                 {
700                                                   584                                                                         "mode_232",
701                                                   585                                                                         "mode_422",
702                                                   586                                                                         "mode_485",
703                                                   587                                                                         "misc_1",
704                                                   588                                                                         "misc_2",
705                                                   589                                                                         "misc_3",
706                                                   590                                                                         "",
707                                                   591                                                                         "",
708                                                   592                                                                         "aux_1",
709                                                   593                                                                         "aux_2",
710                                                   594                                                                         "aux_3",
711                                                   595                                                                 }
712                                                   596                                                         }
713                                                   597                                                 }
714                                         })        598                                         })
715                                 }                 599                                 }
716                         }                         600                         }
717                 }                                 601                 }
718         }                                         602         }
719                                                   603 
720 The location "_SB.PCI0.RP02" is obtained by th    604 The location "_SB.PCI0.RP02" is obtained by the above investigation in the
721 dsdt.dsl table, whereas the device names "BRG1    605 dsdt.dsl table, whereas the device names "BRG1", "BRG2" and "EXAR" are
722 created analyzing the position of the Exar UAR    606 created analyzing the position of the Exar UART in the PCI bus topology.
723                                                   607 
724 References                                        608 References
725 ==========                                        609 ==========
726                                                   610 
727 .. [1] Documentation/firmware-guide/acpi/gpio- !! 611 [1] Documentation/firmware-guide/acpi/gpio-properties.rst
728                                                   612 
729 .. [2] Documentation/admin-guide/acpi/initrd_t !! 613 [2] Documentation/admin-guide/acpi/initrd_table_override.rst
730                                                   614 
731 .. [3] ACPI Specifications, Version 6.3 - Para !! 615 [3] ACPI Specifications, Version 6.3 - Paragraph 6.1.1 _ADR Address)
732     https://uefi.org/sites/default/files/resou    616     https://uefi.org/sites/default/files/resources/ACPI_6_3_May16.pdf,
733     referenced 2020-11-18                         617     referenced 2020-11-18
                                                      

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php