aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/etrax-2.6/patches/cris/016-auto-detect-ram.patch
blob: 51930f2ce21ceced3d2b8594f470893a7260d61b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
diff -urN linux-2.6.19.2//arch/cris/arch-v10/boot/compressed/hw_settings.S /tmp/linux-2.6.19.2/arch/cris/arch-v10/boot/compressed/hw_settings.S
--- linux-2.6.19.2//arch/cris/arch-v10/boot/compressed/hw_settings.S	2007-06-01 00:37:57.000000000 +0200
+++ /tmp/linux-2.6.19.2/arch/cris/arch-v10/boot/compressed/hw_settings.S	2007-06-01 00:34:55.000000000 +0200
@@ -62,3 +62,5 @@
 	.dword 0 ; No more register values
 	.ascii "ACME_PART_MAGIC" ; Magic number
 	.dword 0xdeadc0de
+	.ascii "ACME_RAM_MAGIC" ; Magic number
+	.dword 0x2000000 
diff -urN linux-2.6.19.2//arch/cris/arch-v10/boot/compressed/hw_settings_416.S /tmp/linux-2.6.19.2/arch/cris/arch-v10/boot/compressed/hw_settings_416.S
--- linux-2.6.19.2//arch/cris/arch-v10/boot/compressed/hw_settings_416.S	2007-06-01 00:37:57.000000000 +0200
+++ /tmp/linux-2.6.19.2/arch/cris/arch-v10/boot/compressed/hw_settings_416.S	2007-06-01 00:34:55.000000000 +0200
@@ -62,3 +62,5 @@
 	.dword 0 ; No more register values
 	.ascii "ACME_PART_MAGIC" ; Magic number
 	.dword 0xdeadc0de
+	.ascii "ACME_RAM_MAGIC" ; Magic number
+	.dword 0x1000000 
diff -urN linux-2.6.19.2//arch/cris/arch-v10/boot/compressed/hw_settings_816.S /tmp/linux-2.6.19.2/arch/cris/arch-v10/boot/compressed/hw_settings_816.S
--- linux-2.6.19.2//arch/cris/arch-v10/boot/compressed/hw_settings_816.S	2007-06-01 00:37:57.000000000 +0200
+++ /tmp/linux-2.6.19.2/arch/cris/arch-v10/boot/compressed/hw_settings_816.S	2007-06-01 00:34:55.000000000 +0200
@@ -62,3 +62,5 @@
 	.dword 0 ; No more register values
 	.ascii "ACME_PART_MAGIC" ; Magic number
 	.dword 0xdeadc0de
+	.ascii "ACME_RAM_MAGIC" ; Magic number
+	.dword 0x1000000 
diff -urN linux-2.6.19.2//arch/cris/arch-v10/boot/compressed/hw_settings_832.S /tmp/linux-2.6.19.2/arch/cris/arch-v10/boot/compressed/hw_settings_832.S
--- linux-2.6.19.2//arch/cris/arch-v10/boot/compressed/hw_settings_832.S	2007-06-01 00:37:57.000000000 +0200
+++ /tmp/linux-2.6.19.2/arch/cris/arch-v10/boot/compressed/hw_settings_832.S	2007-06-01 00:34:55.000000000 +0200
@@ -62,3 +62,5 @@
 	.dword 0 ; No more register values
 	.ascii "ACME_PART_MAGIC" ; Magic number
 	.dword 0xdeadc0de
+	.ascii "ACME_RAM_MAGIC" ; Magic number
+	.dword 0x2000000 
diff -urN linux-2.6.19.2//arch/cris/arch-v10/boot/compressed/hw_settings_MCM.S /tmp/linux-2.6.19.2/arch/cris/arch-v10/boot/compressed/hw_settings_MCM.S
--- linux-2.6.19.2//arch/cris/arch-v10/boot/compressed/hw_settings_MCM.S	2007-06-01 00:37:57.000000000 +0200
+++ /tmp/linux-2.6.19.2/arch/cris/arch-v10/boot/compressed/hw_settings_MCM.S	2007-06-01 00:34:55.000000000 +0200
@@ -62,3 +62,5 @@
 	.dword 0 ; No more register values
 	.ascii "ACME_PART_MAGIC" ; Magic number
 	.dword 0xdeadc0de
+	.ascii "ACME_RAM_MAGIC" ; Magic number
+	.dword 0x1000000 
--- linux-2.6.19.2//arch/cris/kernel/setup.c	2007-06-01 00:37:55.000000000 +0200
+++ /tmp/linux-2.6.19.2/arch/cris/kernel/setup.c	2007-06-01 00:34:55.000000000 +0200
@@ -55,6 +55,13 @@
  * boot code and the system.
  *
  */
+#ifdef CONFIG_CRIS_LOW_MAP
+#define FLASH_UNCACHED_ADDR  KSEG_8
+#define FLASH_CACHED_ADDR    KSEG_5
+#else
+#define FLASH_UNCACHED_ADDR  KSEG_E
+#define FLASH_CACHED_ADDR    KSEG_F
+#endif
 
 void __init 
 setup_arch(char **cmdline_p)
@@ -63,15 +70,37 @@
 	unsigned long bootmap_size;
 	unsigned long start_pfn, max_pfn;
 	unsigned long memory_start;
-
+	unsigned int ram_size = 0;
+	unsigned char *flash_mem = (unsigned char*)(FLASH_CACHED_ADDR);
+	unsigned int ram_scan_count = 0;
+	const char *ram_magic = "ACME_RAM_MAGIC";
+	unsigned int magic_len = strlen(ram_magic);
+	unsigned long dend;
  	/* register an initial console printing routine for printk's */
 
 	init_etrax_debug();
 
 	/* we should really poll for DRAM size! */
+	printk(KERN_INFO "Determinig RAM size\n");
+	for(ram_scan_count = 0; ram_scan_count < 100000; ram_scan_count++){
+		if(strncmp(&flash_mem[ram_scan_count], ram_magic, magic_len - 1) == 0){
+			ram_size = flash_mem[ram_scan_count + magic_len ];
+			ram_size <<= 8;
+			ram_size += flash_mem[ram_scan_count + magic_len + 2];
+			ram_size <<= 8;
+			ram_size += flash_mem[ram_scan_count + magic_len + 1];
+			ram_size <<= 8;
+			ram_size += flash_mem[ram_scan_count + magic_len + 3];
+			printk(KERN_INFO "RAM size is %uMB\n", 16 * ram_size);
+			ram_scan_count = 1100000;
+		}
+	}
 
 	high_memory = &dram_end;
-
+	dend = dram_start + 16 * 1024 * 1024 * ram_size;
+	if(ram_size == 1){
+		high_memory = 0xc1000000;
+	}
 	if(romfs_in_flash || !romfs_length) {
 		/* if we have the romfs in flash, or if there is no rom filesystem,
 		 * our free area starts directly after the BSS