Patchwork serprog: add proper serprog_map

login
register
about
Submitter Urja Rannikko
Date 2011-11-18 16:46:57
Message ID <CAPCnQJmeQJgkLD8KuM-9Hox0zJyhjLws=Jw7NjeHBTJ6YKco_Q@mail.gmail.com>
Download mbox | patch
Permalink /patch/3465/
State Superseded
Headers show

Comments

Urja Rannikko - 2011-11-18 16:46:57
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>

-----
That previous one was clearly too verbose, noticed it when I ran this
without any -V. I put those messages down one level of verbosity.

Patch

Index: flashrom.c
===================================================================
--- flashrom.c	(revision 1468)
+++ flashrom.c	(working copy)
@@ -168,7 +168,7 @@ 
 	{
 		.name			= "serprog",
 		.init			= serprog_init,
-		.map_flash_region	= fallback_map,
+		.map_flash_region	= serprog_map,
 		.unmap_flash_region	= fallback_unmap,
 		.delay			= serprog_delay,
 	},
Index: programmer.h
===================================================================
--- programmer.h	(revision 1468)
+++ programmer.h	(working copy)
@@ -635,6 +635,7 @@ 
 /* serprog.c */
 #if CONFIG_SERPROG == 1
 int serprog_init(void);
+void *serprog_map(const char *descr, unsigned long phys_addr, size_t len);
 void serprog_chip_writeb(uint8_t val, chipaddr addr);
 uint8_t serprog_chip_readb(const chipaddr addr);
 void serprog_chip_readn(uint8_t *buf, const chipaddr addr, size_t len);
Index: serprog.c
===================================================================
--- serprog.c	(revision 1468)
+++ serprog.c	(working copy)
@@ -601,6 +601,18 @@ 
 	return 0;
 }
 
+void *serprog_map(const char *descr, unsigned long 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,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,phys_addr,len);
+		return NULL;
+	}
+}
+
+
 /* Move an in flashrom buffer existing write-n operation to	*
  * the on-device operation buffer.				*/
 static void sp_pass_writen(void)