devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Vladimir Zapolskiy <vz@mleia.com>
To: Rob Herring <robh@kernel.org>
Cc: Linus Walleij <linus.walleij@linaro.org>,
	Alexandre Courbot <gnurou@gmail.com>,
	Arnd Bergmann <arnd@arndb.de>,
	Russell King <linux@arm.linux.org.uk>,
	Roland Stigge <stigge@antcom.de>,
	devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-gpio@vger.kernel.org
Subject: Re: [PATCH 1/4] dt-bindings: gpio: update desription of LPC32xx GPIO controller
Date: Fri, 20 Nov 2015 20:27:35 +0200	[thread overview]
Message-ID: <564F6617.6090104@mleia.com> (raw)
In-Reply-To: <20151120141354.GA25446@rob-hp-laptop>

On 20.11.2015 16:13, Rob Herring wrote:
> On Fri, Nov 20, 2015 at 03:29:52AM +0200, Vladimir Zapolskiy wrote:
>> For the purpose of better description of NXP LPC32xx GPIO controller
>> hardware in device tree format, extend the existing description with
>> device tree subnodes, which represent 6 GPIO banks within the
>> controller.
>>
>> Note, client interface to the GPIO controller is untouched.
>>
>> Signed-off-by: Vladimir Zapolskiy <vz@mleia.com>
>> ---
>>  .../devicetree/bindings/gpio/gpio_lpc32xx.txt      | 121 ++++++++++++++++++++-
>>  1 file changed, 120 insertions(+), 1 deletion(-)
>>
>> diff --git a/Documentation/devicetree/bindings/gpio/gpio_lpc32xx.txt b/Documentation/devicetree/bindings/gpio/gpio_lpc32xx.txt
>> index 4981936..d2da63c 100644
>> --- a/Documentation/devicetree/bindings/gpio/gpio_lpc32xx.txt
>> +++ b/Documentation/devicetree/bindings/gpio/gpio_lpc32xx.txt
>> @@ -15,7 +15,43 @@ Required properties:
>>     2) pin number
>>     3) optional parameters:
>>        - bit 0 specifies polarity (0 for normal, 1 for inverted)
>> -- reg: Index of the GPIO group
>> +- #address-cells: should be 2, which stands for GPIO bank id and
>> +  physical base address of this GPIO bank.
> 
> Now you need special code to do address translation. I'd really think 
> twice about doing this.

Correct, address translation code is needed here...

> Why do you need the bank number?

Only one reason -- backward compatibility in sense of referencing a GPIO
line on client's side. This API design is broken, I agree.

Honestly I would prefer to get rid of this "feature", new code allows to
reference on client's side either a parent GPIO controller device node,
or bank nodes, probably the improvement can be done in a few steps?

  - this change,
  - convert clients to reference a GPIO bank directly,
  - remove root GPIO controller (e.g. make it "simple-bus") and convert
GPIO banks to "gpio-controller"s.

Can an evolution like this happen?

>> +- #size-cells: should be 1, total size of GPIO bank registers.
>> +
>> +The NXP LPC32xx SoC GPIO controller device node must contain a list
>> +of device nodes representing GPIO banks and their descriptions.
>> +
>> +The format of subnodes should follow the description below.
>> +
>> +Required properties:
>> +- reg: should contain 3 integer values:
>> +   1) GPIO bank id from 0 to 5,
>> +   2) physical base address of this GPIO bank,
>> +   3) total size of the GPIO bank registers.
>> +
>> +Optional properties:
>> +- gpio-bank-name: human readable name of a GPIO bank,
>> +- gpio-no-output-state: property of P2 bank, which has special,
>> +  mapping of its control registers,
>> +- gpio-offset: property of P3/GPIO bank, offset of bits representing
>> +  GPIO lines in output and direction registers,
> 
> Seems like nr-gpios should have been a mask instead...
> 
>> +- gpios: number of GPIO lines per GPIO bank, if this property is
>> +  omitted, then gpio-input-mask must be present,
> 
> "gpios" is already the property name for the client interface.
> 
>> +- gpio-input-mask: should contain two bitmasks, the first bitmask is
>> +  the mapping of GPIO lines to input status register, the second
>> +  bitmask should be a subset of the first bitmask and it represents
>> +  input GPIO lines, which may serve as an interrupt source,
>> +  if gpio-input-mask roperty is omitted, gpios property should be
>> +  present,
>> +- interrupts: list of parent interrupts mapped to input GPIO lines,
>> +- interrupts-extended: list of parent interrupts mapped to input GPIO
>> +  lines, used if parent interrupts are provided by more than one
>> +  interrupt controller, this option is used by GPI bank,
>> +- interrupt-controller: indicates that GPIO bank may serve as an
>> +  interrupt controller,
>> +- #interrupt-cells: if interrupt-controller property is present,
>> +  it should be 2, interrupt id and its flags.
>>  
>>  Example:
>>  
>> @@ -24,6 +60,89 @@ Example:
>>  		reg = <0x40028000 0x1000>;
>>  		gpio-controller;
>>  		#gpio-cells = <3>; /* bank, pin, flags */
> 
> Can't bank and pin be encoded into one cell as the gpio core binding 
> suggests.

