Linux,ARM:为什么要使用gpiochip< num>仅在引导时存在I2C GPIO扩展器的情况下创建? [英] Linux, ARM: Why is gpiochip<num> only created if I2C GPIO Expander is present at boot?

查看:370
本文介绍了Linux,ARM:为什么要使用gpiochip< num>仅在引导时存在I2C GPIO扩展器的情况下创建?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在imx6sx硬件平台(NXP嵌入式ARM)上使用Linux 3.14.52.

Using Linux 3.14.52 on a imx6sx hardware platform (NXP embedded ARM).

问题在于,除非在内核引导过程中存在设备树中指定的PCF8575 I2C GPIO扩展器,否则它们不会被实例化为/sys/class/gpio结构中的设备.这些设备在/sys/bus/i2c/devices/i2c-1(i2c总线1)结构中列出,但在/sys/class/gpio结构中未指定gpiochip.

The problem is that PCF8575 I2C GPIO expanders specified in the device tree are not instantiated as devices in the /sys/class/gpio structure unless they are present during kernel boot. The devices are listed in the /sys/bus/i2c/devices/i2c-1 (i2c bus 1) structures but are not given gpiochip 's in the /sys/class/gpio structure.

将这些设备添加到系统后,是否有办法在启动后将它们分配为gpiochip?

Is there a way to have these devices assigned as gpiochip after boot once they are added to the system?

在以前的(PowerPC)平台上,设备树中列出的所有设备都被分配了gpiochip的设备,无论它们在内核引导期间是否处于打开状态.但是在我们的ARM平台上,设备必须在内核引导期间可用.我尝试过通过尽可能接近先前平台的方式(通过.config)更改内核i2c/gpio选项,但这似乎没有效果.

On previous (PowerPC) platform, all devices listed in the device tree were assigned gpiochip's regardless of whether they were on during kernel boot. But with our ARM platform, the devices must be available during kernel boot. I have tried changing the kernel i2c/gpio options (via .config) as close to the previous platform as possible but this seems to have no effect.

推荐答案

请确保内核在2.6内核分支中针对sysfs的工作方式有所不同.我也遇到过类似的问题.它与设备树的处理有关.设备树将变得不平坦,但这只会开始实际发现设备.如果设备不存在,则将不会对其进行探测,也不会在sysfs中创建条目.

For sure the kernel worked differently regarding sysfs in the 2.6 kernel branch. I have experienced similar issues as well. It has to do with handling of the device tree. The device tree will get unflattened, but this only kicks off the actual discovery of devices. If the devices do not actual exist, they will not be probed and will not have entries created in sysfs.

设备树使用情况

Linux板支持代码调用of_platform_populate(NULL,NULL,NULL,NULL) 在树的根部开始发现设备.这 参数全为NULL,因为从 树,无需提供起始节点(第一个NULL), 父结构设备(最后一个NULL),我们没有使用匹配项 表(尚未).对于只需要注册设备的板, .init_machine()可以完全为空,除了 of_platform_populate()调用.

Linux board support code calls of_platform_populate(NULL, NULL, NULL, NULL) to kick off discovery of devices at the root of the tree. The parameters are all NULL because when starting from the root of the tree, there is no need to provide a starting node (the first NULL), a parent struct device (the last NULL), and we're not using a match table (yet). For a board that only needs to register devices, .init_machine() can be completely empty except for the of_platform_populate() call.

因此,设备树只会告诉内核要发现的内容,如果找不到,它实际上不会添加任何内容.

So the device tree will only tell the kernel what to discover, it will not actually add anything if it is not found.

我可以确认gpiochip仅添加在您设备的探头上:

I can confirm the gpiochip is ONLY added at probe of your device:

gpio-pcf857x.c

将第397行的呼叫通知给gpiochip_add

Notice the call on line 397 to gpiochip_add

我建议您尝试使用设置为模块的gpio扩展器编译内核,然后在实际附加内核之后对其进行insmod.

What I would recommend is to try compiling your kernel with the gpio expander set as a module and then insmod it after it has actually been attached.

这篇关于Linux,ARM:为什么要使用gpiochip< num>仅在引导时存在I2C GPIO扩展器的情况下创建?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