Add external programmer delay functions so external programmers can handle the delay on their own if needed.
Signed-off-by: Carl-Daniel Hailfinger c-d.hailfinger.devel.2006@gmx.net
Index: flashrom-programmer_delay/flash.h =================================================================== --- flashrom-programmer_delay/flash.h (Revision 576) +++ flashrom-programmer_delay/flash.h (Arbeitskopie) @@ -103,6 +103,8 @@ uint8_t (*chip_readb) (const chipaddr addr); uint16_t (*chip_readw) (const chipaddr addr); uint32_t (*chip_readl) (const chipaddr addr); + + void (*delay) (int usecs); };
extern const struct programmer_entry programmer_table[]; @@ -118,6 +120,7 @@ uint8_t chip_readb(const chipaddr addr); uint16_t chip_readw(const chipaddr addr); uint32_t chip_readl(const chipaddr addr); +void programmer_delay(uint32_t usecs);
#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
@@ -590,7 +593,7 @@ #define W_49V002FA 0x32
/* udelay.c */ -void myusec_delay(int time); +void myusec_delay(int usecs); void myusec_calibrate_delay(void);
/* pcidev.c */ @@ -652,6 +655,7 @@ uint8_t mmio_readb(void *addr); uint16_t mmio_readw(void *addr); uint32_t mmio_readl(void *addr); +void internal_delay(int usecs); void *fallback_map(const char *descr, unsigned long phys_addr, size_t len); void fallback_unmap(void *virt_addr, size_t len); void fallback_chip_writew(uint16_t val, chipaddr addr); Index: flashrom-programmer_delay/en29f002a.c =================================================================== --- flashrom-programmer_delay/en29f002a.c (Revision 576) +++ flashrom-programmer_delay/en29f002a.c (Arbeitskopie) @@ -37,7 +37,7 @@ chip_writeb(0x55, bios + 0x2AA); chip_writeb(0x90, bios + 0x555);
- myusec_delay(10); + programmer_delay(10);
id1 = chip_readb(bios + 0x100); id2 = chip_readb(bios + 0x101); @@ -70,7 +70,7 @@ chip_writeb(0x55, bios + 0xAAA); chip_writeb(0x90, bios + 0x555);
- myusec_delay(10); + programmer_delay(10);
id1 = chip_readb(bios + 0x100); id2 = chip_readb(bios + 0x101); @@ -97,7 +97,7 @@ chipaddr dst = bios;
//chip_writeb(0xF0, bios); - myusec_delay(10); + programmer_delay(10); erase_chip_jedec(flash);
printf("Programming page: "); Index: flashrom-programmer_delay/it87spi.c =================================================================== --- flashrom-programmer_delay/it87spi.c (Revision 576) +++ flashrom-programmer_delay/it87spi.c (Arbeitskopie) @@ -220,7 +220,7 @@ * This usually takes 1-10 ms, so wait in 1 ms steps. */ while (spi_read_status_register() & JEDEC_RDSR_BIT_WIP) - usleep(1000); + programmer_delay(1000); return 0; }
@@ -245,7 +245,7 @@ return result; spi_byte_program(i, buf[i]); while (spi_read_status_register() & JEDEC_RDSR_BIT_WIP) - myusec_delay(10); + programmer_delay(10); } /* resume normal ops... */ OUTB(0x20, it8716f_flashport); Index: flashrom-programmer_delay/jedec.c =================================================================== --- flashrom-programmer_delay/jedec.c (Revision 576) +++ flashrom-programmer_delay/jedec.c (Arbeitskopie) @@ -73,7 +73,7 @@ chip_writeb(0x55, bios + 0x2AAA); chip_writeb(0x20, bios + 0x5555);
- usleep(200); + programmer_delay(200); }
void protect_jedec(chipaddr bios) @@ -82,7 +82,7 @@ chip_writeb(0x55, bios + 0x2AAA); chip_writeb(0xA0, bios + 0x5555);
- usleep(200); + programmer_delay(200); }
int probe_jedec(struct flashchip *flash) @@ -110,14 +110,14 @@
/* Issue JEDEC Product ID Entry command */ chip_writeb(0xAA, bios + 0x5555); - myusec_delay(10); + programmer_delay(10); chip_writeb(0x55, bios + 0x2AAA); - myusec_delay(10); + programmer_delay(10); chip_writeb(0x90, bios + 0x5555); /* Older chips may need up to 100 us to respond. The ATMEL 29C020 * needs 10 ms according to the data sheet. */ - myusec_delay(probe_timing_enter); + programmer_delay(probe_timing_enter);
/* Read product ID */ id1 = chip_readb(bios); @@ -139,11 +139,11 @@
/* Issue JEDEC Product ID Exit command */ chip_writeb(0xAA, bios + 0x5555); - myusec_delay(10); + programmer_delay(10); chip_writeb(0x55, bios + 0x2AAA); - myusec_delay(10); + programmer_delay(10); chip_writeb(0xF0, bios + 0x5555); - myusec_delay(probe_timing_exit); + programmer_delay(probe_timing_exit);
printf_debug("%s: id1 0x%02x, id2 0x%02x", __FUNCTION__, largeid1, largeid2); if (!oddparity(id1)) @@ -179,18 +179,18 @@ { /* Issue the Sector Erase command */ chip_writeb(0xAA, bios + 0x5555); - myusec_delay(10); + programmer_delay(10); chip_writeb(0x55, bios + 0x2AAA); - myusec_delay(10); + programmer_delay(10); chip_writeb(0x80, bios + 0x5555); - myusec_delay(10); + programmer_delay(10);
chip_writeb(0xAA, bios + 0x5555); - myusec_delay(10); + programmer_delay(10); chip_writeb(0x55, bios + 0x2AAA); - myusec_delay(10); + programmer_delay(10); chip_writeb(0x30, bios + page); - myusec_delay(10); + programmer_delay(10);
/* wait for Toggle bit ready */ toggle_ready_jedec(bios); @@ -202,18 +202,18 @@ { /* Issue the Sector Erase command */ chip_writeb(0xAA, bios + 0x5555); - myusec_delay(10); + programmer_delay(10); chip_writeb(0x55, bios + 0x2AAA); - myusec_delay(10); + programmer_delay(10); chip_writeb(0x80, bios + 0x5555); - myusec_delay(10); + programmer_delay(10);
chip_writeb(0xAA, bios + 0x5555); - myusec_delay(10); + programmer_delay(10); chip_writeb(0x55, bios + 0x2AAA); - myusec_delay(10); + programmer_delay(10); chip_writeb(0x50, bios + block); - myusec_delay(10); + programmer_delay(10);
/* wait for Toggle bit ready */ toggle_ready_jedec(bios); @@ -227,18 +227,18 @@
/* Issue the JEDEC Chip Erase command */ chip_writeb(0xAA, bios + 0x5555); - myusec_delay(10); + programmer_delay(10); chip_writeb(0x55, bios + 0x2AAA); - myusec_delay(10); + programmer_delay(10); chip_writeb(0x80, bios + 0x5555); - myusec_delay(10); + programmer_delay(10);
chip_writeb(0xAA, bios + 0x5555); - myusec_delay(10); + programmer_delay(10); chip_writeb(0x55, bios + 0x2AAA); - myusec_delay(10); + programmer_delay(10); chip_writeb(0x10, bios + 0x5555); - myusec_delay(10); + programmer_delay(10);
toggle_ready_jedec(bios);
Index: flashrom-programmer_delay/w29ee011.c =================================================================== --- flashrom-programmer_delay/w29ee011.c (Revision 576) +++ flashrom-programmer_delay/w29ee011.c (Arbeitskopie) @@ -38,17 +38,17 @@
/* Issue JEDEC Product ID Entry command */ chip_writeb(0xAA, bios + 0x5555); - myusec_delay(10); + programmer_delay(10); chip_writeb(0x55, bios + 0x2AAA); - myusec_delay(10); + programmer_delay(10); chip_writeb(0x80, bios + 0x5555); - myusec_delay(10); + programmer_delay(10); chip_writeb(0xAA, bios + 0x5555); - myusec_delay(10); + programmer_delay(10); chip_writeb(0x55, bios + 0x2AAA); - myusec_delay(10); + programmer_delay(10); chip_writeb(0x60, bios + 0x5555); - myusec_delay(10); + programmer_delay(10);
/* Read product ID */ id1 = chip_readb(bios); @@ -56,11 +56,11 @@
/* Issue JEDEC Product ID Exit command */ chip_writeb(0xAA, bios + 0x5555); - myusec_delay(10); + programmer_delay(10); chip_writeb(0x55, bios + 0x2AAA); - myusec_delay(10); + programmer_delay(10); chip_writeb(0xF0, bios + 0x5555); - myusec_delay(10); + programmer_delay(10);
printf_debug("%s: id1 0x%02x, id2 0x%02x\n", __FUNCTION__, id1, id2);
Index: flashrom-programmer_delay/sharplhf00l04.c =================================================================== --- flashrom-programmer_delay/sharplhf00l04.c (Revision 576) +++ flashrom-programmer_delay/sharplhf00l04.c (Arbeitskopie) @@ -46,9 +46,9 @@ #endif
chip_writeb(0xff, bios); - myusec_delay(10); + programmer_delay(10); chip_writeb(0x90, bios); - myusec_delay(10); + programmer_delay(10);
id1 = chip_readb(bios); id2 = chip_readb(bios + 0x01); @@ -58,7 +58,7 @@ chip_writeb(0x55, bios + 0x2AAA); chip_writeb(0xF0, bios + 0x5555);
- myusec_delay(10); + programmer_delay(10);
printf_debug("%s: id1 0x%02x, id2 0x%02x\n", __FUNCTION__, id1, id2);
@@ -85,7 +85,7 @@ // put another command to get out of status register mode
chip_writeb(0x90, bios); - myusec_delay(10); + programmer_delay(10);
id1 = chip_readb(bios); id2 = chip_readb(bios + 0x01); @@ -118,7 +118,7 @@ // now start it chip_writeb(0x20, bios); chip_writeb(0xd0, bios); - myusec_delay(10); + programmer_delay(10); // now let's see what the register is status = wait_lhf00l04(flash->virtual_memory); print_lhf00l04_status(status); Index: flashrom-programmer_delay/spi.c =================================================================== --- flashrom-programmer_delay/spi.c (Revision 576) +++ flashrom-programmer_delay/spi.c (Arbeitskopie) @@ -425,7 +425,7 @@ */ /* FIXME: We assume spi_read_status_register will never fail. */ while (spi_read_status_register() & JEDEC_RDSR_BIT_WIP) - sleep(1); + programmer_delay(1000000); return 0; }
@@ -453,7 +453,7 @@ */ /* FIXME: We assume spi_read_status_register will never fail. */ while (spi_read_status_register() & JEDEC_RDSR_BIT_WIP) - sleep(1); + programmer_delay(1000000); return 0; }
@@ -485,7 +485,7 @@ * This usually takes 100-4000 ms, so wait in 100 ms steps. */ while (spi_read_status_register() & JEDEC_RDSR_BIT_WIP) - usleep(100 * 1000); + programmer_delay(100 * 1000); return 0; }
@@ -511,7 +511,7 @@ * This usually takes 100-4000 ms, so wait in 100 ms steps. */ while (spi_read_status_register() & JEDEC_RDSR_BIT_WIP) - usleep(100 * 1000); + programmer_delay(100 * 1000); return 0; }
@@ -557,7 +557,7 @@ * This usually takes 15-800 ms, so wait in 10 ms steps. */ while (spi_read_status_register() & JEDEC_RDSR_BIT_WIP) - usleep(10 * 1000); + programmer_delay(10 * 1000); return 0; }
@@ -690,7 +690,7 @@ spi_write_enable(); spi_byte_program(i, buf[i]); while (spi_read_status_register() & JEDEC_RDSR_BIT_WIP) - myusec_delay(10); + programmer_delay(10); }
return 0; @@ -748,13 +748,13 @@ return result; spi_command(6, 0, w, NULL); while (spi_read_status_register() & JEDEC_RDSR_BIT_WIP) - myusec_delay(5); /* SST25VF040B Tbp is max 10us */ + programmer_delay(5); /* SST25VF040B Tbp is max 10us */ while (pos < size) { w[1] = buf[pos++]; w[2] = buf[pos++]; spi_command(3, 0, w, NULL); while (spi_read_status_register() & JEDEC_RDSR_BIT_WIP) - myusec_delay(5); /* SST25VF040B Tbp is max 10us */ + programmer_delay(5); /* SST25VF040B Tbp is max 10us */ } spi_write_disable(); return 0; Index: flashrom-programmer_delay/wbsio_spi.c =================================================================== --- flashrom-programmer_delay/wbsio_spi.c (Revision 576) +++ flashrom-programmer_delay/wbsio_spi.c (Arbeitskopie) @@ -159,7 +159,7 @@
OUTB(writearr[0], wbsio_spibase); OUTB(mode, wbsio_spibase + 1); - myusec_delay(10); + programmer_delay(10);
if (!readcnt) return 0; @@ -203,7 +203,7 @@ for (pos = 0; pos < size; pos++) { spi_byte_program(pos, buf[pos]); while (spi_read_status_register() & JEDEC_RDSR_BIT_WIP) - myusec_delay(10); + programmer_delay(10); } spi_write_disable(); return 0; Index: flashrom-programmer_delay/m29f002.c =================================================================== --- flashrom-programmer_delay/m29f002.c (Revision 576) +++ flashrom-programmer_delay/m29f002.c (Arbeitskopie) @@ -29,7 +29,7 @@ chip_writeb(0xaa, bios + 0x555); chip_writeb(0x55, bios + 0xaaa); chip_writeb(0x10, bios + 0x555); - myusec_delay(10); + programmer_delay(10); toggle_ready_jedec(bios); return 0; } @@ -44,7 +44,7 @@ chip_writeb(0xaa, bios + 0x555); chip_writeb(0x55, bios + 0xaaa); chip_writeb(0x30, dst); - myusec_delay(10); + programmer_delay(10); toggle_ready_jedec(bios);
/* program */ Index: flashrom-programmer_delay/w39v040c.c =================================================================== --- flashrom-programmer_delay/w39v040c.c (Revision 576) +++ flashrom-programmer_delay/w39v040c.c (Arbeitskopie) @@ -26,22 +26,22 @@ uint8_t id1, id2, lock;
chip_writeb(0xAA, bios + 0x5555); - myusec_delay(10); + programmer_delay(10); chip_writeb(0x55, bios + 0x2AAA); - myusec_delay(10); + programmer_delay(10); chip_writeb(0x90, bios + 0x5555); - myusec_delay(10); + programmer_delay(10);
id1 = chip_readb(bios); id2 = chip_readb(bios + 1); lock = chip_readb(bios + 0xfff2);
chip_writeb(0xAA, bios + 0x5555); - myusec_delay(10); + programmer_delay(10); chip_writeb(0x55, bios + 0x2AAA); - myusec_delay(10); + programmer_delay(10); chip_writeb(0xF0, bios + 0x5555); - myusec_delay(40); + programmer_delay(40);
printf_debug("%s: id1 0x%02x, id2 0x%02x", __func__, id1, id2); if (!oddparity(id1)) Index: flashrom-programmer_delay/sst28sf040.c =================================================================== --- flashrom-programmer_delay/sst28sf040.c (Revision 576) +++ flashrom-programmer_delay/sst28sf040.c (Arbeitskopie) @@ -94,16 +94,16 @@ uint8_t id1, id2;
chip_writeb(RESET, bios); - myusec_delay(10); + programmer_delay(10);
chip_writeb(READ_ID, bios); - myusec_delay(10); + programmer_delay(10); id1 = chip_readb(bios); - myusec_delay(10); + programmer_delay(10); id2 = chip_readb(bios + 0x01);
chip_writeb(RESET, bios); - myusec_delay(10); + programmer_delay(10);
printf_debug("%s: id1 0x%02x, id2 0x%02x\n", __FUNCTION__, id1, id2); if (id1 == flash->manufacture_id && id2 == flash->model_id) @@ -121,7 +121,7 @@ chip_writeb(CHIP_ERASE, bios); protect_28sf040(bios);
- myusec_delay(10); + programmer_delay(10); toggle_ready_jedec(bios);
return 0; Index: flashrom-programmer_delay/stm50flw0x0x.c =================================================================== --- flashrom-programmer_delay/stm50flw0x0x.c (Revision 576) +++ flashrom-programmer_delay/stm50flw0x0x.c (Arbeitskopie) @@ -35,7 +35,7 @@ chip_writeb(0x55, bios + 0x2AAA); chip_writeb(0xA0, bios + 0x5555);
- usleep(200); + programmer_delay(200); }
int probe_stm50flw0x0x(struct flashchip *flash) @@ -46,11 +46,11 @@
/* Issue JEDEC Product ID Entry command */ chip_writeb(0xAA, bios + 0x5555); - myusec_delay(10); + programmer_delay(10); chip_writeb(0x55, bios + 0x2AAA); - myusec_delay(10); + programmer_delay(10); chip_writeb(0x90, bios + 0x5555); - myusec_delay(40); + programmer_delay(40);
/* Read product ID */ id1 = chip_readb(bios); @@ -72,11 +72,11 @@
/* Issue JEDEC Product ID Exit command */ chip_writeb(0xAA, bios + 0x5555); - myusec_delay(10); + programmer_delay(10); chip_writeb(0x55, bios + 0x2AAA); - myusec_delay(10); + programmer_delay(10); chip_writeb(0xF0, bios + 0x5555); - myusec_delay(40); + programmer_delay(40);
printf_debug("%s: id1 0x%02x, id2 0x%02x\n", __FUNCTION__, largeid1, largeid2); @@ -101,7 +101,7 @@ // put another command to get out of status register mode
chip_writeb(0x90, bios); - myusec_delay(10); + programmer_delay(10);
id1 = chip_readb(bios);
@@ -170,7 +170,7 @@ // now start it chip_writeb(0x20, bios); chip_writeb(0xd0, bios); - myusec_delay(10); + programmer_delay(10);
wait_stm50flw0x0x(flash->virtual_memory);
Index: flashrom-programmer_delay/am29f040b.c =================================================================== --- flashrom-programmer_delay/am29f040b.c (Revision 576) +++ flashrom-programmer_delay/am29f040b.c (Arbeitskopie) @@ -29,7 +29,7 @@ chip_writeb(0x55, bios + 0x2AA); chip_writeb(0x30, bios + address);
- sleep(2); + programmer_delay(1000000 * 2);
/* wait for Toggle bit ready */ toggle_ready_jedec(bios + address); @@ -75,7 +75,7 @@
chip_writeb(0xF0, bios);
- myusec_delay(10); + programmer_delay(10);
printf_debug("%s: id1 0x%02x, id2 0x%02x\n", __FUNCTION__, id1, id2); if (id1 == flash->manufacture_id && id2 == flash->model_id) @@ -95,7 +95,7 @@ chip_writeb(0x55, bios + 0x2AA); chip_writeb(0x10, bios + 0x555);
- myusec_delay(10); + programmer_delay(10); toggle_ready_jedec(bios);
return 0; Index: flashrom-programmer_delay/w39v080fa.c =================================================================== --- flashrom-programmer_delay/w39v080fa.c (Revision 576) +++ flashrom-programmer_delay/w39v080fa.c (Arbeitskopie) @@ -29,7 +29,7 @@ chip_writeb(0xAA, bios + 0x5555); chip_writeb(0x55, bios + 0x2AAA); chip_writeb(0x90, bios + 0x5555); - myusec_delay(10); + programmer_delay(10);
/* Read product ID */ id1 = chip_readb(bios); @@ -39,7 +39,7 @@ chip_writeb(0xAA, bios + 0x5555); chip_writeb(0x55, bios + 0x2AAA); chip_writeb(0xF0, bios + 0x5555); - myusec_delay(10); + programmer_delay(10);
printf_debug("%s: id1 0x%x, id2 0x%x\n", __FUNCTION__, id1, id2);
@@ -108,7 +108,7 @@ chip_writeb(0xAA, bios + 0x5555); chip_writeb(0x55, bios + 0x2AAA); chip_writeb(0x90, bios + 0x5555); - myusec_delay(10); + programmer_delay(10);
/* Read Hardware Lock Bits */ locking = chip_readb(bios + 0xffff2); @@ -117,7 +117,7 @@ chip_writeb(0xAA, bios + 0x5555); chip_writeb(0x55, bios + 0x2AAA); chip_writeb(0xF0, bios + 0x5555); - myusec_delay(10); + programmer_delay(10);
printf_debug("Lockout bits:\n");
Index: flashrom-programmer_delay/flashrom.c =================================================================== --- flashrom-programmer_delay/flashrom.c (Revision 576) +++ flashrom-programmer_delay/flashrom.c (Arbeitskopie) @@ -46,6 +46,7 @@ .chip_writeb = internal_chip_writeb, .chip_writew = internal_chip_writew, .chip_writel = internal_chip_writel, + .delay = internal_delay, },
{ @@ -59,6 +60,7 @@ .chip_writeb = dummy_chip_writeb, .chip_writew = dummy_chip_writew, .chip_writel = dummy_chip_writel, + .delay = internal_delay, },
{ @@ -72,6 +74,7 @@ .chip_writeb = nic3com_chip_writeb, .chip_writew = fallback_chip_writew, .chip_writel = fallback_chip_writel, + .delay = internal_delay, },
{ @@ -85,6 +88,7 @@ .chip_writeb = satasii_chip_writeb, .chip_writew = fallback_chip_writew, .chip_writel = fallback_chip_writel, + .delay = internal_delay, },
{ @@ -98,6 +102,7 @@ .chip_writeb = dummy_chip_writeb, .chip_writew = dummy_chip_writew, .chip_writel = dummy_chip_writel, + .delay = internal_delay, },
{}, @@ -155,6 +160,11 @@ return programmer_table[programmer].chip_readl(addr); }
+void programmer_delay(uint32_t usecs) +{ + programmer_table[programmer].delay(usecs); +} + void map_flash_registers(struct flashchip *flash) { size_t size = flash->total_size * 1024; Index: flashrom-programmer_delay/internal.c =================================================================== --- flashrom-programmer_delay/internal.c (Revision 576) +++ flashrom-programmer_delay/internal.c (Arbeitskopie) @@ -195,6 +195,18 @@ return *(volatile uint32_t *) addr; }
+void internal_delay(int usecs) +{ + /* If the delay is >1 s, use usleep because timing does not need to + * be so precise. + */ + if (usecs > 1000000) { + usleep(usecs); + } else { + myusec_delay(usecs); + } +} + /* Fallback map() for programmers which don't need special handling */ void *fallback_map(const char *descr, unsigned long phys_addr, size_t len) { Index: flashrom-programmer_delay/ichspi.c =================================================================== --- flashrom-programmer_delay/ichspi.c (Revision 576) +++ flashrom-programmer_delay/ichspi.c (Arbeitskopie) @@ -453,7 +453,7 @@ /* wait for cycle complete */ timeout = 100 * 1000 * 60; // 60s is a looong timeout. while (((REGREAD16(ICH7_REG_SPIS) & SPIS_CDS) == 0) && --timeout) { - myusec_delay(10); + programmer_delay(10); } if (!timeout) { printf_debug("timeout\n"); @@ -570,7 +570,7 @@ /*wait for cycle complete */ timeout = 100 * 1000 * 60; // 60s is a looong timeout. while (((REGREAD32(ICH9_REG_SSFS) & SSFS_CDS) == 0) && --timeout) { - myusec_delay(10); + programmer_delay(10); } if (!timeout) { printf_debug("timeout\n"); Index: flashrom-programmer_delay/udelay.c =================================================================== --- flashrom-programmer_delay/udelay.c (Revision 576) +++ flashrom-programmer_delay/udelay.c (Arbeitskopie) @@ -24,10 +24,10 @@ // count to a billion. Time it. If it's < 1 sec, count to 10B, etc. unsigned long micro = 1;
-void myusec_delay(int time) +void myusec_delay(int usecs) { volatile unsigned long i; - for (i = 0; i < time * micro; i++) ; + for (i = 0; i < usecs * micro; i++) ; }
void myusec_calibrate_delay(void) Index: flashrom-programmer_delay/82802ab.c =================================================================== --- flashrom-programmer_delay/82802ab.c (Revision 576) +++ flashrom-programmer_delay/82802ab.c (Arbeitskopie) @@ -53,9 +53,9 @@ #endif
chip_writeb(0xff, bios); - myusec_delay(10); + programmer_delay(10); chip_writeb(0x90, bios); - myusec_delay(10); + programmer_delay(10);
id1 = chip_readb(bios); id2 = chip_readb(bios + 0x01); @@ -65,7 +65,7 @@ chip_writeb(0x55, bios + 0x2AAA); chip_writeb(0xF0, bios + 0x5555);
- myusec_delay(10); + programmer_delay(10);
printf_debug("%s: id1 0x%02x, id2 0x%02x\n", __FUNCTION__, id1, id2);
@@ -92,7 +92,7 @@ // put another command to get out of status register mode
chip_writeb(0x90, bios); - myusec_delay(10); + programmer_delay(10);
id1 = chip_readb(bios); id2 = chip_readb(bios + 0x01); @@ -124,7 +124,7 @@ // now start it chip_writeb(0x20, bios); chip_writeb(0xd0, bios); - myusec_delay(10); + programmer_delay(10); // now let's see what the register is status = wait_82802ab(flash->virtual_memory); //print_82802ab_status(status); Index: flashrom-programmer_delay/mx29f002.c =================================================================== --- flashrom-programmer_delay/mx29f002.c (Revision 576) +++ flashrom-programmer_delay/mx29f002.c (Arbeitskopie) @@ -34,7 +34,7 @@
chip_writeb(0xF0, bios);
- myusec_delay(10); + programmer_delay(10);
printf_debug("%s: id1 0x%02x, id2 0x%02x\n", __FUNCTION__, id1, id2); if (id1 == flash->manufacture_id && id2 == flash->model_id) @@ -55,7 +55,7 @@ chip_writeb(0x55, bios + 0x2AA); chip_writeb(0x10, bios + 0x555);
- myusec_delay(100); + programmer_delay(100); toggle_ready_jedec(bios);
// while ((*bios & 0x40) != 0x40) @@ -82,7 +82,7 @@ chipaddr dst = bios;
chip_writeb(0xF0, bios); - myusec_delay(10); + programmer_delay(10); erase_29f002(flash); //*bios = 0xF0; #if 1 Index: flashrom-programmer_delay/m29f400bt.c =================================================================== --- flashrom-programmer_delay/m29f400bt.c (Revision 576) +++ flashrom-programmer_delay/m29f400bt.c (Arbeitskopie) @@ -26,7 +26,7 @@ chip_writeb(0x55, bios + 0x555); chip_writeb(0xA0, bios + 0xAAA);
- usleep(200); + programmer_delay(200); }
void write_page_m29f400bt(chipaddr bios, uint8_t *src, @@ -42,7 +42,7 @@ /* transfer data from source to destination */ chip_writeb(*src, dst); //chip_writeb(0xF0, bios); - //usleep(5); + //programmer_delay(5); toggle_ready_jedec(dst); printf ("Value in the flash at address 0x%lx = %#x, want %#x\n", @@ -61,7 +61,7 @@ chip_writeb(0x55, bios + 0x555); chip_writeb(0x90, bios + 0xAAA);
- myusec_delay(10); + programmer_delay(10);
id1 = chip_readb(bios); /* The data sheet says id2 is at (bios + 0x01) and id2 listed in @@ -73,7 +73,7 @@ chip_writeb(0x55, bios + 0x555); chip_writeb(0xF0, bios + 0xAAA);
- myusec_delay(10); + programmer_delay(10);
printf_debug("%s: id1 0x%02x, id2 0x%02x\n", __FUNCTION__, id1, id2);
@@ -95,7 +95,7 @@ chip_writeb(0x55, bios + 0x555); chip_writeb(0x10, bios + 0xAAA);
- myusec_delay(10); + programmer_delay(10); toggle_ready_jedec(bios);
return 0; @@ -113,7 +113,7 @@ //chip_writeb(0x10, bios + 0xAAA); chip_writeb(0x30, dst);
- myusec_delay(10); + programmer_delay(10); toggle_ready_jedec(bios);
return 0;
On Fri, Jun 05, 2009 at 06:28:41PM +0200, Carl-Daniel Hailfinger wrote:
Add external programmer delay functions so external programmers can handle the delay on their own if needed.
Signed-off-by: Carl-Daniel Hailfinger c-d.hailfinger.devel.2006@gmx.net
Acked-by: Uwe Hermann uwe@hermann-uwe.de
...but see below.
Index: flashrom-programmer_delay/flash.h
--- flashrom-programmer_delay/flash.h (Revision 576) +++ flashrom-programmer_delay/flash.h (Arbeitskopie) @@ -103,6 +103,8 @@ uint8_t (*chip_readb) (const chipaddr addr); uint16_t (*chip_readw) (const chipaddr addr); uint32_t (*chip_readl) (const chipaddr addr);
- void (*delay) (int usecs);
};
extern const struct programmer_entry programmer_table[]; @@ -118,6 +120,7 @@ uint8_t chip_readb(const chipaddr addr); uint16_t chip_readw(const chipaddr addr); uint32_t chip_readl(const chipaddr addr); +void programmer_delay(uint32_t usecs);
Why uint32_t here and int above?
Index: flashrom-programmer_delay/spi.c
--- flashrom-programmer_delay/spi.c (Revision 576) +++ flashrom-programmer_delay/spi.c (Arbeitskopie) @@ -425,7 +425,7 @@ */ /* FIXME: We assume spi_read_status_register will never fail. */ while (spi_read_status_register() & JEDEC_RDSR_BIT_WIP)
sleep(1);
programmer_delay(1000000);
I'd also make this 100 * 1000 as below, easier on the eyes.
return 0; }
@@ -453,7 +453,7 @@ */ /* FIXME: We assume spi_read_status_register will never fail. */ while (spi_read_status_register() & JEDEC_RDSR_BIT_WIP)
sleep(1);
programmer_delay(1000000);
Ditto.
return 0; }
@@ -485,7 +485,7 @@ * This usually takes 100-4000 ms, so wait in 100 ms steps. */ while (spi_read_status_register() & JEDEC_RDSR_BIT_WIP)
usleep(100 * 1000);
return 0;programmer_delay(100 * 1000);
}
Index: flashrom-programmer_delay/am29f040b.c
--- flashrom-programmer_delay/am29f040b.c (Revision 576) +++ flashrom-programmer_delay/am29f040b.c (Arbeitskopie) @@ -29,7 +29,7 @@ chip_writeb(0x55, bios + 0x2AA); chip_writeb(0x30, bios + address);
- sleep(2);
- programmer_delay(1000000 * 2);
Maybe 2 * 1000 * 1000, same format as above.
Index: flashrom-programmer_delay/internal.c
--- flashrom-programmer_delay/internal.c (Revision 576) +++ flashrom-programmer_delay/internal.c (Arbeitskopie) @@ -195,6 +195,18 @@ return *(volatile uint32_t *) addr; }
+void internal_delay(int usecs) +{
- /* If the delay is >1 s, use usleep because timing does not need to
* be so precise.
Hm, but why not use myusec_delay() always? Does it have drawbacks?
*/
- if (usecs > 1000000) {
usleep(usecs);
- } else {
myusec_delay(usecs);
- }
+}
Uwe.
On Fri, Jun 5, 2009 at 20:23, Uwe Hermann uwe@hermann-uwe.de wrote:
On Fri, Jun 05, 2009 at 06:28:41PM +0200, Carl-Daniel Hailfinger wrote:
Add external programmer delay functions so external programmers can handle the delay on their own if needed.
Signed-off-by: Carl-Daniel Hailfinger c-d.hailfinger.devel.2006@gmx.net
Acked-by: Uwe Hermann uwe@hermann-uwe.de
Also Acked-by: Urja Rannikko <urjaman@gmail.com
Hm, but why not use myusec_delay() always? Does it have drawbacks?
Maybe the 100% CPU usage....
On 05.06.2009 19:23, Uwe Hermann wrote:
On Fri, Jun 05, 2009 at 06:28:41PM +0200, Carl-Daniel Hailfinger wrote:
Add external programmer delay functions so external programmers can handle the delay on their own if needed.
Signed-off-by: Carl-Daniel Hailfinger c-d.hailfinger.devel.2006@gmx.net
Acked-by: Uwe Hermann uwe@hermann-uwe.de
...but see below.
Thanks for the review!
Index: flashrom-programmer_delay/flash.h
--- flashrom-programmer_delay/flash.h (Revision 576) +++ flashrom-programmer_delay/flash.h (Arbeitskopie) @@ -118,6 +120,7 @@ uint8_t chip_readb(const chipaddr addr); uint16_t chip_readw(const chipaddr addr); uint32_t chip_readl(const chipaddr addr); +void programmer_delay(uint32_t usecs);
Why uint32_t here and int above?
Leftover from an earlier version. Should be int.
Index: flashrom-programmer_delay/spi.c
--- flashrom-programmer_delay/spi.c (Revision 576) +++ flashrom-programmer_delay/spi.c (Arbeitskopie) @@ -425,7 +425,7 @@ */ /* FIXME: We assume spi_read_status_register will never fail. */ while (spi_read_status_register() & JEDEC_RDSR_BIT_WIP)
sleep(1);
programmer_delay(1000000);
I'd also make this 100 * 1000 as below, easier on the eyes.
1000 * 1000, sure.
Changed for all other calls as well.
Index: flashrom-programmer_delay/internal.c
--- flashrom-programmer_delay/internal.c (Revision 576) +++ flashrom-programmer_delay/internal.c (Arbeitskopie) @@ -195,6 +195,18 @@ return *(volatile uint32_t *) addr; }
+void internal_delay(int usecs) +{
- /* If the delay is >1 s, use usleep because timing does not need to
* be so precise.
Hm, but why not use myusec_delay() always? Does it have drawbacks?
Yes. myusec_delay is a busy-wait to get some precision. Hogging the CPU for more than 1 second is bad style.
Committed with your suggestions in r578.
Regards, Carl-Daniel