From patchwork Wed Mar 22 14:07:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 95767 Delivered-To: patch@linaro.org Received: by 10.182.3.34 with SMTP id 2csp233766obz; Wed, 22 Mar 2017 07:11:56 -0700 (PDT) X-Received: by 10.84.238.9 with SMTP id u9mr56629028plk.174.1490191916320; Wed, 22 Mar 2017 07:11:56 -0700 (PDT) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [65.50.211.133]) by mx.google.com with ESMTPS id r17si1979508pgi.61.2017.03.22.07.11.56 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 Mar 2017 07:11:56 -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; dkim=neutral (body hash did not verify) header.i=@nifty.com; 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=6FXARLLYWdmDWO34afhgDouskOD1mJmKtNAo9zpPkAY=; b=VH88eMssjVWo3K8WhG0pIGgESM 0viUWw07wZTts80cfPTHmybyHsy7ZjGxMGQ7j7b4TVg9qbMzCvTGq3bEWNLMCtOdNA/p1bEXRhXyY v7epLb90tqpxofsnUO77FD+b6UsZv6un8q3HeEirzZ74q49upZuoxpfJv1id/yG5IGqbkiLnH5Vxd TBLS70JymzQcHNgc/gd45aHOq0JofpQl/n+X6dtyAqL0gG7fHklT1G8KzvG2UonRiNiOA1M8jI1rm C6u6uTwBYnH7BfGjLiKArKBYY38cG8ODTwvWt3Kt0jhD4n85mDzwYHLZCQFE0dJpt3l2rOTpRNFZR wWeERHqw==; 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 1cqgzO-0001hI-5q; Wed, 22 Mar 2017 14:11:50 +0000 Received: from conuserg-07.nifty.com ([210.131.2.74]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cqgxI-000637-Mo for linux-mtd@lists.infradead.org; Wed, 22 Mar 2017 14:09:52 +0000 Received: from pug.jp.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-07.nifty.com with ESMTP id v2ME8LDa010154; Wed, 22 Mar 2017 23:08:48 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com v2ME8LDa010154 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1490191729; bh=uTxP8uSgKDdcyWTVMZxtm2JF7W6b7or+g/XUZVmI6+g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dIQoXSlxtqLHtUrNlAP/iNjHPS+9BpanoqyMp7PXtfJm3yV3OLAEFT+8KRftlXyF3 9RyN6FSEk/Y4CTaWH9kGshutogmxT3jY3fYgT9k8QgmfbBzNfGRXU9nZ2xsxANUFpL hFMDLZcdndGaW+e4O/rSUB+9e76FvjWrPo2bC73OxQECi8l3C6+S/ORvODacQWVMzG nYfhAsNqC4Nvw5K4B1eavNyqa2gdywjZE8HLf0XBBfyGXnVuSuB5JSFAVlHdvG8sCU 3F3emm16JPInKOTVCRlCbno/HqMxN2NVFuvLBozEH2UR0vGT6teOhtGCt98m8IdHLE eYYV1KSvE8fYw== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-mtd@lists.infradead.org Subject: [PATCH v2 17/53] mtd: nand: denali: allow to override revision number Date: Wed, 22 Mar 2017 23:07:24 +0900 Message-Id: <1490191680-14481-18-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1490191680-14481-1-git-send-email-yamada.masahiro@socionext.com> References: <1490191680-14481-1-git-send-email-yamada.masahiro@socionext.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170322_070941_296238_43D48B1C X-CRM114-Status: GOOD ( 18.24 ) 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_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.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent.monat@idquantique.com, Boris Brezillon , thorsten.christiansson@idquantique.com, Richard Weinberger , Marek Vasut , Masahiro Yamada , Artem Bityutskiy , Cyrille Pitchen , Jason Roberts , linux-kernel@vger.kernel.org, Dinh Nguyen , Masami Hiramatsu , Chuanxiao Dong , Jassi Brar , Brian Norris , Enrico Jorns , David Woodhouse , Graham Moore MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+patch=linaro.org@lists.infradead.org Commit 271707b1d817 ("mtd: nand: denali: max_banks calculation changed in revision 5.1") added a revision check to support the new max_banks encoding. Its git-log states "The encoding of max_banks changed in Denali revision 5.1". There are exceptional cases, for example, the revision register on some UniPhier SoCs says the IP is 5.0 but the max_banks is encoded in the new format. This IP updates the resister specification from time to time (often breaking the backward compatibility), but the revision number is not incremented correctly. The max_banks is not only the case that needs revision checking. Let's allow to override an incorrect revision number. Signed-off-by: Masahiro Yamada --- Changes in v2: - Replace the NEW_N_BANKS_FORMAT approach drivers/mtd/nand/denali.c | 19 +++++++++---------- drivers/mtd/nand/denali.h | 3 +-- drivers/mtd/nand/denali_dt.c | 5 ++++- 3 files changed, 14 insertions(+), 13 deletions(-) -- 2.7.4 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/ diff --git a/drivers/mtd/nand/denali.c b/drivers/mtd/nand/denali.c index 513292f..ff6af1d 100644 --- a/drivers/mtd/nand/denali.c +++ b/drivers/mtd/nand/denali.c @@ -449,17 +449,12 @@ static void find_valid_banks(struct denali_nand_info *denali) static void detect_max_banks(struct denali_nand_info *denali) { uint32_t features = ioread32(denali->flash_reg + FEATURES); - /* - * Read the revision register, so we can calculate the max_banks - * properly: the encoding changed from rev 5.0 to 5.1 - */ - u32 revision = MAKE_COMPARABLE_REVISION( - ioread32(denali->flash_reg + REVISION)); - if (revision < REVISION_5_1) - denali->max_banks = 2 << (features & FEATURES__N_BANKS); - else - denali->max_banks = 1 << (features & FEATURES__N_BANKS); + denali->max_banks = 1 << (features & FEATURES__N_BANKS); + + /* the encoding changed from rev 5.0 to 5.1 */ + if (denali->revision < 0x0501) + denali->max_banks <<= 1; } static uint16_t denali_nand_timing_set(struct denali_nand_info *denali) @@ -1348,6 +1343,10 @@ static void denali_cmdfunc(struct mtd_info *mtd, unsigned int cmd, int col, /* Initialization code to bring the device up to a known good state */ static void denali_hw_init(struct denali_nand_info *denali) { + if (!denali->revision) + denali->revision = + swab16(ioread32(denali->flash_reg + REVISION)); + /* * tell driver how many bit controller will skip before * writing ECC code in OOB, this register may be already diff --git a/drivers/mtd/nand/denali.h b/drivers/mtd/nand/denali.h index a8e8d68..58a8042 100644 --- a/drivers/mtd/nand/denali.h +++ b/drivers/mtd/nand/denali.h @@ -179,8 +179,6 @@ #define REVISION 0x370 #define REVISION__VALUE 0xffff -#define MAKE_COMPARABLE_REVISION(x) swab16((x) & REVISION__VALUE) -#define REVISION_5_1 0x00000501 #define ONFI_DEVICE_FEATURES 0x380 #define ONFI_DEVICE_FEATURES__VALUE 0x003f @@ -351,6 +349,7 @@ struct denali_nand_info { int devnum; /* represent how many nands connected */ int bbtskipbytes; int max_banks; + unsigned int revision; unsigned int caps; #define DENALI_CAP_HW_ECC_FIXUP BIT(0) #define DENALI_CAP_DMA_64BIT BIT(1) diff --git a/drivers/mtd/nand/denali_dt.c b/drivers/mtd/nand/denali_dt.c index ada3863..df9ef36 100644 --- a/drivers/mtd/nand/denali_dt.c +++ b/drivers/mtd/nand/denali_dt.c @@ -30,6 +30,7 @@ struct denali_dt { }; struct denali_dt_data { + unsigned int revision; unsigned int caps; }; @@ -60,8 +61,10 @@ static int denali_dt_probe(struct platform_device *pdev) denali = &dt->denali; data = of_device_get_match_data(&pdev->dev); - if (data) + if (data) { + denali->revision = data->revision; denali->caps = data->caps; + } denali->platform = DT; denali->dev = &pdev->dev;