All of lore.kernel.org
 help / color / mirror / Atom feed
From: Boris BREZILLON <boris.brezillon@free-electrons.com>
To: Chen-Yu Tsai <wens@csie.org>
Cc: "Randy Dunlap" <rdunlap@infradead.org>,
	"Maxime Ripard" <maxime.ripard@free-electrons.com>,
	"Emilio López" <emilio@elopez.com.ar>,
	"Mike Turquette" <mturquette@linaro.org>,
	"Linus Walleij" <linus.walleij@linaro.org>,
	devicetree <devicetree@vger.kernel.org>,
	linux-kernel <linux-kernel@vger.kernel.org>,
	linux-arm-kernel <linux-arm-kernel@lists.infradead.org>,
	linux-doc@vger.kernel.org
Subject: Re: [PATCH 00/15] ARM: sunxi: add A31 PL pins support
Date: Wed, 09 Apr 2014 20:04:52 +0200	[thread overview]
Message-ID: <53458BC4.1040100@free-electrons.com> (raw)
In-Reply-To: <CAGb2v651R-sG3OB4aD4UXWiyQVcHz7zXub1wO6B4xp-toUcC7Q@mail.gmail.com>


On 09/04/2014 19:14, Chen-Yu Tsai wrote:
> On Thu, Apr 10, 2014 at 12:14 AM, Boris BREZILLON
> <boris.brezillon@free-electrons.com> wrote:
>> On 09/04/2014 16:53, Chen-Yu Tsai wrote:
>>> Hi Boris,
>>>
>>> On Wed, Apr 9, 2014 at 9:51 PM, Boris BREZILLON
>>> <boris.brezillon@free-electrons.com> wrote:
>>>> Hello,
>>>>
>>>> This series rework the sunxi pinctrl driver to support the PLx pins
>>>> available on the A31 SoC.
>>> Thanks for working on this. I mentioned to Maxime on IRC yesterday that
>>> we have complete pinctrl drivers for both A31 and A23, based on our current
>>> pinctrl-sunxi driver, in the A23 SDK. These have the complete pin mapping.
>> Thanks for pointing this out, I'll take a look.
>>
>>>> It also add missing A31 reset controller DT bindings documentation.
>>>>
>>>> I need those PL pins (actually I only need PL0 and PL1) to support
>>>> the P2WI bus, which in turn is used to communicate with the AXP221
>>>> PMIC.
>>> If you could, please add all the PL and PM pins.
>> Sure, I'll add pin macros for L and M ports.
>>
>>> As I said, you can find complete definitions in the A23 SDK.
>>>
>>>> Let me know if these changes are too intrusive.
>>> I wonder if we should do a separate driver for the new PIO controller.
>>> Clearly it's a separate IP block, with it's own clock and reset controls.
>> This is what I had in mind in the first place, but then I encountered
>> several issues when doing so:
>>
>>  1) the gpio chip is not dynamically allocated but is declared as a
>> static variable instead
> Hmm. Not sure if this is worth the change.

We have to dynamically allocate the gpio chip struct, otherwise you
would add several times the same struct in the gpio_chips list (when you
call gpiochip_add), which will mess up the list.

Actually, I just realized a gpio chip struct was allocated (line 854)
but then the pointer to this chip was overridden with the address to the
static definitions (line 861):

http://lxr.free-electrons.com/source/drivers/pinctrl/pinctrl-sunxi.c#L854


>
>>  2) we have to tweak the pinctrl base field, otherwise the pin numbers
>> overlap
> Documentation says pin numbers are global, however the pinctrl core code
> only looks up a pin by number in a pinctrl device only.
>
> Also I see mfd pinctrl drivers (ab8500, as3722) have pin numbers starting
> from 0. So definitely some confusion there.

I was talking about the base field of the gpio_chip struct.
This field is used to give a unique gpio id from the GPIO point of view:
unique_gpio_id = gpio_id_within_the_gpio_chip + chip->base.

