mtd: change the block number of RSV member into macro
authorYi Zeng <yi.zeng@amlogic.com>
Mon, 29 Jan 2018 06:31:14 +0000 (14:31 +0800)
committerJianxin Pan <jianxin.pan@amlogic.com>
Wed, 7 Mar 2018 06:55:04 +0000 (22:55 -0800)
PD#159810: mtd: change the block number of RSV member into macro

in case of customer want change the RSV part size, we'd better
make the block number of every part be a macro, in case miss modified
in somewhere.

Change-Id: I75e665cc3efd8b4bf4ad5a0843f855d4915ae180
Signed-off-by: Yi Zeng <yi.zeng@amlogic.com>
drivers/amlogic/mtd/aml_mtd.h
drivers/amlogic/mtd/boot.c
drivers/amlogic/mtd/rsv_manage.c

index 98f1247..501132d 100644 (file)
@@ -195,6 +195,12 @@ union nand_core_clk {
 #define BOOT_COPY_NUM (BOOT_TOTAL_PAGES / BOOT_PAGES_PER_COPY)
 /*it also means normal device start addrress */
 #define RESERVED_BLOCK_NUM 48
+/* reserved region info */
+#define NAND_GAP_BLOCK_NUM 4
+#define NAND_BBT_BLOCK_NUM 4
+#define NAND_ENV_BLOCK_NUM 8
+#define NAND_KEY_BLOCK_NUM 8
+#define NAND_DTB_BLOCK_NUM 4
 
 #define AML_CHIP_NONE_RB       4
 #define AML_INTERLEAVING_MODE  8
index e5677bc..d033130 100644 (file)
@@ -156,7 +156,7 @@ void __attribute__((unused)) nand_info_page_prepare(
        (bbt_size + mtd->writesize - 1) / mtd->writesize;
        p_ext_info->bbt_occupy_pages = bbt_pages;
        p_ext_info->bbt_start_block =
-               (BOOT_TOTAL_PAGES >> pages_per_blk_shift) + 4;
+               (BOOT_TOTAL_PAGES >> pages_per_blk_shift) + NAND_GAP_BLOCK_NUM;
        /* fill descrete infos */
        if (aml_chip->bl_mode) {
                p_fip_info->version = 1;
index 552b11b..8ae5cf6 100644 (file)
@@ -810,7 +810,7 @@ int aml_nand_rsv_info_init(struct mtd_info *mtd)
 
        /*bootloader occupy 1024 pages*/
        bbt_start_block = BOOT_TOTAL_PAGES >> pages_per_blk_shift;
-       bbt_start_block += 4; /*gap occupy 4 blocks*/
+       bbt_start_block += NAND_GAP_BLOCK_NUM; /*gap occupy 4 blocks*/
 
        aml_chip->rsv_data_buf = kzalloc(mtd->writesize, GFP_KERNEL);
        if (aml_chip->rsv_data_buf == NULL)
@@ -838,7 +838,7 @@ int aml_nand_rsv_info_init(struct mtd_info *mtd)
        aml_chip->aml_nandbbt_info->valid_node->phy_blk_addr = -1;
        aml_chip->aml_nandbbt_info->start_block = bbt_start_block;
        aml_chip->aml_nandbbt_info->end_block =
-               aml_chip->aml_nandbbt_info->start_block + 4;
+               aml_chip->aml_nandbbt_info->start_block + NAND_BBT_BLOCK_NUM;
        aml_chip->aml_nandbbt_info->size = mtd->size >> phys_erase_shift;
        memcpy(aml_chip->aml_nandbbt_info->name, BBT_NAND_MAGIC, 4);
 
@@ -867,7 +867,7 @@ int aml_nand_rsv_info_init(struct mtd_info *mtd)
        aml_chip->aml_nandenv_info->start_block =
                aml_chip->aml_nandbbt_info->end_block;
        aml_chip->aml_nandenv_info->end_block =
-               aml_chip->aml_nandbbt_info->end_block + 8;
+               aml_chip->aml_nandbbt_info->end_block + NAND_ENV_BLOCK_NUM;
        aml_chip->aml_nandenv_info->size = CONFIG_ENV_SIZE;
        memcpy(aml_chip->aml_nandenv_info->name, ENV_NAND_MAGIC, 4);
 
@@ -887,7 +887,7 @@ int aml_nand_rsv_info_init(struct mtd_info *mtd)
        aml_chip->aml_nandkey_info->start_block =
                aml_chip->aml_nandenv_info->end_block;
        aml_chip->aml_nandkey_info->end_block =
-               aml_chip->aml_nandenv_info->end_block + 8;
+               aml_chip->aml_nandenv_info->end_block + NAND_KEY_BLOCK_NUM;
        aml_chip->aml_nandkey_info->size = aml_chip->keysize;
        memcpy(aml_chip->aml_nandkey_info->name, KEY_NAND_MAGIC, 4);
 
@@ -907,7 +907,7 @@ int aml_nand_rsv_info_init(struct mtd_info *mtd)
        aml_chip->aml_nanddtb_info->start_block =
                aml_chip->aml_nandkey_info->end_block;
        aml_chip->aml_nanddtb_info->end_block =
-               aml_chip->aml_nandkey_info->end_block + 4;
+               aml_chip->aml_nandkey_info->end_block + NAND_DTB_BLOCK_NUM;
        aml_chip->aml_nanddtb_info->size = aml_chip->dtbsize;
        memcpy(aml_chip->aml_nanddtb_info->name, DTB_NAND_MAGIC, 4);