Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp5314935ybp; Tue, 8 Oct 2019 00:31:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqzVFUtoYuDF3mdxBdRFzgFYvV1ogaQCUCjzxeYkdyA8LwOwPtcroIkvTdCNmehkS3/jOKiI X-Received: by 2002:a50:979b:: with SMTP id e27mr31793657edb.173.1570519918390; Tue, 08 Oct 2019 00:31:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570519918; cv=none; d=google.com; s=arc-20160816; b=qmr3KwuuWY3zpwt4GJcIhfyOb9bzLu58gIv8cdczPQPOJ28J+7VfjbvtK/IVSYMnsB X13ANa1kahZidgCGjgQnTg21not82F5ZLD9BOGbg92Hbe/YdWSDOYkEv1kBWlRhozYUc SCUV3+RlMRfqLybMjJaGeWM1dPqA1vMnJSpORdeQijZA2tNhBTQhNr6mSNwV5dg3Tjrq 6C2FV9WLG9/hZnv1Nzqv+Xif+Uoj1UVuH82asjTg3oFpMqma7IWBEHoW1nLy9eGMeQ1k GziBN/3CYpN0+L067q9jieqG/ZnMPqroFiCowYAg+pZbLjrUC/XFVxLk+yk9mSbZNN16 ySRQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date; bh=0pBHsnFwdudfsgsR3mh1g0N6BXW+Th+p8bT8xT9ZOj4=; b=SgdcUI3xbwmRQ4AFn+h+OxwhQq+XYtUEj6noPGvrkXQmmadMCDpmhSG6vXTNM2i2i3 dkQh4vBfQjarE6xq3jQSIlM0Cvd3UpOH1pt43DRZK+sK6nPMzQ3iYwaSiFDh9VfrpcSt YXxB5WQYcXxXog++UlH7G0j+TxizZ/dFim80s7k6ZUEUZRA9rGEcR0S4wkWFiNIVYfoN J5QfrX2g1Bew35W+7zA4KEZ7twjli+qQBdi+XNNGNzzRAWeFPZ2Yd8oFY5q1fz0sfFO3 Q+YtNuUJpMXsdNK1sdyhXSP0M3BJYBS0LyA5XoXRusr6EUw4drh0EqPo+VmnuA2R6oJo 9iNg== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f33si9744925edb.281.2019.10.08.00.31.34; Tue, 08 Oct 2019 00:31:58 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730340AbfJHH2h (ORCPT + 99 others); Tue, 8 Oct 2019 03:28:37 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:41316 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730180AbfJHH2h (ORCPT ); Tue, 8 Oct 2019 03:28:37 -0400 Received: from dhcp-172-31-174-146.wireless.concordia.ca (unknown [IPv6:2a01:e0a:2c:6930:5cf4:84a1:2763:fe0d]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: bbrezillon) by bhuna.collabora.co.uk (Postfix) with ESMTPSA id 2A6D028F59E; Tue, 8 Oct 2019 08:28:35 +0100 (BST) Date: Tue, 8 Oct 2019 09:28:32 +0200 From: Boris Brezillon To: masonccyang@mxic.com.tw Cc: "Miquel Raynal" , bbrezillon@kernel.org, computersforpeace@gmail.com, dwmw2@infradead.org, frieder.schrempf@kontron.de, gregkh@linuxfoundation.org, juliensu@mxic.com.tw, linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org, marcel.ziswiler@toradex.com, marek.vasut@gmail.com, richard@nod.at, tglx@linutronix.de, vigneshr@ti.com Subject: Re: [PATCH RFC 3/3] mtd: rawnand: Add support Macronix power down mode Message-ID: <20191008092832.54492696@dhcp-172-31-174-146.wireless.concordia.ca> In-Reply-To: References: <1568793387-25199-1-git-send-email-masonccyang@mxic.com.tw> <1568793387-25199-3-git-send-email-masonccyang@mxic.com.tw> <20191007104501.1b4ed8ed@xps13> Organization: Collabora X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 8 Oct 2019 10:06:50 +0800 masonccyang@mxic.com.tw wrote: > > > + nand_select_target(chip, 0); > > > > On several NAND controllers there is no way to act on the CS line > > without actually writing bytes to the NAND chip. So basically this > > is very likely to not work. > > any other way to make it work ? GPIO ? > or just have some comments description here. > i.e,. > > /* The NAND chip will exit the deep power down mode with #CS toggling, > * please refer to datasheet for the timing requirement of tCRDP and tRDP. > */ > Good luck with that. As Miquel said, on most NAND controllers select_target() is a dummy operation that just assigns nand_chip->target to the specified value but doesn't assert the CS line. You could send a dummy command here, like a READ_ID, but I guess you need CS to be asserted for at least 20ns before asserting any other signals (CLE/ALE) which might be an issue. > > > > > + ndelay(20); > > > > Is this delay known somewhere? Is this purely experimental? > > it's timing requirement tCRDP 20 ns(min) to release device > from deep power-down mode. > You may download datasheet at > https://www.macronix.com/zh-tw/products/NAND-Flash/SLC-NAND-Flash/Pages/spec.aspx?p=MX30LF4G28AD&m=SLC%20NAND&n=PM2579 Just looked at the datasheet, and there's actually more than tCRDP: - you have to make sure you entered power-down state for at least tDPDD before you try to wake up the device - the device goes back to stand-by state tRDP after the CS pin has been deasserted. I guess we can use ndelay() for those, since they happen before/after the CS pin is asserted/de-asserted. Be careful with ndelay() though, it's not guaranteed to wait the the time you pass, it can return before (maybe we should add a helper to deal with that). Another solution would be to describe CS assertion/de-assertion in the instruction flow, but that requires patching all exec_op() drivers. For the tCRDP timing, I think we should use a nand_operation, this way we can check if the controller is able to deal with dummy CS-assertion before entering deep-power mode. In order to do that you'll have to add a NAND_OP_DUMMY_INSTR (or NAND_OP_DELAY_INSTR), and then have something like: struct nand_op_instr instrs[] = { NAND_OP_DUMMY(tCRDP), };