Browse Source

qcacld-3.0: Add PLD API to send WFC mode to FW

Add PLD API to send WFC(WiFi Calling) mode to WLAN FW.

Change-Id: I4aef58caa93d255233d2412aa6d03017da4b5f10
CRs-Fixed: 3346545
Naman Padhiar 2 years ago
parent
commit
2b2c0a0436
4 changed files with 86 additions and 0 deletions
  1. 19 0
      core/pld/inc/pld_common.h
  2. 25 0
      core/pld/src/pld_common.c
  3. 25 0
      core/pld/src/pld_pcie.c
  4. 17 0
      core/pld/src/pld_pcie.h

+ 19 - 0
core/pld/inc/pld_common.h

@@ -164,6 +164,16 @@ enum pld_platform_cap_flag {
 	PLD_HAS_DRV_SUPPORT = 0x04,
 };
 
+/**
+ * enum pld_wfc_mode - WFC Mode
+ * @PLD_WFC_MODE_OFF: WFC Inactive
+ * @PLD_WFC_MODE_ON: WFC Active
+ */
+enum pld_wfc_mode {
+	PLD_WFC_MODE_OFF,
+	PLD_WFC_MODE_ON,
+};
+
 /**
  * struct pld_platform_cap - platform capabilities
  * @cap_flag: capabilities flag
@@ -1114,6 +1124,15 @@ int pld_thermal_register(struct device *dev, unsigned long state, int mon_id);
  */
 void pld_thermal_unregister(struct device *dev, int mon_id);
 
+/**
+ * pld_set_wfc_mode() - Sent WFC mode to FW via platform driver
+ * @dev: The device structure
+ * @wfc_mode: WFC Modes (0 => Inactive, 1 => Active)
+ *
+ * Return: Error code on error
+ */
+int pld_set_wfc_mode(struct device *dev, enum pld_wfc_mode wfc_mode);
+
 /**
  * pld_bus_width_type_to_str() - Helper function to convert PLD bandwidth level
  *				 to string

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

@@ -3251,6 +3251,31 @@ void pld_thermal_unregister(struct device *dev, int mon_id)
 	}
 }
 
+int pld_set_wfc_mode(struct device *dev, enum pld_wfc_mode wfc_mode)
+{
+	int errno = -ENOTSUPP;
+	enum pld_bus_type type;
+
+	type = pld_get_bus_type(dev);
+	switch (type) {
+	case PLD_BUS_TYPE_SDIO:
+	case PLD_BUS_TYPE_USB:
+	case PLD_BUS_TYPE_SNOC:
+	case PLD_BUS_TYPE_IPCI_FW_SIM:
+	case PLD_BUS_TYPE_SNOC_FW_SIM:
+	case PLD_BUS_TYPE_IPCI:
+	case PLD_BUS_TYPE_PCIE_FW_SIM:
+		break;
+	case PLD_BUS_TYPE_PCIE:
+		errno = pld_pcie_set_wfc_mode(dev, wfc_mode);
+		break;
+	default:
+		pr_err("Invalid device type %d\n", type);
+		break;
+	}
+
+	return errno;
+}
 const char *pld_bus_width_type_to_str(enum pld_bus_width_type level)
 {
 	switch (level) {

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

@@ -1025,5 +1025,30 @@ void pld_pcie_device_self_recovery(struct device *dev,
 	}
 	cnss_self_recovery(dev, cnss_reason);
 }
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0))
+int pld_pcie_set_wfc_mode(struct device *dev,
+			  enum pld_wfc_mode wfc_mode)
+{
+	struct cnss_wfc_cfg cfg;
+	int ret;
+
+	switch (wfc_mode) {
+	case PLD_WFC_MODE_OFF:
+		cfg.mode = CNSS_WFC_MODE_OFF;
+		break;
+	case PLD_WFC_MODE_ON:
+		cfg.mode = CNSS_WFC_MODE_ON;
+		break;
+	default:
+		ret = -EINVAL;
+		goto out;
+	}
+
+	ret = cnss_set_wfc_mode(dev, cfg);
+out:
+	return ret;
+}
+#endif
 #endif
 #endif

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

@@ -450,7 +450,24 @@ static inline
 void pld_pcie_audio_smmu_unmap(struct device *dev, dma_addr_t iova, size_t size)
 {
 }
+
+static inline int pld_pcie_set_wfc_mode(struct device *dev,
+					enum pld_wfc_mode wfc_mode)
+{
+	return 0;
+}
+#else
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0))
+int pld_pcie_set_wfc_mode(struct device *dev,
+			  enum pld_wfc_mode wfc_mode);
 #else
+static inline int pld_pcie_set_wfc_mode(struct device *dev,
+					enum pld_wfc_mode wfc_mode)
+{
+	return 0;
+}
+#endif
+
 int pld_pcie_get_fw_files_for_target(struct device *dev,
 				     struct pld_fw_files *pfw_files,
 				     u32 target_type, u32 target_version);