Lines Matching refs:mtd
237 struct mtd_info mtd; member
351 static int sunxi_nfc_dev_ready(struct mtd_info *mtd) in sunxi_nfc_dev_ready() argument
353 struct nand_chip *nand = mtd->priv; in sunxi_nfc_dev_ready()
389 static void sunxi_nfc_select_chip(struct mtd_info *mtd, int chip) in sunxi_nfc_select_chip() argument
391 struct nand_chip *nand = mtd->priv; in sunxi_nfc_select_chip()
419 writel(mtd->writesize, nfc->regs + NFC_REG_SPARE_AREA); in sunxi_nfc_select_chip()
434 static void sunxi_nfc_read_buf(struct mtd_info *mtd, uint8_t *buf, int len) in sunxi_nfc_read_buf() argument
436 struct nand_chip *nand = mtd->priv; in sunxi_nfc_read_buf()
466 static void sunxi_nfc_write_buf(struct mtd_info *mtd, const uint8_t *buf, in sunxi_nfc_write_buf() argument
469 struct nand_chip *nand = mtd->priv; in sunxi_nfc_write_buf()
498 static uint8_t sunxi_nfc_read_byte(struct mtd_info *mtd) in sunxi_nfc_read_byte() argument
502 sunxi_nfc_read_buf(mtd, &ret, 1); in sunxi_nfc_read_byte()
507 static void sunxi_nfc_cmd_ctrl(struct mtd_info *mtd, int dat, in sunxi_nfc_cmd_ctrl() argument
510 struct nand_chip *nand = mtd->priv; in sunxi_nfc_cmd_ctrl()
542 static void sunxi_nfc_hw_ecc_enable(struct mtd_info *mtd) in sunxi_nfc_hw_ecc_enable() argument
544 struct nand_chip *nand = mtd->priv; in sunxi_nfc_hw_ecc_enable()
557 static void sunxi_nfc_hw_ecc_disable(struct mtd_info *mtd) in sunxi_nfc_hw_ecc_disable() argument
559 struct nand_chip *nand = mtd->priv; in sunxi_nfc_hw_ecc_disable()
574 static int sunxi_nfc_hw_ecc_read_chunk(struct mtd_info *mtd, in sunxi_nfc_hw_ecc_read_chunk() argument
580 struct nand_chip *nand = mtd->priv; in sunxi_nfc_hw_ecc_read_chunk()
587 nand->cmdfunc(mtd, NAND_CMD_RNDOUT, data_off, -1); in sunxi_nfc_hw_ecc_read_chunk()
589 sunxi_nfc_read_buf(mtd, NULL, ecc->size); in sunxi_nfc_hw_ecc_read_chunk()
592 nand->cmdfunc(mtd, NAND_CMD_RNDOUT, oob_off, -1); in sunxi_nfc_hw_ecc_read_chunk()
610 nand->cmdfunc(mtd, NAND_CMD_RNDOUT, oob_off, -1); in sunxi_nfc_hw_ecc_read_chunk()
611 sunxi_nfc_read_buf(mtd, oob, ecc->bytes + 4); in sunxi_nfc_hw_ecc_read_chunk()
627 mtd->ecc_stats.failed++; in sunxi_nfc_hw_ecc_read_chunk()
629 mtd->ecc_stats.corrected += ret; in sunxi_nfc_hw_ecc_read_chunk()
638 static void sunxi_nfc_hw_ecc_read_extra_oob(struct mtd_info *mtd, in sunxi_nfc_hw_ecc_read_extra_oob() argument
641 struct nand_chip *nand = mtd->priv; in sunxi_nfc_hw_ecc_read_extra_oob()
644 int len = mtd->oobsize - offset; in sunxi_nfc_hw_ecc_read_extra_oob()
650 nand->cmdfunc(mtd, NAND_CMD_RNDOUT, in sunxi_nfc_hw_ecc_read_extra_oob()
651 offset + mtd->writesize, -1); in sunxi_nfc_hw_ecc_read_extra_oob()
653 sunxi_nfc_read_buf(mtd, oob + offset, len); in sunxi_nfc_hw_ecc_read_extra_oob()
655 *cur_off = mtd->oobsize + mtd->writesize; in sunxi_nfc_hw_ecc_read_extra_oob()
663 static int sunxi_nfc_hw_ecc_write_chunk(struct mtd_info *mtd, in sunxi_nfc_hw_ecc_write_chunk() argument
668 struct nand_chip *nand = mtd->priv; in sunxi_nfc_hw_ecc_write_chunk()
674 nand->cmdfunc(mtd, NAND_CMD_RNDIN, data_off, -1); in sunxi_nfc_hw_ecc_write_chunk()
676 sunxi_nfc_write_buf(mtd, data, ecc->size); in sunxi_nfc_hw_ecc_write_chunk()
683 nand->cmdfunc(mtd, NAND_CMD_RNDIN, oob_off, -1); in sunxi_nfc_hw_ecc_write_chunk()
702 static void sunxi_nfc_hw_ecc_write_extra_oob(struct mtd_info *mtd, in sunxi_nfc_hw_ecc_write_extra_oob() argument
705 struct nand_chip *nand = mtd->priv; in sunxi_nfc_hw_ecc_write_extra_oob()
708 int len = mtd->oobsize - offset; in sunxi_nfc_hw_ecc_write_extra_oob()
714 nand->cmdfunc(mtd, NAND_CMD_RNDIN, in sunxi_nfc_hw_ecc_write_extra_oob()
715 offset + mtd->writesize, -1); in sunxi_nfc_hw_ecc_write_extra_oob()
717 sunxi_nfc_write_buf(mtd, oob + offset, len); in sunxi_nfc_hw_ecc_write_extra_oob()
719 *cur_off = mtd->oobsize + mtd->writesize; in sunxi_nfc_hw_ecc_write_extra_oob()
722 static int sunxi_nfc_hw_ecc_read_page(struct mtd_info *mtd, in sunxi_nfc_hw_ecc_read_page() argument
730 sunxi_nfc_hw_ecc_enable(mtd); in sunxi_nfc_hw_ecc_read_page()
738 ret = sunxi_nfc_hw_ecc_read_chunk(mtd, data, data_off, oob, in sunxi_nfc_hw_ecc_read_page()
739 oob_off + mtd->writesize, in sunxi_nfc_hw_ecc_read_page()
746 sunxi_nfc_hw_ecc_read_extra_oob(mtd, chip->oob_poi, &cur_off); in sunxi_nfc_hw_ecc_read_page()
748 sunxi_nfc_hw_ecc_disable(mtd); in sunxi_nfc_hw_ecc_read_page()
753 static int sunxi_nfc_hw_ecc_write_page(struct mtd_info *mtd, in sunxi_nfc_hw_ecc_write_page() argument
761 sunxi_nfc_hw_ecc_enable(mtd); in sunxi_nfc_hw_ecc_write_page()
769 ret = sunxi_nfc_hw_ecc_write_chunk(mtd, data, data_off, oob, in sunxi_nfc_hw_ecc_write_page()
770 oob_off + mtd->writesize, in sunxi_nfc_hw_ecc_write_page()
777 sunxi_nfc_hw_ecc_write_extra_oob(mtd, chip->oob_poi, &cur_off); in sunxi_nfc_hw_ecc_write_page()
779 sunxi_nfc_hw_ecc_disable(mtd); in sunxi_nfc_hw_ecc_write_page()
784 static int sunxi_nfc_hw_syndrome_ecc_read_page(struct mtd_info *mtd, in sunxi_nfc_hw_syndrome_ecc_read_page() argument
793 sunxi_nfc_hw_ecc_enable(mtd); in sunxi_nfc_hw_syndrome_ecc_read_page()
801 ret = sunxi_nfc_hw_ecc_read_chunk(mtd, data, data_off, oob, in sunxi_nfc_hw_syndrome_ecc_read_page()
809 sunxi_nfc_hw_ecc_read_extra_oob(mtd, chip->oob_poi, &cur_off); in sunxi_nfc_hw_syndrome_ecc_read_page()
811 sunxi_nfc_hw_ecc_disable(mtd); in sunxi_nfc_hw_syndrome_ecc_read_page()
816 static int sunxi_nfc_hw_syndrome_ecc_write_page(struct mtd_info *mtd, in sunxi_nfc_hw_syndrome_ecc_write_page() argument
824 sunxi_nfc_hw_ecc_enable(mtd); in sunxi_nfc_hw_syndrome_ecc_write_page()
832 ret = sunxi_nfc_hw_ecc_write_chunk(mtd, data, data_off, in sunxi_nfc_hw_syndrome_ecc_write_page()
839 sunxi_nfc_hw_ecc_write_extra_oob(mtd, chip->oob_poi, &cur_off); in sunxi_nfc_hw_syndrome_ecc_write_page()
841 sunxi_nfc_hw_ecc_disable(mtd); in sunxi_nfc_hw_syndrome_ecc_write_page()
1011 chip->nand.select_chip(&chip->mtd, i); in sunxi_nand_chip_init_timings()
1012 ret = chip->nand.onfi_set_features(&chip->mtd, in sunxi_nand_chip_init_timings()
1016 chip->nand.select_chip(&chip->mtd, -1); in sunxi_nand_chip_init_timings()
1029 static int sunxi_nand_hw_common_ecc_ctrl_init(struct mtd_info *mtd, in sunxi_nand_hw_common_ecc_ctrl_init() argument
1034 struct nand_chip *nand = mtd->priv; in sunxi_nand_hw_common_ecc_ctrl_init()
1068 nsectors = mtd->writesize / ecc->size; in sunxi_nand_hw_common_ecc_ctrl_init()
1070 if (mtd->oobsize < ((ecc->bytes + 4) * nsectors)) { in sunxi_nand_hw_common_ecc_ctrl_init()
1093 static int sunxi_nand_hw_ecc_ctrl_init(struct mtd_info *mtd, in sunxi_nand_hw_ecc_ctrl_init() argument
1102 ret = sunxi_nand_hw_common_ecc_ctrl_init(mtd, ecc, np); in sunxi_nand_hw_ecc_ctrl_init()
1109 nsectors = mtd->writesize / ecc->size; in sunxi_nand_hw_ecc_ctrl_init()
1134 if (mtd->oobsize > (ecc->bytes + 4) * nsectors) { in sunxi_nand_hw_ecc_ctrl_init()
1139 layout->oobfree[nsectors].length = mtd->oobsize - in sunxi_nand_hw_ecc_ctrl_init()
1146 static int sunxi_nand_hw_syndrome_ecc_ctrl_init(struct mtd_info *mtd, in sunxi_nand_hw_syndrome_ecc_ctrl_init() argument
1155 ret = sunxi_nand_hw_common_ecc_ctrl_init(mtd, ecc, np); in sunxi_nand_hw_syndrome_ecc_ctrl_init()
1164 nsectors = mtd->writesize / ecc->size; in sunxi_nand_hw_syndrome_ecc_ctrl_init()
1169 layout->oobfree[0].length = mtd->oobsize - i; in sunxi_nand_hw_syndrome_ecc_ctrl_init()
1189 static int sunxi_nand_ecc_init(struct mtd_info *mtd, struct nand_ecc_ctrl *ecc, in sunxi_nand_ecc_init() argument
1192 struct nand_chip *nand = mtd->priv; in sunxi_nand_ecc_init()
1207 ret = sunxi_nand_hw_ecc_ctrl_init(mtd, ecc, np); in sunxi_nand_ecc_init()
1212 ret = sunxi_nand_hw_syndrome_ecc_ctrl_init(mtd, ecc, np); in sunxi_nand_ecc_init()
1220 ecc->layout->oobfree[0].length = mtd->oobsize; in sunxi_nand_ecc_init()
1236 struct mtd_info *mtd; in sunxi_nand_chip_init() local
1340 mtd = &chip->mtd; in sunxi_nand_chip_init()
1341 mtd->dev.parent = dev; in sunxi_nand_chip_init()
1342 mtd->priv = nand; in sunxi_nand_chip_init()
1344 ret = nand_scan_ident(mtd, nsels, NULL); in sunxi_nand_chip_init()
1357 ret = sunxi_nand_ecc_init(mtd, &nand->ecc, np); in sunxi_nand_chip_init()
1363 ret = nand_scan_tail(mtd); in sunxi_nand_chip_init()
1370 ret = mtd_device_parse_register(mtd, NULL, &ppdata, NULL, 0); in sunxi_nand_chip_init()
1373 nand_release(mtd); in sunxi_nand_chip_init()
1410 nand_release(&chip->mtd); in sunxi_nand_chips_cleanup()