From patchwork Mon Apr 30 16:34:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aaron Sierra X-Patchwork-Id: 906772 X-Patchwork-Delegate: boris.brezillon@free-electrons.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=xes-inc.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="D/p/ba41"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40ZVWh0Fygz9s0W for ; Tue, 1 May 2018 02:35:12 +1000 (AEST) 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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Subject:Message-ID:To:From :Date: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=Z0GzQqv/mBU/qksRcq8oFrkmPDVBd9csYu8GEJupJYA=; b=D/p/ba41lHa9Fw nOOyaoUaj6j96YaqRQhFjLoMlJuQ6xkDnR0ivftNlzTppOFIlqGdbas11uKQO4iiitb8CeWhM0zJR XoAi9xE08joKOWlL5H3uxL/VHfbWYNNTLBsZz0nh4oXVItSX/kkxR9Q86DHFkW37hL5osu6aiKSxi 45CdcJ0PNAnNVemyVXu2saTW4ac6H3R3gzJnJKoirklvq8O7OgoudZOl+8YskvgbSjf4fQBnhw/qF f4+n7HHnQMTKpcHwa12kOkM3odilVhu4Uh0tP8uQEDt1DYSj/tRHeGVEuQPBle6Fb/E1X2xkrT59F p/mG1kT0zvRkhHDNmXpA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fDBlX-0003UF-LC; Mon, 30 Apr 2018 16:35:03 +0000 Received: from xes-mad.com ([216.165.139.220] helo=mail.xes-mad.com) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fDBlU-0003Rp-No for linux-mtd@lists.infradead.org; Mon, 30 Apr 2018 16:35:02 +0000 Received: from zimbra.xes-mad.com (zimbra.xes-mad.com [10.52.0.127]) by mail.xes-mad.com (Postfix) with ESMTP id F06262422B; Mon, 30 Apr 2018 11:34:49 -0500 (CDT) Date: Mon, 30 Apr 2018 11:34:49 -0500 (CDT) From: Aaron Sierra To: David Woodhouse , Brian Norris , Boris Brezillon , Marek Vasut , Richard Weinberger Message-ID: <286315039.117511.1525106089951.JavaMail.zimbra@xes-inc.com> Subject: [PATCH v2 1/2] mtd: cfi: Support early CFI fixups MIME-Version: 1.0 X-Originating-IP: [10.52.0.127] X-Mailer: Zimbra 8.7.5_GA_1764 (ZimbraWebClient - FF59 (Linux)/8.7.5_GA_1764) Thread-Index: PyGveoQB/ejmqLMo2lFtMuh/jEdrjg== Thread-Topic: Support early CFI fixups X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180430_093500_853505_B8C013A7 X-CRM114-Status: GOOD ( 11.51 ) X-Spam-Score: -0.0 (/) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [216.165.139.220 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 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: linux-mtd Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Some CFI devices need fixups that affect the number of chips detected, but the current fixup infrastructure (struct cfi_fixup and cfi_fixup()) does not cover this situation. Introduce struct cfi_early_fixup and cfi_early_fixup() to fill the void. Signed-off-by: Aaron Sierra --- v2 - Split into two patches. One adding infrastructure and one adding the first early fixup. - Define struct cfi_early_fixup and cfi_early_fixup() in cfi_probe.c drivers/mtd/chips/cfi_probe.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/drivers/mtd/chips/cfi_probe.c b/drivers/mtd/chips/cfi_probe.c index e8d0164..c05deac 100644 --- a/drivers/mtd/chips/cfi_probe.c +++ b/drivers/mtd/chips/cfi_probe.c @@ -63,6 +63,29 @@ do { \ #endif +/* + * This fixup occurs immediately after reading the CFI structure and can affect + * the number of chips detected, unlike cfi_fixup, which occurs after an + * mtd_info structure has been created for the chip. + */ +struct cfi_early_fixup { + uint16_t mfr; + uint16_t id; + void (*fixup)(struct cfi_private *cfi); +}; + +void cfi_early_fixup(struct cfi_private *cfi, struct cfi_early_fixup *fixups) +{ + struct cfi_early_fixup *f; + + for (f = fixups; f->fixup; f++) { + if (((f->mfr == CFI_MFR_ANY) || (f->mfr == cfi->mfr)) && + ((f->id == CFI_ID_ANY) || (f->id == cfi->id))) { + f->fixup(cfi); + } + } +} + /* check for QRY. in: interleave,type,mode ret: table index, <0 for error @@ -151,6 +174,10 @@ static int __xipram cfi_probe_chip(struct map_info *map, __u32 base, return 1; } +static struct cfi_early_fixup cfi_early_fixup_table[] = { + { 0, 0, NULL }, +}; + static int __xipram cfi_chip_setup(struct map_info *map, struct cfi_private *cfi) { @@ -235,6 +262,8 @@ static int __xipram cfi_chip_setup(struct map_info *map, cfi_qry_mode_off(base, map, cfi); xip_allowed(base, map); + cfi_early_fixup(cfi, cfi_early_fixup_table); + printk(KERN_INFO "%s: Found %d x%d devices at 0x%x in %d-bit bank. Manufacturer ID %#08x Chip ID %#08x\n", map->name, cfi->interleave, cfi->device_type*8, base, map->bankwidth*8, cfi->mfr, cfi->id);