From patchwork Thu Jul 21 06:44:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 2224 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 7CAA344190 for ; Thu, 21 Jul 2022 08:45:03 +0200 (CEST) Received: by mail-wm1-f69.google.com with SMTP id a18-20020a05600c225200b003a30355c0fesf296501wmm.6 for ; Wed, 20 Jul 2022 23:45:03 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1658385903; cv=pass; d=google.com; s=arc-20160816; b=N1Y4mYc8NU9HGtsrFOWm8F6I5T+idmAUhHIGLZEnezvmMjHGldlCygxk+M41HFlIJk I+5Mfvijz9zUFj5joDyAO/m9drv45m6HhF27GQxgDV5JLpfzp7+KNxeQ0HostNxIp8OY jM1OopJddk9F7qrsFzORec95XgEkB17NU45eS1RJX6cStg4pk95o0HPqcBWzIIps+beo SHs9rARePJMzOIO+MecZCOjkrWu0cUskTVT9d9bBTGhJy442tZ44TQ45J9MJ5H2aD4Id mGEcQBXeHWS5VeORcSuZickoKPS3XYtKU02/0Pzln0nfRqV2ZJufR2Dysh46bO/4X3uR 9ymw== 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=gf8yi+A3ByNhda9glCBbh9803s0KyqAl2fy635viMnk=; b=B4U4dm7jiPbhO9/uZvrqljashkLwPgNwfd03eLPm9JWSNb8Bw7CdRSlYYnckXD93j+ 4Woq3NMIyHHj+rx59FTPaMWI9q+VihSMsRb+g+57pRZ/f5ZAABPxVgFenruk0AM1c3xP FGBxmxZExt/Ma4hZ3F2dzs6i/reerL1pO0vbo0RwIxUrhxolLPx50M3XXLtkIxscBtne WpL4zgAKil1VaZbls0mOea/NagUOr4mbJSGJPM+vJf+ucmtgsOFukXYGeW77ZjvZZm9h q1oaOJqTp2RWAjbgRtohQ/Ag25PR0/v09iaDaJG7uK1WKklEAalcqCYncd5nQ7f7w104 hPrQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=SE4nKpY2; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@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=gf8yi+A3ByNhda9glCBbh9803s0KyqAl2fy635viMnk=; b=eoJYsDBc1lZ609tBjuiJI9NtYkb85TS0Hmay62u2jrlcojKsSbyqVtl6Qj12JMPsN5 2vIANvNIFkx1Lo/FmmtUQcWBR+fnKUUqq0mTSCMnroZREf32WwBt+1kfrYfjQyFQ6RWo J3OmLSy+1xY0pY1yb9ZvfZ/edKCLBRCgf+Yg8= 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=gf8yi+A3ByNhda9glCBbh9803s0KyqAl2fy635viMnk=; b=zIx6j7TCnxX5u2MoAxP9rgHnJl3kOAsLXGv44ukLbTaJHj9x1F5tVYrGXs9g8PXnS7 S5ldgN2Yjw2/UrcoeGveQPvYGy3Wg7lCo3ngx1sHYHoxXvU+fwe+CnbNwBDXfZAuecdl 4TD6OuPR/UWVFtKZKKJKJ5712+84/ZHw4ZctFA/O7ATQZnMUau0A27XMGfvWkTm1uaWc aGXs07LiKydQeCdoNS9jagBUPWe+PYWcGgNaHk8f30FRGYq1EconqKtmLDi/zrZE1e9a CyUwG3KcLPM4VXlTHyAMrzygbkw1tzFnrrDS7mbl6ssZWS6Zl6mQ998e4w5+pMj4KMne Qv6Q== X-Gm-Message-State: AJIora/J5oSzyM6wQpw36aJUus9+eTkYLVlAH+ABHbaVAdxpKjX8VEdO iuTVZcTT+r9kcj4P+R8sicl4Ey7M X-Google-Smtp-Source: AGRyM1vEg9zWelDC/ttJfdzh7hmOxactxGYuA/QX90arNYIwF/Cdu+w0N/OQUEW3E95uxP92JnhCEA== X-Received: by 2002:adf:d1c8:0:b0:21d:a082:9290 with SMTP id b8-20020adfd1c8000000b0021da0829290mr34357025wrd.246.1658385903241; Wed, 20 Jul 2022 23:45:03 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:600c:2195:b0:3a3:1b8f:2e1 with SMTP id e21-20020a05600c219500b003a31b8f02e1ls1448220wme.1.-pod-prod-gmail; Wed, 20 Jul 2022 23:45:02 -0700 (PDT) X-Received: by 2002:a7b:c417:0:b0:3a3:236f:9f98 with SMTP id k23-20020a7bc417000000b003a3236f9f98mr6764365wmi.48.1658385902103; Wed, 20 Jul 2022 23:45:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658385902; cv=none; d=google.com; s=arc-20160816; b=DFbqBxC1WQXe9qyNULl6kMSB1Ej1g/tws0f0kGovAadrNv4X8b0NXLWVdOYNI9aYmK q2QnqVSjZF6CG0kc6ZE42LaGEUBV+jBlrF4ztnOjfoLIHTyQBp2/bAyOOj5M8i1JRwuy j31zNtgcAhBVDPNMa/+ClQSWp3ZYaexdfumM2aGd+nGGq3g2JFU6eb2N2UNtUDs7HbEo hojp9jYwxtWtD/6ujL47LB/USjtbadv9J4HlTymPFdj63ZSgeormQ0HKkCgemC+scKc2 ewbqKBMT5I8iZ0FS2R6mg27r9mypukD1QzNIQn4qgXBCQ/WzrydB1r2IHDYOuGXaxW90 0woQ== 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=60G2gAXdyvXVp1G8eokKbB/NS8ffGuQU42nXwBlFMIs=; b=mBpgZ8pjSToDQuIh1wCiAoSYBr90SxgxW4SxHV5GMZrx4pN3cxmhtTqWDiHIi55TRD FScwYrRYmCZSCJeW25lXU6vyTBy0QIZLdNMbzuW/8UrYpFYMRy4ljgwBD8KaQH+KzHcW au0KnueuWE8l9ULp9fvUPjtNpTY+OirT7pyumkpK7rwjS2lvlW2+z1KioMRRTVID+dO9 vmNXfI7TGibeSFa74D9LNNvKaqVkbo2/W+NQd5k+QyEHMblttKJQeG5Tv27chNSrZLnD bhdwEK2JymLES3J2/0P6+AWZuWIcZ8JSLLeGo2wGqW5Dmho2TxmvmVr5Sh5czN6XsSQj qXEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=SE4nKpY2; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@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-20020a5d5886000000b0021b89b50004sor441726wrf.44.2022.07.20.23.45.02 for (Google Transport Security); Wed, 20 Jul 2022 23:45:02 -0700 (PDT) Received-SPF: pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; X-Received: by 2002:a05:6000:144f:b0:21d:a3cc:a6fa with SMTP id v15-20020a056000144f00b0021da3cca6famr33234701wrx.191.1658385901797; Wed, 20 Jul 2022 23:45:01 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.pdxnet.pdxeng.ch (mob-5-90-140-42.net.vodafone.it. [5.90.140.42]) by smtp.gmail.com with ESMTPSA id c18-20020a056000105200b0021e4f446d43sm903711wrx.58.2022.07.20.23.45.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Jul 2022 23:45:01 -0700 (PDT) From: Dario Binacchi To: u-boot@lists.denx.de Cc: Amarula patchwork , michael@amarulasolutions.com, Dario Binacchi , Patrice Chotard , Simon Glass , Wolfgang Denk Subject: [PATCH v3 09/13] mtd: nand: Move Micron specific init logic in nand_micron.c Date: Thu, 21 Jul 2022 08:44:31 +0200 Message-Id: <20220721064435.2456601-10-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220721064435.2456601-1-dario.binacchi@amarulasolutions.com> References: <20220721064435.2456601-1-dario.binacchi@amarulasolutions.com> MIME-Version: 1.0 X-Original-Sender: dario.binacchi@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=SE4nKpY2; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@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: , From: Michael Trimarchi 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 Signed-off-by: Dario Binacchi --- Changes in v3: - Use commit sha1 with 13 digits. - Add the SPDX-License-Identifier tag. - Fix code style warnings raised by patman. Changes in v2: - Use short-commit form - Remove linux info. Uboot seems that backport without add this extra information. - Adjust the include file in nand_micron. drivers/mtd/nand/raw/Makefile | 3 +- drivers/mtd/nand/raw/nand_base.c | 33 +----------- drivers/mtd/nand/raw/nand_ids.c | 2 +- drivers/mtd/nand/raw/nand_micron.c | 87 ++++++++++++++++++++++++++++++ include/linux/mtd/rawnand.h | 21 +------- 5 files changed, 93 insertions(+), 53 deletions(-) create mode 100644 drivers/mtd/nand/raw/nand_micron.c diff --git a/drivers/mtd/nand/raw/Makefile b/drivers/mtd/nand/raw/Makefile index 16e0775395a2..8ef30b45fd2d 100644 --- a/drivers/mtd/nand/raw/Makefile +++ b/drivers/mtd/nand/raw/Makefile @@ -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 diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c index 4ea7f10a06fc..fe7e049d4064 100644 --- a/drivers/mtd/nand/raw/nand_base.c +++ b/drivers/mtd/nand/raw/nand_base.c @@ -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; } diff --git a/drivers/mtd/nand/raw/nand_ids.c b/drivers/mtd/nand/raw/nand_ids.c index 509652c8e26c..bb5ac8337fde 100644 --- a/drivers/mtd/nand/raw/nand_ids.c +++ b/drivers/mtd/nand/raw/nand_ids.c @@ -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", µn_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 index 000000000000..8b31c6198134 --- /dev/null +++ b/drivers/mtd/nand/raw/nand_micron.c @@ -0,0 +1,87 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * 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 + +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, +}; diff --git a/include/linux/mtd/rawnand.h b/include/linux/mtd/rawnand.h index 73abb3401649..ec0f77b24bd6 100644 --- a/include/linux/mtd/rawnand.h +++ b/include/linux/mtd/rawnand.h @@ -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);