linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] pinctrl: sunxi: Fix multi bank interrupt support in gpio_to_irq
@ 2014-06-30 16:04 Chen-Yu Tsai
  2014-07-04  7:03 ` Maxime Ripard
  2014-07-04 21:44 ` Linus Walleij
  0 siblings, 2 replies; 5+ messages in thread
From: Chen-Yu Tsai @ 2014-06-30 16:04 UTC (permalink / raw)
  To: linux-arm-kernel

When mapping the interrupts, the gpio_to_irq function did not consider
the bank number of the gpio pin in question, only the offset or the
interrupt number in the bank. As a result, requests for interrupts in
the later banks get mapped to the first bank.

This issue was discovered while enabling mmc on the new sun8i platform.
The tablet I have uses a pin/interrupt from the second bank to do mmc
card detection. Tested on this very device with register inspection and
actual mmc card insertion/removal.

Signed-off-by: Chen-Yu Tsai <wens@csie.org>
---

Hi,

This patch fixes gpios from the later banks used as external interrupts.
With this, mmc card detection works correctly on my A23 tablet. this
should also get MMC card detection working on the Mele M9.

This patch applies to pinctrl/for-next (4aba0a02ff8). It is a follow-up
fix for Maxime's multiple bank external interrupt support for sunxi pinctrl.
It is orthogonal to Hans' level/edge triggered gpio irqs series. It should
apply cleanly either way.


Cheers
ChenYu

---

 drivers/pinctrl/sunxi/pinctrl-sunxi.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/pinctrl/sunxi/pinctrl-sunxi.c b/drivers/pinctrl/sunxi/pinctrl-sunxi.c
index 66c3b42..33a5e87 100644
--- a/drivers/pinctrl/sunxi/pinctrl-sunxi.c
+++ b/drivers/pinctrl/sunxi/pinctrl-sunxi.c
@@ -521,6 +521,7 @@ static int sunxi_pinctrl_gpio_to_irq(struct gpio_chip *chip, unsigned offset)
 {
 	struct sunxi_pinctrl *pctl = dev_get_drvdata(chip->dev);
 	struct sunxi_desc_function *desc;
+	unsigned irqnum;
 
 	if (offset >= chip->ngpio)
 		return -ENXIO;
@@ -529,10 +530,12 @@ static int sunxi_pinctrl_gpio_to_irq(struct gpio_chip *chip, unsigned offset)
 	if (!desc)
 		return -EINVAL;
 
+	irqnum = desc->irqbank * IRQ_PER_BANK + desc->irqnum;
+
 	dev_dbg(chip->dev, "%s: request IRQ for GPIO %d, return %d\n",
-		chip->label, offset + chip->base, desc->irqnum);
+		chip->label, offset + chip->base, irqnum);
 
-	return irq_find_mapping(pctl->domain, desc->irqnum);
+	return irq_find_mapping(pctl->domain, irqnum);
 }
 
 
-- 
2.0.0

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

* [PATCH] pinctrl: sunxi: Fix multi bank interrupt support in gpio_to_irq
  2014-06-30 16:04 [PATCH] pinctrl: sunxi: Fix multi bank interrupt support in gpio_to_irq Chen-Yu Tsai
@ 2014-07-04  7:03 ` Maxime Ripard
  2014-07-04  7:11   ` Chen-Yu Tsai
  2014-07-04 21:44 ` Linus Walleij
  1 sibling, 1 reply; 5+ messages in thread
From: Maxime Ripard @ 2014-07-04  7:03 UTC (permalink / raw)
  To: linux-arm-kernel

Hi,

On Tue, Jul 01, 2014 at 12:04:59AM +0800, Chen-Yu Tsai wrote:
> When mapping the interrupts, the gpio_to_irq function did not consider
> the bank number of the gpio pin in question, only the offset or the
> interrupt number in the bank. As a result, requests for interrupts in
> the later banks get mapped to the first bank.
> 
> This issue was discovered while enabling mmc on the new sun8i platform.
> The tablet I have uses a pin/interrupt from the second bank to do mmc
> card detection. Tested on this very device with register inspection and
> actual mmc card insertion/removal.
> 
> Signed-off-by: Chen-Yu Tsai <wens@csie.org>

Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>

Linus, could this be merged as a fix for 3.16?

Thanks,
Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140704/94b1554b/attachment-0001.sig>

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

* [PATCH] pinctrl: sunxi: Fix multi bank interrupt support in gpio_to_irq
  2014-07-04  7:03 ` Maxime Ripard
