author | Ruixuan Li <ruixuan.li@amlogic.com> | 2018-06-14 12:21:50 (GMT) |
---|---|---|
committer | Yixun Lan <yixun.lan@amlogic.com> | 2018-08-10 07:25:06 (GMT) |
commit | 8842daf8de22f7b38609bbd50e2379c0c8164dc9 (patch) | |
tree | ad6c9a55c51a9e79183fd66769116c947c457700 | |
parent | 5be8b6507f7fd570617e331bda05bf11968120c3 (diff) | |
download | common-8842daf8de22f7b38609bbd50e2379c0c8164dc9.zip common-8842daf8de22f7b38609bbd50e2379c0c8164dc9.tar.gz common-8842daf8de22f7b38609bbd50e2379c0c8164dc9.tar.bz2 |
emmc: upgrade gpt or ept based on priority
PD#168362: P211: emmc: upgrade gpt or ept based on priority
Change-Id: I0e7ea483ac5fc0a59ee24ae21d2e40e1c5d32465
Signed-off-by: Ruixuan Li <ruixuan.li@amlogic.com>
-rw-r--r-- | block/partition-generic.c | 22 | ||||
-rw-r--r-- | drivers/amlogic/mmc/emmc_partitions.c | 59 |
2 files changed, 76 insertions, 5 deletions
diff --git a/block/partition-generic.c b/block/partition-generic.c index 298c05f..d2582d8 100644 --- a/block/partition-generic.c +++ b/block/partition-generic.c @@ -24,7 +24,8 @@ #ifdef CONFIG_BLK_DEV_MD extern void md_autodetect_dev(dev_t dev); #endif - + +#define AMLOGIC_ADD_PARTITION /* * disk_name() is used by partition check code and the genhd driver. * It formats the devicename of the indicated disk into @@ -289,7 +290,9 @@ struct hd_struct *add_partition(struct gendisk *disk, int partno, struct disk_part_tbl *ptbl; const char *dname; int err; - +#ifdef AMLOGIC_ADD_PARTITION + char *info_name = NULL; +#endif err = disk_expand_part_tbl(disk, partno); if (err) return ERR_PTR(err); @@ -330,10 +333,25 @@ struct hd_struct *add_partition(struct gendisk *disk, int partno, } dname = dev_name(ddev); + +#ifdef AMLOGIC_ADD_PARTITION + if (info) { + info_name = (char *)info->volname; + } + + if (info_name && (strlen(info_name) > 1)) { + dname = (char *)info->volname; + dev_set_name(pdev, "%s", dname); + } else if (isdigit(dname[strlen(dname) - 1])) + dev_set_name(pdev, "%sp%d", dname, partno); + else + dev_set_name(pdev, "%s%d", dname, partno); +#else if (isdigit(dname[strlen(dname) - 1])) dev_set_name(pdev, "%sp%d", dname, partno); else dev_set_name(pdev, "%s%d", dname, partno); +#endif device_initialize(pdev); pdev->class = &block_class; diff --git a/drivers/amlogic/mmc/emmc_partitions.c b/drivers/amlogic/mmc/emmc_partitions.c index 00c4962..b6340aa 100644 --- a/drivers/amlogic/mmc/emmc_partitions.c +++ b/drivers/amlogic/mmc/emmc_partitions.c @@ -51,6 +51,8 @@ #define MAX_TRANS_SIZE (MAX_TRANS_BLK * DTB_BLK_SIZE) #define stamp_after(a, b) ((int)(b) - (int)(a) < 0) +#define GPT_HEADER_SIGNATURE 0x5452415020494645ULL + struct aml_dtb_rsv { u8 data[DTB_BLK_SIZE*DTB_BLK_CNT - 4*sizeof(unsigned int)]; unsigned int magic; @@ -64,6 +66,27 @@ struct aml_dtb_info { u8 valid[2]; }; +struct efi_guid_t { + u8 b[16]; +}; + +struct gpt_header { + __le64 signature; + __le32 revision; + __le32 header_size; + __le32 header_crc32; + __le32 reserved1; + __le64 my_lba; + __le64 alternate_lba; + __le64 first_usable_lba; + __le64 last_usable_lba; + struct efi_guid_t disk_guid; + __le64 partition_entry_lba; + __le32 num_partition_entries; + __le32 sizeof_partition_entry; + __le32 partition_entry_array_crc32; +}; + static dev_t amlmmc_dtb_no; struct cdev amlmmc_dtb; struct device *dtb_dev; @@ -1150,23 +1173,53 @@ int aml_emmc_partition_ops(struct mmc_card *card, struct gendisk *disk) struct disk_part_iter piter; struct hd_struct *part; struct class *aml_store_class = NULL; + struct gpt_header *gpt_h = NULL; + unsigned char *buffer = NULL; + unsigned int pgcnt; + struct page *page = NULL; pr_info("Enter %s\n", __func__); - if (!is_card_emmc(card)) /* not emmc, nothing to do */ + if (is_card_emmc(card) == 0) /* not emmc, nothing to do */ + return 0; + + pgcnt = PAGE_ALIGN(512) >> PAGE_SHIFT; + page = dma_alloc_from_contiguous(NULL, pgcnt, get_order(512)); + + if (!page) + return -ENOMEM; + buffer = page_address(page); + + mmc_claim_host(card->host); + + /*self adapting*/ + ret = mmc_read_internal(card, 1, 1, buffer); + if (ret) { + pr_err("%s: save dtb error", __func__); + goto out; + } + + gpt_h = (struct gpt_header *) buffer; + + if (le64_to_cpu(gpt_h->signature) == GPT_HEADER_SIGNATURE) { + dma_release_from_contiguous(NULL, page, pgcnt); + mmc_release_host(card->host); return 0; + } + + dma_release_from_contiguous(NULL, page, pgcnt); store_device = host->storage_flag; + pt_fmt = kmalloc(sizeof(struct mmc_partitions_fmt), GFP_KERNEL); if (pt_fmt == NULL) { /* pr_info( * "[%s] malloc failed for struct mmc_partitions_fmt!\n", * __func__); */ + mmc_release_host(card->host); return -ENOMEM; } - - mmc_claim_host(card->host); disk_part_iter_init(&piter, disk, DISK_PITER_INCL_EMPTY); while ((part = disk_part_iter_next(&piter))) { |