From patchwork Sat Feb 20 12:58:15 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guillaume LECERF X-Patchwork-Id: 45919 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 D2205B7C33 for ; Sat, 20 Feb 2010 23:58:46 +1100 (EST) Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux)) id 1NiotH-0004uK-Cc; Sat, 20 Feb 2010 12:56:59 +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 1NiotB-0004l0-CS for linux-mtd@lists.infradead.org; Sat, 20 Feb 2010 12:56:58 +0000 Received: from smtp6-g21.free.fr (localhost [127.0.0.1]) by smtp6-g21.free.fr (Postfix) with ESMTP id E2A76E08198; Sat, 20 Feb 2010 13:56:49 +0100 (CET) Received: from shiryu.yomgui.biz (lsd.homeftp.net [82.235.75.105]) by smtp6-g21.free.fr (Postfix) with ESMTP id 0C81AE08101; Sat, 20 Feb 2010 13:56:47 +0100 (CET) Received: from localhost ([127.0.0.1] helo=shiryu.yomgui.biz ident=fox) by shiryu.yomgui.biz with esmtp (Exim 4.71) (envelope-from ) id 1NiouV-000407-4c; Sat, 20 Feb 2010 13:58:15 +0100 Subject: [PATCH 6/6] mtd: cfi_cmdset_0002: add CFI detection for SST 39VF3201 chips To: David Woodhouse From: Guillaume LECERF Date: Sat, 20 Feb 2010 13:58:15 +0100 Message-ID: <20100220125814.14843.41936.stgit@shiryu.yomgui.biz> In-Reply-To: <20100220125748.14843.70415.stgit@shiryu.yomgui.biz> References: <20100220125748.14843.70415.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-20100220_075653_892763_58A0699E X-CRM114-Status: GOOD ( 15.66 ) X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.2.5 on bombadil.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- _SUMMARY_ Cc: linux-mtd 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 39VF0201 chips use the 0x0701 command set, fully compatible with the AMD one. This patch adds support for detecting them in CFI mode. Signed-off-by: Guillaume Lecerf --- drivers/mtd/chips/cfi_cmdset_0002.c | 24 ++++++++++++++++++++++++ drivers/mtd/chips/gen_probe.c | 1 + 2 files changed, 25 insertions(+), 0 deletions(-) diff --git a/drivers/mtd/chips/cfi_cmdset_0002.c b/drivers/mtd/chips/cfi_cmdset_0002.c index 3df6056..ad5271b 100644 --- a/drivers/mtd/chips/cfi_cmdset_0002.c +++ b/drivers/mtd/chips/cfi_cmdset_0002.c @@ -43,6 +43,7 @@ #define MAX_WORD_RETRIES 3 +#define SST39VF3201 0x235b #define SST49LF004B 0x0060 #define SST49LF040B 0x0050 #define SST49LF008A 0x005a @@ -246,6 +247,19 @@ static void fixup_use_erase_chip(struct mtd_info *mtd, void *param) } /* + * SST 32VF3201 chips report 2 erase zones while they actually + * only have 1. Patch this on the fly. + */ +static void fixup_sst39vf3201_erase_zones(struct mtd_info *mtd, void *param) +{ + struct map_info *map = mtd->priv; + struct cfi_private *cfi = map->fldrv_priv; + + cfi->cfiq->NumEraseRegions = 1; + pr_warning("%s: Bad SST39VF3201 CFI data, adjust from 2 to 1 erase region\n", mtd->name); +} + +/* * Some Atmel chips (e.g. the AT49BV6416) power-up with all sectors * locked by default. */ @@ -303,6 +317,7 @@ static struct cfi_fixup jedec_fixup_table[] = { { CFI_MFR_SST, SST49LF004B, fixup_use_fwh_lock, NULL, }, { CFI_MFR_SST, SST49LF040B, fixup_use_fwh_lock, NULL, }, { CFI_MFR_SST, SST49LF008A, fixup_use_fwh_lock, NULL, }, + { CFI_MFR_SST, SST39VF3201, fixup_sst39vf3201_erase_zones, NULL }, { 0, 0, NULL, NULL } }; @@ -352,6 +367,14 @@ struct mtd_info *cfi_cmdset_0002(struct map_info *map, int primary) mtd->writesize = 1; if (cfi->cfi_mode==CFI_MODE_CFI){ + /* + * SST 39VF3201 chips do not have a real PRI. + */ + if (cfi->mfr == CFI_MFR_SST && cfi->id == SST39VF3201) { + cfi->addr_unlock1 = 0x5555; + cfi->addr_unlock2 = 0x2AAA; + } + else { unsigned char bootloc; /* * It's a real CFI chip, not one for which the probe @@ -412,6 +435,7 @@ struct mtd_info *cfi_cmdset_0002(struct map_info *map, int primary) /* Set the default CFI lock/unlock addresses */ cfi->addr_unlock1 = 0x555; cfi->addr_unlock2 = 0x2aa; + } } /* CFI mode */ else if (cfi->cfi_mode == CFI_MODE_JEDEC) { 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