mtd: nand: denali: max_banks calculation changed in revision 5.1

Linux-MTD Mailing List linux-mtd at lists.infradead.org
Fri Nov 6 10:59:05 PST 2015


Gitweb:     http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=271707b1d817f5104e02b2bd1bab43f0c8759418
Commit:     271707b1d817f5104e02b2bd1bab43f0c8759418
Parent:     9c07d094bbfe3d09e4c3e01a81cd1399bd23b268
Author:     Graham Moore <grmoore at opensource.altera.com>
AuthorDate: Tue Jul 21 09:39:31 2015 -0500
Committer:  Brian Norris <computersforpeace at gmail.com>
CommitDate: Tue Sep 29 11:44:59 2015 -0700

    mtd: nand: denali: max_banks calculation changed in revision 5.1
    
    Read Denali hardware revision number and use it to
    calculate max_banks,  The encoding of max_banks changed
    in Denali revision 5.1.
    
    Signed-off-by: Graham Moore <grmoore at opensource.altera.com>
    [Brian: parentheses around macro arg]
    Signed-off-by: Brian Norris <computersforpeace at gmail.com>
---
 drivers/mtd/nand/denali.c | 11 ++++++++++-
 drivers/mtd/nand/denali.h |  2 ++
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/nand/denali.c b/drivers/mtd/nand/denali.c
index 7b6186f..43c0771 100644
--- a/drivers/mtd/nand/denali.c
+++ b/drivers/mtd/nand/denali.c
@@ -458,8 +458,17 @@ static void find_valid_banks(struct denali_nand_info *denali)
 static void detect_max_banks(struct denali_nand_info *denali)
 {
 	uint32_t features = ioread32(denali->flash_reg + FEATURES);
+	/*
+	 * Read the revision register, so we can calculate the max_banks
+	 * properly: the encoding changed from rev 5.0 to 5.1
+	 */
+	u32 revision = MAKE_COMPARABLE_REVISION(
+				ioread32(denali->flash_reg + REVISION));
 
-	denali->max_banks = 2 << (features & FEATURES__N_BANKS);
+	if (revision < REVISION_5_1)
+		denali->max_banks = 2 << (features & FEATURES__N_BANKS);
+	else
+		denali->max_banks = 1 << (features & FEATURES__N_BANKS);
 }
 
 static void detect_partition_feature(struct denali_nand_info *denali)
diff --git a/drivers/mtd/nand/denali.h b/drivers/mtd/nand/denali.h
index 145bf88..4b12cd3 100644
--- a/drivers/mtd/nand/denali.h
+++ b/drivers/mtd/nand/denali.h
@@ -178,6 +178,8 @@
 
 #define REVISION				0x370
 #define     REVISION__VALUE				0xffff
+#define MAKE_COMPARABLE_REVISION(x)		swab16((x) & REVISION__VALUE)
+#define REVISION_5_1				0x00000501
 
 #define ONFI_DEVICE_FEATURES			0x380
 #define     ONFI_DEVICE_FEATURES__VALUE			0x003f



More information about the linux-mtd-cvs mailing list