From patchwork Fri Aug 28 08:05:10 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: massimo cirillo X-Patchwork-Id: 32349 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 0651AB7BCC for ; Fri, 28 Aug 2009 18:08:37 +1000 (EST) Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux)) id 1MgwSY-00075y-5v; Fri, 28 Aug 2009 08:05:22 +0000 Received: from mail-fx0-f226.google.com ([209.85.220.226]) by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux)) id 1MgwSQ-00074t-FT for linux-mtd@lists.infradead.org; Fri, 28 Aug 2009 08:05:19 +0000 Received: by fxm26 with SMTP id 26so1479442fxm.18 for ; Fri, 28 Aug 2009 01:05:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=lvt/9xYeIoksEdFqBydJ4YTZiTTTkIQl6988caR/Hgg=; b=mMiJqsWd2X1HzqPAnAcQU9Dhjqcm+2zOv/NVIuDWtJQno8R0yZNH/87dTS9Kk59j+L 0gBU07K7mijp1GLfEzzz1c/Dohq2EARhXvdoh9gtPLG/7TtkKPl7ul7e/HxY+ygbDptW bYVYXlvAwnfSseUxPppwSmLSZzpy2GoIQ+fpU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=RUPx+brHNZrf1scxrEXmpUSYpT6kUUSfN39novc4AUQTePTsqVyDgPlGs+h+xOY+Na oYQ+M0B7c2kg6trUdzI+5SkWGi6Lxz4lCA3bt8miBMAswJxIjrsWxG+XkS4hhD68UJ6f TA26HNbGFGGhSKeEyZohX2zC1mGTq3alOBDps= MIME-Version: 1.0 Received: by 10.102.211.35 with SMTP id j35mr114355mug.35.1251446710719; Fri, 28 Aug 2009 01:05:10 -0700 (PDT) In-Reply-To: <62cbdcd90908270313i5a45cb4aw6f34477a798bdbfe@mail.gmail.com> References: <62cbdcd90908270313i5a45cb4aw6f34477a798bdbfe@mail.gmail.com> Date: Fri, 28 Aug 2009 10:05:10 +0200 Message-ID: <62cbdcd90908280105w73941da1p211b1b9248bbd275@mail.gmail.com> Subject: Re: [PATCH] [MTD] CHIPS: buffer size adjustment for M29EW Numonyx devices From: massimo cirillo To: linux-mtd@lists.infradead.org X-Spam-Score: 0.0 (/) 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 From: Massimo Cirillo Please, consider this new version of the patch, that leaves unchanged the cfi->id value for AMD devices. Signed-off-by: Massimo Cirillo --- -- 2009/8/27 massimo cirillo : > From: Massimo Cirillo > > The buffer size fot M29EW Numonyx flash devices used in 8bit configuration > is 256 bytes sized, while the CFI contains a wrong value (1024 bytes). > The following patch fixes this hardware bug. > The following patch applies to 2.6.30 kernel. > > Signed-off-by: Massimo Cirillo > --- > diff --git a/drivers/mtd/chips/cfi_probe.c b/drivers/mtd/chips/cfi_probe.c > old mode 100644 > new mode 100755 > index e63e674..1281920 > --- a/drivers/mtd/chips/cfi_probe.c > +++ b/drivers/mtd/chips/cfi_probe.c > @@ -158,6 +158,9 @@ static int __xipram cfi_chip_setup(struct map_info *map, >        __u32 base = 0; >        int num_erase_regions = cfi_read_query(map, base + (0x10 + 28)*ofs_factor); >        int i; > +       int extendedId1 = 0; > +       int extendedId2 = 0; > +       int extendedId3 = 0; > >        xip_enable(base, map, cfi); >  #ifdef DEBUG_CFI > @@ -196,23 +199,39 @@ static int __xipram cfi_chip_setup(struct map_info *map, >        cfi->id = cfi_read_query16(map, base + ofs_factor); > >        /* Get AMD/Spansion extended JEDEC ID */ > -       if (cfi->mfr == CFI_MFR_AMD && (cfi->id & 0xff) == 0x7e) > -               cfi->id = cfi_read_query(map, base + 0xe * ofs_factor) << 8 | > +       if ((cfi->mfr == CFI_MFR_NMX || cfi->mfr == CFI_MFR_ST || > +               cfi->mfr == CFI_MFR_AMD) && ((cfi->id & 0xff) == 0x7e) > +               && (le16_to_cpu(cfi->cfiq->P_ID) == 0x0002)) { > +               extendedId1 = cfi_read_query16(map, base + 0x1 * ofs_factor); > +               extendedId2 = cfi_read_query16(map, base + 0xe * ofs_factor); > +               extendedId3 = cfi_read_query16(map, base + 0xf * ofs_factor); > +               /* compatibility with previous versions */ > +               cfi->id = cfi_read_query(map, base + 0xe * ofs_factor) << 8 | >                          cfi_read_query(map, base + 0xf * ofs_factor); > +       } > >        /* Put it back into Read Mode */ >        cfi_qry_mode_off(base, map, cfi); >        xip_allowed(base, map); > - > -       /* Do any necessary byteswapping */ > + > +       /* Do any necessary byteswapping */ >        cfi->cfiq->P_ID = le16_to_cpu(cfi->cfiq->P_ID); > - >        cfi->cfiq->P_ADR = le16_to_cpu(cfi->cfiq->P_ADR); >        cfi->cfiq->A_ID = le16_to_cpu(cfi->cfiq->A_ID); >        cfi->cfiq->A_ADR = le16_to_cpu(cfi->cfiq->A_ADR); >        cfi->cfiq->InterfaceDesc = le16_to_cpu(cfi->cfiq->InterfaceDesc); >        cfi->cfiq->MaxBufWriteSize = le16_to_cpu(cfi->cfiq->MaxBufWriteSize); > > +       /* If the device is a M29EW used in 8-bit mode, adjust buffer size */ > +       if ((cfi->cfiq->MaxBufWriteSize > 0x8) && (cfi->mfr == CFI_MFR_NMX || > +               cfi->mfr == CFI_MFR_ST) && (extendedId1 == 0x7E) && > +               (extendedId2 == 0x22 || extendedId2 == 0x23 || extendedId2 == 0x28) && > +               (extendedId3 == 0x01)) { > +               cfi->cfiq->MaxBufWriteSize = 0x8; > +               pr_warning("Adjusted buffer size on Numonyx flash M29EW family"); > +               pr_warning(" in 8 bit mode\n"); > +       } > + >  #ifdef DEBUG_CFI >        /* Dump the information therein */ >        print_cfi_ident(cfi->cfiq); > @@ -228,6 +247,8 @@ static int __xipram cfi_chip_setup(struct map_info *map, >  #endif >        } > > + > + >        printk(KERN_INFO "%s: Found %d x%d devices at 0x%x in %d-bit bank\n", >               map->name, cfi->interleave, cfi->device_type*8, base, >               map->bankwidth*8); > diff --git a/include/linux/mtd/cfi.h b/include/linux/mtd/cfi.h > old mode 100644 > new mode 100755 > index 88d3d8f..43d6a77 > --- a/include/linux/mtd/cfi.h > +++ b/include/linux/mtd/cfi.h > @@ -522,6 +522,7 @@ struct cfi_fixup { >  #define CFI_MFR_ATMEL 0x001F >  #define CFI_MFR_SAMSUNG 0x00EC >  #define CFI_MFR_ST  0x0020     /* STMicroelectronics */ > +#define CFI_MFR_NMX 0x0089 /* Numonyx */ > >  void cfi_fixup(struct mtd_info *mtd, struct cfi_fixup* fixups); > diff --git a/drivers/mtd/chips/cfi_probe.c b/drivers/mtd/chips/cfi_probe.c old mode 100644 new mode 100755 index e63e674..e4c5790 --- a/drivers/mtd/chips/cfi_probe.c +++ b/drivers/mtd/chips/cfi_probe.c @@ -158,6 +158,9 @@ static int __xipram cfi_chip_setup(struct map_info *map, __u32 base = 0; int num_erase_regions = cfi_read_query(map, base + (0x10 + 28)*ofs_factor); int i; + int extendedId1 = 0; + int extendedId2 = 0; + int extendedId3 = 0; xip_enable(base, map, cfi); #ifdef DEBUG_CFI @@ -195,6 +198,15 @@ static int __xipram cfi_chip_setup(struct map_info *map, cfi->mfr = cfi_read_query16(map, base); cfi->id = cfi_read_query16(map, base + ofs_factor); + /* Get device ID cycle 1,2,3 for Numonyx/ST devices */ + if ((cfi->mfr == CFI_MFR_NMX || cfi->mfr == CFI_MFR_ST) + && ((cfi->id & 0xff) == 0x7e) + && (le16_to_cpu(cfi->cfiq->P_ID) == 0x0002)) { + extendedId1 = cfi_read_query16(map, base + 0x1 * ofs_factor); + extendedId2 = cfi_read_query16(map, base + 0xe * ofs_factor); + extendedId3 = cfi_read_query16(map, base + 0xf * ofs_factor); + } + /* Get AMD/Spansion extended JEDEC ID */ if (cfi->mfr == CFI_MFR_AMD && (cfi->id & 0xff) == 0x7e) cfi->id = cfi_read_query(map, base + 0xe * ofs_factor) << 8 | @@ -203,16 +215,25 @@ static int __xipram cfi_chip_setup(struct map_info *map, /* Put it back into Read Mode */ cfi_qry_mode_off(base, map, cfi); xip_allowed(base, map); - - /* Do any necessary byteswapping */ + + /* Do any necessary byteswapping */ cfi->cfiq->P_ID = le16_to_cpu(cfi->cfiq->P_ID); - cfi->cfiq->P_ADR = le16_to_cpu(cfi->cfiq->P_ADR); cfi->cfiq->A_ID = le16_to_cpu(cfi->cfiq->A_ID); cfi->cfiq->A_ADR = le16_to_cpu(cfi->cfiq->A_ADR); cfi->cfiq->InterfaceDesc = le16_to_cpu(cfi->cfiq->InterfaceDesc); cfi->cfiq->MaxBufWriteSize = le16_to_cpu(cfi->cfiq->MaxBufWriteSize); + /* If the device is a M29EW used in 8-bit mode, adjust buffer size */ + if ((cfi->cfiq->MaxBufWriteSize > 0x8) && (cfi->mfr == CFI_MFR_NMX || + cfi->mfr == CFI_MFR_ST) && (extendedId1 == 0x7E) && + (extendedId2 == 0x22 || extendedId2 == 0x23 || extendedId2 == 0x28) && + (extendedId3 == 0x01)) { + cfi->cfiq->MaxBufWriteSize = 0x8; + pr_warning("Adjusted buffer size on Numonyx flash M29EW family"); + pr_warning("in 8 bit mode\n"); + } + #ifdef DEBUG_CFI /* Dump the information therein */ print_cfi_ident(cfi->cfiq); @@ -228,6 +249,8 @@ static int __xipram cfi_chip_setup(struct map_info *map, #endif } + + printk(KERN_INFO "%s: Found %d x%d devices at 0x%x in %d-bit bank\n", map->name, cfi->interleave, cfi->device_type*8, base, map->bankwidth*8); diff --git a/include/linux/mtd/cfi.h b/include/linux/mtd/cfi.h old mode 100644 new mode 100755 index 88d3d8f..43d6a77 --- a/include/linux/mtd/cfi.h +++ b/include/linux/mtd/cfi.h @@ -522,6 +522,7 @@ struct cfi_fixup { #define CFI_MFR_ATMEL 0x001F #define CFI_MFR_SAMSUNG 0x00EC #define CFI_MFR_ST 0x0020 /* STMicroelectronics */ +#define CFI_MFR_NMX 0x0089 /* Numonyx */ void cfi_fixup(struct mtd_info *mtd, struct cfi_fixup* fixups);