acpi overlays for embedded devices

26
ACPI overlays for embedded devices Andy Shevchenko <[email protected]> September 10th, 2021.

Upload: others

Post on 02-May-2022

23 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: ACPI overlays for embedded devices

ACPI overlays for embedded devicesAndy Shevchenko <[email protected]>

September 10th, 2021.

Page 2: ACPI overlays for embedded devices

2

Agenda

Introduction to ACPI

Concept of SSDT

SSDT overlays

Demo Resources Q&A

Page 3: ACPI overlays for embedded devices

Introduction to ACPIQuick introduction to ACPI

3

Page 4: ACPI overlays for embedded devices

4

Introduction to ACPI: What is this for?

Advanced Configuration and Power Interface– Platform independent way to suspend and resume the devices and entire system– Interface, agnostic to power management hardware– Common way to discover and configure platform devices

Evolving along with the corresponding power management hardware– Handling hot plug for traditional buses like PCI (v1.0)– Handling hardware reduced platforms like EC-less (v5.0)

Direction towards SoC– Improvement in device discovery and configuration (I²C, SPI, …) (v5.0)– Support arbitrary device properties (v5.1)– Pin control and configuration (v6.2)

Page 5: ACPI overlays for embedded devices

Introduction to ACPI: Interaction with system hardware

5

Page 6: ACPI overlays for embedded devices

Introduction to ACPI: From ASL to AML

6

Page 7: ACPI overlays for embedded devices

Introduction to ACPI: Example of ASL and AML

