Browse Source

qcacmn: Add hif layer changes for sdio bus (Part 3 - HIF SDIO)

Abstract bus related functionalies to respective bus layer.

CRs-Fixed: 969334
Change-Id: Ie14970d69c0a8bf545d136480e4571352f2d4a26
Poddar, Siddarth 9 years ago
parent
commit
e41943f3a8
8 changed files with 206 additions and 156 deletions
  1. 3 0
      hif/inc/hif.h
  2. 1 1
      hif/src/ath_procfs.c
  3. 1 2
      hif/src/ce/ce_diag.c
  4. 160 6
      hif/src/ce/ce_main.c
  5. 20 0
      hif/src/ce/ce_main.h
  6. 5 144
      hif/src/hif_main.c
  7. 1 1
      hif/src/mp_dev.h
  8. 15 2
      hif/src/pcie/if_pci.c

+ 3 - 0
hif/inc/hif.h

@@ -461,6 +461,9 @@ QDF_STATUS hif_start(struct hif_opaque_softc *scn);
 void hif_stop(struct hif_opaque_softc *scn);
 void hif_flush_surprise_remove(struct hif_opaque_softc *scn);
 void hif_dump(struct hif_opaque_softc *scn, uint8_t CmdId, bool start);
+void hif_trigger_dump(struct hif_opaque_softc *hif_ctx,
+		      uint8_t cmd_id, bool start);
+
 QDF_STATUS hif_send_head(struct hif_opaque_softc *scn, uint8_t PipeID,
 				  uint32_t transferID, uint32_t nbytes,
 				  qdf_nbuf_t wbuf, uint32_t data_attr);

+ 1 - 1
hif/src/ath_procfs.c

@@ -36,7 +36,7 @@
 #include "if_usb.h"
 #endif
 #if defined(HIF_SDIO)
-#include "if_ath_sdio.h"
+#include "if_sdio.h"
 #endif
 #include "hif_debug.h"
 

+ 1 - 2
hif/src/ce/ce_diag.c

@@ -44,10 +44,9 @@
 #include "hif_debug.h"
 
 void
-hif_dump_target_memory(struct hif_opaque_softc *hif_ctx, void *ramdump_base,
+hif_ce_dump_target_memory(struct hif_softc *scn, void *ramdump_base,
 						uint32_t address, uint32_t size)
 {
-	struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx);
 	uint32_t loc = address;
 	uint32_t val = 0;
 	uint32_t j = 0;

+ 160 - 6
hif/src/ce/ce_main.c

@@ -53,6 +53,14 @@
 
 #define CE_POLL_TIMEOUT 10      /* ms */
 
+#define AGC_DUMP         1
+#define CHANINFO_DUMP    2
+#define BB_WATCHDOG_DUMP 3
+#ifdef CONFIG_ATH_PCIE_ACCESS_DEBUG
+#define PCIE_ACCESS_DUMP 4
+#endif
+#include "mp_dev.h"
+
 /* Forward references */
 static int hif_post_recv_buffers_for_pipe(struct HIF_CE_pipe_info *pipe_info);
 
@@ -79,6 +87,53 @@ static int hif_post_recv_buffers_for_pipe(struct HIF_CE_pipe_info *pipe_info);
 static int hif_post_recv_buffers(struct hif_softc *scn);
 static void hif_config_rri_on_ddr(struct hif_softc *scn);
 
+/**
+ * hif_target_access_log_dump() - dump access log
+ *
+ * dump access log
+ *
+ * Return: n/a
+ */
+#ifdef CONFIG_ATH_PCIE_ACCESS_DEBUG
+static void hif_target_access_log_dump(void)
+{
+	hif_target_dump_access_log();
+}
+#endif
+
+
+void hif_trigger_dump(struct hif_opaque_softc *hif_ctx,
+		      uint8_t cmd_id, bool start)
+{
+	struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx);
+
+	switch (cmd_id) {
+	case AGC_DUMP:
+		if (start)
+			priv_start_agc(scn);
+		else
+			priv_dump_agc(scn);
+		break;
+	case CHANINFO_DUMP:
+		if (start)
+			priv_start_cap_chaninfo(scn);
+		else
+			priv_dump_chaninfo(scn);
+		break;
+	case BB_WATCHDOG_DUMP:
+		priv_dump_bbwatchdog(scn);
+		break;
+#ifdef CONFIG_ATH_PCIE_ACCESS_DEBUG
+	case PCIE_ACCESS_DUMP:
+		hif_target_access_log_dump();
+		break;
+#endif
+	default:
+		HIF_ERROR("%s: Invalid htc dump command", __func__);
+		break;
+	}
+}
+
 static void ce_poll_timeout(void *arg)
 {
 	struct CE_state *CE_state = (struct CE_state *)arg;
@@ -1805,10 +1860,9 @@ void hif_flush_surprise_remove(struct hif_opaque_softc *hif_ctx)
 	hif_buffer_cleanup(hif_state);
 }
 
