mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Alexandre Torgue <alexandre.torgue@st.com>
To: Linus Walleij <linus.walleij@linaro.org>
Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com>,
	Rob Herring <robh+dt@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Arnd Bergmann <arnd@arndb.de>,
	Russell King <linux@armlinux.org.uk>,
	Olof Johansson <olof@lixom.net>,
	Patrice Chotard <patrice.chotard@st.com>,
	Lee Jones <lee.jones@linaro.org>,
	"linux-arm-kernel@lists.infradead.org" 
	<linux-arm-kernel@lists.infradead.org>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	"linux-gpio@vger.kernel.org" <linux-gpio@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 2/8] pinctrl: stm32: use gpio-ranges to declare bank range
Date: Mon, 30 Jan 2017 17:29:55 +0100	[thread overview]
Message-ID: <2d0cd144-9a72-52d5-b2c9-c6c9e09ac494@st.com> (raw)
In-Reply-To: <CACRpkdYtZCJVrZhXOPXd-MNMX0Ry_H1dLQopKwsj9HnO03BtKg@mail.gmail.com>

Hi Linus,

On 01/30/2017 04:19 PM, Linus Walleij wrote:
> On Fri, Jan 27, 2017 at 5:15 PM, Alexandre TORGUE
> <alexandre.torgue@st.com> wrote:
>
>> Use device tree entries to declare gpio range. It will allow to use
>> no contiguous gpio bank and holes inside a bank.
>>
>> Signed-off-by: Alexandre TORGUE <alexandre.torgue@st.com>
>
> (...)
>> +       of_property_read_string(np, "st,bank-name", &bank->gpio_chip.label);
>> +
>> +       if (!of_parse_phandle_with_fixed_args(np, "gpio-ranges", 3, 0, &args))
>> +               bank_nr = args.args[1] / STM32_GPIO_PINS_PER_BANK;
>> +       else {
>> +               range->name = bank->gpio_chip.label;
>> +               range->id = bank_nr;
>> +               range->pin_base = range->id * STM32_GPIO_PINS_PER_BANK;
>> +               range->base = range->id * STM32_GPIO_PINS_PER_BANK;
>> +               range->npins = npins;
>> +               range->gc = &bank->gpio_chip;
>> +               pinctrl_add_gpio_range(pctl->pctl_dev,
>> +                                      &pctl->banks[bank_nr].range);
>> +       }

I Keep the old way to get range in order to keep compatibility with 
older device tree (if no gpio ranges are defined).

>
> Why are you doing this?
>
> There is already code in drivers/gpio/gpiolib-of.c to pick ranges
> from the device tree and add when you're adding the GPIO chips.

Yes, If I declare gpio-ranges inside DT node, the range is well handled 
by the gpiolib. But in this condition I use gpio-ranges entry to get the 
pin base offset for the bank we are registering. For example, if there 
an hole between 2 banks (GPIOA, GPIOD, ...) I need to know at which pin 
offset the bank D starts. It is the only way I found.

The "else" statement is here to get compatibility with older device tree 
(which don't use gpio-ranges entry).

Regards
Alex


>
> Please use that or figure out what is needed to make it work for
> you instead of reimplementing it.
>
> Yours,
> Linus Walleij
>

  reply	other threads:[~2017-01-30 16:30 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-27 16:15 [PATCH 0/8] Add STM32F469 pinctrl and fix issues in STM32 pinctrl Alexandre TORGUE
2017-01-27 16:15 ` [PATCH 1/8] pinctrl: stm32: fix bad location of gpiochip_lock_as_irq Alexandre TORGUE
2017-01-30 15:15   ` Linus Walleij
2017-01-27 16:15 ` [PATCH 2/8] pinctrl: stm32: use gpio-ranges to declare bank range Alexandre TORGUE
2017-01-30 15:19   ` Linus Walleij
2017-01-30 16:29     ` Alexandre Torgue [this message]
2017-02-01 15:01       ` Linus Walleij
2017-03-27 10:23         ` Alexandre Torgue
2017-01-27 16:15 ` [PATCH 3/8] Documentation: dt: Add bindings for STM32 pinctrl Alexandre TORGUE
2017-02-01 15:04   ` Rob Herring
2017-02-06  8:45   ` Linus Walleij
2017-01-27 16:15 ` [PATCH 4/8] includes: dt-bindings: Rename STM32F429 pinctrl DT bindings Alexandre TORGUE
2017-01-27 16:15 ` [PATCH 5/8] pinctrl: stm32: Add STM32F469 MCU support Alexandre TORGUE
2017-01-27 16:15 ` [PATCH 6/8] Documentation: dt: Add new compatible to STM32 pinctrl driver bindings Alexandre TORGUE
2017-02-01 15:06   ` Rob Herring
2017-02-01 15:58     ` Alexandre Torgue
2017-02-06  8:46       ` Linus Walleij
2017-02-06 11:21         ` Alexandre Torgue
2017-01-27 16:15 ` [PATCH 7/8] ARM: Kconfig: Introduce MACH_STM32F469 flag Alexandre TORGUE
2017-01-27 16:15 ` [PATCH 8/8] ARM: dts: stm32: create dedicated files for pinctrl definitions Alexandre TORGUE
2017-01-30 14:55 ` [PATCH 0/8] Add STM32F469 pinctrl and fix issues in STM32 pinctrl Alexandre Torgue

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=2d0cd144-9a72-52d5-b2c9-c6c9e09ac494@st.com \
    --to=alexandre.torgue@st.com \
    --cc=arnd@arndb.de \
    --cc=devicetree@vger.kernel.org \
    --cc=lee.jones@linaro.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=mark.rutland@arm.com \
    --cc=mcoquelin.stm32@gmail.com \
    --cc=olof@lixom.net \
    --cc=patrice.chotard@st.com \
    --cc=robh+dt@kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®