Linux驱动模块加载失败
作者:互联网
Linux驱动模块加载失败
个人声明:转发请注明出处,个人原创,实属不易。本人水平有限,文章若有不妥之处,还请留言批评指正,不胜感激。
提示:
/lib/modules/4.1.15 # modprobe gpioled.ko
gpioled node is found!
led-gpio num = 3
can't request led gpio!
gpioled node is found!
led-gpio num = 3
can't request led gpio!
modprobe: can't load module gpioled.ko (gpioled.ko): Invalid argument
查找原因:
can’t request led gpio!
->can’t load module gpioled.ko
->Invalid argument
据原子哥提示,GPIO请求失败,很大概率是GPIO使用冲突了!!!
打开Linux内核源码,找到自己开发板对应的设备树源文件XXX.dts,在当前文件下搜索led的GPIO有哪些设备在用:MX6UL_PAD_GPIO1_IO03__GPIO1_IO03
搜索发现:除了我的pinctrlgpioled节点在使用
pinctrl_gpioled: ledgrp{
fsl,pin = <
MX6UL_PAD_GPIO1_IO03__GPIO1_IO03 0x10B0
>;
};
还有pinctrl_tsc设备节点也在使用该GPIO:
pinctrl_tsc: tscgrp {
fsl,pins = <
MX6UL_PAD_GPIO1_IO01__GPIO1_IO01 0xb0
MX6UL_PAD_GPIO1_IO02__GPIO1_IO02 0xb0
MX6UL_PAD_GPIO1_IO03__GPIO1_IO03 0xb0 // 此处为冲突使用的GPIO
MX6UL_PAD_GPIO1_IO04__GPIO1_IO04 0xb0
>;
};
将冲突使用的GPIO屏蔽掉就可以正常使用,除了屏蔽pinctrl节点的GPIO,还要屏蔽其他所有对该GPIO(GPIO1_IO03)有操作的地方,比如:
&tsc {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_tsc>;
xnur-gpio = <&gpio1 3 GPIO_ACTIVE_LOW>; // 此处为对该GPIO有操作的地方,也应该被屏蔽
measure-delay-time = <0xffff>;
pre-charge-time = <0xfff>;
status = "okay";
};
屏蔽后的代码:
/* MX6UL_PAD_GPIO1_IO03__GPIO1_IO03 0xb0 */
/* xnur-gpio = <&gpio1 3 GPIO_ACTIVE_LOW>; */
屏蔽上述两行代码后,重新加载驱动,成功!!!
/lib/modules/4.1.15 # depmod
/lib/modules/4.1.15 # modprobe gpioled.ko
gpioled node is found!
led-gpio num = 3
major is 249, minor is 0
标签:led,Linux,ko,pinctrl,模块,GPIO,gpio,gpioled,加载 来源: https://blog.csdn.net/ZigeSu/article/details/118343103