From: Stefan Roese <sr@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 2/4 v2] cfi_flash: Read PPB sector protection from device for AMD/Spansion chips
Date: Thu, 6 Dec 2012 15:44:10 +0100 [thread overview]
Message-ID: <1354805052-32347-2-git-send-email-sr@denx.de> (raw)
In-Reply-To: <1354805052-32347-1-git-send-email-sr@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 <sr@denx.de>
Cc: Anatolij Gustschin <agust@denx.de>
Cc: Holger Brunck <holger.brunck@keymile.com>
---
v2:
- Added reset command before issuing the autoselect command
(FLASH_CMD_READ_ID). Otherwise STM flash chips didn't report
the correct protection status (on a4m2k board)
- Line length reduced (checkpatch warning)
drivers/mtd/cfi_flash.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/drivers/mtd/cfi_flash.c b/drivers/mtd/cfi_flash.c
index d865c40..045cf4a 100644
--- a/drivers/mtd/cfi_flash.c
+++ b/drivers/mtd/cfi_flash.c
@@ -2160,6 +2160,27 @@ 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_write_cmd(info, 0, 0,
+ info->cmd_reset);
+ 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
next prev parent reply other threads:[~2012-12-06 14:44 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-06 14:44 [U-Boot] [PATCH 1/4] cfi_flash: Add manufact_match helper function Stefan Roese
2012-12-06 14:44 ` Stefan Roese [this message]
2012-12-07 9:19 ` [U-Boot] [PATCH 2/4 v2] cfi_flash: Read PPB sector protection from device for AMD/Spansion chips Holger Brunck
2012-12-06 14:44 ` [U-Boot] [PATCH 3/4] cfi_flash: Enable PPB protection for all AMD cmdset flash chips Stefan Roese
2012-12-07 9:19 ` Holger Brunck
2012-12-06 14:44 ` [U-Boot] [PATCH 4/4] cfi_flash: Report Advanced Sector Protection (PPB) with flinfo cmd Stefan Roese
2012-12-07 9:20 ` Holger Brunck
2013-01-10 14:33 ` [U-Boot] [PATCH 1/4] cfi_flash: Add manufact_match helper function Stefan Roese
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1354805052-32347-2-git-send-email-sr@denx.de \
--to=sr@denx.de \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox