Skip to content

Commit 1542488

Browse files
wojtas-marcinUlf Hansson
authored andcommitted
mmc: sdhci-xenon: use clk only with DT
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> Link: https://lore.kernel.org/r/20201204171626.10935-4-mw@semihalf.com Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
1 parent f29bf66 commit 1542488

1 file changed

Lines changed: 32 additions & 19 deletions

File tree

drivers/mmc/host/sdhci-xenon.c

Lines changed: 32 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -247,14 +247,24 @@ static void xenon_voltage_switch(struct sdhci_host *host)
247247
sdhci_readw(host, SDHCI_HOST_CONTROL2);
248248
}
249249

250+
static unsigned int xenon_get_max_clock(struct sdhci_host *host)
251+
{
252+
struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
253+
254+
if (pltfm_host->clk)
255+
return sdhci_pltfm_clk_get_max_clock(host);
256+
else
257+
return pltfm_host->clock;
258+
}
259+
250260
static const struct sdhci_ops sdhci_xenon_ops = {
251261
.voltage_switch = xenon_voltage_switch,
252262
.set_clock = sdhci_set_clock,
253263
.set_power = xenon_set_power,
254264
.set_bus_width = sdhci_set_bus_width,
255265
.reset = xenon_reset,
256266
.set_uhs_signaling = xenon_set_uhs_signaling,
257-
.get_max_clock = sdhci_pltfm_clk_get_max_clock,
267+
.get_max_clock = xenon_get_max_clock,
258268
};
259269

260270
static const struct sdhci_pltfm_data sdhci_xenon_pdata = {
@@ -483,6 +493,7 @@ static void xenon_sdhc_unprepare(struct sdhci_host *host)
483493
static int xenon_probe(struct platform_device *pdev)
484494
{
485495
struct sdhci_pltfm_host *pltfm_host;
496+
struct device *dev = &pdev->dev;
486497
struct sdhci_host *host;
487498
struct xenon_priv *priv;
488499
int err;
@@ -503,25 +514,27 @@ static int xenon_probe(struct platform_device *pdev)
503514
*/
504515
xenon_replace_mmc_host_ops(host);
505516

506-
pltfm_host->clk = devm_clk_get(&pdev->dev, "core");
507-
if (IS_ERR(pltfm_host->clk)) {
508-
err = PTR_ERR(pltfm_host->clk);
509-
dev_err(&pdev->dev, "Failed to setup input clk: %d\n", err);
510-
goto free_pltfm;
511-
}
512-
err = clk_prepare_enable(pltfm_host->clk);
513-
if (err)
514-
goto free_pltfm;
515-
516-
priv->axi_clk = devm_clk_get(&pdev->dev, "axi");
517-
if (IS_ERR(priv->axi_clk)) {
518-
err = PTR_ERR(priv->axi_clk);
519-
if (err == -EPROBE_DEFER)
520-
goto err_clk;
521-
} else {
522-
err = clk_prepare_enable(priv->axi_clk);
517+
if (dev->of_node) {
518+
pltfm_host->clk = devm_clk_get(&pdev->dev, "core");
519+
if (IS_ERR(pltfm_host->clk)) {
520+
err = PTR_ERR(pltfm_host->clk);
521+
dev_err(&pdev->dev, "Failed to setup input clk: %d\n", err);
522+
goto free_pltfm;
523+
}
524+
err = clk_prepare_enable(pltfm_host->clk);
523525
if (err)
524-
goto err_clk;
526+
goto free_pltfm;
527+
528+
priv->axi_clk = devm_clk_get(&pdev->dev, "axi");
529+
if (IS_ERR(priv->axi_clk)) {
530+
err = PTR_ERR(priv->axi_clk);
531+
if (err == -EPROBE_DEFER)
532+
goto err_clk;
533+
} else {
534+
err = clk_prepare_enable(priv->axi_clk);
535+
if (err)
536+
goto err_clk;
537+
}
525538
}
526539

527540
err = mmc_of_parse(host->mmc);

0 commit comments

Comments
 (0)