Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp1366374rda; Mon, 23 Oct 2023 10:16:06 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHw/BT34bnYJBqvy4A9zTSae7ec2HSVaYsPT0eRNO6UCN+20SCsS3sLWm4oelZMTccuYTmV X-Received: by 2002:a17:90b:118a:b0:27d:3439:c141 with SMTP id gk10-20020a17090b118a00b0027d3439c141mr6647377pjb.39.1698081366542; Mon, 23 Oct 2023 10:16:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698081366; cv=none; d=google.com; s=arc-20160816; b=YVhEvZYH8X/LD8KCLeztE0WkhpdVIPMCa9puKPjTr44rhEzWm4ToYwOsMjsvAbh2Pa mNpPX0bLhzhAx1QxEEGR5ZlVDnzImkLHNY9cKFSnUMaIoum/4ytwmEOHYAIVTu/W4oEX z1FHdkxpm8YKu1J6SAXg0q8Pfu8cDQPZ+JU+NfeHV8EuSZk/l6hVolkdMNQ1MKkNNRGv s3v8Jl4RvwVKtVl2AqF8vaNMf747TtAfzp0XlyTNXASXNYw/apiC//yK6yDIWDEwyeQE QAcz/59H+csY0zHdNbItfFbWdP7pDxZpx2O6YJGcF9kivKDvsZXNtiI88ouDbvVgvRKo IfMQ== 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=GbPzOUHO/8oDScyHKH1QZCa4eUnis0JGP82RDIQFw0g=; fh=EdTPwUecijA4lt+26RESfjrSLeIfqn/38PEwzmRo+y0=; b=iQXjpO0Sr2fo9lk1l2s2mFqcj0NumpzJI2HpLcSv+MoqCsXdKMuAwsGK+oISZRmOjn MSapW7NIOoYoEMjqEjfFUM+010L6jmPe5k191SA3iGCSEUJEaTePvQT5bLqGQRsg+l8v jhPlsKBImQP6RuNBqUSKMdb7pEzN9cMV/e/gEhxFl9bL4IaXfR7szluxgeAlopcZxdE4 M1EaQWePEscIivih4b6vnfzLllEnt1KUu7zn1EVBcOVDzB2F7wxXpVWl7hHmNpCx+Lqr TJZWK9ZeQO3ppovhrIqVq919MqjQ09fP8RMvVhklu0pv0V3k9DiDXO8EXgmQ5rOngi8g eumA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@broadcom.com header.s=dkimrelay header.b=DPVYds28; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 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 morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id ng16-20020a17090b1a9000b0027d09fa3a9bsi6805079pjb.183.2023.10.23.10.16.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Oct 2023 10:16:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@broadcom.com header.s=dkimrelay header.b=DPVYds28; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 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 morse.vger.email (Postfix) with ESMTP id A8B3F808A952; Mon, 23 Oct 2023 10:15:11 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229452AbjJWRPA (ORCPT + 99 others); Mon, 23 Oct 2023 13:15:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38708 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231147AbjJWRO4 (ORCPT ); Mon, 23 Oct 2023 13:14:56 -0400 Received: from relay.smtp-ext.broadcom.com (relay.smtp-ext.broadcom.com [192.19.166.228]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 73E67EE for ; Mon, 23 Oct 2023 10:14:53 -0700 (PDT) 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 331A8C004ECC; Mon, 23 Oct 2023 10:14:53 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 relay.smtp-ext.broadcom.com 331A8C004ECC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=broadcom.com; s=dkimrelay; t=1698081293; bh=a3Dt7syR5zhVX9KM9JkJeWq0PAXWyXzBW8y0XTgiNwU=; h=From:To:Subject:Date:From; b=DPVYds28HnXXIauHOisI/aEi8mllIbZTggVLW3bpsf3ReN6fF7twHLK+Is+jhgyrB n7mc65MfS1MinLEjZ3vHe9T29KM5ru70EXq+1c27gZYZcccW1R55VFMHL8+234GbSv jd+r3bhvzvUIIcnIkqs9WH41jajCiakGJ+0bR/Y8= 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 2E2B018728D; Mon, 23 Oct 2023 10:14:53 -0700 (PDT) From: dregan@broadcom.com To: dregan@broadcom.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 v4 1/4] mtd: rawnand: Add destructive operation Date: Mon, 23 Oct 2023 10:14:41 -0700 Message-Id: <20231023171444.322311-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 autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.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 (morse.vger.email [0.0.0.0]); Mon, 23 Oct 2023 10:15:13 -0700 (PDT) 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 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