Re: [PATCH v4 8/9] spi: spi-engine-ex: Add support for multi-CS devices

From: Andy Shevchenko

Date: Wed Oct 21 2026 - 11:20:12 EST


On Tue, Oct 20, 2026 at 10:58:37PM -0300, Jonathan Santos wrote:
> The SPI Engine controller only handled the first chip select when
> asserting CS lines and configuring CS polarity inversion, ignoring
> additional CS indices present in cs_index_mask.
>
> Update spi_engine_gen_cs() to iterate over all set bits in
> cs_index_mask and toggle each corresponding CS line in the assert mask.
> Update spi_engine_setup() likewise so that SPI_CS_HIGH polarity is
> applied to every active CS index rather than only index 0.
>
> Set SPI_CONTROLLER_MULTI_CS in the controller flags to reflect the
> capability to the SPI core.

...

> +static unsigned long spi_engine_get_chipselect_bits(struct spi_device *spi,
> + unsigned long index_mask)
> +{
> + unsigned long bits = 0;
> + unsigned int idx;
> +
> + for_each_set_bit(idx, &index_mask, SPI_DEVICE_CS_CNT_MAX)
> + bits |= BIT(spi_get_chipselect(spi, idx));
> +
> + return bits;
> +}

Since the chipselects are in a sequential range, wouldn't that repeat one of
bitmap_gather() / bitmap_scatter()?

--
With Best Regards,
Andy Shevchenko