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

dma: mmp_pdma: add filter function

PXA peripherals need to obtain specific DMA request ids which will
eventually be stored in the DRCMR register.

Currently, clients are expected to store that number inside the slave
config block as slave_id, which is unfortunately incompatible with the
way DMA resources are handled in DT environments.

This patch adds a filter function which stores the filter parameter
passed in by of-dma.c into the channel's drcmr register.

For backward compatability, cfg->slave_id is still used if set to
a non-zero value.

Signed-off-by: Daniel Mack <zonque@gmail.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Vinod Koul <vinod.koul@intel.com>

authored by

Daniel Mack and committed by
Vinod Koul
13b3006b 1ac0e845

+35 -1
+20 -1
drivers/dma/mmp_pdma.c
··· 19 19 #include <linux/dmapool.h> 20 20 #include <linux/of_device.h> 21 21 #include <linux/of.h> 22 + #include <linux/dma/mmp-pdma.h> 22 23 23 24 #include "dmaengine.h" 24 25 ··· 636 635 chan->dcmd |= DCMD_BURST32; 637 636 638 637 chan->dir = cfg->direction; 639 - chan->drcmr = cfg->slave_id; 640 638 chan->dev_addr = addr; 639 + /* FIXME: drivers should be ported over to use the filter 640 + * function. Once that's done, the following two lines can 641 + * be removed. 642 + */ 643 + if (cfg->slave_id) 644 + chan->drcmr = cfg->slave_id; 641 645 break; 642 646 default: 643 647 return -ENOSYS; ··· 882 876 .probe = mmp_pdma_probe, 883 877 .remove = mmp_pdma_remove, 884 878 }; 879 + 880 + bool mmp_pdma_filter_fn(struct dma_chan *chan, void *param) 881 + { 882 + struct mmp_pdma_chan *c = to_mmp_pdma_chan(chan); 883 + 884 + if (chan->device->dev->driver != &mmp_pdma_driver.driver) 885 + return false; 886 + 887 + c->drcmr = *(unsigned int *) param; 888 + 889 + return true; 890 + } 891 + EXPORT_SYMBOL_GPL(mmp_pdma_filter_fn); 885 892 886 893 module_platform_driver(mmp_pdma_driver); 887 894
+15
include/linux/dma/mmp-pdma.h
··· 1 + #ifndef _MMP_PDMA_H_ 2 + #define _MMP_PDMA_H_ 3 + 4 + struct dma_chan; 5 + 6 + #ifdef CONFIG_MMP_PDMA 7 + bool mmp_pdma_filter_fn(struct dma_chan *chan, void *param); 8 + #else 9 + static inline bool mmp_pdma_filter_fn(struct dma_chan *chan, void *param) 10 + { 11 + return false; 12 + } 13 + #endif 14 + 15 + #endif /* _MMP_PDMA_H_ */