diff options
author | Ahmad Fatoum <a.fatoum@pengutronix.de> | 2019-05-23 17:39:41 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2019-05-27 10:07:00 +0200 |
commit | 96f3f2fa6395414c7055f49c1b3e56b7a7484b3f (patch) | |
tree | 47e9f3590fb4523f90262e151d4723e5354da2ff /arch/arm/mach-at91 | |
parent | 55a676bf2a8430a3abb0225cb2d5102b777e24be (diff) | |
download | barebox-96f3f2fa6395414c7055f49c1b3e56b7a7484b3f.tar.gz barebox-96f3f2fa6395414c7055f49c1b3e56b7a7484b3f.tar.xz |
ARM: at91: fix at91sama5_get_ddram_size for sama5d4
at91sama5_get_ddram_size() is despite the name specific to the
sama5d3 which it was added alongside of. sama5d4 board code continues
to use it, but accessing SAMA5D3_BASE_MPDDRC (0xffffea00) on
a sama5d4 should result in a Data Abort (Datasheet Figure 5-1)..
Fix this by giving at91sama5_get_ddram_size the mpddrc base
address as argument and migrate users to use one of two helpers
that specify the base address.
Tested-by: Sam Ravnborg <sam@ravnborg.org>
[afa: Sam didn't test this exact change, but tested the use
of the critical part: accessing a different register]
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch/arm/mach-at91')
-rw-r--r-- | arch/arm/mach-at91/include/mach/at91sam9_ddrsdr.h | 13 | ||||
-rw-r--r-- | arch/arm/mach-at91/sama5d3_devices.c | 2 | ||||
-rw-r--r-- | arch/arm/mach-at91/sama5d4_devices.c | 2 |
3 files changed, 13 insertions, 4 deletions
diff --git a/arch/arm/mach-at91/include/mach/at91sam9_ddrsdr.h b/arch/arm/mach-at91/include/mach/at91sam9_ddrsdr.h index 835fdea259..604c38d7e4 100644 --- a/arch/arm/mach-at91/include/mach/at91sam9_ddrsdr.h +++ b/arch/arm/mach-at91/include/mach/at91sam9_ddrsdr.h @@ -198,12 +198,11 @@ static inline u32 at91sam9n12_get_ddram_size(void) return at91_get_ddram_size(IOMEM(AT91SAM9N12_BASE_DDRSDRC0), true); } -static inline u32 at91sama5_get_ddram_size(void) +static inline u32 at91sama5_get_ddram_size(void __iomem *base) { u32 cr; u32 mdr; u32 size; - void * __iomem base = IOMEM(SAMA5D3_BASE_MPDDRC); cr = readl(base + AT91_DDRSDRC_CR); mdr = readl(base + AT91_DDRSDRC_MDR); @@ -228,6 +227,16 @@ static inline u32 at91sama5_get_ddram_size(void) return size; } +static inline u32 at91sama5d3_get_ddram_size(void) +{ + return at91sama5_get_ddram_size(IOMEM(SAMA5D3_BASE_MPDDRC)); +} + +static inline u32 at91sama5d4_get_ddram_size(void) +{ + return at91sama5_get_ddram_size(IOMEM(SAMA5D4_BASE_MPDDRC)); +} + #endif #endif diff --git a/arch/arm/mach-at91/sama5d3_devices.c b/arch/arm/mach-at91/sama5d3_devices.c index f5075b3937..bf4a03d404 100644 --- a/arch/arm/mach-at91/sama5d3_devices.c +++ b/arch/arm/mach-at91/sama5d3_devices.c @@ -28,7 +28,7 @@ void at91_add_device_sdram(u32 size) { if (!size) - size = at91sama5_get_ddram_size(); + size = at91sama5d3_get_ddram_size(); arm_add_mem_device("ram0", SAMA5_DDRCS, size); add_mem_device("sram0", SAMA5D3_SRAM_BASE, diff --git a/arch/arm/mach-at91/sama5d4_devices.c b/arch/arm/mach-at91/sama5d4_devices.c index 4064e4441f..5a1109dc0e 100644 --- a/arch/arm/mach-at91/sama5d4_devices.c +++ b/arch/arm/mach-at91/sama5d4_devices.c @@ -29,7 +29,7 @@ void at91_add_device_sdram(u32 size) { if (!size) - size = at91sama5_get_ddram_size(); + size = at91sama5d4_get_ddram_size(); arm_add_mem_device("ram0", SAMA5_DDRCS, size); add_mem_device("sram0", SAMA5D4_SRAM_BASE, |