Re: [PATCH v3 2/2] hwmon: intel-m10-bmc-hwmon: add hwmon support for Intel MAX 10 BMC

2020-09-29 Thread Guenter Roeck
On 9/20/20 11:17 PM, Xu Yilun wrote:
> This patch adds hwmon functionality for Intel MAX 10 BMC chip. This BMC
> chip connects to a set of sensor chips to monitor current, voltage,
> thermal and power of different components on board. The BMC firmware is
> responsible for sensor data sampling and recording in shared registers.
> Host driver reads the sensor data from these shared registers and
> exposes them to users as hwmon interfaces.
> 
> Signed-off-by: Xu Yilun 
> Signed-off-by: Wu Hao 
> Signed-off-by: Matthew Gerlach 
> Signed-off-by: Tom Rix 

Reviewed-by: Guenter Roeck 

> ---
> v2: add the Documentation
> refactor the code, provide static hwmon_channel_info
> remove Unnecessary hwmon-sysfs.h
> make the sensor data table const
> v3: make the data tables a pointer array indexed by hwmon_sensor_types
> some minor fixes
> ---
>  Documentation/hwmon/index.rst   |   1 +
>  Documentation/hwmon/intel-m10-bmc-hwmon.rst |  78 +++
>  drivers/hwmon/Kconfig   |  11 +
>  drivers/hwmon/Makefile  |   1 +
>  drivers/hwmon/intel-m10-bmc-hwmon.c | 334 
> 
>  5 files changed, 425 insertions(+)
>  create mode 100644 Documentation/hwmon/intel-m10-bmc-hwmon.rst
>  create mode 100644 drivers/hwmon/intel-m10-bmc-hwmon.c
> 
> diff --git a/Documentation/hwmon/index.rst b/Documentation/hwmon/index.rst
> index a926f1a..4bcb1a7 100644
> --- a/Documentation/hwmon/index.rst
> +++ b/Documentation/hwmon/index.rst
> @@ -74,6 +74,7 @@ Hardware Monitoring Kernel Drivers
> ina209
> ina2xx
> ina3221
> +   intel-m10-bmc-hwmon
> ir35221
> ir38064
> isl68137
> diff --git a/Documentation/hwmon/intel-m10-bmc-hwmon.rst 
> b/Documentation/hwmon/intel-m10-bmc-hwmon.rst
> new file mode 100644
> index 000..3d148c6
> --- /dev/null
> +++ b/Documentation/hwmon/intel-m10-bmc-hwmon.rst
> @@ -0,0 +1,78 @@
> +.. SPDX-License-Identifier: GPL-2.0
> +
> +Kernel driver intel-m10-bmc-hwmon
> +=
> +
> +Supported chips:
> +
> + * Intel MAX 10 BMC for Intel PAC N3000
> +
> +   Prefix: 'n3000bmc-hwmon'
> +
> +Author: Xu Yilun 
> +
> +
> +Description
> +---
> +
> +This driver adds the temperature, voltage, current and power reading
> +support for the Intel MAX 10 Board Management Controller (BMC) chip.
> +The BMC chip is integrated in some Intel Programmable Acceleration
> +Cards (PAC). It connects to a set of sensor chips to monitor the
> +sensor data of different components on the board. The BMC firmware is
> +responsible for sensor data sampling and recording in shared
> +registers. The host driver reads the sensor data from these shared
> +registers and exposes them to users as hwmon interfaces.
> +
> +The BMC chip is implemented using the Intel MAX 10 CPLD. It could be
> +reprogramed to some variants in order to support different Intel
> +PACs. The driver is designed to be able to distinguish between the
> +variants, but now it only supports the BMC for Intel PAC N3000.
> +
> +
> +Sysfs attributes
> +
> +
> +The following attributes are supported:
> +
> +- Intel MAX 10 BMC for Intel PAC N3000:
> +
> +=== 
> ===
> +tempX_input Temperature of the component (specified by 
> tempX_label)
> +tempX_max   Temperature maximum setpoint of the component
> +tempX_crit  Temperature critical setpoint of the component
> +tempX_max_hyst  Hysteresis for temperature maximum of the component
> +tempX_crit_hyst Hysteresis for temperature critical of the component
> +temp1_label "Board Temperature"
> +temp2_label "FPGA Die Temperature"
> +temp3_label "QSFP0 Temperature"
> +temp4_label "QSFP1 Temperature"
> +temp5_label "Retimer A Temperature"
> +temp6_label "Retimer A SerDes Temperature"
> +temp7_label "Retimer B Temperature"
> +temp8_label "Retimer B SerDes Temperature"
> +
> +inX_input   Measured voltage of the component (specified by
> +inX_label)
> +in0_label   "QSFP0 Supply Voltage"
> +in1_label   "QSFP1 Supply Voltage"
> +in2_label   "FPGA Core Voltage"
> +in3_label   "12V Backplane Voltage"
> +in4_label   "1.2V Voltage"
> +in5_label   "12V AUX Voltage"
> +in6_label   "1.8V Voltage"
> +in7_label   "3.3V Voltage"
> +
> +currX_input Measured current of the component (specified by
> +currX_label)
> +curr1_label "FPGA Core Current"
> +curr2_label "12V Backplane Current"
> +curr3_label "12V AUX Current"
> +
> +powerX_inputMeasured power of the component (specified by
> +powerX_label)
> +power1_label"Board Power"
> +
> +

