|
| 1 | + |
| 2 | +In order to support ACPI open-ended hardware configurations (e.g. development |
| 3 | +boards) we need a way to augment the ACPI configuration provided by the firmware |
| 4 | +image. A common example is connecting sensors on I2C / SPI buses on development |
| 5 | +boards. |
| 6 | + |
| 7 | +Although this can be accomplished by creating a kernel platform driver or |
| 8 | +recompiling the firmware image with updated ACPI tables, neither is practical: |
| 9 | +the former proliferates board specific kernel code while the latter requires |
| 10 | +access to firmware tools which are often not publicly available. |
| 11 | + |
| 12 | +Because ACPI supports external references in AML code a more practical |
| 13 | +way to augment firmware ACPI configuration is by dynamically loading |
| 14 | +user defined SSDT tables that contain the board specific information. |
| 15 | + |
| 16 | +For example, to enumerate a Bosch BMA222E accelerometer on the I2C bus of the |
| 17 | +Minnowboard MAX development board exposed via the LSE connector [1], the |
| 18 | +following ASL code can be used: |
| 19 | + |
| 20 | +DefinitionBlock ("minnowmax.aml", "SSDT", 1, "Vendor", "Accel", 0x00000003) |
| 21 | +{ |
| 22 | + External (\_SB.I2C6, DeviceObj) |
| 23 | + |
| 24 | + Scope (\_SB.I2C6) |
| 25 | + { |
| 26 | + Device (STAC) |
| 27 | + { |
| 28 | + Name (_ADR, Zero) |
| 29 | + Name (_HID, "BMA222E") |
| 30 | + |
| 31 | + Method (_CRS, 0, Serialized) |
| 32 | + { |
| 33 | + Name (RBUF, ResourceTemplate () |
| 34 | + { |
| 35 | + I2cSerialBus (0x0018, ControllerInitiated, 0x00061A80, |
| 36 | + AddressingMode7Bit, "\\_SB.I2C6", 0x00, |
| 37 | + ResourceConsumer, ,) |
| 38 | + GpioInt (Edge, ActiveHigh, Exclusive, PullDown, 0x0000, |
| 39 | + "\\_SB.GPO2", 0x00, ResourceConsumer, , ) |
| 40 | + { // Pin list |
| 41 | + 0 |
| 42 | + } |
| 43 | + }) |
| 44 | + Return (RBUF) |
| 45 | + } |
| 46 | + } |
| 47 | + } |
| 48 | +} |
| 49 | + |
| 50 | +which can then be compiled to AML binary format: |
| 51 | + |
| 52 | +$ iasl minnowmax.asl |
| 53 | + |
| 54 | +Intel ACPI Component Architecture |
| 55 | +ASL Optimizing Compiler version 20140214-64 [Mar 29 2014] |
| 56 | +Copyright (c) 2000 - 2014 Intel Corporation |
| 57 | + |
| 58 | +ASL Input: minnomax.asl - 30 lines, 614 bytes, 7 keywords |
| 59 | +AML Output: minnowmax.aml - 165 bytes, 6 named objects, 1 executable opcodes |
| 60 | + |
| 61 | +[1] http://wiki.minnowboard.org/MinnowBoard_MAX#Low_Speed_Expansion_Connector_.28Top.29 |
| 62 | + |
| 63 | +The resulting AML code can then be loaded by the kernel using one of the methods |
| 64 | +below. |
| 65 | + |
| 66 | +== Loading ACPI SSDTs from initrd == |
| 67 | + |
| 68 | +This option allows loading of user defined SSDTs from initrd and it is useful |
| 69 | +when the system does not support EFI or when there is not enough EFI storage. |
| 70 | + |
| 71 | +It works in a similar way with initrd based ACPI tables override/upgrade: SSDT |
| 72 | +aml code must be placed in the first, uncompressed, initrd under the |
| 73 | +"kernel/firmware/acpi" path. Multiple files can be used and this will translate |
| 74 | +in loading multiple tables. Only SSDT and OEM tables are allowed. See |
| 75 | +initrd_table_override.txt for more details. |
| 76 | + |
| 77 | +Here is an example: |
| 78 | + |
| 79 | +# Add the raw ACPI tables to an uncompressed cpio archive. |
| 80 | +# They must be put into a /kernel/firmware/acpi directory inside the |
| 81 | +# cpio archive. |
| 82 | +# The uncompressed cpio archive must be the first. |
| 83 | +# Other, typically compressed cpio archives, must be |
| 84 | +# concatenated on top of the uncompressed one. |
| 85 | +mkdir -p kernel/firmware/acpi |
| 86 | +cp ssdt.aml kernel/firmware/acpi |
| 87 | + |
| 88 | +# Create the uncompressed cpio archive and concatenate the original initrd |
| 89 | +# on top: |
| 90 | +find kernel | cpio -H newc --create > /boot/instrumented_initrd |
| 91 | +cat /boot/initrd >>/boot/instrumented_initrd |
0 commit comments