[PATCH 1/8] mmc: sdhci-st: Intial support for ST SDHCI controller
Lee Jones
lee.jones at linaro.org
Thu May 22 09:50:36 PDT 2014
> This platform driver adds initial support for the SDHCI host controller
> found on STMicroelectronics SoCs.
>
> It has been tested on STiH41x b2020 platforms currently.
>
> Signed-off-by: Peter Griffin <peter.griffin at linaro.org>
> Signed-off-by: Giuseppe Cavallaro <peppe.cavallaro at st.com>
> ---
> drivers/mmc/host/Kconfig | 12 +++
> drivers/mmc/host/Makefile | 1 +
> drivers/mmc/host/sdhci-st.c | 244 ++++++++++++++++++++++++++++++++++++++++++++
> 3 files changed, 257 insertions(+)
> create mode 100644 drivers/mmc/host/sdhci-st.c
[...]
> +static int sdhci_st_probe(struct platform_device *pdev)
> +{
> + struct device_node *np = pdev->dev.of_node;
> + struct sdhci_host *host;
> + struct st_mmc_platform_data *pdata;
> + struct sdhci_pltfm_host *pltfm_host;
> + struct clk *clk;
> + int ret = 0;
> + u16 host_version;
> +
> + dev_dbg(&pdev->dev, "SDHCI ST platform driver\n");
> +
> + pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
> + if (!pdata)
> + return -ENOMEM;
> +
> + pdata->rstc = devm_reset_control_get(&pdev->dev, NULL);
> + if (IS_ERR(pdata->rstc))
> + pdata->rstc = NULL;
> + else
> + reset_control_deassert(pdata->rstc);
> +
> + clk = devm_clk_get(&pdev->dev, "mmc");
> + if (IS_ERR(clk)) {
> + dev_err(&pdev->dev, "Perpheral clk not found\n");
> + return PTR_ERR(clk);
> + }
> +
> + host = sdhci_pltfm_init(pdev, &sdhci_st_pdata, 0);
> + if (IS_ERR(host)) {
> + dev_err(&pdev->dev, "Failed sdhci_pltfm_init\n");
> + return PTR_ERR(host);
> + }
> +
> + clk_prepare_enable(clk);
Move this down as far as it will go. When do you _need_ the clock
running by?
> + host->mmc->caps |= MMC_CAP_8_BIT_DATA | MMC_CAP_BUS_WIDTH_TEST
> + | MMC_CAP_1_8V_DDR;
> +
> + if (of_property_read_bool(np, "non-removable"))
> + host->mmc->caps |= MMC_CAP_NONREMOVABLE;
> +
> + pltfm_host = sdhci_priv(host);
> + pltfm_host->clk = clk;
> +
> + ret = sdhci_add_host(host);
> + if (ret) {
> + dev_err(&pdev->dev, "Failed sdhci_add_host\n");
> + goto err_out;
If it's possible to move the clk_prepare enable down past here, then
you only need to do sdhci_pltfm_free() and you can remove all of the
err_out error path.
> + }
> +
> + pltfm_host->priv = pdata;
> +
> + platform_set_drvdata(pdev, host);
> +
> + host_version = readw_relaxed((host->ioaddr + SDHCI_HOST_VERSION));
Do we want to be doing any error checking for unsupported devices
here?
[...]
> +static struct platform_driver sdhci_st_driver = {
> + .probe = sdhci_st_probe,
> + .remove = sdhci_st_remove,
> + .driver = {
> + .name = "sdhci-st",
> + .owner = THIS_MODULE,
> + .pm = SDHCI_ST_PMOPS,
> + .of_match_table = of_match_ptr(st_sdhci_match),
> + },
Tabbing issue here.
> +};
> +
> +module_platform_driver(sdhci_st_driver);
> +
> +MODULE_DESCRIPTION("SDHCI driver for STMicroelectronics SoCs");
> +MODULE_AUTHOR("Giuseppe Cavallaro <peppe.cavallaro at st.com>");
> +MODULE_LICENSE("GPL v2");
> +MODULE_ALIAS("platform:st-sdhci");
--
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
More information about the linux-arm-kernel
mailing list