Hi,

Attached is a proposed patch for improving the ck804 chipset enable.

Comments?

        Jonathan Kollasch
Index: chipset_enable.c
===================================================================
--- chipset_enable.c    (revision 1216)
+++ chipset_enable.c    (working copy)
@@ -776,8 +776,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) {
_______________________________________________
flashrom mailing list
flashrom@flashrom.org
http://www.flashrom.org/mailman/listinfo/flashrom

Reply via email to