From patchwork Thu Jul 14 14:02:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Trimarchi X-Patchwork-Id: 2165 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id E26553F013 for ; Thu, 14 Jul 2022 16:02:45 +0200 (CEST) Received: by mail-wm1-f71.google.com with SMTP id 130-20020a1c0288000000b003a2fe999093sf1812090wmc.6 for ; Thu, 14 Jul 2022 07:02:45 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1657807365; cv=pass; d=google.com; s=arc-20160816; b=HxHkGEE0cU4FWWsWkjXq9DjKqF47hYQ7JAiyrguRVF8loIAApWD+FF1reF8a8ka72Y Zl7zSMrPunv0+JbP+UUxN3gfE0APsSNTOgM6+b4crFo7GDc/dHA+EMlotMGYq+UbsOvN 7lRqN1MHgu4ivuVAM0NLbMjCBI69joMiVoeEK05rVUXnwcG4P0acNxyj5N5ZKrvCiNKt mcXIjjnq6owjJrn2XC8LpMKxZAtNYBVec6NZ5MrTLIpno9kS1dN0Ez2e1XFB0R02QoSE 009inu/t2BIxwcARaxqERQs+4XMcz458TsKwd+79bwfB2rpPpv0LFI949MheiB2YJHZd s9ug== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:to:from:dkim-signature; bh=8hUoPkqEiSFS6XPC2M/gUARltnImO/Au3/3jE9dEg08=; b=Q8DHJL1ix8oKalgL9PdA0GaXtwbw5oKmmcJDEcAAffcZtQTAImP460RmiExpkotjee 2XO3mLSOjHNw9eUAqv412UzhUJwC4Wy0nE1ylW7rAewhBw8ad87etx/4wyK8nSwxhstM OV/Wh8CQ31OOfl6OzRDc1EyUfqmxvbRxlkjCgY+ZAZFcM2zjzjZSTLlKWvnfHWvmg7GT 0V6Vspd14taEXfEkGrAsFoXRCSANKI08rdff/cg6fx0o9NbfKzuSXQ0sRxNrB3DcL9hR sO9hksovhIXRoJCtcx6S+KbbMSMRyjwyznVX2i4Wq4dFQQ1Ewj0QqUcV8Vj5s1LZUCsR HD3A== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=Ub7oxuOI; spf=pass (google.com: domain of michael@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=michael@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :x-original-sender:x-original-authentication-results:precedence :mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=8hUoPkqEiSFS6XPC2M/gUARltnImO/Au3/3jE9dEg08=; b=NcMA6JFc4GBtXSFO9nKaRKTZZyDq++hA5AH7ia+0IkcVsxaWIB53gQ8wE9UNlen1XU uGe5umQ1kDkKblG8fpUTcM5bfdrgZDojKDysC5R0ahmP2/n5PEJzKp0F16Lu50I9f9hY 2GxR/i6sXl/5a1pun8ILCa7FIs0p33HiSxVc0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-unsubscribe; bh=8hUoPkqEiSFS6XPC2M/gUARltnImO/Au3/3jE9dEg08=; b=kzrsEO5hrl3iR/7guCrKA4ieoBrS/HIUjB8XCfldqH/YcaorkYvtHuT7yBDUBi0lPI fZey19XhjROXWkJHVBM2nydN30x5tEcVkPA7XqBWiICyf+r+D8Tdo8GuShT8qLQsqr0g kWE7Wo8aLa0iXrQ8rZ5WhU5Dj/wuLHOmAPJpJVgwJ7HphixP0pOCV3D2gu1wmZkiFDJw n2ZsIEQC+YtKCYJEOGLwUIO2gBRY1tlWUn9EfkbfQWGVykxJr7Q9Wmmr1zi2T4R+5EDR t8QR9sdT9u0Bda16h5EjjrxQYd6VNffRrR3YWq6MacBdGNPVfQ9w7u5DoIfnuOe4tuIY DIQw== X-Gm-Message-State: AJIora9XQ7g39s+zGJ9qUhBZgijpVaBevN2AjOMSm9YOxTe2idq8ioLe OlTfpf5974pTuS6E1hvLaZIznN2A X-Google-Smtp-Source: AGRyM1uQdMu2/m9LSa54epzPRVf1gjQrm2TqbT3CadMVmDvx1IV1ldFUjCF1rrpSg4o3AlMNUVHZEg== X-Received: by 2002:a5d:4890:0:b0:21d:9bf3:89b5 with SMTP id g16-20020a5d4890000000b0021d9bf389b5mr8398248wrq.153.1657807365696; Thu, 14 Jul 2022 07:02:45 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a5d:64af:0:b0:21d:bf45:f904 with SMTP id m15-20020a5d64af000000b0021dbf45f904ls112421wrp.3.gmail; Thu, 14 Jul 2022 07:02:44 -0700 (PDT) X-Received: by 2002:adf:f245:0:b0:21d:a39a:bed5 with SMTP id b5-20020adff245000000b0021da39abed5mr8254400wrp.508.1657807364512; Thu, 14 Jul 2022 07:02:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657807364; cv=none; d=google.com; s=arc-20160816; b=H/wYIZq11Z1FZli58NfNhpzIIM6KnrcvrLE4ZDorUNMJxi41VUZ+31RM5cQ2wWZI91 jJD0W4jYCkNXKwMCZxf8nzyVRHJ1wp2geqyQrM06NWZdLxQFSjM3E337U99xBldqsPHU RD6uVRc+zhicGTNZ9wSRySdw+Ha6jLi62GdsoSs0FlOYF/fX5KJt3mSBcFmgDs5WyMMV Mq15rcS6ofxYyGJ1x4qQHIikS95V019Eb3hlXbM3IjS9WVhDj/cFBX1T7tZSYhoqUZB3 7JfPLFRKYvE+jLWu14YVKyGtOFJJlP+UnzNPQBNb+vf2+88OQweTDqJJoJlQ3+nJebTe xuCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:dkim-signature; bh=sFuEqjFl/Mfka6FIE5bPT04aWRpTL+eJm4w2Fjxnrrg=; b=NNqNdYI9A9t2pw3ZCbhsBEXbwJvpUhDHGCUJSRohY51911WVNYBVitNuyAa4sHG5p6 U8oVTUuRHCnkv/43ll1PuFVQ4XuGe2WTxe1vcuKY4P73ke/J7EpullsIsv5Lc2XdhQt1 nYnze3GghK45ndrT8BGJMYHzIHil4kZFbLx20GYFOg7SIU89ITUwj0Hv2UpC9eYizKfH 70+mn1ED+gaoWaedjVh2eox6lonK2SeANzP7vXB/fj54Ac7HbzwhveU0gTvis7ABq/n9 H+5+Gz/hHOc1HocrlSLqKCIPhH37lPJpYJfKcnjG3bQiwzylpwPrBADEYoRgJQItZA9p ro4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=Ub7oxuOI; spf=pass (google.com: domain of michael@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=michael@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id n6-20020a5d5886000000b0021b89b50004sor846698wrf.44.2022.07.14.07.02.44 for (Google Transport Security); Thu, 14 Jul 2022 07:02:44 -0700 (PDT) Received-SPF: pass (google.com: domain of michael@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; X-Received: by 2002:a05:6000:887:b0:21d:4fca:44fc with SMTP id ca7-20020a056000088700b0021d4fca44fcmr8561501wrb.495.1657807363744; Thu, 14 Jul 2022 07:02:43 -0700 (PDT) Received: from panicking.. ([2.198.242.86]) by smtp.gmail.com with ESMTPSA id k11-20020a7bc40b000000b0039c5cecf206sm2029114wmi.4.2022.07.14.07.02.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Jul 2022 07:02:43 -0700 (PDT) From: Michael Trimarchi To: linux-amarula@amarulasolutions.com, Dario Binacchi , Tommaso Merciai Subject: [PATCH 11/11] mtd: nand: Move Macronix specific initialization in nand_macronix.c Date: Thu, 14 Jul 2022 16:02:15 +0200 Message-Id: <20220714140215.444993-12-michael@amarulasolutions.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220714140215.444993-1-michael@amarulasolutions.com> References: <20220714140215.444993-1-michael@amarulasolutions.com> MIME-Version: 1.0 X-Original-Sender: michael@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=Ub7oxuOI; spf=pass (google.com: domain of michael@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=michael@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Upstream commit 3b5206f4be9b65d2f0f85b3239cf117a1d0de7ce Move Macronix specific initialization logic into nand_macronix.c. This is part of the "separate vendor specific code from core" cleanup process. Signed-off-by: Boris Brezillon Signed-off-by: Michael Trimarchi --- drivers/mtd/nand/raw/Makefile | 4 +++- drivers/mtd/nand/raw/nand_base.c | 11 ---------- drivers/mtd/nand/raw/nand_ids.c | 2 +- drivers/mtd/nand/raw/nand_macronix.c | 32 ++++++++++++++++++++++++++++ include/linux/mtd/rawnand.h | 1 + 5 files changed, 37 insertions(+), 13 deletions(-) create mode 100644 drivers/mtd/nand/raw/nand_macronix.c diff --git a/drivers/mtd/nand/raw/Makefile b/drivers/mtd/nand/raw/Makefile index e1d511c12c..c8317a1078 100644 --- a/drivers/mtd/nand/raw/Makefile +++ b/drivers/mtd/nand/raw/Makefile @@ -14,7 +14,8 @@ 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_amd.o nand_hynix.o nand_micron.o \ +obj-$(CONFIG_SPL_NAND_BASE) += nand_base.o nand_amd.o nand_hynix.o \ + nand_macronix.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 @@ -34,6 +35,7 @@ obj-y += nand_ecc.o obj-y += nand_base.o obj-y += nand_amd.o obj-y += nand_hynix.o +obj-y += nand_macronix.o obj-y += nand_micron.o obj-y += nand_samsung.o obj-y += nand_toshiba.o diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c index f79e57b9fb..a38cc4d135 100644 --- a/drivers/mtd/nand/raw/nand_base.c +++ b/drivers/mtd/nand/raw/nand_base.c @@ -4218,22 +4218,11 @@ static void nand_decode_id(struct nand_chip *chip, static void nand_decode_bbm_options(struct mtd_info *mtd, struct nand_chip *chip) { - int maf_id = chip->id.data[0]; - /* Set the bad block position */ if (mtd->writesize > 512 || (chip->options & NAND_BUSWIDTH_16)) chip->badblockpos = NAND_LARGE_BADBLOCK_POS; else chip->badblockpos = NAND_SMALL_BADBLOCK_POS; - - /* - * Bad block marker is stored in the last page of each block on Samsung - * and Hynix MLC devices; stored in first two pages of each block on - * 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_MACRONIX) - chip->bbt_options |= NAND_BBT_SCAN2NDPAGE; } static inline bool is_full_id_nand(struct nand_flash_dev *type) diff --git a/drivers/mtd/nand/raw/nand_ids.c b/drivers/mtd/nand/raw/nand_ids.c index c78f2e0880..7602dd30f1 100644 --- a/drivers/mtd/nand/raw/nand_ids.c +++ b/drivers/mtd/nand/raw/nand_ids.c @@ -197,7 +197,7 @@ struct nand_manufacturers nand_manuf_ids[] = { {NAND_MFR_HYNIX, "Hynix", &hynix_nand_manuf_ops}, {NAND_MFR_MICRON, "Micron", µn_nand_manuf_ops}, {NAND_MFR_AMD, "AMD/Spansion", &amd_nand_manuf_ops}, - {NAND_MFR_MACRONIX, "Macronix"}, + {NAND_MFR_MACRONIX, "Macronix", ¯onix_nand_manuf_ops}, {NAND_MFR_EON, "Eon"}, {NAND_MFR_SANDISK, "SanDisk"}, {NAND_MFR_INTEL, "Intel"}, diff --git a/drivers/mtd/nand/raw/nand_macronix.c b/drivers/mtd/nand/raw/nand_macronix.c new file mode 100644 index 0000000000..3cccb5869a --- /dev/null +++ b/drivers/mtd/nand/raw/nand_macronix.c @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2017 Free Electrons + * Copyright (C) 2017 NextThing Co + * + * Author: Boris Brezillon + * + * 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 +#include +#include + +static int macronix_nand_init(struct nand_chip *chip) +{ + if (nand_is_slc(chip)) + chip->bbt_options |= NAND_BBT_SCAN2NDPAGE; + + return 0; +} + +const struct nand_manufacturer_ops macronix_nand_manuf_ops = { + .init = macronix_nand_init, +}; diff --git a/include/linux/mtd/rawnand.h b/include/linux/mtd/rawnand.h index bb1a359a9c..aa45558b3d 100644 --- a/include/linux/mtd/rawnand.h +++ b/include/linux/mtd/rawnand.h @@ -1143,6 +1143,7 @@ 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; extern const struct nand_manufacturer_ops amd_nand_manuf_ops; +extern const struct nand_manufacturer_ops macronix_nand_manuf_ops; int nand_default_bbt(struct mtd_info *mtd); int nand_markbad_bbt(struct mtd_info *mtd, loff_t offs);