Lines Matching refs:mtd
192 static void set_addr(struct mtd_info *mtd, int column, int page_addr) in set_addr() argument
194 struct sh_flctl *flctl = mtd_to_flctl(mtd); in set_addr()
500 static void set_cmd_regs(struct mtd_info *mtd, uint32_t cmd, uint32_t flcmcdr_val) in set_cmd_regs() argument
502 struct sh_flctl *flctl = mtd_to_flctl(mtd); in set_cmd_regs()
562 static int flctl_read_page_hwecc(struct mtd_info *mtd, struct nand_chip *chip, in flctl_read_page_hwecc() argument
565 chip->read_buf(mtd, buf, mtd->writesize); in flctl_read_page_hwecc()
567 chip->read_buf(mtd, chip->oob_poi, mtd->oobsize); in flctl_read_page_hwecc()
571 static int flctl_write_page_hwecc(struct mtd_info *mtd, struct nand_chip *chip, in flctl_write_page_hwecc() argument
574 chip->write_buf(mtd, buf, mtd->writesize); in flctl_write_page_hwecc()
575 chip->write_buf(mtd, chip->oob_poi, mtd->oobsize); in flctl_write_page_hwecc()
579 static void execmd_read_page_sector(struct mtd_info *mtd, int page_addr) in execmd_read_page_sector() argument
581 struct sh_flctl *flctl = mtd_to_flctl(mtd); in execmd_read_page_sector()
587 set_cmd_regs(mtd, NAND_CMD_READ0, in execmd_read_page_sector()
602 &flctl->done_buff[mtd->writesize + 16 * sector], in execmd_read_page_sector()
609 flctl->mtd.ecc_stats.corrected++; in execmd_read_page_sector()
615 flctl->mtd.ecc_stats.failed++; in execmd_read_page_sector()
628 static void execmd_read_oob(struct mtd_info *mtd, int page_addr) in execmd_read_oob() argument
630 struct sh_flctl *flctl = mtd_to_flctl(mtd); in execmd_read_oob()
634 set_cmd_regs(mtd, NAND_CMD_READ0, in execmd_read_oob()
640 set_addr(mtd, (512 + 16) * i + 512 , page_addr); in execmd_read_oob()
649 static void execmd_write_page_sector(struct mtd_info *mtd) in execmd_write_page_sector() argument
651 struct sh_flctl *flctl = mtd_to_flctl(mtd); in execmd_write_page_sector()
657 set_cmd_regs(mtd, NAND_CMD_PAGEPROG, in execmd_write_page_sector()
668 write_ec_fiforeg(flctl, 16, mtd->writesize + 16 * sector); in execmd_write_page_sector()
675 static void execmd_write_oob(struct mtd_info *mtd) in execmd_write_oob() argument
677 struct sh_flctl *flctl = mtd_to_flctl(mtd); in execmd_write_oob()
683 set_cmd_regs(mtd, NAND_CMD_PAGEPROG, in execmd_write_oob()
688 set_addr(mtd, sector * 528 + 512, page_addr); in execmd_write_oob()
697 static void flctl_cmdfunc(struct mtd_info *mtd, unsigned int command, in flctl_cmdfunc() argument
700 struct sh_flctl *flctl = mtd_to_flctl(mtd); in flctl_cmdfunc()
714 execmd_read_page_sector(mtd, page_addr); in flctl_cmdfunc()
718 set_cmd_regs(mtd, command, (NAND_CMD_READSTART << 8) in flctl_cmdfunc()
721 set_cmd_regs(mtd, command, command); in flctl_cmdfunc()
723 set_addr(mtd, 0, page_addr); in flctl_cmdfunc()
725 flctl->read_bytes = mtd->writesize + mtd->oobsize; in flctl_cmdfunc()
734 execmd_read_oob(mtd, page_addr); in flctl_cmdfunc()
739 set_cmd_regs(mtd, command, (NAND_CMD_READSTART << 8) in flctl_cmdfunc()
741 set_addr(mtd, mtd->writesize, page_addr); in flctl_cmdfunc()
743 set_cmd_regs(mtd, command, command); in flctl_cmdfunc()
744 set_addr(mtd, 0, page_addr); in flctl_cmdfunc()
746 flctl->read_bytes = mtd->oobsize; in flctl_cmdfunc()
754 set_cmd_regs(mtd, command, (NAND_CMD_RNDOUTSTART << 8) in flctl_cmdfunc()
757 set_cmd_regs(mtd, command, command); in flctl_cmdfunc()
759 set_addr(mtd, column, 0); in flctl_cmdfunc()
761 flctl->read_bytes = mtd->writesize + mtd->oobsize - column; in flctl_cmdfunc()
765 set_cmd_regs(mtd, command, command); in flctl_cmdfunc()
770 set_addr(mtd, column, 0); in flctl_cmdfunc()
785 set_cmd_regs(mtd, NAND_CMD_ERASE1, in flctl_cmdfunc()
787 set_addr(mtd, -1, flctl->erase1_page_addr); in flctl_cmdfunc()
795 if (column >= mtd->writesize) { in flctl_cmdfunc()
796 column -= mtd->writesize; in flctl_cmdfunc()
813 set_cmd_regs(mtd, NAND_CMD_SEQIN, in flctl_cmdfunc()
815 set_addr(mtd, -1, -1); in flctl_cmdfunc()
822 if (flctl->seqin_column == mtd->writesize) in flctl_cmdfunc()
823 execmd_write_oob(mtd); in flctl_cmdfunc()
825 execmd_write_page_sector(mtd); in flctl_cmdfunc()
830 set_cmd_regs(mtd, command, (command << 8) | NAND_CMD_SEQIN); in flctl_cmdfunc()
831 set_addr(mtd, flctl->seqin_column, flctl->seqin_page_addr); in flctl_cmdfunc()
839 set_cmd_regs(mtd, command, command); in flctl_cmdfunc()
840 set_addr(mtd, -1, -1); in flctl_cmdfunc()
849 set_cmd_regs(mtd, command, command); in flctl_cmdfunc()
850 set_addr(mtd, -1, -1); in flctl_cmdfunc()
873 static void flctl_select_chip(struct mtd_info *mtd, int chipnr) in flctl_select_chip() argument
875 struct sh_flctl *flctl = mtd_to_flctl(mtd); in flctl_select_chip()
917 static void flctl_write_buf(struct mtd_info *mtd, const uint8_t *buf, int len) in flctl_write_buf() argument
919 struct sh_flctl *flctl = mtd_to_flctl(mtd); in flctl_write_buf()
925 static uint8_t flctl_read_byte(struct mtd_info *mtd) in flctl_read_byte() argument
927 struct sh_flctl *flctl = mtd_to_flctl(mtd); in flctl_read_byte()
935 static uint16_t flctl_read_word(struct mtd_info *mtd) in flctl_read_word() argument
937 struct sh_flctl *flctl = mtd_to_flctl(mtd); in flctl_read_word()
944 static void flctl_read_buf(struct mtd_info *mtd, uint8_t *buf, int len) in flctl_read_buf() argument
946 struct sh_flctl *flctl = mtd_to_flctl(mtd); in flctl_read_buf()
952 static int flctl_chip_init_tail(struct mtd_info *mtd) in flctl_chip_init_tail() argument
954 struct sh_flctl *flctl = mtd_to_flctl(mtd); in flctl_chip_init_tail()
957 if (mtd->writesize == 512) { in flctl_chip_init_tail()
988 if (mtd->writesize == 512) { in flctl_chip_init_tail()
1123 flctl_mtd = &flctl->mtd; in flctl_probe()
1181 nand_release(&flctl->mtd); in flctl_remove()