@@ -298,14 +298,19 @@ static void meson_nfc_cmd_seed(struct meson_nfc *nfc, u32 seed)
298
298
nfc -> reg_base + NFC_REG_CMD );
299
299
}
300
300
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 )
303
302
{
304
303
struct mtd_info * mtd = nand_to_mtd (nand );
305
304
struct meson_nfc * nfc = nand_get_controller_data (mtd_to_nand (mtd ));
306
305
struct meson_nfc_nand_chip * meson_chip = to_meson_nand (nand );
307
306
u32 bch = meson_chip -> bch_mode , cmd ;
308
307
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 ;
309
314
310
315
pagesize = nand -> ecc .size ;
311
316
@@ -321,6 +326,9 @@ static void meson_nfc_cmd_access(struct nand_chip *nand, int raw, bool dir,
321
326
cmd = CMDRWGEN (DMA_DIR (dir ), scrambler , bch ,
322
327
NFC_CMD_SHORTMODE_DISABLE , pagesize , pages );
323
328
329
+ if (scrambler == NFC_CMD_SCRAMBLER_ENABLE )
330
+ meson_nfc_cmd_seed (nfc , page );
331
+
324
332
writel (cmd , nfc -> reg_base + NFC_REG_CMD );
325
333
}
326
334
@@ -743,14 +751,7 @@ static int meson_nfc_write_page_sub(struct nand_chip *nand,
743
751
if (ret )
744
752
return ret ;
745
753
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 );
754
755
755
756
cmd = nfc -> param .chip_select | NFC_CMD_CLE | NAND_CMD_PAGEPROG ;
756
757
writel (cmd , nfc -> reg_base + NFC_REG_CMD );
@@ -829,14 +830,7 @@ static int meson_nfc_read_page_sub(struct nand_chip *nand,
829
830
if (ret )
830
831
return ret ;
831
832
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 );
840
834
841
835
ret = meson_nfc_wait_dma_finish (nfc );
842
836
meson_nfc_check_ecc_pages_valid (nfc , nand , raw );
0 commit comments