4 #include <linux/mtd/mtd.h>
5 #include <linux/mtd/nand.h>
6 #include <mach/mtk_nand.h>
8 #define MAX_BMT_SIZE (0x200) //0x80
9 #define BMT_VERSION (1) // initial version
11 #define MAIN_SIGNATURE_OFFSET (0)
12 #define OOB_SIGNATURE_OFFSET (1)
13 #define OOB_INDEX_OFFSET (29)
14 #define OOB_INDEX_SIZE (2)
15 #define FAKE_INDEX (0xAAAA)
17 typedef struct _bmt_entry_
19 u16 bad_index
; // bad block index
20 u16 mapped_index
; // mapping block index in the replace pool
27 UPDATE_UNMAPPED_BLOCK
,
33 bmt_entry table
[MAX_BMT_SIZE
];
35 u8 mapped_count
; // mapped block count in pool
36 u8 bad_count
; // bad block count in pool. Not used in V1
39 /***************************************************************
41 * Interface BMT need to use *
43 ***************************************************************/
44 //extern bool mtk_nand_exec_read_page(struct mtd_info *mtd, u32 row, u32 page_size, u8 * dat, u8 * oob);
45 extern int mtk_nand_exec_read_page(struct mtd_info
*mtd
, u32 u4RowAddr
, u32 u4PageSize
, u8
* pPageBuf
, u8
* pFDMBuf
);
46 extern int mtk_nand_block_bad_hw(struct mtd_info
*mtd
, loff_t ofs
);
47 extern int mtk_nand_erase_hw(struct mtd_info
*mtd
, int page
);
48 extern int mtk_nand_block_markbad_hw(struct mtd_info
*mtd
, loff_t ofs
);
49 extern int mtk_nand_exec_write_page(struct mtd_info
*mtd
, u32 row
, u32 page_size
, u8
* dat
, u8
* oob
);
52 /***************************************************************
54 * Different function interface for preloader/uboot/kernel *
56 ***************************************************************/
57 void set_bad_index_to_oob(u8
* oob
, u16 index
);
60 bmt_struct
*init_bmt(struct nand_chip
*nand
, int size
);
61 bool update_bmt(u64 offset
, update_reason_t reason
, u8
* dat
, u8
* oob
);
62 unsigned short get_mapping_block_index(int index
);
64 #endif // #ifndef __BMT_H__