Thomas Heijligen has uploaded this change for review. ( https://review.coreboot.org/c/flashrom/+/52946 )
Change subject: [WIP] move programmer_entry to each programmer file ......................................................................
[WIP] move programmer_entry to each programmer file
Change-Id: I3d02bd789f0299e936eb86819b3b15b5ea2bb921 Signed-off-by: Thomas Heijligen thomas.heijligen@secunet.de --- M atahpt.c M atapromise.c M atavia.c M buspirate_spi.c M ch341a_spi.c M dediprog.c M developerbox_spi.c M digilent_spi.c M drkaiser.c M dummyflasher.c M ene_lpc.c M ft2232_spi.c M gfxnvidia.c M internal.c M it8212.c M jlink_spi.c M linux_mtd.c M linux_spi.c M lspcon_i2c_spi.c M mec1308.c M mstarddc_spi.c M ni845x_spi.c M nic3com.c M nicintel.c M nicintel_eeprom.c M nicintel_spi.c M nicnatsemi.c M nicrealtek.c M ogp_spi.c M pickit2_spi.c M pony_spi.c M programmer.h M programmer_table.c M raiden_debug_spi.c M rayer_spi.c M realtek_mst_i2c_spi.c M satamv.c M satasii.c M serprog.c M stlinkv3_spi.c M usbblaster_spi.c 41 files changed, 447 insertions(+), 547 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/46/52946/1
diff --git a/atahpt.c b/atahpt.c index dae0222..12218cb 100644 --- a/atahpt.c +++ b/atahpt.c @@ -94,6 +94,16 @@ return INB(io_base_addr + BIOS_ROM_DATA); }
+const struct programmer_entry programmer_atahpt = { + .name = "atahpt", + .type = PCI, + .devs.dev = ata_hpt, + .init = atahpt_init, + .map_flash_region = fallback_map, + .unmap_flash_region = fallback_unmap, + .delay = internal_delay, +}; + #else #error PCI port I/O access is not supported on this architecture yet. #endif diff --git a/atapromise.c b/atapromise.c index ab34a1e..f10c3f9 100644 --- a/atapromise.c +++ b/atapromise.c @@ -165,6 +165,16 @@ return pci_mmio_readb(atapromise_bar + (addr & ADDR_MASK)); }
+const struct programmer_entry programmer_atapromise = { + .name = "atapromise", + .type = PCI, + .devs.dev = ata_promise, + .init = atapromise_init, + .map_flash_region = atapromise_map, + .unmap_flash_region = fallback_unmap, + .delay = internal_delay, +}; + #else #error PCI port I/O access is not supported on this architecture yet. #endif diff --git a/atavia.c b/atavia.c index b407a30..5268fc3 100644 --- a/atavia.c +++ b/atavia.c @@ -190,3 +190,13 @@ msg_pspew("%s: 0x%02x from 0x%*" PRIxPTR ".\n", __func__, val, PRIxPTR_WIDTH, addr); return val; } + +const struct programmer_entry programmer_atavia = { + .name = "atavia", + .type = PCI, + .devs.dev = ata_via, + .init = atavia_init, + .map_flash_region = atavia_map, + .unmap_flash_region = fallback_unmap, + .delay = internal_delay, +}; \ No newline at end of file diff --git a/buspirate_spi.c b/buspirate_spi.c index eee8daa..e46e752 100644 --- a/buspirate_spi.c +++ b/buspirate_spi.c @@ -659,3 +659,14 @@
return 0; } + +const struct programmer_entry programmer_buspirate_spi = { + .name = "buspirate_spi", + .type = OTHER, + /* FIXME */ + .devs.note = "Dangerous Prototypes Bus Pirate\n", + .init = buspirate_spi_init, + .map_flash_region = fallback_map, + .unmap_flash_region = fallback_unmap, + .delay = internal_delay, +}; \ No newline at end of file diff --git a/ch341a_spi.c b/ch341a_spi.c index 84cc3fe..f0b6843 100644 --- a/ch341a_spi.c +++ b/ch341a_spi.c @@ -526,3 +526,13 @@ handle = NULL; return -1; } + +const struct programmer_entry programmer_ch341a_spi = { + .name = "ch341a_spi", + .type = USB, + .devs.dev = devs_ch341a_spi, + .init = ch341a_spi_init, + .map_flash_region = fallback_map, + .unmap_flash_region = fallback_unmap, + .delay = ch341a_spi_delay, +}; \ No newline at end of file diff --git a/dediprog.c b/dediprog.c index c50e374..addecc9 100644 --- a/dediprog.c +++ b/dediprog.c @@ -1278,3 +1278,13 @@
return 0; } + +const struct programmer_entry programmer_dediprog = { + .name = "dediprog", + .type = USB, + .devs.dev = devs_dediprog, + .init = dediprog_init, + .map_flash_region = fallback_map, + .unmap_flash_region = fallback_unmap, + .delay = internal_delay, +}; \ No newline at end of file diff --git a/developerbox_spi.c b/developerbox_spi.c index 4ff2fb6..fd91c89 100644 --- a/developerbox_spi.c +++ b/developerbox_spi.c @@ -167,3 +167,13 @@ libusb_exit(usb_ctx); return 1; } + +const struct programmer_entry programmer_developerbox = { + .name = "developerbox", + .type = USB, + .devs.dev = devs_developerbox_spi, + .init = developerbox_spi_init, + .map_flash_region = fallback_map, + .unmap_flash_region = fallback_unmap, + .delay = internal_delay, +}; \ No newline at end of file diff --git a/digilent_spi.c b/digilent_spi.c index 0f7a9da..a44a8bd 100644 --- a/digilent_spi.c +++ b/digilent_spi.c @@ -454,3 +454,13 @@ handle = NULL; return -1; } + +const struct programmer_entry programmer_digilent_spi = { + .name = "digilent_spi", + .type = USB, + .devs.dev = devs_digilent_spi, + .init = digilent_spi_init, + .map_flash_region = fallback_map, + .unmap_flash_region = fallback_unmap, + .delay = internal_delay, +}; \ No newline at end of file diff --git a/drkaiser.c b/drkaiser.c index ac49df3..ab527e7 100644 --- a/drkaiser.c +++ b/drkaiser.c @@ -93,3 +93,13 @@ { return pci_mmio_readb(drkaiser_bar + (addr & DRKAISER_MEMMAP_MASK)); } + +const struct programmer_entry programmer_drkaiser = { + .name = "drkaiser", + .type = PCI, + .devs.dev = drkaiser_pcidev, + .init = drkaiser_init, + .map_flash_region = fallback_map, + .unmap_flash_region = fallback_unmap, + .delay = internal_delay, +}; \ No newline at end of file diff --git a/dummyflasher.c b/dummyflasher.c index ec5060d..6dc6208 100644 --- a/dummyflasher.c +++ b/dummyflasher.c @@ -1079,3 +1079,14 @@ return 1; } #endif + +const struct programmer_entry programmer_dummy = { + .name = "dummy", + .type = OTHER, + /* FIXME */ + .devs.note = "Dummy device, does nothing and logs all accesses\n", + .init = dummy_init, + .map_flash_region = dummy_map, + .unmap_flash_region = dummy_unmap, + .delay = internal_delay, +}; \ No newline at end of file diff --git a/ene_lpc.c b/ene_lpc.c index b66e96e..705d65e 100644 --- a/ene_lpc.c +++ b/ene_lpc.c @@ -586,4 +586,14 @@ return 1; }
+const struct programmer_entry programmer_ene_lpc = { + .name = "ene_lpc", + .type = OTHER, + .devs.note = "ENE LPC interface keyboard controller\n", + .init = ene_lpc_init, + .map_flash_region = fallback_map, + .unmap_flash_region = fallback_unmap, + .delay = internal_delay, +}; + #endif /* __i386__ || __x86_64__ */ diff --git a/ft2232_spi.c b/ft2232_spi.c index bdc6e37..63b3d07 100644 --- a/ft2232_spi.c +++ b/ft2232_spi.c @@ -638,4 +638,13 @@ return ret; }
+const struct programmer_entry programmer_ft2232_spi = { + .name = "ft2232_spi", + .type = USB, + .devs.dev = devs_ft2232spi, + .init = ft2232_spi_init, + .map_flash_region = fallback_map, + .unmap_flash_region = fallback_unmap, + .delay = internal_delay, +}; #endif diff --git a/gfxnvidia.c b/gfxnvidia.c index d8ea4d6..8641120 100644 --- a/gfxnvidia.c +++ b/gfxnvidia.c @@ -119,3 +119,13 @@ { return pci_mmio_readb(nvidia_bar + (addr & GFXNVIDIA_MEMMAP_MASK)); } + +const struct programmer_entry programmer_gfxnvidia = { + .name = "gfxnvidia", + .type = PCI, + .devs.dev = gfx_nvidia, + .init = gfxnvidia_init, + .map_flash_region = fallback_map, + .unmap_flash_region = fallback_unmap, + .delay = internal_delay, +}; \ No newline at end of file diff --git a/internal.c b/internal.c index bdbe32d..82b8126 100644 --- a/internal.c +++ b/internal.c @@ -372,3 +372,13 @@
return ret; } + +const struct programmer_entry programmer_internal = { + .name = "internal", + .type = OTHER, + .devs.note = NULL, + .init = internal_init, + .map_flash_region = physmap, + .unmap_flash_region = physunmap, + .delay = internal_delay, +}; \ No newline at end of file diff --git a/it8212.c b/it8212.c index ac53a6f..a1bef84 100644 --- a/it8212.c +++ b/it8212.c @@ -80,3 +80,13 @@ { return pci_mmio_readb(it8212_bar + (addr & IT8212_MEMMAP_MASK)); } + +const struct programmer_entry programmer_it8212 = { + .name = "it8212", + .type = PCI, + .devs.dev = devs_it8212, + .init = it8212_init, + .map_flash_region = fallback_map, + .unmap_flash_region = fallback_unmap, + .delay = internal_delay, +}; \ No newline at end of file diff --git a/jlink_spi.c b/jlink_spi.c index 8b5cd2c..560058b 100644 --- a/jlink_spi.c +++ b/jlink_spi.c @@ -488,3 +488,13 @@
return 1; } + +const struct programmer_entry programmer_jlink_spi = { + .name = "jlink_spi", + .type = OTHER, + .init = jlink_spi_init, + .devs.note = "SEGGER J-Link and compatible devices\n", + .map_flash_region = fallback_map, + .unmap_flash_region = fallback_unmap, + .delay = internal_delay, +}; \ No newline at end of file diff --git a/linux_mtd.c b/linux_mtd.c index 22702e9..8cdbc70 100644 --- a/linux_mtd.c +++ b/linux_mtd.c @@ -289,7 +289,7 @@ return 0; }
-static struct opaque_master programmer_linux_mtd = { +static struct opaque_master linux_mtd_opaque_master = { /* max_data_{read,write} don't have any effect for this programmer */ .max_data_read = MAX_DATA_UNSPECIFIED, .max_data_write = MAX_DATA_UNSPECIFIED, @@ -404,10 +404,20 @@ if (register_shutdown(linux_mtd_shutdown, NULL)) goto linux_mtd_init_exit;
- register_opaque_master(&programmer_linux_mtd); + register_opaque_master(&linux_mtd_opaque_master);
ret = 0; linux_mtd_init_exit: free(param); return ret; } + +const struct programmer_entry programmer_linux_mtd = { + .name = "linux_mtd", + .type = OTHER, + .devs.note = "Device files /dev/mtd*\n", + .init = linux_mtd_init, + .map_flash_region = fallback_map, + .unmap_flash_region = fallback_unmap, + .delay = internal_delay, +}; \ No newline at end of file diff --git a/linux_spi.c b/linux_spi.c index 4668e7f..86ab81d 100644 --- a/linux_spi.c +++ b/linux_spi.c @@ -252,4 +252,14 @@ return 1; }
+const struct programmer_entry programmer_linux_spi = { + .name = "linux_spi", + .type = OTHER, + .devs.note = "Device files /dev/spidev*.*\n", + .init = linux_spi_init, + .map_flash_region = fallback_map, + .unmap_flash_region = fallback_unmap, + .delay = internal_delay, +}; + #endif // CONFIG_LINUX_SPI == 1 diff --git a/lspcon_i2c_spi.c b/lspcon_i2c_spi.c index b79e7f7..b74af0c 100644 --- a/lspcon_i2c_spi.c +++ b/lspcon_i2c_spi.c @@ -519,3 +519,13 @@
return ret; } + +const struct programmer_entry programmer_lspcon_i2c_spi = { + .name = "lspcon_i2c_spi", + .type = OTHER, + .devs.note = "Device files /dev/i2c-*.\n", + .init = lspcon_i2c_spi_init, + .map_flash_region = fallback_map, + .unmap_flash_region = fallback_unmap, + .delay = internal_delay, +}; \ No newline at end of file diff --git a/mec1308.c b/mec1308.c index 1530d9b..8a9ca05 100644 --- a/mec1308.c +++ b/mec1308.c @@ -522,4 +522,15 @@ free(ctx_data); return 1; } + +const struct programmer_entry programmer_mec1308 = { + .name = "mec1308", + .type = OTHER, + .devs.note = "Microchip MEC1308 Embedded Controller.\n", + .init = mec1308_init, + .map_flash_region = fallback_map, + .unmap_flash_region = fallback_unmap, + .delay = internal_delay, +}; + #endif diff --git a/mstarddc_spi.c b/mstarddc_spi.c index c041bd3..0ddc2c5 100644 --- a/mstarddc_spi.c +++ b/mstarddc_spi.c @@ -227,4 +227,14 @@ return ret; }
+const struct programmer_entry programmer_mstarddc_spi = { + .name = "mstarddc_spi", + .type = OTHER, + .devs.note = "MSTAR DDC devices addressable via /dev/i2c-* on Linux.\n", + .init = mstarddc_spi_init, + .map_flash_region = fallback_map, + .unmap_flash_region = fallback_unmap, + .delay = internal_delay, +}; + #endif diff --git a/ni845x_spi.c b/ni845x_spi.c index 765da8a..5820542 100644 --- a/ni845x_spi.c +++ b/ni845x_spi.c @@ -634,3 +634,13 @@
return 0; } + +const struct programmer_entry programmer_ni845x_spi = { + .name = "ni845x_spi", + .type = OTHER, // choose other because NI-845x uses own USB implementation + .devs.note = "National Instruments USB-845x\n", + .init = ni845x_spi_init, + .map_flash_region = fallback_map, + .unmap_flash_region = fallback_unmap, + .delay = internal_delay, +}; \ No newline at end of file diff --git a/nic3com.c b/nic3com.c index b7b967a..83709a0 100644 --- a/nic3com.c +++ b/nic3com.c @@ -139,6 +139,16 @@ return INB(io_base_addr + BIOS_ROM_DATA); }
+const struct programmer_entry programmer_nic3com = { + .name = "nic3com", + .type = PCI, + .devs.dev = nics_3com, + .init = nic3com_init, + .map_flash_region = fallback_map, + .unmap_flash_region = fallback_unmap, + .delay = internal_delay, +}; + #else #error PCI port I/O access is not supported on this architecture yet. #endif diff --git a/nicintel.c b/nicintel.c index 4672890..b450405 100644 --- a/nicintel.c +++ b/nicintel.c @@ -115,3 +115,13 @@ { return pci_mmio_readb(nicintel_bar + (addr & NICINTEL_MEMMAP_MASK)); } + +const struct programmer_entry programmer_nicintel = { + .name = "nicintel", + .type = PCI, + .devs.dev = nics_intel, + .init = nicintel_init, + .map_flash_region = fallback_map, + .unmap_flash_region = fallback_unmap, + .delay = internal_delay, +}; \ No newline at end of file diff --git a/nicintel_eeprom.c b/nicintel_eeprom.c index 4d45f79..59ef8f5 100644 --- a/nicintel_eeprom.c +++ b/nicintel_eeprom.c @@ -501,3 +501,13 @@
return 1; } + +const struct programmer_entry programmer_nicintel_eeprom = { + .name = "nicintel_eeprom", + .type = PCI, + .devs.dev = nics_intel_ee, + .init = nicintel_ee_init, + .map_flash_region = fallback_map, + .unmap_flash_region = fallback_unmap, + .delay = internal_delay, +}; \ No newline at end of file diff --git a/nicintel_spi.c b/nicintel_spi.c index 1173ef7..3bc1045 100644 --- a/nicintel_spi.c +++ b/nicintel_spi.c @@ -278,3 +278,13 @@
return 0; } + +const struct programmer_entry programmer_nicintel_spi = { + .name = "nicintel_spi", + .type = PCI, + .devs.dev = nics_intel_spi, + .init = nicintel_spi_init, + .map_flash_region = fallback_map, + .unmap_flash_region = fallback_unmap, + .delay = internal_delay, +}; \ No newline at end of file diff --git a/nicnatsemi.c b/nicnatsemi.c index 085768d..65263ea 100644 --- a/nicnatsemi.c +++ b/nicnatsemi.c @@ -106,6 +106,16 @@ return INB(io_base_addr + BOOT_ROM_DATA); }
+const struct programmer_entry programmer_nicnatsemi = { + .name = "nicnatsemi", + .type = PCI, + .devs.dev = nics_natsemi, + .init = nicnatsemi_init, + .map_flash_region = fallback_map, + .unmap_flash_region = fallback_unmap, + .delay = internal_delay, +}; + #else #error PCI port I/O access is not supported on this architecture yet. #endif diff --git a/nicrealtek.c b/nicrealtek.c index 5454b63..09470f9 100644 --- a/nicrealtek.c +++ b/nicrealtek.c @@ -129,6 +129,17 @@ return val; }
+const struct programmer_entry programmer_nicrealtek = { + /* This programmer works for Realtek RTL8139 and SMC 1211. */ + .name = "nicrealtek", + .type = PCI, + .devs.dev = nics_realtek, + .init = nicrealtek_init, + .map_flash_region = fallback_map, + .unmap_flash_region = fallback_unmap, + .delay = internal_delay, +}; + #else #error PCI port I/O access is not supported on this architecture yet. #endif diff --git a/ogp_spi.c b/ogp_spi.c index e603edb..f0233b7 100644 --- a/ogp_spi.c +++ b/ogp_spi.c @@ -140,3 +140,13 @@
return 0; } + +const struct programmer_entry programmer_ogp_spi = { + .name = "ogp_spi", + .type = PCI, + .devs.dev = ogp_spi, + .init = ogp_spi_init, + .map_flash_region = fallback_map, + .unmap_flash_region = fallback_unmap, + .delay = internal_delay, +}; \ No newline at end of file diff --git a/pickit2_spi.c b/pickit2_spi.c index 0bc17af..efd7ac3 100644 --- a/pickit2_spi.c +++ b/pickit2_spi.c @@ -489,3 +489,13 @@
return 0; } + +const struct programmer_entry programmer_pickit2_spi = { + .name = "pickit2_spi", + .type = USB, + .devs.dev = devs_pickit2_spi, + .init = pickit2_spi_init, + .map_flash_region = fallback_map, + .unmap_flash_region = fallback_unmap, + .delay = internal_delay, +}; \ No newline at end of file diff --git a/pony_spi.c b/pony_spi.c index ed9d326..a7eeee3 100644 --- a/pony_spi.c +++ b/pony_spi.c @@ -229,3 +229,14 @@ } return 0; } + +const struct programmer_entry programmer_pony_spi = { + .name = "pony_spi", + .type = OTHER, + /* FIXME */ + .devs.note = "Programmers compatible with SI-Prog, serbang or AJAWe\n", + .init = pony_spi_init, + .map_flash_region = fallback_map, + .unmap_flash_region = fallback_unmap, + .delay = internal_delay, +}; \ No newline at end of file diff --git a/programmer.h b/programmer.h index de03d0e..0e747bc 100644 --- a/programmer.h +++ b/programmer.h @@ -177,6 +177,7 @@
extern const struct programmer_entry *programmer_table[]; extern const size_t programmer_table_size; +extern const struct programmer_entry *default_programmer;
int programmer_init(enum programmer prog, const char *param); int programmer_shutdown(void); @@ -362,7 +363,7 @@ void probe_superio(void); int register_superio(struct superio s); extern enum chipbustype internal_buses_supported; -int internal_init(void); +extern const struct programmer_entry programmer_internal; #endif
/* hwaccess.c */ @@ -400,146 +401,122 @@
/* dummyflasher.c */ #if CONFIG_DUMMY == 1 -int dummy_init(void); -void *dummy_map(const char *descr, uintptr_t phys_addr, size_t len); -void dummy_unmap(void *virt_addr, size_t len); +extern const struct programmer_entry programmer_dummy; #endif
/* nic3com.c */ #if CONFIG_NIC3COM == 1 -int nic3com_init(void); -extern const struct dev_entry nics_3com[]; +extern const struct programmer_entry programmer_nic3com; #endif
/* gfxnvidia.c */ #if CONFIG_GFXNVIDIA == 1 -int gfxnvidia_init(void); -extern const struct dev_entry gfx_nvidia[]; +extern const struct programmer_entry programmer_gfxnvidia; #endif
/* raiden_debug_spi.c */ #if CONFIG_RAIDEN_DEBUG_SPI == 1 -int raiden_debug_spi_init(void); -extern const struct dev_entry devs_raiden[]; +extern const struct programmer_entry programmer_raiden_debug_spi; #endif
/* drkaiser.c */ #if CONFIG_DRKAISER == 1 -int drkaiser_init(void); -extern const struct dev_entry drkaiser_pcidev[]; +extern const struct programmer_entry programmer_drkaiser; #endif
/* nicrealtek.c */ #if CONFIG_NICREALTEK == 1 -int nicrealtek_init(void); -extern const struct dev_entry nics_realtek[]; +extern const struct programmer_entry programmer_nicrealtek; #endif
/* nicnatsemi.c */ #if CONFIG_NICNATSEMI == 1 -int nicnatsemi_init(void); -extern const struct dev_entry nics_natsemi[]; +extern const struct programmer_entry programmer_nicnatsemi; #endif
/* nicintel.c */ #if CONFIG_NICINTEL == 1 -int nicintel_init(void); -extern const struct dev_entry nics_intel[]; +extern const struct programmer_entry programmer_nicintel; #endif
/* nicintel_spi.c */ #if CONFIG_NICINTEL_SPI == 1 -int nicintel_spi_init(void); -extern const struct dev_entry nics_intel_spi[]; +extern const struct programmer_entry programmer_nicintel_spi; #endif
/* nicintel_eeprom.c */ #if CONFIG_NICINTEL_EEPROM == 1 -int nicintel_ee_init(void); -extern const struct dev_entry nics_intel_ee[]; +extern const struct programmer_entry programmer_nicintel_eeprom; #endif
/* ogp_spi.c */ #if CONFIG_OGP_SPI == 1 -int ogp_spi_init(void); -extern const struct dev_entry ogp_spi[]; +extern const struct programmer_entry programmer_ogp_spi; #endif
/* satamv.c */ #if CONFIG_SATAMV == 1 -int satamv_init(void); -extern const struct dev_entry satas_mv[]; +extern const struct programmer_entry programmer_satamv; #endif
/* satasii.c */ #if CONFIG_SATASII == 1 -int satasii_init(void); -extern const struct dev_entry satas_sii[]; +extern const struct programmer_entry programmer_satasii; #endif
/* atahpt.c */ #if CONFIG_ATAHPT == 1 -int atahpt_init(void); -extern const struct dev_entry ata_hpt[]; +extern const struct programmer_entry programmer_atahpt; #endif
/* atavia.c */ #if CONFIG_ATAVIA == 1 -int atavia_init(void); -void *atavia_map(const char *descr, uintptr_t phys_addr, size_t len); -extern const struct dev_entry ata_via[]; +extern const struct programmer_entry programmer_atavia; #endif
/* atapromise.c */ #if CONFIG_ATAPROMISE == 1 -int atapromise_init(void); -void *atapromise_map(const char *descr, uintptr_t phys_addr, size_t len); -extern const struct dev_entry ata_promise[]; +extern const struct programmer_entry programmer_atapromise; #endif
/* it8212.c */ #if CONFIG_IT8212 == 1 -int it8212_init(void); -extern const struct dev_entry devs_it8212[]; +extern const struct programmer_entry programmer_it8212; #endif
/* ft2232_spi.c */ #if CONFIG_FT2232_SPI == 1 -int ft2232_spi_init(void); -extern const struct dev_entry devs_ft2232spi[]; +extern const struct programmer_entry programmer_ft2232_spi; #endif
/* usbblaster_spi.c */ #if CONFIG_USBBLASTER_SPI == 1 -int usbblaster_spi_init(void); -extern const struct dev_entry devs_usbblasterspi[]; +extern const struct programmer_entry programmer_usbblaster_spi; #endif
/* mstarddc_spi.c */ #if CONFIG_MSTARDDC_SPI == 1 -int mstarddc_spi_init(void); +extern const struct programmer_entry programmer_mstarddc_spi; #endif
/* pickit2_spi.c */ #if CONFIG_PICKIT2_SPI == 1 -int pickit2_spi_init(void); -extern const struct dev_entry devs_pickit2_spi[]; +extern const struct programmer_entry programmer_pickit2_spi; #endif
/* stlinkv3_spi.c */ #if CONFIG_STLINKV3_SPI == 1 -int stlinkv3_spi_init(void); -extern const struct dev_entry devs_stlinkv3_spi[]; +extern const struct programmer_entry programmer_stlinkv3_spi; #endif
/* rayer_spi.c */ #if CONFIG_RAYER_SPI == 1 -int rayer_spi_init(void); +extern const struct programmer_entry programmer_rayer_spi; #endif
/* pony_spi.c */ #if CONFIG_PONY_SPI == 1 -int pony_spi_init(void); +extern const struct programmer_entry programmer_pony_spi; #endif
/* bitbang_spi.c */ @@ -547,57 +524,52 @@
/* buspirate_spi.c */ #if CONFIG_BUSPIRATE_SPI == 1 -int buspirate_spi_init(void); +extern const struct programmer_entry programmer_buspirate_spi; #endif
/* linux_mtd.c */ #if CONFIG_LINUX_MTD == 1 -int linux_mtd_init(void); +extern const struct programmer_entry programmer_linux_mtd; #endif
/* linux_spi.c */ #if CONFIG_LINUX_SPI == 1 -int linux_spi_init(void); +extern const struct programmer_entry programmer_linux_spi; #endif
/* dediprog.c */ #if CONFIG_DEDIPROG == 1 -int dediprog_init(void); -extern const struct dev_entry devs_dediprog[]; +extern const struct programmer_entry programmer_dediprog; #endif
/* developerbox_spi.c */ #if CONFIG_DEVELOPERBOX_SPI == 1 -int developerbox_spi_init(void); -extern const struct dev_entry devs_developerbox_spi[]; +extern const struct programmer_entry programmer_developerbox; #endif
/* ch341a_spi.c */ #if CONFIG_CH341A_SPI == 1 -int ch341a_spi_init(void); -void ch341a_spi_delay(unsigned int usecs); -extern const struct dev_entry devs_ch341a_spi[]; +extern const struct programmer_entry programmer_ch341a_spi; #endif
/* digilent_spi.c */ #if CONFIG_DIGILENT_SPI == 1 -int digilent_spi_init(void); -extern const struct dev_entry devs_digilent_spi[]; +extern const struct programmer_entry programmer_digilent_spi; #endif
/* ene_lpc.c */ #if CONFIG_ENE_LPC == 1 -int ene_lpc_init(void); +extern const struct programmer_entry programmer_ene_lpc; #endif
/* jlink_spi.c */ #if CONFIG_JLINK_SPI == 1 -int jlink_spi_init(void); +extern const struct programmer_entry programmer_jlink_spi; #endif
/* ni845x_spi.c */ #if CONFIG_NI845X_SPI == 1 -int ni845x_spi_init(void); +extern const struct programmer_entry programmer_ni845x_spi; #endif
/* flashrom.c */ @@ -694,7 +666,7 @@
#if CONFIG_LINUX_MTD == 1 /* trivial wrapper to avoid cluttering internal_init() with #if */ -static inline int try_mtd(void) { return linux_mtd_init(); }; +static inline int try_mtd(void) { return programmer_linux_mtd.init(); }; #else static inline int try_mtd(void) { return 1; }; #endif @@ -704,7 +676,7 @@
/* mec1308.c */ #if CONFIG_MEC1308 == 1 -int mec1308_init(void); +extern const struct programmer_entry programmer_mec1308; #endif
/* sb600spi.c */ @@ -762,9 +734,7 @@
/* serprog.c */ #if CONFIG_SERPROG == 1 -int serprog_init(void); -void serprog_delay(unsigned int usecs); -void *serprog_map(const char *descr, uintptr_t phys_addr, size_t len); +extern const struct programmer_entry programmer_serprog; #endif
/* serial.c */ @@ -835,12 +805,12 @@
/* lspcon_i2c_spi.c */ #if CONFIG_LSPCON_I2C_SPI == 1 -int lspcon_i2c_spi_init(void); +extern const struct programmer_entry programmer_lspcon_i2c_spi; #endif
/* realtek_mst_i2c_spi.c */ #if CONFIG_REALTEK_MST_I2C_SPI == 1 -int realtek_mst_i2c_spi_init(void); +extern const struct programmer_entry programmer_realtek_mst_i2c_spi; #endif
#endif /* !__PROGRAMMER_H__ */ diff --git a/programmer_table.c b/programmer_table.c index 2465d9e..e8745f2 100644 --- a/programmer_table.c +++ b/programmer_table.c @@ -1,479 +1,5 @@ #include "programmer.h"
-#if CONFIG_INTERNAL == 1 -const struct programmer_entry programmer_internal = { - .name = "internal", - .type = OTHER, - .devs.note = NULL, - .init = internal_init, - .map_flash_region = physmap, - .unmap_flash_region = physunmap, - .delay = internal_delay, -}; -#endif - -#if CONFIG_DUMMY == 1 -const struct programmer_entry programmer_dummy = { - .name = "dummy", - .type = OTHER, - /* FIXME */ - .devs.note = "Dummy device, does nothing and logs all accesses\n", - .init = dummy_init, - .map_flash_region = dummy_map, - .unmap_flash_region = dummy_unmap, - .delay = internal_delay, -}; -#endif - -#if CONFIG_MEC1308 == 1 -const struct programmer_entry programmer_mec1308 = { - .name = "mec1308", - .type = OTHER, - .devs.note = "Microchip MEC1308 Embedded Controller.\n", - .init = mec1308_init, - .map_flash_region = fallback_map, - .unmap_flash_region = fallback_unmap, - .delay = internal_delay, -}; -#endif - -#if CONFIG_NIC3COM == 1 -const struct programmer_entry programmer_nic3com = { - .name = "nic3com", - .type = PCI, - .devs.dev = nics_3com, - .init = nic3com_init, - .map_flash_region = fallback_map, - .unmap_flash_region = fallback_unmap, - .delay = internal_delay, -}; -#endif - -#if CONFIG_NICREALTEK == 1 -const struct programmer_entry programmer_nicrealtek = { - /* This programmer works for Realtek RTL8139 and SMC 1211. */ - .name = "nicrealtek", - .type = PCI, - .devs.dev = nics_realtek, - .init = nicrealtek_init, - .map_flash_region = fallback_map, - .unmap_flash_region = fallback_unmap, - .delay = internal_delay, -}; -#endif - -#if CONFIG_NICNATSEMI == 1 -const struct programmer_entry programmer_nicnatsemi = { - .name = "nicnatsemi", - .type = PCI, - .devs.dev = nics_natsemi, - .init = nicnatsemi_init, - .map_flash_region = fallback_map, - .unmap_flash_region = fallback_unmap, - .delay = internal_delay, -}; -#endif - -#if CONFIG_GFXNVIDIA == 1 -const struct programmer_entry programmer_gfxnvidia = { - .name = "gfxnvidia", - .type = PCI, - .devs.dev = gfx_nvidia, - .init = gfxnvidia_init, - .map_flash_region = fallback_map, - .unmap_flash_region = fallback_unmap, - .delay = internal_delay, -}; -#endif - -#if CONFIG_RAIDEN_DEBUG_SPI == 1 -const struct programmer_entry programmer_raiden_debug_spi = { - .name = "raiden_debug_spi", - .type = USB, - .devs.dev = devs_raiden, - .init = raiden_debug_spi_init, - .map_flash_region = fallback_map, - .unmap_flash_region = fallback_unmap, - .delay = internal_delay, -}; -#endif - -#if CONFIG_DRKAISER == 1 -const struct programmer_entry programmer_drkaiser = { - .name = "drkaiser", - .type = PCI, - .devs.dev = drkaiser_pcidev, - .init = drkaiser_init, - .map_flash_region = fallback_map, - .unmap_flash_region = fallback_unmap, - .delay = internal_delay, -}; -#endif - -#if CONFIG_SATASII == 1 -const struct programmer_entry programmer_satasii = { - .name = "satasii", - .type = PCI, - .devs.dev = satas_sii, - .init = satasii_init, - .map_flash_region = fallback_map, - .unmap_flash_region = fallback_unmap, - .delay = internal_delay, -}; -#endif - -#if CONFIG_ATAHPT == 1 -const struct programmer_entry programmer_atahpt = { - .name = "atahpt", - .type = PCI, - .devs.dev = ata_hpt, - .init = atahpt_init, - .map_flash_region = fallback_map, - .unmap_flash_region = fallback_unmap, - .delay = internal_delay, -}; -#endif - -#if CONFIG_ATAVIA == 1 -const struct programmer_entry programmer_atavia = { - .name = "atavia", - .type = PCI, - .devs.dev = ata_via, - .init = atavia_init, - .map_flash_region = atavia_map, - .unmap_flash_region = fallback_unmap, - .delay = internal_delay, -}; -#endif - -#if CONFIG_ATAPROMISE == 1 -const struct programmer_entry programmer_atapromise = { - .name = "atapromise", - .type = PCI, - .devs.dev = ata_promise, - .init = atapromise_init, - .map_flash_region = atapromise_map, - .unmap_flash_region = fallback_unmap, - .delay = internal_delay, -}; -#endif - -#if CONFIG_IT8212 == 1 -const struct programmer_entry programmer_it8212 = { - .name = "it8212", - .type = PCI, - .devs.dev = devs_it8212, - .init = it8212_init, - .map_flash_region = fallback_map, - .unmap_flash_region = fallback_unmap, - .delay = internal_delay, -}; -#endif - -#if CONFIG_FT2232_SPI == 1 -const struct programmer_entry programmer_ft2232_spi = { - .name = "ft2232_spi", - .type = USB, - .devs.dev = devs_ft2232spi, - .init = ft2232_spi_init, - .map_flash_region = fallback_map, - .unmap_flash_region = fallback_unmap, - .delay = internal_delay, -}; -#endif - -#if CONFIG_SERPROG == 1 -const struct programmer_entry programmer_serprog = { - .name = "serprog", - .type = OTHER, - /* FIXME */ - .devs.note = "All programmer devices speaking the serprog protocol\n", - .init = serprog_init, - .map_flash_region = serprog_map, - .unmap_flash_region = fallback_unmap, - .delay = serprog_delay, -}; -#endif - -#if CONFIG_BUSPIRATE_SPI == 1 -const struct programmer_entry programmer_buspirate_spi = { - .name = "buspirate_spi", - .type = OTHER, - /* FIXME */ - .devs.note = "Dangerous Prototypes Bus Pirate\n", - .init = buspirate_spi_init, - .map_flash_region = fallback_map, - .unmap_flash_region = fallback_unmap, - .delay = internal_delay, -}; -#endif - -#if CONFIG_DEDIPROG == 1 -const struct programmer_entry programmer_dediprog = { - .name = "dediprog", - .type = USB, - .devs.dev = devs_dediprog, - .init = dediprog_init, - .map_flash_region = fallback_map, - .unmap_flash_region = fallback_unmap, - .delay = internal_delay, -}; -#endif - -#if CONFIG_DEVELOPERBOX_SPI == 1 -const struct programmer_entry programmer_developerbox = { - .name = "developerbox", - .type = USB, - .devs.dev = devs_developerbox_spi, - .init = developerbox_spi_init, - .map_flash_region = fallback_map, - .unmap_flash_region = fallback_unmap, - .delay = internal_delay, -}; -#endif - -#if CONFIG_ENE_LPC == 1 -const struct programmer_entry programmer_ene_lpc = { - .name = "ene_lpc", - .type = OTHER, - .devs.note = "ENE LPC interface keyboard controller\n", - .init = ene_lpc_init, - .map_flash_region = fallback_map, - .unmap_flash_region = fallback_unmap, - .delay = internal_delay, -}; -#endif - -#if CONFIG_RAYER_SPI == 1 -const struct programmer_entry programmer_rayer_spi = { - .name = "rayer_spi", - .type = OTHER, - /* FIXME */ - .devs.note = "RayeR parallel port programmer\n", - .init = rayer_spi_init, - .map_flash_region = fallback_map, - .unmap_flash_region = fallback_unmap, - .delay = internal_delay, -}; -#endif - -#if CONFIG_PONY_SPI == 1 -const struct programmer_entry programmer_pony_spi = { - .name = "pony_spi", - .type = OTHER, - /* FIXME */ - .devs.note = "Programmers compatible with SI-Prog, serbang or AJAWe\n", - .init = pony_spi_init, - .map_flash_region = fallback_map, - .unmap_flash_region = fallback_unmap, - .delay = internal_delay, -}; -#endif - -#if CONFIG_NICINTEL == 1 -const struct programmer_entry programmer_nicintel = { - .name = "nicintel", - .type = PCI, - .devs.dev = nics_intel, - .init = nicintel_init, - .map_flash_region = fallback_map, - .unmap_flash_region = fallback_unmap, - .delay = internal_delay, -}; -#endif - -#if CONFIG_NICINTEL_SPI == 1 -const struct programmer_entry programmer_nicintel_spi = { - .name = "nicintel_spi", - .type = PCI, - .devs.dev = nics_intel_spi, - .init = nicintel_spi_init, - .map_flash_region = fallback_map, - .unmap_flash_region = fallback_unmap, - .delay = internal_delay, -}; -#endif - -#if CONFIG_NICINTEL_EEPROM == 1 -const struct programmer_entry programmer_nicintel_eeprom = { - .name = "nicintel_eeprom", - .type = PCI, - .devs.dev = nics_intel_ee, - .init = nicintel_ee_init, - .map_flash_region = fallback_map, - .unmap_flash_region = fallback_unmap, - .delay = internal_delay, -}; -#endif - -#if CONFIG_OGP_SPI == 1 -const struct programmer_entry programmer_ogp_spi = { - .name = "ogp_spi", - .type = PCI, - .devs.dev = ogp_spi, - .init = ogp_spi_init, - .map_flash_region = fallback_map, - .unmap_flash_region = fallback_unmap, - .delay = internal_delay, -}; -#endif - -#if CONFIG_SATAMV == 1 -const struct programmer_entry programmer_satamv = { - .name = "satamv", - .type = PCI, - .devs.dev = satas_mv, - .init = satamv_init, - .map_flash_region = fallback_map, - .unmap_flash_region = fallback_unmap, - .delay = internal_delay, -}; -#endif - -#if CONFIG_LINUX_MTD == 1 -const struct programmer_entry programmer_linux_mtd = { - .name = "linux_mtd", - .type = OTHER, - .devs.note = "Device files /dev/mtd*\n", - .init = linux_mtd_init, - .map_flash_region = fallback_map, - .unmap_flash_region = fallback_unmap, - .delay = internal_delay, -}; -#endif - -#if CONFIG_LINUX_SPI == 1 -const struct programmer_entry programmer_linux_spi = { - .name = "linux_spi", - .type = OTHER, - .devs.note = "Device files /dev/spidev*.*\n", - .init = linux_spi_init, - .map_flash_region = fallback_map, - .unmap_flash_region = fallback_unmap, - .delay = internal_delay, -}; -#endif - -#if CONFIG_LSPCON_I2C_SPI == 1 -const struct programmer_entry programmer_lspcon_i2c_spi = { - .name = "lspcon_i2c_spi", - .type = OTHER, - .devs.note = "Device files /dev/i2c-*.\n", - .init = lspcon_i2c_spi_init, - .map_flash_region = fallback_map, - .unmap_flash_region = fallback_unmap, - .delay = internal_delay, -}; -#endif - -#if CONFIG_REALTEK_MST_I2C_SPI == 1 -const struct programmer_entry programmer_realtek_mst_i2c_spi = { - .name = "realtek_mst_i2c_spi", - .type = OTHER, - .devs.note = "Device files /dev/i2c-*.\n", - .init = realtek_mst_i2c_spi_init, - .map_flash_region = fallback_map, - .unmap_flash_region = fallback_unmap, - .delay = internal_delay, -}; -#endif - -#if CONFIG_USBBLASTER_SPI == 1 -const struct programmer_entry programmer_usbblaster_spi = { - .name = "usbblaster_spi", - .type = USB, - .devs.dev = devs_usbblasterspi, - .init = usbblaster_spi_init, - .map_flash_region = fallback_map, - .unmap_flash_region = fallback_unmap, - .delay = internal_delay, -}; -#endif - -#if CONFIG_MSTARDDC_SPI == 1 -const struct programmer_entry programmer_mstarddc_spi = { - .name = "mstarddc_spi", - .type = OTHER, - .devs.note = "MSTAR DDC devices addressable via /dev/i2c-* on Linux.\n", - .init = mstarddc_spi_init, - .map_flash_region = fallback_map, - .unmap_flash_region = fallback_unmap, - .delay = internal_delay, -}; -#endif - -#if CONFIG_PICKIT2_SPI == 1 -const struct programmer_entry programmer_pickit2_spi = { - .name = "pickit2_spi", - .type = USB, - .devs.dev = devs_pickit2_spi, - .init = pickit2_spi_init, - .map_flash_region = fallback_map, - .unmap_flash_region = fallback_unmap, - .delay = internal_delay, -}; -#endif - -#if CONFIG_CH341A_SPI == 1 -const struct programmer_entry programmer_ch341a_spi = { - .name = "ch341a_spi", - .type = USB, - .devs.dev = devs_ch341a_spi, - .init = ch341a_spi_init, - .map_flash_region = fallback_map, - .unmap_flash_region = fallback_unmap, - .delay = ch341a_spi_delay, -}; -#endif - -#if CONFIG_DIGILENT_SPI == 1 -const struct programmer_entry programmer_digilent_spi = { - .name = "digilent_spi", - .type = USB, - .devs.dev = devs_digilent_spi, - .init = digilent_spi_init, - .map_flash_region = fallback_map, - .unmap_flash_region = fallback_unmap, - .delay = internal_delay, -}; -#endif - -#if CONFIG_JLINK_SPI == 1 -const struct programmer_entry programmer_jlink_spi = { - .name = "jlink_spi", - .type = OTHER, - .init = jlink_spi_init, - .devs.note = "SEGGER J-Link and compatible devices\n", - .map_flash_region = fallback_map, - .unmap_flash_region = fallback_unmap, - .delay = internal_delay, -}; -#endif - -#if CONFIG_NI845X_SPI == 1 -const struct programmer_entry programmer_ni845x_spi = { - .name = "ni845x_spi", - .type = OTHER, // choose other because NI-845x uses own USB implementation - .devs.note = "National Instruments USB-845x\n", - .init = ni845x_spi_init, - .map_flash_region = fallback_map, - .unmap_flash_region = fallback_unmap, - .delay = internal_delay, -}; -#endif - -#if CONFIG_STLINKV3_SPI == 1 -const struct programmer_entry programmer_stlinkv3_spi = { - .name = "stlinkv3_spi", - .type = USB, - .devs.dev = devs_stlinkv3_spi, - .init = stlinkv3_spi_init, - .map_flash_region = fallback_map, - .unmap_flash_region = fallback_unmap, - .delay = internal_delay, -}; -#endif - const struct programmer_entry *programmer_table[] = {
#if CONFIG_INTERNAL == 1 @@ -636,3 +162,11 @@ };
const size_t programmer_table_size = ARRAY_SIZE(programmer_table); + +#ifdef FOO //CONFIG_DEFAULT_PROGRAMMER +#define DEFAULT_PROGRAMMER &programmer_##CONFIG_DEFAULT_PROGRAMMER +#else +#define DEFAULT_PROGRAMMER NULL +#endif + +const struct programmer_entry *default_programmer = DEFAULT_PROGRAMMER; diff --git a/raiden_debug_spi.c b/raiden_debug_spi.c index bd7c054..a1a3d32 100644 --- a/raiden_debug_spi.c +++ b/raiden_debug_spi.c @@ -1619,3 +1619,13 @@
return 0; } + +const struct programmer_entry programmer_raiden_debug_spi = { + .name = "raiden_debug_spi", + .type = USB, + .devs.dev = devs_raiden, + .init = raiden_debug_spi_init, + .map_flash_region = fallback_map, + .unmap_flash_region = fallback_unmap, + .delay = internal_delay, +}; \ No newline at end of file diff --git a/rayer_spi.c b/rayer_spi.c index cde008f..6f91dfa 100644 --- a/rayer_spi.c +++ b/rayer_spi.c @@ -271,6 +271,17 @@ return 0; }
+const struct programmer_entry programmer_rayer_spi = { + .name = "rayer_spi", + .type = OTHER, + /* FIXME */ + .devs.note = "RayeR parallel port programmer\n", + .init = rayer_spi_init, + .map_flash_region = fallback_map, + .unmap_flash_region = fallback_unmap, + .delay = internal_delay, +}; + #else #error PCI port I/O access is not supported on this architecture yet. #endif diff --git a/realtek_mst_i2c_spi.c b/realtek_mst_i2c_spi.c index ae79fdd..23dc74c 100644 --- a/realtek_mst_i2c_spi.c +++ b/realtek_mst_i2c_spi.c @@ -548,3 +548,13 @@
return ret; } + +const struct programmer_entry programmer_realtek_mst_i2c_spi = { + .name = "realtek_mst_i2c_spi", + .type = OTHER, + .devs.note = "Device files /dev/i2c-*.\n", + .init = realtek_mst_i2c_spi_init, + .map_flash_region = fallback_map, + .unmap_flash_region = fallback_unmap, + .delay = internal_delay, +}; \ No newline at end of file diff --git a/satamv.c b/satamv.c index 31265ea..f89c5aa 100644 --- a/satamv.c +++ b/satamv.c @@ -188,6 +188,16 @@ return satamv_indirect_chip_readb(addr); }
+const struct programmer_entry programmer_satamv = { + .name = "satamv", + .type = PCI, + .devs.dev = satas_mv, + .init = satamv_init, + .map_flash_region = fallback_map, + .unmap_flash_region = fallback_unmap, + .delay = internal_delay, +}; + #else #error PCI port I/O access is not supported on this architecture yet. #endif diff --git a/satasii.c b/satasii.c index 8a0938d..64385ee 100644 --- a/satasii.c +++ b/satasii.c @@ -135,3 +135,13 @@
return (pci_mmio_readl(sii_bar + 4)) & 0xff; } + +const struct programmer_entry programmer_satasii = { + .name = "satasii", + .type = PCI, + .devs.dev = satas_sii, + .init = satasii_init, + .map_flash_region = fallback_map, + .unmap_flash_region = fallback_unmap, + .delay = internal_delay, +}; \ No newline at end of file diff --git a/serprog.c b/serprog.c index d583a40..2a8a5b1 100644 --- a/serprog.c +++ b/serprog.c @@ -924,3 +924,14 @@ descr, len, PRIxPTR_WIDTH, phys_addr); return NULL; } + +const struct programmer_entry programmer_serprog = { + .name = "serprog", + .type = OTHER, + /* FIXME */ + .devs.note = "All programmer devices speaking the serprog protocol\n", + .init = serprog_init, + .map_flash_region = serprog_map, + .unmap_flash_region = fallback_unmap, + .delay = serprog_delay, +}; \ No newline at end of file diff --git a/stlinkv3_spi.c b/stlinkv3_spi.c index 7e8336e..133a823 100644 --- a/stlinkv3_spi.c +++ b/stlinkv3_spi.c @@ -518,3 +518,13 @@ libusb_exit(usb_ctx); return 1; } + +const struct programmer_entry programmer_stlinkv3_spi = { + .name = "stlinkv3_spi", + .type = USB, + .devs.dev = devs_stlinkv3_spi, + .init = stlinkv3_spi_init, + .map_flash_region = fallback_map, + .unmap_flash_region = fallback_unmap, + .delay = internal_delay, +}; \ No newline at end of file diff --git a/usbblaster_spi.c b/usbblaster_spi.c index 020c3bf..9121543 100644 --- a/usbblaster_spi.c +++ b/usbblaster_spi.c @@ -214,4 +214,14 @@ return 0; }
+const struct programmer_entry programmer_usbblaster_spi = { + .name = "usbblaster_spi", + .type = USB, + .devs.dev = devs_usbblasterspi, + .init = usbblaster_spi_init, + .map_flash_region = fallback_map, + .unmap_flash_region = fallback_unmap, + .delay = internal_delay, +}; + #endif