Skip to content

Commit

Permalink
spi: bcm2835: Increase the CS limit to 24
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
pelwell committed Apr 30, 2021
1 parent d12a224 commit 05f8d58
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion drivers/spi/spi-bcm2835.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <linux/gpio/consumer.h>
#include <linux/gpio/machine.h> /* FIXME: using chip internals */
#include <linux/gpio/driver.h> /* FIXME: using chip internals */
#include <linux/of_gpio.h>
#include <linux/of_irq.h>
#include <linux/spi/spi.h>

Expand Down Expand Up @@ -68,7 +69,7 @@
#define BCM2835_SPI_FIFO_SIZE 64
#define BCM2835_SPI_FIFO_SIZE_3_4 48
#define BCM2835_SPI_DMA_MIN_LENGTH 96
#define BCM2835_SPI_NUM_CS 4 /* raise as necessary */
#define BCM2835_SPI_NUM_CS 24 /* more than enough */
#define BCM2835_SPI_MODE_BITS (SPI_CPOL | SPI_CPHA | SPI_CS_HIGH \
| SPI_NO_CS | SPI_3WIRE)

Expand Down Expand Up @@ -1292,6 +1293,11 @@ static int bcm2835_spi_probe(struct platform_device *pdev)
struct bcm2835_spi *bs;
int err;

if (of_gpio_named_count(pdev->dev.of_node, "cs-gpios") >
BCM2835_SPI_NUM_CS)
return dev_err_probe(&pdev->dev, -EINVAL,
"too many chip selects\n");

ctlr = devm_spi_alloc_master(&pdev->dev, ALIGN(sizeof(*bs),
dma_get_cache_alignment()));
if (!ctlr)
Expand Down

1 comment on commit 05f8d58

@jabjoe
Copy link
Contributor

@jabjoe jabjoe commented on 05f8d58 Apr 30, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yer that works. No limit is really required, but 24 is pretty high and this is less work than upstream are asking for where there arrays are moved and every SPI device has it's own data structure instead.

Please sign in to comment.