make etrax serial driver register its device nodes, so we get a console
[openwrt.git] / target / linux / etrax / patches / 201-flashsize.patch
1 Index: linux-2.6.25.1/arch/cris/arch-v10/lib/hw_settings.S
2 ===================================================================
3 --- linux-2.6.25.1.orig/arch/cris/arch-v10/lib/hw_settings.S    2008-05-03 20:25:16.000000000 +0100
4 +++ linux-2.6.25.1/arch/cris/arch-v10/lib/hw_settings.S 2008-05-03 20:25:35.000000000 +0100
5 @@ -60,3 +60,5 @@
6         .dword R_PORT_PB_SET
7         .dword PB_SET_VALUE
8         .dword 0 ; No more register values
9 +       .ascii "ACME_PART_MAGIC" 
10 +       .dword 0xdeadc0de
11 Index: linux-2.6.25.1/arch/cris/arch-v10/drivers/axisflashmap.c
12 ===================================================================
13 --- linux-2.6.25.1.orig/arch/cris/arch-v10/drivers/axisflashmap.c       2008-05-03 20:27:28.000000000 +0100
14 +++ linux-2.6.25.1/arch/cris/arch-v10/drivers/axisflashmap.c    2008-05-03 20:34:54.000000000 +0100
15 @@ -113,7 +113,7 @@
16  
17  /* If no partition-table was found, we use this default-set. */
18  #define MAX_PARTITIONS         7
19 -#define NUM_DEFAULT_PARTITIONS 3
20 +#define NUM_DEFAULT_PARTITIONS 2
21  
22  /*
23   * Default flash size is 2MB. CONFIG_ETRAX_PTABLE_SECTOR is most likely the
24 @@ -122,19 +122,14 @@
25   */
26  static struct mtd_partition axis_default_partitions[NUM_DEFAULT_PARTITIONS] = {
27         {
28 -               .name = "boot firmware",
29 -               .size = CONFIG_ETRAX_PTABLE_SECTOR,
30 -               .offset = 0
31 -       },
32 -       {
33                 .name = "kernel",
34 -               .size = 0x200000 - (6 * CONFIG_ETRAX_PTABLE_SECTOR),
35 -               .offset = CONFIG_ETRAX_PTABLE_SECTOR
36 +               .size = 0x00,
37 +               .offset = 0
38         },
39         {
40 -               .name = "filesystem",
41 -               .size = 5 * CONFIG_ETRAX_PTABLE_SECTOR,
42 -               .offset = 0x200000 - (5 * CONFIG_ETRAX_PTABLE_SECTOR)
43 +               .name = "rootfs",
44 +               .size = 0x200000 ,
45 +               .offset = 0x200000
46         }
47  };
48  
49 @@ -281,6 +276,11 @@
50         struct partitiontable_entry *ptable;
51         int use_default_ptable = 1; /* Until proven otherwise. */
52         const char pmsg[] = "  /dev/flash%d at 0x%08x, size 0x%08x\n";
53 +       unsigned int kernel_part_size = 0;
54 +       unsigned char *flash_mem = (unsigned char*)(FLASH_CACHED_ADDR);
55 +       unsigned int flash_scan_count = 0;
56 +       const char *part_magic = "ACME_PART_MAGIC";
57 +       unsigned int magic_len = strlen(part_magic);
58  
59         if (!(mymtd = flash_probe())) {
60                 /* There's no reason to use this module if no flash chip can
61 @@ -292,6 +292,31 @@
62                        mymtd->name, mymtd->size);
63                 axisflash_mtd = mymtd;
64         }
65 +       /* scan flash to findout where out partition starts */
66 +
67 +       printk(KERN_INFO "Scanning flash for end of kernel magic\n");
68 +       for(flash_scan_count = 0; flash_scan_count < 100000; flash_scan_count++){
69 +               if(strncmp(&flash_mem[flash_scan_count], part_magic, magic_len - 1) == 0)
70 +               {
71 +                       kernel_part_size = flash_mem[flash_scan_count + magic_len ];
72 +                       kernel_part_size <<= 8;
73 +                       kernel_part_size += flash_mem[flash_scan_count + magic_len + 2];
74 +                       kernel_part_size <<= 8;
75 +                       kernel_part_size += flash_mem[flash_scan_count + magic_len + 1];
76 +                       kernel_part_size <<= 8;
77 +                       kernel_part_size += flash_mem[flash_scan_count + magic_len + 3];
78 +                       printk(KERN_INFO "Kernel ends at 0x%.08X\n", kernel_part_size);
79 +                       flash_scan_count = 1100000;
80 +               }
81 +       }
82 +
83 +
84 +       if(kernel_part_size){
85 +               kernel_part_size = (kernel_part_size & 0xffff0000);
86 +               axis_default_partitions[0].size = kernel_part_size;
87 +               axis_default_partitions[1].size =  mymtd->size - axis_default_partitions[0].size;
88 +               axis_default_partitions[1].offset = axis_default_partitions[0].size;
89 +       }
90  
91         if (mymtd) {
92                 mymtd->owner = THIS_MODULE;