diff --git a/drivers/mtd/nand/diskonchip.c b/drivers/mtd/nand/diskonchip.c index 12608c1..9151e91 100644 --- a/drivers/mtd/nand/diskonchip.c +++ b/drivers/mtd/nand/diskonchip.c @@ -396,6 +396,34 @@ static int doc2000_verifybuf(struct mtd_ return 0; } +static int doc2000_read_oob(struct mtd_info *mtd, struct nand_chip *chip, + int page, int sndcmd) +{ + if (sndcmd) { + chip->cmdfunc(mtd, NAND_CMD_READOOB, 0, page); + sndcmd = 0; + } + chip->read_buf(mtd, chip->oob_poi, mtd->oobsize); + return sndcmd; +} + +static int doc2000_write_oob(struct mtd_info *mtd, struct nand_chip *chip, + int page) +{ + int status = 0; + const uint8_t *buf = chip->oob_poi; + int length = mtd->oobsize; + + chip->cmdfunc(mtd, NAND_CMD_SEQIN, mtd->writesize, page); + chip->write_buf(mtd, buf, length); + /* Send command to program the OOB data */ + chip->cmdfunc(mtd, NAND_CMD_PAGEPROG, -1, -1); + + status = chip->waitfunc(mtd, chip); + + return status & NAND_STATUS_FAIL ? -EIO : 0; +} + static uint16_t __init doc200x_ident_chip(struct mtd_info *mtd, int nr) { struct nand_chip *this = mtd->priv; @@ -1666,6 +1694,12 @@ static int __init doc_probe(unsigned lon nand->ecc.bytes = 6; nand->options = NAND_USE_FLASH_BBT; + /* Uh, no idea what the correct condition is. */ + if (ChipID == DOC_ChipID_Doc2k) { + nand->ecc.read_oob = doc2000_read_oob; + nand->ecc.write_oob = doc2000_write_oob; + } + doc->physadr = physadr; doc->virtadr = virtadr; doc->ChipID = ChipID;