mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Kamal Mostafa <kamal@canonical.com>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org,
	kernel-team@lists.ubuntu.com
Cc: Hans de Goede <hdegoede@redhat.com>,
	Linus Walleij <linus.walleij@linaro.org>,
	Kamal Mostafa <kamal@canonical.com>
Subject: [PATCH 4.2.y-ckt 15/70] pinctrl: sunxi: Fix A33 external interrupts not working
Date: Tue, 12 Apr 2016 13:52:00 -0700	[thread overview]
Message-ID: <1460494375-30070-16-git-send-email-kamal@canonical.com> (raw)
In-Reply-To: <1460494375-30070-1-git-send-email-kamal@canonical.com>

4.2.8-ckt8 -stable review patch.  If anyone has any objections, please let me know.

---8<------------------------------------------------------------

From: Hans de Goede <hdegoede@redhat.com>

commit 5e7515ba78fff2f5407eaa2f97c1d5c07801ac3d upstream.

pinctrl-sun8i-a33.c (and the dts) declare only 2 interrupt banks,
where as the closely related a23 has 3 banks. This matches with the
datasheet for the A33 where only interrupt banks B and G are specified
where as the A23 has banks A, B and G.

However the A33 being the A23 derative it is means that the interrupt
configure/status io-addresses for the 2 banks it has are not changed
from the A23, iow they have the same address as if bank A was still
present. Where as the sunxi pinctrl currently tries to use the A23 bank
A addresses for bank B, since the pinctrl code does not know about the
removed bank A.

Add a irq_bank_base parameter and use this where appropriate to take
the missing bank A into account.

This fixes external interrupts not working on the A33 (tested with
an i2c touchscreen controller which uses an external interrupt).

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 drivers/pinctrl/sunxi/pinctrl-sun8i-a33.c |  1 +
 drivers/pinctrl/sunxi/pinctrl-sunxi.c     | 17 ++++++++++-------
 drivers/pinctrl/sunxi/pinctrl-sunxi.h     | 21 +++++++++++----------
 3 files changed, 22 insertions(+), 17 deletions(-)

diff --git a/drivers/pinctrl/sunxi/pinctrl-sun8i-a33.c b/drivers/pinctrl/sunxi/pinctrl-sun8i-a33.c
index 00265f0..8b381d6 100644
--- a/drivers/pinctrl/sunxi/pinctrl-sun8i-a33.c
+++ b/drivers/pinctrl/sunxi/pinctrl-sun8i-a33.c
@@ -485,6 +485,7 @@ static const struct sunxi_pinctrl_desc sun8i_a33_pinctrl_data = {
 	.pins = sun8i_a33_pins,
 	.npins = ARRAY_SIZE(sun8i_a33_pins),
 	.irq_banks = 2,
+	.irq_bank_base = 1,
 };
 
 static int sun8i_a33_pinctrl_probe(struct platform_device *pdev)
