Hi,
this patch adds support for a PCI "flash memory card" named "Dr. Kaiser PC-Waechter". The Vendor sold different designs under that name, the patch works with the one that has an ACTEL FPGA as PCI-to-Flash bridge.
The Flash chip is a "Macronix MX29F001B" (128 KB, Parallel) soldered directly to the PCB. Flash operations (PROBE, READ, ERASE, WRITE) work as expected, btw.
I had to modify pcidev.c a bit: This card has 0x0000000 at PCI_BASE_ADDRESS_0 because it uses PCI_BASE_ADDRESS_2 instead.
-- TURBO J
ps. Unrelated issue: My OpenSUSE 11.2 Beta Box needs "make CFLAGS=-fno-strict-aliasing" GCC is "gcc version 4.4.1 [gcc-4_4-branch revision 149935] (SUSE Linux)"
Signed-off-by: TURBO J turboj@gmx.de
Index: flash.h =================================================================== --- flash.h (Revision 710) +++ flash.h (Arbeitskopie) @@ -84,6 +84,7 @@ PROGRAMMER_INTERNAL, PROGRAMMER_DUMMY, PROGRAMMER_NIC3COM, + PROGRAMMER_DRKAISER, PROGRAMMER_SATASII, PROGRAMMER_IT87SPI, #if FT2232_SPI_SUPPORT == 1 @@ -387,6 +388,15 @@ uint8_t nic3com_chip_readb(const chipaddr addr); extern struct pcidev_status nics_3com[];
+/* drkaiser.c */ + +int drkaiser_init(void); +int drkaiser_shutdown(void); +void drkaiser_chip_writeb(uint8_t val, chipaddr addr); +uint8_t drkaiser_chip_readb(const chipaddr addr); + +extern struct pcidev_status drkaiser_pcidev[]; + /* satasii.c */ int satasii_init(void); int satasii_shutdown(void); Index: drkaiser.c =================================================================== --- drkaiser.c (Revision 0) +++ drkaiser.c (Revision 0) @@ -0,0 +1,76 @@ +/* + * This file is part of the flashrom project. + * + * Copyright (C) 2009 TURBO J turboj@web.de + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ +#include <stdlib.h> +#include <string.h> +#include <sys/types.h> +#include "flash.h" +#define PCI_VENDOR_ID_DRKAISER 0x1803 +#define PCI_DEVICE_ID_DRKAISER_ACTEL 0x5057 + + +struct pcidev_status drkaiser_pcidev[] = { + {0x1803, 0x5057,PCI_OK,"Dr.Kaiser","PC-Waechter (Actel FPGA)"}, + {}, +}; + +#define PCI_MAGIC_DRKAISER_ADR 0x50 +#define PCI_MAGIC_DRKAISER_VALUE 0xA971 + +uint8_t * drkaiser_mem; + +int drkaiser_init(void) +{ + get_io_perms(); + pcidev_init(PCI_VENDOR_ID_DRKAISER, drkaiser_pcidev, programmer_param); + + // Write Magic Register to enable FLASH Write + pci_write_word(pcidev_dev,PCI_MAGIC_DRKAISER_ADR, PCI_MAGIC_DRKAISER_VALUE); + + // Map 128KB Flash Memory Window + drkaiser_mem=physmap("Dr.Kaiser PC-Waechter FLASH Memory", + pci_read_long(pcidev_dev,PCI_BASE_ADDRESS_2), 128*1024); + + buses_supported = CHIP_BUSTYPE_PARALLEL; + return 0; +} + +int drkaiser_shutdown(void) +{ + // Write protect the Flash again + pci_write_word(pcidev_dev,PCI_MAGIC_DRKAISER_ADR, 0); + free(programmer_param); + pci_cleanup(pacc); + release_io_perms(); + return 0; +}; + + +void drkaiser_chip_writeb(uint8_t val, chipaddr addr) +{ + mmio_writeb(val, drkaiser_mem+addr ); +} + +uint8_t drkaiser_chip_readb(const chipaddr addr) +{ + return mmio_readb(drkaiser_mem + addr ); +} + + + Index: pcidev.c =================================================================== --- pcidev.c (Revision 710) +++ pcidev.c (Arbeitskopie) @@ -39,6 +39,9 @@
/* Don't use dev->base_addr[0], won't work on older libpci. */ addr = pci_read_long(dev, PCI_BASE_ADDRESS_0) & ~0x03; + + /* Dr. Kaiser has BASE_ADDRESS_0 = 0x000 */ + if (!addr) addr= pci_read_long(dev, PCI_BASE_ADDRESS_2) & ~0x03;
printf("Found "%s %s" (%04x:%04x, BDF %02x:%02x.%x).\n", devs[i].vendor_name, devs[i].device_name, dev->vendor_id, Index: Makefile =================================================================== --- Makefile (Revision 710) +++ Makefile (Arbeitskopie) @@ -50,7 +50,7 @@ flashrom.o w39v080fa.o sharplhf00l04.o w29ee011.o spi.o it87spi.o \ ichspi.o w39v040c.o sb600spi.o wbsio_spi.o m29f002.o internal.o \ dummyflasher.o pcidev.o nic3com.o satasii.o ft2232_spi.o \ - print.o + print.o drkaiser.o
all: pciutils features dep $(PROGRAM)
Index: flashrom.c =================================================================== --- flashrom.c (Revision 710) +++ flashrom.c (Arbeitskopie) @@ -87,7 +87,24 @@ .chip_writen = fallback_chip_writen, .delay = internal_delay, }, + { + .name = "drkaiser", + .init = drkaiser_init, + .shutdown = drkaiser_shutdown, + .map_flash_region = fallback_map, + .unmap_flash_region = fallback_unmap, + .chip_readb = drkaiser_chip_readb, + .chip_readw = fallback_chip_readw, + .chip_readl = fallback_chip_readl, + .chip_readn = fallback_chip_readn, + .chip_writeb = drkaiser_chip_writeb, + .chip_writew = fallback_chip_writew, + .chip_writel = fallback_chip_writel, + .chip_writen = fallback_chip_writen, + .delay = internal_delay, + },
+ { .name = "satasii", .init = satasii_init, @@ -747,6 +764,7 @@ printf("\nSupported PCI devices flashrom can use " "as programmer:\n\n"); print_supported_pcidevs(nics_3com); + print_supported_pcidevs(drkaiser_pcidev); print_supported_pcidevs(satas_sii); exit(0); }