From patchwork Wed Nov 28 08:50:17 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roese X-Patchwork-Id: 202387 X-Patchwork-Delegate: sr@denx.de 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 2655C2C008F for ; Wed, 28 Nov 2012 19:50:56 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 5A6B34A0EF; Wed, 28 Nov 2012 09:50:54 +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 Dtt7qs-I6nrD; Wed, 28 Nov 2012 09:50:54 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id AA1F54A0F0; Wed, 28 Nov 2012 09:50:50 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id D80C84A0EC for ; Wed, 28 Nov 2012 09:50: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 5ZbWoTomOLCP for ; Wed, 28 Nov 2012 09:50:46 +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 mo-p05-ob.rzone.de (mo-p05-ob.rzone.de [81.169.146.182]) by theia.denx.de (Postfix) with ESMTPS id 4A7614A0EF for ; Wed, 28 Nov 2012 09:50:44 +0100 (CET) X-RZG-AUTH: :IW0NeWC7b/q2i6W/qstXb1SBUuFnrGohdvpEkce+Ub4+ReKfHD+mCPMMrYtfgQ== X-RZG-CLASS-ID: mo05 Received: from ubuntu-2012.fritz.box (p57B9468A.dip.t-dialin.net [87.185.70.138]) by smtp.strato.de (jorabe mo11) (RZmta 31.6 DYNA|AUTH) with ESMTPA id 002809oAS8802W ; Wed, 28 Nov 2012 09:50:26 +0100 (CET) From: Stefan Roese To: u-boot@lists.denx.de Date: Wed, 28 Nov 2012 09:50:17 +0100 Message-Id: <1354092617-13570-2-git-send-email-sr@denx.de> X-Mailer: git-send-email 1.8.0.1 In-Reply-To: <1354092617-13570-1-git-send-email-sr@denx.de> References: <1354092617-13570-1-git-send-email-sr@denx.de> Cc: Holger Brunck Subject: [U-Boot] [PATCH 2/2] cfi_flash: Read PPB sector protection from device for AMD/Spansion chips X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de Patch 66863b05 [cfi_flash: add support for Spansion flash PPB sector protection] introduced the PPB (Persistent Protection Bit) locking for Spansion chips. But right now the sector protection status (locked vs unlocked) is set to unlocked for all sectors upon bootup. The real sector protection status is ignored. This patch now reads the current sector protection status and uses it for these AMD/Spansion flash chips. Signed-off-by: Stefan Roese Cc: Anatolij Gustschin Cc: Holger Brunck --- drivers/mtd/cfi_flash.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/drivers/mtd/cfi_flash.c b/drivers/mtd/cfi_flash.c index d865c40..b026815 100644 --- a/drivers/mtd/cfi_flash.c +++ b/drivers/mtd/cfi_flash.c @@ -2160,6 +2160,23 @@ ulong flash_get_size (phys_addr_t base, int banknum) FLASH_OFFSET_PROTECT, FLASH_STATUS_PROTECT); break; + case CFI_CMDSET_AMD_EXTENDED: + case CFI_CMDSET_AMD_STANDARD: + if (!manufact_match(info, AMD_MANUFACT)) { + /* default: not protected */ + info->protect[sect_cnt] = 0; + break; + } + + /* Read protection (PPB) from sector */ + flash_unlock_seq(info, 0); + flash_write_cmd(info, 0, info->addr_unlock1, + FLASH_CMD_READ_ID); + info->protect[sect_cnt] = + flash_isset(info, sect_cnt, + FLASH_OFFSET_PROTECT, + FLASH_STATUS_PROTECT); + break; default: /* default: not protected */ info->protect[sect_cnt] = 0;