Skip to content

Commit

Permalink
astbmc: Use LPC probe calls to determine SIO presence
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
amboar authored and stewartsmith committed Oct 11, 2018
1 parent 5684204 commit dd554ba
Showing 1 changed file with 10 additions and 20 deletions.
30 changes: 10 additions & 20 deletions hw/ast-bmc/ast-io.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit dd554ba

Please sign in to comment.