Skip to contentSkip to conversation

ipmi: add an Aspeed KCS IPMI BMC driver

PATCH New Haiyue Wang 1 participant 2 messages Dec 10, 2017

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 ipmi: add an Aspeed KCS IPMI BMC driver

This patch adds a simple device driver to expose the KCS interface on Aspeed SOCs (AST2400 and AST2500) as a character device. Such SOCs are commonly used as BMCs (BaseBoard Management Controllers) and this driver implements the BMC side of the KCS interface.

The KCS (Keyboard Controller Style) interface is used to perform in-band IPMI communication between a host and its BMC.

The device name defaults to '/dev/ipmi-kcsX', X=1,2,3,4.

---
 .../devicetree/bindings/mfd/aspeed-lpc.txt         |  31 +-
 drivers/char/ipmi/Kconfig                          |   9 +
 drivers/char/ipmi/Makefile                         |   1 +
 drivers/char/ipmi/kcs-bmc.c                        | 759 +++++++++++++++++++++
 include/uapi/linux/kcs-bmc.h                       |  13 +
 5 files changed, 810 insertions(+), 3 deletions(-)
 create mode 100644 drivers/char/ipmi/kcs-bmc.c
 create mode 100644 include/uapi/linux/kcs-bmc.h
Documentation/devicetree/bindings/mfd/aspeed-lpc.txt +28 -3
index a97131a..ed4d796 100644
@@ -62,12 +62,24 @@ BMC Node
 --------
 
 - compatible:	One of:
-		"aspeed,ast2400-lpc-bmc"
-		"aspeed,ast2500-lpc-bmc"
+		"aspeed,ast2400-lpc-bmc", "simple-mfd", "syscon"
+		"aspeed,ast2500-lpc-bmc", "simple-mfd", "syscon"
 
 - reg:		contains the physical address and length values of the
                 H8S/2168-compatible LPC controller memory region
 
+BMC KCS Node
+------------
+
+- compatible:	One of:
+		"aspeed,ast2400-kcs-bmc"
+		"aspeed,ast2500-kcs-bmc"
+
+- kcs_chan: The LPC channel number
+
+- kcs_addr: The host CPU IO map address
+
+
 Host Node
 ---------
 
