All of lore.kernel.org
 help / color / mirror / Atom feed
From: Zhou Wang <wangzhou.bry@gmail.com>
To: Alexandre Courbot <gnurou@gmail.com>
Cc: Russell King <linux@arm.linux.org.uk>,
	Haojian Zhuang <haojian.zhuang@linaro.org>,
	Wei Xu <xuwei5@hisilicon.com>, Olof Johansson <olof@lixom.net>,
	Kevin Hilman <khilman@linaro.org>, Arnd Bergmann <arnd@arndb.de>,
	Linus Walleij <linus.walleij@linaro.org>,
	liguozhu@hisilicon.com, Rob Herring <robh+dt@kernel.org>,
	Pawel Moll <pawel.moll@arm.com>,
	Mark Rutland <mark.rutland@arm.com>,
	Ian Campbell <ijc+devicetree@hellion.org.uk>,
	Kumar Gala <galak@codeaurora.org>,
	atull@altera.com,
	Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>,
	Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
	jamie@jamieiles.com,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	"linux-gpio@vger.kernel.org" <linux-gpio@vger.kernel.org>,
	wangzhou1@hisilicon.com
Subject: Re: [PATCH v4 3/4] gpio: Add find GPIO base in increasing order
Date: Wed, 17 Dec 2014 19:13:00 +0800	[thread overview]
Message-ID: <5491653C.4040709@gmail.com> (raw)
In-Reply-To: <CAAVeFuKzY8C+dARt4U8nEFBzEmRt=j34uEnK0vsS91H6jvkkBQ@mail.gmail.com>

On 2014年12月17日 11:09, Alexandre Courbot wrote:
> On Mon, Dec 15, 2014 at 1:01 PM, Zhou Wang <wangzhou.bry@gmail.com> wrote:
>> On 2014年12月10日 16:51, Alexandre Courbot wrote:
>>>
>>> On Fri, Dec 5, 2014 at 12:38 PM, Zhou Wang <wangzhou.bry@gmail.com> wrote:
>>>>
>>>> In function gpiochip_find_base, base number of a GPIO controller
>>>> is found in decreasing order. ARCH_NR_GPIOS is used to define from
>>>> which number we begin to search for base number of a GPIO controller.
>>>>
>>>> In fact, ARCH_NR_GPIOS brings us some multiplatform problems, like:
>>>> http://www.spinics.net/lists/devicetree/msg60433.html
>>>>
>>>> This patch adds the support to find base number of a GPIO controller
>>>> in increasing order. It will assign base number from 0.
>>>> A new dts property called gpio-number-forward must be add to the related
>>>> GPIO dts nodes if you want it works well.
>>>
>>>
>>> Global GPIO numbers are a Linux-only concept, so your property should
>>> be named linux,gpio-number-forward.
>>>
>>> But even that way I don't think I like this idea. This just adds some
>>> more mess to how the GPIO number space is constructed, and it is
>>> already quite messy as it is. You have no guarantee over the probe
>>> order of your GPIO controllers, so they may very well be probed in a
>>> different order and end up with different base numbers anytime.
>>>
>>> Not that this is your fault - the number namespace is broken by design
>>> and I don't think there is a way to fix it. The long-term solution is
>>> to stop using it by switching to the gpiod interface.
>>>
>>> First a few questions to understand why you need your GPIOs numbered
>>> this way, and if you need it at all:
>>> - Can't you use the gpiod interface instead so you don't need to rely
>>> on GPIO numbers?
>>
>>
>> Hi Alexandre,
>>
>> Sorry for late. Could you give me more clue about the gpiod interface? Don't
>> we also call gpio_request() which uses GPIO number to request a
>> GPIO?
>
> See Documentation/gpio/consumer.txt and Documentation/gpio/board.txt.
> You can obtain a GPIO descriptor without using a number by calling
> gpiod_get(). Prior to that, individual GPIOs need to be bound to
> devices and functions using either DT (preferred) or the platform
> interface. The old integer-based GPIO interface is considered
> deprecated, although still widely used. But new code should rely
> exclusively on gpiod, and we encourage people to convert existing code
> to it too.
>

Hi Alexandre,

Thanks a lot for your explanation!!

>>
>>> - Do you plan to use the sysfs interface? If so then we are screwed,
>>> because there is no way to use it without using global GPIO numbers.
>>
>>
>> I am now enabling GPIO in Hip04-d01. Maybe, I can just use
>> the default ARCH_NR_GPIOS, then users can manage GPIO through sysfs.
>> However if so, GPIO 0~127 will be mapped to GPIO 384~511.
>
> Yeah, I know that's not ideal. As a workaround, users can maybe
> identify the right gpiochip by parsing /sys/class/gpio/gpiochip* and
> comparing the "label" node. Once the right chip is found, its "base"
> entry gives the base GPIO number which can be used to export the
> desired GPIO.
>
> We are also taking steps to come with a better sysfs interface. I will
> keep you in the loop.
>

