linux设备树节点添加新的复位属性之后设备驱动加载异常问题分析 1 linux原始设备驱动信息1.1 设备树节点信息1.2 linux设备驱动1.3 makefile1.4 Kconfig1
该问题是在调试linux设备驱动时出现,根据当时对该问题的理解以及对应的验证方法去整理为该文档。
/ { test_fw_load@0x100000000 { compatible = "test,test-x280-fw"; reg = < 0x01 0x00000000 0x0 0x20000000 >, < 0x0 0x4000f000 0x0 0x200>; };};
这里只给出一个驱动代码的示意test_fw.c,probe函数具体的功能就不再贴出。
// SPDX-License-Identifier: GPL-2.0-or-later#include #include #include #include #include #include #include #include #include #include #include #include #define TEST_FW_LOAD_VERSioN "1.0"static int test_fw_probe(struct platfORM_device *pdev){printk("test fw probe\r\n");return 0;}static int test_fw_remove(struct platform_device *pdev){printk("test fw probe\r\n");return 0;}static const struct of_device_id test_fw_match[] = {{ .compatible = "test,test-x280-fw", },{},};MODULE_DEVICE_TABLE(of, test_fw_match);static struct platform_driver test_fw_load_driver = {.driver = {.name = "test_fw_load",.of_match_table = test_fw_match,},.probe = test_fw_probe,.remove = test_fw_remove,};module_platform_driver(test_fw_load_driver);MODULE_AUTHOR("W Test " );MODULE_VERSION(TEST_FW_LOAD_VERSION);MODULE_LICENSE("GPL V2");
obj-$(CONFIG_TEST_FW_LOAD) += test_fw.o
config TEST_FW_LOAD tristate "X280 Fw load on Test Platform" select FW_LOADER help This option enables support for the Test load X280 FW You may select when support test fw load. To compile this as a module choose M. If unsure, say N.
CONFIG_TEST_FW_LOAD=y
给test_fw_load节点添加了复位属性。
/ {test_reset: test_reset {compatible = "test,scmi-reset";#reset-cells = <1>;};};/ { test_fw_load@0x100000000 { compatible = "test,test-x280-fw"; reg = < 0x01 0x00000000 0x0 0x20000000 >, < 0x0 0x4000f000 0x0 0x200>; resets = <&test_reset 1>; reset-names = "test_reset"; };};
当给test_fw.c对应的设备树添加了复位属性之后就开始出现test_fw.c驱动的probe函数不被执行,整个设备驱动好像就没有被调用。
可以确定test_fw.c所对应的makefile,Kconfig,defconfig均已正常添加对应的配置选项,且之前test_fw.c所对应的驱动运行良好。
同时,如果把复位属性注释掉则驱动又恢复运行良好。
由于添加上复位属性设备驱动就会出现加载异常,注释掉复位属性驱动就运行OK,那么我们可以确定问题是由于添加复位属性引入的。
该问题的主要原因是使用test_reset的复位节点配置,但是test_reset节点所对应的驱动并没有处理并加载,导致test_fw.c所对应的驱动加载异常。
解决test_fw.c对应驱动加载异常的方法就是添加test_reset设备树节点对应节点的设备驱动,下面是已对应的示意代码为例来介绍的。
// SPDX-License-Identifier: GPL-2.0-or-later#include #include #include #include #include #include #include #include #include #include #include static int test_reset_probe(struct platform_device *pdev){ return 0;}static int test_reset_remove(struct platform_device *pdev){ return 0;}static const struct of_device_id test_reset_match[] = { { .compatible = "test,scmi-reset", }, {},};MODULE_DEVICE_TABLE(of, test_reset_match);static struct platform_driver test_reset_driver = { .driver = { .name = "test_reset", .of_match_table = test_reset_match, }, .probe = test_reset_probe, .remove = test_reset_remove,};module_platform_driver(test_reset_driver);MODULE_AUTHOR("W Test " );MODULE_DESCRIPTION("TEST RESET driver");MODULE_LICENSE("GPL V2");
obj-$(CONFIG_TEST_RESET) += test_reset.o
config TEST_RESET tristate "test reset on Test Platform" help This option enables support for the TEST RESET You may select when support test reset. To compile this as a module choose M. If unsure, say N.
CONFIG_TEST_RESET=y
来源地址:https://blog.csdn.net/u014100559/article/details/132865277
--结束END--
本文标题: linux设备树节点添加新的复位属性之后设备驱动加载异常问题分析
本文链接: https://www.lsjlt.com/news/421735.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-03-01
2024-03-01
2024-03-01
2024-03-01
2024-03-01
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0