Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp3395963rdg; Tue, 17 Oct 2023 13:25:24 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGQ4F7WPYQ9CAcM/eGLjcz32owLbMdz9nutJlMdjxnZQDR2JI+TaOZ9u7RJcvoDfCMdO9yX X-Received: by 2002:a17:90a:b116:b0:27d:469b:8847 with SMTP id z22-20020a17090ab11600b0027d469b8847mr4309745pjq.3.1697574323908; Tue, 17 Oct 2023 13:25:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697574323; cv=none; d=google.com; s=arc-20160816; b=vyiZO6X5O4YWEeyZ1WqXch+ehmdcSzqYVdYDAR0CeYTKxQ+eZuRV7p9ANzwOKyZma4 t5dfmEQntDC/5OYb7hI8wqdRrmkxuLDMCAn5E14cMd5Oey1EeYMgE7qztf6gbJA0fYkg HKR7ea/2w6BCIL/d9S5RPR6l9KFhnNtmVykU3WnexYN/tqXsNks4lbv/AGlyuyCHE0a8 LR8VbyCnsgFG19hfIFLJWyvjexxBRbGj4cNFzGHNV2cHYRETtePg7IRlQfFGpHHjZAzW 7BhXiv4eg3mHeGXP7FwJuFHexzJdEnzJsJHXGXXWcCFvbND9iy6TPEoAW5GpZV7HF8tK f8GA== 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=Gr7LV0MCdYIeDbTQFoRwd7icEDoaSY1jNRs368vCLu0=; fh=lfAd5TsfVh9BTYx9igt3Bf9h5gePoTDTN4yNWHzDK+4=; b=D7tIR2Snn1n8XjMkWVw83nOkgK5TLLlQLNnkmkVsZbgHd68fbLWPTxbFNC+wJy8JQ0 MgSwXw8XldHLjaEXEpPOl53CsAUQPpa/3JgRF59yd20lakNxf0UGEo5iCwPVRQkLeMC1 6+t2tVSp97R/LsqaLcY88nSO8FwHRSMcWVH4D1lo4QvH4ZHAY0ijnKkrrv42xPtG+Q8U Lrp/MV2CMRCCuxpmY6IMRKvBENQ5/hg2jGzEJKA/xWHL+qAz33PinnY/89bKQPitSBi1 caQ3QoSI6Ge8xaIByG6EEUEs1WcV3hff7sK6SJeYTHbaPWDWXcwXNPwSar/Je2UXLVRb gWIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@broadcom.com header.s=dkimrelay header.b=Y+eT6a9j; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id gv13-20020a17090b11cd00b00276671731e3si8939377pjb.136.2023.10.17.13.25.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Oct 2023 13:25:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@broadcom.com header.s=dkimrelay header.b=Y+eT6a9j; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (Postfix) with ESMTP id 9EE1080725E1; Tue, 17 Oct 2023 13:25:21 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344259AbjJQUZJ (ORCPT + 99 others); Tue, 17 Oct 2023 16:25:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60184 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229459AbjJQUZG (ORCPT ); Tue, 17 Oct 2023 16:25:06 -0400 Received: from relay.smtp-ext.broadcom.com (relay.smtp-ext.broadcom.com [192.19.144.205]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C71649F for ; Tue, 17 Oct 2023 13:25:04 -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 47F4EC0000D8; Tue, 17 Oct 2023 13:14:25 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 relay.smtp-ext.broadcom.com 47F4EC0000D8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=broadcom.com; s=dkimrelay; t=1697573665; bh=tBn6kkRIWrbPaufSu2mfZ5pGqIIQ8elgGhO/0Q133Gk=; h=From:To:Subject:Date:From; b=Y+eT6a9jWr5nm+jBffFQ/Pge5G0n9ajKdzLObrp4CgSAIJ8mwFFoTbJszmXpXbwBW O9A5S8Wgr83qrE9WkTi3cJNDgeVZG4qfAkov6SNwcYbdJLpYflwfEnUK7I4wtsduCm 7ygYYulzTdYg2Gej7JnTF7I+K+NCAECEsgrlj24E= 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 0AE6418728C; Tue, 17 Oct 2023 13:14:25 -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 , Arseniy Krasnov , Adam Borowski Subject: [PATCH v3 1/4] mtd: rawnand: Add destructive operation Date: Tue, 17 Oct 2023 13:14:14 -0700 Message-Id: <20231017201417.129872-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 groat.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 (groat.vger.email [0.0.0.0]); Tue, 17 Oct 2023 13:25:21 -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 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