Browse Source

qcacld-3.0: Add PLD APIs required for thermal mitigation feature

Add PLD APIs to register, deregister and query current thermal state.

Change-Id: I3da5d3fae20478af66c8dc21468a306b26d09ab9
CRs-Fixed: 3386745
Gangadhar Kavalastramath 2 years ago
parent
commit
b486e63bc2
3 changed files with 80 additions and 0 deletions
  1. 9 0
      core/pld/src/pld_common.c
  2. 31 0
      core/pld/src/pld_pcie.c
  3. 40 0
      core/pld/src/pld_pcie.h

+ 9 - 0
core/pld/src/pld_common.c

@@ -2495,7 +2495,10 @@ int pld_thermal_register(struct device *dev,
 	case PLD_BUS_TYPE_SDIO:
 	case PLD_BUS_TYPE_USB:
 	case PLD_BUS_TYPE_SNOC:
+		break;
 	case PLD_BUS_TYPE_PCIE:
+		errno = pld_pci_thermal_register(dev, max_state, mon_id);
+		break;
 	case PLD_BUS_TYPE_PCIE_FW_SIM:
 		break;
 	case PLD_BUS_TYPE_IPCI_FW_SIM:
@@ -2524,7 +2527,10 @@ void pld_thermal_unregister(struct device *dev, int mon_id)
 	case PLD_BUS_TYPE_SDIO:
 	case PLD_BUS_TYPE_USB:
 	case PLD_BUS_TYPE_SNOC:
+		break;
 	case PLD_BUS_TYPE_PCIE:
+		pld_pci_thermal_unregister(dev, mon_id);
+		break;
 	case PLD_BUS_TYPE_PCIE_FW_SIM:
 		break;
 	case PLD_BUS_TYPE_IPCI_FW_SIM:
@@ -2607,7 +2613,10 @@ int pld_get_thermal_state(struct device *dev, unsigned long *thermal_state,
 	case PLD_BUS_TYPE_SDIO:
 	case PLD_BUS_TYPE_USB:
 	case PLD_BUS_TYPE_SNOC:
+		break;
 	case PLD_BUS_TYPE_PCIE:
+		errno = pld_pci_get_thermal_state(dev, thermal_state, mon_id);
+		break;
 	case PLD_BUS_TYPE_PCIE_FW_SIM:
 		break;
 	case PLD_BUS_TYPE_IPCI_FW_SIM:

+ 31 - 0
core/pld/src/pld_pcie.c

@@ -120,6 +120,36 @@ out:
 	osif_psoc_sync_destroy(psoc_sync);
 }
 
+/**
+ * pld_pcie_set_thermal_state() - Set thermal state for thermal mitigation
+ * @pdev: PCIE device
+ * @thermal_state: Thermal state set by thermal subsystem
+ * @mon_id: Thermal cooling device ID
+ *
+ * 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_pcie_set_thermal_state(struct pci_dev *pdev,
+				      unsigned long thermal_state,
+				      int mon_id)
+{
+	struct pld_context *pld_context;
+
+	pld_context = pld_get_global_context();
+	if (!pld_context)
+		return -EINVAL;
+
+	if (pld_context->ops->set_curr_therm_cdev_state)
+		return pld_context->ops->set_curr_therm_cdev_state(&pdev->dev,
+								thermal_state,
+								mon_id);
+
+	return -ENOTSUPP;
+}
+
 #ifdef CONFIG_PLD_PCIE_CNSS
 /**
  * pld_pcie_idle_restart_cb() - Perform idle restart
@@ -727,6 +757,7 @@ struct cnss_wlan_driver pld_pcie_ops = {
 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0))
 	.chip_version = CHIP_VERSION,
 #endif
+	.set_therm_cdev_state = pld_pcie_set_thermal_state,
 };
 
 int pld_pcie_register_driver(void)

+ 40 - 0
core/pld/src/pld_pcie.h

@@ -501,6 +501,26 @@ static inline int pld_pcie_set_wfc_mode(struct device *dev,
 {
 	return 0;
 }
+
+static inline int pld_pci_thermal_register(struct device *dev,
+					   unsigned long max_state,
+					   int mon_id)
+{
+	return 0;
+}
+
+static inline void pld_pci_thermal_unregister(struct device *dev,
+					      int mon_id)
+{
+}
+
+static inline int pld_pci_get_thermal_state(struct device *dev,
+					    unsigned long *thermal_state,
+					    int mon_id)
+{
+	return 0;
+}
+
 #else
 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0))
 int pld_pcie_set_wfc_mode(struct device *dev,
@@ -865,6 +885,26 @@ static inline bool pld_pcie_platform_driver_support(void)
 	return true;
 }
 
+static inline int pld_pci_thermal_register(struct device *dev,
+					   unsigned long max_state,
+					   int mon_id)
+{
+	return cnss_thermal_cdev_register(dev, max_state, mon_id);
+}
+
+static inline void pld_pci_thermal_unregister(struct device *dev,
+					      int mon_id)
+{
+	cnss_thermal_cdev_unregister(dev, mon_id);
+}
+
+static inline int pld_pci_get_thermal_state(struct device *dev,
+					    unsigned long *thermal_state,
+					    int mon_id)
+{
+	return cnss_get_curr_therm_cdev_state(dev, thermal_state, mon_id);
+}
+
 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 15, 0))
 static inline bool pld_pcie_is_direct_link_supported(struct device *dev)
 {