From mboxrd@z Thu Jan 1 00:00:00 1970 From: Lee Jones Subject: Re: [PATCH 1/8] mmc: sdhci-st: Intial support for ST SDHCI controller Date: Thu, 22 May 2014 17:50:36 +0100 Message-ID: <20140522165036.GK19747@lee--X1> References: <1400771902-26553-1-git-send-email-peter.griffin@linaro.org> <1400771902-26553-2-git-send-email-peter.griffin@linaro.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Return-path: Content-Disposition: inline In-Reply-To: <1400771902-26553-2-git-send-email-peter.griffin-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> Sender: devicetree-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org To: Peter Griffin Cc: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, maxime.coquelin-qxv4g6HH51o@public.gmane.org, patrice.chotard-qxv4g6HH51o@public.gmane.org, srinivas.kandagatla-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org, chris-OsFVWbfNK3isTnJN9+BGXg@public.gmane.org, ulf.hansson-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org, kernel-F5mvAk5X5gdBDgjK7y7TUQ@public.gmane.org, linux-mmc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Giuseppe Cavallaro List-Id: linux-mmc@vger.kernel.org > This platform driver adds initial support for the SDHCI host controll= er > found on STMicroelectronics SoCs. >=20 > It has been tested on STiH41x b2020 platforms currently. >=20 > Signed-off-by: Peter Griffin > Signed-off-by: Giuseppe Cavallaro > --- > 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 =3D 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 =3D 0; > + u16 host_version; > + > + dev_dbg(&pdev->dev, "SDHCI ST platform driver\n"); > + > + pdata =3D devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); > + if (!pdata) > + return -ENOMEM; > + > + pdata->rstc =3D devm_reset_control_get(&pdev->dev, NULL); > + if (IS_ERR(pdata->rstc)) > + pdata->rstc =3D NULL; > + else > + reset_control_deassert(pdata->rstc); > + > + clk =3D devm_clk_get(&pdev->dev, "mmc"); > + if (IS_ERR(clk)) { > + dev_err(&pdev->dev, "Perpheral clk not found\n"); > + return PTR_ERR(clk); > + } > + > + host =3D 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 |=3D 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 |=3D MMC_CAP_NONREMOVABLE; > + > + pltfm_host =3D sdhci_priv(host); > + pltfm_host->clk =3D clk; > + > + ret =3D 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 =3D pdata; > + > + platform_set_drvdata(pdev, host); > + > + host_version =3D 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 =3D { > + .probe =3D sdhci_st_probe, > + .remove =3D sdhci_st_remove, > + .driver =3D { > + .name =3D "sdhci-st", > + .owner =3D THIS_MODULE, > + .pm =3D SDHCI_ST_PMOPS, > + .of_match_table =3D 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 "); > +MODULE_LICENSE("GPL v2"); > +MODULE_ALIAS("platform:st-sdhci"); --=20 Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org =E2=94=82 Open source software for ARM SoCs =46ollow Linaro: Facebook | Twitter | Blog -- To unsubscribe from this list: send the line "unsubscribe devicetree" i= n the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html