You can get an automatically assigned gpio base if you set it to -1
before calling gpiochip_add, but AFAIK (correct me if I'm wrong) this is
used for hotplugable GPIO chips.

For ARCH gpios you


>
>>  3) other things I haven't noticed yet :-)
> Reworking EINT to use one interrupt per bank will yield some more surprises.
>
> There's also new gpiolib irqchip helpers, but that will require reworking
> each pin bank into separate gpio chips. May be more work than just adding
> different irq domains for different banks.
>
> See: https://lkml.org/lkml/2014/3/25/175

Okay, I'll take a look.

>
>> I'll try to rework the driver to be able to declare 2 separated pin
>> controllers.
> Thanks again.
>
> ChenYu
>
>>> Allwinner sources list this block as "R_PIO". I suggest using this name.
>>> Clearly "pioL" does not cover all the functionality.
>> Fair enough. I'll modify it.
>>
>>> I have started to document the PRCM block: http://linux-sunxi.org/PRCM
>>>
>>> Last, please send the patches to the linux-sunxi mailing list as well.
>>> At the very least, Hans will see them and add them to sunxi-devel branch.
>> Sure, this is an oversight, I'm using get_maintainer and just forgot to
>> add Hans and the linux-sunxi ML. But I'll take care to add you, hans and
>> the sunxi ML in Cc next time.
>>
>> Thanks for your review.
>>
>> Best Regards,
>>
>> Boris
>>
>>>
>>> Cheers,
>>> ChenYu
>>>
>>>> Best Regards,
>>>>
>>>> Boris
>>>>
>>>> Boris BREZILLON (15):
>>>>   ARM: sunxi: dt: list all pinctrl compatible strings
>>>>   ARM: sunxi: dt: document pinctrl clock related properties
>>>>   ARM: sunxi: dt: add pinctrl clock-names properties
>>>>   pinctrl: sunxi: specify clk name when retrieving pinctrl pio clk
>>>>   clk: sunxi: add A31 APB0 clk gate defintions
>>>>   clk: sunxi: add A31 APB0 gates compatible string to the documentation
>>>>   ARM: sunxi: dt: define A31's APB0 clk gates node
>>>>   reset: sunxi: document sunxi's reset controllers bindings
>>>>   clk: sunxi: add A31 APB0 reset line defintions
>>>>   pinctrl: sunxi: add PL pin definitions
>>>>   pinctrl: sunxi: add support for A31 PL pins
>>>>   pinctrl: sunxi: retrieve and enable PL clk gate for A31 SoC
>>>>   pinctrl: sunxi: retrieve and enable PL reset line for A31 SoC
>>>>   pinctrl: sunxi: define A31 PL0/PL1 pins
>>>>   ARM: sunxi: dt: add support for A31's PL pins
>>>>
>>>>  Documentation/devicetree/bindings/clock/sunxi.txt  |   1 +
>>>>  .../bindings/pinctrl/allwinner,sunxi-pinctrl.txt   |  13 +-
>>>>  .../bindings/reset/allwinner,sunxi-clock-reset.txt |  21 +++
>>>>  arch/arm/boot/dts/sun4i-a10.dtsi                   |   1 +
>>>>  arch/arm/boot/dts/sun5i-a10s.dtsi                  |   1 +
>>>>  arch/arm/boot/dts/sun5i-a13.dtsi                   |   1 +
>>>>  arch/arm/boot/dts/sun6i-a31.dtsi                   |  25 ++-
>>>>  arch/arm/boot/dts/sun7i-a20.dtsi                   |   1 +
>>>>  drivers/clk/sunxi/clk-sunxi.c                      |   5 +
>>>>  drivers/pinctrl/pinctrl-sunxi-pins.h               |   8 +
>>>>  drivers/pinctrl/pinctrl-sunxi.c                    | 205 +++++++++++++++------
>>>>  drivers/pinctrl/pinctrl-sunxi.h                    |  39 +++-
>>>>  12 files changed, 264 insertions(+), 57 deletions(-)
>>>>  create mode 100644 Documentation/devicetree/bindings/reset/allwinner,sunxi-clock-reset.txt
>>>>
>>>> --
>>>> 1.8.3.2
>>>>
>>>>
>>>> _______________________________________________
>>>> linux-arm-kernel mailing list
>>>> linux-arm-kernel@lists.infradead.org
>>>> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
>> --
>> Boris Brezillon, Free Electrons
>> Embedded Linux and Kernel engineering
>> http://free-electrons.com
>>

