From patchwork Sat Nov 26 18:06:10 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 84310 Delivered-To: patch@linaro.org Received: by 10.182.1.168 with SMTP id 8csp788638obn; Sat, 26 Nov 2016 10:15:50 -0800 (PST) X-Received: by 10.99.67.7 with SMTP id q7mr25041009pga.45.1480184150529; Sat, 26 Nov 2016 10:15:50 -0800 (PST) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id a28si49424966pfl.157.2016.11.26.10.15.50 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 26 Nov 2016 10:15:50 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) client-ip=2001:1868:205::9; Authentication-Results: mx.google.com; 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 2001:1868:205::9 as permitted sender) smtp.mailfrom=linux-mtd-bounces+patch=linaro.org@lists.infradead.org Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1cAhUf-0002ef-T8; Sat, 26 Nov 2016 18:14:33 +0000 Received: from conuserg-11.nifty.com ([210.131.2.78]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1cAhNu-00055P-QQ for linux-mtd@lists.infradead.org; Sat, 26 Nov 2016 18:07:37 +0000 Received: from grover.sesame (FL1-111-169-71-157.osk.mesh.ad.jp [111.169.71.157]) (authenticated) by conuserg-11.nifty.com with ESMTP id uAQI6Ueu018512; Sun, 27 Nov 2016 03:06:52 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-11.nifty.com uAQI6Ueu018512 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1480183613; bh=n95Z07Je0ENWAhWmzGqyj77YSkiu+YfOiJr4r70KQ1Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HrvWYSbQfVu+ic/BX1auoo78GwOZQA7q9IfRzc/MvshzSL8wh/PGto5NrbXTik9k3 ZkW9rP0VspuxXD+Q4VcOhavtYvuG0u1uBCEBxGUBccadjcgJr7HGtLkZFrCZ8eEarj xR1Ahyi8usYNnA5xijO0W8VKQ4YjwDH0ch+fk1lNC3LJif+OeRWQOaDvglT9Ls5dx1 gTDfsKJBSen91u3hgdwGw4uYBnccrpR/tNwNloyMb9IFYqUqa+lVF71up6POj3Ip/W J4P5uRE6r/+o7zoDjEZRbmRRG7dr1DtKgaSImhhGw/lF6RVsZovSrmRijvBb0asqYO UGNaG5W0rEZqA== X-Nifty-SrcIP: [111.169.71.157] From: Masahiro Yamada To: linux-mtd@lists.infradead.org Subject: [PATCH 24/39] mtd: nand: denali: add NEW_N_BANKS_FORMAT capability Date: Sun, 27 Nov 2016 03:06:10 +0900 Message-Id: <1480183585-592-25-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1480183585-592-1-git-send-email-yamada.masahiro@socionext.com> References: <1480183585-592-1-git-send-email-yamada.masahiro@socionext.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161126_100735_465250_EDE97F79 X-CRM114-Status: GOOD ( 13.94 ) X-Spam-Score: -1.2 (-) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-1.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 RCVD_IN_MSPIKE_L4 RBL: Bad reputation (-4) [210.131.2.78 listed in bl.mailspike.net] 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 0.0 RCVD_IN_MSPIKE_BL Mailspike blacklisted X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.20 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+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" but I doubt it. The revision register on some UniPhier SoCs says the IP is 5.0 but the max_banks is encoded in the new format. The revision of this IP is often useless. In order to provide a way to calculate correct max_banks without relying on the revision register, add DENALI_CAPS_NEW_N_BANKS_FORMAT capability (quirk). Signed-off-by: Masahiro Yamada --- drivers/mtd/nand/denali.c | 24 +++++++++++++++++------- drivers/mtd/nand/denali.h | 1 + 2 files changed, 18 insertions(+), 7 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 752ad98..614b4a5 100644 --- a/drivers/mtd/nand/denali.c +++ b/drivers/mtd/nand/denali.c @@ -448,17 +448,27 @@ static void find_valid_banks(struct denali_nand_info *denali) static void detect_max_banks(struct denali_nand_info *denali) { u32 features = ioread32(denali->flash_reg + FEATURES); + bool old_format; + /* - * Read the revision register, so we can calculate the max_banks - * properly: the encoding changed from rev 5.0 to 5.1 + * There are some IP versions with different n_banks encoding. + * Some people say the change happened from rev 5.0 to 5.1, while + * there exist variants with revision older than 5.1 but new encoding. + * The option flag is available in case the revision is useless. */ - u32 revision = MAKE_COMPARABLE_REVISION( + if (denali->caps & DENALI_CAPS_NEW_N_BANKS_FORMAT) + old_format = false; + else { + 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); + old_format = revision < REVISION_5_1; + } + + denali->max_banks = 1 << (features & FEATURES__N_BANKS); + + if (old_format) + denali->max_banks <<= 1; } static u16 denali_nand_timing_set(struct denali_nand_info *denali) diff --git a/drivers/mtd/nand/denali.h b/drivers/mtd/nand/denali.h index 9bdf037..e3fe3bc 100644 --- a/drivers/mtd/nand/denali.h +++ b/drivers/mtd/nand/denali.h @@ -436,6 +436,7 @@ struct denali_nand_info { unsigned int caps; #define DENALI_CAPS_HW_ECC_FIXUP BIT(0) #define DENALI_CAPS_DMA_64BIT BIT(1) +#define DENALI_CAPS_NEW_N_BANKS_FORMAT BIT(2) }; extern int denali_init(struct denali_nand_info *denali);