Skip to content

Commit 05f8d58

Browse files
committed
spi: bcm2835: Increase the CS limit to 24
Increase the maximum number of CS lines to 24, and ensure this limit is not exceeded. See: #4281 Suggested-by: Joe Burmeister <joe.burmeister@devtank.co.uk> Signed-off-by: Phil Elwell <phil@raspberrypi.com>
1 parent d12a224 commit 05f8d58

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

drivers/spi/spi-bcm2835.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include <linux/gpio/consumer.h>
2929
#include <linux/gpio/machine.h> /* FIXME: using chip internals */
3030
#include <linux/gpio/driver.h> /* FIXME: using chip internals */
31+
#include <linux/of_gpio.h>
3132
#include <linux/of_irq.h>
3233
#include <linux/spi/spi.h>
3334

@@ -68,7 +69,7 @@
6869
#define BCM2835_SPI_FIFO_SIZE 64
6970
#define BCM2835_SPI_FIFO_SIZE_3_4 48
7071
#define BCM2835_SPI_DMA_MIN_LENGTH 96
71-
#define BCM2835_SPI_NUM_CS 4 /* raise as necessary */
72+
#define BCM2835_SPI_NUM_CS 24 /* more than enough */
7273
#define BCM2835_SPI_MODE_BITS (SPI_CPOL | SPI_CPHA | SPI_CS_HIGH \
7374
| SPI_NO_CS | SPI_3WIRE)
7475

@@ -1292,6 +1293,11 @@ static int bcm2835_spi_probe(struct platform_device *pdev)
12921293
struct bcm2835_spi *bs;
12931294
int err;
12941295

1296+
if (of_gpio_named_count(pdev->dev.of_node, "cs-gpios") >
1297+
BCM2835_SPI_NUM_CS)
1298+
return dev_err_probe(&pdev->dev, -EINVAL,
1299+
"too many chip selects\n");
1300+
12951301
ctlr = devm_spi_alloc_master(&pdev->dev, ALIGN(sizeof(*bs),
12961302
dma_get_cache_alignment()));
12971303
if (!ctlr)

0 commit comments

Comments
 (0)