Beruflich Dokumente
Kultur Dokumente
Application Note
July 2018
No license (express or implied, by estoppel or otherwise) to any intellectual property rights is granted by this document.
All information provided here is subject to change without notice. Contact your Intel representative to obtain the latest Intel product
specifications and roadmaps.
The products described may contain design defects or errors known as errata, which may cause the product to deviate from published
specifications. Current characterized errata are available on request.
Copies of documents, which have an order number and are referenced in this document may be obtained by calling 1-800-548-4725 or by
visiting: http://www.intel.com/design/literature.htm
Intel technologies’ features and benefits depend on system configuration and may require enabled hardware, software, or service activation. Learn
more at h ttp://www.intel.com/ or from the OEM or retailer.
Intel and the Intel logo are trademarks of Intel Corporation in the U.S. and/or other countries.
ACPI Enumeration
Application Note July 2018
2 Document Number: 598506-0.5
Contents
1.0 Introduction ...............................................................................................................................................................5
2.0 Create the Device ACPI Table..................................................................................................................................6
2.1 Definition Block .............................................................................................................................................6
2.2 External and Scope .......................................................................................................................................6
2.3 Device Definition ...........................................................................................................................................8
2.3.1 _CRS: Current Resource Settings ................................................................................................8
2.3.2 _DSD: Device Specific Data ....................................................................................................... 10
3.0 Create the Device Driver ....................................................................................................................................... 11
3.1 Create and Register a SPI Driver ............................................................................................................. 11
3.2 Access the Device Resources from the Probe Function ..................................................................... 11
4.0 Verification Tips ...................................................................................................................................................... 13
ACPI Enumeration
July 2018 Application Note
Document Number: 598506-0.5 3
Revision History
Terminology
Term Descripti
on
ACPI Advanced Configuration and Power Interface
_ADR Address
_CID Compatible ID
_HID Hardware ID
Relevant Documents
Document Description
ACPI Enumeration
Application Note July 2018
4 Document Number: 598506-0.5
1.0 Introduction
This Application Note walks through the ACPI 5.1 (Advanced Configuration and Power
Interface) specification and the basics of the Linux driver ACPI enumeration and
property access. The Linux driver section is taken from the Linux Kernel ACPI
Enumeration documentation.
This document walks through the details of defining the JMM device that is connected
to a non-enumerable bus. In example used in this document, the JMM device is
connected to the third SPI (Serial Peripheral Interface) bus connected to the root PCI
bus. This example can easily be translated to other non-enumerable buses like I2C
(Inter-Integrated Circuit).
The purpose of this document is to walk through the documentation and create a
working ACPI table and Linux driver. This document does not go into detail. Instead, it
provide links to publicly available documentation that the reader should visit.
This document includes two additional files (see the PDF reader attachment menu):
• JMM00001.asl – The working example of the SSDT ACPI table
• jmm.c – The working example of a SPI driver, which supports the JMM device.
ACPI Enumeration
July 2018 Application Note
Document Number: 598506-0.5 5
2.0 Create the Device ACPI Table
This section walks through the different parts of the JMM0001.asl file.
The JMM example device is connected to the third SPI bus connected to the root PCI
bus. Usually the root PCI bus is named PCI0 and its parent is _SB (System Bus).
Consult the DSDT ACPI table of the system to verify what is the right path to the non-
enumerable bus on which the device is connected. For instance, on an Intel Apollo
Lake SoC:
Listing 2. Decompile the DSDT Table
# Generate the DSDT.dsl file
▶ iasl -d /sys/firmware/acpi/tables/DSDT
ACPI Enumeration
Application Note July 2018
6 Document Number: 598506-0.5
Listing 3. Extract from the Apollo Lake DSDT.dsl
[...]
Scope (\_SB.PCI0)
{
[...]
Device (SPI3)
{
Name (_ADR, 0x00190002)
Name (_DDN, "Intel(R) SPI Controller #3")
Name (_UID, 0x03)
Name (RBUF, ResourceTemplate ()
{
})
Method (_CRS, 0, NotSerialized)
{
Return (RBUF)
}
}
[...]
Device(SPI3) is an SPI controller within APL SoC with PCI bus 0, device number
0x19, and function number 2. The Linux kernel links this device namespace to the
actual PCI device 19.2 at PCI enumeration.
Listing 4. ACPI Namespace Tree with the JMM Device
ACPI Enumeration
July 2018 Application Note
Document Number: 598506-0.5 7
Listing 5. ACPI Namespace Tree with the JMM Device External and Scope Example
[...]
External (\_SB.PCI0.SPI3, DeviceObj)
Scope (\_SB.PCI0.SPI3)
{
[...]
}
[...]
The _CRS Method is either an object that specifies the device's current resource
settings, or a control method that generates such an object. The purpose of this
method is to return a list of hardware resources used by the driver.
In our example, this is a control method that returns a ResourceTemplate object
containing two GpioIo objects, and a SPISerialBus object. See acpi/enumeration.txt
Linux Kernel Documentation for more details. For GPIO meant to be used as interrupt,
see GpioInt and gpio/consumer.txt - GPIOs mapped to IRQs.
ACPI Enumeration
Application Note July 2018
8 Document Number: 598506-0.5
Listing 7. JMM Device _CRS Example Method
[...]
Method (_CRS, 0, Serialized)
{
Name (RBUF, ResourceTemplate ()
{
/* GPIO 24 of the North Community. */
GpioIo (Exclusive, PullDown, 0, 0,
IoRestrictionOutputOnly,
"\\_SB.GPO0", 0, ResourceConsumer)
{
24
}
/* GPIO 74 of the Northwest Community. */
GpioIo (Exclusive, PullDown, 0, 0,
IoRestrictionOutputOnly,
"\\_SB.GPO1", 0, ResourceConsumer)
{
74
}
SpiSerialBus (0x0000, PolarityLow, FourWireMode, 0x08,
ControllerInitiated, 0x000F4240,
ClockPolarityLow, ClockPhaseFirst,
"\\_SB.PCI0.SPI3", 0x00, ResourceConsumer)
})
Return (RBUF)
}
[...]
Consult the DSDT ACPI table of the system to verify the correct ACPI namespace path
for the GPIO community of the GPIO wired to the device. For example, the following
extract shows that the Northwest community GPIO ACPI namespace path is
_SB.GPO1.
Listing 8. Extract from the Apollo Lake DSDT.dsl
[...]
Scope (_SB)
{
[...]
Device (GPO1)
{
Name (_ADR, Zero)
Name (_HID, "INT3452")
Name (_CID, "INT3452")
Name (_DDN, "General Purpose Input/Output (GPIO) Controller -
Northwest")
Name (_UID, 0x02)
[...]
ACPI Enumeration
July 2018 Application Note
Document Number: 598506-0.5 9
2.3.2 _DSD: Device Specific Data
The _DSD (Device Specific Data) is a variable length Package of "Device Data
Descriptor". A "Device Data Descriptor" consists of a UUID and a variable length
Package of Data Structure. The daffd814-6eba-4d8c-8a91-bc9bbf4aa301 UUID is
used to identify Device Properties, which consist of:
1. A key, which should a unique string
2. A value associated with that key
Note:
1. The GPIO name should be suffixed with -gpio in the ACPI table. From the driver side,
gpiod_get() like functions use the name of the GPIO without the -gpio suffix.
2. The format of the supported GPIO property is:
Package () { "name", Package () { ref, index, pin, active_low }}
ACPI Enumeration
Application Note July 2018
10 Document Number: 598506-0.5
3.0 Create the Device Driver
This section walks through the attached example jmm.c.
Then declare our driver "hook" data structure where we bind altogether the name of
our driver, the array of supported IDs, and the probe and the remove functions,
which are called by the Linux kernel when a matching device is found or when a
matching device is removed from the system.
Listing 10. Driver Declaration for "JMM00001" Devices
static const struct acpi_device_id jmm_acpi_ids[] = {
{ "JMM00001", 0 }
};
MODULE_DEVICE_TABLE(acpi, jmm_acpi_ids);
module_spi_driver(jmm_driver);
As an example, the following function is accessing the data provided by the _DSD
object:
1. The power and reset gpios
2. The int property as a uint32_t
3. The string property as a char *
4. The array_of_int property as a uint32_t []
ACPI Enumeration
July 2018 Application Note
Document Number: 598506-0.5 11
Listing 11. GPIO and Properties
return 0;
}
ACPI Enumeration
Application Note July 2018
12 Document Number: 598506-0.5
4.0 Verification Tips
The Linux sysfs is a great source of information regarding device enumeration drivers.
Listing 12. Device Is Enumerated Through ACPI
▶ ls /sys/bus/acpi/devices/ | grep JMM
JMM00001:00
Listing 15. The pxa2xx spi Master and jmm Driver Are Linked
▶ find /sys/devices/pci0000:00 -name *JMM*
/sys/devices/pci0000:00/0000:00:19.2/pxa2xx-spi.5/spi_master/spi3/spi-
JMM00001:00
ACPI Enumeration
July 2018 Application Note
Document Number: 598506-0.5 13