[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250616220054.3968946-5-sean.anderson@linux.dev>
Date: Mon, 16 Jun 2025 18:00:49 -0400
From: Sean Anderson <sean.anderson@...ux.dev>
To: Mark Brown <broonie@...nel.org>,
Michal Simek <michal.simek@....com>,
linux-spi@...r.kernel.org
Cc: Jinjie Ruan <ruanjinjie@...wei.com>,
Miquel Raynal <miquel.raynal@...tlin.com>,
linux-arm-kernel@...ts.infradead.org,
linux-kernel@...r.kernel.org,
David Lechner <dlechner@...libre.com>,
Amit Kumar Mahapatra <amit.kumar-mahapatra@....com>,
Sean Anderson <sean.anderson@...ux.dev>
Subject: [PATCH v2 4/9] spi: Add flag to determine default bus
The ZynqMP GQSPI driver determines the default SPI bus based on the chip
select. For compatibility, introduce a flag to determine the buses from
the chipselect when the spi-buses property is absent.
Signed-off-by: Sean Anderson <sean.anderson@...ux.dev>
---
Changes in v2:
- New
drivers/spi/spi.c | 7 ++++++-
include/linux/spi/spi.h | 2 ++
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 9fbf069623a8..d9d0c24cee0b 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -2470,7 +2470,12 @@ static int of_spi_parse_dt(struct spi_controller *ctlr, struct spi_device *spi,
if (rc == -EINVAL) {
/* Default when property is omitted. */
- spi->buses = BIT(0);
+ if ((ctlr->flags & SPI_CONTROLLER_DEFAULT_BUS_IS_CS) &&
+ cs[0] != SPI_INVALID_CS && cs[0] < ctlr->num_buses) {
+ spi->buses = BIT(cs[0]);
+ } else {
+ spi->buses = BIT(0);
+ }
} else {
for (idx = 0; idx < rc; idx++) {
if (buses[idx] >= ctlr->num_buses) {
diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h
index 70e8e6555a33..cea93b0895b9 100644
--- a/include/linux/spi/spi.h
+++ b/include/linux/spi/spi.h
@@ -621,6 +621,8 @@ struct spi_controller {
* assert/de-assert more than one chip select at once.
*/
#define SPI_CONTROLLER_MULTI_CS BIT(7)
+ /* spi_device->buses defaults to spi_device->cs[0] */
+#define SPI_CONTROLLER_DEFAULT_BUS_IS_CS BIT(8)
/* Flag indicating if the allocation of this struct is devres-managed */
bool devm_allocated;
--
2.35.1.1320.gc452695387.dirty
Powered by blists - more mailing lists