Show
Ignore:
Timestamp:
06/30/08 23:45:17 (5 months ago)
Author:
ruik
Message:

Mine AMIC flash chip needs 4 bytes RDID. Following patch adds support for that.

Signed-off-by: Rudolf Marek <r.marek@…>
Acked-by: Peter Stuge <peter@…>

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/util/flashrom/spi.c

    r3398 r3399  
    4545} 
    4646 
    47 static int spi_rdid(unsigned char *readarr) 
     47static int spi_rdid(unsigned char *readarr, int bytes) 
    4848{ 
    4949        const unsigned char cmd[JEDEC_RDID_OUTSIZE] = {JEDEC_RDID}; 
    5050 
    51         if (spi_command(JEDEC_RDID_OUTSIZE, JEDEC_RDID_INSIZE, cmd, readarr)) 
     51        if (spi_command(JEDEC_RDID_OUTSIZE, bytes, cmd, readarr)) 
    5252                return 1; 
    5353        printf_debug("RDID returned %02x %02x %02x.\n", readarr[0], readarr[1], readarr[2]); 
     
    8181} 
    8282 
    83 int probe_spi_rdid(struct flashchip *flash) 
    84 { 
    85         unsigned char readarr[3]; 
     83static int probe_spi_rdid_generic(struct flashchip *flash, int bytes) 
     84{ 
     85        unsigned char readarr[4]; 
    8686        uint32_t manuf_id; 
    8787        uint32_t model_id; 
    8888 
    89         if (spi_rdid(readarr)) 
     89        if (spi_rdid(readarr, bytes)) 
    9090                return 0; 
    9191 
     
    9999                manuf_id = (readarr[0] << 8) | readarr[1]; 
    100100                model_id = readarr[2]; 
     101                if (bytes > 3) { 
     102                        model_id <<= 8; 
     103                        model_id |= readarr[3]; 
     104                } 
    101105        } else { 
    102106                manuf_id = readarr[0]; 
     
    124128} 
    125129 
     130int probe_spi_rdid(struct flashchip *flash) { 
     131        return probe_spi_rdid_generic(flash, 3); 
     132} 
     133 
     134/* support 4 bytes flash ID */ 
     135int probe_spi_rdid4(struct flashchip *flash) { 
     136 
     137        /* only some SPI chipsets support 4 bytes commands */ 
     138        if (!((ich7_detected) || (ich9_detected) || (viaspi_detected))) 
     139                return 0; 
     140        return probe_spi_rdid_generic(flash, 4); 
     141} 
     142 
    126143int probe_spi_res(struct flashchip *flash) 
    127144{ 
     
    129146        uint32_t model_id; 
    130147 
    131         if (spi_rdid(readarr)) 
     148        if (spi_rdid(readarr, 3)) 
    132149                /* We couldn't issue RDID, it's pointless to try RES. */ 
    133150                return 0;