From: Gareth Williams <gareth.williams.jx@renesas.com>
To: Mark Brown <broonie@kernel.org>
Cc: Phil Edworthy <phil.edworthy@renesas.com>,
linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org,
Gareth Williams <gareth.williams.jx@renesas.com>
Subject: [PATCH v2 3/3] spi: dw: Add support for an optional interface clock
Date: Tue, 19 Mar 2019 15:52:07 +0000 [thread overview]
Message-ID: <1553010727-23157-4-git-send-email-gareth.williams.jx@renesas.com> (raw)
In-Reply-To: <1553010727-23157-1-git-send-email-gareth.williams.jx@renesas.com>
From: Phil Edworthy <phil.edworthy@renesas.com>
The Synopsys SSI Controller has an interface clock, but most SoCs hide
this away. However, on some SoCs you need to explicitly enable the
interface clock in order to access the registers. Therefore, add support
for an optional interface clock.
Signed-off-by: Phil Edworthy <phil.edworthy@renesas.com>
Signed-off-by: Gareth Williams <gareth.williams.jx@renesas.com>
---
v2:
- Added dependancy information to patch notes.
- Expanded on optional clock comment for clarity
Depends on commit 60b8f0ddf1a ("clk: Add (devm_)clk_get_optional()
functions")
---
drivers/spi/spi-dw-mmio.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/drivers/spi/spi-dw-mmio.c b/drivers/spi/spi-dw-mmio.c
index 4bd59a9..de952b1 100644
--- a/drivers/spi/spi-dw-mmio.c
+++ b/drivers/spi/spi-dw-mmio.c
@@ -30,6 +30,7 @@
struct dw_spi_mmio {
struct dw_spi dws;
struct clk *clk;
+ struct clk *pclk;
void *priv;
};
@@ -172,6 +173,14 @@ static int dw_spi_mmio_probe(struct platform_device *pdev)
if (ret)
return ret;
+ /* Optional clock needed to access the registers */
+ dwsmmio->pclk = devm_clk_get_optional(&pdev->dev, "pclk");
+ if (IS_ERR(dwsmmio->pclk))
+ return PTR_ERR(dwsmmio->pclk);
+ ret = clk_prepare_enable(dwsmmio->pclk);
+ if (ret)
+ goto out_clk;
+
dws->bus_num = pdev->id;
dws->max_freq = clk_get_rate(dwsmmio->clk);
@@ -199,6 +208,8 @@ static int dw_spi_mmio_probe(struct platform_device *pdev)
return 0;
out:
+ clk_disable_unprepare(dwsmmio->pclk);
+out_clk:
clk_disable_unprepare(dwsmmio->clk);
return ret;
}
@@ -208,6 +219,7 @@ static int dw_spi_mmio_remove(struct platform_device *pdev)
struct dw_spi_mmio *dwsmmio = platform_get_drvdata(pdev);
dw_spi_remove_host(&dwsmmio->dws);
+ clk_disable_unprepare(dwsmmio->pclk);
clk_disable_unprepare(dwsmmio->clk);
return 0;
--
2.7.4
next prev parent reply other threads:[~2019-03-19 15:55 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-19 15:52 [PATCH v2 0/3] spi: dw: Add support for an optional interface clock Gareth Williams
2019-03-19 15:52 ` [PATCH v2 1/3] dt-bindings: snps,dw-apb-ssi: Add mandatory clock bindings documentation Gareth Williams
2019-03-20 17:30 ` Applied "dt-bindings: snps,dw-apb-ssi: Add mandatory clock bindings documentation" to the spi tree Mark Brown
2019-03-19 15:52 ` [PATCH v2 2/3] dt-bindings: snps,dw-apb-ssi: Add optional clock bindings documentation Gareth Williams
2019-03-20 17:30 ` Applied "dt-bindings: snps,dw-apb-ssi: Add optional clock bindings documentation" to the spi tree Mark Brown
2019-03-19 15:52 ` Gareth Williams [this message]
2019-03-20 17:30 ` Applied "spi: dw: Add support for an optional interface clock" " Mark Brown
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=1553010727-23157-4-git-send-email-gareth.williams.jx@renesas.com \
--to=gareth.williams.jx@renesas.com \
--cc=broonie@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-spi@vger.kernel.org \
--cc=phil.edworthy@renesas.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).