diff --git a/drivers/pinctrl/sunxi/pinctrl-sunxi.c b/drivers/pinctrl/sunxi/pinctrl-sunxi.c
index f09573e..a59db8c 100644
--- a/drivers/pinctrl/sunxi/pinctrl-sunxi.c
+++ b/drivers/pinctrl/sunxi/pinctrl-sunxi.c
@@ -589,7 +589,7 @@ static int sunxi_pinctrl_irq_set_type(struct irq_data *d, unsigned int type)
 {
 	struct sunxi_pinctrl *pctl = irq_data_get_irq_chip_data(d);
 	struct irq_desc *desc = container_of(d, struct irq_desc, irq_data);
-	u32 reg = sunxi_irq_cfg_reg(d->hwirq);
+	u32 reg = sunxi_irq_cfg_reg(d->hwirq, pctl->desc->irq_bank_base);
 	u8 index = sunxi_irq_cfg_offset(d->hwirq);
 	unsigned long flags;
 	u32 regval;
@@ -637,7 +637,8 @@ static int sunxi_pinctrl_irq_set_type(struct irq_data *d, unsigned int type)
 static void sunxi_pinctrl_irq_ack(struct irq_data *d)
 {
 	struct sunxi_pinctrl *pctl = irq_data_get_irq_chip_data(d);
-	u32 status_reg = sunxi_irq_status_reg(d->hwirq);
+	u32 status_reg = sunxi_irq_status_reg(d->hwirq,
+					      pctl->desc->irq_bank_base);
 	u8 status_idx = sunxi_irq_status_offset(d->hwirq);
 
 	/* Clear the IRQ */
@@ -647,7 +648,7 @@ static void sunxi_pinctrl_irq_ack(struct irq_data *d)
 static void sunxi_pinctrl_irq_mask(struct irq_data *d)
 {
 	struct sunxi_pinctrl *pctl = irq_data_get_irq_chip_data(d);
-	u32 reg = sunxi_irq_ctrl_reg(d->hwirq);
+	u32 reg = sunxi_irq_ctrl_reg(d->hwirq, pctl->desc->irq_bank_base);
 	u8 idx = sunxi_irq_ctrl_offset(d->hwirq);
 	unsigned long flags;
 	u32 val;
@@ -664,7 +665,7 @@ static void sunxi_pinctrl_irq_mask(struct irq_data *d)
 static void sunxi_pinctrl_irq_unmask(struct irq_data *d)
 {
 	struct sunxi_pinctrl *pctl = irq_data_get_irq_chip_data(d);
-	u32 reg = sunxi_irq_ctrl_reg(d->hwirq);
+	u32 reg = sunxi_irq_ctrl_reg(d->hwirq, pctl->desc->irq_bank_base);
 	u8 idx = sunxi_irq_ctrl_offset(d->hwirq);
 	unsigned long flags;
 	u32 val;
@@ -722,7 +723,7 @@ static void sunxi_pinctrl_irq_handler(unsigned irq, struct irq_desc *desc)
 	if (bank == pctl->desc->irq_banks)
 		return;
 
-	reg = sunxi_irq_status_reg_from_bank(bank);
+	reg = sunxi_irq_status_reg_from_bank(bank, pctl->desc->irq_bank_base);
 	val = readl(pctl->membase + reg);
 
 	if (val) {
@@ -1001,9 +1002,11 @@ int sunxi_pinctrl_init(struct platform_device *pdev,
 
 	for (i = 0; i < pctl->desc->irq_banks; i++) {
 		/* Mask and clear all IRQs before registering a handler */
-		writel(0, pctl->membase + sunxi_irq_ctrl_reg_from_bank(i));
+		writel(0, pctl->membase + sunxi_irq_ctrl_reg_from_bank(i,
+						pctl->desc->irq_bank_base));
 		writel(0xffffffff,
-			pctl->membase + sunxi_irq_status_reg_from_bank(i));
+		       pctl->membase + sunxi_irq_status_reg_from_bank(i,
+						pctl->desc->irq_bank_base));
 
 		irq_set_chained_handler_and_data(pctl->irq[i],
 						 sunxi_pinctrl_irq_handler,
diff --git a/drivers/pinctrl/sunxi/pinctrl-sunxi.h b/drivers/pinctrl/sunxi/pinctrl-sunxi.h
index e248e81..0afce1a 100644
--- a/drivers/pinctrl/sunxi/pinctrl-sunxi.h
+++ b/drivers/pinctrl/sunxi/pinctrl-sunxi.h
@@ -97,6 +97,7 @@ struct sunxi_pinctrl_desc {
 	int				npins;
 	unsigned			pin_base;
 	unsigned			irq_banks;
+	unsigned			irq_bank_base;
 	bool				irq_read_needs_mux;
 };
 
@@ -233,12 +234,12 @@ static inline u32 sunxi_pull_offset(u16 pin)
 	return pin_num * PULL_PINS_BITS;
 }
 
-static inline u32 sunxi_irq_cfg_reg(u16 irq)
+static inline u32 sunxi_irq_cfg_reg(u16 irq, unsigned bank_base)
 {
 	u8 bank = irq / IRQ_PER_BANK;
 	u8 reg = (irq % IRQ_PER_BANK) / IRQ_CFG_IRQ_PER_REG * 0x04;
 
-	return IRQ_CFG_REG + bank * IRQ_MEM_SIZE + reg;
+	return IRQ_CFG_REG + (bank_base + bank) * IRQ_MEM_SIZE + reg;
 }
 
 static inline u32 sunxi_irq_cfg_offset(u16 irq)
@@ -247,16 +248,16 @@ static inline u32 sunxi_irq_cfg_offset(u16 irq)
 	return irq_num * IRQ_CFG_IRQ_BITS;
 }
 
-static inline u32 sunxi_irq_ctrl_reg_from_bank(u8 bank)
+static inline u32 sunxi_irq_ctrl_reg_from_bank(u8 bank, unsigned bank_base)
 {
-	return IRQ_CTRL_REG + bank * IRQ_MEM_SIZE;
+	return IRQ_CTRL_REG + (bank_base + bank) * IRQ_MEM_SIZE;
 }
 
-static inline u32 sunxi_irq_ctrl_reg(u16 irq)
+static inline u32 sunxi_irq_ctrl_reg(u16 irq, unsigned bank_base)
 {
 	u8 bank = irq / IRQ_PER_BANK;
 
-	return sunxi_irq_ctrl_reg_from_bank(bank);
+	return sunxi_irq_ctrl_reg_from_bank(bank, bank_base);
 }
 
 static inline u32 sunxi_irq_ctrl_offset(u16 irq)
@@ -265,16 +266,16 @@ static inline u32 sunxi_irq_ctrl_offset(u16 irq)
 	return irq_num * IRQ_CTRL_IRQ_BITS;
 }
 
-static inline u32 sunxi_irq_status_reg_from_bank(u8 bank)
+static inline u32 sunxi_irq_status_reg_from_bank(u8 bank, unsigned bank_base)
 {
-	return IRQ_STATUS_REG + bank * IRQ_MEM_SIZE;
+	return IRQ_STATUS_REG + (bank_base + bank) * IRQ_MEM_SIZE;
 }
 
-static inline u32 sunxi_irq_status_reg(u16 irq)
+static inline u32 sunxi_irq_status_reg(u16 irq, unsigned bank_base)
 {
 	u8 bank = irq / IRQ_PER_BANK;
 
-	return sunxi_irq_status_reg_from_bank(bank);
+	return sunxi_irq_status_reg_from_bank(bank, bank_base);
 }
 
 static inline u32 sunxi_irq_status_offset(u16 irq)
-- 
2.7.4

  parent reply	other threads:[~2016-04-12 21:35 UTC|newest]

Thread overview: 71+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-12 20:51 [4.2.y-ckt stable] Linux 4.2.8-ckt8 stable review Kamal Mostafa
2016-04-12 20:51 ` [PATCH 4.2.y-ckt 01/70] [stable-only] Revert "spi: rockchip: modify DMA max burst to 1" Kamal Mostafa
2016-04-12 20:51 ` [PATCH 4.2.y-ckt 02/70] PKCS#7: pkcs7_validate_trust(): initialize the _trusted output argument Kamal Mostafa
2016-04-12 20:51 ` [PATCH 4.2.y-ckt 03/70] ALSA: hda - Asus N750JV external subwoofer fixup Kamal Mostafa
2016-04-12 20:51 ` [PATCH 4.2.y-ckt 04/70] ALSA: hda - Fix white noise on Asus N750JV headphone Kamal Mostafa
2016-04-12 20:51 ` [PATCH 4.2.y-ckt 05/70] ALSA: hda - Apply fix for white noise on Asus N550JV, too Kamal Mostafa
2016-04-12 20:51 ` [PATCH 4.2.y-ckt 06/70] drm/radeon: add a dpm quirk for sapphire Dual-X R7 370 2G D5 Kamal Mostafa
2016-04-12 20:51 ` [PATCH 4.2.y-ckt 07/70] fs: add file_dentry() Kamal Mostafa
2016-04-12 20:51 ` [PATCH 4.2.y-ckt 08/70] nfs: use file_dentry() Kamal Mostafa
2016-04-12 20:51 ` [PATCH 4.2.y-ckt 09/70] hwmon: (max1111) Return -ENODEV from max1111_read_channel if not instantiated Kamal Mostafa
2016-04-12 20:51 ` [PATCH 4.2.y-ckt 10/70] drm/radeon: add another R7 370 quirk Kamal Mostafa
2016-04-12 20:51 ` [PATCH 4.2.y-ckt 11/70] drm/radeon: add a dpm quirk for all R7 370 parts Kamal Mostafa
2016-04-12 20:51 ` [PATCH 4.2.y-ckt 12/70] powerpc/mm: Fixup preempt underflow with huge pages Kamal Mostafa
2016-04-12 20:51 ` [PATCH 4.2.y-ckt 13/70] pinctrl: sh-pfc: only use dummy states for non-DT platforms Kamal Mostafa
2016-04-12 20:51 ` [PATCH 4.2.y-ckt 14/70] pinctrl: pistachio: fix mfio84-89 function description and pinmux Kamal Mostafa
2016-04-12 20:52 ` Kamal Mostafa [this message]
2016-04-12 20:52 ` [PATCH 4.2.y-ckt 16/70] usb: renesas_usbhs: avoid NULL pointer derefernce in usbhsf_pkt_handler() Kamal Mostafa
2016-04-12 20:52 ` [PATCH 4.2.y-ckt 17/70] usb: renesas_usbhs: disable TX IRQ before starting TX DMAC transfer Kamal Mostafa
2016-04-12 20:52 ` [PATCH 4.2.y-ckt 18/70] btrfs: fix crash/invalid memory access on fsync when using overlayfs Kamal Mostafa
2016-04-12 20:52 ` [PATCH 4.2.y-ckt 19/70] ALSA: usb-audio: Minor code cleanup in create_fixed_stream_quirk() Kamal Mostafa
2016-04-12 20:52 ` [PATCH 4.2.y-ckt 20/70] ALSA: usb-audio: Fix double-free in error paths after snd_usb_add_audio_stream() call Kamal Mostafa
2016-04-12 20:52 ` [PATCH 4.2.y-ckt 21/70] USB: mct_u232: add sanity checking in probe Kamal Mostafa
2016-04-12 20:52 ` [PATCH 4.2.y-ckt 22/70] USB: cypress_m8: add endpoint sanity check Kamal Mostafa
2016-04-12 20:52 ` [PATCH 4.2.y-ckt 23/70] USB: digi_acceleport: do sanity checking for the number of ports Kamal Mostafa
2016-04-12 20:52 ` [PATCH 4.2.y-ckt 24/70] [media] au0828: fix au0828_v4l2_close() dev_state race condition Kamal Mostafa
2016-04-12 20:52 ` [PATCH 4.2.y-ckt 25/70] [media] au0828: Fix dev_state handling Kamal Mostafa
2016-04-12 20:52 ` [PATCH 4.2.y-ckt 26/70] sd: Fix excessive capacity printing on devices with blocks bigger than 512 bytes Kamal Mostafa
2016-04-12 20:52 ` [PATCH 4.2.y-ckt 27/70] drm/dp: move hw_mutex up the call stack Kamal Mostafa
2016-04-12 20:52 ` [PATCH 4.2.y-ckt 28/70] drm/udl: Use unlocked gem unreferencing Kamal Mostafa
2016-04-12 20:52 ` [PATCH 4.2.y-ckt 29/70] ext4: add lockdep annotations for i_data_sem Kamal Mostafa
2016-04-12 20:52 ` [PATCH 4.2.y-ckt 30/70] ALSA: hda - fix front mic problem for a HP desktop Kamal Mostafa
2016-04-12 20:52 ` [PATCH 4.2.y-ckt 31/70] KVM: x86: Inject pending interrupt even if pending nmi exist Kamal Mostafa
2016-04-12 20:52 ` [PATCH 4.2.y-ckt 32/70] ALSA: timer: Use mod_timer() for rearming the system timer Kamal Mostafa
2016-04-12 20:52 ` [PATCH 4.2.y-ckt 33/70] mm: fix invalid node in alloc_migrate_target() Kamal Mostafa
2016-04-12 20:52 ` [PATCH 4.2.y-ckt 34/70] iio: st_magn: always define ST_MAGN_TRIGGER_SET_STATE Kamal Mostafa
2016-04-12 20:52 ` [PATCH 4.2.y-ckt 35/70] ext4: ignore quota mount options if the quota feature is enabled Kamal Mostafa
2016-04-12 20:52 ` [PATCH 4.2.y-ckt 36/70] xen/events: Mask a moving irq Kamal Mostafa
2016-04-12 20:52 ` [PATCH 4.2.y-ckt 37/70] usb: renesas_usbhs: fix to avoid using a disabled ep in usbhsg_queue_done() Kamal Mostafa
2016-04-12 20:52 ` [PATCH 4.2.y-ckt 38/70] mac80211: properly deal with station hashtable insert errors Kamal Mostafa
2016-04-12 20:52 ` [PATCH 4.2.y-ckt 39/70] compiler-gcc: disable -ftracer for __noclone functions Kamal Mostafa
2016-04-12 20:52 ` [PATCH 4.2.y-ckt 40/70] rbd: use GFP_NOIO consistently for request allocations Kamal Mostafa
2016-04-12 20:52 ` [PATCH 4.2.y-ckt 41/70] Btrfs: fix file/data loss caused by fsync after rename and new inode Kamal Mostafa
2016-04-12 20:52 ` [PATCH 4.2.y-ckt 42/70] USB: serial: ftdi_sio: Add support for ICP DAS I-756xU devices Kamal Mostafa
2016-04-12 20:52 ` [PATCH 4.2.y-ckt 43/70] USB: serial: cp210x: Adding GE Healthcare Device ID Kamal Mostafa
2016-04-12 20:52 ` [PATCH 4.2.y-ckt 44/70] USB: option: add "D-Link DWM-221 B1" device id Kamal Mostafa
2016-04-12 20:52 ` [PATCH 4.2.y-ckt 45/70] virtio: virtio 1.0 cs04 spec compliance for reset Kamal Mostafa
2016-04-12 20:52 ` [PATCH 4.2.y-ckt 46/70] libnvdimm: fix smart data retrieval Kamal Mostafa
2016-04-12 20:52 ` [PATCH 4.2.y-ckt 47/70] gpio: pca953x: Use correct u16 value for register word write Kamal Mostafa
2016-04-12 20:52 ` [PATCH 4.2.y-ckt 48/70] parisc: Avoid function pointers for kernel exception routines Kamal Mostafa
2016-04-12 20:52 ` [PATCH 4.2.y-ckt 49/70] parisc: Fix kernel crash with reversed copy_from_user() Kamal Mostafa
2016-04-12 20:52 ` [PATCH 4.2.y-ckt 50/70] parisc: Unbreak handling exceptions from kernel modules Kamal Mostafa
2016-04-12 20:52 ` [PATCH 4.2.y-ckt 51/70] net: macb: replace macb_writel() call by queue_writel() to update queue ISR Kamal Mostafa
2016-04-12 20:52 ` [PATCH 4.2.y-ckt 52/70] net: bcmgenet: fix dev->stats.tx_bytes accounting Kamal Mostafa
2016-04-12 20:52 ` [PATCH 4.2.y-ckt 53/70] net: bcmgenet: fix skb_len in bcmgenet_xmit_single() Kamal Mostafa
2016-04-12 20:52 ` [PATCH 4.2.y-ckt 54/70] ipv6: udp: fix UDP_MIB_IGNOREDMULTI updates Kamal Mostafa
2016-04-12 20:52 ` [PATCH 4.2.y-ckt 55/70] pinctrl: nomadik: fix pull debug print inversion Kamal Mostafa
2016-04-12 20:52 ` [PATCH 4.2.y-ckt 56/70] ip6_tunnel: set rtnl_link_ops before calling register_netdevice Kamal Mostafa
2016-04-12 20:52 ` [PATCH 4.2.y-ckt 57/70] KVM: x86: move steal time initialization to vcpu entry time Kamal Mostafa
2016-04-12 20:52 ` [PATCH 4.2.y-ckt 58/70] lib/ucs2_string: Add ucs2 -> utf8 helper functions Kamal Mostafa
2016-04-12 20:52 ` [PATCH 4.2.y-ckt 59/70] efi: Use ucs2_as_utf8 in efivarfs instead of open coding a bad version Kamal Mostafa
2016-04-12 20:52 ` [PATCH 4.2.y-ckt 60/70] efi: Do variable name validation tests in utf8 Kamal Mostafa
2016-04-12 20:52 ` [PATCH 4.2.y-ckt 61/70] efi: Make our variable validation list include the guid Kamal Mostafa
2016-04-12 20:52 ` [PATCH 4.2.y-ckt 62/70] efi: Make efivarfs entries immutable by default Kamal Mostafa
2016-04-12 20:52 ` [PATCH 4.2.y-ckt 63/70] efi: Add pstore variables to the deletion whitelist Kamal Mostafa
2016-04-12 20:52 ` [PATCH 4.2.y-ckt 64/70] lib/ucs2_string: Correct ucs2 -> utf8 conversion Kamal Mostafa
2016-04-12 20:52 ` [PATCH 4.2.y-ckt 65/70] ipr: Fix out-of-bounds null overwrite Kamal Mostafa
2016-04-12 20:52 ` [PATCH 4.2.y-ckt 66/70] ipr: Fix regression when loading firmware Kamal Mostafa
2016-04-12 20:52 ` [PATCH 4.2.y-ckt 67/70] perf/x86/intel: Fix PEBS data source interpretation on Nehalem/Westmere Kamal Mostafa
2016-04-12 20:52 ` [PATCH 4.2.y-ckt 68/70] ALSA: hda - Add new GPU codec ID 0x10de0082 to snd-hda Kamal Mostafa
2016-04-12 20:52 ` [PATCH 4.2.y-ckt 69/70] mwifiex: fix corner case association failure Kamal Mostafa
2016-04-12 20:52 ` [PATCH 4.2.y-ckt 70/70] net: phy: at803x: Request 'reset' GPIO only for AT8030 PHY Kamal Mostafa

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1460494375-30070-16-git-send-email-kamal@canonical.com \
    --to=kamal@canonical.com \
    --cc=hdegoede@redhat.com \
    --cc=kernel-team@lists.ubuntu.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®