summaryrefslogtreecommitdiff
path: root/82802ab.c
diff options
context:
space:
mode:
authorsnelson <snelson@2b7e53f0-3cfb-0310-b3e9-8179ed1497e1>2010-03-22 04:39:31 +0000
committersnelson <snelson@2b7e53f0-3cfb-0310-b3e9-8179ed1497e1>2010-03-22 04:39:31 +0000
commit2e848492c5f549ec976ce8a0679e2e4410b16f55 (patch)
tree6cb766627da69c3d73e6c75b63fc207733d8f334 /82802ab.c
parent5a45de6a816fd243c835eeaea2afc68d794f9ab0 (diff)
downloadflashrom-2e848492c5f549ec976ce8a0679e2e4410b16f55.tar.gz
To access/read the lock bits, we use the same mode to read the chip id.
This patch looks into the write situation for the Intel 28F001BX-{B,T}. Looks like they're just a 82802ab page write. Unlock_28f004s5 has been changed to read all the lock bits and if at least one of the block lock bits are set, clear them all. If the master lock bit is set, we can't do anything about it, so we return. Signed-off-by: Sean Nelson <audiohacked@gmail.com> Acked-by: Carl-Daniel Hailfinger<c-d.hailfinger.devel.2006@gmx.net> git-svn-id: https://code.coreboot.org/svn/flashrom/trunk@965 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
Diffstat (limited to '82802ab.c')
-rw-r--r--82802ab.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/82802ab.c b/82802ab.c
index 1316939..3aa76b4 100644
--- a/82802ab.c
+++ b/82802ab.c
@@ -205,3 +205,52 @@ int write_82802ab(struct flashchip *flash, uint8_t *buf)
return 0;
}
+
+int unlock_28f004s5(struct flashrom *flash)
+{
+ chipaddr bios = flash->virtual_memory;
+ uint8_t mcfg, bcfg, need_unlock = 0, can_unlock = 0;
+
+ /* Clear status register */
+ chip_writeb(0x50, bios);
+
+ /* Read identifier codes */
+ chip_writeb(0x90, bios);
+
+ /* Read master lock-bit */
+ mcfg = chip_readb(bios + 0x3);
+ msg_cinfo("master lock is ");
+ if (mcfg) {
+ msg_cdbg("locked!\n");
+ } else {
+ msg_cdbg("unlocked!\n");
+ can_unlock = 1;
+ }
+
+ /* Read block lock-bits */
+ for (i = 0; i < flash->total_size * 1024; i+= (64 * 1024)) {
+ bcfg = chip_readb(bios + i + 2); // read block lock config
+ msg_cdbg("block lock at %06x is %slocked!\n", i, bcfg ? "" : "un");
+ if (bcfg) {
+ need_unlock = 1;
+ }
+ }
+
+ /* Reset chip */
+ chip_writeb(0xFF, bios);
+
+ /* Unlock: clear block lock-bits, if needed */
+ if (can_unlock && need_unlock) {
+ chip_writeb(0x60, bios);
+ chip_writeb(0xD0, bios);
+ chip_writeb(0xFF, bios);
+ }
+
+ /* Error: master locked or a block is locked */
+ if (!can_unlock && need_unlock) {
+ msg_cerr("At least one block is locked and lockdown is active!\n");
+ return -1;
+ }
+
+ return 0;
+}