On 8/11/09 3:12 AM, Carl-Daniel Hailfinger wrote:
FT2232 and IT87 programmers used functions of the dummy programmer instead of fallback functions. The dummy programmer is a "real" programmer with possible side effects and its functions should not be abused by other programmers. Make FT2232 and IT87 use official fallback functions instead. Create fallback_shutdown(). Create fallback_chip_writeb(). Convert the programmer #defines to an enum.
Signed-off-by: Carl-Daniel Hailfinger c-d.hailfinger.devel.2006@gmx.net
We should drop the dummy programmer then... It's good for nothing
Acked-by: Stefan Reinauer stepan@coresystems.de
Index: flashrom-fallback/flash.h
--- flashrom-fallback/flash.h (Revision 674) +++ flashrom-fallback/flash.h (Arbeitskopie) @@ -80,15 +80,18 @@
typedef unsigned long chipaddr;
-extern int programmer; -#define PROGRAMMER_INTERNAL 0x00 -#define PROGRAMMER_DUMMY 0x01 -#define PROGRAMMER_NIC3COM 0x02 -#define PROGRAMMER_SATASII 0x03 -#define PROGRAMMER_IT87SPI 0x04 -#define PROGRAMMER_FT2232SPI 0x05 -#define PROGRAMMER_SERPROG 0x06 +enum programmer {
- PROGRAMMER_INTERNAL,
- PROGRAMMER_DUMMY,
- PROGRAMMER_NIC3COM,
- PROGRAMMER_SATASII,
- PROGRAMMER_IT87SPI,
- PROGRAMMER_FT2232SPI,
- PROGRAMMER_SERPROG,
+};
+extern enum programmer programmer;
struct programmer_entry { const char *vendor; const char *name; @@ -325,8 +328,10 @@ uint16_t mmio_readw(void *addr); uint32_t mmio_readl(void *addr); void internal_delay(int usecs); +int fallback_shutdown(void); 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_writeb(uint8_t val, chipaddr addr); void fallback_chip_writew(uint16_t val, chipaddr addr); void fallback_chip_writel(uint32_t val, chipaddr addr); void fallback_chip_writen(uint8_t *buf, chipaddr addr, size_t len); @@ -375,7 +380,6 @@ int ft2232_spi_init(void); int ft2232_spi_send_command(unsigned int writecnt, unsigned int readcnt, const unsigned char *writearr, unsigned char *readarr); int ft2232_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len); -int ft2232_spi_write1(struct flashchip *flash, uint8_t *buf); int ft2232_spi_write_256(struct flashchip *flash, uint8_t *buf);
/* flashrom.c */ Index: flashrom-fallback/flashrom.c =================================================================== --- flashrom-fallback/flashrom.c (Revision 674) +++ flashrom-fallback/flashrom.c (Arbeitskopie) @@ -33,7 +33,7 @@ const char *flashrom_version = FLASHROM_VERSION; char *chip_to_probe = NULL; int verbose = 0; -int programmer = PROGRAMMER_INTERNAL; +enum programmer programmer = PROGRAMMER_INTERNAL;
const struct programmer_entry programmer_table[] = { { @@ -102,14 +102,14 @@
{ .init = it87spi_init,
.shutdown = dummy_shutdown,
.map_flash_region = dummy_map,
.unmap_flash_region = dummy_unmap,
.shutdown = fallback_shutdown,
.map_flash_region = fallback_map,
.chip_readb = dummy_chip_readb, .chip_readw = fallback_chip_readw, .chip_readl = fallback_chip_readl, .chip_readn = fallback_chip_readn,.unmap_flash_region = fallback_unmap,
.chip_writeb = dummy_chip_writeb,
.chip_writew = fallback_chip_writew, .chip_writel = fallback_chip_writel, .chip_writen = fallback_chip_writen,.chip_writeb = fallback_chip_writeb,
@@ -118,19 +118,20 @@
{ .init = ft2232_spi_init,
.shutdown = dummy_shutdown,
.map_flash_region = dummy_map,
.unmap_flash_region = dummy_unmap,
.shutdown = fallback_shutdown,
.map_flash_region = fallback_map,
.chip_readb = dummy_chip_readb, .chip_readw = fallback_chip_readw, .chip_readl = fallback_chip_readl, .chip_readn = fallback_chip_readn,.unmap_flash_region = fallback_unmap,
.chip_writeb = dummy_chip_writeb,
.chip_writew = fallback_chip_writew, .chip_writel = fallback_chip_writel, .chip_writen = fallback_chip_writen, .delay = internal_delay, },.chip_writeb = fallback_chip_writeb,
- { .init = serprog_init, .shutdown = serprog_shutdown,
Index: flashrom-fallback/internal.c
--- flashrom-fallback/internal.c (Revision 674) +++ flashrom-fallback/internal.c (Arbeitskopie) @@ -218,6 +218,12 @@ } }
+/* Fallback shutdown() for programmers which don't need special handling */ +int fallback_shutdown(void) +{
- return 0;
+}
/* Fallback map() for programmers which don't need special handling */ void *fallback_map(const char *descr, unsigned long phys_addr, size_t len) { @@ -229,6 +235,11 @@ { }
+/* No-op fallback for drivers not supporting addr/data pair accesses */ +void fallback_chip_writeb(uint8_t val, chipaddr addr) +{ +}
/* Little-endian fallback for drivers not supporting 16 bit accesses */ void fallback_chip_writew(uint16_t val, chipaddr addr) {