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.
- How is the probe function called?
- Should the probe be done manually to locate the devices?
- Is the
probe
call similar to theopen
call? - 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...
Any help would be appreciated.
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:
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.
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.So you unloaded the driver and now
i2cdetect
shows you that there is some device on0x20
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.I can see two possible causes to this issue.
0x20
address, but missing description for device with0x21
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.0x20
address. See section1.4 Hardware Address Decoder
in MCP23017 datasheet for details. CheckA0
,A1
,A2
pins on your chips.