Patchwork [v2] powerpc: Specify GPIO number base for controller in DT

login
register
mail settings
Submitter Wolfgang Ocker
Date Oct. 23, 2008, 2:30 p.m.
Message ID <1224772209.4082.61.camel@galileo.recco.de>
Download mbox | patch
Permalink /patch/5476/
State Superseded
Headers show

Comments

Wolfgang Ocker - Oct. 23, 2008, 2:30 p.m.
The GPIOLIB allows the specification of a base gpio number for a
controller. That is not possible using OF. Instead, free gpio numbers
are assigned.

In order to allow static, predefined gpio numbers, a base property in
the gpio controller node specifies the first gpio number.

v2: added description of base property in doc 

Signed-off-by: Wolfgang Ocker <weo@reccoware.de>
---
Kumar Gala - Oct. 23, 2008, 2:40 p.m.
On Oct 23, 2008, at 9:30 AM, Wolfgang Ocker wrote:

> --- linux-2.6.27.2/Documentation/powerpc/booting-without- 
> of.txt.of_gpiospecbase	2008-10-18 19:57:22.000000000 +0200
> +++ linux-2.6.27.2/Documentation/powerpc/booting-without-of.txt	 
> 2008-10-23 16:23:07.000000000 +0200
> @@ -2580,12 +2582,17 @@
> Every GPIO controller node must have #gpio-cells property defined,
> this information will be used to translate gpio-specifiers.
>
> +Optional properties:
> +	base: first GPIO number handled by this controller; default is -1,
> +		meaning dynamic ID allocation

"default -1" doesn't make any sense.  I assume you mean if the  
property doesn't it exist the behavior is "dynamic ID allocation"

>
> +
> Example of two SOC GPIO banks defined as gpio-controller nodes:
>
> 	qe_pio_a: gpio-controller@1400 {
> 		#gpio-cells = <2>;
> 		compatible = "fsl,qe-pario-bank-a", "fsl,qe-pario-bank";
> 		reg = <0x1400 0x18>;
> +		base = < 0x20 >;
> 		gpio-controller;
> 	};
>

Patch

--- linux-2.6.27.2/drivers/of/gpio.c.of_gpiospecbase	2008-10-18 19:57:22.000000000 +0200
+++ linux-2.6.27.2/drivers/of/gpio.c	2008-10-23 10:55:19.000000000 +0200
@@ -164,6 +164,8 @@ 
 	int ret = -ENOMEM;
 	struct of_gpio_chip *of_gc = &mm_gc->of_gc;
 	struct gpio_chip *gc = &of_gc->gc;
+	const int *basep;
+	int baselen;
 
 	gc->label = kstrdup(np->full_name, GFP_KERNEL);
 	if (!gc->label)
@@ -173,7 +175,11 @@ 
 	if (!mm_gc->regs)
 		goto err1;
 
-	gc->base = -1;
+	basep = of_get_property(np, "base", &baselen);
+	if (!basep || baselen != sizeof(*basep))
+		gc->base = -1;
+	else
+		gc->base = *basep;
 
 	if (!of_gc->xlate)
 		of_gc->xlate = of_gpio_simple_xlate;
--- linux-2.6.27.2/Documentation/powerpc/booting-without-of.txt.of_gpiospecbase	2008-10-18 19:57:22.000000000 +0200
+++ linux-2.6.27.2/Documentation/powerpc/booting-without-of.txt	2008-10-23 16:23:07.000000000 +0200
@@ -2580,12 +2582,17 @@ 
 Every GPIO controller node must have #gpio-cells property defined,
 this information will be used to translate gpio-specifiers.
 
+Optional properties:
+	base: first GPIO number handled by this controller; default is -1,
+		meaning dynamic ID allocation
+
 Example of two SOC GPIO banks defined as gpio-controller nodes:
 
 	qe_pio_a: gpio-controller@1400 {
 		#gpio-cells = <2>;
 		compatible = "fsl,qe-pario-bank-a", "fsl,qe-pario-bank";
 		reg = <0x1400 0x18>;
+		base = < 0x20 >;
 		gpio-controller;
 	};