MCP23017 I2C 设备驱动程序探测函数未被调用 [英] MCP23017 I2C Device driver probe function is not called

查看:18
本文介绍了MCP23017 I2C 设备驱动程序探测函数未被调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用以下 I2C/GPIO 设备驱动程序 访问 MCP23017 GPIO.使用 insmod 命令,我可以加载驱动程序及其在/proc/modules 中列出的内容.我有两个 MCP23017 芯片连接到我的 Raspberry Pi.两者都在地址 0x200x21 处检测到.对驱动程序的 initcall 注册驱动程序.我通过打印一条消息来检查这一点.但是驱动程序探测函数没有被调用.设备未打开/无法位于其他地方.

I am using the following I2C/GPIO Device driver to access the MCP23017 GPIOs. With the insmod command I am able to load the driver and its listed in /proc/modules. I have two MCP23017 chips connected to my Raspberry Pi. Both are detected at addresses 0x20 and 0x21. The initcall to the driver registers the driver. I checked this by printing out a message. But the driver probe function is not called. The devices are not opened/ cannot be located elsewhere.

  1. 探测函数是如何调用的?
  2. 是否应该手动进行探测以定位设备?
  3. probe 调用是否与 open 调用类似?
  4. 我试过这个 echo mcp23017 0x20 >new_device 使用地址手动创建新设备.但它没有用.我收到以下消息:Driver 'mcp23s08' 已经注册,正在中止...
  1. How is the probe function called?
  2. Should the probe be done manually to locate the devices?
  3. Is the probe call similar to the open call?
  4. I tried this echo mcp23017 0x20 > new_device to manually create a new device with the address. But it didnt work. I got the followin message: Driver 'mcp23s08' is already registered, aborting...

任何帮助将不胜感激.

推荐答案

probe() 函数在驱动程序与设备树中的设备描述匹配时调用.当在设备树中找到驱动程序的 compatible 字段时会发生匹配(对于您的驱动程序,它是 "微芯片,mcp23017" 字符串).

probe() function is called when driver is matched with your device description in Device Tree. Matching happens when compatible field of your driver found in Device Tree (for your driver it's "microchip,mcp23017" string).

显然您没有在设备树中描述您的设备 (MCP23017),这就是不调用 probe() 的原因.您可以加载相应的设备树覆盖来解决此问题.您在评论中指出的 one 似乎是正确的.在此处阅读有关在 Raspberry Pi 生态系统中加载叠加层的更多信息.

Apparently you don't have your device (MCP23017) described in Device Tree, that's why probe() is not called. You can load corresponding Device Tree Overlay to overcome this issue. The one you pointed out in your comment seems to be correct. Read more about loading overlays in Raspberry Pi ecosystem here.

您可以尝试像那篇文章中描述的那样加载您的叠加层:

You can try to load your overlay like described in that article:

$ sudo dtoverlay mcp23017.dtbo

或者您可以尝试使用 Capemgr 来达到此目的.就我个人而言,我没有尝试任何一种,所以你应该看看哪种最适合你.

Or you can try to use Capemgr for this purpose. Personally I didn't try any of those, so you should look which works for you best.

在评论中回复您的问题.

Replying to your questions in comments.

但是当我尝试使用 i2cdetect 命令时,它会显示 UU.

But when I try the i2cdetect command it shows UU.

参见man i2cdetect.所以UU"意味着 i2cdetect 跳过了探测,因为你指定地址的设备已经被驱动程序使用了.我猜这就是你的意图,所以没关系.

See man i2cdetect. So "UU" means that i2cdetect skipped probing because device at the address you specified is already used by driver. I guess it what you intended, so it's ok.

使用 rmmod mcp23017 命令我看到设备仍在设备下,但 i2cdetect 显示 0x20

With a rmmod mcp23017 command I see the device still under devices but i2cdetect shows 0x20

所以您卸载了驱动程序,现在 i2cdetect 显示0x20 地址上有一些设备.我想这是正确的行为.此外,如果您想彻底摆脱设备,请尝试卸载 DT 覆盖和驱动程序.

So you unloaded the driver and now i2cdetect shows you that there is some device on 0x20 address. I guess it's correct behavior. Also if you want to get rid completely of your device -- try to unload DT overlay along with driver.

我还连接了两个 MCP23017 芯片.但是我只能在设备下看到 0x20 处的设备.0x21 处的 I2C 芯片仍未检测到,尽管驱动程序说它最多支持 8 个芯片

Also I have connected two MCP23017 chips. But I can see only the device at 0x20 under devices. The I2C chip at 0x21 is still not detected, though the driver says it supports up to 8 chips

我可以看到导致此问题的两个可能原因.

I can see two possible causes to this issue.

  1. DT 覆盖只有地址为 0x20 的设备的描述,但缺少地址为 0x21 的设备的描述.如果是这种情况,您应该找到 DT 覆盖的来源,为其余设备添加描述,编译修改后的 DT 覆盖,然后加载它而不是预先构建的.
  2. 所有设备都可以配置为使用 0x20 地址.见1.4节MCP23017 数据表中的硬件地址解码器 了解详情.检查芯片上的 A0A1A2 引脚.
  1. DT overlay only has description for device with 0x20 address, but missing description for device with 0x21 address. If this is the case, you should find sources for your DT overlay, add description for rest of your devices, compile that modified DT overlay and then load it instead of pre-built one.
  2. All devices may be configured for using 0x20 address. See section 1.4 Hardware Address Decoder in MCP23017 datasheet for details. Check A0, A1, A2 pins on your chips.

这篇关于MCP23017 I2C 设备驱动程序探测函数未被调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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