Skip to contentSkip to conversation

SD/MMC driver for MX25/35/51

PATCH New Wolfram Sang 5 participants 34 messages Oct 11, 2010 – Oct 18, 2010

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover SD/MMC driver for MX25/35/51

Here is the hopefully final (famous last words) version of my patch series. The first four are still updates/improvements for sdhci and sdhci-pltfm and are of generic interest, too. Thanks to Eric for the tests on MX25/35. Looking forward to comments/applied-to-mmc-next-messages ;)

The series is based on mmc-next as of today and also available at

	git://git.pengutronix.de/git/wsa/linux-2.6.git pcm043-mmc

Thanks,

Wolfram

Wolfram Sang (6):
mmc: sdhci-pltfm: Add structure for host-specific data
mmc: sdhci-pltfm: move .h-file into apropriate subdir
mmc: sdhci: introduce private get_ro
mmc: sdhci_pltfm: pass more data on custom init-call
mmc: sdhci-of-esdhc: factor out common stuff
mmc: sdhci-pltfm: add pltfm-driver for imx35/51

 drivers/mmc/host/Kconfig           |   10 +++
 drivers/mmc/host/Makefile          |    1 +
 drivers/mmc/host/sdhci-cns3xxx.c   |    2 +-
 drivers/mmc/host/sdhci-esdhc-imx.c |  143 ++++++++++++++++++++++++++++++++++++
 drivers/mmc/host/sdhci-esdhc.h     |   81 ++++++++++++++++++++
 drivers/mmc/host/sdhci-of-esdhc.c  |   70 ++----------------
 drivers/mmc/host/sdhci-pltfm.c     |   23 ++++--
 drivers/mmc/host/sdhci-pltfm.h     |   10 ++-
 drivers/mmc/host/sdhci.c           |   11 ++-
 drivers/mmc/host/sdhci.h           |    1 +
 include/linux/mmc/sdhci-pltfm.h    |   35 +++++++++
 include/linux/sdhci-pltfm.h        |   35 ---------
 12 files changed, 312 insertions(+), 110 deletions(-)
 create mode 100644 drivers/mmc/host/sdhci-esdhc-imx.c
 create mode 100644 drivers/mmc/host/sdhci-esdhc.h
 create mode 100644 include/linux/mmc/sdhci-pltfm.h
 delete mode 100644 include/linux/sdhci-pltfm.h
#1 lore raw

PATCH 1/6 mmc: sdhci-pltfm: Add structure for host-specific data

We need to carry some information per host, e.g. the clock. Add a structure for it and initialize it in the generic part. Also improve the check for a parent.

Cc Richard R?jfors <[email protected]>

---

Changes since last version:

* Improved detection of a "real" parent device

 drivers/mmc/host/sdhci-pltfm.c |   10 +++++++---
 drivers/mmc/host/sdhci-pltfm.h |    7 +++++++
 2 files changed, 14 insertions(+), 3 deletions(-)
drivers/mmc/host/sdhci-pltfm.c +7 -3
index 4f126de..730fdf5 100644
@@ -55,6 +55,7 @@ static int __devinit sdhci_pltfm_probe(struct platform_device *pdev)
 	struct sdhci_pltfm_data *pdata = pdev->dev.platform_data;
 	const struct platform_device_id *platid = platform_get_device_id(pdev);
 	struct sdhci_host *host;
+	struct sdhci_pltfm_host *pltfm_host;
 	struct resource *iomem;
 	int ret;
 
@@ -71,16 +72,19 @@ static int __devinit sdhci_pltfm_probe(struct platform_device *pdev)
 		dev_err(&pdev->dev, "Invalid iomem size. You may "
 			"experience problems.\n");
 
-	if (pdev->dev.parent)
-		host = sdhci_alloc_host(pdev->dev.parent, 0);
+	/* Some PCI-based MFD need the parent here */
+	if (pdev->dev.parent != &platform_bus)
+		host = sdhci_alloc_host(pdev->dev.parent, sizeof(*pltfm_host));
 	else
-		host = sdhci_alloc_host(&pdev->dev, 0);
+		host = sdhci_alloc_host(&pdev->dev, sizeof(*pltfm_host));
 
 	if (IS_ERR(host)) {
 		ret = PTR_ERR(host);
 		goto err;
 	}
 
+	pltfm_host = sdhci_priv(host);
+
 	host->hw_name = "platform";
 	if (pdata && pdata->ops)
 		host->ops = pdata->ops;
drivers/mmc/host/sdhci-pltfm.h +7 -0
index 900f329..93a0319 100644
@@ -11,8 +11,15 @@
 #ifndef _DRIVERS_MMC_SDHCI_PLTFM_H
 #define _DRIVERS_MMC_SDHCI_PLTFM_H
 
+#include <linux/clk.h>
+#include <linux/types.h>
 #include <linux/sdhci-pltfm.h>
 
+struct sdhci_pltfm_host {
+	struct clk *clk;
+	u32 scratchpad; /* to handle quirks across io-accessor calls */
+};
+
 extern struct sdhci_pltfm_data sdhci_cns3xxx_pdata;
 
 #endif /* _DRIVERS_MMC_SDHCI_PLTFM_H */
Signature · 1 line
1.7.1
#2 lore raw

PATCH 2/6 mmc: sdhci-pltfm: move .h-file into apropriate subdir

In reply to Wolfram Sang

Make use of the mmc-directory.

---
 drivers/mmc/host/sdhci-cns3xxx.c |    2 +-
 drivers/mmc/host/sdhci-pltfm.c   |    2 +-
 drivers/mmc/host/sdhci-pltfm.h   |    2 +-
 include/linux/mmc/sdhci-pltfm.h  |   35 +++++++++++++++++++++++++++++++++++
 include/linux/sdhci-pltfm.h      |   35 -----------------------------------
 5 files changed, 38 insertions(+), 38 deletions(-)
 create mode 100644 include/linux/mmc/sdhci-pltfm.h
 delete mode 100644 include/linux/sdhci-pltfm.h
drivers/mmc/host/sdhci-cns3xxx.c +1 -1
index b7050b3..9ebd1d7 100644
@@ -15,7 +15,7 @@
 #include <linux/delay.h>
 #include <linux/device.h>
 #include <linux/mmc/host.h>
-#include <linux/sdhci-pltfm.h>
+#include <linux/mmc/sdhci-pltfm.h>
 #include <mach/cns3xxx.h>
 #include "sdhci.h"
 #include "sdhci-pltfm.h"
drivers/mmc/host/sdhci-pltfm.c +1 -1
index 730fdf5..685202b 100644
@@ -30,7 +30,7 @@
 #include <linux/mmc/host.h>
 
 #include <linux/io.h>
-#include <linux/sdhci-pltfm.h>
+#include <linux/mmc/sdhci-pltfm.h>
 
 #include "sdhci.h"
 #include "sdhci-pltfm.h"
drivers/mmc/host/sdhci-pltfm.h +1 -1
index 93a0319..562b929 100644
@@ -13,7 +13,7 @@
 
 #include <linux/clk.h>
 #include <linux/types.h>
