diff mbox series

[v2] spi: nxp-fspi: Add 1us delay to make controller ready for next transaction

Message ID 1587450467-19721-1-git-send-email-kuldeep.singh@nxp.com
State New
Headers show
Series [v2] spi: nxp-fspi: Add 1us delay to make controller ready for next transaction | expand

Commit Message

Kuldeep Singh April 21, 2020, 6:27 a.m. UTC
Board gets reset when performing burst read/write operations. On the
other hand, no such behaviour is observed on small size operations.

In Linux, readl_poll_timeout API already add delay of 1us which is
skipped in U-boot. Since, NXP Flexspi U-boot driver is a ported version
of Linux driver and U-boot poll_timeout API lacks delay functionality,
add 1us delay so as to make controller ready for other transactions.

Signed-off-by: Kuldeep Singh <kuldeep.singh at nxp.com>
---
v1: Add comments above udelay(1) change.

 drivers/spi/nxp_fspi.c | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Jagan Teki April 21, 2020, 8:14 a.m. UTC | #1
On Tue, Apr 21, 2020 at 11:57 AM Kuldeep Singh <kuldeep.singh at nxp.com> wrote:
>
> Board gets reset when performing burst read/write operations. On the
> other hand, no such behaviour is observed on small size operations.
>
> In Linux, readl_poll_timeout API already add delay of 1us which is
> skipped in U-boot. Since, NXP Flexspi U-boot driver is a ported version
> of Linux driver and U-boot poll_timeout API lacks delay functionality,
> add 1us delay so as to make controller ready for other transactions.

Can you link me, where  does Linux add this delay?

Jagan.
Kuldeep Singh April 21, 2020, 9:26 a.m. UTC | #2
> -----Original Message-----
> From: Jagan Teki <jagan at amarulasolutions.com>
> Sent: Tuesday, April 21, 2020 1:45 PM
> To: Kuldeep Singh <kuldeep.singh at nxp.com>
> Cc: U-Boot-Denx <u-boot at lists.denx.de>
> Subject: [EXT] Re: [Patch v2] spi: nxp-fspi: Add 1us delay to make controller
> ready for next transaction
> 
> Caution: EXT Email
> 
> On Tue, Apr 21, 2020 at 11:57 AM Kuldeep Singh <mailto:kuldeep.singh at nxp.com>
> wrote:
> >
> > Board gets reset when performing burst read/write operations. On the
> > other hand, no such behaviour is observed on small size operations.
> >
> > In Linux, readl_poll_timeout API already add delay of 1us which is
> > skipped in U-boot. Since, NXP Flexspi U-boot driver is a ported
> > version of Linux driver and U-boot poll_timeout API lacks delay
> > functionality, add 1us delay so as to make controller ready for other
> transactions.
> 
> Can you link me, where  does Linux add this delay?

Please see[1] for Linux nxp flexspi driver code.
fspi_readl_poll_tout, line: 795

If you see implementation of " fspi_readl_poll_tout ", it further calls "readl_poll_timeout" which includes delay of 1us.
And also please see the difference of "readl_poll_timeout" api implementation in uboot and Linux.
This api adds delay in Linux but skips it in uboot.

Thanks
Kuldeep
[1] https://elixir.bootlin.com/linux/latest/source/drivers/spi/spi-nxp-fspi.c
Jagan Teki April 25, 2020, 11:37 a.m. UTC | #3
On Tue, Apr 21, 2020 at 2:56 PM Kuldeep Singh <kuldeep.singh at nxp.com> wrote:
>
>
>
> > -----Original Message-----
> > From: Jagan Teki <jagan at amarulasolutions.com>
> > Sent: Tuesday, April 21, 2020 1:45 PM
> > To: Kuldeep Singh <kuldeep.singh at nxp.com>
> > Cc: U-Boot-Denx <u-boot at lists.denx.de>
> > Subject: [EXT] Re: [Patch v2] spi: nxp-fspi: Add 1us delay to make controller
> > ready for next transaction
> >
> > Caution: EXT Email
> >
> > On Tue, Apr 21, 2020 at 11:57 AM Kuldeep Singh <mailto:kuldeep.singh at nxp.com>
> > wrote:
> > >
> > > Board gets reset when performing burst read/write operations. On the
> > > other hand, no such behaviour is observed on small size operations.
> > >
> > > In Linux, readl_poll_timeout API already add delay of 1us which is
> > > skipped in U-boot. Since, NXP Flexspi U-boot driver is a ported
> > > version of Linux driver and U-boot poll_timeout API lacks delay
> > > functionality, add 1us delay so as to make controller ready for other
> > transactions.
> >
> > Can you link me, where  does Linux add this delay?
>
> Please see[1] for Linux nxp flexspi driver code.
> fspi_readl_poll_tout, line: 795
>
> If you see implementation of " fspi_readl_poll_tout ", it further calls "readl_poll_timeout" which includes delay of 1us.
> And also please see the difference of "readl_poll_timeout" api implementation in uboot and Linux.
> This api adds delay in Linux but skips it in uboot.

Yes, it worked for myself also. so please use the new api which I have
introduced on this series [2]

[2] https://patchwork.ozlabs.org/project/uboot/patch/20200425110354.12381-3-jagan at amarulasolutions.com/
Kuldeep Singh April 27, 2020, 5:33 a.m. UTC | #4
> > If you see implementation of " fspi_readl_poll_tout ", it further calls
> "readl_poll_timeout" which includes delay of 1us.
> > And also please see the difference of "readl_poll_timeout" api
> implementation in uboot and Linux.
> > This api adds delay in Linux but skips it in uboot.
> 
> Yes, it worked for myself also. so please use the new api which I have
> introduced on this series [2]

Thanks Jagan for the new API. I will respin this patch.

-Kuldeep
diff mbox series

Patch

diff --git a/drivers/spi/nxp_fspi.c b/drivers/spi/nxp_fspi.c
index 0e6c7be..1c6538c 100644
--- a/drivers/spi/nxp_fspi.c
+++ b/drivers/spi/nxp_fspi.c
@@ -757,6 +757,13 @@  static int nxp_fspi_exec_op(struct spi_slave *slave,
 				   FSPI_STS0_ARB_IDLE, 1, POLL_TOUT, true);
 	WARN_ON(err);
 
+	/*
+	 * Watchdog gets triggered for large read/write/erase since this
+	 * delay is not present in this API(readl_poll_timeout), add
+	 * this delay here.
+	 */
+	udelay(1);
+
 	nxp_fspi_prepare_lut(f, op);
 	/*
 	 * If we have large chunks of data, we read them through the AHB bus