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
echo mcp23017 0x20 > new_device
Driver 'mcp23s08' is already registered, aborting...
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
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.
Replying to your questions in comments.
But when I try the
i2cdetectcommand 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.
rmmod mcp23017command I see the device still under devices but
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
0x20under devices. The I2C chip at
0x21is still not detected, though the driver says it supports up to 8 chips
I can see two possible causes to this issue.
0x20address, but missing description for device with
0x21address. 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.
0x20address. See section
1.4 Hardware Address Decoderin MCP23017 datasheet for details. Check
A2pins on your chips.