Add serprog_map so that chips are addressed properly. I did this for adding LPC support to my ATmega644 programmer.
Signed-off-by: Urja Rannikko urjaman@gmail.com
----- This is a re-submit because the old patch from 2011 had gotten bit-rotten (didnt apply cleanly).
--- flashrom.c | 2 +- programmer.h | 1 + serprog.c | 13 +++++++++++++ 3 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/flashrom.c b/flashrom.c index afab57c..8831e36 100644 --- a/flashrom.c +++ b/flashrom.c @@ -191,7 +191,7 @@ const struct programmer_entry programmer_table[] = { /* FIXME */ .devs.note = "All programmer devices speaking the serprog protocol\n", .init = serprog_init, - .map_flash_region = fallback_map, + .map_flash_region = serprog_map, .unmap_flash_region = fallback_unmap, .delay = serprog_delay, }, diff --git a/programmer.h b/programmer.h index ef96c9e..6bd49d9 100644 --- a/programmer.h +++ b/programmer.h @@ -654,6 +654,7 @@ int register_programmer(struct registered_programmer *pgm); /* serprog.c */ #if CONFIG_SERPROG == 1 int serprog_init(void); +void *serprog_map(const char *descr, uintptr_t phys_addr, size_t len); void serprog_delay(int usecs); #endif
diff --git a/serprog.c b/serprog.c index 237db7d..5b96e8a 100644 --- a/serprog.c +++ b/serprog.c @@ -671,6 +671,19 @@ int serprog_init(void) return 0; }
+void *serprog_map(const char *descr, uintptr_t phys_addr, size_t len) +{ + if ((phys_addr & 0xFF000000) == 0xFF000000) { + msg_pspew("Serprog map '%s' giving low 24 bits of phys_addr (0x%06X)\n", + descr,(unsigned int)(phys_addr & 0xFFFFFF)); + return (void*)(phys_addr & 0xFFFFFF); + } else { + msg_pdbg("Serprog-incompatible mapping '%s' phys_addr 0x%08X len %d, returning NULL\n", + descr,(unsigned int)phys_addr,len); + return NULL; + } +} + /* Move an in flashrom buffer existing write-n operation to the on-device operation buffer. */ static int sp_pass_writen(void) {