]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
mtd: nand: Move Toshiba specific init/detection logic in nand_toshiba.c
authorMichael Trimarchi <michael@amarulasolutions.com>
Wed, 20 Jul 2022 16:22:11 +0000 (18:22 +0200)
committerMichael Trimarchi <michael@amarulasolutions.com>
Fri, 22 Jul 2022 11:29:06 +0000 (13:29 +0200)
Upstream linux commit 9b2d61f80b060c.

Move Toshiba specific initialization and detection logic into
nand_toshiba.c. This is part of the "separate vendor specific code from
core" cleanup process.

Signed-off-by: Michael Trimarchi <michael@amarulasolutions.com>
Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
drivers/mtd/nand/raw/Makefile
drivers/mtd/nand/raw/nand_base.c
drivers/mtd/nand/raw/nand_ids.c
drivers/mtd/nand/raw/nand_toshiba.c [new file with mode: 0644]
include/linux/mtd/rawnand.h

index 86d9b8e8beb8aa8b004f075fae8711bc649f1e1c..16e0775395a2a5952891cf976636c7c6d3116051 100644 (file)
@@ -14,7 +14,7 @@ obj-$(CONFIG_SPL_NAND_DENALI) += denali_spl.o
 obj-$(CONFIG_SPL_NAND_SIMPLE) += nand_spl_simple.o
 obj-$(CONFIG_SPL_NAND_LOAD) += nand_spl_load.o
 obj-$(CONFIG_SPL_NAND_ECC) += nand_ecc.o
-obj-$(CONFIG_SPL_NAND_BASE) += nand_base.o nand_hynix.o nand_samsung.o
+obj-$(CONFIG_SPL_NAND_BASE) += nand_base.o nand_hynix.o nand_samsung.o nand_toshiba.o
 obj-$(CONFIG_SPL_NAND_IDENT) += nand_ids.o nand_timings.o
 obj-$(CONFIG_TPL_NAND_INIT) += nand.o
 ifeq ($(CONFIG_SPL_ENV_SUPPORT),y)
@@ -33,6 +33,7 @@ obj-y += nand_ecc.o
 obj-y += nand_base.o
 obj-y += nand_hynix.o
 obj-y += nand_samsung.o
+obj-y += nand_toshiba.o
 obj-y += nand_timings.o
 
 endif # not spl
index 5698c1e6a229715a86bd95f899c8d7249b1b7511..4ea7f10a06fcda306c0a09f87f3317e818f3004d 100644 (file)
@@ -4163,12 +4163,11 @@ static int nand_get_bits_per_cell(u8 cellinfo)
 void nand_decode_ext_id(struct nand_chip *chip)
 {
        struct mtd_info *mtd = &chip->mtd;
-       int extid, id_len;
+       int extid;
        /* The 3rd id byte holds MLC / multichip data */
        chip->bits_per_cell = nand_get_bits_per_cell(chip->id.data[2]);
        /* The 4th id byte is the important one */
        extid = chip->id.data[3];
-       id_len = chip->id.len;
 
        /* Calc pagesize */
        mtd->writesize = 1024 << (extid & 0x03);
@@ -4184,21 +4183,6 @@ void nand_decode_ext_id(struct nand_chip *chip)
        /* Get buswidth information */
        if (extid & 0x1)
                chip->options |= NAND_BUSWIDTH_16;
-
-       /*
-        * Toshiba 24nm raw SLC (i.e., not BENAND) have 32B OOB per
-        * 512B page. For Toshiba SLC, we decode the 5th/6th byte as
-        * follows:
-        * - ID byte 6, bits[2:0]: 100b -> 43nm, 101b -> 32nm,
-        *                         110b -> 24nm
-        * - ID byte 5, bit[7]:    1 -> BENAND, 0 -> raw SLC
-        */
-       if (id_len >= 6 && chip->id.data[0] == NAND_MFR_TOSHIBA &&
-           nand_is_slc(chip) &&
-           (chip->id.data[5] & 0x7) == 0x6 /* 24nm */ &&
-           !(chip->id.data[4] & 0x80) /* !BENAND */) {
-               mtd->oobsize = 32 * mtd->writesize >> 9;
-       }
 }
 EXPORT_SYMBOL_GPL(nand_decode_ext_id);
 
