]> git.sur5r.net Git - u-boot/commitdiff
mtd: nand: denali: max_banks calculation changed in revision 5.1
authorGraham Moore <grmoore@opensource.altera.com>
Thu, 24 Mar 2016 13:14:35 +0000 (22:14 +0900)
committerMasahiro Yamada <yamada.masahiro@socionext.com>
Thu, 31 Mar 2016 15:16:55 +0000 (00:16 +0900)
Read Denali hardware revision number and use it to
calculate max_banks,  The encoding of max_banks changed
in Denali revision 5.1.

[ Linux commit : 271707b1d817f5104e02b2bd1bab43f0c8759418 ]

Signed-off-by: Graham Moore <grmoore@opensource.altera.com>
[Brian: parentheses around macro arg]
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
[Masahiro: import from Linux and adjust ioread32() to readl() ]
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
drivers/mtd/nand/denali.c
drivers/mtd/nand/denali.h

index 018d14fc8130486f6c366a1788d79d1a690d2c0b..5894fcc4a8eedece6232fb3b8562fda9d9d10e77 100644 (file)
@@ -431,7 +431,16 @@ static void find_valid_banks(struct denali_nand_info *denali)
 static void detect_max_banks(struct denali_nand_info *denali)
 {
        uint32_t features = readl(denali->flash_reg + FEATURES);
-       denali->max_banks = 2 << (features & FEATURES__N_BANKS);
+       /*
+        * 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(
+                               readl(denali->flash_reg + REVISION));
+       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 93b57259d6125cd117160f7eaa3dcdc5362afb67..db1457a680eef809e282f2175c52ea5b3d99c803 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