Nikolai Artemiev has uploaded this change for review.

View Change

sst49lfxxxc.c: add unlock function for SST chips

Function imported from cros flashrom at
`1f38d1ab13d72912fc2d90c7e964dd15e9ec2c9b`

Change-Id: I019bbb622b2348a05e7d03fbd0aa3bfac5f81175
Signed-off-by: Nikolai Artemiev <nartemiev@google.com>
---
M chipdrivers.h
M sst49lfxxxc.c
2 files changed, 38 insertions(+), 0 deletions(-)

git pull ssh://review.coreboot.org:29418/flashrom refs/changes/08/48108/1
diff --git a/chipdrivers.h b/chipdrivers.h
index cf03811..82ac3a2 100644
--- a/chipdrivers.h
+++ b/chipdrivers.h
@@ -165,6 +165,7 @@

/* sst49lfxxxc.c */
int erase_sector_49lfxxxc(struct flashctx *flash, unsigned int address, unsigned int sector_size);
+int unlock_49lfxxxc(struct flashctx *flash);

/* sst_fwhub.c */
int printlock_sst_fwhub(struct flashctx *flash);
diff --git a/sst49lfxxxc.c b/sst49lfxxxc.c
index a69ab75..9bb4d5d 100644
--- a/sst49lfxxxc.c
+++ b/sst49lfxxxc.c
@@ -18,6 +18,43 @@

#include "flash.h"
#include "chipdrivers.h"
+#include <inttypes.h>
+
+static int write_lockbits_block_49lfxxxc(struct flashctx *flash, unsigned long address, unsigned char bits)
+{
+ unsigned long lock = flash->virtual_registers + address + 2;
+ msg_cdbg("lockbits at address=0x%08lx is 0x%01x\n", lock, chip_readb(flash, lock));
+ chip_writeb(flash, bits, lock);
+
+ return 0;
+}
+
+static int write_lockbits_49lfxxxc(struct flashctx *flash, unsigned char bits)
+{
+ chipaddr registers = flash->virtual_registers;
+ unsigned int i, left = flash->chip->total_size * 1024;
+ unsigned long address;
+
+ msg_cdbg("\nbios=0x%08" PRIxPTR "\n", registers);
+ for (i = 0; left > 65536; i++, left -= 65536) {
+ write_lockbits_block_49lfxxxc(flash, i * 65536, bits);
+ }
+ address = i * 65536;
+ write_lockbits_block_49lfxxxc(flash, address, bits);
+ address += 32768;
+ write_lockbits_block_49lfxxxc(flash, address, bits);
+ address += 8192;
+ write_lockbits_block_49lfxxxc(flash, address, bits);
+ address += 8192;
+ write_lockbits_block_49lfxxxc(flash, address, bits);
+
+ return 0;
+}
+
+int unlock_49lfxxxc(struct flashctx *flash)
+{
+ return write_lockbits_49lfxxxc(flash, 0);
+}

int erase_sector_49lfxxxc(struct flashctx *flash, unsigned int address,
unsigned int sector_size)

To view, visit change 48108. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I019bbb622b2348a05e7d03fbd0aa3bfac5f81175
Gerrit-Change-Number: 48108
Gerrit-PatchSet: 1
Gerrit-Owner: Nikolai Artemiev <nartemiev@google.com>
Gerrit-MessageType: newchange