From: grant.likely@secretlab.ca (Grant Likely)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC PATCH 03/11] dt/irq: add irq_domain_add_simple() helper
Date: Wed, 15 Jun 2011 22:41:45 -0600 [thread overview]
Message-ID: <20110616044141.29371.76366.stgit@ponder> (raw)
In-Reply-To: <20110616042653.29371.2052.stgit@ponder>
irq_domain_add_simple() is an easy way to generate an irq translation
domain for simple irq controllers. It assumes a flat 1:1 mapping from
hardware irq number to an offset of the first linux irq number assigned
to the controller
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
---
include/linux/irq.h | 11 +++++++++
kernel/irq/irqdomain.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 68 insertions(+), 1 deletions(-)
diff --git a/include/linux/irq.h b/include/linux/irq.h
index a103c01..50830fc 100644
--- a/include/linux/irq.h
+++ b/include/linux/irq.h
@@ -797,6 +797,17 @@ extern unsigned int irq_domain_map(struct irq_domain *domain,
irq_hw_number_t hwirq);
extern void irq_domain_unmap(struct irq_domain *domain, irq_hw_number_t hw);
+struct of_device_id;
+#ifdef CONFIG_OF
+extern void irq_domain_add_simple(struct device_node *controller, int irq_base);
+extern void irq_domain_generate_simple(struct of_device_id *match,
+ u64 phys_base, unsigned int irq_start);
+#else
+static inline void irq_domain_generate_simple(struct of_device_id *match,
+ u64 phys_base, unsigned int irq_start) { }
+#endif
+
+
#endif /* !CONFIG_S390 */
#endif /* _LINUX_IRQ_H */
diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c
index 8310d6e..2d03c2d 100644
--- a/kernel/irq/irqdomain.c
+++ b/kernel/irq/irqdomain.c
@@ -1,7 +1,9 @@
-
#include <linux/irq.h>
#include <linux/module.h>
#include <linux/mutex.h>
+#include <linux/of.h>
+#include <linux/of_address.h>
+#include <linux/slab.h>
static LIST_HEAD(irq_domain_list);
static DEFINE_MUTEX(irq_domain_mutex);
@@ -116,6 +118,8 @@ unsigned int irq_create_of_mapping(struct device_node *controller,
irq = irq_domain_map(domain, hwirq);
if (type != IRQ_TYPE_NONE)
irq_set_irq_type(irq, type);
+ pr_debug("%s: mapped hwirq=%i to irq=%i, flags=%x\n",
+ controller->full_name, (int)hwirq, irq, type);
return irq;
}
EXPORT_SYMBOL_GPL(irq_create_of_mapping);
@@ -134,4 +138,56 @@ void irq_dispose_mapping(unsigned int irq)
}
EXPORT_SYMBOL_GPL(irq_dispose_mapping);
+int irq_domain_simple_dt_translate(struct irq_domain *d,
+ struct device_node *controller,
+ const u32 *intspec, unsigned int intsize,
+ irq_hw_number_t *out_hwirq, unsigned int *out_type)
+{
+ if (d->of_node != controller)
+ return -EINVAL;
+ if (intsize != 1)
+ return -EINVAL;
+
+ *out_hwirq = intspec[0];
+ *out_type = IRQ_TYPE_NONE;
+ return 0;
+}
+
+struct irq_domain_ops irq_domain_simple_ops = {
+ .dt_translate = irq_domain_simple_dt_translate,
+};
+
+/**
+ * irq_domain_create_simple() - Set up a 'simple' translation range
+ */
+void irq_domain_add_simple(struct device_node *controller, int irq_base)
+{
+ struct irq_domain *domain;
+
+ domain = kzalloc(sizeof(*domain), GFP_KERNEL);
+ if (!domain) {
+ WARN_ON(1);
+ return;
+ }
+
+ domain->irq_base = irq_base;
+ domain->of_node = of_node_get(controller);
+ domain->ops = &irq_domain_simple_ops;
+ irq_domain_add(domain);
+}
+EXPORT_SYMBOL_GPL(irq_domain_add_simple);
+
+void irq_domain_generate_simple(struct of_device_id *match,
+ u64 phys_base, unsigned int irq_start)
+{
+ struct device_node *node;
+ pr_info("looking for phys_base=%llx, irq_start=%i\n",
+ (unsigned long long) phys_base, (int) irq_start);
+ node = of_find_matching_node_by_address(NULL, match, phys_base);
+ if (node)
+ irq_domain_add_simple(node, irq_start);
+ else
+ pr_info("no node found\n");
+}
+EXPORT_SYMBOL_GPL(irq_domain_generate_simple);
#endif
next prev parent reply other threads:[~2011-06-16 4:41 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-16 4:40 [RFC PATCH 00/11] Full device tree support for ARM Versatile Grant Likely
2011-06-16 4:41 ` [RFC PATCH 01/11] irq: add irq_domain translation infrastructure Grant Likely
2011-06-20 9:54 ` Marc Zyngier
2011-06-16 4:41 ` [RFC PATCH 02/11] of/address: Add of_find_matching_node_by_address helper Grant Likely
2011-06-16 4:41 ` Grant Likely [this message]
2011-06-16 14:04 ` [RFC PATCH 03/11] dt/irq: add irq_domain_add_simple() helper Rob Herring
2011-06-16 14:21 ` Rob Herring
2011-06-16 16:57 ` Grant Likely
2011-06-16 16:56 ` Grant Likely
2011-06-16 4:41 ` [RFC PATCH 04/11] dt: add of_platform_populate() for creating device from the device tree Grant Likely
2011-06-16 4:42 ` [RFC PATCH 05/11] dt: Add default match table for bus ids Grant Likely
2011-06-16 4:42 ` [RFC PATCH 06/11] drivers/amba: create devices from device tree Grant Likely
2011-06-16 4:42 ` [RFC PATCH 07/11] dt/platform: allow device name to be overridden Grant Likely
2011-06-16 4:42 ` [RFC PATCH 08/11] powerpc/5200: convert mpc5200 to use of_platform_populate() Grant Likely
2011-06-16 4:42 ` [RFC PATCH 09/11] arm/dt: Add dt machine definition Grant Likely
2011-07-08 14:30 ` Rob Herring
2011-06-16 4:43 ` [RFC PATCH 10/11] arm/dt: Add skeleton dtsi file Grant Likely
2011-06-16 4:43 ` [RFC PATCH 11/11] arm/versatile: Add device tree support Grant Likely
2011-06-16 14:19 ` Rob Herring
2011-06-16 15:42 ` Grant Likely
2011-06-16 14:20 ` Arnd Bergmann
2011-06-16 14:56 ` Grant Likely
2011-06-17 1:11 ` Shawn Guo
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=20110616044141.29371.76366.stgit@ponder \
--to=grant.likely@secretlab.ca \
--cc=linux-arm-kernel@lists.infradead.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;
as well as URLs for NNTP newsgroup(s).