soc/intel/xeon_sp: Advertise DIMMs on skylake_sp as well
[coreboot.git] / src / drivers / ipmi / ipmi_ops_premem.c
blob99c5842bb3dc3c0b99b5011b34a69e9cdc422e85
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <arch/io.h>
4 #include <console/console.h>
5 #include <device/pnp.h>
6 #include <delay.h>
7 #include <timer.h>
9 #include "ipmi_if.h"
10 #include "chip.h"
12 enum cb_err ipmi_premem_init(const u16 port, const u16 device)
14 const struct drivers_ipmi_config *conf = NULL;
15 const struct device *dev;
17 /* Find IPMI PNP device from devicetree in romstage */
18 dev = dev_find_slot_pnp(port, device);
20 if (!dev) {
21 printk(BIOS_ERR, "IPMI: Cannot find PNP device port: %x, device %x\n",
22 port, device);
23 return CB_ERR;
25 if (!dev->enabled) {
26 printk(BIOS_ERR, "IPMI: device is not enabled\n");
27 return CB_ERR;
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;
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");
38 while (!stopwatch_expired(&sw)) {
39 if (inb(dev->path.pnp.port) != 0xff)
40 break;
41 mdelay(100);
43 if (stopwatch_expired(&sw)) {
44 printk(BIOS_INFO, "IPMI: Waiting for BMC timed out\n");
45 return CB_ERR;
49 if (ipmi_process_self_test_result(dev))
50 return CB_ERR;
52 return CB_SUCCESS;