Commit 2be589e4 authored by pekon gupta's avatar pekon gupta Committed by Brian Norris

mtd: nand: omap: add support for BCH16_ECC - ELM driver updates

ELM hardware engine is used to detect ECC errors for BCHx ecc-schemes
(like BCH4/BCH8/BCH16). This patch extends configuration of ELM registers
for adding support of BCH16_HW ecc-scheme.
Signed-off-by: default avatarPekon Gupta <pekon@ti.com>
Signed-off-by: default avatarBrian Norris <computersforpeace@gmail.com>
parent 27c9fd60
...@@ -213,6 +213,28 @@ static void elm_load_syndrome(struct elm_info *info, ...@@ -213,6 +213,28 @@ static void elm_load_syndrome(struct elm_info *info,
val = cpu_to_be32(*(u32 *) &ecc[0]) >> 12; val = cpu_to_be32(*(u32 *) &ecc[0]) >> 12;
elm_write_reg(info, offset, val); elm_write_reg(info, offset, val);
break; break;
case BCH16_ECC:
val = cpu_to_be32(*(u32 *) &ecc[22]);
elm_write_reg(info, offset, val);
offset += 4;
val = cpu_to_be32(*(u32 *) &ecc[18]);
elm_write_reg(info, offset, val);
offset += 4;
val = cpu_to_be32(*(u32 *) &ecc[14]);
elm_write_reg(info, offset, val);
offset += 4;
val = cpu_to_be32(*(u32 *) &ecc[10]);
elm_write_reg(info, offset, val);
offset += 4;
val = cpu_to_be32(*(u32 *) &ecc[6]);
elm_write_reg(info, offset, val);
offset += 4;
val = cpu_to_be32(*(u32 *) &ecc[2]);
elm_write_reg(info, offset, val);
offset += 4;
val = cpu_to_be32(*(u32 *) &ecc[0]) >> 16;
elm_write_reg(info, offset, val);
break;
default: default:
pr_err("invalid config bch_type\n"); pr_err("invalid config bch_type\n");
} }
...@@ -436,6 +458,13 @@ static int elm_context_save(struct elm_info *info) ...@@ -436,6 +458,13 @@ static int elm_context_save(struct elm_info *info)
for (i = 0; i < ERROR_VECTOR_MAX; i++) { for (i = 0; i < ERROR_VECTOR_MAX; i++) {
offset = i * SYNDROME_FRAGMENT_REG_SIZE; offset = i * SYNDROME_FRAGMENT_REG_SIZE;
switch (bch_type) { switch (bch_type) {
case BCH16_ECC:
regs->elm_syndrome_fragment_6[i] = elm_read_reg(info,
ELM_SYNDROME_FRAGMENT_6 + offset);
regs->elm_syndrome_fragment_5[i] = elm_read_reg(info,
ELM_SYNDROME_FRAGMENT_5 + offset);
regs->elm_syndrome_fragment_4[i] = elm_read_reg(info,
ELM_SYNDROME_FRAGMENT_4 + offset);
case BCH8_ECC: case BCH8_ECC:
regs->elm_syndrome_fragment_3[i] = elm_read_reg(info, regs->elm_syndrome_fragment_3[i] = elm_read_reg(info,
ELM_SYNDROME_FRAGMENT_3 + offset); ELM_SYNDROME_FRAGMENT_3 + offset);
...@@ -474,6 +503,13 @@ static int elm_context_restore(struct elm_info *info) ...@@ -474,6 +503,13 @@ static int elm_context_restore(struct elm_info *info)
for (i = 0; i < ERROR_VECTOR_MAX; i++) { for (i = 0; i < ERROR_VECTOR_MAX; i++) {
offset = i * SYNDROME_FRAGMENT_REG_SIZE; offset = i * SYNDROME_FRAGMENT_REG_SIZE;
switch (bch_type) { switch (bch_type) {
case BCH16_ECC:
elm_write_reg(info, ELM_SYNDROME_FRAGMENT_6 + offset,
regs->elm_syndrome_fragment_6[i]);
elm_write_reg(info, ELM_SYNDROME_FRAGMENT_5 + offset,
regs->elm_syndrome_fragment_5[i]);
elm_write_reg(info, ELM_SYNDROME_FRAGMENT_4 + offset,
regs->elm_syndrome_fragment_4[i]);
case BCH8_ECC: case BCH8_ECC:
elm_write_reg(info, ELM_SYNDROME_FRAGMENT_3 + offset, elm_write_reg(info, ELM_SYNDROME_FRAGMENT_3 + offset,
regs->elm_syndrome_fragment_3[i]); regs->elm_syndrome_fragment_3[i]);
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
enum bch_ecc { enum bch_ecc {
BCH4_ECC = 0, BCH4_ECC = 0,
BCH8_ECC, BCH8_ECC,
BCH16_ECC,
}; };
/* ELM support 8 error syndrome process */ /* ELM support 8 error syndrome process */
...@@ -38,7 +39,7 @@ struct elm_errorvec { ...@@ -38,7 +39,7 @@ struct elm_errorvec {
bool error_reported; bool error_reported;
bool error_uncorrectable; bool error_uncorrectable;
int error_count; int error_count;
int error_loc[ERROR_VECTOR_MAX]; int error_loc[16];
}; };
void elm_decode_bch_error_page(struct device *dev, u8 *ecc_calc, void elm_decode_bch_error_page(struct device *dev, u8 *ecc_calc,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment