From patchwork Thu Jul 14 07:51:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Trimarchi X-Patchwork-Id: 2151 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 1BCA23F013 for ; Thu, 14 Jul 2022 09:51:56 +0200 (CEST) Received: by mail-ed1-f72.google.com with SMTP id j6-20020a05640211c600b0043a8ea2c138sf999333edw.2 for ; Thu, 14 Jul 2022 00:51:56 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1657785116; cv=pass; d=google.com; s=arc-20160816; b=UZ+ESl/QP5BPCAJemXQIfLHzhbnh82AWj4tsaVmgLe7GspBydxpbHZasvi2+slLqi9 dkH+fbrRwQes11F00qURnule95hgBNhK3dYklkAKnQSvu0gGEWyIdrupGzi6MbdC6+3+ Zf9MsZnHzoqvcIMKbPM4A2Bhhwzm3d162ndFyBYhfzxOCTsvxTK6SHNKDOCzAEXiLaCf 8wOg3hpUW7NtMQ85LInDQ57k2vofhdV14LC4wkDBGZ3bUJcMwhtaJ/3SbUsItFi3ZojC Vb25xrdhbMcptsQWnYcjMnhC/hcJ1IFM1v3wRzsZuDWm6Q5+p05LY9OdZFeSStTsvzc/ g1lw== 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=OgVPachqagnBDNSeX/3jXDGME1qhlZYNNy6w6lGKdJY=; b=di7QzMH6+wDRr91m1MKPZlyjJ1GZAs3MvG/rl8sWuqEygE1XBeom7HTPmEn0nGIGKM pISfffvdDZKPx38sHYdhqybMjhAkdbKhQVBcIXCLx2hYCJhUrBlomkTZztYZRztqnDbF S48IHtVbCkogxA1Rn0Rx5TGmBpR8I6BGyTTUM1ricwI1lUP4qZv5RZghIAxXduep27n/ b9KZQ5ZmSLNg84qzehh9ZL9Tt2gG0PxPtUTAmmVk1r6qof+PXKyFbhLVaG2tkJPZaOQ8 dFgYHtiUyLY+zsUcj1XfmaYR/XSU4W7eY1r90BEjkJKSqNBv7MsbelRzz7S+tbO9Tir6 GpWg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=XVqM+ySH; 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=OgVPachqagnBDNSeX/3jXDGME1qhlZYNNy6w6lGKdJY=; b=Pt0ept9WmwnI1aZCGivO80PhGlrRr2xlRw3N/tMCvRd47lXAF0GhCWy1coQqzi3gom u0/S+huko1XzBqbrpxpYihCqmCqJs42kAh9LOWANEPQH+i2LdS3PtJUOwSBLGXwmSzvV nYuELcz4iY+OX24he7HU+XDBoJHgnUGV+ShuU= 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=OgVPachqagnBDNSeX/3jXDGME1qhlZYNNy6w6lGKdJY=; b=heiY/kQ7+SqvdkacfbtcPYocCoQ9GS5PIwI5zzmCj9nodVX+fvQ0k1nDjX+Ojn1saa RA7kOytzp9SDtT+tc9B/Bi2LL5HUwxCO/wAt/qAIv600WYF3+9gROyp2GYLDhwvBoo3T C4s/YXMwDmFIuz4DrIF9QCCYZIWSWGbAFrfoGU3klqIKMjEcFypgz+FB9GCGR+OSvC+Q UuN6hZBQ+YdRoWISzEyzxH+Ujtb3QyPZLHiPBuJZRJL1CwohzUwCEO/8eB7MspaIXeEo vVNRZkD/x5p9c9B0FNQIaxlP2gyRp3Qnrlm2Dawv4FbtMblUJZFAkC5MeEBC+ucgDxWc SDnw== X-Gm-Message-State: AJIora89ZC1A711Gz+qEPiILrKo2ifMgbz9h0qrRpCp+DCicAIP05Y/L fKQZD9vpoklVQpHZel3ra/StEhk0 X-Google-Smtp-Source: AGRyM1sKk8WY+T5M/viZ7thRxlSGfP6/wIQfJ+NzzywrqhuhtzNTKxcXdkN+jlZk+7KIaeTjm/Oq9A== X-Received: by 2002:a17:907:2e01:b0:72b:764f:ea1a with SMTP id ig1-20020a1709072e0100b0072b764fea1amr7420009ejc.666.1657785115982; Thu, 14 Jul 2022 00:51:55 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:906:5ac1:b0:6ff:ab8:e8f with SMTP id x1-20020a1709065ac100b006ff0ab80e8fls4167354ejs.6.gmail; Thu, 14 Jul 2022 00:51:54 -0700 (PDT) X-Received: by 2002:a17:907:720e:b0:72b:9cfe:21da with SMTP id dr14-20020a170907720e00b0072b9cfe21damr6510344ejc.575.1657785114601; Thu, 14 Jul 2022 00:51:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657785114; cv=none; d=google.com; s=arc-20160816; b=ud5thh9kMsF88GnpB0z8E4XcHGmJQofnZdw4gzZhyVbHdWjmR3oF9JDe7sUkrQhw2V 3w1t4gILsCTgFa2OXF/XyDkSNHC1nNLmB2XYpHew8gD+RfE7j7M7aLCeS8EO0MAsdcsy qm8iL6QfFjsHPWJhGedC5887BtFChl0VxwpI7sttbJQOEFpu1kS5vPKEwtQkXD1mEyRB jC7ojqF0Xkv36s42WygvvkaVpEqjWhstEydScI7a8TI/To+Im6xsVwk/+uMJh389zTas LPGnaVk7+NpyQVxGX1/dOTaLWmWdgUPidGxAAowuKkHMYbFCmq4I9l9ZeUxe/Rcbgr/2 zs8Q== 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=xTWhGhVKd/y2r3mBKI9X4AM5rGu1tPmetWYUpZZyazw=; b=ufW7gXcZbRGvWKn3Uag3nKKmymtrIzmPwM3iJTZ/J0UztaffFsbS/ZrjB1rj8gPCbM a1yrCEeGkcY8zTntcaIsxeRaD/uSV1EQpbcnn9Hs36BR/nexwvn/eSzuoaUkG8VDNDOZ 2KwqXiYeUaTXhciGWpE0jnnFVtTLO+SyqEaEtM5pVKISkDZWGW8JPyi7Fa59HAuIO1EL LpQNCZX6Z5AZH2ZLfUypCAnWhgmow2hkUXECvUXX2otfitoDeRo8G+l/SHI/kJBiu3A4 b6CCn8zGOmTPQz8Yl0Ahc46wY8F3UtM5vxZ/1lqyypxVP+CEpfuGtHTW52KWlB5FOcTa w2Qg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=XVqM+ySH; 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 y89-20020a50bb62000000b0043b0e7d0ba4sor440357ede.5.2022.07.14.00.51.54 for (Google Transport Security); Thu, 14 Jul 2022 00:51:54 -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:a50:fd08:0:b0:43a:7890:9c54 with SMTP id i8-20020a50fd08000000b0043a78909c54mr10503073eds.52.1657785113943; Thu, 14 Jul 2022 00:51:53 -0700 (PDT) Received: from panicking.amarulasolutions.com ([2.198.242.86]) by smtp.gmail.com with ESMTPSA id r23-20020a170906a21700b0072b616ade26sm369252ejy.216.2022.07.14.00.51.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Jul 2022 00:51:53 -0700 (PDT) From: Michael Trimarchi To: linux-amarula@amarulasolutions.com, Dario Binacchi , Tommaso Merciai Subject: [PATCH 09/11] mtd: nand: Move Micron specific init logic in nand_micron.c Date: Thu, 14 Jul 2022 09:51:29 +0200 Message-Id: <20220714075131.411548-9-michael@amarulasolutions.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220714075131.411548-1-michael@amarulasolutions.com> References: <20220714075131.411548-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=XVqM+ySH; 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 10d4e75c36f6c16311dde1461f318210da357219 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: Boris Brezillon Acked-by: Richard Weinberger Signed-off-by: Michael Trimarchi --- 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 | 88 ++++++++++++++++++++++++++++++ include/linux/mtd/rawnand.h | 21 +------ 5 files changed, 94 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 2eb08c1a9f..bb20a04616 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_SPL_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 c5a5c22b12..9024948ded 100644 --- a/drivers/mtd/nand/raw/nand_base.c +++ b/drivers/mtd/nand/raw/nand_base.c @@ -3863,30 +3863,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. */ @@ -3986,9 +3962,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 @@ -4265,10 +4238,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 509652c8e2..bb5ac8337f 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 0000000000..a99bf8bbec --- /dev/null +++ b/drivers/mtd/nand/raw/nand_micron.c @@ -0,0 +1,88 @@ +/* + * 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 + +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 73abb34016..ec0f77b24b 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);