From patchwork Fri Jul 22 16:10:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 2239 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id D468F3F047 for ; Fri, 22 Jul 2022 18:11:20 +0200 (CEST) Received: by mail-ej1-f71.google.com with SMTP id hs16-20020a1709073e9000b0072b73a28465sf2107580ejc.17 for ; Fri, 22 Jul 2022 09:11:20 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1658506280; cv=pass; d=google.com; s=arc-20160816; b=MAXsCJzuFxA6xd5+6d6xMem2j14cOdr6r6ETn0zoww+N1sehwCiaTRzqN588tHR1aE rGwgJSsEDU0ywGaoLR7PohLqF8IhX+/u259a2CM6IiEYq2AnGffLpm1OJXqyrnPlZfOT zII07fjJKIePwQLwd/dWP1Dc1MyPf0qFKTH+jpI4MxbAKPOckEj8F9py3tlPSqLp/UX7 sYbR1agMnNHv68ABPcKIlVDHDw4lCmCTa7+wjNKLBvJNo8wACpqAWjtWQ2r4spuLE/Og rHYOjPxo4JwsS5eHF4pKZWFkK3rpySPMffsY69PJcr6dN5cacrD9Et6oHlSWP887D5h6 G9yQ== 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=FZ5EpgOT5fa8C1uj6OSTP7Vd/v+d/VEHYnyuypm/0Ew=; b=yYrvPaLAm67ErRYq/9pn8I1YPkyam7O/OqG5fB6X6lw+kkInXHdJ3CpWZbNf1cr2Sn A8J9FS+uIkAkrI9Ya98mpCpXM4FuwSTIUAseN2QUXGHuN80e2owAQZ8/Qev6vhYnsQw1 TmQFtJYQh0S2+RGSEx1da19srzSoo8q8U6m+EqnAMLBIKPKMSik5ccdyYNA0koyB8ANX E9/zdq8X1eBqVRbPtyFGW5t57JdXSDzsEAHZm0EPMXdiUbEiSmBqgeGPwRl+r1zpvNwK Svk9q9Zu0E20mX9rn1bjyKxLFGD2w81CEu+NcVbVXQveRS/RHz8n1q3oQb4R0AYvg7S3 dR9Q== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=VUUMzG1C; 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=FZ5EpgOT5fa8C1uj6OSTP7Vd/v+d/VEHYnyuypm/0Ew=; b=JxId1s2w7CZR6l+q4nUaylwZLmj9YPa9A9wPYrKu69XTp7KLDDMaTQUHxQIqsCRaWa MaP8Y8JUm+6cvnggqnZ/KkfwXvd3wPxwNjvKREV1wiCa/f6MgpRK2/TXDmFvlJtPN6HX Odum6vYDF8TXsZXn0cDdUa5WE1Fq2dQMGcgjg= 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=FZ5EpgOT5fa8C1uj6OSTP7Vd/v+d/VEHYnyuypm/0Ew=; b=Sn7keuQcIJ06f5CfguBLii9zQzHn/DgKEkyaQfUN1+zfTLkDCShrmP3oVeFgGICrBh 8dlfSxeXmX2msxuGkLBfudiBP1jJ1LBqd0Aeh1Kn3dy7A9cCZ4QSzC28dh/Gd/szxAIN 5+MWG0C5vQZZ7PGeALdcaP8ic+QFEqIKMAQ1BrNbkjPE9zHsfBf3/4lgI3HSphBUaudm MkyDA/Q1Fxrm5SydOMMTIFY6GGYV/KsuoJbKANHnTYCIvlOqkGL/GzUDN/V7gEGu/fpt fQu9swTRWokAeAJlh2wNNyAGJq8cEHo0HWx1SDyRwkII2K0PNSAonLKCoZfxepD4/fkJ uXBQ== X-Gm-Message-State: AJIora+7pYMUARFS4HAK89VR/yj56RA0sGLiyfZwZo5jf/f+2c2t9E0A mlF/9s/ped8MR36C373CIJp9c8Fs X-Google-Smtp-Source: AGRyM1v+qrjRCSQVXcHZ2M/fYT4kVXf2inNh8Dq7FDOACBlT3tiJe453Z3cQMFGP272SrpxckUcwMw== X-Received: by 2002:a17:907:9493:b0:72f:40ca:fe79 with SMTP id dm19-20020a170907949300b0072f40cafe79mr471046ejc.511.1658506280664; Fri, 22 Jul 2022 09:11:20 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:6402:2809:b0:43a:77a6:b0d with SMTP id h9-20020a056402280900b0043a77a60b0dls2108227ede.3.-pod-prod-gmail; Fri, 22 Jul 2022 09:11:19 -0700 (PDT) X-Received: by 2002:a05:6402:48c:b0:43a:8bc7:f440 with SMTP id k12-20020a056402048c00b0043a8bc7f440mr619671edv.8.1658506279460; Fri, 22 Jul 2022 09:11:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658506279; cv=none; d=google.com; s=arc-20160816; b=LJ9VzWGujCW7tukWOpCDwC0nZHZi9JU+GOKw7v7AsaliaWJpe3CjfmCgoK88B6Jkj0 EtAPEqVIKu9gEyphDRopWyqr+9pmb9wiRVrq46DYvcAs+kokPuZOtj/cyUncMM3ctoKU w4R6zBZtUtPy96fR3GIUXEAIAXtDamoRwG47qGCafp/tkODkF9d9hQ5f3zPU2Hn80TjD GcEk0/eJ3RLWi6ACsh3J6ymPqbabfDfxY/lpf0mAMWsLyzNMlSwHocni3hz30GP6oBJ5 3YzhThCbghmPqIYmIjh7aJQWnspg7n49tsasJT2Epe9nG5Zco/WBuOU3s1jGW1V3Jws/ AfTw== 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=VTfPyW+HXeu/cQyhrJLPIcmJVM7MYEIoxq4LeP00Dkg=; b=kXvniLI9xgMZpIRsCCQSiilg20TkkerNEHcjOh8H5x8PbMRjERCc2Uub6WT1u3d4+P p4i4yfTt29RuXw+Os0q+7+YAv9E/ajm5/9/q4ds/7j2CS3Wcu5wDGFJRtmBgSHCRM+Wr 3QjSmDIT9Dwl2kGCYfo9bK4E1gwAwHORWcm3X4VKhSbjSSfo+V/5auErb5+RZbTt4gcy irj5Dl3cRo3AyJWHeZ73jBupo+032Q+hDIKyPFaqmu7ZuSreb4Qxc91ITCDxEkagW52D fb1/t2OfEbokOWBO1cwOm4gian554HCiL5Z5bn5BzVkX5tf6LTJyMU6h37OsdP54E+bP Dc1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=VUUMzG1C; 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 v5-20020a170906b00500b0072b616ac648sor2151698ejy.85.2022.07.22.09.11.19 for (Google Transport Security); Fri, 22 Jul 2022 09:11:19 -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:a17:907:1c95:b0:72b:4e37:7736 with SMTP id nb21-20020a1709071c9500b0072b4e377736mr484247ejc.516.1658506279154; Fri, 22 Jul 2022 09:11:19 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.pdxnet.pdxeng.ch (host-87-14-98-67.retail.telecomitalia.it. [87.14.98.67]) by smtp.gmail.com with ESMTPSA id d19-20020a170906305300b006fe8ac6bc69sm2174025ejd.140.2022.07.22.09.11.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Jul 2022 09:11:18 -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 v4 10/14] mtd: nand: Move Micron specific init logic in nand_micron.c Date: Fri, 22 Jul 2022 18:10:04 +0200 Message-Id: <20220722161009.2686504-11-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220722161009.2686504-1-dario.binacchi@amarulasolutions.com> References: <20220722161009.2686504-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=VUUMzG1C; 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 --- (no changes since v3) 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);