summaryrefslogtreecommitdiff
path: root/target/linux/ar71xx/files/arch/mips
diff options
context:
space:
mode:
authorGabor Juhos <juhosg@openwrt.org>2008-11-13 15:55:39 +0000
committerGabor Juhos <juhosg@openwrt.org>2008-11-13 15:55:39 +0000
commitd1c40911ebf121bb4914b7d08374e9a4bc5d1ae5 (patch)
treefbd1f96b22934dcace135baa840ba8b52ab0bd5e /target/linux/ar71xx/files/arch/mips
parent2b10284b6212d931be8458e069a3a495a2c4fa23 (diff)
downloadmtk-20170518-d1c40911ebf121bb4914b7d08374e9a4bc5d1ae5.zip
mtk-20170518-d1c40911ebf121bb4914b7d08374e9a4bc5d1ae5.tar.gz
mtk-20170518-d1c40911ebf121bb4914b7d08374e9a4bc5d1ae5.tar.bz2
rewrite memory size detection
SVN-Revision: 13198
Diffstat (limited to 'target/linux/ar71xx/files/arch/mips')
-rw-r--r--target/linux/ar71xx/files/arch/mips/ar71xx/setup.c28
1 files changed, 7 insertions, 21 deletions
diff --git a/target/linux/ar71xx/files/arch/mips/ar71xx/setup.c b/target/linux/ar71xx/files/arch/mips/ar71xx/setup.c
index 855497c..fc86520 100644
--- a/target/linux/ar71xx/files/arch/mips/ar71xx/setup.c
+++ b/target/linux/ar71xx/files/arch/mips/ar71xx/setup.c
@@ -85,28 +85,14 @@ int __init ar71xx_pci_init(unsigned nr_irqs, struct ar71xx_pci_irq *map)
static void __init ar71xx_detect_mem_size(void)
{
- volatile u8 *p;
- u8 memsave;
- u32 size;
-
- p = (volatile u8 *) KSEG1ADDR(0);
- memsave = *p;
- for (size = AR71XX_MEM_SIZE_MIN;
- size <= (AR71XX_MEM_SIZE_MAX >> 1); size <<= 1) {
- volatile u8 *r;
-
- r = (p + size);
- *p = 0x55;
- if (*r == 0x55) {
- /* Mirrored data found, try another pattern */
- *p = 0xAA;
- if (*r == 0xAA) {
- /* Mirrored data found again, stop detection */
- break;
- }
- }
+ unsigned long size;
+
+ for (size = AR71XX_MEM_SIZE_MIN; size < AR71XX_MEM_SIZE_MAX;
+ size <<= 1 ) {
+ if (!memcmp(ar71xx_detect_mem_size,
+ ar71xx_detect_mem_size + size, 1024))
+ break;
}
- *p = memsave;
add_memory_region(0, size, BOOT_MEM_RAM);
}