All of lore.kernel.org
 help / color / mirror / Atom feed
From: Linus Walleij <linus.walleij@linaro.org>
To: Stephen Warren <swarren@nvidia.com>
Cc: Barry Song <21cnbao@gmail.com>,
	Linus Walleij <linus.walleij@stericsson.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-arm-kernel@lists.infradead.org" 
	<linux-arm-kernel@lists.infradead.org>,
	Grant Likely <grant.likely@secretlab.ca>,
	Russell King <linux@arm.linux.org.uk>,
	Joe Perches <joe@perches.com>,
	Linaro Dev <linaro-dev@lists.linaro.org>,
	Lee Jones <lee.jones@linaro.org>
Subject: Re: [PATCH 0/4 v4] pin controller subsystem v4
Date: Mon, 29 Aug 2011 10:33:52 +0200	[thread overview]
Message-ID: <CACRpkdY93J-dSx+TM+RpQgSx09Mq-d3mwe-Scd_6GUhccMo-kg@mail.gmail.com> (raw)
In-Reply-To: <74CDBE0F657A3D45AFBB94109FB122FF04B24A4113@HQMAIL01.nvidia.com>

On Fri, Aug 26, 2011 at 7:12 PM, Stephen Warren <swarren@nvidia.com> wrote:
> [Barry]
>> static int xxx_gpio_request(struct gpio_chip *chip, unsigned offset)
>> {
>>         int ret = 0;
>>
>>         ret = pinmux_request_gpio(chip->base + offset);
>>         if (ret)
>>                 goto out;
>>         .....
>> out:
>>         return ret;
>> }
>
> I would have expected this to work the other way around; "gpio" is just
> another function that can be assigned to a pin.

That's basically how it work internally, what I noticed is that GPIO
requests seem to come in single pins (not groups) so there is
a special function to request a pin by passing in the number from
the GPIO pinspace and this optionally propagates all the way
to the driver if there is a quick way to request this pin to be
muxed in as GPIO.

> 1) Pin is SF or a particular GPIO.
>
> 2) Pin is SF or a particular GPIO from GPIO controller A, or a particular
>   GPIO from controller B
>
> 3) Pin is SF, or one of a number of user-selectable GPIOs.
>
> Case (1) is covered by the code quoted above from earlier in the thread.
> Cases (2) and (3) can't be covered by that code, and according to comments
> in earlier replies, both actually exist in real HW.

I think we can handle this quite well conceptually, but I don't
know if we have the proper interaction with the drivers yet,
so let's rinse and repeat a bit here.

I'll post v5 today with your proposed changes
(if you recognize them...)

> 1) Have a single function "gpio" that can be applied to any pin that
> supports it. The actual GPIO number that gets mux'd onto the pin differs
> per pin, and is determine by HW design. But logically, we're connecting
> that pin to function "gpio", so we only need one function name for that.

Actually I think the new code can do this, one function "gpio" with
multiple what I call "positions", so "gpio" can be on pin {1, 5, 95, ..}

> 2) Have a function for each GPIO controller that can be attached to a
> pin; "gpioa" or "gpiob". Based on the pin being configured, and which of
> those two GPIO functions is selected, the HW determines the specific GPIO
> number that's assigned to the pin.

Should also work now with functions and positions per function
I hope.

> 3) Where the GPIO ID assigned to pins is user-selectable, have a function
> per GPIO ID; "gpio1", "gpio2", "gpio3", ... "gpio31". This sounds like
> it'd cause a huge explosion in the number of functions; one to represent
> each GPIO ID. However, I suspect this won't be too bad in practice, since
> there's presumably some practical limit to the amount of muxing logic that
> can be applied to each pin in HW, so the set of options won't be too large.

What happens right now is that the pinmux core system names the
pin as taken by "gpioN" where N is the number from the GPIOlib number
space.

However that is just a name, not a function, and we have this special
callback to the driver to mux in a single pin for GPIO.

So what I need to do to support this is to support machine mappings for
the GPIOs as function with positions which currently not available.

Lemme see what I can do about that in v6.

> If the set of GPIO IDs that can be assigned to any particular pin is a subset
> of the whole GPIO number space, e.g.:
>
> pina: gpio1, gpio2, gpio3, gpio4
> pinb: gpio2, gpio3, gpio4, gpio5
> pinc: gpio3, gpio4, gpio5, gpio6
>
> ... then I imagine HW has already defined an enumerator gpioa, gpiob, gpioc,
> gpiod and a mapping from those to the specific GPIO ID that each means when
> assigned to a given pin, so those gpioa/b/c/d values could be used as the
> function exposed by the pinmux driver.

Yep should be possible to make it work that way. Just need a way
to map that for the machine.

Yours,
Linus Walleij

WARNING: multiple messages have this Message-ID (diff)
From: linus.walleij@linaro.org (Linus Walleij)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 0/4 v4] pin controller subsystem v4
Date: Mon, 29 Aug 2011 10:33:52 +0200	[thread overview]
Message-ID: <CACRpkdY93J-dSx+TM+RpQgSx09Mq-d3mwe-Scd_6GUhccMo-kg@mail.gmail.com> (raw)
In-Reply-To: <74CDBE0F657A3D45AFBB94109FB122FF04B24A4113@HQMAIL01.nvidia.com>