-void hif_stop(struct hif_opaque_softc *hif_ctx)
+void hif_ce_stop(struct hif_softc *scn)
 {
-	struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx);
-	struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(hif_ctx);
+	struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(scn);
 	int pipe_num;
 
 	scn->hif_init_done = false;
@@ -2202,7 +2256,7 @@ int hif_ce_fastpath_cb_register(struct hif_opaque_softc *hif_ctx,
 
 #ifdef IPA_OFFLOAD
 /**
- * hif_ipa_get_ce_resource() - get uc resource on hif
+ * hif_ce_ipa_get_ce_resource() - get uc resource on hif
  * @scn: bus context
  * @ce_sr_base_paddr: copyengine source ring base physical address
  * @ce_sr_ring_size: copyengine source ring size
@@ -2214,12 +2268,11 @@ int hif_ce_fastpath_cb_register(struct hif_opaque_softc *hif_ctx,
  *
  * Return: None
  */
-void hif_ipa_get_ce_resource(struct hif_opaque_softc *hif_ctx,
+void hif_ce_ipa_get_ce_resource(struct hif_softc *scn,
 			     qdf_dma_addr_t *ce_sr_base_paddr,
 			     uint32_t *ce_sr_ring_size,
 			     qdf_dma_addr_t *ce_reg_paddr)
 {
-	struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx);
 	struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(scn);
 	struct HIF_CE_pipe_info *pipe_info =
 		&(hif_state->pipe_info[HIF_PCI_IPA_UC_ASSIGNED_CE]);
@@ -2775,3 +2828,104 @@ void hif_disable_interrupt(struct hif_opaque_softc *osc, uint32_t pipe_num)
 	CE_COPY_COMPLETE_INTR_DISABLE(scn, ctrl_addr);
 	Q_TARGET_ACCESS_END(scn);
 }
+
+/**
+ * hif_fw_event_handler() - hif fw event handler
+ * @hif_state: pointer to hif ce state structure
+ *
+ * Process fw events and raise HTC callback to process fw events.
+ *
+ * Return: none
+ */
+static inline void hif_fw_event_handler(struct HIF_CE_state *hif_state)
+{
+	struct hif_msg_callbacks *msg_callbacks =
+		&hif_state->msg_callbacks_current;
+
+	if (!msg_callbacks->fwEventHandler)
+		return;
+
+	msg_callbacks->fwEventHandler(msg_callbacks->Context,
+			QDF_STATUS_E_FAILURE);
+}
+
+#ifndef QCA_WIFI_3_0
+/**
+ * hif_fw_interrupt_handler() - FW interrupt handler
+ * @irq: irq number
+ * @arg: the user pointer
+ *
+ * Called from the PCI interrupt handler when a
+ * firmware-generated interrupt to the Host.
+ *
+ * Return: status of handled irq
+ */
+irqreturn_t hif_fw_interrupt_handler(int irq, void *arg)
+{
+	struct hif_softc *scn = arg;
+	struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(scn);
+	uint32_t fw_indicator_address, fw_indicator;
+
+	if (Q_TARGET_ACCESS_BEGIN(scn) < 0)
+		return ATH_ISR_NOSCHED;
+
+	fw_indicator_address = hif_state->fw_indicator_address;
+	/* For sudden unplug this will return ~0 */
+	fw_indicator = A_TARGET_READ(scn, fw_indicator_address);
+
+	if ((fw_indicator != ~0) && (fw_indicator & FW_IND_EVENT_PENDING)) {
+		/* ACK: clear Target-side pending event */
+		A_TARGET_WRITE(scn, fw_indicator_address,
+			       fw_indicator & ~FW_IND_EVENT_PENDING);
+		if (Q_TARGET_ACCESS_END(scn) < 0)
+			return ATH_ISR_SCHED;
+
+		if (hif_state->started) {
+			hif_fw_event_handler(hif_state);
+		} else {
+			/*
+			 * Probable Target failure before we're prepared
+			 * to handle it.  Generally unexpected.
+			 */
+			AR_DEBUG_PRINTF(ATH_DEBUG_ERR,
+				("%s: Early firmware event indicated\n",
+				 __func__));
+		}
+	} else {
+		if (Q_TARGET_ACCESS_END(scn) < 0)
+			return ATH_ISR_SCHED;
+	}
+
+	return ATH_ISR_SCHED;
+}
+#else
+irqreturn_t hif_fw_interrupt_handler(int irq, void *arg)
+{
+	return ATH_ISR_SCHED;
+}
+#endif /* #ifdef QCA_WIFI_3_0 */
+
+
+/**
+ * hif_wlan_disable(): call the platform driver to disable wlan
+ * @scn: HIF Context
+ *
+ * This function passes the con_mode to platform driver to disable
+ * wlan.
+ *
+ * Return: void
+ */
+void hif_wlan_disable(struct hif_softc *scn)
+{
+	enum icnss_driver_mode mode;
+	uint32_t con_mode = hif_get_conparam(scn);
+
+	if (QDF_GLOBAL_FTM_MODE == con_mode)
+		mode = ICNSS_FTM;
+	else if (QDF_IS_EPPING_ENABLED(con_mode))
+		mode = ICNSS_EPPING;
+	else
+		mode = ICNSS_MISSION;
+
+	icnss_wlan_disable(mode);
+}

+ 20 - 0
hif/src/ce/ce_main.h

@@ -157,8 +157,28 @@ struct shadow_reg_cfg {
 	uint16_t reg_offset;
 };
 
+void hif_ce_stop(struct hif_softc *scn);
 int hif_dump_ce_registers(struct hif_softc *scn);
+void
+hif_ce_dump_target_memory(struct hif_softc *scn, void *ramdump_base,
+			  uint32_t address, uint32_t size);
+
+#ifdef IPA_OFFLOAD
+void hif_ce_ipa_get_ce_resource(struct hif_softc *scn,
+			     qdf_dma_addr_t *ce_sr_base_paddr,
+			     uint32_t *ce_sr_ring_size,
+			     qdf_dma_addr_t *ce_reg_paddr);
+#else
+static inline
+void hif_ce_ipa_get_ce_resource(struct hif_softc *scn,
+			     qdf_dma_addr_t *ce_sr_base_paddr,
+			     uint32_t *ce_sr_ring_size,
+			     qdf_dma_addr_t *ce_reg_paddr)
+{
+	return;
+}
 
+#endif
 int hif_wlan_enable(struct hif_softc *scn);
 void hif_wlan_disable(struct hif_softc *scn);
 void hif_get_target_ce_config(struct CE_pipe_config **target_ce_config_ret,

+ 5 - 144
hif/src/hif_main.c

@@ -38,8 +38,11 @@
 #include <a_debug.h>
 #include "hif_main.h"
 #include "hif_hw_version.h"
+#if defined(HIF_PCI) || defined(HIF_SNOC) || defined(HIF_AHB)
 #include "ce_api.h"
 #include "ce_tasklet.h"
+#include "platform_icnss.h"
+#endif
 #include "qdf_trace.h"
 #include "qdf_status.h"
 #ifdef CONFIG_CNSS
@@ -47,60 +50,10 @@
 #endif
 #include "hif_debug.h"
 #include "mp_dev.h"
-#include "platform_icnss.h"
-
-#define AGC_DUMP         1
-#define CHANINFO_DUMP    2
-#define BB_WATCHDOG_DUMP 3
-#ifdef CONFIG_ATH_PCIE_ACCESS_DEBUG
-#define PCIE_ACCESS_DUMP 4
-#endif
 
 void hif_dump(struct hif_opaque_softc *hif_ctx, uint8_t cmd_id, bool start)
 {
-	struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx);
-	switch (cmd_id) {
-	case AGC_DUMP:
-		if (start)
-			priv_start_agc(scn);
-		else
-			priv_dump_agc(scn);
-		break;
-
-	case CHANINFO_DUMP:
-		if (start)
-			priv_start_cap_chaninfo(scn);
-		else
-			priv_dump_chaninfo(scn);
-		break;
-
-	case BB_WATCHDOG_DUMP:
-		priv_dump_bbwatchdog(scn);
-		break;
-
-#ifdef CONFIG_ATH_PCIE_ACCESS_DEBUG
-	case PCIE_ACCESS_DUMP:
-		hif_target_dump_access_log();
-		break;
-#endif
-	default:
-		HIF_ERROR("%s: Invalid htc dump command", __func__);
-		break;
-	}
-}
-
-/**
- * hif_shut_down_device() - hif_shut_down_device
- *
- * SThis fucntion shuts down the device
- *
- * @scn: hif_opaque_softc
- *
- * Return: void
- */
-void hif_shut_down_device(struct hif_opaque_softc *scn)
-{
-	hif_stop(scn);
+	hif_trigger_dump(hif_ctx, cmd_id, start);
 }
 
 /**
@@ -117,74 +70,6 @@ A_target_id_t hif_get_target_id(struct hif_softc *scn)
 	return scn->mem;
 }
 
-static inline void hif_fw_event_handler(struct HIF_CE_state *hif_state)
-{
-	struct hif_msg_callbacks *msg_callbacks =
-		&hif_state->msg_callbacks_current;
-
-	if (!msg_callbacks->fwEventHandler)
-		return;
-
-	msg_callbacks->fwEventHandler(msg_callbacks->Context,
-			QDF_STATUS_E_FAILURE);
-}
-
-/**
- * hif_fw_interrupt_handler(): FW interrupt handler
- *
- * This function is the FW interrupt handlder
- *
- * @irq: irq number
- * @arg: the user pointer
- *
- * Return: bool
- */
-#ifndef QCA_WIFI_3_0
-irqreturn_t hif_fw_interrupt_handler(int irq, void *arg)
-{
-	struct hif_softc *scn = arg;
-	struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(scn);
-	uint32_t fw_indicator_address, fw_indicator;
-
-	if (Q_TARGET_ACCESS_BEGIN(scn) < 0)
-		return ATH_ISR_NOSCHED;
-
-	fw_indicator_address = hif_state->fw_indicator_address;
-	/* For sudden unplug this will return ~0 */
-	fw_indicator = A_TARGET_READ(scn, fw_indicator_address);
-
-	if ((fw_indicator != ~0) && (fw_indicator & FW_IND_EVENT_PENDING)) {
-		/* ACK: clear Target-side pending event */
-		A_TARGET_WRITE(scn, fw_indicator_address,
-			       fw_indicator & ~FW_IND_EVENT_PENDING);
-		if (Q_TARGET_ACCESS_END(scn) < 0)
-			return ATH_ISR_SCHED;
-
-		if (hif_state->started) {
-			hif_fw_event_handler(hif_state);
-		} else {
-			/*
-			 * Probable Target failure before we're prepared
-			 * to handle it.  Generally unexpected.
-			 */
-			AR_DEBUG_PRINTF(ATH_DEBUG_ERR,
-				("%s: Early firmware event indicated\n",
-				 __func__));
-		}
-	} else {
-		if (Q_TARGET_ACCESS_END(scn) < 0)
-			return ATH_ISR_SCHED;
-	}
-
-	return ATH_ISR_SCHED;
-}
-#else
-irqreturn_t hif_fw_interrupt_handler(int irq, void *arg)
-{
-	return ATH_ISR_SCHED;
-}
-#endif /* #ifdef QCA_WIFI_3_0 */
-
 /**
  * hif_get_targetdef(): hif_get_targetdef
  * @scn: scn
@@ -579,30 +464,6 @@ QDF_STATUS hif_enable(struct hif_opaque_softc *hif_ctx, struct device *dev,
 	return QDF_STATUS_SUCCESS;
 }
 
-/**
- * hif_wlan_disable(): call the platform driver to disable wlan
- * @scn: HIF Context
- *
- * This function passes the con_mode to platform driver to disable
- * wlan.
- *
- * Return: void
- */
-void hif_wlan_disable(struct hif_softc *scn)
-{
-	enum icnss_driver_mode mode;
-	uint32_t con_mode = hif_get_conparam(scn);
-
-	if (QDF_GLOBAL_FTM_MODE == con_mode)
-		mode = ICNSS_FTM;
-	else if (QDF_IS_EPPING_ENABLED(con_mode))
-		mode = ICNSS_EPPING;
-	else
-		mode = ICNSS_MISSION;
-
-	icnss_wlan_disable(mode);
-}
-
 void hif_disable(struct hif_opaque_softc *hif_ctx, enum hif_disable_type type)
 {
 	struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx);
@@ -612,7 +473,7 @@ void hif_disable(struct hif_opaque_softc *hif_ctx, enum hif_disable_type type)
 
 	hif_nointrs(scn);
 	if (scn->hif_init_done == false)
-		hif_shut_down_device(hif_ctx);
+		hif_shutdown_device(hif_ctx);
 	else
 		hif_stop(hif_ctx);
 

+ 1 - 1
hif/src/mp_dev.h

@@ -32,5 +32,5 @@ void priv_dump_agc(struct hif_softc *scn);
 void priv_start_cap_chaninfo(struct hif_softc *scn);
 void priv_dump_chaninfo(struct hif_softc *scn);
 void priv_dump_bbwatchdog(struct hif_softc *scn);
-void hif_shut_down_device(struct hif_opaque_softc *scn);
+void hif_shutdown_device(struct hif_opaque_softc *scn);
 #endif /* __MP_DEV_H__ */

+ 15 - 2
hif/src/pcie/if_pci.c

@@ -2541,7 +2541,7 @@ static int hif_bus_suspend_link_up(struct hif_softc *scn)
 		return -EINVAL;
 	}
 
-	hif_pci_cancel_deferred_target_sleep(scn);
+	hif_cancel_deferred_target_sleep(scn);
 
 	return 0;
 }
@@ -2603,7 +2603,7 @@ static int hif_bus_suspend_link_down(struct hif_softc *scn)
 	}
 
 	/* Stop the HIF Sleep Timer */
-	hif_pci_cancel_deferred_target_sleep(scn);
+	hif_cancel_deferred_target_sleep(scn);
 
 	qdf_atomic_set(&scn->link_suspended, 1);
 
@@ -3996,3 +3996,16 @@ void hif_runtime_lock_deinit(struct hif_opaque_softc *hif_ctx,
 }
 
 #endif /* FEATURE_RUNTIME_PM */
+
+/**
+ * hif_pci_bus_pkt_dl_len_set() set the HTT packet download length
+ * @sc: context
+ * @pkt_download_len: download length
+ *
+ * Return: void
+ */
+void hif_pci_bus_pkt_dl_len_set(struct hif_softc *sc,
+				u_int32_t pkt_download_len)
+{
+	ce_pkt_dl_len_set(sc, pkt_download_len);
+}