-- 
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com


WARNING: multiple messages have this Message-ID (diff)
From: boris.brezillon@free-electrons.com (Boris BREZILLON)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 00/15] ARM: sunxi: add A31 PL pins support
Date: Wed, 09 Apr 2014 20:04:52 +0200	[thread overview]
Message-ID: <53458BC4.1040100@free-electrons.com> (raw)
In-Reply-To: <CAGb2v651R-sG3OB4aD4UXWiyQVcHz7zXub1wO6B4xp-toUcC7Q@mail.gmail.com>


On 09/04/2014 19:14, Chen-Yu Tsai wrote:
> On Thu, Apr 10, 2014 at 12:14 AM, Boris BREZILLON
> <boris.brezillon@free-electrons.com> wrote:
>> On 09/04/2014 16:53, Chen-Yu Tsai wrote:
>>> Hi Boris,
>>>
>>> On Wed, Apr 9, 2014 at 9:51 PM, Boris BREZILLON
>>> <boris.brezillon@free-electrons.com> wrote:
>>>> Hello,
>>>>
>>>> This series rework the sunxi pinctrl driver to support the PLx pins
>>>> available on the A31 SoC.
>>> Thanks for working on this. I mentioned to Maxime on IRC yesterday that
>>> we have complete pinctrl drivers for both A31 and A23, based on our current
>>> pinctrl-sunxi driver, in the A23 SDK. These have the complete pin mapping.
>> Thanks for pointing this out, I'll take a look.
>>
>>>> It also add missing A31 reset controller DT bindings documentation.
>>>>
>>>> I need those PL pins (actually I only need PL0 and PL1) to support
>>>> the P2WI bus, which in turn is used to communicate with the AXP221
>>>> PMIC.
>>> If you could, please add all the PL and PM pins.
>> Sure, I'll add pin macros for L and M ports.
>>
>>> As I said, you can find complete definitions in the A23 SDK.
>>>
>>>> Let me know if these changes are too intrusive.
>>> I wonder if we should do a separate driver for the new PIO controller.
>>> Clearly it's a separate IP block, with it's own clock and reset controls.
>> This is what I had in mind in the first place, but then I encountered
>> several issues when doing so:
>>
>>  1) the gpio chip is not dynamically allocated but is declared as a
>> static variable instead
> Hmm. Not sure if this is worth the change.

We have to dynamically allocate the gpio chip struct, otherwise you
would add several times the same struct in the gpio_chips list (when you
call gpiochip_add), which will mess up the list.

Actually, I just realized a gpio chip struct was allocated (line 854)
but then the pointer to this chip was overridden with the address to the
static definitions (line 861):

http://lxr.free-electrons.com/source/drivers/pinctrl/pinctrl-sunxi.c#L854


>
>>  2) we have to tweak the pinctrl base field, otherwise the pin numbers
>> overlap
> Documentation says pin numbers are global, however the pinctrl core code
> only looks up a pin by number in a pinctrl device only.
>
> Also I see mfd pinctrl drivers (ab8500, as3722) have pin numbers starting
> from 0. So definitely some confusion there.

I was talking about the base field of the gpio_chip struct.
This field is used to give a unique gpio id from the GPIO point of view:
unique_gpio_id = gpio_id_within_the_gpio_chip + chip->base.

