From: Haojian Zhuang <haojian.zhuang@marvell.com>
To: arnd@arndb.de, linux-arm-kernel@lists.infradead.org,
devicetree-discuss@lists.ozlabs.org, grant.likely@secretlab.ca,
linux@arm.linux.org.uk, eric.y.miao@gmail.com
Cc: Haojian Zhuang <haojian.zhuang@marvell.com>
Subject: [PATCH 1/8] gpio: pxa: add OF support
Date: Thu, 1 Mar 2012 14:10:21 +0800 [thread overview]
Message-ID: <1330582228-12424-2-git-send-email-haojian.zhuang@marvell.com> (raw)
In-Reply-To: <1330582228-12424-1-git-send-email-haojian.zhuang@marvell.com>
gpio-pxa drivers needs to parse two properties: mrvl,gpio-irq0 and
mrvl,gpio-irq1.
There may be 3 irqs in gpio devices in arch-pxa. The first one may
be only for gpio0, the second on may be only for gpio1, and the last
one may be the irq mux for other gpios. In arch-mmp, there's only
one irq mux for all gpios.
Since irq mux is common, we only specify it in interrupts propery.
And we creates two properties mrvl,gpio-irq0 and mrvl,gpio-irq1 for
arch-pxa.
Signed-off-by: Haojian Zhuang <haojian.zhuang@marvell.com>
---
drivers/gpio/gpio-pxa.c | 40 +++++++++++++++++++++++++++++++++++++---
1 files changed, 37 insertions(+), 3 deletions(-)
diff --git a/drivers/gpio/gpio-pxa.c b/drivers/gpio/gpio-pxa.c
index b2d3ee1..7d8e1d0 100644
--- a/drivers/gpio/gpio-pxa.c
+++ b/drivers/gpio/gpio-pxa.c
@@ -18,6 +18,7 @@
#include <linux/init.h>
#include <linux/irq.h>
#include <linux/io.h>
+#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/syscore_ops.h>
#include <linux/slab.h>
@@ -464,6 +465,39 @@ static int pxa_gpio_nums(void)
return count;
}
+#ifdef CONFIG_OF
+static int __devinit pxa_gpio_probe_dt(struct platform_device *pdev,
+ int *irq0, int *irq1, int *irq_mux)
+{
+ struct device_node *np = pdev->dev.of_node;
+ const __be32 *irq;
+
+ irq = of_get_property(np, "mrvl,gpio-irq0", NULL);
+ if (irq)
+ *irq0 = be32_to_cpup(irq);
+ irq = of_get_property(np, "mrvl,gpio-irq1", NULL);
+ if (irq)
+ *irq1 = be32_to_cpup(irq);
+ *irq_mux = platform_get_irq(pdev, 0);
+ return 0;
+}
+#else
+static int __devinit pxa_gpio_probe_dt(struct platform_device *pdev,
+ int *irq0, int *irq1, int *irq_mux)
+{
+ return 1;
+}
+#endif
+
+static int __devinit pxa_gpio_probe_irq(struct platform_device *pdev,
+ int *irq0, int *irq1, int *irq_mux)
+{
+ *irq0 = platform_get_irq_byname(pdev, "gpio0");
+ *irq1 = platform_get_irq_byname(pdev, "gpio1");
+ *irq_mux = platform_get_irq_byname(pdev, "gpio_mux");
+ return 0;
+}
+
static int __devinit pxa_gpio_probe(struct platform_device *pdev)
{
struct pxa_gpio_chip *c;
@@ -476,9 +510,9 @@ static int __devinit pxa_gpio_probe(struct platform_device *pdev)
if (!pxa_last_gpio)
return -EINVAL;
- irq0 = platform_get_irq_byname(pdev, "gpio0");
- irq1 = platform_get_irq_byname(pdev, "gpio1");
- irq_mux = platform_get_irq_byname(pdev, "gpio_mux");
+ ret = pxa_gpio_probe_dt(pdev, &irq0, &irq1, &irq_mux);
+ if (ret > 0)
+ ret = pxa_gpio_probe_irq(pdev, &irq0, &irq1, &irq_mux);
if ((irq0 > 0 && irq1 <= 0) || (irq0 <= 0 && irq1 > 0)
|| (irq_mux <= 0))
return -EINVAL;
--
1.7.0.4
next prev parent reply other threads:[~2012-03-01 6:10 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-01 6:10 [PATCH 0/8] ARM: mmp: support OF on pxa168 Haojian Zhuang
2012-03-01 6:10 ` Haojian Zhuang [this message]
[not found] ` <1330582228-12424-2-git-send-email-haojian.zhuang-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org>
2012-03-01 9:40 ` [PATCH 1/8] gpio: pxa: add OF support Arnd Bergmann
[not found] ` <201203010940.37123.arnd-r2nGTMty4D4@public.gmane.org>
2012-03-01 9:51 ` Arnd Bergmann
2012-03-01 6:10 ` [PATCH 2/8] serial: " Haojian Zhuang
[not found] ` <1330582228-12424-3-git-send-email-haojian.zhuang-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org>
2012-03-01 9:47 ` Arnd Bergmann
[not found] ` <201203010947.39601.arnd-r2nGTMty4D4@public.gmane.org>
2012-03-01 9:48 ` Russell King - ARM Linux
[not found] ` <20120301094853.GA7363-l+eeeJia6m9vn6HldHNs0ANdhmdF6hFW@public.gmane.org>
2012-03-01 12:55 ` Haojian Zhuang
2012-03-01 6:10 ` [PATCH 3/8] rtc: sa1100: " Haojian Zhuang
[not found] ` <1330582228-12424-4-git-send-email-haojian.zhuang-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org>
2012-03-01 9:51 ` Arnd Bergmann
[not found] ` <201203010951.12405.arnd-r2nGTMty4D4@public.gmane.org>
2012-03-01 12:52 ` Haojian Zhuang
2012-03-01 6:10 ` [PATCH 4/8] i2c: pxa: " Haojian Zhuang
[not found] ` <1330582228-12424-5-git-send-email-haojian.zhuang-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org>
2012-03-01 10:01 ` Arnd Bergmann
2012-03-01 6:10 ` [PATCH 5/8] ARM: mmp: enable rtc clk in pxa168 Haojian Zhuang
2012-03-01 6:10 ` [PATCH 6/8] ARM: mmp: append OF support on pxa168 Haojian Zhuang
2012-03-01 6:10 ` [PATCH 7/8] ARM: dts: append DTS file of pxa168 Haojian Zhuang
2012-03-01 6:10 ` [PATCH 8/8] Document: devicetree: add OF documents for arch-mmp Haojian Zhuang
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=1330582228-12424-2-git-send-email-haojian.zhuang@marvell.com \
--to=haojian.zhuang@marvell.com \
--cc=arnd@arndb.de \
--cc=devicetree-discuss@lists.ozlabs.org \
--cc=eric.y.miao@gmail.com \
--cc=grant.likely@secretlab.ca \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux@arm.linux.org.uk \
/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).