public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH V3] mtd: nand: mxs check maximum ecc that platfrom supports
@ 2015-09-07  8:12 Peng Fan
  2015-09-20  8:00 ` Stefano Babic
  0 siblings, 1 reply; 2+ messages in thread
From: Peng Fan @ 2015-09-07  8:12 UTC (permalink / raw)
  To: u-boot

Check maximum ecc strength for each platfrom to avoid the calculated ecc
exceed the limitation.

Signed-off-by: Peng Fan <Peng.Fan@freescale.com>
Signed-off-by: Han Xu <b45815@freescale.com>
Tested-By: Tim Harvey <tharvey@gateworks.com>
Reviewed-by: Marek Vasut <marex@denx.de>
Acked-by: Scott Wood <scottwood@freescale.com>
Cc: Stefano Babic <sbabic@denx.de>
---

Original V2 mail thread:
http://lists.denx.de/pipermail/u-boot/2015-August/225362.html

Because is_cpu_type was not merged to uboot upstream at that time,
this patch can not be compiled successfully. Since now is_cpu_type
is already in uboot upstream master branch, this patch can be applied
and built without failure.

Changes v3:
 Add Scott's Acked by
 Add Tim's Tested by

Changes v2:
 Add Marek's reviewed by.

 drivers/mtd/nand/mxs_nand.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/nand/mxs_nand.c b/drivers/mtd/nand/mxs_nand.c
index 1d68901..f15cf36 100644
--- a/drivers/mtd/nand/mxs_nand.c
+++ b/drivers/mtd/nand/mxs_nand.c
@@ -149,6 +149,13 @@ static inline uint32_t mxs_nand_get_ecc_strength(uint32_t page_data_size,
 						uint32_t page_oob_size)
 {
 	int ecc_strength;
+	int max_ecc_strength_supported;
+
+	/* Refer to Chapter 17 for i.MX6DQ, Chapter 18 for i.MX6SX */
+	if (is_cpu_type(MXC_CPU_MX6SX))
+		max_ecc_strength_supported = 62;
+	else
+		max_ecc_strength_supported = 40;
 
 	/*
 	 * Determine the ECC layout with the formula:
@@ -162,7 +169,7 @@ static inline uint32_t mxs_nand_get_ecc_strength(uint32_t page_data_size,
 			/ (galois_field *
 			   mxs_nand_ecc_chunk_cnt(page_data_size));
 
-	return round_down(ecc_strength, 2);
+	return min(round_down(ecc_strength, 2), max_ecc_strength_supported);
 }
 
 static inline uint32_t mxs_nand_get_mark_offset(uint32_t page_data_size,
-- 
1.8.4

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-09-20  8:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-07  8:12 [U-Boot] [PATCH V3] mtd: nand: mxs check maximum ecc that platfrom supports Peng Fan
2015-09-20  8:00 ` Stefano Babic

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox