Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp3726788ybg; Mon, 28 Oct 2019 18:11:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqwKmL8QAKp28Tc5nSw3Iz62YKdHR1IaRcOfG7h8c4OqUf3F3vdvPlG5l+9cMHVm8xtez0vQ X-Received: by 2002:a50:b83d:: with SMTP id j58mr22768207ede.84.1572311498854; Mon, 28 Oct 2019 18:11:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572311498; cv=none; d=google.com; s=arc-20160816; b=nF7Jfii9R1xe1U0/gPeSqyg3z2Sw+09LKTqiP1Gh8WtRcm7nn2x6vr80Wr1FdXfrcL zcgZ/21TI9TwFZbth8zeIsRXKImt2r6oqyGCx52pE3K3zJqiL1SzZ3rE9anAaMCKY6ue QCO7YzjvV6h0o3T6GScxmtJEzsquSAXcdl0BJwuCZNkDDpSJgARekW0gTmIcN4MDMozB AFEzmnNIpfuXg+oOeWZI0dnt5g7rEK088CQStlIZ2CoxsebyUYCL1osfB1fzBVwsqFkZ DX0kt/zXudlLU5o5XVyiedlTDIPpUs74rY/J0lzPfBSjOOwD9h7ZC3o20TVC8FiIjY4P xiNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=5FUewC+sR5MfS3fdt0bCKapESHh6J96O8Ow/6mfDKFs=; b=oJp3L989zXu53NiOn0YQD855opP+PiAtetURT4Lt5W4CdsrGhP8GWk2W2lQKEDWbRN 0ba8XKFw1B02rBSjMs/h74RdYQPCHli3YiZrCKzBI5BrxeWLLbZNVgOQkChmVv0ZlmMZ eT8LHKyYJpTnxocdN6X+l9dcfhy7hhOWiTbha7fLRnu1zmoKYZniTdTlLStZEdkimdU0 qegnBXLv9HpRiQGn2fqMwcZcDG3r7IehaRUhqeFPo5BCxWT27lBzILk/KHN9e+GS6+RX /z7Ji68R8XeysWL2og7vK2SVdLNeDrMHA8A859Ah0TN0a1NQh4qPjD/M8dtM+kSWrYB3 d21Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 17si6829866ejt.403.2019.10.28.18.11.15; Mon, 28 Oct 2019 18:11:38 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732261AbfJ1J3j (ORCPT + 99 others); Mon, 28 Oct 2019 05:29:39 -0400 Received: from twhmllg4.macronix.com ([211.75.127.132]:61717 "EHLO TWHMLLG4.macronix.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731707AbfJ1J3j (ORCPT ); Mon, 28 Oct 2019 05:29:39 -0400 Received: from localhost.localdomain ([172.17.195.96]) by TWHMLLG4.macronix.com with ESMTP id x9S9TQPN013435; Mon, 28 Oct 2019 17:29:27 +0800 (GMT-8) (envelope-from masonccyang@mxic.com.tw) From: Mason Yang To: miquel.raynal@bootlin.com, richard@nod.at, marek.vasut@gmail.com, dwmw2@infradead.org, bbrezillon@kernel.org, computersforpeace@gmail.com, vigneshr@ti.com Cc: juliensu@mxic.com.tw, linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org, masonccyang@mxic.com.tw Subject: [PATCH v2 1/4] mtd: rawnand: Add support manufacturer specific lock/unlock operatoin Date: Mon, 28 Oct 2019 17:55:24 +0800 Message-Id: <1572256527-5074-2-git-send-email-masonccyang@mxic.com.tw> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1572256527-5074-1-git-send-email-masonccyang@mxic.com.tw> References: <1572256527-5074-1-git-send-email-masonccyang@mxic.com.tw> X-MAIL: TWHMLLG4.macronix.com x9S9TQPN013435 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add nand_lock() & nand_unlock() for manufacturer specific lock & unlock operation while the device supports Block Protection function. Signed-off-by: Mason Yang --- drivers/mtd/nand/raw/nand_base.c | 32 ++++++++++++++++++++++++++++++-- include/linux/mtd/rawnand.h | 3 +++ 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c index 5c2c30a..5e318ff 100644 --- a/drivers/mtd/nand/raw/nand_base.c +++ b/drivers/mtd/nand/raw/nand_base.c @@ -4356,6 +4356,34 @@ static void nand_shutdown(struct mtd_info *mtd) nand_suspend(mtd); } +/** + * nand_lock - [MTD Interface] Lock the NAND flash + * @mtd: MTD device structure + */ +static int nand_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len) +{ + struct nand_chip *chip = mtd_to_nand(mtd); + + if (!chip->_lock) + return -ENOTSUPP; + + return chip->_lock(chip, ofs, len); +} + +/** + * nand_unlock - [MTD Interface] Unlock the NAND flash + * @mtd: MTD device structure + */ +static int nand_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len) +{ + struct nand_chip *chip = mtd_to_nand(mtd); + + if (!chip->_unlock) + return -ENOTSUPP; + + return chip->_unlock(chip, ofs, len); +} + /* Set default functions */ static void nand_set_defaults(struct nand_chip *chip) { @@ -5782,8 +5810,8 @@ static int nand_scan_tail(struct nand_chip *chip) mtd->_read_oob = nand_read_oob; mtd->_write_oob = nand_write_oob; mtd->_sync = nand_sync; - mtd->_lock = NULL; - mtd->_unlock = NULL; + mtd->_lock = nand_lock; + mtd->_unlock = nand_unlock; mtd->_suspend = nand_suspend; mtd->_resume = nand_resume; mtd->_reboot = nand_shutdown; diff --git a/include/linux/mtd/rawnand.h b/include/linux/mtd/rawnand.h index 4ab9bcc..2430ecd 100644 --- a/include/linux/mtd/rawnand.h +++ b/include/linux/mtd/rawnand.h @@ -1136,6 +1136,9 @@ struct nand_chip { const struct nand_manufacturer *desc; void *priv; } manufacturer; + + int (*_lock)(struct nand_chip *chip, loff_t ofs, uint64_t len); + int (*_unlock)(struct nand_chip *chip, loff_t ofs, uint64_t len); }; extern const struct mtd_ooblayout_ops nand_ooblayout_sp_ops; -- 1.9.1