-#include <linux/sdhci-pltfm.h>
+#include <linux/mmc/sdhci-pltfm.h>
 
 struct sdhci_pltfm_host {
 	struct clk *clk;
include/linux/mmc/sdhci-pltfm.h new file +35 -0
new file mode 100644
index 0000000..0239bd7
@@ -0,0 +1,35 @@
+/*
+ * Platform data declarations for the sdhci-pltfm driver.
+ *
+ * Copyright (c) 2010 MontaVista Software, LLC.
+ *
+ * Author: Anton Vorontsov <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ */
+
+#ifndef _SDHCI_PLTFM_H
+#define _SDHCI_PLTFM_H
+
+struct sdhci_ops;
+struct sdhci_host;
+
+/**
+ * struct sdhci_pltfm_data - SDHCI platform-specific information & hooks
+ * @ops: optional pointer to the platform-provided SDHCI ops
+ * @quirks: optional SDHCI quirks
+ * @init: optional hook that is called during device probe, before the
+ *        driver tries to access any SDHCI registers
+ * @exit: optional hook that is called during device removal
+ */
+struct sdhci_pltfm_data {
+	struct sdhci_ops *ops;
+	unsigned int quirks;
+	int (*init)(struct sdhci_host *host);
+	void (*exit)(struct sdhci_host *host);
+};
+
+#endif /* _SDHCI_PLTFM_H */
include/linux/sdhci-pltfm.h deleted +0 -35
deleted file mode 100644
index 0239bd7..0000000
@@ -1,35 +0,0 @@
-/*
- * Platform data declarations for the sdhci-pltfm driver.
- *
- * Copyright (c) 2010 MontaVista Software, LLC.
- *
- * Author: Anton Vorontsov <[email protected]>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- */
-
-#ifndef _SDHCI_PLTFM_H
-#define _SDHCI_PLTFM_H
-
-struct sdhci_ops;
-struct sdhci_host;
-
-/**
- * struct sdhci_pltfm_data - SDHCI platform-specific information & hooks
- * @ops: optional pointer to the platform-provided SDHCI ops
- * @quirks: optional SDHCI quirks
- * @init: optional hook that is called during device probe, before the
- *        driver tries to access any SDHCI registers
- * @exit: optional hook that is called during device removal
- */
-struct sdhci_pltfm_data {
-	struct sdhci_ops *ops;
-	unsigned int quirks;
-	int (*init)(struct sdhci_host *host);
-	void (*exit)(struct sdhci_host *host);
-};
-
-#endif /* _SDHCI_PLTFM_H */
Signature · 1 line
1.7.1
#3 lore raw

PATCH 3/6 mmc: sdhci: introduce private get_ro

In reply to Wolfram Sang

Some controllers handle their write-protection differently. Introduce a callback to be able to handle it, ensuring the same locking takes place for it.

---
 drivers/mmc/host/sdhci.c |   11 +++++++----
 drivers/mmc/host/sdhci.h |    1 +
 2 files changed, 8 insertions(+), 4 deletions(-)
drivers/mmc/host/sdhci.c +7 -4
index 9cb60ba..970110a 100644
@@ -1231,14 +1231,17 @@ static int sdhci_get_ro(struct mmc_host *mmc)
 
 	if (host->flags & SDHCI_DEVICE_DEAD)
 		present = 0;
+	else if (host->ops->get_ro)
+		present = host->ops->get_ro(host);
 	else
-		present = sdhci_readl(host, SDHCI_PRESENT_STATE);
+		present = !(sdhci_readl(host, SDHCI_PRESENT_STATE)
+				& SDHCI_WRITE_PROTECT);
 
 	spin_unlock_irqrestore(&host->lock, flags);
 
-	if (host->quirks & SDHCI_QUIRK_INVERTED_WRITE_PROTECT)
-		return !!(present & SDHCI_WRITE_PROTECT);
-	return !(present & SDHCI_WRITE_PROTECT);
+	/* This quirk needs to be replaced by a callback-function later */
+	return host->quirks & SDHCI_QUIRK_INVERTED_WRITE_PROTECT ?
+		!present : present;
 }
 
 static void sdhci_enable_sdio_irq(struct mmc_host *mmc, int enable)
drivers/mmc/host/sdhci.h +1 -0
index bfcd611..b7b8a3b 100644
@@ -214,6 +214,7 @@ struct sdhci_ops {
 	unsigned int	(*get_timeout_clock)(struct sdhci_host *host);
 	void (*platform_send_init_74_clocks)(struct sdhci_host *host,
 					     u8 power_mode);
+	unsigned int    (*get_ro)(struct sdhci_host *host);
 };
 
 #ifdef CONFIG_MMC_SDHCI_IO_ACCESSORS
Signature · 1 line
1.7.1
#4 lore raw

PATCH 4/6 mmc: sdhci_pltfm: pass more data on custom init-call

In reply to Wolfram Sang

The custom init call may need more data to perform its job, so we pass it a pointer to pdata, too. Also, always use the platform_id specific data even if platform_data is present. Doing that, platform_data can additionally be parsed by init() for board-specific information (via sdhci->mmc->parent).

(Note: the old behaviour was that you could override the platform_id specific data with your own. However, one can still do this by using the "sdhci" id instead of "sdhci-<something>".)

---
 drivers/mmc/host/sdhci-pltfm.c  |    8 +++++---
 include/linux/mmc/sdhci-pltfm.h |    2 +-
 2 files changed, 6 insertions(+), 4 deletions(-)
drivers/mmc/host/sdhci-pltfm.c +5 -3
index 685202b..00e8a8a 100644
@@ -52,15 +52,17 @@ static struct sdhci_ops sdhci_pltfm_ops = {
 
 static int __devinit sdhci_pltfm_probe(struct platform_device *pdev)
 {
-	struct sdhci_pltfm_data *pdata = pdev->dev.platform_data;
 	const struct platform_device_id *platid = platform_get_device_id(pdev);
+	struct sdhci_pltfm_data *pdata;
 	struct sdhci_host *host;
 	struct sdhci_pltfm_host *pltfm_host;
 	struct resource *iomem;
 	int ret;
 
-	if (!pdata && platid && platid->driver_data)
+	if (platid && platid->driver_data)
 		pdata = (void *)platid->driver_data;
+	else
+		pdata = pdev->dev.platform_data;
 
 	iomem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	if (!iomem) {
@@ -109,7 +111,7 @@ static int __devinit sdhci_pltfm_probe(struct platform_device *pdev)
 	}
 
 	if (pdata && pdata->init) {
-		ret = pdata->init(host);
+		ret = pdata->init(host, pdata);
 		if (ret)
 			goto err_plat_init;
 	}
include/linux/mmc/sdhci-pltfm.h +1 -1
index 0239bd7..548d59d 100644
@@ -28,7 +28,7 @@ struct sdhci_host;
 struct sdhci_pltfm_data {
 	struct sdhci_ops *ops;
 	unsigned int quirks;
-	int (*init)(struct sdhci_host *host);
+	int (*init)(struct sdhci_host *host, struct sdhci_pltfm_data *pdata);
 	void (*exit)(struct sdhci_host *host);
 };
 
Signature · 1 line
1.7.1
#5 lore raw

PATCH 5/6 mmc: sdhci-of-esdhc: factor out common stuff

In reply to Wolfram Sang

Put everything which can be shared between the OF and platform version of this driver into a local .h-file.

---
 drivers/mmc/host/sdhci-esdhc.h    |   81 +++++++++++++++++++++++++++++++++++++
 drivers/mmc/host/sdhci-of-esdhc.c |   70 ++++----------------------------
 2 files changed, 89 insertions(+), 62 deletions(-)
 create mode 100644 drivers/mmc/host/sdhci-esdhc.h
drivers/mmc/host/sdhci-esdhc.h new file +81 -0
new file mode 100644
index 0000000..7ccc8cb
@@ -0,0 +1,81 @@
+/*
+ * Freescale eSDHC controller driver generics for OF and pltfm.
+ *
+ * Copyright (c) 2007 Freescale Semiconductor, Inc.
+ * Copyright (c) 2009 MontaVista Software, Inc.
+ * Copyright (c) 2010 Pengutronix e.K.
+ *   Author: Wolfram Sang <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License.
+ */
+
+#ifndef _DRIVERS_MMC_SDHCI_ESDHC_H
+#define _DRIVERS_MMC_SDHCI_ESDHC_H
+
+/*
+ * Ops and quirks for the Freescale eSDHC controller.
+ */
+
+#define ESDHC_DEFAULT_QUIRKS	(SDHCI_QUIRK_FORCE_BLK_SZ_2048 | \
+				SDHCI_QUIRK_BROKEN_CARD_DETECTION | \
+				SDHCI_QUIRK_NO_BUSY_IRQ | \
+				SDHCI_QUIRK_NONSTANDARD_CLOCK | \
+				SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK | \
+				SDHCI_QUIRK_PIO_NEEDS_DELAY | \
+				SDHCI_QUIRK_RESTORE_IRQS_AFTER_RESET | \
+				SDHCI_QUIRK_NO_CARD_NO_RESET)
+
+#define ESDHC_SYSTEM_CONTROL	0x2c
+#define ESDHC_CLOCK_MASK	0x0000fff0
+#define ESDHC_PREDIV_SHIFT	8
+#define ESDHC_DIVIDER_SHIFT	4
+#define ESDHC_CLOCK_PEREN	0x00000004
+#define ESDHC_CLOCK_HCKEN	0x00000002
+#define ESDHC_CLOCK_IPGEN	0x00000001
+
+/* pltfm-specific */
+#define ESDHC_HOST_CONTROL_LE	0x20
+
+/* OF-specific */
+#define ESDHC_DMA_SYSCTL	0x40c
+#define ESDHC_DMA_SNOOP		0x00000040
+
+#define ESDHC_HOST_CONTROL_RES	0x05
+
+static inline void esdhc_set_clock(struct sdhci_host *host, unsigned int clock)
+{
+	int pre_div = 2;
+	int div = 1;
+	u32 temp;
+
+	temp = sdhci_readl(host, ESDHC_SYSTEM_CONTROL);
+	temp &= ~(ESDHC_CLOCK_IPGEN | ESDHC_CLOCK_HCKEN | ESDHC_CLOCK_PEREN | ESDHC_CLOCK_MASK);
+	sdhci_writel(host, temp, ESDHC_SYSTEM_CONTROL);
+
+	if (clock == 0)
+		goto out;
+
+	while (host->max_clk / pre_div / 16 > clock && pre_div < 256)
+		pre_div *= 2;
+
+	while (host->max_clk / pre_div / div > clock && div < 16)
+		div++;
+
+	dev_dbg(mmc_dev(host->mmc), "desired SD clock: %d, actual: %d\n",
+		clock, host->max_clk / pre_div / div);
+
+	pre_div >>= 1;
+	div--;
+
+	temp = sdhci_readl(host, ESDHC_SYSTEM_CONTROL);
+	temp |= (ESDHC_CLOCK_IPGEN | ESDHC_CLOCK_HCKEN | ESDHC_CLOCK_PEREN |
+		  (div << ESDHC_DIVIDER_SHIFT) | (pre_div << ESDHC_PREDIV_SHIFT));
+	sdhci_writel(host, temp, ESDHC_SYSTEM_CONTROL);
+	mdelay(100);
+out:
+	host->clock = clock;
+}
+
+#endif /* _DRIVERS_MMC_SDHCI_ESDHC_H */
drivers/mmc/host/sdhci-of-esdhc.c +8 -62

104 lines not on this page · raw message

Signature · 1 line
1.7.1
#6 lore raw

PATCH v2 5/6 mmc: sdhci-of-esdhc: factor out common stuff

Put everything which can be shared between the OF and platform version of this driver into a local .h-file.

---

80 char/line fixed. Untested as of now, can only test tomorrow again. Should be safe changes, though (famous last words again ;)))

 drivers/mmc/host/sdhci-esdhc.h    |   83 +++++++++++++++++++++++++++++++++++++
 drivers/mmc/host/sdhci-of-esdhc.c |   70 ++++---------------------------
 2 files changed, 91 insertions(+), 62 deletions(-)
 create mode 100644 drivers/mmc/host/sdhci-esdhc.h
drivers/mmc/host/sdhci-esdhc.h new file +83 -0
new file mode 100644
index 0000000..afaf1bc
@@ -0,0 +1,83 @@
+/*
+ * Freescale eSDHC controller driver generics for OF and pltfm.
+ *
+ * Copyright (c) 2007 Freescale Semiconductor, Inc.
+ * Copyright (c) 2009 MontaVista Software, Inc.
+ * Copyright (c) 2010 Pengutronix e.K.
+ *   Author: Wolfram Sang <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License.
+ */
+
+#ifndef _DRIVERS_MMC_SDHCI_ESDHC_H
+#define _DRIVERS_MMC_SDHCI_ESDHC_H
+
+/*
+ * Ops and quirks for the Freescale eSDHC controller.
+ */
+
+#define ESDHC_DEFAULT_QUIRKS	(SDHCI_QUIRK_FORCE_BLK_SZ_2048 | \
+				SDHCI_QUIRK_BROKEN_CARD_DETECTION | \
+				SDHCI_QUIRK_NO_BUSY_IRQ | \
+				SDHCI_QUIRK_NONSTANDARD_CLOCK | \
+				SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK | \
+				SDHCI_QUIRK_PIO_NEEDS_DELAY | \
+				SDHCI_QUIRK_RESTORE_IRQS_AFTER_RESET | \
+				SDHCI_QUIRK_NO_CARD_NO_RESET)
+
+#define ESDHC_SYSTEM_CONTROL	0x2c
+#define ESDHC_CLOCK_MASK	0x0000fff0
+#define ESDHC_PREDIV_SHIFT	8
+#define ESDHC_DIVIDER_SHIFT	4
+#define ESDHC_CLOCK_PEREN	0x00000004
+#define ESDHC_CLOCK_HCKEN	0x00000002
+#define ESDHC_CLOCK_IPGEN	0x00000001
+
+/* pltfm-specific */
+#define ESDHC_HOST_CONTROL_LE	0x20
+
+/* OF-specific */
+#define ESDHC_DMA_SYSCTL	0x40c
+#define ESDHC_DMA_SNOOP		0x00000040
+
+#define ESDHC_HOST_CONTROL_RES	0x05
+
+static inline void esdhc_set_clock(struct sdhci_host *host, unsigned int clock)
+{
+	int pre_div = 2;
+	int div = 1;
+	u32 temp;
+
+	temp = sdhci_readl(host, ESDHC_SYSTEM_CONTROL);
+	temp &= ~(ESDHC_CLOCK_IPGEN | ESDHC_CLOCK_HCKEN | ESDHC_CLOCK_PEREN
+		| ESDHC_CLOCK_MASK);
+	sdhci_writel(host, temp, ESDHC_SYSTEM_CONTROL);
+
+	if (clock == 0)
+		goto out;
+
+	while (host->max_clk / pre_div / 16 > clock && pre_div < 256)
+		pre_div *= 2;
+
+	while (host->max_clk / pre_div / div > clock && div < 16)
+		div++;
+
+	dev_dbg(mmc_dev(host->mmc), "desired SD clock: %d, actual: %d\n",
+		clock, host->max_clk / pre_div / div);
+
+	pre_div >>= 1;
+	div--;
+
+	temp = sdhci_readl(host, ESDHC_SYSTEM_CONTROL);
+	temp |= (ESDHC_CLOCK_IPGEN | ESDHC_CLOCK_HCKEN | ESDHC_CLOCK_PEREN
+		| (div << ESDHC_DIVIDER_SHIFT)
+		| (pre_div << ESDHC_PREDIV_SHIFT));
+	sdhci_writel(host, temp, ESDHC_SYSTEM_CONTROL);
+	mdelay(100);
+out:
+	host->clock = clock;
+}
+
+#endif /* _DRIVERS_MMC_SDHCI_ESDHC_H */
drivers/mmc/host/sdhci-of-esdhc.c +8 -62

104 lines not on this page · raw message

Signature · 1 line
1.7.1
#7 lore raw

PATCH v2 5/6 mmc: sdhci-of-esdhc: factor out common stuff

Hi Wolfram,

Quoted 22 lines · Wolfram Sang
drivers/mmc/host/sdhci-esdhc.h new file +22 -0
+static inline void esdhc_set_clock(struct sdhci_host *host, unsigned int clock)
+{
+	int pre_div = 2;
+	int div = 1;
+	u32 temp;
+
+	temp = sdhci_readl(host, ESDHC_SYSTEM_CONTROL);
+	temp &= ~(ESDHC_CLOCK_IPGEN | ESDHC_CLOCK_HCKEN | ESDHC_CLOCK_PEREN
+		| ESDHC_CLOCK_MASK);
+	sdhci_writel(host, temp, ESDHC_SYSTEM_CONTROL);
+
+	if (clock == 0)
+		goto out;
+
+	while (host->max_clk / pre_div / 16 > clock && pre_div < 256)
+		pre_div *= 2;
+
+	while (host->max_clk / pre_div / div > clock && div < 16)
+		div++;
+
+	dev_dbg(mmc_dev(host->mmc), "desired SD clock: %d, actual: %d\n",
+		clock, host->max_clk / pre_div / div);

drivers/mmc/host/sdhci-esdhc.h line 78

Quoted 10 lines
drivers/mmc/host/sdhci-esdhc.h new file +10 -0
+
+	pre_div >>= 1;
+	div--;
+
+	temp = sdhci_readl(host, ESDHC_SYSTEM_CONTROL);
+	temp |= (ESDHC_CLOCK_IPGEN | ESDHC_CLOCK_HCKEN | ESDHC_CLOCK_PEREN
+		| (div << ESDHC_DIVIDER_SHIFT)
+		| (pre_div << ESDHC_PREDIV_SHIFT));
+	sdhci_writel(host, temp, ESDHC_SYSTEM_CONTROL);
+	mdelay(100);

This isn't directly related to this patchset (the code was there beforehand), but it would be nice to rework the mdelay(100).

Thanks,

Signature · 2 lines
Chris Ball   <[email protected]>   <http://printf.net/>
One Laptop Per Child
#8 lore raw

PATCH v2 5/6 mmc: sdhci-of-esdhc: factor out common stuff

Hi Wolfram:
It's better that the mdelay(100) is replaced by some litter value such as 10ms and so on,
since I encounter one bug ever when this values is set to 100. The
audio playback would
be noised by the sd/mmc insertion/extraction operations.

Best Regards
Richard Zhu

Quoted 5 lines

-----Original Message-----
From: Chris Ball [mailto:[email protected]]
Sent: Tuesday, October 12, 2010 2:33 AM
To: Wolfram Sang
Cc: [email protected]; [email protected];

Zhu

Quoted 2 lines

Richard-R65037
Subject: Re: [PATCH v2 5/6] mmc: sdhci-of-esdhc: factor out common

stuff

Quoted 5 lines

Hi Wolfram,

Quoted 1 line · Wolfram Sang

+static inline void esdhc_set_clock(struct sdhci_host *host,

unsigned

Quoted 7 lines

drivers/mmc/host/sdhci-esdhc.h

Quoted 7 lines
drivers/mmc/host/sdhci-esdhc.h new file +7 -0
+int clock) {
+	int pre_div = 2;
+	int div = 1;
+	u32 temp;
+
+	temp = sdhci_readl(host, ESDHC_SYSTEM_CONTROL);
+	temp &= ~(ESDHC_CLOCK_IPGEN | ESDHC_CLOCK_HCKEN |

ESDHC_CLOCK_PEREN

Quoted 5 lines
Quoted 5 lines
drivers/mmc/host/sdhci-esdhc.h new file +5 -0
+		| ESDHC_CLOCK_MASK);
+	sdhci_writel(host, temp, ESDHC_SYSTEM_CONTROL);
+
+	if (clock == 0)
+		goto out;
Quoted 8 lines

drivers/mmc/host/sdhci-esdhc.h

Quoted 8 lines
drivers/mmc/host/sdhci-esdhc.h new file +8 -0
+
+	while (host->max_clk / pre_div / 16 > clock && pre_div < 256)
+		pre_div *= 2;
+
+	while (host->max_clk / pre_div / div > clock && div < 16)
+		div++;
+
+	dev_dbg(mmc_dev(host->mmc), "desired SD clock: %d, actual:

%d\n",

Quoted 7 lines

drivers/mmc/host/sdhci-esdhc.h

Quoted 7 lines
drivers/mmc/host/sdhci-esdhc.h new file +7 -0
+		clock, host->max_clk / pre_div / div);
+
+	pre_div >>= 1;
+	div--;
+
+	temp = sdhci_readl(host, ESDHC_SYSTEM_CONTROL);
+	temp |= (ESDHC_CLOCK_IPGEN | ESDHC_CLOCK_HCKEN |

ESDHC_CLOCK_PEREN

Quoted 13 lines

drivers/mmc/host/sdhci-esdhc.h line 78

Quoted 4 lines
drivers/mmc/host/sdhci-esdhc.h new file +4 -0
+		| (div << ESDHC_DIVIDER_SHIFT)
+		| (pre_div << ESDHC_PREDIV_SHIFT));
+	sdhci_writel(host, temp, ESDHC_SYSTEM_CONTROL);
+	mdelay(100);

This isn't directly related to this patchset (the code was there beforehand), but it would be nice to rework the mdelay(100).

Thanks,

--
Chris Ball <[email protected]> <http://printf.net/>
One Laptop Per Child

#9 lore raw

PATCH v2 5/6 mmc: sdhci-of-esdhc: factor out common stuff

Quoted 5 lines · On Wed, Oct 13, 2010 at 06:22:14PM +0800, Zhu Richard-R65037 wrote:

It's better that the mdelay(100) is replaced by some litter value such as 10ms and so on,
since I encounter one bug ever when this values is set to 100. The
audio playback would
be noised by the sd/mmc insertion/extraction operations.

Okay. Can you send a patch (as you seem to have a testcase)?

Signature · 9 lines
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20101013/86a990e3/attachment.sig>
#10 lore raw

PATCH 6/6 mmc: sdhci-pltfm: add pltfm-driver for imx35/51

In reply to Wolfram Sang

This driver adds basic support for the esdhc-core found on e.g. imx35/51. It adds up to the pltfm-core.

---

Changes since last version:

* use PTR_ERR if clk_get failed

 drivers/mmc/host/Kconfig           |   10 +++
 drivers/mmc/host/Makefile          |    1 +
 drivers/mmc/host/sdhci-esdhc-imx.c |  143 ++++++++++++++++++++++++++++++++++++
 drivers/mmc/host/sdhci-pltfm.c     |    3 +
 drivers/mmc/host/sdhci-pltfm.h     |    1 +
 5 files changed, 158 insertions(+), 0 deletions(-)
 create mode 100644 drivers/mmc/host/sdhci-esdhc-imx.c
drivers/mmc/host/Kconfig +10 -0
index 8de7b9e..7b07f10 100644
@@ -130,6 +130,16 @@ config MMC_SDHCI_CNS3XXX
 
 	  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
+	select MMC_SDHCI_IO_ACCESSORS
+	help
+	  This selects the Freescale eSDHC controller support on the platform
+	  bus, found on platforms like mx35/51.
+
+	  If unsure, say N.
+
 config MMC_SDHCI_S3C
 	tristate "SDHCI support on Samsung S3C SoC"
 	depends on MMC_SDHCI && PLAT_SAMSUNG
drivers/mmc/host/Makefile +1 -0
index eae5d62..6c4ac67 100644
@@ -37,6 +37,7 @@ 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
 
 obj-$(CONFIG_MMC_SDHCI_OF)	+= sdhci-of.o
 sdhci-of-y				:= sdhci-of-core.o
drivers/mmc/host/sdhci-esdhc-imx.c new file +143 -0

143 lines not on this page · raw message

drivers/mmc/host/sdhci-pltfm.c +3 -0
index 00e8a8a..0502f89 100644
@@ -167,6 +167,9 @@ static const struct platform_device_id sdhci_pltfm_ids[] = {
 #ifdef CONFIG_MMC_SDHCI_CNS3XXX
 	{ "sdhci-cns3xxx", (kernel_ulong_t)&sdhci_cns3xxx_pdata },
 #endif
+#ifdef CONFIG_MMC_SDHCI_ESDHC_IMX
+	{ "sdhci-esdhc-imx", (kernel_ulong_t)&sdhci_esdhc_imx_pdata },
+#endif
 	{ },
 };
 MODULE_DEVICE_TABLE(platform, sdhci_pltfm_ids);
drivers/mmc/host/sdhci-pltfm.h +1 -0
index 562b929..c1bfe48 100644
@@ -21,5 +21,6 @@ struct sdhci_pltfm_host {
 };
 
 extern struct sdhci_pltfm_data sdhci_cns3xxx_pdata;
+extern struct sdhci_pltfm_data sdhci_esdhc_imx_pdata;
 
 #endif /* _DRIVERS_MMC_SDHCI_PLTFM_H */
Signature · 1 line
1.7.1
#11 lore raw

PATCH 6/6 mmc: sdhci-pltfm: add pltfm-driver for imx35/51

Hi Wolfram,

Quoted 28 lines · Wolfram Sang

This driver adds basic support for the esdhc-core found on e.g. imx35/51. It adds up to the pltfm-core.

---

Changes since last version:

* use PTR_ERR if clk_get failed

 drivers/mmc/host/Kconfig           |   10 +++
 drivers/mmc/host/Makefile          |    1 +
 drivers/mmc/host/sdhci-esdhc-imx.c |  143 ++++++++++++++++++++++++++++++++++++
 drivers/mmc/host/sdhci-pltfm.c     |    3 +
 drivers/mmc/host/sdhci-pltfm.h     |    1 +
 5 files changed, 158 insertions(+), 0 deletions(-)
 create mode 100644 drivers/mmc/host/sdhci-esdhc-imx.c
drivers/mmc/host/Kconfig +0 -0
index 8de7b9e..7b07f10 100644
@@ -130,6 +130,16 @@ config MMC_SDHCI_CNS3XXX
 
 	  If unsure, say N.
 

drivers/mmc/host/Kconfig config MMC_SDHCI_CNS3XXX · line 142

Quoted 10 lines
drivers/mmc/host/Kconfig +10 -0
+config MMC_SDHCI_ESDHC_IMX
+	bool "SDHCI platform support for the Freescale eSDHC i.MX controller"
+	depends on MMC_SDHCI_PLTFM
+	select MMC_SDHCI_IO_ACCESSORS
+	help
+	  This selects the Freescale eSDHC controller support on the platform
+	  bus, found on platforms like mx35/51.
+
+	  If unsure, say N.
+

Could you add a machine dependency here? Otherwise this is going to offer itself to x86 users, and then fail to compile due to lack of a clk_* implementation.

Apart from that, looks ready for mmc-next -- the mdelay(100) fix can come later, since that's orthogonal.

Thanks,

Signature · 2 lines
Chris Ball   <[email protected]>   <http://printf.net/>
One Laptop Per Child
#12 lore raw

cover SD/MMC driver for MX25/35/51

In reply to Wolfram Sang

Hi Wolfram,

Quoted 7 lines · Wolfram Sang

Wolfram Sang (6):
mmc: sdhci-pltfm: Add structure for host-specific data
mmc: sdhci-pltfm: move .h-file into apropriate subdir
mmc: sdhci: introduce private get_ro
mmc: sdhci_pltfm: pass more data on custom init-call
mmc: sdhci-of-esdhc: factor out common stuff
mmc: sdhci-pltfm: add pltfm-driver for imx35/51

Mind fixing up the >80 char lines in the last two patches? It's just:

WARNING: line over 80 characters
#79: FILE: drivers/mmc/host/sdhci-esdhc.h:54:
+ temp &= ~(ESDHC_CLOCK_IPGEN | ESDHC_CLOCK_HCKEN | ESDHC_CLOCK_PEREN | ESDHC_CLOCK_MASK);

WARNING: line over 80 characters
#99: FILE: drivers/mmc/host/sdhci-esdhc.h:74:
+ (div << ESDHC_DIVIDER_SHIFT) | (pre_div << ESDHC_PREDIV_SHIFT));

WARNING: line over 80 characters
#86: FILE: drivers/mmc/host/sdhci-esdhc-imx.c:24:
+static inline void esdhc_clrset_le(struct sdhci_host *host, u32 mask, u32 val, int reg)

WARNING: line over 80 characters
#164: FILE: drivers/mmc/host/sdhci-esdhc-imx.c:102:
+static int esdhc_pltfm_init(struct sdhci_host *host, struct sdhci_pltfm_data *pdata)

Thanks,

Signature · 2 lines
Chris Ball   <[email protected]>   <http://printf.net/>
One Laptop Per Child
#13 lore raw

cover SD/MMC driver for MX25/35/51

Quoted 10 lines
Quoted 8 lines

Wolfram Sang (6):
mmc: sdhci-pltfm: Add structure for host-specific data
mmc: sdhci-pltfm: move .h-file into apropriate subdir
mmc: sdhci: introduce private get_ro
mmc: sdhci_pltfm: pass more data on custom init-call
mmc: sdhci-of-esdhc: factor out common stuff
mmc: sdhci-pltfm: add pltfm-driver for imx35/51

Mind fixing up the >80 char lines in the last two patches? It's just:

Sigh, I don't think it will help the readability of the code, but if it can't be helped...

Signature · 9 lines
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20101011/10b93013/attachment.sig>
#14 lore raw

cover SD/MMC driver for MX25/35/51

Hi Wolfram,

Quoted 4 lines · Wolfram Sang
Quoted 1 line

Mind fixing up the >80 char lines in the last two patches? It's just:

Sigh, I don't think it will help the readability of the code, but if it can't be helped...

Okay. Perhaps as a compromise, just reflow the two lines in 5/6 and leave the long prototypes in 6/6 as they are? (For the second hunk in 5/6, you could just pull the start of the line back two cols.)

Thanks,

Signature · 2 lines
Chris Ball   <[email protected]>   <http://printf.net/>
One Laptop Per Child
#15 lore raw

cover SD/MMC driver for MX25/35/51

In reply to Wolfram Sang

Wolfram Sang <[email protected]> writes:

Hi,

Quoted 8 lines

Here is the hopefully final (famous last words) version of my patch series. The first four are still updates/improvements for sdhci and sdhci-pltfm and are of generic interest, too. Thanks to Eric for the tests on MX25/35. Looking forward to comments/applied-to-mmc-next-messages ;)

