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: 819863 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="ksUcbjmh"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=nifty.com header.i=@nifty.com header.b="qpHjiCJF"; 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 3y3SlC45S2z9t32 for ; Fri, 29 Sep 2017 20:40:55 +1000 (AEST) 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-3y; 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+incoming=patchwork.ozlabs.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(-) 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 */