PCA GPIO interrupt triggers
Subsystems (2)
Hi,
I'm using a GPIO chip (PCA9554) for a matrix-keypad. The keypad driver itself needs interrupts for both rising and falling edges. The PCA driver (gpio-pca953x.c) doesn't support it, but I don't understand why.
I think, this patch should work:
drivers/gpio/gpio-pca953x.c +0 -6
@@ -356,12 +356,6 @@ static int pca953x_irq_set_type(struct irq_data *d, unsigned int type)uint16_t level = d->irq - chip->irq_base;uint16_t mask =1 << level; -if (!(type &IRQ_TYPE_EDGE_BOTH )) { -dev_err (&chip->client->dev,"irq %d: unsupported type %d\n" , - d->irq, type); -return -EINVAL ; - } -if (type &IRQ_TYPE_EDGE_FALLING ) chip->irq_trig_fall |= mask;else
I think that the other parts of the code checks for rising and falling edges correctly. Am I missing something?
Signature · 10 lines
Ruskó Péter Fejlesztőmérnök Prolan Zrt. / Prolan Co. Hungary 2011 Budakalász, Szentendrei út 1-3. Tel./Phone: +36 20 954 3118 Fax: +36 26 540 420 E-mail: [email protected] Web: www.prolan.hu Timezone:CET
Quoted 7 lines · Peter Rusko
Hi,
I'm using a GPIO chip (PCA9554) for a matrix-keypad. The keypad driver itself needs interrupts for both rising and falling edges. The PCA driver (
gpio-pca953x.c) doesn't support it, but I don't understand why.I think, this patch should work:
Can someone with hardware review this patch please? David perhaps?
g.
Quoted 34 lines
drivers/gpio/gpio-pca953x.c +0
-6@@ -356,12 +356,6 @@ static int pca953x_irq_set_type(struct irq_data *d, unsigned int type)uint16_t level = d->irq - chip->irq_base;uint16_t mask =1 << level; -if (!(type &IRQ_TYPE_EDGE_BOTH )) { -dev_err (&chip->client->dev,"irq %d: unsupported type %d\n" , - d->irq, type); -return -EINVAL ; - } -if (type &IRQ_TYPE_EDGE_FALLING ) chip->irq_trig_fall |= mask;else
I think that the other parts of the code checks for rising and falling edges correctly. Am I missing something?
Signature · 10 lines
Ruskó Péter Fejlesztőmérnök Prolan Zrt. / Prolan Co. Hungary 2011 Budakalász, Szentendrei út 1-3. Tel./Phone: +36 20 954 3118 Fax: +36 26 540 420 E-mail: [email protected] Web: www.prolan.hu Timezone:CET
Signature · 2 lines
Grant Likely, B.Sc, P.Eng. Secret Lab Technologies,Ltd.
Quoted 5 lines
I'm using a GPIO chip (PCA9554) for a matrix-keypad. The keypad driver itself needs interrupts for both rising and falling edges. The PCA driver (
gpio-pca953x.c) doesn't support it, but I don't understand why.
? I fail to see why having EDGE_FALLING together with EDGE_RISING is not supported. Are you sure you didn't use some other IRQ_TYPE here?
Quoted 1 line
I think, this patch should work:
Think? Can't you test it :)
Regards,
Wolfram
Signature · 2 lines
Pengutronix e.K. | Wolfram Sang | Industrial Linux Solutions | http://www.pengutronix.de/ |
Re: PCA GPIO interrupt triggers, matrix-keypad
Quoted 3 lines
? I fail to see why having
EDGE_FALLINGtogether withEDGE_RISINGis not supported. Are you sure you didn't use some otherIRQ_TYPEhere?
Yes, you're right, the problem is not there.
Quoted 3 lines
Quoted 1 line
I think, this patch should work:
Think? Can't you test it :)
I wish that could be that simple :)
I can test it with the matrix-keypad driver. But there's an inverter (+delay) in the circuit (to prevent contact bounce) and I don't know how it affects the signals. But in the end sometimes I don't get e.g. the key-release event.
Another change in the code was with the IRQ request. I could only make the matrix-keypad driver working with threaded interrupts:
drivers/input/keyboard/matrix_keypad.c +0 -0
@@ -48,7 +48,7 @@ struct matrix_keypad { static void __activate_col(const struct matrix_keypad_platform_data
*pdata,
int col, bool on)
{
- bool level_on = !pdata->active_low;
+ bool level_on = (!pdata->active_low)^(!!pdata->invert_output);
if (on) {
gpio_direction_output(pdata->col_gpios[col], level_on);
@@ -341,7 +341,8 @@ static int __devinit init_matrix_gpio(struct platform_device *pdev,
}
} else {
for (i = 0; i < pdata->num_row_gpios; i++) {- err = request_irq(gpio_to_irq(pdata->row_gpios[i]),
+ err = request_threaded_irq(gpio_to_irq(pdata->row_gpios[i]),
+ NULL,
matrix_keypad_interrupt, IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
Is this okay, or is there another way?
Regards,
Peter
Re: PCA GPIO interrupt triggers, matrix-keypad
Quoted 4 lines · Peter Rusko
Quoted 3 lines
? I fail to see why having
EDGE_FALLINGtogether withEDGE_RISINGis not supported. Are you sure you didn't use some otherIRQ_TYPEhere?Yes, you're right, the problem is not there.
It was the most likely answer looking at how IRQ_TYPE_EDGE_BOTH is defined.
Quoted 10 lines
Quoted 4 lines
Quoted 2 lines
I think, this patch should work:
Think? Can't you test it :)
I wish that could be that simple :)
I can test it with the matrix-keypad driver. But there's an inverter (+delay) in the circuit (to prevent contact bounce) and I don't know how it affects the signals. But in the end sometimes I don't get e.g. the key-release event.
It would be great if you could find out, since it might result in arbitrary patches otherwise which would be a waste of time to review.
Quoted 2 lines
Another change in the code was with the IRQ request. I could only make the matrix-keypad driver working with threaded interrupts:
[...]
Quoted 1 line
Is this okay, or is there another way?
The change itself is basically correct, but you need to make a proper patch out of it. Please read Documentation/SubmittingPatches (also Documentation/development-process/ if you haven't already) how to generate one. Look at other threaded irq users how to convert properly (you are missing something). Please CC me to the generated patch.
Regards,
Wolfram
Signature · 2 lines
Pengutronix e.K. | Wolfram Sang | Industrial Linux Solutions | http://www.pengutronix.de/ |