?? u-boot-lfc.patch
字號:
- /* If the parity is wrong, no rescue possible */- return parity ? -1 : nerr;-}--static void DoC_Delay(struct doc_priv *doc, unsigned short cycles)-{- volatile char dummy;- int i;-- for (i = 0; i < cycles; i++) {- if (DoC_is_Millennium(doc))- dummy = ReadDOC(doc->virtadr, NOP);- else if (DoC_is_MillenniumPlus(doc))- dummy = ReadDOC(doc->virtadr, Mplus_NOP);- else- dummy = ReadDOC(doc->virtadr, DOCStatus);- }--}--#define CDSN_CTRL_FR_B_MASK (CDSN_CTRL_FR_B0 | CDSN_CTRL_FR_B1)--/* DOC_WaitReady: Wait for RDY line to be asserted by the flash chip */-static int _DoC_WaitReady(struct doc_priv *doc)-{- void __iomem *docptr = doc->virtadr;- unsigned long timeo = jiffies + (HZ * 10);-- if(debug) printk("_DoC_WaitReady...\n");- /* Out-of-line routine to wait for chip response */- if (DoC_is_MillenniumPlus(doc)) {- while ((ReadDOC(docptr, Mplus_FlashControl) & CDSN_CTRL_FR_B_MASK) != CDSN_CTRL_FR_B_MASK) {- if (time_after(jiffies, timeo)) {- printk("_DoC_WaitReady timed out.\n");- return -EIO;- }- udelay(1);- cond_resched();- }- } else {- while (!(ReadDOC(docptr, CDSNControl) & CDSN_CTRL_FR_B)) {- if (time_after(jiffies, timeo)) {- printk("_DoC_WaitReady timed out.\n");- return -EIO;- }- udelay(1);- cond_resched();- }- }-- return 0;-}--static inline int DoC_WaitReady(struct doc_priv *doc)-{- void __iomem *docptr = doc->virtadr;- int ret = 0;-- if (DoC_is_MillenniumPlus(doc)) {- DoC_Delay(doc, 4);-- if ((ReadDOC(docptr, Mplus_FlashControl) & CDSN_CTRL_FR_B_MASK) != CDSN_CTRL_FR_B_MASK)- /* Call the out-of-line routine to wait */- ret = _DoC_WaitReady(doc);- } else {- DoC_Delay(doc, 4);-- if (!(ReadDOC(docptr, CDSNControl) & CDSN_CTRL_FR_B))- /* Call the out-of-line routine to wait */- ret = _DoC_WaitReady(doc);- DoC_Delay(doc, 2);- }-- if(debug) printk("DoC_WaitReady OK\n");- return ret;-}--static void doc2000_write_byte(struct mtd_info *mtd, u_char datum)-{- struct nand_chip *this = mtd->priv;- struct doc_priv *doc = this->priv;- void __iomem *docptr = doc->virtadr;-- if(debug)printk("write_byte %02x\n", datum);- WriteDOC(datum, docptr, CDSNSlowIO);- WriteDOC(datum, docptr, 2k_CDSN_IO);-}--static u_char doc2000_read_byte(struct mtd_info *mtd)-{- struct nand_chip *this = mtd->priv;- struct doc_priv *doc = this->priv;- void __iomem *docptr = doc->virtadr;- u_char ret;-- ReadDOC(docptr, CDSNSlowIO);- DoC_Delay(doc, 2);- ret = ReadDOC(docptr, 2k_CDSN_IO);- if (debug) printk("read_byte returns %02x\n", ret);- return ret;-}--static void doc2000_writebuf(struct mtd_info *mtd,- const u_char *buf, int len)-{- struct nand_chip *this = mtd->priv;- struct doc_priv *doc = this->priv;- void __iomem *docptr = doc->virtadr;- int i;- if (debug)printk("writebuf of %d bytes: ", len);- for (i=0; i < len; i++) {- WriteDOC_(buf[i], docptr, DoC_2k_CDSN_IO + i);- if (debug && i < 16)- printk("%02x ", buf[i]);- }- if (debug) printk("\n");-}--static void doc2000_readbuf(struct mtd_info *mtd,- u_char *buf, int len)-{- struct nand_chip *this = mtd->priv;- struct doc_priv *doc = this->priv;- void __iomem *docptr = doc->virtadr;- int i;-- if (debug)printk("readbuf of %d bytes: ", len);-- for (i=0; i < len; i++) {- buf[i] = ReadDOC(docptr, 2k_CDSN_IO + i);- }-}--static void doc2000_readbuf_dword(struct mtd_info *mtd,- u_char *buf, int len)-{- struct nand_chip *this = mtd->priv;- struct doc_priv *doc = this->priv;- void __iomem *docptr = doc->virtadr;- int i;-- if (debug) printk("readbuf_dword of %d bytes: ", len);-- if (unlikely((((unsigned long)buf)|len) & 3)) {- for (i=0; i < len; i++) {- *(uint8_t *)(&buf[i]) = ReadDOC(docptr, 2k_CDSN_IO + i);- }- } else {- for (i=0; i < len; i+=4) {- *(uint32_t*)(&buf[i]) = readl(docptr + DoC_2k_CDSN_IO + i);- }- }-}--static int doc2000_verifybuf(struct mtd_info *mtd,- const u_char *buf, int len)-{- struct nand_chip *this = mtd->priv;- struct doc_priv *doc = this->priv;- void __iomem *docptr = doc->virtadr;- int i;-- for (i=0; i < len; i++)- if (buf[i] != ReadDOC(docptr, 2k_CDSN_IO))- return -EFAULT;- return 0;-}--static uint16_t __init doc200x_ident_chip(struct mtd_info *mtd, int nr)-{- struct nand_chip *this = mtd->priv;- struct doc_priv *doc = this->priv;- uint16_t ret;-- doc200x_select_chip(mtd, nr);- doc200x_hwcontrol(mtd, NAND_CTL_SETCLE);- this->write_byte(mtd, NAND_CMD_READID);- doc200x_hwcontrol(mtd, NAND_CTL_CLRCLE);- doc200x_hwcontrol(mtd, NAND_CTL_SETALE);- this->write_byte(mtd, 0);- doc200x_hwcontrol(mtd, NAND_CTL_CLRALE);-- ret = this->read_byte(mtd) << 8;- ret |= this->read_byte(mtd);-- if (doc->ChipID == DOC_ChipID_Doc2k && try_dword && !nr) {- /* First chip probe. See if we get same results by 32-bit access */- union {- uint32_t dword;- uint8_t byte[4];- } ident;- void __iomem *docptr = doc->virtadr;-- doc200x_hwcontrol(mtd, NAND_CTL_SETCLE);- doc2000_write_byte(mtd, NAND_CMD_READID);- doc200x_hwcontrol(mtd, NAND_CTL_CLRCLE);- doc200x_hwcontrol(mtd, NAND_CTL_SETALE);- doc2000_write_byte(mtd, 0);- doc200x_hwcontrol(mtd, NAND_CTL_CLRALE);-- ident.dword = readl(docptr + DoC_2k_CDSN_IO);- if (((ident.byte[0] << 8) | ident.byte[1]) == ret) {- printk(KERN_INFO "DiskOnChip 2000 responds to DWORD access\n");- this->read_buf = &doc2000_readbuf_dword;- }- }-- return ret;-}--static void __init doc2000_count_chips(struct mtd_info *mtd)-{- struct nand_chip *this = mtd->priv;- struct doc_priv *doc = this->priv;- uint16_t mfrid;- int i;-- /* Max 4 chips per floor on DiskOnChip 2000 */- doc->chips_per_floor = 4;-- /* Find out what the first chip is */- mfrid = doc200x_ident_chip(mtd, 0);-- /* Find how many chips in each floor. */- for (i = 1; i < 4; i++) {- if (doc200x_ident_chip(mtd, i) != mfrid)- break;- }- doc->chips_per_floor = i;- printk(KERN_DEBUG "Detected %d chips per floor.\n", i);-}--static int doc200x_wait(struct mtd_info *mtd, struct nand_chip *this, int state)-{- struct doc_priv *doc = this->priv;-- int status;-- DoC_WaitReady(doc);- this->cmdfunc(mtd, NAND_CMD_STATUS, -1, -1);- DoC_WaitReady(doc);- status = (int)this->read_byte(mtd);-- return status;-}--static void doc2001_write_byte(struct mtd_info *mtd, u_char datum)-{- struct nand_chip *this = mtd->priv;- struct doc_priv *doc = this->priv;- void __iomem *docptr = doc->virtadr;-- WriteDOC(datum, docptr, CDSNSlowIO);- WriteDOC(datum, docptr, Mil_CDSN_IO);- WriteDOC(datum, docptr, WritePipeTerm);-}--static u_char doc2001_read_byte(struct mtd_info *mtd)-{- struct nand_chip *this = mtd->priv;- struct doc_priv *doc = this->priv;- void __iomem *docptr = doc->virtadr;-- /*ReadDOC(docptr, CDSNSlowIO); */- /* 11.4.5 -- delay twice to allow extended length cycle */- DoC_Delay(doc, 2);- ReadDOC(docptr, ReadPipeInit);- /*return ReadDOC(docptr, Mil_CDSN_IO); */- return ReadDOC(docptr, LastDataRead);-}--static void doc2001_writebuf(struct mtd_info *mtd,- const u_char *buf, int len)-{- struct nand_chip *this = mtd->priv;- struct doc_priv *doc = this->priv;- void __iomem *docptr = doc->virtadr;- int i;-- for (i=0; i < len; i++)- WriteDOC_(buf[i], docptr, DoC_Mil_CDSN_IO + i);- /* Terminate write pipeline */- WriteDOC(0x00, docptr, WritePipeTerm);-}--static void doc2001_readbuf(struct mtd_info *mtd,- u_char *buf, int len)-{- struct nand_chip *this = mtd->priv;- struct doc_priv *doc = this->priv;- void __iomem *docptr = doc->virtadr;- int i;-- /* Start read pipeline */- ReadDOC(docptr, ReadPipeInit);-- for (i=0; i < len-1; i++)- buf[i] = ReadDOC(docptr, Mil_CDSN_IO + (i & 0xff));-- /* Terminate read pipeline */- buf[i] = ReadDOC(docptr, LastDataRead);-}--static int doc2001_verifybuf(struct mtd_info *mtd,- const u_char *buf, int len)-{- struct nand_chip *this = mtd->priv;- struct doc_priv *doc = this->priv;- void __iomem *docptr = doc->virtadr;- int i;-- /* Start read pipeline */- ReadDOC(docptr, ReadPipeInit);-- for (i=0; i < len-1; i++)- if (buf[i] != ReadDOC(docptr, Mil_CDSN_IO)) {- ReadDOC(docptr, LastDataRead);- return i;- }- if (buf[i] != ReadDOC(docptr, LastDataRead))- return i;- return 0;-}--static u_char doc2001plus_read_byte(struct mtd_info *mtd)-{- struct nand_chip *this = mtd->priv;- struct doc_priv *doc = this->priv;- void __iomem *docptr = doc->virtadr;- u_char ret;-- ReadDOC(docptr, Mplus_ReadPipeInit);- ReadDOC(docptr, Mplus_ReadPipeInit);- ret = ReadDOC(docptr, Mplus_LastDataRead);- if (debug) printk("read_byte returns %02x\n", ret);- return ret;-}--static void doc2001plus_writebuf(struct mtd_info *mtd,- const u_char *buf, int len)-{- struct nand_chip *this = mtd->priv;- struct doc_priv *doc = this->priv;- void __iomem *docptr = doc->virtadr;- int i;-- if (debug)printk("writebuf of %d bytes: ", len);- for (i=0; i < len; i++) {- WriteDOC_(buf[i], docptr, DoC_Mil_CDSN_IO + i);- if (debug && i < 16)- printk("%02x ", buf[i]);- }- if (debug) printk("\n");-}--static void doc2001plus_readbuf(struct mtd_info *mtd,- u_char *buf, int len)-{- struct nand_chip *this = mtd->priv;- struct doc_priv *doc = this->priv;- void __iomem *docptr = doc->virtadr;- int i;-- if (debug)printk("readbuf of %d bytes: ", len);-- /* Start read pipeline */- ReadDOC(docptr, Mplus_ReadPipeInit);- ReadDOC(docptr, Mplus_ReadPipeInit);-- for (i=0; i < len-2; i++) {- buf[i] = ReadDOC(docptr, Mil_CDSN_IO);- if (debug && i < 16)- printk("%02x ", buf[i]);- }-- /* Terminate read pipeline */- buf[len-2] = ReadDOC(docptr, Mplus_LastDataRead);- if (debug && i < 16)- printk("%02x ", buf[len-2]);- buf[len-1] = ReadDOC(docptr, Mplus_LastDataRead);- if (debug && i < 16)- printk("%02x ", buf[len-1]);- if (debug) printk("\n");-}--static int doc2001plus_verifybuf(struct mtd_info *mtd,- const u_char *buf, int len)-{- struct nand_chip *this = mtd->priv;- struct doc_priv *doc = this->priv;- void __iomem *docptr = doc->virtadr;- int i;-- if (debug)printk("verifybuf of %d bytes: ", len);-- /* Start read pipeline */- ReadDOC(docptr, Mplus_ReadPipeInit);- ReadDOC(docptr, Mplus_ReadPipeInit);-- for (i=0; i < len-2; i++)- if (buf[i] != ReadDOC(docptr, Mil_CDSN_IO)) {- ReadDOC(docptr, Mplus_LastDataRead);- ReadDOC(docptr, Mplus_LastDataRead);- return i;- }- if (buf[len-2] != ReadDOC(docptr, Mplus_LastDataRead))- return len-2;- if (buf[len-1] != ReadDOC(docptr, Mplus_LastDataRead))- return len-1;- return 0;-}--static void doc2001plus_select_chip(struct mtd_info *mtd, int chip)-{- struct nand_chip *this = mtd->priv;- struct doc_priv *doc = this->priv;- void __iomem *docptr = doc->virtadr;- int floor = 0;-- if(debug)printk("select chip (%d)\n", chip);-- if (chip == -1) {- /* Disable flash internally */- WriteDOC(0, docptr, Mplus_FlashSelect);- return;- }-- floor = chip / doc->chips_per_floor;- chip -= (floor * doc->chips_per_floor);-- /* Assert ChipEnable and deassert WriteProtect */- WriteDOC((DOC_FLASH_CE), docptr, Mplus_FlashSelect);- this->cmdfunc(mtd, NAND_CMD_RESET, -1, -1);-- doc->curchip = chip;- doc->curfloor = floor;-}--static void doc200x_select_chip(struct mtd_info *mtd, int chip)-{- struct nand_chip *this = mtd->priv;- struct doc_priv *doc = this->priv;- void __iomem *docptr = doc->virtadr;- int floor = 0;-- if(debug)printk("select chip (%d)\n", chip);-- if (chip == -1)- return;-- floor = chip / doc->chips_per_floor;- chip -= (floor * doc->chips_per_floor);-- /* 11.4.4 -- deassert CE before changing chip */- doc200x_hwcontrol(mtd, NAND_CTL_CLRNCE);-- WriteDOC(floor, docptr, FloorSelect);- WriteDOC(chip, docptr, CDSNDeviceSelect);-- doc200x_hwcontrol(mtd, NAND_CTL_SETNCE);-
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -