All of lore.kernel.org
 help / color / mirror / Atom feed
From: Florian Fainelli <f.fainelli@gmail.com>
To: Stefan Wahren <stefan.wahren@i2se.com>,
	"linus.walleij" <linus.walleij@linaro.org>,
	linux-arm-kernel <linux-arm-kernel@lists.infradead.org>
Cc: Phil Elwell <phil@raspberrypi.com>
Subject: Re: DTB backward/forward compatibility with "pinctrl: bcm2835: Change init order for gpio hogs"
Date: Tue, 8 Mar 2022 17:10:25 -0800	[thread overview]
Message-ID: <223c0109-5d64-0f2b-e412-4afd4cfbc20b@gmail.com> (raw)
In-Reply-To: <75266ed1-666a-138b-80f1-ae9a06b7bdf3@i2se.com>

On 3/8/22 11:13 AM, Stefan Wahren wrote:
> Am 07.03.22 um 12:38 schrieb Stefan Wahren:
>> Hi,
>>
>> Am 06.03.22 um 17:54 schrieb Florian Fainelli:
>>> Hi Stefan,
>>>
>>> On 3/6/2022 7:03 AM, Stefan Wahren wrote:
>>>> Hi Florian,
>>>>
>>>> it seems that other platform stumbled on the same issue:
>>>>
>>>> https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?h=next-20220304&id=9b4924da4711674e62d97d4f5360446cc78337af
>>>>
>>>>
>>>> https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?h=next-20220304&id=7ed07855773814337b9814f1c3e866df52ebce68
>>>>
>>>>
>>>> I will try to prepare a patch.
>>> Thank you! Do you think we could have a core function expose which
>>> would do essentially avoid drivers having to sprinkle checks for the
>>> absence of a 'gpio-ranges' property?
>> unfortunately my first attempts to implement it similiar to the
>> solutions above failed. I read the explanations from the original fix
>> from Christian Lamparter [1] and from my understanding the backward
>> compatibility must be implemented into gpiochip_add_data() or a variant.
>> Before the gpiochip is not registered and afterwards it would be too late.
>>
>> My test scenario (worst case) is an additional gpio hog for the
>> Raspberry Pi 3 B with removed gpio-ranges:
>>
> Not sure this is the right place, but the following hack make the
> Raspberry Pi boot for the defined worst case szenario (no gpio-ranges
> but at least one gpio-hog):

This worked with 'gpio-ranges' as well as without a 'gpio-ranges', the
kernel did warn as you added the message:

[    0.588730] /rdb/gpio@2200000: gpio-ranges missing. Try to fallback!

and gpio-ranges was the same before/after the patch:

# cat /sys/kernel/debug/pinctrl/47e200000.gpio-pinctrl-bcm2711/gpio-ranges
GPIO ranges handled:
0: pinctrl-bcm2711 GPIOS [4294967295 - 56] PINS [0 - 57]
0: pinctrl-bcm2711 GPIOS [454 - 511] PINS [0 - 57]
#


thanks a lot Stefan!

> 
> diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c
> 
> index 91dcf2c..23386dd 100644
> --- a/drivers/gpio/gpiolib-of.c
> +++ b/drivers/gpio/gpiolib-of.c
> @@ -933,6 +933,24 @@ static int of_gpiochip_add_pin_range(struct
> gpio_chip *chip
> )
>         if (!np)
>                 return 0;
>  
> +       if (!of_property_read_bool(np, "gpio-ranges")) {
> +               pr_warn("%pOF: gpio-ranges missing. Try to fallback!\n",
> np);
> +
> +               pctldev = of_pinctrl_get(np);
> +               of_node_put(np);
> +
> +               if (!pctldev)
> +                       return 0;
> +
> +               gpiochip_add_pin_range(chip,
> +                               pinctrl_dev_get_devname(pctldev),
> +                               0,
> +                               0,
> +                               chip->ngpio);
> +
> +               return 0;
> +       }
> +
>         group_names = of_find_property(np, group_names_propname, NULL);
>  
>         for (;; index++) {
> 


-- 
Florian

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

      reply	other threads:[~2022-03-09  1:11 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-25 19:39 DTB backward/forward compatibility with "pinctrl: bcm2835: Change init order for gpio hogs" Florian Fainelli
2022-01-25 19:48 ` Phil Elwell
2022-01-25 19:58   ` Florian Fainelli
2022-01-26  1:33     ` Florian Fainelli
2022-01-27 16:31       ` Stefan Wahren
2022-03-06 15:03         ` Stefan Wahren
2022-03-06 16:54           ` Florian Fainelli
2022-03-06 17:58             ` Stefan Wahren
2022-03-07 11:38             ` Stefan Wahren
2022-03-08 19:13               ` Stefan Wahren
2022-03-09  1:10                 ` Florian Fainelli [this message]

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=223c0109-5d64-0f2b-e412-4afd4cfbc20b@gmail.com \
    --to=f.fainelli@gmail.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=phil@raspberrypi.com \
    --cc=stefan.wahren@i2se.com \
    /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.