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

spi: mxs-spi: 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 handling in probe function also gets removed.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
Acked-by: Grant Likely <grant.likely@secretlab.ca>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>

Shawn Guo 26aafa77 0e91e434

+18 -58
+8 -4
Documentation/devicetree/bindings/spi/mxs-spi.txt
··· 3 3 Required properties: 4 4 - compatible: Should be "fsl,<soc>-spi", where soc is "imx23" or "imx28" 5 5 - reg: Offset and length of the register set for the device 6 - - interrupts: Should contain SSP interrupts (error irq first, dma irq second) 7 - - fsl,ssp-dma-channel: APBX DMA channel for the SSP 6 + - interrupts: Should contain SSP ERROR interrupt 7 + - dmas: DMA specifier, consisting of a phandle to DMA controller node 8 + and SSP DMA channel ID. 9 + Refer to dma.txt and fsl-mxs-dma.txt for details. 10 + - dma-names: Must be "rx-tx". 8 11 9 12 Optional properties: 10 13 - clock-frequency : Input clock frequency to the SPI block in Hz. ··· 20 17 #size-cells = <0>; 21 18 compatible = "fsl,imx28-spi"; 22 19 reg = <0x80010000 0x2000>; 23 - interrupts = <96 82>; 24 - fsl,ssp-dma-channel = <0>; 20 + interrupts = <96>; 21 + dmas = <&dma_apbh 0>; 22 + dma-names = "rx-tx"; 25 23 };
+9 -51
drivers/spi/spi-mxs.c
··· 490 490 return status; 491 491 } 492 492 493 - static bool mxs_ssp_dma_filter(struct dma_chan *chan, void *param) 494 - { 495 - struct mxs_ssp *ssp = param; 496 - 497 - if (!mxs_dma_is_apbh(chan)) 498 - return false; 499 - 500 - if (chan->chan_id != ssp->dma_channel) 501 - return false; 502 - 503 - chan->private = &ssp->dma_data; 504 - 505 - return true; 506 - } 507 - 508 493 static const struct of_device_id mxs_spi_dt_ids[] = { 509 494 { .compatible = "fsl,imx23-spi", .data = (void *) IMX23_SSP, }, 510 495 { .compatible = "fsl,imx28-spi", .data = (void *) IMX28_SSP, }, ··· 505 520 struct spi_master *master; 506 521 struct mxs_spi *spi; 507 522 struct mxs_ssp *ssp; 508 - struct resource *iores, *dmares; 523 + struct resource *iores; 509 524 struct pinctrl *pinctrl; 510 525 struct clk *clk; 511 526 void __iomem *base; 512 - int devid, dma_channel, clk_freq; 513 - int ret = 0, irq_err, irq_dma; 514 - dma_cap_mask_t mask; 527 + int devid, clk_freq; 528 + int ret = 0, irq_err; 515 529 516 530 /* 517 531 * Default clock speed for the SPI core. 160MHz seems to ··· 521 537 522 538 iores = platform_get_resource(pdev, IORESOURCE_MEM, 0); 523 539 irq_err = platform_get_irq(pdev, 0); 524 - irq_dma = platform_get_irq(pdev, 1); 525 - if (!iores || irq_err < 0 || irq_dma < 0) 540 + if (!iores || irq_err < 0) 526 541 return -EINVAL; 527 542 528 543 base = devm_ioremap_resource(&pdev->dev, iores); ··· 536 553 if (IS_ERR(clk)) 537 554 return PTR_ERR(clk); 538 555 539 - if (np) { 540 - devid = (enum mxs_ssp_id) of_id->data; 541 - /* 542 - * TODO: This is a temporary solution and should be changed 543 - * to use generic DMA binding later when the helpers get in. 544 - */ 545 - ret = of_property_read_u32(np, "fsl,ssp-dma-channel", 546 - &dma_channel); 547 - if (ret) { 548 - dev_err(&pdev->dev, 549 - "Failed to get DMA channel\n"); 550 - return -EINVAL; 551 - } 552 - 553 - ret = of_property_read_u32(np, "clock-frequency", 554 - &clk_freq); 555 - if (ret) 556 - clk_freq = clk_freq_default; 557 - } else { 558 - dmares = platform_get_resource(pdev, IORESOURCE_DMA, 0); 559 - if (!dmares) 560 - return -EINVAL; 561 - devid = pdev->id_entry->driver_data; 562 - dma_channel = dmares->start; 556 + devid = (enum mxs_ssp_id) of_id->data; 557 + ret = of_property_read_u32(np, "clock-frequency", 558 + &clk_freq); 559 + if (ret) 563 560 clk_freq = clk_freq_default; 564 - } 565 561 566 562 master = spi_alloc_master(&pdev->dev, sizeof(*spi)); 567 563 if (!master) ··· 559 597 ssp->clk = clk; 560 598 ssp->base = base; 561 599 ssp->devid = devid; 562 - ssp->dma_channel = dma_channel; 563 600 564 601 init_completion(&spi->c); 565 602 ··· 567 606 if (ret) 568 607 goto out_master_free; 569 608 570 - dma_cap_zero(mask); 571 - dma_cap_set(DMA_SLAVE, mask); 572 - ssp->dma_data.chan_irq = irq_dma; 573 - ssp->dmach = dma_request_channel(mask, mxs_ssp_dma_filter, ssp); 609 + ssp->dmach = dma_request_slave_channel(&pdev->dev, "rx-tx"); 574 610 if (!ssp->dmach) { 575 611 dev_err(ssp->dev, "Failed to request DMA\n"); 576 612 goto out_master_free;
+1 -3
include/linux/spi/mxs-spi.h
··· 24 24 #ifndef __LINUX_SPI_MXS_SPI_H__ 25 25 #define __LINUX_SPI_MXS_SPI_H__ 26 26 27 - #include <linux/fsl/mxs-dma.h> 27 + #include <linux/dmaengine.h> 28 28 29 29 #define ssp_is_old(host) ((host)->devid == IMX23_SSP) 30 30 ··· 137 137 unsigned int clk_rate; 138 138 enum mxs_ssp_id devid; 139 139 140 - int dma_channel; 141 140 struct dma_chan *dmach; 142 - struct mxs_dma_data dma_data; 143 141 unsigned int dma_dir; 144 142 enum dma_transfer_direction slave_dirn; 145 143 u32 ssp_pio_words[SSP_PIO_NUM];