參考其它的ARM的NAND FLASH驅動,發現別人的NAND FLASH是采用一個表格來檢測不同的NAND FLASH,現在已經移植到S3C2410中了。測試也是OK滴。。。只測試過64M的NAND FLASH,我想1G也是差不多滴,只需要看看SPEC。就知道怎麼去做了。
這是S3C2410下的NAND FLASH驅動表格:
#define BW_X08 0
#define BW_X16 1
#define BW_X32 2
/*****************************************************************************/
/* S2410 Internal Data Structure Definition */
/*****************************************************************************/
typedef struct
{
UINT16 nMID; /* Manufacturer ID */
UINT16 nDID; /* Device ID */
UINT16 nNumOfBlks; /* Number of Blocks */
UINT16 nPgsPerBlk; /* Number of Pages per block */
UINT16 nSctsPerPg; /* Number of Sectors per page */
UINT16 nNumOfPlanes; /* Number of Planes */
UINT16 nBlksInRsv; /* The Number of Blocks in Reservior for Bad Blocks */
UINT8 nBadPos; /* BadBlock Information Poisition*/
UINT8 nLsnPos; /* LSN Position */
UINT8 nECCPos; /* ECC Policy : HW_ECC, SW_ECC */
UINT16 nBWidth; /* Nand Organization X8 or X16 */
} S2410Spec;
static S2410Spec astNandSpec[] = {
/*************************************************************************/
/* nMID, nDID, */
/* nNumOfBlks */
/* nPgsPerBlk */
/* nSctsPerPg */
/* nNumOfPlanes */
/* nBlksInRsv */
/* nBadPos */
/* nLsnPos */
/* nECCPos */
/* nBWidth */
/*************************************************************************/
/* 8Gbit DDP NAND Flash */
{ 0xEC, 0xD3, 8192, 64, 4, 2,160, 0, 2, 8, BW_X08},
/* 4Gbit DDP NAND Flash */
{ 0xEC, 0xAC, 4096, 64, 4, 2, 80, 0, 2, 8, BW_X08},
{ 0xEC, 0xDC, 4096, 64, 4, 2, 80, 0, 2, 8, BW_X08},
//{ 0xEC, 0xBC, 4096, 64, 4, 2, 80, 0, 2, 8, BW_X16},
//{ 0xEC, 0xCC, 4096, 64, 4, 2, 80, 0, 2, 8, BW_X16},
/* 2Gbit NAND Flash */
{ 0xEC, 0xAA, 2048, 64, 4, 1, 40, 0, 2, 8, BW_X08},
{ 0xEC, 0xDA, 2048, 64, 4, 1, 40, 0, 2, 8, BW_X08},
//{ 0xEC, 0xBA, 2048, 64, 4, 1, 40, 0, 2, 8, BW_X16},
//{ 0xEC, 0xCA, 2048, 64, 4, 1, 40, 0, 2, 8, BW_X16},
/* 2Gbit DDP NAND Flash */
{ 0xEC, 0xDA, 2048, 64, 4, 2, 40, 0, 2, 8, BW_X08},
{ 0xEC, 0xAA, 2048, 64, 4, 2, 40, 0, 2, 8, BW_X08},
//{ 0xEC, 0xBA, 2048, 64, 4, 2, 40, 0, 2, 8, BW_X16},
//{ 0xEC, 0xCA, 2048, 64, 4, 2, 40, 0, 2, 8, BW_X16},
/*1Gbit NAND Flash */
{ 0xEC, 0xA1, 1024, 64, 4, 1, 20, 0, 2, 8, BW_X08},
{ 0xEC, 0xF1, 1024, 64, 4, 1, 20, 0, 2, 8, BW_X08},
//{ 0xEC, 0xB1, 1024, 64, 4, 1, 20, 0, 2, 8, BW_X16},
//{ 0xEC, 0xC1, 1024, 64, 4, 1, 20, 0, 2, 8, BW_X16},
/* 1Gbit NAND Flash */
{ 0xEC, 0x79, 8192, 32, 1, 4,120, 5, 0, 6, BW_X08},
{ 0xEC, 0x78, 8192, 32, 1, 4,120, 5, 0, 6, BW_X08},
//{ 0xEC, 0x74, 8192, 32, 1, 4,120,11, 0, 6, BW_X16},
//{ 0xEC, 0x72, 8192, 32, 1, 4,120,11, 0, 6, BW_X16},
/* 512Mbit NAND Flash */
{ 0xEC, 0x76, 4096, 32, 1, 4, 70, 5, 0, 6, BW_X08},
{ 0xEC, 0x36, 4096, 32, 1, 4, 70, 5, 0, 6, BW_X08},
//{ 0xEC, 0x56, 4096, 32, 1, 4, 70,11, 0, 6, BW_X16},
//{ 0xEC, 0x46, 4096, 32, 1, 4, 70,11, 0, 6, BW_X16},
/* 256Mbit NAND Flash */
{ 0xEC, 0x75, 2048, 32, 1, 1, 35, 5, 0, 6, BW_X08},
{ 0xEC, 0x35, 2048, 32, 1, 1, 35, 5, 0, 6, BW_X08},
//{ 0xEC, 0x55, 2048, 32, 1, 1, 35,11, 0, 6, BW_X16},
//{ 0xEC, 0x45, 2048, 32, 1, 1, 35,11, 0, 6, BW_X16},
/* 128Mbit NAND Flash */
{ 0xEC, 0x73, 1024, 32, 1, 1, 20, 5, 0, 6, BW_X08},
{ 0xEC, 0x33, 1024, 32, 1, 1, 20, 5, 0, 6, BW_X08},
//{ 0xEC, 0x53, 1024, 32, 1, 1, 20,11, 0, 6, BW_X16},
//{ 0xEC, 0x43, 1024, 32, 1, 1, 20,11, 0, 6, BW_X16},
{ 0x00, 0x00, 0, 0, 0, 0, 0, 0, 0, 0, 0}
};
嘿嘿,總算是搞定NAND FLASH的編程了。可以支持64M到1GB的FLASH了。可以直接換IC即可。不需要更換驅動程序。在驅動中作了一個表格,從64M的到1GB的芯片信息全部在這個表格中,驅動采用查表得方式找到對應的IC。從而確定需要支持多大的NAND FLASH。。S3C2410的驅動和S3C2440的驅動還是有很多不一樣的地方,相比較而言。。。S3C2440的驅動好寫些。而S3C2410的不太好寫。特別是ECC的校驗。方式有點不一樣。寫法也不一樣。前期老是出現:WARNING: OEMPlatformInit failed to initialize Boot Media。很頭痛。後來仔細分析了這兩顆IC發現寄存器還是有點不一樣呀。汗顏啦。不動手實踐,還是不知道答案滴。行動產生效率。