From: Dong Aisheng <b29396@freescale.com>
To: devicetree-discuss@lists.ozlabs.org,
linux-kernel@vger.kernel.org, linux-mmc@vger.kernel.org,
linux-arm-kernel@lists.infradead.org
Cc: vinod.koul@linux.intel.com, s.hauer@pengutronix.de,
rob.herring@calxeda.com, grant.likely@secretlab.ca,
rdunlap@xenotime.net, kernel@pengutronix.de, cjb@laptop.org,
shawn.guo@freescale.com
Subject: [PATCH v1 2/5] mmc: mxs-mmc: add dt probe support
Date: Tue, 13 Mar 2012 16:47:05 +0800 [thread overview]
Message-ID: <1331628428-24017-3-git-send-email-b29396@freescale.com> (raw)
In-Reply-To: <1331628428-24017-1-git-send-email-b29396@freescale.com>
From: Dong Aisheng <dong.aisheng@linaro.org>
Signed-off-by: Dong Aisheng <dong.aisheng@linaro.org>
---
The patch is still using a private way for dma part binding
since the common dma binding is still under discussion.
http://www.spinics.net/lists/linux-omap/msg65528.html
Will update to use common dma binding when it hits mainline.
---
.../devicetree/bindings/mmc/fsl-mxs-mmc.txt | 23 ++++++
drivers/mmc/host/mxs-mmc.c | 82 +++++++++++++++++++-
2 files changed, 102 insertions(+), 3 deletions(-)
diff --git a/Documentation/devicetree/bindings/mmc/fsl-mxs-mmc.txt b/Documentation/devicetree/bindings/mmc/fsl-mxs-mmc.txt
new file mode 100644
index 0000000..adc1142
--- /dev/null
+++ b/Documentation/devicetree/bindings/mmc/fsl-mxs-mmc.txt
@@ -0,0 +1,23 @@
+* FREESCALE MXS MMC peripheral
+
+Required properties:
+- compatible : Should be "fsl,<chip>-mmc"
+- reg : Should contain registers location and length
+- interrupts : Should contain interrupt.
+ The format is <irq_err irq_dma>.
+- dma_channel: Should contain the dma channel it uses
+
+Optional properties:
+- wp-gpios : Specify GPIOs for write protection
+- slot-4bit: Specify 4 bit mode support
+- slot-8bit: Specify 8 bit and 4 bit mode support
+
+Examples:
+mmc1: ssp@80010000 {
+ compatible = "fsl,imx28-mmc";
+ reg = <0x80010000 2000>;
+ /* <irq_err irq_dma> */
+ interrupts = <96 82>;
+ dma_channel = <0>;
+ slot-8bit;
+};
diff --git a/drivers/mmc/host/mxs-mmc.c b/drivers/mmc/host/mxs-mmc.c
index 382c835..6cf2d17 100644
--- a/drivers/mmc/host/mxs-mmc.c
+++ b/drivers/mmc/host/mxs-mmc.c
@@ -38,6 +38,10 @@
#include <linux/gpio.h>
#include <linux/regulator/consumer.h>
#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
+#include <linux/of_gpio.h>
+#include <linux/slab.h>
#include <mach/mxs.h>
#include <mach/common.h>
@@ -673,17 +677,79 @@ static bool mxs_mmc_dma_filter(struct dma_chan *chan, void *param)
return true;
}
+#ifdef CONFIG_OF
+static struct resource * __devinit mxs_mmc_get_of_dmares(
+ struct platform_device *pdev)
+{
+ struct device_node *np = pdev->dev.of_node;
+ struct resource *dmares;
+ int ret;
+
+ if (!np)
+ return NULL;
+
+ dmares = kzalloc(sizeof(*dmares), GFP_KERNEL);
+ dmares->flags = IORESOURCE_DMA;
+ ret = of_property_read_u32(np, "dma_channel", &dmares->start);
+ if (ret) {
+ dev_err(&pdev->dev, "unable to get dmares from dt\n");
+ return NULL;
+ }
+ dmares->end = dmares->start;
+
+ return dmares;
+}
+
+static int __devinit mxs_mmc_get_of_property(struct platform_device *pdev,
+ struct mxs_mmc_platform_data **ppdata)
+{
+ struct device_node *np = pdev->dev.of_node;
+ struct mxs_mmc_platform_data *pdata = *ppdata;
+
+ if (!np)
+ return -ENODEV;
+
+ pdata = kzalloc(sizeof(*pdata), GFP_KERNEL);
+
+ if (of_get_property(np, "slot-8bit", NULL))
+ pdata->flags |= SLOTF_8_BIT_CAPABLE;
+
+ if (of_get_property(np, "slot-4bit", NULL))
+ pdata->flags |= SLOTF_4_BIT_CAPABLE;
+
+ pdata->wp_gpio = of_get_named_gpio(np, "wp-gpios", 0);
+
+ dev_dbg(&pdev->dev, "wp-gpios %d flags %d\n", pdata->wp_gpio,
+ pdata->flags);
+
+ return 0;
+}
+#else
+static struct resource * __devinit mxs_mmc_get_of_dmares(
+ struct platform_device *pdev)
+{
+ return NULL;
+}
+static inline int mxs_mmc_get_of_property(struct platform_device *pdev,
+ struct mxs_mmc_platform_data *pdata)
+{
+ return -ENODEV;
+}
+#endif
+
static int mxs_mmc_probe(struct platform_device *pdev)
{
struct mxs_mmc_host *host;
struct mmc_host *mmc;
struct resource *iores, *dmares, *r;
- struct mxs_mmc_platform_data *pdata;
+ struct mxs_mmc_platform_data *pdata = NULL;
int ret = 0, irq_err, irq_dma;
dma_cap_mask_t mask;
iores = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- dmares = platform_get_resource(pdev, IORESOURCE_DMA, 0);
+ dmares = mxs_mmc_get_of_dmares(pdev);
+ if (dmares == NULL)
+ dmares = platform_get_resource(pdev, IORESOURCE_DMA, 0);
irq_err = platform_get_irq(pdev, 0);
irq_dma = platform_get_irq(pdev, 1);
if (!iores || !dmares || irq_err < 0 || irq_dma < 0)
@@ -740,7 +806,9 @@ static int mxs_mmc_probe(struct platform_device *pdev)
mmc->caps = MMC_CAP_SD_HIGHSPEED | MMC_CAP_MMC_HIGHSPEED |
MMC_CAP_SDIO_IRQ | MMC_CAP_NEEDS_POLL;
- pdata = mmc_dev(host->mmc)->platform_data;
+ mxs_mmc_get_of_property(pdev, &pdata);
+ if (pdata == NULL)
+ pdata = mmc_dev(host->mmc)->platform_data;
if (pdata) {
if (pdata->flags & SLOTF_8_BIT_CAPABLE)
mmc->caps |= MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA;
@@ -851,6 +919,13 @@ static const struct dev_pm_ops mxs_mmc_pm_ops = {
};
#endif
+static const struct of_device_id mxs_mmc_dt_ids[] = {
+ { .compatible = "fsl,imx23-mmc", .data = NULL, },
+ { .compatible = "fsl,imx28-mmc", .data = NULL, },
+ { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, mxs_mmc_dt_ids);
+
static struct platform_driver mxs_mmc_driver = {
.probe = mxs_mmc_probe,
.remove = mxs_mmc_remove,
@@ -860,6 +935,7 @@ static struct platform_driver mxs_mmc_driver = {
#ifdef CONFIG_PM
.pm = &mxs_mmc_pm_ops,
#endif
+ .of_match_table = mxs_mmc_dt_ids,
},
};
--
1.7.0.4
next prev parent reply other threads:[~2012-03-13 8:47 UTC|newest]
Thread overview: 65+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-13 8:47 [PATCH v1 0/5] dt: add basic imx28 support Dong Aisheng
2012-03-13 8:47 ` [PATCH v1 1/5] ARM: imx28: add basic dt support Dong Aisheng
2012-03-13 14:35 ` Rob Herring
2012-03-13 14:59 ` Zach Sadecki
2012-03-13 17:28 ` Grant Likely
2012-03-14 5:38 ` Shawn Guo
2012-03-14 6:23 ` Dong Aisheng
2012-03-14 6:51 ` Marek Vasut
2012-03-14 13:05 ` Rob Herring
2012-03-15 2:57 ` Dong Aisheng
2012-03-13 17:23 ` Grant Likely
2012-03-14 5:41 ` Shawn Guo
2012-03-14 5:56 ` Marek Vasut
2012-03-14 6:30 ` Dong Aisheng
2012-03-14 12:45 ` Dong Aisheng
2012-03-14 14:16 ` s.hauer
2012-03-15 3:02 ` Dong Aisheng
2012-03-15 6:53 ` Lothar Waßmann
2012-03-15 10:59 ` Dong Aisheng
[not found] ` <20120315105927.GE13022-Fb7DQEYuewWctlrPMvKcciBecyulp+rMXqFh9Ls21Oc@public.gmane.org>
2012-03-15 11:22 ` Lothar Waßmann
2012-03-16 3:01 ` Dong Aisheng
2012-03-16 7:48 ` Lothar Waßmann
2012-03-16 8:22 ` Dong Aisheng
[not found] ` <20120316030134.GA5161-Fb7DQEYuewWctlrPMvKcciBecyulp+rMXqFh9Ls21Oc@public.gmane.org>
2012-03-18 18:47 ` Grant Likely
2012-03-19 6:54 ` Lothar Waßmann
[not found] ` <20326.55337.249575.289067-VjFSrY7JcPWvSplVBqRQBQ@public.gmane.org>
2012-03-19 15:06 ` Grant Likely
2012-03-19 16:49 ` Lothar Waßmann
[not found] ` <20327.25470.723875.916422-VjFSrY7JcPWvSplVBqRQBQ@public.gmane.org>
2012-03-19 22:02 ` Grant Likely
2012-03-20 12:49 ` Dong Aisheng
2012-03-20 13:17 ` Lothar Waßmann
2012-03-21 11:06 ` Dong Aisheng
2012-03-16 8:49 ` Shawn Guo
2012-03-15 11:24 ` s.hauer
2012-03-16 3:05 ` Dong Aisheng
2012-03-14 19:41 ` Sascha Hauer
2012-03-15 3:05 ` Dong Aisheng
2012-03-13 8:47 ` Dong Aisheng [this message]
2012-03-13 17:42 ` [PATCH v1 2/5] mmc: mxs-mmc: add dt probe support Grant Likely
2012-03-14 6:42 ` Dong Aisheng
2012-03-14 5:58 ` Marek Vasut
2012-03-14 6:55 ` Dong Aisheng
2012-03-14 7:09 ` Marek Vasut
2012-03-14 7:13 ` s.hauer
2012-03-14 7:26 ` Dong Aisheng
2012-03-14 11:17 ` Marek Vasut
2012-03-14 7:23 ` Jean-Christophe PLAGNIOL-VILLARD
2012-03-14 8:09 ` Dong Aisheng
[not found] ` <20120314080939.GA1180-Fb7DQEYuewWctlrPMvKcciBecyulp+rMXqFh9Ls21Oc@public.gmane.org>
2012-03-14 8:52 ` Jean-Christophe PLAGNIOL-VILLARD
2012-03-13 8:47 ` [PATCH v1 3/5] ARM: imx28evk: add mmc dt support Dong Aisheng
2012-03-13 14:39 ` Rob Herring
2012-03-13 16:52 ` Sascha Hauer
2012-03-13 17:45 ` Rob Herring
2012-03-14 7:30 ` Jean-Christophe PLAGNIOL-VILLARD
2012-03-14 8:20 ` Dong Aisheng
2012-03-14 8:54 ` Jean-Christophe PLAGNIOL-VILLARD
2012-03-14 7:28 ` Jean-Christophe PLAGNIOL-VILLARD
2012-03-13 8:47 ` [PATCH v1 4/5] dma: mxs-dma: add dt probe support Dong Aisheng
2012-03-14 7:54 ` Huang Shijie
2012-03-14 8:23 ` Dong Aisheng
2012-03-13 8:47 ` [PATCH v1 5/5] ARM: mxs: add mxs dma dt support Dong Aisheng
2012-03-14 7:58 ` Huang Shijie
2012-03-14 8:30 ` Dong Aisheng
2012-03-14 8:43 ` Huang Shijie
2012-03-14 6:01 ` [PATCH v1 0/5] dt: add basic imx28 support Marek Vasut
2012-03-14 7:34 ` Dong Aisheng
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1331628428-24017-3-git-send-email-b29396@freescale.com \
--to=b29396@freescale.com \
--cc=cjb@laptop.org \
--cc=devicetree-discuss@lists.ozlabs.org \
--cc=grant.likely@secretlab.ca \
--cc=kernel@pengutronix.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mmc@vger.kernel.org \
--cc=rdunlap@xenotime.net \
--cc=rob.herring@calxeda.com \
--cc=s.hauer@pengutronix.de \
--cc=shawn.guo@freescale.com \
--cc=vinod.koul@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).