Hi, On 12/30/2013 01:50 AM, Siarhei Siamashka wrote:
These macros are used to convert between physical addresses (as seen by the CPU) and bus addresses (as seen by various peripherals such as the display controller, cedar, g2d, mali, ...).The difference between physical and bus addresses is 0x40000000, because that's the physical address of SDRAM (and PHYS_OFFSET define in the kernel). Huang Benn has provided an explanation earlier: http://thread.gmane.org/gmane.comp.hardware.netbook.arm.sunxi/2827 But some additional demystification might be useful. Basically, when we write an address to some hardware register of the display controller, it is expected to be a bus address. However as long as the size of RAM is just 1 GiB or less, adding or subtracting a multiple of PHYS_OFFSET (which happens to be 1 GiB) to this address does not have any adverse effects. We just get some garbage in the high address lines on the memory interface, but these high address lines are not connected anywhere and have no effect. So using either bus addresses or just physical addresses was fine for the systems with 1 GiB of RAM or less. But when having 2 GiB of RAM, using proper bus addresses becomes really important. A failure to do so and an incorrect value in the high address bit results in memory accesses going to a low or high 1 GiB part of DRAM based on the value of this bit. This behaviour is expected to be the same for all sunxi hardware with 2 GiB of RAM. There is nothing sun7i specific in it and it makes sense to treat sun4i/sun5i/sun7i in the same way. Also the conversion between bus and physical addresses is a simple addition or subtraction of PHYS_OFFSET without any need for convoluted logic. Signed-off-by: Siarhei Siamashka <[email protected]>
Looks good: Acked-by: Hans de Goede <[email protected]> Regards, Hans
--- arch/arm/plat-sunxi/include/plat/memory.h | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/arch/arm/plat-sunxi/include/plat/memory.h b/arch/arm/plat-sunxi/include/plat/memory.h index 20c27bd..42a4afa 100644 --- a/arch/arm/plat-sunxi/include/plat/memory.h +++ b/arch/arm/plat-sunxi/include/plat/memory.h @@ -30,13 +30,7 @@ /* default ATAG_MEM size */ #define MEM_SIZE (512*1024*1024) -#ifdef CONFIG_ARCH_SUN7I -#define __phys_to_bus(x) (((x)>=PLAT_PHYS_OFFSET)?(x)-PLAT_PHYS_OFFSET:(x)) -#define __bus_to_phys(x) (((x)<PLAT_PHYS_OFFSET)?(x)+PLAT_PHYS_OFFSET:(x)) -#else -#define __phys_to_bus(x) (x) -#define __bus_to_phys(x) (x) -#endif - +#define __phys_to_bus(x) ((x) - PLAT_PHYS_OFFSET) +#define __bus_to_phys(x) ((x) + PLAT_PHYS_OFFSET) #endif
-- You received this message because you are subscribed to the Google Groups "linux-sunxi" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.
