This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] Linux/AM5728:映射到物理 GPIO 时分配 GPIO sysfs gpiochip 编号

Guru**** 2551110 points


请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/processors-group/processors/f/processors-forum/611907/linux-am5728-gpio-sysfs-gpiochip-number-assignment-when-mapping-to-physical-gpio

器件型号:AM5728

工具/软件:Linux

您好!

客户注意到物理 gpioX_Y 到/sys/class/gpio/gpiochipXXX 虚拟文件的非确定性映射。 在 Linux 4.1等以前的内核中、有一个确定性映射。 但是、如果看一下 Linux 4.4中的映射、那么到 GPIO 模块物理地址的映射似乎是随机的。

root@am57xx-EVM:~# ls -l /sys/class/gpio
-- w ----    1    根根         4096 Mar 30 00:56导出
lrwxrwxrwx   1 root    root 用户            0 Mar 30 00:56 gpiochip0 ->../../devices/platform/44000000.ocp/4ae10000.gpio/gpio/gpiochip0
lrwxrwxrwx   1 root    root 用户            0 Mar 30 00:56 gpiochip128 ->../../devices/platform/44000000.ocp/4805b000.gpio/gpio/gpiochip128
lrwxrwxrwx   1 root    root 用户            0 Mar 30 00:56 gpiochip160 ->../../devices/platform/44000000.ocp/4805d000.gpio/gpio/gpiochip160
lrwxrwxrwx   1 root    root 用户            0 Mar 30 00:56 gpiochip192 ->../../devices/platform/44000000.ocp/48051000.gpio/gpio/gpiochip192
lrwxrwxrwx   1 root    root 用户            0 Mar 30 00:56 gpiochip224 ->../../devices/platform/44000000.ocp/48053000.gpio/gpio/gpiochip224
lrwxrwxrwx   1 root    root 用户            0 Mar 30 00:56 gpiochip32 ->../../devices/platform/44000000.ocp/48055000.gpio/gpio/gpiochip32
lrwxrwxrwx   1 root    root 用户            0 Mar 30 00:56 gpiochip504 ->../../devices/platform/44000000.ocp/48070000.i2c/i2c-0/0-0058/48070000.i2c:tps659038@58:tps659038_GPIO/gpio/gpiochip504
lrwxrwxrwx   1 root    root 用户            0 Mar 30 00:56 gpiochip64 ->../../devices/platform/44000000.ocp/48057000.gpio/gpio/gpiochip64
lrwxrwxrwx   1 root    root 用户            0 Mar 30 00:56 gpiochip96 ->../../devices/platform/44000000.ocp/48059000.gpio/gpio/gpiochip96
-- w ----    1    根根         4096 Mar 30 00:56 unexport

您能帮助我了解分配是如何进行的? 它是动态的吗? 通过 sysfs 接口切换 GPIO 时、如何事先知道映射是什么?

谢谢、

-Gunter

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
    您好 Gunter、

    这是最新的 TIISDK 还是社区内核版本?
    我知道 AM437x 存在此类问题、但 AM572x 没有问题。 我将查看并更新。

    此致、
    Yordan
  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    Yordan、您好!

    这种情况已有一段时间未能解决。 您能否更新一下映射为什么是非确定性的、以及映射的定义是什么?

    谢谢、

    -Gunter

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
    Gunter、

    您应该能够从/drivers/gpio/gpiolib-sysfs.c.中的 gpiochip_sysfs_register()函数开始跟踪此情况

    此致、
    Yordan