From: Nicolas Ferre <nicolas.ferre-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>
To: Ludovic Desroches
<ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linus.walleij-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org
Cc: plagnioj-sclMFOaUSTBWk0Htik3J/w@public.gmane.org,
Alexandre Belloni
<alexandre.belloni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>,
Boris BREZILLON
<boris.brezillon-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
Subject: Re: [PATCH 1/2] pinctrl: at91: allow disabled gpio controllers
Date: Mon, 1 Dec 2014 14:59:34 +0100 [thread overview]
Message-ID: <547C7446.1090909@atmel.com> (raw)
In-Reply-To: <1417193367-12422-1-git-send-email-ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>
Le 28/11/2014 17:49, Ludovic Desroches a écrit :
> This patch allows to have gpio controller with status set to disabled.
>
> gpio_banks represents all the gpio banks available on the device whereas
> nbanks represents the gpio banks used. Having a disabled gpio controller
> involves that nbanks value is lower than gpio_banks and that some
> pointers in the gpio_chips array are NULL. This patch deals with these
> specific cases.
>
> Signed-off-by: Ludovic Desroches <ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>
Yes:
Acked-by: Nicolas Ferre <nicolas.ferre-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>
Linus, is it too late for 3.18? Otherwise, we can add this tag:
Cc: <stable-u79uwXL29TY76Z2rM5mHXA@public.gmane.org> # v3.18+
Bye,
> ---
>
> Hi,
>
> Without this patch, pinctrl is broken on sama5d4 because pinctrl-at91 doesn't
> support unused gpio bank.
>
>
> drivers/pinctrl/pinctrl-at91.c | 30 ++++++++++++++++++------------
> 1 file changed, 18 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/pinctrl/pinctrl-at91.c b/drivers/pinctrl/pinctrl-at91.c
> index 94643bb..95ae122 100644
> --- a/drivers/pinctrl/pinctrl-at91.c
> +++ b/drivers/pinctrl/pinctrl-at91.c
> @@ -981,7 +981,8 @@ static void at91_pinctrl_child_count(struct at91_pinctrl *info,
>
> for_each_child_of_node(np, child) {
> if (of_device_is_compatible(child, gpio_compat)) {
> - info->nbanks++;
> + if (of_device_is_available(child))
> + info->nbanks++;
> } else {
> info->nfunctions++;
> info->ngroups += of_get_child_count(child);
> @@ -1003,11 +1004,11 @@ static int at91_pinctrl_mux_mask(struct at91_pinctrl *info,
> }
>
> size /= sizeof(*list);
> - if (!size || size % info->nbanks) {
> + if (!size || size % gpio_banks) {
> dev_err(info->dev, "wrong mux mask array should be by %d\n", info->nbanks);
> return -EINVAL;
> }
> - info->nmux = size / info->nbanks;
> + info->nmux = size / gpio_banks;
>
> info->mux_mask = devm_kzalloc(info->dev, sizeof(u32) * size, GFP_KERNEL);
> if (!info->mux_mask) {
> @@ -1185,7 +1186,7 @@ static int at91_pinctrl_probe(struct platform_device *pdev)
> {
> struct at91_pinctrl *info;
> struct pinctrl_pin_desc *pdesc;
> - int ret, i, j, k;
> + int ret, i, j, k, ngpio_chips_enabled = 0;
>
> info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL);
> if (!info)
> @@ -1200,12 +1201,14 @@ static int at91_pinctrl_probe(struct platform_device *pdev)
> * to obtain references to the struct gpio_chip * for them, and we
> * need this to proceed.
> */
> - for (i = 0; i < info->nbanks; i++) {
> - if (!gpio_chips[i]) {
> - dev_warn(&pdev->dev, "GPIO chip %d not registered yet\n", i);
> - devm_kfree(&pdev->dev, info);
> - return -EPROBE_DEFER;
> - }
> + for (i = 0; i < gpio_banks; i++) {
> + if (gpio_chips[i])
> + ngpio_chips_enabled++;
> + }
> + if (ngpio_chips_enabled < info->nbanks) {
> + dev_warn(&pdev->dev, "All GPIO chips are not registered yet\n");
> + devm_kfree(&pdev->dev, info);
> + return -EPROBE_DEFER;
> }
>
> at91_pinctrl_desc.name = dev_name(&pdev->dev);
> @@ -1234,8 +1237,9 @@ static int at91_pinctrl_probe(struct platform_device *pdev)
> }
>
> /* We will handle a range of GPIO pins */
> - for (i = 0; i < info->nbanks; i++)
> - pinctrl_add_gpio_range(info->pctl, &gpio_chips[i]->range);
> + for (i = 0; i < gpio_banks; i++)
> + if (gpio_chips[i])
> + pinctrl_add_gpio_range(info->pctl, &gpio_chips[i]->range);
>
> dev_info(&pdev->dev, "initialized AT91 pinctrl driver\n");
>
> @@ -1681,6 +1685,8 @@ static void at91_gpio_probe_fixup(void)
>
> for (i = 0; i < gpio_banks; i++) {
> at91_gpio = gpio_chips[i];
> + if (!at91_gpio)
> + continue;
>
> /*
> * GPIO controller are grouped on some SoC:
>
--
Nicolas Ferre
--
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
next prev parent reply other threads:[~2014-12-01 13:59 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-28 16:49 [PATCH 1/2] pinctrl: at91: allow disabled gpio controllers Ludovic Desroches
[not found] ` <1417193367-12422-1-git-send-email-ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>
2014-11-28 16:49 ` [PATCH 2/2] ARM: at91/dt: sama5d4: add pioD controller Ludovic Desroches
2014-12-01 13:56 ` [PATCH 1/2] pinctrl: at91: allow disabled gpio controllers Linus Walleij
[not found] ` <CACRpkdbXuXyfwAyFTHVDGa4OS88KsHXZeDDAeXf6ZJ_JQmduoQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-12-01 14:39 ` Ludovic Desroches
2014-12-03 15:08 ` Ludovic Desroches
2014-12-05 10:17 ` Linus Walleij
[not found] ` <CACRpkdbkUUzVVMp14szY+vGNd+d+8bL066STh_XMGud-UsFBqA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-12-15 9:57 ` [PATCH RFC] pinctrl: at91 Ludovic Desroches
[not found] ` <1418637470-5839-1-git-send-email-ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>
2014-12-19 14:41 ` Nicolas Ferre
2015-01-06 9:37 ` Ludovic Desroches
2015-01-14 12:26 ` Linus Walleij
[not found] ` <CACRpkda9wTPcRy6nRGP08rDpHV=tRyYVuD80TeO2zFGzX+aJcg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-01-14 15:03 ` Ludovic Desroches
2015-01-19 10:12 ` Linus Walleij
[not found] ` <CACRpkdY6M=U-XA=Sd2DH6jVjCABUTSYq+oUs_DBy14M2tccrMw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-01-19 10:30 ` Ludovic Desroches
[not found] ` <20150119103046.GB19014-FuRPzXQv2LUWBfJKYY8PcdBPR1lH4CV8@public.gmane.org>
2015-01-19 10:54 ` Nicolas Ferre
2014-12-01 13:59 ` Nicolas Ferre [this message]
[not found] ` <547C7446.1090909-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>
2014-12-02 14:50 ` [PATCH 1/2] pinctrl: at91: allow disabled gpio controllers Linus Walleij
2015-01-14 20:45 ` Jean-Christophe PLAGNIOL-VILLARD
[not found] ` <20150114204512.GB14457-HVbc7XotTAhnXn40ka+A6Q@public.gmane.org>
2015-01-19 10:16 ` Linus Walleij
[not found] ` <CACRpkdZ0X_9TX_R7OJJxNynBq0gZd8i_iUE11VXtiKSN+uqpmQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-01-19 10:34 ` Ludovic Desroches
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=547C7446.1090909@atmel.com \
--to=nicolas.ferre-aife0yeh4naavxtiumwx3w@public.gmane.org \
--cc=alexandre.belloni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org \
--cc=boris.brezillon-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org \
--cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linus.walleij-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
--cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
--cc=ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org \
--cc=plagnioj-sclMFOaUSTBWk0Htik3J/w@public.gmane.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 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).