@ 2014-07-04  7:11   ` Chen-Yu Tsai
  2014-07-04  7:22     ` Maxime Ripard
  0 siblings, 1 reply; 5+ messages in thread
From: Chen-Yu Tsai @ 2014-07-04  7:11 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, Jul 4, 2014 at 3:03 PM, Maxime Ripard
<maxime.ripard@free-electrons.com> wrote:
> Hi,
>
> On Tue, Jul 01, 2014 at 12:04:59AM +0800, Chen-Yu Tsai wrote:
>> When mapping the interrupts, the gpio_to_irq function did not consider
>> the bank number of the gpio pin in question, only the offset or the
>> interrupt number in the bank. As a result, requests for interrupts in
>> the later banks get mapped to the first bank.
>>
>> This issue was discovered while enabling mmc on the new sun8i platform.
>> The tablet I have uses a pin/interrupt from the second bank to do mmc
>> card detection. Tested on this very device with register inspection and
>> actual mmc card insertion/removal.
>>
>> Signed-off-by: Chen-Yu Tsai <wens@csie.org>
>
> Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>
>
> Linus, could this be merged as a fix for 3.16?

Aren't your multi-bank external interrupt patches queued for 3.17?
This patch applies over them.


ChenYu

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

* [PATCH] pinctrl: sunxi: Fix multi bank interrupt support in gpio_to_irq
  2014-07-04  7:11   ` Chen-Yu Tsai
@ 2014-07-04  7:22     ` Maxime Ripard
  0 siblings, 0 replies; 5+ messages in thread
From: Maxime Ripard @ 2014-07-04  7:22 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, Jul 04, 2014 at 03:11:04PM +0800, Chen-Yu Tsai wrote:
> On Fri, Jul 4, 2014 at 3:03 PM, Maxime Ripard
> <maxime.ripard@free-electrons.com> wrote:
> > Hi,
> >
> > On Tue, Jul 01, 2014 at 12:04:59AM +0800, Chen-Yu Tsai wrote:
> >> When mapping the interrupts, the gpio_to_irq function did not consider
> >> the bank number of the gpio pin in question, only the offset or the
> >> interrupt number in the bank. As a result, requests for interrupts in
> >> the later banks get mapped to the first bank.
> >>
> >> This issue was discovered while enabling mmc on the new sun8i platform.
> >> The tablet I have uses a pin/interrupt from the second bank to do mmc
> >> card detection. Tested on this very device with register inspection and
> >> actual mmc card insertion/removal.
> >>
> >> Signed-off-by: Chen-Yu Tsai <wens@csie.org>
> >
> > Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>
> >
> > Linus, could this be merged as a fix for 3.16?
> 
> Aren't your multi-bank external interrupt patches queued for 3.17?
> This patch applies over them.

Ah, yes, you're right.

Sorry for the noise :)

Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140704/bc1b6b4d/attachment.sig>

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

* [PATCH] pinctrl: sunxi: Fix multi bank interrupt support in gpio_to_irq
  2014-06-30 16:04 [PATCH] pinctrl: sunxi: Fix multi bank interrupt support in gpio_to_irq Chen-Yu Tsai
  2014-07-04  7:03 ` Maxime Ripard
@ 2014-07-04 21:44 ` Linus Walleij
  1 sibling, 0 replies; 5+ messages in thread
From: Linus Walleij @ 2014-07-04 21:44 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Jun 30, 2014 at 6:04 PM, Chen-Yu Tsai <wens@csie.org> wrote:

> When mapping the interrupts, the gpio_to_irq function did not consider
> the bank number of the gpio pin in question, only the offset or the
> interrupt number in the bank. As a result, requests for interrupts in
> the later banks get mapped to the first bank.
>
> This issue was discovered while enabling mmc on the new sun8i platform.
> The tablet I have uses a pin/interrupt from the second bank to do mmc
> card detection. Tested on this very device with register inspection and
> actual mmc card insertion/removal.
>
> Signed-off-by: Chen-Yu Tsai <wens@csie.org>

Patch applied with Maxime's ACK.

Yours,
Linus Walleij

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

end of thread, other threads:[~2014-07-04 21:44 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-30 16:04 [PATCH] pinctrl: sunxi: Fix multi bank interrupt support in gpio_to_irq Chen-Yu Tsai
2014-07-04  7:03 ` Maxime Ripard
2014-07-04  7:11   ` Chen-Yu Tsai
2014-07-04  7:22     ` Maxime Ripard
2014-07-04 21:44 ` Linus Walleij

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).