@@ -94,8 +106,21 @@ lpc: lpc@1e789000 {
 	ranges = <0x0 0x1e789000 0x1000>;
 
 	lpc_bmc: lpc-bmc@0 {
-		compatible = "aspeed,ast2500-lpc-bmc";
+		compatible = "aspeed,ast2500-lpc-bmc", "simple-mfd", "syscon";
 		reg = <0x0 0x80>;
+		reg-io-width = <4>;
+
+		#address-cells = <1>;
+		#size-cells = <1>;
+		ranges = <0x0 0x0 0x80>;
+
+		kcs3: kcs3@0 {
+			compatible = "aspeed,ast2500-kcs-bmc";
+			interrupts = <8>;
+			kcs_chan = <3>;
+			kcs_addr = <0xCA2>;
+			status = "okay";
+		};
 	};
 
 	lpc_host: lpc-host@80 {
drivers/char/ipmi/Kconfig +9 -0
index 90f3edf..daa6dfc 100644
@@ -85,3 +85,12 @@ config ASPEED_BT_IPMI_BMC
 	  Provides a driver for the BT (Block Transfer) IPMI interface
 	  found on Aspeed SOCs (AST2400 and AST2500). The driver
 	  implements the BMC side of the BT interface.
+
+config ASPEED_KCS_IPMI_BMC
+	depends on ARCH_ASPEED || COMPILE_TEST
+        depends on REGMAP && REGMAP_MMIO && MFD_SYSCON
+	tristate "KCS IPMI bmc driver"
+	help
+	  Provides a driver for the KCS (Keyboard Controller Style) IPMI
+	  interface found on Aspeed SOCs (AST2400 and AST2500). The driver
+	  implements the BMC side of the KCS interface.
\ No newline at end of file
drivers/char/ipmi/Makefile +1 -0
index 0d98cd9..35272a7 100644
@@ -12,3 +12,4 @@ obj-$(CONFIG_IPMI_POWERNV) += ipmi_powernv.o
 obj-$(CONFIG_IPMI_WATCHDOG) += ipmi_watchdog.o
 obj-$(CONFIG_IPMI_POWEROFF) += ipmi_poweroff.o
 obj-$(CONFIG_ASPEED_BT_IPMI_BMC) += bt-bmc.o
+obj-$(CONFIG_ASPEED_KCS_IPMI_BMC) += kcs-bmc.o
\ No newline at end of file
drivers/char/ipmi/kcs-bmc.c new file +759 -0

759 lines not on this page · raw message

include/uapi/linux/kcs-bmc.h new file +13 -0
new file mode 100644
index 0000000..f0c3ff60
@@ -0,0 +1,13 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (c) 2015-2017, Intel Corporation.
+
+#ifndef _UAPI_LINUX_KCS_BMC_H
+#define _UAPI_LINUX_KCS_BMC_H
+
+#include <linux/ioctl.h>
+
+#define __KCS_BMC_IOCTL_MAGIC      'K'
+#define KCS_BMC_IOCTL_SMS_ATN      _IOW(__KCS_BMC_IOCTL_MAGIC, 1, unsigned long)
+#define KCS_BMC_IOCTL_FORCE_ABORT  _IO(__KCS_BMC_IOCTL_MAGIC, 2)
+
+#endif /* _UAPI_LINUX_KCS_BMC_H */
Signature · 1 line
2.7.4
#1 lore raw

PATCH 2/2 ipmi: add the KCS nodes into AST2500 device tree

Add kcs1, kcs2, kcs3 into mfd node 'lpc-bmc at 0', and add kcs4 into mfd node 'lpc-host at 80'.

---
 arch/arm/boot/dts/aspeed-g5.dtsi | 42 ++++++++++++++++++++++++++++++++++++----
 1 file changed, 38 insertions(+), 4 deletions(-)
arch/arm/boot/dts/aspeed-g5.dtsi +38 -4
index ba3607c..5d67f55 100644
@@ -135,8 +135,39 @@
 			ranges = <0x0 0x1e789000 0x1000>;
 
 			lpc_bmc: lpc-bmc at 0 {
-				compatible = "aspeed,ast2500-lpc-bmc";
+				compatible = "aspeed,ast2500-lpc-bmc", "simple-mfd", "syscon";
 				reg = <0x0 0x80>;
+
+				#address-cells = <1>;
+				#size-cells = <1>;
+				ranges = <0x0 0x0 0x80>;
+
+				kcs1: kcs1 at 0 {
+					compatible = "aspeed,ast2500-kcs-bmc";
+					reg = <0x0 0x80>;
+					interrupts = <8>;
+					kcs_chan = <1>;
+					kcs_addr = <0x0>;
+					status = "disabled";
+				};
+
+				kcs2: kcs2 at 0 {
+					compatible = "aspeed,ast2500-kcs-bmc";
+					reg = <0x0 0x80>;
+					interrupts = <8>;
+					kcs_chan = <2>;
+					kcs_addr = <0x0>;
+					status = "disabled";
+				};
+
+				kcs3: kcs3 at 0 {
+					compatible = "aspeed,ast2500-kcs-bmc";
+					reg = <0x0 0x80>;
+					interrupts = <8>;
+					kcs_chan = <3>;
+					kcs_addr = <0x0>;
+					status = "disabled";
+				};
 			};
 
 			lpc_host: lpc-host at 80 {
@@ -148,9 +179,12 @@
 				#size-cells = <1>;
 				ranges = <0x0 0x80 0x1e0>;
 
-				lpc_ctrl: lpc-ctrl at 0 {
-					compatible = "aspeed,ast2500-lpc-ctrl";
-					reg = <0x0 0x80>;
+				kcs4: kcs4 at 0 {
+					compatible = "aspeed,ast2500-kcs-bmc";
+					reg = <0x0 0xa0>;
+					interrupts = <8>;
+					kcs_chan = <4>;
+					kcs_addr = <0x0>;
 					status = "disabled";
 				};
 
Signature · 1 line
2.7.4