Changeset 1397
- Timestamp:
- 07/28/11 10:13:25 (10 months ago)
- Location:
- trunk
- Files:
-
- 20 edited
-
82802ab.c (modified) (5 diffs)
-
a25.c (modified) (4 diffs)
-
bitbang_spi.c (modified) (1 diff)
-
board_enable.c (modified) (31 diffs)
-
buspirate_spi.c (modified) (4 diffs)
-
chipset_enable.c (modified) (34 diffs)
-
cli_classic.c (modified) (4 diffs)
-
dediprog.c (modified) (20 diffs)
-
dmi.c (modified) (4 diffs)
-
drkaiser.c (modified) (1 diff)
-
dummyflasher.c (modified) (2 diffs)
-
flashrom.c (modified) (27 diffs)
-
ft2232_spi.c (modified) (5 diffs)
-
gfxnvidia.c (modified) (1 diff)
-
hwaccess.h (modified) (1 diff)
-
ichspi.c (modified) (1 diff)
-
it85spi.c (modified) (12 diffs)
-
it87spi.c (modified) (9 diffs)
-
pcidev.c (modified) (1 diff)
-
physmap.c (modified) (15 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/82802ab.c
r1353 r1397 30 30 #include "chipdrivers.h" 31 31 32 // I need that Berkeley bit-map printer33 32 void print_status_82802ab(uint8_t status) 34 33 { … … 45 44 { 46 45 chipaddr bios = flash->virtual_memory; 47 uint8_t id1, id2; 48 uint8_t flashcontent1, flashcontent2; 46 uint8_t id1, id2, flashcontent1, flashcontent2; 49 47 int shifted = (flash->feature_bits & FEATURE_ADDR_SHIFTED) != 0; 50 48 … … 70 68 msg_cdbg(", id1 parity violation"); 71 69 72 /* Read the product ID location again. We should now see normal flash contents. */ 70 /* 71 * Read the product ID location again. We should now see normal 72 * flash contents. 73 */ 73 74 flashcontent1 = chip_readb(bios + (0x00 << shifted)); 74 75 flashcontent2 = chip_readb(bios + (0x01 << shifted)); … … 113 114 114 115 for (i = 0; i < flash->total_size * 1024; i+= flash->page_size) 115 {116 116 chip_writeb(0, flash->virtual_registers + i + 2); 117 } 118 119 return 0; 120 } 121 122 int erase_block_82802ab(struct flashchip *flash, unsigned int page,unsigned int pagesize)117 118 return 0; 119 } 120 121 int erase_block_82802ab(struct flashchip *flash, unsigned int page, 122 unsigned int pagesize) 123 123 { 124 124 chipaddr bios = flash->virtual_memory; … … 179 179 can_unlock = 1; 180 180 } 181 181 182 182 /* Read block lock-bits */ 183 183 for (i = 0; i < flash->total_size * 1024; i+= (64 * 1024)) { -
trunk/a25.c
r1316 r1397 32 32 33 33 msg_cdbg("Chip status register: Status Register Write Disable " 34 "(SRWD) is %sset\n", (status & (1 << 7)) ? "" : "not ");34 "(SRWD) is %sset\n", (status & (1 << 7)) ? "" : "not "); 35 35 spi_prettyprint_status_register_bit(status, 6); 36 36 spi_prettyprint_status_register_bit(status, 5); … … 49 49 50 50 msg_cdbg("Chip status register: Status Register Write Disable " 51 "(SRWD) is %sset\n", (status & (1 << 7)) ? "" : "not ");51 "(SRWD) is %sset\n", (status & (1 << 7)) ? "" : "not "); 52 52 spi_prettyprint_status_register_bit(status, 6); 53 53 spi_prettyprint_status_register_bit(status, 5); … … 65 65 66 66 msg_cdbg("Chip status register: Status Register Write Disable " 67 "(SRWD) is %sset\n", (status & (1 << 7)) ? "" : "not ");67 "(SRWD) is %sset\n", (status & (1 << 7)) ? "" : "not "); 68 68 msg_cdbg("Chip status register: Sector Protect Size (SEC) " 69 69 "is %i KB\n", (status & (1 << 6)) ? 4 : 64); … … 84 84 85 85 msg_cdbg("Chip status register: Status Register Write Disable " 86 "(SRWD) is %sset\n", (status & (1 << 7)) ? "" : "not ");86 "(SRWD) is %sset\n", (status & (1 << 7)) ? "" : "not "); 87 87 msg_cdbg("Chip status register: Sector Protect Size (SEC) " 88 88 "is %i KB\n", (status & (1 << 6)) ? 4 : 64); -
trunk/bitbang_spi.c
r1299 r1397 69 69 70 70 static const struct spi_programmer spi_programmer_bitbang = { 71 .type = SPI_CONTROLLER_BITBANG,72 .max_data_read = MAX_DATA_READ_UNLIMITED,73 .max_data_write = MAX_DATA_WRITE_UNLIMITED,74 .command = bitbang_spi_send_command,75 .multicommand = default_spi_send_multicommand,76 .read = default_spi_read,77 .write_256 = default_spi_write_256,71 .type = SPI_CONTROLLER_BITBANG, 72 .max_data_read = MAX_DATA_READ_UNLIMITED, 73 .max_data_write = MAX_DATA_WRITE_UNLIMITED, 74 .command = bitbang_spi_send_command, 75 .multicommand = default_spi_send_multicommand, 76 .read = default_spi_read, 77 .write_256 = default_spi_write_256, 78 78 }; 79 79 -
trunk/board_enable.c
r1396 r1397 180 180 UNIMPLEMENTED_PORT, 181 181 {w83627hf_port2_mux, 0x08, 0, 0xF0}, 182 UNIMPLEMENTED_PORT 182 UNIMPLEMENTED_PORT, 183 183 }; 184 184 … … 191 191 {0x2A, 0x01, 0x01}, 192 192 {0x2A, 0x01, 0x01}, 193 {0x2A, 0x01, 0x01} 193 {0x2A, 0x01, 0x01}, 194 194 }; 195 195 … … 200 200 UNIMPLEMENTED_PORT, 201 201 UNIMPLEMENTED_PORT, 202 UNIMPLEMENTED_PORT 202 UNIMPLEMENTED_PORT, 203 203 }; 204 204 … … 211 211 {0x2D, 0x20, 0x20}, /* or suspend LED */ 212 212 {0x2D, 0x40, 0x40}, /* or panel switch input */ 213 {0x2D, 0x80, 0x80} /* or panel switch output */213 {0x2D, 0x80, 0x80}, /* or panel switch output */ 214 214 }; 215 215 … … 219 219 UNIMPLEMENTED_PORT, /* GPIO3 */ 220 220 {w83627thf_port4_mux, 0x09, 1, 0xF4}, 221 UNIMPLEMENTED_PORT /* GPIO5 */221 UNIMPLEMENTED_PORT, /* GPIO5 */ 222 222 }; 223 223 … … 562 562 id = sio_read(0x2E, 0x20); 563 563 if (id != chipid) { 564 msg_perr("PC8736x: unexpected ID %02x (expected %02x)\n", id, chipid); 564 msg_perr("PC8736x: unexpected ID %02x (expected %02x)\n", 565 id, chipid); 565 566 return -1; 566 567 } … … 812 813 struct pci_dev *dev; 813 814 814 dev = pci_dev_find(0x10DE, 0x0050); /* NVIDIA CK804 ISA Bridge. */815 dev = pci_dev_find(0x10DE, 0x0050); /* NVIDIA CK804 ISA bridge. */ 815 816 if (!dev) { 816 817 msg_perr("\nERROR: NVIDIA nForce4 ISA bridge not found.\n"); … … 818 819 } 819 820 820 /* one of those bits seems to be connected to TBL#, but -ENOINFO. */821 /* One of those bits seems to be connected to TBL#, but -ENOINFO. */ 821 822 pci_write_byte(dev, 0x92, 0); 822 823 … … 852 853 { 853 854 struct pci_dev *dev; 854 uint16_t base; 855 uint16_t devclass; 855 uint16_t base, devclass; 856 856 uint8_t tmp; 857 857 … … 861 861 } 862 862 863 /* First, check the ISA Bridge */863 /* First, check the ISA bridge */ 864 864 dev = pci_dev_find_vendorclass(0x10DE, 0x0601); 865 865 switch (dev->device_id) { … … 1093 1093 /* 1094 1094 * Suited for: 1095 * - A susA8AE-LE (Codename AmberineM; used in Compaq Presario 061)1095 * - ASUS A8AE-LE (Codename AmberineM; used in Compaq Presario 061) 1096 1096 * Datasheet(s) used: 1097 1097 * - AMD document 43009 "AMD SB700/710/750 Register Reference Guide" rev. 1.00 … … 1102 1102 uint32_t reg; 1103 1103 1104 dev = pci_dev_find(0x1002, 0x4372); /* AMD SMBus Controller */1104 dev = pci_dev_find(0x1002, 0x4372); /* AMD SMBus controller */ 1105 1105 if (!dev) { 1106 1106 msg_perr("\nERROR: AMD SMBus Controller (0x4372) not found.\n"); … … 1129 1129 uint32_t tmp, base; 1130 1130 1131 static const uint32_t nonmuxed_gpos = 0x58000101; /* GPPO {0,8,27,28,30} are always available */ 1131 /* GPPO {0,8,27,28,30} are always available */ 1132 static const uint32_t nonmuxed_gpos = 0x58000101; 1132 1133 1133 1134 static const struct {unsigned int reg, mask, value; } piix4_gpo[] = { 1134 {0},1135 {0xB0, 0x0001, 0x0000}, /* GPO1... */1136 {0xB0, 0x0001, 0x0000},1137 {0xB0, 0x0001, 0x0000},1138 {0xB0, 0x0001, 0x0000},1139 {0xB0, 0x0001, 0x0000},1140 {0xB0, 0x0001, 0x0000},1141 {0xB0, 0x0001, 0x0000}, /* ...GPO7: GENCFG bit 0 */1142 {0},1143 {0xB0, 0x0100, 0x0000}, /* GPO9: GENCFG bit 8 */1144 {0xB0, 0x0200, 0x0000}, /* GPO10: GENCFG bit 9 */1145 {0xB0, 0x0400, 0x0000}, /* GPO11: GENCFG bit 10 */1146 {0x4E, 0x0100, 0x0000}, /* GPO12... */1147 {0x4E, 0x0100, 0x0000},1148 {0x4E, 0x0100, 0x0000}, /* ...GPO14: XBCS bit 8 */1149 {0xB2, 0x0002, 0x0002}, /* GPO15... */1150 {0xB2, 0x0002, 0x0002}, /* ...GPO16: GENCFG bit 17 */1151 {0xB2, 0x0004, 0x0004}, /* GPO17: GENCFG bit 18 */1152 {0xB2, 0x0008, 0x0008}, /* GPO18: GENCFG bit 19 */1153 {0xB2, 0x0010, 0x0010}, /* GPO19: GENCFG bit 20 */1154 {0xB2, 0x0020, 0x0020}, /* GPO20: GENCFG bit 21 */1155 {0xB2, 0x0040, 0x0040}, /* GPO21: GENCFG bit 22 */1156 {0xB2, 0x1000, 0x1000}, /* GPO22... */1157 {0xB2, 0x1000, 0x1000}, /* ...GPO23: GENCFG bit 28 */1158 {0xB2, 0x2000, 0x2000}, /* GPO24: GENCFG bit 29 */1159 {0xB2, 0x4000, 0x4000}, /* GPO25: GENCFG bit 30 */1160 {0xB2, 0x8000, 0x8000}, /* GPO26: GENCFG bit 31 */1161 {0},1162 {0},1163 {0x4E, 0x0100, 0x0000}, /* ...GPO29: XBCS bit 8 */1164 {0}1135 {0}, 1136 {0xB0, 0x0001, 0x0000}, /* GPO1... */ 1137 {0xB0, 0x0001, 0x0000}, 1138 {0xB0, 0x0001, 0x0000}, 1139 {0xB0, 0x0001, 0x0000}, 1140 {0xB0, 0x0001, 0x0000}, 1141 {0xB0, 0x0001, 0x0000}, 1142 {0xB0, 0x0001, 0x0000}, /* ...GPO7: GENCFG bit 0 */ 1143 {0}, 1144 {0xB0, 0x0100, 0x0000}, /* GPO9: GENCFG bit 8 */ 1145 {0xB0, 0x0200, 0x0000}, /* GPO10: GENCFG bit 9 */ 1146 {0xB0, 0x0400, 0x0000}, /* GPO11: GENCFG bit 10 */ 1147 {0x4E, 0x0100, 0x0000}, /* GPO12... */ 1148 {0x4E, 0x0100, 0x0000}, 1149 {0x4E, 0x0100, 0x0000}, /* ...GPO14: XBCS bit 8 */ 1150 {0xB2, 0x0002, 0x0002}, /* GPO15... */ 1151 {0xB2, 0x0002, 0x0002}, /* ...GPO16: GENCFG bit 17 */ 1152 {0xB2, 0x0004, 0x0004}, /* GPO17: GENCFG bit 18 */ 1153 {0xB2, 0x0008, 0x0008}, /* GPO18: GENCFG bit 19 */ 1154 {0xB2, 0x0010, 0x0010}, /* GPO19: GENCFG bit 20 */ 1155 {0xB2, 0x0020, 0x0020}, /* GPO20: GENCFG bit 21 */ 1156 {0xB2, 0x0040, 0x0040}, /* GPO21: GENCFG bit 22 */ 1157 {0xB2, 0x1000, 0x1000}, /* GPO22... */ 1158 {0xB2, 0x1000, 0x1000}, /* ...GPO23: GENCFG bit 28 */ 1159 {0xB2, 0x2000, 0x2000}, /* GPO24: GENCFG bit 29 */ 1160 {0xB2, 0x4000, 0x4000}, /* GPO25: GENCFG bit 30 */ 1161 {0xB2, 0x8000, 0x8000}, /* GPO26: GENCFG bit 31 */ 1162 {0}, 1163 {0}, 1164 {0x4E, 0x0100, 0x0000}, /* ...GPO29: XBCS bit 8 */ 1165 {0} 1165 1166 }; 1166 1167 1167 1168 1168 dev = pci_dev_find(0x8086, 0x7110); /* Intel PIIX4 ISA bridge */ … … 1178 1178 } 1179 1179 1180 if ( (((1 << gpo) & nonmuxed_gpos) == 0) && 1181 (pci_read_word(dev, piix4_gpo[gpo].reg) & piix4_gpo[gpo].mask) != piix4_gpo[gpo].value ) { 1182 msg_perr("\nERROR: PIIX4 GPO%d not programmed for output.\n", gpo); 1183 return -1; 1180 if ((((1 << gpo) & nonmuxed_gpos) == 0) && 1181 (pci_read_word(dev, piix4_gpo[gpo].reg) 1182 & piix4_gpo[gpo].mask) != piix4_gpo[gpo].value) { 1183 msg_perr("\nERROR: PIIX4 GPO%d not programmed for output.\n", 1184 gpo); 1185 return -1; 1184 1186 } 1185 1187 … … 1316 1318 device_class = pci_read_word(dev, PCI_CLASS_DEVICE); 1317 1319 if ((dev->vendor_id == 0x8086) && 1318 (device_class == 0x0601)) { /* ISA Bridge */1320 (device_class == 0x0601)) { /* ISA bridge */ 1319 1321 /* Is this device in our list? */ 1320 1322 for (i = 0; intel_ich_gpio_table[i].id; i++) … … 1328 1330 1329 1331 if (!dev) { 1330 msg_perr("\nERROR: No Known Intel LPC Bridge found.\n");1332 msg_perr("\nERROR: No known Intel LPC bridge found.\n"); 1331 1333 return -1; 1332 1334 } … … 1348 1350 1349 1351 if (!allowed) { 1350 msg_perr("\nERROR: This Intel LPC Bridge does not allow"1351 " setting GPIO%02d\n", gpio);1352 return -1; 1353 } 1354 1355 msg_pdbg("\nIntel ICH LPC Bridge: %sing GPIO%02d.\n",1356 raise ? "Rais" : "Dropp", gpio);1352 msg_perr("\nERROR: This Intel LPC bridge does not allow" 1353 " setting GPIO%02d\n", gpio); 1354 return -1; 1355 } 1356 1357 msg_pdbg("\nIntel ICH LPC bridge: %sing GPIO%02d.\n", 1358 raise ? "Rais" : "Dropp", gpio); 1357 1359 1358 1360 if (gpio < 32) { … … 1372 1374 tmp = INL(base); 1373 1375 if (!(tmp & (1 << gpio))) { 1374 msg_perr("\nERROR: This Intel LPC Bridge"1376 msg_perr("\nERROR: This Intel LPC bridge" 1375 1377 " does not allow setting GPIO%02d\n", 1376 1378 gpio); … … 1404 1406 tmp = INL(base + 30); 1405 1407 if (!(tmp & (1 << gpio))) { 1406 msg_perr("\nERROR: This Intel LPC Bridge"1408 msg_perr("\nERROR: This Intel LPC bridge" 1407 1409 " does not allow setting GPIO%02d\n", 1408 1410 gpio + 32); … … 1433 1435 tmp = INL(base + 40); 1434 1436 if (!(tmp & (1 << gpio))) { 1435 msg_perr("\nERROR: This Intel LPC Bridge does "1437 msg_perr("\nERROR: This Intel LPC bridge does " 1436 1438 "not allow setting GPIO%02d\n", gpio + 64); 1437 1439 return -1; … … 1608 1610 int ret; 1609 1611 1610 /* vendor BIOS ends up in LDN6... maybe the board enable is wrong,1612 /* Vendor BIOS ends up in LDN6... maybe the board enable is wrong, 1611 1613 * or perhaps it's not needed at all? 1612 * the regs it tries to touch are 0xF0, 0xF1, 0xF2 which means if it1613 * were in the right LDN, it would have to be GPIO1 or GPIO3 1614 * The regs it tries to touch are 0xF0, 0xF1, 0xF2 which means if it 1615 * were in the right LDN, it would have to be GPIO1 or GPIO3. 1614 1616 */ 1615 1617 /* … … 1660 1662 { 1661 1663 struct pci_dev *dev; 1662 uint32_t base; 1663 uint32_t tmp; 1664 1665 /* VT82C686 Power management */ 1664 uint32_t base, tmp; 1665 1666 /* VT82C686 power management */ 1666 1667 dev = pci_dev_find(0x1106, 0x3057); 1667 1668 if (!dev) { … … 1671 1672 1672 1673 msg_pdbg("\nVIA Apollo ACPI: %sing GPIO%02d.\n", 1673 raise ? "Rais" : "Dropp", gpio);1674 1675 /* select GPO function on multiplexed pins*/1674 raise ? "Rais" : "Dropp", gpio); 1675 1676 /* Select GPO function on multiplexed pins. */ 1676 1677 tmp = pci_read_byte(dev, 0x54); 1677 switch(gpio) 1678 { 1679 case 0: 1680 tmp &= ~0x03; 1681 break; 1682 case 1: 1683 tmp |= 0x04; 1684 break; 1685 case 2: 1686 tmp |= 0x08; 1687 break; 1688 case 3: 1689 tmp |= 0x10; 1690 break; 1678 switch (gpio) { 1679 case 0: 1680 tmp &= ~0x03; 1681 break; 1682 case 1: 1683 tmp |= 0x04; 1684 break; 1685 case 2: 1686 tmp |= 0x08; 1687 break; 1688 case 3: 1689 tmp |= 0x10; 1690 break; 1691 1691 } 1692 1692 pci_write_byte(dev, 0x54, tmp); … … 1881 1881 if ((port > 4) || /* also catches unsigned -1 */ 1882 1882 ((port < 4) && (line > 7)) || ((port == 4) && (line > 5))) { 1883 msg_perr("\nERROR: Unsupported IT8712F GPIO line %02d.\n", line);1884 return -1;1883 msg_perr("\nERROR: Unsupported IT8712F GPIO line %02d.\n", line); 1884 return -1; 1885 1885 } 1886 1886 … … 1907 1907 } 1908 1908 1909 /* set GPIO. */1909 /* Set GPIO. */ 1910 1910 tmp = INB(base + port); 1911 1911 if (raise) … … 2092 2092 * Require main PCI IDs to match too as extra safety. 2093 2093 */ 2094 static const struct board_pciid_enable *board_match_coreboot_name( const char *vendor,2095 const char *part)2094 static const struct board_pciid_enable *board_match_coreboot_name( 2095 const char *vendor, const char *part) 2096 2096 { 2097 2097 const struct board_pciid_enable *board = board_pciid_enables; … … 2120 2120 msg_pinfo("AMBIGUOUS BOARD NAME: %s\n", part); 2121 2121 msg_pinfo("At least vendors '%s' and '%s' match.\n", 2122 partmatch->lb_vendor, board->lb_vendor);2122 partmatch->lb_vendor, board->lb_vendor); 2123 2123 msg_perr("Please use the full -m vendor:part syntax.\n"); 2124 2124 return NULL; … … 2136 2136 */ 2137 2137 msg_perr("\nUnknown vendor:board from -m option: %s:%s\n\n", 2138 vendor, part);2138 vendor, part); 2139 2139 } 2140 2140 return NULL; … … 2145 2145 * Second set of IDs can be main only or missing completely. 2146 2146 */ 2147 const static struct board_pciid_enable *board_match_pci_card_ids(enum board_match_phase phase) 2147 const static struct board_pciid_enable *board_match_pci_card_ids( 2148 enum board_match_phase phase) 2148 2149 { 2149 2150 const struct board_pciid_enable *board = board_pciid_enables; … … 2178 2179 if (!has_dmi_support) { 2179 2180 msg_perr("WARNING: Can't autodetect %s %s," 2180 " DMI info unavailable.\n",2181 board->vendor_name, board->board_name);2181 " DMI info unavailable.\n", 2182 board->vendor_name, board->board_name); 2182 2183 continue; 2183 2184 } else { … … 2203 2204 if (!force_boardenable) { 2204 2205 msg_pinfo("WARNING: Your mainboard is %s %s, but the mainboard-specific\n" 2205 "code has not been tested, and thus will not be executed by default.\n"2206 "Depending on your hardware environment, erasing, writing or even probing\n"2207 "can fail without running the board specific code.\n\n"2208 "Please see the man page (section PROGRAMMER SPECIFIC INFO, subsection\n"2209 "\"internal programmer\") for details.\n",2210 board->vendor_name, board->board_name);2206 "code has not been tested, and thus will not be executed by default.\n" 2207 "Depending on your hardware environment, erasing, writing or even probing\n" 2208 "can fail without running the board specific code.\n\n" 2209 "Please see the man page (section PROGRAMMER SPECIFIC INFO, subsection\n" 2210 "\"internal programmer\") for details.\n", 2211 board->vendor_name, board->board_name); 2211 2212 return 1; 2212 2213 } -
trunk/buspirate_spi.c
r1367 r1397 51 51 #endif 52 52 53 static int buspirate_sendrecv(unsigned char *buf, unsigned int writecnt, unsigned int readcnt) 53 static int buspirate_sendrecv(unsigned char *buf, unsigned int writecnt, 54 unsigned int readcnt) 54 55 { 55 56 int i, ret = 0; … … 91 92 92 93 static const struct spi_programmer spi_programmer_buspirate = { 93 .type = SPI_CONTROLLER_BUSPIRATE,94 .max_data_read = 12,95 .max_data_write = 12,96 .command = buspirate_spi_send_command,97 .multicommand = default_spi_send_multicommand,98 .read = default_spi_read,99 .write_256 = default_spi_write_256,94 .type = SPI_CONTROLLER_BUSPIRATE, 95 .max_data_read = 12, 96 .max_data_write = 12, 97 .command = buspirate_spi_send_command, 98 .multicommand = default_spi_send_multicommand, 99 .read = default_spi_read, 100 .write_256 = default_spi_write_256, 100 101 }; 101 102 … … 109 110 {"4M", 0x6}, 110 111 {"8M", 0x7}, 111 {NULL, 0x0} 112 {NULL, 0x0}, 112 113 }; 113 114 … … 150 151 { 151 152 unsigned char buf[512]; 152 int ret = 0; 153 int i; 153 int ret = 0, i, spispeed = 0x7; 154 154 char *dev = NULL; 155 155 char *speed = NULL; 156 int spispeed = 0x7;157 156 158 157 dev = extract_programmer_param("dev"); -
trunk/chipset_enable.c
r1396 r1397 78 78 newer = pci_read_byte(dev, 0x40); 79 79 if (newer != new) { 80 msg_pinfo("tried to set register 0x%x to 0x%x on %s failed (WARNING ONLY)\n", 0x40, new, name); 80 msg_pinfo("tried to set register 0x%x to 0x%x on %s " 81 "failed (WARNING ONLY)\n", 0x40, new, name); 81 82 msg_pinfo("Stuck at 0x%x\n", newer); 82 83 return -1; … … 88 89 { 89 90 struct pci_dev *sbdev; 90 91 91 92 sbdev = pci_dev_find_vendorclass(vendor, 0x0601); 92 93 if (!sbdev) … … 98 99 if (sbdev) 99 100 msg_pdbg("Found southbridge %04x:%04x at %02x:%02x:%01x\n", 100 sbdev->vendor_id, sbdev->device_id,101 sbdev->bus, sbdev->dev, sbdev->func);101 sbdev->vendor_id, sbdev->device_id, 102 sbdev->bus, sbdev->dev, sbdev->func); 102 103 return sbdev; 103 104 } … … 166 167 newer = pci_read_byte(sbdev, 0x45); 167 168 if (newer != new) { 168 msg_pinfo("tried to set register 0x%x to 0x%x on %s failed (WARNING ONLY)\n", 0x45, new, name); 169 msg_pinfo("tried to set register 0x%x to 0x%x on %s failed " 170 "(WARNING ONLY)\n", 0x45, new, name); 169 171 msg_pinfo("Stuck at 0x%x\n", newer); 170 172 ret = -1; … … 192 194 newer = pci_read_byte(sbdev, 0x45); 193 195 if (newer != new) { 194 msg_pinfo("tried to set register 0x%x to 0x%x on %s failed (WARNING ONLY)\n", 0x45, new, name); 196 msg_pinfo("tried to set register 0x%x to 0x%x on %s failed " 197 "(WARNING ONLY)\n", 0x45, new, name); 195 198 msg_pinfo("Stuck at 0x%x\n", newer); 196 199 ret = -1; … … 239 242 240 243 if (pci_read_word(dev, xbcs) != new) { 241 msg_pinfo("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n", xbcs, new, name); 244 msg_pinfo("tried to set 0x%x to 0x%x on %s failed " 245 "(WARNING ONLY)\n", xbcs, new, name); 242 246 return -1; 243 247 } … … 262 266 263 267 msg_pdbg("\nBIOS Lock Enable: %sabled, ", 264 (old & (1 << 1)) ? "en" : "dis");268 (old & (1 << 1)) ? "en" : "dis"); 265 269 msg_pdbg("BIOS Write Enable: %sabled, ", 266 (old & (1 << 0)) ? "en" : "dis");270 (old & (1 << 0)) ? "en" : "dis"); 267 271 msg_pdbg("BIOS_CNTL is 0x%x\n", old); 268 272 … … 272 276 * 1 = BIOS region SMM protection is enabled. 273 277 * The BIOS Region is not writable unless all processors are in SMM." 274 * In earlier chipsets this bit is reserved. */ 275 if (old & (1 << 5)) { 278 * In earlier chipsets this bit is reserved. 279 */ 280 if (old & (1 << 5)) 276 281 msg_pinfo("WARNING: BIOS region SMM protection is enabled!\n"); 277 }278 282 279 283 new = old | 1; … … 284 288 285 289 if (pci_read_byte(dev, bios_cntl) != new) { 286 msg_pinfo("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n", bios_cntl, new, name); 290 msg_pinfo("tried to set 0x%x to 0x%x on %s failed " 291 "(WARNING ONLY)\n", bios_cntl, new, name); 287 292 return -1; 288 293 } … … 305 310 { 306 311 uint32_t fwh_conf; 307 int i;308 312 char *idsel = NULL; 309 int tmp; 310 int max_decode_fwh_idsel = 0; 311 int max_decode_fwh_decode = 0; 313 int i, tmp, max_decode_fwh_idsel = 0, max_decode_fwh_decode = 0; 312 314 int contiguous = 1; 313 315 314 316 idsel = extract_programmer_param("fwh_idsel"); 315 317 if (idsel && strlen(idsel)) { 316 uint64_t fwh_idsel_old; 317 uint64_t fwh_idsel; 318 uint64_t fwh_idsel_old, fwh_idsel; 318 319 errno = 0; 319 320 /* Base 16, nothing else makes sense. */ … … 359 360 tmp = (fwh_conf >> (i * 4)) & 0xf; 360 361 msg_pdbg("\n0x%08x/0x%08x FWH IDSEL: 0x%x", 361 (0x1ff8 + i) * 0x80000,362 (0x1ff0 + i) * 0x80000,363 tmp);362 (0x1ff8 + i) * 0x80000, 363 (0x1ff0 + i) * 0x80000, 364 tmp); 364 365 if ((tmp == 0) && contiguous) { 365 366 max_decode_fwh_idsel = (8 - i) * 0x80000; … … 373 374 tmp = (fwh_conf >> (i * 4)) & 0xf; 374 375 msg_pdbg("\n0x%08x/0x%08x FWH IDSEL: 0x%x", 375 (0xff4 + i) * 0x100000,376 (0xff0 + i) * 0x100000,377 tmp);376 (0xff4 + i) * 0x100000, 377 (0xff0 + i) * 0x100000, 378 tmp); 378 379 if ((tmp == 0) && contiguous) { 379 380 max_decode_fwh_idsel = (8 - i) * 0x100000; … … 388 389 tmp = (fwh_conf >> (i + 0x8)) & 0x1; 389 390 msg_pdbg("\n0x%08x/0x%08x FWH decode %sabled", 390 (0x1ff8 + i) * 0x80000,391 (0x1ff0 + i) * 0x80000,392 tmp ? "en" : "dis");391 (0x1ff8 + i) * 0x80000, 392 (0x1ff0 + i) * 0x80000, 393 tmp ? "en" : "dis"); 393 394 if ((tmp == 1) && contiguous) { 394 395 max_decode_fwh_decode = (8 - i) * 0x80000; … … 400 401 tmp = (fwh_conf >> i) & 0x1; 401 402 msg_pdbg("\n0x%08x/0x%08x FWH decode %sabled", 402 (0xff4 + i) * 0x100000,403 (0xff0 + i) * 0x100000,404 tmp ? "en" : "dis");403 (0xff4 + i) * 0x100000, 404 (0xff0 + i) * 0x100000, 405 tmp ? "en" : "dis"); 405 406 if ((tmp == 1) && contiguous) { 406 407 max_decode_fwh_decode = (8 - i) * 0x100000; … … 421 422 static int enable_flash_poulsbo(struct pci_dev *dev, const char *name) 422 423 { 423 uint16_t old, new;424 int err;425 426 if ((err = enable_flash_ich(dev, name, 0xd8)) != 0)427 return err;428 429 old = pci_read_byte(dev, 0xd9);430 msg_pdbg("BIOS Prefetch Enable: %sabled, ",431 (old & 1) ? "en" : "dis");432 new = old & ~1;433 434 if (new != old)435 rpci_write_byte(dev, 0xd9, new);424 uint16_t old, new; 425 int err; 426 427 if ((err = enable_flash_ich(dev, name, 0xd8)) != 0) 428 return err; 429 430 old = pci_read_byte(dev, 0xd9); 431 msg_pdbg("BIOS Prefetch Enable: %sabled, ", 432 (old & 1) ? "en" : "dis"); 433 new = old & ~1; 434 435 if (new != old) 436 rpci_write_byte(dev, 0xd9, new); 436 437 437 438 buses_supported = BUS_FWH; 438 return 0; 439 } 440 439 return 0; 440 } 441 441 442 442 #define ICH_STRAP_RSVD 0x00 … … 458 458 uint32_t tmp, gcs; 459 459 void *rcrb; 460 //TODO: These names are incorrect for EP80579. For that, the solution would look like the commented line 461 //static const char *straps_names[] = {"SPI", "reserved", "reserved", "LPC" }; 460 461 /* 462 * TODO: These names are incorrect for EP80579. For that, the solution 463 * would look like the commented line below. 464 */ 465 // static const char *straps_names[] = {"SPI", "reserved", "reserved", "LPC" }; 462 466 static const char *straps_names[] = { "reserved", "SPI", "PCI", "LPC" }; 463 467 … … 475 479 msg_pdbg("GCS = 0x%x: ", gcs); 476 480 msg_pdbg("BIOS Interface Lock-Down: %sabled, ", 477 (gcs & 0x1) ? "en" : "dis");481 (gcs & 0x1) ? "en" : "dis"); 478 482 bbs = (gcs >> 10) & 0x3; 479 483 msg_pdbg("BOOT BIOS Straps: 0x%x (%s)\n", bbs, straps_names[bbs]); … … 481 485 buc = mmio_readb(rcrb + 0x3414); 482 486 msg_pdbg("Top Swap : %s\n", 483 (buc & 1) ? "enabled (A16 inverted)" : "not enabled");487 (buc & 1) ? "enabled (A16 inverted)" : "not enabled"); 484 488 485 489 /* It seems the ICH7 does not support SPI and LPC chips at the same … … 490 494 buses_supported = BUS_FWH; 491 495 if (ich_generation == 7) { 492 if (bbs == ICH_STRAP_LPC) {496 if (bbs == ICH_STRAP_LPC) { 493 497 /* No further SPI initialization required */ 494 498 return ret; 495 } 496 else 499 } else { 497 500 /* Disable LPC/FWH if strapped to PCI or SPI */ 498 501 buses_supported = 0; 499 } 500 501 /* this adds BUS_SPI */ 502 } 503 } 504 505 /* This adds BUS_SPI */ 502 506 if (ich_init_spi(dev, tmp, rcrb, ich_generation) != 0) { 503 if (!ret)504 ret = ERROR_NONFATAL;505 }507 if (!ret) 508 ret = ERROR_NONFATAL; 509 } 506 510 507 511 return ret; … … 533 537 534 538 val = pci_read_byte(dev, 0x71); 535 if (val & 0x40) 536 { 539 if (val & 0x40) { 537 540 msg_pdbg("Disabling byte merging\n"); 538 541 val &= ~0x40; … … 546 549 uint8_t val; 547 550 548 /* enable ROM decode range (1MB) FFC00000 - FFFFFFFF*/551 /* Enable ROM decode range (1MB) FFC00000 - FFFFFFFF. */ 549 552 rpci_write_byte(dev, 0x41, 0x7f); 550 553 … … 556 559 if (pci_read_byte(dev, 0x40) != val) { 557 560 msg_pinfo("\nWARNING: Failed to enable flash write on \"%s\"\n", 558 name);561 name); 559 562 return -1; 560 563 } 561 564 562 565 if (dev->device_id == 0x3227) { /* VT8237R */ 563 /* All memory cycles, not just ROM ones, go to LPC. */564 val = pci_read_byte(dev, 0x59);565 val &= ~0x80;566 rpci_write_byte(dev, 0x59, val);566 /* All memory cycles, not just ROM ones, go to LPC. */ 567 val = pci_read_byte(dev, 0x59); 568 val &= ~0x80; 569 rpci_write_byte(dev, 0x59, val); 567 570 } 568 571 … … 672 675 673 676 if (new != 0xee) { 674 msg_pinfo("tried to set register 0x%x to 0x%x on %s failed (WARNING ONLY)\n", 0x52, new, name); 677 msg_pinfo("tried to set register 0x%x to 0x%x on %s failed " 678 "(WARNING ONLY)\n", 0x52, new, name); 675 679 return -1; 676 680 } … … 690 694 rpci_write_byte(dev, 0x43, new); 691 695 if (pci_read_byte(dev, 0x43) != new) { 692 msg_pinfo("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n", 0x43, new, name); 696 msg_pinfo("tried to set 0x%x to 0x%x on %s failed " 697 "(WARNING ONLY)\n", 0x43, new, name); 693 698 } 694 699 } … … 702 707 703 708 if (pci_read_byte(dev, 0x40) != new) { 704 msg_pinfo("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n", 0x40, new, name); 709 msg_pinfo("tried to set 0x%x to 0x%x on %s failed " 710 "(WARNING ONLY)\n", 0x40, new, name); 705 711 return -1; 706 712 } … … 722 728 continue; 723 729 msg_pinfo("SB600 %s%sprotected from 0x%08x to 0x%08x\n", 724 (prot & 0x1) ? "write " : "",725 (prot & 0x2) ? "read " : "",726 (prot & 0xfffff800),727 (prot & 0xfffff800) + (((prot & 0x7fc) << 8) | 0x3ff));730 (prot & 0x1) ? "write " : "", 731 (prot & 0x2) ? "read " : "", 732 (prot & 0xfffff800), 733 (prot & 0xfffff800) + (((prot & 0x7fc) << 8) | 0x3ff)); 728 734 prot &= 0xfffffffc; 729 735 rpci_write_byte(dev, reg, prot); … … 731 737 if (prot & 0x3) 732 738 msg_perr("SB600 %s%sunprotect failed from 0x%08x to 0x%08x\n", 733 (prot & 0x1) ? "write " : "",734 (prot & 0x2) ? "read " : "",735 (prot & 0xfffff800),736 (prot & 0xfffff800) + (((prot & 0x7fc) << 8) | 0x3ff));739 (prot & 0x1) ? "write " : "", 740 (prot & 0x2) ? "read " : "", 741 (prot & 0xfffff800), 742 (prot & 0xfffff800) + (((prot & 0x7fc) << 8) | 0x3ff)); 737 743 } 738 744 … … 801 807 rpci_write_byte(dev, 0x88, new); 802 808 if (pci_read_byte(dev, 0x88) != new) { 803 msg_pinfo("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n", 0x88, new, name); 809 msg_pinfo("tried to set 0x%x to 0x%x on %s failed " 810 "(WARNING ONLY)\n", 0x88, new, name); 804 811 } 805 812 } … … 812 819 813 820 if (pci_read_byte(dev, 0x6d) != new) { 814 msg_pinfo("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n", 0x6d, new, name); 821 msg_pinfo("tried to set 0x%x to 0x%x on %s failed " 822 "(WARNING ONLY)\n", 0x6d, new, name); 815 823 return -1; 816 824 } … … 895 903 896 904 if (pci_read_byte(dev, 0x6d) != new) { 897 msg_pinfo("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n", 0x6d, new, name); 905 msg_pinfo("tried to set 0x%x to 0x%x on %s failed " 906 "(WARNING ONLY)\n", 0x6d, new, name); 898 907 return -1; 899 908 } … … 909 918 static int enable_flash_mcp6x_7x(struct pci_dev *dev, const char *name) 910 919 { 911 int ret = 0; 912 int want_spi = 0; 920 int ret = 0, want_spi = 0; 913 921 uint8_t val; 914 922 … … 953 961 #endif 954 962 955 if (mcp6x_spi_init(want_spi)) {963 if (mcp6x_spi_init(want_spi)) 956 964 ret = 1; 957 } 965 958 966 out_msg: 959 967 msg_pinfo("Please send the output of \"flashrom -V\" to " … … 1021 1029 } 1022 1030 } else { 1023 msg_pinfo("AMD Elan SC520 detected, but no BOOTCS. Assuming flash at 4G\n"); 1031 msg_pinfo("AMD Elan SC520 detected, but no BOOTCS. " 1032 "Assuming flash at 4G\n"); 1024 1033 } 1025 1034 … … 1270 1279 } else if (ret < 0) 1271 1280 msg_pinfo("FAILED!\n"); 1272 else if (ret == 0)1281 else if (ret == 0) 1273 1282 msg_pinfo("OK.\n"); 1274 else if (ret == ERROR_NONFATAL)1283 else if (ret == ERROR_NONFATAL) 1275 1284 msg_pinfo("PROBLEMS, continuing anyway\n"); 1276 1285 } -
trunk/cli_classic.c
r1386 r1397 104 104 struct flashchip flashes[3]; 105 105 struct flashchip *fill_flash; 106 int startchip = 0;107 int chipcount = 0;108 106 const char *name; 109 int namelen; 110 int opt; 111 int option_index = 0; 112 int force = 0; 107 int startchip = 0, chipcount = 0, namelen, opt, option_index = 0; 113 108 int read_it = 0, write_it = 0, erase_it = 0, verify_it = 0; 114 int dont_verify_it = 0, list_supported = 0 ;109 int dont_verify_it = 0, list_supported = 0, force = 0; 115 110 #if CONFIG_PRINT_WIKI == 1 116 111 int list_supported_wiki = 0; 117 112 #endif 118 int operation_specified = 0; 119 int i; 120 int ret = 0; 113 int operation_specified = 0, i, ret = 0; 121 114 122 115 static const char optstring[] = "r:Rw:v:nVEfc:m:l:i:p:Lzh"; 123 116 static const struct option long_options[] = { 124 {"read", 1, NULL, 'r'},125 {"write", 1, NULL, 'w'},126 {"erase", 0, NULL, 'E'},127 {"verify", 1, NULL, 'v'},128 {"noverify", 0, NULL, 'n'},129 {"chip", 1, NULL, 'c'},130 {"mainboard", 1, NULL, 'm'},131 {"verbose", 0, NULL, 'V'},132 {"force", 0, NULL, 'f'},133 {"layout", 1, NULL, 'l'},134 {"image", 1, NULL, 'i'},135 {"list-supported", 0, NULL, 'L'},136 {"list-supported-wiki", 0, NULL, 'z'},137 {"programmer", 1, NULL, 'p'},138 {"help", 0, NULL, 'h'},139 {"version", 0, NULL, 'R'},140 {NULL, 0, NULL, 0}117 {"read", 1, NULL, 'r'}, 118 {"write", 1, NULL, 'w'}, 119 {"erase", 0, NULL, 'E'}, 120 {"verify", 1, NULL, 'v'}, 121 {"noverify", 0, NULL, 'n'}, 122 {"chip", 1, NULL, 'c'}, 123 {"mainboard", 1, NULL, 'm'}, 124 {"verbose", 0, NULL, 'V'}, 125 {"force", 0, NULL, 'f'}, 126 {"layout", 1, NULL, 'l'}, 127 {"image", 1, NULL, 'i'}, 128 {"list-supported", 0, NULL, 'L'}, 129 {"list-supported-wiki", 0, NULL, 'z'}, 130 {"programmer", 1, NULL, 'p'}, 131 {"help", 0, NULL, 'h'}, 132 {"version", 0, NULL, 'R'}, 133 {NULL, 0, NULL, 0}, 141 134 }; 142 135 143 136 char *filename = NULL; 144 145 137 char *tempstr = NULL; 146 138 char *pparam = NULL; … … 356 348 chip_to_probe); 357 349 printf("Run flashrom -L to view the hardware supported " 358 "in this flashrom version.\n");350 "in this flashrom version.\n"); 359 351 exit(1); 360 352 } … … 385 377 for (i = 1; i < chipcount; i++) 386 378 printf(", \"%s\"", flashes[i].name); 387 printf("\nPlease specify which chip to use with the -c <chipname> option.\n"); 379 printf("\nPlease specify which chip to use with the " 380 "-c <chipname> option.\n"); 388 381 ret = 1; 389 382 goto out_shutdown; … … 391 384 printf("No EEPROM/flash device found.\n"); 392 385 if (!force || !chip_to_probe) { 393 printf("Note: flashrom can never write if the flash chip isn't found automatically.\n"); 386 printf("Note: flashrom can never write if the flash " 387 "chip isn't found automatically.\n"); 394 388 } 395 389 if (force && read_it && chip_to_probe) { 396 printf("Force read (-f -r -c) requested, pretending the chip is there:\n"); 390 printf("Force read (-f -r -c) requested, pretending " 391 "the chip is there:\n"); 397 392 startchip = probe_flash(0, &flashes[0], 1); 398 393 if (startchip == -1) { 399 printf("Probing for flash chip '%s' failed.\n", chip_to_probe); 394 printf("Probing for flash chip '%s' failed.\n", 395 chip_to_probe); 400 396 ret = 1; 401 397 goto out_shutdown; 402 398 } 403 printf("Please note that forced reads most likely contain garbage.\n"); 399 printf("Please note that forced reads most likely " 400 "contain garbage.\n"); 404 401 return read_flash_to_file(&flashes[0], filename); 405 402 } -
trunk/dediprog.c
r1338 r1397 72 72 { 73 73 int ret, target_leds; 74 74 75 75 if (leds < 0 || leds > 7) 76 76 leds = 0; // Bogus value, enable all LEDs … … 93 93 } 94 94 95 ret = usb_control_msg(dediprog_handle, 0x42, 0x07, 0x09, target_leds, NULL, 0x0, DEFAULT_TIMEOUT); 95 ret = usb_control_msg(dediprog_handle, 0x42, 0x07, 0x09, target_leds, 96 NULL, 0x0, DEFAULT_TIMEOUT); 96 97 if (ret != 0x0) { 97 msg_perr("Command Set LED 0x%x failed (%s)!\n", leds, usb_strerror()); 98 msg_perr("Command Set LED 0x%x failed (%s)!\n", 99 leds, usb_strerror()); 98 100 return 1; 99 101 } … … 130 132 millivolt % 1000); 131 133 132 ret = usb_control_msg(dediprog_handle, 0x42, 0x9, voltage_selector, 0xff, NULL, 0x0, DEFAULT_TIMEOUT); 134 ret = usb_control_msg(dediprog_handle, 0x42, 0x9, voltage_selector, 135 0xff, NULL, 0x0, DEFAULT_TIMEOUT); 133 136 if (ret != 0x0) { 134 msg_perr("Command Set SPI Voltage 0x%x failed!\n", voltage_selector); 137 msg_perr("Command Set SPI Voltage 0x%x failed!\n", 138 voltage_selector); 135 139 return 1; 136 140 } … … 187 191 msg_pdbg("Setting SPI speed to %u kHz\n", khz); 188 192 189 ret = usb_control_msg(dediprog_handle, 0x42, 0x61, speed, 0xff, NULL, 0x0, DEFAULT_TIMEOUT); 193 ret = usb_control_msg(dediprog_handle, 0x42, 0x61, speed, 0xff, NULL, 194 0x0, DEFAULT_TIMEOUT); 190 195 if (ret != 0x0) { 191 196 msg_perr("Command Set SPI Speed 0x%x failed!\n", speed); … … 249 254 } 250 255 251 static int dediprog_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len) 256 static int dediprog_spi_read(struct flashchip *flash, uint8_t *buf, int start, 257 int len) 252 258 { 253 259 int ret; … … 294 300 } 295 301 296 static int dediprog_spi_write_256(struct flashchip *flash, uint8_t *buf, int start, int len) 302 static int dediprog_spi_write_256(struct flashchip *flash, uint8_t *buf, 303 int start, int len) 297 304 { 298 305 int ret; … … 328 335 } 329 336 330 ret = usb_control_msg(dediprog_handle, 0x42, 0x1, 0xff, readcnt ? 0x1 : 0x0, (char *)writearr, writecnt, DEFAULT_TIMEOUT); 337 ret = usb_control_msg(dediprog_handle, 0x42, 0x1, 0xff, 338 readcnt ? 0x1 : 0x0, (char *)writearr, writecnt, 339 DEFAULT_TIMEOUT); 331 340 if (ret != writecnt) { 332 341 msg_perr("Send SPI failed, expected %i, got %i %s!\n", … … 337 346 return 0; 338 347 memset(readarr, 0, readcnt); 339 ret = usb_control_msg(dediprog_handle, 0xc2, 0x01, 0xbb8, 0x0000, (char *)readarr, readcnt, DEFAULT_TIMEOUT); 348 ret = usb_control_msg(dediprog_handle, 0xc2, 0x01, 0xbb8, 0x0000, 349 (char *)readarr, readcnt, DEFAULT_TIMEOUT); 340 350 if (ret != readcnt) { 341 351 msg_perr("Receive SPI failed, expected %i, got %i %s!\n", … … 354 364 /* Command Prepare Receive Device String. */ 355 365 memset(buf, 0, sizeof(buf)); 356 ret = usb_control_msg(dediprog_handle, 0xc3, 0x7, 0x0, 0xef03, buf, 0x1, DEFAULT_TIMEOUT); 366 ret = usb_control_msg(dediprog_handle, 0xc3, 0x7, 0x0, 0xef03, buf, 367 0x1, DEFAULT_TIMEOUT); 357 368 /* The char casting is needed to stop gcc complaining about an always true comparison. */ 358 369 if ((ret != 0x1) || (buf[0] != (char)0xff)) { … … 363 374 /* Command Receive Device String. */ 364 375 memset(buf, 0, sizeof(buf)); 365 ret = usb_control_msg(dediprog_handle, 0xc2, 0x8, 0xff, 0xff, buf, 0x10, DEFAULT_TIMEOUT); 376 ret = usb_control_msg(dediprog_handle, 0xc2, 0x8, 0xff, 0xff, buf, 377 0x10, DEFAULT_TIMEOUT); 366 378 if (ret != 0x10) { 367 379 msg_perr("Incomplete/failed Command Receive Device String!\n"); … … 398 410 399 411 memset(buf, 0, sizeof(buf)); 400 ret = usb_control_msg(dediprog_handle, 0xc3, 0xb, 0x0, 0x0, buf, 0x1, DEFAULT_TIMEOUT); 412 ret = usb_control_msg(dediprog_handle, 0xc3, 0xb, 0x0, 0x0, buf, 413 0x1, DEFAULT_TIMEOUT); 401 414 if (ret < 0) { 402 415 msg_perr("Command A failed (%s)!\n", usb_strerror()); … … 421 434 422 435 memset(buf, 0, sizeof(buf)); 423 ret = usb_control_msg(dediprog_handle, 0xc3, 0x7, 0x0, 0xef00, buf, 0x3, DEFAULT_TIMEOUT); 436 ret = usb_control_msg(dediprog_handle, 0xc3, 0x7, 0x0, 0xef00, buf, 437 0x3, DEFAULT_TIMEOUT); 424 438 if (ret < 0) { 425 439 msg_perr("Command B failed (%s)!\n", usb_strerror()); … … 445 459 int ret; 446 460 447 ret = usb_control_msg(dediprog_handle, 0x42, 0x4, 0x0, 0x0, NULL, 0x0, DEFAULT_TIMEOUT); 461 ret = usb_control_msg(dediprog_handle, 0x42, 0x4, 0x0, 0x0, NULL, 462 0x0, DEFAULT_TIMEOUT); 448 463 if (ret != 0x0) { 449 464 msg_perr("Command C failed (%s)!\n", usb_strerror()); … … 465 480 466 481 memset(buf, 0, sizeof(buf)); 467 ret = usb_control_msg(dediprog_handle, 0xc2, 0x11, 0xff, 0xff, buf, 0x1, timeout); 482 ret = usb_control_msg(dediprog_handle, 0xc2, 0x11, 0xff, 0xff, buf, 483 0x1, timeout); 468 484 /* This check is most probably wrong. Command F always causes a timeout 469 485 * in the logs, so we should check for timeout instead of checking for … … 481 497 { 482 498 char *tmp = NULL; 483 int i; 484 int millivolt; 485 int fraction = 0; 499 int i, millivolt, fraction = 0; 486 500 487 501 if (!voltage || !strlen(voltage)) { … … 528 542 529 543 static const struct spi_programmer spi_programmer_dediprog = { 530 .type = SPI_CONTROLLER_DEDIPROG,531 .max_data_read = MAX_DATA_UNSPECIFIED,532 .max_data_write = MAX_DATA_UNSPECIFIED,533 .command = dediprog_spi_send_command,534 .multicommand = default_spi_send_multicommand,535 .read = dediprog_spi_read,536 .write_256 = dediprog_spi_write_256,544 .type = SPI_CONTROLLER_DEDIPROG, 545 .max_data_read = MAX_DATA_UNSPECIFIED, 546 .max_data_write = MAX_DATA_UNSPECIFIED, 547 .command = dediprog_spi_send_command, 548 .multicommand = default_spi_send_multicommand, 549 .read = dediprog_spi_read, 550 .write_256 = dediprog_spi_write_256, 537 551 }; 538 552 … … 561 575 struct usb_device *dev; 562 576 char *voltage; 563 int millivolt = 3500; 564 int ret; 577 int millivolt = 3500, ret; 565 578 566 579 msg_pspew("%s\n", __func__); … … 570 583 millivolt = parse_voltage(voltage); 571 584 free(voltage); 572 if (millivolt < 0) {585 if (millivolt < 0) 573 586 return 1; 574 }575 587 msg_pinfo("Setting voltage to %i mV\n", millivolt); 576 588 } … … 586 598 } 587 599 msg_pdbg("Found USB device (%04x:%04x).\n", 588 dev->descriptor.idVendor, 589 dev->descriptor.idProduct); 600 dev->descriptor.idVendor, dev->descriptor.idProduct); 590 601 dediprog_handle = usb_open(dev); 591 602 ret = usb_set_configuration(dediprog_handle, 1); … … 667 678 msg_pdbg("Sending RDID\n"); 668 679 buf[0] = JEDEC_RDID; 669 if (dediprog_spi_send_command(JEDEC_RDID_OUTSIZE, JEDEC_RDID_INSIZE, (unsigned char *)buf, (unsigned char *)buf)) 680 if (dediprog_spi_send_command(JEDEC_RDID_OUTSIZE, JEDEC_RDID_INSIZE, 681 (unsigned char *)buf, (unsigned char *)buf)) 670 682 return 1; 671 683 msg_pdbg("Receiving response: "); -
trunk/dmi.c
r1390 r1397 108 108 109 109 /* Kill lines starting with '#', as recent dmidecode versions 110 have the quirk to emit a "# SMBIOS implementations newer..." 111 message even on "-s" if the SMBIOS declares a 112 newer-than-supported version number, while it *should* only print 113 the requested string. */ 110 * have the quirk to emit a "# SMBIOS implementations newer..." 111 * message even on "-s" if the SMBIOS declares a 112 * newer-than-supported version number, while it *should* only print 113 * the requested string. 114 */ 114 115 do { 115 116 if (!fgets(answerbuf, DMI_MAX_ANSWER_LEN, dmidecode_pipe)) { 116 if (ferror(dmidecode_pipe)) {117 if (ferror(dmidecode_pipe)) { 117 118 msg_perr("DMI pipe read error\n"); 118 119 pclose(dmidecode_pipe); … … 122 123 } 123 124 } 124 } while (answerbuf[0] == '#');125 } while (answerbuf[0] == '#'); 125 126 126 127 /* Toss all output above DMI_MAX_ANSWER_LEN away to prevent … … 130 131 if (pclose(dmidecode_pipe) != 0) { 131 132 msg_pinfo("dmidecode execution unsuccessful - continuing " 132 "without DMI info\n");133 "without DMI info\n"); 133 134 return NULL; 134 135 } 135 136 136 137 /* Chomp trailing newline. */ 137 if (answerbuf[0] != 0 && 138 answerbuf[strlen(answerbuf) - 1] == '\n') 138 if (answerbuf[0] != 0 && answerbuf[strlen(answerbuf) - 1] == '\n') 139 139 answerbuf[strlen(answerbuf) - 1] = 0; 140 140 msg_pdbg("DMI string %s: \"%s\"\n", string_name, answerbuf); … … 197 197 static int dmi_compare(const char *value, const char *pattern) 198 198 { 199 int anchored = 0; 200 int patternlen; 199 int anchored = 0, patternlen; 201 200 202 201 msg_pspew("matching %s against %s\n", value, pattern); -
trunk/drkaiser.c
r1396 r1397 59 59 /* Write magic register to enable flash write. */ 60 60 rpci_write_word(pcidev_dev, PCI_MAGIC_DRKAISER_ADDR, 61 PCI_MAGIC_DRKAISER_VALUE);61 PCI_MAGIC_DRKAISER_VALUE); 62 62 63 63 /* Map 128kB flash memory window. */ -
trunk/dummyflasher.c
r1396 r1397 63 63 static int dummy_spi_send_command(unsigned int writecnt, unsigned int readcnt, 64 64 const unsigned char *writearr, unsigned char *readarr); 65 static int dummy_spi_write_256(struct flashchip *flash, uint8_t *buf, int start, int len); 65 static int dummy_spi_write_256(struct flashchip *flash, uint8_t *buf, 66 int start, int len); 66 67 67 68 static const struct spi_programmer spi_programmer_dummyflasher = { 68 .type = SPI_CONTROLLER_DUMMY,69 .max_data_read = MAX_DATA_READ_UNLIMITED,70 .max_data_write = MAX_DATA_UNSPECIFIED,71 .command = dummy_spi_send_command,72 .multicommand = default_spi_send_multicommand,73 .read = default_spi_read,74 .write_256 = dummy_spi_write_256,69 .type = SPI_CONTROLLER_DUMMY, 70 .max_data_read = MAX_DATA_READ_UNLIMITED, 71 .max_data_write = MAX_DATA_UNSPECIFIED, 72 .command = dummy_spi_send_command, 73 .multicommand = default_spi_send_multicommand, 74 .read = default_spi_read, 75 .write_256 = dummy_spi_write_256, 75 76 }; 76 77 … … 521 522 #endif 522 523 msg_pspew(" reading %u bytes:", readcnt); 523 for (i = 0; i < readcnt; i++) {524 for (i = 0; i < readcnt; i++) 524 525 msg_pspew(" 0x%02x", readarr[i]); 525 }526 526 msg_pspew("\n"); 527 527 return 0; 528 528 } 529 529 530 static int dummy_spi_write_256(struct flashchip *flash, uint8_t *buf, int start, int len) 530 static int dummy_spi_write_256(struct flashchip *flash, uint8_t *buf, 531 int start, int len) 531 532 { 532 533 return spi_write_chunked(flash, buf, start, len, -
trunk/flashrom.c
r1396 r1397 183 183 { 184 184 /* This programmer works for Realtek RTL8139 and SMC 1211. */ 185 .name = "nicrealtek",186 //.name = "nicsmc1211",187 .init = nicrealtek_init,188 .map_flash_region = fallback_map,189 .unmap_flash_region = fallback_unmap,190 .chip_readb = nicrealtek_chip_readb,191 .chip_readw = fallback_chip_readw,192 .chip_readl = fallback_chip_readl,193 .chip_readn = fallback_chip_readn,194 .chip_writeb = nicrealtek_chip_writeb,195 .chip_writew = fallback_chip_writew,196 .chip_writel = fallback_chip_writel,197 .chip_writen = fallback_chip_writen,198 .delay = internal_delay,185 .name = "nicrealtek", 186 //.name = "nicsmc1211", 187 .init = nicrealtek_init, 188 .map_flash_region = fallback_map, 189 .unmap_flash_region = fallback_unmap, 190 .chip_readb = nicrealtek_chip_readb, 191 .chip_readw = fallback_chip_readw, 192 .chip_readl = fallback_chip_readl, 193 .chip_readn = fallback_chip_readn, 194 .chip_writeb = nicrealtek_chip_writeb, 195 .chip_writew = fallback_chip_writew, 196 .chip_writel = fallback_chip_writel, 197 .chip_writen = fallback_chip_writen, 198 .delay = internal_delay, 199 199 }, 200 200 #endif … … 202 202 #if CONFIG_NICNATSEMI == 1 203 203 { 204 .name = "nicnatsemi",205 .init = nicnatsemi_init,206 .map_flash_region = fallback_map,207 .unmap_flash_region = fallback_unmap,208 .chip_readb = nicnatsemi_chip_readb,209 .chip_readw = fallback_chip_readw,210 .chip_readl = fallback_chip_readl,211 .chip_readn = fallback_chip_readn,212 .chip_writeb = nicnatsemi_chip_writeb,213 .chip_writew = fallback_chip_writew,214 .chip_writel = fallback_chip_writel,215 .chip_writen = fallback_chip_writen,216 .delay = internal_delay,204 .name = "nicnatsemi", 205 .init = nicnatsemi_init, 206 .map_flash_region = fallback_map, 207 .unmap_flash_region = fallback_unmap, 208 .chip_readb = nicnatsemi_chip_readb, 209 .chip_readw = fallback_chip_readw, 210 .chip_readl = fallback_chip_readl, 211 .chip_readn = fallback_chip_readn, 212 .chip_writeb = nicnatsemi_chip_writeb, 213 .chip_writew = fallback_chip_writew, 214 .chip_writel = fallback_chip_writel, 215 .chip_writen = fallback_chip_writen, 216 .delay = internal_delay, 217 217 }, 218 218 #endif … … 400 400 #if CONFIG_NICINTEL_SPI == 1 401 401 { 402 .name = "nicintel_spi",403 .init = nicintel_spi_init,404 .map_flash_region = fallback_map,405 .unmap_flash_region = fallback_unmap,406 .chip_readb = noop_chip_readb,407 .chip_readw = fallback_chip_readw,408 .chip_readl = fallback_chip_readl,409 .chip_readn = fallback_chip_readn,410 .chip_writeb = noop_chip_writeb,411 .chip_writew = fallback_chip_writew,412 .chip_writel = fallback_chip_writel,413 .chip_writen = fallback_chip_writen,414 .delay = internal_delay,402 .name = "nicintel_spi", 403 .init = nicintel_spi_init, 404 .map_flash_region = fallback_map, 405 .unmap_flash_region = fallback_unmap, 406 .chip_readb = noop_chip_readb, 407 .chip_readw = fallback_chip_readw, 408 .chip_readl = fallback_chip_readl, 409 .chip_readn = fallback_chip_readn, 410 .chip_writeb = noop_chip_writeb, 411 .chip_writew = fallback_chip_writew, 412 .chip_writel = fallback_chip_writel, 413 .chip_writen = fallback_chip_writen, 414 .delay = internal_delay, 415 415 }, 416 416 #endif … … 418 418 #if CONFIG_OGP_SPI == 1 419 419 { 420 .name = "ogp_spi",421 .init = ogp_spi_init,422 .map_flash_region = fallback_map,423 .unmap_flash_region = fallback_unmap,424 .chip_readb = noop_chip_readb,425 .chip_readw = fallback_chip_readw,426 .chip_readl = fallback_chip_readl,427 .chip_readn = fallback_chip_readn,428 .chip_writeb = noop_chip_writeb,429 .chip_writew = fallback_chip_writew,430 .chip_writel = fallback_chip_writel,431 .chip_writen = fallback_chip_writen,432 .delay = internal_delay,420 .name = "ogp_spi", 421 .init = ogp_spi_init, 422 .map_flash_region = fallback_map, 423 .unmap_flash_region = fallback_unmap, 424 .chip_readb = noop_chip_readb, 425 .chip_readw = fallback_chip_readw, 426 .chip_readl = fallback_chip_readl, 427 .chip_readn = fallback_chip_readn, 428 .chip_writeb = noop_chip_writeb, 429 .chip_writew = fallback_chip_writew, 430 .chip_writel = fallback_chip_writel, 431 .chip_writen = fallback_chip_writen, 432 .delay = internal_delay, 433 433 }, 434 434 #endif … … 504 504 .lpc = 0xffffffff, 505 505 .fwh = 0xffffffff, 506 .spi = 0xffffffff 506 .spi = 0xffffffff, 507 507 }; 508 508 buses_supported = BUS_NONE; … … 601 601 /* Flash registers live 4 MByte below the flash. */ 602 602 /* FIXME: This is incorrect for nonstandard flashbase. */ 603 flash->virtual_registers = (chipaddr)programmer_map_flash_region("flash chip registers", (0xFFFFFFFF - 0x400000 - size + 1), size); 603 flash->virtual_registers = (chipaddr)programmer_map_flash_region( 604 "flash chip registers", (0xFFFFFFFF - 0x400000 - size + 1), size); 604 605 } 605 606 … … 607 608 { 608 609 chip_readn(buf, flash->virtual_memory + start, len); 609 610 610 611 return 0; 611 612 } … … 686 687 param_pos = strstr(param_pos, needle); 687 688 } while (1); 688 689 689 690 if (param_pos) { 690 691 /* Get the string after needle and '='. */ … … 744 745 /* 745 746 * @cmpbuf buffer to compare against, cmpbuf[0] is expected to match the 746 flash content at location start747 * flash content at location start 747 748 * @start offset to the base address of the flash chip 748 749 * @len length of the verified area … … 750 751 * @return 0 for success, -1 for failure 751 752 */ 752 int verify_range(struct flashchip *flash, uint8_t *cmpbuf, int start, int len, const char *message) 753 { 754 int i, ret = 0; 753 int verify_range(struct flashchip *flash, uint8_t *cmpbuf, int start, int len, 754 const char *message) 755 { 756 int i, ret = 0, failcount = 0; 755 757 uint8_t *readbuf = malloc(len); 756 int failcount = 0;757 758 758 759 if (!len) … … 777 778 if (!message) 778 779 message = "VERIFY"; 779 780 780 781 ret = flash->read(flash, readbuf, start, len); 781 782 if (ret) { … … 797 798 if (failcount) { 798 799 msg_cerr(" failed byte count from 0x%08x-0x%08x: 0x%x\n", 799 start, start + len - 1, failcount);800 start, start + len - 1, failcount); 800 801 ret = -1; 801 802 } … … 832 833 int need_erase(uint8_t *have, uint8_t *want, int len, enum write_granularity gran) 833 834 { 834 int result = 0; 835 int i, j, limit; 835 int result = 0, i, j, limit; 836 836 837 837 switch (gran) { … … 899 899 int *first_start, enum write_granularity gran) 900 900 { 901 int need_write = 0, rel_start = 0, first_len = 0; 902 int i, limit, stride; 901 int need_write = 0, rel_start = 0, first_len = 0, i, limit, stride; 903 902 904 903 switch (gran) { … … 1081 1080 { 1082 1081 int limitexceeded = 0; 1083 if ((buses & BUS_PARALLEL) && 1084 (max_rom_decode.parallel < size)) {1082 1083 if ((buses & BUS_PARALLEL) && (max_rom_decode.parallel < size)) { 1085 1084 limitexceeded++; 1086 1085 msg_pdbg("Chip size %u kB is bigger than supported " 1087 "size %u kB of chipset/board/programmer "1088 "for %s interface, "1089 "probe/read/erase/write may fail. ", size / 1024,1090 max_rom_decode.parallel / 1024, "Parallel");1086 "size %u kB of chipset/board/programmer " 1087 "for %s interface, " 1088 "probe/read/erase/write may fail. ", size / 1024, 1089 max_rom_decode.parallel / 1024, "Parallel"); 1091 1090 } 1092 1091 if ((buses & BUS_LPC) && (max_rom_decode.lpc < size)) { 1093 1092 limitexceeded++; 1094 1093 msg_pdbg("Chip size %u kB is bigger than supported " 1095 "size %u kB of chipset/board/programmer "1096 "for %s interface, "1097 "probe/read/erase/write may fail. ", size / 1024,1098 max_rom_decode.lpc / 1024, "LPC");1094 "size %u kB of chipset/board/programmer " 1095 "for %s interface, " 1096 "probe/read/erase/write may fail. ", size / 1024, 1097 max_rom_decode.lpc / 1024, "LPC"); 1099 1098 } 1100 1099 if ((buses & BUS_FWH) && (max_rom_decode.fwh < size)) { 1101 1100 limitexceeded++; 1102 1101 msg_pdbg("Chip size %u kB is bigger than supported " 1103 "size %u kB of chipset/board/programmer "1104 "for %s interface, "1105 "probe/read/erase/write may fail. ", size / 1024,1106 max_rom_decode.fwh / 1024, "FWH");1102 "size %u kB of chipset/board/programmer " 1103 "for %s interface, " 1104 "probe/read/erase/write may fail. ", size / 1024, 1105 max_rom_decode.fwh / 1024, "FWH"); 1107 1106 } 1108 1107 if ((buses & BUS_SPI) && (max_rom_decode.spi < size)) { 1109 1108 limitexceeded++; 1110 1109 msg_pdbg("Chip size %u kB is bigger than supported " 1111 "size %u kB of chipset/board/programmer "1112 "for %s interface, "1113 "probe/read/erase/write may fail. ", size / 1024,1114 max_rom_decode.spi / 1024, "SPI");1110 "size %u kB of chipset/board/programmer " 1111 "for %s interface, " 1112 "probe/read/erase/write may fail. ", size / 1024, 1113 max_rom_decode.spi / 1024, "SPI"); 1115 1114 } 1116 1115 if (!limitexceeded) … … 1122 1121 /* FIXME: This message is designed towards CLI users. */ 1123 1122 msg_pdbg("There is at least one common chip/programmer " 1124 "interface which can support a chip of this size. "1125 "You can try --force at your own risk.\n");1123 "interface which can support a chip of this size. " 1124 "You can try --force at your own risk.\n"); 1126 1125 return 1; 1127 1126 } … … 1233 1232 } 1234 1233 1235 int read_buf_from_file(unsigned char *buf, unsigned long size, const char *filename) 1234 int read_buf_from_file(unsigned char *buf, unsigned long size, 1235 const char *filename) 1236 1236 { 1237 1237 unsigned long numbytes; … … 1266 1266 } 1267 1267 1268 int write_buf_to_file(unsigned char *buf, unsigned long size, const char *filename) 1268 int write_buf_to_file(unsigned char *buf, unsigned long size, 1269 const char *filename) 1269 1270 { 1270 1271 unsigned long numbytes; … … 1326 1327 static int selfcheck_eraseblocks(const struct flashchip *flash) 1327 1328 { 1328 int i, j, k; 1329 int ret = 0; 1329 int i, j, k, ret = 0; 1330 1330 1331 1331 for (k = 0; k < NUM_ERASEFUNCTIONS; k++) { … … 1358 1358 if (!done && eraser.block_erase) 1359 1359 msg_gspew("Strange: Empty eraseblock definition with " 1360 "non-empty erase function. Not an error.\n");1360 "non-empty erase function. Not an error.\n"); 1361 1361 if (!done) 1362 1362 continue; … … 1397 1397 unsigned int len)) 1398 1398 { 1399 int starthere = 0; 1400 int lenhere = 0; 1401 int ret = 0; 1402 int skip = 1; 1403 int writecount = 0; 1399 int starthere = 0, lenhere = 0, ret = 0, skip = 1, writecount = 0; 1404 1400 enum write_granularity gran = write_gran_256bytes; /* FIXME */ 1405 1401 … … 1456 1452 { 1457 1453 int i, j; 1458 unsigned int start = 0; 1459 unsigned int len; 1454 unsigned int start = 0, len; 1460 1455 struct block_eraser eraser = flash->block_erasers[erasefunction]; 1456 1461 1457 for (i = 0; i < NUM_ERASEREGIONS; i++) { 1462 1458 /* count==0 for all automatically initialized array … … 1505 1501 } 1506 1502 1507 int erase_and_write_flash(struct flashchip *flash, uint8_t *oldcontents, uint8_t *newcontents) 1503 int erase_and_write_flash(struct flashchip *flash, uint8_t *oldcontents, 1504 uint8_t *newcontents) 1508 1505 { 1509 1506 int k, ret = 1; … … 1592 1589 } 1593 1590 1594 /* The way to go if you want a delimited list of programmers */1591 /* The way to go if you want a delimited list of programmers */ 1595 1592 void list_programmers(const char *delim) 1596 1593 { … … 1607 1604 { 1608 1605 const char *pname; 1609 int pnamelen; 1610 int remaining = 0; 1611 int firstline = 1; 1606 int pnamelen, remaining = 0, firstline = 1, i; 1612 1607 enum programmer p; 1613 int i;1614 1608 1615 1609 for (p = 0; p < PROGRAMMER_INVALID; p++) { … … 1698 1692 { 1699 1693 msg_ginfo("flashrom is free software, get the source code at " 1700 "http://www.flashrom.org\n");1694 "http://www.flashrom.org\n"); 1701 1695 msg_ginfo("\n"); 1702 1696 } … … 1744 1738 ret = 1; 1745 1739 } 1746 #endif // CONFIG_INTERNAL == 11740 #endif 1747 1741 return ret; 1748 1742 } -
trunk/ft2232_spi.c
r1377 r1397 142 142 143 143 static const struct spi_programmer spi_programmer_ft2232 = { 144 .type = SPI_CONTROLLER_FT2232,145 .max_data_read = 64 * 1024,146 .max_data_write = 256,147 .command = ft2232_spi_send_command,148 .multicommand = default_spi_send_multicommand,149 .read = default_spi_read,150 .write_256 = default_spi_write_256,144 .type = SPI_CONTROLLER_FT2232, 145 .max_data_read = 64 * 1024, 146 .max_data_write = 256, 147 .command = ft2232_spi_send_command, 148 .multicommand = default_spi_send_multicommand, 149 .read = default_spi_read, 150 .write_256 = default_spi_write_256, 151 151 }; 152 152 … … 247 247 } 248 248 249 if (ftdi_usb_reset(ftdic) < 0) {249 if (ftdi_usb_reset(ftdic) < 0) 250 250 msg_perr("Unable to reset FTDI device\n"); 251 } 252 253 if (ftdi_set_latency_timer(ftdic, 2) < 0) { 251 252 if (ftdi_set_latency_timer(ftdic, 2) < 0) 254 253 msg_perr("Unable to set latency timer\n"); 255 } 256 257 if (ftdi_write_data_set_chunksize(ftdic, 256)) { 254 255 if (ftdi_write_data_set_chunksize(ftdic, 256)) 258 256 msg_perr("Unable to set chunk size\n"); 259 } 260 261 if (ftdi_set_bitmode(ftdic, 0x00, BITMODE_BITBANG_SPI) < 0) { 257 258 if (ftdi_set_bitmode(ftdic, 0x00, BITMODE_BITBANG_SPI) < 0) 262 259 msg_perr("Unable to set bitmode to SPI\n"); 263 }264 260 265 261 if (clock_5x) { … … 286 282 287 283 msg_pdbg("MPSSE clock: %f MHz divisor: %d " 288 "SPI clock: %f MHz\n", 289 mpsse_clk, DIVIDE_BY, 284 "SPI clock: %f MHz\n", mpsse_clk, DIVIDE_BY, 290 285 (double)(mpsse_clk / (((DIVIDE_BY - 1) + 1) * 2))); 291 286 … … 329 324 static unsigned char *buf = NULL; 330 325 /* failed is special. We use bitwise ops, but it is essentially bool. */ 331 int i = 0, ret = 0, failed = 0; 332 int bufsize; 326 int i = 0, ret = 0, failed = 0, bufsize; 333 327 static int oldbufsize = 0; 334 328 … … 380 374 /* We can't abort here, we still have to deassert CS#. */ 381 375 if (ret) 382 msg_perr("send_buf failed before read: %i\n", 383 ret); 376 msg_perr("send_buf failed before read: %i\n", ret); 384 377 i = 0; 385 378 if (ret == 0) { -
trunk/gfxnvidia.c
r1396 r1397 86 86 nvidia_bar = physmap("NVIDIA", io_base_addr, GFXNVIDIA_MEMMAP_SIZE); 87 87 88 /* must be done before rpci calls*/88 /* Must be done before rpci calls. */ 89 89 if (register_shutdown(gfxnvidia_shutdown, NULL)) 90 90 return 1; -
trunk/hwaccess.h
r1282 r1397 221 221 #define INL inportl 222 222 223 #else 223 #else 224 224 225 225 #define OUTB outb -
trunk/ichspi.c
r1396 r1397 363 363 int a; 364 364 365 for (a = 0; a < sizeof(POSSIBLE_OPCODES)/sizeof(POSSIBLE_OPCODES[0]); a++) {365 for (a = 0; a < ARRAY_SIZE(POSSIBLE_OPCODES); a++) { 366 366 if (POSSIBLE_OPCODES[a].opcode == opcode) 367 367 return POSSIBLE_OPCODES[a].spi_type; -
trunk/it85spi.c
r1396 r1397 91 91 * 1 -- timeout reached. 92 92 */ 93 static int wait_for( 94 const unsigned int mask, 95 const unsigned int expected_value, 96 const int timeout, /* in usec */ 97 const char* error_message, 98 const char* function_name, 99 const int lineno 100 ) { 93 static int wait_for(const unsigned int mask, const unsigned int expected_value, 94 const int timeout /* in usec */, const char *error_message, 95 const char *function_name, const int lineno) 96 { 101 97 int time_passed; 102 98 … … 113 109 } 114 110 115 /* IT8502 employs a scratch ramwhen flash is being updated. Call the following111 /* IT8502 employs a scratch RAM when flash is being updated. Call the following 116 112 * two functions before/after flash erase/program. */ 117 void it85xx_enter_scratch_rom() 118 { 119 int ret; 120 int tries; 113 void it85xx_enter_scratch_rom(void) 114 { 115 int ret, tries; 121 116 122 117 msg_pdbg("%s():%d was called ...\n", __FUNCTION__, __LINE__); 123 if (it85xx_scratch_rom_reenter > 0) return; 118 if (it85xx_scratch_rom_reenter > 0) 119 return; 124 120 125 121 #if 0 … … 128 124 * we find out the root cause. */ 129 125 ret = system("stop powerd >&2"); 130 if (ret) {126 if (ret) 131 127 msg_perr("Cannot stop powerd.\n"); 132 }133 128 #endif 134 129 … … 174 169 } 175 170 176 void it85xx_exit_scratch_rom( )171 void it85xx_exit_scratch_rom(void) 177 172 { 178 173 #if 0 … … 182 177 183 178 msg_pdbg("%s():%d was called ...\n", __FUNCTION__, __LINE__); 184 if (it85xx_scratch_rom_reenter <= 0) return; 179 if (it85xx_scratch_rom_reenter <= 0) 180 return; 185 181 186 182 for (tries = 0; tries < MAX_TRY; ++tries) { … … 221 217 * we find out the root cause. */ 222 218 ret = system("start powerd >&2"); 223 if (ret) {219 if (ret) 224 220 msg_perr("Cannot start powerd again.\n"); 225 }226 221 #endif 227 222 } … … 246 241 247 242 #ifdef LPC_IO 248 /* Get LPCPNP of SHM. That's big-endian */243 /* Get LPCPNP of SHM. That's big-endian. */ 249 244 sio_write(s.port, LDNSEL, 0x0F); /* Set LDN to SHM (0x0F) */ 250 245 shm_io_base = (sio_read(s.port, SHM_IO_BAR0) << 8) + … … 256 251 * register for indirect access. */ 257 252 base = 0xFFFFF000; 258 ce_high = ((unsigned char *)base) + 0xE00; /* 0xFFFFFE00 */259 ce_low = ((unsigned char *)base) + 0xD00; /* 0xFFFFFD00 */253 ce_high = ((unsigned char *)base) + 0xE00; /* 0xFFFFFE00 */ 254 ce_low = ((unsigned char *)base) + 0xD00; /* 0xFFFFFD00 */ 260 255 261 256 /* pre-set indirect-access registers since in most of cases they are … … 270 265 msg_pdbg("%s():%d base=0x%08x\n", __func__, __LINE__, 271 266 (unsigned int)base); 272 ce_high = (unsigned char *)(base + 0xE00); /* 0xFFFFFE00 */273 ce_low = (unsigned char *)(base + 0xD00); /* 0xFFFFFD00 */267 ce_high = (unsigned char *)(base + 0xE00); /* 0xFFFFFE00 */ 268 ce_low = (unsigned char *)(base + 0xD00); /* 0xFFFFFD00 */ 274 269 #endif 275 270 … … 281 276 282 277 static const struct spi_programmer spi_programmer_it85xx = { 283 .type = SPI_CONTROLLER_IT85XX,284 .max_data_read = 64,285 .max_data_write = 64,286 .command = it85xx_spi_send_command,287 .multicommand = default_spi_send_multicommand,288 .read = default_spi_read,289 .write_256 = default_spi_write_256,278 .type = SPI_CONTROLLER_IT85XX, 279 .max_data_read = 64, 280 .max_data_write = 64, 281 .command = it85xx_spi_send_command, 282 .multicommand = default_spi_send_multicommand, 283 .read = default_spi_read, 284 .write_256 = default_spi_write_256, 290 285 }; 291 286 … … 306 301 msg_pdbg("Overriding chipset SPI with IT85 FWH|SPI.\n"); 307 302 /* Really leave FWH enabled? */ 308 /* Set this as spicontroller. */303 /* Set this as SPI controller. */ 309 304 register_spi_programmer(&spi_programmer_it85xx); 310 305 } … … 325 320 326 321 it85xx_enter_scratch_rom(); 327 /* exit scratch romONLY when programmer shuts down. Otherwise, the322 /* exit scratch ROM ONLY when programmer shuts down. Otherwise, the 328 323 * temporary flash state may halt EC. */ 329 324 -
trunk/it87spi.c
r1396 r1397 94 94 msg_pdbg("Found ITE EC, ID 0x%04hx," 95 95 "Rev 0x%02x on port 0x%x.\n", 96 s.model, 97 sio_read(s.port, CHIP_VER_REG), 96 s.model, sio_read(s.port, CHIP_VER_REG), 98 97 s.port); 99 98 register_superio(s); … … 107 106 static int it8716f_spi_send_command(unsigned int writecnt, unsigned int readcnt, 108 107 const unsigned char *writearr, unsigned char *readarr); 109 static int it8716f_spi_chip_read(struct flashchip *flash, uint8_t *buf, int start, int len); 110 static int it8716f_spi_chip_write_256(struct flashchip *flash, uint8_t *buf, int start, int len); 108 static int it8716f_spi_chip_read(struct flashchip *flash, uint8_t *buf, 109 int start, int len); 110 static int it8716f_spi_chip_write_256(struct flashchip *flash, uint8_t *buf, 111 int start, int len); 111 112 112 113 static const struct spi_programmer spi_programmer_it87xx = { 113 .type = SPI_CONTROLLER_IT87XX,114 .max_data_read = MAX_DATA_UNSPECIFIED,115 .max_data_write = MAX_DATA_UNSPECIFIED,116 .command = it8716f_spi_send_command,117 .multicommand = default_spi_send_multicommand,118 .read = it8716f_spi_chip_read,119 .write_256 = it8716f_spi_chip_write_256,114 .type = SPI_CONTROLLER_IT87XX, 115 .max_data_read = MAX_DATA_UNSPECIFIED, 116 .max_data_write = MAX_DATA_UNSPECIFIED, 117 .command = it8716f_spi_send_command, 118 .multicommand = default_spi_send_multicommand, 119 .read = it8716f_spi_chip_read, 120 .write_256 = it8716f_spi_chip_write_256, 120 121 }; 121 122 … … 203 204 int init_superio_ite(void) 204 205 { 205 int i; 206 int ret = 0; 206 int i, ret = 0; 207 207 208 208 for (i = 0; i < superio_count; i++) { … … 260 260 if (readcnt > 3) { 261 261 msg_pinfo("%s called with unsupported readcnt %i.\n", 262 __func__, readcnt);262 __func__, readcnt); 263 263 return SPI_INVALID_LENGTH; 264 264 } … … 290 290 default: 291 291 msg_pinfo("%s called with unsupported writecnt %i.\n", 292 __func__, writecnt);292 __func__, writecnt); 293 293 return SPI_INVALID_LENGTH; 294 294 } … … 314 314 315 315 /* Page size is usually 256 bytes */ 316 static int it8716f_spi_page_program(struct flashchip *flash, uint8_t *buf, int start)317 { 318 int i; 319 int result;316 static int it8716f_spi_page_program(struct flashchip *flash, uint8_t *buf, 317 int start) 318 { 319 int i, result; 320 320 chipaddr bios = flash->virtual_memory; 321 321 … … 326 326 OUTB(0x06, it8716f_flashport + 1); 327 327 OUTB(((2 + (fast_spi ? 1 : 0)) << 4), it8716f_flashport); 328 for (i = 0; i < flash->page_size; i++) {328 for (i = 0; i < flash->page_size; i++) 329 329 chip_writeb(buf[i], bios + start + i); 330 }331 330 OUTB(0, it8716f_flashport); 332 331 /* Wait until the Write-In-Progress bit is cleared. … … 342 341 * Need to read this big flash using firmware cycles 3 byte at a time. 343 342 */ 344 static int it8716f_spi_chip_read(struct flashchip *flash, uint8_t *buf, int start, int len) 343 static int it8716f_spi_chip_read(struct flashchip *flash, uint8_t *buf, 344 int start, int len) 345 345 { 346 346 fast_spi = 0; … … 359 359 } 360 360 361 static int it8716f_spi_chip_write_256(struct flashchip *flash, uint8_t *buf, int start, int len) 361 static int it8716f_spi_chip_write_256(struct flashchip *flash, uint8_t *buf, 362 int start, int len) 362 363 { 363 364 /* -
trunk/pcidev.c
r1370 r1397 248 248 for (i = 0; devs[i].vendor_name != NULL; i++) { 249 249 msg_pinfo("%s %s [%04x:%04x]%s\n", devs[i].vendor_name, 250 devs[i].device_name, devs[i].vendor_id,251 devs[i].device_id,252 (devs[i].status == NT) ? " (untested)" : "");250 devs[i].device_name, devs[i].vendor_id, 251 devs[i].device_id, 252 (devs[i].status == NT) ? " (untested)" : ""); 253 253 } 254 254 } -
trunk/physmap.c
r1282 r1397 44 44 static void *map_first_meg(unsigned long phys_addr, size_t len) 45 45 { 46 47 if (realmem_map) { 46 if (realmem_map) 48 47 return realmem_map + phys_addr; 49 }50 48 51 49 realmem_map = valloc(1024 * 1024); 52 50 53 if (!realmem_map) {51 if (!realmem_map) 54 52 return ERROR_PTR; 55 }56 53 57 54 if (__djgpp_map_physical_memory(realmem_map, (1024 * 1024), 0)) { … … 69 66 __dpmi_meminfo mi; 70 67 71 /* enable 4GB limit on DS descriptor*/72 if (!__djgpp_nearptr_enable()) {68 /* Enable 4GB limit on DS descriptor. */ 69 if (!__djgpp_nearptr_enable()) 73 70 return ERROR_PTR; 74 }75 71 76 72 if ((phys_addr + len - 1) < (1024 * 1024)) { 77 /* we need to use another method to map first 1MB*/73 /* We need to use another method to map first 1MB. */ 78 74 return map_first_meg(phys_addr, len); 79 75 } … … 81 77 mi.address = phys_addr; 82 78 mi.size = len; 83 ret = __dpmi_physical_address_mapping (&mi);84 85 if (ret != 0) {79 ret = __dpmi_physical_address_mapping (&mi); 80 81 if (ret != 0) 86 82 return ERROR_PTR; 87 }88 83 89 84 return (void *) mi.address + __djgpp_conventional_base; … … 100 95 * do this for us on exit. 101 96 */ 102 if ((virt_addr >= realmem_map) && ((virt_addr + len) <= (realmem_map + (1024 * 1024)))) { 97 if ((virt_addr >= realmem_map) && 98 ((virt_addr + len) <= (realmem_map + (1024 * 1024)))) { 103 99 return; 104 100 } … … 115 111 void *sys_physmap(unsigned long phys_addr, size_t len) 116 112 { 117 return (void *)phys_to_virt(phys_addr);113 return (void *)phys_to_virt(phys_addr); 118 114 } 119 115 … … 196 192 /* Open the memory device CACHED. */ 197 193 if (-1 == (fd_mem_cached = open(MEM_DEV, O_RDWR))) { 198 msg_perr("Critical error: open(" MEM_DEV "): %s", strerror(errno)); 194 msg_perr("Critical error: open(" MEM_DEV "): %s", 195 strerror(errno)); 199 196 exit(2); 200 197 } … … 222 219 #define PHYSMAP_RO 1 223 220 224 static void *physmap_common(const char *descr, unsigned long phys_addr, size_t len, int mayfail, int readonly) 221 static void *physmap_common(const char *descr, unsigned long phys_addr, 222 size_t len, int mayfail, int readonly) 225 223 { 226 224 void *virt_addr; … … 228 226 if (len == 0) { 229 227 msg_pspew("Not mapping %s, zero size at 0x%08lx.\n", 230 descr, phys_addr);228 descr, phys_addr); 231 229 return ERROR_PTR; 232 230 } 233 231 234 232 if ((getpagesize() - 1) & len) { 235 233 msg_perr("Mapping %s at 0x%08lx, unaligned size 0x%lx.\n", 236 descr, phys_addr, (unsigned long)len);234 descr, phys_addr, (unsigned long)len); 237 235 } 238 236 239 237 if ((getpagesize() - 1) & phys_addr) { 240 238 msg_perr("Mapping %s, 0x%lx bytes at unaligned 0x%08lx.\n", 241 descr, (unsigned long)len, phys_addr);242 } 243 244 if (readonly) {239 descr, (unsigned long)len, phys_addr); 240 } 241 242 if (readonly) 245 243 virt_addr = sys_physmap_ro_cached(phys_addr, len); 246 } else {244 else 247 245 virt_addr = sys_physmap_rw_uncached(phys_addr, len); 248 }249 246 250 247 if (ERROR_PTR == virt_addr) { 251 248 if (NULL == descr) 252 249 descr = "memory"; 253 msg_perr("Error accessing %s, 0x%lx bytes at 0x%08lx\n", descr, (unsigned long)len, phys_addr); 250 msg_perr("Error accessing %s, 0x%lx bytes at 0x%08lx\n", descr, 251 (unsigned long)len, phys_addr); 254 252 perror(MEM_DEV " mmap failed"); 255 253 #ifdef __linux__ … … 263 261 #elif defined (__OpenBSD__) 264 262 msg_perr("Please set securelevel=-1 in /etc/rc.securelevel " 265 "and reboot, or reboot into \n");266 msg_perr("single user mode.\n");263 "and reboot, or reboot into\n" 264 "single user mode.\n"); 267 265 #endif 268 266 if (!mayfail) … … 275 273 void *physmap(const char *descr, unsigned long phys_addr, size_t len) 276 274 { 277 return physmap_common(descr, phys_addr, len, PHYSMAP_NOFAIL, PHYSMAP_RW); 275 return physmap_common(descr, phys_addr, len, PHYSMAP_NOFAIL, 276 PHYSMAP_RW); 278 277 } 279 278 280 279 void *physmap_try_ro(const char *descr, unsigned long phys_addr, size_t len) 281 280 { 282 return physmap_common(descr, phys_addr, len, PHYSMAP_MAYFAIL, PHYSMAP_RO); 281 return physmap_common(descr, phys_addr, len, PHYSMAP_MAYFAIL, 282 PHYSMAP_RO); 283 283 } 284 284 … … 289 289 * Reading and writing to MSRs, however requires instructions rdmsr/wrmsr, 290 290 * which are ring0 privileged instructions so only the kernel can do the 291 * read/write. This function, therefore, requires that the msr kernel module291 * read/write. This function, therefore, requires that the msr kernel module 292 292 * be loaded to access these instructions from user space using device 293 293 * /dev/cpu/0/msr. … … 310 310 msr.lo = buf[0]; 311 311 msr.hi = buf[1]; 312 313 312 return msr; 314 313 } … … 342 341 } 343 342 344 /* some MSRs must not be written*/343 /* Some MSRs must not be written. */ 345 344 if (errno == EIO) 346 345 return -1; … … 380 379 close(fd_msr); 381 380 382 /* Clear MSR file descriptor */381 /* Clear MSR file descriptor. */ 383 382 fd_msr = -1; 384 383 } … … 463 462 close(fd_msr); 464 463 465 /* Clear MSR file descriptor */464 /* Clear MSR file descriptor. */ 466 465 fd_msr = -1; 467 466 }
Note: See TracChangeset
for help on using the changeset viewer.
