浏览代码

qcacmn: remove PLD_PCIE_INIT compile flag and use runtime checks

This change will help to have pld and non-based based chipset
to work on the same WIN AP platform.

Change-Id: I778cf0d548f5a8575cd6a4fcc76afd0043e5942b
Balamurugan Mahalingam 6 年之前
父节点
当前提交
1b4476e7b6
共有 2 个文件被更改,包括 52 次插入27 次删除
  1. 47 27
      hif/src/pcie/if_pci.c
  2. 5 0
      hif/src/pcie/if_pci.h

+ 47 - 27
hif/src/pcie/if_pci.c

@@ -2078,10 +2078,9 @@ void hif_pci_close(struct hif_softc *hif_sc)
 
 #define BAR_NUM 0
 
-#ifndef CONFIG_PLD_PCIE_INIT
-static int hif_enable_pci(struct hif_pci_softc *sc,
-			  struct pci_dev *pdev,
-			  const struct pci_device_id *id)
+static int hif_enable_pci_nopld(struct hif_pci_softc *sc,
+				struct pci_dev *pdev,
+				const struct pci_device_id *id)
 {
 	void __iomem *mem;
 	int ret = 0;
@@ -2193,29 +2192,27 @@ err_region:
 	pci_disable_device(pdev);
 	return ret;
 }
-#else
-static int hif_enable_pci(struct hif_pci_softc *sc,
-			  struct pci_dev *pdev,
-			  const struct pci_device_id *id)
+
+static int hif_enable_pci_pld(struct hif_pci_softc *sc,
+			      struct pci_dev *pdev,
+			      const struct pci_device_id *id)
 {
 	PCI_CFG_TO_DISABLE_L1SS_STATES(pdev, 0x188);
 	sc->pci_enabled = true;
 	return 0;
 }
-#endif
 
 
-#ifndef CONFIG_PLD_PCIE_INIT
-static inline void hif_pci_deinit(struct hif_pci_softc *sc)
+static void hif_pci_deinit_nopld(struct hif_pci_softc *sc)
 {
+	pci_disable_msi(sc->pdev);
 	pci_iounmap(sc->pdev, sc->mem);
 	pci_clear_master(sc->pdev);
 	pci_release_region(sc->pdev, BAR_NUM);
 	pci_disable_device(sc->pdev);
 }
-#else
-static inline void hif_pci_deinit(struct hif_pci_softc *sc) {}
-#endif
+
+static void hif_pci_deinit_pld(struct hif_pci_softc *sc) {}
 
 static void hif_disable_pci(struct hif_pci_softc *sc)
 {
@@ -2226,8 +2223,7 @@ static void hif_disable_pci(struct hif_pci_softc *sc)
 		return;
 	}
 	hif_pci_device_reset(sc);
-
-	hif_pci_deinit(sc);
+	sc->hif_pci_deinit(sc);
 
 	sc->mem = NULL;
 	ol_sc->mem = NULL;
@@ -2648,15 +2644,12 @@ void hif_pci_disable_bus(struct hif_softc *scn)
 #endif
 	mem = (void __iomem *)sc->mem;
 	if (mem) {
-#ifndef CONFIG_PLD_PCIE_INIT
-		pci_disable_msi(pdev);
-#endif
 		hif_dump_pipe_debug_count(scn);
 		if (scn->athdiag_procfs_inited) {
 			athdiag_procfs_remove();
 			scn->athdiag_procfs_inited = false;
 		}
-		hif_pci_deinit(sc);
+		sc->hif_pci_deinit(sc);
 		scn->mem = NULL;
 	}
 	HIF_INFO("%s: X", __func__);
@@ -3780,8 +3773,8 @@ static void hif_target_sync(struct hif_softc *scn)
 			PCIE_SOC_WAKE_ADDRESS, PCIE_SOC_WAKE_RESET);
 }
 
-#ifdef CONFIG_PLD_PCIE_INIT
-static void hif_pci_get_soc_info(struct hif_pci_softc *sc, struct device *dev)
+static void hif_pci_get_soc_info_pld(struct hif_pci_softc *sc,
+				     struct device *dev)
 {
 	struct pld_soc_info info;
 
@@ -3790,10 +3783,36 @@ static void hif_pci_get_soc_info(struct hif_pci_softc *sc, struct device *dev)
 	sc->ce_sc.ol_sc.mem    = info.v_addr;
 	sc->ce_sc.ol_sc.mem_pa = info.p_addr;
 }
-#else
-static void hif_pci_get_soc_info(struct hif_pci_softc *sc, struct device *dev)
+
+static void hif_pci_get_soc_info_nopld(struct hif_pci_softc *sc,
+				       struct device *dev)
 {}
-#endif
+
+static bool hif_is_pld_based_target(int device_id)
+{
+	switch (device_id) {
+	case QCA6290_DEVICE_ID:
+	case QCA6290_EMULATION_DEVICE_ID:
+	case QCA6390_DEVICE_ID:
+	case AR6320_DEVICE_ID:
+		return true;
+	}
+	return false;
+}
+
+static void hif_pci_init_deinit_ops_attach(struct hif_pci_softc *sc,
+					   int device_id)
+{
+	if (hif_is_pld_based_target(device_id)) {
+		sc->hif_enable_pci = hif_enable_pci_pld;
+		sc->hif_pci_deinit = hif_pci_deinit_pld;
+		sc->hif_pci_get_soc_info = hif_pci_get_soc_info_pld;
+	} else {
+		sc->hif_enable_pci = hif_enable_pci_nopld;
+		sc->hif_pci_deinit = hif_pci_deinit_nopld;
+		sc->hif_pci_get_soc_info = hif_pci_get_soc_info_nopld;
+	}
+}
 
 #ifdef HIF_REG_WINDOW_SUPPORT
 static void hif_pci_init_reg_windowing_support(struct hif_pci_softc *sc,
@@ -3857,9 +3876,10 @@ QDF_STATUS hif_pci_enable_bus(struct hif_softc *ol_sc,
 	sc->devid = id->device;
 	sc->cacheline_sz = dma_get_cache_alignment();
 	tgt_info = hif_get_target_info_handle(hif_hdl);
-	hif_pci_get_soc_info(sc, dev);
+	hif_pci_init_deinit_ops_attach(sc, id->device);
+	sc->hif_pci_get_soc_info(sc, dev);
 again:
-	ret = hif_enable_pci(sc, pdev, id);
+	ret = sc->hif_enable_pci(sc, pdev, id);
 	if (ret < 0) {
 		HIF_ERROR("%s: ERROR - hif_enable_pci error = %d",
 		       __func__, ret);

+ 5 - 0
hif/src/pcie/if_pci.h

@@ -136,6 +136,11 @@ struct hif_pci_softc {
 	struct dentry *pm_dentry;
 #endif
 #endif
+	int (*hif_enable_pci)(struct hif_pci_softc *sc, struct pci_dev *pdev,
+			      const struct pci_device_id *id);
+	void (*hif_pci_deinit)(struct hif_pci_softc *sc);
+	void (*hif_pci_get_soc_info)(struct hif_pci_softc *sc,
+				     struct device *dev);
 };
 
 bool hif_pci_targ_is_present(struct hif_softc *scn, void *__iomem *mem);