Skip to contentSkip to conversation

SD/MMC-driver for MX35/51 (and improvements to SDHCI)

PATCH Superseded Wolfram Sang 7 participants 22 messages Sep 29, 2010 – Oct 11, 2010

Subsystems (6)

v3 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v3 cover SD/MMC-driver for MX35/51 (and improvements to SDHCI)

Okay, here is the next version of my patch series. The first four are updates/improvements for sdhci and sdhci-pltfm and are of generic interest, too. I am still hoping for some Acked-by/Tested-by tags ;) Changes from the previous version are mentioned in the seperate files. I should have addressed all concerns raised. If not, please speak up.

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     |   22 ++++--
 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, 310 insertions(+), 111 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 v3 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 do not use the parent of the platform_device (if it is available), this breaks the clock-matching on ARM.

Cc Richard R?jfors <[email protected]>

---

Changes since last version:

* added types.h
* removed usage of pdev->dev.parent to ensure clk-matching Please speak up if this has a use case I failed to see!

 drivers/mmc/host/sdhci-pltfm.c |    8 ++++----
 drivers/mmc/host/sdhci-pltfm.h |    7 +++++++
 2 files changed, 11 insertions(+), 4 deletions(-)
drivers/mmc/host/sdhci-pltfm.c +4 -4
index e045e3c..095ca9d 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,15 @@ 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);
-	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 1/6 mmc: sdhci-pltfm: Add structure for host-specific data

Quoted 4 lines · Wolfram Sang

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 do not use the parent of the platform_device (if it is available), this breaks the clock-matching on ARM.

The reason it's there is for instance a case when the shdci device is exposed from a MFD device which sits on top of PCI. Then the parent (PCI device) is the device that is DMA capable. This patch will break such usage.

What is the purpose of this patch? You allocate space for an extra struct, which you have a pointer pointing to, but you never use the pointer?

Quoted 8 lines
Cc Richard R?jfors<[email protected]>

---

Changes since last version:

* added types.h

I saw no types.h?

Quoted 59 lines

* removed usage of pdev->dev.parent to ensure clk-matching Please speak up if this has a use case I failed to see!

  drivers/mmc/host/sdhci-pltfm.c |    8 ++++----
  drivers/mmc/host/sdhci-pltfm.h |    7 +++++++
  2 files changed, 11 insertions(+), 4 deletions(-)
drivers/mmc/host/sdhci-pltfm.c +4 -4
index e045e3c..095ca9d 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,15 @@ 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);
-	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 */
#3 lore raw

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

Hi Richard,

Quoted 9 lines · Richard R?jfors
Quoted 4 lines · Wolfram Sang

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 do not use the parent of the platform_device (if it is available), this breaks the clock-matching on ARM.

The reason it's there is for instance a case when the shdci device is exposed from a MFD device which sits on top of PCI. Then the parent (PCI device) is the device that is DMA capable. This patch will break such usage.

I feared that there is a reason. The problem I see is now, that the parent gets always set (from drivers/base/platform.c):

37c12e74 (Russell King            2005-11-05 21:19:33 +0000  235) int platform_device_add(struct platform_device *pdev)
^1da177e (Linus Torvalds          2005-04-16 15:20:36 -0700  236) {
^1da177e (Linus Torvalds          2005-04-16 15:20:36 -0700  237)       int i, ret = 0;
^1da177e (Linus Torvalds          2005-04-16 15:20:36 -0700  238) 
^1da177e (Linus Torvalds          2005-04-16 15:20:36 -0700  239)       if (!pdev)
^1da177e (Linus Torvalds          2005-04-16 15:20:36 -0700  240)               return -EINVAL;
^1da177e (Linus Torvalds          2005-04-16 15:20:36 -0700  241) 
^1da177e (Linus Torvalds          2005-04-16 15:20:36 -0700  242)       if (!pdev->dev.parent)
^1da177e (Linus Torvalds          2005-04-16 15:20:36 -0700  243)               pdev->dev.parent = &platform_bus;

...

So, sdhci-plftm cannot access the platform_data connected to the original platform_device via host->mmc->parent.

Quoted 2 lines

What is the purpose of this patch? You allocate space for an extra struct, which you have a pointer pointing to, but you never use the pointer?

We want to extend sdhci-pltfm to support the various sdhci-cores on (for now mainly) ARM platforms. A number of those cores need board specific information to be used in a custom init()-call, which shall be passed via platform_data. The pointer will be used in the platform specific extensions.

Quoted 10 lines
Quoted 8 lines
Cc Richard R?jfors<[email protected]>

---

Changes since last version:

* added types.h

I saw no types.h?

In the second chunk, the include file.

Thanks,

Wolfram

Quoted 60 lines
Quoted 60 lines

* removed usage of pdev->dev.parent to ensure clk-matching Please speak up if this has a use case I failed to see!

 drivers/mmc/host/sdhci-pltfm.c |    8 ++++----
 drivers/mmc/host/sdhci-pltfm.h |    7 +++++++
 2 files changed, 11 insertions(+), 4 deletions(-)
drivers/mmc/host/sdhci-pltfm.c +4 -4
index e045e3c..095ca9d 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,15 @@ 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);
-	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 · 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/20100930/fba09373/attachment.sig>
#4 lore raw

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

Quoted 9 lines · Wolfram Sang

Hi Richard,

Quoted 6 lines · Richard R?jfors
Quoted 4 lines · Wolfram Sang

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 do not use the parent of the platform_device (if it is available), this breaks the clock-matching on ARM.

Quoted 6 lines
Quoted 3 lines

The reason it's there is for instance a case when the shdci device is exposed from a MFD device which sits on top of PCI. Then the parent (PCI device) is the device that is DMA capable. This patch will break such usage.

I feared that there is a reason. The problem I see is now, that the parent gets always set (from drivers/base/platform.c):

Then we obviously need to pass more information in the platform_data to be able to chose which device to be used.

Quoted 3 lines

So, sdhci-plftm cannot access the platform_data connected to the original platform_device via host->mmc->parent.

You're right it wouldn't. But isn't it a bit risky even if you could access it, in the long the platform_data coild point to something that is in the __devinit section or similar?
What about extend the struct you defined with the pieces needed, and access it via sdhci_priv?

Quoted 7 lines
Quoted 2 lines

What is the purpose of this patch? You allocate space for an extra struct, which you have a pointer pointing to, but you never use the pointer?

We want to extend sdhci-pltfm to support the various sdhci-cores on (for now mainly) ARM platforms. A number of those cores need board specific information to be used in a custom init()-call, which shall be passed via platform_data. The pointer will be used in the platform specific extensions.

Sounds good.

Regards,
Richard

Quoted 79 lines
Quoted 11 lines
Quoted 9 lines
Cc Richard R?jfors<[email protected]>

---

Changes since last version:

* added types.h

I saw no types.h?

In the second chunk, the include file.

Thanks,

Wolfram

Quoted 60 lines
Quoted 60 lines

* removed usage of pdev->dev.parent to ensure clk-matching Please speak up if this has a use case I failed to see!

  drivers/mmc/host/sdhci-pltfm.c |    8 ++++----
  drivers/mmc/host/sdhci-pltfm.h |    7 +++++++
  2 files changed, 11 insertions(+), 4 deletions(-)
drivers/mmc/host/sdhci-pltfm.c +4 -4
index e045e3c..095ca9d 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,15 @@ 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);
-	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 */
#5 lore raw

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

Quoted 14 lines · Richard R?jfors
Quoted 13 lines · Wolfram Sang

Hi Richard,

Quoted 9 lines · Richard R?jfors
Quoted 4 lines · Wolfram Sang

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 do not use the parent of the platform_device (if it is available), this breaks the clock-matching on ARM.

The reason it's there is for instance a case when the shdci device is exposed from a MFD device which sits on top of PCI. Then the parent (PCI device) is the device that is DMA capable. This patch will break such usage.

Quoted 5 lines
Quoted 2 lines

I feared that there is a reason. The problem I see is now, that the parent gets always set (from drivers/base/platform.c):

Then we obviously need to pass more information in the platform_data to be able to chose which device to be used.

Yeah, that was my idea, too.

Quoted 6 lines
Quoted 2 lines

So, sdhci-plftm cannot access the platform_data connected to the original platform_device via host->mmc->parent.

You're right it wouldn't. But isn't it a bit risky even if you could access it, in the long the platform_data coild point to something that is in the __devinit section or similar?

