Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp223246ybl; Tue, 10 Dec 2019 21:34:59 -0800 (PST) X-Google-Smtp-Source: APXvYqwBnECLzASx+EVnC61/IsMHIqUZ5hsgOyvIZ5Lrhz0SsLzQWlHhM9uIyLqSbzadab/TWI4s X-Received: by 2002:a05:6830:2087:: with SMTP id y7mr1009837otq.96.1576042499248; Tue, 10 Dec 2019 21:34:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576042499; cv=none; d=google.com; s=arc-20160816; b=Do/fYJgqz2H8rQPs/cF5772+p72kxYGHBhw0zW94t7uMLFhZKqQ/Sqx+YrhSPd6yfD 1Q0Ob70idGZQyL8O3fA+HP53dAhyuHTM0BJoTLThh7pWOlGUAE3WWjPH9S53G5CgnZq/ bZZHujorelhnUUNe2N9ofPEu5t1hx95AB7R9IMn92lmpaaUUG2EvUiuse9QZL6ix1cH0 rfvDcfhXr1MyS0IXgpqKmO4o2u85Pya0pd0j2fILdkhjlkQFvb1hgj8QQeZfBLoO13wz I/MLtiL1XMolyePswIppoSiHWO4tU4azKHvpEBen3sWvwNC31wyo101cxTbcu420tI/b rsrg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature:dkim-filter; bh=69MyOS9aB1VcMJQYBz4dgojoS/Cbyu8xTjZZlTo6P5s=; b=ZlDSnGcyuOQcwJ2LxnIelXqEyXCADtzLlhGKvfSsE3+VZ7g/qpemQ5MlAjpnqi2bSh qnrggFBGM5RL014+DfuOZBws6vySBQ3gZUEBQnUMsURLPWQcEMeQWyMn50kLQItkaQso uZTvwFRvM7OrSGwqOsod3Ntkh1hjO51ugw+c7m+YUACapLMATxS6mvg6BlFfGdSrjw+R xO/7Ib6wDKsHy3W4tDno7Fn/tcyhKs4DJMU1Upoo9YG5fw+e3hVHqdgkgHw2sM3+/Hff qq6prYMdSzzCNHpSA1/kDrOjfL/bIESzwLllJ7brx5zmDR7QdJ+xeIAYbDVcezxafvJ9 k8Aw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=mgu6WfR0; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l131si525384oig.120.2019.12.10.21.34.43; Tue, 10 Dec 2019 21:34:59 -0800 (PST) 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; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=mgu6WfR0; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726463AbfLKFds (ORCPT + 99 others); Wed, 11 Dec 2019 00:33:48 -0500 Received: from conssluserg-01.nifty.com ([210.131.2.80]:54020 "EHLO conssluserg-01.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725768AbfLKFds (ORCPT ); Wed, 11 Dec 2019 00:33:48 -0500 Received: from mail-vs1-f46.google.com (mail-vs1-f46.google.com [209.85.217.46]) (authenticated) by conssluserg-01.nifty.com with ESMTP id xBB5XhoM016835; Wed, 11 Dec 2019 14:33:44 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conssluserg-01.nifty.com xBB5XhoM016835 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1576042424; bh=69MyOS9aB1VcMJQYBz4dgojoS/Cbyu8xTjZZlTo6P5s=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=mgu6WfR0mgo5KyWtmdw5tLsuYQv4aDvzYvAYL/FF6aKwitb+xpd2Iccpnpy4qfOx2 G3ymr5lmhl9TigDpw+HUoZfEKUmfsCNXZ5I/lSK8vkg5n73qmKmAmhRLzxpsSx75U2 3S4+0labv7jYO48OzAhz7YZf5pxn+yoYKWXkvsSN0w4+7lobN2fMk610fFy8j/1tok N5DUIBLWFyapuODtcjscxnidwWWJ3C0ZjfgDcIl9meS4hyLUvxZ9Y6FOZfUJBLA0dX M1Pv3ZHLpe2GaCZ/LvC9+ZAaQc5mVbPsaEmrfDgwIg+hG/niR5emvFKJc4YggsN7gl 35epSYACyPcgw== X-Nifty-SrcIP: [209.85.217.46] Received: by mail-vs1-f46.google.com with SMTP id x4so14901102vsx.10; Tue, 10 Dec 2019 21:33:44 -0800 (PST) X-Gm-Message-State: APjAAAUFelvNG32QuDLInDnU+NhbSZ0r5dLaVRcAbiakao5FZ4ZR/Sgk cX+UNp1+pA0rBdiqbXk9dSkV+Ig4BVqNYRIfsEE= X-Received: by 2002:a67:7ac4:: with SMTP id v187mr1028357vsc.181.1576042422892; Tue, 10 Dec 2019 21:33:42 -0800 (PST) MIME-Version: 1.0 References: <20191210091453.26346-1-yamada.masahiro@socionext.com> In-Reply-To: From: Masahiro Yamada Date: Wed, 11 Dec 2019 14:33:07 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] mtd: rawnand: denali: add reset controlling To: "Tan, Ley Foon" Cc: "linux-mtd@lists.infradead.org" , Dinh Nguyen , Marek Vasut , Mark Rutland , Miquel Raynal , Philipp Zabel , Richard Weinberger , Rob Herring , Vignesh Raghavendra , "devicetree@vger.kernel.org" , "linux-kernel@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Dec 11, 2019 at 2:23 PM Tan, Ley Foon wrote: > > > > > -----Original Message----- > > From: Masahiro Yamada > > Sent: Tuesday, December 10, 2019 5:15 PM > > To: linux-mtd@lists.infradead.org > > Cc: Dinh Nguyen ; Marek Vasut ; > > Tan, Ley Foon ; Masahiro Yamada > > ; Mark Rutland > > ; Miquel Raynal ; > > Philipp Zabel ; Richard Weinberger > > ; Rob Herring ; Vignesh > > Raghavendra ; devicetree@vger.kernel.org; linux- > > kernel@vger.kernel.org > > Subject: [PATCH] mtd: rawnand: denali: add reset controlling > > > > According to the Denali User's Guide, this IP has two reset signals. > > > > rst_n: reset most of FFs in the controller core > > reg_rst_n: reset all FFs in the register interface, and in the > > initialization sequence > > > > This commit supports controlling those reset signals, although they might be > > often tied up together in actual SoC integration. > > > > One thing that should be kept in mind is the automated initialization > > sequence (a.k.a. 'bootstrap' process) is kicked off when reg_rst_n is > > deasserted. > > > > When the reset is deasserted, the controller issues a RESET command to the > > chip select 0, and attempts to read out the chip ID, and further more, ONFI > > parameters if it is an ONFI-compliant device. Then, the controller sets up the > > relevant registers based on the detected device parameters. > > > > This process is just redundant for Linux because nand_scan_ident() probes > > devices and sets up parameters accordingly. Rather, this hardware feature is > > annoying because it ends up with misdetection due to bugs. > > > > So, commit 0615e7ad5d52 ("mtd: nand: denali: remove Toshiba and Hynix > > specific fixup code") changed the driver to not rely on it. > > > > However, there is no way to prevent it from running. The IP provides the > > 'bootstrap_inhibit_init' port to suppress this sequence, but it is usually out of > > software control, and dependent on SoC implementation. > > As for the Socionext UniPhier platform, LD4 always enables it. For the later > > SoCs, the bootstrap sequence runs depending on the boot mode. > > > > I added usleep_range() to make the driver wait until the sequence finishes. > > Otherwise, the driver would fail to detect the chip due to the race between > > the driver and hardware-controlled sequence. > > > > Signed-off-by: Masahiro Yamada > > --- > > > > .../devicetree/bindings/mtd/denali-nand.txt | 7 ++++ > > drivers/mtd/nand/raw/denali_dt.c | 40 ++++++++++++++++++- > > 2 files changed, 46 insertions(+), 1 deletion(-) > > > > diff --git a/Documentation/devicetree/bindings/mtd/denali-nand.txt > > b/Documentation/devicetree/bindings/mtd/denali-nand.txt > > index b32aed1db46d..a48b17fb969a 100644 > > --- a/Documentation/devicetree/bindings/mtd/denali-nand.txt > > +++ b/Documentation/devicetree/bindings/mtd/denali-nand.txt > > @@ -14,6 +14,11 @@ Required properties: > > interface clock, and the ECC circuit clock. > > - clock-names: should contain "nand", "nand_x", "ecc" > > > > +Optional properties: > > + - resets: may contain phandles to the controller core reset, the > > +register reset > > + - reset-names: may contain "nand", "reg" > > + > > Sub-nodes: > > Sub-nodes represent available NAND chips. > > > > @@ -46,6 +51,8 @@ nand: nand@ff900000 { > > reg-names = "nand_data", "denali_reg"; > > clocks = <&nand_clk>, <&nand_x_clk>, <&nand_ecc_clk>; > > clock-names = "nand", "nand_x", "ecc"; > > + resets = <&nand_rst>, <&nand_reg_rst>; > > + reset-names = "nand", "reg"; > > interrupts = <0 144 4>; > > > > nand@0 { > > diff --git a/drivers/mtd/nand/raw/denali_dt.c > > b/drivers/mtd/nand/raw/denali_dt.c > > index 8b779a899dcf..132bc6cc066c 100644 > > --- a/drivers/mtd/nand/raw/denali_dt.c > > +++ b/drivers/mtd/nand/raw/denali_dt.c > > @@ -6,6 +6,7 @@ > > */ > > > > #include > > +#include > > #include > > #include > > #include > > @@ -14,6 +15,7 @@ > > #include > > #include > > #include > > +#include > > > > #include "denali.h" > > > > @@ -22,6 +24,8 @@ struct denali_dt { > > struct clk *clk; /* core clock */ > > struct clk *clk_x; /* bus interface clock */ > > struct clk *clk_ecc; /* ECC circuit clock */ > > + struct reset_control *rst; /* core reset */ > > + struct reset_control *rst_reg; /* register reset */ > > }; > > > > struct denali_dt_data { > > @@ -151,6 +155,14 @@ static int denali_dt_probe(struct platform_device > > *pdev) > > if (IS_ERR(dt->clk_ecc)) > > return PTR_ERR(dt->clk_ecc); > > > > + dt->rst = devm_reset_control_get_optional_shared(dev, "nand"); > > + if (IS_ERR(dt->rst)) > > + return PTR_ERR(dt->rst); > > + > > + dt->rst_reg = devm_reset_control_get_optional_shared(dev, "reg"); > > + if (IS_ERR(dt->rst_reg)) > > + return PTR_ERR(dt->rst_reg); > Will it trigger error if dts doesn't have "nand" or "reg" for reset-name? > SOCFPGA dts doesn't have this. No. These are optional resets. If they are not found in DT, the driver will skip the reset controlling. Of course, you can add them to your DT later if you want the driver to take care of the resets. Best Regards Masahiro Yamada