From patchwork Thu Jul 14 14:35:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Trimarchi X-Patchwork-Id: 2177 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 3A59C3F066 for ; Thu, 14 Jul 2022 16:36:28 +0200 (CEST) Received: by mail-wr1-f69.google.com with SMTP id k26-20020adfb35a000000b0021d6c3b9363sf600063wrd.1 for ; Thu, 14 Jul 2022 07:36:28 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1657809388; cv=pass; d=google.com; s=arc-20160816; b=G0bsBM5o4wHYNiSl2R+VtJ+2e2rmN1rRRgYWzEcZDfMwRQlT46ZpZspDiLjqiRHqN6 yV7mBZHet2M2w8a3dsT8MZo1m2z9PdpHKyhZd81m5FqO/JXN+JXnpr4p/kXqVEnUvp2u A7bzs+25jr00qsmw5o81qHIswb6FzZsw6Zwt/BHtgzLUPO39YPylxQpL3K1+exAoiCEZ uOn0hAyf5Fd7OzWLOFUaqfhchSIkWG+4/DtXUmm3qTyD6+mYBqYXvOoonedN6/0zHktT 8hX7r9XUWDVW+Q4yZ/LTU2fteCim8JGLxbNEc5hX+WX95D9YY977hWaLg7L0qv3V2BMc gRIg== 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:cc:to:from:dkim-signature; bh=8hUoPkqEiSFS6XPC2M/gUARltnImO/Au3/3jE9dEg08=; b=QeFofFwJ51sPVbIVlY55LGNyy+eOIrjShAtgHVyDimucQNVu5W/y2Z5IsFsYt/JzJh DCWqD2wc1NNkhMZRpxo2I5RhvcPmhL2Zraf/pSGUn7gLhACiTJcJT7iJ2ZaGlO+vRInm sByhEqsh8aJSWiBUDDVrkB95ZUVb3VrVT55GHNvlrAfD4mkZfvFbWlZTHouPKGv15jLB UhFreXZiNcqCcPWyxFH0XhxmpSU/1hOjuFxxgAe8/H8bXVA4ntT/NqstZMekRJOxzck3 tjp+qOHgNKayblGduax+olR+SyqV8K/Gx1nBUC5Lvw9MZ3yhdy62G65C/oae5d4kDYgT qXew== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=d6LIp2T3; 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:cc: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=YPC2xHE2Fdiax0PM59u8ZS4FGRmCZSNV8yj01UYW/0NZaIqh/r2/VgA0AKxEvbvvPX Y9whea/TON0jae8Fdo45h9xJ95POzA658de5mgXW4smXAHZXB5JzbJE3eHtxe9Ypsf/F Q6tF/YHJbMhaA1msJh4gLtcPAQxF8wjIVTrHc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc: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=ayTSSZqIQJYbzXHO4vjeFWEum7tU7xykFW5uJV6AhmZ+BCYv0Hwt2534CfdkjJ3RT8 OEdHx6SoTWM/blHETvH73pb9MwOmzd+2aA/+LfzEDRIiK/egVM/mqma5BWXHwqdZso3E OIle7JChlARkLyYJ/gHXmmaNpjQXg9gD+g7SPZ4/p5CGe3/IkwTsxLY5izqy1XS3zpVh lyTN1oDpQT4H9p1ba6kcUdQPDFNpHzs9cQss1I6C0NtBeLVdGDKe9NESKOV630CD4Tu1 KRV7RDnZim8K2B73lwc0w5+WYgDxG5Vb452ZI3UQYiY4mY0JM8Y4m1ewfw5JcZnCM4hD mwpw== X-Gm-Message-State: AJIora83uAYR6H597rcKbKX+M3e/Vo9s7luXlkxNwB2yV3JGGEXV+U+n FbcLo09obFhZx7JcKqsWTXeRvHTc X-Google-Smtp-Source: AGRyM1tyevYuGki13Q6ZYbYyw/fJRO6LLHOMdIik/WgQhQygLzV1qJb9IWdhNNGivI25KTKau0gurQ== X-Received: by 2002:a05:6000:3c3:b0:21d:9a5e:5326 with SMTP id b3-20020a05600003c300b0021d9a5e5326mr8401719wrg.93.1657809388021; Thu, 14 Jul 2022 07:36:28 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:600c:3485:b0:3a2:e5bf:aeec with SMTP id a5-20020a05600c348500b003a2e5bfaeecls6275824wmq.0.canary-gmail; Thu, 14 Jul 2022 07:36:26 -0700 (PDT) X-Received: by 2002:a7b:cd82:0:b0:3a1:7528:2d79 with SMTP id y2-20020a7bcd82000000b003a175282d79mr15757034wmj.79.1657809386739; Thu, 14 Jul 2022 07:36:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657809386; cv=none; d=google.com; s=arc-20160816; b=mbIxZbPsO/j9VAQ4H6vAmXZ65ZliP5XdYtq3q3hkFNU0pKibWe1vWh8s1FrD3O+q4L tSuHuSqXxxouhVQ6nKxzbmdE+mZCsBlcMdXTGYMTfeszBlhOHj+dBRPgL16KTlkYxIym ToTkDqT8myHugGh/m3QAKulWhU2zovnogvlLSk/hQLnh6M6S9UjIGuDN/I38Zl2Hpzl8 Pxt0P3TtHLsBkhTdSCnAcA159g7iCUwFgj2+ew1u1YG3pnhtIJyp6Dko+mnphcgwsavc IL0ksqiv5deQZI1w+I1Ey/GpseBQJPtU8BRbeUHXC26k+5APMylrC4oo60H6/7rDlkDw t+yQ== 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:cc:to:from:dkim-signature; bh=sFuEqjFl/Mfka6FIE5bPT04aWRpTL+eJm4w2Fjxnrrg=; b=mr828daIVM6LxA48ilnagFXOnVMnLR634Sk7z8/L8BTobVKWCcsf3Vr7d64lNKdC6q rcKpVA+21/XI9MFg23jUqJBF8N2X2s+6ZCRVPakIucYm/booBNYjHosp+dqIwUfRfKUG jcP1lOS8F0khYwhc8yNepULLxY3JVuOP0rPHEgGMob1BTAuqzRoC4/PUpH4E9bB/t3q1 oUIpjOf5MbP52PMgqvFiwgOdJ0cbZnMt5muxCzYwpiXsEVxcFBsiicCUm3BezUCn5G76 JVi9mqJZkP2R9xr7AlZo3cDfrOybGqzhVJ2vW1USujJYzP6fS0UZ7KrbagWWi7RtPCzk Pwlg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=d6LIp2T3; 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 j2-20020adfa782000000b0021d8b1a6796sor900939wrc.16.2022.07.14.07.36.26 for (Google Transport Security); Thu, 14 Jul 2022 07:36:26 -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:1549:b0:21d:c154:486d with SMTP id 9-20020a056000154900b0021dc154486dmr4448312wry.50.1657809385951; Thu, 14 Jul 2022 07:36:25 -0700 (PDT) Received: from panicking.. ([2.198.242.86]) by smtp.gmail.com with ESMTPSA id u18-20020a05600c19d200b003973c54bd69sm5712357wmq.1.2022.07.14.07.36.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Jul 2022 07:36:25 -0700 (PDT) From: Michael Trimarchi To: linux-amarula@amarulasolutions.com, Dario Binacchi , Tommaso Merciai , Boris Brezillon , Richard Weinberger , Patrice Chotard , Simon Glass , Wolfgang Denk , u-boot@lists.denx.de (open list) Cc: Boris Brezillon , u-boot@lists.denx.de (open list) Subject: [PATCH 11/11] mtd: nand: Move Macronix specific initialization in nand_macronix.c Date: Thu, 14 Jul 2022 16:35:43 +0200 Message-Id: <20220714143543.448991-12-michael@amarulasolutions.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220714143543.448991-1-michael@amarulasolutions.com> References: <20220714143543.448991-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=d6LIp2T3; 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);