The use-case we see now is in the custom init() call, i.e. setting up GPIO, enabling clocks. That is in the same section. Accessing platform_data later is in deed always risky and should not be done, sdhci-pltfm is no special case here.

Quoted 2 lines

What about extend the struct you defined with the pieces needed, and access it via sdhci_priv?

At the moment, I don't think this is needed. Will think more about it (and the other comments) next week, already preparing for a long weekend \o/

Thanks,

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/20100930/d0f79250/attachment.sig>
#6 lore raw

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

On Thu, Sep 30, 2010 at 12:19:38PM +0200, Wolfram Sang wrote:
[...]

Quoted 8 lines
Quoted 3 lines

You're right it wouldn't. But isn't it a bit risky even if you could access it, in the long the platform_data coild point to something that is in the __devinit section or similar?

The use-case we see now is in the custom init() call, i.e. setting up GPIO, enabling clocks. That is in the same section. Accessing platform_data later is in deed always risky and should not be done, sdhci-pltfm is no special case here.

I don't think that it's always risky, it's more driver-specific.

Many drivers access it from everywhere, see drivers/mmc/host/mmc_spi.c for example. In general, if the driver needs most of the platform data in the run-time, it makes no sense to duplicate or copy the pdata into the private struct field by field.

Thanks,

Signature · 3 lines
Anton Vorontsov
email: cbouatmailru at gmail.com
irc://irc.freenode.net/bd2
#7 lore raw

PATCH v3 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 095ca9d..e95b454 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
#8 lore raw

PATCH v3 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 96c7f60..129958e 100644
@@ -1229,14 +1229,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 112543a..66f83f4 100644
@@ -336,6 +336,7 @@ struct sdhci_ops {
 	unsigned int	(*get_max_clock)(struct sdhci_host *host);
 	unsigned int	(*get_min_clock)(struct sdhci_host *host);
 	unsigned int	(*get_timeout_clock)(struct sdhci_host *host);
+	unsigned int    (*get_ro)(struct sdhci_host *host);
 };
 
 #ifdef CONFIG_MMC_SDHCI_IO_ACCESSORS
Signature · 1 line
1.7.1
#9 lore raw

PATCH v3 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>".)

---

Changes since last version:

* Removed priv_data-variable.

 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 e95b454..5d963fe 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) {
@@ -105,7 +107,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
#10 lore raw

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

Hi,

Quoted 6 lines · 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).

Why not a pointer to the platform_device itself? Then the callback function would have even more information (e.g. platform_device ID) and could easily get at the platform_data too.

Lothar Wa?mann

Signature · 9 lines
___________________________________________________________

Ka-Ro electronics GmbH | Pascalstra?e 22 | D - 52076 Aachen
Phone: +49 2408 1402-0 | Fax: +49 2408 1402-10
Gesch?ftsf?hrer: Matthias Kaussen
Handelsregistereintrag: Amtsgericht Aachen, HRB 4996

www.karo-electronics.de | info at karo-electronics.de
___________________________________________________________
#11 lore raw

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

Quoted 9 lines · Lothar Wa?mann
Quoted 6 lines

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).

Why not a pointer to the platform_device itself? Then the callback function would have even more information (e.g. platform_device ID) and could easily get at the platform_data too.

dev->platform_data may not be there. There are two ways to pass the "platform data" to the sdhci-pltfm driver:

a) via dev->platform_data
b) via platform_device_id->driver_data

Technically, we can do something like this in the probe():

if (!pdev->dev.platform_data)

	pdev->dev.platform_data = platform_device_id->driver_data;

pdata->init(dev);

Note, in this case we must also NULLify platform_data it at remove(), as platform_device_release() will try to free statically allocated memory.

Thanks,

Signature · 3 lines
Anton Vorontsov
email: cbouatmailru at gmail.com
irc://irc.freenode.net/bd2
#12 lore raw

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

Quoted 11 lines · Anton Vorontsov
Quoted 9 lines · Lothar Wa?mann
Quoted 6 lines

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).

Why not a pointer to the platform_device itself? Then the callback function would have even more information (e.g. platform_device ID) and could easily get at the platform_data too.

Quoted 5 lines

dev->platform_data may not be there. There are two ways to pass the "platform data" to the sdhci-pltfm driver:

a) via dev->platform_data
b) via platform_device_id->driver_data

or c) both :)

