X-Git-Url: https://git.rohieb.name/openwrt.git/blobdiff_plain/6ad1668c37fef80075e1a69b0ef71d0f8bbeb9c3..ff51b5599255b0c536ac17fb98e41948dc01b3c2:/target/linux/ifxmips/files/drivers/mtd/maps/ifxmips.c diff --git a/target/linux/ifxmips/files/drivers/mtd/maps/ifxmips.c b/target/linux/ifxmips/files/drivers/mtd/maps/ifxmips.c index b4faf0535..376fd0b2f 100644 --- a/target/linux/ifxmips/files/drivers/mtd/maps/ifxmips.c +++ b/target/linux/ifxmips/files/drivers/mtd/maps/ifxmips.c @@ -29,9 +29,9 @@ #include #include -#include -#include -#include +#include +#include +#include #ifndef CONFIG_MTD_PARTITIONS #error Please enable CONFIG_MTD_PARTITIONS @@ -102,11 +102,11 @@ static struct mtd_partition ifxmips_partitions[] = { { .name = "uboot_env", .offset = 0x00020000, - .size = 0x00010000, + .size = 0x0, }, { .name = "kernel", - .offset = 0x00030000, + .offset = 0x0, .size = 0x0, }, { @@ -134,8 +134,8 @@ int find_uImage_size(unsigned long start_offset) unsigned long magic; unsigned long temp; ifxmips_copy_from(&ifxmips_map, &magic, start_offset, 4); - if (!(ntohl(magic) == 0x27051956)) { - printk(KERN_INFO "ifxmips_mtd: invalid magic (0x%08X) of kernel at 0x%08lx \n", ntohl(magic), start_offset); + if (le32_to_cpu(magic) != 0x56190527) { + printk(KERN_INFO "ifxmips_mtd: invalid magic (0x%08X) of kernel at 0x%08lx \n", le32_to_cpu(magic), start_offset); return 0; } ifxmips_copy_from(&ifxmips_map, &temp, start_offset + 12, 4); @@ -159,7 +159,7 @@ int detect_squashfs_partition(unsigned long start_offset) { unsigned long temp; ifxmips_copy_from(&ifxmips_map, &temp, start_offset, 4); - return temp == SQUASHFS_MAGIC; + return le32_to_cpu(temp) == SQUASHFS_MAGIC; } static int ifxmips_mtd_probe(struct platform_device *dev) @@ -208,6 +208,10 @@ static int ifxmips_mtd_probe(struct platform_device *dev) rootfs_part = i; } } else { + /* if the flash is 64k sectors, the kernel will reside at 0xb0030000 + if the flash is 128k sectors, the kernel will reside at 0xb0040000 */ + ifxmips_partitions[1].size = ifxmips_mtd->erasesize; + ifxmips_partitions[2].offset = ifxmips_partitions[1].offset + ifxmips_mtd->erasesize; parts = &ifxmips_partitions[0]; } @@ -218,8 +222,8 @@ static int ifxmips_mtd_probe(struct platform_device *dev) if (detect_squashfs_partition(parts[kernel_part].offset + uimage_size)) { printk(KERN_INFO "ifxmips_mtd: found a squashfs following the uImage\n"); } else { - uimage_size &= ~0xffff; - uimage_size += 0x10000; + uimage_size &= ~(ifxmips_mtd->erasesize -1); + uimage_size += ifxmips_mtd->erasesize; } parts[kernel_part].size = uimage_size; @@ -232,9 +236,10 @@ static int ifxmips_mtd_probe(struct platform_device *dev) if (err <= 0) { if (ifxmips_has_brn_block()) { - parts[4].size -= ifxmips_mtd->erasesize; - parts[5].offset = ifxmips_mtd->size - ifxmips_mtd->erasesize; - parts[5].size = ifxmips_mtd->erasesize; + parts[3].size -= ifxmips_mtd->erasesize; + parts[4].offset = ifxmips_mtd->size - ifxmips_mtd->erasesize; + parts[4].size = ifxmips_mtd->erasesize; + ifxmips_meta_partition.size -= ifxmips_mtd->erasesize; } else { num_parts--; } @@ -244,7 +249,7 @@ static int ifxmips_mtd_probe(struct platform_device *dev) add_mtd_partitions(ifxmips_mtd, &ifxmips_meta_partition, 1); printk(KERN_INFO "ifxmips_mtd: added %s flash with %dMB\n", - ifxmips_map.name, ifxmips_mtd->size >> 20); + ifxmips_map.name, ((int)ifxmips_mtd->size) >> 20); return 0; }