diff options
| author | Sourav Mohapatra <mohapatr@codeaurora.org> | 2019-05-02 09:37:21 +0530 |
|---|---|---|
| committer | nshrivas <nshrivas@codeaurora.org> | 2019-07-17 01:28:23 -0700 |
| commit | 44e742f75154c4f026fefbfdf5610bbb8bbede98 (patch) | |
| tree | 2de22d1084bd5402ee241df4eac46da04b70ec8c | |
| parent | 3f97d298ee0c3a76e1de529cf15680086c26b975 (diff) | |
qcacld-3.0: Add PLD ops to notify thermal level change
As a part of a requirement, the platform driver registers with thermal
subsystem as a cooling device. After this registration, the thermal
subsystem notifies the platform driver when there is a change in the
temperature level according to predefined thresholds in the dtsi.
This notification needs to be forwared to WLAN host, on which
appropriate mitigation action can take place.
Add a PLD ops - set_curr_therm_state() using which the platform driver
sends thermal state change notification to WLAN host. The callback
contains state variable to store the current thermal state.
Change-Id: Idac72a8ac8b1d6f2a5a7ed585a8d9e0470bb99a5
CRs-Fixed: 2468796
| -rw-r--r-- | core/pld/inc/pld_common.h | 35 | ||||
| -rw-r--r-- | core/pld/src/pld_common.c | 32 | ||||
| -rw-r--r-- | core/pld/src/pld_snoc.c | 30 |
3 files changed, 95 insertions, 2 deletions
diff --git a/core/pld/inc/pld_common.h b/core/pld/inc/pld_common.h index aef1aaecc70c..7cfc2c8c8f84 100644 --- a/core/pld/inc/pld_common.h +++ b/core/pld/inc/pld_common.h @@ -292,7 +292,7 @@ struct pld_soc_info { * @modem_status: optional operation, will be called when platform driver * sending modem power status to WLAN FW * @uevent: optional operation, will be called when platform driver - * updating driver status + * updating driver status * @runtime_suspend: optional operation, prepare the device for a condition * in which it won't be able to communicate with the CPU(s) * and RAM due to power management. @@ -301,6 +301,11 @@ struct pld_soc_info { * hardware or at the request of software. * @suspend_noirq: optional operation, complete the actions started by suspend() * @resume_noirq: optional operation, prepare for the execution of resume() + * @set_curr_therm_state: optional operation, will be called when there is a + * change in the thermal level triggered by the thermal + * subsystem thus requiring mitigation actions. This will + * be called every time there is a change in the state + * and after driver load. */ struct pld_driver_ops { int (*probe)(struct device *dev, @@ -334,6 +339,7 @@ struct pld_driver_ops { enum pld_bus_type bus_type); int (*resume_noirq)(struct device *dev, enum pld_bus_type bus_type); + int (*set_curr_therm_state)(struct device *dev, int state); }; int pld_init(void); @@ -616,4 +622,31 @@ static inline int pld_nbuf_pre_alloc_free(struct sk_buff *skb) return 0; } #endif + +/** + * pld_thermal_register() - Register the thermal device with the thermal system + * @dev: The device structure + * @state: The max state to be configured on registration + * + * Return: Error code on error + */ +int pld_thermal_register(struct device *dev, int state); + +/** + * pld_thermal_unregister() - Unregister the device with the thermal system + * @dev: The device structure + * + * Return: None + */ +void pld_thermal_unregister(struct device *dev); + +/** + * pld_get_thermal_state() - Get the current thermal state from the PLD + * @dev: The device structure + * @thermal_state: param to store the current thermal state + * + * Return: Non-zero code for error; zero for success + */ +int pld_get_thermal_state(struct device *dev, uint16_t *thermal_state); + #endif diff --git a/core/pld/src/pld_common.c b/core/pld/src/pld_common.c index d278a004b3b2..19db8f54e6b4 100644 --- a/core/pld/src/pld_common.c +++ b/core/pld/src/pld_common.c @@ -1575,3 +1575,35 @@ void pld_block_shutdown(struct device *dev, bool status) break; } } + +#ifdef CONFIG_PLD_SNOC_ICNSS +int pld_thermal_register(struct device *dev, int max_state) +{ + return icnss_thermal_register(dev, max_state); +} + +void pld_thermal_unregister(struct device *dev) +{ + icnss_thermal_unregister(dev); +} + +int pld_get_thermal_state(struct device *dev, uint16_t *thermal_state) +{ + return icnss_get_curr_therm_state(dev, (unsigned long *)thermal_state); +} + +#else +int pld_thermal_register(struct device *dev, int max_state) +{ + return -ENOTSUPP; +} + +void pld_thermal_unregister(struct device *dev) +{ +} + +int pld_get_thermal_state(struct device *dev, uint16_t *thermal_state) +{ + return -ENOTSUPP; +} +#endif diff --git a/core/pld/src/pld_snoc.c b/core/pld/src/pld_snoc.c index b1d1ed25b740..cb3dc8dd2ce9 100644 --- a/core/pld/src/pld_snoc.c +++ b/core/pld/src/pld_snoc.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2018 The Linux Foundation. All rights reserved. + * Copyright (c) 2016-2019 The Linux Foundation. All rights reserved. * * Permission to use, copy, modify, and/or distribute this software for * any purpose with or without fee is hereby granted, provided that the @@ -262,6 +262,33 @@ static int pld_snoc_uevent(struct device *dev, return 0; } +/** + * pld_snoc_set_thermal_state() - Set thermal state for thermal mitigation + * @dev: device + * @thermal_state: Thermal state set by thermal subsystem + * + * This function will be called when thermal subsystem notifies platform + * driver about change in thermal state. + * + * Return: 0 for success + * Non zero failure code for errors + */ +static int pld_snoc_set_thermal_state(struct device *dev, + unsigned long thermal_state) +{ + struct pld_context *pld_context; + + pld_context = pld_get_global_context(); + if (!pld_context) + return -EINVAL; + + if (pld_context->ops->set_curr_therm_state) + return pld_context->ops->set_curr_therm_state(dev, + thermal_state); + + return -ENOTSUPP; +} + #ifdef MULTI_IF_NAME #define PLD_SNOC_OPS_NAME "pld_snoc_" MULTI_IF_NAME #else @@ -280,6 +307,7 @@ struct icnss_driver_ops pld_snoc_ops = { .suspend_noirq = pld_snoc_suspend_noirq, .resume_noirq = pld_snoc_resume_noirq, .uevent = pld_snoc_uevent, + .set_therm_state = pld_snoc_set_thermal_state, }; /** |
