Commit 85d6509d authored by Shawn Guo's avatar Shawn Guo Committed by Chris Ball
Browse files

mmc: sdhci: make sdhci-pltfm device drivers self registered



The patch turns the common stuff in sdhci-pltfm.c into functions, and
add device drivers their own .probe and .remove which in turn call
into the common functions, so that those sdhci-pltfm device drivers
register itself and keep all device specific things away from common
sdhci-pltfm file.

Signed-off-by: default avatarShawn Guo <shawn.guo@linaro.org>
Reviewed-by: default avatarGrant Likely <grant.likely@secretlab.ca>
Acked-by: default avatarArnd Bergmann <arnd@arndb.de>
Acked-by: default avatarAnton Vorontsov <cbouatmailru@gmail.com>
Signed-off-by: default avatarChris Ball <cjb@laptop.org>
parent 3a5c3743
Loading
Loading
Loading
Loading
+10 −19
Original line number Diff line number Diff line
@@ -112,29 +112,19 @@ config MMC_SDHCI_OF_HLWD

	  If unsure, say N.

config MMC_SDHCI_PLTFM
	tristate "SDHCI support on the platform specific bus"
	depends on MMC_SDHCI
	help
	  This selects the platform specific bus support for Secure Digital Host
	  Controller Interface.

	  If you have a controller with this interface, say Y or M here.

	  If unsure, say N.

config MMC_SDHCI_CNS3XXX
	bool "SDHCI support on the Cavium Networks CNS3xxx SoC"
	tristate "SDHCI support on the Cavium Networks CNS3xxx SoC"
	depends on ARCH_CNS3XXX
	depends on MMC_SDHCI_PLTFM
	depends on MMC_SDHCI
	help
	  This selects the SDHCI support for CNS3xxx System-on-Chip devices.

	  If unsure, say N.

config MMC_SDHCI_ESDHC_IMX
	bool "SDHCI platform support for the Freescale eSDHC i.MX controller"
	depends on MMC_SDHCI_PLTFM && (ARCH_MX25 || ARCH_MX35 || ARCH_MX5)
	tristate "SDHCI platform support for the Freescale eSDHC i.MX controller"
	depends on ARCH_MX25 || ARCH_MX35 || ARCH_MX5
	depends on MMC_SDHCI
	select MMC_SDHCI_IO_ACCESSORS
	help
	  This selects the Freescale eSDHC controller support on the platform
@@ -143,9 +133,9 @@ config MMC_SDHCI_ESDHC_IMX
	  If unsure, say N.

config MMC_SDHCI_DOVE
	bool "SDHCI support on Marvell's Dove SoC"
	tristate "SDHCI support on Marvell's Dove SoC"
	depends on ARCH_DOVE
	depends on MMC_SDHCI_PLTFM
	depends on MMC_SDHCI
	select MMC_SDHCI_IO_ACCESSORS
	help
	  This selects the Secure Digital Host Controller Interface in
@@ -154,8 +144,9 @@ config MMC_SDHCI_DOVE
	  If unsure, say N.

config MMC_SDHCI_TEGRA
	bool "SDHCI platform support for the Tegra SD/MMC Controller"
	depends on MMC_SDHCI_PLTFM && ARCH_TEGRA
	tristate "SDHCI platform support for the Tegra SD/MMC Controller"
	depends on ARCH_TEGRA
	depends on MMC_SDHCI
	select MMC_SDHCI_IO_ACCESSORS
	help
	  This selects the Tegra SD/MMC controller. If you have a Tegra
+8 −6
Original line number Diff line number Diff line
@@ -44,12 +44,14 @@ obj-$(CONFIG_MMC_JZ4740) += jz4740_mmc.o
obj-$(CONFIG_MMC_VUB300)	+= vub300.o
obj-$(CONFIG_MMC_USHC)		+= ushc.o

obj-$(CONFIG_MMC_SDHCI_PLTFM)			+= sdhci-platform.o
sdhci-platform-y				:= sdhci-pltfm.o
sdhci-platform-$(CONFIG_MMC_SDHCI_CNS3XXX)	+= sdhci-cns3xxx.o
sdhci-platform-$(CONFIG_MMC_SDHCI_ESDHC_IMX)	+= sdhci-esdhc-imx.o
sdhci-platform-$(CONFIG_MMC_SDHCI_DOVE)		+= sdhci-dove.o
sdhci-platform-$(CONFIG_MMC_SDHCI_TEGRA)	+= sdhci-tegra.o
obj-$(CONFIG_MMC_SDHCI_CNS3XXX)		+= sdhci-cns3xxx.o
sdhci-cns3xxx-objs			:= sdhci-pltfm.o
obj-$(CONFIG_MMC_SDHCI_ESDHC_IMX)	+= sdhci-esdhc-imx.o
sdhci-esdhc-imx-objs			:= sdhci-pltfm.o
obj-$(CONFIG_MMC_SDHCI_DOVE)		+= sdhci-dove.o
sdhci-dove-objs				:= sdhci-pltfm.o
obj-$(CONFIG_MMC_SDHCI_TEGRA)		+= sdhci-tegra.o
sdhci-tegra-objs			:= sdhci-pltfm.o

obj-$(CONFIG_MMC_SDHCI_OF)	+= sdhci-of.o
sdhci-of-y				:= sdhci-of-core.o
+41 −1
Original line number Diff line number Diff line
@@ -86,7 +86,7 @@ static struct sdhci_ops sdhci_cns3xxx_ops = {
	.set_clock	= sdhci_cns3xxx_set_clock,
};

struct sdhci_pltfm_data sdhci_cns3xxx_pdata = {
static struct sdhci_pltfm_data sdhci_cns3xxx_pdata = {
	.ops = &sdhci_cns3xxx_ops,
	.quirks = SDHCI_QUIRK_BROKEN_DMA |
		  SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK |
@@ -95,3 +95,43 @@ struct sdhci_pltfm_data sdhci_cns3xxx_pdata = {
		  SDHCI_QUIRK_BROKEN_TIMEOUT_VAL |
		  SDHCI_QUIRK_NONSTANDARD_CLOCK,
};

static int __devinit sdhci_cns3xxx_probe(struct platform_device *pdev)
{
	return sdhci_pltfm_register(pdev, &sdhci_cns3xxx_pdata);
}

static int __devexit sdhci_cns3xxx_remove(struct platform_device *pdev)
{
	return sdhci_pltfm_unregister(pdev);
}

static struct platform_driver sdhci_cns3xxx_driver = {
	.driver		= {
		.name	= "sdhci-cns3xxx",
		.owner	= THIS_MODULE,
	},
	.probe		= sdhci_cns3xxx_probe,
	.remove		= __devexit_p(sdhci_cns3xxx_remove),
#ifdef CONFIG_PM
	.suspend	= sdhci_pltfm_suspend,
	.resume		= sdhci_pltfm_resume,
#endif
};

static int __init sdhci_cns3xxx_init(void)
{
	return platform_driver_register(&sdhci_cns3xxx_driver);
}
module_init(sdhci_cns3xxx_init);

static void __exit sdhci_cns3xxx_exit(void)
{
	platform_driver_unregister(&sdhci_cns3xxx_driver);
}
module_exit(sdhci_cns3xxx_exit);

MODULE_DESCRIPTION("SDHCI driver for CNS3xxx");
MODULE_AUTHOR("Scott Shu, "
	      "Anton Vorontsov <avorontsov@mvista.com>");
MODULE_LICENSE("GPL v2");
+41 −1
Original line number Diff line number Diff line
@@ -61,10 +61,50 @@ static struct sdhci_ops sdhci_dove_ops = {
	.read_l	= sdhci_dove_readl,
};

struct sdhci_pltfm_data sdhci_dove_pdata = {
static struct sdhci_pltfm_data sdhci_dove_pdata = {
	.ops	= &sdhci_dove_ops,
	.quirks	= SDHCI_QUIRK_NO_SIMULT_VDD_AND_POWER |
		  SDHCI_QUIRK_NO_BUSY_IRQ |
		  SDHCI_QUIRK_BROKEN_TIMEOUT_VAL |
		  SDHCI_QUIRK_FORCE_DMA,
};

static int __devinit sdhci_dove_probe(struct platform_device *pdev)
{
	return sdhci_pltfm_register(pdev, &sdhci_dove_pdata);
}

static int __devexit sdhci_dove_remove(struct platform_device *pdev)
{
	return sdhci_pltfm_unregister(pdev);
}

static struct platform_driver sdhci_dove_driver = {
	.driver		= {
		.name	= "sdhci-dove",
		.owner	= THIS_MODULE,
	},
	.probe		= sdhci_dove_probe,
	.remove		= __devexit_p(sdhci_dove_remove),
#ifdef CONFIG_PM
	.suspend	= sdhci_pltfm_suspend,
	.resume		= sdhci_pltfm_resume,
#endif
};

static int __init sdhci_dove_init(void)
{
	return platform_driver_register(&sdhci_dove_driver);
}
module_init(sdhci_dove_init);

static void __exit sdhci_dove_exit(void)
{
	platform_driver_unregister(&sdhci_dove_driver);
}
module_exit(sdhci_dove_exit);

MODULE_DESCRIPTION("SDHCI driver for Dove");
MODULE_AUTHOR("Saeed Bishara <saeed@marvell.com>, "
	      "Mike Rapoport <mike@compulab.co.il>");
MODULE_LICENSE("GPL v2");
+82 −31
Original line number Diff line number Diff line
@@ -191,16 +191,6 @@ static unsigned int esdhc_pltfm_get_min_clock(struct sdhci_host *host)
	return clk_get_rate(pltfm_host->clk) / 256 / 16;
}

static unsigned int esdhc_pltfm_get_ro(struct sdhci_host *host)
{
	struct esdhc_platform_data *boarddata = host->mmc->parent->platform_data;

	if (boarddata && gpio_is_valid(boarddata->wp_gpio))
		return gpio_get_value(boarddata->wp_gpio);
	else
		return -ENOSYS;
}

static struct sdhci_ops sdhci_esdhc_ops = {
	.read_l = esdhc_readl_le,
	.read_w = esdhc_readw_le,
@@ -212,6 +202,24 @@ static struct sdhci_ops sdhci_esdhc_ops = {
	.get_min_clock = esdhc_pltfm_get_min_clock,
};

static struct sdhci_pltfm_data sdhci_esdhc_imx_pdata = {
	.quirks = ESDHC_DEFAULT_QUIRKS | SDHCI_QUIRK_BROKEN_ADMA
			| SDHCI_QUIRK_BROKEN_CARD_DETECTION,
	/* ADMA has issues. Might be fixable */
	.ops = &sdhci_esdhc_ops,
};

static unsigned int esdhc_pltfm_get_ro(struct sdhci_host *host)
{
	struct esdhc_platform_data *boarddata =
			host->mmc->parent->platform_data;

	if (boarddata && gpio_is_valid(boarddata->wp_gpio))
		return gpio_get_value(boarddata->wp_gpio);
	else
		return -ENOSYS;
}

static irqreturn_t cd_irq(int irq, void *data)
{
	struct sdhci_host *sdhost = (struct sdhci_host *)data;
@@ -220,30 +228,35 @@ static irqreturn_t cd_irq(int irq, void *data)
	return IRQ_HANDLED;
};

static int esdhc_pltfm_init(struct sdhci_host *host, struct sdhci_pltfm_data *pdata)
static int __devinit sdhci_esdhc_imx_probe(struct platform_device *pdev)
{
	struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
	struct esdhc_platform_data *boarddata = host->mmc->parent->platform_data;
	struct sdhci_pltfm_host *pltfm_host;
	struct sdhci_host *host;
	struct esdhc_platform_data *boarddata;
	struct clk *clk;
	int err;
	struct pltfm_imx_data *imx_data;

	host = sdhci_pltfm_init(pdev, &sdhci_esdhc_imx_pdata);
	if (IS_ERR(host))
		return PTR_ERR(host);

	pltfm_host = sdhci_priv(host);

	imx_data = kzalloc(sizeof(struct pltfm_imx_data), GFP_KERNEL);
	if (!imx_data)
		return -ENOMEM;
	pltfm_host->priv = imx_data;

	clk = clk_get(mmc_dev(host->mmc), NULL);
	if (IS_ERR(clk)) {
		dev_err(mmc_dev(host->mmc), "clk err\n");
		return PTR_ERR(clk);
		err = PTR_ERR(clk);
		goto err_clk_get;
	}
	clk_enable(clk);
	pltfm_host->clk = clk;

	imx_data = kzalloc(sizeof(struct pltfm_imx_data), GFP_KERNEL);
	if (!imx_data) {
		clk_disable(pltfm_host->clk);
		clk_put(pltfm_host->clk);
		return -ENOMEM;
	}
	pltfm_host->priv = imx_data;

	if (!cpu_is_mx25())
		host->quirks |= SDHCI_QUIRK_BROKEN_TIMEOUT_VAL;

@@ -257,6 +270,7 @@ static int esdhc_pltfm_init(struct sdhci_host *host, struct sdhci_pltfm_data *pd
	if (!(cpu_is_mx25() || cpu_is_mx35() || cpu_is_mx51()))
		imx_data->flags |= ESDHC_FLAG_MULTIBLK_NO_INT;

	boarddata = host->mmc->parent->platform_data;
	if (boarddata) {
		err = gpio_request_one(boarddata->wp_gpio, GPIOF_IN, "ESDHC_WP");
		if (err) {
@@ -289,6 +303,10 @@ static int esdhc_pltfm_init(struct sdhci_host *host, struct sdhci_pltfm_data *pd
		host->quirks &= ~SDHCI_QUIRK_BROKEN_CARD_DETECTION;
	}

	err = sdhci_add_host(host);
	if (err)
		goto err_add_host;

	return 0;

 no_card_detect_irq:
@@ -297,14 +315,23 @@ static int esdhc_pltfm_init(struct sdhci_host *host, struct sdhci_pltfm_data *pd
	boarddata->cd_gpio = err;
 not_supported:
	kfree(imx_data);
	return 0;
 err_add_host:
	clk_disable(pltfm_host->clk);
	clk_put(pltfm_host->clk);
 err_clk_get:
	sdhci_pltfm_free(pdev);
	return err;
}

static void esdhc_pltfm_exit(struct sdhci_host *host)
static int __devexit sdhci_esdhc_imx_remove(struct platform_device *pdev)
{
	struct sdhci_host *host = platform_get_drvdata(pdev);
	struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
	struct esdhc_platform_data *boarddata = host->mmc->parent->platform_data;
	struct pltfm_imx_data *imx_data = pltfm_host->priv;
	int dead = (readl(host->ioaddr + SDHCI_INT_STATUS) == 0xffffffff);

	sdhci_remove_host(host, dead);

	if (boarddata && gpio_is_valid(boarddata->wp_gpio))
		gpio_free(boarddata->wp_gpio);
@@ -319,13 +346,37 @@ static void esdhc_pltfm_exit(struct sdhci_host *host)
	clk_disable(pltfm_host->clk);
	clk_put(pltfm_host->clk);
	kfree(imx_data);

	sdhci_pltfm_free(pdev);

	return 0;
}

struct sdhci_pltfm_data sdhci_esdhc_imx_pdata = {
	.quirks = ESDHC_DEFAULT_QUIRKS | SDHCI_QUIRK_BROKEN_ADMA
			| SDHCI_QUIRK_BROKEN_CARD_DETECTION,
	/* ADMA has issues. Might be fixable */
	.ops = &sdhci_esdhc_ops,
	.init = esdhc_pltfm_init,
	.exit = esdhc_pltfm_exit,
static struct platform_driver sdhci_esdhc_imx_driver = {
	.driver		= {
		.name	= "sdhci-esdhc-imx",
		.owner	= THIS_MODULE,
	},
	.probe		= sdhci_esdhc_imx_probe,
	.remove		= __devexit_p(sdhci_esdhc_imx_remove),
#ifdef CONFIG_PM
	.suspend	= sdhci_pltfm_suspend,
	.resume		= sdhci_pltfm_resume,
#endif
};

static int __init sdhci_esdhc_imx_init(void)
{
	return platform_driver_register(&sdhci_esdhc_imx_driver);
}
module_init(sdhci_esdhc_imx_init);

static void __exit sdhci_esdhc_imx_exit(void)
{
	platform_driver_unregister(&sdhci_esdhc_imx_driver);
}
module_exit(sdhci_esdhc_imx_exit);

MODULE_DESCRIPTION("SDHCI driver for Freescale i.MX eSDHC");
MODULE_AUTHOR("Wolfram Sang <w.sang@pengutronix.de>");
MODULE_LICENSE("GPL v2");
Loading