summaryrefslogtreecommitdiffstats
path: root/sst_fwhub.c
diff options
context:
space:
mode:
authorSean Nelson <audiohacked@gmail.com>2010-03-16 03:09:10 +0000
committerSean Nelson <audiohacked@gmail.com>2010-03-16 03:09:10 +0000
commitccf7a2a231a213fe987a675ca6869456dbbd37da (patch)
treed9264e9d63564e55fcaa38d819e69d6ae3715087 /sst_fwhub.c
parentb3289c904c0242333d1283e85d88e61ee2d3e923 (diff)
downloadast2050-flashrom-ccf7a2a231a213fe987a675ca6869456dbbd37da.zip
ast2050-flashrom-ccf7a2a231a213fe987a675ca6869456dbbd37da.tar.gz
Further cleanup after JEDEC refactorings
Convert _sst_fwhub functions to jedec. Corresponding to flashrom svn r943. kill unused sst_fwhub.c functions make unlock_* check if unlock was successful and only return 0 when fully successful Signed-off-by: Sean Nelson <audiohacked@gmail.com> Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Diffstat (limited to 'sst_fwhub.c')
-rw-r--r--sst_fwhub.c103
1 files changed, 9 insertions, 94 deletions
diff --git a/sst_fwhub.c b/sst_fwhub.c
index a325278..328d39a 100644
--- a/sst_fwhub.c
+++ b/sst_fwhub.c
@@ -27,18 +27,6 @@
#include "flash.h"
#include "chipdrivers.h"
-// I need that Berkeley bit-map printer
-void print_sst_fwhub_status(uint8_t status)
-{
- printf("%s", status & 0x80 ? "Ready:" : "Busy:");
- printf("%s", status & 0x40 ? "BE SUSPEND:" : "BE RUN/FINISH:");
- printf("%s", status & 0x20 ? "BE ERROR:" : "BE OK:");
- printf("%s", status & 0x10 ? "PROG ERR:" : "PROG OK:");
- printf("%s", status & 0x8 ? "VP ERR:" : "VPP OK:");
- printf("%s", status & 0x4 ? "PROG SUSPEND:" : "PROG RUN/FINISH:");
- printf("%s", status & 0x2 ? "WP|TBL#|WP#,ABORT:" : "UNLOCK:");
-}
-
int check_sst_fwhub_block_lock(struct flashchip *flash, int offset)
{
chipaddr registers = flash->virtual_registers;
@@ -93,91 +81,18 @@ int printlock_sst_fwhub(struct flashchip *flash)
return 0;
}
-int erase_sst_fwhub_block(struct flashchip *flash, unsigned int offset, unsigned int page_size)
-{
- uint8_t blockstatus = clear_sst_fwhub_block_lock(flash, offset);
-
- if (blockstatus) {
- printf("Block lock clearing failed, not erasing block "
- "at 0x%06x\n", offset);
- return 1;
- }
-
- if (erase_block_jedec(flash, offset, page_size)) {
- fprintf(stderr, "ERASE FAILED!\n");
- return -1;
- }
- toggle_ready_jedec(flash->virtual_memory);
-
- return 0;
-}
-
-int erase_sst_fwhub_sector(struct flashchip *flash, unsigned int offset, unsigned int page_size)
-{
- uint8_t blockstatus = clear_sst_fwhub_block_lock(flash, offset);
-
- if (blockstatus) {
- printf("Sector lock clearing failed, not erasing sector "
- "at 0x%06x\n", offset);
- return 1;
- }
-
- if (erase_sector_jedec(flash, offset, page_size)) {
- fprintf(stderr, "ERASE FAILED!\n");
- return -1;
- }
- toggle_ready_jedec(flash->virtual_memory);
-
- return 0;
-}
-
-int erase_sst_fwhub(struct flashchip *flash)
+int unlock_sst_fwhub(struct flashchip *flash)
{
- int i;
- unsigned int total_size = flash->total_size * 1024;
+ int i, ret=0;
- for (i = 0; i < total_size; i += flash->page_size) {
- if (erase_sst_fwhub_block(flash, i, flash->page_size)) {
- fprintf(stderr, "ERASE FAILED!\n");
- return -1;
+ for (i = 0; i < flash->total_size * 1024; i += flash->page_size)
+ {
+ if (clear_sst_fwhub_block_lock(flash, i))
+ {
+ msg_cdbg("Warning: Unlock Failed for block 0x%06x\n", i);
+ ret++;
}
}
-
- return 0;
+ return ret;
}
-int write_sst_fwhub(struct flashchip *flash, uint8_t *buf)
-{
- int i, rc;
- int total_size = flash->total_size * 1024;
- int page_size = flash->page_size;
- chipaddr bios = flash->virtual_memory;
- uint8_t *readbuf = malloc(page_size);
-
- printf("Programming page: ");
- for (i = 0; i < total_size / page_size; i++) {
- printf("%04d at address: 0x%08x", i, i * page_size);
-
- /* Auto Skip Blocks, which already contain the desired data:
- * Faster, because we only write, what has changed
- * More secure, because blocks, which are excluded
- * (with the exclude or layout feature)
- * are not erased and rewritten; data is retained also
- * in sudden power off situations
- */
- flash->read(flash, readbuf, i * page_size, page_size);
- if (memcmp((void *)(buf + i * page_size),
- (void *)(readbuf), page_size)) {
- rc = erase_sst_fwhub_block(flash, i * page_size,
- page_size);
- if (rc)
- return 1;
- write_sector_jedec_common(flash, buf + i * page_size,
- bios + i * page_size, page_size, 0xffff);
- }
- printf("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b");
- }
- printf("\n");
-
- return 0;
-}
OpenPOWER on IntegriCloud