RE: How to use an ACPI declared GPIO in a userspace ...

Flavio Suligoi
2020-10-02T10:26:18Z

Hi Andy,

with my custom SSDT table:

DefinitionBlock ("gpio_button.aml", "SSDT", 5, "ASEMsp", "GPIO_BTN", 1)
{
External (_SB_.GPO1, DeviceObj)
Scope (\_SB.GPO1)
{
Device (BTNS)
{
Name (_HID, "ASEM0005") // _HID: Hardware ID PRP0001
Name (_UID, Zero) // _UID: Unique ID
Name (_DDN, "DDN - SW Readable Button") // _DDN: DOS Device Name
Name (_STR, Unicode ("STR - SW Readable Button")) // _STR: Description String

Name (_CRS, ResourceTemplate () // _CRS: Current Resource Settings
{
GpioIo (
Shared, // Not shared
PullNone, // No need for pulls
0, // Debounce timeout
0, // Drive strength
IoRestrictionInputOnly, // Only used as input
"\\_SB.GPO1", // GPIO controller
0, ResourceConsumer, , ) // Must be 0
{
25, // GPIO number 25
}
})
}
}
}

I'm able to see the GPIO in:

/sys/bus/platform/devices/ASEM0005:00/firmware_node:

-r--r--r-- 1 root root 4096 Oct 2 12:10 description
-r--r--r-- 1 root root 4096 Oct 2 12:10 hid
-r--r--r-- 1 root root 4096 Oct 2 12:10 modalias
-r--r--r-- 1 root root 4096 Oct 2 12:10 path
lrwxrwxrwx 1 root root 0 Oct 2 12:10 physical_node -> ../../../../platform/INT3452:01/ASEM0005:00
drwxr-xr-x 2 root root 0 Oct 2 12:10 power
lrwxrwxrwx 1 root root 0 Oct 2 12:10 subsystem -> ../../../../../bus/acpi
-rw-r--r-- 1 root root 4096 Oct 2 12:10 uevent
-r--r--r-- 1 root root 4096 Oct 2 12:10 uid

and so I can see some useful info:

# cat description
STR - SW Readable Button
# cat hid
ASEM0005
# cat modalias
acpi:ASEM0005:
bmxxxx-x86-64:/sys/bus/platform/devices/ASEM0005:00/firmware_node# cat path
\_SB_.GPO1.BTNS

So, from userspace, I can discover the GPIO controller /dev/gpiochip1,
but I don't know how to discover the GPIO number (25 in this case).
Do you have any suggestion about how to discover this GPIO number?

Thanks!

> --
> With Best Regards,
> Andy Shevchenko

Best regards,
Flavio