From: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
To: Peter Griffin <peter.griffin@linaro.org>,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, maxime.coquelin@st.com,
patrice.chotard@st.com, srinivas.kandagatla@gmail.com,
chris@printf.net, ulf.hansson@linaro.org
Cc: devicetree@vger.kernel.org, kernel@stlinux.com,
linux-mmc@vger.kernel.org,
Giuseppe Cavallaro <peppe.cavallaro@st.com>,
lee.jones@linaro.org
Subject: Re: [PATCH 1/8] mmc: sdhci-st: Intial support for ST SDHCI controller
Date: Fri, 23 May 2014 07:18:52 +0100 [thread overview]
Message-ID: <537EE84C.2020607@linaro.org> (raw)
In-Reply-To: <1400771902-26553-2-git-send-email-peter.griffin@linaro.org>
Hi Pete,
On 22/05/14 16:18, Peter Griffin wrote:
>
> ifeq ($(CONFIG_CB710_DEBUG),y)
> CFLAGS-cb710-mmc += -DDEBUG
> diff --git a/drivers/mmc/host/sdhci-st.c b/drivers/mmc/host/sdhci-st.c
> new file mode 100644
> index 0000000..1790fa7
> --- /dev/null
> +++ b/drivers/mmc/host/sdhci-st.c
> @@ -0,0 +1,244 @@
> +/*
> + * Support for SDHCI on STMicroelectronics SoCs
> + *
> + * Copyright (C) 2014 STMicroelectronics Ltd
> + * Author: Giuseppe Cavallaro <peppe.cavallaro@st.com>
> + *
> + * Based on sdhci-cns3xxx.c
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + * GNU General Public License for more details.
> + *
> + */
> +
> +#include <linux/io.h>
> +#include <linux/of.h>
> +#include <linux/module.h>
> +#include <linux/err.h>
> +#include <linux/of_gpio.h>
Do you need this header?
> +#include <linux/mmc/host.h>
> +#include <linux/reset.h>
> +
> +#include "sdhci-pltfm.h"
> +
> +struct st_mmc_platform_data {
> + struct reset_control *rstc;
> +};
st_mmc_platform_data name is bit missleading as this data is not part of
platform data. Probably you could rename it to struct sdhci_st_data.
...
> +
> +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);
> +
> + 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;
> + }
> +
> + pltfm_host->priv = pdata;
> +
> + platform_set_drvdata(pdev, host);
Why not platform_set_drvdata(pdev, priv_host);
As you are not using sdhci_host directly, this will reduced few
indirections in the driver.
> +
> + host_version = readw_relaxed((host->ioaddr + SDHCI_HOST_VERSION));
> +
> + dev_dbg(&pdev->dev, "SDHCI ST Initialised: Host Version: 0x%x Vendor Version 0x%x\n",
> + host_version, ((host_version & SDHCI_VENDOR_VER_MASK) >>
> + SDHCI_VENDOR_VER_SHIFT));
> +
> + return 0;
> +
> +err_out:
> + clk_disable_unprepare(clk);
> + sdhci_pltfm_free(pdev);
> +
IP could be left out of reset in this path.
> + return ret;
> +}
> +
> +static int sdhci_st_remove(struct platform_device *pdev)
> +{
> + struct sdhci_host *host = platform_get_drvdata(pdev);
> + struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
> + struct st_mmc_platform_data *pdata = pltfm_host->priv;
> + int ret;
> +
> + clk_disable_unprepare(pltfm_host->clk);
> +
> + ret = sdhci_pltfm_unregister(pdev);
> +
> + if (pdata->rstc)
> + reset_control_assert(pdata->rstc);
> +
> + return ret;
> +}
> +
> +#ifdef CONFIG_PM_SLEEP
> +static int sdhci_st_suspend(struct device *dev)
> +{
> + struct sdhci_host *host = dev_get_drvdata(dev);
> + struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
> + struct st_mmc_platform_data *pdata = pltfm_host->priv;
> + int ret = sdhci_suspend_host(host);
> +
> + if (ret)
> + goto out;
> +
> + if (pdata->rstc)
> + reset_control_assert(pdata->rstc);
> +
> + clk_disable_unprepare(pltfm_host->clk);
> +out:
> + return ret;
> +}
> +
> +static int sdhci_st_resume(struct device *dev)
> +{
> + struct sdhci_host *host = dev_get_drvdata(dev);
> + struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
> + struct st_mmc_platform_data *pdata = pltfm_host->priv;
> +
> + clk_prepare_enable(pltfm_host->clk);
> +
> + if (pdata->rstc)
> + reset_control_deassert(pdata->rstc);
> +
> + return sdhci_resume_host(host);
> +}
> +
replace:
[...
> +static SIMPLE_DEV_PM_OPS(sdhci_st_pmops, sdhci_st_suspend, sdhci_st_resume);
> +#define SDHCI_ST_PMOPS (&sdhci_st_pmops)
> +#else
> +#define SDHCI_ST_PMOPS NULL
> +#endif
...]
with :
#endif
static SIMPLE_DEV_PM_OPS(sdhci_st_pmops, sdhci_st_suspend, sdhci_st_resume);
> +
> +static const struct of_device_id st_sdhci_match[] = {
> + { .compatible = "st,sdhci" },
> + {},
> +};
> +
> +MODULE_DEVICE_TABLE(of, st_sdhci_match);
> +
> +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,
use .pm = sdhci_st_pmops,
> + .of_match_table = of_match_ptr(st_sdhci_match),
> + },
> +};
> +
> +module_platform_driver(sdhci_st_driver);
> +
> +MODULE_DESCRIPTION("SDHCI driver for STMicroelectronics SoCs");
> +MODULE_AUTHOR("Giuseppe Cavallaro <peppe.cavallaro@st.com>");
> +MODULE_LICENSE("GPL v2");
> +MODULE_ALIAS("platform:st-sdhci");
>
next prev parent reply other threads:[~2014-05-23 6:18 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-22 15:18 Add SDHCI support for STMicroelectronics SoCs Peter Griffin
2014-05-22 15:18 ` [PATCH 1/8] mmc: sdhci-st: Intial support for ST SDHCI controller Peter Griffin
2014-05-22 15:41 ` Maxime Coquelin
2014-06-04 11:05 ` Peter Griffin
[not found] ` <1400771902-26553-2-git-send-email-peter.griffin-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2014-05-22 16:50 ` Lee Jones
2014-06-02 11:06 ` Peter Griffin
2014-05-23 6:18 ` Srinivas Kandagatla [this message]
[not found] ` <537EE84C.2020607-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2014-06-04 8:37 ` Peter Griffin
2014-05-23 7:34 ` Ulf Hansson
[not found] ` <20140604084831.GB23469@griffinp-ThinkPad-X1-Carbon-2nd>
2014-06-04 11:06 ` Ulf Hansson
2014-05-22 15:18 ` [PATCH 2/8] mmc: sdhci-st: STMicroelectronics SDHCI binding documentation Peter Griffin
[not found] ` <1400771902-26553-3-git-send-email-peter.griffin-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2014-05-22 15:46 ` Maxime Coquelin
2014-05-22 16:06 ` Lee Jones
2014-05-23 6:57 ` Ulf Hansson
2014-05-22 15:18 ` [PATCH 3/8] ARM: STi: DT: Add sdhci pins for stih416 Peter Griffin
2014-05-22 15:50 ` Maxime Coquelin
2014-05-22 15:59 ` Lee Jones
2014-05-22 15:18 ` [PATCH 4/8] ARM: STi: DT: Add sdhci controller " Peter Griffin
2014-05-22 15:58 ` Lee Jones
2014-05-22 15:18 ` [PATCH 5/8] ARM: STi: DT: Add sdhci pin configuration for stih415 Peter Griffin
[not found] ` <1400771902-26553-6-git-send-email-peter.griffin-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2014-05-22 15:57 ` Lee Jones
2014-05-22 15:18 ` [PATCH 6/8] ARM: STi: DT: Enable mmc0 for both stih415 and stih416 SoCs Peter Griffin
[not found] ` <1400771902-26553-7-git-send-email-peter.griffin-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2014-05-22 15:41 ` Lee Jones
2014-05-22 15:18 ` [PATCH 7/8] ARM: STi: DT: Enable second sdhci controller for stih416 b2020 boards Peter Griffin
2014-05-22 15:39 ` Lee Jones
2014-05-22 15:18 ` [PATCH 8/8] ARM: update multi_v7_defconfig for STI Peter Griffin
2014-05-22 15:36 ` Lee Jones
2014-05-22 15:44 ` Add SDHCI support for STMicroelectronics SoCs Maxime Coquelin
2014-06-02 10:29 ` Peter Griffin
2014-06-02 13:53 ` Lee Jones
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=537EE84C.2020607@linaro.org \
--to=srinivas.kandagatla@linaro.org \
--cc=chris@printf.net \
--cc=devicetree@vger.kernel.org \
--cc=kernel@stlinux.com \
--cc=lee.jones@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mmc@vger.kernel.org \
--cc=maxime.coquelin@st.com \
--cc=patrice.chotard@st.com \
--cc=peppe.cavallaro@st.com \
--cc=peter.griffin@linaro.org \
--cc=srinivas.kandagatla@gmail.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).