diff options
author | Changbin Du <changbin.du@gmail.com> | 2019-04-24 13:52:45 -0400 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2019-04-25 17:07:19 -0400 |
commit | c24bc66e8157ca4956b8be1ed62493d70dfdb547 (patch) | |
tree | 0e7230df081c81291f95fcda276475f529e1b7f6 | |
parent | 8a2fe04b446f909ffffadb84b886199edbe408c2 (diff) |
Documentation: ACPI: move enumeration.txt to firmware-guide/acpi and convert to reST
This converts the plain text documentation to reStructuredText format
and adds it to Sphinx TOC tree.
No essential content change.
Signed-off-by: Changbin Du <changbin.du@gmail.com>
Reviewed-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-rw-r--r-- | Documentation/firmware-guide/acpi/enumeration.rst (renamed from Documentation/acpi/enumeration.txt) | 135 | ||||
-rw-r--r-- | Documentation/firmware-guide/acpi/index.rst | 1 |
2 files changed, 74 insertions, 62 deletions
diff --git a/Documentation/acpi/enumeration.txt b/Documentation/firmware-guide/acpi/enumeration.rst index 1395b844649c..6b32b7be8c85 100644 --- a/Documentation/acpi/enumeration.txt +++ b/Documentation/firmware-guide/acpi/enumeration.rst | |||
@@ -1,5 +1,9 @@ | |||
1 | ACPI based device enumeration | 1 | .. SPDX-License-Identifier: GPL-2.0 |
2 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | 2 | |
3 | ============================= | ||
4 | ACPI Based Device Enumeration | ||
5 | ============================= | ||
6 | |||
3 | ACPI 5 introduced a set of new resources (UartTSerialBus, I2cSerialBus, | 7 | ACPI 5 introduced a set of new resources (UartTSerialBus, I2cSerialBus, |
4 | SpiSerialBus, GpioIo and GpioInt) which can be used in enumerating slave | 8 | SpiSerialBus, GpioIo and GpioInt) which can be used in enumerating slave |
5 | devices behind serial bus controllers. | 9 | devices behind serial bus controllers. |
@@ -11,12 +15,12 @@ that are accessed through memory-mapped registers. | |||
11 | In order to support this and re-use the existing drivers as much as | 15 | In order to support this and re-use the existing drivers as much as |
12 | possible we decided to do following: | 16 | possible we decided to do following: |
13 | 17 | ||
14 | o Devices that have no bus connector resource are represented as | 18 | - Devices that have no bus connector resource are represented as |
15 | platform devices. | 19 | platform devices. |
16 | 20 | ||
17 | o Devices behind real busses where there is a connector resource | 21 | - Devices behind real busses where there is a connector resource |
18 | are represented as struct spi_device or struct i2c_device | 22 | are represented as struct spi_device or struct i2c_device |
19 | (standard UARTs are not busses so there is no struct uart_device). | 23 | (standard UARTs are not busses so there is no struct uart_device). |
20 | 24 | ||
21 | As both ACPI and Device Tree represent a tree of devices (and their | 25 | As both ACPI and Device Tree represent a tree of devices (and their |
22 | resources) this implementation follows the Device Tree way as much as | 26 | resources) this implementation follows the Device Tree way as much as |
@@ -31,7 +35,8 @@ enumerated from ACPI namespace. This handle can be used to extract other | |||
31 | device-specific configuration. There is an example of this below. | 35 | device-specific configuration. There is an example of this below. |
32 | 36 | ||
33 | Platform bus support | 37 | Platform bus support |
34 | ~~~~~~~~~~~~~~~~~~~~ | 38 | ==================== |
39 | |||
35 | Since we are using platform devices to represent devices that are not | 40 | Since we are using platform devices to represent devices that are not |
36 | connected to any physical bus we only need to implement a platform driver | 41 | connected to any physical bus we only need to implement a platform driver |
37 | for the device and add supported ACPI IDs. If this same IP-block is used on | 42 | for the device and add supported ACPI IDs. If this same IP-block is used on |
@@ -39,7 +44,7 @@ some other non-ACPI platform, the driver might work out of the box or needs | |||
39 | some minor changes. | 44 | some minor changes. |
40 | 45 | ||
41 | Adding ACPI support for an existing driver should be pretty | 46 | Adding ACPI support for an existing driver should be pretty |
42 | straightforward. Here is the simplest example: | 47 | straightforward. Here is the simplest example:: |
43 | 48 | ||
44 | #ifdef CONFIG_ACPI | 49 | #ifdef CONFIG_ACPI |
45 | static const struct acpi_device_id mydrv_acpi_match[] = { | 50 | static const struct acpi_device_id mydrv_acpi_match[] = { |
@@ -61,12 +66,13 @@ configuring GPIOs it can get its ACPI handle and extract this information | |||
61 | from ACPI tables. | 66 | from ACPI tables. |
62 | 67 | ||
63 | DMA support | 68 | DMA support |
64 | ~~~~~~~~~~~ | 69 | =========== |
70 | |||
65 | DMA controllers enumerated via ACPI should be registered in the system to | 71 | DMA controllers enumerated via ACPI should be registered in the system to |
66 | provide generic access to their resources. For example, a driver that would | 72 | provide generic access to their resources. For example, a driver that would |
67 | like to be accessible to slave devices via generic API call | 73 | like to be accessible to slave devices via generic API call |
68 | dma_request_slave_channel() must register itself at the end of the probe | 74 | dma_request_slave_channel() must register itself at the end of the probe |
69 | function like this: | 75 | function like this:: |
70 | 76 | ||
71 | err = devm_acpi_dma_controller_register(dev, xlate_func, dw); | 77 | err = devm_acpi_dma_controller_register(dev, xlate_func, dw); |
72 | /* Handle the error if it's not a case of !CONFIG_ACPI */ | 78 | /* Handle the error if it's not a case of !CONFIG_ACPI */ |
@@ -74,7 +80,7 @@ function like this: | |||
74 | and implement custom xlate function if needed (usually acpi_dma_simple_xlate() | 80 | and implement custom xlate function if needed (usually acpi_dma_simple_xlate() |
75 | is enough) which converts the FixedDMA resource provided by struct | 81 | is enough) which converts the FixedDMA resource provided by struct |
76 | acpi_dma_spec into the corresponding DMA channel. A piece of code for that case | 82 | acpi_dma_spec into the corresponding DMA channel. A piece of code for that case |
77 | could look like: | 83 | could look like:: |
78 | 84 | ||
79 | #ifdef CONFIG_ACPI | 85 | #ifdef CONFIG_ACPI |
80 | struct filter_args { | 86 | struct filter_args { |
@@ -114,7 +120,7 @@ provided by struct acpi_dma. | |||
114 | Clients must call dma_request_slave_channel() with the string parameter that | 120 | Clients must call dma_request_slave_channel() with the string parameter that |
115 | corresponds to a specific FixedDMA resource. By default "tx" means the first | 121 | corresponds to a specific FixedDMA resource. By default "tx" means the first |
116 | entry of the FixedDMA resource array, "rx" means the second entry. The table | 122 | entry of the FixedDMA resource array, "rx" means the second entry. The table |
117 | below shows a layout: | 123 | below shows a layout:: |
118 | 124 | ||
119 | Device (I2C0) | 125 | Device (I2C0) |
120 | { | 126 | { |
@@ -138,12 +144,13 @@ acpi_dma_request_slave_chan_by_index() directly and therefore choose the | |||
138 | specific FixedDMA resource by its index. | 144 | specific FixedDMA resource by its index. |
139 | 145 | ||
140 | SPI serial bus support | 146 | SPI serial bus support |
141 | ~~~~~~~~~~~~~~~~~~~~~~ | 147 | ====================== |
148 | |||
142 | Slave devices behind SPI bus have SpiSerialBus resource attached to them. | 149 | Slave devices behind SPI bus have SpiSerialBus resource attached to them. |
143 | This is extracted automatically by the SPI core and the slave devices are | 150 | This is extracted automatically by the SPI core and the slave devices are |
144 | enumerated once spi_register_master() is called by the bus driver. | 151 | enumerated once spi_register_master() is called by the bus driver. |
145 | 152 | ||
146 | Here is what the ACPI namespace for a SPI slave might look like: | 153 | Here is what the ACPI namespace for a SPI slave might look like:: |
147 | 154 | ||
148 | Device (EEP0) | 155 | Device (EEP0) |
149 | { | 156 | { |
@@ -163,7 +170,7 @@ Here is what the ACPI namespace for a SPI slave might look like: | |||
163 | 170 | ||
164 | The SPI device drivers only need to add ACPI IDs in a similar way than with | 171 | The SPI device drivers only need to add ACPI IDs in a similar way than with |
165 | the platform device drivers. Below is an example where we add ACPI support | 172 | the platform device drivers. Below is an example where we add ACPI support |
166 | to at25 SPI eeprom driver (this is meant for the above ACPI snippet): | 173 | to at25 SPI eeprom driver (this is meant for the above ACPI snippet):: |
167 | 174 | ||
168 | #ifdef CONFIG_ACPI | 175 | #ifdef CONFIG_ACPI |
169 | static const struct acpi_device_id at25_acpi_match[] = { | 176 | static const struct acpi_device_id at25_acpi_match[] = { |
@@ -182,7 +189,7 @@ to at25 SPI eeprom driver (this is meant for the above ACPI snippet): | |||
182 | 189 | ||
183 | Note that this driver actually needs more information like page size of the | 190 | Note that this driver actually needs more information like page size of the |
184 | eeprom etc. but at the time writing this there is no standard way of | 191 | eeprom etc. but at the time writing this there is no standard way of |
185 | passing those. One idea is to return this in _DSM method like: | 192 | passing those. One idea is to return this in _DSM method like:: |
186 | 193 | ||
187 | Device (EEP0) | 194 | Device (EEP0) |
188 | { | 195 | { |
@@ -202,7 +209,7 @@ passing those. One idea is to return this in _DSM method like: | |||
202 | } | 209 | } |
203 | 210 | ||
204 | Then the at25 SPI driver can get this configuration by calling _DSM on its | 211 | Then the at25 SPI driver can get this configuration by calling _DSM on its |
205 | ACPI handle like: | 212 | ACPI handle like:: |
206 | 213 | ||
207 | struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL }; | 214 | struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL }; |
208 | struct acpi_object_list input; | 215 | struct acpi_object_list input; |
@@ -220,14 +227,15 @@ ACPI handle like: | |||
220 | kfree(output.pointer); | 227 | kfree(output.pointer); |
221 | 228 | ||
222 | I2C serial bus support | 229 | I2C serial bus support |
223 | ~~~~~~~~~~~~~~~~~~~~~~ | 230 | ====================== |
231 | |||
224 | The slaves behind I2C bus controller only need to add the ACPI IDs like | 232 | The slaves behind I2C bus controller only need to add the ACPI IDs like |
225 | with the platform and SPI drivers. The I2C core automatically enumerates | 233 | with the platform and SPI drivers. The I2C core automatically enumerates |
226 | any slave devices behind the controller device once the adapter is | 234 | any slave devices behind the controller device once the adapter is |
227 | registered. | 235 | registered. |
228 | 236 | ||
229 | Below is an example of how to add ACPI support to the existing mpu3050 | 237 | Below is an example of how to add ACPI support to the existing mpu3050 |
230 | input driver: | 238 | input driver:: |
231 | 239 | ||
232 | #ifdef CONFIG_ACPI | 240 | #ifdef CONFIG_ACPI |
233 | static const struct acpi_device_id mpu3050_acpi_match[] = { | 241 | static const struct acpi_device_id mpu3050_acpi_match[] = { |
@@ -251,56 +259,57 @@ input driver: | |||
251 | }; | 259 | }; |
252 | 260 | ||
253 | GPIO support | 261 | GPIO support |
254 | ~~~~~~~~~~~~ | 262 | ============ |
263 | |||
255 | ACPI 5 introduced two new resources to describe GPIO connections: GpioIo | 264 | ACPI 5 introduced two new resources to describe GPIO connections: GpioIo |
256 | and GpioInt. These resources can be used to pass GPIO numbers used by | 265 | and GpioInt. These resources can be used to pass GPIO numbers used by |
257 | the device to the driver. ACPI 5.1 extended this with _DSD (Device | 266 | the device to the driver. ACPI 5.1 extended this with _DSD (Device |
258 | Specific Data) which made it possible to name the GPIOs among other things. | 267 | Specific Data) which made it possible to name the GPIOs among other things. |
259 | 268 | ||
260 | For example: | 269 | For example:: |
261 | 270 | ||
262 | Device (DEV) | 271 | Device (DEV) |
263 | { | ||
264 | Method (_CRS, 0, NotSerialized) | ||
265 | { | 272 | { |
266 | Name (SBUF, ResourceTemplate() | 273 | Method (_CRS, 0, NotSerialized) |
267 | { | 274 | { |
268 | ... | 275 | Name (SBUF, ResourceTemplate() |
269 | // Used to power on/off the device | ||
270 | GpioIo (Exclusive, PullDefault, 0x0000, 0x0000, | ||
271 | IoRestrictionOutputOnly, "\\_SB.PCI0.GPI0", | ||
272 | 0x00, ResourceConsumer,,) | ||
273 | { | 276 | { |
274 | // Pin List | 277 | ... |
275 | 0x0055 | 278 | // Used to power on/off the device |
276 | } | 279 | GpioIo (Exclusive, PullDefault, 0x0000, 0x0000, |
280 | IoRestrictionOutputOnly, "\\_SB.PCI0.GPI0", | ||
281 | 0x00, ResourceConsumer,,) | ||
282 | { | ||
283 | // Pin List | ||
284 | 0x0055 | ||
285 | } | ||
286 | |||
287 | // Interrupt for the device | ||
288 | GpioInt (Edge, ActiveHigh, ExclusiveAndWake, PullNone, | ||
289 | 0x0000, "\\_SB.PCI0.GPI0", 0x00, ResourceConsumer,,) | ||
290 | { | ||
291 | // Pin list | ||
292 | 0x0058 | ||
293 | } | ||
294 | |||
295 | ... | ||
277 | 296 | ||
278 | // Interrupt for the device | ||
279 | GpioInt (Edge, ActiveHigh, ExclusiveAndWake, PullNone, | ||
280 | 0x0000, "\\_SB.PCI0.GPI0", 0x00, ResourceConsumer,,) | ||
281 | { | ||
282 | // Pin list | ||
283 | 0x0058 | ||
284 | } | 297 | } |
285 | 298 | ||
286 | ... | 299 | Return (SBUF) |
287 | |||
288 | } | 300 | } |
289 | 301 | ||
290 | Return (SBUF) | 302 | // ACPI 5.1 _DSD used for naming the GPIOs |
291 | } | 303 | Name (_DSD, Package () |
292 | |||
293 | // ACPI 5.1 _DSD used for naming the GPIOs | ||
294 | Name (_DSD, Package () | ||
295 | { | ||
296 | ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"), | ||
297 | Package () | ||
298 | { | 304 | { |
299 | Package () {"power-gpios", Package() {^DEV, 0, 0, 0 }}, | 305 | ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"), |
300 | Package () {"irq-gpios", Package() {^DEV, 1, 0, 0 }}, | 306 | Package () |
301 | } | 307 | { |
302 | }) | 308 | Package () {"power-gpios", Package() {^DEV, 0, 0, 0 }}, |
303 | ... | 309 | Package () {"irq-gpios", Package() {^DEV, 1, 0, 0 }}, |
310 | } | ||
311 | }) | ||
312 | ... | ||
304 | 313 | ||
305 | These GPIO numbers are controller relative and path "\\_SB.PCI0.GPI0" | 314 | These GPIO numbers are controller relative and path "\\_SB.PCI0.GPI0" |
306 | specifies the path to the controller. In order to use these GPIOs in Linux | 315 | specifies the path to the controller. In order to use these GPIOs in Linux |
@@ -310,7 +319,7 @@ There is a standard GPIO API for that and is documented in | |||
310 | Documentation/gpio/. | 319 | Documentation/gpio/. |
311 | 320 | ||
312 | In the above example we can get the corresponding two GPIO descriptors with | 321 | In the above example we can get the corresponding two GPIO descriptors with |
313 | a code like this: | 322 | a code like this:: |
314 | 323 | ||
315 | #include <linux/gpio/consumer.h> | 324 | #include <linux/gpio/consumer.h> |
316 | ... | 325 | ... |
@@ -334,21 +343,22 @@ See Documentation/acpi/gpio-properties.txt for more information about the | |||
334 | _DSD binding related to GPIOs. | 343 | _DSD binding related to GPIOs. |
335 | 344 | ||
336 | MFD devices | 345 | MFD devices |
337 | ~~~~~~~~~~~ | 346 | =========== |
347 | |||
338 | The MFD devices register their children as platform devices. For the child | 348 | The MFD devices register their children as platform devices. For the child |
339 | devices there needs to be an ACPI handle that they can use to reference | 349 | devices there needs to be an ACPI handle that they can use to reference |
340 | parts of the ACPI namespace that relate to them. In the Linux MFD subsystem | 350 | parts of the ACPI namespace that relate to them. In the Linux MFD subsystem |
341 | we provide two ways: | 351 | we provide two ways: |
342 | 352 | ||
343 | o The children share the parent ACPI handle. | 353 | - The children share the parent ACPI handle. |
344 | o The MFD cell can specify the ACPI id of the device. | 354 | - The MFD cell can specify the ACPI id of the device. |
345 | 355 | ||
346 | For the first case, the MFD drivers do not need to do anything. The | 356 | For the first case, the MFD drivers do not need to do anything. The |
347 | resulting child platform device will have its ACPI_COMPANION() set to point | 357 | resulting child platform device will have its ACPI_COMPANION() set to point |
348 | to the parent device. | 358 | to the parent device. |
349 | 359 | ||
350 | If the ACPI namespace has a device that we can match using an ACPI id or ACPI | 360 | If the ACPI namespace has a device that we can match using an ACPI id or ACPI |
351 | adr, the cell should be set like: | 361 | adr, the cell should be set like:: |
352 | 362 | ||
353 | static struct mfd_cell_acpi_match my_subdevice_cell_acpi_match = { | 363 | static struct mfd_cell_acpi_match my_subdevice_cell_acpi_match = { |
354 | .pnpid = "XYZ0001", | 364 | .pnpid = "XYZ0001", |
@@ -366,7 +376,8 @@ the MFD device and if found, that ACPI companion device is bound to the | |||
366 | resulting child platform device. | 376 | resulting child platform device. |
367 | 377 | ||
368 | Device Tree namespace link device ID | 378 | Device Tree namespace link device ID |
369 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | 379 | ==================================== |
380 | |||
370 | The Device Tree protocol uses device identification based on the "compatible" | 381 | The Device Tree protocol uses device identification based on the "compatible" |
371 | property whose value is a string or an array of strings recognized as device | 382 | property whose value is a string or an array of strings recognized as device |
372 | identifiers by drivers and the driver core. The set of all those strings may be | 383 | identifiers by drivers and the driver core. The set of all those strings may be |
@@ -449,4 +460,4 @@ the _DSD of the device object itself or the _DSD of its ancestor in the | |||
449 | Otherwise, the _DSD itself is regarded as invalid and therefore the "compatible" | 460 | Otherwise, the _DSD itself is regarded as invalid and therefore the "compatible" |
450 | property returned by it is meaningless. | 461 | property returned by it is meaningless. |
451 | 462 | ||
452 | Refer to DSD-properties-rules.txt for more information. | 463 | Refer to :doc:`DSD-properties-rules` for more information. |
diff --git a/Documentation/firmware-guide/acpi/index.rst b/Documentation/firmware-guide/acpi/index.rst index 210ad8acd6df..99677c73f1fb 100644 --- a/Documentation/firmware-guide/acpi/index.rst +++ b/Documentation/firmware-guide/acpi/index.rst | |||
@@ -8,3 +8,4 @@ ACPI Support | |||
8 | :maxdepth: 1 | 8 | :maxdepth: 1 |
9 | 9 | ||
10 | namespace | 10 | namespace |
11 | enumeration | ||