You can get an automatically assigned gpio base if you set it to -1
before calling gpiochip_add, but AFAIK (correct me if I'm wrong) this is
used for hotplugable GPIO chips.

For ARCH gpios you


>
>>  3) other things I haven't noticed yet :-)
> Reworking EINT to use one interrupt per bank will yield some more surprises.
>
> There's also new gpiolib irqchip helpers, but that will require reworking
> each pin bank into separate gpio chips. May be more work than just adding
> different irq domains for different banks.
>
> See: https://lkml.org/lkml/2014/3/25/175

Okay, I'll take a look.

>
>> I'll try to rework the driver to be able to declare 2 separated pin
>> controllers.
> Thanks again.
>
> ChenYu
>
>>> Allwinner sources list this block as "R_PIO". I suggest using this name.
>>> Clearly "pioL" does not cover all the functionality.
>> Fair enough. I'll modify it.
>>
>>> I have started to document the PRCM block: http://linux-sunxi.org/PRCM
>>>
>>> Last, please send the patches to the linux-sunxi mailing list as well.
>>> At the very least, Hans will see them and add them to sunxi-devel branch.
>> Sure, this is an oversight, I'm using get_maintainer and just forgot to
>> add Hans and the linux-sunxi ML. But I'll take care to add you, hans and
>> the sunxi ML in Cc next time.
>>
>> Thanks for your review.
>>
>> Best Regards,
>>
>> Boris
>>
>>>
>>> Cheers,
>>> ChenYu
>>>
>>>> Best Regards,
>>>>
>>>> Boris
>>>>
>>>> Boris BREZILLON (15):
>>>>   ARM: sunxi: dt: list all pinctrl compatible strings
>>>>   ARM: sunxi: dt: document pinctrl clock related properties
>>>>   ARM: sunxi: dt: add pinctrl clock-names properties
>>>>   pinctrl: sunxi: specify clk name when retrieving pinctrl pio clk
>>>>   clk: sunxi: add A31 APB0 clk gate defintions
>>>>   clk: sunxi: add A31 APB0 gates compatible string to the documentation
>>>>   ARM: sunxi: dt: define A31's APB0 clk gates node
>>>>   reset: sunxi: document sunxi's reset controllers bindings
>>>>   clk: sunxi: add A31 APB0 reset line defintions
>>>>   pinctrl: sunxi: add PL pin definitions
>>>>   pinctrl: sunxi: add support for A31 PL pins
>>>>   pinctrl: sunxi: retrieve and enable PL clk gate for A31 SoC
>>>>   pinctrl: sunxi: retrieve and enable PL reset line for A31 SoC
>>>>   pinctrl: sunxi: define A31 PL0/PL1 pins
>>>>   ARM: sunxi: dt: add support for A31's PL pins
>>>>
>>>>  Documentation/devicetree/bindings/clock/sunxi.txt  |   1 +
>>>>  .../bindings/pinctrl/allwinner,sunxi-pinctrl.txt   |  13 +-
>>>>  .../bindings/reset/allwinner,sunxi-clock-reset.txt |  21 +++
>>>>  arch/arm/boot/dts/sun4i-a10.dtsi                   |   1 +
>>>>  arch/arm/boot/dts/sun5i-a10s.dtsi                  |   1 +
>>>>  arch/arm/boot/dts/sun5i-a13.dtsi                   |   1 +
>>>>  arch/arm/boot/dts/sun6i-a31.dtsi                   |  25 ++-
>>>>  arch/arm/boot/dts/sun7i-a20.dtsi                   |   1 +
>>>>  drivers/clk/sunxi/clk-sunxi.c                      |   5 +
>>>>  drivers/pinctrl/pinctrl-sunxi-pins.h               |   8 +
>>>>  drivers/pinctrl/pinctrl-sunxi.c                    | 205 +++++++++++++++------
>>>>  drivers/pinctrl/pinctrl-sunxi.h                    |  39 +++-
>>>>  12 files changed, 264 insertions(+), 57 deletions(-)
>>>>  create mode 100644 Documentation/devicetree/bindings/reset/allwinner,sunxi-clock-reset.txt
>>>>
>>>> --
>>>> 1.8.3.2
>>>>
>>>>
>>>> _______________________________________________
>>>> linux-arm-kernel mailing list
>>>> linux-arm-kernel at lists.infradead.org
>>>> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
>> --
>> Boris Brezillon, Free Electrons
>> Embedded Linux and Kernel engineering
>> http://free-electrons.com
>>

