|
@@ -19,6 +19,10 @@
|
|
#include <linux/sysfs.h>
|
|
#include <linux/sysfs.h>
|
|
#include <linux/aer.h>
|
|
#include <linux/aer.h>
|
|
#include <linux/log2.h>
|
|
#include <linux/log2.h>
|
|
|
|
+#ifdef CONFIG_QLCNIC_HWMON
|
|
|
|
+#include <linux/hwmon.h>
|
|
|
|
+#include <linux/hwmon-sysfs.h>
|
|
|
|
+#endif
|
|
|
|
|
|
#define QLC_STATUS_UNSUPPORTED_CMD -2
|
|
#define QLC_STATUS_UNSUPPORTED_CMD -2
|
|
|
|
|
|
@@ -1243,6 +1247,68 @@ static struct bin_attribute bin_attr_flash = {
|
|
.write = qlcnic_83xx_sysfs_flash_write_handler,
|
|
.write = qlcnic_83xx_sysfs_flash_write_handler,
|
|
};
|
|
};
|
|
|
|
|
|
|
|
+#ifdef CONFIG_QLCNIC_HWMON
|
|
|
|
+
|
|
|
|
+static ssize_t qlcnic_hwmon_show_temp(struct device *dev,
|
|
|
|
+ struct device_attribute *dev_attr,
|
|
|
|
+ char *buf)
|
|
|
|
+{
|
|
|
|
+ struct qlcnic_adapter *adapter = dev_get_drvdata(dev);
|
|
|
|
+ unsigned int temperature = 0, value = 0;
|
|
|
|
+
|
|
|
|
+ if (qlcnic_83xx_check(adapter))
|
|
|
|
+ value = QLCRDX(adapter->ahw, QLC_83XX_ASIC_TEMP);
|
|
|
|
+ else if (qlcnic_82xx_check(adapter))
|
|
|
|
+ value = QLC_SHARED_REG_RD32(adapter, QLCNIC_ASIC_TEMP);
|
|
|
|
+
|
|
|
|
+ temperature = qlcnic_get_temp_val(value);
|
|
|
|
+ /* display millidegree celcius */
|
|
|
|
+ temperature *= 1000;
|
|
|
|
+ return sprintf(buf, "%u\n", temperature);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/* hwmon-sysfs attributes */
|
|
|
|
+static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO,
|
|
|
|
+ qlcnic_hwmon_show_temp, NULL, 1);
|
|
|
|
+
|
|
|
|
+static struct attribute *qlcnic_hwmon_attrs[] = {
|
|
|
|
+ &sensor_dev_attr_temp1_input.dev_attr.attr,
|
|
|
|
+ NULL
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+ATTRIBUTE_GROUPS(qlcnic_hwmon);
|
|
|
|
+
|
|
|
|
+void qlcnic_register_hwmon_dev(struct qlcnic_adapter *adapter)
|
|
|
|
+{
|
|
|
|
+ struct device *dev = &adapter->pdev->dev;
|
|
|
|
+ struct device *hwmon_dev;
|
|
|
|
+
|
|
|
|
+ /* Skip hwmon registration for a VF device */
|
|
|
|
+ if (qlcnic_sriov_vf_check(adapter)) {
|
|
|
|
+ adapter->ahw->hwmon_dev = NULL;
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ hwmon_dev = hwmon_device_register_with_groups(dev, qlcnic_driver_name,
|
|
|
|
+ adapter,
|
|
|
|
+ qlcnic_hwmon_groups);
|
|
|
|
+ if (IS_ERR(hwmon_dev)) {
|
|
|
|
+ dev_err(dev, "Cannot register with hwmon, err=%ld\n",
|
|
|
|
+ PTR_ERR(hwmon_dev));
|
|
|
|
+ hwmon_dev = NULL;
|
|
|
|
+ }
|
|
|
|
+ adapter->ahw->hwmon_dev = hwmon_dev;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void qlcnic_unregister_hwmon_dev(struct qlcnic_adapter *adapter)
|
|
|
|
+{
|
|
|
|
+ struct device *hwmon_dev = adapter->ahw->hwmon_dev;
|
|
|
|
+ if (hwmon_dev) {
|
|
|
|
+ hwmon_device_unregister(hwmon_dev);
|
|
|
|
+ adapter->ahw->hwmon_dev = NULL;
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+#endif
|
|
|
|
+
|
|
void qlcnic_create_sysfs_entries(struct qlcnic_adapter *adapter)
|
|
void qlcnic_create_sysfs_entries(struct qlcnic_adapter *adapter)
|
|
{
|
|
{
|
|
struct device *dev = &adapter->pdev->dev;
|
|
struct device *dev = &adapter->pdev->dev;
|