mtd: nand: denali: max_banks calculation changed in revision 5.1
authorGraham Moore <grmoore@opensource.altera.com>
Tue, 21 Jul 2015 14:39:31 +0000 (09:39 -0500)
committerBrian Norris <computersforpeace@gmail.com>
Tue, 29 Sep 2015 18:44:59 +0000 (11:44 -0700)
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@opensource.altera.com>
[Brian: parentheses around macro arg]
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
drivers/mtd/nand/denali.c
drivers/mtd/nand/denali.h

index 7b6186ffe3accd5ef25e8260a32260f89fb02e2d..43c0771c587cfb53531d77f6e42a00e0ac51ab23 100644 (file)
@@ -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)
index 145bf88930e82e24a6e9cd43fbd1a2cf81a60e0e..4b12cd302819ac21479ef84d5cee3237f7514834 100644 (file)
 
 #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