From: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
To: linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org
Cc: Russell King <linux@arm.linux.org.uk>,
Linus Walleij <linus.walleij@linaro.org>,
Dmitry Artamonow <mad_soft@inbox.ru>
Subject: [PATCH 9/9] ARM: sa1100: refactor irq driver
Date: Fri, 15 Nov 2013 12:48:00 +0400 [thread overview]
Message-ID: <1384505280-25389-10-git-send-email-dbaryshkov@gmail.com> (raw)
In-Reply-To: <1384505280-25389-1-git-send-email-dbaryshkov@gmail.com>
* Replace direct-mapped access with proper ioremap.
* Introduce irq domain for system controller irqs
* Merge "save" state to common newly create private data.
Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
arch/arm/mach-sa1100/irq.c | 111 +++++++++++++++++++++++++++++----------------
1 file changed, 71 insertions(+), 40 deletions(-)
diff --git a/arch/arm/mach-sa1100/irq.c b/arch/arm/mach-sa1100/irq.c
index d96f65f..a26a6a2 100644
--- a/arch/arm/mach-sa1100/irq.c
+++ b/arch/arm/mach-sa1100/irq.c
@@ -14,26 +14,50 @@
#include <linux/interrupt.h>
#include <linux/io.h>
#include <linux/irq.h>
+#include <linux/irqdomain.h>
#include <linux/ioport.h>
#include <linux/syscore_ops.h>
-#include <mach/hardware.h>
#include <asm/exception.h>
#include "generic.h"
+#define ICIP 0x00 /* IC IRQ Pending reg. */
+#define ICMR 0x04 /* IC Mask Reg. */
+#define ICLR 0x08 /* IC Level Reg. */
+#define ICCR 0x0C /* IC Control Reg. */
+#define ICFP 0x10 /* IC FIQ Pending reg. */
+#define ICPR 0x20 /* IC Pending Reg. */
+
+struct sa1100_sc {
+ struct irq_domain *domain;
+ void __iomem *regbase;
+
+ unsigned int saved_icmr;
+ unsigned int saved_iclr;
+ unsigned int saved_iccr;
+};
+
/*
* We don't need to ACK IRQs on the SA1100 unless they're GPIOs
* this is for internal IRQs i.e. from 11 to 31.
*/
static void sa1100_mask_irq(struct irq_data *d)
{
- ICMR &= ~(1 << d->irq);
+ struct sa1100_sc *sc = irq_data_get_irq_chip_data(d);
+ uint32_t icmr = readl_relaxed(sc->regbase + ICMR);
+
+ icmr &= ~BIT(d->hwirq);
+ writel_relaxed(icmr, sc->regbase + ICMR);
}
static void sa1100_unmask_irq(struct irq_data *d)
{
- ICMR |= (1 << d->irq);
+ struct sa1100_sc *sc = irq_data_get_irq_chip_data(d);
+ uint32_t icmr = readl_relaxed(sc->regbase + ICMR);
+
+ icmr |= BIT(d->hwirq);
+ writel_relaxed(icmr, sc->regbase + ICMR);
}
/*
@@ -41,7 +65,7 @@ static void sa1100_unmask_irq(struct irq_data *d)
*/
static int sa1100_set_wake(struct irq_data *d, unsigned int on)
{
- return sa11x0_sc_set_wake(d->irq, on);
+ return sa11x0_sc_set_wake(d->hwirq, on);
}
static struct irq_chip sa1100_normal_chip = {
@@ -55,28 +79,37 @@ static struct irq_chip sa1100_normal_chip = {
static struct resource irq_resource =
DEFINE_RES_MEM_NAMED(0x90050000, SZ_64K, "irqs");
-static struct sa1100irq_state {
- unsigned int saved;
- unsigned int icmr;
- unsigned int iclr;
- unsigned int iccr;
-} sa1100irq_state;
+static int sa1100_irqdomain_map(struct irq_domain *d, unsigned int irq,
+ irq_hw_number_t hwirq)
+{
+ struct sa1100_sc *sc = d->host_data;
+
+ irq_set_chip_data(irq, sc);
+ irq_set_chip_and_handler(irq, &sa1100_normal_chip, handle_level_irq);
+ set_irq_flags(irq, IRQF_VALID);
+
+ return 0;
+}
+
+static struct irq_domain_ops sa1100_irqdomain_ops = {
+ .map = sa1100_irqdomain_map,
+ .xlate = irq_domain_xlate_onetwocell,
+};
+
+static struct sa1100_sc state;
static int sa1100irq_suspend(void)
{
- struct sa1100irq_state *st = &sa1100irq_state;
+ struct sa1100_sc *sc = &state;
- st->saved = 1;
- st->icmr = ICMR;
- st->iclr = ICLR;
- st->iccr = ICCR;
+ sc->saved_icmr = readl_relaxed(sc->regbase + ICMR);
+ sc->saved_iclr = readl_relaxed(sc->regbase + ICLR);
+ sc->saved_iccr = readl_relaxed(sc->regbase + ICCR);
/*
* Disable all GPIO-based interrupts.
*/
- ICMR &= ~(IC_GPIO11_27|IC_GPIO10|IC_GPIO9|IC_GPIO8|IC_GPIO7|
- IC_GPIO6|IC_GPIO5|IC_GPIO4|IC_GPIO3|IC_GPIO2|
- IC_GPIO1|IC_GPIO0);
+ writel_relaxed(sc->saved_icmr & ~0xFFF, sc->regbase + ICMR);
return 0;
@@ -84,13 +117,11 @@ static int sa1100irq_suspend(void)
static void sa1100irq_resume(void)
{
- struct sa1100irq_state *st = &sa1100irq_state;
+ struct sa1100_sc *sc = &state;
- if (st->saved) {
- ICCR = st->iccr;
- ICLR = st->iclr;
- ICMR = st->icmr;
- }
+ writel_relaxed(sc->saved_iccr, sc->regbase + ICCR);
+ writel_relaxed(sc->saved_iclr, sc->regbase + ICLR);
+ writel_relaxed(sc->saved_icmr, sc->regbase + ICMR);
}
static struct syscore_ops sa1100irq_syscore_ops = {
@@ -110,42 +141,42 @@ static asmlinkage void __exception_irq_entry
sa1100_handle_irq(struct pt_regs *regs)
{
uint32_t icip, icmr, mask;
+ int irq;
- do {
- icip = (ICIP);
- icmr = (ICMR);
+ while (1) {
+ icip = readl_relaxed(state.regbase + ICIP);
+ icmr = readl_relaxed(state.regbase + ICMR);
mask = icip & icmr;
if (mask == 0)
break;
- handle_IRQ(fls(mask) - 1, regs);
- } while (1);
+ irq = fls(mask) - 1;
+ handle_IRQ(irq_find_mapping(state.domain, irq), regs);
+ }
}
void __init sa1100_init_irq(void)
{
- unsigned int irq;
-
request_resource(&iomem_resource, &irq_resource);
+ state.regbase = ioremap(irq_resource.start,
+ resource_size(&irq_resource));
+
/* disable all IRQs */
- ICMR = 0;
+ writel_relaxed(0, state.regbase + ICMR);
/* all IRQs are IRQ, not FIQ */
- ICLR = 0;
+ writel_relaxed(0, state.regbase + ICLR);
/*
* Whatever the doc says, this has to be set for the wait-on-irq
- * instruction to work... on a SA1100 rev 9 at least.
+ * instruction to work... on a SA1100 rev 9 at leastate.
*/
- ICCR = 1;
+ writel_relaxed(1, state.regbase + ICCR);
- for (irq = 0; irq <= 31; irq++) {
- irq_set_chip_and_handler(irq, &sa1100_normal_chip,
- handle_level_irq);
- set_irq_flags(irq, IRQF_VALID);
- }
+ state.domain = irq_domain_add_legacy(NULL, 32, 0, 0,
+ &sa1100_irqdomain_ops, &state);
set_handle_irq(sa1100_handle_irq);
}
--
1.8.4.2
next prev parent reply other threads:[~2013-11-15 8:48 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-15 8:47 [PATCH 0/9] ARM: sa1100: Rework IRQ handling Dmitry Eremin-Solenikov
2013-11-15 8:47 ` [PATCH 1/9] ARM: sa1100 collie: use gpio-charger instead of pda-power Dmitry Eremin-Solenikov
2013-11-15 8:47 ` [PATCH 2/9] ARM: locomo: don't clobber chip data for chained irq Dmitry Eremin-Solenikov
2013-11-15 8:47 ` [PATCH 3/9] ARM: sa1100: switch to MULTI_IRQ_HANDLER Dmitry Eremin-Solenikov
2013-11-15 8:47 ` [PATCH 4/9] ARM: sa1100: convert gpio driver to be a proper platform driver Dmitry Eremin-Solenikov
2013-11-19 10:08 ` Linus Walleij
2013-11-15 8:47 ` [PATCH 5/9] ARM: sa1100: add platform functions to handle PWER settings Dmitry Eremin-Solenikov
2013-11-15 8:47 ` [PATCH 6/9] ARM: sa1100: enable IRQ domains Dmitry Eremin-Solenikov
2013-11-15 8:47 ` [PATCH 7/9] ARM: sa1100: move gpio irq handling to GPIO driver Dmitry Eremin-Solenikov
2013-11-22 17:45 ` Russell King - ARM Linux
2013-11-22 19:46 ` Dmitry Eremin-Solenikov
2013-11-22 20:02 ` Russell King - ARM Linux
2013-11-22 21:20 ` Dmitry Eremin-Solenikov
2013-11-15 8:47 ` [PATCH 8/9] ARM: sa1100: move per-IRQ PWER settings to core code Dmitry Eremin-Solenikov
2013-11-15 8:48 ` Dmitry Eremin-Solenikov [this message]
2013-11-19 13:00 ` [PATCH 0/9] ARM: sa1100: Rework IRQ handling Linus Walleij
2013-11-19 15:17 ` Dmitry Eremin-Solenikov
2013-11-19 20:24 ` Linus Walleij
2013-11-20 0:20 ` Russell King - ARM Linux
2013-11-20 0:45 ` Dmitry Eremin-Solenikov
2013-11-20 7:43 ` Dmitry Artamonow
2013-11-22 17:58 ` Russell King - ARM Linux
2013-11-22 19:12 ` Dmitry Eremin-Solenikov
2013-11-22 19:51 ` Russell King - ARM Linux
2013-11-22 21:23 ` Dmitry Eremin-Solenikov
2013-11-20 0:40 ` Dmitry Eremin-Solenikov
2013-11-22 17:33 ` Dmitry Eremin-Solenikov
2013-11-22 21:35 ` Dmitry Eremin-Solenikov
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=1384505280-25389-10-git-send-email-dbaryshkov@gmail.com \
--to=dbaryshkov@gmail.com \
--cc=linus.walleij@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux@arm.linux.org.uk \
--cc=mad_soft@inbox.ru \
/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;
as well as URLs for NNTP newsgroup(s).