Skip to content

Commit e19c127

Browse files
ffainellibroonie
authored andcommitted
spi: bcm2835: Restore native CS probing when pinctrl-bcm2835 is absent
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. 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: 21f252c ("spi: bcm2835: reduce the abuse of the GPIO API") Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com> Link: https://patch.msgid.link/20250401233603.2938955-1-florian.fainelli@broadcom.com Acked-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org> Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent d669101 commit e19c127

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

drivers/spi/spi-bcm2835.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1226,7 +1226,12 @@ static int bcm2835_spi_setup(struct spi_device *spi)
12261226
struct bcm2835_spi *bs = spi_controller_get_devdata(ctlr);
12271227
struct bcm2835_spidev *target = spi_get_ctldata(spi);
12281228
struct gpiod_lookup_table *lookup __free(kfree) = NULL;
1229-
int ret;
1229+
const char *pinctrl_compats[] = {
1230+
"brcm,bcm2835-gpio",
1231+
"brcm,bcm2711-gpio",
1232+
"brcm,bcm7211-gpio",
1233+
};
1234+
int ret, i;
12301235
u32 cs;
12311236

12321237
if (!target) {
@@ -1291,6 +1296,14 @@ static int bcm2835_spi_setup(struct spi_device *spi)
12911296
goto err_cleanup;
12921297
}
12931298

1299+
for (i = 0; i < ARRAY_SIZE(pinctrl_compats); i++) {
1300+
if (of_find_compatible_node(NULL, NULL, pinctrl_compats[i]))
1301+
break;
1302+
}
1303+
1304+
if (i == ARRAY_SIZE(pinctrl_compats))
1305+
return 0;
1306+
12941307
/*
12951308
* TODO: The code below is a slightly better alternative to the utter
12961309
* abuse of the GPIO API that I found here before. It creates a

0 commit comments

Comments
 (0)