Add stubs for the TotalPhase Cheetah SPI programmer.
The programmer code is not finished yet, but the glue code is extremely painful to carry forward especially because these areas in flash.h, flashrom.c, flashrom.8 and Makefile are touched each time someone adds another external programmer to the tree. Having the glue code in reduces conflict resolution time to zero for me. That's also the reason I committed a stubbed version of Urja's serial flasher patch.
Signed-off-by: Carl-Daniel Hailfinger c-d.hailfinger.devel.2006@gmx.net
Index: flashrom-cheetah/flashrom.8 =================================================================== --- flashrom-cheetah/flashrom.8 (Revision 626) +++ flashrom-cheetah/flashrom.8 (Arbeitskopie) @@ -138,6 +138,8 @@ .sp .BR "* ft2232spi" " (for flash ROMs attached to a FT2232H/FT4232H based USB SPI programmer)" .sp +.BR "* cheetah" " (for flash ROMs attached to a TotalPhase Cheetah SPI programmer)" +.sp The dummy programmer has an optional parameter specifying the bus types it should support. For that you have to use the .B "flashrom -p dummy=type" Index: flashrom-cheetah/flash.h =================================================================== --- flashrom-cheetah/flash.h (Revision 626) +++ flashrom-cheetah/flash.h (Arbeitskopie) @@ -88,6 +88,7 @@ #define PROGRAMMER_IT87SPI 0x04 #define PROGRAMMER_FT2232SPI 0x05 #define PROGRAMMER_SERPROG 0x06 +#define PROGRAMMER_CHEETAH 0x07
struct programmer_entry { const char *vendor; @@ -374,6 +375,14 @@ int ft2232_spi_write1(struct flashchip *flash, uint8_t *buf); int ft2232_spi_write_256(struct flashchip *flash, uint8_t *buf);
+/* cheetah.c */ +int cheetah_spi_init(void); +int cheetah_spi_shutdown(void); +int cheetah_spi_command(unsigned int writecnt, unsigned int readcnt, + const unsigned char *writearr, unsigned char *readarr); +int cheetah_spi_write_256(struct flashchip *flash, uint8_t *buf); +int cheetah_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len); + /* flashrom.c */ extern int verbose; #define printf_debug(x...) { if (verbose) printf(x); } @@ -409,6 +418,7 @@ SPI_CONTROLLER_VIA, SPI_CONTROLLER_WBSIO, SPI_CONTROLLER_FT2232, + SPI_CONTROLLER_CHEETAH, SPI_CONTROLLER_DUMMY, }; extern enum spi_controller spi_controller; Index: flashrom-cheetah/spi.c =================================================================== --- flashrom-cheetah/spi.c (Revision 626) +++ flashrom-cheetah/spi.c (Arbeitskopie) @@ -49,6 +49,8 @@ return wbsio_spi_command(writecnt, readcnt, writearr, readarr); case SPI_CONTROLLER_FT2232: return ft2232_spi_command(writecnt, readcnt, writearr, readarr); + case SPI_CONTROLLER_CHEETAH: + return cheetah_spi_command(writecnt, readcnt, writearr, readarr); case SPI_CONTROLLER_DUMMY: return dummy_spi_command(writecnt, readcnt, writearr, readarr); default: @@ -215,6 +217,7 @@ case SPI_CONTROLLER_SB600: case SPI_CONTROLLER_WBSIO: case SPI_CONTROLLER_FT2232: + case SPI_CONTROLLER_CHEETAH: case SPI_CONTROLLER_DUMMY: return probe_spi_rdid_generic(flash, 4); default: @@ -731,6 +734,8 @@ return wbsio_spi_read(flash, buf, start, len); case SPI_CONTROLLER_FT2232: return ft2232_spi_read(flash, buf, start, len); + case SPI_CONTROLLER_CHEETAH: + return cheetah_spi_read(flash, buf, start, len); default: printf_debug ("%s called, but no SPI chipset/strapping detected\n", @@ -781,6 +786,8 @@ return wbsio_spi_write_1(flash, buf); case SPI_CONTROLLER_FT2232: return ft2232_spi_write_256(flash, buf); + case SPI_CONTROLLER_CHEETAH: + return cheetah_spi_write_256(flash, buf); default: printf_debug ("%s called, but no SPI chipset/strapping detected\n", Index: flashrom-cheetah/Makefile =================================================================== --- flashrom-cheetah/Makefile (Revision 626) +++ flashrom-cheetah/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 serprog.o \ - print.o + print.o cheetah.o
all: pciutils features dep $(PROGRAM)
Index: flashrom-cheetah/cheetah.c =================================================================== --- flashrom-cheetah/cheetah.c (Revision 0) +++ flashrom-cheetah/cheetah.c (Revision 0) @@ -0,0 +1,65 @@ +/* + * This file is part of the flashrom project. + * + * Copyright (C) 2009 Carl-Daniel Hailfinger + * + * 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; version 2 of the License. + * As a special exception, you may also incorporate this code into programs + * licensed under later versions of the GNU GPL provided your changes to + * this code are made available under the same conditions as the original code. + * + * 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 <string.h> +#include <stdlib.h> +#include "flash.h" + + +#define CHEETAH_SPI_SUPPORT 0 + +#if CHEETAH_SPI_SUPPORT == 1 + +#else + +int cheetah_spi_shutdown(void) +{ + fprintf(stderr, "Cheetah SPI support was not compiled in\n"); + exit(1); +} + +int cheetah_spi_init(void) +{ + fprintf(stderr, "Cheetah SPI support was not compiled in\n"); + exit(1); +} + +int cheetah_spi_command(unsigned int writecnt, unsigned int readcnt, + const unsigned char *writearr, unsigned char *readarr) +{ + fprintf(stderr, "Cheetah SPI support was not compiled in\n"); + exit(1); +} + +int cheetah_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len) +{ + fprintf(stderr, "Cheetah SPI support was not compiled in\n"); + exit(1); +} + +int cheetah_spi_write_256(struct flashchip *flash, uint8_t * buf) +{ + fprintf(stderr, "Cheetah SPI support was not compiled in\n"); + exit(1); +} + +#endif Index: flashrom-cheetah/flashrom.c =================================================================== --- flashrom-cheetah/flashrom.c (Revision 626) +++ flashrom-cheetah/flashrom.c (Arbeitskopie) @@ -130,6 +130,7 @@ .chip_writen = fallback_chip_writen, .delay = internal_delay, }, + { .init = serprog_init, .shutdown = serprog_shutdown, @@ -146,6 +147,22 @@ .delay = serprog_delay, },
+ { + .init = cheetah_spi_init, + .shutdown = cheetah_spi_shutdown, + .map_flash_region = dummy_map, + .unmap_flash_region = dummy_unmap, + .chip_readb = dummy_chip_readb, + .chip_readw = dummy_chip_readw, + .chip_readl = dummy_chip_readl, + .chip_readn = fallback_chip_readn, + .chip_writeb = dummy_chip_writeb, + .chip_writew = dummy_chip_writew, + .chip_writel = dummy_chip_writel, + .chip_writen = fallback_chip_writen, + .delay = internal_delay, + }, + {}, };
@@ -515,7 +532,7 @@ " -z | --list-supported-wiki: print supported devices in wiki syntax\n" " -p | --programmer <name>: specify the programmer device\n" " (internal, dummy, nic3com, satasii,\n" - " it87spi, ft2232spi, serprog)\n" + " it87spi, ft2232spi, serprog, cheetah)\n" " -h | --help: print this help text\n" " -R | --version: print the version (release)\n" "\nYou can specify one of -E, -r, -w, -v or no operation. " @@ -672,6 +689,8 @@ programmer = PROGRAMMER_SERPROG; if (optarg[7] == '=') serprog_param = strdup(optarg + 8); + } else if (strncmp(optarg, "cheetah", 7) == 0) { + programmer = PROGRAMMER_CHEETAH; } else { printf("Error: Unknown programmer.\n"); exit(1);