* [PATCH] mmc: sdhci_f_sdh30: add ACPI support
@ 2017-12-27 18:14 Ard Biesheuvel
2018-01-08 9:18 ` Adrian Hunter
0 siblings, 1 reply; 2+ messages in thread
From: Ard Biesheuvel @ 2017-12-27 18:14 UTC (permalink / raw)
To: linux-mmc, ulf.hansson, adrian.hunter; +Cc: Ard Biesheuvel
The Fujitsu SDH30 SDHCI controller may be described as a SCX0002 ACPI
device on ACPI platforms incorporating the Socionext SynQuacer SoC.
Given that mmc_of_parse() has already been made ACPI/DT agnostic,
making the SDH30 driver ACPI capable is actually rather simple:
all we need to do is make the call to sdhci_get_of_property() [which
does not set any properties we care about] and the clock handling
dependent on whether we are dealing with a DT device, and exposing
the ACPI id via the platform_driver struct and the module metadata.
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
drivers/mmc/host/sdhci_f_sdh30.c | 53 +++++++++++++-------
1 file changed, 34 insertions(+), 19 deletions(-)
diff --git a/drivers/mmc/host/sdhci_f_sdh30.c b/drivers/mmc/host/sdhci_f_sdh30.c
index 04ca0d33a521..102321a9ea34 100644
--- a/drivers/mmc/host/sdhci_f_sdh30.c
+++ b/drivers/mmc/host/sdhci_f_sdh30.c
@@ -10,6 +10,7 @@
* the Free Software Foundation, version 2 of the License.
*/
+#include <linux/acpi.h>
#include <linux/err.h>
#include <linux/delay.h>
#include <linux/module.h>
@@ -146,7 +147,6 @@ static int sdhci_f_sdh30_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, host);
- sdhci_get_of_property(pdev);
host->hw_name = "f_sdh30";
host->ops = &sdhci_f_sdh30_ops;
host->irq = irq;
@@ -158,25 +158,29 @@ static int sdhci_f_sdh30_probe(struct platform_device *pdev)
goto err;
}
- priv->clk_iface = devm_clk_get(&pdev->dev, "iface");
- if (IS_ERR(priv->clk_iface)) {
- ret = PTR_ERR(priv->clk_iface);
- goto err;
- }
+ if (dev_of_node(dev)) {
+ sdhci_get_of_property(pdev);
- ret = clk_prepare_enable(priv->clk_iface);
- if (ret)
- goto err;
+ priv->clk_iface = devm_clk_get(&pdev->dev, "iface");
+ if (IS_ERR(priv->clk_iface)) {
+ ret = PTR_ERR(priv->clk_iface);
+ goto err;
+ }
- priv->clk = devm_clk_get(&pdev->dev, "core");
- if (IS_ERR(priv->clk)) {
- ret = PTR_ERR(priv->clk);
- goto err_clk;
- }
+ ret = clk_prepare_enable(priv->clk_iface);
+ if (ret)
+ goto err;
- ret = clk_prepare_enable(priv->clk);
- if (ret)
- goto err_clk;
+ priv->clk = devm_clk_get(&pdev->dev, "core");
+ if (IS_ERR(priv->clk)) {
+ ret = PTR_ERR(priv->clk);
+ goto err_clk;
+ }
+
+ ret = clk_prepare_enable(priv->clk);
+ if (ret)
+ goto err_clk;
+ }
/* init vendor specific regs */
ctrl = sdhci_readw(host, F_SDH30_AHB_CONFIG);
@@ -217,8 +221,10 @@ static int sdhci_f_sdh30_remove(struct platform_device *pdev)
sdhci_remove_host(host, readl(host->ioaddr + SDHCI_INT_STATUS) ==
0xffffffff);
- clk_disable_unprepare(priv->clk_iface);
- clk_disable_unprepare(priv->clk);
+ if (dev_of_node(priv->dev)) {
+ clk_disable_unprepare(priv->clk_iface);
+ clk_disable_unprepare(priv->clk);
+ }
sdhci_free_host(host);
platform_set_drvdata(pdev, NULL);
@@ -232,10 +238,19 @@ static const struct of_device_id f_sdh30_dt_ids[] = {
};
MODULE_DEVICE_TABLE(of, f_sdh30_dt_ids);
+#ifdef CONFIG_ACPI
+static const struct acpi_device_id f_sdh30_acpi_ids[] = {
+ { "SCX0002" },
+ { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(acpi, f_sdh30_acpi_ids);
+#endif
+
static struct platform_driver sdhci_f_sdh30_driver = {
.driver = {
.name = "f_sdh30",
.of_match_table = f_sdh30_dt_ids,
+ .acpi_match_table = ACPI_PTR(f_sdh30_acpi_ids),
.pm = &sdhci_pltfm_pmops,
},
.probe = sdhci_f_sdh30_probe,
--
2.11.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] mmc: sdhci_f_sdh30: add ACPI support
2017-12-27 18:14 [PATCH] mmc: sdhci_f_sdh30: add ACPI support Ard Biesheuvel
@ 2018-01-08 9:18 ` Adrian Hunter
0 siblings, 0 replies; 2+ messages in thread
From: Adrian Hunter @ 2018-01-08 9:18 UTC (permalink / raw)
To: Ard Biesheuvel, linux-mmc, ulf.hansson
On 27/12/17 20:14, Ard Biesheuvel wrote:
> The Fujitsu SDH30 SDHCI controller may be described as a SCX0002 ACPI
> device on ACPI platforms incorporating the Socionext SynQuacer SoC.
>
> Given that mmc_of_parse() has already been made ACPI/DT agnostic,
> making the SDH30 driver ACPI capable is actually rather simple:
> all we need to do is make the call to sdhci_get_of_property() [which
> does not set any properties we care about] and the clock handling
> dependent on whether we are dealing with a DT device, and exposing
> the ACPI id via the platform_driver struct and the module metadata.
>
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> ---
> drivers/mmc/host/sdhci_f_sdh30.c | 53 +++++++++++++-------
> 1 file changed, 34 insertions(+), 19 deletions(-)
>
> diff --git a/drivers/mmc/host/sdhci_f_sdh30.c b/drivers/mmc/host/sdhci_f_sdh30.c
> index 04ca0d33a521..102321a9ea34 100644
> --- a/drivers/mmc/host/sdhci_f_sdh30.c
> +++ b/drivers/mmc/host/sdhci_f_sdh30.c
> @@ -10,6 +10,7 @@
> * the Free Software Foundation, version 2 of the License.
> */
>
> +#include <linux/acpi.h>
> #include <linux/err.h>
> #include <linux/delay.h>
> #include <linux/module.h>
> @@ -146,7 +147,6 @@ static int sdhci_f_sdh30_probe(struct platform_device *pdev)
>
> platform_set_drvdata(pdev, host);
>
> - sdhci_get_of_property(pdev);
> host->hw_name = "f_sdh30";
> host->ops = &sdhci_f_sdh30_ops;
> host->irq = irq;
> @@ -158,25 +158,29 @@ static int sdhci_f_sdh30_probe(struct platform_device *pdev)
> goto err;
> }
>
> - priv->clk_iface = devm_clk_get(&pdev->dev, "iface");
> - if (IS_ERR(priv->clk_iface)) {
> - ret = PTR_ERR(priv->clk_iface);
> - goto err;
> - }
> + if (dev_of_node(dev)) {
> + sdhci_get_of_property(pdev);
>
> - ret = clk_prepare_enable(priv->clk_iface);
> - if (ret)
> - goto err;
> + priv->clk_iface = devm_clk_get(&pdev->dev, "iface");
> + if (IS_ERR(priv->clk_iface)) {
> + ret = PTR_ERR(priv->clk_iface);
> + goto err;
> + }
>
> - priv->clk = devm_clk_get(&pdev->dev, "core");
> - if (IS_ERR(priv->clk)) {
> - ret = PTR_ERR(priv->clk);
> - goto err_clk;
> - }
> + ret = clk_prepare_enable(priv->clk_iface);
> + if (ret)
> + goto err;
>
> - ret = clk_prepare_enable(priv->clk);
> - if (ret)
> - goto err_clk;
> + priv->clk = devm_clk_get(&pdev->dev, "core");
> + if (IS_ERR(priv->clk)) {
> + ret = PTR_ERR(priv->clk);
> + goto err_clk;
> + }
> +
> + ret = clk_prepare_enable(priv->clk);
> + if (ret)
> + goto err_clk;
> + }
>
> /* init vendor specific regs */
> ctrl = sdhci_readw(host, F_SDH30_AHB_CONFIG);
> @@ -217,8 +221,10 @@ static int sdhci_f_sdh30_remove(struct platform_device *pdev)
> sdhci_remove_host(host, readl(host->ioaddr + SDHCI_INT_STATUS) ==
> 0xffffffff);
>
> - clk_disable_unprepare(priv->clk_iface);
> - clk_disable_unprepare(priv->clk);
> + if (dev_of_node(priv->dev)) {
You check dev_of_node(priv->dev) here but not in the error path of
sdhci_f_sdh30_probe(). I guess passing NULL to clk_disable_unprepare() is
OK anyway, so is the check needed at all?
> + clk_disable_unprepare(priv->clk_iface);
> + clk_disable_unprepare(priv->clk);
> + }
>
> sdhci_free_host(host);
> platform_set_drvdata(pdev, NULL);
> @@ -232,10 +238,19 @@ static const struct of_device_id f_sdh30_dt_ids[] = {
> };
> MODULE_DEVICE_TABLE(of, f_sdh30_dt_ids);
>
> +#ifdef CONFIG_ACPI
> +static const struct acpi_device_id f_sdh30_acpi_ids[] = {
> + { "SCX0002" },
> + { /* sentinel */ }
> +};
> +MODULE_DEVICE_TABLE(acpi, f_sdh30_acpi_ids);
> +#endif
> +
> static struct platform_driver sdhci_f_sdh30_driver = {
> .driver = {
> .name = "f_sdh30",
> .of_match_table = f_sdh30_dt_ids,
Perhaps you should tidy up the Kconfig too e.g.
diff --git a/drivers/mmc/host/Kconfig b/drivers/mmc/host/Kconfig
index cc4fd07735a7..55aee47df96c 100644
--- a/drivers/mmc/host/Kconfig
+++ b/drivers/mmc/host/Kconfig
@@ -320,8 +320,7 @@ config MMC_SDHCI_BCM_KONA
config MMC_SDHCI_F_SDH30
tristate "SDHCI support for Fujitsu Semiconductor F_SDH30"
depends on MMC_SDHCI_PLTFM
- depends on OF
+ depends on OF || ACPI
help
This selects the Secure Digital Host Controller Interface (SDHCI)
Needed by some Fujitsu SoC for MMC / SD / SDIO support.
Then consider using of_match_ptr() and #ifdef CONFIG_OF around
f_sdh30_acpi_ids so it all looks nice and symmetrical.
> + .acpi_match_table = ACPI_PTR(f_sdh30_acpi_ids),
> .pm = &sdhci_pltfm_pmops,
> },
> .probe = sdhci_f_sdh30_probe,
>
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-01-08 9:18 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-12-27 18:14 [PATCH] mmc: sdhci_f_sdh30: add ACPI support Ard Biesheuvel
2018-01-08 9:18 ` Adrian Hunter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox