Преглед на файлове

qcacld-3.0: Configure tsf gpio pin

qcacld-2.0 to qcacld-3.0 propagation

Add configuration of gpio pin used for TSF. FW shall toggle
this gpio when receive capture/get tsf cmd.

Change-Id: I442f2de3af4f3946a20bf3f4a9d8c9b285aa7a7c
CRs-Fixed: 817527
Manikandan Mohan преди 9 години
родител
ревизия
976e756f56

+ 6 - 0
core/hdd/inc/wlan_hdd_cfg.h

@@ -2911,6 +2911,11 @@ enum dot11p_mode {
 #define CFG_INFORM_BSS_RSSI_RAW_MAX                (1)
 #define CFG_INFORM_BSS_RSSI_RAW_DEFAULT            (1)
 
+/* GPIO pin to toggle when capture tsf */
+#define CFG_SET_TSF_GPIO_PIN_NAME                  "gtsf_gpio_pin"
+#define CFG_SET_TSF_GPIO_PIN_MIN                   (0)
+#define CFG_SET_TSF_GPIO_PIN_MAX                   (255)
+#define CFG_SET_TSF_GPIO_PIN_DEFAULT               (34)
 
 /*
  * OBSS scan parameters
@@ -3579,6 +3584,7 @@ struct hdd_config {
 	uint16_t obss_passive_dwelltime;
 	uint16_t obss_width_trigger_interval;
 	uint8_t inform_bss_rssi_raw;
+	uint32_t tsf_gpio_pin;
 #ifdef QCA_WIFI_3_0_EMU
 	bool enable_m2m_limitation;
 #endif

+ 9 - 0
core/hdd/src/wlan_hdd_cfg.c

@@ -3725,6 +3725,15 @@ REG_TABLE_ENTRY g_registry_table[] = {
 		CFG_INFORM_BSS_RSSI_RAW_MIN,
 		CFG_INFORM_BSS_RSSI_RAW_MAX),
 
+#ifdef WLAN_FEATURE_TSF
+	REG_VARIABLE(CFG_SET_TSF_GPIO_PIN_NAME, WLAN_PARAM_Integer,
+		struct hdd_config, tsf_gpio_pin,
+		VAR_FLAGS_OPTIONAL | VAR_FLAGS_RANGE_CHECK_ASSUME_DEFAULT,
+		CFG_SET_TSF_GPIO_PIN_DEFAULT,
+		CFG_SET_TSF_GPIO_PIN_MIN,
+		CFG_SET_TSF_GPIO_PIN_MAX),
+#endif
+
 #ifdef QCA_WIFI_3_0_EMU
 	REG_VARIABLE(CFG_ENABLE_M2M_LIMITATION, WLAN_PARAM_Integer,
 		struct hdd_config, enable_m2m_limitation,

+ 4 - 0
core/hdd/src/wlan_hdd_main.c

@@ -5943,6 +5943,10 @@ int hdd_wlan_startup(struct device *dev, void *hif_sc)
 	if (QDF_IS_STATUS_SUCCESS(status))
 		hdd_err("Error setting txlimit in sme: %d", status);
 
+	status = sme_set_tsf_gpio(hdd_ctx->hHal, hdd_ctx->config->tsf_gpio_pin);
+	if (!QDF_IS_STATUS_SUCCESS(status))
+		hdd_err("set tsf GPIO fail");
+
 #ifdef MSM_PLATFORM
 	spin_lock_init(&hdd_ctx->bus_bw_lock);
 	qdf_mc_timer_init(&hdd_ctx->bus_bw_timer,

+ 2 - 0
core/mac/src/include/sir_params.h

@@ -599,6 +599,8 @@ typedef struct sSirMbMsgP2p {
 #define SIR_HAL_SET_EGAP_CONF_PARAMS        (SIR_HAL_ITC_MSG_TYPES_BEGIN + 336)
 #define SIR_HAL_HT40_OBSS_SCAN_IND          (SIR_HAL_ITC_MSG_TYPES_BEGIN + 337)
 
+#define SIR_HAL_TSF_GPIO_PIN_REQ            (SIR_HAL_ITC_MSG_TYPES_BEGIN + 338)
+
 #define SIR_HAL_ADD_BCN_FILTER_CMDID        (SIR_HAL_ITC_MSG_TYPES_BEGIN + 339)
 #define SIR_HAL_REMOVE_BCN_FILTER_CMDID     (SIR_HAL_ITC_MSG_TYPES_BEGIN + 340)
 

+ 9 - 0
core/sme/inc/sme_api.h

@@ -1099,6 +1099,15 @@ QDF_STATUS sme_ht40_stop_obss_scan(tHalHandle hHal, uint32_t vdev_id);
 QDF_STATUS sme_set_tsfcb(tHalHandle hHal,
 	int (*cb_fn)(void *cb_ctx, struct stsf *ptsf), void *cb_ctx);
 
+#ifdef WLAN_FEATURE_TSF
+QDF_STATUS sme_set_tsf_gpio(tHalHandle h_hal, uint32_t pinvalue);
+#else
+static inline QDF_STATUS sme_set_tsf_gpio(tHalHandle h_hal, uint32_t pinvalue)
+{
+	return QDF_STATUS_E_FAILURE;
+}
+#endif
+
 QDF_STATUS sme_update_mimo_power_save(tHalHandle hHal,
 				      uint8_t is_ht_smps_enabled,
 				      uint8_t ht_smps_mode,

+ 38 - 7
core/sme/src/common/sme_api.c

@@ -7310,26 +7310,57 @@ QDF_STATUS sme_preferred_network_found_ind(tHalHandle hHal, void *pMsg)
 
 /*
  * sme_set_tsfcb() - Set callback for TSF capture
- * @hHal: Handler return by macOpen
+ * @h_hal: Handler return by mac_open
  * @cb_fn: Callback function pointer
  * @db_ctx: Callback data
  *
  * Return: QDF_STATUS
  */
-QDF_STATUS sme_set_tsfcb(tHalHandle hHal,
+QDF_STATUS sme_set_tsfcb(tHalHandle h_hal,
 	int (*cb_fn)(void *cb_ctx, struct stsf *ptsf), void *cb_ctx)
 {
-	tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
+	tpAniSirGlobal mac = PMAC_STRUCT(h_hal);
 	QDF_STATUS status;
 
-	status = sme_acquire_global_lock(&pMac->sme);
+	status = sme_acquire_global_lock(&mac->sme);
 	if (QDF_IS_STATUS_SUCCESS(status)) {
-		pMac->sme.get_tsf_cb = cb_fn;
-		pMac->sme.get_tsf_cxt = cb_ctx;
-		sme_release_global_lock(&pMac->sme);
+		mac->sme.get_tsf_cb = cb_fn;
+		mac->sme.get_tsf_cxt = cb_ctx;
+		sme_release_global_lock(&mac->sme);
+	}
+	return status;
+}
+
+#ifdef WLAN_FEATURE_TSF
+/*
+ * sme_set_tsf_gpio() - set gpio pin that be toggled when capture tef
+ * @h_hal: Handler return by mac_open
+ * @pinvalue: gpio pin id
+ *
+ * Return: QDF_STATUS
+ */
+QDF_STATUS sme_set_tsf_gpio(tHalHandle h_hal, uint32_t pinvalue)
+{
+	QDF_STATUS status;
+	cds_msg_t tsf_msg = {0};
+	tpAniSirGlobal mac = PMAC_STRUCT(h_hal);
+
+	status = sme_acquire_global_lock(&mac->sme);
+	if (QDF_IS_STATUS_SUCCESS(status)) {
+		tsf_msg.type = WMA_TSF_GPIO_PIN;
+		tsf_msg.reserved = 0;
+		tsf_msg.bodyval = pinvalue;
+
+		status = cds_mq_post_message(CDS_MQ_ID_WMA, &tsf_msg);
+		if (!QDF_IS_STATUS_SUCCESS(status)) {
+			sms_log(mac, LOGE, "Unable to post WMA_TSF_GPIO_PIN");
+			status = QDF_STATUS_E_FAILURE;
+		}
+		sme_release_global_lock(&mac->sme);
 	}
 	return status;
 }
+#endif
 
 QDF_STATUS sme_get_cfg_valid_channels(tHalHandle hHal, uint8_t *aValidChannels,
 				      uint32_t *len)

+ 28 - 0
core/wma/inc/wma_internal.h

@@ -1072,9 +1072,37 @@ QDF_STATUS wma_set_auto_shutdown_timer_req(tp_wma_handle wma_handle,
 					   auto_sh_cmd);
 #endif
 
+#ifdef WLAN_FEATURE_TSF
 int wma_vdev_tsf_handler(void *handle, uint8_t *data, uint32_t data_len);
 QDF_STATUS wma_capture_tsf(tp_wma_handle wma_handle, uint32_t vdev_id);
 QDF_STATUS wma_reset_tsf_gpio(tp_wma_handle wma_handle, uint32_t vdev_id);
+QDF_STATUS wma_set_tsf_gpio_pin(WMA_HANDLE handle, uint32_t pin);
+#else
+static inline QDF_STATUS wma_capture_tsf(tp_wma_handle wma_handle,
+					uint32_t vdev_id)
+{
+	return QDF_STATUS_SUCCESS;
+}
+
+static inline QDF_STATUS wma_reset_tsf_gpio(tp_wma_handle wma_handle,
+					 uint32_t vdev_id)
+{
+	return QDF_STATUS_SUCCESS;
+}
+
+static inline int wma_vdev_tsf_handler(void *handle, uint8_t *data,
+					uint32_t data_len)
+{
+	return 0;
+}
+
+static inline QDF_STATUS wma_set_tsf_gpio_pin(WMA_HANDLE handle, uint32_t pin)
+{
+	return QDF_STATUS_E_INVAL;
+}
+#endif
+
+
 
 #ifdef WLAN_FEATURE_NAN
 

+ 1 - 0
core/wma/inc/wma_types.h

@@ -432,6 +432,7 @@
 #endif
 
 #define WMA_SET_SCAN_MAC_OUI_REQ              SIR_HAL_SET_SCAN_MAC_OUI_REQ
+#define WMA_TSF_GPIO_PIN                      SIR_HAL_TSF_GPIO_PIN_REQ
 
 #ifdef DHCP_SERVER_OFFLOAD
 #define WMA_SET_DHCP_SERVER_OFFLOAD_CMD       SIR_HAL_SET_DHCP_SERVER_OFFLOAD

+ 28 - 13
core/wma/src/wma_features.c

@@ -419,24 +419,39 @@ error:
 		wmi_buf_free(buf);
 	return status;
 }
-#else
-QDF_STATUS wma_capture_tsf(tp_wma_handle wma_handle, uint32_t vdev_id)
-{
-	return QDF_STATUS_SUCCESS;
-}
 
-QDF_STATUS wma_reset_tsf_gpio(tp_wma_handle wma_handle, uint32_t vdev_id)
+/**
+ * wma_set_tsf_gpio_pin() - send wmi cmd to configure gpio pin
+ * @handle: wma handler
+ * @pin: GPIO pin id
+ *
+ * Return: QDF_STATUS
+ */
+QDF_STATUS wma_set_tsf_gpio_pin(WMA_HANDLE handle, uint32_t pin)
 {
-	return QDF_STATUS_SUCCESS;
-}
+	tp_wma_handle wma = (tp_wma_handle)handle;
+	struct pdev_params pdev_param = {0};
+	int32_t ret;
 
-int wma_vdev_tsf_handler(void *handle, uint8_t *data, uint32_t data_len)
-{
-	return 0;
-}
-#endif
+	if (!wma || !wma->wmi_handle) {
+		WMA_LOGE("%s: WMA is closed, can not set gpio", __func__);
+		return QDF_STATUS_E_INVAL;
+	}
 
+	WMA_LOGD("%s: set tsf gpio pin: %d", __func__, pin);
 
+	pdev_param.param_id = WMI_PDEV_PARAM_WNTS_CONFIG;
+	pdev_param.param_value = pin;
+	ret = wmi_unified_pdev_param_send(wma->wmi_handle,
+					 &pdev_param,
+					 WMA_WILDCARD_PDEV_ID);
+	if (ret) {
+		WMA_LOGE("%s: Failed to set tsf gpio pin (%d)", __func__, ret);
+		return QDF_STATUS_E_FAILURE;
+	}
+	return QDF_STATUS_SUCCESS;
+}
+#endif
 
 #ifdef FEATURE_WLAN_LPHB
 /**

+ 4 - 0
core/wma/src/wma_main.c

@@ -5123,6 +5123,10 @@ QDF_STATUS wma_mc_process_msg(void *cds_context, cds_msg_t *msg)
 		wma_get_temperature(wma_handle);
 		qdf_mem_free(msg->bodyptr);
 		break;
+	case WMA_TSF_GPIO_PIN:
+		wma_set_tsf_gpio_pin(wma_handle, msg->bodyval);
+		break;
+
 #ifdef DHCP_SERVER_OFFLOAD
 	case WMA_SET_DHCP_SERVER_OFFLOAD_CMD:
 		wma_process_dhcpserver_offload(wma_handle,