From patchwork Fri Sep 29 10:38:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 114508 Delivered-To: patch@linaro.org Received: by 10.140.104.133 with SMTP id a5csp636540qgf; Fri, 29 Sep 2017 03:40:58 -0700 (PDT) X-Google-Smtp-Source: AOwi7QDANBldzyIG0OZIsbecRfwjYdCobev50RIh0nu5eGUz3g6K8fcd80/p91Qoqjhrjp857sN1 X-Received: by 10.99.99.197 with SMTP id x188mr6881165pgb.38.1506681658916; Fri, 29 Sep 2017 03:40:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506681658; cv=none; d=google.com; s=arc-20160816; b=dglrbC4Mpt3f2MCS9tn6WSED+H1LX5ffvCiZ7qo1Dcdh6+kqDDZhAfGiL1mWCq3hEg NUks9HdArkSUccSt0VCmjNchemkS26htRKomjd2WGyEua5IkoX4u51h7UGTTbeC9P/n4 7BKo8YP0qJupUmyJnidFiigvp5ZVl9NXgpLcRTIlXzUryylzvK+7KL5zT3zZSC4pFKGA oWLkRiIDsUb5Hk4/x/q9qm7cx9lbTqaXJRwkP8cZ0LPySDz9A1+TCJh07qMCHt/spQf9 mR7m5hSj9yhhatUEB2pt/e29E3MqWbVWiDKviZgnHbH0QYck9mrCK/pmVPEKRd40I/as OxqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:references:in-reply-to:message-id:date:subject :to:from:dkim-signature:dkim-filter:dkim-signature :arc-authentication-results; bh=vjybKI5BOE4AvHWmBQsJhh6CEcxJDVW25Ft/g3KO7Ik=; b=NKTu8NgcT1B5uN8sdL1cWpHUqwKrsqXGmRFJDgLNfA+i3g/hUK2/G6qbvDnrOw6cer EBs6BH1GtlaUmFG+Z05URVdQJ/tDtvjCyessmcJnlava5u9Tm6LnYd5CzjYxN+QofwnY YMDHIMKlGpjTbLR7GaB2oG1NX8Iz/aWPGVqjGQKCrlPpmlbdzpSfPTqK+PwdgF4NxGzv oGxBvsyWNYuZdMQbUUgDwEBwlvlwl0OYfhjW8I7mWs/UHA3b71OXpefklxRtDQdyv4uT 6/1PXn8jGfEhJS8iL15AKxNNP5iFk4rsAfj/A9C1MFOlrj6WVpZUvQzsKMJsWSa4HGeC 2djg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20170209 header.b=ksUcbjmh; dkim=neutral (body hash did not verify) header.i=@nifty.com header.s=dec2015msa header.b=qpHjiCJF; spf=pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 65.50.211.133 as permitted sender) smtp.mailfrom=linux-mtd-bounces+patch=linaro.org@lists.infradead.org Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [65.50.211.133]) by mx.google.com with ESMTPS id f185si3208676pfa.471.2017.09.29.03.40.58 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 29 Sep 2017 03:40:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 65.50.211.133 as permitted sender) client-ip=65.50.211.133; Authentication-Results: mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20170209 header.b=ksUcbjmh; dkim=neutral (body hash did not verify) header.i=@nifty.com header.s=dec2015msa header.b=qpHjiCJF; spf=pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 65.50.211.133 as permitted sender) smtp.mailfrom=linux-mtd-bounces+patch=linaro.org@lists.infradead.org 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=vjybKI5BOE4AvHWmBQsJhh6CEcxJDVW25Ft/g3KO7Ik=; b=ksUcbjmhdXDbyLouwh5EfDapj6 6dbTAY7yVCLZmJBnOeSpxt4ApVlR7SoqTmnsDSTO+E/sMNzF6a1o32CdVw3HmPgyOkepMMbmBt8dR cWQ81cVjq19G5D45JxnIWwsY8VmB0EKA4wUAn66sT0hE37Qb1hawwr2vydnhDT+baU1b2rfJH9Mx5 Q3SyT26Oa1GL5fvwQe6n6sfX3Ra463KFh8/FJNkHAgZ9epX/gHFrKeo4JQAonCNudyl8sDS+G2ln6 gqZPcozpcGSukOlKKY/6B/db1TRy3QKwGlAicpxP5Pw5JgwKPHr04qfsDOvlv24F2ht+I83cru2sg Ztj6Obvg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dxsiu-0000eJ-MA; Fri, 29 Sep 2017 10:40:48 +0000 Received: from conuserg-12.nifty.com ([210.131.2.79]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dxshj-00074M-As for linux-mtd@lists.infradead.org; Fri, 29 Sep 2017 10:39:39 +0000 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-12.nifty.com with ESMTP id v8TAcmAD012917; Fri, 29 Sep 2017 19:38:50 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-12.nifty.com v8TAcmAD012917 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1506681531; bh=tL4/ntMt/VMAHS0F4rQBe8JE+TBR4whS8LbNnR/jxuA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qpHjiCJFxUYsRHGsayDoiyltuc1W0Q4ocNf153wTkcuQUxH7rJ+hE7gu8niBLcMhs tz6KXGMsmbuFEMIZ9wVciPmqcj73/hWi/DYec68rNEk5rafm7HHR2yiW3h0uyC6fEh d7RuIcA0MTexx5KDXEiTZSXk4Nchm+DzMNi54Iipfh+CALvgclqqFfFt9RtCa8ioo4 9EazMAlyEVnvHzHlrOUKMmWHU1OxgxBxt0zB02RlkYJL2ZXQzqu8xN0K4LiT5hDxmv pz5daOWP/O2BgIMS5JvGamMcls1pJHcLuPk7lDkDwO8i8f4FdHGPL7+oTZPN1mUtKK Jk8KVYqOqyauw== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-mtd@lists.infradead.org Subject: [PATCH v2 1/2] mtd: nand: wait for tWHR after NAND_CMD_STATUS / NAND_CMD_READID Date: Fri, 29 Sep 2017 19:38:39 +0900 Message-Id: <1506681520-13897-2-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1506681520-13897-1-git-send-email-yamada.masahiro@socionext.com> References: <1506681520-13897-1-git-send-email-yamada.masahiro@socionext.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170929_033935_763196_7E6EA0E7 X-CRM114-Status: GOOD ( 13.30 ) X-Spam-Score: -1.2 (-) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-1.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.7 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid 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: Boris Brezillon , Marek Vasut , Richard Weinberger , linux-kernel@vger.kernel.org, Masahiro Yamada , Cyrille Pitchen , Brian Norris , David Woodhouse MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+patch=linaro.org@lists.infradead.org For commands such as Read Status, Read ID, etc. the controller needs to wait for tWHR before it reads out the first data. If the controller does not take care of it, the driver has to wait explicitly to make sure to meet the spec. Introduce NAND_WAIT_TWHR, which works like NAND_WAIT_TCCS. The driver can set this flag to let the core to handle the tWHR delay. Signed-off-by: Masahiro Yamada --- Changes in v2: - Add nand_whr_delay() helper Wait for tWHR only for drivers that explicitly set NAND_WAIT_TWHR flag drivers/mtd/nand/nand_base.c | 21 +++++++++++++++++++-- include/linux/mtd/rawnand.h | 13 ++++++++----- 2 files changed, 27 insertions(+), 7 deletions(-) -- 2.7.4 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/ diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c index b1cf32c..455085d 100644 --- a/drivers/mtd/nand/nand_base.c +++ b/drivers/mtd/nand/nand_base.c @@ -676,6 +676,17 @@ static void nand_wait_status_ready(struct mtd_info *mtd, unsigned long timeo) } while (time_before(jiffies, timeo)); }; +static void nand_whr_delay(struct nand_chip *chip) +{ + if (!(chip->options & NAND_WAIT_TWHR)) + return; + + if (chip->data_interface && chip->data_interface->timings.sdr.tWHR_min) + ndelay(chip->data_interface->timings.sdr.tWHR_min / 1000); + else + ndelay(200); +} + /** * nand_command - [DEFAULT] Send command to NAND device * @mtd: MTD device structure @@ -742,9 +753,12 @@ static void nand_command(struct mtd_info *mtd, unsigned int command, case NAND_CMD_ERASE1: case NAND_CMD_ERASE2: case NAND_CMD_SEQIN: + case NAND_CMD_SET_FEATURES: + return; + case NAND_CMD_STATUS: case NAND_CMD_READID: - case NAND_CMD_SET_FEATURES: + nand_whr_delay(chip); return; case NAND_CMD_RESET: @@ -871,9 +885,12 @@ static void nand_command_lp(struct mtd_info *mtd, unsigned int command, case NAND_CMD_ERASE1: case NAND_CMD_ERASE2: case NAND_CMD_SEQIN: + case NAND_CMD_SET_FEATURES: + return; + case NAND_CMD_STATUS: case NAND_CMD_READID: - case NAND_CMD_SET_FEATURES: + nand_whr_delay(chip); return; case NAND_CMD_RNDIN: diff --git a/include/linux/mtd/rawnand.h b/include/linux/mtd/rawnand.h index 749bb08..bb0165b 100644 --- a/include/linux/mtd/rawnand.h +++ b/include/linux/mtd/rawnand.h @@ -213,13 +213,16 @@ enum nand_ecc_algo { /* * In case your controller is implementing ->cmd_ctrl() and is relying on the - * default ->cmdfunc() implementation, you may want to let the core handle the - * tCCS delay which is required when a column change (RNDIN or RNDOUT) is - * requested. - * If your controller already takes care of this delay, you don't need to set - * this flag. + * default ->cmdfunc() implementation, you may want to let the core handle + * some delays to meet the timing specification. + * If your controller already takes care of these delays, you don't need to set + * the following flags. */ + +/* tCCS for a column change (RNDIN or RNDOUT) */ #define NAND_WAIT_TCCS 0x00200000 +/* tWHR for STATUS, READID, etc. */ +#define NAND_WAIT_TWHR 0x00400000 /* Options set by nand scan */ /* Nand scan has allocated controller struct */