wcnss: add driver API to support Thermal Mitigation
The wcnss driver currently supports a sysfs-based mechanism which
allows the Thermal Mitigation function in userspace to read and write
the current thermal mitigation level. An API is added to allow other
drivers (specifically the WLAN Driver) to register a notifier to be
invoked when the thermal mitigation level is changed.
CRs-Fixed: 317376
Change-Id: Ieda320b618a0a08186db791168e586a86b54d173
Signed-off-by: Jeff Johnson <jjohnson@codeaurora.org>
diff --git a/drivers/net/wireless/wcnss/wcnss_wlan.c b/drivers/net/wireless/wcnss/wcnss_wlan.c
index 3e3b57f..cc95fcd 100644
--- a/drivers/net/wireless/wcnss/wcnss_wlan.c
+++ b/drivers/net/wireless/wcnss/wcnss_wlan.c
@@ -45,6 +45,7 @@
int smd_channel_ready;
unsigned int serial_number;
int thermal_mitigation;
+ void (*tm_notify)(int);
struct wcnss_wlan_config wlan_config;
struct delayed_work wcnss_work;
} *penv = NULL;
@@ -97,6 +98,8 @@
if (sscanf(buf, "%d", &value) != 1)
return -EINVAL;
penv->thermal_mitigation = value;
+ if (penv->tm_notify)
+ (penv->tm_notify)(value);
return count;
}
@@ -272,6 +275,23 @@
}
EXPORT_SYMBOL(wcnss_wlan_unregister_pm_ops);
+void wcnss_register_thermal_mitigation(void (*tm_notify)(int))
+{
+ if (penv && tm_notify)
+ penv->tm_notify = tm_notify;
+}
+EXPORT_SYMBOL(wcnss_register_thermal_mitigation);
+
+void wcnss_unregister_thermal_mitigation(void (*tm_notify)(int))
+{
+ if (penv && tm_notify) {
+ if (tm_notify != penv->tm_notify)
+ pr_err("tm_notify doesn't match registered\n");
+ penv->tm_notify = NULL;
+ }
+}
+EXPORT_SYMBOL(wcnss_unregister_thermal_mitigation);
+
unsigned int wcnss_get_serial_number(void)
{
if (penv)
diff --git a/include/linux/wcnss_wlan.h b/include/linux/wcnss_wlan.h
index 9759b32..1c492f9 100644
--- a/include/linux/wcnss_wlan.h
+++ b/include/linux/wcnss_wlan.h
@@ -35,6 +35,8 @@
const struct dev_pm_ops *pm_ops);
void wcnss_wlan_unregister_pm_ops(struct device *dev,
const struct dev_pm_ops *pm_ops);
+void wcnss_register_thermal_mitigation(void (*tm_notify)(int));
+void wcnss_unregister_thermal_mitigation(void (*tm_notify)(int));
struct platform_device *wcnss_get_platform_device(void);
struct wcnss_wlan_config *wcnss_get_wlan_config(void);
int wcnss_wlan_power(struct device *dev,