On Fri, Aug 26, 2011 at 7:12 PM, Stephen Warren <swarren@nvidia.com> wrote:
> [Barry]
>> static int xxx_gpio_request(struct gpio_chip *chip, unsigned offset)
>> {
>> ? ? ? ? int ret = 0;
>>
>> ? ? ? ? ret = pinmux_request_gpio(chip->base + offset);
>> ? ? ? ? if (ret)
>> ? ? ? ? ? ? ? ? goto out;
>> ? ? ? ? .....
>> out:
>> ? ? ? ? return ret;
>> }
>
> I would have expected this to work the other way around; "gpio" is just
> another function that can be assigned to a pin.

That's basically how it work internally, what I noticed is that GPIO
requests seem to come in single pins (not groups) so there is
a special function to request a pin by passing in the number from
the GPIO pinspace and this optionally propagates all the way
to the driver if there is a quick way to request this pin to be
muxed in as GPIO.

> 1) Pin is SF or a particular GPIO.
>
> 2) Pin is SF or a particular GPIO from GPIO controller A, or a particular
> ? GPIO from controller B
>
> 3) Pin is SF, or one of a number of user-selectable GPIOs.
>
> Case (1) is covered by the code quoted above from earlier in the thread.
> Cases (2) and (3) can't be covered by that code, and according to comments
> in earlier replies, both actually exist in real HW.

I think we can handle this quite well conceptually, but I don't
know if we have the proper interaction with the drivers yet,
so let's rinse and repeat a bit here.

I'll post v5 today with your proposed changes
(if you recognize them...)

> 1) Have a single function "gpio" that can be applied to any pin that
> supports it. The actual GPIO number that gets mux'd onto the pin differs
> per pin, and is determine by HW design. But logically, we're connecting
> that pin to function "gpio", so we only need one function name for that.

Actually I think the new code can do this, one function "gpio" with
multiple what I call "positions", so "gpio" can be on pin {1, 5, 95, ..}

> 2) Have a function for each GPIO controller that can be attached to a
> pin; "gpioa" or "gpiob". Based on the pin being configured, and which of
> those two GPIO functions is selected, the HW determines the specific GPIO
> number that's assigned to the pin.

Should also work now with functions and positions per function
I hope.

> 3) Where the GPIO ID assigned to pins is user-selectable, have a function
> per GPIO ID; "gpio1", "gpio2", "gpio3", ... "gpio31". This sounds like
> it'd cause a huge explosion in the number of functions; one to represent
> each GPIO ID. However, I suspect this won't be too bad in practice, since
> there's presumably some practical limit to the amount of muxing logic that
> can be applied to each pin in HW, so the set of options won't be too large.

What happens right now is that the pinmux core system names the
pin as taken by "gpioN" where N is the number from the GPIOlib number
space.

However that is just a name, not a function, and we have this special
callback to the driver to mux in a single pin for GPIO.

So what I need to do to support this is to support machine mappings for
the GPIOs as function with positions which currently not available.

Lemme see what I can do about that in v6.

> If the set of GPIO IDs that can be assigned to any particular pin is a subset
> of the whole GPIO number space, e.g.:
>
> pina: gpio1, gpio2, gpio3, gpio4
> pinb: gpio2, gpio3, gpio4, gpio5
> pinc: gpio3, gpio4, gpio5, gpio6
>
> ... then I imagine HW has already defined an enumerator gpioa, gpiob, gpioc,
> gpiod and a mapping from those to the specific GPIO ID that each means when
> assigned to a given pin, so those gpioa/b/c/d values could be used as the
> function exposed by the pinmux driver.

Yep should be possible to make it work that way. Just need a way
to map that for the machine.

Yours,
Linus Walleij

  reply	other threads:[~2011-08-29  8:33 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-19  9:53 [PATCH 0/4 v4] pin controller subsystem v4 Linus Walleij
2011-08-19  9:53 ` Linus Walleij
2011-08-21 14:42 ` Barry Song
2011-08-21 14:42   ` Barry Song
2011-08-22 12:28   ` Linus Walleij
2011-08-22 12:28     ` Linus Walleij
2011-08-26  1:58     ` Barry Song
2011-08-26  1:58       ` Barry Song
2011-08-26  7:57       ` Linus Walleij
2011-08-26  7:57         ` Linus Walleij
2011-08-26 17:12       ` Stephen Warren
2011-08-26 17:12         ` Stephen Warren
2011-08-29  8:33         ` Linus Walleij [this message]
2011-08-29  8:33           ` 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=CACRpkdY93J-dSx+TM+RpQgSx09Mq-d3mwe-Scd_6GUhccMo-kg@mail.gmail.com \
    --to=linus.walleij@linaro.org \
    --cc=21cnbao@gmail.com \
    --cc=grant.likely@secretlab.ca \
    --cc=joe@perches.com \
    --cc=lee.jones@linaro.org \
    --cc=linaro-dev@lists.linaro.org \
    --cc=linus.walleij@stericsson.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=swarren@nvidia.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.