which is the reason for the current implementation. platform_device_id->driver_data may still need additional information from the board (e.g. a write protect pin from board pcm043) while the larger part of the driver_data-extensions are still generic (e.g. to imx-esdhc).

Quoted 22 lines

Technically, we can do something like this in the probe():

if (!pdev->dev.platform_data)

	pdev->dev.platform_data = platform_device_id->driver_data;

pdata->init(dev);

Note, in this case we must also NULLify platform_data it at remove(), as platform_device_release() will try to free statically allocated memory.

Thanks,

Signature · 7 lines
Anton Vorontsov
email: cbouatmailru at gmail.com
irc://irc.freenode.net/bd2
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
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/20101011/f3816841/attachment.sig>
#13 lore raw

PATCH v3 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.

---

Changes since last version:

* use inline for set_clock()

 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
#14 lore raw

PATCH v3 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:

* some more -imx suffixes added
* reworked the clock-matching. Now matching the pdev

 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 6f12d5d..3c8c286 100644
@@ -143,6 +143,16 @@ config MMC_SDHCI_MV
 
 	  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 ef32c32..5f283b5 100644
@@ -38,6 +38,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 2b315e9..9ef7050 100644
@@ -164,6 +164,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
#15 lore raw

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

Hi Wolfram,

Quoted 160 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:

* some more -imx suffixes added
* reworked the clock-matching. Now matching the pdev

 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 6f12d5d..3c8c286 100644
@@ -143,6 +143,16 @@ config MMC_SDHCI_MV
 
 	  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 ef32c32..5f283b5 100644
@@ -38,6 +38,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 +101 -0
new file mode 100644
index 0000000..68cf78c
@@ -0,0 +1,143 @@
+/*
+ * Freescale eSDHC i.MX controller driver for the platform bus.
+ *
+ * derived from the OF-version.
+ *
+ * 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.
+ */
+
+#include <linux/io.h>
+#include <linux/delay.h>
+#include <linux/err.h>
+#include <linux/clk.h>
+#include <linux/mmc/host.h>
+#include <linux/mmc/sdhci-pltfm.h>
+#include "sdhci.h"
+#include "sdhci-pltfm.h"
+#include "sdhci-esdhc.h"
+
+static inline void esdhc_clrset_le(struct sdhci_host *host, u32 mask, u32 val, int reg)
+{
+	void __iomem *base = host->ioaddr + (reg & ~0x3);
+	u32 shift = (reg & 0x3) * 8;
+
+	writel(((readl(base) & ~(mask << shift)) | (val << shift)), base);
+}
+
+static u16 esdhc_readw_le(struct sdhci_host *host, int reg)
+{
+	if (unlikely(reg == SDHCI_HOST_VERSION))
+		reg ^= 2;
+
+	return readw(host->ioaddr + reg);
+}
+
+static void esdhc_writew_le(struct sdhci_host *host, u16 val, int reg)
+{
+	struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
+
+	switch (reg) {
+	case SDHCI_TRANSFER_MODE:
+		/*
+		 * Postpone this write, we must do it together with a
+		 * command write that is down below.
+		 */
+		pltfm_host->scratchpad = val;
+		return;
+	case SDHCI_COMMAND:
+		writel(val << 16 | pltfm_host->scratchpad,
+			host->ioaddr + SDHCI_TRANSFER_MODE);
+		return;
+	case SDHCI_BLOCK_SIZE:
+		val &= ~SDHCI_MAKE_BLKSZ(0x7, 0);
+		break;
+	}
+	esdhc_clrset_le(host, 0xffff, val, reg);
+}
+
+static void esdhc_writeb_le(struct sdhci_host *host, u8 val, int reg)
+{
+	u32 new_val;
+
+	switch (reg) {
+	case SDHCI_POWER_CONTROL:
+		/*
+		 * FSL put some DMA bits here
+		 * If your board has a regulator, code should be here
+		 */
+		return;
+	case SDHCI_HOST_CONTROL:
+		/* FSL messed up here, so we can just keep those two */
+		new_val = val & (SDHCI_CTRL_LED | SDHCI_CTRL_4BITBUS);
+		/* ensure the endianess */
+		new_val |= ESDHC_HOST_CONTROL_LE;
+		/* DMA mode bits are shifted */
+		new_val |= (val & SDHCI_CTRL_DMA_MASK) << 5;
+
+		esdhc_clrset_le(host, 0xffff, new_val, reg);
+		return;
+	}
+	esdhc_clrset_le(host, 0xff, val, reg);
+}
+
+static unsigned int esdhc_pltfm_get_max_clock(struct sdhci_host *host)
+{
+	struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
+
+	return clk_get_rate(pltfm_host->clk);
+}
+
+static unsigned int esdhc_pltfm_get_min_clock(struct sdhci_host *host)
+{
+	struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
+
+	return clk_get_rate(pltfm_host->clk) / 256 / 16;
+}
+

