Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp1366373rda; Mon, 23 Oct 2023 10:16:06 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHq098HbNHrUq/x2JrWnh/XbxLw0GGkZtva7yHzVngyvd3bBiD5SPBUKswbMBgUWwKlynIV X-Received: by 2002:a17:902:d487:b0:1ca:dee1:4d1a with SMTP id c7-20020a170902d48700b001cadee14d1amr3960278plg.25.1698081366551; 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=Ahgipr43LcF/w1wAnAlnekeFFLhKgleOz734k/PcW9JBCEM9QgLQXs7jO5k/J7vj+g vp8uczhXG9j4cYUdEL/bOO8SSro1da5QLEcWk9LGODw/v3iVNOMPuCi+9wWQFl1owrW7 0HK7Z38+DNkpWDBkguc9xycCxMAd7qzIJ65JVUqHxZnesab53QjW749qbpnjSULfV87+ AH1KBSUlziL7AIop0GFYNbxYoqt4NB4jhiwSZOlnLHGNIqOHX32BlAHv8M2gU/LhSeI0 adCTXVZzV6OQknv31OkILoSF3xcPyqkSyLN32gMKSRZKcRRS1fACQt1DWnRiAk/UTKqg vvww== 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=7pXgd3lq3w9XrS6bgdfdUC+nqjZSiy118vpqz6pZEKI=; fh=EdTPwUecijA4lt+26RESfjrSLeIfqn/38PEwzmRo+y0=; b=D5zT/T8TnqasZfe5oX0mzR8WJ1J9fGX3898mSeM3wll4Z1Qg893ule+DmeTcPKG0vN QEHrEu//FiU/0EXzqCqgGG1Cf0fNcNMVEvxA3QJQYwb9AkCkAE59mGH1Vlr0ixLmoQ+K dAAe+U2Vz9YiIs2fWs/gT3KRxack3tegNtZEprUrEnJfKlfF9oQQOmqWGLa44fpB1uLw NJUAHmsXJ7JhyC0ZZxSQxYBuNdbkXFe3CvA8ntijuXwTBP+5BbD4DzblC9iNGaGUELIu DWP3SeE7bNCiiqj5CatPSYDnk5e7L5pgaIKlxJ/6D3I1aDPJss13MpuN1WrMymSiOg4V rtAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@broadcom.com header.s=dkimrelay header.b=X5OC5BT6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id a11-20020a170902eccb00b001b894687ec9si6881397plh.462.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 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@broadcom.com header.s=dkimrelay header.b=X5OC5BT6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (Postfix) with ESMTP id 0CF5C8077519; Mon, 23 Oct 2023 10:15:23 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231352AbjJWRPC (ORCPT + 99 others); Mon, 23 Oct 2023 13:15:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38760 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231236AbjJWRPB (ORCPT ); Mon, 23 Oct 2023 13:15:01 -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 1667910A for ; Mon, 23 Oct 2023 10:14:59 -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 6C831C0070BB; Mon, 23 Oct 2023 10:14:58 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 relay.smtp-ext.broadcom.com 6C831C0070BB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=broadcom.com; s=dkimrelay; t=1698081298; bh=a2hqiY6Qekk9mAIPXaQG+LhooV2+mDpVnQWIKZr0zN8=; h=From:To:Subject:Date:In-Reply-To:References:From; b=X5OC5BT6FdP3hKL974YGYiLj9tPPOJYcfB7coPvW/m06Gok50BmQo4sVP9hGYIIeR aS6qW3HMxzPykCMWmfSV7grUzS9ajFcrlKcgHL8AWzx4pE9YGNhwP/dSzSofX5UeTc wGcKiCHLotS2tngoFYvmXXs+vjI2VQYgAuVIW/gw= 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 6058D18728D; Mon, 23 Oct 2023 10:14:58 -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 2/4] mtd: rawnand: NAND controller write protect Date: Mon, 23 Oct 2023 10:14:42 -0700 Message-Id: <20231023171444.322311-2-dregan@broadcom.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20231023171444.322311-1-dregan@broadcom.com> References: <20231023171444.322311-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 lipwig.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 (lipwig.vger.email [0.0.0.0]); Mon, 23 Oct 2023 10:15: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 v4: none 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