| 1 |
|
| 2 |
|
| 3 |
#include <arch/io.h> |
| 4 |
#include <console/console.h> |
| 5 |
#include <device/pnp.h> |
| 6 |
#include <delay.h> |
| 7 |
#include <timer.h> |
| 8 |
|
| 9 |
#include "ipmi_if.h" |
| 10 |
#include "chip.h" |
| 11 |
|
| 12 |
enum cb_err ipmi_premem_init(const u16 port, const u16 device) |
| 13 |
{ |
| 14 |
const struct drivers_ipmi_config *conf = NULL; |
| 15 |
const struct device *dev; |
| 16 |
|
| 17 |
|
| 18 |
dev = dev_find_slot_pnp(port, device); |
| 19 |
|
| 20 |
if (!dev) { |
| 21 |
printk(BIOS_ERR, "IPMI: Cannot find PNP device port: %x, device %x\n", |
| 22 |
port, device); |
| 23 |
return CB_ERR; |
| 24 |
} |
| 25 |
if (!dev->enabled) { |
| 26 |
printk(BIOS_ERR, "IPMI: device is not enabled\n"); |
| 27 |
return CB_ERR; |
| 28 |
} |
| 29 |
printk(BIOS_DEBUG, "IPMI: romstage PNP KCS 0x%x\n", dev->path.pnp.port); |
| 30 |
if (dev->chip_info) |
| 31 |
conf = dev->chip_info; |
| 32 |
|
| 33 |
if (conf && conf->wait_for_bmc && conf->bmc_boot_timeout) { |
| 34 |
struct stopwatch sw; |
| 35 |
stopwatch_init_msecs_expire(&sw, conf->bmc_boot_timeout * 1000); |
| 36 |
printk(BIOS_DEBUG, "IPMI: Waiting for BMC...\n"); |
| 37 |
|
| 38 |
while (!stopwatch_expired(&sw)) { |
| 39 |
if (inb(dev->path.pnp.port) != 0xff) |
| 40 |
break; |
| 41 |
mdelay(100); |
| 42 |
} |
| 43 |
if (stopwatch_expired(&sw)) { |
| 44 |
printk(BIOS_INFO, "IPMI: Waiting for BMC timed out\n"); |
| 45 |
return CB_ERR; |
| 46 |
} |
| 47 |
} |
| 48 |
|
| 49 |
if (ipmi_process_self_test_result(dev)) |
| 50 |
return CB_ERR; |
| 51 |
|
| 52 |
return CB_SUCCESS; |
| 53 |
} |