Skip to contentSkip to conversation

arm pxa: remove "direction input" forcing for IRQ GPIOs

PATCH New Rodolfo Giometti 6 participants 15 messages Nov 17, 2009

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 arm pxa: remove "direction input" forcing for IRQ GPIOs

PXA CPUs may use their GPIOs as IRQ lines even if they are selected as outputs (see for example figure 24-1 into PXA27x Processor Family Developer's Manual). So forcing GPIOs IRQ lines as inputs is not correct.

Programmers should set up GPIOs direction according to their usage and the function pxa_gpio_irq_type() should simply enable the IRQ detection.

Cc raffaele.recalcati at bticino.it
---
 arch/arm/plat-pxa/gpio.c |    7 -------
 1 files changed, 0 insertions(+), 7 deletions(-)
arch/arm/plat-pxa/gpio.c +0 -7
index 98548c6..3f17221 100644
@@ -176,13 +176,6 @@ static int pxa_gpio_irq_type(unsigned int irq, unsigned int type)
 		type = IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING;
 	}
 
-	gpdr = __raw_readl(c->regbase + GPDR_OFFSET);
-
-	if (__gpio_is_inverted(gpio))
-		__raw_writel(gpdr | mask,  c->regbase + GPDR_OFFSET);
-	else
-		__raw_writel(gpdr & ~mask, c->regbase + GPDR_OFFSET);
-
 	if (type & IRQ_TYPE_EDGE_RISING)
 		c->irq_edge_rise |= mask;
 	else
Signature · 1 line
1.6.3.3
#1 lore raw

PATCH 1/1 arm pxa: remove "direction input" forcing for IRQ GPIOs

Quoted 8 lines · Rodolfo Giometti

