src/drivers/ipmi: Add DEBUG_IPMI option

IPMI debug was extra spewy, so add a debug option as SPI and
other drivers have when they need to be debugged.

Change-Id: I788d67c242cac23bde9750aa3e95e3276c3f1fd7
Signed-off-by: Marc Jones <marcjones@sysproconsulting.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/52449
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
diff --git a/src/Kconfig b/src/Kconfig
index 9106c05..fe325e8 100644
--- a/src/Kconfig
+++ b/src/Kconfig
@@ -1105,6 +1105,13 @@
 	help
 	  This option enables additional SPI flash related debug messages.
 
+config DEBUG_IPMI
+	bool "Output verbose IPMI debug messages"
+	default n
+	depends on IPMI_KCS
+	help
+	  This option enables additional IPMI related debug messages.
+
 if SOUTHBRIDGE_INTEL_BD82X6X && DEFAULT_CONSOLE_LOGLEVEL_8
 # Only visible with the right southbridge and loglevel.
 config DEBUG_INTEL_ME
diff --git a/src/drivers/ipmi/ipmi_kcs.c b/src/drivers/ipmi/ipmi_kcs.c
index dcad862..12cbe82f1 100644
--- a/src/drivers/ipmi/ipmi_kcs.c
+++ b/src/drivers/ipmi/ipmi_kcs.c
@@ -29,7 +29,8 @@
 static unsigned char ipmi_kcs_status(int port)
 {
 	unsigned char status = inb(IPMI_STAT(port));
-	printk(BIOS_SPEW, "%s: 0x%02x\n", __func__, status);
+	if (CONFIG(DEBUG_IPMI))
+		printk(BIOS_SPEW, "%s: 0x%02x\n", __func__, status);
 	return status;
 }
 
@@ -57,7 +58,8 @@
 {
 	unsigned char status;
 
-	printk(BIOS_SPEW, "%s: 0x%02x\n", __func__, byte);
+	if (CONFIG(DEBUG_IPMI))
+		printk(BIOS_SPEW, "%s: 0x%02x\n", __func__, byte);
 
 	outb(byte, IPMI_DATA(port));
 
@@ -80,7 +82,8 @@
 {
 	unsigned char status;
 
-	printk(BIOS_SPEW, "%s: 0x%02x\n", __func__, byte);
+	if (CONFIG(DEBUG_IPMI))
+		printk(BIOS_SPEW, "%s: 0x%02x\n", __func__, byte);
 
 	if (wait_ibf_timeout(port))
 		return 1;
@@ -101,7 +104,8 @@
 
 static int ipmi_kcs_send_cmd_byte(int port, const unsigned char byte)
 {
-	printk(BIOS_SPEW, "%s: 0x%02x\n", __func__, byte);
+	if (CONFIG(DEBUG_IPMI))
+		printk(BIOS_SPEW, "%s: 0x%02x\n", __func__, byte);
 
 	if (wait_ibf_timeout(port))
 		return 1;