I have some troubles to get my PCA9555 gpio extender registered as something like /sys/class/gpio/gpiochipX. The I²C-adapter is the i2c-tiny-usb, connected to a TL-WR1043ND. While other devices can be added through sysfs without any problems like this:
root@OpenWrt:/# echo pca9548 0x70 > /sys/bus/i2c/devices/i2c-1/new_device
root@OpenWrt:/# dmesg | tail
i2c i2c-1: Added multiplexed i2c bus 2
i2c i2c-1: Added multiplexed i2c bus 3
i2c i2c-1: Added multiplexed i2c bus 4
i2c i2c-1: Added multiplexed i2c bus 5
i2c i2c-1: Added multiplexed i2c bus 6
i2c i2c-1: Added multiplexed i2c bus 7
i2c i2c-1: Added multiplexed i2c bus 8
i2c i2c-1: Added multiplexed i2c bus 9
pca954x 1-0070: registered 8 multiplexed busses for I2C switch pca9548
i2c i2c-1: new_device: Instantiated device pca9548 at 0x70
it just doesn't work with the PCA9555:
root@OpenWrt:/# echo pca9555 0x21 > /sys/bus/i2c/devices/i2c-1/new_device
root@OpenWrt:/# dmesg | tail
pca953x 1-0021: no platform data
pca953x: probe of 1-0021 failed with error -22
i2c i2c-1: new_device: Instantiated device pca9555 at 0x21
My researches so far got me to the point, that the platform data (as indicated) needs to be extended. So I added the following lines to my arch/mips/ar71xx/mach-tl-wr1043nd.c:
#include <linux/i2c.h>
#include <linux/i2c/pca953x.h>
static struct pca953x_platform_data pca9555_0 = {
.gpio_base = 32,
};
static struct i2c_board_info __initdata i2c_tiny_board_info[] = {
{
I2C_BOARD_INFO("pca9555",0x21),
.platform_data = &pca9555_0,
}
};
#endif
static struct platform_device i2c_tiny_usb_device = {
.name = "i2c-tiny-usb",
.id = 0,
};
static void __devinit i2c_tiny_usb_init(void)
{
i2c_register_board_info(0,i2c_tiny_board_info, ARRAY_SIZE(i2c_tiny_board_info));
platform_device_register(&i2c_tiny_usb_device);
};
And in the __init section:
i2c_tiny_usb_init();
It compiles without any issues, but now my I²C-adapter is registered as i2c-1 (instead of i2c-0) and the PCA9555 is not registered as gpiochip1.
How can I tell the kernel to bind the PCA9555 to the I²C-bus provided by the i2c-tiny-usb (or later on to one of the switched busses provided by a PCA9548 mux connected inbetween)? Or is there any other way to do a userspace configuration at runtime?