dmaengine: bam-dma: Split device_control
Split the device_control callback of the Qualcomm BAM DMA driver to make use of the newly introduced callbacks, that will eventually be used to retrieve slave capabilities. Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com> Signed-off-by: Vinod Koul <vinod.koul@intel.com>
This commit is contained in:
parent
740aa95703
commit
62ec8eb52d
|
@ -530,11 +530,18 @@ static void bam_free_chan(struct dma_chan *chan)
|
||||||
* Sets slave configuration for channel
|
* Sets slave configuration for channel
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
static void bam_slave_config(struct bam_chan *bchan,
|
static int bam_slave_config(struct dma_chan *chan,
|
||||||
struct dma_slave_config *cfg)
|
struct dma_slave_config *cfg)
|
||||||
{
|
{
|
||||||
|
struct bam_chan *bchan = to_bam_chan(chan);
|
||||||
|
unsigned long flag;
|
||||||
|
|
||||||
|
spin_lock_irqsave(&bchan->vc.lock, flag);
|
||||||
memcpy(&bchan->slave, cfg, sizeof(*cfg));
|
memcpy(&bchan->slave, cfg, sizeof(*cfg));
|
||||||
bchan->reconfigure = 1;
|
bchan->reconfigure = 1;
|
||||||
|
spin_unlock_irqrestore(&bchan->vc.lock, flag);
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -627,8 +634,9 @@ static struct dma_async_tx_descriptor *bam_prep_slave_sg(struct dma_chan *chan,
|
||||||
* No callbacks are done
|
* No callbacks are done
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
static void bam_dma_terminate_all(struct bam_chan *bchan)
|
static int bam_dma_terminate_all(struct dma_chan *chan)
|
||||||
{
|
{
|
||||||
|
struct bam_chan *bchan = to_bam_chan(chan);
|
||||||
unsigned long flag;
|
unsigned long flag;
|
||||||
LIST_HEAD(head);
|
LIST_HEAD(head);
|
||||||
|
|
||||||
|
@ -643,56 +651,46 @@ static void bam_dma_terminate_all(struct bam_chan *bchan)
|
||||||
spin_unlock_irqrestore(&bchan->vc.lock, flag);
|
spin_unlock_irqrestore(&bchan->vc.lock, flag);
|
||||||
|
|
||||||
vchan_dma_desc_free_list(&bchan->vc, &head);
|
vchan_dma_desc_free_list(&bchan->vc, &head);
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* bam_control - DMA device control
|
* bam_pause - Pause DMA channel
|
||||||
* @chan: dma channel
|
* @chan: dma channel
|
||||||
* @cmd: control cmd
|
|
||||||
* @arg: cmd argument
|
|
||||||
*
|
|
||||||
* Perform DMA control command
|
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
static int bam_control(struct dma_chan *chan, enum dma_ctrl_cmd cmd,
|
static int bam_pause(struct dma_chan *chan)
|
||||||
unsigned long arg)
|
|
||||||
{
|
{
|
||||||
struct bam_chan *bchan = to_bam_chan(chan);
|
struct bam_chan *bchan = to_bam_chan(chan);
|
||||||
struct bam_device *bdev = bchan->bdev;
|
struct bam_device *bdev = bchan->bdev;
|
||||||
int ret = 0;
|
|
||||||
unsigned long flag;
|
unsigned long flag;
|
||||||
|
|
||||||
switch (cmd) {
|
spin_lock_irqsave(&bchan->vc.lock, flag);
|
||||||
case DMA_PAUSE:
|
writel_relaxed(1, bam_addr(bdev, bchan->id, BAM_P_HALT));
|
||||||
spin_lock_irqsave(&bchan->vc.lock, flag);
|
bchan->paused = 1;
|
||||||
writel_relaxed(1, bam_addr(bdev, bchan->id, BAM_P_HALT));
|
spin_unlock_irqrestore(&bchan->vc.lock, flag);
|
||||||
bchan->paused = 1;
|
|
||||||
spin_unlock_irqrestore(&bchan->vc.lock, flag);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case DMA_RESUME:
|
return 0;
|
||||||
spin_lock_irqsave(&bchan->vc.lock, flag);
|
}
|
||||||
writel_relaxed(0, bam_addr(bdev, bchan->id, BAM_P_HALT));
|
|
||||||
bchan->paused = 0;
|
|
||||||
spin_unlock_irqrestore(&bchan->vc.lock, flag);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case DMA_TERMINATE_ALL:
|
/**
|
||||||
bam_dma_terminate_all(bchan);
|
* bam_resume - Resume DMA channel operations
|
||||||
break;
|
* @chan: dma channel
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
static int bam_resume(struct dma_chan *chan)
|
||||||
|
{
|
||||||
|
struct bam_chan *bchan = to_bam_chan(chan);
|
||||||
|
struct bam_device *bdev = bchan->bdev;
|
||||||
|
unsigned long flag;
|
||||||
|
|
||||||
case DMA_SLAVE_CONFIG:
|
spin_lock_irqsave(&bchan->vc.lock, flag);
|
||||||
spin_lock_irqsave(&bchan->vc.lock, flag);
|
writel_relaxed(0, bam_addr(bdev, bchan->id, BAM_P_HALT));
|
||||||
bam_slave_config(bchan, (struct dma_slave_config *)arg);
|
bchan->paused = 0;
|
||||||
spin_unlock_irqrestore(&bchan->vc.lock, flag);
|
spin_unlock_irqrestore(&bchan->vc.lock, flag);
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
return 0;
|
||||||
ret = -ENXIO;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1148,7 +1146,10 @@ static int bam_dma_probe(struct platform_device *pdev)
|
||||||
bdev->common.device_alloc_chan_resources = bam_alloc_chan;
|
bdev->common.device_alloc_chan_resources = bam_alloc_chan;
|
||||||
bdev->common.device_free_chan_resources = bam_free_chan;
|
bdev->common.device_free_chan_resources = bam_free_chan;
|
||||||
bdev->common.device_prep_slave_sg = bam_prep_slave_sg;
|
bdev->common.device_prep_slave_sg = bam_prep_slave_sg;
|
||||||
bdev->common.device_control = bam_control;
|
bdev->common.device_config = bam_slave_config;
|
||||||
|
bdev->common.device_pause = bam_pause;
|
||||||
|
bdev->common.device_resume = bam_resume;
|
||||||
|
bdev->common.device_terminate_all = bam_dma_terminate_all;
|
||||||
bdev->common.device_issue_pending = bam_issue_pending;
|
bdev->common.device_issue_pending = bam_issue_pending;
|
||||||
bdev->common.device_tx_status = bam_tx_status;
|
bdev->common.device_tx_status = bam_tx_status;
|
||||||
bdev->common.dev = bdev->dev;
|
bdev->common.dev = bdev->dev;
|
||||||
|
@ -1187,7 +1188,7 @@ static int bam_dma_remove(struct platform_device *pdev)
|
||||||
devm_free_irq(bdev->dev, bdev->irq, bdev);
|
devm_free_irq(bdev->dev, bdev->irq, bdev);
|
||||||
|
|
||||||
for (i = 0; i < bdev->num_channels; i++) {
|
for (i = 0; i < bdev->num_channels; i++) {
|
||||||
bam_dma_terminate_all(&bdev->channels[i]);
|
bam_dma_terminate_all(&bdev->channels[i].vc.chan);
|
||||||
tasklet_kill(&bdev->channels[i].vc.task);
|
tasklet_kill(&bdev->channels[i].vc.task);
|
||||||
|
|
||||||
dma_free_writecombine(bdev->dev, BAM_DESC_FIFO_SIZE,
|
dma_free_writecombine(bdev->dev, BAM_DESC_FIFO_SIZE,
|
||||||
|
|
Loading…
Reference in New Issue