From: Mika Westerberg <mika.westerberg@linux.intel.com>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: linux-gpio@vger.kernel.org, Linus Walleij <linus.walleij@linaro.org>
Subject: Re: [PATCH v1 1/4] pinctrl: intel: Introduce common flags for GPIO mapping scheme
Date: Wed, 1 Apr 2020 12:51:42 +0300 [thread overview]
Message-ID: <20200401095142.GS2564@lahna.fi.intel.com> (raw)
In-Reply-To: <20200331152547.34044-1-andriy.shevchenko@linux.intel.com>
On Tue, Mar 31, 2020 at 06:25:44PM +0300, Andy Shevchenko wrote:
> Few drivers are using the same flag to tell Intel pin control core
> how to interpret GPIO base.
>
> Provide a generic flags so all drivers can use.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
> drivers/pinctrl/intel/pinctrl-intel.c | 19 +++++++++++++------
> drivers/pinctrl/intel/pinctrl-intel.h | 5 +++--
> 2 files changed, 16 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/pinctrl/intel/pinctrl-intel.c b/drivers/pinctrl/intel/pinctrl-intel.c
> index 74fdfd2b9ff5..a1b286dc7008 100644
> --- a/drivers/pinctrl/intel/pinctrl-intel.c
> +++ b/drivers/pinctrl/intel/pinctrl-intel.c
> @@ -798,7 +798,7 @@ static int intel_gpio_to_pin(struct intel_pinctrl *pctrl, unsigned int offset,
> for (j = 0; j < comm->ngpps; j++) {
> const struct intel_padgroup *pgrp = &comm->gpps[j];
>
> - if (pgrp->gpio_base < 0)
> + if (pgrp->gpio_base == INTEL_GPIO_BASE_NOMAP)
> continue;
>
> if (offset >= pgrp->gpio_base &&
> @@ -1138,7 +1138,7 @@ static int intel_gpio_add_community_ranges(struct intel_pinctrl *pctrl,
> for (i = 0; i < community->ngpps; i++) {
> const struct intel_padgroup *gpp = &community->gpps[i];
>
> - if (gpp->gpio_base < 0)
> + if (gpp->gpio_base == INTEL_GPIO_BASE_NOMAP)
> continue;
>
> ret = gpiochip_add_pin_range(&pctrl->chip, dev_name(pctrl->dev),
> @@ -1180,7 +1180,7 @@ static unsigned int intel_gpio_ngpio(const struct intel_pinctrl *pctrl)
> for (j = 0; j < community->ngpps; j++) {
> const struct intel_padgroup *gpp = &community->gpps[j];
>
> - if (gpp->gpio_base < 0)
> + if (gpp->gpio_base == INTEL_GPIO_BASE_NOMAP)
> continue;
>
> if (gpp->gpio_base + gpp->size > ngpio)
> @@ -1276,8 +1276,15 @@ static int intel_pinctrl_add_padgroups(struct intel_pinctrl *pctrl,
> if (gpps[i].size > 32)
> return -EINVAL;
>
> - if (!gpps[i].gpio_base)
> - gpps[i].gpio_base = gpps[i].base;
> + /* Special treatment for GPIO base */
> + switch (gpps[i].gpio_base) {
> + case INTEL_GPIO_BASE_MATCH:
> + gpps[i].gpio_base = gpps[i].base;
> + break;
> + case INTEL_GPIO_BASE_NOMAP:
> + default:
> + break;
> + }
>
> gpps[i].padown_num = padown_num;
>
> @@ -1596,7 +1603,7 @@ static void intel_restore_hostown(struct intel_pinctrl *pctrl, unsigned int c,
> struct device *dev = pctrl->dev;
> u32 requested;
>
> - if (padgrp->gpio_base < 0)
> + if (padgrp->gpio_base == INTEL_GPIO_BASE_NOMAP)
> return;
>
> requested = intel_gpio_is_requested(&pctrl->chip, padgrp->gpio_base, padgrp->size);
> diff --git a/drivers/pinctrl/intel/pinctrl-intel.h b/drivers/pinctrl/intel/pinctrl-intel.h
> index c6f066f6d3fb..df11bd6e4a80 100644
> --- a/drivers/pinctrl/intel/pinctrl-intel.h
> +++ b/drivers/pinctrl/intel/pinctrl-intel.h
> @@ -53,8 +53,7 @@ struct intel_function {
> * @reg_num: GPI_IS register number
> * @base: Starting pin of this group
> * @size: Size of this group (maximum is 32).
> - * @gpio_base: Starting GPIO base of this group (%0 if matches with @base,
> - * and %-1 if no GPIO mapping should be created)
> + * @gpio_base: Starting GPIO base of this group
> * @padown_num: PAD_OWN register number (assigned by the core driver)
> *
> * If pad groups of a community are not the same size, use this structure
> @@ -64,6 +63,8 @@ struct intel_padgroup {
> unsigned int reg_num;
> unsigned int base;
> unsigned int size;
> +#define INTEL_GPIO_BASE_MATCH 0 /* matches with @base */
> +#define INTEL_GPIO_BASE_NOMAP (-1) /* no GPIO mapping should be created */
Maybe use enum and add kernel-doc there?
> int gpio_base;
> unsigned int padown_num;
> };
> --
> 2.25.1
next prev parent reply other threads:[~2020-04-01 9:51 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-31 15:25 [PATCH v1 1/4] pinctrl: intel: Introduce common flags for GPIO mapping scheme Andy Shevchenko
2020-03-31 15:25 ` [PATCH v1 2/4] pinctrl: cannonlake: Use generic flag for special GPIO base treatment Andy Shevchenko
2020-03-31 15:25 ` [PATCH v1 3/4] pinctrl: icelake: " Andy Shevchenko
2020-03-31 15:25 ` [PATCH v1 4/4] pinctrl: tigerlake: " Andy Shevchenko
2020-04-01 9:51 ` Mika Westerberg [this message]
2020-04-01 12:56 ` [PATCH v1 1/4] pinctrl: intel: Introduce common flags for GPIO mapping scheme Andy Shevchenko
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=20200401095142.GS2564@lahna.fi.intel.com \
--to=mika.westerberg@linux.intel.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.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.