linux - How to identify GPIO pin numbers? Is GPIO driver loaded? - Unix & Linux Stack Exchange
update:2021-11-9
My system: CPU Version: Intel(R) Celeron(R) CPU J1900 @ 1.99GHz

At some point I figured that this implements the IT8786 Chip.

If you check your Kernel Configuration, you might find support for the IT87x family of drivers (under GPIO Drivers of course). In my case this was only enable as a Module.

Then, I loaded the module with:

sudo insmod /lib/modules/5.8.0-55-generic/kernel/drivers/gpio/gpio-it87.ko
dmesg returned the following item:

gpio_it87: Found Chip IT8786 rev 2. 64 GPIO lines starting at 0a00h
By checking /dev, gpiochip0 appeared and from there on you can use the already mentioned sysfs method if you wish so (although in retirement).

If you don't know how to relate the physical pins to the hardware, then try this:

apt-get install gpiod
Running gpioinfo returns in my case the following:

gpiochip0 - 64 lines:

    line   0:  "it87_gp10"       unused   input  active-high
    line   1:  "it87_gp11"       unused   input  active-high
    line   2:  "it87_gp12"      "sysfs"   input  active-high [used]
    line   3:  "it87_gp13"       unused   input  active-high
    line   4:  "it87_gp14"       unused   input  active-high
    line   5:  "it87_gp15"       unused   input  active-high
    line   6:  "it87_gp16"       unused   input  active-high
    line   7:  "it87_gp17"       unused   input  active-high
    line   8:  "it87_gp20"       unused   input  active-high
    line   9:  "it87_gp21"       unused   input  active-high
    line  10:  "it87_gp22"       unused   input  active-high
    line  11:  "it87_gp23"       unused   input  active-high
    line  12:  "it87_gp24"      "sysfs"   input  active-high [used]
    line  13:  "it87_gp25"       unused   input  active-high
    line  14:  "it87_gp26"       unused   input  active-high
    line  15:  "it87_gp27"       unused   input  active-high
    line  16:  "it87_gp30"       unused   input  active-high
    line  17:  "it87_gp31"       unused   input  active-high
    line  18:  "it87_gp32"       unused   input  active-high
    line  19:  "it87_gp33"       unused   input  active-high
    line  20:  "it87_gp34"       unused   input  active-high
    line  21:  "it87_gp35"       unused   input  active-high
    line  22:  "it87_gp36"      "sysfs"  output  active-high [used]
    line  23:  "it87_gp37"       unused   input  active-high
    line  24:  "it87_gp40"       unused   input  active-high
    line  25:  "it87_gp41"       unused   input  active-high
    line  26:  "it87_gp42"       unused   input  active-high
    line  27:  "it87_gp43"       unused   input  active-high
    line  28:  "it87_gp44"       unused   input  active-high
    line  29:  "it87_gp45"       unused   input  active-high
    line  30:  "it87_gp46"       unused   input  active-high
    line  31:  "it87_gp47"       unused   input  active-high
    line  32:  "it87_gp50"       unused   input  active-high
    line  33:  "it87_gp51"       unused   input  active-high
    line  34:  "it87_gp52"       unused   input  active-high
    line  35:  "it87_gp53"       unused   input  active-high
    line  36:  "it87_gp54"       unused   input  active-high
    line  37:  "it87_gp55"       unused   input  active-high
    line  38:  "it87_gp56"       unused   input  active-high
    line  39:  "it87_gp57"       unused   input  active-high
    line  40:  "it87_gp60"       unused   input  active-high
    line  41:  "it87_gp61"       unused   input  active-high
    line  42:  "it87_gp62"       unused   input  active-high
    line  43:  "it87_gp63"       unused   input  active-high
    line  44:  "it87_gp64"       unused   input  active-high
    line  45:  "it87_gp65"       unused   input  active-high
    line  46:  "it87_gp66"       unused   input  active-high
    line  47:  "it87_gp67"       unused   input  active-high
    line  48:  "it87_gp70"       unused   input  active-high
    line  49:  "it87_gp71"       unused   input  active-high
    line  50:  "it87_gp72"       unused   input  active-high
    line  51:  "it87_gp73"      "sysfs"   input  active-high [used]
    line  52:  "it87_gp74"      "sysfs"  output  active-high [used]
    line  53:  "it87_gp75"      "sysfs"   input  active-high [used]
    line  54:  "it87_gp76"      "sysfs"   input  active-high [used]
    line  55:  "it87_gp77"       unused   input  active-high
    line  56:  "it87_gp80"       unused   input  active-high
    line  57:  "it87_gp81"       unused  output  active-high
    line  58:  "it87_gp82"       unused   input  active-high
    line  59:  "it87_gp83"       unused   input  active-high
    line  60:  "it87_gp84"       unused   input  active-high
    line  61:  "it87_gp85"       unused   input  active-high
    line  62:  "it87_gp86"       unused   input  active-high
    line  63:  "it87_gp87"       unused   input  active-high

You can use the utilities of gpiod to work with the different pins. If your manufacturer has in some way indicated which GPI/O you can use, then you can related the "line" to the it87_gpXX" part, being XX the pins probably provided by the manufacturer.

A quick check can be done on the old way.

Go to /sys/class/gpio and see what gpiochip you find. The base number inside the gpiochip is the start position and the line points returned by gpioinfo the offset.

In my case I had 448 as base. If I want to reach GP81, that is line 57, so I would do this:

echo 505 > /sys/class/gpio/export
I hope this helps! It saved me from writing the Driver (By the way, the manufacturer sent me a driver but it didn't work)
Referenced from:https://unix.stackexchange.com/questions/485324/how-to-identify-gpio-pin-numbers-is-gpio-driver-loaded

本文链接地址:https://const.net.cn/575.html

标签: GPIO

添加新评论