- Timestamp:
- 10/20/11 14:57:14 (7 months ago)
- Location:
- trunk
- Files:
-
- 3 edited
-
ich_descriptors.c (modified) (1 diff)
-
ich_descriptors.h (modified) (1 diff)
-
ichspi.c (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ich_descriptors.c
r1443 r1452 214 214 } 215 215 216 /** Returns the integer representation of the component density with index 217 idx in bytes or 0 if a correct size can not be determined. */ 218 int getFCBA_component_density(const struct ich_descriptors *desc, uint8_t idx) 219 { 220 uint8_t size_enc; 221 222 switch(idx) { 223 case 0: 224 size_enc = desc->component.comp1_density; 225 break; 226 case 1: 227 if (desc->content.NC == 0) 228 return 0; 229 size_enc = desc->component.comp2_density; 230 break; 231 default: 232 msg_perr("Only ICH SPI component index 0 or 1 are supported " 233 "yet.\n"); 234 return 0; 235 } 236 if (size_enc > 5) { 237 msg_perr("Density of ICH SPI component with index %d is " 238 "invalid. Encoded density is 0x%x.\n", idx, size_enc); 239 return 0; 240 } 241 return (1 << (19 + size_enc)); 242 } 243 216 244 static uint32_t read_descriptor_reg(uint8_t section, uint16_t offset, void *spibar) 217 245 { -
trunk/ich_descriptors.h
r1443 r1452 256 256 257 257 int read_ich_descriptors_via_fdo(void *spibar, struct ich_descriptors *desc); 258 int getFCBA_component_density(const struct ich_descriptors *desc, uint8_t idx); 258 259 259 260 #endif /* __ICH_DESCRIPTORS_H__ */ -
trunk/ichspi.c
r1449 r1452 27 27 28 28 #include <string.h> 29 #include <stdlib.h> 29 30 #include "flash.h" 30 31 #include "programmer.h" … … 1080 1081 return result; 1081 1082 } 1083 1084 #if 0 1085 /* Sets FLA in FADDR to (addr & 0x01FFFFFF) without touching other bits. */ 1086 static void ich_hwseq_set_addr(uint32_t addr) 1087 { 1088 uint32_t addr_old = REGREAD32(ICH9_REG_FADDR) & ~0x01FFFFFF; 1089 REGWRITE32(ICH9_REG_FADDR, (addr & 0x01FFFFFF) | addr_old); 1090 } 1091 1092 /* Sets FADDR.FLA to 'addr' and returns the erase block size in bytes 1093 * of the block containing this address. May return nonsense if the address is 1094 * not valid. The erase block size for a specific address depends on the flash 1095 * partition layout as specified by FPB and the partition properties as defined 1096 * by UVSCC and LVSCC respectively. An alternative to implement this method 1097 * would be by querying FPB and the respective VSCC register directly. 1098 */ 1099 static uint32_t ich_hwseq_get_erase_block_size(unsigned int addr) 1100 { 1101 uint8_t enc_berase; 1102 static const uint32_t const dec_berase[4] = { 1103 256, 1104 4 * 1024, 1105 8 * 1024, 1106 64 * 1024 1107 }; 1108 1109 ich_hwseq_set_addr(addr); 1110 enc_berase = (REGREAD16(ICH9_REG_HSFS) & HSFS_BERASE) >> 1111 HSFS_BERASE_OFF; 1112 return dec_berase[enc_berase]; 1113 } 1114 1115 /* Polls for Cycle Done Status, Flash Cycle Error or timeout in 8 us intervals. 1116 Resets all error flags in HSFS. 1117 Returns 0 if the cycle completes successfully without errors within 1118 timeout us, 1 on errors. */ 1119 static int ich_hwseq_wait_for_cycle_complete(unsigned int timeout, 1120 unsigned int len) 1121 { 1122 uint16_t hsfs; 1123 uint32_t addr; 1124 1125 timeout /= 8; /* scale timeout duration to counter */ 1126 while ((((hsfs = REGREAD16(ICH9_REG_HSFS)) & 1127 (HSFS_FDONE | HSFS_FCERR)) == 0) && 1128 --timeout) { 1129 programmer_delay(8); 1130 } 1131 REGWRITE16(ICH9_REG_HSFS, REGREAD16(ICH9_REG_HSFS)); 1132 if (!timeout) { 1133 addr = REGREAD32(ICH9_REG_FADDR) & 0x01FFFFFF; 1134 msg_perr("Timeout error between offset 0x%08x and " 1135 "0x%08x + %d (=0x%08x)!\n", 1136 addr, addr, len - 1, addr + len - 1); 1137 prettyprint_ich9_reg_hsfs(hsfs); 1138 prettyprint_ich9_reg_hsfc(REGREAD16(ICH9_REG_HSFC)); 1139 return 1; 1140 } 1141 1142 if (hsfs & HSFS_FCERR) { 1143 addr = REGREAD32(ICH9_REG_FADDR) & 0x01FFFFFF; 1144 msg_perr("Transaction error between offset 0x%08x and " 1145 "0x%08x (=0x%08x + %d)!\n", 1146 addr, addr + len - 1, addr, len - 1); 1147 prettyprint_ich9_reg_hsfs(hsfs); 1148 prettyprint_ich9_reg_hsfc(REGREAD16(ICH9_REG_HSFC)); 1149 return 1; 1150 } 1151 return 0; 1152 } 1153 #endif 1082 1154 1083 1155 static int ich_spi_send_multicommand(struct spi_command *cmds) … … 1251 1323 uint16_t spibar_offset, tmp2; 1252 1324 uint32_t tmp; 1253 int ichspi_desc= 0;1325 int desc_valid = 0; 1254 1326 1255 1327 switch (ich_generation) { 1256 1328 case 7: 1257 register_spi_programmer(&spi_programmer_ich7);1258 1329 spibar_offset = 0x3020; 1259 1330 break; 1260 1331 case 8: 1261 register_spi_programmer(&spi_programmer_ich9);1262 1332 spibar_offset = 0x3020; 1263 1333 break; … … 1265 1335 case 10: 1266 1336 default: /* Future version might behave the same */ 1267 register_spi_programmer(&spi_programmer_ich9);1268 1337 spibar_offset = 0x3800; 1269 1338 break; … … 1276 1345 ich_spibar = rcrb + spibar_offset; 1277 1346 1278 switch ( spi_programmer->type) {1279 case SPI_CONTROLLER_ICH7:1347 switch (ich_generation) { 1348 case 7: 1280 1349 msg_pdbg("0x00: 0x%04x (SPIS)\n", 1281 1350 mmio_readw(ich_spibar + 0)); … … 1314 1383 } 1315 1384 ich_set_bbar(ich_generation, 0); 1385 register_spi_programmer(&spi_programmer_ich7); 1316 1386 ich_init_opcodes(); 1317 1387 break; 1318 case SPI_CONTROLLER_ICH9: 1388 case 8: 1389 case 9: 1390 case 10: 1391 default: /* Future version might behave the same */ 1319 1392 tmp2 = mmio_readw(ich_spibar + ICH9_REG_HSFS); 1320 1393 msg_pdbg("0x04: 0x%04x (HSFS)\n", tmp2); … … 1325 1398 } 1326 1399 if (tmp2 & HSFS_FDV) 1327 ichspi_desc= 1;1328 if (!(tmp2 & HSFS_FDOPSS) && ichspi_desc)1400 desc_valid = 1; 1401 if (!(tmp2 & HSFS_FDOPSS) && desc_valid) 1329 1402 msg_pinfo("The Flash Descriptor Security Override " 1330 1403 "Strap-Pin is set. Restrictions implied\n" … … 1401 1474 1402 1475 msg_pdbg("\n"); 1403 if ( ichspi_desc) {1476 if (desc_valid) { 1404 1477 struct ich_descriptors desc = {{ 0 }}; 1405 1478 if (read_ich_descriptors_via_fdo(ich_spibar, &desc) == … … 1408 1481 &desc); 1409 1482 } 1483 register_spi_programmer(&spi_programmer_ich9); 1410 1484 ich_init_opcodes(); 1411 break;1412 default:1413 /* Nothing */1414 1485 break; 1415 1486 }
Note: See TracChangeset
for help on using the changeset viewer.
