Adding gpio expander (pca9555) to imx6 linux

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Adding gpio expander (pca9555) to imx6 linux

Jump to solution
4,825 Views
j-g
Contributor III

Hello,

I am trying to add three pca9555 i2c gpio expanders by adding them to my board file (board-mx6q_qmx6.c) and have some issues I hope someone could help me with.  I've already enabled pca953x in the kernel config and added the below to the board file.  My first question is can someone explain what to place in for .gpio_base specific to the imx6?  I placed in -1 as I saw in a post elsewhere but there were complaints.  I also tried some static values thinking that these must be past the last gpio, 232 for ext1_pdata, 248 for ext2_pdata and 254 for ext3_pdata, but only the first one showed up in /sys/class/gpio/ and got complaints about the other two.  Thank you.

Complaints:

pca953x 0-0021: failed to request irq 0

pca953x: probe of 0-0021 failed with error -16

pca953x 0-0022: failed to request irq 0

pca953x: probe of 0-0022 failed with error -16

What I put in the board file:

/* PCA9555 */

static struct imxi2c_platform_data mx6q_qmx6_i2c_data = {
.bitrate = 100000,
};


static struct pca953x_platform_data gpio_ext1_pdata = {
.gpio_base = ?,
};

static struct pca953x_platform_data gpio_ext2_pdata = {
.gpio_base = ?,
};

static struct pca953x_platform_data gpio_ext3_pdata = {
.gpio_base = ?,
};

static struct i2c_board_info mxc_i2c0_board_info[] __initdata = {
{
  I2C_BOARD_INFO("pca9555", 0x20),
  .platform_data = &gpio_ext1_pdata,
},
{
  I2C_BOARD_INFO("pca9555", 0x21),
  .platform_data = &gpio_ext2_pdata,
},
{
  I2C_BOARD_INFO("pca9555", 0x22),
  .platform_data = &gpio_ext3_pdata,
},
};

Place this in board specific initialization function:   static void __init_mx6_qmx6_board_init(void)

/* I2C */

imx6q_add_imx_i2c(0, &mx6q_qmx6_i2c_data);

Labels (4)
0 Kudos
1 Solution
2,592 Views
j-g
Contributor III

Had to increase the value of ARCH_NR_GPIOS in /include/asm-generic/gpio.h

View solution in original post

0 Kudos
2 Replies
2,592 Views
j-g
Contributor III

Update:

If I add only two pca9555 (any combination of two, either 0x20,0x21 or 0x21,0x22, or 0x20,0x22) both will work and show up under /sys/class/gpio/gpiochipX, but if I try to add all three only the first two 0x20 and 0x21 will load successfully but not 0x22.  Any ideas?

.gpio_base = -1 on all three.

0 Kudos
2,593 Views
j-g
Contributor III

Had to increase the value of ARCH_NR_GPIOS in /include/asm-generic/gpio.h

0 Kudos