Index: chipset_enable.c =================================================================== --- chipset_enable.c (revision 1253) +++ chipset_enable.c (working copy) @@ -764,8 +764,50 @@ static int enable_flash_ck804(struct pci_dev *dev, const char *name) { + uint32_t segctrl; + int segreg; uint8_t old, new; + for (segreg = 0x8c; segreg <= 0x97; segreg += 4) { + segctrl = pci_read_long(dev, segreg); + if ((segctrl & 0x33333333) != 0x00000000) { + /* reads or writes are locked */ + if ((segctrl & 0xcccccccc) == 0x00000000) { + /* we can unlock */ + msg_pinfo("unlocking in %#02x\n", segreg); + pci_write_long(dev, segreg, 0x00000000); + } else { + msg_pinfo("can't unlock in %#02x\n", segreg); + programmer_may_write = 0; + return -1; + } + } + segctrl = pci_read_long(dev, segreg); + if ((segctrl & 0x33333333) != 0x00000000) { + msg_pinfo("still locked in %#02x (%#08x)\n", + segreg, segctrl); + programmer_may_write = 0; + return -1; + } + } + segctrl = pci_read_byte(dev, 0x8a); + if ((segctrl & 0x3) != 0x0) { + if ((segctrl & 0xc) == 0x0) { + msg_pinfo("unlocking in %#02x\n", 0x8a); + pci_write_byte(dev, 0x8a, segctrl & 0xf0); + } else { + msg_pinfo("can't unlock in %#02x\n", 0x8a); + programmer_may_write = 0; + return -1; + } + } + segctrl = pci_read_byte(dev, 0x8a); + if ((segctrl & 0x3) != 0x0) { + msg_pinfo("still locked in %#02x (%#08x)\n", segreg, segctrl); + programmer_may_write = 0; + return -1; + } + old = pci_read_byte(dev, 0x88); new = old | 0xc0; if (new != old) {