1 --- a/drivers/mtd/maps/lantiq.c
2 +++ b/drivers/mtd/maps/lantiq.c
5 #include <lantiq_platform.h>
7 +#ifdef CONFIG_SOC_LANTIQ_XWAY
12 lq_read16(struct map_info *map, unsigned long adr)
14 @@ -77,6 +81,75 @@ lq_copy_to(struct map_info *map, unsigne
15 spin_unlock_irqrestore(&ebu_lock, flags);
19 +find_uImage_size(struct map_info *map, unsigned long offset)
21 +#define UBOOT_MAGIC 0x56190527
22 + unsigned long magic;
24 + map->copy_from(map, &magic, offset, 4);
25 + if (le32_to_cpu(magic) != UBOOT_MAGIC)
27 + map->copy_from(map, &temp, offset + 12, 4);
32 +detect_squashfs_partition(struct map_info *map, unsigned long offset)
35 + map->copy_from(map, &temp, offset, 4);
36 + return le32_to_cpu(temp) == SQUASHFS_MAGIC;
39 +static struct mtd_partition split_partitions[] = {
52 +mtd_split_linux(struct map_info *map, struct mtd_info *mtd,
53 + struct mtd_partition *parts, int nr_parts)
57 + for (i = 0; i < nr_parts && !base_part; i++) {
58 + if(!strcmp("linux", parts[i].name))
63 + split_partitions[0].size = find_uImage_size(map, parts[base_part].offset);
64 + if (!split_partitions[0].size) {
65 + printk(KERN_INFO "lq_nor: no uImage found in linux partition");
68 + if (!detect_squashfs_partition(map,
69 + parts[base_part].offset + split_partitions[0].size)) {
70 + split_partitions[0].size &= ~(mtd->erasesize - 1);
71 + split_partitions[0].size += mtd->erasesize;
73 + split_partitions[0].offset = parts[base_part].offset;
74 + split_partitions[1].offset =
75 + parts[base_part].offset + split_partitions[0].size;
76 + split_partitions[1].size =
77 + parts[base_part].size - split_partitions[0].size;
80 + add_mtd_partitions(mtd, parts, base_part);
81 + add_mtd_partitions(mtd, split_partitions, 2);
82 + if(nr_parts != base_part)
83 + add_mtd_partitions(mtd, &parts[base_part], nr_parts - base_part);
84 + return nr_parts + 2;
87 static const char *part_probe_types[] = { "cmdlinepart", NULL };
89 static struct map_info lq_map = {
90 @@ -142,7 +215,8 @@ lq_mtd_probe(struct platform_device *pde
91 parts = lq_mtd_data->parts;
94 - add_mtd_partitions(lq_mtd, parts, nr_parts);
95 + if (!mtd_split_linux(&lq_map, lq_mtd, parts, nr_parts))
96 + add_mtd_partitions(lq_mtd, parts, nr_parts);