2024-04-16 15:59:30

by Serge Semin

[permalink] [raw]
Subject: [PATCH RESEND v3 0/4] spi: dw: Auto-detect number of native CS

The main goal of the short series is to provide a procedure implementing
the auto-detection of the number of native Chip-Select signals supported
by the controller. The suggested algorithm is straightforward. It relies
on the fact that the SER register writable flags reflects the actual
number of available native chip-select signals. So the DW APB/AHB SSI
driver now tests the SER register for having the writable bits,
calculates the number of CS signals based on the number of set flags and
then initializes the num_cs private data field based on that, which then
will be passed to the SPI-core subsystem indicating the number of
supported hardware chip-selects. The implemented procedure will be useful
for the DW SSI device nodes not having the explicitly set "num-cs"
property. In case if the property is specified it will be utilized instead
of the auto-detection procedure.

Besides of that a small cleanup patch is introduced in the head of the
series. It converts the driver to using the BITS_TO_BYTES() macro instead
of the hard-coded DIV_ROUND_UP()-based calculation of the number of
bytes-per-transfer-word.

Link: https://lore.kernel.org/linux-spi/[email protected]
Changelog v2:
- Add a new patch:
[PATCH v2 3/4] spi: dw: Convert dw_spi::num_cs to u32
- Fix some spelling notes (@Andy).

Link: https://lore.kernel.org/linux-spi/[email protected]/
Changelog v3:
- Add Andy' Rb tag.
- Rebase onto the kernel v6.9 and resubmit.

Signed-off-by: Serge Semin <[email protected]>
Cc: Andy Shevchenko <[email protected]>
Cc: Andy Shevchenko <[email protected]>
Cc: [email protected]
Cc: [email protected]

Serge Semin (4):
spi: dw: Convert to using BITS_TO_BYTES() macro
spi: dw: Add a number of native CS auto-detection
spi: dw: Convert dw_spi::num_cs to u32
spi: dw: Drop default number of CS setting

drivers/spi/spi-dw-core.c | 20 ++++++++++++++++----
drivers/spi/spi-dw-mmio.c | 8 ++------
drivers/spi/spi-dw.h | 2 +-
3 files changed, 19 insertions(+), 11 deletions(-)

--
2.43.0



2024-04-16 16:00:30

by Serge Semin

[permalink] [raw]
Subject: [PATCH RESEND v3 3/4] spi: dw: Convert dw_spi::num_cs to u32

Number of native chip-select lines is either retrieved from the "num-cs"
DT-property or auto-detected in the generic DW APB/AHB SSI probe method.
In the former case the property is supposed to be of the "u32" size.
Convert the field type to being u32 then to be able to drop the temporary
variable afterwards.

Signed-off-by: Serge Semin <[email protected]>
Reviewed-by: Andy Shevchenko <[email protected]>

---

Changelog v2:
- Just added.
---
drivers/spi/spi-dw.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/spi/spi-dw.h b/drivers/spi/spi-dw.h
index 6cafeee8ee2a..fc267c6437ae 100644
--- a/drivers/spi/spi-dw.h
+++ b/drivers/spi/spi-dw.h
@@ -164,8 +164,8 @@ struct dw_spi {
u32 max_freq; /* max bus freq supported */

u32 reg_io_width; /* DR I/O width in bytes */
+ u32 num_cs; /* chip select lines */
u16 bus_num;
- u16 num_cs; /* supported slave numbers */
void (*set_cs)(struct spi_device *spi, bool enable);

/* Current message transfer state info */
--
2.43.0