dmaengine: axi-dmac: wrap channel parameter adjust into function
The channel parameters (which are read from the device-tree) are adjusted for the DMAEngine framework in the axi_dmac_parse_chan_dt() function, after they are read from the device-tree. When we want to read these from registers, we will need to use the same logic, so this change splits the logic into a separate function. Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com> Link: https://lore.kernel.org/r/20200825151950.57605-6-alexandru.ardelean@analog.com Signed-off-by: Vinod Koul <vkoul@kernel.org>
This commit is contained in:
parent
06b6e88c7e
commit
3061a65c1b
@ -717,6 +717,20 @@ static const struct regmap_config axi_dmac_regmap_config = {
|
|||||||
.writeable_reg = axi_dmac_regmap_rdwr,
|
.writeable_reg = axi_dmac_regmap_rdwr,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static void axi_dmac_adjust_chan_params(struct axi_dmac_chan *chan)
|
||||||
|
{
|
||||||
|
chan->address_align_mask = max(chan->dest_width, chan->src_width) - 1;
|
||||||
|
|
||||||
|
if (axi_dmac_dest_is_mem(chan) && axi_dmac_src_is_mem(chan))
|
||||||
|
chan->direction = DMA_MEM_TO_MEM;
|
||||||
|
else if (!axi_dmac_dest_is_mem(chan) && axi_dmac_src_is_mem(chan))
|
||||||
|
chan->direction = DMA_MEM_TO_DEV;
|
||||||
|
else if (axi_dmac_dest_is_mem(chan) && !axi_dmac_src_is_mem(chan))
|
||||||
|
chan->direction = DMA_DEV_TO_MEM;
|
||||||
|
else
|
||||||
|
chan->direction = DMA_DEV_TO_DEV;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The configuration stored in the devicetree matches the configuration
|
* The configuration stored in the devicetree matches the configuration
|
||||||
* parameters of the peripheral instance and allows the driver to know which
|
* parameters of the peripheral instance and allows the driver to know which
|
||||||
@ -760,16 +774,7 @@ static int axi_dmac_parse_chan_dt(struct device_node *of_chan,
|
|||||||
return ret;
|
return ret;
|
||||||
chan->dest_width = val / 8;
|
chan->dest_width = val / 8;
|
||||||
|
|
||||||
chan->address_align_mask = max(chan->dest_width, chan->src_width) - 1;
|
axi_dmac_adjust_chan_params(chan);
|
||||||
|
|
||||||
if (axi_dmac_dest_is_mem(chan) && axi_dmac_src_is_mem(chan))
|
|
||||||
chan->direction = DMA_MEM_TO_MEM;
|
|
||||||
else if (!axi_dmac_dest_is_mem(chan) && axi_dmac_src_is_mem(chan))
|
|
||||||
chan->direction = DMA_MEM_TO_DEV;
|
|
||||||
else if (axi_dmac_dest_is_mem(chan) && !axi_dmac_src_is_mem(chan))
|
|
||||||
chan->direction = DMA_DEV_TO_MEM;
|
|
||||||
else
|
|
||||||
chan->direction = DMA_DEV_TO_DEV;
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user