From patchwork Wed Jul 10 01:15:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cheng Ming Lin X-Patchwork-Id: 1958631 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=cLjUmcVO; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=YpqEBpD6; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WJg2F3PJvz20B3 for ; Wed, 10 Jul 2024 11:17:23 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=E4S4XgBfeMv4+Tpu/pJGEZVCscd+ITajsT7DLac5m5k=; b=cLjUmcVOBnHQF0 D3EfX4JGt0OyjhFbSy/pYdIal/YubxPiDg0tWw+1LqbBGox+YxCD141B57xMcP6ps0CfcHEOYfNBr JRY2nQf8FNh1+9R3akpFOsrFTTz8vU/MBZEW9b+kXDcbwPPZjdYwiCskO9YAgteCDME7hBUXTLJiJ w5z23Jn34WwFevoz2puwNCB8AhbGzS9sxuKNy18A3d5pvRZMxJYUWedtaAyFMKB9cjCEBHcMA7F7B RoCzqV0sm5TOHtMbrG41wPJs0Pz1TtOv7iJSHtSUyiIQlUXYOu4C8TyZpkDVfr+TZ+BtCChng+h0p qsZf2KmNxLBrmWYAaYZA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sRLxD-000000093Rk-1PXM; Wed, 10 Jul 2024 01:17:07 +0000 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sRLx9-000000093Pp-2oZ5 for linux-mtd@lists.infradead.org; Wed, 10 Jul 2024 01:17:05 +0000 Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-1fb8781ef1bso19105755ad.3 for ; Tue, 09 Jul 2024 18:17:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720574223; x=1721179023; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Lf0ReuyQOi5SXQsUOQzTmoOvTe5c8o2DFeqT2/r8W4I=; b=YpqEBpD69sC8LauXB/0a8nTGL/fBB8TxJ1gf+uo7WYfH411+q3i0xLImzNq5ifBA9h 0Mw7cBwyg+mfYieOo5hFW52SQyPAe9sVUTS16piK8LKmev1qygi9cRrVV96d7HvI1aN1 wRToy+JarikkvoKyiOf0r+Gp1gtXfSZ2QjCD6LrzUkHeVJ2SQclnI5qERsYzOTFtd1fX PcU2AO0ZKWsVXCKlgSGUMUGXuYymdCcuYE2qJopp4BD71lLEqZosluUNSAHWpmbKuXwX zZ7JjJePLmNkYmKHDfYImtA/1WDtytxlt2gwkwI+xmNlmNTv5QlDnuOi2QtyLSw9hCDL xCfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720574223; x=1721179023; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Lf0ReuyQOi5SXQsUOQzTmoOvTe5c8o2DFeqT2/r8W4I=; b=kzx0x+JdYySLXaV1QzfHwyeP2gFnRjYQwRIx3wHskPODKhP9ruw+rayu6OOixX7ohY j5GRCjZX7V5TToS3B/OeC4c0rlvITm2txPENfDs+67MfHqoOo7sWYa5mgxCVcyJ4anvR oiWtuKgkm/7H2PtV4LUT1qScOioM+dKpUqFVoIji+F461F6mgZKJnw7E/dcgFLcc3fAd JYKtxN4hct0lhdQ6vizu+37E0H6zmS+Vi/vtev9wUjmcvUZza2gpCuwK2ICGCSSw5DNH zxOqPDrSlTc2CEeYofH4rPgAWo+11kTxxyx0cV5B7Pj2Fbbx3n+8yp3y+snxqxB5ilIX Px9g== X-Forwarded-Encrypted: i=1; AJvYcCV/ZW98qJBNks1PqQmL5wjS1TaKSjjWMK/ZGq0E4Iqj7KMg03s0mvmGy2Nf1WUeqSJuTFj6PlDSy1hsYM+T5vQXL6P1vdH+t4vzFg+OXQ== X-Gm-Message-State: AOJu0YwctCvzpHcNymJ2NQFFCCWBAcFZPThJ/4KQ8YZSfJ26/rf6oUB1 dV3C786pvtYRL+QW3eCe/r6PozTINbFBEvBjEFTrzGH5Lui/12LT X-Google-Smtp-Source: AGHT+IEgKzUS2C58JGutlZ0YXRBY+FjMO0+UJyNyABmzG1f2vpoCM4JuCsrJpw5PgmaB9SqS74yOZQ== X-Received: by 2002:a17:902:e54c:b0:1fb:5c3d:b8c3 with SMTP id d9443c01a7336-1fbb6cdab3amr35816045ad.4.1720574222520; Tue, 09 Jul 2024 18:17:02 -0700 (PDT) Received: from twhmp6px (mxsmtp211.mxic.com.tw. [211.75.127.162]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fbb6ad4bc9sm22010445ad.286.2024.07.09.18.17.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jul 2024 18:17:02 -0700 (PDT) Received: from hqs-appsw-a2o.mp600.macronix.com (linux-patcher [172.17.236.67]) by twhmp6px (Postfix) with ESMTPS id 9157880B36; Wed, 10 Jul 2024 09:26:27 +0800 (CST) From: Cheng Ming Lin To: miquel.raynal@bootlin.com, vigneshr@ti.com, linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org Cc: richard@nod.at, alvinzhou@mxic.com.tw, leoyu@mxic.com.tw, Cheng Ming Lin Subject: [PATCH 1/3] include/linux/mtd/spinand.h: Add fixups for spinand Date: Wed, 10 Jul 2024 09:15:39 +0800 Message-Id: <20240710011541.342682-2-linchengming884@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240710011541.342682-1-linchengming884@gmail.com> References: <20240710011541.342682-1-linchengming884@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240709_181703_778940_224B2223 X-CRM114-Status: GOOD ( 11.51 ) X-Spam-Score: -1.8 (-) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From: Cheng Ming Lin Add struct spi_nand_fixups as SPI NAND fixup hooks. To determine whether the Plane Select bit should be inserted into the column address in core.c, add the member struct spinand_info to struct spinand_device to ascertain whether the device has fixups. Content analysis details: (-1.8 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [linchengming884(at)gmail.com] 0.2 FREEMAIL_ENVFROM_END_DIGIT Envelope-from freemail username ends in digit [linchengming884(at)gmail.com] -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:636 listed in] [list.dnswl.org] X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: Cheng Ming Lin Add struct spi_nand_fixups as SPI NAND fixup hooks. To determine whether the Plane Select bit should be inserted into the column address in core.c, add the member struct spinand_info to struct spinand_device to ascertain whether the device has fixups. Signed-off-by: Cheng Ming Lin --- include/linux/mtd/spinand.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/include/linux/mtd/spinand.h b/include/linux/mtd/spinand.h index 5c19ead60499..c079c6ac1541 100644 --- a/include/linux/mtd/spinand.h +++ b/include/linux/mtd/spinand.h @@ -354,6 +354,7 @@ struct spinand_info { } op_variants; int (*select_target)(struct spinand_device *spinand, unsigned int target); + const struct spi_nand_fixups *fixups; }; #define SPINAND_ID(__method, ...) \ @@ -379,6 +380,9 @@ struct spinand_info { #define SPINAND_SELECT_TARGET(__func) \ .select_target = __func, +#define SPINAND_PLANE_SELECT_BIT(__func) \ + .fixups = __func, + #define SPINAND_INFO(__model, __id, __memorg, __eccreq, __op_variants, \ __flags, ...) \ { \ @@ -398,6 +402,18 @@ struct spinand_dirmap { struct spi_mem_dirmap_desc *rdesc_ecc; }; +/** + * struct spi_nand_fixups - SPI NAND fixup hooks + * @write_to_cache: program load requires Plane Select bit in CADD. + * @read_from_cache: read from cache requires Plane Select bit in CADD. + */ +struct spi_nand_fixups { + unsigned int (*write_to_cache)(struct spinand_device *spinand, + const struct nand_page_io_req *req, unsigned int column); + u16 (*read_from_cache)(struct spinand_device *spinand, + const struct nand_page_io_req *req, u16 column); +}; + /** * struct spinand_device - SPI NAND device instance * @base: NAND device instance @@ -449,6 +465,7 @@ struct spinand_device { u8 *databuf; u8 *oobbuf; u8 *scratchbuf; + const struct spinand_info *info; const struct spinand_manufacturer *manufacturer; void *priv; }; From patchwork Wed Jul 10 01:15:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cheng Ming Lin X-Patchwork-Id: 1958632 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=HVZpIs2i; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=Ej3yMpxs; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WJg2F5v6Hz20B4 for ; Wed, 10 Jul 2024 11:17:25 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=QLtG8melpOl+z1NB0keSuOwQZDy17s5XYTfvOFr2v/8=; b=HVZpIs2i3ri1OL lWYpNC2DeNSFmCzvVdDp7lrWNbJ3saqRIdHwbEAGbPC/K0W5pAwBLERTqA+r3fWdm6hNDtoaohLPI e1JUi02L4Rfxtv+pOEVuSEEFErT46SuH7RxfCNjTQLHku8ra6CWtvNtLelsPc1FrVbNi+qNM/6IrC OQxFDzKzb+OTU4wK14lQ+vhpPSpsXW1aOhzbWyEVoz5hmaiAFpzV4hbEhPaZgQJlPxWcGGxLjRUvf tie3aMNpvROBgCp6tJMzt1Jpc6YuNLXmlVzknU4ji+9kzpDFhtDtzNUM/eZxWIY7uaRpugnZ0L92T 7H+e5r/kPpTMuGq+VB+Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sRLxI-000000093Tf-2Ywr; Wed, 10 Jul 2024 01:17:12 +0000 Received: from mail-pf1-x435.google.com ([2607:f8b0:4864:20::435]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sRLxG-000000093RV-04wU for linux-mtd@lists.infradead.org; Wed, 10 Jul 2024 01:17:11 +0000 Received: by mail-pf1-x435.google.com with SMTP id d2e1a72fcca58-70b4a8a5587so794544b3a.2 for ; Tue, 09 Jul 2024 18:17:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720574224; x=1721179024; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=GEYUgRgAX3U4wZonxbVp1RvGhxBw1XYv1pj8Gg2uytQ=; b=Ej3yMpxs7gNgN4vDLzZc7aVBisjg/0GXk8+QbtJ8OmXkWul5PgRTxnWoVGIHGibNfd PrKJo7g4GO65SLonKfqp2FyDDuWU4Pnbu3tc8FPDw1F3RPospcw6w+qDwKg41XMM5m2w DN+5i79e7zINIoeZe55B55ZQd3RYKGQVd5YY6kgWuW3SyyuYZTswe1nRTfLjBoeEqGRv YRRtqIrG/2veAhaDw8qw/imNdADP7qj8iLJl9Bi2ZJlOGgSHr2AyyP+bRZ+mnxvDBenp EL0pTmqKj2B2qdlHVJtfXNN4nHjgRFqYoxe00UkNAIJFYE32jx0qZ2ROpXP5SAvearQJ C1jg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720574224; x=1721179024; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=GEYUgRgAX3U4wZonxbVp1RvGhxBw1XYv1pj8Gg2uytQ=; b=btp/zkSUCclAK//JHguTaBI+GDNKv5QISrL3uKIZ5OBCHyeqWITEXHCW50+AWdrqYq L7zmlJciKVcK/eIvlYGkpbsaPB1jwpx1Yww4v9ZJwvjWDxsZf3aUi9mt97ifIzUVO6uR IhO7n7H+0sRg9xKoWSA2/9D3Hj77J/REKL48hEAduqAHb8TvaXmUTckJA/tUkmhAUwEy XqMqlEzEq/0RHB2ZC7dcyMb+qKGsM3luyWNlqvFxdiYUwov1opf0sjlTM4hIUBa8o6ZQ TWdyDOt6lekYTrRAo8yg5xYYWRDHNozmovKvSXFok631vjH0MTtWsPD4BInUj1vbVpJQ rK9A== X-Forwarded-Encrypted: i=1; AJvYcCVyrRQ8y2mvb1fqK3/Dnpb4EJ0AqIrCHIFrJzeBWUyv4VuR5v97hKEhbquyRBP5nl2Uds/hscVbASjI8nnMVNODl9cibF/6hs47KCg+Hw== X-Gm-Message-State: AOJu0Yy96+1ziEyqkElSYtkphPDF0pJ/G9/YDeynhlHnb70VK3H4X+NO Rkv3zNvWhRgcUZ5y3IdiGfI4NPczBfkEocMvolzy+2uNDmDGq81d X-Google-Smtp-Source: AGHT+IHmS97jexThoPIwIyD6WHVucBTTOKtk03NW9U9PP/pL/Peaar9imzg5L17ydYUIhYovDsgw0A== X-Received: by 2002:a05:6a20:da8a:b0:1c2:8d3f:793 with SMTP id adf61e73a8af0-1c2984cda76mr4332546637.46.1720574224311; Tue, 09 Jul 2024 18:17:04 -0700 (PDT) Received: from twhmp6px (mxsmtp211.mxic.com.tw. [211.75.127.162]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2c99a95624dsm10689540a91.20.2024.07.09.18.17.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jul 2024 18:17:03 -0700 (PDT) Received: from hqs-appsw-a2o.mp600.macronix.com (linux-patcher [172.17.236.67]) by twhmp6px (Postfix) with ESMTPS id 5526B80D2B; Wed, 10 Jul 2024 09:26:28 +0800 (CST) From: Cheng Ming Lin To: miquel.raynal@bootlin.com, vigneshr@ti.com, linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org Cc: richard@nod.at, alvinzhou@mxic.com.tw, leoyu@mxic.com.tw, Cheng Ming Lin Subject: [PATCH 2/3] mtd: spinand: macronix: Fixups for PLANE_SELECT_BIT Date: Wed, 10 Jul 2024 09:15:40 +0800 Message-Id: <20240710011541.342682-3-linchengming884@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240710011541.342682-1-linchengming884@gmail.com> References: <20240710011541.342682-1-linchengming884@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240709_181710_345856_B36B7109 X-CRM114-Status: GOOD ( 11.44 ) X-Spam-Score: -1.8 (-) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From: Cheng Ming Lin Macronix serial NAND flash with a two-plane structure requires insertion of Plane Select bit into the column address during the write_to_cache operation. Additionally, for MX35{U,F}2G14AC, insertion of Plane Select bit into the column address is required during the read_from_cache operation. Content analysis details: (-1.8 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:435 listed in] [list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [linchengming884(at)gmail.com] 0.2 FREEMAIL_ENVFROM_END_DIGIT Envelope-from freemail username ends in digit [linchengming884(at)gmail.com] X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: Cheng Ming Lin Macronix serial NAND flash with a two-plane structure requires insertion of Plane Select bit into the column address during the write_to_cache operation. Additionally, for MX35{U,F}2G14AC, insertion of Plane Select bit into the column address is required during the read_from_cache operation. Signed-off-by: Cheng Ming Lin --- drivers/mtd/nand/spi/macronix.c | 51 +++++++++++++++++++++++++++++---- 1 file changed, 45 insertions(+), 6 deletions(-) diff --git a/drivers/mtd/nand/spi/macronix.c b/drivers/mtd/nand/spi/macronix.c index 3f9e9c572854..c61f1ba31f0c 100644 --- a/drivers/mtd/nand/spi/macronix.c +++ b/drivers/mtd/nand/spi/macronix.c @@ -100,6 +100,39 @@ static int mx35lf1ge4ab_ecc_get_status(struct spinand_device *spinand, return -EINVAL; } +/** + * Macronix serial NAND flash with a two-plane structure + * should insert Plane Select bit into the column address + * during the write_to_cache operation. + * Additionally, MX35{U,F}2G14AC also need to insert Plane + * Select bit into the column address during the read_from_cache + * operation. + */ +static unsigned int write_Plane_Select_bit_in_cadd(struct spinand_device *spinand, + const struct nand_page_io_req *req, unsigned int column) +{ + struct nand_device *nand = spinand_to_nand(spinand); + + return column | (req->pos.plane << fls(nanddev_page_size(nand))); +} + +static u16 read_Plane_Select_bit_in_cadd(struct spinand_device *spinand, + const struct nand_page_io_req *req, u16 column) +{ + struct nand_device *nand = spinand_to_nand(spinand); + + return column | (req->pos.plane << fls(nanddev_page_size(nand))); +} + +static const struct spi_nand_fixups write_fixups = { + .write_to_cache = write_Plane_Select_bit_in_cadd, +}; + +static const struct spi_nand_fixups read_and_write_fixups = { + .write_to_cache = write_Plane_Select_bit_in_cadd, + .read_from_cache = read_Plane_Select_bit_in_cadd, +}; + static const struct spinand_info macronix_spinand_table[] = { SPINAND_INFO("MX35LF1GE4AB", SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x12), @@ -157,7 +190,8 @@ static const struct spinand_info macronix_spinand_table[] = { &write_cache_variants, &update_cache_variants), SPINAND_HAS_QE_BIT, - SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout, NULL)), + SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout, NULL), + SPINAND_PLANE_SELECT_BIT(&write_fixups)), SPINAND_INFO("MX35LF2G24AD-Z4I8", SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x64, 0x03), NAND_MEMORG(1, 2048, 128, 64, 2048, 40, 1, 1, 1), @@ -175,7 +209,8 @@ static const struct spinand_info macronix_spinand_table[] = { &write_cache_variants, &update_cache_variants), SPINAND_HAS_QE_BIT, - SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout, NULL)), + SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout, NULL), + SPINAND_PLANE_SELECT_BIT(&write_fixups)), SPINAND_INFO("MX35LF4G24AD-Z4I8", SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x75, 0x03), NAND_MEMORG(1, 4096, 256, 64, 2048, 40, 1, 1, 1), @@ -215,7 +250,8 @@ static const struct spinand_info macronix_spinand_table[] = { &update_cache_variants), SPINAND_HAS_QE_BIT, SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout, - mx35lf1ge4ab_ecc_get_status)), + mx35lf1ge4ab_ecc_get_status), + SPINAND_PLANE_SELECT_BIT(&read_and_write_fixups)), SPINAND_INFO("MX35UF4G24AD", SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0xb5, 0x03), NAND_MEMORG(1, 4096, 256, 64, 2048, 40, 2, 1, 1), @@ -225,7 +261,8 @@ static const struct spinand_info macronix_spinand_table[] = { &update_cache_variants), SPINAND_HAS_QE_BIT, SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout, - mx35lf1ge4ab_ecc_get_status)), + mx35lf1ge4ab_ecc_get_status), + SPINAND_PLANE_SELECT_BIT(&write_fixups)), SPINAND_INFO("MX35UF4G24AD-Z4I8", SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0xf5, 0x03), NAND_MEMORG(1, 4096, 256, 64, 2048, 40, 1, 1, 1), @@ -255,7 +292,8 @@ static const struct spinand_info macronix_spinand_table[] = { &update_cache_variants), SPINAND_HAS_QE_BIT, SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout, - mx35lf1ge4ab_ecc_get_status)), + mx35lf1ge4ab_ecc_get_status), + SPINAND_PLANE_SELECT_BIT(&read_and_write_fixups)), SPINAND_INFO("MX35UF2G24AD", SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0xa4, 0x03), NAND_MEMORG(1, 2048, 128, 64, 2048, 40, 2, 1, 1), @@ -265,7 +303,8 @@ static const struct spinand_info macronix_spinand_table[] = { &update_cache_variants), SPINAND_HAS_QE_BIT, SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout, - mx35lf1ge4ab_ecc_get_status)), + mx35lf1ge4ab_ecc_get_status), + SPINAND_PLANE_SELECT_BIT(&write_fixups)), SPINAND_INFO("MX35UF2G24AD-Z4I8", SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0xe4, 0x03), NAND_MEMORG(1, 2048, 128, 64, 2048, 40, 1, 1, 1), From patchwork Wed Jul 10 01:15:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cheng Ming Lin X-Patchwork-Id: 1958629 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=pLnhoAnC; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=UZzdIzGx; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WJg2F3ML9z1ymj for ; Wed, 10 Jul 2024 11:17:23 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=npZJ8NbImitE3ITUgeCG46VK51gaL9mniFbSnG4JKtM=; b=pLnhoAnCg2u273 GvrJUa5ewYUaJJ9V+6daeoHBRwcZylmpLIsCk9G0bDL88dQHxlFQZai5DT749dGxXS4o/0+8XclJR fS6h1hnQMxaDV4668MrUWBliq4FIGSfcX8vhnm3Z9/vP4UuRvA5B03VhyjRH1hhcvzkk7Eo9HCDmf m1FS8PPeV25F6YugO6BJFCqyhB8FNPA55gcB+EbFa1eYrcnVEqZno5K/aEIABaZzjk+cafNDOPWvY ThRiMu0VNkqXR1GP1J913mKN5/L1ISONAr+8vI1pga510JOdrQXzNRTjZ4dmn+jV8vaFcDUEwON1J oofWmjpiN/ZH9ZjES16Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sRLxD-000000093Ry-3mBT; Wed, 10 Jul 2024 01:17:07 +0000 Received: from mail-pg1-x529.google.com ([2607:f8b0:4864:20::529]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sRLxB-000000093Qv-2MRM for linux-mtd@lists.infradead.org; Wed, 10 Jul 2024 01:17:07 +0000 Received: by mail-pg1-x529.google.com with SMTP id 41be03b00d2f7-75c3acf90f0so3251344a12.2 for ; Tue, 09 Jul 2024 18:17:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720574224; x=1721179024; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=L2dsJ2aWzWwaeeiB+7cgn67HIrpaGRIuOZ04+FOm5ts=; b=UZzdIzGx3OssCXt9Alv4Tqossvy6rBhSpayUAp/I60dhTdpLxz7PMkQDTLy3GEjPcT 13G9MtnpmscD57Nb7G4/RYWBhmBDDvDHiNLNJb0yyr1/e/ZHmP3Mlg+70RmSPRbFFh/l LqnUr4/HkeYyDWrTGwwa0qLBqKdy07hnSwbTOiORwvlh6/Rgr8iV+jK7LUpST4L1Vmsw QzAgTayHqCSC+XTKtrcTQtbPLC1goXqhjmAiYLRdJHKvWf+D3/nYR6YrJ3NEW9sKMI9l HV0x/e9ftuf8q2Ti6sbtHbMr7SVKjP6CsZNLCCFE5t30UR3ShvtkK7V0ALxb2YvJkJSA lKbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720574224; x=1721179024; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=L2dsJ2aWzWwaeeiB+7cgn67HIrpaGRIuOZ04+FOm5ts=; b=xEaisFerhIZ2ppW19t1XEZ6McDibOb0DO/tG8++JfTgXblpu5i7FkLgTpVXTA/d+3g suQ/otHCPCxrHSzAVA4cIjn2B78WkaYyN+/haKLmEGY4lzXwznYnLYCH/kbNegKMGNCF ZbpRqHdMYLhx4ozTSU9VxDkCDxBnoWnJDc78FceIlXwcLVOkk0Q4w/aHl78mZYWu57E7 uoXAtCNc2K+UxheBtxshXVzhk9taIFDK9waGzyLdMJ/6of2OdhgBtL8fPca3qa3qXFp4 BCEogA9AdMkPlag9u6T/rHBZZMg0VSsAe3WG3ev28JZiO43EL2GsRNmqfB3k7SYMWq1w 18JA== X-Forwarded-Encrypted: i=1; AJvYcCV2iJ0IjOYHTtEjmX0Zr0bONR4fcGCEuHWEnt1ywECzKmmPDbx9bTUqKWgET5elL5Hx4C3E2iOkmsoR+L8IwJgpL3D3ie3pXrKuoC6/og== X-Gm-Message-State: AOJu0YzM0O3eVJq4dthUejuUFXMQ1JJwQy3HLwEK6OJLmgLv8jsTDhJ+ meSOgixB82sXAHbotlRrnD/GylkS649rpi+ZuxI1vwjBz3kZFRz5 X-Google-Smtp-Source: AGHT+IHm6oTa46wAfHgqvgABJgg5St2rt8NOqt0qemFHgyPVBzhcmvIccECM4VmefXK8hvUPLjeUqw== X-Received: by 2002:a05:6a20:7288:b0:1c1:f6f1:de05 with SMTP id adf61e73a8af0-1c298206687mr5241342637.6.1720574223818; Tue, 09 Jul 2024 18:17:03 -0700 (PDT) Received: from twhmp6px (mxsmtp211.mxic.com.tw. [211.75.127.162]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fbb6ad4b60sm21960575ad.296.2024.07.09.18.17.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jul 2024 18:17:03 -0700 (PDT) Received: from hqs-appsw-a2o.mp600.macronix.com (linux-patcher [172.17.236.67]) by twhmp6px (Postfix) with ESMTPS id 5D9C480DF0; Wed, 10 Jul 2024 09:26:29 +0800 (CST) From: Cheng Ming Lin To: miquel.raynal@bootlin.com, vigneshr@ti.com, linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org Cc: richard@nod.at, alvinzhou@mxic.com.tw, leoyu@mxic.com.tw, Cheng Ming Lin Subject: [PATCH 3/3] mtd: spinand: Insert Plane Select bit for the column address Date: Wed, 10 Jul 2024 09:15:41 +0800 Message-Id: <20240710011541.342682-4-linchengming884@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240710011541.342682-1-linchengming884@gmail.com> References: <20240710011541.342682-1-linchengming884@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240709_181705_627769_FE6C3342 X-CRM114-Status: GOOD ( 10.34 ) X-Spam-Score: -1.8 (-) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From: Cheng Ming Lin In the function spinand_read_from_cache_op and spinand_write_to_cache_op, add an if statement to determine whether the device has fixups and their corresponding functions. If so, give the Plane Select [...] Content analysis details: (-1.8 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [linchengming884(at)gmail.com] 0.2 FREEMAIL_ENVFROM_END_DIGIT Envelope-from freemail username ends in digit [linchengming884(at)gmail.com] -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:529 listed in] [list.dnswl.org] X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: Cheng Ming Lin In the function spinand_read_from_cache_op and spinand_write_to_cache_op, add an if statement to determine whether the device has fixups and their corresponding functions. If so, give the Plane Select bit to the column address. In the function spinand_match_and_init, add spinand_info in spinand_device for determining whether Plane Select bit should be inserted. Signed-off-by: Cheng Ming Lin --- drivers/mtd/nand/spi/core.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/mtd/nand/spi/core.c b/drivers/mtd/nand/spi/core.c index e0b6715e5dfe..d6d6f3832f9d 100644 --- a/drivers/mtd/nand/spi/core.c +++ b/drivers/mtd/nand/spi/core.c @@ -386,6 +386,9 @@ static int spinand_read_from_cache_op(struct spinand_device *spinand, else rdesc = spinand->dirmaps[req->pos.plane].rdesc_ecc; + if (spinand->info->fixups && spinand->info->fixups->read_from_cache) + column = spinand->info->fixups->read_from_cache(spinand, req, column); + while (nbytes) { ret = spi_mem_dirmap_read(rdesc, column, nbytes, buf); if (ret < 0) @@ -460,6 +463,9 @@ static int spinand_write_to_cache_op(struct spinand_device *spinand, else wdesc = spinand->dirmaps[req->pos.plane].wdesc_ecc; + if (spinand->info->fixups && spinand->info->fixups->write_to_cache) + column = spinand->info->fixups->write_to_cache(spinand, req, column); + while (nbytes) { ret = spi_mem_dirmap_write(wdesc, column, nbytes, buf); if (ret < 0) @@ -1095,6 +1101,7 @@ int spinand_match_and_init(struct spinand_device *spinand, spinand->flags = table[i].flags; spinand->id.len = 1 + table[i].devid.len; spinand->select_target = table[i].select_target; + spinand->info = info; op = spinand_select_op_variant(spinand, info->op_variants.read_cache);