mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-10 21:07:02 +09:00
ODROID-COMMON: mmc: read MPT partition from a certain sector
Change-Id: Ibac5bb733270583f1a3a2ee7a24091c453261753 Signed-off-by: Dongjin Kim <tobetter@gmail.com>
This commit is contained in:
@@ -148,5 +148,7 @@ source "drivers/amlogic/pixel_probe/Kconfig"
|
||||
|
||||
source "drivers/amlogic/firmware/Kconfig"
|
||||
|
||||
source "drivers/amlogic/media_modules/Kconfig"
|
||||
|
||||
endmenu
|
||||
endif
|
||||
|
||||
@@ -145,3 +145,5 @@ obj-$(CONFIG_AMLOGIC_IRCUT) += ircut/
|
||||
obj-$(CONFIG_AMLOGIC_PIXEL_PROBE) += pixel_probe/
|
||||
|
||||
obj-$(CONFIG_AMLOGIC_FIRMWARE) += firmware/
|
||||
|
||||
obj-y += media_modules/
|
||||
|
||||
@@ -716,12 +716,17 @@ static int mmc_read_partition_tbl(struct mmc_card *card,
|
||||
memset(pt_fmt, 0, sizeof(struct mmc_partitions_fmt));
|
||||
memset(buf, 0, blk_size);
|
||||
|
||||
#if defined(CONFIG_ARCH_MESON64_ODROID_COMMON)
|
||||
/* LBA unit */
|
||||
start_blk = 2048;
|
||||
#else
|
||||
start_blk = get_reserve_partition_off(card);
|
||||
if (start_blk < 0) {
|
||||
ret = -EINVAL;
|
||||
goto exit_err;
|
||||
}
|
||||
start_blk >>= bit;
|
||||
#endif
|
||||
size = sizeof(struct mmc_partitions_fmt);
|
||||
dst = (char *)pt_fmt;
|
||||
if (size >= blk_size) {
|
||||
@@ -929,22 +934,38 @@ static int add_emmc_partition(struct gendisk *disk,
|
||||
uint64_t offset, size, cap;
|
||||
struct partitions *pp;
|
||||
struct proc_dir_entry *proc_card;
|
||||
#if defined(CONFIG_ARCH_MESON64_ODROID_COMMON)
|
||||
int shift = 0;
|
||||
#else
|
||||
int shift = 9;
|
||||
#endif
|
||||
int partno = 1;
|
||||
|
||||
pr_info("add_emmc_partition\n");
|
||||
|
||||
cap = get_capacity(disk); /* unit:512 bytes */
|
||||
for (i = 0; i < pt_fmt->part_num; i++) {
|
||||
pp = &(pt_fmt->partitions[i]);
|
||||
offset = pp->offset >> 9; /* unit:512 bytes */
|
||||
size = pp->size >> 9; /* unit:512 bytes */
|
||||
#if defined(CONFIG_ARCH_MESON64_ODROID_COMMON)
|
||||
if (pp->name[0] == '@') {
|
||||
/* It's hiden partition */
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
|
||||
offset = pp->offset >> shift; /* unit:512 bytes */
|
||||
size = pp->size >> shift; /* unit:512 bytes */
|
||||
if ((offset + size) <= cap) {
|
||||
ret = add_emmc_each_part(disk, 1+i, offset,
|
||||
ret = add_emmc_each_part(disk, partno, offset,
|
||||
size, 0, pp->name);
|
||||
|
||||
pr_info("[%sp%02d] %20s offset 0x%012llx, size 0x%012llx %s\n",
|
||||
disk->disk_name, 1+i,
|
||||
pp->name, offset<<9,
|
||||
size<<9, IS_ERR(ret) ? "add fail":"");
|
||||
disk->disk_name, partno,
|
||||
pp->name, offset<<shift,
|
||||
size << shift,
|
||||
IS_ERR(ret) ? "add fail":"");
|
||||
/* increase the partition number */
|
||||
partno++;
|
||||
} else {
|
||||
pr_info("[%s] %s: partition exceeds device capacity:\n",
|
||||
__func__, disk->disk_name);
|
||||
|
||||
@@ -3017,6 +3017,38 @@ static const struct mmc_fixup blk_fixups[] =
|
||||
END_FIXUP
|
||||
};
|
||||
|
||||
#ifdef CONFIG_AMLOGIC_MMC
|
||||
static int mmc_validate_mpt_partition(struct mmc_card *card)
|
||||
{
|
||||
char *buf;
|
||||
int ret;
|
||||
|
||||
/* check only if 'card' is eMMC device */
|
||||
if (strcmp(mmc_hostname(card->host), "emmc"))
|
||||
return -EINVAL;
|
||||
|
||||
buf = (char*)kmalloc(1 << card->csd.read_blkbits, GFP_KERNEL);
|
||||
if (buf == NULL)
|
||||
return -ENOMEM;
|
||||
|
||||
mmc_claim_host(card->host);
|
||||
|
||||
/* FIXME: fix up the magic number for start block to check MPT partition */
|
||||
ret = mmc_read_internal(card, 8184, 1, buf);
|
||||
if (ret == 0) {
|
||||
if (strncmp(buf, MMC_PARTITIONS_MAGIC,
|
||||
sizeof(((struct mmc_partitions_fmt*)0)->magic)) != 0) {
|
||||
ret = -EINVAL;
|
||||
}
|
||||
}
|
||||
|
||||
mmc_release_host(card->host);
|
||||
|
||||
kfree(buf);
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int mmc_blk_probe(struct mmc_card *card)
|
||||
{
|
||||
struct mmc_blk_data *md, *part_md;
|
||||
@@ -3049,8 +3081,10 @@ static int mmc_blk_probe(struct mmc_card *card)
|
||||
goto out;
|
||||
|
||||
#ifdef CONFIG_AMLOGIC_MMC
|
||||
/* amlogic add emmc partitions ops */
|
||||
aml_emmc_partition_ops(card, md->disk);
|
||||
if (mmc_validate_mpt_partition(card) == 0) {
|
||||
/* amlogic add emmc partitions ops */
|
||||
aml_emmc_partition_ops(card, md->disk);
|
||||
}
|
||||
#endif
|
||||
|
||||
list_for_each_entry(part_md, &md->part, part) {
|
||||
|
||||
Reference in New Issue
Block a user