[PATCH v3 2/2] hwmon: intel-m10-bmc-hwmon: add hwmon support for Intel MAX 10 BMC

2020-09-20 Thread Xu Yilun
This patch adds hwmon functionality for Intel MAX 10 BMC chip. This BMC
chip connects to a set of sensor chips to monitor current, voltage,
thermal and power of different components on board. The BMC firmware is
responsible for sensor data sampling and recording in shared registers.
Host driver reads the sensor data from these shared registers and
exposes them to users as hwmon interfaces.

Signed-off-by: Xu Yilun 
Signed-off-by: Wu Hao 
Signed-off-by: Matthew Gerlach 
Signed-off-by: Tom Rix 
---
v2: add the Documentation
refactor the code, provide static hwmon_channel_info
remove Unnecessary hwmon-sysfs.h
make the sensor data table const
v3: make the data tables a pointer array indexed by hwmon_sensor_types
some minor fixes
---
 Documentation/hwmon/index.rst   |   1 +
 Documentation/hwmon/intel-m10-bmc-hwmon.rst |  78 +++
 drivers/hwmon/Kconfig   |  11 +
 drivers/hwmon/Makefile  |   1 +
 drivers/hwmon/intel-m10-bmc-hwmon.c | 334 
 5 files changed, 425 insertions(+)
 create mode 100644 Documentation/hwmon/intel-m10-bmc-hwmon.rst
 create mode 100644 drivers/hwmon/intel-m10-bmc-hwmon.c

diff --git a/Documentation/hwmon/index.rst b/Documentation/hwmon/index.rst
index a926f1a..4bcb1a7 100644
--- a/Documentation/hwmon/index.rst
+++ b/Documentation/hwmon/index.rst
@@ -74,6 +74,7 @@ Hardware Monitoring Kernel Drivers
ina209
ina2xx
ina3221
+   intel-m10-bmc-hwmon
ir35221
ir38064
isl68137
diff --git a/Documentation/hwmon/intel-m10-bmc-hwmon.rst 
b/Documentation/hwmon/intel-m10-bmc-hwmon.rst
new file mode 100644
index 000..3d148c6
--- /dev/null
+++ b/Documentation/hwmon/intel-m10-bmc-hwmon.rst
@@ -0,0 +1,78 @@
+.. SPDX-License-Identifier: GPL-2.0
+
+Kernel driver intel-m10-bmc-hwmon
+=
+
+Supported chips:
+
+ * Intel MAX 10 BMC for Intel PAC N3000
+
+   Prefix: 'n3000bmc-hwmon'
+
+Author: Xu Yilun 
+
+
+Description
+---
+
+This driver adds the temperature, voltage, current and power reading
+support for the Intel MAX 10 Board Management Controller (BMC) chip.
+The BMC chip is integrated in some Intel Programmable Acceleration
+Cards (PAC). It connects to a set of sensor chips to monitor the
+sensor data of different components on the board. The BMC firmware is
+responsible for sensor data sampling and recording in shared
+registers. The host driver reads the sensor data from these shared
+registers and exposes them to users as hwmon interfaces.
+
+The BMC chip is implemented using the Intel MAX 10 CPLD. It could be
+reprogramed to some variants in order to support different Intel
+PACs. The driver is designed to be able to distinguish between the
+variants, but now it only supports the BMC for Intel PAC N3000.
+
+
+Sysfs attributes
+
+
+The following attributes are supported:
+
+- Intel MAX 10 BMC for Intel PAC N3000:
+
+=== ===
+tempX_input Temperature of the component (specified by tempX_label)
+tempX_max   Temperature maximum setpoint of the component
+tempX_crit  Temperature critical setpoint of the component
+tempX_max_hyst  Hysteresis for temperature maximum of the component
+tempX_crit_hyst Hysteresis for temperature critical of the component
+temp1_label "Board Temperature"
+temp2_label "FPGA Die Temperature"
+temp3_label "QSFP0 Temperature"
+temp4_label "QSFP1 Temperature"
+temp5_label "Retimer A Temperature"
+temp6_label "Retimer A SerDes Temperature"
+temp7_label "Retimer B Temperature"
+temp8_label "Retimer B SerDes Temperature"
+
+inX_input   Measured voltage of the component (specified by
+inX_label)
+in0_label   "QSFP0 Supply Voltage"
+in1_label   "QSFP1 Supply Voltage"
+in2_label   "FPGA Core Voltage"
+in3_label   "12V Backplane Voltage"
+in4_label   "1.2V Voltage"
+in5_label   "12V AUX Voltage"
+in6_label   "1.8V Voltage"
+in7_label   "3.3V Voltage"
+
+currX_input Measured current of the component (specified by
+currX_label)
+curr1_label "FPGA Core Current"
+curr2_label "12V Backplane Current"
+curr3_label "12V AUX Current"
+
+powerX_inputMeasured power of the component (specified by
+powerX_label)
+power1_label"Board Power"
+
+=== ===
+
+All the attributes are read-only.
diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig
index 8dc28b2..53af15c 100644
--- a/drivers/hwmon/Kconfig
+++ b/drivers/hwmon/Kconfig
@@ -2064,6 +2064,17 @@ config SENSORS_XGENE
  If you say