aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/bcm63xx/patches-5.4/437-mtd-rawnand-brcmnand-improve-hamming-oob-layout.patch
diff options
context:
space:
mode:
Diffstat (limited to 'target/linux/bcm63xx/patches-5.4/437-mtd-rawnand-brcmnand-improve-hamming-oob-layout.patch')
-rw-r--r--target/linux/bcm63xx/patches-5.4/437-mtd-rawnand-brcmnand-improve-hamming-oob-layout.patch52
1 files changed, 52 insertions, 0 deletions
diff --git a/target/linux/bcm63xx/patches-5.4/437-mtd-rawnand-brcmnand-improve-hamming-oob-layout.patch b/target/linux/bcm63xx/patches-5.4/437-mtd-rawnand-brcmnand-improve-hamming-oob-layout.patch
new file mode 100644
index 0000000000..68bbc7ad19
--- /dev/null
+++ b/target/linux/bcm63xx/patches-5.4/437-mtd-rawnand-brcmnand-improve-hamming-oob-layout.patch
@@ -0,0 +1,52 @@
+--- a/drivers/mtd/nand/raw/brcmnand/brcmnand.c
++++ b/drivers/mtd/nand/raw/brcmnand/brcmnand.c
+@@ -1003,33 +1003,30 @@ static int brcmnand_hamming_ooblayout_fr
+ struct brcmnand_cfg *cfg = &host->hwcfg;
+ int sas = cfg->spare_area_size << cfg->sector_size_1k;
+ int sectors = cfg->page_size / (512 << cfg->sector_size_1k);
++ u32 next;
+
+- if (section >= sectors * 2)
++ if (section > sectors)
+ return -ERANGE;
+
+- oobregion->offset = (section / 2) * sas;
++ next = (section * sas);
++ if (section < sectors)
++ next += 6;
+
+- if (section & 1) {
+- oobregion->offset += 9;
+- oobregion->length = 7;
++ if (section) {
++ oobregion->offset = ((section - 1) * sas) + 9;
+ } else {
+- oobregion->length = 6;
+-
+- /* First sector of each page may have BBI */
+- if (!section) {
+- /*
+- * Small-page NAND use byte 6 for BBI while large-page
+- * NAND use bytes 0 and 1.
+- */
+- if (cfg->page_size > 512) {
+- oobregion->offset += 2;
+- oobregion->length -= 2;
+- } else {
+- oobregion->length--;
+- }
++ if (cfg->page_size > 512) {
++ /* Large page NAND uses first 2 bytes for BBI */
++ oobregion->offset = 2;
++ } else {
++ /* Small page NAND uses last byte before ECC for BBI */
++ oobregion->offset = 0;
++ next--;
+ }
+ }
+
++ oobregion->length = next - oobregion->offset;
++
+ return 0;
+ }
+