summaryrefslogtreecommitdiffstats
path: root/chipset_enable.c
diff options
context:
space:
mode:
authorJonathan Kollasch <jakllsch@kollasch.net>2012-09-04 03:55:04 +0000
committerStefan Tauner <stefan.tauner@alumni.tuwien.ac.at>2012-09-04 03:55:04 +0000
commitc81900005f096edb9ebb841c4e2787d09b7f2da4 (patch)
treedbd5e4e09fae9afd5bff933e51a0de929bb43ff4 /chipset_enable.c
parentb66ba1e2c25033cd8b367efe88f97a1e5fd36dce (diff)
downloadflashrom-c81900005f096edb9ebb841c4e2787d09b7f2da4.tar.gz
flashrom-c81900005f096edb9ebb841c4e2787d09b7f2da4.tar.bz2
flashrom-c81900005f096edb9ebb841c4e2787d09b7f2da4.zip
Try to remove all read and write locks on CK804 (and MCP51)
We made a first step into this direction in r1405, but failed to notice that there was already an extended patch by Jonathan which was refined to become this one. Allows the removal of board_shuttle_fn25 (which was also intended to be used on the ASUS A8N-SLI Deluxe, but this was never tested). Corresponding to flashrom svn r1593. A previous iteration was tested on CK804 and Signed-off-by: Jonathan Kollasch <jakllsch@kollasch.net> which was then Acked-by: Stefan Reinauer <stepan@coreboot.org> Rebasing, refining and making errors non-fatal is Signed-off-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at> Acked-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
Diffstat (limited to 'chipset_enable.c')
-rw-r--r--chipset_enable.c71
1 files changed, 60 insertions, 11 deletions
diff --git a/chipset_enable.c b/chipset_enable.c
index 2e4a5fc90..e1684f998 100644
--- a/chipset_enable.c
+++ b/chipset_enable.c
@@ -997,25 +997,74 @@ static int enable_flash_nvidia_nforce2(struct pci_dev *dev, const char *name)
static int enable_flash_ck804(struct pci_dev *dev, const char *name)
{
- uint8_t old, new;
+ uint32_t segctrl;
+ uint8_t reg, old, new;
+ unsigned int err = 0;
+
+ /* 0x8A is special: it is a single byte and only one nibble is touched. */
+ reg = 0x8A;
+ segctrl = pci_read_byte(dev, reg);
+ if ((segctrl & 0x3) != 0x0) {
+ if ((segctrl & 0xC) != 0x0) {
+ msg_pinfo("Can not unlock existing protection in register 0x%02x.\n", reg);
+ err++;
+ } else {
+ msg_pdbg("Unlocking protection in register 0x%02x... ", reg);
+ rpci_write_byte(dev, reg, segctrl & 0xF0);
+
+ segctrl = pci_read_byte(dev, reg);
+ if ((segctrl & 0x3) != 0x0) {
+ msg_pinfo("Could not unlock protection in register 0x%02x (new value: 0x%x).\n",
+ reg, segctrl);
+ err++;
+ } else
+ msg_pdbg("OK\n");
+ }
+ }
- pci_write_byte(dev, 0x92, 0x00);
- if (pci_read_byte(dev, 0x92) != 0x00) {
- msg_pinfo("Setting register 0x%x to 0x%x on %s failed "
- "(WARNING ONLY).\n", 0x92, 0x00, name);
+ for (reg = 0x8C; reg <= 0x94; reg += 4) {
+ segctrl = pci_read_long(dev, reg);
+ if ((segctrl & 0x33333333) == 0x00000000) {
+ /* reads and writes are unlocked */
+ continue;
+ }
+ if ((segctrl & 0xCCCCCCCC) != 0x00000000) {
+ msg_pinfo("Can not unlock existing protection in register 0x%02x.\n", reg);
+ err++;
+ continue;
+ }
+ msg_pdbg("Unlocking protection in register 0x%02x... ", reg);
+ rpci_write_long(dev, reg, 0x00000000);
+
+ segctrl = pci_read_long(dev, reg);
+ if ((segctrl & 0x33333333) != 0x00000000) {
+ msg_pinfo("Could not unlock protection in register 0x%02x (new value: 0x%08x).\n",
+ reg, segctrl);
+ err++;
+ } else
+ msg_pdbg("OK\n");
+ }
+
+ if (err > 0) {
+ msg_pinfo("%d locks could not be disabled, disabling writes (reads may also fail).\n", err);
+ programmer_may_write = 0;
}
- old = pci_read_byte(dev, 0x88);
- new = old | 0xc0;
+ reg = 0x88;
+ old = pci_read_byte(dev, reg);
+ new = old | 0xC0;
if (new != old) {
- rpci_write_byte(dev, 0x88, new);
- if (pci_read_byte(dev, 0x88) != new) {
- msg_pinfo("Setting register 0x%x to 0x%x on %s failed "
- "(WARNING ONLY).\n", 0x88, new, name);
+ rpci_write_byte(dev, reg, new);
+ if (pci_read_byte(dev, reg) != new) {
+ msg_pinfo("Setting register 0x%02x to 0x%x on %s failed.\n", reg, new, name);
+ err++;
}
}
if (enable_flash_nvidia_common(dev, name))
+ err++;
+
+ if (err > 0)
return ERROR_NONFATAL;
else
return 0;