This patchs enables the usage of mtd partitions passed as platform data from platform setup functions.
Index: target/linux/ifxmips/files/drivers/mtd/maps/ifxmips.c =================================================================== --- target/linux/ifxmips/files/drivers/mtd/maps/ifxmips.c (revision 24118) +++ target/linux/ifxmips/files/drivers/mtd/maps/ifxmips.c (working copy) @@ -24,6 +24,7 @@ #include <linux/init.h> #include <linux/mtd/mtd.h> #include <linux/mtd/map.h> +#include <linux/mtd/physmap.h> #include <linux/mtd/partitions.h> #include <linux/mtd/cfi.h> #include <linux/magic.h> @@ -93,7 +94,7 @@ spin_unlock_irqrestore(&ebu_lock, flags); } -static struct mtd_partition ifxmips_partitions[] = { +static struct mtd_partition default_ifxmips_partitions[] = { { .name = "uboot", .offset = 0x00000000, @@ -168,8 +169,9 @@ struct mtd_partition *parts = NULL; unsigned long uimage_size; int err, i; - int kernel_part = 2, rootfs_part = 3; - int num_parts = ARRAY_SIZE(ifxmips_partitions); + int kernel_part = -1, rootfs_part = -1; + int num_parts = (dev->dev.platform_data ? ((struct physmap_flash_data *)(dev->dev.platform_data))->nr_parts : ARRAY_SIZE(default_ifxmips_partitions)); + struct mtd_partition *ifxmips_partitions = (dev->dev.platform_data ? ((struct physmap_flash_data *)(dev->dev.platform_data))->parts : default_ifxmips_partitions); ifxmips_w32(0x1d7ff, IFXMIPS_EBU_BUSCON0); @@ -208,10 +210,16 @@ 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; + for (i = 0; i < num_parts; i++) { + if (strcmp(ifxmips_partitions[i].name, "kernel") == 0) + kernel_part = i; + if (strcmp(ifxmips_partitions[i].name, "rootfs") == 0) + rootfs_part = i; + } + if ((kernel_part != -1) && (!ifxmips_partitions[kernel_part].size)) + ifxmips_partitions[kernel_part].size = ifxmips_mtd->erasesize; + if ((rootfs_part != -1) && (!ifxmips_partitions[rootfs_part].offset)) + ifxmips_partitions[rootfs_part].offset = ifxmips_partitions[kernel_part].offset + ifxmips_mtd->erasesize; parts = &ifxmips_partitions[0]; } @@ -228,20 +236,29 @@ parts[kernel_part].size = uimage_size; parts[rootfs_part].offset = parts[kernel_part].offset + parts[kernel_part].size; - parts[rootfs_part].size = ((ifxmips_mtd->size >> 20) * 1024 * 1024) - parts[rootfs_part].offset; + if ((rootfs_part+1 < num_parts) && (parts[rootfs_part+1].offset)) + parts[rootfs_part].size = parts[rootfs_part+1].offset - parts[rootfs_part].offset; + else + parts[rootfs_part].size = ((ifxmips_mtd->size >> 20) * 1024 * 1024) - parts[rootfs_part].offset; ifxmips_meta_partition.offset = parts[kernel_part].offset; ifxmips_meta_partition.size = parts[kernel_part].size + parts[rootfs_part].size; } if (err <= 0) { - if (ifxmips_has_brn_block()) { - 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--; + if (rootfs_part+1 < num_parts){ +#if defined CONFIG_IFXMIPS_ARCAYDIAN_BRNBOOT + if (ifxmips_has_brn_block()) { + if (!parts[rootfs_part+1].offset){ + parts[rootfs_part].size -= ifxmips_mtd->erasesize; + ifxmips_meta_partition.size -= ifxmips_mtd->erasesize; + parts[rootfs_part+1].offset = ifxmips_mtd->size - ifxmips_mtd->erasesize; + } + parts[rootfs_part+1].size = ifxmips_mtd->erasesize; + } + else +#endif + num_parts--; } }
_______________________________________________ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel