Linux,ARM:为什么 gpiochip<num> 仅在启动时存在 I2C GPIO 扩展器时才创建?
Linux, ARM: Why is gpiochip<num> only created if I2C GPIO Expander is present at boot?
在 imx6sx 硬件平台(NXP 嵌入式 ARM)上使用 Linux 3.14.52。
问题是设备树中指定的 PCF8575 I2C GPIO 扩展器不会实例化为 /sys/class/gpio 结构中的设备,除非它们在内核引导期间存在。这些设备列在 /sys/bus/i2c/devices/i2c-1
(i2c 总线 1)结构中,但未在 /sys/class/gpio
结构中给出 gpiochip。
有没有办法在将这些设备添加到系统后在启动后将它们指定为 gpiochip?
在以前的 (PowerPC) 平台上,设备树中列出的所有设备都分配了 gpiochip,无论它们是否在内核引导期间打开。但是对于我们的 ARM 平台,设备必须在内核启动期间可用。我已经尝试更改内核 i2c/gpio 选项(通过 .config)尽可能接近以前的平台,但这似乎没有效果。
确定内核在 2.6 内核分支中对 sysfs 的工作方式不同。我也遇到过类似的问题。它与设备树的处理有关。设备树将变得不平坦,但这只会启动实际的设备发现。如果设备实际上不存在,则不会对其进行探测,并且不会在 sysfs 中创建条目。
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.
所以设备树只会告诉内核要发现什么,如果没有找到它实际上不会添加任何东西。
我可以确认 gpio 芯片仅添加在您设备的探针上:
注意第 397 行对 gpiochip_add
的调用
我建议尝试将 gpio 扩展器设置为模块来编译您的内核,然后在实际附加后对其进行 insmod。
在 imx6sx 硬件平台(NXP 嵌入式 ARM)上使用 Linux 3.14.52。
问题是设备树中指定的 PCF8575 I2C GPIO 扩展器不会实例化为 /sys/class/gpio 结构中的设备,除非它们在内核引导期间存在。这些设备列在 /sys/bus/i2c/devices/i2c-1
(i2c 总线 1)结构中,但未在 /sys/class/gpio
结构中给出 gpiochip。
有没有办法在将这些设备添加到系统后在启动后将它们指定为 gpiochip?
在以前的 (PowerPC) 平台上,设备树中列出的所有设备都分配了 gpiochip,无论它们是否在内核引导期间打开。但是对于我们的 ARM 平台,设备必须在内核启动期间可用。我已经尝试更改内核 i2c/gpio 选项(通过 .config)尽可能接近以前的平台,但这似乎没有效果。
确定内核在 2.6 内核分支中对 sysfs 的工作方式不同。我也遇到过类似的问题。它与设备树的处理有关。设备树将变得不平坦,但这只会启动实际的设备发现。如果设备实际上不存在,则不会对其进行探测,并且不会在 sysfs 中创建条目。
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.
所以设备树只会告诉内核要发现什么,如果没有找到它实际上不会添加任何东西。
我可以确认 gpio 芯片仅添加在您设备的探针上:
注意第 397 行对 gpiochip_add
我建议尝试将 gpio 扩展器设置为模块来编译您的内核,然后在实际附加后对其进行 insmod。