From patchwork Tue Mar 30 13:35:13 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guillaume LECERF X-Patchwork-Id: 48961 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [18.85.46.34]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 861EFB7CB6 for ; Wed, 31 Mar 2010 00:38:05 +1100 (EST) Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux)) id 1NwbcZ-0004vk-IW; Tue, 30 Mar 2010 13:36:43 +0000 Received: from smtp6-g21.free.fr ([212.27.42.6]) by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux)) id 1NwbcR-0004p1-2f for linux-mtd@lists.infradead.org; Tue, 30 Mar 2010 13:36:42 +0000 Received: from smtp6-g21.free.fr (localhost [127.0.0.1]) by smtp6-g21.free.fr (Postfix) with ESMTP id D0335E0801F; Tue, 30 Mar 2010 15:36:30 +0200 (CEST) Received: from shiryu.yomgui.biz (lsd.homeftp.net [82.235.75.105]) by smtp6-g21.free.fr (Postfix) with ESMTP id DF5D2E081DB; Tue, 30 Mar 2010 15:36:27 +0200 (CEST) Received: from localhost ([127.0.0.1] helo=shiryu.yomgui.biz) by shiryu.yomgui.biz with esmtp (Exim 4.71) (envelope-from ) id 1Nwbb7-0005G0-N7; Tue, 30 Mar 2010 15:35:13 +0200 Subject: [PATCH v2 6/7] mtd: cfi_cmdset_0002: add CFI detection for SST 39VF{16, 32}xx chips To: linux-mtd From: Guillaume LECERF Date: Tue, 30 Mar 2010 15:35:13 +0200 Message-ID: <20100330133513.20107.72328.stgit@shiryu.yomgui.biz> In-Reply-To: <20100330133448.20107.1077.stgit@shiryu.yomgui.biz> References: <20100330133448.20107.1077.stgit@shiryu.yomgui.biz> User-Agent: StGit/0.15 MIME-Version: 1.0 X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20100330_093635_652400_9EBECE1F X-CRM114-Status: GOOD ( 16.86 ) X-Spam-Score: 2.4 (++) X-Spam-Report: SpamAssassin version 3.2.5 on bombadil.infradead.org summary: Content analysis details: (2.4 points) pts rule name description ---- ---------------------- -------------------------------------------------- 2.4 DNS_FROM_OPENWHOIS RBL: Envelope sender listed in bl.open-whois.org. Cc: David Woodhouse , Artem Bityutskiy X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-mtd-bounces@lists.infradead.org Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org SST 39VF{16,32}xx chips use the 0x0701 command set, fully compatible with the AMD one. This patch adds support for detecting them in CFI mode. Based on a patch by Peter Turczaki [1]. [1] http://www.mail-archive.com/uclinux-dev@uclinux.org/msg05737.html Signed-off-by: Guillaume LECERF --- drivers/mtd/chips/cfi_cmdset_0002.c | 41 +++++++++++++++++++++++++++++++++++ drivers/mtd/chips/gen_probe.c | 1 + 2 files changed, 42 insertions(+), 0 deletions(-) diff --git a/drivers/mtd/chips/cfi_cmdset_0002.c b/drivers/mtd/chips/cfi_cmdset_0002.c index de1b4ba..e3e4a94 100644 --- a/drivers/mtd/chips/cfi_cmdset_0002.c +++ b/drivers/mtd/chips/cfi_cmdset_0002.c @@ -256,6 +256,36 @@ static void fixup_use_atmel_lock(struct mtd_info *mtd, void *param) mtd->flags |= MTD_POWERUP_LOCK; } +/** While reporting a mostly-correct CFI-Information block + * the eraseblock-region information is severely damaged in SST + * parts at least those of the 39VF{16,32,64}xxB series. + **/ +static void fixup_old_sst_eraseregion(struct mtd_info *mtd) +{ + struct map_info *map = mtd->priv; + struct cfi_private *cfi = map->fldrv_priv; + + /** Although the part claims to have two eraseblock-regions + * these refer to the same region within the flash-array. + * Because a really CFI-Compliant part may only return + * one eraseblock-length per physical memory region + * we pretend the part said it had just one region ;) + **/ + cfi->cfiq->NumEraseRegions = 1; + cfi->cfiq->EraseRegionInfo[0] = cfi->cfiq->EraseRegionInfo[1]; +} + +static void fixup_sst39vf(struct mtd_info *mtd, void *param) +{ + struct map_info *map = mtd->priv; + struct cfi_private *cfi = map->fldrv_priv; + + fixup_old_sst_eraseregion(mtd); + + cfi->addr_unlock1 = 0x5555; + cfi->addr_unlock2 = 0x2AAA; +} + static void fixup_s29gl064n_sectors(struct mtd_info *mtd, void *param) { struct map_info *map = mtd->priv; @@ -278,6 +308,16 @@ static void fixup_s29gl032n_sectors(struct mtd_info *mtd, void *param) } } +/* Used to fix CFI-Tables of chips without Extended Query Tables + */ +static struct cfi_fixup cfi_nopri_fixup_table[] = { + { CFI_MFR_SST, 0x234A, fixup_sst39vf, NULL, }, // SST39VF1602 + { CFI_MFR_SST, 0x234B, fixup_sst39vf, NULL, }, // SST39VF1601 + { CFI_MFR_SST, 0x235A, fixup_sst39vf, NULL, }, // SST39VF3202 + { CFI_MFR_SST, 0x235B, fixup_sst39vf, NULL, }, // SST39VF3201 + { 0, 0, NULL, NULL } +}; + static struct cfi_fixup cfi_fixup_table[] = { { CFI_MFR_ATMEL, CFI_ID_ANY, fixup_convert_atmel_pri, NULL }, #ifdef AMD_BOOTLOC_BUG @@ -408,6 +448,7 @@ struct mtd_info *cfi_cmdset_0002(struct map_info *map, int primary) cfi->addr_unlock1 = 0x555; cfi->addr_unlock2 = 0x2aa; } + cfi_fixup(mtd, cfi_nopri_fixup_table); if (!cfi->addr_unlock1 || !cfi->addr_unlock2) { kfree(mtd); diff --git a/drivers/mtd/chips/gen_probe.c b/drivers/mtd/chips/gen_probe.c index 991c457..599c259 100644 --- a/drivers/mtd/chips/gen_probe.c +++ b/drivers/mtd/chips/gen_probe.c @@ -249,6 +249,7 @@ static struct mtd_info *check_cmd_set(struct map_info *map, int primary) #endif #ifdef CONFIG_MTD_CFI_AMDSTD case P_ID_AMD_STD: + case P_ID_SST_OLD: return cfi_cmdset_0002(map, primary); #endif #ifdef CONFIG_MTD_CFI_STAA