Collectives on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more

I have some question about ACPI table. I want to control Intel Edison default GPIO on boot, so I make ACPI table to control it. But did not cause any changes. This is my ASL code:

Device (DEV)
    Name (_HID, "PRP0001")
    Name (_DDN, "GPIO LEDs device")
    Name (_CRS, ResourceTemplate()
            GpioIo (Shared, PullNone, 0x0000, 0x0000,
                    IoRestrictionOutputOnly, "\\_SB.PCI0.GPI0",
                    0x00, ResourceConsumer,,){12,13}
    Name (_DSD, Package () {
        ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
        Package () {
            Package () { "compatible", Package() { "gpio-leds" } },
        ToUUID("dbb8e3e6-5886-4ba6-8795-1319f52a966b"),
        Package () {
            Package () {"led-0", "LED0"},
            Package () {"led-1", "LED1"},
     * For more information about these bindings see:
     * Documentation/devicetree/bindings/leds/common.yaml,
     * Documentation/devicetree/bindings/leds/leds-gpio.yaml and
     * Documentation/firmware-guide/acpi/gpio-properties.rst.
     Name (LED0, Package () {
            ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
            Package () {
                Package () {"label", "green"},
                Package () {"default-state", "off"},
                Package () {"gpios", Package () {^LEDS, 0, 0, 0}},
                Package () {"retain-state-suspended", 1},
     Name (LED1, Package () {
            ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
            Package () {
                Package () {"label", "red"},
                Package () {"default-state", "off"},
                Package () {"gpios", Package () {^LEDS, 0, 1, 0}},
                Package () {"retain-state-suspended", 1},

Look like my leds_test.aml is loaded. This is my /sys/kernel/debug/gpio:

root@:~# cat /sys/kernel/debug/gpio
gpiochip0: GPIOs 0-191, parent: pci/0000:00:0c.0, 0000:00:0c.0:
gpio-47  (                    |?                   ) out hi
gpio-71  (                    |shutdown            ) out hi
gpio-77  (                    |sd_cd               ) in  hi IRQ
gpio-96  (                    |ACPI:OpRegion       ) out hi
gpio-110 (                    |cs                  ) out hi
gpio-111 (                    |cs                  ) out hi
gpio-112 (                    |cs                  ) out lo
gpio-113 (                    |cs                  ) out lo
gpio-184 (                    |device-wakeup       ) out lo
gpio-185 (                    |host-wakeup         ) in  lo IRQ
root@:~# dmesg | grep ACPI
[    0.002615] ACPI: Early table checksum verification disabled
[    0.002631] ACPI: RSDP 0x00000000000E4500 000024 (v02 U-BOOT)
[    0.002655] ACPI: XSDT 0x00000000000E45E0 00004C (v01 U-BOOT U-BOOTBL 20200909 INTL 00000000)
[    0.002688] ACPI: FACP 0x00000000000E5310 0000F4 (v06 U-BOOT U-BOOTBL 20200909 INTL 00000000)
[    0.002724] ACPI: DSDT 0x00000000000E4780 000A8A (v02 U-BOOT U-BOOTBL 00010000 INTL 20190215)
[    0.002749] ACPI: APIC 0x00000000000E5410 000048 (v04 U-BOOT U-BOOTBL 20200909 INTL 00000000)
[    0.002772] ACPI: MCFG 0x00000000000E5460 00003C (v01 U-BOOT U-BOOTBL 20200909 INTL 00000000)
[    0.002794] ACPI: CSRT 0x00000000000E54A0 000058 (v00 U-BOOT U-BOOTBL 20200909 INTL 00000000)
[    0.002817] ACPI: SPCR 0x00000000000E5500 000050 (v02 U-BOOT U-BOOTBL 20200909 INTL 00000000)
[    0.002866] ACPI: Local APIC address 0xfee00000
[    0.035260] ACPI: no legacy devices present
[    0.035266] ACPI: probing for VGA not safe
[    0.035281] ACPI: Local APIC address 0xfee00000
[    0.035303] ACPI: LAPIC (acpi_id[0x00] lapic_id[0x00] enabled)
[    0.035315] ACPI: LAPIC (acpi_id[0x02] lapic_id[0x02] enabled)
[    0.035338] ACPI: IOAPIC (id[0x02] address[0xfec00000] gsi_base[0])
[    0.035385] Using ACPI (MADT) for SMP configuration information
[    0.035400] ACPI: SPCR: console: uart,mmio,0xff010180
[    1.158446] ACPI: Core revision 20191018
[    1.182930] ACPI FADT declares the system doesn't support PCIe ASPM, so disable it
[    1.182938] ACPI: bus type PCI registered
[    1.215373] ACPI: Added _OSI(Module Device)
[    1.215771] ACPI: Added _OSI(Processor Device)
[    1.215778] ACPI: Added _OSI(3.0 _SCP Extensions)
[    1.215784] ACPI: Added _OSI(Processor Aggregator Device)
[    1.215793] ACPI: Added _OSI(Linux-Dell-Video)
[    1.215801] ACPI: Added _OSI(Linux-Lenovo-NV-HDMI-Audio)
[    1.215808] ACPI: Added _OSI(Linux-HPI-Hybrid-Graphics)
[    1.220700] ACPI: 1 ACPI AML tables successfully acquired and loaded
[    1.222647] ACPI: Interpreter enabled
[    1.222705] ACPI: (supports S0)
[    1.222740] ACPI: Using IOAPIC for interrupt routing
[    1.222853] PCI: Using host bridge windows from ACPI; if necessary, use "pci=nocrs" and report a bug
[    1.236360] ACPI: PCI Root Bridge [PCI0] (domain 0000 [bus 00-ff])
[    1.266154] ACPI: bus type USB registered
[    2.126336] pnp: PnP ACPI init
[    2.126853] pnp 00:00: Plug and Play ACPI device, IDs PNP0b00 (active)
[    2.127373] system 00:01: Plug and Play ACPI device, IDs PNP0c02 (active)
[    2.128692] pnp: PnP ACPI: found 2 devices
[    3.028011] ACPI: Host-directed Dynamic ACPI Table Load:
[    3.028045] ACPI: SSDT 0xFFFF8B1279103A80 0000A6 (v05        SPIDEV   00000001 INTL 20190215)
[    3.059576] ACPI: Host-directed Dynamic ACPI Table Load:
[    3.059611] ACPI: SSDT 0xFFFF8B12792C4C00 00016D (v05        LEDS     00000001 INTL 20190215)
[    3.112334] ACPI: Host-directed Dynamic ACPI Table Load:
[    3.112367] ACPI: SSDT 0xFFFF8B12793D6B00 0000E5 (v05        i2c      00000001 INTL 20190215)

But I have not got my LED on,and also I ensure CONFIG_LEDS_GPIO=y and CONFIG_LEDS_CLASS=y in my kernel configuration and built kernel.

First of all, you have ambiguous GPIO resources in _CRS. What did you mean under pin 47 is being provided as GpioIo() and GpioInt() simultaneously? Second, it's not obvious what did you mean under I want to ... GPIO 48 to low when you are talking about GpioInt(). Please, clarify these items in the question. – 0andriy Aug 12 '20 at 9:31 Sorry is my fault ,I thought Gpioint() means initial.... I changed my ASL code.then I means want to set GPIO 47 value to high and GPIO 48 value to low in boot – 蕭舜誠 Aug 13 '20 at 2:35 In new kernels the GPIO numbering is kept the same for backward compatibility, so GP47 means GPIO 47 in the kernel and ACPI. You may do this from ACPI, but you need to understand that the actual pin value comes from the driver. So before the driver is loaded nothing is changed, even if you have ACPI tables already present and parsed. – 0andriy Aug 27 '20 at 13:04 I suggest to drop unrelated / staled comments. Meanwhile I think you need to check polarity of the pin. In my case I used Active Low and had to update _DSD gpios property for that. In any case the example in answer is correct and works for me. – 0andriy Aug 31 '20 at 12:51

Follow this leds.asli and try to create test example that is work now.

example:

Device (DEV)
    Name (_HID, "PRP0001")
    Name (_DDN, "GPIO LEDs device")
    Name (_CRS, ResourceTemplate()
            GpioIo (Shared, PullNone, 0x0000, 0x0000,
                    IoRestrictionOutputOnly, "\\_SB.PCI0.GPI0",
                    0x00, ResourceConsumer,,){12,13}
    Name (_DSD, Package () {
        ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
        Package () {
            Package () { "compatible", Package() { "gpio-leds" } },
        ToUUID("dbb8e3e6-5886-4ba6-8795-1319f52a966b"),
        Package () {
            Package () {"led-0", "LED0"},
            Package () {"led-1", "LED1"},
     * For more information about these bindings see:
     * Documentation/devicetree/bindings/leds/common.yaml,
     * Documentation/devicetree/bindings/leds/leds-gpio.yaml and
     * Documentation/firmware-guide/acpi/gpio-properties.rst.
     Name (LED0, Package () {
            ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
            Package () {
                Package () {"label", "green"},
                Package () {"default-state", "off"},
                Package () {"gpios", Package () {^LEDS, 0, 0, 0}},
                Package () {"retain-state-suspended", 1},
     Name (LED1, Package () {
            ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
            Package () {
                Package () {"label", "red"},
                Package () {"default-state", "off"},
                Package () {"gpios", Package () {^LEDS, 0, 1, 0}},
                Package () {"retain-state-suspended", 1},

/sys/kernel/debug/gpio:

root@:~# cat /sys/kernel/debug/gpio
gpiochip0: GPIOs 0-191, parent: pci/0000:00:0c.0, 0000:00:0c.0:
gpio-12  (                    |green               ) out lo
gpio-13  (                    |red                 ) out lo
gpio-71  (                    |shutdown            ) out hi
gpio-77  (                    |sd_cd               ) in  hi IRQ
gpio-96  (                    |ACPI:OpRegion       ) out hi
gpio-110 (                    |cs                  ) out hi
gpio-111 (                    |cs                  ) out hi
gpio-112 (                    |cs                  ) out lo
gpio-113 (                    |cs                  ) out lo
gpio-184 (                    |device-wakeup       ) out lo
gpio-185 (                    |host-wakeup         ) in  lo IRQ
                I have taken this example + DefinitionBlock() and Scope(), changed GPIO to 48 and set it active low (because it's DFRobot IO expander board). Then I ensure CONFIG_LEDS_GPIO=y and CONFIG_LEDS_CLASS=y in my kernel configuration and built kernel.  I compiled ASL and attached it to initramfs and booted. As soon as LED GPIO driver is probed (see below), I have got my LED on. grep led /sys/kernel/debug/gpio: gpio-48..., [    0.001269] ACPI: SSDT ACPI table found in initrd [led48.aml], [   22.627591] bus: 'platform': really_probe: bound device PRP0001:00 to driver leds-gpio.
– 0andriy
                Aug 27 '20 at 14:00
                So, @22.62 seconds from boot I have got my LED on. It took long due to big initramfs to decompress.
– 0andriy
                Aug 27 '20 at 14:02
        

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.