From: Marcin Wojtas <mw@semihalf.com>
To: linux-kernel@vger.kernel.org, linux-mmc@vger.kernel.org
Cc: ulf.hansson@linaro.org, huziji@marvell.com,
adrian.hunter@intel.com, jaz@semihalf.com, tn@semihalf.com,
ard.biesheuvel@arm.com, kostap@marvell.com,
Marcin Wojtas <mw@semihalf.com>
Subject: [PATCH v3 3/4] mmc: sdhci-xenon: use clk only with DT
Date: Wed, 2 Dec 2020 19:51:17 +0100 [thread overview]
Message-ID: <20201202185118.29076-4-mw@semihalf.com> (raw)
In-Reply-To: <20201202185118.29076-1-mw@semihalf.com>
As a preparation for supporting ACPI, modify the driver
to use the clk framework only when booting with DT -
otherwise rely on the configuration done by firmware.
For that purpose introduce also a custom SDHCI get_max_clock
callback.
Signed-off-by: Marcin Wojtas <mw@semihalf.com>
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
---
drivers/mmc/host/sdhci-xenon.c | 61 ++++++++++++--------
1 file changed, 38 insertions(+), 23 deletions(-)
diff --git a/drivers/mmc/host/sdhci-xenon.c b/drivers/mmc/host/sdhci-xenon.c
index bfc76b0e3eaa..cc0fcc646b0e 100644
--- a/drivers/mmc/host/sdhci-xenon.c
+++ b/drivers/mmc/host/sdhci-xenon.c
@@ -247,6 +247,16 @@ static void xenon_voltage_switch(struct sdhci_host *host)
sdhci_readw(host, SDHCI_HOST_CONTROL2);
}
+static unsigned int xenon_get_max_clock(struct sdhci_host *host)
+{
+ struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
+
+ if (pltfm_host->clk)
+ return sdhci_pltfm_clk_get_max_clock(host);
+ else
+ return pltfm_host->clock;
+}
+
static const struct sdhci_ops sdhci_xenon_ops = {
.voltage_switch = xenon_voltage_switch,
.set_clock = sdhci_set_clock,
@@ -254,7 +264,7 @@ static const struct sdhci_ops sdhci_xenon_ops = {
.set_bus_width = sdhci_set_bus_width,
.reset = xenon_reset,
.set_uhs_signaling = xenon_set_uhs_signaling,
- .get_max_clock = sdhci_pltfm_clk_get_max_clock,
+ .get_max_clock = xenon_get_max_clock,
};
static const struct sdhci_pltfm_data sdhci_xenon_pdata = {
@@ -483,6 +493,7 @@ static void xenon_sdhc_unprepare(struct sdhci_host *host)
static int xenon_probe(struct platform_device *pdev)
{
struct sdhci_pltfm_host *pltfm_host;
+ struct device *dev = &pdev->dev;
struct sdhci_host *host;
struct xenon_priv *priv;
int err;
@@ -503,25 +514,27 @@ static int xenon_probe(struct platform_device *pdev)
*/
xenon_replace_mmc_host_ops(host);
- pltfm_host->clk = devm_clk_get(&pdev->dev, "core");
- if (IS_ERR(pltfm_host->clk)) {
- err = PTR_ERR(pltfm_host->clk);
- dev_err(&pdev->dev, "Failed to setup input clk: %d\n", err);
- goto free_pltfm;
- }
- err = clk_prepare_enable(pltfm_host->clk);
- if (err)
- goto free_pltfm;
-
- priv->axi_clk = devm_clk_get(&pdev->dev, "axi");
- if (IS_ERR(priv->axi_clk)) {
- err = PTR_ERR(priv->axi_clk);
- if (err == -EPROBE_DEFER)
- goto err_clk;
- } else {
- err = clk_prepare_enable(priv->axi_clk);
+ if (dev->of_node) {
+ pltfm_host->clk = devm_clk_get(&pdev->dev, "core");
+ if (IS_ERR(pltfm_host->clk)) {
+ err = PTR_ERR(pltfm_host->clk);
+ dev_err(&pdev->dev, "Failed to setup input clk: %d\n", err);
+ goto free_pltfm;
+ }
+ err = clk_prepare_enable(pltfm_host->clk);
if (err)
- goto err_clk;
+ goto free_pltfm;
+
+ priv->axi_clk = devm_clk_get(&pdev->dev, "axi");
+ if (IS_ERR(priv->axi_clk)) {
+ err = PTR_ERR(priv->axi_clk);
+ if (err == -EPROBE_DEFER)
+ goto err_clk;
+ } else {
+ err = clk_prepare_enable(priv->axi_clk);
+ if (err)
+ goto err_clk;
+ }
}
err = mmc_of_parse(host->mmc);
@@ -637,10 +650,12 @@ static int xenon_runtime_resume(struct device *dev)
struct xenon_priv *priv = sdhci_pltfm_priv(pltfm_host);
int ret;
- ret = clk_prepare_enable(pltfm_host->clk);
- if (ret) {
- dev_err(dev, "can't enable mainck\n");
- return ret;
+ if (dev->of_node) {
+ ret = clk_prepare_enable(pltfm_host->clk);
+ if (ret) {
+ dev_err(dev, "can't enable mainck\n");
+ return ret;
+ }
}
if (priv->restore_needed) {
--
2.29.0
next prev parent reply other threads:[~2020-12-02 18:53 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-02 18:51 [PATCH v3 0/4] sdhci-xenon ACPI support Marcin Wojtas
2020-12-02 18:51 ` [PATCH v3 1/4] mmc: sdhci-xenon: use match data for controllers variants Marcin Wojtas
2020-12-02 18:51 ` [PATCH v3 2/4] mmc: sdhci-xenon: switch to device_* API Marcin Wojtas
2020-12-02 18:51 ` Marcin Wojtas [this message]
2020-12-04 13:51 ` [PATCH v3 3/4] mmc: sdhci-xenon: use clk only with DT Ulf Hansson
2020-12-04 17:19 ` Marcin Wojtas
2020-12-02 18:51 ` [PATCH v3 4/4] mmc: sdhci-xenon: introduce ACPI support Marcin Wojtas
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=20201202185118.29076-4-mw@semihalf.com \
--to=mw@semihalf.com \
--cc=adrian.hunter@intel.com \
--cc=ard.biesheuvel@arm.com \
--cc=huziji@marvell.com \
--cc=jaz@semihalf.com \
--cc=kostap@marvell.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mmc@vger.kernel.org \
--cc=tn@semihalf.com \
--cc=ulf.hansson@linaro.org \
/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).