Lines Matching full:ecc
3 * JZ4740 ECC controller driver
45 static void jz4740_ecc_reset(struct ingenic_ecc *ecc, bool calc_ecc) in jz4740_ecc_reset() argument
50 writel(0, ecc->base + JZ_REG_NAND_IRQ_STAT); in jz4740_ecc_reset()
52 /* Initialize and enable ECC hardware */ in jz4740_ecc_reset()
53 reg = readl(ecc->base + JZ_REG_NAND_ECC_CTRL); in jz4740_ecc_reset()
57 if (calc_ecc) /* calculate ECC from data */ in jz4740_ecc_reset()
59 else /* correct data from ECC */ in jz4740_ecc_reset()
62 writel(reg, ecc->base + JZ_REG_NAND_ECC_CTRL); in jz4740_ecc_reset()
65 static int jz4740_ecc_calculate(struct ingenic_ecc *ecc, in jz4740_ecc_calculate() argument
73 jz4740_ecc_reset(ecc, true); in jz4740_ecc_calculate()
76 status = readl(ecc->base + JZ_REG_NAND_IRQ_STAT); in jz4740_ecc_calculate()
82 reg = readl(ecc->base + JZ_REG_NAND_ECC_CTRL); in jz4740_ecc_calculate()
84 writel(reg, ecc->base + JZ_REG_NAND_ECC_CTRL); in jz4740_ecc_calculate()
87 ecc_code[i] = readb(ecc->base + JZ_REG_NAND_PAR0 + i); in jz4740_ecc_calculate()
91 * ECC, otherwise we will get in trouble when doing subpage writes. in jz4740_ecc_calculate()
117 static int jz4740_ecc_correct(struct ingenic_ecc *ecc, in jz4740_ecc_correct() argument
125 jz4740_ecc_reset(ecc, false); in jz4740_ecc_correct()
128 writeb(ecc_code[i], ecc->base + JZ_REG_NAND_PAR0 + i); in jz4740_ecc_correct()
130 reg = readl(ecc->base + JZ_REG_NAND_ECC_CTRL); in jz4740_ecc_correct()
132 writel(reg, ecc->base + JZ_REG_NAND_ECC_CTRL); in jz4740_ecc_correct()
135 status = readl(ecc->base + JZ_REG_NAND_IRQ_STAT); in jz4740_ecc_correct()
141 reg = readl(ecc->base + JZ_REG_NAND_ECC_CTRL); in jz4740_ecc_correct()
143 writel(reg, ecc->base + JZ_REG_NAND_ECC_CTRL); in jz4740_ecc_correct()
152 error = readl(ecc->base + JZ_REG_NAND_ERR(i)); in jz4740_ecc_correct()
164 static void jz4740_ecc_disable(struct ingenic_ecc *ecc) in jz4740_ecc_disable() argument
168 writel(0, ecc->base + JZ_REG_NAND_IRQ_STAT); in jz4740_ecc_disable()
169 reg = readl(ecc->base + JZ_REG_NAND_ECC_CTRL); in jz4740_ecc_disable()
171 writel(reg, ecc->base + JZ_REG_NAND_ECC_CTRL); in jz4740_ecc_disable()
181 { .compatible = "ingenic,jz4740-ecc", .data = &jz4740_ecc_ops },
189 .name = "jz4740-ecc",
196 MODULE_DESCRIPTION("Ingenic JZ4740 ECC controller driver");