@@ -128,6 +128,7 @@ struct mmp_pdma_device {
void __iomem *base;
struct device *dev;
struct dma_device device;
+ struct of_dma_slave_xlate_info xlate_info;
struct mmp_pdma_phy *phy;
spinlock_t phy_lock; /* protect alloc/free phy channels */
};
@@ -889,37 +890,14 @@ static struct of_device_id mmp_pdma_dt_ids[] = {
};
MODULE_DEVICE_TABLE(of, mmp_pdma_dt_ids);
-static struct dma_chan *mmp_pdma_dma_xlate(struct of_phandle_args *dma_spec,
- struct of_dma *ofdma)
+static int mmp_pdma_of_xlate_post_alloc(struct dma_chan *chan,
+ struct of_phandle_args *dma_spec)
{
- struct mmp_pdma_device *d = ofdma->of_dma_data;
- struct dma_chan *chan, *candidate;
-
-retry:
- candidate = NULL;
-
- /* walk the list of channels registered with the current instance and
- * find one that is currently unused */
- list_for_each_entry(chan, &d->device.channels, device_node)
- if (chan->client_count == 0) {
- candidate = chan;
- break;
- }
-
- if (!candidate)
- return NULL;
+ struct mmp_pdma_chan *c = to_mmp_pdma_chan(chan);
- /* dma_get_slave_channel will return NULL if we lost a race between
- * the lookup and the reservation */
- chan = dma_get_slave_channel(candidate);
+ c->drcmr = dma_spec->args[0];
- if (chan) {
- struct mmp_pdma_chan *c = to_mmp_pdma_chan(chan);
- c->drcmr = dma_spec->args[0];
- return chan;
- }
-
- goto retry;
+ return 0;
}
static int mmp_pdma_probe(struct platform_device *op)
@@ -1009,8 +987,11 @@ static int mmp_pdma_probe(struct platform_device *op)
if (op->dev.of_node) {
/* Device-tree DMA controller registration */
+ pdev->xlate_info.device = &pdev->device;
+ pdev->xlate_info.post_alloc = mmp_pdma_of_xlate_post_alloc;
ret = of_dma_controller_register(op->dev.of_node,
- mmp_pdma_dma_xlate, pdev);
+ of_dma_slave_xlate,
+ &pdev->xlate_info);
if (ret < 0) {
dev_err(&op->dev, "of_dma_controller_register failed\n");
return ret;