mtd: rawnand: add defines for ONFI version bits
authorChris Packham <chris.packham@alliedtelesis.co.nz>
Sun, 24 Jun 2018 22:44:45 +0000 (10:44 +1200)
committerMiquel Raynal <miquel.raynal@bootlin.com>
Mon, 2 Jul 2018 07:02:22 +0000 (09:02 +0200)
Add defines for the ONFI version bits and use them in
nand_flash_detect_onfi().

Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
Reviewed-by: Boris Brezillon <boris.brezillon@bootlin.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
drivers/mtd/nand/raw/nand_base.c
include/linux/mtd/rawnand.h

index f362c09a71d7f74424ac0fb3c2e5ad09fce9d4ec..dbf6e80e9ab5240664d9095019a3e210647ae94d 100644 (file)
@@ -5174,15 +5174,15 @@ static int nand_flash_detect_onfi(struct nand_chip *chip)
 
        /* Check version */
        val = le16_to_cpu(p->revision);
-       if (val & (1 << 5))
+       if (val & ONFI_VERSION_2_3)
                chip->parameters.onfi.version = 23;
-       else if (val & (1 << 4))
+       else if (val & ONFI_VERSION_2_2)
                chip->parameters.onfi.version = 22;
-       else if (val & (1 << 3))
+       else if (val & ONFI_VERSION_2_1)
                chip->parameters.onfi.version = 21;
-       else if (val & (1 << 2))
+       else if (val & ONFI_VERSION_2_0)
                chip->parameters.onfi.version = 20;
-       else if (val & (1 << 1))
+       else if (val & ONFI_VERSION_1_0)
                chip->parameters.onfi.version = 10;
 
        if (!chip->parameters.onfi.version) {
index dc4538b58b84267738266095d18381ccad8b367e..fbac4741da5248f12ee906873f9aa7e189645ef5 100644 (file)
@@ -237,6 +237,17 @@ enum nand_ecc_algo {
 /* Keep gcc happy */
 struct nand_chip;
 
+/* ONFI version bits */
+#define ONFI_VERSION_1_0               BIT(1)
+#define ONFI_VERSION_2_0               BIT(2)
+#define ONFI_VERSION_2_1               BIT(3)
+#define ONFI_VERSION_2_2               BIT(4)
+#define ONFI_VERSION_2_3               BIT(5)
+#define ONFI_VERSION_3_0               BIT(6)
+#define ONFI_VERSION_3_1               BIT(7)
+#define ONFI_VERSION_3_2               BIT(8)
+#define ONFI_VERSION_4_0               BIT(9)
+
 /* ONFI features */
 #define ONFI_FEATURE_16_BIT_BUS                (1 << 0)
 #define ONFI_FEATURE_EXT_PARAM_PAGE    (1 << 7)