The series is based on mmc-next as of today and also available at

	git://git.pengutronix.de/git/wsa/linux-2.6.git pcm043-mmc

I've tried it on a efika mx (to2 version) and I've a problem with the write-protect. It's on a GPIO and I don't see any way to configure the esdhc-imx driver to use it. Any idea on how it should be done ?

thanks,
Arnaud

#16 lore raw

cover SD/MMC driver for MX25/35/51

Hi,

Le 13/10/2010 00:06, Arnaud Patard (Rtp) a ?crit :

Quoted 6 lines
Quoted 5 lines · Wolfram Sang

Here is the hopefully final (famous last words) version of my patch series. The first four are still updates/improvements for sdhci and sdhci-pltfm and are of generic interest, too. Thanks to Eric for the tests on MX25/35. Looking forward to comments/applied-to-mmc-next-messages ;)

Quoted 8 lines
Quoted 3 lines

The series is based on mmc-next as of today and also available at

	git://git.pengutronix.de/git/wsa/linux-2.6.git pcm043-mmc

I've tried it on a efika mx (to2 version) and I've a problem with the write-protect. It's on a GPIO and I don't see any way to configure the esdhc-imx driver to use it. Any idea on how it should be done ?

it's actually not yet supported by the driver. There is a wp_gpio in struct esdhc_platform_data (arch/arm/plat-mxc/include/mach/esdhc.h) but it's not yet used by the driver.
Also card detect using a GPIO is not implemented and card detect if actually done by polling.

