aboutsummaryrefslogtreecommitdiffstats
path: root/arch/blackfin/kernel/setup.c
diff options
context:
space:
mode:
authorMike Frysinger <vapier.adi@gmail.com>2008-04-24 14:04:05 -0400
committerBryan Wu <cooloney@kernel.org>2008-04-24 14:04:05 -0400
commita086ee2268abcfcbf80a114f4602e5b26aa80bf0 (patch)
treefe027181ea37e00e85040977788cad82aa3faea5 /arch/blackfin/kernel/setup.c
parenta81501af19830ff43688781edad7e9c0cbd668af (diff)
[Blackfin] arch: detect the memory available in the system on the fly by default
detect the memory available in the system on the fly by default rather than forcing people to set this manually in the kconfig Signed-off-by: Mike Frysinger <vapier.adi@gmail.com> Signed-off-by: Bryan Wu <cooloney@kernel.org>
Diffstat (limited to 'arch/blackfin/kernel/setup.c')
-rw-r--r--arch/blackfin/kernel/setup.c45
1 files changed, 44 insertions, 1 deletions
diff --git a/arch/blackfin/kernel/setup.c b/arch/blackfin/kernel/setup.c
index c2f3e73ba25a..d6668328be72 100644
--- a/arch/blackfin/kernel/setup.c
+++ b/arch/blackfin/kernel/setup.c
@@ -649,6 +649,49 @@ static __init void setup_bootmem_allocator(void)
649 BOOTMEM_DEFAULT); 649 BOOTMEM_DEFAULT);
650} 650}
651 651
652#define EBSZ_TO_MEG(ebsz) \
653({ \
654 int meg = 0; \
655 switch (ebsz & 0xf) { \
656 case 0x1: meg = 16; break; \
657 case 0x3: meg = 32; break; \
658 case 0x5: meg = 64; break; \
659 case 0x7: meg = 128; break; \
660 case 0x9: meg = 256; break; \
661 case 0xb: meg = 512; break; \
662 } \
663 meg; \
664})
665static inline int __init get_mem_size(void)
666{
667#ifdef CONFIG_MEM_SIZE
668 return CONFIG_MEM_SIZE;
669#else
670# if defined(EBIU_SDBCTL)
671# if defined(BF561_FAMILY)
672 int ret = 0;
673 u32 sdbctl = bfin_read_EBIU_SDBCTL();
674 ret += EBSZ_TO_MEG(sdbctl >> 0);
675 ret += EBSZ_TO_MEG(sdbctl >> 8);
676 ret += EBSZ_TO_MEG(sdbctl >> 16);
677 ret += EBSZ_TO_MEG(sdbctl >> 24);
678 return ret;
679# else
680 return EBSZ_TO_MEG(bfin_read_EBIU_SDBCTL());
681# endif
682# elif defined(EBIU_DDRCTL1)
683 switch (bfin_read_EBIU_DDRCTL1() & 0xc0000) {
684 case DEVSZ_64: return 64;
685 case DEVSZ_128: return 128;
686 case DEVSZ_256: return 256;
687 case DEVSZ_512: return 512;
688 default: return 0;
689 }
690# endif
691#endif
692 BUG();
693}
694
652void __init setup_arch(char **cmdline_p) 695void __init setup_arch(char **cmdline_p)
653{ 696{
654 unsigned long sclk, cclk; 697 unsigned long sclk, cclk;
@@ -669,7 +712,7 @@ void __init setup_arch(char **cmdline_p)
669 712
670 /* setup memory defaults from the user config */ 713 /* setup memory defaults from the user config */
671 physical_mem_end = 0; 714 physical_mem_end = 0;
672 _ramend = CONFIG_MEM_SIZE * 1024 * 1024; 715 _ramend = get_mem_size() * 1024 * 1024;
673 716
674 memset(&bfin_memmap, 0, sizeof(bfin_memmap)); 717 memset(&bfin_memmap, 0, sizeof(bfin_memmap));
675 718