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