Thanks. I'd like to keep an eye on this.

Regard,
Zhou

>>
>>> This is something we should/will fix with named exported GPIOs, but we
>>> are not here yet.
>>>
>>> As to how we can solve your problem: if you must use GPIO integers
>>> (because you need to use the sysfs interface for instance), and need
>>> them affected consistently, the only way I can think of is to
>>> introduce a "linux,gpio-base" property that will set gpiochip->base to
>>> a fixed number. It still kind of sucks, but at least it will enforce
>>
>>
>> Thanks for your suggestion. But setting "linux,gpio-base" will bring
>> gpio base implementation specific, and in face there is no place to gain
>> this gpio base info, not appropriate both in gpio arch code and dwapb
>> code.
>
> Yeah, besides this property did not receive a warm reception. So my
> suggestion for now is to workaround the issue using the technique
> described above, until we come with a better sysfs interface that does
> not rely on GPIO numbers. Sorry for that inconvenience.
>

--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

WARNING: multiple messages have this Message-ID (diff)
From: wangzhou.bry@gmail.com (Zhou Wang)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v4 3/4] gpio: Add find GPIO base in increasing order
Date: Wed, 17 Dec 2014 19:13:00 +0800	[thread overview]
Message-ID: <5491653C.4040709@gmail.com> (raw)
In-Reply-To: <CAAVeFuKzY8C+dARt4U8nEFBzEmRt=j34uEnK0vsS91H6jvkkBQ@mail.gmail.com>

On 2014?12?17? 11:09, Alexandre Courbot wrote:
> On Mon, Dec 15, 2014 at 1:01 PM, Zhou Wang <wangzhou.bry@gmail.com> wrote:
>> On 2014?12?10? 16:51, Alexandre Courbot wrote:
>>>
>>> On Fri, Dec 5, 2014 at 12:38 PM, Zhou Wang <wangzhou.bry@gmail.com> wrote:
>>>>
>>>> In function gpiochip_find_base, base number of a GPIO controller
>>>> is found in decreasing order. ARCH_NR_GPIOS is used to define from
>>>> which number we begin to search for base number of a GPIO controller.
>>>>
>>>> In fact, ARCH_NR_GPIOS brings us some multiplatform problems, like:
>>>> http://www.spinics.net/lists/devicetree/msg60433.html
>>>>
>>>> This patch adds the support to find base number of a GPIO controller
>>>> in increasing order. It will assign base number from 0.
>>>> A new dts property called gpio-number-forward must be add to the related
>>>> GPIO dts nodes if you want it works well.
>>>
>>>
>>> Global GPIO numbers are a Linux-only concept, so your property should
>>> be named linux,gpio-number-forward.
>>>
>>> But even that way I don't think I like this idea. This just adds some
>>> more mess to how the GPIO number space is constructed, and it is
>>> already quite messy as it is. You have no guarantee over the probe
>>> order of your GPIO controllers, so they may very well be probed in a
>>> different order and end up with different base numbers anytime.
>>>
>>> Not that this is your fault - the number namespace is broken by design
>>> and I don't think there is a way to fix it. The long-term solution is
>>> to stop using it by switching to the gpiod interface.
>>>
>>> First a few questions to understand why you need your GPIOs numbered
>>> this way, and if you need it at all:
>>> - Can't you use the gpiod interface instead so you don't need to rely
>>> on GPIO numbers?
>>
>>
>> Hi Alexandre,
>>
>> Sorry for late. Could you give me more clue about the gpiod interface? Don't
>> we also call gpio_request() which uses GPIO number to request a
>> GPIO?
>
> See Documentation/gpio/consumer.txt and Documentation/gpio/board.txt.
> You can obtain a GPIO descriptor without using a number by calling
> gpiod_get(). Prior to that, individual GPIOs need to be bound to
> devices and functions using either DT (preferred) or the platform
> interface. The old integer-based GPIO interface is considered
> deprecated, although still widely used. But new code should rely
> exclusively on gpiod, and we encourage people to convert existing code
> to it too.
>

Hi Alexandre,

Thanks a lot for your explanation!!

