Changeset 3399 for trunk/util/flashrom/spi.c
- Timestamp:
- 06/30/08 23:45:17 (5 months ago)
- Files:
-
- 1 modified
-
trunk/util/flashrom/spi.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/util/flashrom/spi.c
r3398 r3399 45 45 } 46 46 47 static int spi_rdid(unsigned char *readarr )47 static int spi_rdid(unsigned char *readarr, int bytes) 48 48 { 49 49 const unsigned char cmd[JEDEC_RDID_OUTSIZE] = {JEDEC_RDID}; 50 50 51 if (spi_command(JEDEC_RDID_OUTSIZE, JEDEC_RDID_INSIZE, cmd, readarr))51 if (spi_command(JEDEC_RDID_OUTSIZE, bytes, cmd, readarr)) 52 52 return 1; 53 53 printf_debug("RDID returned %02x %02x %02x.\n", readarr[0], readarr[1], readarr[2]); … … 81 81 } 82 82 83 int probe_spi_rdid(struct flashchip *flash)84 { 85 unsigned char readarr[ 3];83 static int probe_spi_rdid_generic(struct flashchip *flash, int bytes) 84 { 85 unsigned char readarr[4]; 86 86 uint32_t manuf_id; 87 87 uint32_t model_id; 88 88 89 if (spi_rdid(readarr ))89 if (spi_rdid(readarr, bytes)) 90 90 return 0; 91 91 … … 99 99 manuf_id = (readarr[0] << 8) | readarr[1]; 100 100 model_id = readarr[2]; 101 if (bytes > 3) { 102 model_id <<= 8; 103 model_id |= readarr[3]; 104 } 101 105 } else { 102 106 manuf_id = readarr[0]; … … 124 128 } 125 129 130 int probe_spi_rdid(struct flashchip *flash) { 131 return probe_spi_rdid_generic(flash, 3); 132 } 133 134 /* support 4 bytes flash ID */ 135 int 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 126 143 int probe_spi_res(struct flashchip *flash) 127 144 { … … 129 146 uint32_t model_id; 130 147 131 if (spi_rdid(readarr ))148 if (spi_rdid(readarr, 3)) 132 149 /* We couldn't issue RDID, it's pointless to try RES. */ 133 150 return 0;
