Lines Matching full:nand

161  * struct sunxi_nand_chip_sel - stores information related to NAND Chip Select
163 * @cs: the NAND CS id used to communicate with a NAND Chip
174 * @ecc_ctl: ECC_CTL register value for this NAND chip
181 * struct sunxi_nand_chip - stores NAND chip device related information
183 * @node: used to store NAND chips into a list
184 * @nand: base NAND chip structure
186 * @clk_rate: clk_rate required for this NAND chip
187 * @timing_cfg: TIMING_CFG register value for this NAND chip
188 * @timing_ctl: TIMING_CTL register value for this NAND chip
189 * @nsels: number of CS lines required by the NAND chip
194 struct nand_chip nand; member
203 static inline struct sunxi_nand_chip *to_sunxi_nand(struct nand_chip *nand) in to_sunxi_nand() argument
205 return container_of(nand, struct sunxi_nand_chip, nand); in to_sunxi_nand()
209 * NAND Controller capabilities structure: stores NAND controller capabilities
224 * struct sunxi_nfc - stores sunxi NAND controller information
228 * @regs: NAND controller registers
229 * @ahb_clk: NAND controller AHB clock
230 * @mod_clk: NAND controller mod clock
231 * @reset: NAND controller reset line
233 * @clk_rate: NAND controller current clock rate
234 * @chips: a list containing all the NAND chips attached to this NAND
236 * @complete: a completion object used to wait for NAND controller events
237 * @dmac: the DMA channel attached to the NAND controller
238 * @caps: NAND Controller capabilities
344 dev_err(nfc->dev, "wait for NAND controller reset timedout\n"); in sunxi_nfc_rst()
415 static void sunxi_nfc_select_chip(struct nand_chip *nand, unsigned int cs) in sunxi_nfc_select_chip() argument
417 struct mtd_info *mtd = nand_to_mtd(nand); in sunxi_nfc_select_chip()
418 struct sunxi_nand_chip *sunxi_nand = to_sunxi_nand(nand); in sunxi_nfc_select_chip()
419 struct sunxi_nfc *nfc = to_sunxi_nfc(sunxi_nand->nand.controller); in sunxi_nfc_select_chip()
430 ctl |= NFC_CE_SEL(sel->cs) | NFC_EN | NFC_PAGE_SHIFT(nand->page_shift); in sunxi_nfc_select_chip()
446 static void sunxi_nfc_read_buf(struct nand_chip *nand, uint8_t *buf, int len) in sunxi_nfc_read_buf() argument
448 struct sunxi_nand_chip *sunxi_nand = to_sunxi_nand(nand); in sunxi_nfc_read_buf()
449 struct sunxi_nfc *nfc = to_sunxi_nfc(sunxi_nand->nand.controller); in sunxi_nfc_read_buf()
483 static void sunxi_nfc_write_buf(struct nand_chip *nand, const uint8_t *buf, in sunxi_nfc_write_buf() argument
486 struct sunxi_nand_chip *sunxi_nand = to_sunxi_nand(nand); in sunxi_nfc_write_buf()
487 struct sunxi_nfc *nfc = to_sunxi_nfc(sunxi_nand->nand.controller); in sunxi_nfc_write_buf()
602 static u16 sunxi_nfc_randomizer_state(struct nand_chip *nand, int page, in sunxi_nfc_randomizer_state() argument
605 struct mtd_info *mtd = nand_to_mtd(nand); in sunxi_nfc_randomizer_state()
622 static void sunxi_nfc_randomizer_config(struct nand_chip *nand, int page, in sunxi_nfc_randomizer_config() argument
625 struct sunxi_nfc *nfc = to_sunxi_nfc(nand->controller); in sunxi_nfc_randomizer_config()
629 if (!(nand->options & NAND_NEED_SCRAMBLING)) in sunxi_nfc_randomizer_config()
633 state = sunxi_nfc_randomizer_state(nand, page, ecc); in sunxi_nfc_randomizer_config()
638 static void sunxi_nfc_randomizer_enable(struct nand_chip *nand) in sunxi_nfc_randomizer_enable() argument
640 struct sunxi_nfc *nfc = to_sunxi_nfc(nand->controller); in sunxi_nfc_randomizer_enable()
642 if (!(nand->options & NAND_NEED_SCRAMBLING)) in sunxi_nfc_randomizer_enable()
649 static void sunxi_nfc_randomizer_disable(struct nand_chip *nand) in sunxi_nfc_randomizer_disable() argument
651 struct sunxi_nfc *nfc = to_sunxi_nfc(nand->controller); in sunxi_nfc_randomizer_disable()
653 if (!(nand->options & NAND_NEED_SCRAMBLING)) in sunxi_nfc_randomizer_disable()
660 static void sunxi_nfc_randomize_bbm(struct nand_chip *nand, int page, u8 *bbm) in sunxi_nfc_randomize_bbm() argument
662 u16 state = sunxi_nfc_randomizer_state(nand, page, true); in sunxi_nfc_randomize_bbm()
668 static void sunxi_nfc_randomizer_write_buf(struct nand_chip *nand, in sunxi_nfc_randomizer_write_buf() argument
672 sunxi_nfc_randomizer_config(nand, page, ecc); in sunxi_nfc_randomizer_write_buf()
673 sunxi_nfc_randomizer_enable(nand); in sunxi_nfc_randomizer_write_buf()
674 sunxi_nfc_write_buf(nand, buf, len); in sunxi_nfc_randomizer_write_buf()
675 sunxi_nfc_randomizer_disable(nand); in sunxi_nfc_randomizer_write_buf()
678 static void sunxi_nfc_randomizer_read_buf(struct nand_chip *nand, uint8_t *buf, in sunxi_nfc_randomizer_read_buf() argument
681 sunxi_nfc_randomizer_config(nand, page, ecc); in sunxi_nfc_randomizer_read_buf()
682 sunxi_nfc_randomizer_enable(nand); in sunxi_nfc_randomizer_read_buf()
683 sunxi_nfc_read_buf(nand, buf, len); in sunxi_nfc_randomizer_read_buf()
684 sunxi_nfc_randomizer_disable(nand); in sunxi_nfc_randomizer_read_buf()
687 static void sunxi_nfc_hw_ecc_enable(struct nand_chip *nand) in sunxi_nfc_hw_ecc_enable() argument
689 struct sunxi_nand_chip *sunxi_nand = to_sunxi_nand(nand); in sunxi_nfc_hw_ecc_enable()
690 struct sunxi_nfc *nfc = to_sunxi_nfc(nand->controller); in sunxi_nfc_hw_ecc_enable()
695 static void sunxi_nfc_hw_ecc_disable(struct nand_chip *nand) in sunxi_nfc_hw_ecc_disable() argument
697 struct sunxi_nfc *nfc = to_sunxi_nfc(nand->controller); in sunxi_nfc_hw_ecc_disable()
715 static void sunxi_nfc_hw_ecc_get_prot_oob_bytes(struct nand_chip *nand, u8 *oob, in sunxi_nfc_hw_ecc_get_prot_oob_bytes() argument
718 struct sunxi_nfc *nfc = to_sunxi_nfc(nand->controller); in sunxi_nfc_hw_ecc_get_prot_oob_bytes()
724 if (bbm && (nand->options & NAND_NEED_SCRAMBLING)) in sunxi_nfc_hw_ecc_get_prot_oob_bytes()
725 sunxi_nfc_randomize_bbm(nand, page, oob); in sunxi_nfc_hw_ecc_get_prot_oob_bytes()
728 static void sunxi_nfc_hw_ecc_set_prot_oob_bytes(struct nand_chip *nand, in sunxi_nfc_hw_ecc_set_prot_oob_bytes() argument
732 struct sunxi_nfc *nfc = to_sunxi_nfc(nand->controller); in sunxi_nfc_hw_ecc_set_prot_oob_bytes()
736 if (bbm && (nand->options & NAND_NEED_SCRAMBLING)) { in sunxi_nfc_hw_ecc_set_prot_oob_bytes()
738 sunxi_nfc_randomize_bbm(nand, page, user_data); in sunxi_nfc_hw_ecc_set_prot_oob_bytes()
746 static void sunxi_nfc_hw_ecc_update_stats(struct nand_chip *nand, in sunxi_nfc_hw_ecc_update_stats() argument
749 struct mtd_info *mtd = nand_to_mtd(nand); in sunxi_nfc_hw_ecc_update_stats()
759 static int sunxi_nfc_hw_ecc_correct(struct nand_chip *nand, u8 *data, u8 *oob, in sunxi_nfc_hw_ecc_correct() argument
762 struct sunxi_nfc *nfc = to_sunxi_nfc(nand->controller); in sunxi_nfc_hw_ecc_correct()
763 struct nand_ecc_ctrl *ecc = &nand->ecc; in sunxi_nfc_hw_ecc_correct()
795 static int sunxi_nfc_hw_ecc_read_chunk(struct nand_chip *nand, in sunxi_nfc_hw_ecc_read_chunk() argument
802 struct sunxi_nfc *nfc = to_sunxi_nfc(nand->controller); in sunxi_nfc_hw_ecc_read_chunk()
803 struct nand_ecc_ctrl *ecc = &nand->ecc; in sunxi_nfc_hw_ecc_read_chunk()
809 nand_change_read_column_op(nand, data_off, NULL, 0, false); in sunxi_nfc_hw_ecc_read_chunk()
811 sunxi_nfc_randomizer_read_buf(nand, NULL, ecc->size, false, page); in sunxi_nfc_hw_ecc_read_chunk()
814 nand_change_read_column_op(nand, oob_off, NULL, 0, false); in sunxi_nfc_hw_ecc_read_chunk()
820 sunxi_nfc_randomizer_enable(nand); in sunxi_nfc_hw_ecc_read_chunk()
825 sunxi_nfc_randomizer_disable(nand); in sunxi_nfc_hw_ecc_read_chunk()
831 ret = sunxi_nfc_hw_ecc_correct(nand, data, oob_required ? oob : NULL, 0, in sunxi_nfc_hw_ecc_read_chunk()
842 if (nand->options & NAND_NEED_SCRAMBLING) in sunxi_nfc_hw_ecc_read_chunk()
843 nand_change_read_column_op(nand, data_off, data, in sunxi_nfc_hw_ecc_read_chunk()
849 nand_change_read_column_op(nand, oob_off, oob, ecc->bytes + 4, in sunxi_nfc_hw_ecc_read_chunk()
861 nand_change_read_column_op(nand, oob_off, NULL, 0, in sunxi_nfc_hw_ecc_read_chunk()
863 sunxi_nfc_randomizer_read_buf(nand, oob, ecc->bytes + 4, in sunxi_nfc_hw_ecc_read_chunk()
866 sunxi_nfc_hw_ecc_get_prot_oob_bytes(nand, oob, 0, in sunxi_nfc_hw_ecc_read_chunk()
871 sunxi_nfc_hw_ecc_update_stats(nand, max_bitflips, ret); in sunxi_nfc_hw_ecc_read_chunk()
876 static void sunxi_nfc_hw_ecc_read_extra_oob(struct nand_chip *nand, in sunxi_nfc_hw_ecc_read_extra_oob() argument
880 struct mtd_info *mtd = nand_to_mtd(nand); in sunxi_nfc_hw_ecc_read_extra_oob()
881 struct nand_ecc_ctrl *ecc = &nand->ecc; in sunxi_nfc_hw_ecc_read_extra_oob()
889 nand_change_read_column_op(nand, mtd->writesize, NULL, 0, in sunxi_nfc_hw_ecc_read_extra_oob()
893 sunxi_nfc_read_buf(nand, oob + offset, len); in sunxi_nfc_hw_ecc_read_extra_oob()
895 sunxi_nfc_randomizer_read_buf(nand, oob + offset, len, in sunxi_nfc_hw_ecc_read_extra_oob()
902 static int sunxi_nfc_hw_ecc_read_chunks_dma(struct nand_chip *nand, uint8_t *buf, in sunxi_nfc_hw_ecc_read_chunks_dma() argument
906 bool randomized = nand->options & NAND_NEED_SCRAMBLING; in sunxi_nfc_hw_ecc_read_chunks_dma()
907 struct sunxi_nfc *nfc = to_sunxi_nfc(nand->controller); in sunxi_nfc_hw_ecc_read_chunks_dma()
908 struct mtd_info *mtd = nand_to_mtd(nand); in sunxi_nfc_hw_ecc_read_chunks_dma()
909 struct nand_ecc_ctrl *ecc = &nand->ecc; in sunxi_nfc_hw_ecc_read_chunks_dma()
924 sunxi_nfc_hw_ecc_enable(nand); in sunxi_nfc_hw_ecc_read_chunks_dma()
925 sunxi_nfc_randomizer_config(nand, page, false); in sunxi_nfc_hw_ecc_read_chunks_dma()
926 sunxi_nfc_randomizer_enable(nand); in sunxi_nfc_hw_ecc_read_chunks_dma()
945 sunxi_nfc_randomizer_disable(nand); in sunxi_nfc_hw_ecc_read_chunks_dma()
946 sunxi_nfc_hw_ecc_disable(nand); in sunxi_nfc_hw_ecc_read_chunks_dma()
959 u8 *oob = nand->oob_poi + oob_off; in sunxi_nfc_hw_ecc_read_chunks_dma()
962 ret = sunxi_nfc_hw_ecc_correct(nand, randomized ? data : NULL, in sunxi_nfc_hw_ecc_read_chunks_dma()
972 nand_change_read_column_op(nand, in sunxi_nfc_hw_ecc_read_chunks_dma()
976 sunxi_nfc_hw_ecc_get_prot_oob_bytes(nand, oob, i, in sunxi_nfc_hw_ecc_read_chunks_dma()
983 sunxi_nfc_hw_ecc_update_stats(nand, &max_bitflips, ret); in sunxi_nfc_hw_ecc_read_chunks_dma()
991 u8 *oob = nand->oob_poi + oob_off; in sunxi_nfc_hw_ecc_read_chunks_dma()
1002 nand_change_read_column_op(nand, data_off, in sunxi_nfc_hw_ecc_read_chunks_dma()
1007 nand_change_read_column_op(nand, in sunxi_nfc_hw_ecc_read_chunks_dma()
1018 sunxi_nfc_hw_ecc_update_stats(nand, &max_bitflips, ret); in sunxi_nfc_hw_ecc_read_chunks_dma()
1023 sunxi_nfc_hw_ecc_read_extra_oob(nand, nand->oob_poi, in sunxi_nfc_hw_ecc_read_chunks_dma()
1030 static int sunxi_nfc_hw_ecc_write_chunk(struct nand_chip *nand, in sunxi_nfc_hw_ecc_write_chunk() argument
1036 struct sunxi_nfc *nfc = to_sunxi_nfc(nand->controller); in sunxi_nfc_hw_ecc_write_chunk()
1037 struct nand_ecc_ctrl *ecc = &nand->ecc; in sunxi_nfc_hw_ecc_write_chunk()
1041 nand_change_write_column_op(nand, data_off, NULL, 0, false); in sunxi_nfc_hw_ecc_write_chunk()
1043 sunxi_nfc_randomizer_write_buf(nand, data, ecc->size, false, page); in sunxi_nfc_hw_ecc_write_chunk()
1046 nand_change_write_column_op(nand, oob_off, NULL, 0, false); in sunxi_nfc_hw_ecc_write_chunk()
1052 sunxi_nfc_randomizer_enable(nand); in sunxi_nfc_hw_ecc_write_chunk()
1053 sunxi_nfc_hw_ecc_set_prot_oob_bytes(nand, oob, 0, bbm, page); in sunxi_nfc_hw_ecc_write_chunk()
1060 sunxi_nfc_randomizer_disable(nand); in sunxi_nfc_hw_ecc_write_chunk()
1069 static void sunxi_nfc_hw_ecc_write_extra_oob(struct nand_chip *nand, in sunxi_nfc_hw_ecc_write_extra_oob() argument
1073 struct mtd_info *mtd = nand_to_mtd(nand); in sunxi_nfc_hw_ecc_write_extra_oob()
1074 struct nand_ecc_ctrl *ecc = &nand->ecc; in sunxi_nfc_hw_ecc_write_extra_oob()
1082 nand_change_write_column_op(nand, offset + mtd->writesize, in sunxi_nfc_hw_ecc_write_extra_oob()
1085 sunxi_nfc_randomizer_write_buf(nand, oob + offset, len, false, page); in sunxi_nfc_hw_ecc_write_extra_oob()
1091 static int sunxi_nfc_hw_ecc_read_page(struct nand_chip *nand, uint8_t *buf, in sunxi_nfc_hw_ecc_read_page() argument
1094 struct mtd_info *mtd = nand_to_mtd(nand); in sunxi_nfc_hw_ecc_read_page()
1095 struct nand_ecc_ctrl *ecc = &nand->ecc; in sunxi_nfc_hw_ecc_read_page()
1100 sunxi_nfc_select_chip(nand, nand->cur_cs); in sunxi_nfc_hw_ecc_read_page()
1102 nand_read_page_op(nand, page, 0, NULL, 0); in sunxi_nfc_hw_ecc_read_page()
1104 sunxi_nfc_hw_ecc_enable(nand); in sunxi_nfc_hw_ecc_read_page()
1110 u8 *oob = nand->oob_poi + oob_off; in sunxi_nfc_hw_ecc_read_page()
1112 ret = sunxi_nfc_hw_ecc_read_chunk(nand, data, data_off, oob, in sunxi_nfc_hw_ecc_read_page()
1123 sunxi_nfc_hw_ecc_read_extra_oob(nand, nand->oob_poi, &cur_off, in sunxi_nfc_hw_ecc_read_page()
1126 sunxi_nfc_hw_ecc_disable(nand); in sunxi_nfc_hw_ecc_read_page()
1131 static int sunxi_nfc_hw_ecc_read_page_dma(struct nand_chip *nand, u8 *buf, in sunxi_nfc_hw_ecc_read_page_dma() argument
1136 sunxi_nfc_select_chip(nand, nand->cur_cs); in sunxi_nfc_hw_ecc_read_page_dma()
1138 nand_read_page_op(nand, page, 0, NULL, 0); in sunxi_nfc_hw_ecc_read_page_dma()
1140 ret = sunxi_nfc_hw_ecc_read_chunks_dma(nand, buf, oob_required, page, in sunxi_nfc_hw_ecc_read_page_dma()
1141 nand->ecc.steps); in sunxi_nfc_hw_ecc_read_page_dma()
1146 return sunxi_nfc_hw_ecc_read_page(nand, buf, oob_required, page); in sunxi_nfc_hw_ecc_read_page_dma()
1149 static int sunxi_nfc_hw_ecc_read_subpage(struct nand_chip *nand, in sunxi_nfc_hw_ecc_read_subpage() argument
1153 struct mtd_info *mtd = nand_to_mtd(nand); in sunxi_nfc_hw_ecc_read_subpage()
1154 struct nand_ecc_ctrl *ecc = &nand->ecc; in sunxi_nfc_hw_ecc_read_subpage()
1158 sunxi_nfc_select_chip(nand, nand->cur_cs); in sunxi_nfc_hw_ecc_read_subpage()
1160 nand_read_page_op(nand, page, 0, NULL, 0); in sunxi_nfc_hw_ecc_read_subpage()
1162 sunxi_nfc_hw_ecc_enable(nand); in sunxi_nfc_hw_ecc_read_subpage()
1169 u8 *oob = nand->oob_poi + oob_off; in sunxi_nfc_hw_ecc_read_subpage()
1171 ret = sunxi_nfc_hw_ecc_read_chunk(nand, data, data_off, in sunxi_nfc_hw_ecc_read_subpage()
1180 sunxi_nfc_hw_ecc_disable(nand); in sunxi_nfc_hw_ecc_read_subpage()
1185 static int sunxi_nfc_hw_ecc_read_subpage_dma(struct nand_chip *nand, in sunxi_nfc_hw_ecc_read_subpage_dma() argument
1189 int nchunks = DIV_ROUND_UP(data_offs + readlen, nand->ecc.size); in sunxi_nfc_hw_ecc_read_subpage_dma()
1192 sunxi_nfc_select_chip(nand, nand->cur_cs); in sunxi_nfc_hw_ecc_read_subpage_dma()
1194 nand_read_page_op(nand, page, 0, NULL, 0); in sunxi_nfc_hw_ecc_read_subpage_dma()
1196 ret = sunxi_nfc_hw_ecc_read_chunks_dma(nand, buf, false, page, nchunks); in sunxi_nfc_hw_ecc_read_subpage_dma()
1201 return sunxi_nfc_hw_ecc_read_subpage(nand, data_offs, readlen, in sunxi_nfc_hw_ecc_read_subpage_dma()
1205 static int sunxi_nfc_hw_ecc_write_page(struct nand_chip *nand, in sunxi_nfc_hw_ecc_write_page() argument
1209 struct mtd_info *mtd = nand_to_mtd(nand); in sunxi_nfc_hw_ecc_write_page()
1210 struct nand_ecc_ctrl *ecc = &nand->ecc; in sunxi_nfc_hw_ecc_write_page()
1213 sunxi_nfc_select_chip(nand, nand->cur_cs); in sunxi_nfc_hw_ecc_write_page()
1215 nand_prog_page_begin_op(nand, page, 0, NULL, 0); in sunxi_nfc_hw_ecc_write_page()
1217 sunxi_nfc_hw_ecc_enable(nand); in sunxi_nfc_hw_ecc_write_page()
1223 const u8 *oob = nand->oob_poi + oob_off; in sunxi_nfc_hw_ecc_write_page()
1225 ret = sunxi_nfc_hw_ecc_write_chunk(nand, data, data_off, oob, in sunxi_nfc_hw_ecc_write_page()
1232 if (oob_required || (nand->options & NAND_NEED_SCRAMBLING)) in sunxi_nfc_hw_ecc_write_page()
1233 sunxi_nfc_hw_ecc_write_extra_oob(nand, nand->oob_poi, in sunxi_nfc_hw_ecc_write_page()
1236 sunxi_nfc_hw_ecc_disable(nand); in sunxi_nfc_hw_ecc_write_page()
1238 return nand_prog_page_end_op(nand); in sunxi_nfc_hw_ecc_write_page()
1241 static int sunxi_nfc_hw_ecc_write_subpage(struct nand_chip *nand, in sunxi_nfc_hw_ecc_write_subpage() argument
1246 struct mtd_info *mtd = nand_to_mtd(nand); in sunxi_nfc_hw_ecc_write_subpage()
1247 struct nand_ecc_ctrl *ecc = &nand->ecc; in sunxi_nfc_hw_ecc_write_subpage()
1250 sunxi_nfc_select_chip(nand, nand->cur_cs); in sunxi_nfc_hw_ecc_write_subpage()
1252 nand_prog_page_begin_op(nand, page, 0, NULL, 0); in sunxi_nfc_hw_ecc_write_subpage()
1254 sunxi_nfc_hw_ecc_enable(nand); in sunxi_nfc_hw_ecc_write_subpage()
1261 const u8 *oob = nand->oob_poi + oob_off; in sunxi_nfc_hw_ecc_write_subpage()
1263 ret = sunxi_nfc_hw_ecc_write_chunk(nand, data, data_off, oob, in sunxi_nfc_hw_ecc_write_subpage()
1270 sunxi_nfc_hw_ecc_disable(nand); in sunxi_nfc_hw_ecc_write_subpage()
1272 return nand_prog_page_end_op(nand); in sunxi_nfc_hw_ecc_write_subpage()
1275 static int sunxi_nfc_hw_ecc_write_page_dma(struct nand_chip *nand, in sunxi_nfc_hw_ecc_write_page_dma() argument
1280 struct sunxi_nfc *nfc = to_sunxi_nfc(nand->controller); in sunxi_nfc_hw_ecc_write_page_dma()
1281 struct nand_ecc_ctrl *ecc = &nand->ecc; in sunxi_nfc_hw_ecc_write_page_dma()
1286 sunxi_nfc_select_chip(nand, nand->cur_cs); in sunxi_nfc_hw_ecc_write_page_dma()
1298 const u8 *oob = nand->oob_poi + (i * (ecc->bytes + 4)); in sunxi_nfc_hw_ecc_write_page_dma()
1300 sunxi_nfc_hw_ecc_set_prot_oob_bytes(nand, oob, i, !i, page); in sunxi_nfc_hw_ecc_write_page_dma()
1303 nand_prog_page_begin_op(nand, page, 0, NULL, 0); in sunxi_nfc_hw_ecc_write_page_dma()
1305 sunxi_nfc_hw_ecc_enable(nand); in sunxi_nfc_hw_ecc_write_page_dma()
1306 sunxi_nfc_randomizer_config(nand, page, false); in sunxi_nfc_hw_ecc_write_page_dma()
1307 sunxi_nfc_randomizer_enable(nand); in sunxi_nfc_hw_ecc_write_page_dma()
1327 sunxi_nfc_randomizer_disable(nand); in sunxi_nfc_hw_ecc_write_page_dma()
1328 sunxi_nfc_hw_ecc_disable(nand); in sunxi_nfc_hw_ecc_write_page_dma()
1335 if (oob_required || (nand->options & NAND_NEED_SCRAMBLING)) in sunxi_nfc_hw_ecc_write_page_dma()
1337 sunxi_nfc_hw_ecc_write_extra_oob(nand, nand->oob_poi, in sunxi_nfc_hw_ecc_write_page_dma()
1340 return nand_prog_page_end_op(nand); in sunxi_nfc_hw_ecc_write_page_dma()
1343 return sunxi_nfc_hw_ecc_write_page(nand, buf, oob_required, page); in sunxi_nfc_hw_ecc_write_page_dma()
1346 static int sunxi_nfc_hw_ecc_read_oob(struct nand_chip *nand, int page) in sunxi_nfc_hw_ecc_read_oob() argument
1348 u8 *buf = nand_get_data_buf(nand); in sunxi_nfc_hw_ecc_read_oob()
1350 return nand->ecc.read_page(nand, buf, 1, page); in sunxi_nfc_hw_ecc_read_oob()
1353 static int sunxi_nfc_hw_ecc_write_oob(struct nand_chip *nand, int page) in sunxi_nfc_hw_ecc_write_oob() argument
1355 struct mtd_info *mtd = nand_to_mtd(nand); in sunxi_nfc_hw_ecc_write_oob()
1356 u8 *buf = nand_get_data_buf(nand); in sunxi_nfc_hw_ecc_write_oob()
1360 ret = nand->ecc.write_page(nand, buf, 1, page); in sunxi_nfc_hw_ecc_write_oob()
1365 return nand_prog_page_end_op(nand); in sunxi_nfc_hw_ecc_write_oob()
1389 static int sunxi_nfc_setup_interface(struct nand_chip *nand, int csline, in sunxi_nfc_setup_interface() argument
1392 struct sunxi_nand_chip *sunxi_nand = to_sunxi_nand(nand); in sunxi_nfc_setup_interface()
1393 struct sunxi_nfc *nfc = to_sunxi_nfc(sunxi_nand->nand.controller); in sunxi_nfc_setup_interface()
1479 * the sunxi NAND controller does not allow us to have different in sunxi_nfc_setup_interface()
1520 * TODO: according to ONFI specs this value only applies for DDR NAND, in sunxi_nfc_setup_interface()
1562 struct nand_chip *nand = mtd_to_nand(mtd); in sunxi_nand_ooblayout_ecc() local
1563 struct nand_ecc_ctrl *ecc = &nand->ecc; in sunxi_nand_ooblayout_ecc()
1577 struct nand_chip *nand = mtd_to_nand(mtd); in sunxi_nand_ooblayout_free() local
1578 struct nand_ecc_ctrl *ecc = &nand->ecc; in sunxi_nand_ooblayout_free()
1617 static int sunxi_nand_hw_ecc_ctrl_init(struct nand_chip *nand, in sunxi_nand_hw_ecc_ctrl_init() argument
1622 struct sunxi_nand_chip *sunxi_nand = to_sunxi_nand(nand); in sunxi_nand_hw_ecc_ctrl_init()
1623 struct sunxi_nfc *nfc = to_sunxi_nfc(nand->controller); in sunxi_nand_hw_ecc_ctrl_init()
1624 struct mtd_info *mtd = nand_to_mtd(nand); in sunxi_nand_hw_ecc_ctrl_init()
1703 nand->options |= NAND_USES_DMA; in sunxi_nand_hw_ecc_ctrl_init()
1724 static int sunxi_nand_attach_chip(struct nand_chip *nand) in sunxi_nand_attach_chip() argument
1727 nanddev_get_ecc_requirements(&nand->base); in sunxi_nand_attach_chip()
1728 struct nand_ecc_ctrl *ecc = &nand->ecc; in sunxi_nand_attach_chip()
1729 struct device_node *np = nand_get_flash_node(nand); in sunxi_nand_attach_chip()
1732 if (nand->bbt_options & NAND_BBT_USE_FLASH) in sunxi_nand_attach_chip()
1733 nand->bbt_options |= NAND_BBT_NO_OOB; in sunxi_nand_attach_chip()
1735 if (nand->options & NAND_NEED_SCRAMBLING) in sunxi_nand_attach_chip()
1736 nand->options |= NAND_NO_SUBPAGE_WRITE; in sunxi_nand_attach_chip()
1738 nand->options |= NAND_SUBPAGE_READ; in sunxi_nand_attach_chip()
1750 ret = sunxi_nand_hw_ecc_ctrl_init(nand, ecc, np); in sunxi_nand_attach_chip()
1764 static int sunxi_nfc_exec_subop(struct nand_chip *nand, in sunxi_nfc_exec_subop() argument
1767 struct sunxi_nfc *nfc = to_sunxi_nfc(nand->controller); in sunxi_nfc_exec_subop()
1860 static int sunxi_nfc_soft_waitrdy(struct nand_chip *nand, in sunxi_nfc_soft_waitrdy() argument
1863 return nand_soft_waitrdy(nand, in sunxi_nfc_soft_waitrdy()
1897 static int sunxi_nfc_exec_op(struct nand_chip *nand, in sunxi_nfc_exec_op() argument
1900 struct sunxi_nand_chip *sunxi_nand = to_sunxi_nand(nand); in sunxi_nfc_exec_op()
1904 sunxi_nfc_select_chip(nand, op->cs); in sunxi_nfc_exec_op()
1911 return nand_op_parser_exec_op(nand, parser, op, check_only); in sunxi_nfc_exec_op()
1930 chip = &sunxi_nand->nand; in sunxi_nand_chips_cleanup()
1943 struct nand_chip *nand; in sunxi_nand_chip_init() local
1994 nand = &sunxi_nand->nand; in sunxi_nand_chip_init()
1996 nand->controller = &nfc->controller; in sunxi_nand_chip_init()
1997 nand->controller->ops = &sunxi_nand_controller_ops; in sunxi_nand_chip_init()
2003 nand->ecc.engine_type = NAND_ECC_ENGINE_TYPE_ON_HOST; in sunxi_nand_chip_init()
2004 nand_set_flash_node(nand, np); in sunxi_nand_chip_init()
2006 mtd = nand_to_mtd(nand); in sunxi_nand_chip_init()
2009 ret = nand_scan(nand, nsels); in sunxi_nand_chip_init()
2016 nand_cleanup(nand); in sunxi_nand_chip_init()
2129 0, "sunxi-nand", nfc); in sunxi_nfc_probe()
2142 dev_err(dev, "failed to init nand chips\n"); in sunxi_nfc_probe()
2182 .compatible = "allwinner,sun4i-a10-nand",
2186 .compatible = "allwinner,sun8i-a23-nand-controller",
2205 MODULE_DESCRIPTION("Allwinner NAND Flash Controller driver");