diff options
author | Rafał Miłecki <zajec5@gmail.com> | 2014-04-19 06:49:46 -0400 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2014-05-30 05:00:21 -0400 |
commit | 96a8123e5f965825a61a74617b8da1199646d392 (patch) | |
tree | 5c4c5a54046601668f23627c733883bd05c60a08 /arch/mips/bcm47xx | |
parent | d8ce75934b888df0bd73dfd9c030a2b034a04977 (diff) |
MIPS: BCM47XX: Slightly clean memory detection
Patch was tested on devices with 64 MiB and 256 MiB of RAM.
It documents every part nicely and drops this hacky part of code:
max = off | ((128 << 20) - 1);
Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
Cc: linux-mips@linux-mips.org
Cc: Hauke Mehrtens <hauke@hauke-m.de>
Patchwork: https://patchwork.linux-mips.org/patch/6808/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips/bcm47xx')
-rw-r--r-- | arch/mips/bcm47xx/prom.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/arch/mips/bcm47xx/prom.c b/arch/mips/bcm47xx/prom.c index 0af808dfd1ca..1a03a2f43496 100644 --- a/arch/mips/bcm47xx/prom.c +++ b/arch/mips/bcm47xx/prom.c | |||
@@ -69,15 +69,18 @@ static __init void prom_init_mem(void) | |||
69 | * BCM47XX uses 128MB for addressing the ram, if the system contains | 69 | * BCM47XX uses 128MB for addressing the ram, if the system contains |
70 | * less that that amount of ram it remaps the ram more often into the | 70 | * less that that amount of ram it remaps the ram more often into the |
71 | * available space. | 71 | * available space. |
72 | * Accessing memory after 128MB will cause an exception. | ||
73 | * max contains the biggest possible address supported by the platform. | ||
74 | * If the method wants to try something above we assume 128MB ram. | ||
75 | */ | 72 | */ |
76 | off = (unsigned long)prom_init; | 73 | |
77 | max = off | ((128 << 20) - 1); | 74 | /* Physical address, without mapping to any kernel segment */ |
78 | for (mem = (1 << 20); mem < (128 << 20); mem += (1 << 20)) { | 75 | off = CPHYSADDR((unsigned long)prom_init); |
79 | if ((off + mem) > max) { | 76 | |
80 | mem = (128 << 20); | 77 | /* Accessing memory after 128 MiB will cause an exception */ |
78 | max = 128 << 20; | ||
79 | |||
80 | for (mem = 1 << 20; mem < max; mem += 1 << 20) { | ||
81 | /* Loop condition may be not enough, off may be over 1 MiB */ | ||
82 | if (off + mem >= max) { | ||
83 | mem = max; | ||
81 | printk(KERN_DEBUG "assume 128MB RAM\n"); | 84 | printk(KERN_DEBUG "assume 128MB RAM\n"); |
82 | break; | 85 | break; |
83 | } | 86 | } |