bcm2835: Getting DMA-busaddress for HW-register

Martin Sperl kernel at martin.sperl.org
Sun May 10 05:35:23 PDT 2015


To make the dma implementation of spi-bcm2835.c portable
I need to get the DMA address for the registers somewhere.

platform_get_resource only gives me the address of the register
in arm-address-space (so for SPI: start=20204000 end=20204fff)

Is there a better (and portable) way to get the dma_addr_t 
other than using the following (as per sound/soc/bcm/bcm2835-i2s.c):

#define BCM2835_VCMMU_SHIFT             (0x7E000000 - 0x20000000)
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
dma_reg = res->start + BCM2835_VCMMU_SHIFT + BCM2835_SPI_FIFO;

This obviously does not/will not work with a rpi2 where it would
need to be defined as:
#define BCM2835_VCMMU_SHIFT             (0x7E000000 - 0x3F000000)

Another option would be hard-coding the base-address
(as it can not change anyway):
dma_reg = 0x7E204000 + BCM2835_SPI_FIFO;

In principle the information is in the device-tree:
        soc {
                compatible = "simple-bus";
                ranges = <0x7e000000 0x20000000 0x2000000>;
...
                spi at 7e204000 {
                        reg = <0x7e204000 0x1000>;

So how can I get the base address from the device tree?

Thanks,
	Martin

p.s: this is based on 4.1.0-rc2





More information about the linux-rpi-kernel mailing list