drivers/mmc/host/sdhci-esdhc-imx.c line 111

Quoted 10 lines
drivers/mmc/host/sdhci-esdhc-imx.c new file +10 -0
+static int esdhc_pltfm_init(struct sdhci_host *host, struct sdhci_pltfm_data *pdata)
+{
+	struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
+	struct clk *clk;
+
+	clk = clk_get(mmc_dev(host->mmc), NULL);
+	if (IS_ERR(clk)) {
+		dev_err(mmc_dev(host->mmc), "clk err\n");
+		return -ENODEV;
+	}

Is there a reason to return -ENODEV instead of PTR_ERR(clk)?

Patchset is looking good, thanks very much for keeping work going on -pltfm,

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

PATCH 1/4 mach-cpuimx35: remove unecessary tsc2007 functions + style cleanup

In reply to Wolfram Sang

- remove functions which are no more necessary for tsc2007
- indent platform_data for better readability

---
 arch/arm/mach-mx3/mach-cpuimx35.c |   32 +++++---------------------------
 1 files changed, 5 insertions(+), 27 deletions(-)
arch/arm/mach-mx3/mach-cpuimx35.c +5 -27
index 2a4f8b7..ea0a85f 100644
@@ -31,6 +31,7 @@
 #include <linux/usb/otg.h>
 #include <linux/usb/ulpi.h>
 #include <linux/fsl_devices.h>
+#include <linux/i2c-gpio.h>
 
 #include <asm/mach-types.h>
 #include <asm/mach/arch.h>
@@ -53,39 +54,16 @@ static const struct imxuart_platform_data uart_pdata __initconst = {
 };
 
 static const struct imxi2c_platform_data
-eukrea_cpuimx35_i2c0_data __initconst = {
-	.bitrate = 50000,
+		eukrea_cpuimx35_i2c0_data __initconst = {
+	.bitrate =		100000,
 };
 
-#define TSC2007_IRQGPIO		(2 * 32 + 2)
-static int ts_get_pendown_state(void)
-{
-	int val = 0;
-	gpio_free(TSC2007_IRQGPIO);
-	gpio_request(TSC2007_IRQGPIO, NULL);
-	gpio_direction_input(TSC2007_IRQGPIO);
-
-	val = gpio_get_value(TSC2007_IRQGPIO);
-
-	gpio_free(TSC2007_IRQGPIO);
-	gpio_request(TSC2007_IRQGPIO, NULL);
-
-	return val ? 0 : 1;
-}
-
-static int ts_init(void)
-{
-	gpio_request(TSC2007_IRQGPIO, NULL);
-	return 0;
-}
-
 static struct tsc2007_platform_data tsc2007_info = {
 	.model			= 2007,
 	.x_plate_ohms		= 180,
-	.get_pendown_state	= ts_get_pendown_state,
-	.init_platform_hw	= ts_init,
 };
 
+#define TSC2007_IRQGPIO		(2 * 32 + 2)
 static struct i2c_board_info eukrea_cpuimx35_i2c_devices[] = {
 	{
 		I2C_BOARD_INFO("pcf8563", 0x51),
@@ -135,7 +113,7 @@ static struct pad_desc eukrea_cpuimx35_pads[] = {
 };
 
 static const struct mxc_nand_platform_data
-eukrea_cpuimx35_nand_board_info __initconst = {
+		eukrea_cpuimx35_nand_board_info __initconst = {
 	.width		= 1,
 	.hw_ecc		= 1,
 	.flash_bbt	= 1,
Signature · 1 line
1.7.0.4
#17 lore raw

PATCH 2/4 eukrea_mbimxsd for cpuimx35: add CAN & SDCard support

In reply to Wolfram Sang
---
 arch/arm/mach-mx3/Kconfig                    |    2 ++
 arch/arm/mach-mx3/eukrea_mbimxsd-baseboard.c |   13 +++++++++++++
 2 files changed, 15 insertions(+), 0 deletions(-)
arch/arm/mach-mx3/Kconfig +2 -0
index 2f4d6cb..2c08dfd 100644
@@ -160,6 +160,8 @@ config MACH_EUKREA_CPUIMX35
 	select IMX_HAVE_PLATFORM_IMX_UART
 	select IMX_HAVE_PLATFORM_IMX_I2C
 	select IMX_HAVE_PLATFORM_MXC_NAND
+	select IMX_HAVE_PLATFORM_FLEXCAN
+	select IMX_HAVE_PLATFORM_ESDHC
 	select MXC_ULPI if USB_ULPI
 	help
 	  Include support for Eukrea CPUIMX35 platform. This includes
arch/arm/mach-mx3/eukrea_mbimxsd-baseboard.c +13 -0
index f8f15e3..0d219bb 100644
@@ -120,6 +120,16 @@ static struct pad_desc eukrea_mbimxsd_pads[] = {
 	MX35_PAD_STXD4__AUDMUX_AUD4_TXD,
 	MX35_PAD_SRXD4__AUDMUX_AUD4_RXD,
 	MX35_PAD_SCK4__AUDMUX_AUD4_TXC,
+	/* CAN2 */
+	MX35_PAD_TX5_RX0__CAN2_TXCAN,
+	MX35_PAD_TX4_RX1__CAN2_RXCAN,
+	/* SDCARD */
+	MX35_PAD_SD1_CMD__ESDHC1_CMD,
+	MX35_PAD_SD1_CLK__ESDHC1_CLK,
+	MX35_PAD_SD1_DATA0__ESDHC1_DAT0,
+	MX35_PAD_SD1_DATA1__ESDHC1_DAT1,
+	MX35_PAD_SD1_DATA2__ESDHC1_DAT2,
+	MX35_PAD_SD1_DATA3__ESDHC1_DAT3,
 };
 
 #define GPIO_LED1	(2 * 32 + 29)
@@ -244,6 +254,9 @@ void __init eukrea_mbimxsd35_baseboard_init(void)
 
 	mxc_register_device(&imx_ssi_device0, &eukrea_mbimxsd_ssi_pdata);
 
+	imx35_add_flexcan1(NULL);
+	imx35_add_esdhc0(NULL);
+
 	gpio_request(GPIO_LED1, "LED1");
 	gpio_direction_output(GPIO_LED1, 1);
 	gpio_free(GPIO_LED1);
Signature · 1 line
1.7.0.4
#18 lore raw

imx-for-2.6.37 broken [Was: [PATCH 2/4] eukrea_mbimxsd for cpuimx35: add CAN & SDCard support]

Hei Sascha,

you took this patch (patches 3 and 4, too) for your 2.6.37 branch without taking the dependencies (i.e. Wolfram's Patches that add the functions to register ehci devices.)

Best regards
Uwe

Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-K?nig            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
#19 lore raw

PATCH 3/4 i.mx25: add esdhc support

In reply to Wolfram Sang
---
 arch/arm/mach-mx25/clock.c            |   22 ++++++++++++++++++++++
 arch/arm/mach-mx25/devices-imx25.h    |    5 +++++
 arch/arm/plat-mxc/include/mach/mx25.h |    4 ++++
 3 files changed, 31 insertions(+), 0 deletions(-)
arch/arm/mach-mx25/clock.c +22 -0
index 40c7cc4..7a3d4e6 100644
@@ -139,6 +139,16 @@ static unsigned long get_rate_lcdc(struct clk *clk)
 	return get_rate_per(7);
 }
 
+static unsigned long get_rate_esdhc1(struct clk *clk)
+{
+	return get_rate_per(3);
+}
+
+static unsigned long get_rate_esdhc2(struct clk *clk)
+{
+	return get_rate_per(4);
+}
+
 static unsigned long get_rate_csi(struct clk *clk)
 {
 	return get_rate_per(0);
@@ -213,6 +223,12 @@ DEFINE_CLOCK(ssi2_per_clk, 0, CCM_CGCR0, 14, get_rate_ipg, NULL, NULL);
 DEFINE_CLOCK(cspi1_clk,  0, CCM_CGCR1,  5, get_rate_ipg, NULL, NULL);
 DEFINE_CLOCK(cspi2_clk,  0, CCM_CGCR1,  6, get_rate_ipg, NULL, NULL);
 DEFINE_CLOCK(cspi3_clk,  0, CCM_CGCR1,  7, get_rate_ipg, NULL, NULL);
+DEFINE_CLOCK(esdhc1_ahb_clk, 0, CCM_CGCR0, 21, get_rate_esdhc1,	 NULL, NULL);
+DEFINE_CLOCK(esdhc1_per_clk, 0, CCM_CGCR0,  3, get_rate_esdhc1,	 NULL,
+		&esdhc1_ahb_clk);
+DEFINE_CLOCK(esdhc2_ahb_clk, 0, CCM_CGCR0, 22, get_rate_esdhc2,	 NULL, NULL);
+DEFINE_CLOCK(esdhc2_per_clk, 0, CCM_CGCR0,  4, get_rate_esdhc2,	 NULL,
+		&esdhc2_ahb_clk);
 DEFINE_CLOCK(fec_ahb_clk, 0, CCM_CGCR0, 23, NULL,	 NULL, NULL);
 DEFINE_CLOCK(lcdc_ahb_clk, 0, CCM_CGCR0, 24, NULL,	 NULL, NULL);
 DEFINE_CLOCK(lcdc_per_clk, 0, CCM_CGCR0,  7, NULL,	 NULL, &lcdc_ahb_clk);
@@ -238,6 +254,10 @@ DEFINE_CLOCK(lcdc_clk,	 0, CCM_CGCR1, 29, get_rate_lcdc, NULL, &lcdc_per_clk);
 DEFINE_CLOCK(wdt_clk,    0, CCM_CGCR2, 19, get_rate_ipg, NULL,  NULL);
 DEFINE_CLOCK(ssi1_clk,  0, CCM_CGCR2, 11, get_rate_ssi1, NULL, &ssi1_per_clk);
 DEFINE_CLOCK(ssi2_clk,  1, CCM_CGCR2, 12, get_rate_ssi2, NULL, &ssi2_per_clk);
+DEFINE_CLOCK(esdhc1_clk,  0, CCM_CGCR1, 13, get_rate_esdhc1, NULL,
+		&esdhc1_per_clk);
+DEFINE_CLOCK(esdhc2_clk,  1, CCM_CGCR1, 14, get_rate_esdhc2, NULL,
+		&esdhc2_per_clk);
 DEFINE_CLOCK(audmux_clk, 0, CCM_CGCR1, 0, NULL, NULL, NULL);
 DEFINE_CLOCK(csi_clk,    0, CCM_CGCR1,  4, get_rate_csi, NULL,  &csi_per_clk);
 DEFINE_CLOCK(can1_clk,	 0, CCM_CGCR1,  2, get_rate_ipg, NULL, NULL);
@@ -279,6 +299,8 @@ static struct clk_lookup lookups[] = {
 	_REGISTER_CLOCK("imx-wdt.0", NULL, wdt_clk)
 	_REGISTER_CLOCK("imx-ssi.0", NULL, ssi1_clk)
 	_REGISTER_CLOCK("imx-ssi.1", NULL, ssi2_clk)
+	_REGISTER_CLOCK(NULL, "sdhc", esdhc1_clk)
+	_REGISTER_CLOCK(NULL, "sdhc", esdhc2_clk)
 	_REGISTER_CLOCK("mx2-camera.0", NULL, csi_clk)
 	_REGISTER_CLOCK(NULL, "audmux", audmux_clk)
 	_REGISTER_CLOCK("flexcan.0", NULL, can1_clk)
arch/arm/mach-mx25/devices-imx25.h +5 -0
index d86a7c3..4acb0c9 100644
@@ -41,3 +41,8 @@
 	imx_add_spi_imx(1, MX25_CSPI2_BASE_ADDR, SZ_16K, MX25_INT_CSPI2, pdata)
 #define imx25_add_spi_imx2(pdata)	\
 	imx_add_spi_imx(2, MX25_CSPI3_BASE_ADDR, SZ_16K, MX25_INT_CSPI3, pdata)
+
+#define imx25_add_esdhc0(pdata)	\
+	imx_add_esdhc(0, MX25_ESDHC1_BASE_ADDR, SZ_16K, MX25_INT_MMC_SDHC1, pdata)
+#define imx25_add_esdhc1(pdata)	\
+	imx_add_esdhc(1, MX25_ESDHC2_BASE_ADDR, SZ_16K, MX25_INT_MMC_SDHC2, pdata)
arch/arm/plat-mxc/include/mach/mx25.h +4 -0
index 4a6f800..67060e9 100644
@@ -50,6 +50,8 @@
 #define MX25_SSI1_BASE_ADDR		0x50034000
 #define MX25_NFC_BASE_ADDR		0xbb000000
 #define MX25_DRYICE_BASE_ADDR		0x53ffc000
+#define MX25_ESDHC1_BASE_ADDR		0x53fb4000
+#define MX25_ESDHC2_BASE_ADDR		0x53fb8000
 #define MX25_LCDC_BASE_ADDR		0x53fbc000
 #define MX25_KPP_BASE_ADDR		0x43fa8000
 #define MX25_OTG_BASE_ADDR		0x53ff4000
@@ -59,6 +61,8 @@
 #define MX25_INT_I2C1		3
 #define MX25_INT_I2C2		4
 #define MX25_INT_UART4		5
+#define MX25_INT_MMC_SDHC2	8
+#define MX25_INT_MMC_SDHC1	9
 #define MX25_INT_I2C3		10
 #define MX25_INT_SSI2		11
 #define MX25_INT_SSI1		12
Signature · 1 line
1.7.0.4
#20 lore raw

PATCH 4/4 eukrea_mbimxsd for cpuimx25: add CAN & SDCard support

In reply to Wolfram Sang
---
 arch/arm/mach-mx25/Kconfig                    |    2 ++
 arch/arm/mach-mx25/eukrea_mbimxsd-baseboard.c |    5 +++++
 2 files changed, 7 insertions(+), 0 deletions(-)
arch/arm/mach-mx25/Kconfig +2 -0
index c71a7bc..60cc16e 100644
@@ -12,6 +12,8 @@ config MACH_EUKREA_CPUIMX25
 	select IMX_HAVE_PLATFORM_IMX_I2C
 	select IMX_HAVE_PLATFORM_IMX_UART
 	select IMX_HAVE_PLATFORM_MXC_NAND
+	select IMX_HAVE_PLATFORM_FLEXCAN
+	select IMX_HAVE_PLATFORM_ESDHC
 	select MXC_ULPI if USB_ULPI
 
 choice
arch/arm/mach-mx25/eukrea_mbimxsd-baseboard.c +5 -0
index 4aaadc7..f4c4c6f 100644
@@ -90,6 +90,9 @@ static struct pad_desc eukrea_mbimxsd_pads[] = {
 	MX25_PAD_KPP_COL2__AUD5_TXC,
 	MX25_PAD_KPP_COL1__AUD5_RXD,
 	MX25_PAD_KPP_COL0__AUD5_TXD,
+	/* CAN */
+	MX25_PAD_GPIO_D__CAN2_RX,
+	MX25_PAD_GPIO_C__CAN2_TX,
 };
 
 #define GPIO_LED1	83
@@ -240,6 +243,8 @@ void __init eukrea_mbimxsd25_baseboard_init(void)
 	imx25_add_imx_uart1(&uart_pdata);
 	mxc_register_device(&mx25_fb_device, &eukrea_mximxsd_fb_pdata);
 	mxc_register_device(&imx_ssi_device0, &eukrea_mbimxsd_ssi_pdata);
+	imx25_add_flexcan1(NULL);
+	imx25_add_esdhc0(NULL);
 
 	gpio_request(GPIO_LED1, "LED1");
 	gpio_direction_output(GPIO_LED1, 1);
Signature · 1 line
1.7.0.4
#21 lore raw

v3 cover SD/MMC-driver for MX35/51 (and improvements to SDHCI)

In reply to Wolfram Sang

Le 29/09/2010 22:07, Wolfram Sang a ?crit :

Quoted 6 lines

Okay, here is the next version of my patch series. The first four are updates/improvements for sdhci and sdhci-pltfm and are of generic interest, too. I am still hoping for some Acked-by/Tested-by tags ;) Changes from the previous version are mentioned in the seperate files. I should have addressed all concerns raised. If not, please speak up.

Eric