1 --- a/drivers/mtd/ar7part.c
2 +++ b/drivers/mtd/ar7part.c
5 #include <uapi/linux/magic.h>
7 +#include <asm/mach-ar7/prom.h>
10 #define ROOT_OFFSET 0xe0000
12 #define LOADER_MAGIC1 le32_to_cpu(0xfeedfa42)
13 #define LOADER_MAGIC2 le32_to_cpu(0xfeed1281)
14 +#define LOADER_MAGIC3 le32_to_cpu(0x434d4d4c)
17 unsigned int checksum;
18 @@ -42,12 +45,16 @@ struct ar7_bin_rec {
22 +int create_titan_partitions(struct mtd_info *master,
23 + struct mtd_partition **pparts,
24 + struct mtd_part_parser_data *data);
26 static int create_mtd_partitions(struct mtd_info *master,
27 struct mtd_partition **pparts,
28 struct mtd_part_parser_data *data)
30 struct ar7_bin_rec header;
31 - unsigned int offset;
32 + unsigned int offset, mtd_start, mtd_end;
34 unsigned int pre_size = master->erasesize, post_size = 0;
35 unsigned int root_offset = ROOT_OFFSET;
36 @@ -55,6 +62,16 @@ static int create_mtd_partitions(struct
38 struct mtd_partition *ar7_parts;
40 + const char *prom_str = prom_getenv("ProductID");
41 + char mtd_name[] = "mtd1";
43 + (strcmp(prom_str, "CYWL")==0 ||
44 + strcmp(prom_str, "CYWM")==0 ||
45 + strcmp(prom_str, "CYLM")==0 ||
46 + strcmp(prom_str, "CYLL")==0)){
47 + return create_titan_partitions(master, pparts, data);
50 ar7_parts = kzalloc(sizeof(*ar7_parts) * AR7_PARTS, GFP_KERNEL);
53 @@ -83,34 +100,39 @@ static int create_mtd_partitions(struct
57 - if (!ar7_parts[1].offset) {
58 - ar7_parts[1].offset = master->size - master->erasesize;
59 - post_size = master->erasesize;
62 switch (header.checksum) {
64 - while (header.length) {
65 - offset += sizeof(header) + header.length;
66 - mtd_read(master, offset, sizeof(header), &len,
67 - (uint8_t *)&header);
69 - root_offset = offset + sizeof(header) + 4;
72 + for (retries = 0; retries <= 9; retries++) {
73 + mtd_name[3] = '0' + retries;
74 + prom_str = prom_getenv(mtd_name);
75 + if (prom_str == NULL)
77 + sscanf(prom_str, "%i,%i", &mtd_start, &mtd_end);
78 + if (pre_size == (mtd_start & 0x1ffffff)) {
79 + ar7_parts[1].offset = mtd_end &= 0x1ffffff;
80 + ar7_parts[1].size = post_size = master->size - mtd_end;
85 + root_offset = (header.checksum == LOADER_MAGIC1) ? 4 : 0;
86 while (header.length) {
87 offset += sizeof(header) + header.length;
88 mtd_read(master, offset, sizeof(header), &len,
91 - root_offset = offset + sizeof(header) + 4 + 0xff;
92 - root_offset &= ~(uint32_t)0xff;
93 + root_offset += offset + sizeof(header);
96 printk(KERN_WARNING "Unknown magic: %08x\n", header.checksum);
100 + if (!ar7_parts[1].offset) {
101 + post_size = master->erasesize;
102 + ar7_parts[1].offset = master->size - post_size;
105 mtd_read(master, root_offset, sizeof(header), &len, (u8 *)&header);
106 if (header.checksum != SQUASHFS_MAGIC) {
107 root_offset += master->erasesize - 1;
108 --- a/drivers/mtd/titanpart.c
109 +++ b/drivers/mtd/titanpart.c
110 @@ -149,7 +149,7 @@ static void titan_add_partition(char * e
112 int create_titan_partitions(struct mtd_info *master,
113 struct mtd_partition **pparts,
114 - unsigned long origin)
115 + struct mtd_part_parser_data *data)
117 struct nsp_img_hdr_head hdr;
118 struct nsp_img_hdr_section_info sect_info;