|
| |
精品推荐 |
 |
|
| |
|
|
|
|
The Linux MTD, YAFFS Howto
|
日期:2008年6月4日 作者: 查看:[大字体
中字体 小字体]
|
1 The Linux MTD, YAFFS Howto User ProgramSystem Call InterfaceBlock Device InterfaceFIle System(jffs,yaffs)Virtual File SystemMTD Driver ModuleNAND FLASH MEMORYMTD ModuleUser ModuleDriver Module Picture 1-1 MTD System Organization 1.1 MTD Nand Device Driver Modify drivers/mtd/nand/nand.c and eos_nand.c(Copy spia.c). int __init eosnand_init (void) { struct nand_chip *this; *(volatile unsigned char *) 0x1ff00010 = 0x82; // Pin Mux Control Register set eos_writel(0x33002, NFMCON); // Nand Flash Memory Control Register set … this = (struct nand_chip *) (&eosnand_mtd[1]); … this->hwcontrol = eosnand_hwcontrol; // Device I/O Set this->chip_delay = 15; // delay set this->eccmode = NAND_ECC_SOFT; // ECC Use Set. // target nand flash ID search if (nand_scan (eosnand_mtd)) { kfree (eosnand_mtd); return -ENXIO; } // initialized eosnand_mtd registration add_mtd_partitions(eosnand_mtd, partition_info, NUM_PARTITIONS); return 0; } Code 1-1 eosnand_init() EOS Nand Flash Device I/O Setup Function Void eosnand_hwcontrol(int cmd) { switch(cmd){ case NAND_CTL_CLRNCE: // Nand Flash Enable eos_writel(eos_readl(NFMCON) & ~0x02, NFMCON); case NAND_CTL_SETNCE: // Nand Flash Disable eos_writel(eos_readl(NFMCON) 0x02, NFMCON); case NAND_CTL_CHKRB: // Nand Flash busy check { int temp; while(1) { temp = eos_readb(NFMSTAT); temp &= 0x01; if (temp) break; } } } } #define nand_select() this->hwcontrol(NAND_CTL_SETNCE); #define nand_deselect() this->hwcontrol(NAND_CTL_CLRNCE); #define nand_busy() this->hwcontrol(NAND_CTL_CHKRB); Code 1-2 eosnand_hwcontrol() Next, Manufacture ID read and additional hardware initializing function. int nand_scan (struct mtd_info *mtd) { int i, nand_maf_id, nand_dev_id; struct nand_chip *this = mtd->priv; // check for proper chip_delay setup, set 20us if not if (!this->chip_delay) this->chip_delay = 20; // check, if a user supplied command function given if (this->cmdfunc == NULL) this->cmdfunc = nand_command; … nand_select(); // Nand Chip Enable // Function to read Device ID. this->cmdfunc (mtd, NAND_CMD_READID, 0x00, -1); // Manufacture ID and Device ID read. nand_maf_id = eos_readb (NFMDATA); nand_dev_id = eos_readb (NFMDATA); // Save Device information. for (i = 0; nand_flash_ids[i].name != NULL; i++) { if (nand_dev_id == nand_flash_ids[i].id && !mtd->size) { … }
上一篇:编程使用系统热键{演示RegisterHotKey()和UnregisterHotKey()}
下一篇:14.6.5 Prefix in- and decrement operators
|
| 相关文章: |
|
|
|
| 相关软件: |
|
|
|
|