From patchwork Wed Mar 9 06:41:35 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiko Schocher X-Patchwork-Id: 86063 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id AF1D9B70F7 for ; Wed, 9 Mar 2011 17:41:48 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 033972808A; Wed, 9 Mar 2011 07:41:47 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 8nPb7Iql-SF7; Wed, 9 Mar 2011 07:41:46 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 97B0028081; Wed, 9 Mar 2011 07:41:44 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 0D3DB28081 for ; Wed, 9 Mar 2011 07:41:43 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id tzz7lwWxbRMZ for ; Wed, 9 Mar 2011 07:41:41 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from b.relay.invitel.net (b.relay.invitel.net [62.77.203.4]) by theia.denx.de (Postfix) with ESMTP id 1C7AF2807F for ; Wed, 9 Mar 2011 07:41:38 +0100 (CET) Received: from mail.invitel.hu (mail.invitel.hu [213.163.59.4]) by b.relay.invitel.net (Invitel Core SMTP Transmitter) with ESMTP id 4E72331A2E2; Wed, 9 Mar 2011 07:41:38 +0100 (CET) Received: from [192.168.1.6] ([91.82.146.131]) by mail.invitel.hu (Invitel Messaging Server) with ESMTPA id <0LHS00EE12LBDJA0@invitel.hu>; Wed, 09 Mar 2011 07:41:36 +0100 (CET) Date: Wed, 09 Mar 2011 07:41:35 +0100 From: Heiko Schocher In-reply-to: <20110308142651.GA26540@frolo.macqel> To: Philippe De Muyter Message-id: <4D77211F.9090203@denx.de> Organization: DENX Software Engineering MIME-version: 1.0 References: <4D762A4A.8070002@denx.de> <20110308142651.GA26540@frolo.macqel> User-Agent: Thunderbird 2.0.0.6 (X11/20070801) Cc: U-Boot user list , Stefan Roese , Holger Brunck Subject: Re: [U-Boot] cfi: Problem with Intel Strata 28F320 flash X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.9 Precedence: list Reply-To: hs@denx.de List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de Hello Philippe, Philippe De Muyter wrote: > On Tue, Mar 08, 2011 at 02:08:26PM +0100, Heiko Schocher wrote: >> Hello, >> >> as I am actual trying to get the keymile boards in sync with actual >> mainline u-boot, I faced the following Problem with an Intel Strata >> Flash on the mgcoge (mpc8247 based board): >> >> I couldn;t unprotect/erase/write/protect some (not all!) Flash sectors. >> >> For Example, I could do this without errors on the sectors where >> u-boot sits (First three sectors), but not with the environment (next >> two sectors)! > > That's exactly the problem I had, but triggered by another valid command > sequence. > > So it is also a flash bug. Hmm.. I wouldn;t call it bug, because the sequence which is run without 54652991caedc39b2ec2e5b49e750669bfcd1e2e, is exactly the sequence, which is described in the datasheet for the 29Fxxx chips ... > Have you searched with google for your chip plus "errata" or "specification > update" as they call that ? No, see above comment. >> After some debugging, I found out, that, if I revert commit >> >> commit 54652991caedc39b2ec2e5b49e750669bfcd1e2e >> Author: Philippe De Muyter >> Date: Tue Aug 17 18:40:25 2010 +0200 >> >> Work around bug in Numonyx P33/P30 256-Mbit 65nm flash chips. >> >> I have "ported" U-boot to a in house made board with Numonyx Axcell P33/P30 >> 256-Mbit 65nm flash chips. >> >> After some time :( searching for bugs in our board or soft, we have >> discovered that those chips have a small but annoying bug, documented in >> "Numonyx Axcell P33/P30 256-Mbit Specification Update" >> [...] >> >> It works again fine, and without problems ... did somebody faced >> similiar issues with the cfi driver? Some Ideas? > > It seems like we'll need to check the flash chip type before issuing one command > sequence or another. Maybe a way to go ... more comments? Below a patch, which introduces a function, which checks for "protection bugfixes", and if no bugfix is found the old code is executed. Just a fast RFC patch. bye, Heiko diff --git a/drivers/mtd/cfi_flash.c b/drivers/mtd/cfi_flash.c index dd394a8..9d3fdcc 100644 --- a/drivers/mtd/cfi_flash.c +++ b/drivers/mtd/cfi_flash.c @@ -1376,6 +1376,38 @@ int write_buff (flash_info_t * info, uchar * src, ulong addr, ulong cnt) */ #ifdef CONFIG_SYS_FLASH_PROTECTION +static int cfi_protect_bugfix(flash_info_t * info, long sector, int prot) +{ + if ((info->manufacturer_id == 0x89) && (info->device_id == 0x8922)) { + /* + * see errata called + * "Numonyx Axcell P33/P30 Specification Update" :) + */ + flash_write_cmd (info, sector, 0, FLASH_CMD_READ_ID); + if (!flash_isequal (info, sector, FLASH_OFFSET_PROTECT, + prot)) { + /* + * cmd must come before FLASH_CMD_PROTECT + 20us + * Disable interrupts which might cause a timeout here. + */ + int flag = disable_interrupts (); + unsigned short cmd; + if (prot) + cmd = FLASH_CMD_PROTECT_SET; + else + cmd = FLASH_CMD_PROTECT_CLEAR; + flash_write_cmd (info, sector, 0, + FLASH_CMD_PROTECT); + flash_write_cmd (info, sector, 0, cmd); + /* re-enable interrupts if necessary */ + if (flag) + enable_interrupts (); + } + return 1; + } + return 0; +} + int flash_real_protect (flash_info_t * info, long sector, int prot) { int retcode = 0; @@ -1384,31 +1416,18 @@ int flash_real_protect (flash_info_t * info, long sector, int prot) case CFI_CMDSET_INTEL_PROG_REGIONS: case CFI_CMDSET_INTEL_STANDARD: case CFI_CMDSET_INTEL_EXTENDED: - /* - * see errata called - * "Numonyx Axcell P33/P30 Specification Update" :) - */ - flash_write_cmd (info, sector, 0, FLASH_CMD_READ_ID); - if (!flash_isequal (info, sector, FLASH_OFFSET_PROTECT, - prot)) { - /* - * cmd must come before FLASH_CMD_PROTECT + 20us - * Disable interrupts which might cause a timeout here. - */ - int flag = disable_interrupts (); - unsigned short cmd; - + if (!cfi_protect_bugfix(info, sector, prot)) { + flash_write_cmd (info, sector, 0, + FLASH_CMD_CLEAR_STATUS); + flash_write_cmd (info, sector, 0, + FLASH_CMD_PROTECT); if (prot) - cmd = FLASH_CMD_PROTECT_SET; + flash_write_cmd (info, sector, 0, + FLASH_CMD_PROTECT_SET); else - cmd = FLASH_CMD_PROTECT_CLEAR; + flash_write_cmd (info, sector, 0, + FLASH_CMD_PROTECT_CLEAR); - flash_write_cmd (info, sector, 0, - FLASH_CMD_PROTECT); - flash_write_cmd (info, sector, 0, cmd); - /* re-enable interrupts if necessary */ - if (flag) - enable_interrupts (); } break; case CFI_CMDSET_AMD_EXTENDED: