diff options
author | Graham Moore <grmoore@opensource.altera.com> | 2016-03-24 22:14:35 +0900 |
---|---|---|
committer | Masahiro Yamada <yamada.masahiro@socionext.com> | 2016-04-01 00:16:55 +0900 |
commit | 15305c2f0334c52d1afaed7cf7dcaa6944019f68 (patch) | |
tree | 8e1816a7e09537c8240ffde6dd897932133bf026 | |
parent | 080c499df689e8c42df70de44502c0d71533dda8 (diff) |
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.
[ 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>
-rw-r--r-- | drivers/mtd/nand/denali.c | 11 | ||||
-rw-r--r-- | drivers/mtd/nand/denali.h | 2 |
2 files changed, 12 insertions, 1 deletions
diff --git a/drivers/mtd/nand/denali.c b/drivers/mtd/nand/denali.c index 018d14fc81..5894fcc4a8 100644 --- a/drivers/mtd/nand/denali.c +++ b/drivers/mtd/nand/denali.c @@ -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) diff --git a/drivers/mtd/nand/denali.h b/drivers/mtd/nand/denali.h index 93b57259d6..db1457a680 100644 --- a/drivers/mtd/nand/denali.h +++ b/drivers/mtd/nand/denali.h @@ -166,6 +166,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 |