Eric

#17 lore raw

cover SD/MMC driver for MX25/35/51

Quoted 7 lines · Eric B?nard
Quoted 4 lines

I've tried it on a efika mx (to2 version) and I've a problem with the write-protect. It's on a GPIO and I don't see any way to configure the esdhc-imx driver to use it. Any idea on how it should be done ?

it's actually not yet supported by the driver. There is a wp_gpio in struct esdhc_platform_data (arch/arm/plat-mxc/include/mach/esdhc.h) but it's not yet used by the driver.

It's all prepared. I finally will have a look into it today.

Signature · 9 lines
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20101013/55c7b3f3/attachment.sig>
#18 lore raw

cover SD/MMC driver for MX25/35/51

Wolfram Sang <[email protected]> writes:

Hi,

Quoted 11 lines · Eric Bénard
Quoted 8 lines
Quoted 5 lines

I've tried it on a efika mx (to2 version) and I've a problem with the write-protect. It's on a GPIO and I don't see any way to configure the esdhc-imx driver to use it. Any idea on how it should be done ?

it's actually not yet supported by the driver. There is a wp_gpio in struct esdhc_platform_data (arch/arm/plat-mxc/include/mach/esdhc.h) but it's not yet used by the driver.

It's all prepared. I finally will have a look into it today.

oh, great. I was thinking about doing it but I'll wait for your patches then. I'm sure I need support for WP on GPIO but I may also need support for CD on GPIO so I'll be happy to test any patch you have.

Thanks,
Arnaud

#19 lore raw

cover SD/MMC driver for MX25/35/51

Hi Arnaud:
The mechanism of the GPIO used as write protection pin is implemented ever, you can make a reference to the following suggestions. The details pls refer to the [PATCH 3/6] mmc: sdhci: introduce private get_ro sent by wolfram.
and
http://lists.infradead.org/pipermail/linux-arm-kernel/2010-September/027269.html

The GPIO Card Detection solution maybe a little complex refer to the GPIO Write Protection,
since the CD irq should be configured, and the poll Of card detection should be disabled at the same time.
So the sdhc-pltfm.c maybe should be changed too.

Hi Eric:
Can you add this GPIO WP mechanism into your serial patches?
I can't access the external git repos because of the firewall.:(.
The GPIO WP solution had been implemented in my patches before, the details pls refer to the URL listed above.

The codes are simple, maybe the definition of the platform data should be considered.

Best Regards
Richard Zhu

Quoted 32 lines

-----Original Message-----
From: Arnaud Patard [mailto:arnaud.patard at rtp-net.org]
Sent: Wednesday, October 13, 2010 5:28 PM
To: Wolfram Sang
Cc: Eric B?nard; Zhu Richard-R65037; linux-mmc at vger.kernel.org; linux- arm-kernel at lists.infradead.org
Subject: Re: [PATCH 0/6] SD/MMC driver for MX25/35/51

Wolfram Sang <[email protected]> writes:

Hi,

Quoted 5 lines · Eric B?nard
Quoted 4 lines
Quoted 4 lines

I've tried it on a efika mx (to2 version) and I've a problem with the write-protect. It's on a GPIO and I don't see any way to configure the esdhc-imx driver to use it. Any idea on how it should

be done ?

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

it's actually not yet supported by the driver. There is a wp_gpio in struct esdhc_platform_data (arch/arm/plat-mxc/include/mach/esdhc.h) but it's not yet used by the driver.

It's all prepared. I finally will have a look into it today.

oh, great. I was thinking about doing it but I'll wait for your patches then. I'm sure I need support for WP on GPIO but I may also need support for CD on GPIO so I'll be happy to test any patch you have.

Thanks,
Arnaud

#20 lore raw

cover SD/MMC driver for MX25/35/51

Hi Richard,

great to have you back! Did you have the chance to test my latest patch-series? And can you help Eric with the comments for the clock-calculation on MX51?

Quoted 1 line

I can't access the external git repos because of the firewall.:(.

Ouch! I hope you already complained ;) At least my repo should be accessible via HTTP by the way...

Regards,

Wolfram

Signature · 9 lines
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20101013/bcf36423/attachment.sig>
#21 lore raw

cover SD/MMC driver for MX25/35/51

Hi Wolfram,

Le 13/10/2010 12:06, Wolfram Sang a ?crit :

Quoted 4 lines

great to have you back! Did you have the chance to test my latest patch-series? And can you help Eric with the comments for the clock-calculation on MX51?

that's solved in the latest version of the patch (and the max value checks in the function were improved at the same time).

Eric

#22 lore raw

cover SD/MMC driver for MX25/35/51

Hi Wolfram&Eric:
I take one day leave yesterday for one examination that had been booked a few days ago,
and missed Eric's patches, so regretful.

Best Regards
Richard Zhu

Quoted 19 lines

-----Original Message-----
From: Eric Bénard [mailto:[email protected]]
Sent: Wednesday, October 13, 2010 6:10 PM
To: Wolfram Sang
Cc: Zhu Richard-R65037; Arnaud Patard; [email protected]; linux- [email protected]
Subject: Re: [PATCH 0/6] SD/MMC driver for MX25/35/51

Hi Wolfram,

Quoted 4 lines · Wolfram Sang

