summaryrefslogtreecommitdiff
path: root/src/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'src/drivers')
-rw-r--r--src/drivers/ipmi/Kconfig9
-rw-r--r--src/drivers/ipmi/ipmi_kcs.c31
2 files changed, 22 insertions, 18 deletions
diff --git a/src/drivers/ipmi/Kconfig b/src/drivers/ipmi/Kconfig
index 44ed17e548..1137dcf8d5 100644
--- a/src/drivers/ipmi/Kconfig
+++ b/src/drivers/ipmi/Kconfig
@@ -33,3 +33,12 @@ config BMC_KCS_BASE
help
The PNP base address of BMC KCS. It must be equal to the
pnp port value defined in devicetree for chip drivers/ipmi.
+
+config IPMI_KCS_TIMEOUT_MS
+ int
+ default 5000
+ depends on IPMI_KCS
+ help
+ The time unit is millisecond for each IPMI KCS transfer.
+ IPMI spec v2.0 rev 1.1 Sec. 9.15, a five-second timeout or
+ greater is recommended.
diff --git a/src/drivers/ipmi/ipmi_kcs.c b/src/drivers/ipmi/ipmi_kcs.c
index 1d6b71cee9..f8c64c68e9 100644
--- a/src/drivers/ipmi/ipmi_kcs.c
+++ b/src/drivers/ipmi/ipmi_kcs.c
@@ -3,7 +3,7 @@
#include <console/console.h>
#include <device/device.h>
#include <arch/io.h>
-#include <delay.h>
+#include <timer.h>
#include "ipmi_kcs.h"
#define IPMI_KCS_STATE(_x) ((_x) >> 6)
@@ -35,27 +35,22 @@ static unsigned char ipmi_kcs_status(int port)
static int wait_ibf_timeout(int port)
{
- int timeout = 1000;
- do {
- if (!(ipmi_kcs_status(port) & IPMI_KCS_IBF))
- return 0;
- udelay(100);
- } while (timeout--);
- printk(BIOS_ERR, "wait_ibf timeout!\n");
- return timeout;
+ if (!wait_ms(CONFIG_IPMI_KCS_TIMEOUT_MS, !(ipmi_kcs_status(port) & IPMI_KCS_IBF))) {
+ printk(BIOS_ERR, "wait_ibf timeout!\n");
+ return 1;
+ } else {
+ return 0;
+ }
}
static int wait_obf_timeout(int port)
{
- int timeout = 1000;
- do {
- if ((ipmi_kcs_status(port) & IPMI_KCS_OBF))
- return 0;
- udelay(100);
- } while (timeout--);
-
- printk(BIOS_ERR, "wait_obf timeout!\n");
- return timeout;
+ if (!wait_ms(CONFIG_IPMI_KCS_TIMEOUT_MS, (ipmi_kcs_status(port) & IPMI_KCS_OBF))) {
+ printk(BIOS_ERR, "wait_obf timeout!\n");
+ return 1;
+ } else {
+ return 0;
+ }
}