Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e22aec0f authored by Maxime Ripard's avatar Maxime Ripard Committed by Vinod Koul
Browse files

dmaengine: nbpfaxi: Split device_control



Split the device_control callback of the NBPF AXI DMA driver to make use
of the newly introduced callbacks, that will eventually be used to retrieve
slave capabilities.

Signed-off-by: default avatarMaxime Ripard <maxime.ripard@free-electrons.com>
Signed-off-by: default avatarVinod Koul <vinod.koul@intel.com>
parent 5c9d2e37
Loading
Loading
Loading
Loading
+46 −47
Original line number Diff line number Diff line
@@ -565,13 +565,6 @@ static void nbpf_configure(struct nbpf_device *nbpf)
	nbpf_write(nbpf, NBPF_CTRL, NBPF_CTRL_LVINT);
}

static void nbpf_pause(struct nbpf_channel *chan)
{
	nbpf_chan_write(chan, NBPF_CHAN_CTRL, NBPF_CHAN_CTRL_SETSUS);
	/* See comment in nbpf_prep_one() */
	nbpf_chan_write(chan, NBPF_CHAN_CTRL, NBPF_CHAN_CTRL_CLREN);
}

/*		Generic part			*/

/* DMA ENGINE functions */
@@ -837,25 +830,39 @@ static void nbpf_chan_idle(struct nbpf_channel *chan)
	}
}

static int nbpf_control(struct dma_chan *dchan, enum dma_ctrl_cmd cmd,
			unsigned long arg)
static int nbpf_pause(struct dma_chan *dchan)
{
	struct nbpf_channel *chan = nbpf_to_chan(dchan);
	struct dma_slave_config *config;

	dev_dbg(dchan->device->dev, "Entry %s(%d)\n", __func__, cmd);
	dev_dbg(dchan->device->dev, "Entry %s\n", __func__);

	chan->paused = true;
	nbpf_chan_write(chan, NBPF_CHAN_CTRL, NBPF_CHAN_CTRL_SETSUS);
	/* See comment in nbpf_prep_one() */
	nbpf_chan_write(chan, NBPF_CHAN_CTRL, NBPF_CHAN_CTRL_CLREN);

	return 0;
}

static int nbpf_terminate_all(struct dma_chan *dchan)
{
	struct nbpf_channel *chan = nbpf_to_chan(dchan);

	switch (cmd) {
	case DMA_TERMINATE_ALL:
	dev_dbg(dchan->device->dev, "Entry %s\n", __func__);
	dev_dbg(dchan->device->dev, "Terminating\n");

	nbpf_chan_halt(chan);
	nbpf_chan_idle(chan);
		break;

	case DMA_SLAVE_CONFIG:
		if (!arg)
			return -EINVAL;
		config = (struct dma_slave_config *)arg;
	return 0;
}

static int nbpf_config(struct dma_chan *dchan,
		       struct dma_slave_config *config)
{
	struct nbpf_channel *chan = nbpf_to_chan(dchan);

	dev_dbg(dchan->device->dev, "Entry %s\n", __func__);

	/*
	 * We could check config->slave_id to match chan->terminal here,
@@ -875,16 +882,6 @@ static int nbpf_control(struct dma_chan *dchan, enum dma_ctrl_cmd cmd,
	chan->slave_src_burst = nbpf_xfer_size(chan->nbpf,
					       config->src_addr_width,
					       config->src_maxburst);
		break;

	case DMA_PAUSE:
		chan->paused = true;
		nbpf_pause(chan);
		break;

	default:
		return -ENXIO;
	}

	return 0;
}
@@ -1426,7 +1423,9 @@ static int nbpf_probe(struct platform_device *pdev)

	/* Compulsory for DMA_SLAVE fields */
	dma_dev->device_prep_slave_sg = nbpf_prep_slave_sg;
	dma_dev->device_control = nbpf_control;
	dma_dev->device_config = nbpf_config;
	dma_dev->device_pause = nbpf_pause;
	dma_dev->device_terminate_all = nbpf_terminate_all;

	platform_set_drvdata(pdev, nbpf);