great to have you back! Did you have the chance to test my latest patch-series? And can you help Eric with the comments for the clock-calculation on MX51?

that's solved in the latest version of the patch (and the max value checks in the function were improved at the same time).

Eric

#23 lore raw

cover SD/MMC driver for MX25/35/51

Quoted 3 lines

I take one day leave yesterday for one examination that had been booked a few days ago,
and missed Eric's patches, so regretful.

No problem, such things happen. If you'd have time to review those patches now, that would be great, too.

Signature · 9 lines
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20101013/933dd515/attachment.sig>
#24 lore raw

cover SD/MMC driver for MX25/35/51

Richard,

Quoted 5 lines
Quoted 2 lines

I take one day leave yesterday for one examination that had been booked a few days ago,
and missed Eric's patches, so regretful.

No problem, such things happen. If you'd have time to review those patches now, that would be great, too.

Do you have time to check the latest series (V5, just posted)? BTW which patch-set are you using now for development?

Regards,

Wolfram

Signature · 9 lines
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20101015/23e80511/attachment.sig>
#25 lore raw

cover SD/MMC driver for MX25/35/51

Hi Wolfram:
Can you sync-up the http URL of your repos with your latest patches?
I can't get fetch and sync-up with your latest codes now, since I can only used the HTTP URL to clone your codes.

Best Regards
Richard Zhu

Quoted 28 lines

-----Original Message-----
From: Wolfram Sang [mailto:w.sang at pengutronix.de]
Sent: Friday, October 15, 2010 6:27 PM
To: Zhu Richard-R65037
Cc: Eric B?nard; Arnaud Patard; linux-mmc at vger.kernel.org; linux-arm- kernel at lists.infradead.org
Subject: Re: [PATCH 0/6] SD/MMC driver for MX25/35/51

Richard,

Quoted 5 lines
Quoted 2 lines

I take one day leave yesterday for one examination that had been booked a few days ago, and missed Eric's patches, so regretful.

No problem, such things happen. If you'd have time to review those patches now, that would be great, too.

Do you have time to check the latest series (V5, just posted)? BTW which patch-set are you using now for development?

Regards,

Wolfram

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

#26 lore raw

cover SD/MMC driver for MX25/35/51

In reply to Wolfram Sang

Hi Wolfram:
I tested your serial patches with Eric's platform related codes on i.MX51 BBG3.0 board. Two phenomena:
The debug msg "mmc0: mmc_rescan: trying to init card at 400000 Hz..." are dumped out repeatedly.
ROOT: There are pr_info codes in the mmc_rescan func.

The other:
Encounter the Timeout and CRC error when the sandisk 4G SDHC card are used as the ROOTFS storage media When I boot up the BBG board.

It seems that the "SDHCI_QUIRK_BROKEN_TIMEOUT_VAL" is mandatory required at my side when I did the tests
on BBG3.0 board, and the i.MX51 board can support the "MULTI-BLOCK".

Hi Eric:
What's kinds of tests and environment you did at your side?

