diff mbox

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

Message ID 1224773378.4082.64.camel@galileo.recco.de (mailing list archive)
State Rejected, archived
Headers show

Commit Message

Wolfgang Ocker Oct. 23, 2008, 2:49 p.m. UTC
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, v3: added/improved description of base property in doc 

Signed-off-by: Wolfgang Ocker <weo@reccoware.de>
---

Comments

Stefan Roese Oct. 23, 2008, 6:13 p.m. UTC | #1
On Thursday 23 October 2008, Wolfgang Ocker wrote:
> 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, v3: added/improved description of base property in doc

These version descriptions are better placed below the "---" line. And you 
should remove the "Re: " from the subject line. Other than this:

Acked-by: Stefan Roese <sr@denx.de>

> Signed-off-by: Wolfgang Ocker <weo@reccoware.de>
> ---

Best regards,
Stefan
Anton Vorontsov Oct. 24, 2008, 4:54 p.m. UTC | #2
On Thu, Oct 23, 2008 at 08:13:00PM +0200, Stefan Roese wrote:
> On Thursday 23 October 2008, Wolfgang Ocker wrote:
> > 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, v3: added/improved description of base property in doc
> 
> These version descriptions are better placed below the "---" line. And you 
> should remove the "Re: " from the subject line. Other than this:
> 
> Acked-by: Stefan Roese <sr@denx.de>

Please-defer-this-patch-by: Anton Vorontsov <avorontsov@ru.mvista.com>

Wolfgang, Stefan, see this comment:

http://ozlabs.org/pipermail/linuxppc-dev/2008-October/064505.html

..just tell me what are you trying to solve.

Thanks,
Grant Likely Oct. 24, 2008, 5:12 p.m. UTC | #3
On Fri, Oct 24, 2008 at 10:54 AM, Anton Vorontsov
<avorontsov@ru.mvista.com> wrote:
> On Thu, Oct 23, 2008 at 08:13:00PM +0200, Stefan Roese wrote:
>> On Thursday 23 October 2008, Wolfgang Ocker wrote:
>> > 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, v3: added/improved description of base property in doc
>>
>> These version descriptions are better placed below the "---" line. And you
>> should remove the "Re: " from the subject line. Other than this:
>>
>> Acked-by: Stefan Roese <sr@denx.de>
>
> Please-defer-this-patch-by: Anton Vorontsov <avorontsov@ru.mvista.com>
>
> Wolfgang, Stefan, see this comment:
>
> http://ozlabs.org/pipermail/linuxppc-dev/2008-October/064505.html
>
> ..just tell me what are you trying to solve.

Yeah, I don't like this patch either.  GPIO numbering is a Linux
internal detail and has no bearing on the hardware description.  If
you need to know what a particular gpio number is then it should be
resolved by finding the device tree node; not by trying to fix a GPIO
controller to a particular number.

g.
Wolfgang Ocker Oct. 24, 2008, 6 p.m. UTC | #4
On Fri, 2008-10-24 at 11:12 -0600, Grant Likely wrote:
> On Fri, Oct 24, 2008 at 10:54 AM, Anton Vorontsov
> <avorontsov@ru.mvista.com> wrote:
> > On Thu, Oct 23, 2008 at 08:13:00PM +0200, Stefan Roese wrote:
> >> On Thursday 23 October 2008, Wolfgang Ocker wrote:
> >> > 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, v3: added/improved description of base property in doc
> >>
> >> These version descriptions are better placed below the "---" line. And you
> >> should remove the "Re: " from the subject line. Other than this:
> >>
> >> Acked-by: Stefan Roese <sr@denx.de>

> Yeah, I don't like this patch either.  GPIO numbering is a Linux
> internal detail and has no bearing on the hardware description.  If
> you need to know what a particular gpio number is then it should be
> resolved by finding the device tree node; not by trying to fix a GPIO
> controller to a particular number.

Okay, now I think I understand.

I'll try to solve the chip select pin addressing in the spi driver
differently. Thank you guys!

Wolfgang
diff mbox

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:45:06.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; if the property
+		does not exist, the first GPIO number is allocated dynamicly
+
 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;
 	};