* [PATCH 0/2] RFC: gpio: driver-local pin configuration
@ 2011-06-10 8:48 ` Linus Walleij
0 siblings, 0 replies; 18+ messages in thread
From: Linus Walleij @ 2011-06-10 8:48 UTC (permalink / raw)
To: linux-arm-kernel
From: Linus Walleij <linus.walleij@linaro.org>
This is a modification of the previous generic GPIO configuration
patch series.
I'm Cc:ing everyone involved in earlier discussions so we can
move forward on this consolidation work, lest I cannot convert
my drivers to use struct gpio_chip / gpiolib.
Background: Grant didn't like the idea of an ioctl() like
configuration function in the struct gpio_chip vtable, so we
decided to see if it was wiser to go back to the initial suggestion
of making it possible for drivers to dereference the struct
gpio_chip and perform driver-local operations via regular
function calls instead.
So in this patch set I expose gpio_to_chip(), then alter the
previous rewrite of the U300 GPIO driver to instead use a local
configuration function by wrapping the previously defined config
function into this:
/* External function to configure pins */
int u300_gpio_set_config(unsigned gpio, u16 param, unsigned long *data)
{
struct gpio_chip *chip = gpio_to_chip(gpio);
unsigned offset = gpio - chip->base;
return u300_gpio_config(chip, offset, param, data);
}
This one is then exposed in the chip-specific header in
<linux/gpio/u300.h>, and all the configuration defines that
were previously globally generic in <linux/gpio.h> are also
moved there and made driver-specific without any attempt of
generalizing this.
So for anything that is not currently in struct gpio_chip you
will have to implement something like this, per driver.
I'm open for keeping the generic config defines in <linux/gpio.h>
if Grant accepts that, it certainly will avoid some define
duplication in driver headers. Right now I stay away from the
gpiolib as much as I can.
Comments welcome!
Thanks,
Linus Walleij
Linus Walleij (2):
gpio: expose gpio_to_chip()
gpio/u300: rewrite gpio driver
arch/arm/Kconfig | 2 +-
arch/arm/mach-u300/Kconfig | 1 +
arch/arm/mach-u300/core.c | 31 +-
arch/arm/mach-u300/include/mach/gpio.h | 163 +-----
arch/arm/mach-u300/include/mach/irqs.h | 25 +-
drivers/gpio/Kconfig | 9 +
drivers/gpio/gpio-u300.c | 1176 +++++++++++++++++++-------------
drivers/gpio/gpiolib.c | 2 +-
include/asm-generic/gpio.h | 1 +
include/linux/gpio/u300.h | 82 +++
10 files changed, 833 insertions(+), 659 deletions(-)
create mode 100644 include/linux/gpio/u300.h
--
1.7.3.2
^ permalink raw reply [flat|nested] 18+ messages in thread* [PATCH 0/2] RFC: gpio: driver-local pin configuration @ 2011-06-10 8:48 ` Linus Walleij 0 siblings, 0 replies; 18+ messages in thread From: Linus Walleij @ 2011-06-10 8:48 UTC (permalink / raw) To: Grant Likely, linux-kernel, linux-arm-kernel Cc: Lee Jones, Linus Walleij, Alan Cox, Kyungmin Park, Kurt Van Dijck, Ben Nizette, Mark Brown, Haojian Zhuang, Stijn Devriendt, Rohit Vaswani, Russell King, H Hartley Sweeten From: Linus Walleij <linus.walleij@linaro.org> This is a modification of the previous generic GPIO configuration patch series. I'm Cc:ing everyone involved in earlier discussions so we can move forward on this consolidation work, lest I cannot convert my drivers to use struct gpio_chip / gpiolib. Background: Grant didn't like the idea of an ioctl() like configuration function in the struct gpio_chip vtable, so we decided to see if it was wiser to go back to the initial suggestion of making it possible for drivers to dereference the struct gpio_chip and perform driver-local operations via regular function calls instead. So in this patch set I expose gpio_to_chip(), then alter the previous rewrite of the U300 GPIO driver to instead use a local configuration function by wrapping the previously defined config function into this: /* External function to configure pins */ int u300_gpio_set_config(unsigned gpio, u16 param, unsigned long *data) { struct gpio_chip *chip = gpio_to_chip(gpio); unsigned offset = gpio - chip->base; return u300_gpio_config(chip, offset, param, data); } This one is then exposed in the chip-specific header in <linux/gpio/u300.h>, and all the configuration defines that were previously globally generic in <linux/gpio.h> are also moved there and made driver-specific without any attempt of generalizing this. So for anything that is not currently in struct gpio_chip you will have to implement something like this, per driver. I'm open for keeping the generic config defines in <linux/gpio.h> if Grant accepts that, it certainly will avoid some define duplication in driver headers. Right now I stay away from the gpiolib as much as I can. Comments welcome! Thanks, Linus Walleij Linus Walleij (2): gpio: expose gpio_to_chip() gpio/u300: rewrite gpio driver arch/arm/Kconfig | 2 +- arch/arm/mach-u300/Kconfig | 1 + arch/arm/mach-u300/core.c | 31 +- arch/arm/mach-u300/include/mach/gpio.h | 163 +----- arch/arm/mach-u300/include/mach/irqs.h | 25 +- drivers/gpio/Kconfig | 9 + drivers/gpio/gpio-u300.c | 1176 +++++++++++++++++++------------- drivers/gpio/gpiolib.c | 2 +- include/asm-generic/gpio.h | 1 + include/linux/gpio/u300.h | 82 +++ 10 files changed, 833 insertions(+), 659 deletions(-) create mode 100644 include/linux/gpio/u300.h -- 1.7.3.2 ^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH 0/2] RFC: gpio: driver-local pin configuration 2011-06-10 8:48 ` Linus Walleij @ 2011-06-23 10:54 ` Linus Walleij -1 siblings, 0 replies; 18+ messages in thread From: Linus Walleij @ 2011-06-23 10:54 UTC (permalink / raw) To: linux-arm-kernel 2011/6/10 Linus Walleij <linus.walleij@stericsson.com>: > in this patch set I expose gpio_to_chip(), then alter the > previous rewrite of the U300 GPIO driver to instead use a local > configuration function (...) Any feedback on this? Good? Bad? Linus (W) is an idiot? Any third path to doing custom config? Thanks, Linus Walleij ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 0/2] RFC: gpio: driver-local pin configuration @ 2011-06-23 10:54 ` Linus Walleij 0 siblings, 0 replies; 18+ messages in thread From: Linus Walleij @ 2011-06-23 10:54 UTC (permalink / raw) To: Grant Likely, linux-kernel, linux-arm-kernel Cc: Kyungmin Park, Linus Walleij, Mark Brown, Rohit Vaswani, Haojian Zhuang, Russell King, Ben Nizette, Stijn Devriendt, Lee Jones, H Hartley Sweeten, Alan Cox, Kurt Van Dijck 2011/6/10 Linus Walleij <linus.walleij@stericsson.com>: > in this patch set I expose gpio_to_chip(), then alter the > previous rewrite of the U300 GPIO driver to instead use a local > configuration function (...) Any feedback on this? Good? Bad? Linus (W) is an idiot? Any third path to doing custom config? Thanks, Linus Walleij ^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH 0/2] RFC: gpio: driver-local pin configuration 2011-06-10 8:48 ` Linus Walleij @ 2011-06-27 10:57 ` Stijn Devriendt -1 siblings, 0 replies; 18+ messages in thread From: Stijn Devriendt @ 2011-06-27 10:57 UTC (permalink / raw) To: linux-arm-kernel On Fri, Jun 10, 2011 at 10:48 AM, Linus Walleij <linus.walleij@stericsson.com> wrote: > From: Linus Walleij <linus.walleij@linaro.org> > > This is a modification of the previous generic GPIO configuration > patch series. > > I'm Cc:ing everyone involved in earlier discussions so we can > move forward on this consolidation work, lest I cannot convert > my drivers to use struct gpio_chip / gpiolib. > > Background: Grant didn't like the idea of an ioctl() like > configuration function in the struct gpio_chip vtable, so we > decided to see if it was wiser to go back to the initial suggestion > of making it possible for drivers to dereference the struct > gpio_chip and perform driver-local operations via regular > function calls instead. > I couldn't find Grant's rationale in an e-mail thread somewhere, but except from the few comments I passed on, I liked the approach. > So in this patch set I expose gpio_to_chip(), then alter the > previous rewrite of the U300 GPIO driver to instead use a local > configuration function by wrapping the previously defined config > function into this: > I rather dislike exposing the gpio_to_chip. It makes implementations work around gpiolib completely. We might as well strip it out completely then and go back to drivers doing platform specific GPIO register accesses. I have a patch lying around somewhere which introduces the concept of gpio groups. This is already a step up from the single gpio-pin access and will duplicate every effort to do things like the configuration below. It already duplicates most of the calls for multiple pins... > /* External function to configure pins */ > int u300_gpio_set_config(unsigned gpio, u16 param, unsigned long *data) > { > ? ? ? ?struct gpio_chip *chip = gpio_to_chip(gpio); > ? ? ? ?unsigned offset = gpio - chip->base; > > ? ? ? ?return u300_gpio_config(chip, offset, param, data); > } > > This one is then exposed in the chip-specific header ?in > <linux/gpio/u300.h>, and all the configuration defines that > were previously globally generic in <linux/gpio.h> are also > moved there and made driver-specific without any attempt of > generalizing this. > How about a SPI flash that has its chip select hooked up to a GPIO that requires setting open-drain for example. Now that SPI-driver needs to be aware of each independent gpio-chip implementation. Stijn ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 0/2] RFC: gpio: driver-local pin configuration @ 2011-06-27 10:57 ` Stijn Devriendt 0 siblings, 0 replies; 18+ messages in thread From: Stijn Devriendt @ 2011-06-27 10:57 UTC (permalink / raw) To: Linus Walleij Cc: Grant Likely, linux-kernel, linux-arm-kernel, Lee Jones, Linus Walleij, Alan Cox, Kyungmin Park, Kurt Van Dijck, Ben Nizette, Mark Brown, Haojian Zhuang, Rohit Vaswani, Russell King, H Hartley Sweeten On Fri, Jun 10, 2011 at 10:48 AM, Linus Walleij <linus.walleij@stericsson.com> wrote: > From: Linus Walleij <linus.walleij@linaro.org> > > This is a modification of the previous generic GPIO configuration > patch series. > > I'm Cc:ing everyone involved in earlier discussions so we can > move forward on this consolidation work, lest I cannot convert > my drivers to use struct gpio_chip / gpiolib. > > Background: Grant didn't like the idea of an ioctl() like > configuration function in the struct gpio_chip vtable, so we > decided to see if it was wiser to go back to the initial suggestion > of making it possible for drivers to dereference the struct > gpio_chip and perform driver-local operations via regular > function calls instead. > I couldn't find Grant's rationale in an e-mail thread somewhere, but except from the few comments I passed on, I liked the approach. > So in this patch set I expose gpio_to_chip(), then alter the > previous rewrite of the U300 GPIO driver to instead use a local > configuration function by wrapping the previously defined config > function into this: > I rather dislike exposing the gpio_to_chip. It makes implementations work around gpiolib completely. We might as well strip it out completely then and go back to drivers doing platform specific GPIO register accesses. I have a patch lying around somewhere which introduces the concept of gpio groups. This is already a step up from the single gpio-pin access and will duplicate every effort to do things like the configuration below. It already duplicates most of the calls for multiple pins... > /* External function to configure pins */ > int u300_gpio_set_config(unsigned gpio, u16 param, unsigned long *data) > { > struct gpio_chip *chip = gpio_to_chip(gpio); > unsigned offset = gpio - chip->base; > > return u300_gpio_config(chip, offset, param, data); > } > > This one is then exposed in the chip-specific header in > <linux/gpio/u300.h>, and all the configuration defines that > were previously globally generic in <linux/gpio.h> are also > moved there and made driver-specific without any attempt of > generalizing this. > How about a SPI flash that has its chip select hooked up to a GPIO that requires setting open-drain for example. Now that SPI-driver needs to be aware of each independent gpio-chip implementation. Stijn ^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH 0/2] RFC: gpio: driver-local pin configuration 2011-06-27 10:57 ` Stijn Devriendt @ 2011-06-27 11:44 ` Linus Walleij -1 siblings, 0 replies; 18+ messages in thread From: Linus Walleij @ 2011-06-27 11:44 UTC (permalink / raw) To: linux-arm-kernel On Mon, Jun 27, 2011 at 12:57 PM, Stijn Devriendt <highguy@gmail.com> wrote: > On Fri, Jun 10, 2011 at 10:48 AM, Linus Walleij > <linus.walleij@stericsson.com> wrote: >> >> Background: Grant didn't like the idea of an ioctl() like >> configuration function in the struct gpio_chip vtable, so we >> decided to see if it was wiser to go back to the initial suggestion >> of making it possible for drivers to dereference the struct >> gpio_chip and perform driver-local operations via regular >> function calls instead. >> > I couldn't find Grant's rationale in an e-mail thread somewhere, but > except from the few comments I passed on, I liked the approach. Grant gave me these comments in person. Grant, maybe you can restate? I might be referring it the wrong way. > I rather dislike exposing the gpio_to_chip. It makes implementations > work around gpiolib completely. We might as well strip it out > completely then and go back to drivers doing platform specific GPIO > register accesses. Myself I am pretty neutral and happy with any of these two approaches, I just want to be able to migrate my U300 and Nomadik drivers to gpio_chip and irq_chip, and without a handle on the memory map I cannot do that. >> This one is then exposed in the chip-specific header ?in >> <linux/gpio/u300.h>, and all the configuration defines that >> were previously globally generic in <linux/gpio.h> are also >> moved there and made driver-specific without any attempt of >> generalizing this. >> > How about a SPI flash that has its chip select hooked up to a > GPIO that requires setting open-drain for example. Now that > SPI-driver needs to be aware of each independent gpio-chip > implementation. Yes. To make the driver platform neutral, it needs to for example provide a callback in the platform data like (* set_pin_bias) or so, and then your platform has to implement this biasing. In this specific case that kind of stuff would likely be preferable to have in the platform anyway, but I understand what you mean. In the pinctrl framework I try to handle all such pin control stuff with the intention of letting the GPIO drivers wrap it if they prefer, but in this framework platforms could also handle GPIO and pin control in an orthogonal way, which would likely be preferable in most cases. Linus Walleij ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 0/2] RFC: gpio: driver-local pin configuration @ 2011-06-27 11:44 ` Linus Walleij 0 siblings, 0 replies; 18+ messages in thread From: Linus Walleij @ 2011-06-27 11:44 UTC (permalink / raw) To: Stijn Devriendt, Grant Likely Cc: Linus Walleij, linux-kernel, linux-arm-kernel, Lee Jones, Alan Cox, Kyungmin Park, Kurt Van Dijck, Ben Nizette, Mark Brown, Haojian Zhuang, Rohit Vaswani, Russell King, H Hartley Sweeten On Mon, Jun 27, 2011 at 12:57 PM, Stijn Devriendt <highguy@gmail.com> wrote: > On Fri, Jun 10, 2011 at 10:48 AM, Linus Walleij > <linus.walleij@stericsson.com> wrote: >> >> Background: Grant didn't like the idea of an ioctl() like >> configuration function in the struct gpio_chip vtable, so we >> decided to see if it was wiser to go back to the initial suggestion >> of making it possible for drivers to dereference the struct >> gpio_chip and perform driver-local operations via regular >> function calls instead. >> > I couldn't find Grant's rationale in an e-mail thread somewhere, but > except from the few comments I passed on, I liked the approach. Grant gave me these comments in person. Grant, maybe you can restate? I might be referring it the wrong way. > I rather dislike exposing the gpio_to_chip. It makes implementations > work around gpiolib completely. We might as well strip it out > completely then and go back to drivers doing platform specific GPIO > register accesses. Myself I am pretty neutral and happy with any of these two approaches, I just want to be able to migrate my U300 and Nomadik drivers to gpio_chip and irq_chip, and without a handle on the memory map I cannot do that. >> This one is then exposed in the chip-specific header in >> <linux/gpio/u300.h>, and all the configuration defines that >> were previously globally generic in <linux/gpio.h> are also >> moved there and made driver-specific without any attempt of >> generalizing this. >> > How about a SPI flash that has its chip select hooked up to a > GPIO that requires setting open-drain for example. Now that > SPI-driver needs to be aware of each independent gpio-chip > implementation. Yes. To make the driver platform neutral, it needs to for example provide a callback in the platform data like (* set_pin_bias) or so, and then your platform has to implement this biasing. In this specific case that kind of stuff would likely be preferable to have in the platform anyway, but I understand what you mean. In the pinctrl framework I try to handle all such pin control stuff with the intention of letting the GPIO drivers wrap it if they prefer, but in this framework platforms could also handle GPIO and pin control in an orthogonal way, which would likely be preferable in most cases. Linus Walleij ^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH 0/2] RFC: gpio: driver-local pin configuration 2011-06-27 11:44 ` Linus Walleij @ 2011-06-27 12:02 ` Mark Brown -1 siblings, 0 replies; 18+ messages in thread From: Mark Brown @ 2011-06-27 12:02 UTC (permalink / raw) To: linux-arm-kernel On Mon, Jun 27, 2011 at 01:44:43PM +0200, Linus Walleij wrote: > Yes. To make the driver platform neutral, it needs to for example > provide a callback in the platform data like (* set_pin_bias) or so, > and then your platform has to implement this biasing. > In this specific case that kind of stuff would likely be preferable > to have in the platform anyway, but I understand what you mean. How about device tree usage? I guess there we'd end up doing it by putting the configuration on the GPIO end of things rather than on the GPIO user side? ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 0/2] RFC: gpio: driver-local pin configuration @ 2011-06-27 12:02 ` Mark Brown 0 siblings, 0 replies; 18+ messages in thread From: Mark Brown @ 2011-06-27 12:02 UTC (permalink / raw) To: Linus Walleij Cc: Stijn Devriendt, Grant Likely, Linus Walleij, linux-kernel, linux-arm-kernel, Lee Jones, Alan Cox, Kyungmin Park, Kurt Van Dijck, Ben Nizette, Haojian Zhuang, Rohit Vaswani, Russell King, H Hartley Sweeten On Mon, Jun 27, 2011 at 01:44:43PM +0200, Linus Walleij wrote: > Yes. To make the driver platform neutral, it needs to for example > provide a callback in the platform data like (* set_pin_bias) or so, > and then your platform has to implement this biasing. > In this specific case that kind of stuff would likely be preferable > to have in the platform anyway, but I understand what you mean. How about device tree usage? I guess there we'd end up doing it by putting the configuration on the GPIO end of things rather than on the GPIO user side? ^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH 0/2] RFC: gpio: driver-local pin configuration 2011-06-27 12:02 ` Mark Brown @ 2011-06-27 12:37 ` Linus Walleij -1 siblings, 0 replies; 18+ messages in thread From: Linus Walleij @ 2011-06-27 12:37 UTC (permalink / raw) To: linux-arm-kernel On Mon, Jun 27, 2011 at 2:02 PM, Mark Brown <broonie@opensource.wolfsonmicro.com> wrote: > On Mon, Jun 27, 2011 at 01:44:43PM +0200, Linus Walleij wrote: > >> Yes. To make the driver platform neutral, it needs to for example >> provide a callback in the platform data like (* set_pin_bias) or so, >> and then your platform has to implement this biasing. > >> In this specific case that kind of stuff would likely be preferable >> to have in the platform anyway, but I understand what you mean. > > How about device tree usage? ?I guess there we'd end up doing it by > putting the configuration on the GPIO end of things rather than on the > GPIO user side? Sorry I can't quite understand that, please elaborate! Thanks, Linus Walleij ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 0/2] RFC: gpio: driver-local pin configuration @ 2011-06-27 12:37 ` Linus Walleij 0 siblings, 0 replies; 18+ messages in thread From: Linus Walleij @ 2011-06-27 12:37 UTC (permalink / raw) To: Mark Brown Cc: Stijn Devriendt, Grant Likely, Linus Walleij, linux-kernel, linux-arm-kernel, Lee Jones, Alan Cox, Kyungmin Park, Kurt Van Dijck, Ben Nizette, Haojian Zhuang, Rohit Vaswani, Russell King, H Hartley Sweeten On Mon, Jun 27, 2011 at 2:02 PM, Mark Brown <broonie@opensource.wolfsonmicro.com> wrote: > On Mon, Jun 27, 2011 at 01:44:43PM +0200, Linus Walleij wrote: > >> Yes. To make the driver platform neutral, it needs to for example >> provide a callback in the platform data like (* set_pin_bias) or so, >> and then your platform has to implement this biasing. > >> In this specific case that kind of stuff would likely be preferable >> to have in the platform anyway, but I understand what you mean. > > How about device tree usage? I guess there we'd end up doing it by > putting the configuration on the GPIO end of things rather than on the > GPIO user side? Sorry I can't quite understand that, please elaborate! Thanks, Linus Walleij ^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH 0/2] RFC: gpio: driver-local pin configuration 2011-06-27 12:37 ` Linus Walleij @ 2011-06-28 11:53 ` Stijn Devriendt -1 siblings, 0 replies; 18+ messages in thread From: Stijn Devriendt @ 2011-06-28 11:53 UTC (permalink / raw) To: linux-arm-kernel On Mon, Jun 27, 2011 at 2:37 PM, Linus Walleij <linus.walleij@linaro.org> wrote: > On Mon, Jun 27, 2011 at 2:02 PM, Mark Brown > <broonie@opensource.wolfsonmicro.com> wrote: >> On Mon, Jun 27, 2011 at 01:44:43PM +0200, Linus Walleij wrote: >> >>> Yes. To make the driver platform neutral, it needs to for example >>> provide a callback in the platform data like (* set_pin_bias) or so, >>> and then your platform has to implement this biasing. >> >>> In this specific case that kind of stuff would likely be preferable >>> to have in the platform anyway, but I understand what you mean. >> >> How about device tree usage? ?I guess there we'd end up doing it by >> putting the configuration on the GPIO end of things rather than on the >> GPIO user side? > > Sorry I can't quite understand that, please elaborate! > I have some code doing this as well (in a very limited fashion): int of_request_gpio(..., int* remaining_flags) { of_get_gpio_flags(of_dev, i, remaining_flags) if (flags & bias_X) { gpio_set_bias(gpio, ...) flags &= ~bias_X } // interpret all generic flags here }; So drivers need not worry about all gpio flags and special things. They just request the pin; what they receive is a fully configured pin (with the exception of unknown flags passed out via remaining_flags). Regards, Stijn ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 0/2] RFC: gpio: driver-local pin configuration @ 2011-06-28 11:53 ` Stijn Devriendt 0 siblings, 0 replies; 18+ messages in thread From: Stijn Devriendt @ 2011-06-28 11:53 UTC (permalink / raw) To: Linus Walleij Cc: Mark Brown, Grant Likely, Linus Walleij, linux-kernel, linux-arm-kernel, Lee Jones, Alan Cox, Kyungmin Park, Kurt Van Dijck, Ben Nizette, Haojian Zhuang, Rohit Vaswani, Russell King, H Hartley Sweeten On Mon, Jun 27, 2011 at 2:37 PM, Linus Walleij <linus.walleij@linaro.org> wrote: > On Mon, Jun 27, 2011 at 2:02 PM, Mark Brown > <broonie@opensource.wolfsonmicro.com> wrote: >> On Mon, Jun 27, 2011 at 01:44:43PM +0200, Linus Walleij wrote: >> >>> Yes. To make the driver platform neutral, it needs to for example >>> provide a callback in the platform data like (* set_pin_bias) or so, >>> and then your platform has to implement this biasing. >> >>> In this specific case that kind of stuff would likely be preferable >>> to have in the platform anyway, but I understand what you mean. >> >> How about device tree usage? I guess there we'd end up doing it by >> putting the configuration on the GPIO end of things rather than on the >> GPIO user side? > > Sorry I can't quite understand that, please elaborate! > I have some code doing this as well (in a very limited fashion): int of_request_gpio(..., int* remaining_flags) { of_get_gpio_flags(of_dev, i, remaining_flags) if (flags & bias_X) { gpio_set_bias(gpio, ...) flags &= ~bias_X } // interpret all generic flags here }; So drivers need not worry about all gpio flags and special things. They just request the pin; what they receive is a fully configured pin (with the exception of unknown flags passed out via remaining_flags). Regards, Stijn ^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH 0/2] RFC: gpio: driver-local pin configuration 2011-06-28 11:53 ` Stijn Devriendt @ 2011-06-29 6:18 ` Linus Walleij -1 siblings, 0 replies; 18+ messages in thread From: Linus Walleij @ 2011-06-29 6:18 UTC (permalink / raw) To: linux-arm-kernel 2011/6/28 Stijn Devriendt <highguy@gmail.com>: > On Mon, Jun 27, 2011 at 2:37 PM, Linus Walleij <linus.walleij@linaro.org> wrote: >> On Mon, Jun 27, 2011 at 2:02 PM, Mark Brown >>> How about device tree usage? ?I guess there we'd end up doing it by >>> putting the configuration on the GPIO end of things rather than on the >>> GPIO user side? >> >> Sorry I can't quite understand that, please elaborate! >> > > I have some code doing this as well (in a very limited fashion): > > int of_request_gpio(..., int* remaining_flags) > { > ?of_get_gpio_flags(of_dev, i, remaining_flags) > ?if (flags & bias_X) { > ? ? gpio_set_bias(gpio, ...) > ? ? flags &= ~bias_X > ?} > ?// interpret all generic flags here > }; > > So drivers need not worry about all gpio flags and special things. > They just request the pin; what they receive is a fully configured > pin (with the exception of unknown flags passed out via > remaining_flags). Sorry there is something I don't get here or there is something you assume, maybe. How does this kind of design account for the case where you need to change the biasing at runtime? Thanks, Linus Walleij ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 0/2] RFC: gpio: driver-local pin configuration @ 2011-06-29 6:18 ` Linus Walleij 0 siblings, 0 replies; 18+ messages in thread From: Linus Walleij @ 2011-06-29 6:18 UTC (permalink / raw) To: Stijn Devriendt Cc: Kyungmin Park, Mark Brown, linux-kernel, Haojian Zhuang, Rohit Vaswani, Grant Likely, Alan Cox, Russell King, Ben Nizette, Lee Jones, H Hartley Sweeten, linux-arm-kernel, Kurt Van Dijck 2011/6/28 Stijn Devriendt <highguy@gmail.com>: > On Mon, Jun 27, 2011 at 2:37 PM, Linus Walleij <linus.walleij@linaro.org> wrote: >> On Mon, Jun 27, 2011 at 2:02 PM, Mark Brown >>> How about device tree usage? I guess there we'd end up doing it by >>> putting the configuration on the GPIO end of things rather than on the >>> GPIO user side? >> >> Sorry I can't quite understand that, please elaborate! >> > > I have some code doing this as well (in a very limited fashion): > > int of_request_gpio(..., int* remaining_flags) > { > of_get_gpio_flags(of_dev, i, remaining_flags) > if (flags & bias_X) { > gpio_set_bias(gpio, ...) > flags &= ~bias_X > } > // interpret all generic flags here > }; > > So drivers need not worry about all gpio flags and special things. > They just request the pin; what they receive is a fully configured > pin (with the exception of unknown flags passed out via > remaining_flags). Sorry there is something I don't get here or there is something you assume, maybe. How does this kind of design account for the case where you need to change the biasing at runtime? Thanks, Linus Walleij ^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH 0/2] RFC: gpio: driver-local pin configuration 2011-06-29 6:18 ` Linus Walleij @ 2011-06-29 7:39 ` Stijn Devriendt -1 siblings, 0 replies; 18+ messages in thread From: Stijn Devriendt @ 2011-06-29 7:39 UTC (permalink / raw) To: linux-arm-kernel On Wed, Jun 29, 2011 at 8:18 AM, Linus Walleij <linus.walleij@linaro.org> wrote: > 2011/6/28 Stijn Devriendt <highguy@gmail.com>: >> On Mon, Jun 27, 2011 at 2:37 PM, Linus Walleij <linus.walleij@linaro.org> wrote: >>> On Mon, Jun 27, 2011 at 2:02 PM, Mark Brown >>>> How about device tree usage? ?I guess there we'd end up doing it by >>>> putting the configuration on the GPIO end of things rather than on the >>>> GPIO user side? >>> >>> Sorry I can't quite understand that, please elaborate! >>> >> >> I have some code doing this as well (in a very limited fashion): >> >> int of_request_gpio(..., int* remaining_flags) >> { >> ?of_get_gpio_flags(of_dev, i, remaining_flags) >> ?if (flags & bias_X) { >> ? ? gpio_set_bias(gpio, ...) >> ? ? flags &= ~bias_X >> ?} >> ?// interpret all generic flags here >> }; >> >> So drivers need not worry about all gpio flags and special things. >> They just request the pin; what they receive is a fully configured >> pin (with the exception of unknown flags passed out via >> remaining_flags). > > Sorry there is something I don't get here or there is something you > assume, maybe. > > How does this kind of design account for the case where you need > to change the biasing at runtime? > You're right, it doesn't. It only accounts for preconfiguring pins from device-tree of platform data. Regards, Stijn ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 0/2] RFC: gpio: driver-local pin configuration @ 2011-06-29 7:39 ` Stijn Devriendt 0 siblings, 0 replies; 18+ messages in thread From: Stijn Devriendt @ 2011-06-29 7:39 UTC (permalink / raw) To: Linus Walleij Cc: Kyungmin Park, Mark Brown, linux-kernel, Haojian Zhuang, Rohit Vaswani, Grant Likely, Alan Cox, Russell King, Ben Nizette, Lee Jones, H Hartley Sweeten, linux-arm-kernel, Kurt Van Dijck On Wed, Jun 29, 2011 at 8:18 AM, Linus Walleij <linus.walleij@linaro.org> wrote: > 2011/6/28 Stijn Devriendt <highguy@gmail.com>: >> On Mon, Jun 27, 2011 at 2:37 PM, Linus Walleij <linus.walleij@linaro.org> wrote: >>> On Mon, Jun 27, 2011 at 2:02 PM, Mark Brown >>>> How about device tree usage? I guess there we'd end up doing it by >>>> putting the configuration on the GPIO end of things rather than on the >>>> GPIO user side? >>> >>> Sorry I can't quite understand that, please elaborate! >>> >> >> I have some code doing this as well (in a very limited fashion): >> >> int of_request_gpio(..., int* remaining_flags) >> { >> of_get_gpio_flags(of_dev, i, remaining_flags) >> if (flags & bias_X) { >> gpio_set_bias(gpio, ...) >> flags &= ~bias_X >> } >> // interpret all generic flags here >> }; >> >> So drivers need not worry about all gpio flags and special things. >> They just request the pin; what they receive is a fully configured >> pin (with the exception of unknown flags passed out via >> remaining_flags). > > Sorry there is something I don't get here or there is something you > assume, maybe. > > How does this kind of design account for the case where you need > to change the biasing at runtime? > You're right, it doesn't. It only accounts for preconfiguring pins from device-tree of platform data. Regards, Stijn ^ permalink raw reply [flat|nested] 18+ messages in thread
end of thread, other threads:[~2011-06-29 7:39 UTC | newest] Thread overview: 18+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2011-06-10 8:48 [PATCH 0/2] RFC: gpio: driver-local pin configuration Linus Walleij 2011-06-10 8:48 ` Linus Walleij 2011-06-23 10:54 ` Linus Walleij 2011-06-23 10:54 ` Linus Walleij 2011-06-27 10:57 ` Stijn Devriendt 2011-06-27 10:57 ` Stijn Devriendt 2011-06-27 11:44 ` Linus Walleij 2011-06-27 11:44 ` Linus Walleij 2011-06-27 12:02 ` Mark Brown 2011-06-27 12:02 ` Mark Brown 2011-06-27 12:37 ` Linus Walleij 2011-06-27 12:37 ` Linus Walleij 2011-06-28 11:53 ` Stijn Devriendt 2011-06-28 11:53 ` Stijn Devriendt 2011-06-29 6:18 ` Linus Walleij 2011-06-29 6:18 ` Linus Walleij 2011-06-29 7:39 ` Stijn Devriendt 2011-06-29 7:39 ` Stijn Devriendt
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.