Edit: I was being a dolt and was focused on I2C packages only (opkg list | grep i2c) and neglected to install a critical one. Once installed everything worked:
opkg install kmod-gpio-pcf857x
I have no problem running I2C, specifically with a pcf8574 on the 66XX series routers. I would use those routers except that have issues with rt3070 chipsets where it can’t use a USB wifi more than occasionally unless it is plugged in through a USB hub (powered or unpowered). It appears to have issues handshaking with that chipset reliably on all the adapters I have - but that’s a story for another post.
I have done the same process on the on the MT300N (using the clean CC image from GL). It seems like it will work up until it is time to export the GPIOs that should be created by the PCF chip and then it appears there is a conflict with the rt2880 driver trying to use those pins, which is confusing because from what I understand these pins are free to use for other uses.
I selected GPIO 2 for SDA and GPIO 44 for SCL. I verified those GPIOs work fine as both in and out modes prior to using them for I2C. I have installed all the modules and the PCF is detected on 0x20.
#insmod i2c-gpio-custom bus0=0,2,44
dmesg seems to indicate no problem with this
[ 99.100000] i2c-gpio i2c-gpio.0: no of_node; not parsing pinctrl DT
[ 99.100000] rt2880-pinmux pinctrl: request pin 2 (io2) for pio:2
[ 99.100000] rt2880-pinmux pinctrl: request pin 44 (io44) for pio:44
[ 99.100000] i2c-gpio i2c-gpio.0: using pins 2 (SDA) and 44 (SCL)
#i2cdetect 0
reports the device was found at 0x20 (no new errors or logs in dmesg)
#echo pcf8574 0x20 > /sys/bus/i2c/devices/i2c-0/new_device
dmesg reports it seems OK with [ 268.870000] i2c i2c-0: new_device: Instantiated device pcf8574 at 0x20
All of that works as expected and you would think it is going to work… and by the way, this same chip/board does work with the 66XX when I plug it into it, so it isn’t the PCF module. EXCEPT…
The dmesg is missing an important part, “gpiochip_add” is missing in that log that tells us it created a new chip for the expander and what new GPIOs were registered on the device. If it were working like it should it would say something like this as it does on the 66XX series: “<span style=“background-color: #f8f8f8; color: #000000; font-family: Consolas, Monaco, monospace;”>gpiochip_add: registered GPIOs 56 to 63 on device: pcf8574”</span>
The problem happens that I expect the PCF to register as chip56 and I can export GPIOs 56 through 63. Or, even if it wasn’t going to be at 56 that a new chip would be registered in /sys/class/gpio. But after creating the new device no new chip shows up in there. So I try to export gpio 56 anyways.
echo 56 > /sys/class/gpio/export
ash: write error: Invalid argument
dmesg says:
[ 240.890000] rt2880-pinmux pinctrl: request pin 56 (io56) for pio:56
[ 240.890000] rt2880-pinmux pinctrl: pin 56 is not set to gpio mux
[ 240.890000] rt2880-pinmux pinctrl: request() failed for pin 56
[ 240.900000] rt2880-pinmux pinctrl: pin-56 (pio:56) status -22
Since I don’t see a new chip appear for the PCF it seems like it really is not initiated and it did not create the GPIOs which makes me believe that gpiochip_add is not being called.
Can anyone assist on this? We are so close to buying a lot of these GL routers but it seems like each model has some sort of problem. One works great with I2C but has trouble using the adapters we use, one works great with adapters but I2C is broken. The MT300N has been the best performer for our application but without I2C is won’t work.