spi: bcm2835: Support spi0-0cs and SPI_NO_CS mode

The forced conversion of native CS lines into software CS lines is done
whether or not the controller has been given any CS lines to use. This
breaks the use of the spi0-0cs overlay to prevent SPI from claiming any
CS lines, particularly with spidev which doesn't pass in the SPI_NO_CS
flag at creation.

Use the presence of an empty cs-gpios property as an indication that no
CS lines should be used, bypassing the native CS conversion code.

See: https://github.com/raspberrypi/linux/issues/5835

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
This commit is contained in:
Phil Elwell
2024-01-08 11:42:57 +00:00
committed by Dom Cobley
parent d704c3160c
commit ad6bc36e60

View File

@@ -1232,6 +1232,7 @@ static int bcm2835_spi_setup(struct spi_device *spi)
"brcm,bcm7211-gpio",
};
int ret, i;
int len;
u32 cs;
if (!target) {
@@ -1304,6 +1305,10 @@ static int bcm2835_spi_setup(struct spi_device *spi)
if (i == ARRAY_SIZE(pinctrl_compats))
return 0;
/* Skip forced CS conversion if controller has an empty cs-gpios property */
if (of_find_property(ctlr->dev.of_node, "cs-gpios", &len) && len == 0)
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