From: Domenico Andreoli <cavokz-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
Subject: [PATCH v3] Add GPIO DT support to s3c24xx
Date: Mon, 11 Apr 2011 11:33:04 +0200 [thread overview]
Message-ID: <20110411093304.GA21589@dandreoli.com> (raw)
In-Reply-To: <20110411064719.GD4439-MrY2KI0G/OVr83L8+7iqerDks+cytr/Z@public.gmane.org>
From: Domenico Andreoli <cavokz-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Assign proper OF node (= with matching physical base address) to each
s3c24xx GPIO chip.
Signed-off-by: Domenico Andreoli <cavokz-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
With this new patch there is no need to add the dt_compat field to
s3c_gpio_chip, such string is now chosen in base of the s3c gpio chip
base address.
Respect to v2, s3c24xx_attach_of_node() now uses of_address_to_resource()
instead of of_get_address()+of_translate_address(). I don't see where
is the gain.
---
arch/arm/plat-s3c24xx/gpiolib.c | 36 ++++++++++++++++++++++++++++++++++++
1 file changed, 36 insertions(+)
Index: b/arch/arm/plat-s3c24xx/gpiolib.c
===================================================================
--- a/arch/arm/plat-s3c24xx/gpiolib.c 2011-04-10 23:28:31.000000000 +0200
+++ b/arch/arm/plat-s3c24xx/gpiolib.c 2011-04-11 11:23:36.000000000 +0200
@@ -19,6 +19,8 @@
#include <linux/ioport.h>
#include <linux/io.h>
#include <linux/gpio.h>
+#include <linux/of.h>
+#include <linux/of_address.h>
#include <plat/gpio-core.h>
#include <plat/gpio-cfg.h>
@@ -210,6 +212,39 @@
},
};
+#ifdef CONFIG_OF_GPIO
+
+static void s3c24xx_attach_of_node(struct s3c_gpio_chip *chip)
+{
+ struct device_node *dn;
+ struct resource res;
+ const char *dt_compat;
+
+ if (chip->base == S3C2410_GPACON)
+ dt_compat = "samsung,s3c2410-gpio-a";
+ else
+ dt_compat = "samsung,s3c2410-gpio";
+
+ for_each_compatible_node(dn, NULL, dt_compat) {
+ if (of_address_to_resource(dn, 0, &res) < 0) {
+ printk(KERN_ERR "%s: unable to translate DT address\n", dn->full_name);
+ continue;
+ }
+
+ if (chip->base == (res.start - S3C24XX_PA_GPIO + S3C24XX_VA_GPIO)) {
+ chip->chip.of_node = dn;
+ break;
+ }
+ }
+}
+
+#else
+
+static void s3c24xx_attach_of_node(struct s3c_gpio_chip *chip)
+{
+}
+
+#endif
static __init int s3c24xx_gpiolib_init(void)
{
@@ -220,6 +255,7 @@
if (!chip->config)
chip->config = &s3c24xx_gpiocfg_default;
+ s3c24xx_attach_of_node(chip);
s3c_gpiolib_add(chip);
}
next prev parent reply other threads:[~2011-04-11 9:33 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20110410152735.338798127@gmail.com>
2011-04-10 15:33 ` [patch 1/2] Add dt_compat field to struct s3c_gpio_chip Domenico Andreoli
[not found] ` <20110410153312.GB27088-iIV0ii4H0r6tG0bUXCXiUA@public.gmane.org>
2011-04-11 6:41 ` Grant Likely
2011-04-10 15:33 ` [patch 2/2] Add GPIO DT support to s3c24xx Domenico Andreoli
[not found] ` <20110410153316.GC27088-iIV0ii4H0r6tG0bUXCXiUA@public.gmane.org>
2011-04-11 6:47 ` Grant Likely
[not found] ` <20110411064719.GD4439-MrY2KI0G/OVr83L8+7iqerDks+cytr/Z@public.gmane.org>
2011-04-11 9:33 ` Domenico Andreoli [this message]
2011-04-15 0:08 ` [PATCH v3] " Marek Vasut
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=20110411093304.GA21589@dandreoli.com \
--to=cavokz-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
--cc=devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org \
--cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.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).