Skip to contentSkip to conversation

pinctrl: sunxi: Fix multi bank interrupt support in gpio_to_irq

PATCH New Chen-Yu Tsai 3 participants 5 messages Jun 30, 2014 – Jul 4, 2014

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

PATCH 1/1 pinctrl: sunxi: Fix multi bank interrupt support in gpio_to_irq

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.

---

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(-)
drivers/pinctrl/sunxi/pinctrl-sunxi.c +5 -2
index 66c3b42..33a5e87 100644
@@ -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);
 }
 
 
Signature · 1 line
2.0.0
#1 lore raw

PATCH 1/1 pinctrl: sunxi: Fix multi bank interrupt support in gpio_to_irq

Hi,

Quoted 11 lines · Chen-Yu Tsai

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.

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

Thanks,
Maxime

Signature · 10 lines
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>
#2 lore raw

PATCH 1/1 pinctrl: sunxi: Fix multi bank interrupt support in gpio_to_irq

Quoted 13 lines · Maxime Ripard

Hi,

Quoted 10 lines · Chen-Yu Tsai

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.

Quoted 5 lines
Quoted 1 line

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

#3 lore raw

PATCH 1/1 pinctrl: sunxi: Fix multi bank interrupt support in gpio_to_irq

Quoted 15 lines · Chen-Yu Tsai
Quoted 13 lines · Maxime Ripard

Hi,

Quoted 10 lines · Chen-Yu Tsai

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.

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

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

Signature · 10 lines
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>
#4 lore raw

PATCH 1/1 pinctrl: sunxi: Fix multi bank interrupt support in gpio_to_irq

In reply to Chen-Yu Tsai
Quoted 11 lines · Chen-Yu Tsai

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.

Patch applied with Maxime's ACK.

Yours,
Linus Walleij