I am just wondering how it works.
And...source code is your answers.
I clone kernel source from cm-kernel
https://github.com/CyanogenMod/cm-kernel.git
branch: android-msm-2.6.37
- arch/arm/mach-msm/nand_partitions.c:
Extract partition information from ATAG setup by boot loader.
static int __init parse_tag_msm_partition(...)
{
....
msm_nand_data.nr_parts = count;
msm_nand_data.parts = msm_nand_partitions;
return 0;
}
This puts partition information into flash_platform_data
- drivers/mtd/devices/msm_nand.c (msm nand flash controller driver)
// request to use cmdlinepart parser
static const char *part_probes[] = { "cmdlinepart", NULL, };
...
static int __devinit msm_nand_probe(struct platform_device *pdev)
{
...
#ifdef CONFIG_MTD_PARTITIONS
err = parse_mtd_partitions(&info->mtd, part_probes,
&info->parts, 0);
// if kernel command line has partition information, use it!
if (err > 0)
add_mtd_partitions(&info->mtd, info->parts, err);
else if (err <= 0 && pdata && pdata->parts) {
// else use partition information from boot loader
for (i = 0; i < pdata->nr_parts; ++i) {
pdata->parts[i].offset *= info->mtd.erasesize;
pdata->parts[i].size *= info->mtd.erasesize;
}
add_mtd_partitions(&info->mtd,
pdata->parts, pdata->nr_parts);
} else
#endif
err = add_mtd_device(&info->mtd);
}