* [PATCH v2 0/2] of/gpio: Automatic handling of devicetree open-drain GPIO specifications. @ 2014-02-11 19:49 David Daney 2014-02-11 19:49 ` [PATCH v2 1/2] of/gpio: Define OF_GPIO_OPEN_DRAIN and OF_GPIO_OPEN_SOURCE flags David Daney 2014-02-11 19:50 ` [PATCH v2 2/2] of/gpio: Automatically decode OF_GPIO_OPEN_DRAIN and OF_GPIO_OPEN_SOURCE flags in gpiolib David Daney 0 siblings, 2 replies; 7+ messages in thread From: David Daney @ 2014-02-11 19:49 UTC (permalink / raw) To: Grant Likely, Rob Herring, devicetree-u79uwXL29TY76Z2rM5mHXA, Linus Walleij, Alexandre Courbot, linux-gpio-u79uwXL29TY76Z2rM5mHXA Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA, David Daney From: David Daney <david.daney-YGCgFSpz5w/QT0dZR+AlfA@public.gmane.org> Add two new flags for open-drain and open-source GPIOs and the corresponding handling in gpiod_get() to automatically set the corresponding flags in the GPIO system. Changes from v1 (suggested by Alexandre Courbot): o Add OF_GPIO_OPEN_SOURCE o Add automatic propagation of the flags in gpiod_get() et al. David Daney (2): of/gpio: Define OF_GPIO_OPEN_DRAIN and OF_GPIO_OPEN_SOURCE flags. of/gpio: Automatically decode OF_GPIO_OPEN_DRAIN and OF_GPIO_OPEN_SOURCE flags in gpiolib. drivers/gpio/gpiolib.c | 6 ++++++ include/linux/of_gpio.h | 2 ++ 2 files changed, 8 insertions(+) -- 1.7.11.7 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2 1/2] of/gpio: Define OF_GPIO_OPEN_DRAIN and OF_GPIO_OPEN_SOURCE flags. 2014-02-11 19:49 [PATCH v2 0/2] of/gpio: Automatic handling of devicetree open-drain GPIO specifications David Daney @ 2014-02-11 19:49 ` David Daney 2014-02-12 2:20 ` Alexandre Courbot ` (2 more replies) 2014-02-11 19:50 ` [PATCH v2 2/2] of/gpio: Automatically decode OF_GPIO_OPEN_DRAIN and OF_GPIO_OPEN_SOURCE flags in gpiolib David Daney 1 sibling, 3 replies; 7+ messages in thread From: David Daney @ 2014-02-11 19:49 UTC (permalink / raw) To: Grant Likely, Rob Herring, devicetree, Linus Walleij, Alexandre Courbot, linux-gpio Cc: linux-kernel, David Daney From: David Daney <david.daney@cavium.com> When we have a GPIO pin connected to an open-drain network, we want a standard way of specifying this in the device tree. So we choose bit 1 of the flag field to indicate open drain. A typical use case would be something like: enum of_gpio_flags f; . . . reset_gpio = of_get_named_gpio_flags(node, "reset", 0, &f); . . . ret = gpio_request_one(reset_gpio, (f & OF_GPIO_OPEN_DRAIN) ? GPIOF_OPEN_DRAIN : 0, "reset"); . . . gpio_direction_output(reset_gpio, 1); gpio_set_value(reset_gpio, 0); msleep(20); gpio_set_value(reset_gpio, 1); . . . Since the same arguments hold for open-source configurations, add a definition for OF_GPIO_OPEN_SOURCE as well. Signed-off-by: David Daney <david.daney@cavium.com> --- include/linux/of_gpio.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/linux/of_gpio.h b/include/linux/of_gpio.h index f14123a..cfacf5875 100644 --- a/include/linux/of_gpio.h +++ b/include/linux/of_gpio.h @@ -30,6 +30,8 @@ struct device_node; */ enum of_gpio_flags { OF_GPIO_ACTIVE_LOW = 0x1, + OF_GPIO_OPEN_DRAIN = 0x2, + OF_GPIO_OPEN_SOURCE = 0x4, }; #ifdef CONFIG_OF_GPIO -- 1.7.11.7 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v2 1/2] of/gpio: Define OF_GPIO_OPEN_DRAIN and OF_GPIO_OPEN_SOURCE flags. 2014-02-11 19:49 ` [PATCH v2 1/2] of/gpio: Define OF_GPIO_OPEN_DRAIN and OF_GPIO_OPEN_SOURCE flags David Daney @ 2014-02-12 2:20 ` Alexandre Courbot 2014-02-24 12:09 ` Linus Walleij 2014-02-24 12:11 ` Linus Walleij 2 siblings, 0 replies; 7+ messages in thread From: Alexandre Courbot @ 2014-02-12 2:20 UTC (permalink / raw) To: David Daney Cc: Grant Likely, Rob Herring, devicetree@vger.kernel.org, Linus Walleij, linux-gpio@vger.kernel.org, Linux Kernel Mailing List, David Daney On Wed, Feb 12, 2014 at 4:49 AM, David Daney <ddaney.cavm@gmail.com> wrote: > From: David Daney <david.daney@cavium.com> > > When we have a GPIO pin connected to an open-drain network, we want a > standard way of specifying this in the device tree. So we choose bit > 1 of the flag field to indicate open drain. > > A typical use case would be something like: > > enum of_gpio_flags f; > . > . > . > reset_gpio = of_get_named_gpio_flags(node, "reset", 0, &f); > . > . > . > ret = gpio_request_one(reset_gpio, > (f & OF_GPIO_OPEN_DRAIN) ? GPIOF_OPEN_DRAIN : 0, > "reset"); > . > . > . > gpio_direction_output(reset_gpio, 1); > gpio_set_value(reset_gpio, 0); > msleep(20); > gpio_set_value(reset_gpio, 1); > . > . > . > > Since the same arguments hold for open-source configurations, add a > definition for OF_GPIO_OPEN_SOURCE as well. > > Signed-off-by: David Daney <david.daney@cavium.com> Reviewed-by: Alexandre Courbot <acourbot@nvidia.com> ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 1/2] of/gpio: Define OF_GPIO_OPEN_DRAIN and OF_GPIO_OPEN_SOURCE flags. 2014-02-11 19:49 ` [PATCH v2 1/2] of/gpio: Define OF_GPIO_OPEN_DRAIN and OF_GPIO_OPEN_SOURCE flags David Daney 2014-02-12 2:20 ` Alexandre Courbot @ 2014-02-24 12:09 ` Linus Walleij 2014-02-24 12:11 ` Linus Walleij 2 siblings, 0 replies; 7+ messages in thread From: Linus Walleij @ 2014-02-24 12:09 UTC (permalink / raw) To: David Daney Cc: Grant Likely, Rob Herring, devicetree@vger.kernel.org, Alexandre Courbot, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, David Daney On Tue, Feb 11, 2014 at 8:49 PM, David Daney <ddaney.cavm@gmail.com> wrote: > From: David Daney <david.daney@cavium.com> > > When we have a GPIO pin connected to an open-drain network, we want a > standard way of specifying this in the device tree. So we choose bit > 1 of the flag field to indicate open drain. Same comments as for v1... Yours, Linus Walleij ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 1/2] of/gpio: Define OF_GPIO_OPEN_DRAIN and OF_GPIO_OPEN_SOURCE flags. 2014-02-11 19:49 ` [PATCH v2 1/2] of/gpio: Define OF_GPIO_OPEN_DRAIN and OF_GPIO_OPEN_SOURCE flags David Daney 2014-02-12 2:20 ` Alexandre Courbot 2014-02-24 12:09 ` Linus Walleij @ 2014-02-24 12:11 ` Linus Walleij 2 siblings, 0 replies; 7+ messages in thread From: Linus Walleij @ 2014-02-24 12:11 UTC (permalink / raw) To: David Daney Cc: Grant Likely, Rob Herring, devicetree@vger.kernel.org, Alexandre Courbot, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, David Daney On Tue, Feb 11, 2014 at 8:49 PM, David Daney <ddaney.cavm@gmail.com> wrote: > enum of_gpio_flags { > OF_GPIO_ACTIVE_LOW = 0x1, > + OF_GPIO_OPEN_DRAIN = 0x2, > + OF_GPIO_OPEN_SOURCE = 0x4, > }; BTW I think this enum shall be deleted and replaced by #include <dt-bindings/gpio/gpio.h> and use the definition from there. Yours, Linus Walleij ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2 2/2] of/gpio: Automatically decode OF_GPIO_OPEN_DRAIN and OF_GPIO_OPEN_SOURCE flags in gpiolib. 2014-02-11 19:49 [PATCH v2 0/2] of/gpio: Automatic handling of devicetree open-drain GPIO specifications David Daney 2014-02-11 19:49 ` [PATCH v2 1/2] of/gpio: Define OF_GPIO_OPEN_DRAIN and OF_GPIO_OPEN_SOURCE flags David Daney @ 2014-02-11 19:50 ` David Daney [not found] ` <1392148200-5393-3-git-send-email-ddaney.cavm-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 1 sibling, 1 reply; 7+ messages in thread From: David Daney @ 2014-02-11 19:50 UTC (permalink / raw) To: Grant Likely, Rob Herring, devicetree, Linus Walleij, Alexandre Courbot, linux-gpio Cc: linux-kernel, David Daney From: David Daney <david.daney@cavium.com> Just as gpiod_get() automatically interprets the OF_GPIO_ACTIVE_LOW flag from the device tree, add handling for OF_GPIO_OPEN_DRAIN and OF_GPIO_OPEN_SOURCE. This keeps the details of handling open-drain GPIOs in the core GPIO code, and out of the individual drivers. Signed-off-by: David Daney <david.daney@cavium.com> --- drivers/gpio/gpiolib.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 50c4922..7f596d0 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -2307,6 +2307,12 @@ static struct gpio_desc *of_find_gpio(struct device *dev, const char *con_id, if (of_flags & OF_GPIO_ACTIVE_LOW) *flags |= GPIO_ACTIVE_LOW; + if (of_flags & OF_GPIO_OPEN_DRAIN) + *flags |= GPIO_OPEN_DRAIN; + + if (of_flags & OF_GPIO_OPEN_SOURCE) + *flags |= GPIO_OPEN_SOURCE; + return desc; } #else -- 1.7.11.7 ^ permalink raw reply related [flat|nested] 7+ messages in thread
[parent not found: <1392148200-5393-3-git-send-email-ddaney.cavm-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>]
* Re: [PATCH v2 2/2] of/gpio: Automatically decode OF_GPIO_OPEN_DRAIN and OF_GPIO_OPEN_SOURCE flags in gpiolib. [not found] ` <1392148200-5393-3-git-send-email-ddaney.cavm-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> @ 2014-02-12 2:21 ` Alexandre Courbot 0 siblings, 0 replies; 7+ messages in thread From: Alexandre Courbot @ 2014-02-12 2:21 UTC (permalink / raw) To: David Daney Cc: Grant Likely, Rob Herring, devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Linus Walleij, linux-gpio-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Linux Kernel Mailing List, David Daney On Wed, Feb 12, 2014 at 4:50 AM, David Daney <ddaney.cavm-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > From: David Daney <david.daney-YGCgFSpz5w/QT0dZR+AlfA@public.gmane.org> > > Just as gpiod_get() automatically interprets the OF_GPIO_ACTIVE_LOW > flag from the device tree, add handling for OF_GPIO_OPEN_DRAIN and > OF_GPIO_OPEN_SOURCE. > > This keeps the details of handling open-drain GPIOs in the core GPIO > code, and out of the individual drivers. > > Signed-off-by: David Daney <david.daney-YGCgFSpz5w/QT0dZR+AlfA@public.gmane.org> > --- > drivers/gpio/gpiolib.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c > index 50c4922..7f596d0 100644 > --- a/drivers/gpio/gpiolib.c > +++ b/drivers/gpio/gpiolib.c > @@ -2307,6 +2307,12 @@ static struct gpio_desc *of_find_gpio(struct device *dev, const char *con_id, > if (of_flags & OF_GPIO_ACTIVE_LOW) > *flags |= GPIO_ACTIVE_LOW; > > + if (of_flags & OF_GPIO_OPEN_DRAIN) > + *flags |= GPIO_OPEN_DRAIN; > + > + if (of_flags & OF_GPIO_OPEN_SOURCE) > + *flags |= GPIO_OPEN_SOURCE; > + > return desc; > } Reviewed-by: Alexandre Courbot <acourbot-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org> Thanks for taking the time to do this! -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2014-02-24 12:11 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2014-02-11 19:49 [PATCH v2 0/2] of/gpio: Automatic handling of devicetree open-drain GPIO specifications David Daney 2014-02-11 19:49 ` [PATCH v2 1/2] of/gpio: Define OF_GPIO_OPEN_DRAIN and OF_GPIO_OPEN_SOURCE flags David Daney 2014-02-12 2:20 ` Alexandre Courbot 2014-02-24 12:09 ` Linus Walleij 2014-02-24 12:11 ` Linus Walleij 2014-02-11 19:50 ` [PATCH v2 2/2] of/gpio: Automatically decode OF_GPIO_OPEN_DRAIN and OF_GPIO_OPEN_SOURCE flags in gpiolib David Daney [not found] ` <1392148200-5393-3-git-send-email-ddaney.cavm-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 2014-02-12 2:21 ` Alexandre Courbot
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).