mirror of
https://review.coreboot.org/flashrom.git
synced 2025-07-01 22:21:16 +02:00
Refactor unlocking of many chips with locking at register space address +2
This includes PMC Pm49*, SST 49LF00*, ST M50* and Winbond W39* families. The erase and write test status bits of all affected chips have been reset. Corresponding to flashrom svn r1833. Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> Signed-off-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at> Acked-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
This commit is contained in:

committed by
Stefan Tauner

parent
2a41f0a2c0
commit
ef3ac8ac17
112
w39.c
112
w39.c
@ -20,65 +20,7 @@
|
||||
*/
|
||||
|
||||
#include "flash.h"
|
||||
|
||||
static int printlock_w39_fwh_block(struct flashctx *flash, unsigned int offset)
|
||||
{
|
||||
chipaddr wrprotect = flash->virtual_registers + offset + 2;
|
||||
uint8_t locking;
|
||||
|
||||
locking = chip_readb(flash, wrprotect);
|
||||
msg_cdbg("Lock status of block at 0x%08x is ", offset);
|
||||
switch (locking & 0x7) {
|
||||
case 0:
|
||||
msg_cdbg("Full Access.\n");
|
||||
break;
|
||||
case 1:
|
||||
msg_cdbg("Write Lock (Default State).\n");
|
||||
break;
|
||||
case 2:
|
||||
msg_cdbg("Locked Open (Full Access, Lock Down).\n");
|
||||
break;
|
||||
case 3:
|
||||
msg_cerr("Error: Write Lock, Locked Down.\n");
|
||||
break;
|
||||
case 4:
|
||||
msg_cdbg("Read Lock.\n");
|
||||
break;
|
||||
case 5:
|
||||
msg_cdbg("Read/Write Lock.\n");
|
||||
break;
|
||||
case 6:
|
||||
msg_cerr("Error: Read Lock, Locked Down.\n");
|
||||
break;
|
||||
case 7:
|
||||
msg_cerr("Error: Read/Write Lock, Locked Down.\n");
|
||||
break;
|
||||
}
|
||||
|
||||
/* Read or write lock present? */
|
||||
return (locking & ((1 << 2) | (1 << 0))) ? -1 : 0;
|
||||
}
|
||||
|
||||
static int unlock_w39_fwh_block(struct flashctx *flash, unsigned int offset)
|
||||
{
|
||||
chipaddr wrprotect = flash->virtual_registers + offset + 2;
|
||||
uint8_t locking;
|
||||
|
||||
locking = chip_readb(flash, wrprotect);
|
||||
/* Read or write lock present? */
|
||||
if (locking & ((1 << 2) | (1 << 0))) {
|
||||
/* Lockdown active? */
|
||||
if (locking & (1 << 1)) {
|
||||
msg_cerr("Can't unlock block at 0x%08x!\n", offset);
|
||||
return -1;
|
||||
} else {
|
||||
msg_cdbg("Unlocking block at 0x%08x\n", offset);
|
||||
chip_writeb(flash, 0, wrprotect);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
#include "chipdrivers.h"
|
||||
|
||||
static uint8_t w39_idmode_readb(struct flashctx *flash, unsigned int offset)
|
||||
{
|
||||
@ -145,30 +87,6 @@ static int printlock_w39_common(struct flashctx *flash, unsigned int offset)
|
||||
return printlock_w39_tblwp(lock);
|
||||
}
|
||||
|
||||
static int printlock_w39_fwh(struct flashctx *flash)
|
||||
{
|
||||
unsigned int i, total_size = flash->chip->total_size * 1024;
|
||||
int ret = 0;
|
||||
|
||||
/* Print lock status of the complete chip */
|
||||
for (i = 0; i < total_size; i += flash->chip->page_size)
|
||||
ret |= printlock_w39_fwh_block(flash, i);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int unlock_w39_fwh(struct flashctx *flash)
|
||||
{
|
||||
unsigned int i, total_size = flash->chip->total_size * 1024;
|
||||
|
||||
/* Unlock the complete chip */
|
||||
for (i = 0; i < total_size; i += flash->chip->page_size)
|
||||
if (unlock_w39_fwh_block(flash, i))
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int printlock_w39f010(struct flashctx *flash)
|
||||
{
|
||||
uint8_t lock;
|
||||
@ -267,7 +185,7 @@ int printlock_w39v040fa(struct flashctx *flash)
|
||||
int ret = 0;
|
||||
|
||||
ret = printlock_w39v040a(flash);
|
||||
ret |= printlock_w39_fwh(flash);
|
||||
ret |= printlock_regspace2_uniform_64k(flash);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -277,7 +195,7 @@ int printlock_w39v040fb(struct flashctx *flash)
|
||||
int ret = 0;
|
||||
|
||||
ret = printlock_w39v040b(flash);
|
||||
ret |= printlock_w39_fwh(flash);
|
||||
ret |= printlock_regspace2_uniform_64k(flash);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -288,7 +206,7 @@ int printlock_w39v040fc(struct flashctx *flash)
|
||||
|
||||
/* W39V040C and W39V040FC use different WP/TBL offsets. */
|
||||
ret = printlock_w39_common(flash, 0x7fff2);
|
||||
ret |= printlock_w39_fwh(flash);
|
||||
ret |= printlock_regspace2_uniform_64k(flash);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -303,7 +221,7 @@ int printlock_w39v080fa(struct flashctx *flash)
|
||||
int ret = 0;
|
||||
|
||||
ret = printlock_w39v080a(flash);
|
||||
ret |= printlock_w39_fwh(flash);
|
||||
ret |= printlock_regspace2_uniform_64k(flash);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -316,26 +234,6 @@ int printlock_w39v080fa_dual(struct flashctx *flash)
|
||||
return -1;
|
||||
}
|
||||
|
||||
int unlock_w39v040fb(struct flashctx *flash)
|
||||
{
|
||||
if (unlock_w39_fwh(flash))
|
||||
return -1;
|
||||
if (printlock_w39_common(flash, 0x7fff2))
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int unlock_w39v080fa(struct flashctx *flash)
|
||||
{
|
||||
if (unlock_w39_fwh(flash))
|
||||
return -1;
|
||||
if (printlock_w39_common(flash, 0xffff2))
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int printlock_at49f(struct flashctx *flash)
|
||||
{
|
||||
uint8_t lock = w39_idmode_readb(flash, 0x00002);
|
||||
|
Reference in New Issue
Block a user