Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c7bb4487 authored by Guennadi Liakhovetski's avatar Guennadi Liakhovetski Committed by Chris Ball
Browse files

mmc: sdhi: add OF support, make platform data optional



Add primitive support for OF to the SDHI TMIO glue, which also makes it
necessary to be able to run without platform data.

Signed-off-by: default avatarGuennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: default avatarChris Ball <cjb@laptop.org>
parent 3071cafb
Loading
Loading
Loading
Loading
+23 −12
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@
#include <linux/kernel.h>
#include <linux/clk.h>
#include <linux/slab.h>
#include <linux/mod_devicetable.h>
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/mmc/host.h>
@@ -133,13 +134,15 @@ static int __devinit sh_mobile_sdhi_probe(struct platform_device *pdev)
	}

	mmc_data = &priv->mmc_data;
	p->pdata = mmc_data;

	if (p) {
		p->pdata = mmc_data;
		if (p->init) {
			ret = p->init(pdev, &sdhi_ops);
			if (ret)
				goto einit;
		}
	}

	snprintf(clk_name, sizeof(clk_name), "sdhi%d", pdev->id);
	priv->clk = clk_get(&pdev->dev, clk_name);
@@ -149,10 +152,6 @@ static int __devinit sh_mobile_sdhi_probe(struct platform_device *pdev)
		goto eclkget;
	}

	if (p->set_pwr)
		mmc_data->set_pwr = sh_mobile_sdhi_set_pwr;
	if (p->get_cd)
		mmc_data->get_cd = sh_mobile_sdhi_get_cd;
	mmc_data->clk_enable = sh_mobile_sdhi_clk_enable;
	mmc_data->clk_disable = sh_mobile_sdhi_clk_disable;
	mmc_data->capabilities = MMC_CAP_MMC_HIGHSPEED;
@@ -164,6 +163,10 @@ static int __devinit sh_mobile_sdhi_probe(struct platform_device *pdev)
		mmc_data->capabilities |= p->tmio_caps;
		mmc_data->capabilities2 |= p->tmio_caps2;
		mmc_data->cd_gpio = p->cd_gpio;
		if (p->set_pwr)
			mmc_data->set_pwr = sh_mobile_sdhi_set_pwr;
		if (p->get_cd)
			mmc_data->get_cd = sh_mobile_sdhi_get_cd;

		if (p->dma_slave_tx > 0 && p->dma_slave_rx > 0) {
			priv->param_tx.slave_id = p->dma_slave_tx;
@@ -269,7 +272,7 @@ static int __devinit sh_mobile_sdhi_probe(struct platform_device *pdev)
eprobe:
	clk_put(priv->clk);
eclkget:
	if (p->cleanup)
	if (p && p->cleanup)
		p->cleanup(pdev);
einit:
	kfree(priv);
@@ -284,6 +287,7 @@ static int sh_mobile_sdhi_remove(struct platform_device *pdev)
	struct sh_mobile_sdhi_info *p = pdev->dev.platform_data;
	int i = 0, irq;

	if (p)
		p->pdata = NULL;

	tmio_mmc_host_remove(host);
@@ -297,7 +301,7 @@ static int sh_mobile_sdhi_remove(struct platform_device *pdev)

	clk_put(priv->clk);

	if (p->cleanup)
	if (p && p->cleanup)
		p->cleanup(pdev);

	kfree(priv);
@@ -312,11 +316,18 @@ static const struct dev_pm_ops tmio_mmc_dev_pm_ops = {
	.runtime_resume = tmio_mmc_host_runtime_resume,
};

static const struct of_device_id sh_mobile_sdhi_of_match[] = {
	{ .compatible = "renesas,shmobile-sdhi" },
	{ }
};
MODULE_DEVICE_TABLE(of, sh_mobile_sdhi_of_match);

static struct platform_driver sh_mobile_sdhi_driver = {
	.driver		= {
		.name	= "sh_mobile_sdhi",
		.owner	= THIS_MODULE,
		.pm	= &tmio_mmc_dev_pm_ops,
		.of_match_table = sh_mobile_sdhi_of_match,
	},
	.probe		= sh_mobile_sdhi_probe,
	.remove		= __devexit_p(sh_mobile_sdhi_remove),