From: Florian Fainelli <florian.fainelli@broadcom.com>
To: Bartosz Golaszewski <brgl@bgdev.pl>
Cc: linux-kernel@vger.kernel.org, Mark Brown <broonie@kernel.org>,
Ray Jui <rjui@broadcom.com>,
Scott Branden <sbranden@broadcom.com>,
Broadcom internal kernel review list
<bcm-kernel-feedback-list@broadcom.com>,
Linus Walleij <linus.walleij@linaro.org>,
Bartosz Golaszewski <bartosz.golaszewski@linaro.org>,
"open list:SPI SUBSYSTEM" <linux-spi@vger.kernel.org>,
"moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE"
<linux-rpi-kernel@lists.infradead.org>,
"moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE"
<linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH] spi: bcm2835: Restore native CS probing when pinctrl-bcm2835 is absent
Date: Wed, 2 Apr 2025 09:04:14 -0700 [thread overview]
Message-ID: <92d95675-5d4a-4bc1-b2a2-8f2f1668a640@broadcom.com> (raw)
In-Reply-To: <CAMRc=MeiALzO3XAmH9BLjxrB3EA1br1tpzHd5Qucw2NCVQ2q7g@mail.gmail.com>
On 4/2/25 04:44, Bartosz Golaszewski wrote:
> On Wed, Apr 2, 2025 at 1:37 AM Florian Fainelli
> <florian.fainelli@broadcom.com> wrote:
>>
>> The lookup table forces the use of the "pinctrl-bcm2835" GPIO chip
>> provider and essentially assumes that there is going to be such a
>> provider, and if not, we will fail to set-up the SPI device.
>>
>
> Yeah, the consumer driver itself is an unfortunate place to define the
> provider data. This could potentially be moved to gpiolib-of.c quirks.
>
>> While this is true on Raspberry Pi based systems (2835/36/37, 2711,
>> 2712), this is not true on 7712/77122 Broadcom STB systems which use the
>> SPI driver, but not the GPIO driver.
>>
>> There used to be an early check:
>>
>> chip = gpiochip_find("pinctrl-bcm2835", chip_match_name);
>> if (!chip)
>> return 0;
>>
>> which would accomplish that nicely, bring something similar back by
>> checking for the compatible strings matched by the pinctrl-bcm2835.c
>> driver, if there is no Device Tree node matching those compatible
>> strings, then we won't find any GPIO provider registered by the
>> "pinctrl-bcm2835" driver.
>>
>> Fixes: 21f252cd29f0 ("spi: bcm2835: reduce the abuse of the GPIO API")
>> Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com>
>> ---
>> drivers/spi/spi-bcm2835.c | 15 ++++++++++++++-
>> 1 file changed, 14 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/spi/spi-bcm2835.c b/drivers/spi/spi-bcm2835.c
>> index a5d621b94d5e..5926e004d9a6 100644
>> --- a/drivers/spi/spi-bcm2835.c
>> +++ b/drivers/spi/spi-bcm2835.c
>> @@ -1226,7 +1226,12 @@ static int bcm2835_spi_setup(struct spi_device *spi)
>> struct bcm2835_spi *bs = spi_controller_get_devdata(ctlr);
>> struct bcm2835_spidev *target = spi_get_ctldata(spi);
>> struct gpiod_lookup_table *lookup __free(kfree) = NULL;
>> - int ret;
>> + const char *pinctrl_compats[] = {
>> + "brcm,bcm2835-gpio",
>> + "brcm,bcm2711-gpio",
>> + "brcm,bcm7211-gpio",
>> + };
>> + int ret, i;
>> u32 cs;
>>
>> if (!target) {
>> @@ -1291,6 +1296,14 @@ static int bcm2835_spi_setup(struct spi_device *spi)
>> goto err_cleanup;
>> }
>>
>> + for (i = 0; i < ARRAY_SIZE(pinctrl_compats); i++) {
>> + if (of_find_compatible_node(NULL, NULL, pinctrl_compats[i]))
>> + break;
>> + }
>> +
>> + if (i == ARRAY_SIZE(pinctrl_compats))
>> + return 0;
>> +
>> /*
>> * TODO: The code below is a slightly better alternative to the utter
>> * abuse of the GPIO API that I found here before. It creates a
>> --
>> 2.34.1
>>
>>
>
> The fix is good for now but I'd still try to move this out of the
> driver at some point.
>
> Acked-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Thanks, I will see what I can do on that front, but if you don't hear
from me in the next few weeks, don't hesitate to ask again :)
--
Florian
next prev parent reply other threads:[~2025-04-02 16:04 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-01 23:36 [PATCH] spi: bcm2835: Restore native CS probing when pinctrl-bcm2835 is absent Florian Fainelli
2025-04-02 11:44 ` Bartosz Golaszewski
2025-04-02 16:04 ` Florian Fainelli [this message]
2025-04-02 15:20 ` Mark Brown
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=92d95675-5d4a-4bc1-b2a2-8f2f1668a640@broadcom.com \
--to=florian.fainelli@broadcom.com \
--cc=bartosz.golaszewski@linaro.org \
--cc=bcm-kernel-feedback-list@broadcom.com \
--cc=brgl@bgdev.pl \
--cc=broonie@kernel.org \
--cc=linus.walleij@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rpi-kernel@lists.infradead.org \
--cc=linux-spi@vger.kernel.org \
--cc=rjui@broadcom.com \
--cc=sbranden@broadcom.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox