Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp3395979rdg; Tue, 17 Oct 2023 13:25:26 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEAY6nkruef/SE18lOK8PYvs83kChmrpUfRLC9pw1xcDpfPWfPr0ANAcEajkYUs+yn1da6F X-Received: by 2002:a05:6a21:3d85:b0:170:3e5b:bccd with SMTP id bj5-20020a056a213d8500b001703e5bbccdmr3372721pzc.30.1697574325782; Tue, 17 Oct 2023 13:25:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697574325; cv=none; d=google.com; s=arc-20160816; b=IPj7Fot24ly2WI447KJ3GtvInHNh4Tf8twrBko79Bzv4liNYYBZ7KevjC3ETc6WhDU XodqK0jDdr/47j885u53am28VMCVFuW0QJgnSSV1kt892kRWK0/MZUcOlxsG6puCwN7F jyiWifykeoX1RVRywaV28dapEr2kb6pB/QXAc6f5SnQd1hSjiwRH9YyL7ri1Xifr1hsg vzdwSO6oNWuXzB/puYGxRIGrQRkEuj6NcaR3XIv7PMqOJK/C3835swWvj2fy8IYDJk1O jfFjjfznAFklMvqrC6ozauoY9mGN7iSiT8jIlSsiVi8YFj5KNTKl+0eid77D0qM1ExFY 2e8g== 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 :references:in-reply-to:message-id:date:subject:to:from :dkim-signature:dkim-filter; bh=+IW9nXW1eqnuGSU1PZwQqo7XciJD4fNTX+uinsYyQqA=; fh=lfAd5TsfVh9BTYx9igt3Bf9h5gePoTDTN4yNWHzDK+4=; b=Uxu6VSsOMxh5VJgMrA7levVdLpDsy5lPO4f64ej3up9Av4XqcDqFKjDWVD+tSOdhfU CHKymOvo0YyHMqQd2P+TBSdvP1J2bva6ouAAMfS0uBgYXBFlL0Q/zgRxTxv+W05aLmYG ygwd0XS0TigCEzJBCsmio5ztODSqIaxEpay1adnDWlWq87wP21yDNCUFbaYqAco8LUcT /xqPfnPPA/Uqvzip1va5MnJyYD1NEzse7zEnkexi+dAcX0d4Vm0HiK2eUvB/VRc9yG+R fZEW4GN1vY87Nm1q01/tqjSPdcPTB2A+fv3gXGdeCkj2DUrnZQcym3qeWeeyupqsXIC8 C8lA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@broadcom.com header.s=dkimrelay header.b=bLOui97v; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id r36-20020a635d24000000b005aba9cdf091si531841pgb.579.2023.10.17.13.25.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Oct 2023 13:25:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@broadcom.com header.s=dkimrelay header.b=bLOui97v; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (Postfix) with ESMTP id 71DB88027A29; Tue, 17 Oct 2023 13:25:23 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232593AbjJQUZI (ORCPT + 99 others); Tue, 17 Oct 2023 16:25:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231149AbjJQUZG (ORCPT ); Tue, 17 Oct 2023 16:25:06 -0400 X-Greylist: delayed 638 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Tue, 17 Oct 2023 13:25:04 PDT Received: from relay.smtp-ext.broadcom.com (saphodev.broadcom.com [192.19.144.205]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C711092 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 0BD47C0000EC; Tue, 17 Oct 2023 13:14:27 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 relay.smtp-ext.broadcom.com 0BD47C0000EC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=broadcom.com; s=dkimrelay; t=1697573667; bh=oW0lQ3mYZRJIZP8XWJKIYdybmuCVAGqC6zfftB7GtOY=; h=From:To:Subject:Date:In-Reply-To:References:From; b=bLOui97vVPIIAoyBiNvaNPSDGKX4vJPCpU6gKWtKhyke5YskrVqDIHOch+H92sqWw 1yFn8P/zuTiA8Yvnl/JNCY/UxZx+Qowgecy+EGNeyA0GurDlL91iySkiS9cD1Dop8V kkNxGalHPTrHw7sZUJyNUkCL2HVHJpUig5f0ozgk= 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 BB8AE18728C; Tue, 17 Oct 2023 13:14:26 -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 2/4] mtd: rawnand: NAND controller write protect Date: Tue, 17 Oct 2023 13:14:15 -0700 Message-Id: <20231017201417.129872-2-dregan@broadcom.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20231017201417.129872-1-dregan@broadcom.com> References: <20231017201417.129872-1-dregan@broadcom.com> 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 agentk.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 (agentk.vger.email [0.0.0.0]); Tue, 17 Oct 2023 13:25:23 -0700 (PDT) From: David Regan Allow NAND controller to be responsible for write protect pin handling during fast path and exec_op destructive operation when controller_wp flag is set. Signed-off-by: David Regan --- Changes in v3: update comments Changes in v2: none --- drivers/mtd/nand/raw/nand_base.c | 4 ++++ include/linux/mtd/rawnand.h | 2 ++ 2 files changed, 6 insertions(+) diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c index 47cc2c35153b..38ed0ced5b8e 100644 --- a/drivers/mtd/nand/raw/nand_base.c +++ b/drivers/mtd/nand/raw/nand_base.c @@ -367,6 +367,10 @@ static int nand_check_wp(struct nand_chip *chip) if (chip->options & NAND_BROKEN_XD) return 0; + /* controller responsible for NAND write protect */ + if (chip->controller->controller_wp) + return 0; + /* Check the WP bit */ ret = nand_status_op(chip, &status); if (ret) diff --git a/include/linux/mtd/rawnand.h b/include/linux/mtd/rawnand.h index 31aceda8616c..fcad94aa0515 100644 --- a/include/linux/mtd/rawnand.h +++ b/include/linux/mtd/rawnand.h @@ -1111,6 +1111,7 @@ struct nand_controller_ops { * the bus without restarting an entire read operation nor * changing the column. * @supported_op.cont_read: The controller supports sequential cache reads. + * @controller_wp: the controller is in charge of handling the WP pin. */ struct nand_controller { struct mutex lock; @@ -1119,6 +1120,7 @@ struct nand_controller { unsigned int data_only_read: 1; unsigned int cont_read: 1; } supported_op; + bool controller_wp; }; static inline void nand_controller_init(struct nand_controller *nfc) -- 2.37.3