aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Jeffery <andrew@aj.id.au>2018-10-09 00:32:35 -0700
committerStewart Smith <stewart@linux.ibm.com>2018-10-11 01:26:19 -0500
commitdd554bacd13c6dea481ea4e1ec9f3c32087295d9 (patch)
tree650a2733170087b8d861a51c175e102538a7cd6f
parent5684204c2d0b470de72eff563c9e0172bbdbcb18 (diff)
downloadskiboot-dd554bacd13c6dea481ea4e1ec9f3c32087295d9.zip
skiboot-dd554bacd13c6dea481ea4e1ec9f3c32087295d9.tar.gz
skiboot-dd554bacd13c6dea481ea4e1ec9f3c32087295d9.tar.bz2
astbmc: Use LPC probe calls to determine SIO presence
Avoid the probabilistic approach and use a deterministic one instead. The probe calls use a slow, synchronous method to capture the the state of the target device, so it is used sparingly (only on first access). Signed-off-by: Andrew Jeffery <andrew@aj.id.au> Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
-rw-r--r--hw/ast-bmc/ast-io.c30
1 files changed, 10 insertions, 20 deletions
diff --git a/hw/ast-bmc/ast-io.c b/hw/ast-bmc/ast-io.c
index 7f8c2da..e053484 100644
--- a/hw/ast-bmc/ast-io.c
+++ b/hw/ast-bmc/ast-io.c
@@ -323,36 +323,26 @@ static void ast_setup_sio_irq_polarity(void)
static bool ast_sio_is_enabled(void)
{
- bool enabled;
+ int64_t rc;
- lpc_outb(0xa5, 0x2e);
+ /* Begin the unlock sequence with a probe to establish presence */
+ rc = lpc_probe_write(OPAL_LPC_IO, 0x2e, 0xa5, 1);
+ if (rc)
+ return false;
+
+ /* Complete the unlock sequence if the device is present */
lpc_outb(0xa5, 0x2e);
- /* Heuristic attempt to confirm SIO is enabled.
- *
- * Do two tests of 1 byte, giving a false positive probability of
- * 1/65536. Read tests on disabled SIO tended to return 0x60.
- */
- bmc_sio_outb(0x2, 0x07);
- enabled = bmc_sio_inb(0x07) == 2;
- if (enabled) {
- bmc_sio_outb(0xd, 0x07);
- enabled = bmc_sio_inb(0x07) == 0xd;
- }
+ /* Re-lock to return to a known state */
+ lpc_outb(0xaa, 0x2e);
- if (enabled)
- lpc_outb(0xaa, 0x2e);
-
- return enabled;
+ return true;
}
bool ast_sio_init(void)
{
bool enabled = ast_sio_is_enabled();
- prlog(PR_NOTICE, "PLAT: SuperIO is %s\n",
- enabled ? "available" : "unavailable!");
-
/* Configure all AIO interrupts to level low */
if (enabled)
ast_setup_sio_irq_polarity();