Lines Matching refs:mtd
222 struct mtd_info mtd; member
334 static int sunxi_nfc_dev_ready(struct mtd_info *mtd) in sunxi_nfc_dev_ready() argument
336 struct nand_chip *nand = mtd->priv; in sunxi_nfc_dev_ready()
372 static void sunxi_nfc_select_chip(struct mtd_info *mtd, int chip) in sunxi_nfc_select_chip() argument
374 struct nand_chip *nand = mtd->priv; in sunxi_nfc_select_chip()
402 writel(mtd->writesize, nfc->regs + NFC_REG_SPARE_AREA); in sunxi_nfc_select_chip()
415 static void sunxi_nfc_read_buf(struct mtd_info *mtd, uint8_t *buf, int len) in sunxi_nfc_read_buf() argument
417 struct nand_chip *nand = mtd->priv; in sunxi_nfc_read_buf()
447 static void sunxi_nfc_write_buf(struct mtd_info *mtd, const uint8_t *buf, in sunxi_nfc_write_buf() argument
450 struct nand_chip *nand = mtd->priv; in sunxi_nfc_write_buf()
479 static uint8_t sunxi_nfc_read_byte(struct mtd_info *mtd) in sunxi_nfc_read_byte() argument
483 sunxi_nfc_read_buf(mtd, &ret, 1); in sunxi_nfc_read_byte()
488 static void sunxi_nfc_cmd_ctrl(struct mtd_info *mtd, int dat, in sunxi_nfc_cmd_ctrl() argument
491 struct nand_chip *nand = mtd->priv; in sunxi_nfc_cmd_ctrl()
523 static int sunxi_nfc_hw_ecc_read_page(struct mtd_info *mtd, in sunxi_nfc_hw_ecc_read_page() argument
547 chip->cmdfunc(mtd, NAND_CMD_RNDOUT, i * ecc->size, -1); in sunxi_nfc_hw_ecc_read_page()
549 offset = mtd->writesize + layout->eccpos[i * ecc->bytes] - 4; in sunxi_nfc_hw_ecc_read_page()
551 chip->read_buf(mtd, NULL, ecc->size); in sunxi_nfc_hw_ecc_read_page()
553 chip->cmdfunc(mtd, NAND_CMD_RNDOUT, offset, -1); in sunxi_nfc_hw_ecc_read_page()
570 mtd->ecc_stats.failed++; in sunxi_nfc_hw_ecc_read_page()
573 mtd->ecc_stats.corrected += tmp; in sunxi_nfc_hw_ecc_read_page()
578 chip->cmdfunc(mtd, NAND_CMD_RNDOUT, offset, -1); in sunxi_nfc_hw_ecc_read_page()
584 offset -= mtd->writesize; in sunxi_nfc_hw_ecc_read_page()
585 chip->read_buf(mtd, chip->oob_poi + offset, in sunxi_nfc_hw_ecc_read_page()
593 offset = mtd->writesize + in sunxi_nfc_hw_ecc_read_page()
595 chip->cmdfunc(mtd, NAND_CMD_RNDOUT, offset, -1); in sunxi_nfc_hw_ecc_read_page()
596 offset -= mtd->writesize; in sunxi_nfc_hw_ecc_read_page()
597 chip->read_buf(mtd, chip->oob_poi + offset, cnt); in sunxi_nfc_hw_ecc_read_page()
609 static int sunxi_nfc_hw_ecc_write_page(struct mtd_info *mtd, in sunxi_nfc_hw_ecc_write_page() argument
632 chip->cmdfunc(mtd, NAND_CMD_RNDIN, i * ecc->size, -1); in sunxi_nfc_hw_ecc_write_page()
634 chip->write_buf(mtd, buf + (i * ecc->size), ecc->size); in sunxi_nfc_hw_ecc_write_page()
636 offset = layout->eccpos[i * ecc->bytes] - 4 + mtd->writesize; in sunxi_nfc_hw_ecc_write_page()
643 chip->cmdfunc(mtd, NAND_CMD_RNDIN, offset, -1); in sunxi_nfc_hw_ecc_write_page()
660 offset = mtd->writesize + in sunxi_nfc_hw_ecc_write_page()
662 chip->cmdfunc(mtd, NAND_CMD_RNDIN, offset, -1); in sunxi_nfc_hw_ecc_write_page()
663 offset -= mtd->writesize; in sunxi_nfc_hw_ecc_write_page()
664 chip->write_buf(mtd, chip->oob_poi + offset, cnt); in sunxi_nfc_hw_ecc_write_page()
676 static int sunxi_nfc_hw_syndrome_ecc_read_page(struct mtd_info *mtd, in sunxi_nfc_hw_syndrome_ecc_read_page() argument
700 chip->read_buf(mtd, NULL, ecc->size); in sunxi_nfc_hw_syndrome_ecc_read_page()
714 mtd->ecc_stats.failed++; in sunxi_nfc_hw_syndrome_ecc_read_page()
717 mtd->ecc_stats.corrected += tmp; in sunxi_nfc_hw_syndrome_ecc_read_page()
722 chip->cmdfunc(mtd, NAND_CMD_RNDOUT, offset, -1); in sunxi_nfc_hw_syndrome_ecc_read_page()
723 chip->read_buf(mtd, oob, ecc->bytes + ecc->prepad); in sunxi_nfc_hw_syndrome_ecc_read_page()
731 cnt = mtd->oobsize - (oob - chip->oob_poi); in sunxi_nfc_hw_syndrome_ecc_read_page()
733 chip->cmdfunc(mtd, NAND_CMD_RNDOUT, offset, -1); in sunxi_nfc_hw_syndrome_ecc_read_page()
734 chip->read_buf(mtd, oob, cnt); in sunxi_nfc_hw_syndrome_ecc_read_page()
744 static int sunxi_nfc_hw_syndrome_ecc_write_page(struct mtd_info *mtd, in sunxi_nfc_hw_syndrome_ecc_write_page() argument
767 chip->write_buf(mtd, buf + (i * ecc->size), ecc->size); in sunxi_nfc_hw_syndrome_ecc_write_page()
787 cnt = mtd->oobsize - (oob - chip->oob_poi); in sunxi_nfc_hw_syndrome_ecc_write_page()
789 chip->cmdfunc(mtd, NAND_CMD_RNDIN, offset, -1); in sunxi_nfc_hw_syndrome_ecc_write_page()
790 chip->write_buf(mtd, oob, cnt); in sunxi_nfc_hw_syndrome_ecc_write_page()
902 ret = chip->nand.onfi_set_features(&chip->mtd, &chip->nand, in sunxi_nand_chip_init_timings()
916 static int sunxi_nand_hw_common_ecc_ctrl_init(struct mtd_info *mtd, in sunxi_nand_hw_common_ecc_ctrl_init() argument
921 struct nand_chip *nand = mtd->priv; in sunxi_nand_hw_common_ecc_ctrl_init()
955 nsectors = mtd->writesize / ecc->size; in sunxi_nand_hw_common_ecc_ctrl_init()
957 if (mtd->oobsize < ((ecc->bytes + 4) * nsectors)) { in sunxi_nand_hw_common_ecc_ctrl_init()
980 static int sunxi_nand_hw_ecc_ctrl_init(struct mtd_info *mtd, in sunxi_nand_hw_ecc_ctrl_init() argument
989 ret = sunxi_nand_hw_common_ecc_ctrl_init(mtd, ecc, np); in sunxi_nand_hw_ecc_ctrl_init()
996 nsectors = mtd->writesize / ecc->size; in sunxi_nand_hw_ecc_ctrl_init()
1021 if (mtd->oobsize > (ecc->bytes + 4) * nsectors) { in sunxi_nand_hw_ecc_ctrl_init()
1026 layout->oobfree[nsectors].length = mtd->oobsize - in sunxi_nand_hw_ecc_ctrl_init()
1033 static int sunxi_nand_hw_syndrome_ecc_ctrl_init(struct mtd_info *mtd, in sunxi_nand_hw_syndrome_ecc_ctrl_init() argument
1042 ret = sunxi_nand_hw_common_ecc_ctrl_init(mtd, ecc, np); in sunxi_nand_hw_syndrome_ecc_ctrl_init()
1051 nsectors = mtd->writesize / ecc->size; in sunxi_nand_hw_syndrome_ecc_ctrl_init()
1056 layout->oobfree[0].length = mtd->oobsize - i; in sunxi_nand_hw_syndrome_ecc_ctrl_init()
1076 static int sunxi_nand_ecc_init(struct mtd_info *mtd, struct nand_ecc_ctrl *ecc, in sunxi_nand_ecc_init() argument
1079 struct nand_chip *nand = mtd->priv; in sunxi_nand_ecc_init()
1107 ret = sunxi_nand_hw_ecc_ctrl_init(mtd, ecc, np); in sunxi_nand_ecc_init()
1112 ret = sunxi_nand_hw_syndrome_ecc_ctrl_init(mtd, ecc, np); in sunxi_nand_ecc_init()
1120 ecc->layout->oobfree[0].length = mtd->oobsize; in sunxi_nand_ecc_init()
1136 struct mtd_info *mtd; in sunxi_nand_chip_init() local
1237 mtd = &chip->mtd; in sunxi_nand_chip_init()
1238 mtd->dev.parent = dev; in sunxi_nand_chip_init()
1239 mtd->priv = nand; in sunxi_nand_chip_init()
1240 mtd->owner = THIS_MODULE; in sunxi_nand_chip_init()
1242 ret = nand_scan_ident(mtd, nsels, NULL); in sunxi_nand_chip_init()
1252 ret = sunxi_nand_ecc_init(mtd, &nand->ecc, np); in sunxi_nand_chip_init()
1258 ret = nand_scan_tail(mtd); in sunxi_nand_chip_init()
1265 ret = mtd_device_parse_register(mtd, NULL, &ppdata, NULL, 0); in sunxi_nand_chip_init()
1268 nand_release(mtd); in sunxi_nand_chip_init()
1305 nand_release(&chip->mtd); in sunxi_nand_chips_cleanup()