[PATCH 04/14] ppc mpc5200: add function to determine configured sdram size

Sascha Hauer s.hauer at pengutronix.de
Tue Sep 27 04:28:19 EDT 2011


Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 arch/ppc/mach-mpc5xxx/cpu.c                  |   17 +++++++++++++++++
 arch/ppc/mach-mpc5xxx/include/mach/mpc5xxx.h |    3 +++
 2 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/arch/ppc/mach-mpc5xxx/cpu.c b/arch/ppc/mach-mpc5xxx/cpu.c
index 391c705..cf2ca2f 100644
--- a/arch/ppc/mach-mpc5xxx/cpu.c
+++ b/arch/ppc/mach-mpc5xxx/cpu.c
@@ -113,3 +113,20 @@ int cpu_init_board_data(bd_t *bd)
 	bd->bi_pcifreq = get_pci_clock();
 	return 0;
 }
+
+unsigned long mpc5200_get_sdram_size(unsigned int cs)
+{
+	unsigned long size;
+
+	if (cs > 1)
+		return 0;
+
+	/* retrieve size of memory connected to SDRAM CS0 */
+	size = *(vu_long *)(MPC5XXX_SDRAM_CS0CFG + (cs * 4)) & 0xFF;
+	if (size >= 0x13)
+		size = (1 << (size - 0x13)) << 20;
+	else
+		size = 0;
+
+	return size;
+}
diff --git a/arch/ppc/mach-mpc5xxx/include/mach/mpc5xxx.h b/arch/ppc/mach-mpc5xxx/include/mach/mpc5xxx.h
index d7d0811..aad2418 100644
--- a/arch/ppc/mach-mpc5xxx/include/mach/mpc5xxx.h
+++ b/arch/ppc/mach-mpc5xxx/include/mach/mpc5xxx.h
@@ -779,6 +779,9 @@ struct mpc5xxx_mscan {
 /* function prototypes */
 void loadtask(int basetask, int tasks);
 
+/* retrieve configured sdram size connected to a chipselect */
+unsigned long mpc5200_get_sdram_size(unsigned int cs);
+
 #endif /* __ASSEMBLY__ */
 
 #endif /* __ASMPPC_MPC5XXX_H */
-- 
1.7.6.3




More information about the barebox mailing list