devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch 2/2] Add GPIO DT support to s3c24xx
       [not found] <20110407163322.465935232@gmail.com>
@ 2011-04-07 16:39 ` Domenico Andreoli
  0 siblings, 0 replies; 8+ messages in thread
From: Domenico Andreoli @ 2011-04-07 16:39 UTC (permalink / raw)
  To: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ
  Cc: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r

[-- Attachment #1: s3c24xx-gpio-add-dt-support --]
[-- Type: text/plain, Size: 3140 bytes --]

From: Domenico Andreoli <cavokz-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

Add DT compat strings to the GPIO chips registerd by s3c24xx SOCs.

Signed-off-by: Domenico Andreoli <cavokz-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

---
 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-07 18:16:09.000000000 +0200
+++ b/arch/arm/plat-s3c24xx/gpiolib.c	2011-04-07 18:20:41.000000000 +0200
@@ -94,6 +94,9 @@
 			.owner			= THIS_MODULE,
 			.label			= "GPIOA",
 			.ngpio			= 24,
+#if defined(CONFIG_OF_GPIO)
+			.dt_compat		= "samsung,s3c2410-gpio-a",
+#endif
 			.direction_input	= s3c24xx_gpiolib_banka_input,
 			.direction_output	= s3c24xx_gpiolib_banka_output,
 		},
@@ -106,6 +109,9 @@
 			.owner			= THIS_MODULE,
 			.label			= "GPIOB",
 			.ngpio			= 16,
+#if defined(CONFIG_OF_GPIO)
+			.dt_compat		= "samsung,s3c2410-gpio-b",
+#endif
 		},
 	},
 	[2] = {
@@ -116,6 +122,9 @@
 			.owner			= THIS_MODULE,
 			.label			= "GPIOC",
 			.ngpio			= 16,
+#if defined(CONFIG_OF_GPIO)
+			.dt_compat		= "samsung,s3c2410-gpio-c",
+#endif
 		},
 	},
 	[3] = {
@@ -126,6 +135,9 @@
 			.owner			= THIS_MODULE,
 			.label			= "GPIOD",
 			.ngpio			= 16,
+#if defined(CONFIG_OF_GPIO)
+			.dt_compat		= "samsung,s3c2410-gpio-d",
+#endif
 		},
 	},
 	[4] = {
@@ -136,6 +148,9 @@
 			.label			= "GPIOE",
 			.owner			= THIS_MODULE,
 			.ngpio			= 16,
+#if defined(CONFIG_OF_GPIO)
+			.dt_compat		= "samsung,s3c2410-gpio-e",
+#endif
 		},
 	},
 	[5] = {
@@ -147,6 +162,9 @@
 			.label			= "GPIOF",
 			.ngpio			= 8,
 			.to_irq			= s3c24xx_gpiolib_bankf_toirq,
+#if defined(CONFIG_OF_GPIO)
+			.dt_compat		= "samsung,s3c2410-gpio-f",
+#endif
 		},
 	},
 	[6] = {
@@ -159,6 +177,9 @@
 			.label			= "GPIOG",
 			.ngpio			= 16,
 			.to_irq			= samsung_gpiolib_to_irq,
+#if defined(CONFIG_OF_GPIO)
+			.dt_compat		= "samsung,s3c2410-gpio-g",
+#endif
 		},
 	}, {
 		.base	= S3C2410_GPHCON,
@@ -168,6 +189,9 @@
 			.owner			= THIS_MODULE,
 			.label			= "GPIOH",
 			.ngpio			= 11,
+#if defined(CONFIG_OF_GPIO)
+			.dt_compat		= "samsung,s3c2410-gpio-h",
+#endif
 		},
 	},
 		/* GPIOS for the S3C2443 and later devices. */
@@ -179,6 +203,9 @@
 			.owner			= THIS_MODULE,
 			.label			= "GPIOJ",
 			.ngpio			= 16,
+#if defined(CONFIG_OF_GPIO)
+			.dt_compat		= "samsung,s3c2440-gpio-j",
+#endif
 		},
 	}, {
 		.base	= S3C2443_GPKCON,
@@ -188,6 +215,9 @@
 			.owner			= THIS_MODULE,
 			.label			= "GPIOK",
 			.ngpio			= 16,
+#if defined(CONFIG_OF_GPIO)
+			.dt_compat		= "samsung,s3c2443-gpio-k",
+#endif
 		},
 	}, {
 		.base	= S3C2443_GPLCON,
@@ -197,6 +227,9 @@
 			.owner			= THIS_MODULE,
 			.label			= "GPIOL",
 			.ngpio			= 15,
+#if defined(CONFIG_OF_GPIO)
+			.dt_compat		= "samsung,s3c2443-gpio-l",
+#endif
 		},
 	}, {
 		.base	= S3C2443_GPMCON,
@@ -206,6 +239,9 @@
 			.owner			= THIS_MODULE,
 			.label			= "GPIOM",
 			.ngpio			= 2,
+#if defined(CONFIG_OF_GPIO)
+			.dt_compat		= "samsung,s3c2443-gpio-m",
+#endif
 		},
 	},
 };

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [patch 1/2] Add dt_compat field to struct s3c_gpio_chip
       [not found] <20110410152735.338798127@gmail.com>
@ 2011-04-10 15:33 ` Domenico Andreoli
       [not found]   ` <20110410153312.GB27088-iIV0ii4H0r6tG0bUXCXiUA@public.gmane.org>
  2011-04-10 15:33 ` [patch 2/2] Add GPIO DT support to s3c24xx Domenico Andreoli
  1 sibling, 1 reply; 8+ messages in thread