PXA CPUs may use their GPIOs as IRQ lines even if they are selected as outputs (see for example figure 24-1 into PXA27x Processor Family Developer's Manual). So forcing GPIOs IRQ lines as inputs is not correct.

Programmers should set up GPIOs direction according to their usage and the function pxa_gpio_irq_type() should simply enable the IRQ detection.

Interesting. Is this an academic issue or do you actually use that? That would mean you externally drive the IO pin level to something else than the output driver provides, which isn't healthy at all.

Daniel

#2 lore raw

PATCH 1/1 arm pxa: remove "direction input" forcing for IRQ GPIOs

Quoted 6 lines · Daniel Mack
Quoted 5 lines · Rodolfo Giometti

PXA CPUs may use their GPIOs as IRQ lines even if they are selected as outputs (see for example figure 24-1 into PXA27x Processor Family Developer's Manual). So forcing GPIOs IRQ lines as inputs is not correct.

Quoted 7 lines
Quoted 3 lines

Programmers should set up GPIOs direction according to their usage and the function pxa_gpio_irq_type() should simply enable the IRQ detection.

Interesting. Is this an academic issue or do you actually use that? That would mean you externally drive the IO pin level to something else than the output driver provides, which isn't healthy at all.

It's a real configuration with no electrical drawbacks at all! Of course the driver's output must be passive (I use it to detect a CARD insert) but it's functional.

Ciao,

Rodolfo

Signature · 5 lines
GNU/Linux Solutions                  e-mail: giometti at enneenne.com
Linux Device Driver                          giometti at linux.it
Embedded Systems                     phone:  +39 349 2432127
UNIX programming                     skype:  rodolfo.giometti
Freelance ICT Italia - Consulente ICT Italia - www.consulenti-ict.it
#3 lore raw

PATCH 1/1 arm pxa: remove "direction input" forcing for IRQ GPIOs

Quoted 11 lines · Rodolfo Giometti
Quoted 10 lines · Daniel Mack
Quoted 8 lines · Rodolfo Giometti

PXA CPUs may use their GPIOs as IRQ lines even if they are selected as outputs (see for example figure 24-1 into PXA27x Processor Family Developer's Manual). So forcing GPIOs IRQ lines as inputs is not correct.

Programmers should set up GPIOs direction according to their usage and the function pxa_gpio_irq_type() should simply enable the IRQ detection.

Quoted 7 lines
Quoted 3 lines

Interesting. Is this an academic issue or do you actually use that? That would mean you externally drive the IO pin level to something else than the output driver provides, which isn't healthy at all.

It's a real configuration with no electrical drawbacks at all! Of course the driver's output must be passive (I use it to detect a CARD insert) but it's functional.

Well, that might be possible configuration but as long as there is no real issue with this, I'd prefer the safe guard here remain intact atm.

#4 lore raw

PATCH 1/1 arm pxa: remove "direction input" forcing for IRQ GPIOs

In reply to Rodolfo Giometti
Quoted 11 lines · Rodolfo Giometti
Quoted 10 lines · Daniel Mack
Quoted 8 lines · Rodolfo Giometti

PXA CPUs may use their GPIOs as IRQ lines even if they are selected as outputs (see for example figure 24-1 into PXA27x Processor Family Developer's Manual). So forcing GPIOs IRQ lines as inputs is not correct.

Programmers should set up GPIOs direction according to their usage and the function pxa_gpio_irq_type() should simply enable the IRQ detection.

Quoted 7 lines
Quoted 3 lines

Interesting. Is this an academic issue or do you actually use that? That would mean you externally drive the IO pin level to something else than the output driver provides, which isn't healthy at all.

It's a real configuration with no electrical drawbacks at all! Of course the driver's output must be passive (I use it to detect a CARD insert) but it's functional.

For such situations, the pullup/pulldown functions are normally used. Have you tried that?

Daniel

#5 lore raw

PATCH 1/1 arm pxa: remove "direction input" forcing for IRQ GPIOs

Quoted 16 lines · Daniel Mack
Quoted 15 lines · Rodolfo Giometti
Quoted 13 lines · Daniel Mack
Quoted 8 lines · Rodolfo Giometti

PXA CPUs may use their GPIOs as IRQ lines even if they are selected as outputs (see for example figure 24-1 into PXA27x Processor Family Developer's Manual). So forcing GPIOs IRQ lines as inputs is not correct.

Programmers should set up GPIOs direction according to their usage and the function pxa_gpio_irq_type() should simply enable the IRQ detection.

Interesting. Is this an academic issue or do you actually use that? That would mean you externally drive the IO pin level to something else than the output driver provides, which isn't healthy at all.

Quoted 6 lines
Quoted 3 lines

It's a real configuration with no electrical drawbacks at all! Of course the driver's output must be passive (I use it to detect a CARD insert) but it's functional.

For such situations, the pullup/pulldown functions are normally used. Have you tried that?

Yes, the code has been tested on my board and it works perfectly.

Ciao,

Rodolfo

Signature · 5 lines
GNU/Linux Solutions                  e-mail: giometti at enneenne.com
Linux Device Driver                          giometti at linux.it
Embedded Systems                     phone:  +39 349 2432127
UNIX programming                     skype:  rodolfo.giometti
Freelance ICT Italia - Consulente ICT Italia - www.consulenti-ict.it
#6 lore raw

PATCH 1/1 arm pxa: remove "direction input" forcing for IRQ GPIOs

Quoted 17 lines · Rodolfo Giometti
Quoted 16 lines · Daniel Mack
Quoted 15 lines · Rodolfo Giometti
Quoted 13 lines · Daniel Mack
Quoted 8 lines · Rodolfo Giometti

PXA CPUs may use their GPIOs as IRQ lines even if they are selected as outputs (see for example figure 24-1 into PXA27x Processor Family Developer's Manual). So forcing GPIOs IRQ lines as inputs is not correct.

Programmers should set up GPIOs direction according to their usage and the function pxa_gpio_irq_type() should simply enable the IRQ detection.

Interesting. Is this an academic issue or do you actually use that? That would mean you externally drive the IO pin level to something else than the output driver provides, which isn't healthy at all.

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

It's a real configuration with no electrical drawbacks at all! Of course the driver's output must be passive (I use it to detect a CARD insert) but it's functional.

For such situations, the pullup/pulldown functions are normally used. Have you tried that?

Yes, the code has been tested on my board and it works perfectly.

What I mean is a mfp_cfg_t configuration as input pin with pull flags MFP_PULL_{HIGH,LOW} set.

Daniel

#7 lore raw

PATCH 1/1 arm pxa: remove "direction input" forcing for IRQ GPIOs

Quoted 22 lines · Daniel Mack
Quoted 21 lines · Rodolfo Giometti
Quoted 20 lines · Daniel Mack
Quoted 18 lines · Rodolfo Giometti
Quoted 6 lines · Daniel Mack
Quoted 5 lines · Rodolfo Giometti

PXA CPUs may use their GPIOs as IRQ lines even if they are selected as outputs (see for example figure 24-1 into PXA27x Processor Family Developer's Manual). So forcing GPIOs IRQ lines as inputs is not correct.

Quoted 7 lines
Quoted 3 lines

Programmers should set up GPIOs direction according to their usage and the function pxa_gpio_irq_type() should simply enable the IRQ detection.

Interesting. Is this an academic issue or do you actually use that? That would mean you externally drive the IO pin level to something else than the output driver provides, which isn't healthy at all.

It's a real configuration with no electrical drawbacks at all! Of course the driver's output must be passive (I use it to detect a CARD insert) but it's functional.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

For such situations, the pullup/pulldown functions are normally used. Have you tried that?

Yes, the code has been tested on my board and it works perfectly.

What I mean is a mfp_cfg_t configuration as input pin with pull flags MFP_PULL_{HIGH,LOW} set.

I see... no I didn't noticed such possibility.

however I suppose that even using such flags my patch is needed in order to avoid pxa_gpio_irq_type() forcing the input direction...

Ciao,

Rodolfo

Signature · 5 lines
GNU/Linux Solutions                  e-mail: giometti at enneenne.com
Linux Device Driver                          giometti at linux.it
Embedded Systems                     phone:  +39 349 2432127
UNIX programming                     skype:  rodolfo.giometti
Freelance ICT Italia - Consulente ICT Italia - www.consulenti-ict.it
#8 lore raw

PATCH 1/1 arm pxa: remove "direction input" forcing for IRQ GPIOs

Quoted 8 lines · Rodolfo Giometti
Quoted 7 lines · Daniel Mack
Quoted 5 lines · Rodolfo Giometti
Quoted 2 lines · Daniel Mack

For such situations, the pullup/pulldown functions are normally used. Have you tried that?

Yes, the code has been tested on my board and it works perfectly.

Quoted 7 lines
Quoted 2 lines

What I mean is a mfp_cfg_t configuration as input pin with pull flags MFP_PULL_{HIGH,LOW} set.

I see... no I didn't noticed such possibility.

however I suppose that even using such flags my patch is needed in order to avoid pxa_gpio_irq_type() forcing the input direction...

No, that's exactly my point. You don't need to set the pin to output direction to make use of those pull features. More than that, when confiugured as output, the pull flags actually don't make sense.

As an IRQ is always inbound, I agree with Eric that the code should stay in there for safety and sanity.

Daniel

#9 lore raw

PATCH 1/1 arm pxa: remove "direction input" forcing for IRQ GPIOs

Quoted 17 lines · Daniel Mack
Quoted 8 lines · Rodolfo Giometti
Quoted 7 lines · Daniel Mack
Quoted 5 lines · Rodolfo Giometti
Quoted 2 lines · Daniel Mack

For such situations, the pullup/pulldown functions are normally used. Have you tried that?

Yes, the code has been tested on my board and it works perfectly.

Quoted 7 lines
Quoted 2 lines

What I mean is a mfp_cfg_t configuration as input pin with pull flags MFP_PULL_{HIGH,LOW} set.

I see... no I didn't noticed such possibility.

however I suppose that even using such flags my patch is needed in order to avoid pxa_gpio_irq_type() forcing the input direction...

Quoted 6 lines

No, that's exactly my point. You don't need to set the pin to output direction to make use of those pull features. More than that, when confiugured as output, the pull flags actually don't make sense.

As an IRQ is always inbound, I agree with Eric that the code should stay in there for safety and sanity.

I see what you mean... I'll test those flags and report results ASAP.

Thanks,

Rodolfo

Signature · 5 lines
GNU/Linux Solutions                  e-mail: giometti at enneenne.com
Linux Device Driver                          giometti at linux.it
Embedded Systems                     phone:  +39 349 2432127
UNIX programming                     skype:  rodolfo.giometti
Freelance ICT Italia - Consulente ICT Italia - www.consulenti-ict.it
#10 lore raw

PATCH 1/1 arm pxa: remove "direction input" forcing for IRQ GPIOs

In reply to Daniel Mack
Quoted 12 lines · Daniel Mack
Quoted 11 lines · Rodolfo Giometti
Quoted 9 lines · Daniel Mack
Quoted 5 lines · Rodolfo Giometti
Quoted 2 lines · Daniel Mack

For such situations, the pullup/pulldown functions are normally used. Have you tried that?

Yes, the code has been tested on my board and it works perfectly.

What I mean is a mfp_cfg_t configuration as input pin with pull flags MFP_PULL_{HIGH,LOW} set.

Quoted 8 lines
Quoted 4 lines

I see... no I didn't noticed such possibility.

however I suppose that even using such flags my patch is needed in order to avoid pxa_gpio_irq_type() forcing the input direction...

No, that's exactly my point. You don't need to set the pin to output direction to make use of those pull features. More than that, when confiugured as output, the pull flags actually don't make sense.

I just looking at pxa27x user manual but I don't see such pull-up functionality... are you sure these settings aren't pxa3xx specific? =:-o

Thanks,

Rodolfo

Signature · 5 lines
GNU/Linux Solutions                  e-mail: giometti at enneenne.com
Linux Device Driver                          giometti at linux.it
Embedded Systems                     phone:  +39 349 2432127
UNIX programming                     skype:  rodolfo.giometti
Freelance ICT Italia - Consulente ICT Italia - www.consulenti-ict.it
#11 lore raw

PATCH 1/1 arm pxa: remove "direction input" forcing for IRQ GPIOs

Quoted 11 lines · Rodolfo Giometti
Quoted 6 lines · Daniel Mack
Quoted 1 line · Rodolfo Giometti

On Tue, Nov 17, 2009 at 01:43:34PM +0100, Daniel Mack wrote:

No, that's exactly my point. You don't need to set the pin to output direction to make use of those pull features. More than that, when confiugured as output, the pull flags actually don't make sense.

I just looking at pxa27x user manual but I don't see such pull-up functionality... are you sure these settings aren't pxa3xx specific? =:-o

I haven't checked the datasheet but the header files that defines this macro only. And it didn't appear to be PXA3x specific.

Anyway, if this is unavailable on your hardware, the proper way would be to place an external resistor on the board (given that you can modify the schematics).

I'm still not convinced that driving the pad as output GPIO and then applying a different level externally to generate an IRQ is intended.

Daniel

#12 lore raw

PATCH 1/1 arm pxa: remove "direction input" forcing for IRQ GPIOs

Quoted 9 lines · Daniel Mack
Quoted 8 lines · Rodolfo Giometti
Quoted 6 lines · Daniel Mack
Quoted 1 line · Rodolfo Giometti

On Tue, Nov 17, 2009 at 01:43:34PM +0100, Daniel Mack wrote:

No, that's exactly my point. You don't need to set the pin to output direction to make use of those pull features. More than that, when confiugured as output, the pull flags actually don't make sense.

Quoted 6 lines
Quoted 3 lines

I just looking at pxa27x user manual but I don't see such pull-up functionality... are you sure these settings aren't pxa3xx specific? =:-o

I haven't checked the datasheet but the header files that defines this macro only. And it didn't appear to be PXA3x specific.

I cannot find such register nor pull-up/down management into whole PXA27x user manual.

Quoted 3 lines

Anyway, if this is unavailable on your hardware, the proper way would be to place an external resistor on the board (given that you can modify the schematics).

Why should I do as you suggest when the CPU can support such electrical configuration?

Quoted 2 lines

I'm still not convinced that driving the pad as output GPIO and then applying a different level externally to generate an IRQ is intended.

No external different level applyed! Just a pull-down enabled by a machanical switch: if no cards are inserted I read 1 but if I insert a card I got 0 due the pull-down enabling.

I tested the code on my hardware who works perfectly.

Ciao,

Rodolfo

Signature · 5 lines
GNU/Linux Solutions                  e-mail: giometti at enneenne.com
Linux Device Driver                          giometti at linux.it
Embedded Systems                     phone:  +39 349 2432127
UNIX programming                     skype:  rodolfo.giometti
Freelance ICT Italia - Consulente ICT Italia - www.consulenti-ict.it
#13 lore raw

PATCH 1/1 arm pxa: remove "direction input" forcing for IRQ GPIOs

Quoted 7 lines · Rodolfo Giometti
Quoted 2 lines · Daniel Mack

I'm still not convinced that driving the pad as output GPIO and then applying a different level externally to generate an IRQ is intended.

No external different level applyed! Just a pull-down enabled by a machanical switch: if no cards are inserted I read 1 but if I insert a card I got 0 due the pull-down enabling.

I'm sorry, but I really can't believe you mean what you just said. The two sentences are definitely contradictory.

In the first, you say that you're not applying a different level.

In the second, you say that you're applying zero volts to the output. That _is_ a different level, no two ways about it.

By doing so, you are brute-force fighting the FET in the SoC which is trying to pull the output up to logic '1'. God knows how much current you're causing the FET to pass - and therefore how much power it is dissapating - but according to the PXA270 spec, it'll be in excess of 3mA. (At 3mA, the output voltage on a GPIO pin is guaranteed to be, for logic 1, at least 0.8 * VCC_IO).

This is in no way good electronic practice.

#14 lore raw

PATCH 1/1 arm pxa: remove "direction input" forcing for IRQ GPIOs

In reply to Daniel Mack
Quoted 6 lines · Daniel Mack
Quoted 5 lines · Rodolfo Giometti

PXA CPUs may use their GPIOs as IRQ lines even if they are selected as outputs (see for example figure 24-1 into PXA27x Processor Family Developer's Manual). So forcing GPIOs IRQ lines as inputs is not correct.

Quoted 7 lines
Quoted 3 lines

Programmers should set up GPIOs direction according to their usage and the function pxa_gpio_irq_type() should simply enable the IRQ detection.

Interesting. Is this an academic issue or do you actually use that? That would mean you externally drive the IO pin level to something else than the output driver provides, which isn't healthy at all.

Actually, it appears this is a way of generating a software interrupt.

If the GPIO IRQ line is set as an output you could drive the pin to the appropriate level to generate an interrupt.

Regards,
Hartley