Skip to content
/ linux Public

Commit eb81ed5

Browse files
lsun100storulf
authored andcommitted
mmc: sdhci-of-dwcmshc: add ACPI support for BlueField-3 SoC
This commit adds ACPI support in the sdhci-of-dwcmshc driver for BlueField-3 SoC. It has changes to only use the clock hierarchy for Deviec Tree since the clk is not supported by ACPI. Instead, ACPI can define 'clock-frequency' which is parsed by existing sdhci_get_property(). This clock value will be returned in function dwcmshc_get_max_clock(). Signed-off-by: Liming Sun <limings@nvidia.com> Reviewed-by: Khalil Blaiech <kblaiech@nvidia.com> Link: https://lore.kernel.org/r/1616453211-275165-1-git-send-email-limings@nvidia.com Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
1 parent ee62911 commit eb81ed5

File tree

1 file changed

+36
-14
lines changed

1 file changed

+36
-14
lines changed

drivers/mmc/host/sdhci-of-dwcmshc.c

Lines changed: 36 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* Author: Jisheng Zhang <jszhang@kernel.org>
88
*/
99

10+
#include <linux/acpi.h>
1011
#include <linux/clk.h>
1112
#include <linux/dma-mapping.h>
1213
#include <linux/iopoll.h>
@@ -94,6 +95,16 @@ static void dwcmshc_adma_write_desc(struct sdhci_host *host, void **desc,
9495
sdhci_adma_write_desc(host, desc, addr, len, cmd);
9596
}
9697

98+
static unsigned int dwcmshc_get_max_clock(struct sdhci_host *host)
99+
{
100+
struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
101+
102+
if (pltfm_host->clk)
103+
return sdhci_pltfm_clk_get_max_clock(host);
104+
else
105+
return pltfm_host->clock;
106+
}
107+
97108
static void dwcmshc_check_auto_cmd23(struct mmc_host *mmc,
98109
struct mmc_request *mrq)
99110
{
@@ -248,7 +259,7 @@ static const struct sdhci_ops sdhci_dwcmshc_ops = {
248259
.set_clock = sdhci_set_clock,
249260
.set_bus_width = sdhci_set_bus_width,
250261
.set_uhs_signaling = dwcmshc_set_uhs_signaling,
251-
.get_max_clock = sdhci_pltfm_clk_get_max_clock,
262+
.get_max_clock = dwcmshc_get_max_clock,
252263
.reset = sdhci_reset,
253264
.adma_write_desc = dwcmshc_adma_write_desc,
254265
};
@@ -323,8 +334,16 @@ static const struct of_device_id sdhci_dwcmshc_dt_ids[] = {
323334
};
324335
MODULE_DEVICE_TABLE(of, sdhci_dwcmshc_dt_ids);
325336

337+
#ifdef CONFIG_ACPI
338+
static const struct acpi_device_id sdhci_dwcmshc_acpi_ids[] = {
339+
{ .id = "MLNXBF30" },
340+
{}
341+
};
342+
#endif
343+
326344
static int dwcmshc_probe(struct platform_device *pdev)
327345
{
346+
struct device *dev = &pdev->dev;
328347
struct sdhci_pltfm_host *pltfm_host;
329348
struct sdhci_host *host;
330349
struct dwcmshc_priv *priv;
@@ -347,27 +366,29 @@ static int dwcmshc_probe(struct platform_device *pdev)
347366
/*
348367
* extra adma table cnt for cross 128M boundary handling.
349368
*/
350-
extra = DIV_ROUND_UP_ULL(dma_get_required_mask(&pdev->dev), SZ_128M);
369+
extra = DIV_ROUND_UP_ULL(dma_get_required_mask(dev), SZ_128M);
351370
if (extra > SDHCI_MAX_SEGS)
352371
extra = SDHCI_MAX_SEGS;
353372
host->adma_table_cnt += extra;
354373

355374
pltfm_host = sdhci_priv(host);
356375
priv = sdhci_pltfm_priv(pltfm_host);
357376

358-
pltfm_host->clk = devm_clk_get(&pdev->dev, "core");
359-
if (IS_ERR(pltfm_host->clk)) {
360-
err = PTR_ERR(pltfm_host->clk);
361-
dev_err(&pdev->dev, "failed to get core clk: %d\n", err);
362-
goto free_pltfm;
363-
}
364-
err = clk_prepare_enable(pltfm_host->clk);
365-
if (err)
366-
goto free_pltfm;
377+
if (dev->of_node) {
378+
pltfm_host->clk = devm_clk_get(dev, "core");
379+
if (IS_ERR(pltfm_host->clk)) {
380+
err = PTR_ERR(pltfm_host->clk);
381+
dev_err(dev, "failed to get core clk: %d\n", err);
382+
goto free_pltfm;
383+
}
384+
err = clk_prepare_enable(pltfm_host->clk);
385+
if (err)
386+
goto free_pltfm;
367387

368-
priv->bus_clk = devm_clk_get(&pdev->dev, "bus");
369-
if (!IS_ERR(priv->bus_clk))
370-
clk_prepare_enable(priv->bus_clk);
388+
priv->bus_clk = devm_clk_get(dev, "bus");
389+
if (!IS_ERR(priv->bus_clk))
390+
clk_prepare_enable(priv->bus_clk);
391+
}
371392

372393
err = mmc_of_parse(host->mmc);
373394
if (err)
@@ -489,6 +510,7 @@ static struct platform_driver sdhci_dwcmshc_driver = {
489510
.name = "sdhci-dwcmshc",
490511
.probe_type = PROBE_PREFER_ASYNCHRONOUS,
491512
.of_match_table = sdhci_dwcmshc_dt_ids,
513+
.acpi_match_table = ACPI_PTR(sdhci_dwcmshc_acpi_ids),
492514
.pm = &dwcmshc_pmops,
493515
},
494516
.probe = dwcmshc_probe,

0 commit comments

Comments
 (0)