All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jagan Teki <jagan@amarulasolutions.com>
To: u-boot@lists.denx.de
Subject: [PATCH v3 15/17] mtd: spi-nor-core: Perform a Soft Reset on boot
Date: Wed, 13 May 2020 15:26:08 +0530	[thread overview]
Message-ID: <CAMty3ZAoc_ijAi-R9H7zaOReXkmwuJoE0+c+sm4Cg0F0oMt6Uw@mail.gmail.com> (raw)
In-Reply-To: <20200513085415.kmunxqxqkrimshbh@ti.com>

On Wed, May 13, 2020 at 2:24 PM Pratyush Yadav <p.yadav@ti.com> wrote:
>
> On 13/05/20 12:17PM, Jagan Teki wrote:
> > On Mon, Mar 30, 2020 at 9:16 PM Pratyush Yadav <p.yadav@ti.com> wrote:
> > >
> > > When the flash is handed to us in a stateful mode like 8D-8D-8D, it is
> > > difficult to detect the mode the flash is in. One option is to read SFDP
> > > in all modes and see which one gives the correct "SFDP" signature, but
> > > not all flashes support SFDP in 8D-8D-8D mode.
> > >
> > > Further, even if you detect the mode of the flash via SFDP, you still
> > > have the problem of actually reading the ID. The Read ID command is not
> > > standardized across flash vendors. Flashes can have different dummy
> > > cycles needed for reading the ID. Some flashes even expect a 4-byte
> > > dummy address with the Read ID command. All this information cannot be
> > > obtained from the SFDP table.
> > >
> > > So, perform a Software Reset sequence before reading the ID and
> > > initializing the flash. A Soft Reset will bring back the flash in its
> > > default protocol mode assuming no non-volatile configuration was set.
> > > This will let us detect the flash even if ROM hands it to us in Octal
> > > DTR mode.
> > >
> > > To accommodate cases where there is more than one flash on a board, and
> > > only one of them needs a soft reset, failure to reset is not made fatal,
> > > and we still try to read ID if possible.
> > >
> > > Signed-off-by: Pratyush Yadav <p.yadav@ti.com>
> > > ---
> > >  drivers/mtd/spi/Kconfig        | 11 +++++++++++
> > >  drivers/mtd/spi/spi-nor-core.c | 27 +++++++++++++++++++++++++++
> > >  2 files changed, 38 insertions(+)
> > >
> > > diff --git a/drivers/mtd/spi/Kconfig b/drivers/mtd/spi/Kconfig
> > > index 018e8c597e..38d509c568 100644
> > > --- a/drivers/mtd/spi/Kconfig
> > > +++ b/drivers/mtd/spi/Kconfig
> > > @@ -88,6 +88,17 @@ config SPI_FLASH_SFDP_SUPPORT
> > >          SPI NOR flashes using Serial Flash Discoverable Parameters (SFDP)
> > >          tables as per JESD216 standard.
> > >
> > > +config SPI_FLASH_SOFT_RESET
> > > +       bool "Software Reset support for SPI NOR flashes"
> > > +       help
> > > +        Enable support for xSPI Software Reset. It will be used to switch
> > > +        from Octal DTR mode to legacy mode to allow detecting flashes that
> > > +        are handed to us in Octal DTR mode. It is expected that if the config
> > > +        is enabled the flash supports the Soft Reset sequence and is booted in
> > > +        Octal DTR mode. Do not enable this config on flashes that are not
> > > +        supposed to be handed to U-Boot in Octal DTR mode, even if they _do_
> > > +        support the Soft Reset sequence.
> > > +
> > >  config SPI_FLASH_BAR
> > >         bool "SPI flash Bank/Extended address register support"
> > >         help
> > > diff --git a/drivers/mtd/spi/spi-nor-core.c b/drivers/mtd/spi/spi-nor-core.c
> > > index 52b3775035..3af2c6afa9 100644
> > > --- a/drivers/mtd/spi/spi-nor-core.c
> > > +++ b/drivers/mtd/spi/spi-nor-core.c
> > > @@ -2922,6 +2922,33 @@ int spi_nor_scan(struct spi_nor *nor)
> > >
> > >         nor->setup = spi_nor_default_setup;
> > >
> > > +#if defined(CONFIG_SPI_FLASH_SOFT_RESET)
> > > +       /*
> > > +        * When the flash is handed to us in a stateful mode like 8D-8D-8D, it
> > > +        * is difficult to detect the mode the flash is in. One option is to
> > > +        * read SFDP in all modes and see which one gives the correct "SFDP"
> > > +        * signature, but not all flashes support SFDP in 8D-8D-8D mode.
> > > +        *
> > > +        * Further, even if you detect the mode of the flash via SFDP, you
> > > +        * still have the problem of actually reading the ID. The Read ID
> > > +        * command is not standardized across flash vendors. Flashes can have
> > > +        * different dummy cycles needed for reading the ID. Some flashes even
> > > +        * expect a 4-byte dummy address with the Read ID command. All this
> > > +        * information cannot be obtained from the SFDP table.
> > > +        *
> > > +        * So, perform a Software Reset sequence before reading the ID and
> > > +        * initializing the flash. A Soft Reset will bring back the flash in
> > > +        * its default protocol mode assuming no non-volatile configuration was
> > > +        * set. This will let us detect the flash even if ROM hands it to us in
> > > +        * Octal DTR mode.
> > > +        *
> > > +        * To accommodate cases where there is more than one flash on a board,
> > > +        * and only one of them needs a soft reset, failure to reset is not
> > > +        * made fatal, and we still try to read ID if possible.
> > > +        */
> > > +       spi_nor_soft_reset(nor);
> > > +#endif /* CONFIG_SPI_FLASH_SOFT_RESET */
> >
> > Does it specific to a particular flash chip? I believe add flash chip
> > fixups would make more sense instead of having it like this.
>
> To run a flash fixup, we need to know which flash it is. But if ROM
> hands us the flash in 8D mode, we can't reliably detect the ID of the
> flash since the Read ID command differs from one flash to another. For
> example, on the Cypress S28 flash family, the Read ID command in 8D mode
> expects 4 dummy address bytes and 3 dummy cycles. But on the Micron
> MT35XU flashes, Read ID in 8D needs 0 address bytes and 8 dummy cycles.
>
> This works around the issue by issuing a soft reset command so even if
> the flash is in 8D mode, it gets switched back to 1S mode so we can
> detect it.