Device (GPO1) {

Name (_HID, "PRP0001") Name (_DDN, "74X164 8-bits shift register GPIO expander")

Name (_CRS, ResourceTemplate () { SpiSerialBus ( 1, // Chip select PolarityLow, // Chip select is active low FourWireMode, // Full duplex 8, // Bits per word is 8 (byte) ControllerInitiated, // Don't care 1000000, // 1 MHz ClockPolarityLow, // SPI mode 0 ClockPhaseFirst, // SPI mode 0 "\\_SB.PCI0.SPI5", // SPI host controller 0 // Must be 0 ) })

/* * See Documentation/devicetree/bindings/gpio/gpio-74x164.txt * for more information about these bindings. */ Name (_DSD, Package () { ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"), Package () { Package () { "compatible", Package () { "fairchild,74hc595" } }, Package () { "registers-number", 1 }, } })

}

0000 53 53 44 54 1c 01 00 00 05 48 00 00 SSDT.....H..000c 00 00 00 00 37 34 58 31 36 34 00 00 ....74X164..0018 01 00 00 00 49 4e 54 4c 03 07 19 20 ....INTL... 0024 a0 14 00 15 5c 2f 03 5f 53 42 5f 50 ....\/._SB_P0030 43 49 30 53 50 49 35 06 00 10 42 0e CI0SPI5...B.003c 5c 2f 03 5f 53 42 5f 50 43 49 30 53 \/._SB_PCI0S0048 50 49 35 5b 82 4f 0c 47 50 4f 31 08 PI5[.O.GPO1.0054 5f 48 49 44 0d 50 52 50 30 30 30 31 _HID.PRP00010060 00 08 5f 44 44 4e 0d 37 34 58 31 36 .._DDN.74X16006c 34 20 38 2d 62 69 74 73 20 73 68 69 4 8-bits shi0078 66 74 20 72 65 67 69 73 74 65 72 20 ft register 0084 47 50 49 4f 20 65 78 70 61 6e 64 65 GPIO expande0090 72 00 08 5f 43 52 53 11 29 0a 26 8e r.._CRS.).&.009c 21 00 01 00 02 02 00 00 01 09 00 40 !..........@00a8 42 0f 00 08 00 00 01 00 5c 5f 53 42 B.......\_SB00b4 2e 50 43 49 30 2e 53 50 49 35 00 79 .PCI0.SPI5.y00c0 00 08 5f 44 53 44 12 45 05 02 11 13 .._DSD.E....00cc 0a 10 14 d8 ff da ba 6e 8c 4d 8a 91 .......n.M..00d8 bc 9b bf 4a a3 01 12 3d 02 12 24 02 ...J...=..$.00e4 0d 63 6f 6d 70 61 74 69 62 6c 65 00 .compatible.00f0 12 15 01 0d 66 61 69 72 63 68 69 6c ....fairchil00fc 64 2c 37 34 68 63 35 39 35 00 12 15 d,74hc595...0108 02 0d 72 65 67 69 73 74 65 72 73 2d ..registers-0114 6e 75 6d 62 65 72 00 01 number..

7

Page 8: ACPI overlays for embedded devices

Introduction to ACPI: Comparison to Device Tree

8

ASL (ACPI Source Language)

AML (ACPI Machine Language)

ACPI Tables

ACPI Definition Blocks

ACPI Namespace

ACPI Objects

Device Description Data

DTS (Device Tree Source)

DTB (Device Tree Blob)

Device Tree

Device Nodes

Device Description Data

Page 9: ACPI overlays for embedded devices

Introduction to ACPI: Creating the ACPI namespace at OS boot-time

9

Page 10: ACPI overlays for embedded devices

Concept of SSDTWhat SSDT is and how it allows to adjust the ACPI namespace at boot- and run-time

10

Page 11: ACPI overlays for embedded devices

11

Concept of SSDT: The idea behind

Rationale– Allows to split table to the base support and smaller system options

Features– DSDT may become static across the platforms– Firmware can construct the dynamic information on per platform basis

Limitations– Can rely only on the previously loaded information (DSDT, SSDTs)– Additional tables can only add data

Caveats– The data can be added to anywhere in the ACPI namespace

Page 12: ACPI overlays for embedded devices

12

Concept of SSDT: Support in the Linux kernel

Multiple SSDT – OS loads them in order– Maximum of 64 additional tables (initramfs)

Sources of the tables– Firmware (ACPI compatible firmware, usually known as BIOS on x86)– Boot loader (U-Boot, Coreboot, ...)

– Trailer of initramfs (CONFIG_ACPI_INITRD_TABLE_OVERRIDE, prior v4.7)– Trailer of initramfs (CONFIG_ACPI_TABLE_UPGRADE, v4.7 onward)– EFI variable (CONFIG_ACPI, v4.8 .. v5.7)– EFI variable (CONFIG_EFI_CUSTOM_SSDT_OVERLAYS, v5.8 onward)– ConfigFS (CONFIG_ACPI_CONFIGFS, v4.8 onward)

Page 13: ACPI overlays for embedded devices

SSDT overlaysCreating an SSDT overlay step-by-step

13

Page 14: ACPI overlays for embedded devices

SSDT overlays: ASL example for Solomon SSD1306 OLED display (SPI resource)

SpiSerialBus ( 1, // Chip select PolarityLow, // Chip select is active low FourWireMode, // Full duplex 8, // Bits per word is 8 (byte) ControllerInitiated, // Don't care 16000000, // 16 MHz ClockPolarityLow, // SPI mode 0 ClockPhaseFirst, // SPI mode 0 "\\_SB.PCI0.SPI5", // SPI host controller 0 // Must be 0 )

14

Page 15: ACPI overlays for embedded devices

SSDT overlays: ASL example for Solomon SSD1306 OLED display (GPIO resources)

GpioIo(Exclusive, PullNone, 0, 0, IoRestrictionOutputOnly, "\\_SB.PCI0.GPIO", 0, ResourceConsumer, , ) { 14 // Pin for Data/Command }

GpioIo(Exclusive, PullUp, 0, 0, IoRestrictionOutputOnly, "\\_SB.PCI0.GPIO", 0, ResourceConsumer, , ) { 15 // Pin for Reset }

15

Page 16: ACPI overlays for embedded devices

SSDT overlays: ASL example for Solomon SSD1306 OLED display (device properties)

Name (_DSD, Package () { ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),

Package () { Package () { "compatible", Package () { "solomon,ssd1306" } }, Package () { "dc-gpios", Package () { ^OLED, 0, 0, 0 } }, Package () { "reset-gpios", Package () { ^OLED, 1, 0, 1 } }, Package () { "width", 64 }, Package () { "height", 48 }, Package () { "buswidth", 8 }, } })

16

Page 17: ACPI overlays for embedded devices

SSDT overlays: ASL example for Solomon SSD1306 OLED display (Device object)

Device (OLED) { Name (_HID, "PRP0001") Name (_DDN, "Solomon SSD1306 OLED display")

Name (_CRS, ResourceTemplate () { ...SPI and GPIO resources... })

Name (_DSD, Package () { ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"), Package () { ...device properties... } }) }

17

Page 18: ACPI overlays for embedded devices

SSDT overlays: ASL example for Solomon SSD1306 OLED display (complete SSDT)

DefinitionBlock ("ssd1306.aml", "SSDT", 5, "", "SSD1306", 1) { External (\_SB.PCI0.SPI5, DeviceObj)

Scope (\_SB.PCI0.SPI5) { Device (OLED) {

...device object...

} } }

18

Page 19: ACPI overlays for embedded devices

SSDT overlays: Boot-time initramfs approach

# Compile ASL to create an AML blob$ iasl -p kernel/firmware/acpi/ssd1306 ssd1306.asl

Intel ACPI Component ArchitectureASL+ Optimizing Compiler/Disassembler version 20200925Copyright (c) 2000 - 2020 Intel Corporation

ASL Input: ssd1306.asl - 1358 bytes 19 keywords 33 source linesAML Output: ssd1306.aml - 1700 bytes 0 opcodes 19 named objects

Compilation successful. 0 Errors, 0 Warnings, 0 Remarks, 34 Optimizations

# Archive the blob without any compression$ find kernel | cpio -H newc --create > /boot/initrd+acpi

# Attach initramfs to previously created archive$ cat /boot/initrd >> /boot/initrd+acpi

19

Page 20: ACPI overlays for embedded devices

SSDT overlays: Run-time ConfigFS approach (performing by root on the target system)

# Mount ConfigFS$ mount -t configfs none /sys/kernel/config

# Load ACPI ConfigFS support (if it’s a module)$ modprobe acpi-configfs

# Allocate a new SSDT$ mkdir /sys/kernel/config/acpi/table/ssd1306

# Assume we have ssd1306.aml on our root file system$ cat "$1" > "/sys/kernel/config/acpi/table/ssd1306/aml"

20

Page 21: ACPI overlays for embedded devices

DemoDemo slides

21

Page 22: ACPI overlays for embedded devices

ResourcesUseful resources to continue with

22

Page 23: ACPI overlays for embedded devices

23

Resource links

ACPI Specification v6.4 (released January 2021) or newer

ACPI support documents: https://www.uefi.org/acpi

Linux kernel documentation– Documentation/admin-guide/acpi/ssdt-overlays.rst– Via web: https://www.kernel.org/doc/html/latest/admin-guide/acpi/ssdt-overlays.html

Source code repositories– The meta-acpi project: https://github.com/westeri/meta-acpi/– Examples of ASL from the above:

https://github.com/westeri/meta-acpi/tree/master/recipes-bsp/acpi-tables/samples– BuildRoot fork: https://github.com/andy-shev/buildroot/tree/intel/board/intel/common

Page 24: ACPI overlays for embedded devices

24

Questions and AnswersThank you!

Page 25: ACPI overlays for embedded devices

25

Legal Information

Intel is a trademark of Intel Corporation in the U.S. and other countries.

*Other names and brands may be claimed as property of others.

Copyright © 2021 Intel Corporation, All rights reserved.

Page 26: ACPI overlays for embedded devices