- Timestamp:
- 09/12/11 08:17:06 (8 months ago)
- Location:
- trunk
- Files:
-
- 2 edited
-
flashrom.8 (modified) (2 diffs)
-
rayer_spi.c (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/flashrom.8
r1412 r1437 211 211 .BR "* dediprog" " (for SPI flash ROMs attached to a Dediprog SF100)" 212 212 .sp 213 .BR "* rayer_spi" " (for SPI flash ROMs attached to a RayeR parport \214 based programmer)" 213 .BR "* rayer_spi" " (for SPI flash ROMs attached to a RayeR parport " 214 or Xilinx DLC5 compatible cable) 215 215 .sp 216 216 .BR "* nicintel_spi" " (for SPI flash ROMs on Intel Gigabit network cards)" … … 513 513 four. Make sure to not forget the "0x" prefix for hexadecimal port addresses. 514 514 .sp 515 More information about the hardware is available at 516 .BR http://rayer.ic.cz/elektro/spipgm.htm . 515 The default cable type is the RayeR cable. You can use the optional 516 .B type 517 parameter to specify the cable type with the 518 .sp 519 .B " flashrom \-p rayer_spi:type=model" 520 .sp 521 syntax where 522 .B model 523 can be 524 .BR rayer " for the RayeR cable or " xilinx " for the Xilinx Parallel Cable III 525 (DLC 5). 526 .sp 527 More information about the RayeR hardware is available at 528 .BR "http://rayer.ic.cz/elektro/spipgm.htm " . 529 The schematic of the Xilinx DLC 5 was published at 530 .BR "http://www.xilinx.com/itp/xilinx4/data/docs/pac/appendixb.html " . 517 531 .TP 518 532 .BR "ogp_spi " programmer -
trunk/rayer_spi.c
r1299 r1437 32 32 33 33 #include <stdlib.h> 34 #include <string.h> 34 35 #include "flash.h" 35 36 #include "programmer.h" 36 37 38 enum rayer_type { 39 TYPE_RAYER, 40 TYPE_XILINX_DLC5, 41 }; 42 37 43 /* We have two sets of pins, out and in. The numbers for both sets are 38 44 * independent and are bitshift values, not real pin numbers. 45 * Default settings are for the the RayeR hardware. 39 46 */ 40 47 /* Pins for master->slave direction */ 41 #define SPI_CS_PIN 5 42 #define SPI_SCK_PIN 6 43 #define SPI_MOSI_PIN 7 48 static int rayer_cs_bit = 5; 49 static int rayer_sck_bit = 6; 50 static int rayer_mosi_bit = 7; 44 51 /* Pins for slave->master direction */ 45 #define SPI_MISO_PIN 6 52 static int rayer_miso_bit = 6; 46 53 47 54 static uint16_t lpt_iobase; … … 52 59 static void rayer_bitbang_set_cs(int val) 53 60 { 54 lpt_outbyte &= ~(1 << SPI_CS_PIN);55 lpt_outbyte |= (val << SPI_CS_PIN);61 lpt_outbyte &= ~(1 << rayer_cs_bit); 62 lpt_outbyte |= (val << rayer_cs_bit); 56 63 OUTB(lpt_outbyte, lpt_iobase); 57 64 } … … 59 66 static void rayer_bitbang_set_sck(int val) 60 67 { 61 lpt_outbyte &= ~(1 << SPI_SCK_PIN);62 lpt_outbyte |= (val << SPI_SCK_PIN);68 lpt_outbyte &= ~(1 << rayer_sck_bit); 69 lpt_outbyte |= (val << rayer_sck_bit); 63 70 OUTB(lpt_outbyte, lpt_iobase); 64 71 } … … 66 73 static void rayer_bitbang_set_mosi(int val) 67 74 { 68 lpt_outbyte &= ~(1 << SPI_MOSI_PIN);69 lpt_outbyte |= (val << SPI_MOSI_PIN);75 lpt_outbyte &= ~(1 << rayer_mosi_bit); 76 lpt_outbyte |= (val << rayer_mosi_bit); 70 77 OUTB(lpt_outbyte, lpt_iobase); 71 78 } … … 76 83 77 84 tmp = INB(lpt_iobase + 1); 78 tmp = (tmp >> SPI_MISO_PIN) & 0x1;85 tmp = (tmp >> rayer_miso_bit) & 0x1; 79 86 return tmp; 80 87 } … … 90 97 int rayer_spi_init(void) 91 98 { 92 char *portpos = NULL; 99 char *arg = NULL; 100 enum rayer_type rayer_type = TYPE_RAYER; 93 101 94 102 /* Non-default port requested? */ 95 portpos= extract_programmer_param("iobase");96 if ( portpos) {103 arg = extract_programmer_param("iobase"); 104 if (arg) { 97 105 char *endptr = NULL; 98 106 unsigned long tmp; 99 tmp = strtoul( portpos, &endptr, 0);107 tmp = strtoul(arg, &endptr, 0); 100 108 /* Port 0, port >0x10000, unaligned ports and garbage strings 101 109 * are rejected. … … 110 118 "given was invalid.\nIt must be a multiple of " 111 119 "0x4 and lie between 0x100 and 0xfffc.\n"); 112 free( portpos);120 free(arg); 113 121 return 1; 114 122 } else { … … 121 129 lpt_iobase = 0x378; 122 130 } 123 free( portpos);131 free(arg); 124 132 125 133 msg_pdbg("Using address 0x%x as I/O base for parallel port access.\n", 126 134 lpt_iobase); 135 136 arg = extract_programmer_param("type"); 137 if (arg) { 138 if (!strcasecmp(arg, "rayer")) { 139 rayer_type = TYPE_RAYER; 140 } else if (!strcasecmp(arg, "xilinx")) { 141 rayer_type = TYPE_XILINX_DLC5; 142 } else { 143 msg_perr("Error: Invalid device type specified.\n"); 144 free(arg); 145 return 1; 146 } 147 } 148 free(arg); 149 switch (rayer_type) { 150 case TYPE_RAYER: 151 msg_pdbg("Using RayeR SPIPGM pinout.\n"); 152 /* Bits for master->slave direction */ 153 rayer_cs_bit = 5; 154 rayer_sck_bit = 6; 155 rayer_mosi_bit = 7; 156 /* Bits for slave->master direction */ 157 rayer_miso_bit = 6; 158 break; 159 case TYPE_XILINX_DLC5: 160 msg_pdbg("Using Xilinx Parallel Cable III (DLC 5) pinout.\n"); 161 /* Bits for master->slave direction */ 162 rayer_cs_bit = 2; 163 rayer_sck_bit = 1; 164 rayer_mosi_bit = 0; 165 /* Bits for slave->master direction */ 166 rayer_miso_bit = 4; 167 } 127 168 128 169 get_io_perms();
Note: See TracChangeset
for help on using the changeset viewer.