I got this from the commit message, thanks. Point I'm trying to
understand here about can't we detect soft reset of associate flash
via some bits in SFDP? if yes then we can dynamically process the soft
reset on associated flash like quad enable does?

Jagan.

  reply	other threads:[~2020-05-13  9:56 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-30 15:45 [PATCH v3 00/17] mtd: spi-nor-core: add xSPI Octal DTR support Pratyush Yadav
2020-03-30 15:45 ` [PATCH v3 01/17] spi: spi-mem: allow specifying whether an op is DTR or not Pratyush Yadav
2020-03-30 15:45 ` [PATCH v3 02/17] spi: spi-mem: allow specifying a command's extension Pratyush Yadav
2020-03-30 15:45 ` [PATCH v3 03/17] spi: cadence-qspi: Do not calibrate when device tree sets read delay Pratyush Yadav
2020-03-30 15:45 ` [PATCH v3 04/17] spi: cadence-qspi: Add support for octal DTR flashes Pratyush Yadav
2020-03-30 15:45 ` [PATCH v3 05/17] mtd: spi-nor-core: Add a ->setup() hook Pratyush Yadav
2020-03-30 15:45 ` [PATCH v3 06/17] mtd: spi-nor-core: Move SFDP related declarations to top Pratyush Yadav
2020-03-30 15:45 ` [PATCH v3 07/17] mtd: spi-nor-core: Introduce flash-specific fixup hooks Pratyush Yadav
2020-03-30 15:45 ` [PATCH v3 08/17] mtd: spi-nor-core: Rework hwcaps selection Pratyush Yadav
2020-03-30 15:45 ` [PATCH v3 09/17] mtd: spi-nor-core: Add support for DTR protocol Pratyush Yadav
2020-03-30 15:45 ` [PATCH v3 10/17] mtd: spi-nor-core: Get command opcode extension type from BFPT Pratyush Yadav
2020-05-18 14:31   ` Pragnesh Patel
2020-05-18 18:33     ` Pratyush Yadav
2020-03-30 15:45 ` [PATCH v3 11/17] mtd: spi-nor-core: Parse xSPI Profile 1.0 table Pratyush Yadav
2020-03-30 15:45 ` [PATCH v3 12/17] mtd: spi-nor-core: Prepare Read SR and FSR for Octal DTR mode Pratyush Yadav
2020-03-30 15:45 ` [PATCH v3 13/17] mtd: spi-nor-core: Enable octal DTR mode when possible Pratyush Yadav
2020-03-30 15:45 ` [PATCH v3 14/17] mtd: spi-nor-core: Perform a Soft Reset on shutdown Pratyush Yadav
2020-05-13  6:44   ` Jagan Teki
2020-05-19 15:09     ` Pratyush Yadav
2020-03-30 15:45 ` [PATCH v3 15/17] mtd: spi-nor-core: Perform a Soft Reset on boot Pratyush Yadav
2020-05-13  6:47   ` Jagan Teki
2020-05-13  8:54     ` Pratyush Yadav
2020-05-13  9:56       ` Jagan Teki [this message]
2020-05-13 11:04         ` Pratyush Yadav
2020-05-15  7:42           ` Jagan Teki
2020-05-19 15:33             ` Pratyush Yadav
2020-03-30 15:45 ` [PATCH v3 16/17] mtd: spi-nor-core: Add support for Cypress Semper flash Pratyush Yadav
2020-03-30 15:45 ` [PATCH v3 17/17] mtd: spi-nor-core: Allow using Micron mt35xu512aba in Octal DTR mode Pratyush Yadav
2020-04-21  7:49 ` [PATCH v3 00/17] mtd: spi-nor-core: add xSPI Octal DTR support Pratyush Yadav
2020-04-21  8:09   ` Jagan Teki
2020-05-05  7:58   ` Vignesh Raghavendra
2020-05-12 16:43 ` Jagan Teki
2020-05-12 18:23   ` Pratyush Yadav

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAMty3ZAoc_ijAi-R9H7zaOReXkmwuJoE0+c+sm4Cg0F0oMt6Uw@mail.gmail.com \
    --to=jagan@amarulasolutions.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.