From: Patrice CHOTARD <patrice.chotard@st.com>
To: Christian Ruppert <christian.ruppert@abilis.com>
Cc: Linus Walleij <linus.walleij@linaro.org>,
Stephen Warren <swarren@wwwdotorg.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Grant Likely <grant.likely@secretlab.ca>,
Rob Herring <rob.herring@calxeda.com>,
Rob Landley <rob@landley.net>,
Sascha Leuenberger <sascha.leuenberger@abilis.com>,
Pierrick Hascoet <pierrick.hascoet@abilis.com>,
"devicetree-discuss@lists.ozlabs.org"
<devicetree-discuss@lists.ozlabs.org>,
"linux-doc@vger.kernel.org" <linux-doc@vger.kernel.org>,
Alexandre Courbot <acourbot@nvidia.com>
Subject: Re: [PATCH 1/2] Add pin list based GPIO ranges
Date: Fri, 14 Jun 2013 09:17:53 +0200 [thread overview]
Message-ID: <51BAC3A1.80105@st.com> (raw)
In-Reply-To: <1371128132-18266-1-git-send-email-christian.ruppert@abilis.com>
On 06/13/2013 02:55 PM, Christian Ruppert wrote:
> Traditionally, GPIO ranges are based on consecutive ranges of both GPIO
> and pin numbers. This patch allows for GPIO ranges with arbitrary lists
> of pin numbers.
>
> Signed-off-by: Christian Ruppert <christian.ruppert@abilis.com>
> ---
> drivers/pinctrl/core.c | 59 ++++++++++++++++++++++++++++++++------
> include/linux/pinctrl/pinctrl.h | 4 ++-
> 2 files changed, 52 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/pinctrl/core.c b/drivers/pinctrl/core.c
> index 5327f35..25bb17e 100644
> --- a/drivers/pinctrl/core.c
> +++ b/drivers/pinctrl/core.c
> @@ -280,6 +280,29 @@ static int pinctrl_register_pins(struct pinctrl_dev *pctldev,
> }
>
> /**
> + * gpio_to_pin() - GPIO range GPIO number to pin number translation
> + * @range: GPIO range used for the translation
> + * @gpio: gpio pin to translate to a pin number
> + *
> + * Finds the pin number for a given GPIO using the specified GPIO range
> + * as a base for translation. The distinction between linear GPIO ranges
> + * and pin list based GPIO ranges is managed correctly by this function.
> + *
> + * This function assumes the gpio is part of the specified GPIO range, use
> + * only after making sure this is the case (e.g. by calling it on the
> + * result of successful pinctrl_get_device_gpio_range calls)!
> + */
> +static inline int gpio_to_pin(struct pinctrl_gpio_range *range,
> + unsigned int gpio)
> +{
> + unsigned int offset = gpio - range->base;
> + if (range->pins)
> + return range->pins[offset];
> + else
> + return range->pin_base + offset;
> +}
> +
> +/**
> * pinctrl_match_gpio_range() - check if a certain GPIO pin is in range
> * @pctldev: pin controller device to check
> * @gpio: gpio pin to check taken from the global GPIO pin space
> @@ -444,8 +467,14 @@ pinctrl_find_gpio_range_from_pin(struct pinctrl_dev *pctldev,
> /* Loop over the ranges */
> list_for_each_entry(range, &pctldev->gpio_ranges, node) {
> /* Check if we're in the valid range */
> - if (pin >= range->pin_base &&
> - pin < range->pin_base + range->npins) {
> + if (range->pins) {
> + int a;
> + for (a = 0; a < range->npins; a++) {
> + if (range->pins[a] == pin)
> + return range;
> + }
> + } else if (pin >= range->pin_base &&
> + pin < range->pin_base + range->npins) {
> mutex_unlock(&pctldev->mutex);
> return range;
> }
> @@ -528,7 +557,7 @@ int pinctrl_request_gpio(unsigned gpio)
> }
>
> /* Convert to the pin controllers number space */
> - pin = gpio - range->base + range->pin_base;
> + pin = gpio_to_pin(range, gpio);
>
> ret = pinmux_request_gpio(pctldev, range, pin, gpio);
>
> @@ -562,7 +591,7 @@ void pinctrl_free_gpio(unsigned gpio)
> mutex_lock(&pctldev->mutex);
>
> /* Convert to the pin controllers number space */
> - pin = gpio - range->base + range->pin_base;
> + pin = gpio_to_pin(range, gpio);
>
> pinmux_free_gpio(pctldev, pin, range);
>
> @@ -589,7 +618,7 @@ static int pinctrl_gpio_direction(unsigned gpio, bool input)
> mutex_lock(&pctldev->mutex);
>
> /* Convert to the pin controllers number space */
> - pin = gpio - range->base + range->pin_base;
> + pin = gpio_to_pin(range, gpio);
> ret = pinmux_gpio_direction(pctldev, range, pin, input);
>
> mutex_unlock(&pctldev->mutex);
> @@ -1296,11 +1325,21 @@ static int pinctrl_gpioranges_show(struct seq_file *s, void *what)
>
> /* Loop over the ranges */
> list_for_each_entry(range, &pctldev->gpio_ranges, node) {
> - seq_printf(s, "%u: %s GPIOS [%u - %u] PINS [%u - %u]\n",
> - range->id, range->name,
> - range->base, (range->base + range->npins - 1),
> - range->pin_base,
> - (range->pin_base + range->npins - 1));
> + if (range->pins) {
> + int a;
> + seq_printf(s, "%u: %s GPIOS [%u - %u] PINS {",
> + range->id, range->name,
> + range->base, (range->base + range->npins - 1));
> + for (a = 0; a < range->npins - 1; a++)
> + seq_printf(s, "%u, ", range->pins[a]);
> + seq_printf(s, "%u}\n", range->pins[a]);
> + }
> + else
> + seq_printf(s, "%u: %s GPIOS [%u - %u] PINS [%u - %u]\n",
> + range->id, range->name,
> + range->base, (range->base + range->npins - 1),
> + range->pin_base,
> + (range->pin_base + range->npins - 1));
> }
>
> mutex_unlock(&pctldev->mutex);
> diff --git a/include/linux/pinctrl/pinctrl.h b/include/linux/pinctrl/pinctrl.h
> index 2c2a9e8..176a6c1 100644
> --- a/include/linux/pinctrl/pinctrl.h
> +++ b/include/linux/pinctrl/pinctrl.h
> @@ -49,7 +49,8 @@ struct pinctrl_pin_desc {
> * @name: a name for the chip in this range
> * @id: an ID number for the chip in this range
> * @base: base offset of the GPIO range
> - * @pin_base: base pin number of the GPIO range
> + * @pin_base: base pin number of the GPIO range if pins != NULL
Hi Christian,
It seems that your comment is not correct, it should be :
* @pin_base: base pin number of the GPIO range if pins == NULL
Patrice
> + * @pins: enumeration of pins in GPIO range or NULL
> * @npins: number of pins in the GPIO range, including the base number
> * @gc: an optional pointer to a gpio_chip
> */
> @@ -59,6 +60,7 @@ struct pinctrl_gpio_range {
> unsigned int id;
> unsigned int base;
> unsigned int pin_base;
> + unsigned const *pins;
> unsigned int npins;
> struct gpio_chip *gc;
> };
next prev parent reply other threads:[~2013-06-14 7:17 UTC|newest]
Thread overview: 147+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-10 15:45 [PATCH 1/2] pinmux: Add TB10x pinmux driver Christian Ruppert
2013-04-10 15:45 ` [PATCH 2/2] GPIO: Add TB10x GPIO driver Christian Ruppert
2013-04-17 15:13 ` Linus Walleij
2013-04-17 18:37 ` Stephen Warren
2013-04-17 14:48 ` [PATCH 1/2] pinmux: Add TB10x pinmux driver Linus Walleij
2013-04-17 18:32 ` Stephen Warren
2013-04-18 9:03 ` Christian Ruppert
2013-04-26 7:47 ` Linus Walleij
2013-04-29 16:17 ` Christian Ruppert
[not found] ` <20130429161725.GB30136-7oYq3qWSd+k@public.gmane.org>
2013-05-02 18:49 ` Stephen Warren
2013-05-02 18:49 ` Stephen Warren
2013-05-03 18:03 ` Linus Walleij
2013-05-08 16:41 ` Christian Ruppert
2013-05-08 20:01 ` Stephen Warren
2013-05-10 8:25 ` Christian Ruppert
2013-05-14 12:29 ` Linus Walleij
2013-05-15 9:41 ` Christian Ruppert
2013-05-20 8:03 ` Linus Walleij
2013-05-22 9:49 ` Christian Ruppert
2013-06-12 16:44 ` [RFC] Allow GPIO ranges based on pinctl pin groups Christian Ruppert
[not found] ` <1371055449-15828-1-git-send-email-christian.ruppert-ux6zf3SgZrrQT0dZR+AlfA@public.gmane.org>
2013-06-13 9:00 ` Linus Walleij
2013-06-13 9:00 ` Linus Walleij
2013-06-13 12:55 ` [PATCH 1/2] Add pin list based GPIO ranges Christian Ruppert
[not found] ` <1371128132-18266-1-git-send-email-christian.ruppert-ux6zf3SgZrrQT0dZR+AlfA@public.gmane.org>
2013-06-13 18:30 ` Linus Walleij
2013-06-13 18:30 ` Linus Walleij
2013-06-14 7:17 ` Patrice CHOTARD [this message]
2013-06-14 8:24 ` [PATCH] Fix comment on pinctrl_gpio_range.pin_base Christian Ruppert
2013-06-16 10:19 ` Linus Walleij
2013-06-13 12:55 ` [PATCH 2/2] Make non-linear GPIO ranges accesible from gpiolib Christian Ruppert
2013-06-13 18:36 ` Linus Walleij
2013-06-13 21:38 ` Stephen Warren
2013-06-14 9:12 ` Christian Ruppert
2013-06-19 18:10 ` Stephen Warren
2013-06-19 18:27 ` Stephen Warren
2013-06-20 11:57 ` Christian Ruppert
2013-06-21 21:17 ` Stephen Warren
2013-06-25 11:59 ` Christian Ruppert
2013-06-25 15:59 ` Stephen Warren
2013-06-25 14:27 ` Linus Walleij
2013-06-25 15:19 ` Stephen Warren
2013-06-25 14:32 ` Linus Walleij
2013-06-25 15:22 ` Stephen Warren
2013-06-25 14:56 ` Linus Walleij
2013-06-25 15:31 ` Stephen Warren
2013-06-25 15:47 ` Linus Walleij
2013-06-25 15:28 ` Linus Walleij
2013-06-25 15:39 ` Stephen Warren
2013-06-25 15:53 ` Linus Walleij
2013-06-17 16:03 ` Christian Ruppert
2013-06-17 16:04 ` [PATCH 1/4] " Christian Ruppert
2013-06-18 8:09 ` Linus Walleij
2013-06-18 9:25 ` Christian Ruppert
2013-06-18 9:29 ` Christian Ruppert
2013-06-19 12:03 ` Linus Walleij
2013-06-19 18:15 ` Stephen Warren
2013-06-26 11:42 ` Christian Ruppert
2013-06-26 17:33 ` Stephen Warren
2013-06-19 22:27 ` Stephen Warren
2013-06-26 11:46 ` Christian Ruppert
2013-06-26 17:34 ` Stephen Warren
2013-06-18 9:29 ` [PATCH 2/4] pinmux: Add TB10x pinmux driver Christian Ruppert
2013-06-19 22:35 ` Stephen Warren
2013-06-26 11:50 ` Christian Ruppert
2013-06-26 17:40 ` Stephen Warren
2013-07-05 9:49 ` Christian Ruppert
2013-07-05 18:40 ` Stephen Warren
2013-07-08 13:02 ` Christian Ruppert
2013-07-10 19:27 ` Stephen Warren
2013-07-16 8:47 ` Christian Ruppert
2013-07-16 16:04 ` Stephen Warren
2013-07-18 16:07 ` Christian Ruppert
2013-07-18 19:54 ` Stephen Warren
2013-07-26 9:42 ` Christian Ruppert
2013-07-26 16:05 ` Stephen Warren
2013-07-29 22:35 ` Linus Walleij
2013-08-05 11:51 ` Christian Ruppert
2013-08-05 11:51 ` Christian Ruppert
2013-08-14 16:53 ` Linus Walleij
2013-08-21 15:57 ` Christian Ruppert
2013-08-22 20:10 ` Stephen Warren
2013-08-28 14:47 ` Christian Ruppert
2013-10-08 12:21 ` Christian Ruppert
2013-10-08 12:25 ` [PATCH 01/03] Make non-linear GPIO ranges accesible from gpiolib Christian Ruppert
2013-10-09 11:58 ` Linus Walleij
2013-10-09 13:28 ` Christian Ruppert
2013-10-09 14:01 ` Linus Walleij
2013-10-10 20:49 ` Stephen Warren
2013-10-11 7:53 ` Linus Walleij
2013-10-15 13:36 ` Christian Ruppert
2013-10-15 13:37 ` [PATCH V2] " Christian Ruppert
2013-10-16 11:19 ` Linus Walleij
2013-10-16 12:56 ` [PATCH] Add a short note on pinctrl_get_group_pins to pinctrl.txt Christian Ruppert
2013-10-16 13:36 ` Linus Walleij
2013-10-10 20:47 ` [PATCH 01/03] Make non-linear GPIO ranges accesible from gpiolib Stephen Warren
2013-10-08 12:25 ` [PATCH 02/03] pinmux: Add TB10x pinmux driver Christian Ruppert
2013-10-09 12:30 ` Linus Walleij
[not found] ` <CACRpkdZdELan7OyMjt4KOi=q-v1xkSaNZNyZ7AnOBY1R=SoW3w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-10-15 13:39 ` [PATCH V2] " Christian Ruppert
2013-10-15 13:39 ` Christian Ruppert
2013-10-16 11:25 ` Linus Walleij
2013-10-08 12:25 ` [PATCH 03/03] GPIO: Add TB10x GPIO driver Christian Ruppert
2013-10-09 12:19 ` Linus Walleij
2013-10-15 13:45 ` Christian Ruppert
2013-10-16 11:29 ` Linus Walleij
2013-10-16 12:58 ` Christian Ruppert
2013-10-24 16:23 ` Christian Ruppert
2013-10-25 21:44 ` Linus Walleij
2013-10-25 3:27 ` Kumar Gala
2013-08-28 18:49 ` [PATCH 2/4] pinmux: Add TB10x pinmux driver Linus Walleij
2013-08-29 7:35 ` Christian Ruppert
2013-08-29 8:24 ` Linus Walleij
2013-08-30 8:19 ` Christian Ruppert
2013-06-18 9:29 ` [PATCH 3/4] GPIO: Add TB10x GPIO driver Christian Ruppert
2013-06-19 22:37 ` Stephen Warren
2013-06-18 9:29 ` [PATCH 4/4] Add Abilis Systems Sarl to device tree vendor prefixes Christian Ruppert
2013-06-17 16:04 ` [PATCH 2/4] pinmux: Add TB10x pinmux driver Christian Ruppert
2013-06-17 16:04 ` [PATCH 3/4] GPIO: Add TB10x GPIO driver Christian Ruppert
2013-06-17 16:04 ` [PATCH 4/4] Add Abilis Systems Sarl to device tree vendor prefixes Christian Ruppert
2013-05-16 0:12 ` [PATCH 1/2] pinmux: Add TB10x pinmux driver Stephen Warren
2013-05-20 8:10 ` Linus Walleij
2013-05-22 14:28 ` Christian Ruppert
2013-05-23 7:43 ` Haojian Zhuang
2013-05-24 11:50 ` Christian Ruppert
2013-05-26 15:49 ` Haojian Zhuang
2013-06-03 12:30 ` Christian Ruppert
[not found] ` <20130603123001.GD31808-7oYq3qWSd+k@public.gmane.org>
2013-06-05 1:44 ` Haojian Zhuang
2013-06-05 1:44 ` Haojian Zhuang
2013-06-06 14:11 ` Christian Ruppert
2013-06-06 14:32 ` Haojian Zhuang
2013-06-06 15:30 ` Christian Ruppert
2013-06-07 0:00 ` Haojian Zhuang
2013-06-07 11:32 ` Christian Ruppert
[not found] ` <20130607113207.GE11875-7oYq3qWSd+k@public.gmane.org>
2013-06-07 14:57 ` Haojian Zhuang
2013-06-07 14:57 ` Haojian Zhuang
2013-06-07 19:18 ` Stephen Warren
2013-06-08 8:31 ` Haojian Zhuang
2013-06-09 2:47 ` Stephen Warren
2013-06-11 7:27 ` Christian Ruppert
2013-06-16 11:11 ` Linus Walleij
2013-05-29 12:21 ` Linus Walleij
2013-06-03 9:42 ` Christian Ruppert
[not found] ` <20130603094204.GC31808-7oYq3qWSd+k@public.gmane.org>
2013-06-07 11:36 ` Linus Walleij
2013-06-07 11:36 ` Linus Walleij
2013-06-07 13:34 ` Christian Ruppert
2013-05-24 9:20 ` Linus Walleij
2013-05-24 12:03 ` Christian Ruppert
[not found] ` <20130418090310.GA17636-7oYq3qWSd+k@public.gmane.org>
2013-05-02 18:52 ` Stephen Warren
2013-05-02 18:52 ` Stephen Warren
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=51BAC3A1.80105@st.com \
--to=patrice.chotard@st.com \
--cc=acourbot@nvidia.com \
--cc=christian.ruppert@abilis.com \
--cc=devicetree-discuss@lists.ozlabs.org \
--cc=grant.likely@secretlab.ca \
--cc=linus.walleij@linaro.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pierrick.hascoet@abilis.com \
--cc=rob.herring@calxeda.com \
--cc=rob@landley.net \
--cc=sascha.leuenberger@abilis.com \
--cc=swarren@wwwdotorg.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 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.