1 From 6d317d92627736a94e6c1c4b49c3f63cc33c28aa Mon Sep 17 00:00:00 2001
2 From: Phil Elwell <phil@raspberrypi.com>
3 Date: Thu, 11 May 2023 10:00:01 +0100
4 Subject: [PATCH] bcm2835-dma: Derive slave DMA addresses correctly
6 Slave addresses for DMA are meant to be supplied as physical addresses
7 (contrary to what struct snd_dmaengine_dai_dma_data does). It is up to
8 the DMA controller driver to perform the translation based on its own
9 view of the world, as described in Device Tree.
11 Now that the Pi Device Trees have the correct peripheral mappings,
12 replace the hacky address munging with phys_to_dma().
14 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
16 drivers/dma/bcm2835-dma.c | 23 +++++------------------
17 1 file changed, 5 insertions(+), 18 deletions(-)
19 --- a/drivers/dma/bcm2835-dma.c
20 +++ b/drivers/dma/bcm2835-dma.c
22 * Copyright 2012 Marvell International Ltd.
24 #include <linux/dmaengine.h>
25 +#include <linux/dma-direct.h>
26 #include <linux/dma-mapping.h>
27 #include <linux/dmapool.h>
28 #include <linux/err.h>
29 @@ -910,22 +911,12 @@ static struct dma_async_tx_descriptor *b
30 if (direction == DMA_DEV_TO_MEM) {
31 if (c->cfg.src_addr_width != DMA_SLAVE_BUSWIDTH_4_BYTES)
33 - src = c->cfg.src_addr;
35 - * One would think it ought to be possible to get the physical
36 - * to dma address mapping information from the dma-ranges DT
37 - * property, but I've not found a way yet that doesn't involve
38 - * open-coding the whole thing.
40 - if (c->is_40bit_channel)
41 - src |= 0x400000000ull;
42 + src = phys_to_dma(chan->device->dev, c->cfg.src_addr);
43 info |= BCM2835_DMA_S_DREQ | BCM2835_DMA_D_INC;
45 if (c->cfg.dst_addr_width != DMA_SLAVE_BUSWIDTH_4_BYTES)
47 - dst = c->cfg.dst_addr;
48 - if (c->is_40bit_channel)
49 - dst |= 0x400000000ull;
50 + dst = phys_to_dma(chan->device->dev, c->cfg.dst_addr);
51 info |= BCM2835_DMA_D_DREQ | BCM2835_DMA_S_INC;
54 @@ -994,17 +985,13 @@ static struct dma_async_tx_descriptor *b
55 if (direction == DMA_DEV_TO_MEM) {
56 if (c->cfg.src_addr_width != DMA_SLAVE_BUSWIDTH_4_BYTES)
58 - src = c->cfg.src_addr;
59 - if (c->is_40bit_channel)
60 - src |= 0x400000000ull;
61 + src = phys_to_dma(chan->device->dev, c->cfg.src_addr);
63 info |= BCM2835_DMA_S_DREQ | BCM2835_DMA_D_INC;
65 if (c->cfg.dst_addr_width != DMA_SLAVE_BUSWIDTH_4_BYTES)
67 - dst = c->cfg.dst_addr;
68 - if (c->is_40bit_channel)
69 - dst |= 0x400000000ull;
70 + dst = phys_to_dma(chan->device->dev, c->cfg.dst_addr);
72 info |= BCM2835_DMA_D_DREQ | BCM2835_DMA_S_INC;