Please see the comment above, the proposed change does not modify this
legacy part.

>> +
>> +		ranges = <0 0x0 0x40028000 0x00001000>,
>> +			 <1 0x0 0x40028000 0x00001000>,
>> +			 <2 0x0 0x40028000 0x00001000>,
>> +			 <3 0x0 0x40028000 0x00001000>,
>> +			 <4 0x0 0x40028000 0x00001000>,
>> +			 <5 0x0 0x40028000 0x00001000>;
>> +		#address-cells = <2>;
>> +		#size-cells = <1>;
>> +
>> +		gpio_p0: gpio-controller@0 {
>> +			reg = <0 0x40 0x1C>;
>> +			gpio-bank-name = "p0";
>> +			gpios = <8>;
>> +
>> +			interrupt-parent = <&sic2>;
>> +			interrupts = <8 IRQ_TYPE_LEVEL_HIGH>;
>> +		};
>> +
>> +		gpio_p1: gpio-controller@1 {
>> +			reg = <1 0x60 0x1C>;
>> +			gpio-bank-name = "p1";
>> +			gpios = <24>;
>> +
>> +			interrupt-parent = <&sic2>;
>> +			interrupts = <8 IRQ_TYPE_LEVEL_HIGH>;
>> +		};
>> +
>> +		gpio_p2: gpio-controller@2 {
>> +			reg = <2 0x10 0x18>;
>> +			gpio-bank-name = "p2";
>> +			gpios = <13>;
>> +			gpio-no-output-state;
>> +		};
>> +
>> +		gpio_gpio: gpio-controller@3 {
>> +			reg = <3 0x00 0x1C>;
> 
> This overlaps with bank 2.

Yes, it is. Thousand thanks to hardware designers.

--
With best wishes,
Vladimir

  reply	other threads:[~2015-11-20 18:27 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-20  1:29 [PATCH 0/4] gpio: lpc32xx: add new LPC32xx GPIO controller driver Vladimir Zapolskiy
     [not found] ` <1447982995-30231-1-git-send-email-vz-ChpfBGZJDbMAvxtiuMwx3w@public.gmane.org>
2015-11-20  1:29   ` [PATCH 1/4] dt-bindings: gpio: update desription of LPC32xx GPIO controller Vladimir Zapolskiy
2015-11-20 14:13     ` Rob Herring
2015-11-20 18:27       ` Vladimir Zapolskiy [this message]
2015-11-22 21:09         ` Rob Herring
2015-11-30 10:40     ` Linus Walleij
2015-11-30 12:13       ` Vladimir Zapolskiy
     [not found]         ` <565C3D80.1090204-nmGgyN9QBj3QT0dZR+AlfA@public.gmane.org>
2015-12-10 15:34           ` Linus Walleij
2015-11-20  1:29   ` [PATCH 3/4] gpio: lpc32xx: remove legacy LPC32xx GPIO driver Vladimir Zapolskiy
2015-11-20  1:29   ` [PATCH 4/4] gpio: lpc32xx: add new LPC32xx GPIO controller driver Vladimir Zapolskiy
2015-11-30 10:23     ` Linus Walleij
2015-11-20  1:29 ` [PATCH 2/4] arm: dts: lpc32xx: extend description of gpio controller node Vladimir Zapolskiy
2015-11-30  8:54 ` [PATCH 0/4] gpio: lpc32xx: add new LPC32xx GPIO controller driver Linus Walleij
2015-11-30  9:13   ` Vladimir Zapolskiy

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=564F6617.6090104@mleia.com \
    --to=vz@mleia.com \
    --cc=arnd@arndb.de \
    --cc=devicetree@vger.kernel.org \
    --cc=gnurou@gmail.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=robh@kernel.org \
    --cc=stigge@antcom.de \
    /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).