From: Domenico Andreoli @ 2011-04-10 15:33 UTC (permalink / raw)
  To: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ
  Cc: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r

[-- Attachment #1: arm-plat-samsung-add-dt_compat-to-s3c_gpio_chip --]
[-- Type: text/plain, Size: 832 bytes --]

From: Domenico Andreoli <cavokz-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

This new field allows easy creation of GPIO chips in base of struct arrays.

Signed-off-by: Domenico Andreoli <cavokz-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

---
 arch/arm/plat-samsung/include/plat/gpio-core.h |    3 +++
 1 file changed, 3 insertions(+)

Index: b/arch/arm/plat-samsung/include/plat/gpio-core.h
===================================================================
--- a/arch/arm/plat-samsung/include/plat/gpio-core.h	2011-04-07 22:43:45.000000000 +0200
+++ b/arch/arm/plat-samsung/include/plat/gpio-core.h	2011-04-10 16:00:39.000000000 +0200
@@ -71,6 +71,9 @@
 #ifdef CONFIG_PM
 	u32			pm_save[4];
 #endif
+#ifdef CONFIG_OF_GPIO
+	const char		*dt_compat;
+#endif
 };
 
 static inline struct s3c_gpio_chip *to_s3c_gpio(struct gpio_chip *gpc)

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [patch 2/2] Add GPIO DT support to s3c24xx
       [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
@ 2011-04-10 15:33 ` Domenico Andreoli
       [not found]   ` <20110410153316.GC27088-iIV0ii4H0r6tG0bUXCXiUA@public.gmane.org>
  1 sibling, 1 reply; 8+ messages in thread
From: Domenico Andreoli @ 2011-04-10 15:33 UTC (permalink / raw)
  To: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ
  Cc: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r

[-- Attachment #1: s3c24xx-gpio-add-dt-support --]
[-- Type: text/plain, Size: 2090 bytes --]

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>

---
 arch/arm/plat-s3c24xx/gpiolib.c |   45 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)

Index: b/arch/arm/plat-s3c24xx/gpiolib.c
===================================================================
--- a/arch/arm/plat-s3c24xx/gpiolib.c	2011-04-10 16:24:59.000000000 +0200
+++ b/arch/arm/plat-s3c24xx/gpiolib.c	2011-04-10 17:12:32.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>
@@ -97,6 +99,9 @@
 			.direction_input	= s3c24xx_gpiolib_banka_input,
 			.direction_output	= s3c24xx_gpiolib_banka_output,
 		},
+#ifdef CONFIG_OF_GPIO
+		.dt_compat = "samsung,s3c2410-gpio-a",
+#endif
 	},
 	[1] = {
 		.base	= S3C2410_GPBCON,
@@ -210,6 +215,45 @@
 	},
 };
 
