Changeset 272 for trunk/spi.c
- Timestamp:
- Jun 24, 2008 3:22:03 AM (5 years ago)
- File:
-
- 1 edited
-
trunk/spi.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/spi.c
r239 r272 83 83 uint32_t manuf_id; 84 84 uint32_t model_id; 85 if (!spi_rdid(readarr)) { 86 if (!oddparity(readarr[0])) 87 printf_debug("RDID byte 0 parity violation.\n"); 88 /* Check if this is a continuation vendor ID */ 89 if (readarr[0] == 0x7f) { 90 if (!oddparity(readarr[1])) 91 printf_debug("RDID byte 1 parity violation.\n"); 92 manuf_id = (readarr[0] << 8) | readarr[1]; 93 model_id = readarr[2]; 94 } else { 95 manuf_id = readarr[0]; 96 model_id = (readarr[1] << 8) | readarr[2]; 97 } 98 printf_debug("%s: id1 0x%x, id2 0x%x\n", __FUNCTION__, manuf_id, model_id); 99 if (manuf_id == flash->manufacture_id && 100 model_id == flash->model_id) { 101 /* Print the status register to tell the 102 * user about possible write protection. 103 */ 104 spi_prettyprint_status_register(flash); 105 106 return 1; 107 } 108 /* Test if this is a pure vendor match. */ 109 if (manuf_id == flash->manufacture_id && 110 GENERIC_DEVICE_ID == flash->model_id) 111 return 1; 112 } 85 86 if (spi_rdid(readarr)) 87 return 0; 88 89 if (!oddparity(readarr[0])) 90 printf_debug("RDID byte 0 parity violation.\n"); 91 92 /* Check if this is a continuation vendor ID */ 93 if (readarr[0] == 0x7f) { 94 if (!oddparity(readarr[1])) 95 printf_debug("RDID byte 1 parity violation.\n"); 96 manuf_id = (readarr[0] << 8) | readarr[1]; 97 model_id = readarr[2]; 98 } else { 99 manuf_id = readarr[0]; 100 model_id = (readarr[1] << 8) | readarr[2]; 101 } 102 103 printf_debug("%s: id1 0x%x, id2 0x%x\n", __FUNCTION__, manuf_id, model_id); 104 105 if (manuf_id == flash->manufacture_id && 106 model_id == flash->model_id) { 107 /* Print the status register to tell the 108 * user about possible write protection. 109 */ 110 spi_prettyprint_status_register(flash); 111 112 return 1; 113 } 114 115 /* Test if this is a pure vendor match. */ 116 if (manuf_id == flash->manufacture_id && 117 GENERIC_DEVICE_ID == flash->model_id) 118 return 1; 113 119 114 120 return 0; … … 119 125 unsigned char readarr[3]; 120 126 uint32_t model_id; 121 if (!spi_rdid(readarr)) { 122 /* Check if RDID returns 0xff 0xff 0xff, then we use RES. */ 123 if ((readarr[0] != 0xff) || (readarr[1] != 0xff) || 124 (readarr[2] != 0xff)) 125 return 0; 126 } else { 127 128 if (spi_rdid(readarr)) 127 129 /* We couldn't issue RDID, it's pointless to try RES. */ 128 130 return 0; 129 } 130 if (!spi_res(readarr)) { 131 model_id = readarr[0]; 132 printf_debug("%s: id 0x%x\n", __FUNCTION__, model_id); 133 if (model_id == flash->model_id) { 134 /* Print the status register to tell the 135 * user about possible write protection. 136 */ 137 spi_prettyprint_status_register(flash); 138 139 return 1; 140 } 141 } 142 143 return 0; 131 132 /* Check if RDID returns 0xff 0xff 0xff, then we use RES. */ 133 if ((readarr[0] != 0xff) || (readarr[1] != 0xff) || 134 (readarr[2] != 0xff)) 135 return 0; 136 137 if (spi_res(readarr)) 138 return 0; 139 140 model_id = readarr[0]; 141 printf_debug("%s: id 0x%x\n", __FUNCTION__, model_id); 142 if (model_id != flash->model_id) 143 return 0; 144 145 /* Print the status register to tell the 146 * user about possible write protection. 147 */ 148 spi_prettyprint_status_register(flash); 149 return 1; 144 150 } 145 151
Note: See TracChangeset
for help on using the changeset viewer.
