Re: [PATCH] spi: atmel: Fix CS and initialization bug

From: Dan.Sneddon
Date: Tue Jun 29 2021 - 13:02:06 EST


On 6/29/21 9:47 AM, Mark Brown wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
>
> On Tue, Jun 29, 2021 at 09:29:14AM -0700, Dan Sneddon wrote:
>
>> spi_setup won't get programmed into the hardware. This patch makes
>> sure the cs_activate call is made even with a gpio controlled chip
>> select.
>
>In what way does it do that? I can't tell what the patch is supposed >to
>do.

The SPI_MASTER_GPIO_SS flag has to be set so that the set_cs function
gets called even when using gpio cs pins.

>
>> - enable =3D (!!(spi->mode & SPI_CS_HIGH) =3D=3D enable);
>> =20
>> - if (enable) {
>> + if ((enable && (spi->mode & SPI_CS_HIGH))
>> + || (!enable && !(spi->mode & SPI_CS_HIGH))) {
>
>This looks especially suspicious.
It's due to the fact that the spi core tells set_cs if the cs should be
high or low, not active or disabled. This logic is to convert from
high/low to active/disabled.