linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Using PXA arm board with MAX7319 GPIO expander input
@ 2010-02-08  5:44 Jebediah Huang
  2010-02-08  6:02 ` Eric Miao
  2010-02-09  1:07 ` Eric Miao
  0 siblings, 2 replies; 14+ messages in thread
From: Jebediah Huang @ 2010-02-08  5:44 UTC (permalink / raw)
  To: linux-arm-kernel, linux-input

Hello ,

I have PXA166 board with MAX7319 GPIO expander connected with 8
buttons. When any button is pressed, I want to get input event. Can
this be done?

I have read the littleton and aspenite code to try. The SDA is 105,
SCL is 106. I use MAX732x driver. It is set as I2C slave at 0x6C. So I
set up:

static struct i2c_pxa_platform_data pwri2c_info __initdata = {
        .use_pio                = 1,
};

static unsigned long peony_pin_config[] __initdata = {
        /* i2c bus */
        GPIO105_CI2C_SDA,
        GPIO106_CI2C_SCL,
}

static struct max732x_platform_data max7319_data[] = {
        [0] = {
                .gpio_base      = GPIO_EXT0(0),
        },
};

static struct i2c_board_info i2c_board_info[] =
{
        {
                .type           = "max7319",
                .addr           = 0x6C,
                .irq            = IRQ_GPIO(105),
                .platform_data  = &max7319_data[0],
        },
};