-- 
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

  reply	other threads:[~2014-04-09 18:05 UTC|newest]

Thread overview: 91+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-09 13:51 [PATCH 00/15] ARM: sunxi: add A31 PL pins support Boris BREZILLON
2014-04-09 13:51 ` Boris BREZILLON
2014-04-09 13:51 ` [PATCH 01/15] ARM: sunxi: dt: list all pinctrl compatible strings Boris BREZILLON
2014-04-09 13:51   ` Boris BREZILLON
2014-04-09 14:43   ` Maxime Ripard
2014-04-09 14:43     ` Maxime Ripard
2014-04-09 14:43     ` Maxime Ripard
2014-04-09 13:51 ` [PATCH 02/15] ARM: sunxi: dt: document pinctrl clock related properties Boris BREZILLON
2014-04-09 13:51   ` Boris BREZILLON
2014-04-09 14:45   ` Maxime Ripard
2014-04-09 14:45     ` Maxime Ripard
2014-04-09 13:51 ` [PATCH 03/15] ARM: sunxi: dt: add pinctrl clock-names properties Boris BREZILLON
2014-04-09 13:51   ` Boris BREZILLON
2014-04-09 13:51 ` [PATCH 04/15] pinctrl: sunxi: specify clk name when retrieving pinctrl pio clk Boris BREZILLON
2014-04-09 13:51   ` Boris BREZILLON
2014-04-10 18:14   ` Linus Walleij
2014-04-10 18:14     ` Linus Walleij
2014-04-10 18:14     ` Linus Walleij
2014-04-10 18:16     ` Linus Walleij
2014-04-10 18:16       ` Linus Walleij
2014-04-10 21:17       ` Boris BREZILLON
2014-04-10 21:17         ` Boris BREZILLON
2014-04-09 13:51 ` [PATCH 05/15] clk: sunxi: add A31 APB0 clk gate defintions Boris BREZILLON
2014-04-09 13:51   ` Boris BREZILLON
2014-04-09 13:51   ` Boris BREZILLON
2014-04-09 14:49   ` Maxime Ripard
2014-04-09 14:49     ` Maxime Ripard
2014-04-09 13:51 ` [PATCH 06/15] clk: sunxi: add A31 APB0 gates compatible string to the documentation Boris BREZILLON
2014-04-09 13:51   ` Boris BREZILLON
2014-04-09 13:51   ` Boris BREZILLON
2014-04-09 13:59   ` Chen-Yu Tsai
2014-04-09 13:59     ` Chen-Yu Tsai
2014-04-09 14:45     ` Boris BREZILLON
2014-04-09 14:45       ` Boris BREZILLON
2014-04-09 14:51   ` Maxime Ripard
2014-04-09 14:51     ` Maxime Ripard
2014-04-09 13:51 ` [PATCH 07/15] ARM: sunxi: dt: define A31's APB0 clk gates node Boris BREZILLON
2014-04-09 13:51   ` Boris BREZILLON
2014-04-09 13:51   ` Boris BREZILLON
2014-04-09 14:06   ` Emilio López
2014-04-09 14:06     ` Emilio López
2014-04-09 14:43     ` Boris BREZILLON
2014-04-09 14:43       ` Boris BREZILLON
2014-04-09 15:08   ` Maxime Ripard
2014-04-09 15:08     ` Maxime Ripard
2014-04-09 13:51 ` [PATCH 08/15] reset: sunxi: document sunxi's reset controllers bindings Boris BREZILLON
2014-04-09 13:51   ` Boris BREZILLON
2014-04-09 13:51 ` [PATCH 09/15] clk: sunxi: add A31 APB0 reset line defintions Boris BREZILLON
2014-04-09 13:51   ` Boris BREZILLON
2014-04-09 13:51   ` Boris BREZILLON
2014-04-09 13:51 ` [PATCH 10/15] pinctrl: sunxi: add PL pin definitions Boris BREZILLON
2014-04-09 13:51   ` Boris BREZILLON
2014-04-09 13:51 ` [PATCH 11/15] pinctrl: sunxi: add support for A31 PL pins Boris BREZILLON
2014-04-09 13:51   ` Boris BREZILLON
2014-04-09 13:51 ` [PATCH 12/15] pinctrl: sunxi: retrieve and enable PL clk gate for A31 SoC Boris BREZILLON
2014-04-09 13:51   ` Boris BREZILLON
2014-04-09 15:33   ` Maxime Ripard
2014-04-09 15:33     ` Maxime Ripard
2014-04-09 13:51 ` [PATCH 13/15] pinctrl: sunxi: retrieve and enable PL reset line " Boris BREZILLON
2014-04-09 13:51   ` Boris BREZILLON
2014-04-09 13:51   ` Boris BREZILLON
2014-04-09 15:34   ` Maxime Ripard
2014-04-09 15:34     ` Maxime Ripard
2014-04-09 15:34     ` Maxime Ripard
2014-04-09 13:51 ` [PATCH 14/15] pinctrl: sunxi: define A31 PL0/PL1 pins Boris BREZILLON
2014-04-09 13:51   ` Boris BREZILLON
2014-04-09 13:51   ` Boris BREZILLON
2014-04-09 15:38   ` Maxime Ripard
2014-04-09 15:38     ` Maxime Ripard
2014-04-09 13:51 ` [PATCH 15/15] ARM: sunxi: dt: add support for A31's PL pins Boris BREZILLON
2014-04-09 13:51   ` Boris BREZILLON
2014-04-09 14:53 ` [PATCH 00/15] ARM: sunxi: add A31 PL pins support Chen-Yu Tsai
2014-04-09 14:53   ` Chen-Yu Tsai
2014-04-09 15:17   ` Maxime Ripard
2014-04-09 15:17     ` Maxime Ripard
2014-04-09 15:45     ` Maxime Ripard
2014-04-09 15:45       ` Maxime Ripard
2014-04-09 16:27     ` Chen-Yu Tsai
2014-04-09 16:27       ` Chen-Yu Tsai
2014-04-10  8:10       ` Maxime Ripard
2014-04-10  8:10         ` Maxime Ripard
2014-04-10  9:56         ` Chen-Yu Tsai
2014-04-10  9:56           ` Chen-Yu Tsai
2014-04-09 16:14   ` Boris BREZILLON
2014-04-09 16:14     ` Boris BREZILLON
2014-04-09 17:14     ` Chen-Yu Tsai
2014-04-09 17:14       ` Chen-Yu Tsai
2014-04-09 18:04       ` Boris BREZILLON [this message]
2014-04-09 18:04         ` Boris BREZILLON
2014-04-10  8:16       ` Maxime Ripard
2014-04-10  8:16         ` Maxime Ripard

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=53458BC4.1040100@free-electrons.com \
    --to=boris.brezillon@free-electrons.com \
    --cc=devicetree@vger.kernel.org \
    --cc=emilio@elopez.com.ar \
    --cc=linus.walleij@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maxime.ripard@free-electrons.com \
    --cc=mturquette@linaro.org \
    --cc=rdunlap@infradead.org \
    --cc=wens@csie.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.