[PATCH] spi: add STM32 SPI controller driver

Antony Pavlov antonynpavlov at gmail.com
Fri Nov 19 00:36:26 PST 2021


On Thu, 18 Nov 2021 13:32:18 +0100
Ahmad Fatoum <a.fatoum at pengutronix.de> wrote:

Hi Ahmad!

> On 08.11.21 18:01, Antony Pavlov wrote:
> > On Fri,  5 Nov 2021 08:46:57 +0100
> > Ahmad Fatoum <a.fatoum at pengutronix.de> wrote:
> > 
> >> Tested on a STM32MP1 communicating with a ksz9563.
> > 
> > ...
> > 
> >> diff --git a/drivers/spi/stm32_spi.c b/drivers/spi/stm32_spi.c
> >> new file mode 100644
> >> index 000000000000..0cb04a968c8a
> >> --- /dev/null
> >> +++ b/drivers/spi/stm32_spi.c
> >> @@ -0,0 +1,590 @@
> >> +// SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
> >> +/*
> >> + * Copyright (C) 2019, STMicroelectronics - All Rights Reserved
> >> + *
> >> + * Driver for STMicroelectronics Serial peripheral interface (SPI)
> >> + */
> >> +
> > 
> > ...
> > 
> >> +/* STM32_SPI_CR2 bit fields */
> >> +#define SPI_CR2_TSIZE		GENMASK(15, 0)
> > 
> > So SPI_CR2_TSIZE is (64K - 1)
> > 
> > ...
> > 
> >> +
> >> +static int stm32_spi_transfer_one(struct stm32_spi_priv *priv,
> >> +				  struct spi_transfer *t)
> >> +{
> >> +	struct device_d *dev = priv->master.dev;
> >> +	u32 sr;
> >> +	u32 ifcr = 0;
> >> +	u32 mode;
> >> +	int xfer_status = 0;
> >> +
> >> +	if (t->len <= SPI_CR2_TSIZE)
> >> +		writel(t->len, priv->base + STM32_SPI_CR2);
> >> +	else
> >> +		return -EMSGSIZE;
> > 
> > So stm32_spi_transfer_one() can transfer no more than (64K - 1).
> > At the other hand imd tends to read more than  (64K - 1) from SPI flash, e.g.
> > 
> >   barebox:/ imd /dev/m25p0
> >   imd: error 90
> > 
> > Here is my solution for handling SPI flash by stm32 SPI driver (not tested on stm32):
> 
> Thanks for the input. I believe I have STM32 with a SPI flash, where
> I should be able to test this. I'll report back once I come around to it.
> 
> Can I have your Signed-off-by for this patch here?

Yes, please add my Signed-off-by for the patch.

-- 
Best regards,
  Antony Pavlov



More information about the barebox mailing list