From: marex@denx.de (Marek Vasut)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 08/10] mmc: mxs-mmc: add device tree support
Date: Tue, 8 May 2012 01:58:07 +0200 [thread overview]
Message-ID: <201205080158.07259.marex@denx.de> (raw)
In-Reply-To: <1336401793-13753-9-git-send-email-shawn.guo@linaro.org>
Dear Shawn Guo,
> It adds device tree probe support for mxs-mmc driver.
>
> Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
> ---
> Documentation/devicetree/bindings/mmc/mxs-mmc.txt | 26 +++++++++++
> drivers/mmc/host/mxs-mmc.c | 48
> ++++++++++++++++++-- 2 files changed, 69 insertions(+), 5 deletions(-)
> create mode 100644 Documentation/devicetree/bindings/mmc/mxs-mmc.txt
>
> diff --git a/Documentation/devicetree/bindings/mmc/mxs-mmc.txt
> b/Documentation/devicetree/bindings/mmc/mxs-mmc.txt new file mode 100644
> index 0000000..d7c2a40
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/mmc/mxs-mmc.txt
> @@ -0,0 +1,26 @@
> +* Freescale MXS MMC controller
> +
> +The Freescale MXS Synchronous Serial Ports (SSP) can act as a MMC
> controller +to support MMC, SD, and SDIO types of memory cards.
> +
> +Required properties:
> +- compatible: Should be "fsl,<chip>-mmc". The supported chips include
> + imx23 and imx28.
> +- reg: Should contain registers location and length
> +- interrupts: Should contain ERROR and DMA interrupts
> +- fsl,ssp-dma-channel: APBH DMA channel for the SSP
> +- fsl,bus-width: Number of data lines, can be <1>, <4>, or <8>
> +
> +Optional properties:
> +- wp-gpios: Specify GPIOs for write protection
You can have multiple wp-gpio per port? :-)
> +
> +Examples:
> +
> +ssp0: ssp at 80010000 {
> + compatible = "fsl,imx28-mmc";
> + reg = <0x80010000 2000>;
> + interrupts = <96 82>;
> + fsl,ssp-dma-channel = <0>;
> + fsl,bus-width = <8>;
> + status = "okay";
> +};
> diff --git a/drivers/mmc/host/mxs-mmc.c b/drivers/mmc/host/mxs-mmc.c
> index 66f792a..c6b56b4 100644
> --- a/drivers/mmc/host/mxs-mmc.c
> +++ b/drivers/mmc/host/mxs-mmc.c
> @@ -23,6 +23,9 @@
> #include <linux/kernel.h>
> #include <linux/init.h>
> #include <linux/ioport.h>
> +#include <linux/of.h>
> +#include <linux/of_device.h>
> +#include <linux/of_gpio.h>
> #include <linux/platform_device.h>
> #include <linux/delay.h>
> #include <linux/interrupt.h>
> @@ -685,8 +688,18 @@ static struct platform_device_id mxs_mmc_ids[] = {
> };
> MODULE_DEVICE_TABLE(platform, mxs_mmc_ids);
>
> +static const struct of_device_id mxs_mmc_dt_ids[] = {
> + { .compatible = "fsl,imx23-mmc", .data = (void *) IMX23_MMC, },
> + { .compatible = "fsl,imx28-mmc", .data = (void *) IMX28_MMC, },
> + { /* sentinel */ }
> +};
> +MODULE_DEVICE_TABLE(of, mxs_mmc_dt_ids);
> +
> static int mxs_mmc_probe(struct platform_device *pdev)
> {
> + const struct of_device_id *of_id =
> + of_match_device(mxs_mmc_dt_ids, &pdev->dev);
> + struct device_node *np = pdev->dev.of_node;
> struct mxs_mmc_host *host;
> struct mmc_host *mmc;
> struct resource *iores, *dmares;
> @@ -699,7 +712,7 @@ static int mxs_mmc_probe(struct platform_device *pdev)
> 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)
> + if (!iores || irq_err < 0 || irq_dma < 0)
> return -EINVAL;
>
> mmc = mmc_alloc_host(sizeof(struct mxs_mmc_host), &pdev->dev);
> @@ -713,15 +726,31 @@ static int mxs_mmc_probe(struct platform_device
> *pdev) goto out_mmc_free;
> }
>
> - host->devid = pdev->id_entry->driver_data;
> + if (np) {
> + host->devid = (enum mxs_mmc_id) of_id->data;
> + /*
> + * TODO: This is a temporary solution and should be changed
> + * to use generic DMA binding later when the helplers get in.
> + */
> + ret = of_property_read_u32(np, "fsl,ssp-dma-channel",
> + &host->dma_channel);
> + if (ret) {
> + dev_err(mmc_dev(host->mmc),
> + "failed to get dma channel\n");
> + goto out_mmc_free;
> + }
> + } else {
> + host->devid = pdev->id_entry->driver_data;
> + host->dma_channel = dmares->start;
> + }
> +
> host->mmc = mmc;
> - host->dma_channel = dmares->start;
> host->sdio_irq_en = 0;
>
> pinctrl = devm_pinctrl_get_select_default(&pdev->dev);
> if (IS_ERR(pinctrl)) {
> ret = PTR_ERR(pinctrl);
> - goto out_iounmap;
> + goto out_mmc_free;
> }
>
> host->clk = clk_get(&pdev->dev, NULL);
> @@ -749,7 +778,15 @@ static int mxs_mmc_probe(struct platform_device *pdev)
> MMC_CAP_SDIO_IRQ | MMC_CAP_NEEDS_POLL;
>
> pdata = mmc_dev(host->mmc)->platform_data;
> - if (pdata) {
> + if (!pdata) {
> + u32 bus_width = 0;
> + of_property_read_u32(np, "fsl,bus-width", &bus_width);
> + if (bus_width == 4)
> + mmc->caps |= MMC_CAP_4_BIT_DATA;
> + else if (bus_width == 8)
> + mmc->caps |= MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA;
> + host->wp_gpio = of_get_named_gpio(np, "wp-gpios", 0);
> + } else {
> if (pdata->flags & SLOTF_8_BIT_CAPABLE)
> mmc->caps |= MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA;
> if (pdata->flags & SLOTF_4_BIT_CAPABLE)
> @@ -857,6 +894,7 @@ static struct platform_driver mxs_mmc_driver = {
> .owner = THIS_MODULE,
> #ifdef CONFIG_PM
> .pm = &mxs_mmc_pm_ops,
> + .of_match_table = mxs_mmc_dt_ids,
> #endif
> },
> };
Best regards,
Marek Vasut
next prev parent reply other threads:[~2012-05-07 23:58 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-07 14:43 [PATCH 00/10] Add device tree support for mxs-mmc Shawn Guo
2012-05-07 14:43 ` [PATCH 01/10] mmc: mxs-mmc: use global stmp_device functionality Shawn Guo
2012-05-07 23:41 ` Marek Vasut
2012-05-07 14:43 ` [PATCH 02/10] mmc: mxs-mmc: let ssp_is_old take host as parameter Shawn Guo
2012-05-07 23:43 ` Marek Vasut
2012-05-08 14:32 ` Shawn Guo
2012-05-07 14:43 ` [PATCH 03/10] mmc: mxs-mmc: get rid of the use of cpu_is_xxx Shawn Guo
2012-05-07 23:46 ` Marek Vasut
2012-05-08 14:35 ` Shawn Guo
2012-05-07 14:43 ` [PATCH 04/10] mmc: mxs-mmc: move header from mach into linux folder Shawn Guo
2012-05-07 23:47 ` Marek Vasut
2012-05-07 14:43 ` [PATCH 05/10] mmc: mxs-mmc: use devm_* helper to make cleanup simpler Shawn Guo
2012-05-07 23:49 ` Marek Vasut
2012-05-08 14:38 ` Shawn Guo
2012-05-07 14:43 ` [PATCH 06/10] mmc: mxs-mmc: have dma_channel than dma_res in mxs_mmc_host Shawn Guo
2012-05-07 23:51 ` Marek Vasut
2012-05-07 14:43 ` [PATCH 07/10] mmc: mxs-mmc: copy wp_gpio in struct mxs_mmc_host Shawn Guo
2012-05-07 23:53 ` Marek Vasut
2012-05-08 14:40 ` Shawn Guo
2012-05-07 14:43 ` [PATCH 08/10] mmc: mxs-mmc: add device tree support Shawn Guo
2012-05-07 23:58 ` Marek Vasut [this message]
2012-05-08 14:43 ` Shawn Guo
2012-05-12 14:44 ` Chris Ball
2012-05-13 0:03 ` Shawn Guo
2012-05-13 0:11 ` Chris Ball
2012-05-13 0:21 ` Shawn Guo
2012-05-13 0:29 ` Shawn Guo
2012-05-07 14:43 ` [PATCH 09/10] ARM: dts: enable mmc for imx23-evk Shawn Guo
2012-05-07 14:43 ` [PATCH 10/10] ARM: dts: enable mmc for imx28-evk Shawn Guo
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=201205080158.07259.marex@denx.de \
--to=marex@denx.de \
--cc=linux-arm-kernel@lists.infradead.org \
/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).