mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-07 11:26:02 +09:00
drivers: rkflash: Support NOR Flash to init MTD part list by default partition.
Change-Id: I108c6ea704307221a58e3a7cdf4d6dc83b153437 Signed-off-by: Dingqiang Lin <jon.lin@rock-chips.com>
This commit is contained in:
@@ -156,6 +156,17 @@ static int sfc_read_mtd(struct mtd_info *mtd, loff_t from, size_t len,
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* if not support rk_partition and partition is confirmed, you can define
|
||||
* strust def_nor_part by adding new partition like following example:
|
||||
* {"u-boot", 0x1000 * 512, 0x2000 * 512},
|
||||
* Note.
|
||||
* 1. New partition format {name. size, offset}
|
||||
* 2. Unit:Byte
|
||||
* 3. Last partition 'size' can be set 0xFFFFFFFFF to fully user left space.
|
||||
*/
|
||||
struct mtd_partition def_nor_part[] = {};
|
||||
|
||||
int sfc_nor_mtd_init(struct SFNOR_DEV *p_dev)
|
||||
{
|
||||
int ret, i, part_num = 0;
|
||||
@@ -204,13 +215,24 @@ int sfc_nor_mtd_init(struct SFNOR_DEV *p_dev)
|
||||
(u64)g_part->part[i].ui_pt_sz << 9;
|
||||
nor_parts[i].mask_flags = 0;
|
||||
}
|
||||
} else {
|
||||
part_num = ARRAY_SIZE(def_nor_part);
|
||||
for (i = 0; i < part_num; i++) {
|
||||
nor_parts[i].name =
|
||||
kstrdup(def_nor_part[i].name,
|
||||
GFP_KERNEL);
|
||||
if (def_nor_part[i].size == 0xFFFFFFFF)
|
||||
def_nor_part[i].size = (capacity << 9) -
|
||||
def_nor_part[i].offset;
|
||||
nor_parts[i].offset =
|
||||
def_nor_part[i].offset;
|
||||
nor_parts[i].size =
|
||||
def_nor_part[i].size;
|
||||
nor_parts[i].mask_flags = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
kfree(g_part);
|
||||
if (part_num == 0) {
|
||||
ret = -1;
|
||||
goto free_dma_buf;
|
||||
}
|
||||
ret = mtd_device_register(&p_dev->mtd, nor_parts, part_num);
|
||||
if (ret != 0)
|
||||
goto free_dma_buf;
|
||||
|
||||
Reference in New Issue
Block a user