how to use i2ctool to set PCA9535 register?

Hi,

I am having issue setting upper bits (direction out) from the IO Expander 9535 from the my user space application,while
the lower byte D0 to D7 are responding well.
The PCA expander is attached to the bus 2 of the P9 connector of the BB-xM.
I would like to use the i2c tool to see if the issue is it due to the kernel driver or not.
I am using the 3.9.11-x5 #11 SMP Tue Dec 2 11:16:45 CET 2014 armv7l GNU/Linux, (gcc version 4.7.3 20130328 (prerelease) (crosstool-NG linaro-1.13.1-4.7-2013.04-20130415 - Linaro GCC 2013.04).

The 4 expanders are detected using :
i2cdetect -y 2:
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: – -- – -- – -- – -- – -- – -- –
10: – -- – -- – -- – -- – -- – -- – -- – --
20: UU UU UU – UU – -- – -- – -- – -- – -- –
30: – -- – -- – -- – -- – -- – -- – -- – --
40: – -- – -- – -- – -- – -- – -- – -- – --
50: 50 – -- – -- – -- – -- – -- – -- – -- –
60: – -- – -- – -- – -- – -- – -- – -- – --
70: – -- – -- – -- – --

but when trying to send this to adress 0x20 (first expander):
i2cget -y 2 0x20 0x06
Error: Could not set address to 0x20: Device or resource busy.

Could you advise how to send command using i2c tool to the PCA9535? this way I can see if I can set manually using command byte 0x07 D8–D15?

I have instantiate the expander in the board-omap3beagle.c as follow:

static struct pca953x_platform_data pca9535_data[] = {
{.gpio_base = GPIO_EXPANDER_BASE, .invert = 0xFFFFFFFF},
{.gpio_base = GPIO_EXPANDER_BASE+16, .invert = 0xFFFFFFFF},
{.gpio_base = GPIO_EXPANDER_BASE+32, .invert = 0xFFFFFFFF},
{.gpio_base = GPIO_EXPANDER_BASE+48, .invert = 0, .irq_base = -1},
};

static struct i2c_board_info __initdata i2c_expanders_devices[] = {
{
I2C_BOARD_INFO(“pca9535”,0x20),
.platform_data = &pca9535_data[0],
},
{
I2C_BOARD_INFO(“pca9535”,0x21),
.platform_data = &pca9535_data[1],
},
{
I2C_BOARD_INFO(“pca9535”,0x22),
.platform_data = &pca9535_data[2],
},
{
I2C_BOARD_INFO(“pca9535”,0x24),
.platform_data = &pca9535_data[3],
},

Thanks in advance,

It looks like the kernel drivers have already claimed those addresses and will not let i2c tool talk to them. (That is what the UU means.)

The same thing happens for memory addresses 54-57 when the standard kernel with cape manager is installed, because those addresses are reserved for capes.

If you want to check out the hardware, install a different kernel, such as the standard distribution kernel, and those addresses will become available to i2c tools.

— Graham