Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

Shawn Guo 0e91e434 d84f638b

+13 -47
+8 -4
Documentation/devicetree/bindings/mmc/mxs-mmc.txt
··· 9 9 Required properties: 10 10 - compatible: Should be "fsl,<chip>-mmc". The supported chips include 11 11 imx23 and imx28. 12 - - interrupts: Should contain ERROR and DMA interrupts 13 - - fsl,ssp-dma-channel: APBH DMA channel for the SSP 12 + - interrupts: Should contain ERROR interrupt number 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 18 Examples: 16 19 17 20 ssp0: ssp@80010000 { 18 21 compatible = "fsl,imx28-mmc"; 19 22 reg = <0x80010000 2000>; 20 - interrupts = <96 82>; 21 - fsl,ssp-dma-channel = <0>; 23 + interrupts = <96>; 24 + dmas = <&dma_apbh 0>; 25 + dma-names = "rx-tx"; 22 26 bus-width = <8>; 23 27 };
+5 -43
drivers/mmc/host/mxs-mmc.c
··· 548 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 551 static struct platform_device_id mxs_ssp_ids[] = { 568 552 { 569 553 .name = "imx23-mmc", ··· 575 591 struct device_node *np = pdev->dev.of_node; 576 592 struct mxs_mmc_host *host; 577 593 struct mmc_host *mmc; 578 - struct resource *iores, *dmares; 594 + struct resource *iores; 579 595 struct pinctrl *pinctrl; 580 - int ret = 0, irq_err, irq_dma; 581 - dma_cap_mask_t mask; 596 + int ret = 0, irq_err; 582 597 struct regulator *reg_vmmc; 583 598 enum of_gpio_flags flags; 584 599 struct mxs_ssp *ssp; 585 600 u32 bus_width = 0; 586 601 587 602 iores = platform_get_resource(pdev, IORESOURCE_MEM, 0); 588 - dmares = platform_get_resource(pdev, IORESOURCE_DMA, 0); 589 603 irq_err = platform_get_irq(pdev, 0); 590 - irq_dma = platform_get_irq(pdev, 1); 591 - if (!iores || irq_err < 0 || irq_dma < 0) 604 + if (!iores || irq_err < 0) 592 605 return -EINVAL; 593 606 594 607 mmc = mmc_alloc_host(sizeof(struct mxs_mmc_host), &pdev->dev); ··· 601 620 goto out_mmc_free; 602 621 } 603 622 604 - if (np) { 605 - ssp->devid = (enum mxs_ssp_id) of_id->data; 606 - /* 607 - * TODO: This is a temporary solution and should be changed 608 - * to use generic DMA binding later when the helpers get in. 609 - */ 610 - ret = of_property_read_u32(np, "fsl,ssp-dma-channel", 611 - &ssp->dma_channel); 612 - if (ret) { 613 - dev_err(mmc_dev(host->mmc), 614 - "failed to get dma channel\n"); 615 - goto out_mmc_free; 616 - } 617 - } else { 618 - ssp->devid = pdev->id_entry->driver_data; 619 - ssp->dma_channel = dmares->start; 620 - } 623 + ssp->devid = (enum mxs_ssp_id) of_id->data; 621 624 622 625 host->mmc = mmc; 623 626 host->sdio_irq_en = 0; ··· 631 666 632 667 mxs_mmc_reset(host); 633 668 634 - dma_cap_zero(mask); 635 - dma_cap_set(DMA_SLAVE, mask); 636 - ssp->dma_data.chan_irq = irq_dma; 637 - ssp->dmach = dma_request_channel(mask, mxs_mmc_dma_filter, host); 669 + ssp->dmach = dma_request_slave_channel(&pdev->dev, "rx-tx"); 638 670 if (!ssp->dmach) { 639 671 dev_err(mmc_dev(host->mmc), 640 672 "%s: failed to request dma\n", __func__);