Changeset 1437 for trunk


Ignore:
Timestamp:
09/12/11 08:17:06 (8 months ago)
Author:
hailfinger
Message:

Add support for Xilinx parallel III (DLC5) programing cable

The rayer_spi driver defaults to the RayeR cable, but selecting other
predefined pin layouts with the type= parameter is possible:
flashrom -p rayer_spi:type=xilinx

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@…>
Acked-by: Stefan Tauner <stefan.tauner@…>

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/flashrom.8

    r1412 r1437  
    211211.BR "* dediprog" " (for SPI flash ROMs attached to a Dediprog SF100)" 
    212212.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 " 
     214or Xilinx DLC5 compatible cable) 
    215215.sp 
    216216.BR "* nicintel_spi" " (for SPI flash ROMs on Intel Gigabit network cards)" 
     
    513513four. Make sure to not forget the "0x" prefix for hexadecimal port addresses. 
    514514.sp 
    515 More information about the hardware is available at 
    516 .BR http://rayer.ic.cz/elektro/spipgm.htm . 
     515The default cable type is the RayeR cable. You can use the optional 
     516.B type 
     517parameter to specify the cable type with the 
     518.sp 
     519.B "  flashrom \-p rayer_spi:type=model" 
     520.sp 
     521syntax where 
     522.B model 
     523can be 
     524.BR rayer " for the RayeR cable or " xilinx " for the Xilinx Parallel Cable III 
     525(DLC 5). 
     526.sp 
     527More information about the RayeR hardware is available at 
     528.BR "http://rayer.ic.cz/elektro/spipgm.htm " . 
     529The schematic of the Xilinx DLC 5 was published at 
     530.BR "http://www.xilinx.com/itp/xilinx4/data/docs/pac/appendixb.html " . 
    517531.TP 
    518532.BR "ogp_spi " programmer 
  • trunk/rayer_spi.c

    r1299 r1437  
    3232 
    3333#include <stdlib.h> 
     34#include <string.h> 
    3435#include "flash.h" 
    3536#include "programmer.h" 
    3637 
     38enum rayer_type { 
     39        TYPE_RAYER, 
     40        TYPE_XILINX_DLC5, 
     41}; 
     42 
    3743/* We have two sets of pins, out and in. The numbers for both sets are 
    3844 * independent and are bitshift values, not real pin numbers. 
     45 * Default settings are for the the RayeR hardware. 
    3946 */ 
    4047/* Pins for master->slave direction */ 
    41 #define SPI_CS_PIN 5 
    42 #define SPI_SCK_PIN 6 
    43 #define SPI_MOSI_PIN 7 
     48static int rayer_cs_bit = 5; 
     49static int rayer_sck_bit = 6; 
     50static int rayer_mosi_bit = 7; 
    4451/* Pins for slave->master direction */ 
    45 #define SPI_MISO_PIN 6 
     52static int rayer_miso_bit = 6; 
    4653 
    4754static uint16_t lpt_iobase; 
     
    5259static void rayer_bitbang_set_cs(int val) 
    5360{ 
    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); 
    5663        OUTB(lpt_outbyte, lpt_iobase); 
    5764} 
     
    5966static void rayer_bitbang_set_sck(int val) 
    6067{ 
    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); 
    6370        OUTB(lpt_outbyte, lpt_iobase); 
    6471} 
     
    6673static void rayer_bitbang_set_mosi(int val) 
    6774{ 
    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); 
    7077        OUTB(lpt_outbyte, lpt_iobase); 
    7178} 
     
    7683 
    7784        tmp = INB(lpt_iobase + 1); 
    78         tmp = (tmp >> SPI_MISO_PIN) & 0x1; 
     85        tmp = (tmp >> rayer_miso_bit) & 0x1; 
    7986        return tmp; 
    8087} 
     
    9097int rayer_spi_init(void) 
    9198{ 
    92         char *portpos = NULL; 
     99        char *arg = NULL; 
     100        enum rayer_type rayer_type = TYPE_RAYER; 
    93101 
    94102        /* Non-default port requested? */ 
    95         portpos = extract_programmer_param("iobase"); 
    96         if (portpos) { 
     103        arg = extract_programmer_param("iobase"); 
     104        if (arg) { 
    97105                char *endptr = NULL; 
    98106                unsigned long tmp; 
    99                 tmp = strtoul(portpos, &endptr, 0); 
     107                tmp = strtoul(arg, &endptr, 0); 
    100108                /* Port 0, port >0x10000, unaligned ports and garbage strings 
    101109                 * are rejected. 
     
    110118                                 "given was invalid.\nIt must be a multiple of " 
    111119                                 "0x4 and lie between 0x100 and 0xfffc.\n"); 
    112                         free(portpos); 
     120                        free(arg); 
    113121                        return 1; 
    114122                } else { 
     
    121129                lpt_iobase = 0x378; 
    122130        } 
    123         free(portpos); 
     131        free(arg); 
    124132         
    125133        msg_pdbg("Using address 0x%x as I/O base for parallel port access.\n", 
    126134                 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        } 
    127168 
    128169        get_io_perms(); 
Note: See TracChangeset for help on using the changeset viewer.