+#ifdef CONFIG_OF_GPIO
+static int s3c24xx_of_base_match(struct s3c_gpio_chip *chip, struct device_node *dn)
+{
+	const u32 *addrp;
+	u64 addr;
+
+	addrp = of_get_address(dn, 0, 0, NULL);
+	if (!addrp)
+		return 0;
+
+	addr = of_translate_address(dn, addrp);
+	if (addr == OF_BAD_ADDR)
+		return 0;
+
+	return chip->base == (addr - S3C24XX_PA_GPIO + S3C24XX_VA_GPIO);
+}
+
+static void s3c24xx_attach_of_node(struct s3c_gpio_chip *chip)
+{
+	struct device_node *dn;
+
+	if (!chip->dt_compat)
+		chip->dt_compat = "samsung,s3c2410-gpio";
+
+	for_each_compatible_node(dn, NULL, chip->dt_compat) {
+		if (s3c24xx_of_base_match(chip, dn)) {
+			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 +264,7 @@
 		if (!chip->config)
 			chip->config = &s3c24xx_gpiocfg_default;
 
+		s3c24xx_attach_of_node(chip);
 		s3c_gpiolib_add(chip);
 	}

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [patch 1/2] Add dt_compat field to struct s3c_gpio_chip
       [not found]   ` <20110410153312.GB27088-iIV0ii4H0r6tG0bUXCXiUA@public.gmane.org>
@ 2011-04-11  6:41     ` Grant Likely
  0 siblings, 0 replies; 8+ messages in thread
From: Grant Likely @ 2011-04-11  6:41 UTC (permalink / raw)
  To: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	Domenico Andreoli

On Sun, Apr 10, 2011 at 05:33:12PM +0200, Domenico Andreoli wrote:
> From: Domenico Andreoli <cavokz-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> 
> This new field allows easy creation of GPIO chips in base of struct arrays.
> 
> Signed-off-by: Domenico Andreoli <cavokz-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> 
> ---
>  arch/arm/plat-samsung/include/plat/gpio-core.h |    3 +++
>  1 file changed, 3 insertions(+)
> 
> Index: b/arch/arm/plat-samsung/include/plat/gpio-core.h
> ===================================================================
> --- a/arch/arm/plat-samsung/include/plat/gpio-core.h	2011-04-07 22:43:45.000000000 +0200
> +++ b/arch/arm/plat-samsung/include/plat/gpio-core.h	2011-04-10 16:00:39.000000000 +0200
> @@ -71,6 +71,9 @@
>  #ifdef CONFIG_PM
>  	u32			pm_save[4];
>  #endif
> +#ifdef CONFIG_OF_GPIO
> +	const char		*dt_compat;
> +#endif

I think you can merge this with the next patch.

g.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [patch 2/2] Add GPIO DT support to s3c24xx
       [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>
  0 siblings, 1 reply; 8+ messages in thread
From: Grant Likely @ 2011-04-11  6:47 UTC (permalink / raw)
  To: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	Domenico Andreoli

On Sun, Apr 10, 2011 at 05:33:16PM +0200, Domenico Andreoli wrote:
> 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>

Looks pretty good.  Minor comments below.

g.

> 
> ---
>  arch/arm/plat-s3c24xx/gpiolib.c |   45 ++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 45 insertions(+)
> 
> Index: b/arch/arm/plat-s3c24xx/gpiolib.c
> ===================================================================
> --- a/arch/arm/plat-s3c24xx/gpiolib.c	2011-04-10 16:24:59.000000000 +0200
> +++ b/arch/arm/plat-s3c24xx/gpiolib.c	2011-04-10 17:12:32.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>
> @@ -97,6 +99,9 @@
>  			.direction_input	= s3c24xx_gpiolib_banka_input,
>  			.direction_output	= s3c24xx_gpiolib_banka_output,
>  		},
> +#ifdef CONFIG_OF_GPIO
> +		.dt_compat = "samsung,s3c2410-gpio-a",
> +#endif

The '-a' bit I suspect is wrong.  Aren't all the gpio banks of the same type?

>  	},
>  	[1] = {
>  		.base	= S3C2410_GPBCON,
> @@ -210,6 +215,45 @@
>  	},
>  };
>  
> +#ifdef CONFIG_OF_GPIO
> +static int s3c24xx_of_base_match(struct s3c_gpio_chip *chip, struct device_node *dn)
> +{
> +	const u32 *addrp;
> +	u64 addr;
> +
> +	addrp = of_get_address(dn, 0, 0, NULL);
> +	if (!addrp)
> +		return 0;
> +
> +	addr = of_translate_address(dn, addrp);
> +	if (addr == OF_BAD_ADDR)
> +		return 0;

Use of_address_to_resource() instead.

> +
> +	return chip->base == (addr - S3C24XX_PA_GPIO + S3C24XX_VA_GPIO);
> +}
> +
> +static void s3c24xx_attach_of_node(struct s3c_gpio_chip *chip)
> +{
> +	struct device_node *dn;
> +
> +	if (!chip->dt_compat)
> +		chip->dt_compat = "samsung,s3c2410-gpio";
> +
> +	for_each_compatible_node(dn, NULL, chip->dt_compat) {
> +		if (s3c24xx_of_base_match(chip, dn)) {
> +			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 +264,7 @@
>  		if (!chip->config)
>  			chip->config = &s3c24xx_gpiocfg_default;
>  
> +		s3c24xx_attach_of_node(chip);
>  		s3c_gpiolib_add(chip);
>  	}
>  
> 
> _______________________________________________
> devicetree-discuss mailing list
> devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org
> https://lists.ozlabs.org/listinfo/devicetree-discuss

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v3] Add GPIO DT support to s3c24xx
       [not found]       ` <20110411064719.GD4439-MrY2KI0G/OVr83L8+7iqerDks+cytr/Z@public.gmane.org>
@ 2011-04-11  9:33         ` Domenico Andreoli
  2011-04-15  0:08           ` Marek Vasut
  0 siblings, 1 reply; 8+ messages in thread
From: Domenico Andreoli @ 2011-04-11  9:33 UTC (permalink / raw)
  To: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r

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);
 	}

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v3] Add GPIO DT support to s3c24xx
  2011-04-11  9:33         ` [PATCH v3] " Domenico Andreoli
@ 2011-04-15  0:08           ` Marek Vasut
  0 siblings, 0 replies; 8+ messages in thread
From: Marek Vasut @ 2011-04-15  0:08 UTC (permalink / raw)
  To: linux-arm-kernel; +Cc: devicetree-discuss, Domenico Andreoli

On Monday, April 11, 2011 11:33:04 AM Domenico Andreoli wrote:
> From: Domenico Andreoli <cavokz@gmail.com>
> 
> Assign proper OF node (= with matching physical base address) to each
> s3c24xx GPIO chip.
> 
> Signed-off-by: Domenico Andreoli <cavokz@gmail.com>
> 
> ---
> 
> 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)

static inline void maybe ;)

> +{
> +}
> +
> +#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);
>  	}
> 
> 
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 2/2] Add GPIO DT support to s3c24xx
       [not found] <20110421130711.920096092@gmail.com>
@ 2011-04-21 13:17 ` Domenico Andreoli
  0 siblings, 0 replies; 8+ messages in thread
From: Domenico Andreoli @ 2011-04-21 13:17 UTC (permalink / raw)
  To: devicetree-discuss, linux-mmc, spi-devel-general

[-- Attachment #1: s3c24xx-gpio-add-dt-support --]
[-- Type: text/plain, Size: 1709 bytes --]

From: Domenico Andreoli <cavokz@gmail.com>

Assign proper OF node (= with matching physical base address) to each
s3c24xx GPIO chip.

Signed-off-by: Domenico Andreoli <cavokz@gmail.com>

---
 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);
 	}
 


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2011-04-21 13:17 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [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         ` [PATCH v3] " Domenico Andreoli
2011-04-15  0:08           ` Marek Vasut
     [not found] <20110421130711.920096092@gmail.com>
2011-04-21 13:17 ` [PATCH 2/2] " Domenico Andreoli
     [not found] <20110407163322.465935232@gmail.com>
2011-04-07 16:39 ` [patch " Domenico Andreoli

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).