From: Stefan Roese Date: Wed, 28 Nov 2012 09:50:17 +0100 Subject: [U-Boot] [PATCH 2/2] cfi_flash: Read PPB sector protection from device for AMD/Spansion chips In-Reply-To: <1354092617-13570-1-git-send-email-sr@denx.de> References: <1354092617-13570-1-git-send-email-sr@denx.de> Message-ID: <1354092617-13570-2-git-send-email-sr@denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@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; -- 1.8.0.1