@@ -298,14 +298,19 @@ static void meson_nfc_cmd_seed(struct meson_nfc *nfc, u32 seed)
298298 nfc -> reg_base + NFC_REG_CMD );
299299}
300300
301- static void meson_nfc_cmd_access (struct nand_chip * nand , int raw , bool dir ,
302- int scrambler )
301+ static void meson_nfc_cmd_access (struct nand_chip * nand , int raw , bool dir , int page )
303302{
304303 struct mtd_info * mtd = nand_to_mtd (nand );
305304 struct meson_nfc * nfc = nand_get_controller_data (mtd_to_nand (mtd ));
306305 struct meson_nfc_nand_chip * meson_chip = to_meson_nand (nand );
307306 u32 bch = meson_chip -> bch_mode , cmd ;
308307 int len = mtd -> writesize , pagesize , pages ;
308+ int scrambler ;
309+
310+ if (nand -> options & NAND_NEED_SCRAMBLING )
311+ scrambler = NFC_CMD_SCRAMBLER_ENABLE ;
312+ else
313+ scrambler = NFC_CMD_SCRAMBLER_DISABLE ;
309314
310315 pagesize = nand -> ecc .size ;
311316
@@ -321,6 +326,9 @@ static void meson_nfc_cmd_access(struct nand_chip *nand, int raw, bool dir,
321326 cmd = CMDRWGEN (DMA_DIR (dir ), scrambler , bch ,
322327 NFC_CMD_SHORTMODE_DISABLE , pagesize , pages );
323328
329+ if (scrambler == NFC_CMD_SCRAMBLER_ENABLE )
330+ meson_nfc_cmd_seed (nfc , page );
331+
324332 writel (cmd , nfc -> reg_base + NFC_REG_CMD );
325333}
326334
@@ -743,14 +751,7 @@ static int meson_nfc_write_page_sub(struct nand_chip *nand,
743751 if (ret )
744752 return ret ;
745753
746- if (nand -> options & NAND_NEED_SCRAMBLING ) {
747- meson_nfc_cmd_seed (nfc , page );
748- meson_nfc_cmd_access (nand , raw , DIRWRITE ,
749- NFC_CMD_SCRAMBLER_ENABLE );
750- } else {
751- meson_nfc_cmd_access (nand , raw , DIRWRITE ,
752- NFC_CMD_SCRAMBLER_DISABLE );
753- }
754+ meson_nfc_cmd_access (nand , raw , DIRWRITE , page );
754755
755756 cmd = nfc -> param .chip_select | NFC_CMD_CLE | NAND_CMD_PAGEPROG ;
756757 writel (cmd , nfc -> reg_base + NFC_REG_CMD );
@@ -829,14 +830,7 @@ static int meson_nfc_read_page_sub(struct nand_chip *nand,
829830 if (ret )
830831 return ret ;
831832
832- if (nand -> options & NAND_NEED_SCRAMBLING ) {
833- meson_nfc_cmd_seed (nfc , page );
834- meson_nfc_cmd_access (nand , raw , DIRREAD ,
835- NFC_CMD_SCRAMBLER_ENABLE );
836- } else {
837- meson_nfc_cmd_access (nand , raw , DIRREAD ,
838- NFC_CMD_SCRAMBLER_DISABLE );
839- }
833+ meson_nfc_cmd_access (nand , raw , DIRREAD , page );
840834
841835 ret = meson_nfc_wait_dma_finish (nfc );
842836 meson_nfc_check_ecc_pages_valid (nfc , nand , raw );
0 commit comments