brcm2708: switch to linux 4.4 and update patches
[openwrt.git] / target / linux / brcm2708 / patches-4.4 / 0014-bcm2835-i2s-get-base-address-for-DMA-from-devicetree.patch
1 From 5d6a70aac1ff4f0c898131100599340c1c3aba25 Mon Sep 17 00:00:00 2001
2 From: Matthias Reichl <hias@horus.com>
3 Date: Sun, 11 Oct 2015 16:44:05 +0200
4 Subject: [PATCH 014/156] bcm2835-i2s: get base address for DMA from devicetree
5
6 Code copied from spi-bcm2835. Get physical address from devicetree
7 instead of using hardcoded constant.
8
9 Signed-off-by: Matthias Reichl <hias@horus.com>
10 ---
11  sound/soc/bcm/bcm2835-i2s.c | 20 ++++++++++++--------
12  1 file changed, 12 insertions(+), 8 deletions(-)
13
14 --- a/sound/soc/bcm/bcm2835-i2s.c
15 +++ b/sound/soc/bcm/bcm2835-i2s.c
16 @@ -38,6 +38,7 @@
17  #include <linux/delay.h>
18  #include <linux/io.h>
19  #include <linux/clk.h>
20 +#include <linux/of_address.h>
21  
22  #include <sound/core.h>
23  #include <sound/pcm.h>
24 @@ -158,10 +159,6 @@ static const unsigned int bcm2835_clk_fr
25  #define BCM2835_I2S_INT_RXR            BIT(1)
26  #define BCM2835_I2S_INT_TXW            BIT(0)
27  
28 -/* I2S DMA interface */
29 -/* FIXME: Needs IOMMU support */
30 -#define BCM2835_VCMMU_SHIFT            (0x7E000000 - 0x20000000)
31 -
32  /* General device struct */
33  struct bcm2835_i2s_dev {
34         struct device                           *dev;
35 @@ -791,6 +788,15 @@ static int bcm2835_i2s_probe(struct plat
36         int ret;
37         struct regmap *regmap[2];
38         struct resource *mem[2];
39 +       const __be32 *addr;
40 +       dma_addr_t dma_reg_base;
41 +
42 +       addr = of_get_address(pdev->dev.of_node, 0, NULL, NULL);
43 +       if (!addr) {
44 +               dev_err(&pdev->dev, "could not get DMA-register address\n");
45 +               return -ENODEV;
46 +       }
47 +       dma_reg_base = be32_to_cpup(addr);
48  
49         /* Request both ioareas */
50         for (i = 0; i <= 1; i++) {
51 @@ -817,12 +823,10 @@ static int bcm2835_i2s_probe(struct plat
52  
53         /* Set the DMA address */
54         dev->dma_data[SNDRV_PCM_STREAM_PLAYBACK].addr =
55 -               (dma_addr_t)mem[0]->start + BCM2835_I2S_FIFO_A_REG
56 -                                         + BCM2835_VCMMU_SHIFT;
57 +               dma_reg_base + BCM2835_I2S_FIFO_A_REG;
58  
59         dev->dma_data[SNDRV_PCM_STREAM_CAPTURE].addr =
60 -               (dma_addr_t)mem[0]->start + BCM2835_I2S_FIFO_A_REG
61 -                                         + BCM2835_VCMMU_SHIFT;
62 +               dma_reg_base + BCM2835_I2S_FIFO_A_REG;
63  
64         /* Set the bus width */
65         dev->dma_data[SNDRV_PCM_STREAM_PLAYBACK].addr_width =