0014-bcm2835-i2s-get-base-address-for-DMA-from-devicetree.patch 2.0 KB

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