>>
>>> - Do you plan to use the sysfs interface? If so then we are screwed,
>>> because there is no way to use it without using global GPIO numbers.
>>
>>
>> I am now enabling GPIO in Hip04-d01. Maybe, I can just use
>> the default ARCH_NR_GPIOS, then users can manage GPIO through sysfs.
>> However if so, GPIO 0~127 will be mapped to GPIO 384~511.
>
> Yeah, I know that's not ideal. As a workaround, users can maybe
> identify the right gpiochip by parsing /sys/class/gpio/gpiochip* and
> comparing the "label" node. Once the right chip is found, its "base"
> entry gives the base GPIO number which can be used to export the
> desired GPIO.
>
> We are also taking steps to come with a better sysfs interface. I will
> keep you in the loop.
>

Thanks. I'd like to keep an eye on this.

Regard,
Zhou

>>
>>> This is something we should/will fix with named exported GPIOs, but we
>>> are not here yet.
>>>
>>> As to how we can solve your problem: if you must use GPIO integers
>>> (because you need to use the sysfs interface for instance), and need
>>> them affected consistently, the only way I can think of is to
>>> introduce a "linux,gpio-base" property that will set gpiochip->base to
>>> a fixed number. It still kind of sucks, but at least it will enforce
>>
>>
>> Thanks for your suggestion. But setting "linux,gpio-base" will bring
>> gpio base implementation specific, and in face there is no place to gain
>> this gpio base info, not appropriate both in gpio arch code and dwapb
>> code.
>
> Yeah, besides this property did not receive a warm reception. So my
> suggestion for now is to workaround the issue using the technique
> described above, until we come with a better sysfs interface that does
> not rely on GPIO numbers. Sorry for that inconvenience.
>

  reply	other threads:[~2014-12-17 11:13 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-05  3:38 [PATCH v4 0/4] ARM: hip04: add GPIO support Zhou Wang
2014-12-05  3:38 ` Zhou Wang
2014-12-05  3:38 ` [PATCH v4 1/4] ARM: hip04: add GPIO configure in hisi_defconfig Zhou Wang
2014-12-05  3:38   ` Zhou Wang
2014-12-05  3:38 ` [PATCH v4 2/4] ARM: dts: hip04: add GPIO pieces Zhou Wang
2014-12-05  3:38   ` Zhou Wang
2014-12-05  3:38 ` [PATCH v4 3/4] gpio: Add find GPIO base in increasing order Zhou Wang
2014-12-05  3:38   ` Zhou Wang
2014-12-10  8:51   ` Alexandre Courbot
2014-12-10  8:51     ` Alexandre Courbot
2014-12-15  4:01     ` Zhou Wang
2014-12-15  4:01       ` Zhou Wang
2014-12-17  3:09       ` Alexandre Courbot
2014-12-17  3:09         ` Alexandre Courbot
2014-12-17 11:13         ` Zhou Wang [this message]
2014-12-17 11:13           ` Zhou Wang
2015-01-14  8:13     ` Linus Walleij
2015-01-14  8:13       ` Linus Walleij
2015-01-14  8:17       ` Alexandre Courbot
2015-01-14  8:17         ` Alexandre Courbot
     [not found]         ` <CAAVeFuJkr9mFwJq0GdbLO7EgbffvD25bjBVdXAFZubq5Sz4MZQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-01-16 15:24           ` Linus Walleij
2015-01-16 15:24             ` Linus Walleij
     [not found]             ` <CACRpkdYeiaWxPeeoJjX6BKDmnk2swKCnGgJCW6p9AZ3fdFVSpQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-01-18  7:04               ` Alexandre Courbot
2015-01-18  7:04                 ` Alexandre Courbot
2014-12-05  3:38 ` [PATCH v4 4/4] Documentation: dt: gpio: Add gpio-number-forward property in snps gpio binding doc Zhou Wang
2014-12-05  3:38   ` Zhou Wang
2014-12-31  8:18   ` Linus Walleij
2014-12-31  8:18     ` Linus Walleij

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=5491653C.4040709@gmail.com \
    --to=wangzhou.bry@gmail.com \
    --cc=arnd@arndb.de \
    --cc=atull@altera.com \
    --cc=bigeasy@linutronix.de \
    --cc=devicetree@vger.kernel.org \
    --cc=galak@codeaurora.org \
    --cc=gnurou@gmail.com \
    --cc=haojian.zhuang@linaro.org \
    --cc=ijc+devicetree@hellion.org.uk \
    --cc=jamie@jamieiles.com \
    --cc=khilman@linaro.org \
    --cc=liguozhu@hisilicon.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=mark.rutland@arm.com \
    --cc=olof@lixom.net \
    --cc=pawel.moll@arm.com \
    --cc=robh+dt@kernel.org \
    --cc=sebastian.hesselbarth@gmail.com \
    --cc=wangzhou1@hisilicon.com \
    --cc=xuwei5@hisilicon.com \
    /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.