From patchwork Sat Feb 3 09:55:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miquel Raynal X-Patchwork-Id: 868878 X-Patchwork-Delegate: boris.brezillon@free-electrons.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=65.50.211.133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="AkFonbGH"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zYTmF70sTz9t5l for ; Sat, 3 Feb 2018 20:57:17 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=XBohOp/z5zclx0XYuaVFqCZ5JsqbSVTrmy4BUaZlHpY=; b=AkFonbGHAmvdR2f0nOy3ZE9mwc QsHyoBvH984fWh1fq9sJGBeP9lKbhWTWzE8kH9lR+OKFOb2+tJ32uACcHdCGnd8dMXy8j5pzOBToP DAE90Fqdl59yPC+Y8pQbdhYf/0wFuY2+bXuM8zgA9cf6UGcpY8w6E8c2uuKVh5bLBGZ8dRttvacRN UMP1cDdtt6tcHp6vn1RGAufaLwBtG0hdXyZ9NleWABOEK0G189f/xiBdCnbRpNHeyYn2rS6fOPemZ CHHEbUxefisOxl3IoTjgRyyWry78V7197fGflbojWiK+ZODtzoGgqt20FIV2WvttAg/kz+UlW4xvE PbbHeQAQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1ehuZL-00035S-FI; Sat, 03 Feb 2018 09:57:11 +0000 Received: from mail.free-electrons.com ([62.4.15.54]) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1ehuYv-0002cI-RK for linux-mtd@lists.infradead.org; Sat, 03 Feb 2018 09:56:49 +0000 Received: by mail.free-electrons.com (Postfix, from userid 110) id BF889219A2; Sat, 3 Feb 2018 10:56:38 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail.free-electrons.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT, URIBL_BLOCKED shortcircuit=ham autolearn=disabled version=3.4.0 Received: from localhost.localdomain (unknown [37.170.174.132]) by mail.free-electrons.com (Postfix) with ESMTPSA id C2435219A3; Sat, 3 Feb 2018 10:56:27 +0100 (CET) From: Miquel Raynal To: Boris Brezillon , Richard Weinberger , David Woodhouse , Brian Norris , Marek Vasut , Cyrille Pitchen Subject: [PATCH 5/6] mtd: nand: Allow vendors to declare (un)supported features Date: Sat, 3 Feb 2018 10:55:43 +0100 Message-Id: <20180203095544.9855-6-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180203095544.9855-1-miquel.raynal@bootlin.com> References: <20180203095544.9855-1-miquel.raynal@bootlin.com> X-Spam-Note: CRM114 invocation failed X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-1.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-mtd@lists.infradead.org, Miquel Raynal MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: Miquel Raynal If SET/GET_FEATURES is available (from the parameter page), use a bitmap to declare what feature is actually supported. Initialize the bitmap in the core to support timing changes (only feature used by the core), also add support for Micron specific features used in Micron initialization code (in the init routine). Signed-off-by: Miquel Raynal --- drivers/mtd/nand/nand_base.c | 11 ++++++++--- drivers/mtd/nand/nand_micron.c | 4 ++++ include/linux/mtd/rawnand.h | 5 ++++- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c index 4a879b1635b3..859d9ba2678f 100644 --- a/drivers/mtd/nand/nand_base.c +++ b/drivers/mtd/nand/nand_base.c @@ -1174,7 +1174,8 @@ int nand_get_features(struct nand_chip *chip, int addr, { struct mtd_info *mtd = nand_to_mtd(chip); - if (!chip->parameters.support_setting_features) + if (!chip->parameters.support_setting_features || + !test_bit(addr, chip->parameters.feature_list)) return -ENOTSUPP; return chip->onfi_get_features(mtd, chip, addr, subfeature_param); @@ -1195,7 +1196,8 @@ int nand_set_features(struct nand_chip *chip, int addr, { struct mtd_info *mtd = nand_to_mtd(chip); - if (!chip->parameters.support_setting_features) + if (!chip->parameters.support_setting_features || + !test_bit(addr, chip->parameters.feature_list)) return -ENOTSUPP; return chip->onfi_set_features(mtd, chip, addr, subfeature_param); @@ -5304,8 +5306,11 @@ static int nand_flash_detect_onfi(struct nand_chip *chip) } /* Save some parameters from the parameter page for future use */ - if (le16_to_cpu(p->opt_cmd) & ONFI_OPT_CMD_SET_GET_FEATURES) + if (le16_to_cpu(p->opt_cmd) & ONFI_OPT_CMD_SET_GET_FEATURES) { chip->parameters.support_setting_features = true; + bitmap_set(chip->parameters.feature_list, + ONFI_FEATURE_ADDR_TIMING_MODE, 1); + } chip->parameters.t_prog = le16_to_cpu(p->t_prog); chip->parameters.t_bers = le16_to_cpu(p->t_bers); chip->parameters.t_r = le16_to_cpu(p->t_r); diff --git a/drivers/mtd/nand/nand_micron.c b/drivers/mtd/nand/nand_micron.c index eaf14885e059..3c5b884e0eae 100644 --- a/drivers/mtd/nand/nand_micron.c +++ b/drivers/mtd/nand/nand_micron.c @@ -64,6 +64,10 @@ static int micron_nand_onfi_init(struct nand_chip *chip) chip->setup_read_retry = micron_nand_setup_read_retry; } + if (p->support_setting_features) { + set_bit(ONFI_FEATURE_ADDR_TIMING_MODE, p->feature_list); + set_bit(ONFI_FEATURE_ADDR_READ_RETRY, p->feature_list); + } return 0; } diff --git a/include/linux/mtd/rawnand.h b/include/linux/mtd/rawnand.h index 6d8667bb96f4..39a38196dbac 100644 --- a/include/linux/mtd/rawnand.h +++ b/include/linux/mtd/rawnand.h @@ -21,6 +21,7 @@ #include #include #include +#include struct mtd_info; struct nand_flash_dev; @@ -235,7 +236,8 @@ struct nand_chip; #define ONFI_TIMING_MODE_5 (1 << 5) #define ONFI_TIMING_MODE_UNKNOWN (1 << 6) -/* ONFI feature address */ +/* ONFI feature number/address */ +#define ONFI_FEATURE_NUMBER 256 #define ONFI_FEATURE_ADDR_TIMING_MODE 0x1 /* Vendor-specific feature address (Micron) */ @@ -434,6 +436,7 @@ struct nand_parameters { char model[20]; /* ONFI parameters */ bool support_setting_features; + DECLARE_BITMAP(feature_list, ONFI_FEATURE_NUMBER); u16 t_prog; u16 t_bers; u16 t_r;