uint16_t probe_id_ite(uint16_t port) { uint16_t id; enter_conf_mode_ite(port); id = sio_read(port, CHIP_ID_BYTE1_REG) << 8; id |= sio_read(port, CHIP_ID_BYTE2_REG); exit_conf_mode_ite(port); return id; }
void probe_idregs_ite(uint16_t port) { chip_found_at_port = 0; if (port == 0x3f0 || port == 0x3bd || port == 0x370) { enter_conf_mode_ite_legacy(port, initkey_it8661f); probe_idregs_ite_helper("(init=legacy/it8661f) ", port); exit_conf_mode_ite(port); if (chip_found_at_port) return; enter_conf_mode_ite_legacy(port, initkey_it8671f); probe_idregs_ite_helper("(init=legacy/it8671f) ", port); exit_conf_mode_ite(port); if (chip_found_at_port) return; } else { enter_conf_mode_ite(port); probe_idregs_ite_helper("(init=standard) ", port); exit_conf_mode_ite(port); if (chip_found_at_port) return; enter_conf_mode_ite_it8502e(port); probe_idregs_ite_helper("(init=it8502e) ", port); exit_conf_mode_ite(port); if (chip_found_at_port) return; enter_conf_mode_ite_it8761e(port); probe_idregs_ite_helper("(init=it8761e) ", port); exit_conf_mode_ite(port); if (chip_found_at_port) return; enter_conf_mode_ite_it8228e(port); probe_idregs_ite_helper("(init=it8228e) ", port); exit_conf_mode_ite(port); if (chip_found_at_port) return; enter_conf_mode_winbond_fintek_ite_8787(port); probe_idregs_ite_helper("(init=0x87,0x87) ", port); exit_conf_mode_winbond_fintek_ite_8787(port); if (chip_found_at_port) return; } }
static uint16_t it87spi_probe(uint16_t port) { uint8_t tmp = 0; char *portpos = NULL; uint16_t flashport = 0; enter_conf_mode_ite(port); /* NOLDN, reg 0x24, mask out lowest bit (suspend) */ tmp = sio_read(port, 0x24) & 0xFE; /* If IT87SPI was not explicitly selected, we want to check * quickly if LPC->SPI translation is active. */ if ((programmer == PROGRAMMER_INTERNAL) && !(tmp & (0x0E))) { msg_pdbg("No IT87* serial flash segment enabled.\n"); exit_conf_mode_ite(port); /* Nothing to do. */ return 0; } msg_pdbg("Serial flash segment 0x%08x-0x%08x %sabled\n", 0xFFFE0000, 0xFFFFFFFF, (tmp & 1 << 1) ? "en" : "dis"); msg_pdbg("Serial flash segment 0x%08x-0x%08x %sabled\n", 0x000E0000, 0x000FFFFF, (tmp & 1 << 1) ? "en" : "dis"); msg_pdbg("Serial flash segment 0x%08x-0x%08x %sabled\n", 0xFFEE0000, 0xFFEFFFFF, (tmp & 1 << 2) ? "en" : "dis"); msg_pdbg("Serial flash segment 0x%08x-0x%08x %sabled\n", 0xFFF80000, 0xFFFEFFFF, (tmp & 1 << 3) ? "en" : "dis"); msg_pdbg("LPC write to serial flash %sabled\n", (tmp & 1 << 4) ? "en" : "dis"); /* The LPC->SPI force write enable below only makes sense for * non-programmer mode. */ /* If any serial flash segment is enabled, enable writing. */ if ((tmp & 0xe) && (!(tmp & 1 << 4))) { msg_pdbg("Enabling LPC write to serial flash\n"); tmp |= 1 << 4; sio_write(port, 0x24, tmp); } msg_pdbg("Serial flash pin %i\n", (tmp & 1 << 5) ? 87 : 29); /* LDN 0x7, reg 0x64/0x65 */ sio_write(port, 0x07, 0x7); flashport = sio_read(port, 0x64) << 8; flashport |= sio_read(port, 0x65); msg_pdbg("Serial flash port 0x%04x\n", flashport); /* Non-default port requested? */ portpos = extract_programmer_param("it87spiport"); if (portpos) { char *endptr = NULL; unsigned long forced_flashport; forced_flashport = strtoul(portpos, &endptr, 0); /* Port 0, port >0x1000, unaligned ports and garbage strings * are rejected. */ if (!forced_flashport || (forced_flashport >= 0x1000) || (forced_flashport & 0x7) || (*endptr != '\0')) { /* Using ports below 0x100 is a really bad idea, and * should only be done if no port between 0x100 and * 0xff8 works due to routing issues. */ msg_perr("Error: it87spiport specified, but no valid " "port specified.\nPort must be a multiple of " "0x8 and lie between 0x100 and 0xff8.\n"); free(portpos); return 1; } else { flashport = (uint16_t)forced_flashport; msg_pinfo("Forcing serial flash port 0x%04x\n", flashport); sio_write(port, 0x64, (flashport >> 8)); sio_write(port, 0x65, (flashport & 0xff)); } } free(portpos); exit_conf_mode_ite(port); it8716f_flashport = flashport; if (buses_supported & CHIP_BUSTYPE_SPI) msg_pdbg("Overriding chipset SPI with IT87 SPI.\n"); /* FIXME: Add the SPI bus or replace the other buses with it? */ register_spi_programmer(&spi_programmer_it87xx); return 0; }