diff options
author | Shawn Guo <shawn.guo@linaro.org> | 2013-02-25 21:10:38 -0500 |
---|---|---|
committer | Shawn Guo <shawn.guo@linaro.org> | 2013-04-04 09:22:44 -0400 |
commit | 0e91e434c86c84e84c46cf8bff2b5e53daee85d5 (patch) | |
tree | 2c8505b03948d91424731318dfa3d7745fae82b5 | |
parent | d84f638b037fcd132ecf6f09f5b8ccf82278b9ee (diff) |
mmc: mxs-mmc: move to use generic DMA helper
With the generic DMA device tree helper supported by mxs-dma driver,
client devices only need to call dma_request_slave_channel() for
requesting a DMA channel from dmaengine.
Since mxs is a DT only platform now, along with the changes, the non-DT
case checking in probe function also gets cleaned up.
Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
Cc: Chris Ball <cjb@laptop.org>
Cc: linux-mmc@vger.kernel.org
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
-rw-r--r-- | Documentation/devicetree/bindings/mmc/mxs-mmc.txt | 12 | ||||
-rw-r--r-- | drivers/mmc/host/mxs-mmc.c | 48 |
2 files changed, 13 insertions, 47 deletions
diff --git a/Documentation/devicetree/bindings/mmc/mxs-mmc.txt b/Documentation/devicetree/bindings/mmc/mxs-mmc.txt index 54949f6faede..515addc20070 100644 --- a/Documentation/devicetree/bindings/mmc/mxs-mmc.txt +++ b/Documentation/devicetree/bindings/mmc/mxs-mmc.txt | |||
@@ -9,15 +9,19 @@ and the properties used by the mxsmmc driver. | |||
9 | Required properties: | 9 | Required properties: |
10 | - compatible: Should be "fsl,<chip>-mmc". The supported chips include | 10 | - compatible: Should be "fsl,<chip>-mmc". The supported chips include |
11 | imx23 and imx28. | 11 | imx23 and imx28. |
12 | - interrupts: Should contain ERROR and DMA interrupts | 12 | - interrupts: Should contain ERROR interrupt number |
13 | - fsl,ssp-dma-channel: APBH DMA channel for the SSP | 13 | - dmas: DMA specifier, consisting of a phandle to DMA controller node |
14 | and SSP DMA channel ID. | ||
15 | Refer to dma.txt and fsl-mxs-dma.txt for details. | ||
16 | - dma-names: Must be "rx-tx". | ||
14 | 17 | ||
15 | Examples: | 18 | Examples: |
16 | 19 | ||
17 | ssp0: ssp@80010000 { | 20 | ssp0: ssp@80010000 { |
18 | compatible = "fsl,imx28-mmc"; | 21 | compatible = "fsl,imx28-mmc"; |
19 | reg = <0x80010000 2000>; | 22 | reg = <0x80010000 2000>; |
20 | interrupts = <96 82>; | 23 | interrupts = <96>; |
21 | fsl,ssp-dma-channel = <0>; | 24 | dmas = <&dma_apbh 0>; |
25 | dma-names = "rx-tx"; | ||
22 | bus-width = <8>; | 26 | bus-width = <8>; |
23 | }; | 27 | }; |
diff --git a/drivers/mmc/host/mxs-mmc.c b/drivers/mmc/host/mxs-mmc.c index 4efe3021b217..4fdc71113e6d 100644 --- a/drivers/mmc/host/mxs-mmc.c +++ b/drivers/mmc/host/mxs-mmc.c | |||
@@ -548,22 +548,6 @@ static const struct mmc_host_ops mxs_mmc_ops = { | |||
548 | .enable_sdio_irq = mxs_mmc_enable_sdio_irq, | 548 | .enable_sdio_irq = mxs_mmc_enable_sdio_irq, |
549 | }; | 549 | }; |
550 | 550 | ||
551 | static bool mxs_mmc_dma_filter(struct dma_chan *chan, void *param) | ||
552 | { | ||
553 | struct mxs_mmc_host *host = param; | ||
554 | struct mxs_ssp *ssp = &host->ssp; | ||
555 | |||
556 | if (!mxs_dma_is_apbh(chan)) | ||
557 | return false; | ||
558 | |||
559 | if (chan->chan_id != ssp->dma_channel) | ||
560 | return false; | ||
561 | |||
562 | chan->private = &ssp->dma_data; | ||
563 | |||
564 | return true; | ||
565 | } | ||
566 | |||
567 | static struct platform_device_id mxs_ssp_ids[] = { | 551 | static struct platform_device_id mxs_ssp_ids[] = { |
568 | { | 552 | { |
569 | .name = "imx23-mmc", | 553 | .name = "imx23-mmc", |
@@ -591,20 +575,17 @@ static int mxs_mmc_probe(struct platform_device *pdev) | |||
591 | struct device_node *np = pdev->dev.of_node; | 575 | struct device_node *np = pdev->dev.of_node; |
592 | struct mxs_mmc_host *host; | 576 | struct mxs_mmc_host *host; |
593 | struct mmc_host *mmc; | 577 | struct mmc_host *mmc; |
594 | struct resource *iores, *dmares; | 578 | struct resource *iores; |
595 | struct pinctrl *pinctrl; | 579 | struct pinctrl *pinctrl; |
596 | int ret = 0, irq_err, irq_dma; | 580 | int ret = 0, irq_err; |
597 | dma_cap_mask_t mask; | ||
598 | struct regulator *reg_vmmc; | 581 | struct regulator *reg_vmmc; |
599 | enum of_gpio_flags flags; | 582 | enum of_gpio_flags flags; |
600 | struct mxs_ssp *ssp; | 583 | struct mxs_ssp *ssp; |
601 | u32 bus_width = 0; | 584 | u32 bus_width = 0; |
602 | 585 | ||
603 | iores = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 586 | iores = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
604 | dmares = platform_get_resource(pdev, IORESOURCE_DMA, 0); | ||
605 | irq_err = platform_get_irq(pdev, 0); | 587 | irq_err = platform_get_irq(pdev, 0); |
606 | irq_dma = platform_get_irq(pdev, 1); | 588 | if (!iores || irq_err < 0) |
607 | if (!iores || irq_err < 0 || irq_dma < 0) | ||
608 | return -EINVAL; | 589 | return -EINVAL; |
609 | 590 | ||
610 | mmc = mmc_alloc_host(sizeof(struct mxs_mmc_host), &pdev->dev); | 591 | mmc = mmc_alloc_host(sizeof(struct mxs_mmc_host), &pdev->dev); |
@@ -620,23 +601,7 @@ static int mxs_mmc_probe(struct platform_device *pdev) | |||
620 | goto out_mmc_free; | 601 | goto out_mmc_free; |
621 | } | 602 | } |
622 | 603 | ||
623 | if (np) { | 604 | ssp->devid = (enum mxs_ssp_id) of_id->data; |
624 | ssp->devid = (enum mxs_ssp_id) of_id->data; | ||
625 | /* | ||
626 | * TODO: This is a temporary solution and should be changed | ||
627 | * to use generic DMA binding later when the helpers get in. | ||
628 | */ | ||
629 | ret = of_property_read_u32(np, "fsl,ssp-dma-channel", | ||
630 | &ssp->dma_channel); | ||
631 | if (ret) { | ||
632 | dev_err(mmc_dev(host->mmc), | ||
633 | "failed to get dma channel\n"); | ||
634 | goto out_mmc_free; | ||
635 | } | ||
636 | } else { | ||
637 | ssp->devid = pdev->id_entry->driver_data; | ||
638 | ssp->dma_channel = dmares->start; | ||
639 | } | ||
640 | 605 | ||
641 | host->mmc = mmc; | 606 | host->mmc = mmc; |
642 | host->sdio_irq_en = 0; | 607 | host->sdio_irq_en = 0; |
@@ -666,10 +631,7 @@ static int mxs_mmc_probe(struct platform_device *pdev) | |||
666 | 631 | ||
667 | mxs_mmc_reset(host); | 632 | mxs_mmc_reset(host); |
668 | 633 | ||
669 | dma_cap_zero(mask); | 634 | ssp->dmach = dma_request_slave_channel(&pdev->dev, "rx-tx"); |
670 | dma_cap_set(DMA_SLAVE, mask); | ||
671 | ssp->dma_data.chan_irq = irq_dma; | ||
672 | ssp->dmach = dma_request_channel(mask, mxs_mmc_dma_filter, host); | ||
673 | if (!ssp->dmach) { | 635 | if (!ssp->dmach) { |
674 | dev_err(mmc_dev(host->mmc), | 636 | dev_err(mmc_dev(host->mmc), |
675 | "%s: failed to request dma\n", __func__); | 637 | "%s: failed to request dma\n", __func__); |