summaryrefslogtreecommitdiffstats
path: root/it85spi.c
diff options
context:
space:
mode:
authorDavid Hendricks <dhendrix@google.com>2011-06-14 01:35:36 +0000
committerDavid Hendricks <david.hendricks@gmail.com>2011-06-14 01:35:36 +0000
commit8bb2021d77c8ee213b53d671687b7a1179335522 (patch)
treea77cc4239b59731e98cf6c9681b5a7c665613038 /it85spi.c
parent9d9a1042332cd08aa66eee6f37d80c0f09f47d70 (diff)
downloadast2050-flashrom-8bb2021d77c8ee213b53d671687b7a1179335522.zip
ast2050-flashrom-8bb2021d77c8ee213b53d671687b7a1179335522.tar.gz
Use shutdown callback mechanism to shutdown programmers
This patch attempts to resolve some programmer shutdown ordering issues by having the programmer init functions register shutdown callbacks explicitly wherever it makes most sense. Before, assumptions were made that could lead to the internal programmer's state changing before the external programmer could be shut down properly. Now, each programmer cleans up after itself and (hopefully) performs each operation in the correct order. As a side-effect, this patch gives us a better usage model for reverse operations such as rpci_* and rmmio_*. In the long-run, this should make reversing the initialization process easier to understand, less tedious, and less error-prone. In short, this patch does the following: - Registers a shutdown callback during initialization for each programmer. - Kills the .shutdown function pointer from programmer_entry struct. Also, make most shutdown functions static. - Adds a few minor clean-ups and corrections (e.g. missing physunmap() calls). TODO: Remove forward declaration of serprog_shutdown() (added to simplify diff) Corresponding to flashrom svn r1338. Signed-off-by: David Hendricks <dhendrix@google.com> Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Diffstat (limited to 'it85spi.c')
-rw-r--r--it85spi.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/it85spi.c b/it85spi.c
index c6c945b..d4ca13b 100644
--- a/it85spi.c
+++ b/it85spi.c
@@ -226,6 +226,14 @@ void it85xx_exit_scratch_rom()
#endif
}
+static int it85xx_shutdown(void *data)
+{
+ msg_pdbg("%s():%d\n", __func__, __LINE__);
+ it85xx_exit_scratch_rom();
+
+ return 0; /* FIXME: Should probably return something meaningful */
+}
+
static int it85xx_spi_common_init(struct superio s)
{
chipaddr base;
@@ -233,6 +241,9 @@ static int it85xx_spi_common_init(struct superio s)
msg_pdbg("%s():%d superio.vendor=0x%02x\n", __func__, __LINE__,
s.vendor);
+ if (register_shutdown(it85xx_shutdown, NULL))
+ return 1;
+
#ifdef LPC_IO
/* Get LPCPNP of SHM. That's big-endian */
sio_write(s.port, LDNSEL, 0x0F); /* Set LDN to SHM (0x0F) */
@@ -300,13 +311,6 @@ int it85xx_spi_init(struct superio s)
return ret;
}
-int it85xx_shutdown(void)
-{
- msg_pdbg("%s():%d\n", __func__, __LINE__);
- it85xx_exit_scratch_rom();
- return 0;
-}
-
/* According to ITE 8502 document, the procedure to follow mode is following:
* 1. write 0x00 to LPC/FWH address 0xffff_fexxh (drive CE# high)
* 2. write data to LPC/FWH address 0xffff_fdxxh (drive CE# low and MOSI
OpenPOWER on IntegriCloud