From patchwork Thu Nov 6 16:13:39 2008 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hartley Sweeten X-Patchwork-Id: 7546 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@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 27AFEDDDF0 for ; Fri, 7 Nov 2008 03:15:16 +1100 (EST) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.68 #1 (Red Hat Linux)) id 1Ky7UT-0006HD-7q; Thu, 06 Nov 2008 16:13:49 +0000 Received: from exprod6og116.obsmtp.com ([64.18.1.37]) by bombadil.infradead.org with smtp (Exim 4.68 #1 (Red Hat Linux)) id 1Ky7UR-00061h-5w for linux-mtd@lists.infradead.org; Thu, 06 Nov 2008 16:13:47 +0000 Received: from source ([63.240.6.3]) (using TLSv1) by exprod6ob116.postini.com ([64.18.5.12]) with SMTP; Thu, 06 Nov 2008 08:13:47 PST Received: from d01smtp06.Mi8.com ([172.16.1.239]) by Outbound02.Mi8.com with Microsoft SMTPSVC(6.0.3790.3959); Thu, 6 Nov 2008 11:13:40 -0500 Received: from mi8nycmail19.Mi8.com ([172.16.7.219]) by d01smtp06.Mi8.com with Microsoft SMTPSVC(6.0.3790.3959); Thu, 6 Nov 2008 11:13:39 -0500 X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message MIME-Version: 1.0 Subject: RE: [PATCH] mtd: m25p80.c add support for non-JEDEC ID devices Date: Thu, 6 Nov 2008 11:13:39 -0500 Message-ID: In-Reply-To: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PATCH] mtd: m25p80.c add support for non-JEDEC ID devices thread-index: AckxFlBHCO3XX7cLQZiojfBxLTD0ygBCn/MgA4JHFiA= References: <1224330021.6770.1350.camel@macbook.infradead.org> From: "hartleys" To: "David Woodhouse" X-OriginalArrivalTime: 06 Nov 2008 16:13:39.0832 (UTC) FILETIME=[A1742F80:01C9402A] X-Spam-Score: -4.0 (----) X-Spam-Report: SpamAssassin version 3.2.5 on bombadil.infradead.org summary: Content analysis details: (-4.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -4.0 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, medium trust [64.18.1.37 listed in list.dnswl.org] Cc: linux-mtd@lists.infradead.org X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.9 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 On Sunday, October 19, 2008 12:32 PM, hartleys wrote: >>> This patch allows the m25p80 driver to support non-JEDEC ID devices. >>> >>> It has been tested on an EP93xx based ARM platform with a SST25LF020A >>> >>> 2Mbit SPI Serial Flash device. >>> >>> Any comments would be appreciated. >> >> Looks sane, but could I have an updated copy against the current git >> tree please? > > I assume you meant the current mtd git tree. > > Here is the updated patch based on a: > > $ git clone > git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git linux-2.6 > $ git-clone --reference linux-2.6 git://git.infradead.org/mtd-2.6 > > Hope this one is better. > > Signed-off-by: H Hartley Sweeten Did this patch look better? I see the current mtd git tree has another change. static inline int write_enable(struct m25p *flash) { u8 code = OPCODE_WREN; - return spi_write(flash->spi, &code, 1); + return spi_write_then_read(flash->spi, &code, 1, NULL, 0); } Do I need to create another updated patch? Thanks, Hartley --- /* Status Register bits. */ #define SR_WIP 1 /* Write in progress */ @@ -542,12 +543,16 @@ static struct flash_info __devinitdata m25p_data [] = { { "w25x16", 0xef3015, 0, 64 * 1024, 32, SECT_4K, }, { "w25x32", 0xef3016, 0, 64 * 1024, 64, SECT_4K, }, { "w25x64", 0xef3017, 0, 64 * 1024, 128, SECT_4K, }, + + /* Non JEDEC ID SST -- large erase sizes are "overlays", "sectors" are 4K */ + { "sst25lf020a", 0xbf43, 0, 32 * 1024, 8, SECT_4K, }, + { "sst25lf040a", 0xbf44, 0, 32 * 1024, 16, SECT_4K, }, }; static struct flash_info *__devinit jedec_probe(struct spi_device *spi) { int tmp; - u8 code = OPCODE_RDID; + u8 code[4]; u8 id[5]; u32 jedec; u16 ext_jedec; @@ -557,6 +562,7 @@ static struct flash_info *__devinit jedec_probe(struct spi_device *spi) * string for after vendor-specific data, after the three bytes * we use here. Supporting some chips might require using it. */ + code[0] = OPCODE_RDID; tmp = spi_write_then_read(spi, &code, 1, id, 5); if (tmp < 0) { DEBUG(MTD_DEBUG_LEVEL0, "%s: error %d reading JEDEC ID\n", @@ -580,6 +586,31 @@ static struct flash_info *__devinit jedec_probe(struct spi_device *spi) return info; } dev_err(&spi->dev, "unrecognized JEDEC id %06x\n", jedec); + + /* Try reading the non-JEDEC Manufacture/Device ID */ + code[0] = OPCODE_RDID_NON_JEDEC; + code[1] = 0x00; + code[2] = 0x00; + code[3] = 0x00; + tmp = spi_write_then_read(spi, code, 4, id, 2); + if (tmp < 0) { + DEBUG(MTD_DEBUG_LEVEL0, "%s: error %d reading ID\n", + spi->dev.bus_id, tmp); + return NULL; + } + + jedec = id[0]; + jedec = jedec << 8; + jedec |= id[1]; + + for (tmp = 0, info = m25p_data; + tmp < ARRAY_SIZE(m25p_data); + tmp++, info++) { + if (info->jedec_id == jedec) + return info; + } + dev_err(&spi->dev, "unrecognized id %04x\n", jedec); + return NULL; } diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c index 697a3a2..f75c70f 100644 --- a/drivers/mtd/devices/m25p80.c +++ b/drivers/mtd/devices/m25p80.c @@ -42,6 +42,7 @@ #define OPCODE_BE 0xc7 /* Erase whole flash block */ #define OPCODE_SE 0xd8 /* Sector erase (usually 64KiB) */ #define OPCODE_RDID 0x9f /* Read JEDEC ID */ +#define OPCODE_RDID_NON_JEDEC 0x90 /* Read non-JEDEC ID */