bcm27xx: add kernel 5.10 support
[openwrt/openwrt.git] / target / linux / bcm27xx / patches-5.10 / 950-0595-spi-bcm2835-Increase-the-CS-limit-to-24.patch
1 From c3fbb1e6771dabb14571552c036a049ffa470eb1 Mon Sep 17 00:00:00 2001
2 From: Phil Elwell <phil@raspberrypi.com>
3 Date: Fri, 30 Apr 2021 08:34:36 +0100
4 Subject: [PATCH] spi: bcm2835: Increase the CS limit to 24
5
6 Increase the maximum number of CS lines to 24, and ensure this limit is
7 not exceeded.
8
9 See: https://github.com/raspberrypi/linux/pull/4281
10
11 Suggested-by: Joe Burmeister <joe.burmeister@devtank.co.uk>
12 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
13 ---
14 drivers/spi/spi-bcm2835.c | 6 ++++++
15 1 file changed, 6 insertions(+)
16
17 --- a/drivers/spi/spi-bcm2835.c
18 +++ b/drivers/spi/spi-bcm2835.c
19 @@ -28,6 +28,7 @@
20 #include <linux/gpio/consumer.h>
21 #include <linux/gpio/machine.h> /* FIXME: using chip internals */
22 #include <linux/gpio/driver.h> /* FIXME: using chip internals */
23 +#include <linux/of_gpio.h>
24 #include <linux/of_irq.h>
25 #include <linux/spi/spi.h>
26
27 @@ -1299,6 +1300,11 @@ static int bcm2835_spi_probe(struct plat
28 struct bcm2835_spi *bs;
29 int err;
30
31 + if (of_gpio_named_count(pdev->dev.of_node, "cs-gpios") >
32 + BCM2835_SPI_NUM_CS)
33 + return dev_err_probe(&pdev->dev, -EINVAL,
34 + "too many chip selects\n");
35 +
36 ctlr = devm_spi_alloc_master(&pdev->dev, ALIGN(sizeof(*bs),
37 dma_get_cache_alignment()));
38 if (!ctlr)