summaryrefslogtreecommitdiff
path: root/ichspi.c
diff options
context:
space:
mode:
authorstefanct <stefanct@2b7e53f0-3cfb-0310-b3e9-8179ed1497e1>2011-09-17 22:21:55 +0000
committerstefanct <stefanct@2b7e53f0-3cfb-0310-b3e9-8179ed1497e1>2011-09-17 22:21:55 +0000
commitf72605ef9be0b87da0742ddb2b27f04d028319b3 (patch)
treea332b8d1e0aa6b8bd1a15ca78db9bb942d5af2ff /ichspi.c
parent0c020a57255fdc62ec13937a385da43262f24303 (diff)
downloadflashrom-f72605ef9be0b87da0742ddb2b27f04d028319b3.tar.gz
ichspi: unlock PR register restrictions on ICH8+ if not locked down
Tested-by: Shailendra Sodhi (predecessor/proof of concept patch) http://www.flashrom.org/pipermail/flashrom/2011-August/007717.html Signed-off-by: Stefan Tauner <stefan.tauner@student.tuwien.ac.at> Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> git-svn-id: https://code.coreboot.org/svn/flashrom/trunk@1447 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
Diffstat (limited to 'ichspi.c')
-rw-r--r--ichspi.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/ichspi.c b/ichspi.c
index 19edb83..e3a2d75 100644
--- a/ichspi.c
+++ b/ichspi.c
@@ -1200,6 +1200,29 @@ static void prettyprint_ich9_reg_pr(int i)
msg_pdbg2(", unused)\n");
}
+/* Set/Clear the read and write protection enable bits of PR register @i
+ * according to @read_prot and @write_prot. */
+static void ich9_set_pr(int i, int read_prot, int write_prot)
+{
+ void *addr = ich_spibar + ICH9_REG_PR0 + (i * 4);
+ uint32_t old = mmio_readl(addr);
+ uint32_t new;
+
+ msg_gspew("PR%u is 0x%08x", i, old);
+ new = old & ~((1 << PR_RP_OFF) | (1 << PR_WP_OFF));
+ if (read_prot)
+ new |= (1 << PR_RP_OFF);
+ if (write_prot)
+ new |= (1 << PR_WP_OFF);
+ if (old == new) {
+ msg_gspew(" already.\n");
+ return;
+ }
+ msg_gspew(", trying to set it to 0x%08x ", new);
+ rmmio_writel(new, addr);
+ msg_gspew("resulted in 0x%08x.\n", mmio_readl(addr));
+}
+
static const struct spi_programmer spi_programmer_ich7 = {
.type = SPI_CONTROLLER_ICH7,
.max_data_read = 64,
@@ -1320,6 +1343,10 @@ int ich_init_spi(struct pci_dev *dev, uint32_t base, void *rcrb,
for(i = 0; i < 5; i++)
do_ich9_spi_frap(tmp, i);
+ /* try to disable PR locks before printing them */
+ if (!ichspi_lock)
+ for(i = 0; i < 5; i++)
+ ich9_set_pr(i, 0, 0);
for(i = 0; i < 5; i++)
prettyprint_ich9_reg_pr(i);