aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChangbin Du <changbin.du@gmail.com>2019-04-24 13:52:45 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2019-04-25 17:07:19 -0400
commitc24bc66e8157ca4956b8be1ed62493d70dfdb547 (patch)
tree0e7230df081c81291f95fcda276475f529e1b7f6
parent8a2fe04b446f909ffffadb84b886199edbe408c2 (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.rst1
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 @@
1ACPI based device enumeration 1.. SPDX-License-Identifier: GPL-2.0
2~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2
3=============================
4ACPI Based Device Enumeration
5=============================
6
3ACPI 5 introduced a set of new resources (UartTSerialBus, I2cSerialBus, 7ACPI 5 introduced a set of new resources (UartTSerialBus, I2cSerialBus,
4SpiSerialBus, GpioIo and GpioInt) which can be used in enumerating slave 8SpiSerialBus, GpioIo and GpioInt) which can be used in enumerating slave
5devices behind serial bus controllers. 9devices behind serial bus controllers.
@@ -11,12 +15,12 @@ that are accessed through memory-mapped registers.
11In order to support this and re-use the existing drivers as much as 15In order to support this and re-use the existing drivers as much as
12possible we decided to do following: 16possible 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
21As both ACPI and Device Tree represent a tree of devices (and their 25As both ACPI and Device Tree represent a tree of devices (and their
22resources) this implementation follows the Device Tree way as much as 26resources) 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
31device-specific configuration. There is an example of this below. 35device-specific configuration. There is an example of this below.
32 36
33Platform bus support 37Platform bus support
34~~~~~~~~~~~~~~~~~~~~ 38====================
39
35Since we are using platform devices to represent devices that are not 40Since we are using platform devices to represent devices that are not
36connected to any physical bus we only need to implement a platform driver 41connected to any physical bus we only need to implement a platform driver
37for the device and add supported ACPI IDs. If this same IP-block is used on 42for 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
39some minor changes. 44some minor changes.
40 45
41Adding ACPI support for an existing driver should be pretty 46Adding ACPI support for an existing driver should be pretty
42straightforward. Here is the simplest example: 47straightforward. 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
61from ACPI tables. 66from ACPI tables.
62 67
63DMA support 68DMA support
64~~~~~~~~~~~ 69===========
70
65DMA controllers enumerated via ACPI should be registered in the system to 71DMA controllers enumerated via ACPI should be registered in the system to
66provide generic access to their resources. For example, a driver that would 72provide generic access to their resources. For example, a driver that would
67like to be accessible to slave devices via generic API call 73like to be accessible to slave devices via generic API call
68dma_request_slave_channel() must register itself at the end of the probe 74dma_request_slave_channel() must register itself at the end of the probe
69function like this: 75function 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:
74and implement custom xlate function if needed (usually acpi_dma_simple_xlate() 80and implement custom xlate function if needed (usually acpi_dma_simple_xlate()
75is enough) which converts the FixedDMA resource provided by struct 81is enough) which converts the FixedDMA resource provided by struct
76acpi_dma_spec into the corresponding DMA channel. A piece of code for that case 82acpi_dma_spec into the corresponding DMA channel. A piece of code for that case
77could look like: 83could 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.
114Clients must call dma_request_slave_channel() with the string parameter that 120Clients must call dma_request_slave_channel() with the string parameter that
115corresponds to a specific FixedDMA resource. By default "tx" means the first 121corresponds to a specific FixedDMA resource. By default "tx" means the first
116entry of the FixedDMA resource array, "rx" means the second entry. The table 122entry of the FixedDMA resource array, "rx" means the second entry. The table
117below shows a layout: 123below 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
138specific FixedDMA resource by its index. 144specific FixedDMA resource by its index.
139 145
140SPI serial bus support 146SPI serial bus support
141~~~~~~~~~~~~~~~~~~~~~~ 147======================
148
142Slave devices behind SPI bus have SpiSerialBus resource attached to them. 149Slave devices behind SPI bus have SpiSerialBus resource attached to them.
143This is extracted automatically by the SPI core and the slave devices are 150This is extracted automatically by the SPI core and the slave devices are
144enumerated once spi_register_master() is called by the bus driver. 151enumerated once spi_register_master() is called by the bus driver.
145 152
146Here is what the ACPI namespace for a SPI slave might look like: 153Here 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
164The SPI device drivers only need to add ACPI IDs in a similar way than with 171The SPI device drivers only need to add ACPI IDs in a similar way than with
165the platform device drivers. Below is an example where we add ACPI support 172the platform device drivers. Below is an example where we add ACPI support
166to at25 SPI eeprom driver (this is meant for the above ACPI snippet): 173to 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
183Note that this driver actually needs more information like page size of the 190Note that this driver actually needs more information like page size of the
184eeprom etc. but at the time writing this there is no standard way of 191eeprom etc. but at the time writing this there is no standard way of
185passing those. One idea is to return this in _DSM method like: 192passing 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
204Then the at25 SPI driver can get this configuration by calling _DSM on its 211Then the at25 SPI driver can get this configuration by calling _DSM on its
205ACPI handle like: 212ACPI 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
222I2C serial bus support 229I2C serial bus support
223~~~~~~~~~~~~~~~~~~~~~~ 230======================
231
224The slaves behind I2C bus controller only need to add the ACPI IDs like 232The slaves behind I2C bus controller only need to add the ACPI IDs like
225with the platform and SPI drivers. The I2C core automatically enumerates 233with the platform and SPI drivers. The I2C core automatically enumerates
226any slave devices behind the controller device once the adapter is 234any slave devices behind the controller device once the adapter is
227registered. 235registered.
228 236
229Below is an example of how to add ACPI support to the existing mpu3050 237Below is an example of how to add ACPI support to the existing mpu3050
230input driver: 238input 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
253GPIO support 261GPIO support
254~~~~~~~~~~~~ 262============
263
255ACPI 5 introduced two new resources to describe GPIO connections: GpioIo 264ACPI 5 introduced two new resources to describe GPIO connections: GpioIo
256and GpioInt. These resources can be used to pass GPIO numbers used by 265and GpioInt. These resources can be used to pass GPIO numbers used by
257the device to the driver. ACPI 5.1 extended this with _DSD (Device 266the device to the driver. ACPI 5.1 extended this with _DSD (Device
258Specific Data) which made it possible to name the GPIOs among other things. 267Specific Data) which made it possible to name the GPIOs among other things.
259 268
260For example: 269For example::
261 270
262Device (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
305These GPIO numbers are controller relative and path "\\_SB.PCI0.GPI0" 314These GPIO numbers are controller relative and path "\\_SB.PCI0.GPI0"
306specifies the path to the controller. In order to use these GPIOs in Linux 315specifies 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
310Documentation/gpio/. 319Documentation/gpio/.
311 320
312In the above example we can get the corresponding two GPIO descriptors with 321In the above example we can get the corresponding two GPIO descriptors with
313a code like this: 322a 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
336MFD devices 345MFD devices
337~~~~~~~~~~~ 346===========
347
338The MFD devices register their children as platform devices. For the child 348The MFD devices register their children as platform devices. For the child
339devices there needs to be an ACPI handle that they can use to reference 349devices there needs to be an ACPI handle that they can use to reference
340parts of the ACPI namespace that relate to them. In the Linux MFD subsystem 350parts of the ACPI namespace that relate to them. In the Linux MFD subsystem
341we provide two ways: 351we 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
346For the first case, the MFD drivers do not need to do anything. The 356For the first case, the MFD drivers do not need to do anything. The
347resulting child platform device will have its ACPI_COMPANION() set to point 357resulting child platform device will have its ACPI_COMPANION() set to point
348to the parent device. 358to the parent device.
349 359
350If the ACPI namespace has a device that we can match using an ACPI id or ACPI 360If the ACPI namespace has a device that we can match using an ACPI id or ACPI
351adr, the cell should be set like: 361adr, 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
366resulting child platform device. 376resulting child platform device.
367 377
368Device Tree namespace link device ID 378Device Tree namespace link device ID
369~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 379====================================
380
370The Device Tree protocol uses device identification based on the "compatible" 381The Device Tree protocol uses device identification based on the "compatible"
371property whose value is a string or an array of strings recognized as device 382property whose value is a string or an array of strings recognized as device
372identifiers by drivers and the driver core. The set of all those strings may be 383identifiers 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
449Otherwise, the _DSD itself is regarded as invalid and therefore the "compatible" 460Otherwise, the _DSD itself is regarded as invalid and therefore the "compatible"
450property returned by it is meaningless. 461property returned by it is meaningless.
451 462
452Refer to DSD-properties-rules.txt for more information. 463Refer 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