nicamd: Introduce new programmer driver for AMD NICs

On a PCnet32 FAST card with a nice PLCC32 socket, only 18 of the 20 ad-
dress lines were connected. It's not easy to detect this, but we'll do
our best: Check the ROM contents for repeating patterns, and allow the
user to override the guessed size. We use the ROM BAR here, though not
for the actual flash reading / writing. According to the datasheet the
ROM BAR interface always reads four bytes, and doesn't seem to support
writes.

Otherwise tested successfully with the first 256KiB of an SST39VF040.

Datasheet used:
https://www.amd.com/content/dam/amd/en/documents/archived-tech-docs/datasheets/20550.pdf

Change-Id: I3bddfcd1e242d28790a0916197ebd8b8bba5a70a
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.sourcearcade.org/c/flashprog/+/530
Reviewed-by: Arthur Heymans <arthur@aheymans.xyz>
diff --git a/flashprog.8.tmpl b/flashprog.8.tmpl
index 2048da7..d771333 100644
--- a/flashprog.8.tmpl
+++ b/flashprog.8.tmpl
@@ -308,6 +308,8 @@
 .sp
 .BR "* nicintel" " (for parallel flash ROMs on Intel 10/100Mbit network cards)
 .sp
+.BR "* nicamd" " (for parallel flash ROMs on AMD PCnet network cards)
+.sp
 .BR "* gfxnvidia" " (for flash ROMs on NVIDIA graphics cards)"
 .sp
 .BR "* drkaiser" " (for flash ROMs on Dr. Kaiser PC-Waechter PCI cards)"
@@ -761,9 +763,9 @@
 not here).
 .SS
 .BR "nic3com" , " nicrealtek" , " nicnatsemi" , " nicintel", " nicintel_eeprom"\
-, " nicintel_spi" , " gfxnvidia" , " ogp_spi" , " drkaiser" , " satasii"\
-, " scsilsi", " satamv" , " atahpt", " atavia ", " atapromise " and " it8212 "\
-programmers
+, " nicintel_spi" , " nicamd" , " gfxnvidia" , " ogp_spi" , " drkaiser"\
+, " satasii" , " scsilsi", " satamv" , " atahpt", " atavia ", " atapromise "\
+and " it8212 " programmers
 .IP
 These programmers have an option to specify the PCI address of the card
 your want to use, which must be specified if more than one card supported
@@ -812,6 +814,15 @@
 unprogrammed EEPROM/card is detected. Intel specifies following EEPROMs to be compatible:
 Atmel AT25128, AT25256, Micron (ST) M95128, M95256 and OnSemi (Catalyst) CAT25CS128.
 .SS
+.BR "nicamd " programmer
+.IP
+This programmer module supports parallel flash up to 1MiB, attached to AMD PCnet cards. As it can't be said
+for sure if all 20 parallel address lines are connected on a given card, flashprog will try to probe the
+addressable size. If this doesn't work reliably, one can override the probing logic with the
+.BR "max_decode_kb " parameter.
+.sp
+.B "  flashprog \-p nicamd:max_decode_kb=128"
+.SS
 .BR "ft2232_spi " programmer
 .IP
 This module supports various programmers based on FTDI FT2232/FT4232H/FT4233H/FT232H chips including the DLP Design
@@ -1565,7 +1576,7 @@
 .BR satasii ", " scsilsi ", " nicintel ", " nicintel_eeprom " and " nicintel_spi
 need PCI configuration space read access and raw memory access.
 .sp
-.BR satamv " and " atapromise
+.BR nicamd ", " satamv " and " atapromise
 need PCI configuration space read access, raw I/O port access and raw memory
 access.
 .sp
@@ -1584,7 +1595,7 @@
 .B dummy
 needs no access permissions at all.
 .sp
-.BR internal ", " nic3com ", " nicrealtek ", " nicnatsemi ", "
+.BR internal ", " nicamd ", " nic3com ", " nicrealtek ", " nicnatsemi ", "
 .BR gfxnvidia ", " drkaiser ", " satamv ", " satasii ", " scsilsi ", "
 .BR atahpt ", " atavia " and " atapromise
 have to be run as superuser/root, and need additional raw access permission.