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

Commit d877a721 authored by Ludovic Desroches's avatar Ludovic Desroches Committed by Wolfram Sang
Browse files

i2c: at91: convert to dma_request_slave_channel_compat()



Use generic DMA DT helper. Platforms booting with or without DT populated are
both supported.

Signed-off-by: default avatarLudovic Desroches <ludovic.desroches@atmel.com>
Acked-by: default avatarJean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Signed-off-by: default avatarWolfram Sang <wsa@the-dreams.de>
parent 92b775c2
Loading
Loading
Loading
Loading
+25 −24
Original line number Original line Diff line number Diff line
@@ -605,11 +605,16 @@ static const struct of_device_id atmel_twi_dt_ids[] = {
MODULE_DEVICE_TABLE(of, atmel_twi_dt_ids);
MODULE_DEVICE_TABLE(of, atmel_twi_dt_ids);
#endif
#endif


static bool filter(struct dma_chan *chan, void *slave)
static bool filter(struct dma_chan *chan, void *pdata)
{
{
	struct at_dma_slave *sl = slave;
	struct at91_twi_pdata *sl_pdata = pdata;
	struct at_dma_slave *sl;


	if (sl->dma_dev == chan->device->dev) {
	if (!sl_pdata)
		return false;

	sl = &sl_pdata->dma_slave;
	if (sl && (sl->dma_dev == chan->device->dev)) {
		chan->private = sl;
		chan->private = sl;
		return true;
		return true;
	} else {
	} else {
@@ -620,11 +625,10 @@ static bool filter(struct dma_chan *chan, void *slave)
static int at91_twi_configure_dma(struct at91_twi_dev *dev, u32 phy_addr)
static int at91_twi_configure_dma(struct at91_twi_dev *dev, u32 phy_addr)
{
{
	int ret = 0;
	int ret = 0;
	struct at_dma_slave *sdata;
	struct at91_twi_pdata *pdata = dev->pdata;
	struct dma_slave_config slave_config;
	struct dma_slave_config slave_config;
	struct at91_twi_dma *dma = &dev->dma;
	struct at91_twi_dma *dma = &dev->dma;

	dma_cap_mask_t mask;
	sdata = &dev->pdata->dma_slave;


	memset(&slave_config, 0, sizeof(slave_config));
	memset(&slave_config, 0, sizeof(slave_config));
	slave_config.src_addr = (dma_addr_t)phy_addr + AT91_TWI_RHR;
	slave_config.src_addr = (dma_addr_t)phy_addr + AT91_TWI_RHR;
@@ -635,27 +639,24 @@ static int at91_twi_configure_dma(struct at91_twi_dev *dev, u32 phy_addr)
	slave_config.dst_maxburst = 1;
	slave_config.dst_maxburst = 1;
	slave_config.device_fc = false;
	slave_config.device_fc = false;


	if (sdata && sdata->dma_dev) {
		dma_cap_mask_t mask;

	dma_cap_zero(mask);
	dma_cap_zero(mask);
	dma_cap_set(DMA_SLAVE, mask);
	dma_cap_set(DMA_SLAVE, mask);
		dma->chan_tx = dma_request_channel(mask, filter, sdata);

	dma->chan_tx = dma_request_slave_channel_compat(mask, filter, pdata,
							dev->dev, "tx");
	if (!dma->chan_tx) {
	if (!dma->chan_tx) {
			dev_err(dev->dev, "no DMA channel available for tx\n");
		dev_err(dev->dev, "can't get a DMA channel for tx\n");
		ret = -EBUSY;
		ret = -EBUSY;
		goto error;
		goto error;
	}
	}
		dma->chan_rx = dma_request_channel(mask, filter, sdata);

	dma->chan_rx = dma_request_slave_channel_compat(mask, filter, pdata,
							dev->dev, "rx");
	if (!dma->chan_rx) {
	if (!dma->chan_rx) {
			dev_err(dev->dev, "no DMA channel available for rx\n");
		dev_err(dev->dev, "can't get a DMA channel for rx\n");
		ret = -EBUSY;
		ret = -EBUSY;
		goto error;
		goto error;
	}
	}
	} else {
		ret = -EINVAL;
		goto error;
	}


	slave_config.direction = DMA_MEM_TO_DEV;
	slave_config.direction = DMA_MEM_TO_DEV;
	if (dmaengine_slave_config(dma->chan_tx, &slave_config)) {
	if (dmaengine_slave_config(dma->chan_tx, &slave_config)) {