BTW, I still can't fetch out the latest codes out, that means I still can't found the V5 patches, although I run the git fetch and git rebase. :(

Best Regards
Richard Zhu

Quoted 45 lines

-----Original Message-----
From: Zhu Richard-R65037
Sent: Monday, October 18, 2010 11:30 AM
To: 'Wolfram Sang'
Cc: Eric Bénard; Arnaud Patard; [email protected]; linux-arm- [email protected]
Subject: RE: [PATCH 0/6] SD/MMC driver for MX25/35/51

Hi Wolfram:
Can you sync-up the http URL of your repos with your latest patches? I can't get fetch and sync-up with your latest codes now, since I can only used the HTTP URL to clone your codes.

Best Regards
Richard Zhu

Quoted 28 lines

-----Original Message-----
From: Wolfram Sang [mailto:[email protected]]
Sent: Friday, October 15, 2010 6:27 PM
To: Zhu Richard-R65037
Cc: Eric Bénard; Arnaud Patard; [email protected]; linux-arm- [email protected]
Subject: Re: [PATCH 0/6] SD/MMC driver for MX25/35/51

Richard,

Quoted 5 lines
Quoted 2 lines

I take one day leave yesterday for one examination that had been booked a few days ago, and missed Eric's patches, so regretful.

No problem, such things happen. If you'd have time to review those patches now, that would be great, too.

Do you have time to check the latest series (V5, just posted)? BTW which patch-set are you using now for development?

Regards,

Wolfram

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

#27 lore raw

cover SD/MMC driver for MX25/35/51

Hi Richard,

Le 18/10/2010 10:48, Zhu Richard-R65037 a ?crit :

Quoted 5 lines

I tested your serial patches with Eric's platform related codes on i.MX51 BBG3.0 board. Two phenomena:
The debug msg "mmc0: mmc_rescan: trying to init card at 400000 Hz..." are dumped out repeatedly.
ROOT: There are pr_info codes in the mmc_rescan func.

fixed by this patch :
http://git.kernel.org/?p=linux/kernel/git/cjb/mmc.git;a=commit;h=0ca6d53ec81a13263f6643372b2a5abf7818e8fa

Quoted 7 lines

The other:
Encounter the Timeout and CRC error when the sandisk 4G SDHC card are used as the ROOTFS storage media When I boot up the BBG board.

It seems that the "SDHCI_QUIRK_BROKEN_TIMEOUT_VAL" is mandatory required at my side when I did the tests
on BBG3.0 board, and the i.MX51 board can support the "MULTI-BLOCK".

you seems to be right, the attached patch seems to fix it (tested on our board using a Linaro rootfs on a Transcend SDHC card and I didn't get errors after applying this patch but I'm stopped by udev errors now with this rootfs).

(quoted diff) +0 -0

b/drivers/mmc/host/sdhci-esdhc-imx.c
index 2e9cca1..e8f7048 100644

drivers/mmc/host/sdhci-esdhc-imx.c +2 -1
@@ -134,7 +134,8 @@ static struct sdhci_ops sdhci_esdhc_ops = {
 
  struct sdhci_pltfm_data sdhci_esdhc_imx_pdata = {
         .quirks = ESDHC_DEFAULT_QUIRKS | SDHCI_QUIRK_NO_MULTIBLOCK
-                       | SDHCI_QUIRK_BROKEN_ADMA,
+                       | SDHCI_QUIRK_BROKEN_ADMA
+                       | SDHCI_QUIRK_BROKEN_TIMEOUT_VAL,
         /* ADMA has issues. Might be fixable */
         /* NO_MULTIBLOCK might be MX35 only (Errata: ENGcm07207) */
         .ops = &sdhci_esdhc_ops,
Quoted 2 lines

What's kinds of tests and environment you did at your side?

Environment : our i.MX515 based boards.
Tests (until now) : mount + a few read/write.
We have a nand flash on board so our rootfs is on it so I didn't test a rootfs until this morning.

Eric

#28 lore raw

cover SD/MMC driver for MX25/35/51

Hi Eric:
Got that, great.
I tested at my side with the "SDHCI_QUIRK_BROKEN_TIMEOUT_VAL" added, and I can login the ROOTFS, and complete some general tests. :)

HI Wolfram:
About the codes I used in my verification, pls refer to the following log with "git log" cmd commit 44139322fc36bb23a066ccebb85981b544c957e7

Author: Wolfram Sang <[email protected]>
Date:   Fri Sep 3 18:27:48 2010 +0200

mmc: sdhci-pltfm: add pltfm-driver for imx35/51

This driver adds basic support for the esdhc-core found on e.g. imx35/51. It adds up to the pltfm-core.

commit 1c458bcff936e8b391b47cf916bcc2b17774cba9

Author: Wolfram Sang <[email protected]>
Date:   Tue Sep 7 13:00:26 2010 +0200

mmc: sdhci-of-esdhc: factor out common stuff

Put everything which can be shared between the OF and platform version of this driver into a local .h-file.

Best Regards
Richard Zhu

Quoted 60 lines

-----Original Message-----
From: Eric Bénard [mailto:[email protected]]
Sent: Monday, October 18, 2010 5:37 PM
To: Zhu Richard-R65037
Cc: Wolfram Sang; [email protected]; Guo Shawn-R65073; [email protected]; Arnaud Patard
Subject: Re: [PATCH 0/6] SD/MMC driver for MX25/35/51

Hi Richard,

Quoted 1 line · Le 18/10/2010 10:48, Zhu Richard-R65037 a écrit :

I tested your serial patches with Eric's platform related codes on

i.MX51 BBG3.0 board.

Quoted 2 lines

Two phenomena:
The debug msg "mmc0: mmc_rescan: trying to init card at 400000 Hz..."

are dumped out repeatedly.

Quoted 2 lines

ROOT: There are pr_info codes in the mmc_rescan func.

fixed by this patch :
http://git.kernel.org/?p=linux/kernel/git/cjb/mmc.git;a=commit;h=0ca6d53e
c81a13263f6643372b2a5abf7818e8fa

Quoted 5 lines

The other:
Encounter the Timeout and CRC error when the sandisk 4G SDHC card are used as the ROOTFS storage media When I boot up the BBG board.

It seems that the "SDHCI_QUIRK_BROKEN_TIMEOUT_VAL" is mandatory

required at my side when I did the tests

Quoted 2 lines

on BBG3.0 board, and the i.MX51 board can support the "MULTI-BLOCK".

you seems to be right, the attached patch seems to fix it (tested on our board using a Linaro rootfs on a Transcend SDHC card and I didn't get errors after applying this patch but I'm stopped by udev errors now with this rootfs).

drivers/mmc/host/sdhci-esdhc-imx.c +2 -1
index 2e9cca1..e8f7048 100644
@@ -134,7 +134,8 @@ static struct sdhci_ops sdhci_esdhc_ops = {
 
  struct sdhci_pltfm_data sdhci_esdhc_imx_pdata = {
         .quirks = ESDHC_DEFAULT_QUIRKS | SDHCI_QUIRK_NO_MULTIBLOCK
-                       | SDHCI_QUIRK_BROKEN_ADMA,
+                       | SDHCI_QUIRK_BROKEN_ADMA
+                       | SDHCI_QUIRK_BROKEN_TIMEOUT_VAL,
         /* ADMA has issues. Might be fixable */
         /* NO_MULTIBLOCK might be MX35 only (Errata: ENGcm07207) */
         .ops = &sdhci_esdhc_ops,
Quoted 4 lines

What's kinds of tests and environment you did at your side?

Environment : our i.MX515 based boards.
Tests (until now) : mount + a few read/write.
We have a nand flash on board so our rootfs is on it so I didn't test a rootfs until this morning.

Eric

#29 lore raw

cover SD/MMC driver for MX25/35/51

In reply to Eric Bénard
Quoted 4 lines

you seems to be right, the attached patch seems to fix it (tested on our board using a Linaro rootfs on a Transcend SDHC card and I didn't get errors after applying this patch but I'm stopped by udev errors now with this rootfs).

Is this needed on MX35, too?

Signature · 9 lines
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20101018/1609f006/attachment.sig>
#30 lore raw

cover SD/MMC driver for MX25/35/51

Le 18/10/2010 13:38, Wolfram Sang a ?crit :

Quoted 7 lines
Quoted 4 lines

you seems to be right, the attached patch seems to fix it (tested on our board using a Linaro rootfs on a Transcend SDHC card and I didn't get errors after applying this patch but I'm stopped by udev errors now with this rootfs).

Is this needed on MX35, too?

will test asap and send a formal patch once tested.

Eric

#31 lore raw

cover SD/MMC driver for MX25/35/51

In reply to Zhu Richard-R65037

Hi Richard,

Quoted 2 lines · On Mon, Oct 18, 2010 at 04:48:07PM +0800, Zhu Richard-R65037 wrote:

The debug msg "mmc0: mmc_rescan: trying to init card at 400000 Hz..." are dumped out repeatedly.
ROOT: There are pr_info codes in the mmc_rescan func.

There was already a patch on this list fixing it.

Quoted 6 lines

The other:
Encounter the Timeout and CRC error when the sandisk 4G SDHC card are used as the ROOTFS storage media When I boot up the BBG board.

It seems that the "SDHCI_QUIRK_BROKEN_TIMEOUT_VAL" is mandatory required at my side when I did the tests
on BBG3.0 board, and the i.MX51 board can support the "MULTI-BLOCK".

Okay, this can be fixed...

Quoted 2 lines

BTW, I still can't fetch out the latest codes out, that means I still can't found the V5 patches, although I run the git fetch and git rebase. :(

My branch gets rebased because I can't mainline the driver with all my incremental improvements. Does just taking the branch and cherry-pick your additions work? (BTW meanwhile you can also just use mmc-next)

Regards,

Wolfram

Signature · 9 lines
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20101018/bd8ece60/attachment.sig>
#32 lore raw

cover SD/MMC driver for MX25/35/51

In reply to Arnaud Patard (Rtp)
Quoted 9 lines · Arnaud Patard
Quoted 5 lines
Quoted 3 lines

it's actually not yet supported by the driver. There is a wp_gpio in struct esdhc_platform_data (arch/arm/plat-mxc/include/mach/esdhc.h) but it's not yet used by the driver.

It's all prepared. I finally will have a look into it today.

oh, great. I was thinking about doing it but I'll wait for your patches then. I'm sure I need support for WP on GPIO but I may also need support for CD on GPIO so I'll be happy to test any patch you have.

Just to keep you updated: Got a bit distracted again but I hope to finish it on Saturday. Looks like a patch for the gpiolib is also needed...

Signature · 9 lines
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20101015/e8fb7eaf/attachment.sig>
#33 lore raw

cover SD/MMC driver for MX25/35/51

Wolfram Sang <[email protected]> writes:

Hi,

Quoted 8 lines · Arnaud Patard
Quoted 7 lines
Quoted 6 lines
Quoted 4 lines

it's actually not yet supported by the driver. There is a wp_gpio in struct esdhc_platform_data (arch/arm/plat-mxc/include/mach/esdhc.h) but it's not yet used by the driver.

It's all prepared. I finally will have a look into it today.

Quoted 7 lines
Quoted 3 lines

oh, great. I was thinking about doing it but I'll wait for your patches then. I'm sure I need support for WP on GPIO but I may also need support for CD on GPIO so I'll be happy to test any patch you have.

Just to keep you updated: Got a bit distracted again but I hope to finish it on Saturday. Looks like a patch for the gpiolib is also needed...

ok. Take your time. It turns out that the infos I had were a bit misleading. I've been told the mmc driver was using some gpios and the gpios are GPIO_1_0/1_1 and GPIO_1_7/1_8... which are in fact the esdhc1 and esdhc2 CD and WP.

This means :
- with proper iomux configuration, WP detection is working fine
- I should still be able to test WP on GPIO

Thanks,
Arnaud