@@ -4289,8 +4273,7 @@ static void nand_decode_bbm_options(struct mtd_info *mtd,
         * AMD/Spansion, and Macronix.  All others scan only the first page.
         */
        if ((nand_is_slc(chip) &&
-            (maf_id == NAND_MFR_TOSHIBA ||
-             maf_id == NAND_MFR_AMD ||
+            (maf_id == NAND_MFR_AMD ||
              maf_id == NAND_MFR_MACRONIX)) ||
            (mtd->writesize == 2048 && maf_id == NAND_MFR_MICRON))
                chip->bbt_options |= NAND_BBT_SCAN2NDPAGE;
index ec263a43279ae201e93bfdc4821ff77fc1ba89ea..509652c8e26c133dd15a1ac1dba383d24f3224f4 100644 (file)
@@ -188,7 +188,7 @@ struct nand_flash_dev nand_flash_ids[] = {
 
 /* Manufacturer IDs */
 struct nand_manufacturers nand_manuf_ids[] = {
-       {NAND_MFR_TOSHIBA, "Toshiba"},
+       {NAND_MFR_TOSHIBA, "Toshiba", &toshiba_nand_manuf_ops},
        {NAND_MFR_SAMSUNG, "Samsung", &samsung_nand_manuf_ops},
        {NAND_MFR_FUJITSU, "Fujitsu"},
        {NAND_MFR_NATIONAL, "National"},
diff --git a/drivers/mtd/nand/raw/nand_toshiba.c b/drivers/mtd/nand/raw/nand_toshiba.c
new file mode 100644 (file)
index 0000000..f7426fa
--- /dev/null
@@ -0,0 +1,53 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2017 Free Electrons
+ * Copyright (C) 2017 NextThing Co
+ *
+ * Author: Boris Brezillon <boris.brezillon@free-electrons.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/bug.h>
+#include <linux/mtd/rawnand.h>
+
+static void toshiba_nand_decode_id(struct nand_chip *chip)
+{
+       struct mtd_info *mtd = nand_to_mtd(chip);
+
+       nand_decode_ext_id(chip);
+
+       /*
+        * Toshiba 24nm raw SLC (i.e., not BENAND) have 32B OOB per
+        * 512B page. For Toshiba SLC, we decode the 5th/6th byte as
+        * follows:
+        * - ID byte 6, bits[2:0]: 100b -> 43nm, 101b -> 32nm,
+        *                         110b -> 24nm
+        * - ID byte 5, bit[7]:    1 -> BENAND, 0 -> raw SLC
+        */
+       if (chip->id.len >= 6 && nand_is_slc(chip) &&
+           (chip->id.data[5] & 0x7) == 0x6 /* 24nm */ &&
+           !(chip->id.data[4] & 0x80) /* !BENAND */)
+               mtd->oobsize = 32 * mtd->writesize >> 9;
+}
+
+static int toshiba_nand_init(struct nand_chip *chip)
+{
+       if (nand_is_slc(chip))
+               chip->bbt_options |= NAND_BBT_SCAN2NDPAGE;
+
+       return 0;
+}
+
+const struct nand_manufacturer_ops toshiba_nand_manuf_ops = {
+       .detect = toshiba_nand_decode_id,
+       .init = toshiba_nand_init,
+};
index d35277d187991956fba5283b3c0aa6548450cfc1..73abb3401649b9b47769d8ddadbbbfeb9ef0895d 100644 (file)
@@ -1158,6 +1158,7 @@ struct nand_manufacturers {
 extern struct nand_flash_dev nand_flash_ids[];
 extern struct nand_manufacturers nand_manuf_ids[];
 
+extern const struct nand_manufacturer_ops toshiba_nand_manuf_ops;
 extern const struct nand_manufacturer_ops samsung_nand_manuf_ops;
 extern const struct nand_manufacturer_ops hynix_nand_manuf_ops;