MCP23017 I2C Device driver probe function is not called

ぃ、小莉子 提交于 2019-12-06 07:57:56

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).

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

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.

Update

Replying to your questions in comments.

But when I try the i2cdetect command it shows UU.

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.

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

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.

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 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.
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!