* PCA GPIO interrupt triggers
@ 2012-03-22 15:58 Peter Rusko
2012-03-24 17:02 ` Grant Likely
2012-03-25 7:40 ` Wolfram Sang
0 siblings, 2 replies; 5+ messages in thread
From: Peter Rusko @ 2012-03-22 15:58 UTC (permalink / raw)
To: Grant Likely; +Cc: linux-kernel
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:
diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c
index 147df8a..be9aff4 100644
--- a/drivers/gpio/gpio-pca953x.c
+++ b/drivers/gpio/gpio-pca953x.c
@@ -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?
--
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: rusko.peter@prolan.hu
Web: www.prolan.hu
Timezone:CET
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: PCA GPIO interrupt triggers
2012-03-22 15:58 PCA GPIO interrupt triggers Peter Rusko
@ 2012-03-24 17:02 ` Grant Likely
2012-03-25 7:40 ` Wolfram Sang
1 sibling, 0 replies; 5+ messages in thread
From: Grant Likely @ 2012-03-24 17:02 UTC (permalink / raw)
To: Peter Rusko, David Jander; +Cc: linux-kernel
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1541 bytes --]
On Thu, 22 Mar 2012 16:58:09 +0100, Peter Rusko <rusko.peter@prolan.hu> wrote:
> 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.
>
> diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c
> index 147df8a..be9aff4 100644
> --- a/drivers/gpio/gpio-pca953x.c
> +++ b/drivers/gpio/gpio-pca953x.c
> @@ -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?
>
> --
> 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: rusko.peter@prolan.hu
> Web: www.prolan.hu
> Timezone:CET
--
Grant Likely, B.Sc, P.Eng.
Secret Lab Technologies,Ltd.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: PCA GPIO interrupt triggers
2012-03-22 15:58 PCA GPIO interrupt triggers Peter Rusko
2012-03-24 17:02 ` Grant Likely
@ 2012-03-25 7:40 ` Wolfram Sang
2012-03-26 10:27 ` PCA GPIO interrupt triggers, matrix-keypad Peter Rusko
1 sibling, 1 reply; 5+ messages in thread
From: Wolfram Sang @ 2012-03-25 7:40 UTC (permalink / raw)
To: Peter Rusko; +Cc: Grant Likely, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 620 bytes --]
> 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?
> I think, this patch should work:
Think? Can't you test it :)
Regards,
Wolfram
--
Pengutronix e.K. | Wolfram Sang |
Industrial Linux Solutions | http://www.pengutronix.de/ |
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: PCA GPIO interrupt triggers, matrix-keypad
2012-03-25 7:40 ` Wolfram Sang
@ 2012-03-26 10:27 ` Peter Rusko
2012-03-27 7:54 ` Wolfram Sang
0 siblings, 1 reply; 5+ messages in thread
From: Peter Rusko @ 2012-03-26 10:27 UTC (permalink / raw)
To: Wolfram Sang; +Cc: Grant Likely, linux-kernel
> ? 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?
>
Yes, you're right, the problem is not there.
>> 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:
diff --git a/drivers/input/keyboard/matrix_keypad.c
b/drivers/input/keyboard/matrix_keypad.c
index e2ae657..f047502 100644
--- a/drivers/input/keyboard/matrix_keypad.c
+++ b/drivers/input/keyboard/matrix_keypad.c
@@ -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
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: PCA GPIO interrupt triggers, matrix-keypad
2012-03-26 10:27 ` PCA GPIO interrupt triggers, matrix-keypad Peter Rusko
@ 2012-03-27 7:54 ` Wolfram Sang
0 siblings, 0 replies; 5+ messages in thread
From: Wolfram Sang @ 2012-03-27 7:54 UTC (permalink / raw)
To: Peter Rusko; +Cc: Grant Likely, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 1573 bytes --]
On Mon, Mar 26, 2012 at 12:27:28PM +0200, Peter Rusko wrote:
> >? 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?
> >
> Yes, you're right, the problem is not there.
It was the most likely answer looking at how IRQ_TYPE_EDGE_BOTH is
defined.
>
> >>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.
> Another change in the code was with the IRQ request. I could only make
> the matrix-keypad driver working with threaded interrupts:
[...]
> 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
--
Pengutronix e.K. | Wolfram Sang |
Industrial Linux Solutions | http://www.pengutronix.de/ |
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2012-03-27 7:54 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-22 15:58 PCA GPIO interrupt triggers Peter Rusko
2012-03-24 17:02 ` Grant Likely
2012-03-25 7:40 ` Wolfram Sang
2012-03-26 10:27 ` PCA GPIO interrupt triggers, matrix-keypad Peter Rusko
2012-03-27 7:54 ` Wolfram Sang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox