public inbox for linux-mmc@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] add support PXA168/PXA910/MMP2 SD Host Controller
@ 2010-09-20  9:46 zhangfei gao
  2010-09-20  9:50 ` Wolfram Sang
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: zhangfei gao @ 2010-09-20  9:46 UTC (permalink / raw)
  To: Chris Ball, linux-mmc; +Cc: Kyungmin Park, eric.y.miao, Haojian Zhuang

[-- Attachment #1: Type: text/plain, Size: 10103 bytes --]

Hi, Chris,

Here is patch to support pxa168(aspen)/pxa910(ttc)/mmp2, the
controller follow sdh 3.0.
Currently verified sd, Micron 16G emmc need some workaround, 8G is OK,
marvell 8787 would be verified later.
Help review.

>From 76c61b86ae8ae6b84030a31ec4ae7c08214de18b Mon Sep 17 00:00:00 2001
From: Zhangfei Gao <zhangfei.gao@marvell.com>
Date: Mon, 20 Sep 2010 10:51:28 -0400
Subject: [PATCH] mmc: add support of sdhci-pxa driver

	Support Marvell PXA168/PXA910/MMP2 SD Host Controller

Change-Id: I9f22b5a5664d4dd1b6cd2f8f4ef15a373ce123ff

Signed-off-by: Zhangfei Gao <zhangfei.gao@marvell.com>
---
 arch/arm/plat-pxa/include/plat/sdhci.h |   32 ++++
 drivers/mmc/host/Kconfig               |   12 ++
 drivers/mmc/host/Makefile              |    1 +
 drivers/mmc/host/sdhci-pxa.c           |  253 ++++++++++++++++++++++++++++++++
 4 files changed, 298 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/plat-pxa/include/plat/sdhci.h
 create mode 100644 drivers/mmc/host/sdhci-pxa.c

diff --git a/arch/arm/plat-pxa/include/plat/sdhci.h
b/arch/arm/plat-pxa/include/plat/sdhci.h
new file mode 100644
index 0000000..55e1c85
--- /dev/null
+++ b/arch/arm/plat-pxa/include/plat/sdhci.h
@@ -0,0 +1,32 @@
+/* linux/arch/arm/plat-pxa/include/plat/sdhci.h
+ *
+ * Copyright 2010 Marvell
+ *	Zhangfei Gao <zhangfei.gao@marvell.com>
+ *
+ * PXA Platform - SDHCI platform data definitions
+ *
+ * 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.
+*/
+
+#ifndef __PLAT_PXA_SDHCI_H
+#define __PLAT_PXA_SDHCI_H __FILE__
+
+/* pxa specific quirks */
+/* Card alwayes wired to host, like emmc */
+#define PXA_QUIRK_BROKEN_CARD_DETECTION (1<<0)
+/* Require clock free running */
+#define	PXA_QUIRK_DISABLE_CLOCK_GATING (1<<1)
+
+/**
+ * struct pxa_sdhci_platdata() - Platform device data for PXA SDHCI
+ * @max_speed: The maximum speed supported.
+ * @pxa_quirks: specific quirk of pxa
+*/
+struct sdhci_pxa_platdata {
+	unsigned int	max_speed;
+	unsigned int	pxa_quirk;
+};
+
+#endif /* __PLAT_PXA_SDHCI_H */
diff --git a/drivers/mmc/host/Kconfig b/drivers/mmc/host/Kconfig
index 6f12d5d..40aa3ba 100644
--- a/drivers/mmc/host/Kconfig
+++ b/drivers/mmc/host/Kconfig
@@ -158,6 +158,18 @@ config MMC_SDHCI_S3C

 	  If unsure, say N.

+config MMC_SDHCI_PXA
+	tristate "Marvell PXA168/PXA910/MMP2 SD Host Controller support"
+	depends on ARCH_PXA || ARCH_MMP
+	select MMC_SDHCI
+	select MMC_SDHCI_IO_ACCESSORS
+	help
+	  This selects the Marvell(R) PXA168/PXA910/MMP2 SD Host Controller.
+	  If you have a PXA168/PXA910/MMP2 platform with SD Host Controller and a
+	  card slot,say Y or M here.
+
+	  If unsure, say N.
+
 config MMC_SDHCI_SPEAR
 	tristate "SDHCI support on ST SPEAr platform"
 	depends on MMC_SDHCI && PLAT_SPEAR
diff --git a/drivers/mmc/host/Makefile b/drivers/mmc/host/Makefile
index 697bbfe..3a9f7fe 100644
--- a/drivers/mmc/host/Makefile
+++ b/drivers/mmc/host/Makefile
@@ -13,6 +13,7 @@ obj-$(CONFIG_MMC_MXC)		+= mxcmmc.o
 obj-$(CONFIG_MMC_SDHCI)		+= sdhci.o
 obj-$(CONFIG_MMC_SDHCI_MV)	+= sdhci-mv.o
 obj-$(CONFIG_MMC_SDHCI_PCI)	+= sdhci-pci.o
+obj-$(CONFIG_MMC_SDHCI_PXA)	+= sdhci-pxa.o
 obj-$(CONFIG_MMC_SDHCI_S3C)	+= sdhci-s3c.o
 obj-$(CONFIG_MMC_SDHCI_SPEAR)	+= sdhci-spear.o
 obj-$(CONFIG_MMC_WBSD)		+= wbsd.o
diff --git a/drivers/mmc/host/sdhci-pxa.c b/drivers/mmc/host/sdhci-pxa.c
new file mode 100644
index 0000000..3e091c1
--- /dev/null
+++ b/drivers/mmc/host/sdhci-pxa.c
@@ -0,0 +1,253 @@
+/* linux/drivers/mmc/host/sdhci-pxa.c
+ *
+ * Copyright 2010 Marvell
+ *      Zhangfei Gao <zhangfei.gao@marvell.com>
+ *
+ * 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.
+ */
+
+/* Supports:
+ * SDHCI support for MMP2/PXA910/PXA168
+ *
+ * Based on sdhci-platfm.c
+ */
+
+#include <linux/delay.h>
+#include <linux/platform_device.h>
+#include <linux/mmc/host.h>
+#include <linux/clk.h>
+#include <linux/io.h>
+#include <linux/err.h>
+#include <plat/sdhci.h>
+#include "sdhci.h"
+
+#define DRIVER_NAME	"sdhci-pxa"
+
+#define SD_FIFO_PARAM		0x104
+#define DIS_PAD_SD_CLK_GATE	0x400
+
+struct sdhci_pxa {
+	struct sdhci_host		*host;
+	struct sdhci_pxa_platdata	*pdata;
+	struct clk			*clk;
+	struct resource			*res;
+
+	u8 clk_enable;
+};
+
+/*****************************************************************************\
+ *                                                                           *
+ * SDHCI core callbacks                                                      *
+ *                                                                           *
+\*****************************************************************************/
+static void set_clock(struct sdhci_host *host, unsigned int clock)
+{
+	struct sdhci_pxa *pxa = sdhci_priv(host);
+	u32 tmp = 0;
+
+	if (clock == 0) {
+		if (pxa->clk_enable) {
+			clk_disable(pxa->clk);
+			pxa->clk_enable = 0;
+		}
+	} else {
+		if (0 == pxa->clk_enable) {
+			if (pxa->pdata->pxa_quirk
+					& PXA_QUIRK_DISABLE_CLOCK_GATING) {
+				tmp = readl(host->ioaddr + SD_FIFO_PARAM);
+				tmp |= DIS_PAD_SD_CLK_GATE;
+				writel(tmp, host->ioaddr + SD_FIFO_PARAM);
+			}
+			clk_enable(pxa->clk);
+			pxa->clk_enable = 1;
+		}
+	}
+}
+
+static struct sdhci_ops sdhci_pxa_ops = {
+	.set_clock = set_clock,
+};
+
+/*****************************************************************************\
+ *                                                                           *
+ * Device probing/removal                                                    *
+ *                                                                           *
+\*****************************************************************************/
+
+static int __devinit sdhci_pxa_probe(struct platform_device *pdev)
+{
+	struct sdhci_pxa_platdata *pdata = pdev->dev.platform_data;
+	struct device *dev = &pdev->dev;
+	struct sdhci_host *host = NULL;
+	struct resource *iomem;
+	struct sdhci_pxa *pxa;
+	int ret, irq;
+
+	irq = platform_get_irq(pdev, 0);
+	if (irq < 0) {
+		dev_err(dev, "no irq specified\n");
+		return irq;
+	}
+
+	iomem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (!iomem) {
+		dev_err(dev, "no memory specified\n");
+		return -ENOENT;
+	}
+
+	host = sdhci_alloc_host(&pdev->dev, sizeof(struct sdhci_pxa));
+	if (IS_ERR(host)) {
+		dev_err(dev, "failed to alloc host\n");
+		ret = PTR_ERR(host);
+		goto out;
+	}
+
+	pxa = sdhci_priv(host);
+	pxa->host = host;
+	pxa->pdata = pdata;
+	pxa->clk_enable = 0;
+
+	pxa->clk = clk_get(dev, "PXA-SDHCLK");
+	if (IS_ERR(pxa->clk)) {
+		dev_err(dev, "failed to get io clock\n");
+		ret = PTR_ERR(pxa->clk);
+		goto out;
+	}
+
+	pxa->res = request_mem_region(iomem->start, resource_size(iomem),
+		mmc_hostname(host->mmc));
+	if (!pxa->res) {
+		dev_err(&pdev->dev, "cannot request region\n");
+		ret = -EBUSY;
+		goto out;
+	}
+
+	host->ioaddr = ioremap(iomem->start, resource_size(iomem));
+	if (!host->ioaddr) {
+		dev_err(&pdev->dev, "failed to remap registers\n");
+		ret = -ENOMEM;
+		goto out;
+	}
+
+	host->hw_name = "MMC";
+	host->ops = &sdhci_pxa_ops;
+	host->irq = irq;
+	host->quirks = SDHCI_QUIRK_BROKEN_ADMA | SDHCI_QUIRK_BROKEN_TIMEOUT_VAL;
+
+	if (pdata->pxa_quirk & PXA_QUIRK_BROKEN_CARD_DETECTION)
+		host->quirks |= SDHCI_QUIRK_BROKEN_CARD_DETECTION;
+
+	ret = sdhci_add_host(host);
+	if (ret) {
+		dev_err(&pdev->dev, "failed to add host\n");
+		goto out;
+	}
+
+	if (pxa->pdata->max_speed)
+		host->mmc->f_max = pxa->pdata->max_speed;
+
+	platform_set_drvdata(pdev, host);
+
+	return 0;
+out:
+	if (host) {
+		if (host->ioaddr)
+			iounmap(host->ioaddr);
+		if (pxa->res)
+			release_mem_region(pxa->res->start,
+					resource_size(pxa->res));
+		sdhci_free_host(host);
+	}
+
+	return ret;
+}
+
+static int __devexit sdhci_pxa_remove(struct platform_device *pdev)
+{
+	struct sdhci_host *host = platform_get_drvdata(pdev);
+	struct sdhci_pxa *pxa = sdhci_priv(host);
+	int dead = 0;
+	u32 scratch;
+
+	if (host) {
+		scratch = readl(host->ioaddr + SDHCI_INT_STATUS);
+		if (scratch == (u32)-1)
+			dead = 1;
+
+		sdhci_remove_host(host, dead);
+
+		if (host->ioaddr)
+			iounmap(host->ioaddr);
+		if (pxa->res)
+			release_mem_region(pxa->res->start,
+					resource_size(pxa->res));
+		clk_disable(pxa->clk);
+		clk_put(pxa->clk);
+
+		sdhci_free_host(host);
+		platform_set_drvdata(pdev, NULL);
+	}
+
+	return 0;
+}
+
+#ifdef CONFIG_PM
+static int sdhci_pxa_suspend(struct platform_device *dev, pm_message_t state)
+{
+	struct sdhci_host *host = platform_get_drvdata(dev);
+	int ret = 0;
+
+	ret = sdhci_suspend_host(host, state);
+
+	return ret;
+}
+
+static int sdhci_pxa_resume(struct platform_device *dev)
+{
+	struct sdhci_host *host = platform_get_drvdata(dev);
+	int ret = 0;
+
+	ret = sdhci_resume_host(host);
+
+	return ret;
+}
+#else
+#define sdhci_pxa_suspend	NULL
+#define sdhci_pxa_resume	NULL
+#endif
+
+static struct platform_driver sdhci_pxa_driver = {
+	.probe		= sdhci_pxa_probe,
+	.remove		= sdhci_pxa_remove,
+	.suspend	= sdhci_pxa_suspend,
+	.resume		= sdhci_pxa_resume,
+	.driver		= {
+		.name	= DRIVER_NAME,
+		.owner	= THIS_MODULE,
+	},
+};
+
+/*****************************************************************************\
+ *                                                                           *
+ * Driver init/exit                                                          *
+ *                                                                           *
+\*****************************************************************************/
+
+static int __init sdhci_pxa_init(void)
+{
+	return platform_driver_register(&sdhci_pxa_driver);
+}
+
+static void __exit sdhci_pxa_exit(void)
+{
+	platform_driver_unregister(&sdhci_pxa_driver);
+}
+
+module_init(sdhci_pxa_init);
+module_exit(sdhci_pxa_exit);
+
+MODULE_DESCRIPTION("SDH controller driver for PXA168/PXA910/MMP2");
+MODULE_AUTHOR("Zhangfei Gao <zhangfei.gao@marvell.com>");
+MODULE_LICENSE("GPL v2");
-- 
1.7.0.4

[-- Attachment #2: 0001-mmc-add-support-of-sdhci-pxa-driver.patch --]
[-- Type: application/octet-stream, Size: 9882 bytes --]

From 76c61b86ae8ae6b84030a31ec4ae7c08214de18b Mon Sep 17 00:00:00 2001
From: Zhangfei Gao <zhangfei.gao@marvell.com>
Date: Mon, 20 Sep 2010 10:51:28 -0400
Subject: [PATCH] mmc: add support of sdhci-pxa driver

	Support Marvell PXA168/PXA910/MMP2 SD Host Controller

Change-Id: I9f22b5a5664d4dd1b6cd2f8f4ef15a373ce123ff

Signed-off-by: Zhangfei Gao <zhangfei.gao@marvell.com>
---
 arch/arm/plat-pxa/include/plat/sdhci.h |   32 ++++
 drivers/mmc/host/Kconfig               |   12 ++
 drivers/mmc/host/Makefile              |    1 +
 drivers/mmc/host/sdhci-pxa.c           |  253 ++++++++++++++++++++++++++++++++
 4 files changed, 298 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/plat-pxa/include/plat/sdhci.h
 create mode 100644 drivers/mmc/host/sdhci-pxa.c

diff --git a/arch/arm/plat-pxa/include/plat/sdhci.h b/arch/arm/plat-pxa/include/plat/sdhci.h
new file mode 100644
index 0000000..55e1c85
--- /dev/null
+++ b/arch/arm/plat-pxa/include/plat/sdhci.h
@@ -0,0 +1,32 @@
+/* linux/arch/arm/plat-pxa/include/plat/sdhci.h
+ *
+ * Copyright 2010 Marvell
+ *	Zhangfei Gao <zhangfei.gao@marvell.com>
+ *
+ * PXA Platform - SDHCI platform data definitions
+ *
+ * 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.
+*/
+
+#ifndef __PLAT_PXA_SDHCI_H
+#define __PLAT_PXA_SDHCI_H __FILE__
+
+/* pxa specific quirks */
+/* Card alwayes wired to host, like emmc */
+#define PXA_QUIRK_BROKEN_CARD_DETECTION (1<<0)
+/* Require clock free running */
+#define	PXA_QUIRK_DISABLE_CLOCK_GATING (1<<1)
+
+/**
+ * struct pxa_sdhci_platdata() - Platform device data for PXA SDHCI
+ * @max_speed: The maximum speed supported.
+ * @pxa_quirks: specific quirk of pxa
+*/
+struct sdhci_pxa_platdata {
+	unsigned int	max_speed;
+	unsigned int	pxa_quirk;
+};
+
+#endif /* __PLAT_PXA_SDHCI_H */
diff --git a/drivers/mmc/host/Kconfig b/drivers/mmc/host/Kconfig
index 6f12d5d..40aa3ba 100644
--- a/drivers/mmc/host/Kconfig
+++ b/drivers/mmc/host/Kconfig
@@ -158,6 +158,18 @@ config MMC_SDHCI_S3C
 
 	  If unsure, say N.
 
+config MMC_SDHCI_PXA
+	tristate "Marvell PXA168/PXA910/MMP2 SD Host Controller support"
+	depends on ARCH_PXA || ARCH_MMP
+	select MMC_SDHCI
+	select MMC_SDHCI_IO_ACCESSORS
+	help
+	  This selects the Marvell(R) PXA168/PXA910/MMP2 SD Host Controller.
+	  If you have a PXA168/PXA910/MMP2 platform with SD Host Controller and a
+	  card slot,say Y or M here.
+
+	  If unsure, say N.
+
 config MMC_SDHCI_SPEAR
 	tristate "SDHCI support on ST SPEAr platform"
 	depends on MMC_SDHCI && PLAT_SPEAR
diff --git a/drivers/mmc/host/Makefile b/drivers/mmc/host/Makefile
index 697bbfe..3a9f7fe 100644
--- a/drivers/mmc/host/Makefile
+++ b/drivers/mmc/host/Makefile
@@ -13,6 +13,7 @@ obj-$(CONFIG_MMC_MXC)		+= mxcmmc.o
 obj-$(CONFIG_MMC_SDHCI)		+= sdhci.o
 obj-$(CONFIG_MMC_SDHCI_MV)	+= sdhci-mv.o
 obj-$(CONFIG_MMC_SDHCI_PCI)	+= sdhci-pci.o
+obj-$(CONFIG_MMC_SDHCI_PXA)	+= sdhci-pxa.o
 obj-$(CONFIG_MMC_SDHCI_S3C)	+= sdhci-s3c.o
 obj-$(CONFIG_MMC_SDHCI_SPEAR)	+= sdhci-spear.o
 obj-$(CONFIG_MMC_WBSD)		+= wbsd.o
diff --git a/drivers/mmc/host/sdhci-pxa.c b/drivers/mmc/host/sdhci-pxa.c
new file mode 100644
index 0000000..3e091c1
--- /dev/null
+++ b/drivers/mmc/host/sdhci-pxa.c
@@ -0,0 +1,253 @@
+/* linux/drivers/mmc/host/sdhci-pxa.c
+ *
+ * Copyright 2010 Marvell
+ *      Zhangfei Gao <zhangfei.gao@marvell.com>
+ *
+ * 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.
+ */
+
+/* Supports:
+ * SDHCI support for MMP2/PXA910/PXA168
+ *
+ * Based on sdhci-platfm.c
+ */
+
+#include <linux/delay.h>
+#include <linux/platform_device.h>
+#include <linux/mmc/host.h>
+#include <linux/clk.h>
+#include <linux/io.h>
+#include <linux/err.h>
+#include <plat/sdhci.h>
+#include "sdhci.h"
+
+#define DRIVER_NAME	"sdhci-pxa"
+
+#define SD_FIFO_PARAM		0x104
+#define DIS_PAD_SD_CLK_GATE	0x400
+
+struct sdhci_pxa {
+	struct sdhci_host		*host;
+	struct sdhci_pxa_platdata	*pdata;
+	struct clk			*clk;
+	struct resource			*res;
+
+	u8 clk_enable;
+};
+
+/*****************************************************************************\
+ *                                                                           *
+ * SDHCI core callbacks                                                      *
+ *                                                                           *
+\*****************************************************************************/
+static void set_clock(struct sdhci_host *host, unsigned int clock)
+{
+	struct sdhci_pxa *pxa = sdhci_priv(host);
+	u32 tmp = 0;
+
+	if (clock == 0) {
+		if (pxa->clk_enable) {
+			clk_disable(pxa->clk);
+			pxa->clk_enable = 0;
+		}
+	} else {
+		if (0 == pxa->clk_enable) {
+			if (pxa->pdata->pxa_quirk
+					& PXA_QUIRK_DISABLE_CLOCK_GATING) {
+				tmp = readl(host->ioaddr + SD_FIFO_PARAM);
+				tmp |= DIS_PAD_SD_CLK_GATE;
+				writel(tmp, host->ioaddr + SD_FIFO_PARAM);
+			}
+			clk_enable(pxa->clk);
+			pxa->clk_enable = 1;
+		}
+	}
+}
+
+static struct sdhci_ops sdhci_pxa_ops = {
+	.set_clock = set_clock,
+};
+
+/*****************************************************************************\
+ *                                                                           *
+ * Device probing/removal                                                    *
+ *                                                                           *
+\*****************************************************************************/
+
+static int __devinit sdhci_pxa_probe(struct platform_device *pdev)
+{
+	struct sdhci_pxa_platdata *pdata = pdev->dev.platform_data;
+	struct device *dev = &pdev->dev;
+	struct sdhci_host *host = NULL;
+	struct resource *iomem;
+	struct sdhci_pxa *pxa;
+	int ret, irq;
+
+	irq = platform_get_irq(pdev, 0);
+	if (irq < 0) {
+		dev_err(dev, "no irq specified\n");
+		return irq;
+	}
+
+	iomem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (!iomem) {
+		dev_err(dev, "no memory specified\n");
+		return -ENOENT;
+	}
+
+	host = sdhci_alloc_host(&pdev->dev, sizeof(struct sdhci_pxa));
+	if (IS_ERR(host)) {
+		dev_err(dev, "failed to alloc host\n");
+		ret = PTR_ERR(host);
+		goto out;
+	}
+
+	pxa = sdhci_priv(host);
+	pxa->host = host;
+	pxa->pdata = pdata;
+	pxa->clk_enable = 0;
+
+	pxa->clk = clk_get(dev, "PXA-SDHCLK");
+	if (IS_ERR(pxa->clk)) {
+		dev_err(dev, "failed to get io clock\n");
+		ret = PTR_ERR(pxa->clk);
+		goto out;
+	}
+
+	pxa->res = request_mem_region(iomem->start, resource_size(iomem),
+		mmc_hostname(host->mmc));
+	if (!pxa->res) {
+		dev_err(&pdev->dev, "cannot request region\n");
+		ret = -EBUSY;
+		goto out;
+	}
+
+	host->ioaddr = ioremap(iomem->start, resource_size(iomem));
+	if (!host->ioaddr) {
+		dev_err(&pdev->dev, "failed to remap registers\n");
+		ret = -ENOMEM;
+		goto out;
+	}
+
+	host->hw_name = "MMC";
+	host->ops = &sdhci_pxa_ops;
+	host->irq = irq;
+	host->quirks = SDHCI_QUIRK_BROKEN_ADMA | SDHCI_QUIRK_BROKEN_TIMEOUT_VAL;
+
+	if (pdata->pxa_quirk & PXA_QUIRK_BROKEN_CARD_DETECTION)
+		host->quirks |= SDHCI_QUIRK_BROKEN_CARD_DETECTION;
+
+	ret = sdhci_add_host(host);
+	if (ret) {
+		dev_err(&pdev->dev, "failed to add host\n");
+		goto out;
+	}
+
+	if (pxa->pdata->max_speed)
+		host->mmc->f_max = pxa->pdata->max_speed;
+
+	platform_set_drvdata(pdev, host);
+
+	return 0;
+out:
+	if (host) {
+		if (host->ioaddr)
+			iounmap(host->ioaddr);
+		if (pxa->res)
+			release_mem_region(pxa->res->start,
+					resource_size(pxa->res));
+		sdhci_free_host(host);
+	}
+
+	return ret;
+}
+
+static int __devexit sdhci_pxa_remove(struct platform_device *pdev)
+{
+	struct sdhci_host *host = platform_get_drvdata(pdev);
+	struct sdhci_pxa *pxa = sdhci_priv(host);
+	int dead = 0;
+	u32 scratch;
+
+	if (host) {
+		scratch = readl(host->ioaddr + SDHCI_INT_STATUS);
+		if (scratch == (u32)-1)
+			dead = 1;
+
+		sdhci_remove_host(host, dead);
+
+		if (host->ioaddr)
+			iounmap(host->ioaddr);
+		if (pxa->res)
+			release_mem_region(pxa->res->start,
+					resource_size(pxa->res));
+		clk_disable(pxa->clk);
+		clk_put(pxa->clk);
+
+		sdhci_free_host(host);
+		platform_set_drvdata(pdev, NULL);
+	}
+
+	return 0;
+}
+
+#ifdef CONFIG_PM
+static int sdhci_pxa_suspend(struct platform_device *dev, pm_message_t state)
+{
+	struct sdhci_host *host = platform_get_drvdata(dev);
+	int ret = 0;
+
+	ret = sdhci_suspend_host(host, state);
+
+	return ret;
+}
+
+static int sdhci_pxa_resume(struct platform_device *dev)
+{
+	struct sdhci_host *host = platform_get_drvdata(dev);
+	int ret = 0;
+
+	ret = sdhci_resume_host(host);
+
+	return ret;
+}
+#else
+#define sdhci_pxa_suspend	NULL
+#define sdhci_pxa_resume	NULL
+#endif
+
+static struct platform_driver sdhci_pxa_driver = {
+	.probe		= sdhci_pxa_probe,
+	.remove		= sdhci_pxa_remove,
+	.suspend	= sdhci_pxa_suspend,
+	.resume		= sdhci_pxa_resume,
+	.driver		= {
+		.name	= DRIVER_NAME,
+		.owner	= THIS_MODULE,
+	},
+};
+
+/*****************************************************************************\
+ *                                                                           *
+ * Driver init/exit                                                          *
+ *                                                                           *
+\*****************************************************************************/
+
+static int __init sdhci_pxa_init(void)
+{
+	return platform_driver_register(&sdhci_pxa_driver);
+}
+
+static void __exit sdhci_pxa_exit(void)
+{
+	platform_driver_unregister(&sdhci_pxa_driver);
+}
+
+module_init(sdhci_pxa_init);
+module_exit(sdhci_pxa_exit);
+
+MODULE_DESCRIPTION("SDH controller driver for PXA168/PXA910/MMP2");
+MODULE_AUTHOR("Zhangfei Gao <zhangfei.gao@marvell.com>");
+MODULE_LICENSE("GPL v2");
-- 
1.7.0.4


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH] add support PXA168/PXA910/MMP2 SD Host Controller
  2010-09-20  9:46 [PATCH] add support PXA168/PXA910/MMP2 SD Host Controller zhangfei gao
@ 2010-09-20  9:50 ` Wolfram Sang
  2010-09-20 12:09   ` zhangfei gao
  2010-09-21  1:03 ` Chris Ball
  2010-09-21  9:42 ` claud yu
  2 siblings, 1 reply; 13+ messages in thread
From: Wolfram Sang @ 2010-09-20  9:50 UTC (permalink / raw)
  To: zhangfei gao
  Cc: Chris Ball, linux-mmc, Kyungmin Park, eric.y.miao, Haojian Zhuang

[-- Attachment #1: Type: text/plain, Size: 939 bytes --]

On Mon, Sep 20, 2010 at 05:46:02PM +0800, zhangfei gao wrote:

> diff --git a/drivers/mmc/host/sdhci-pxa.c b/drivers/mmc/host/sdhci-pxa.c
> new file mode 100644
> index 0000000..3e091c1
> --- /dev/null
> +++ b/drivers/mmc/host/sdhci-pxa.c
> @@ -0,0 +1,253 @@
> +/* linux/drivers/mmc/host/sdhci-pxa.c
> + *
> + * Copyright 2010 Marvell
> + *      Zhangfei Gao <zhangfei.gao@marvell.com>
> + *
> + * 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.
> + */
> +
> +/* Supports:
> + * SDHCI support for MMP2/PXA910/PXA168
> + *
> + * Based on sdhci-platfm.c
> + */

Why is it only "based on" and not directly using it?

-- 
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] add support PXA168/PXA910/MMP2 SD Host Controller
  2010-09-20  9:50 ` Wolfram Sang
@ 2010-09-20 12:09   ` zhangfei gao
  2010-09-20 13:10     ` Wolfram Sang
  0 siblings, 1 reply; 13+ messages in thread
From: zhangfei gao @ 2010-09-20 12:09 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: Chris Ball, linux-mmc, Kyungmin Park, eric.y.miao, Haojian Zhuang

[-- Attachment #1: Type: text/plain, Size: 12060 bytes --]

On Mon, Sep 20, 2010 at 5:50 AM, Wolfram Sang <w.sang@pengutronix.de> wrote:
> On Mon, Sep 20, 2010 at 05:46:02PM +0800, zhangfei gao wrote:
>
>> diff --git a/drivers/mmc/host/sdhci-pxa.c b/drivers/mmc/host/sdhci-pxa.c
>> new file mode 100644
>> index 0000000..3e091c1
>> --- /dev/null
>> +++ b/drivers/mmc/host/sdhci-pxa.c
>> @@ -0,0 +1,253 @@
>> +/* linux/drivers/mmc/host/sdhci-pxa.c
>> + *
>> + * Copyright 2010 Marvell
>> + *      Zhangfei Gao <zhangfei.gao@marvell.com>
>> + *
>> + * 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.
>> + */
>> +
>> +/* Supports:
>> + * SDHCI support for MMP2/PXA910/PXA168
>> + *
>> + * Based on sdhci-platfm.c
>> + */
>
> Why is it only "based on" and not directly using it?

Thanks for your suggestion.
This is the first stage, already implement sd card function, we will
have some patches later to enhance the driver.
We have to access many private registers to enable specific control.
Besides some sdio device need some specific control, like marvell 8787
host sleep, it is much reasonable to implement inside the driver.

>
> --
> Pengutronix e.K.                           | Wolfram Sang                |
> Industrial Linux Solutions                 | http://www.pengutronix.de/  |
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.10 (GNU/Linux)
>
> iEYEARECAAYFAkyXLnIACgkQD27XaX1/VRs1tACguzCS47XrzzMD+mWwFOSkgr1q
> AR8AnRbztMJI30NqFihZyE8bkVlFJe18
> =BsNX
> -----END PGP SIGNATURE-----
>
>

Update pm interface,

>From b49462b85bdc8f81cc074079fa768d53d8653cb1 Mon Sep 17 00:00:00 2001
From: Zhangfei Gao <zhangfei.gao@marvell.com>
Date: Mon, 20 Sep 2010 10:51:28 -0400
Subject: [PATCH] mmc: add support of sdhci-pxa driver

	Support Marvell PXA168/PXA910/MMP2 SD Host Controller

Signed-off-by: Zhangfei Gao <zhangfei.gao@marvell.com>
---
 arch/arm/plat-pxa/include/plat/sdhci.h |   32 ++++
 drivers/mmc/host/Kconfig               |   12 ++
 drivers/mmc/host/Makefile              |    1 +
 drivers/mmc/host/sdhci-pxa.c           |  260 ++++++++++++++++++++++++++++++++
 4 files changed, 305 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/plat-pxa/include/plat/sdhci.h
 create mode 100644 drivers/mmc/host/sdhci-pxa.c

diff --git a/arch/arm/plat-pxa/include/plat/sdhci.h
b/arch/arm/plat-pxa/include/plat/sdhci.h
new file mode 100644
index 0000000..55e1c85
--- /dev/null
+++ b/arch/arm/plat-pxa/include/plat/sdhci.h
@@ -0,0 +1,32 @@
+/* linux/arch/arm/plat-pxa/include/plat/sdhci.h
+ *
+ * Copyright 2010 Marvell
+ *	Zhangfei Gao <zhangfei.gao@marvell.com>
+ *
+ * PXA Platform - SDHCI platform data definitions
+ *
+ * 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.
+*/
+
+#ifndef __PLAT_PXA_SDHCI_H
+#define __PLAT_PXA_SDHCI_H __FILE__
+
+/* pxa specific quirks */
+/* Card alwayes wired to host, like emmc */
+#define PXA_QUIRK_BROKEN_CARD_DETECTION (1<<0)
+/* Require clock free running */
+#define	PXA_QUIRK_DISABLE_CLOCK_GATING (1<<1)
+
+/**
+ * struct pxa_sdhci_platdata() - Platform device data for PXA SDHCI
+ * @max_speed: The maximum speed supported.
+ * @pxa_quirks: specific quirk of pxa
+*/
+struct sdhci_pxa_platdata {
+	unsigned int	max_speed;
+	unsigned int	pxa_quirk;
+};
+
+#endif /* __PLAT_PXA_SDHCI_H */
diff --git a/drivers/mmc/host/Kconfig b/drivers/mmc/host/Kconfig
index 6f12d5d..40aa3ba 100644
--- a/drivers/mmc/host/Kconfig
+++ b/drivers/mmc/host/Kconfig
@@ -158,6 +158,18 @@ config MMC_SDHCI_S3C

 	  If unsure, say N.

+config MMC_SDHCI_PXA
+	tristate "Marvell PXA168/PXA910/MMP2 SD Host Controller support"
+	depends on ARCH_PXA || ARCH_MMP
+	select MMC_SDHCI
+	select MMC_SDHCI_IO_ACCESSORS
+	help
+	  This selects the Marvell(R) PXA168/PXA910/MMP2 SD Host Controller.
+	  If you have a PXA168/PXA910/MMP2 platform with SD Host Controller and a
+	  card slot,say Y or M here.
+
+	  If unsure, say N.
+
 config MMC_SDHCI_SPEAR
 	tristate "SDHCI support on ST SPEAr platform"
 	depends on MMC_SDHCI && PLAT_SPEAR
diff --git a/drivers/mmc/host/Makefile b/drivers/mmc/host/Makefile
index 697bbfe..3a9f7fe 100644
--- a/drivers/mmc/host/Makefile
+++ b/drivers/mmc/host/Makefile
@@ -13,6 +13,7 @@ obj-$(CONFIG_MMC_MXC)		+= mxcmmc.o
 obj-$(CONFIG_MMC_SDHCI)		+= sdhci.o
 obj-$(CONFIG_MMC_SDHCI_MV)	+= sdhci-mv.o
 obj-$(CONFIG_MMC_SDHCI_PCI)	+= sdhci-pci.o
+obj-$(CONFIG_MMC_SDHCI_PXA)	+= sdhci-pxa.o
 obj-$(CONFIG_MMC_SDHCI_S3C)	+= sdhci-s3c.o
 obj-$(CONFIG_MMC_SDHCI_SPEAR)	+= sdhci-spear.o
 obj-$(CONFIG_MMC_WBSD)		+= wbsd.o
diff --git a/drivers/mmc/host/sdhci-pxa.c b/drivers/mmc/host/sdhci-pxa.c
new file mode 100644
index 0000000..c375a6d
--- /dev/null
+++ b/drivers/mmc/host/sdhci-pxa.c
@@ -0,0 +1,260 @@
+/* linux/drivers/mmc/host/sdhci-pxa.c
+ *
+ * Copyright 2010 Marvell
+ *      Zhangfei Gao <zhangfei.gao@marvell.com>
+ *
+ * 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.
+ */
+
+/* Supports:
+ * SDHCI support for MMP2/PXA910/PXA168
+ *
+ * Based on sdhci-platfm.c
+ */
+
+#include <linux/delay.h>
+#include <linux/platform_device.h>
+#include <linux/mmc/host.h>
+#include <linux/clk.h>
+#include <linux/io.h>
+#include <linux/err.h>
+#include <plat/sdhci.h>
+#include "sdhci.h"
+
+#define DRIVER_NAME	"sdhci-pxa"
+
+#define SD_FIFO_PARAM		0x104
+#define DIS_PAD_SD_CLK_GATE	0x400
+
+struct sdhci_pxa {
+	struct sdhci_host		*host;
+	struct sdhci_pxa_platdata	*pdata;
+	struct clk			*clk;
+	struct resource			*res;
+
+	u8 clk_enable;
+};
+
+/*****************************************************************************\
+ *                                                                           *
+ * SDHCI core callbacks                                                      *
+ *                                                                           *
+\*****************************************************************************/
+static void set_clock(struct sdhci_host *host, unsigned int clock)
+{
+	struct sdhci_pxa *pxa = sdhci_priv(host);
+	u32 tmp = 0;
+
+	if (clock == 0) {
+		if (pxa->clk_enable) {
+			clk_disable(pxa->clk);
+			pxa->clk_enable = 0;
+		}
+	} else {
+		if (0 == pxa->clk_enable) {
+			if (pxa->pdata->pxa_quirk
+					& PXA_QUIRK_DISABLE_CLOCK_GATING) {
+				tmp = readl(host->ioaddr + SD_FIFO_PARAM);
+				tmp |= DIS_PAD_SD_CLK_GATE;
+				writel(tmp, host->ioaddr + SD_FIFO_PARAM);
+			}
+			clk_enable(pxa->clk);
+			pxa->clk_enable = 1;
+		}
+	}
+}
+
+static struct sdhci_ops sdhci_pxa_ops = {
+	.set_clock = set_clock,
+};
+
+/*****************************************************************************\
+ *                                                                           *
+ * Device probing/removal                                                    *
+ *                                                                           *
+\*****************************************************************************/
+
+static int __devinit sdhci_pxa_probe(struct platform_device *pdev)
+{
+	struct sdhci_pxa_platdata *pdata = pdev->dev.platform_data;
+	struct device *dev = &pdev->dev;
+	struct sdhci_host *host = NULL;
+	struct resource *iomem = NULL;
+	struct sdhci_pxa *pxa = NULL;
+	int ret, irq;
+
+	irq = platform_get_irq(pdev, 0);
+	if (irq < 0) {
+		dev_err(dev, "no irq specified\n");
+		return irq;
+	}
+
+	iomem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (!iomem) {
+		dev_err(dev, "no memory specified\n");
+		return -ENOENT;
+	}
+
+	host = sdhci_alloc_host(&pdev->dev, sizeof(struct sdhci_pxa));
+	if (IS_ERR(host)) {
+		dev_err(dev, "failed to alloc host\n");
+		ret = PTR_ERR(host);
+		goto out;
+	}
+
+	pxa = sdhci_priv(host);
+	pxa->host = host;
+	pxa->pdata = pdata;
+	pxa->clk_enable = 0;
+
+	pxa->clk = clk_get(dev, "PXA-SDHCLK");
+	if (IS_ERR(pxa->clk)) {
+		dev_err(dev, "failed to get io clock\n");
+		ret = PTR_ERR(pxa->clk);
+		goto out;
+	}
+
+	pxa->res = request_mem_region(iomem->start, resource_size(iomem),
+		mmc_hostname(host->mmc));
+	if (!pxa->res) {
+		dev_err(&pdev->dev, "cannot request region\n");
+		ret = -EBUSY;
+		goto out;
+	}
+
+	host->ioaddr = ioremap(iomem->start, resource_size(iomem));
+	if (!host->ioaddr) {
+		dev_err(&pdev->dev, "failed to remap registers\n");
+		ret = -ENOMEM;
+		goto out;
+	}
+
+	host->hw_name = "MMC";
+	host->ops = &sdhci_pxa_ops;
+	host->irq = irq;
+	host->quirks = SDHCI_QUIRK_BROKEN_ADMA | SDHCI_QUIRK_BROKEN_TIMEOUT_VAL;
+
+	if (pdata->pxa_quirk & PXA_QUIRK_BROKEN_CARD_DETECTION)
+		host->quirks |= SDHCI_QUIRK_BROKEN_CARD_DETECTION;
+
+	ret = sdhci_add_host(host);
+	if (ret) {
+		dev_err(&pdev->dev, "failed to add host\n");
+		goto out;
+	}
+
+	if (pxa->pdata->max_speed)
+		host->mmc->f_max = pxa->pdata->max_speed;
+
+	platform_set_drvdata(pdev, host);
+
+	return 0;
+out:
+	if (host) {
+		if (host->ioaddr)
+			iounmap(host->ioaddr);
+		if (pxa->res)
+			release_mem_region(pxa->res->start,
+					resource_size(pxa->res));
+		sdhci_free_host(host);
+	}
+
+	return ret;
+}
+
+static int __devexit sdhci_pxa_remove(struct platform_device *pdev)
+{
+	struct sdhci_host *host = platform_get_drvdata(pdev);
+	struct sdhci_pxa *pxa = sdhci_priv(host);
+	int dead = 0;
+	u32 scratch;
+
+	if (host) {
+		scratch = readl(host->ioaddr + SDHCI_INT_STATUS);
+		if (scratch == (u32)-1)
+			dead = 1;
+
+		sdhci_remove_host(host, dead);
+
+		if (host->ioaddr)
+			iounmap(host->ioaddr);
+		if (pxa->res)
+			release_mem_region(pxa->res->start,
+					resource_size(pxa->res));
+		clk_disable(pxa->clk);
+		clk_put(pxa->clk);
+
+		sdhci_free_host(host);
+		platform_set_drvdata(pdev, NULL);
+	}
+
+	return 0;
+}
+
+#ifdef CONFIG_PM
+static int sdhci_pxa_suspend(struct platform_device *dev)
+{
+	struct platform_device *pdev = to_platform_device(dev);
+	struct sdhci_host *host = platform_get_drvdata(dev);
+	int ret = 0;
+
+	ret = sdhci_suspend_host(host, state);
+
+	return ret;
+}
+
+static int sdhci_pxa_resume(struct platform_device *dev)
+{
+	struct platform_device *pdev = to_platform_device(dev);
+	struct sdhci_host *host = platform_get_drvdata(dev);
+	int ret = 0;
+
+	ret = sdhci_resume_host(host);
+
+	return ret;
+}
+#else
+#define sdhci_pxa_suspend	NULL
+#define sdhci_pxa_resume	NULL
+#endif
+
+static const struct dev_pm_ops sdhci_pxa_pm_ops = {
+	.suspend	= sdhci_pxa_suspend,
+	.resume		= sdhci_pxa_resume,
+};
+
+
+static struct platform_driver sdhci_pxa_driver = {
+	.probe		= sdhci_pxa_probe,
+	.remove		= __devexit_p(sdhci_pxa_remove),
+	.driver		= {
+		.name	= DRIVER_NAME,
+		.owner	= THIS_MODULE,
+		.pm = &sdhci_pxa_pm_ops,
+	},
+};
+
+/*****************************************************************************\
+ *                                                                           *
+ * Driver init/exit                                                          *
+ *                                                                           *
+\*****************************************************************************/
+
+static int __init sdhci_pxa_init(void)
+{
+	return platform_driver_register(&sdhci_pxa_driver);
+}
+
+static void __exit sdhci_pxa_exit(void)
+{
+	platform_driver_unregister(&sdhci_pxa_driver);
+}
+
+module_init(sdhci_pxa_init);
+module_exit(sdhci_pxa_exit);
+
+MODULE_DESCRIPTION("SDH controller driver for PXA168/PXA910/MMP2");
+MODULE_AUTHOR("Zhangfei Gao <zhangfei.gao@marvell.com>");
+MODULE_LICENSE("GPL v2");
-- 
1.7.0.4

[-- Attachment #2: 0001-mmc-add-support-of-sdhci-pxa-driver.patch --]
[-- Type: text/x-patch, Size: 10040 bytes --]

From b49462b85bdc8f81cc074079fa768d53d8653cb1 Mon Sep 17 00:00:00 2001
From: Zhangfei Gao <zhangfei.gao@marvell.com>
Date: Mon, 20 Sep 2010 10:51:28 -0400
Subject: [PATCH] mmc: add support of sdhci-pxa driver

	Support Marvell PXA168/PXA910/MMP2 SD Host Controller

Signed-off-by: Zhangfei Gao <zhangfei.gao@marvell.com>
---
 arch/arm/plat-pxa/include/plat/sdhci.h |   32 ++++
 drivers/mmc/host/Kconfig               |   12 ++
 drivers/mmc/host/Makefile              |    1 +
 drivers/mmc/host/sdhci-pxa.c           |  260 ++++++++++++++++++++++++++++++++
 4 files changed, 305 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/plat-pxa/include/plat/sdhci.h
 create mode 100644 drivers/mmc/host/sdhci-pxa.c

diff --git a/arch/arm/plat-pxa/include/plat/sdhci.h b/arch/arm/plat-pxa/include/plat/sdhci.h
new file mode 100644
index 0000000..55e1c85
--- /dev/null
+++ b/arch/arm/plat-pxa/include/plat/sdhci.h
@@ -0,0 +1,32 @@
+/* linux/arch/arm/plat-pxa/include/plat/sdhci.h
+ *
+ * Copyright 2010 Marvell
+ *	Zhangfei Gao <zhangfei.gao@marvell.com>
+ *
+ * PXA Platform - SDHCI platform data definitions
+ *
+ * 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.
+*/
+
+#ifndef __PLAT_PXA_SDHCI_H
+#define __PLAT_PXA_SDHCI_H __FILE__
+
+/* pxa specific quirks */
+/* Card alwayes wired to host, like emmc */
+#define PXA_QUIRK_BROKEN_CARD_DETECTION (1<<0)
+/* Require clock free running */
+#define	PXA_QUIRK_DISABLE_CLOCK_GATING (1<<1)
+
+/**
+ * struct pxa_sdhci_platdata() - Platform device data for PXA SDHCI
+ * @max_speed: The maximum speed supported.
+ * @pxa_quirks: specific quirk of pxa
+*/
+struct sdhci_pxa_platdata {
+	unsigned int	max_speed;
+	unsigned int	pxa_quirk;
+};
+
+#endif /* __PLAT_PXA_SDHCI_H */
diff --git a/drivers/mmc/host/Kconfig b/drivers/mmc/host/Kconfig
index 6f12d5d..40aa3ba 100644
--- a/drivers/mmc/host/Kconfig
+++ b/drivers/mmc/host/Kconfig
@@ -158,6 +158,18 @@ config MMC_SDHCI_S3C
 
 	  If unsure, say N.
 
+config MMC_SDHCI_PXA
+	tristate "Marvell PXA168/PXA910/MMP2 SD Host Controller support"
+	depends on ARCH_PXA || ARCH_MMP
+	select MMC_SDHCI
+	select MMC_SDHCI_IO_ACCESSORS
+	help
+	  This selects the Marvell(R) PXA168/PXA910/MMP2 SD Host Controller.
+	  If you have a PXA168/PXA910/MMP2 platform with SD Host Controller and a
+	  card slot,say Y or M here.
+
+	  If unsure, say N.
+
 config MMC_SDHCI_SPEAR
 	tristate "SDHCI support on ST SPEAr platform"
 	depends on MMC_SDHCI && PLAT_SPEAR
diff --git a/drivers/mmc/host/Makefile b/drivers/mmc/host/Makefile
index 697bbfe..3a9f7fe 100644
--- a/drivers/mmc/host/Makefile
+++ b/drivers/mmc/host/Makefile
@@ -13,6 +13,7 @@ obj-$(CONFIG_MMC_MXC)		+= mxcmmc.o
 obj-$(CONFIG_MMC_SDHCI)		+= sdhci.o
 obj-$(CONFIG_MMC_SDHCI_MV)	+= sdhci-mv.o
 obj-$(CONFIG_MMC_SDHCI_PCI)	+= sdhci-pci.o
+obj-$(CONFIG_MMC_SDHCI_PXA)	+= sdhci-pxa.o
 obj-$(CONFIG_MMC_SDHCI_S3C)	+= sdhci-s3c.o
 obj-$(CONFIG_MMC_SDHCI_SPEAR)	+= sdhci-spear.o
 obj-$(CONFIG_MMC_WBSD)		+= wbsd.o
diff --git a/drivers/mmc/host/sdhci-pxa.c b/drivers/mmc/host/sdhci-pxa.c
new file mode 100644
index 0000000..c375a6d
--- /dev/null
+++ b/drivers/mmc/host/sdhci-pxa.c
@@ -0,0 +1,260 @@
+/* linux/drivers/mmc/host/sdhci-pxa.c
+ *
+ * Copyright 2010 Marvell
+ *      Zhangfei Gao <zhangfei.gao@marvell.com>
+ *
+ * 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.
+ */
+
+/* Supports:
+ * SDHCI support for MMP2/PXA910/PXA168
+ *
+ * Based on sdhci-platfm.c
+ */
+
+#include <linux/delay.h>
+#include <linux/platform_device.h>
+#include <linux/mmc/host.h>
+#include <linux/clk.h>
+#include <linux/io.h>
+#include <linux/err.h>
+#include <plat/sdhci.h>
+#include "sdhci.h"
+
+#define DRIVER_NAME	"sdhci-pxa"
+
+#define SD_FIFO_PARAM		0x104
+#define DIS_PAD_SD_CLK_GATE	0x400
+
+struct sdhci_pxa {
+	struct sdhci_host		*host;
+	struct sdhci_pxa_platdata	*pdata;
+	struct clk			*clk;
+	struct resource			*res;
+
+	u8 clk_enable;
+};
+
+/*****************************************************************************\
+ *                                                                           *
+ * SDHCI core callbacks                                                      *
+ *                                                                           *
+\*****************************************************************************/
+static void set_clock(struct sdhci_host *host, unsigned int clock)
+{
+	struct sdhci_pxa *pxa = sdhci_priv(host);
+	u32 tmp = 0;
+
+	if (clock == 0) {
+		if (pxa->clk_enable) {
+			clk_disable(pxa->clk);
+			pxa->clk_enable = 0;
+		}
+	} else {
+		if (0 == pxa->clk_enable) {
+			if (pxa->pdata->pxa_quirk
+					& PXA_QUIRK_DISABLE_CLOCK_GATING) {
+				tmp = readl(host->ioaddr + SD_FIFO_PARAM);
+				tmp |= DIS_PAD_SD_CLK_GATE;
+				writel(tmp, host->ioaddr + SD_FIFO_PARAM);
+			}
+			clk_enable(pxa->clk);
+			pxa->clk_enable = 1;
+		}
+	}
+}
+
+static struct sdhci_ops sdhci_pxa_ops = {
+	.set_clock = set_clock,
+};
+
+/*****************************************************************************\
+ *                                                                           *
+ * Device probing/removal                                                    *
+ *                                                                           *
+\*****************************************************************************/
+
+static int __devinit sdhci_pxa_probe(struct platform_device *pdev)
+{
+	struct sdhci_pxa_platdata *pdata = pdev->dev.platform_data;
+	struct device *dev = &pdev->dev;
+	struct sdhci_host *host = NULL;
+	struct resource *iomem = NULL;
+	struct sdhci_pxa *pxa = NULL;
+	int ret, irq;
+
+	irq = platform_get_irq(pdev, 0);
+	if (irq < 0) {
+		dev_err(dev, "no irq specified\n");
+		return irq;
+	}
+
+	iomem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (!iomem) {
+		dev_err(dev, "no memory specified\n");
+		return -ENOENT;
+	}
+
+	host = sdhci_alloc_host(&pdev->dev, sizeof(struct sdhci_pxa));
+	if (IS_ERR(host)) {
+		dev_err(dev, "failed to alloc host\n");
+		ret = PTR_ERR(host);
+		goto out;
+	}
+
+	pxa = sdhci_priv(host);
+	pxa->host = host;
+	pxa->pdata = pdata;
+	pxa->clk_enable = 0;
+
+	pxa->clk = clk_get(dev, "PXA-SDHCLK");
+	if (IS_ERR(pxa->clk)) {
+		dev_err(dev, "failed to get io clock\n");
+		ret = PTR_ERR(pxa->clk);
+		goto out;
+	}
+
+	pxa->res = request_mem_region(iomem->start, resource_size(iomem),
+		mmc_hostname(host->mmc));
+	if (!pxa->res) {
+		dev_err(&pdev->dev, "cannot request region\n");
+		ret = -EBUSY;
+		goto out;
+	}
+
+	host->ioaddr = ioremap(iomem->start, resource_size(iomem));
+	if (!host->ioaddr) {
+		dev_err(&pdev->dev, "failed to remap registers\n");
+		ret = -ENOMEM;
+		goto out;
+	}
+
+	host->hw_name = "MMC";
+	host->ops = &sdhci_pxa_ops;
+	host->irq = irq;
+	host->quirks = SDHCI_QUIRK_BROKEN_ADMA | SDHCI_QUIRK_BROKEN_TIMEOUT_VAL;
+
+	if (pdata->pxa_quirk & PXA_QUIRK_BROKEN_CARD_DETECTION)
+		host->quirks |= SDHCI_QUIRK_BROKEN_CARD_DETECTION;
+
+	ret = sdhci_add_host(host);
+	if (ret) {
+		dev_err(&pdev->dev, "failed to add host\n");
+		goto out;
+	}
+
+	if (pxa->pdata->max_speed)
+		host->mmc->f_max = pxa->pdata->max_speed;
+
+	platform_set_drvdata(pdev, host);
+
+	return 0;
+out:
+	if (host) {
+		if (host->ioaddr)
+			iounmap(host->ioaddr);
+		if (pxa->res)
+			release_mem_region(pxa->res->start,
+					resource_size(pxa->res));
+		sdhci_free_host(host);
+	}
+
+	return ret;
+}
+
+static int __devexit sdhci_pxa_remove(struct platform_device *pdev)
+{
+	struct sdhci_host *host = platform_get_drvdata(pdev);
+	struct sdhci_pxa *pxa = sdhci_priv(host);
+	int dead = 0;
+	u32 scratch;
+
+	if (host) {
+		scratch = readl(host->ioaddr + SDHCI_INT_STATUS);
+		if (scratch == (u32)-1)
+			dead = 1;
+
+		sdhci_remove_host(host, dead);
+
+		if (host->ioaddr)
+			iounmap(host->ioaddr);
+		if (pxa->res)
+			release_mem_region(pxa->res->start,
+					resource_size(pxa->res));
+		clk_disable(pxa->clk);
+		clk_put(pxa->clk);
+
+		sdhci_free_host(host);
+		platform_set_drvdata(pdev, NULL);
+	}
+
+	return 0;
+}
+
+#ifdef CONFIG_PM
+static int sdhci_pxa_suspend(struct platform_device *dev)
+{
+	struct platform_device *pdev = to_platform_device(dev);
+	struct sdhci_host *host = platform_get_drvdata(dev);
+	int ret = 0;
+
+	ret = sdhci_suspend_host(host, state);
+
+	return ret;
+}
+
+static int sdhci_pxa_resume(struct platform_device *dev)
+{
+	struct platform_device *pdev = to_platform_device(dev);
+	struct sdhci_host *host = platform_get_drvdata(dev);
+	int ret = 0;
+
+	ret = sdhci_resume_host(host);
+
+	return ret;
+}
+#else
+#define sdhci_pxa_suspend	NULL
+#define sdhci_pxa_resume	NULL
+#endif
+
+static const struct dev_pm_ops sdhci_pxa_pm_ops = {
+	.suspend	= sdhci_pxa_suspend,
+	.resume		= sdhci_pxa_resume,
+};
+
+
+static struct platform_driver sdhci_pxa_driver = {
+	.probe		= sdhci_pxa_probe,
+	.remove		= __devexit_p(sdhci_pxa_remove),
+	.driver		= {
+		.name	= DRIVER_NAME,
+		.owner	= THIS_MODULE,
+		.pm = &sdhci_pxa_pm_ops,
+	},
+};
+
+/*****************************************************************************\
+ *                                                                           *
+ * Driver init/exit                                                          *
+ *                                                                           *
+\*****************************************************************************/
+
+static int __init sdhci_pxa_init(void)
+{
+	return platform_driver_register(&sdhci_pxa_driver);
+}
+
+static void __exit sdhci_pxa_exit(void)
+{
+	platform_driver_unregister(&sdhci_pxa_driver);
+}
+
+module_init(sdhci_pxa_init);
+module_exit(sdhci_pxa_exit);
+
+MODULE_DESCRIPTION("SDH controller driver for PXA168/PXA910/MMP2");
+MODULE_AUTHOR("Zhangfei Gao <zhangfei.gao@marvell.com>");
+MODULE_LICENSE("GPL v2");
-- 
1.7.0.4


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH] add support PXA168/PXA910/MMP2 SD Host Controller
  2010-09-20 12:09   ` zhangfei gao
@ 2010-09-20 13:10     ` Wolfram Sang
  2010-09-21  8:24       ` zhangfei gao
  0 siblings, 1 reply; 13+ messages in thread
From: Wolfram Sang @ 2010-09-20 13:10 UTC (permalink / raw)
  To: zhangfei gao
  Cc: Chris Ball, linux-mmc, Kyungmin Park, eric.y.miao, Haojian Zhuang

[-- Attachment #1: Type: text/plain, Size: 1673 bytes --]

On Mon, Sep 20, 2010 at 08:09:26AM -0400, zhangfei gao wrote:
> On Mon, Sep 20, 2010 at 5:50 AM, Wolfram Sang <w.sang@pengutronix.de> wrote:
> > On Mon, Sep 20, 2010 at 05:46:02PM +0800, zhangfei gao wrote:
> >
> >> diff --git a/drivers/mmc/host/sdhci-pxa.c b/drivers/mmc/host/sdhci-pxa.c
> >> new file mode 100644
> >> index 0000000..3e091c1
> >> --- /dev/null
> >> +++ b/drivers/mmc/host/sdhci-pxa.c
> >> @@ -0,0 +1,253 @@
> >> +/* linux/drivers/mmc/host/sdhci-pxa.c
> >> + *
> >> + * Copyright 2010 Marvell
> >> + *      Zhangfei Gao <zhangfei.gao@marvell.com>
> >> + *
> >> + * 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.
> >> + */
> >> +
> >> +/* Supports:
> >> + * SDHCI support for MMP2/PXA910/PXA168
> >> + *
> >> + * Based on sdhci-platfm.c
> >> + */
> >
> > Why is it only "based on" and not directly using it?
> 
> Thanks for your suggestion.
> This is the first stage, already implement sd card function, we will
> have some patches later to enhance the driver.
> We have to access many private registers to enable specific control.
> Besides some sdio device need some specific control, like marvell 8787
> host sleep, it is much reasonable to implement inside the driver.

Hmm, which hooks are missing for you to implement this as an extension
of the pltfm-driver? Maybe it makes sense to simply add this hook?

-- 
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] add support PXA168/PXA910/MMP2 SD Host Controller
  2010-09-20  9:46 [PATCH] add support PXA168/PXA910/MMP2 SD Host Controller zhangfei gao
  2010-09-20  9:50 ` Wolfram Sang
@ 2010-09-21  1:03 ` Chris Ball
  2010-09-21  3:16   ` zhangfei gao
  2010-09-21  9:42 ` claud yu
  2 siblings, 1 reply; 13+ messages in thread
From: Chris Ball @ 2010-09-21  1:03 UTC (permalink / raw)
  To: zhangfei gao
  Cc: linux-mmc, Saeed Bishara, Kyungmin Park, eric.y.miao,
	Haojian Zhuang

Hi Zhangfei/Saeed,

On Mon, Sep 20, 2010 at 05:46:02PM +0800, zhangfei gao wrote:
> Hi, Chris,
> 
> Here is patch to support pxa168(aspen)/pxa910(ttc)/mmp2, the
> controller follow sdh 3.0.
> Currently verified sd, Micron 16G emmc need some workaround, 8G is OK,
> marvell 8787 would be verified later.
> Help review.

Could you help me understand how this new driver relates to the Marvell
SoC driver that I merged last week (CONFIG_MMC_SDHCI_MV)?  Are the SD
IPs in Dove and MMP2 different enough to warrant a separate driver, or
could support for both be included in sdhci-mv.c?

If we're going to have multiple drivers for the SD blocks in Armada/PXA,
it at least seems that MMC_SDHCI_MV has been mis-named.  Any thoughts?

Thanks,

- Chris.
-- 
Chris Ball   <cjb@laptop.org>   <http://printf.net/>
One Laptop Per Child

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] add support PXA168/PXA910/MMP2 SD Host Controller
  2010-09-21  1:03 ` Chris Ball
@ 2010-09-21  3:16   ` zhangfei gao
  2010-09-22  2:27     ` Chris Ball
  0 siblings, 1 reply; 13+ messages in thread
From: zhangfei gao @ 2010-09-21  3:16 UTC (permalink / raw)
  To: Chris Ball
  Cc: linux-mmc, Saeed Bishara, Kyungmin Park, eric.y.miao,
	Haojian Zhuang

On Mon, Sep 20, 2010 at 9:03 PM, Chris Ball <cjb@laptop.org> wrote:
> Hi Zhangfei/Saeed,
>
> On Mon, Sep 20, 2010 at 05:46:02PM +0800, zhangfei gao wrote:
>> Hi, Chris,
>>
>> Here is patch to support pxa168(aspen)/pxa910(ttc)/mmp2, the
>> controller follow sdh 3.0.
>> Currently verified sd, Micron 16G emmc need some workaround, 8G is OK,
>> marvell 8787 would be verified later.
>> Help review.
>
> Could you help me understand how this new driver relates to the Marvell
> SoC driver that I merged last week (CONFIG_MMC_SDHCI_MV)?  Are the SD
> IPs in Dove and MMP2 different enough to warrant a separate driver, or
> could support for both be included in sdhci-mv.c?
>
> If we're going to have multiple drivers for the SD blocks in Armada/PXA,
> it at least seems that MMC_SDHCI_MV has been mis-named.  Any thoughts?
>
> Thanks,
>
> - Chris.
> --
> Chris Ball   <cjb@laptop.org>   <http://printf.net/>
> One Laptop Per Child
>

Hi, Chris

We have considered using the same driver with dove once saeed push the
driver, but at last we decide to use seperate driver to easy
maintaince and further extension.

There are different IP developed by different group between Dove and
pxa168/pxa910/mmp2, and would be more and more different.
The pxa serious ip is follow sdh spec 3.0, and support sd 3.0 and emmc
4.4, which need ddr50 and 1.8v requirement, the limitation is adma
still has some issue and in fixing.
Still some private register with differnt address, such as power
control, clock timming tunning and etc.

The dove ip is follow sdh spec 2.0, and it has own limitation, such as
1.8v may not be supported.

In a word, they are differnt ip, and it is reasonable to use seprate driver.

Thanks

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] add support PXA168/PXA910/MMP2 SD Host Controller
  2010-09-20 13:10     ` Wolfram Sang
@ 2010-09-21  8:24       ` zhangfei gao
  2010-09-21 10:11         ` Wolfram Sang
  0 siblings, 1 reply; 13+ messages in thread
From: zhangfei gao @ 2010-09-21  8:24 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: Chris Ball, linux-mmc, Kyungmin Park, eric.y.miao, Haojian Zhuang

On Mon, Sep 20, 2010 at 9:10 AM, Wolfram Sang <w.sang@pengutronix.de> wrote:
> On Mon, Sep 20, 2010 at 08:09:26AM -0400, zhangfei gao wrote:
>> On Mon, Sep 20, 2010 at 5:50 AM, Wolfram Sang <w.sang@pengutronix.de> wrote:
>> > On Mon, Sep 20, 2010 at 05:46:02PM +0800, zhangfei gao wrote:
>> >
>> >> diff --git a/drivers/mmc/host/sdhci-pxa.c b/drivers/mmc/host/sdhci-pxa.c
>> >> new file mode 100644
>> >> index 0000000..3e091c1
>> >> --- /dev/null
>> >> +++ b/drivers/mmc/host/sdhci-pxa.c
>> >> @@ -0,0 +1,253 @@
>> >> +/* linux/drivers/mmc/host/sdhci-pxa.c
>> >> + *
>> >> + * Copyright 2010 Marvell
>> >> + *      Zhangfei Gao <zhangfei.gao@marvell.com>
>> >> + *
>> >> + * 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.
>> >> + */
>> >> +
>> >> +/* Supports:
>> >> + * SDHCI support for MMP2/PXA910/PXA168
>> >> + *
>> >> + * Based on sdhci-platfm.c
>> >> + */
>> >
>> > Why is it only "based on" and not directly using it?
>>
>> Thanks for your suggestion.
>> This is the first stage, already implement sd card function, we will
>> have some patches later to enhance the driver.
>> We have to access many private registers to enable specific control.
>> Besides some sdio device need some specific control, like marvell 8787
>> host sleep, it is much reasonable to implement inside the driver.
>
> Hmm, which hooks are missing for you to implement this as an extension
> of the pltfm-driver? Maybe it makes sense to simply add this hook?

We refered several mmc host drivers, such as sdhci-s3c.c,
sdhci-spear.c, and we want to align with others, which also meet pxa
requirement and low risk to transfer from the existing driver.

We have three or four device in one soc with the same driver, for
example one for sd, one for wifi, one for emmc, etc.
Each device have specific clock provider, which should be opened at
start, and closed when no operation to same power.
Specific quirk is needed for different device, which should be
transfered from platform data, for example on-chip wifi alwayes stay
on chip and emmc may require sd_clk free running to init.
The max_speed also may be different for board issue though controller
support max is 50M, which could get from capability.

>
> --
> Pengutronix e.K.                           | Wolfram Sang                |
> Industrial Linux Solutions                 | http://www.pengutronix.de/  |
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.10 (GNU/Linux)
>
> iEYEARECAAYFAkyXXV8ACgkQD27XaX1/VRtAxQCfafH+k4+HhWiDxM+cRqDn8KYC
> Mq0AnRrh3v5192K7LdpIlLIxVBQI4ljW
> =RPet
> -----END PGP SIGNATURE-----
>
>

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] add support PXA168/PXA910/MMP2 SD Host Controller
  2010-09-20  9:46 [PATCH] add support PXA168/PXA910/MMP2 SD Host Controller zhangfei gao
  2010-09-20  9:50 ` Wolfram Sang
  2010-09-21  1:03 ` Chris Ball
@ 2010-09-21  9:42 ` claud yu
  2010-09-26  9:05   ` zhangfei gao
  2 siblings, 1 reply; 13+ messages in thread
From: claud yu @ 2010-09-21  9:42 UTC (permalink / raw)
  To: zhangfei gao
  Cc: Chris Ball, linux-mmc, Kyungmin Park, eric.y.miao, Haojian Zhuang

Hi ,

I had worked with MMP2 platform several weeks. The mmc/sdio interface
have constraint about transfer size. The transfer size must be 8-byte
alignment. If any transfer size is 4 byte alignment and not 8-byte
alignment. This peripheral ip can't support(miss dma end interrupt or
bad transmission) even DMA mode or PIO mode.

Claud Yu

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] add support PXA168/PXA910/MMP2 SD Host Controller
  2010-09-21  8:24       ` zhangfei gao
@ 2010-09-21 10:11         ` Wolfram Sang
  2010-09-21 10:18           ` Eric Miao
  2010-09-21 16:18           ` Chris Ball
  0 siblings, 2 replies; 13+ messages in thread
From: Wolfram Sang @ 2010-09-21 10:11 UTC (permalink / raw)
  To: zhangfei gao
  Cc: Chris Ball, linux-mmc, Kyungmin Park, eric.y.miao, Haojian Zhuang

[-- Attachment #1: Type: text/plain, Size: 3287 bytes --]

> >> >> diff --git a/drivers/mmc/host/sdhci-pxa.c b/drivers/mmc/host/sdhci-pxa.c
> >> >> new file mode 100644
> >> >> index 0000000..3e091c1
> >> >> --- /dev/null
> >> >> +++ b/drivers/mmc/host/sdhci-pxa.c
> >> >> @@ -0,0 +1,253 @@
> >> >> +/* linux/drivers/mmc/host/sdhci-pxa.c
> >> >> + *
> >> >> + * Copyright 2010 Marvell
> >> >> + *      Zhangfei Gao <zhangfei.gao@marvell.com>
> >> >> + *
> >> >> + * 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.
> >> >> + */
> >> >> +
> >> >> +/* Supports:
> >> >> + * SDHCI support for MMP2/PXA910/PXA168
> >> >> + *
> >> >> + * Based on sdhci-platfm.c
> >> >> + */
> >> >
> >> > Why is it only "based on" and not directly using it?
> >>
> >> Thanks for your suggestion.
> >> This is the first stage, already implement sd card function, we will
> >> have some patches later to enhance the driver.
> >> We have to access many private registers to enable specific control.
> >> Besides some sdio device need some specific control, like marvell 8787
> >> host sleep, it is much reasonable to implement inside the driver.
> >
> > Hmm, which hooks are missing for you to implement this as an extension
> > of the pltfm-driver? Maybe it makes sense to simply add this hook?
> 
> We refered several mmc host drivers, such as sdhci-s3c.c,
> sdhci-spear.c, and we want to align with others, which also meet pxa
> requirement and low risk to transfer from the existing driver.

I see. It is true that the pltfm-part is not widely used up to now. The
question is if it might be a good idea to change this? There have been
voices asking to merge the s3c-driver into the pltfm one. If you look at
sdhci-cns3xxx.c, it looks clearer and reduces code duplication. The
current state of the pltfm-driver might not cover all cases (yet), true,
but those should be at least identified IMHO. This will help us for
similar decisions in the future.

> We have three or four device in one soc with the same driver, for
> example one for sd, one for wifi, one for emmc, etc.
> Each device have specific clock provider, which should be opened at
> start, and closed when no operation to same power.
> Specific quirk is needed for different device, which should be
> transfered from platform data, for example on-chip wifi alwayes stay
> on chip and emmc may require sd_clk free running to init.
> The max_speed also may be different for board issue though controller
> support max is 50M, which could get from capability.

I guess to fully understand all constraints, one must really working
with your platform, what I don't do. I agree that a nicely working
driver is better than no driver; however, I fear once a driver hit the
mainline being non-pltfm, it will hardly be converted later, even if it
was considered to be worthwhile. So this is why I ask initially if it
couldn't be done.

Chris, do you see a rule of thumb here? Or what are your preferences?

Kind regards,

   Wolfram

-- 
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] add support PXA168/PXA910/MMP2 SD Host Controller
  2010-09-21 10:11         ` Wolfram Sang
@ 2010-09-21 10:18           ` Eric Miao
  2010-09-21 16:18           ` Chris Ball
  1 sibling, 0 replies; 13+ messages in thread
From: Eric Miao @ 2010-09-21 10:18 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: zhangfei gao, Chris Ball, linux-mmc, Kyungmin Park,
	Haojian Zhuang

On Tue, Sep 21, 2010 at 6:11 PM, Wolfram Sang <w.sang@pengutronix.de> wrote:
>> >> >> diff --git a/drivers/mmc/host/sdhci-pxa.c b/drivers/mmc/host/sdhci-pxa.c
>> >> >> new file mode 100644
>> >> >> index 0000000..3e091c1
>> >> >> --- /dev/null
>> >> >> +++ b/drivers/mmc/host/sdhci-pxa.c
>> >> >> @@ -0,0 +1,253 @@
>> >> >> +/* linux/drivers/mmc/host/sdhci-pxa.c
>> >> >> + *
>> >> >> + * Copyright 2010 Marvell
>> >> >> + *      Zhangfei Gao <zhangfei.gao@marvell.com>
>> >> >> + *
>> >> >> + * 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.
>> >> >> + */
>> >> >> +
>> >> >> +/* Supports:
>> >> >> + * SDHCI support for MMP2/PXA910/PXA168
>> >> >> + *
>> >> >> + * Based on sdhci-platfm.c
>> >> >> + */
>> >> >
>> >> > Why is it only "based on" and not directly using it?
>> >>
>> >> Thanks for your suggestion.
>> >> This is the first stage, already implement sd card function, we will
>> >> have some patches later to enhance the driver.
>> >> We have to access many private registers to enable specific control.
>> >> Besides some sdio device need some specific control, like marvell 8787
>> >> host sleep, it is much reasonable to implement inside the driver.
>> >
>> > Hmm, which hooks are missing for you to implement this as an extension
>> > of the pltfm-driver? Maybe it makes sense to simply add this hook?
>>
>> We refered several mmc host drivers, such as sdhci-s3c.c,
>> sdhci-spear.c, and we want to align with others, which also meet pxa
>> requirement and low risk to transfer from the existing driver.
>
> I see. It is true that the pltfm-part is not widely used up to now. The
> question is if it might be a good idea to change this? There have been
> voices asking to merge the s3c-driver into the pltfm one. If you look at
> sdhci-cns3xxx.c, it looks clearer and reduces code duplication. The
> current state of the pltfm-driver might not cover all cases (yet), true,
> but those should be at least identified IMHO. This will help us for
> similar decisions in the future.
>
>> We have three or four device in one soc with the same driver, for
>> example one for sd, one for wifi, one for emmc, etc.
>> Each device have specific clock provider, which should be opened at
>> start, and closed when no operation to same power.
>> Specific quirk is needed for different device, which should be
>> transfered from platform data, for example on-chip wifi alwayes stay
>> on chip and emmc may require sd_clk free running to init.
>> The max_speed also may be different for board issue though controller
>> support max is 50M, which could get from capability.
>
> I guess to fully understand all constraints, one must really working
> with your platform, what I don't do. I agree that a nicely working
> driver is better than no driver; however, I fear once a driver hit the
> mainline being non-pltfm, it will hardly be converted later, even if it
> was considered to be worthwhile. So this is why I ask initially if it
> couldn't be done.
>

My two cents, considering the quirks and several other things that
sdhci-pltfm.c is missing, e.g. suspend/resume and clk handling. I'd
prefer a diverge at this time, until we figure out what is common to
all sdhci platform bus based driver, and get those common part back
into sdhci-pltfm.c

> Chris, do you see a rule of thumb here? Or what are your preferences?
>
> Kind regards,
>
>   Wolfram
>
> --
> Pengutronix e.K.                           | Wolfram Sang                |
> Industrial Linux Solutions                 | http://www.pengutronix.de/  |
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.10 (GNU/Linux)
>
> iEYEARECAAYFAkyYhMQACgkQD27XaX1/VRsK1wCfaGVLkGpVEsrn+OQrpPBVHa54
> yDAAniBRPOamvs7wU8krhKMjjWqMxn9q
> =zQvu
> -----END PGP SIGNATURE-----
>
>

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] add support PXA168/PXA910/MMP2 SD Host Controller
  2010-09-21 10:11         ` Wolfram Sang
  2010-09-21 10:18           ` Eric Miao
@ 2010-09-21 16:18           ` Chris Ball
  1 sibling, 0 replies; 13+ messages in thread
From: Chris Ball @ 2010-09-21 16:18 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: zhangfei gao, linux-mmc, Kyungmin Park, eric.y.miao,
	Haojian Zhuang

Hi Wolfram,

On Tue, Sep 21, 2010 at 12:11:16PM +0200, Wolfram Sang wrote:
> I guess to fully understand all constraints, one must really working
> with your platform, what I don't do. I agree that a nicely working
> driver is better than no driver; however, I fear once a driver hit the
> mainline being non-pltfm, it will hardly be converted later, even if it
> was considered to be worthwhile. So this is why I ask initially if it
> couldn't be done.
> 
> Chris, do you see a rule of thumb here? Or what are your preferences?

I agree with you entirely:  even if we end up deciding not to use -pltfm
here (which looks like it's probably going to be the case), we should at
least specify what's stopping us from doing so and look into extending
-pltfm so that it might be useful next time around.  So, thank you for
asking those questions!

- Chris.
-- 
Chris Ball   <cjb@laptop.org>   <http://printf.net/>
One Laptop Per Child

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] add support PXA168/PXA910/MMP2 SD Host Controller
  2010-09-21  3:16   ` zhangfei gao
@ 2010-09-22  2:27     ` Chris Ball
  0 siblings, 0 replies; 13+ messages in thread
From: Chris Ball @ 2010-09-22  2:27 UTC (permalink / raw)
  To: zhangfei gao
  Cc: linux-mmc, Saeed Bishara, Kyungmin Park, eric.y.miao,
	Haojian Zhuang

Hi,

On Mon, Sep 20, 2010 at 11:16:18PM -0400, zhangfei gao wrote:
> We have considered using the same driver with dove once saeed push the
> driver, but at last we decide to use seperate driver to easy
> maintaince and further extension.
> 
> There are different IP developed by different group between Dove and
> pxa168/pxa910/mmp2, and would be more and more different.
> The pxa serious ip is follow sdh spec 3.0, and support sd 3.0 and emmc
> 4.4, which need ddr50 and 1.8v requirement, the limitation is adma
> still has some issue and in fixing.
> Still some private register with differnt address, such as power
> control, clock timming tunning and etc.
> 
> The dove ip is follow sdh spec 2.0, and it has own limitation, such as
> 1.8v may not be supported.
> 
> In a word, they are differnt ip, and it is reasonable to use seprate driver.

Okay.  If we're going to have two different MV_SDHCI drivers, please
coordinate to have different Kconfig entries for the Dove/MMP and MMP2
drivers that correctly identify which SoCs are supported by each, and
resend.  Neither driver should be called CONFIG_MV_SDHCI, since there
will be no one driver for all MV_SDHCIs.

Thanks,

- Chris.
-- 
Chris Ball   <cjb@laptop.org>   <http://printf.net/>
One Laptop Per Child

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] add support PXA168/PXA910/MMP2 SD Host Controller
  2010-09-21  9:42 ` claud yu
