]> git.baikalelectronics.ru Git - uboot.git/commitdiff
mtd: nand: Move Micron specific init logic in nand_micron.c
authorMichael Trimarchi <michael@amarulasolutions.com>
Wed, 20 Jul 2022 16:22:12 +0000 (18:22 +0200)
committerMichael Trimarchi <michael@amarulasolutions.com>
Fri, 22 Jul 2022 11:29:06 +0000 (13:29 +0200)
Upstream linux commit 10d4e75c36f6c1.

Move Micron specific initialization logic into nand_micron.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_micron.c [new file with mode: 0644]
include/linux/mtd/rawnand.h

index 16e0775395a2a5952891cf976636c7c6d3116051..8ef30b45fd2d5b354af5b24145bce3c75a40e329 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 nand_toshiba.o
+obj-$(CONFIG_SPL_NAND_BASE) += nand_base.o nand_hynix.o nand_micron.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)
@@ -32,6 +32,7 @@ obj-y += nand_util.o
 obj-y += nand_ecc.o
 obj-y += nand_base.o
 obj-y += nand_hynix.o
+obj-y += nand_micron.o
 obj-y += nand_samsung.o
 obj-y += nand_toshiba.o
 obj-y += nand_timings.o
index 4ea7f10a06fcda306c0a09f87f3317e818f3004d..fe7e049d4064fa726671bc5f8ac08c4cbb25ad78 100644 (file)
@@ -3871,30 +3871,6 @@ ext_out:
        return ret;
 }
 
-static int nand_setup_read_retry_micron(struct mtd_info *mtd, int retry_mode)
-{
-       struct nand_chip *chip = mtd_to_nand(mtd);
-       uint8_t feature[ONFI_SUBFEATURE_PARAM_LEN] = {retry_mode};
-
-       return chip->onfi_set_features(mtd, chip, ONFI_FEATURE_ADDR_READ_RETRY,
-                       feature);
-}
-
-/*
- * Configure chip properties from Micron vendor-specific ONFI table
- */
-static void nand_onfi_detect_micron(struct nand_chip *chip,
-               struct nand_onfi_params *p)
-{
-       struct nand_onfi_vendor_micron *micron = (void *)p->vendor;
-
-       if (le16_to_cpu(p->vendor_revision) < 1)
-               return;
-
-       chip->read_retries = micron->read_retry_options;
-       chip->setup_read_retry = nand_setup_read_retry_micron;
-}
-
 /*
  * Check if the NAND chip is ONFI compliant, returns 1 if it is, 0 otherwise.
  */
@@ -3994,9 +3970,6 @@ static int nand_flash_detect_onfi(struct mtd_info *mtd, struct nand_chip *chip)
                pr_warn("Could not retrieve ONFI ECC requirements\n");
        }
 
-       if (p->jedec_id == NAND_MFR_MICRON)
-               nand_onfi_detect_micron(chip, p);
-
        return 1;
 }
 #else
@@ -4272,10 +4245,8 @@ static void nand_decode_bbm_options(struct mtd_info *mtd,
         * Micron devices with 2KiB pages and on SLC Samsung, Hynix, Toshiba,
         * AMD/Spansion, and Macronix.  All others scan only the first page.
         */
-       if ((nand_is_slc(chip) &&
-            (maf_id == NAND_MFR_AMD ||
-             maf_id == NAND_MFR_MACRONIX)) ||
-           (mtd->writesize == 2048 && maf_id == NAND_MFR_MICRON))
+       if (nand_is_slc(chip) &&
+           (maf_id == NAND_MFR_AMD || maf_id == NAND_MFR_MACRONIX))
                chip->bbt_options |= NAND_BBT_SCAN2NDPAGE;
 }
 
index 509652c8e26c133dd15a1ac1dba383d24f3224f4..bb5ac8337fde42c4e07791206d0637a611d5d40b 100644 (file)
@@ -195,7 +195,7 @@ struct nand_manufacturers nand_manuf_ids[] = {
        {NAND_MFR_RENESAS, "Renesas"},
        {NAND_MFR_STMICRO, "ST Micro"},
        {NAND_MFR_HYNIX, "Hynix", &hynix_nand_manuf_ops},
-       {NAND_MFR_MICRON, "Micron"},
+       {NAND_MFR_MICRON, "Micron", &micron_nand_manuf_ops},
        {NAND_MFR_AMD, "AMD/Spansion"},
        {NAND_MFR_MACRONIX, "Macronix"},
        {NAND_MFR_EON, "Eon"},
diff --git a/drivers/mtd/nand/raw/nand_micron.c b/drivers/mtd/nand/raw/nand_micron.c
new file mode 100644 (file)
index 0000000..8b31c61
--- /dev/null
@@ -0,0 +1,87 @@
+// 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/mtd/rawnand.h>
+
+struct nand_onfi_vendor_micron {
+       u8 two_plane_read;
+       u8 read_cache;
+       u8 read_unique_id;
+       u8 dq_imped;
+       u8 dq_imped_num_settings;
+       u8 dq_imped_feat_addr;
+       u8 rb_pulldown_strength;
+       u8 rb_pulldown_strength_feat_addr;
+       u8 rb_pulldown_strength_num_settings;
+       u8 otp_mode;
+       u8 otp_page_start;
+       u8 otp_data_prot_addr;
+       u8 otp_num_pages;
+       u8 otp_feat_addr;
+       u8 read_retry_options;
+       u8 reserved[72];
+       u8 param_revision;
+} __packed;
+
+static int micron_nand_setup_read_retry(struct mtd_info *mtd, int retry_mode)
+{
+       struct nand_chip *chip = mtd_to_nand(mtd);
+       u8 feature[ONFI_SUBFEATURE_PARAM_LEN] = {retry_mode};
+
+       return chip->onfi_set_features(mtd, chip, ONFI_FEATURE_ADDR_READ_RETRY,
+                                      feature);
+}
+
+/*
+ * Configure chip properties from Micron vendor-specific ONFI table
+ */
+static int micron_nand_onfi_init(struct nand_chip *chip)
+{
+       struct nand_onfi_params *p = &chip->onfi_params;
+       struct nand_onfi_vendor_micron *micron = (void *)p->vendor;
+
+       if (!chip->onfi_version)
+               return 0;
+
+       if (le16_to_cpu(p->vendor_revision) < 1)
+               return 0;
+
+       chip->read_retries = micron->read_retry_options;
+       chip->setup_read_retry = micron_nand_setup_read_retry;
+
+       return 0;
+}
+
+static int micron_nand_init(struct nand_chip *chip)
+{
+       struct mtd_info *mtd = nand_to_mtd(chip);
+       int ret;
+
+       ret = micron_nand_onfi_init(chip);
+       if (ret)
+               return ret;
+
+       if (mtd->writesize == 2048)
+               chip->bbt_options |= NAND_BBT_SCAN2NDPAGE;
+
+       return 0;
+}
+
+const struct nand_manufacturer_ops micron_nand_manuf_ops = {
+       .init = micron_nand_init,
+};
index 73abb3401649b9b47769d8ddadbbbfeb9ef0895d..ec0f77b24bd6ad0f33d5455dc61f764eed278de9 100644 (file)
@@ -388,26 +388,6 @@ struct onfi_ext_param_page {
         */
 } __packed;
 
-struct nand_onfi_vendor_micron {
-       u8 two_plane_read;
-       u8 read_cache;
-       u8 read_unique_id;
-       u8 dq_imped;
-       u8 dq_imped_num_settings;
-       u8 dq_imped_feat_addr;
-       u8 rb_pulldown_strength;
-       u8 rb_pulldown_strength_feat_addr;
-       u8 rb_pulldown_strength_num_settings;
-       u8 otp_mode;
-       u8 otp_page_start;
-       u8 otp_data_prot_addr;
-       u8 otp_num_pages;
-       u8 otp_feat_addr;
-       u8 read_retry_options;
-       u8 reserved[72];
-       u8 param_revision;
-} __packed;
-
 struct jedec_ecc_info {
        u8 ecc_bits;
        u8 codeword_size;
@@ -1161,6 +1141,7 @@ 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;
+extern const struct nand_manufacturer_ops micron_nand_manuf_ops;
 
 int nand_default_bbt(struct mtd_info *mtd);
 int nand_markbad_bbt(struct mtd_info *mtd, loff_t offs);