@@ -788,6 +788,10 @@ struct iwl_mvm {
*/
bool temperature_test; /* Debug test temperature is enabled */
+#if IS_ENABLED(CONFIG_HWMON)
+ struct device *hwmon;
+#endif
+
struct iwl_time_quota_cmd last_quota_cmd;
#ifdef CONFIG_NL80211_TESTMODE
@@ -1416,6 +1420,13 @@ void iwl_mvm_tt_initialize(struct iwl_mvm *mvm, u32 min_backoff);
void iwl_mvm_tt_exit(struct iwl_mvm *mvm);
void iwl_mvm_set_hw_ctkill_state(struct iwl_mvm *mvm, bool state);
int iwl_mvm_get_temp(struct iwl_mvm *mvm);
+#if IS_ENABLED(CONFIG_HWMON)
+int iwl_mvm_hwmon_register(struct iwl_mvm *mvm);
+void iwl_mvm_hwmon_unregister(struct iwl_mvm *mvm);
+#else
+static inline int iwl_mvm_hwmon_register(struct iwl_mvm *mvm) { return 0; }
+static inline void iwl_mvm_hwmon_unregister(struct iwl_mvm *mvm) {}
+#endif
/* Location Aware Regulatory */
struct iwl_mcc_update_resp *
@@ -595,6 +595,7 @@ iwl_op_mode_mvm_start(struct iwl_trans *trans, const struct iwl_cfg *cfg,
mvm->refs[IWL_MVM_REF_UCODE_DOWN] = 1;
iwl_mvm_tof_init(mvm);
+ iwl_mvm_hwmon_register(mvm);
return op_mode;
@@ -616,6 +617,7 @@ static void iwl_op_mode_mvm_stop(struct iwl_op_mode *op_mode)
struct iwl_mvm *mvm = IWL_OP_MODE_GET_MVM(op_mode);
int i;
+ iwl_mvm_hwmon_unregister(mvm);
iwl_mvm_leds_exit(mvm);
iwl_mvm_tt_exit(mvm);
@@ -64,6 +64,7 @@
*
*****************************************************************************/
+#include <linux/hwmon.h>
#include "mvm.h"
#define IWL_MVM_TEMP_NOTIF_WAIT_TIMEOUT HZ
@@ -414,6 +415,67 @@ void iwl_mvm_tt_handler(struct iwl_mvm *mvm)
}
}
+#if IS_ENABLED(CONFIG_HWMON)
+static ssize_t temp1_input_show(struct device *device,
+ struct device_attribute *devattr,
+ char *buf)
+{
+ struct iwl_mvm *mvm = dev_get_drvdata(device);
+
+ return snprintf(buf, PAGE_SIZE, "%d\n", mvm->temperature * 1000);
+}
+static DEVICE_ATTR_RO(temp1_input);
+
+static ssize_t temp1_crit_show(struct device *device,
+ struct device_attribute *devattr,
+ char *buf)
+{
+ struct iwl_mvm *mvm = dev_get_drvdata(device);
+ struct iwl_tt_params *params = &mvm->thermal_throttle.params;
+
+ return snprintf(buf, PAGE_SIZE, "%d\n", params->ct_kill_entry * 1000);
+}
+static DEVICE_ATTR_RO(temp1_crit);
+
+static ssize_t temp1_max_show(struct device *device,
+ struct device_attribute *devattr,
+ char *buf)
+{
+ struct iwl_mvm *mvm = dev_get_drvdata(device);
+ struct iwl_tt_params *params = &mvm->thermal_throttle.params;
+
+ return snprintf(buf, PAGE_SIZE, "%d\n", params->tx_protection_entry * 1000);
+}
+static DEVICE_ATTR_RO(temp1_max);
+
+static struct attribute *mvm_hwmon_attrs[] = {
+ &dev_attr_temp1_input.attr,
+ &dev_attr_temp1_crit.attr,
+ &dev_attr_temp1_max.attr,
+ NULL,
+};
+ATTRIBUTE_GROUPS(mvm_hwmon);
+
+int iwl_mvm_hwmon_register(struct iwl_mvm *mvm)
+{
+ struct wiphy *wiphy = mvm->hw->wiphy;
+ struct device *hwmon;
+
+ hwmon = hwmon_device_register_with_groups(mvm->dev, wiphy_name(wiphy),
+ mvm, mvm_hwmon_groups);
+ if (!IS_ERR(hwmon))
+ mvm->hwmon = hwmon;
+ return PTR_ERR_OR_ZERO(hwmon);
+}
+
+void iwl_mvm_hwmon_unregister(struct iwl_mvm *mvm)
+{
+ if (mvm->hwmon)
+ hwmon_device_unregister(mvm->hwmon);
+ mvm->hwmon = NULL;
+}
+#endif /* CONFIG_HWMON */
+
static const struct iwl_tt_params iwl_mvm_default_tt_params = {
.ct_kill_entry = 118,
.ct_kill_exit = 96,