when bootup I see;
<6>[    0.290770] I2C: i2c-0: PXA I2C adapter
<6>[    0.307118] I2C: i2c-1: PXA I2C adapter
<6>[    0.821709] hello pony_init
<3>[    0.838559] platform_driver_register
<6>[    0.868069] max732x_read: read g 1
<6>[    0.881893] max732x_read: read g 0
<4>[    0.898895] i2c: error: exhausted retries
<4>[    0.911947] i2c: msg_num: 0 msg_idx: -2000 msg_ptr: 0
<4>[    0.927509] i2c: ICR: 000007e0 ISR: 00000002
<4>[    0.927526] i2c: log: [00000006:00000000] [00000006:00000000]
[00000006:00000000] [00000006:00000000] [00000006:00000000]
[00000006:00000000] [0000000
<3>[    1.167890] dummy 0-005d: failed reading
<5>[    1.182585] SCSI subsystem initialized

Maybe max732x driver is not getting correct data from my setup? No
event when pressing button. If any ideas?

Thank you very much!
Jeb

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Using PXA arm board with MAX7319 GPIO expander input
  2010-02-08  5:44 Using PXA arm board with MAX7319 GPIO expander input Jebediah Huang
@ 2010-02-08  6:02 ` Eric Miao
  2010-02-08  7:02   ` Jebediah Huang
  2010-02-09  1:07 ` Eric Miao
  1 sibling, 1 reply; 14+ messages in thread
From: Eric Miao @ 2010-02-08  6:02 UTC (permalink / raw)
  To: Jebediah Huang; +Cc: linux-arm-kernel, linux-input

On Mon, Feb 8, 2010 at 1:44 PM, Jebediah Huang <jebediah.huang@gmail.com> wrote:
> Hello ,
>
> I have PXA166 board with MAX7319 GPIO expander connected with 8
> buttons. When any button is pressed, I want to get input event. Can
> this be done?
>
> I have read the littleton and aspenite code to try. The SDA is 105,
> SCL is 106. I use MAX732x driver. It is set as I2C slave at 0x6C. So I
> set up:
>
> static struct i2c_pxa_platform_data pwri2c_info __initdata = {
>        .use_pio                = 1,
> };
>
> static unsigned long peony_pin_config[] __initdata = {
>        /* i2c bus */
>        GPIO105_CI2C_SDA,
>        GPIO106_CI2C_SCL,
> }
>
> static struct max732x_platform_data max7319_data[] = {
>        [0] = {
>                .gpio_base      = GPIO_EXT0(0),
>        },
> };
>
> static struct i2c_board_info i2c_board_info[] =
> {
>        {
>                .type           = "max7319",
>                .addr           = 0x6C,
>                .irq            = IRQ_GPIO(105),

This doesn't look correct, if max7319 is ever able to interrupt the host
CPU, this should be something other than SDA.

However, this isn't supposed to be the reason for the failure. The
failure looks like an I2C communication issue to me, which means:

1. the i2c host driver isn't setup correctly
2. pin setup
3. max7319 power supply and chip select
4. i2c bus (incorrect pull-up/down etc)
5. i2c device address

I'd recommend an oscilloscope/LA for the I2C protocol on the lines
to identify the real issue.

>                .platform_data  = &max7319_data[0],
>        },
> };
>
> when bootup I see;
> <6>[    0.290770] I2C: i2c-0: PXA I2C adapter
> <6>[    0.307118] I2C: i2c-1: PXA I2C adapter
> <6>[    0.821709] hello pony_init
> <3>[    0.838559] platform_driver_register
> <6>[    0.868069] max732x_read: read g 1
> <6>[    0.881893] max732x_read: read g 0
> <4>[    0.898895] i2c: error: exhausted retries
> <4>[    0.911947] i2c: msg_num: 0 msg_idx: -2000 msg_ptr: 0
> <4>[    0.927509] i2c: ICR: 000007e0 ISR: 00000002
> <4>[    0.927526] i2c: log: [00000006:00000000] [00000006:00000000]
> [00000006:00000000] [00000006:00000000] [00000006:00000000]
> [00000006:00000000] [0000000
> <3>[    1.167890] dummy 0-005d: failed reading
> <5>[    1.182585] SCSI subsystem initialized
>
> Maybe max732x driver is not getting correct data from my setup? No
> event when pressing button. If any ideas?
>
> Thank you very much!
> Jeb
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
>
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Using PXA arm board with MAX7319 GPIO expander input
  2010-02-08  6:02 ` Eric Miao
@ 2010-02-08  7:02   ` Jebediah Huang
  2010-02-08  7:36     ` Daniel Mack
  2010-02-08 11:08     ` Jebediah Huang
  0 siblings, 2 replies; 14+ messages in thread
From: Jebediah Huang @ 2010-02-08  7:02 UTC (permalink / raw)
  To: Eric Miao; +Cc: linux-arm-kernel, linux-input

On Mon, Feb 8, 2010 at 2:02 PM, Eric Miao <eric.y.miao@gmail.com> wrote:
> On Mon, Feb 8, 2010 at 1:44 PM, Jebediah Huang <jebediah.huang@gmail.com> wrote:
>> static struct i2c_board_info i2c_board_info[] =
>> {
>>        {
>>                .type           = "max7319",
>>                .addr           = 0x6C,
>>                .irq            = IRQ_GPIO(105),
>
> This doesn't look correct, if max7319 is ever able to interrupt the host
> CPU, this should be something other than SDA.

Thank you. I remove irq now. It is not used.

>
> However, this isn't supposed to be the reason for the failure. The
> failure looks like an I2C communication issue to me, which means:
>
> 1. the i2c host driver isn't setup correctly
> 2. pin setup
> 3. max7319 power supply and chip select
> 4. i2c bus (incorrect pull-up/down etc)
> 5. i2c device address
>
> I'd recommend an oscilloscope/LA for the I2C protocol on the lines
> to identify the real issue.
>

I test hardware is ok. I test with this:
 {
        int fd, t;
        int i;
        char buf[512];
        fd = open("/dev/i2c-0", O_RDWR);
        printf("fd=%d\n",fd);
        t = ioctl(fd, I2C_SLAVE, 0x6c);
        printf("t=%d\n",t);
        memset(buf,0,512);
        t = read(fd,buf,512);
        printf("t=%d\n",t);
        for(i=0;i<t;i++) {
        printf("0x%x,",buf[i]);
        }
        printf("\n");
        exit(0);
}

output if max732x enabled is:
# ./i2ctest
[  184.070025] i2c: error: exhausted retries
fd=3
t=-1
[  184.074256] i2c: msg_num: 0 msg_idx: -2000 msg_ptr: 0
[  184.080428] i2c: ICR: 000007e0 ISR: 00000002
[  184.080444] i2c: log: [00000006:00000000] [00000006:00000000]
[00000006:00000000] [00000006:00000000] [00000006:00000000]
[00000006:00000000] [00000006:00
000000] [00000006:00000000] [00000006:00000000] [00000006:00000000]
[00000006:00000000] [00000007:00000000] [00000447:000007e0]
t=-1

disable max732x is:
# ./i2ctest no button pressed
fd=3
t=0
t=512
0xff,0x8,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff
,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0
,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xf
f,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x
0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0x
ff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0
x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0
xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,
0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,
0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff
,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0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f,0x0,0x7f,0x0,0x7f,0x0
,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7
f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x
0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x
7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0
x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0
x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,

I think problem is my setup max732x failure.
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Using PXA arm board with MAX7319 GPIO expander input
  2010-02-08  7:02   ` Jebediah Huang
@ 2010-02-08  7:36     ` Daniel Mack
  2010-02-08  7:56       ` Jebediah Huang
  2010-02-08 11:08     ` Jebediah Huang
  1 sibling, 1 reply; 14+ messages in thread
From: Daniel Mack @ 2010-02-08  7:36 UTC (permalink / raw)
  To: Jebediah Huang; +Cc: Eric Miao, linux-arm-kernel, linux-input

On Mon, Feb 08, 2010 at 03:02:14PM +0800, Jebediah Huang wrote:
> On Mon, Feb 8, 2010 at 2:02 PM, Eric Miao <eric.y.miao@gmail.com> wrote:
> > On Mon, Feb 8, 2010 at 1:44 PM, Jebediah Huang <jebediah.huang@gmail.com> wrote:
> >> static struct i2c_board_info i2c_board_info[] =
> >> {
> >>        {
> >>                .type           = "max7319",
> >>                .addr           = 0x6C,
> >>                .irq            = IRQ_GPIO(105),
> >
> > This doesn't look correct, if max7319 is ever able to interrupt the host
> > CPU, this should be something other than SDA.
> 
> Thank you. I remove irq now. It is not used.

If you didn't wire an IRQ from the max7319 to your CPU, you can't easily
use it as an input device. I2C is a polled bus, all transactions are
always initiated from the CPU side. So you would need to 'ask' the chip
constantly for its current state, which is not good.

The INT line should be connected to some GPIO on your PXA so the chip
can actively let the PXA know when any input line stated changed.
Everything else makes very little sense.

> I test hardware is ok. I test with this:
>  {
>         int fd, t;
>         int i;
>         char buf[512];
>         fd = open("/dev/i2c-0", O_RDWR);
>         printf("fd=%d\n",fd);
>         t = ioctl(fd, I2C_SLAVE, 0x6c);
>         printf("t=%d\n",t);
>         memset(buf,0,512);
>         t = read(fd,buf,512);
>         printf("t=%d\n",t);
>         for(i=0;i<t;i++) {
>         printf("0x%x,",buf[i]);
>         }
>         printf("\n");
>         exit(0);
> }
> 
> output if max732x enabled is:
> # ./i2ctest
> [  184.070025] i2c: error: exhausted retries
> fd=3
> t=-1
> [  184.074256] i2c: msg_num: 0 msg_idx: -2000 msg_ptr: 0
> [  184.080428] i2c: ICR: 000007e0 ISR: 00000002
> [  184.080444] i2c: log: [00000006:00000000] [00000006:00000000]
> [00000006:00000000] [00000006:00000000] [00000006:00000000]
> [00000006:00000000] [00000006:00
> 000000] [00000006:00000000] [00000006:00000000] [00000006:00000000]
> [00000006:00000000] [00000007:00000000] [00000447:000007e0]
> t=-1

How do you enable/disable the chip? As Eric said, the error above
indicates an eletrical issue with the bus. 

> disable max732x is:
> # ./i2ctest no button pressed

What are you testing without the chip?

Daniel

--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Using PXA arm board with MAX7319 GPIO expander input
  2010-02-08  7:36     ` Daniel Mack
@ 2010-02-08  7:56       ` Jebediah Huang
  0 siblings, 0 replies; 14+ messages in thread
From: Jebediah Huang @ 2010-02-08  7:56 UTC (permalink / raw)
  To: Daniel Mack; +Cc: Eric Miao, linux-arm-kernel, linux-input

On Mon, Feb 8, 2010 at 3:36 PM, Daniel Mack <daniel@caiaq.de> wrote:
> On Mon, Feb 08, 2010 at 03:02:14PM +0800, Jebediah Huang wrote:
>>
>> output if max732x enabled is:
>> # ./i2ctest
>> [  184.070025] i2c: error: exhausted retries
>> fd=3
>> t=-1
>> [  184.074256] i2c: msg_num: 0 msg_idx: -2000 msg_ptr: 0
>> [  184.080428] i2c: ICR: 000007e0 ISR: 00000002
>> [  184.080444] i2c: log: [00000006:00000000] [00000006:00000000]
>> [00000006:00000000] [00000006:00000000] [00000006:00000000]
>> [00000006:00000000] [00000006:00
>> 000000] [00000006:00000000] [00000006:00000000] [00000006:00000000]
>> [00000006:00000000] [00000007:00000000] [00000447:000007e0]
>> t=-1
>
> How do you enable/disable the chip? As Eric said, the error above
> indicates an eletrical issue with the bus.

I disable by doing menuconfig and disable max732x:

# CONFIG_GPIO_MAX732X is not set

>
>> disable max732x is:
>> # ./i2ctest no button pressed
>
> What are you testing without the chip?
>

I am testing the I2C from i2ctest application using I2C_PXA.
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Using PXA arm board with MAX7319 GPIO expander input
  2010-02-08  7:02   ` Jebediah Huang
  2010-02-08  7:36     ` Daniel Mack
@ 2010-02-08 11:08     ` Jebediah Huang
  2010-02-08 11:33       ` Daniel Mack
  1 sibling, 1 reply; 14+ messages in thread
From: Jebediah Huang @ 2010-02-08 11:08 UTC (permalink / raw)
  To: Eric Miao; +Cc: linux-arm-kernel, linux-input

On Mon, Feb 8, 2010 at 3:02 PM, Jebediah Huang <jebediah.huang@gmail.com> wrote:
>
> # ./i2ctest 2 button pressed
> fd=3
> t=0
> t=512
> 0x7f,0x80,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7
> f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x
> 0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x
> 7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0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,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x
> 0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x
> 7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0
> x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0
> x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,0x7f,0x0,
>
> I think problem is my setup max732x failure.
>

Is it correct that max732x driver will take i2c configuration from my
setup info and make each max7319 input signel into a gpio?

Hardware work correctly because without max732x driver, above i2c-dev
code can read max7319 input signel. Configuration is correct.

gpio_base is starting where max732x driver will add new gpio number
for max7319 signel.

static struct max732x_platform_data max7319_data[] = {
       [0] = {
               .gpio_base      =  NR_BUILTIN_GPIO,
       },
};

static struct i2c_board_info i2c_board_info[] =
{
       {
               .type           = "max7319",
               .addr           = 0x6C,
               .irq            = IRQ_GPIO(125), <= this is my irq pin
for max7319 INT_N
               .platform_data  = &max7319_data[0],
       },
};

static unsigned long peony_pin_config[] __initdata = {
       /* i2c bus */
       GPIO105_CI2C_SDA,
       GPIO106_CI2C_SCL,
} <= this correct because i2c-dev can work.

Is my understanding wrong?

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Using PXA arm board with MAX7319 GPIO expander input
  2010-02-08 11:08     ` Jebediah Huang
@ 2010-02-08 11:33       ` Daniel Mack
  2010-02-08 12:32         ` Marc Zyngier
  0 siblings, 1 reply; 14+ messages in thread
From: Daniel Mack @ 2010-02-08 11:33 UTC (permalink / raw)
  To: Jebediah Huang; +Cc: Eric Miao, linux-arm-kernel, linux-input

On Mon, Feb 08, 2010 at 07:08:06PM +0800, Jebediah Huang wrote:
> Is it correct that max732x driver will take i2c configuration from my
> setup info and make each max7319 input signel into a gpio?
> 
> Hardware work correctly because without max732x driver, above i2c-dev
> code can read max7319 input signel. Configuration is correct.
> 
> gpio_base is starting where max732x driver will add new gpio number
> for max7319 signel.

Yes, that should be right. After the driver is probed successfully, you
should be able to access the GPIOs with generic functions as described
in include/linux/gpio.h. Can you try if that works?

And if you can, you should really hook up an I2C analyzer to your bus
and see what is happening electrically and which messages pass the bus.

> static struct max732x_platform_data max7319_data[] = {
>        [0] = {
>                .gpio_base      =  NR_BUILTIN_GPIO,
>        },
> };
> 
> static struct i2c_board_info i2c_board_info[] =
> {
>        {
>                .type           = "max7319",
>                .addr           = 0x6C,
>                .irq            = IRQ_GPIO(125), <= this is my irq pin
> for max7319 INT_N

I just saw that there is indeed no support for irq line handling in this
driver. In order to use these lines as input for something like the
gpio_keys driver, support for that should be added. I never used this
driver and can't say whether it is under active development.

> Is my understanding wrong?

One thing you should also know is that once the kernel driver is active,
it blocks the address it is configured to, so you can't access the same
address via the userspace API. That might be confusing if you're not
aware of that.

Daniel

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Using PXA arm board with MAX7319 GPIO expander input
  2010-02-08 11:33       ` Daniel Mack
@ 2010-02-08 12:32         ` Marc Zyngier
  2010-02-08 13:04           ` Daniel Mack
  2010-02-09  1:05           ` Eric Miao
  0 siblings, 2 replies; 14+ messages in thread
From: Marc Zyngier @ 2010-02-08 12:32 UTC (permalink / raw)
  To: Daniel Mack; +Cc: Jebediah Huang, Eric Miao, linux-arm-kernel, linux-input

> I just saw that there is indeed no support for irq line handling in this
> driver. In order to use these lines as input for something like the
> gpio_keys driver, support for that should be added. I never used this
> driver and can't say whether it is under active development.

It should be rather easy to introduce something similar to what I did for
the pca953x driver (http://patchwork.kernel.org/patch/77418/)

MAX732x seems a lot saner than PCA953x, as it has at least a hardware
interrupt mask...

        M.
-- 
And if you don't know where you're going, any road will take you there...



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Using PXA arm board with MAX7319 GPIO expander input
  2010-02-08 12:32         ` Marc Zyngier
@ 2010-02-08 13:04           ` Daniel Mack
  2010-02-09  1:05           ` Eric Miao
  1 sibling, 0 replies; 14+ messages in thread
From: Daniel Mack @ 2010-02-08 13:04 UTC (permalink / raw)
  To: Marc Zyngier; +Cc: Jebediah Huang, Eric Miao, linux-arm-kernel, linux-input

On Mon, Feb 08, 2010 at 12:32:38PM -0000, Marc Zyngier wrote:
> > I just saw that there is indeed no support for irq line handling in this
> > driver. In order to use these lines as input for something like the
> > gpio_keys driver, support for that should be added. I never used this
> > driver and can't say whether it is under active development.
> 
> It should be rather easy to introduce something similar to what I did for
> the pca953x driver (http://patchwork.kernel.org/patch/77418/)
> 
> MAX732x seems a lot saner than PCA953x, as it has at least a hardware
> interrupt mask...

Is anyone with access to such hardware able to implement this?

Daniel

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Using PXA arm board with MAX7319 GPIO expander input
  2010-02-08 12:32         ` Marc Zyngier
  2010-02-08 13:04           ` Daniel Mack
@ 2010-02-09  1:05           ` Eric Miao
  2010-02-09  7:39             ` Marc Zyngier
  1 sibling, 1 reply; 14+ messages in thread
From: Eric Miao @ 2010-02-09  1:05 UTC (permalink / raw)
  To: Marc Zyngier; +Cc: Daniel Mack, Jebediah Huang, linux-arm-kernel, linux-input

On Mon, Feb 8, 2010 at 8:32 PM, Marc Zyngier <maz@misterjones.org> wrote:
>> I just saw that there is indeed no support for irq line handling in this
>> driver. In order to use these lines as input for something like the
>> gpio_keys driver, support for that should be added. I never used this
>> driver and can't say whether it is under active development.
>
> It should be rather easy to introduce something similar to what I did for
> the pca953x driver (http://patchwork.kernel.org/patch/77418/)
>
> MAX732x seems a lot saner than PCA953x, as it has at least a hardware
> interrupt mask...

Well, I'd say max732x is a chip of heavy simplification, input/output direction
of each pin is normally hardcoded, depending on the chip model used, there
seems no such interrupt mask registers for SW use really.


>
>        M.
> --
> And if you don't know where you're going, any road will take you there...
>
>
>
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Using PXA arm board with MAX7319 GPIO expander input
  2010-02-08  5:44 Using PXA arm board with MAX7319 GPIO expander input Jebediah Huang
  2010-02-08  6:02 ` Eric Miao
@ 2010-02-09  1:07 ` Eric Miao
  1 sibling, 0 replies; 14+ messages in thread
From: Eric Miao @ 2010-02-09  1:07 UTC (permalink / raw)
  To: Jebediah Huang; +Cc: linux-arm-kernel, linux-input

On Mon, Feb 8, 2010 at 1:44 PM, Jebediah Huang <jebediah.huang@gmail.com> wrote:
> Hello ,
>
> I have PXA166 board with MAX7319 GPIO expander connected with 8
> buttons. When any button is pressed, I want to get input event. Can
> this be done?
>
> I have read the littleton and aspenite code to try. The SDA is 105,
> SCL is 106. I use MAX732x driver. It is set as I2C slave at 0x6C. So I
> set up:
>
> static struct i2c_pxa_platform_data pwri2c_info __initdata = {
>        .use_pio                = 1,
> };
>
> static unsigned long peony_pin_config[] __initdata = {
>        /* i2c bus */
>        GPIO105_CI2C_SDA,
>        GPIO106_CI2C_SCL,
> }
>
> static struct max732x_platform_data max7319_data[] = {
>        [0] = {
>                .gpio_base      = GPIO_EXT0(0),
>        },
> };
>
> static struct i2c_board_info i2c_board_info[] =
> {
>        {
>                .type           = "max7319",
>                .addr           = 0x6C,
>                .irq            = IRQ_GPIO(105),
>                .platform_data  = &max7319_data[0],
>        },
> };
>
> when bootup I see;
> <6>[    0.290770] I2C: i2c-0: PXA I2C adapter
> <6>[    0.307118] I2C: i2c-1: PXA I2C adapter
> <6>[    0.821709] hello pony_init
> <3>[    0.838559] platform_driver_register
> <6>[    0.868069] max732x_read: read g 1
> <6>[    0.881893] max732x_read: read g 0
> <4>[    0.898895] i2c: error: exhausted retries
> <4>[    0.911947] i2c: msg_num: 0 msg_idx: -2000 msg_ptr: 0
> <4>[    0.927509] i2c: ICR: 000007e0 ISR: 00000002
> <4>[    0.927526] i2c: log: [00000006:00000000] [00000006:00000000]
> [00000006:00000000] [00000006:00000000] [00000006:00000000]
> [00000006:00000000] [0000000
> <3>[    1.167890] dummy 0-005d: failed reading

Just noted the exhausted retries are for 0-005d, you sure this is
max7319 instead of something else, as I was seeing the max7319
address to be 0x6c in the setup above?
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Using PXA arm board with MAX7319 GPIO expander input
  2010-02-09  1:05           ` Eric Miao
@ 2010-02-09  7:39             ` Marc Zyngier
  2010-02-09  8:19               ` Eric Miao
  0 siblings, 1 reply; 14+ messages in thread
From: Marc Zyngier @ 2010-02-09  7:39 UTC (permalink / raw)
  To: Eric Miao; +Cc: Daniel Mack, Jebediah Huang, linux-arm-kernel, linux-input

On Tue, 9 Feb 2010 09:05:22 +0800
Eric Miao <eric.y.miao@gmail.com> wrote:

> On Mon, Feb 8, 2010 at 8:32 PM, Marc Zyngier <maz@misterjones.org> wrote:
> >> I just saw that there is indeed no support for irq line handling in this
> >> driver. In order to use these lines as input for something like the
> >> gpio_keys driver, support for that should be added. I never used this
> >> driver and can't say whether it is under active development.
> >
> > It should be rather easy to introduce something similar to what I did for
> > the pca953x driver (http://patchwork.kernel.org/patch/77418/)
> >
> > MAX732x seems a lot saner than PCA953x, as it has at least a hardware
> > interrupt mask...
> 
> Well, I'd say max732x is a chip of heavy simplification, input/output direction
> of each pin is normally hardcoded, depending on the chip model used, there
> seems no such interrupt mask registers for SW use really.

I'm currently staring at the max7319 datasheet, and it really looks
like there is such a register:

"All input ports are continuously monitored for state changes
(transition detection). Transitions are latched, allowing detection of
transient changes. Any combination of inputs can be selected using the
interrupt mask to assert the INT output. When the MAX7319 is
subsequently accessed through the serial interface, any pending
interrupt is cleared."

So it would seems (although I agree with you that max732x as a GPIO
expander is grossly simplified) that the feature is at least advertised.

	M.
-- 
I'm the slime oozin' out from your TV set...

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Using PXA arm board with MAX7319 GPIO expander input
  2010-02-09  7:39             ` Marc Zyngier
@ 2010-02-09  8:19               ` Eric Miao
  2010-02-09 10:22                 ` Marc Zyngier
  0 siblings, 1 reply; 14+ messages in thread
From: Eric Miao @ 2010-02-09  8:19 UTC (permalink / raw)
  To: Marc Zyngier; +Cc: Jebediah Huang, linux-arm-kernel, Daniel Mack, linux-input

On Tue, Feb 9, 2010 at 3:39 PM, Marc Zyngier <maz@misterjones.org> wrote:
> On Tue, 9 Feb 2010 09:05:22 +0800
> Eric Miao <eric.y.miao@gmail.com> wrote:
>
>> On Mon, Feb 8, 2010 at 8:32 PM, Marc Zyngier <maz@misterjones.org> wrote:
>> >> I just saw that there is indeed no support for irq line handling in this
>> >> driver. In order to use these lines as input for something like the
>> >> gpio_keys driver, support for that should be added. I never used this
>> >> driver and can't say whether it is under active development.
>> >
>> > It should be rather easy to introduce something similar to what I did for
>> > the pca953x driver (http://patchwork.kernel.org/patch/77418/)
>> >
>> > MAX732x seems a lot saner than PCA953x, as it has at least a hardware
>> > interrupt mask...
>>
>> Well, I'd say max732x is a chip of heavy simplification, input/output direction
>> of each pin is normally hardcoded, depending on the chip model used, there
>> seems no such interrupt mask registers for SW use really.
>
> I'm currently staring at the max7319 datasheet, and it really looks
> like there is such a register:
>
> "All input ports are continuously monitored for state changes
> (transition detection). Transitions are latched, allowing detection of
> transient changes. Any combination of inputs can be selected using the
> interrupt mask to assert the INT output. When the MAX7319 is
> subsequently accessed through the serial interface, any pending
> interrupt is cleared."
>
> So it would seems (although I agree with you that max732x as a GPIO
> expander is grossly simplified) that the feature is at least advertised.
>

That sounds like a good news. I'm seeing your previous implementation
of interrupt support on pca953x as a good one, so probably would be
good to follow that, and not sure Jebediah Huang can have this tested :-)

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Using PXA arm board with MAX7319 GPIO expander input
  2010-02-09  8:19               ` Eric Miao
@ 2010-02-09 10:22                 ` Marc Zyngier
  0 siblings, 0 replies; 14+ messages in thread
From: Marc Zyngier @ 2010-02-09 10:22 UTC (permalink / raw)
  To: Eric Miao; +Cc: Daniel Mack, Jebediah Huang, linux-arm-kernel, linux-input


On Tue, February 9, 2010 08:19, Eric Miao wrote:
> That sounds like a good news. I'm seeing your previous implementation
> of interrupt support on pca953x as a good one, so probably would be
> good to follow that, and not sure Jebediah Huang can have this tested :-)

It will probably take a while before I have access to my PXA boards again
(currently moving), but unless someone beats me to it, I'll probably give
it a go in a few weeks. Provided that I can source the hardware, of
course... :-)

        M.
-- 
And if you don't know where you're going, any road will take you there...



^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2010-02-09 10:23 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-02-08  5:44 Using PXA arm board with MAX7319 GPIO expander input Jebediah Huang
2010-02-08  6:02 ` Eric Miao
2010-02-08  7:02   ` Jebediah Huang
2010-02-08  7:36     ` Daniel Mack
2010-02-08  7:56       ` Jebediah Huang
2010-02-08 11:08     ` Jebediah Huang
2010-02-08 11:33       ` Daniel Mack
2010-02-08 12:32         ` Marc Zyngier
2010-02-08 13:04           ` Daniel Mack
2010-02-09  1:05           ` Eric Miao
2010-02-09  7:39             ` Marc Zyngier
2010-02-09  8:19               ` Eric Miao
2010-02-09 10:22                 ` Marc Zyngier
2010-02-09  1:07 ` Eric Miao

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).