From: Niklas Cassel <Niklas.Cassel@wdc.com>
To: Serge Semin <fancer.lancer@gmail.com>
Cc: Serge Semin <Sergey.Semin@baikalelectronics.ru>,
Mark Brown <broonie@kernel.org>,
Philipp Zabel <p.zabel@pengutronix.de>,
"linux-spi@vger.kernel.org" <linux-spi@vger.kernel.org>
Subject: Re: [PATCH] spi: dw: assert reset before deasserting reset
Date: Fri, 11 Mar 2022 15:51:23 +0000 [thread overview]
Message-ID: <Yitv+tKTH2RpTV2K@x1-carbon> (raw)
In-Reply-To: <20220311142550.haw5jnrjycavr43m@mobilestation>
On Fri, Mar 11, 2022 at 05:25:50PM +0300, Serge Semin wrote:
> Hello Niklas
Hello Serge,
>
> On Tue, Mar 01, 2022 at 11:17:20AM +0000, Niklas Cassel wrote:
> > From: Niklas Cassel <niklas.cassel@wdc.com>
> >
> > Simply deasserting reset just ensures that the hardware is taken out of
> > reset, if it was booted with the hardware reset asserted.
> >
> > In order actually reset the SPI controller, we need to assert reset before
> > deasserting.
> >
> > By doing this, we ensure that the hardware is not in some bad state, and we
> > ensure that the hardware registers get set to their reset default, clearing
> > any setting set by e.g. a bootloader.
> >
> > Signed-off-by: Niklas Cassel <niklas.cassel@wdc.com>
> > ---
> > drivers/spi/spi-dw-mmio.c | 2 ++
> > 1 file changed, 2 insertions(+)
> >
> > diff --git a/drivers/spi/spi-dw-mmio.c b/drivers/spi/spi-dw-mmio.c
> > index 5101c4c6017b..eb1dacb45ca2 100644
> > --- a/drivers/spi/spi-dw-mmio.c
> > +++ b/drivers/spi/spi-dw-mmio.c
> > @@ -289,6 +289,8 @@ static int dw_spi_mmio_probe(struct platform_device *pdev)
> > ret = PTR_ERR(dwsmmio->rstc);
> > goto out_clk;
> > }
>
> > + reset_control_assert(dwsmmio->rstc);
> > + udelay(2);
>
> Do we really need this? dw_spi_add_host() is doing a sort of soft reset
> anyway by calling the dw_spi_hw_init() method. Do you have a real
> platform, which requires to do a full hard-reset?
Does this solve a real problem that I've seen with the SPI controller?
No.
Which register write in dw_spi_hw_init() is doing a soft reset?
I assume that you mean one of the writes in dw_spi_reset_chip(),
probably DW_SPI_SSIENR.
I don't think us toggling this register will reset all registers
to their reset default values.
I think it is a good to start off with all registers in their
default reset values.
Arguably, I think it looks wrong to see a reset_control_deassert()
without any previous reset_control_assert().
Do a simple:
git grep -C 10 reset_control_deassert drivers/spi/
And you see that most SPI drivers (and most other device drivers for
that matter), usually assert reset before deasserting it, in order
to ensure that a reset pulse is actually sent to the hardware.
Simply deasserting reset, will have the hardware in a "fresh" state
if it was a cold boot (where reset is usually asserted until deasserted),
but will not have the hardware in a "fresh" state if booted via a boot
loader. This is an inconsistency, and could potentially lead to issues
that are only noticed if booting via a bootloader.
>
> What about the self-reset based controllers?
Not sure what specific feature in the SPI controller you are
referring to.
Kind regards,
Niklas
next prev parent reply other threads:[~2022-03-11 15:53 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-01 11:17 [PATCH] spi: dw: assert reset before deasserting reset Niklas Cassel
2022-03-11 14:25 ` Serge Semin
2022-03-11 15:51 ` Niklas Cassel [this message]
2022-03-11 16:06 ` Mark Brown
2022-03-11 17:05 ` Serge Semin
2022-03-16 14:11 ` Niklas Cassel
2022-03-17 10:17 ` Philipp Zabel
2022-03-22 10:32 ` Niklas Cassel
2022-03-22 11:08 ` Philipp Zabel
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=Yitv+tKTH2RpTV2K@x1-carbon \
--to=niklas.cassel@wdc.com \
--cc=Sergey.Semin@baikalelectronics.ru \
--cc=broonie@kernel.org \
--cc=fancer.lancer@gmail.com \
--cc=linux-spi@vger.kernel.org \
--cc=p.zabel@pengutronix.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.