From: <kostap@marvell.com>
To: <linux-spi@vger.kernel.org>
Cc: <devicetree@vger.kernel.org>, <broonie@kernel.org>,
<robh+dt@kernel.org>, <mw@semihalf.com>, <jaz@semihalf.com>,
<nadavh@marvell.com>, <bpeled@marvell.com>, <stefanc@marvell.com>,
Konstantin Porotchkin <kostap@marvell.com>
Subject: [PATCH v2 1/2] spi: orion: enable clocks before spi_setup
Date: Thu, 17 Dec 2020 19:09:31 +0200 [thread overview]
Message-ID: <20201217170933.10717-2-kostap@marvell.com> (raw)
In-Reply-To: <20201217170933.10717-1-kostap@marvell.com>
From: Marcin Wojtas <mw@semihalf.com>
The spi-orion driver disables its clocks whenever it is not used.
In usual case during boot (i.e. using SPI flash) it is not a problem,
as the child device driver is present and probed along with
spi_register_master() execution.
However in case the child device driver is not ready
(e.g. when its type is module_spi_driver) the spi_setup() callback
can be called after the spi-orion probe. It may happen,
that as a result there will be an attempt to access controller's
registers with the clocks disabled.
Prevent such situations and make sure the clocks are on,
each time the spi_setup() is called.
Signed-off-by: Marcin Wojtas <mw@semihalf.com>
Signed-off-by: Konstantin Porotchkin <kostap@marvell.com>
---
drivers/spi/spi-orion.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/drivers/spi/spi-orion.c b/drivers/spi/spi-orion.c
index b57b8b3cc26e..3bfda4225d45 100644
--- a/drivers/spi/spi-orion.c
+++ b/drivers/spi/spi-orion.c
@@ -507,6 +507,16 @@ static int orion_spi_transfer_one(struct spi_master *master,
static int orion_spi_setup(struct spi_device *spi)
{
+ struct orion_spi *orion_spi = spi_master_get_devdata(spi->master);
+
+ /*
+ * Make sure the clocks are enabled before
+ * configuring the SPI controller.
+ */
+ clk_prepare_enable(orion_spi->clk);
+ if (!IS_ERR(orion_spi->axi_clk))
+ clk_prepare_enable(orion_spi->axi_clk);
+
return orion_spi_setup_transfer(spi, NULL);
}
--
2.17.1
next prev parent reply other threads:[~2020-12-17 17:11 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-17 17:09 [PATCH v2 0/2] spi: new feature and fix for Marvell Orion driver kostap
2020-12-17 17:09 ` kostap [this message]
2020-12-17 17:25 ` [PATCH v2 1/2] spi: orion: enable clocks before spi_setup Mark Brown
2020-12-22 12:46 ` [EXT] " Kostya Porotchkin
2020-12-22 16:56 ` Mark Brown
2020-12-17 17:09 ` [PATCH v2 2/2] spi: orion: enable support for switching CS every transferred byte kostap
2020-12-17 17:42 ` Mark Brown
2020-12-17 17:09 ` [PATCH v2 0/2] spi: new feature and fix for Marvell Orion driver kostap
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=20201217170933.10717-2-kostap@marvell.com \
--to=kostap@marvell.com \
--cc=bpeled@marvell.com \
--cc=broonie@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=jaz@semihalf.com \
--cc=linux-spi@vger.kernel.org \
--cc=mw@semihalf.com \
--cc=nadavh@marvell.com \
--cc=robh+dt@kernel.org \
--cc=stefanc@marvell.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).