From e96185199fdde59146608885ac1762a1121c72e9 Mon Sep 17 00:00:00 2001 From: Ruixuan Li Date: Tue, 8 Jun 2021 15:31:23 +0800 Subject: [PATCH] emmc: build fake bootloader0 & bootloader1 [1/1] PD#SWPL-52307 Problem: need bootloader0 & bootloader1 offset from 1 sector Solution: add fake partition Verify: passed on t3_t982 Signed-off-by: Ruixuan Li Change-Id: Iddac88632af72fb9251a19c4941efc9a29cd6b59 --- drivers/amlogic/mmc/emmc_partitions.c | 25 +++++++++++++++++++++++++ drivers/mmc/card/block.c | 8 ++++++++ include/linux/mmc/emmc_partitions.h | 1 + 3 files changed, 34 insertions(+) diff --git a/drivers/amlogic/mmc/emmc_partitions.c b/drivers/amlogic/mmc/emmc_partitions.c index ead579f276d4..f1c74c66229f 100644 --- a/drivers/amlogic/mmc/emmc_partitions.c +++ b/drivers/amlogic/mmc/emmc_partitions.c @@ -1342,6 +1342,31 @@ __ATTR(bl_off_bytes, 0444, get_bootloader_offset, NULL); * __ATTR(cdirq_cnt, S_IRUGO, get_cdirq_cnt, NULL); */ +int add_fake_boot_partition(struct gendisk *disk, char *name, int idx) +{ + u64 boot_size = (u64)get_capacity(disk) - 1; + char fake_name[80]; + int offset = 1; + struct hd_struct *ret = NULL; + struct disk_part_iter piter; + struct hd_struct *part; + + sprintf(fake_name, name, idx); + ret = add_emmc_each_part(disk, 1 + idx, + offset, boot_size, 0, fake_name); + if (IS_ERR(ret)) + pr_info("%s added failed\n", fake_name); + + disk_part_iter_init(&piter, disk, 0); + while ((part = disk_part_iter_next(&piter))) { + dev_set_uevent_suppress(part_to_dev(part), 0); + kobject_uevent(&part_to_dev(part)->kobj, KOBJ_ADD); + } + disk_part_iter_exit(&piter); + + return 0; +} + int aml_emmc_partition_ops(struct mmc_card *card, struct gendisk *disk) { int ret = 0; diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c index 7774489d89ab..a64e30a06eb1 100644 --- a/drivers/mmc/card/block.c +++ b/drivers/mmc/card/block.c @@ -3021,6 +3021,9 @@ static int mmc_blk_probe(struct mmc_card *card) { struct mmc_blk_data *md, *part_md; char cap_str[10]; +#ifdef CONFIG_AMLOGIC_MMC + int idx = 0; +#endif /* * Check that the card supports the command class(es) we need. @@ -3056,6 +3059,11 @@ static int mmc_blk_probe(struct mmc_card *card) list_for_each_entry(part_md, &md->part, part) { if (mmc_add_disk(part_md)) goto out; +#ifdef CONFIG_AMLOGIC_MMC + if (part_md->area_type == MMC_BLK_DATA_AREA_BOOT) + add_fake_boot_partition(part_md->disk, + "bootloader%d", idx++); +#endif } pm_runtime_set_autosuspend_delay(&card->dev, 3000); diff --git a/include/linux/mmc/emmc_partitions.h b/include/linux/mmc/emmc_partitions.h index 6cd4e6ac0b24..441a8d02d12b 100644 --- a/include/linux/mmc/emmc_partitions.h +++ b/include/linux/mmc/emmc_partitions.h @@ -67,6 +67,7 @@ struct mmc_partitions_fmt { }; /*#ifdef CONFIG_MMC_AML*/ int aml_emmc_partition_ops(struct mmc_card *card, struct gendisk *disk); +int add_fake_boot_partition(struct gendisk *disk, char *name, int idx); /* *#else *static inline int aml_emmc_partition_ops(struct mmc_card *card, -- 2.20.1