From patchwork Wed Dec 11 05:45:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 181184 Delivered-To: patch@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp97429ile; Tue, 10 Dec 2019 21:46:27 -0800 (PST) X-Google-Smtp-Source: APXvYqxjk2L6zpWHIVFaahIMN5hk8FSz8UidKuopt3AhBH6Cn5UYy87kLM4QlAXxUfHzmPUKaHsI X-Received: by 2002:a17:902:6805:: with SMTP id h5mr1288866plk.275.1576043187215; Tue, 10 Dec 2019 21:46:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576043187; cv=none; d=google.com; s=arc-20160816; b=pP3O+4yHcCRKehJ2odlfc1DGVgECFfvT0sAXiTpKiIkfY4Bn294RQUMtlaDiXoAGX/ tF6HYnLpWfx6dTUBwObRLiPDVPEUrIxZrHZcKkW3GpusED9dZFWa7chCC7TzL5e+O28v eKxbzmLeb8vsyHW96kVI1ZQ+HqoQbjwOigxLh/SmJUC14RG/4HCpLfSDNzxsSp9Ogmtt x+jYrnqe4vgHQfXz+rB/oCHv5w/vyFfaAM8cDEfyqVhTk3LPxGbx6lQFvpV59J3LJ7mw K54QW7WQY/bHPcvLwe8cKVugeQNGUkrbcGmAdxp60HjSipvOQNa/j2do5Cz+svzYyHSA alEw== 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:message-id:date:subject:to:from:dkim-signature :dkim-filter:dkim-signature; bh=efNQ0+AABKPDqdD0J+X5iHyknE0jockSXB2rJ8IWAZU=; b=uz4oLbYoAZT4MA9sLP3Us/OXOybRYIfJ40Wv5V5cmJLcWQkCw/JfS+jXWEQXq9iu6V JgfeqQqbfCEnpDvpkyMLZjlRjdPclu/6vWPWeYTVeM0THYaHfu/2nxj3fX+5Xfj5H2Fp vmlDBNYJNA4T/15UOaw8tIBqESru+V5AwqG1zbebTaWU5Ar6HeNmX3Cu6H9tRJ2fqKAx b/WQlmxCdjrLUMUVgfEn/sGOI/jukmqIBPaEQHFTwlJIJnJiwrsk3twmU7bRO1tSxFSH L74rBBVV8WZ6AtsBQWDWXdJ0gQMgftpmX/wbURm81XaZzb88vQwPFpcAFVCjhrREM92d WxXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20170209 header.b=T9lQpAbF; dkim=neutral (body hash did not verify) header.i=@nifty.com header.s=dec2015msa header.b="abIzf/VH"; spf=pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 2607:7c80:54:e::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. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id 38si799902plf.329.2019.12.10.21.46.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Dec 2019 21:46:27 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20170209 header.b=T9lQpAbF; dkim=neutral (body hash did not verify) header.i=@nifty.com header.s=dec2015msa header.b="abIzf/VH"; spf=pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 2607:7c80:54:e::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: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:In-Reply-To: References:List-Owner; bh=efNQ0+AABKPDqdD0J+X5iHyknE0jockSXB2rJ8IWAZU=; b=T9l QpAbFat7PytxS9aOxJUVHuONHSeVX6zfYfcfTRQQBHv+UUh5RzryAeJqQ619o/tMw6vmXtViFMPtm zUMpw9BSNPX5gqgkNDSATqRn38iaUVJm/oMeQrwXPhHlIBVjvSJUurGfPLUSyerqio+U7Cy8W8dpT KQsEQZXXHZsF5C1WlAxhsyRKdMpk26xIYK/XY+nFGEs9bXdGHUoaA940bA4H4soGRFsCHzUL8fUSq QBzBYAUEYhiQ3aAg9mYd0zoKTAAHGx6poyvzc2O6AKZNgcl8x2Fw3OuoLwilriSSSvWUNjhKfc4GM /5UJxRK4G0y37OaQib2Ov17KkwuPGtw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ieupF-00053x-OB; Wed, 11 Dec 2019 05:46:17 +0000 Received: from conuserg-10.nifty.com ([210.131.2.77]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ieuoz-0004tS-Qb for linux-mtd@lists.infradead.org; Wed, 11 Dec 2019 05:46:03 +0000 Received: from localhost.localdomain (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-10.nifty.com with ESMTP id xBB5jdVa019523; Wed, 11 Dec 2019 14:45:40 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-10.nifty.com xBB5jdVa019523 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1576043141; bh=UxDx8RnuQhkTN8+zyVJvCjCQ3hY035WRmN5rhX+qiCg=; h=From:To:Cc:Subject:Date:From; b=abIzf/VHWf80xkCNM9Nq9l7bCTZhTmzvAGgpyGNxWkKxeNhSUY0HzAoJS1K5AHGZx qcghRfQPNCejAohtVrKvGe/1q2hkoB7P1vRWONc2sa3mkdinujSyiHWkpZaoDcHVT2 zLPKf8piCsaFj9Z/2bobrErHtgQrZf7eTZhphVaG76AjykCd1sXuqDV4q+Y4tejqhZ wZfufdLfCb6ZEkfRpHSeyvPdwg4bWncJdnoa0uyZE0hiubTf/osHL2jjna/WnDaNk1 nEwqKSCGynuEPXml7xxwpm/HF52oewbK7/qwron40H4rYnyHkUjYBlZuDcRXj5UonQ V6RaKNL1cLNvQ== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-mtd@lists.infradead.org Subject: [PATCH v2 1/2] dt-binding: mtd: denali_dt: document reset property Date: Wed, 11 Dec 2019 14:45:37 +0900 Message-Id: <20191211054538.8283-1-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.17.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191210_214602_090290_FA135870 X-CRM114-Status: UNSURE ( 9.08 ) X-CRM114-Notice: Please train this message. X-Spam-Score: 1.0 (+) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (1.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [210.131.2.77 listed in list.dnswl.org] 1.0 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Marek Vasut , devicetree@vger.kernel.org, Vignesh Raghavendra , Masahiro Yamada , Richard Weinberger , linux-kernel@vger.kernel.org, Ley Foon Tan , Dinh Nguyen , Rob Herring , Philipp Zabel , Miquel Raynal , Mark Rutland MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+patch=linaro.org@lists.infradead.org According to the Denali NAND Flash Memory Controller 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 sequencer This commit specifies those reset signals. It is possible to control them separately from the IP point of view although they might be often tied up together in actual SoC integration. At least for the upstream platforms, Altera/Intel SOCFPGA and Socionext UniPhier, the reset controller seems to provide only 1-bit control for the NAND controller. If it is the case, the resets property should reference to the same phandles for "nand" and "reg" resets, like this: resets = <&nand_rst>, <&nand_rst>; reset-names = "nand", "reg"; Signed-off-by: Masahiro Yamada --- Changes in v2: - Split into two patches Documentation/devicetree/bindings/mtd/denali-nand.txt | 7 +++++++ 1 file changed, 7 insertions(+) -- 2.17.1 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/ diff --git a/Documentation/devicetree/bindings/mtd/denali-nand.txt b/Documentation/devicetree/bindings/mtd/denali-nand.txt index b32aed1db46d..98916a84bbf6 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 { From patchwork Wed Dec 11 05:45:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 181183 Delivered-To: patch@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp97352ile; Tue, 10 Dec 2019 21:46:19 -0800 (PST) X-Google-Smtp-Source: APXvYqwngSfXBZfKdjqprm6txOBUdpXGSuMnmbGPdIeo9exixQoxKsShGxJLHwsWV8OqGbEeIcZt X-Received: by 2002:a17:90a:8a98:: with SMTP id x24mr1552584pjn.113.1576043179503; Tue, 10 Dec 2019 21:46:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576043179; cv=none; d=google.com; s=arc-20160816; b=hjntjpjXA31S2X3tiK8F9H+pQu/V1bRw733tyHqEHKg/1vfnNaHehwiZ4hJ9tDs6TL R0CokcU24ZtYikx4btoIQCKhWLLQfiWVz1wEO3HUXlkRszrCzA7FcQE3gai66zbWTJri WGBWJCptMlFLMhvLBwsysUVxUytUpWBB+b551AHLc85ICFf80rg7//ri7I2KZCe146lo amBKY87+qWzFNzzLh1MeY6vMQxdscyWo4PbAJQvkuDT84L5aWFxFuj+6JbmHkGyuPZCs 1gPZgAHnG/J0OrL8CoTohyv5eLHh91/b2PAfmvQTcA8GH1z8GLUKmjvSzU2v16EHwQj8 MefA== 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; bh=w06cEOzBtpS/V3a9HJ/ZKYAhdkwdVqizpjGwYDEwFT8=; b=EL8pA5Cq4ZDVFThKOTztbN5GEmeX/KQcUrionURFZbvy3cvmhbOWRvkazEjtKOle1v 1EdMW1BAKmlRatBOMDKh2nM33D/OB64R5rxQdTqTOpE6bksV37R5P3zqfhz40gCG0wG7 hG8Yb6zjo56xTs6WYsnavPyjvfoUVattmx/WQKkvuG+QTmPpv18khJ2S/vqnrPbL7Xkt Tx7MhpoCMHwvFDRTx02rzSFyrb5U4Cp7F2hhEeqLkpmz3MhPgNhTt5vrpZwWuo3vwnRN oGEKuCo2La5Voca2f3FWaw/ookde27hkehEbenVjUEAowenDFjMEzFwd1gRrbSj+fka0 +0uQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20170209 header.b=YtGmkg4e; dkim=neutral (body hash did not verify) header.i=@nifty.com header.s=dec2015msa header.b=20huwndA; spf=pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 2607:7c80:54:e::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. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id p18si762751plo.228.2019.12.10.21.46.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Dec 2019 21:46:19 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20170209 header.b=YtGmkg4e; dkim=neutral (body hash did not verify) header.i=@nifty.com header.s=dec2015msa header.b=20huwndA; spf=pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 2607:7c80:54:e::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=w06cEOzBtpS/V3a9HJ/ZKYAhdkwdVqizpjGwYDEwFT8=; b=YtGmkg4eAXvVhsW8YAJ9w1JGUv L4jNiiCfQUq9qsz4tqtUAwCVcdNuLbqEFvBrKp9Y6E4hgTrJx7gX5HbQO1iIabdgkbPp+5WG7HpCt 3+1CXhSAVjwt67uRn4TxHCmmv8gOUgXL3jyWN6NQLtjYBHMVfHfh/nekU9MkdE1tBrJ+JuHJG6BGp UR/lDl2QFAqpSjdu2WKxwUE/oHAk27rf9kQu8wOmuJkdz3GukmRdp4PiydacYDkdE72oPrP9jqeLb yZNKc3bsHYUevkgHLHoSnpkr511ShlsEcpGXJQnuur6HiSTpL8o5/FnzrtTd/d47ZafYhgGGypiiV goYTQ5jg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ieup2-0004tr-2N; Wed, 11 Dec 2019 05:46:04 +0000 Received: from conuserg-10.nifty.com ([210.131.2.77]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ieuoy-0004t9-C1 for linux-mtd@lists.infradead.org; Wed, 11 Dec 2019 05:46:02 +0000 Received: from localhost.localdomain (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-10.nifty.com with ESMTP id xBB5jdVb019523; Wed, 11 Dec 2019 14:45:41 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-10.nifty.com xBB5jdVb019523 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1576043142; bh=5tRNV+uzJuKYOSVUsYXTU2MrmaE0khMYlLEUoRe31qk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=20huwndAsZd8pNPrAO75GRTW41FmXK5L/af2R9egldxaSTeoLXA1cDLnahlzlucmS LpR62oEUtUEmPlwS7bLW6nCh6Kd5x+z5RZ3eJiLVWPoDH7vosMIqCa/dXw0GzCB0im mQLWnBL24Y54gTkjtbF0QPSDOaSsrO6ASRsTtr4/vvsHZh2DvJ20oadGNCQ81zSTeu 5B708QnHg7ODZJdZ8by93NHJWvlf8bSXljveTq9ucgmDzNR0Q9TJRbHMerX4+IS0tM Rfcgi0/5AcyeVtlmgI+0xZaJhlcg09+FM0rlrE5Xq5cb1Hyo3rsVUvM124cpKrlXJj 2Td98Q8XctjsA== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-mtd@lists.infradead.org Subject: [PATCH v2 2/2] mtd: rawnand: denali_dt: add reset controlling Date: Wed, 11 Dec 2019 14:45:38 +0900 Message-Id: <20191211054538.8283-2-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191211054538.8283-1-yamada.masahiro@socionext.com> References: <20191211054538.8283-1-yamada.masahiro@socionext.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191210_214600_642979_5F70DD43 X-CRM114-Status: GOOD ( 18.58 ) X-Spam-Score: 1.0 (+) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (1.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [210.131.2.77 listed in list.dnswl.org] 1.0 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Marek Vasut , devicetree@vger.kernel.org, Vignesh Raghavendra , Masahiro Yamada , Richard Weinberger , linux-kernel@vger.kernel.org, Ley Foon Tan , Dinh Nguyen , Rob Herring , Philipp Zabel , Miquel Raynal MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+patch=linaro.org@lists.infradead.org According to the Denali NAND Flash Memory Controller 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 sequencer This commit supports controlling those reset signals. It is possible to control them separately from the IP point of view although they might be often tied up together in actual SoC integration. The IP spec says, asserting only the reg_rst_n without asserting rst_n will cause unpredictable behavior in the controller. So, the driver deasserts ->rst_reg and ->rst in this order. Another 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 might be useful for tiny boot firmware, but is redundant for Linux Kernel 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 Reviewed-by: Philipp Zabel --- Changes in v2: - Split into two patches drivers/mtd/nand/raw/denali_dt.c | 40 +++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) -- 2.17.1 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/ diff --git a/drivers/mtd/nand/raw/denali_dt.c b/drivers/mtd/nand/raw/denali_dt.c index 8b779a899dcf..9a294c3f6ec8 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); + ret = clk_prepare_enable(dt->clk); if (ret) return ret; @@ -166,10 +178,30 @@ static int denali_dt_probe(struct platform_device *pdev) denali->clk_rate = clk_get_rate(dt->clk); denali->clk_x_rate = clk_get_rate(dt->clk_x); - ret = denali_init(denali); + /* + * Deassert the register reset, and the core reset in this order. + * Deasserting the core reset while the register reset is asserted + * will cause unpredictable behavior in the controller. + */ + ret = reset_control_deassert(dt->rst_reg); if (ret) goto out_disable_clk_ecc; + ret = reset_control_deassert(dt->rst); + if (ret) + goto out_assert_rst_reg; + + /* + * When the reset is deasserted, the initialization sequence is kicked + * (bootstrap process). The driver must wait until it finished. + * Otherwise, it will result in unpredictable behavior. + */ + usleep_range(200, 1000); + + ret = denali_init(denali); + if (ret) + goto out_assert_rst; + for_each_child_of_node(dev->of_node, np) { ret = denali_dt_chip_init(denali, np); if (ret) { @@ -184,6 +216,10 @@ static int denali_dt_probe(struct platform_device *pdev) out_remove_denali: denali_remove(denali); +out_assert_rst: + reset_control_assert(dt->rst); +out_assert_rst_reg: + reset_control_assert(dt->rst_reg); out_disable_clk_ecc: clk_disable_unprepare(dt->clk_ecc); out_disable_clk_x: @@ -199,6 +235,8 @@ static int denali_dt_remove(struct platform_device *pdev) struct denali_dt *dt = platform_get_drvdata(pdev); denali_remove(&dt->controller); + reset_control_assert(dt->rst); + reset_control_assert(dt->rst_reg); clk_disable_unprepare(dt->clk_ecc); clk_disable_unprepare(dt->clk_x); clk_disable_unprepare(dt->clk);