Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp1584447rdh; Fri, 24 Nov 2023 17:25:51 -0800 (PST) X-Google-Smtp-Source: AGHT+IHLLso9IVcg6A3KmI4WBzaBxidQYNSuuAT+w9iXPhg/v+qiu8YfqSJYLYKxt5TDGTUek9PE X-Received: by 2002:a17:903:4284:b0:1cf:a7f9:1e7a with SMTP id ju4-20020a170903428400b001cfa7f91e7amr2986959plb.45.1700875551104; Fri, 24 Nov 2023 17:25:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700875551; cv=none; d=google.com; s=arc-20160816; b=HCspmO/5mLp+ijWWZToZTjGr7dDaVmpuiiTLDIzB4KZYVJ7AGkHHv6TdBzdBHJOqnz SFNlbDol8UbQXExVw2Tdv3j0cGDwk+R3aOyvpWZMbBr1Z65d7sXV76XJ0Tro3XtFXfrx oQacYFqPRSUBmds4+LHJk2WMTQcA4kGOglLsNQbGtNsM6Uaef9Dw1hOaXC7a5wsatFQ9 qWfvhFOk3CvGViA4VYZAoLdVQg6kTWTVP4EkPFIT5gEXhkdO3AsGc8Bfp2CsFIBHjtYj CuEGPx133tuKGG8IvbfYoLrn8GcNXe/S97xy+tdlt+7XhE11xl4SmW9GZgcviSUzjgFL lB8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:to:from:dkim-signature:dkim-filter; bh=8cKH+00QLPYphjd6nI/Q/1ew+GnNQ+JWlAdIXyGF73Q=; fh=D0xTDT8JZUJUGz1XFB7l99IKFp7kT1GUVSOnE/fHaPw=; b=jhn/dh/TMOYfwxuV89d3Fp32kWZCSlXjSOOKpOi//H0vNtIeyM1DsOknIgYGV3gVXH r9LC7jmM0R0318weohvCZPKEVH5t1z6B4Qfr1MBY/JKDZbXuAKKwCsSa7Y457fKvCkoV l6VX94m2hCg4UGXrFUxMiPO3C1ZcAGfq8sHOEJZJyikBOiobpnKEmFbe6OEmXG84yMJV MkWwN2yMcNH622EfgcXehQ7kxqdP1qW6a1fy4hD77V7r4CR4EG8R5/asCCsJBGfJTDax vzxoS8K+P1DLQWwaAAi0psTaBnQQUMansJgqALgAz1z3+KaDJT/u+ymcYFu34clZRPfk l+sQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@broadcom.com header.s=dkimrelay header.b=RCjXWtK0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id t16-20020a170902e85000b001cfad613daesi1385742plg.426.2023.11.24.17.25.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Nov 2023 17:25:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@broadcom.com header.s=dkimrelay header.b=RCjXWtK0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 3150A81CA3DD; Fri, 24 Nov 2023 17:25:19 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231477AbjKYBYx (ORCPT + 99 others); Fri, 24 Nov 2023 20:24:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46774 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229665AbjKYBYw (ORCPT ); Fri, 24 Nov 2023 20:24:52 -0500 Received: from relay.smtp-ext.broadcom.com (lpdvacalvio01.broadcom.com [192.19.166.228]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 67FF519A7 for ; Fri, 24 Nov 2023 17:24:59 -0800 (PST) Received: from bld-lvn-bcawlan-34.lvn.broadcom.net (bld-lvn-bcawlan-34.lvn.broadcom.net [10.75.138.137]) by relay.smtp-ext.broadcom.com (Postfix) with ESMTP id B7B1DC00D81F; Fri, 24 Nov 2023 17:24:58 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 relay.smtp-ext.broadcom.com B7B1DC00D81F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=broadcom.com; s=dkimrelay; t=1700875498; bh=DQ8LMf3Ex880b9Z5syPjfKqs+fmbjl2xowcOD65nBa8=; h=From:To:Subject:Date:From; b=RCjXWtK0+B4kAQZNXBVDYC6jlYop0gCNDeLrm5Foeq4DvOIDMc7jvM6gO9QM4PnSC t3HewKQ3+J+2AHaBnBPRalMIK6bgcTzAeIFkUVF53THzBqLxUz57011sqD64LzemdP NdCHPW+KfhXk44LQBXv76jfpMi9kHsdn5ajRacJU= Received: from bcacpedev-irv-3.lvn.broadcom.net (bcacpedev-irv-3.lvn.broadcom.net [10.75.138.105]) by bld-lvn-bcawlan-34.lvn.broadcom.net (Postfix) with ESMTPSA id B2E1618728D; Fri, 24 Nov 2023 17:24:58 -0800 (PST) From: dregan@broadcom.com To: dregan@broadcom.com, miquel.raynal@bootlin.com, bcm-kernel-feedback-list@broadcom.com, linux-mtd@lists.infradead.org, f.fainelli@gmail.com, rafal@milecki.pl, joel.peshkin@broadcom.com, computersforpeace@gmail.com, dan.beygelman@broadcom.com, william.zhang@broadcom.com, frieder.schrempf@kontron.de, linux-kernel@vger.kernel.org, vigneshr@ti.com, richard@nod.at, bbrezillon@kernel.org, kdasu.kdev@gmail.com, JaimeLiao , Adam Borowski Subject: [PATCH v5 1/4] mtd: rawnand: Add destructive operation Date: Fri, 24 Nov 2023 17:24:35 -0800 Message-Id: <20231125012438.15191-1-dregan@broadcom.com> X-Mailer: git-send-email 2.37.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Fri, 24 Nov 2023 17:25:19 -0800 (PST) From: Boris Brezillon Erase and program operations need the write protect (wp) pin to be de-asserted to take effect. Add the concept of destructive operation and pass the information to exec_op() so controllers know when they should de-assert this pin without having to decode the command opcode. Signed-off-by: Boris Brezillon Signed-off-by: David Regan --- Changes in v5: none Changes in v4: none Changes in v3: updated comments and email address Changes in v2: gave credit to Boris Brezillon --- drivers/mtd/nand/raw/nand_base.c | 6 ++++-- include/linux/mtd/rawnand.h | 9 +++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c index d4b55155aeae..47cc2c35153b 100644 --- a/drivers/mtd/nand/raw/nand_base.c +++ b/drivers/mtd/nand/raw/nand_base.c @@ -1494,7 +1494,8 @@ static int nand_exec_prog_page_op(struct nand_chip *chip, unsigned int page, NAND_COMMON_TIMING_NS(conf, tWB_max)), NAND_OP_WAIT_RDY(NAND_COMMON_TIMING_MS(conf, tPROG_max), 0), }; - struct nand_operation op = NAND_OPERATION(chip->cur_cs, instrs); + struct nand_operation op = NAND_DESTRUCTIVE_OPERATION(chip->cur_cs, + instrs); int naddrs = nand_fill_column_cycles(chip, addrs, offset_in_page); if (naddrs < 0) @@ -1917,7 +1918,8 @@ int nand_erase_op(struct nand_chip *chip, unsigned int eraseblock) NAND_OP_WAIT_RDY(NAND_COMMON_TIMING_MS(conf, tBERS_max), 0), }; - struct nand_operation op = NAND_OPERATION(chip->cur_cs, instrs); + struct nand_operation op = NAND_DESTRUCTIVE_OPERATION(chip->cur_cs, + instrs); if (chip->options & NAND_ROW_ADDR_3) instrs[1].ctx.addr.naddrs++; diff --git a/include/linux/mtd/rawnand.h b/include/linux/mtd/rawnand.h index 90a141ba2a5a..31aceda8616c 100644 --- a/include/linux/mtd/rawnand.h +++ b/include/linux/mtd/rawnand.h @@ -1008,6 +1008,7 @@ struct nand_op_parser { */ struct nand_operation { unsigned int cs; + bool deassert_wp; const struct nand_op_instr *instrs; unsigned int ninstrs; }; @@ -1019,6 +1020,14 @@ struct nand_operation { .ninstrs = ARRAY_SIZE(_instrs), \ } +#define NAND_DESTRUCTIVE_OPERATION(_cs, _instrs) \ + { \ + .cs = _cs, \ + .deassert_wp = true, \ + .instrs = _instrs, \ + .ninstrs = ARRAY_SIZE(_instrs), \ + } + int nand_op_parser_exec_op(struct nand_chip *chip, const struct nand_op_parser *parser, const struct nand_operation *op, bool check_only); -- 2.37.3