summaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-at91
diff options
context:
space:
mode:
authorAhmad Fatoum <a.fatoum@pengutronix.de>2019-05-23 17:39:42 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2019-05-27 10:07:00 +0200
commita57be6b7ee47e92618ce13430e158c91cfaba3ca (patch)
tree91bc68d9d8a2c902e74f015e357609e313eae2f4 /arch/arm/mach-at91
parent96f3f2fa6395414c7055f49c1b3e56b7a7484b3f (diff)
downloadbarebox-a57be6b7ee47e92618ce13430e158c91cfaba3ca.tar.gz
barebox-a57be6b7ee47e92618ce13430e158c91cfaba3ca.tar.xz
ARM: at91: remove duplicate get_ddram_size code
Both at91_get_ddram_size and at91sama5_get_ddram_size are the same if is_sdram == false and is_nb == true. is_sdram is always false, because according to the sama5d{2,3,4} datasheets, the lowest possible value for AT91_DDRSDRC_MD is 3 (i.e. none of them supports SDR SDRAM). Therefore replace calls to at91sama5_get_ddram_size with at91_get_ddram_size while is_nb == true and remove the duplicate code. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Reviewed-by: Sam Ravnborg <sam@ravnborg.org> Tested-by: Sam Ravnborg <sam@ravnborg.org> 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.h34
1 files changed, 3 insertions, 31 deletions
diff --git a/arch/arm/mach-at91/include/mach/at91sam9_ddrsdr.h b/arch/arm/mach-at91/include/mach/at91sam9_ddrsdr.h
index 604c38d7e4..34b2eed057 100644
--- a/arch/arm/mach-at91/include/mach/at91sam9_ddrsdr.h
+++ b/arch/arm/mach-at91/include/mach/at91sam9_ddrsdr.h
@@ -149,6 +149,7 @@ static inline u32 at91_get_ddram_size(void * __iomem base, bool is_nb)
cr = readl(base + AT91_DDRSDRC_CR);
mdr = readl(base + AT91_DDRSDRC_MDR);
+ /* will always be false for sama5d2, sama5d3 or sama5d4 */
is_sdram = (mdr & AT91_DDRSDRC_MD) <= AT91_DDRSDRC_MD_LOW_POWER_SDR;
/* Formula:
@@ -198,43 +199,14 @@ 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 __iomem *base)
-{
- u32 cr;
- u32 mdr;
- u32 size;
-
- cr = readl(base + AT91_DDRSDRC_CR);
- mdr = readl(base + AT91_DDRSDRC_MDR);
-
- /* Formula:
- * size = bank << (col + row + 1);
- * if (bandwidth == 32 bits)
- * size <<= 1;
- */
- size = 1;
- /* COL */
- size += (cr & AT91_DDRSDRC_NC) + 9;
- /* ROW */
- size += ((cr & AT91_DDRSDRC_NR) >> 2) + 11;
- /* BANK */
- size = ((cr & AT91_DDRSDRC_NB) ? 8 : 4) << size;
-
- /* bandwidth */
- if (!(mdr & AT91_DDRSDRC_DBW))
- size <<= 1;
-
- return size;
-}
-
static inline u32 at91sama5d3_get_ddram_size(void)
{
- return at91sama5_get_ddram_size(IOMEM(SAMA5D3_BASE_MPDDRC));
+ return at91_get_ddram_size(IOMEM(SAMA5D3_BASE_MPDDRC), true);
}
static inline u32 at91sama5d4_get_ddram_size(void)
{
- return at91sama5_get_ddram_size(IOMEM(SAMA5D4_BASE_MPDDRC));
+ return at91_get_ddram_size(IOMEM(SAMA5D4_BASE_MPDDRC), true);
}
#endif