@ 2010-09-26  9:05   ` zhangfei gao
  0 siblings, 0 replies; 13+ messages in thread
From: zhangfei gao @ 2010-09-26  9:05 UTC (permalink / raw)
  To: claud yu
  Cc: Chris Ball, linux-mmc, Kyungmin Park, eric.y.miao, Haojian Zhuang

On Tue, Sep 21, 2010 at 5:42 AM, claud yu <claud.yu@gmail.com> wrote:
> Hi ,
>
> I had worked with MMP2 platform several weeks. The mmc/sdio interface
> have constraint about transfer size. The transfer size must be 8-byte
> alignment. If any transfer size is 4 byte alignment and not 8-byte
> alignment. This peripheral ip can't support(miss dma end interrupt or
> bad transmission) even DMA mode or PIO mode.
>

8 bytes alignment limitation has been solved from A0, bytes alignment is OK now.
> Claud Yu
>

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2010-09-26  9:05 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-09-20  9:46 [PATCH] add support PXA168/PXA910/MMP2 SD Host Controller zhangfei gao
2010-09-20  9:50 ` Wolfram Sang
2010-09-20 12:09   ` zhangfei gao
2010-09-20 13:10     ` Wolfram Sang
2010-09-21  8:24       ` zhangfei gao
2010-09-21 10:11         ` Wolfram Sang
2010-09-21 10:18           ` Eric Miao
2010-09-21 16:18           ` Chris Ball
2010-09-21  1:03 ` Chris Ball
2010-09-21  3:16   ` zhangfei gao
2010-09-22  2:27     ` Chris Ball
2010-09-21  9:42 ` claud yu
2010-09-26  9:05   ` zhangfei gao

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox