@@ -172,10 +172,10 @@ struct sunxi_nand_chip_sel {
172
172
/**
173
173
* struct sunxi_nand_hw_ecc - stores information related to HW ECC support
174
174
*
175
- * @mode: the sunxi ECC mode field deduced from ECC requirements
175
+ * @ecc_ctl: ECC_CTL register value for this NAND chip
176
176
*/
177
177
struct sunxi_nand_hw_ecc {
178
- int mode ;
178
+ u32 ecc_ctl ;
179
179
};
180
180
181
181
/**
@@ -689,26 +689,15 @@ static void sunxi_nfc_hw_ecc_enable(struct nand_chip *nand)
689
689
{
690
690
struct sunxi_nand_chip * sunxi_nand = to_sunxi_nand (nand );
691
691
struct sunxi_nfc * nfc = to_sunxi_nfc (nand -> controller );
692
- u32 ecc_ctl ;
693
-
694
- ecc_ctl = readl (nfc -> regs + NFC_REG_ECC_CTL );
695
- ecc_ctl &= ~(NFC_ECC_MODE_MSK | NFC_ECC_PIPELINE |
696
- NFC_ECC_BLOCK_SIZE_MSK );
697
- ecc_ctl |= NFC_ECC_EN | NFC_ECC_MODE (sunxi_nand -> ecc .mode ) |
698
- NFC_ECC_EXCEPTION | NFC_ECC_PIPELINE ;
699
-
700
- if (nand -> ecc .size == 512 )
701
- ecc_ctl |= NFC_ECC_BLOCK_512 ;
702
692
703
- writel (ecc_ctl , nfc -> regs + NFC_REG_ECC_CTL );
693
+ writel (sunxi_nand -> ecc . ecc_ctl , nfc -> regs + NFC_REG_ECC_CTL );
704
694
}
705
695
706
696
static void sunxi_nfc_hw_ecc_disable (struct nand_chip * nand )
707
697
{
708
698
struct sunxi_nfc * nfc = to_sunxi_nfc (nand -> controller );
709
699
710
- writel (readl (nfc -> regs + NFC_REG_ECC_CTL ) & ~NFC_ECC_EN ,
711
- nfc -> regs + NFC_REG_ECC_CTL );
700
+ writel (0 , nfc -> regs + NFC_REG_ECC_CTL );
712
701
}
713
702
714
703
static inline void sunxi_nfc_user_data_to_buf (u32 user_data , u8 * buf )
@@ -1693,8 +1682,6 @@ static int sunxi_nand_hw_ecc_ctrl_init(struct nand_chip *nand,
1693
1682
return - ENOTSUPP ;
1694
1683
}
1695
1684
1696
- sunxi_nand -> ecc .mode = i ;
1697
-
1698
1685
/* HW ECC always request ECC bytes for 1024 bytes blocks */
1699
1686
ecc -> bytes = DIV_ROUND_UP (ecc -> strength * fls (8 * 1024 ), 8 );
1700
1687
@@ -1726,6 +1713,12 @@ static int sunxi_nand_hw_ecc_ctrl_init(struct nand_chip *nand,
1726
1713
ecc -> read_oob_raw = nand_read_oob_std ;
1727
1714
ecc -> write_oob_raw = nand_write_oob_std ;
1728
1715
1716
+ sunxi_nand -> ecc .ecc_ctl = NFC_ECC_MODE (i ) | NFC_ECC_EXCEPTION |
1717
+ NFC_ECC_PIPELINE | NFC_ECC_EN ;
1718
+
1719
+ if (ecc -> size == 512 )
1720
+ sunxi_nand -> ecc .ecc_ctl |= NFC_ECC_BLOCK_512 ;
1721
+
1729
1722
return 0 ;
1730
1723
}
1731
1724
0 commit comments