ソースを参照

qcacld-3.0: Add PLD wrapper for MHI state info

Add pld_get_mhi_state API to get current MHI state and
pld_is_pci_ep_awake to indicate that PCI EP is out of
low power state.

Also enable pld_prevent_l1 and pld_allow_l1 API for WCN6750
to manage low power state of PCI EP from Host.

Change-Id: Ic574bf7d7886b8e59b98e65806b387eef3a54e94
Naman Padhiar 4 年 前
コミット
5beeb03f45
3 ファイル変更127 行追加0 行削除
  1. 3 0
      core/pld/inc/pld_common.h
  2. 85 0
      core/pld/src/pld_common.c
  3. 39 0
      core/pld/src/pld_ipci.h

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

@@ -35,6 +35,7 @@
 #define PLD_SETUP_FILE               "athsetup.bin"
 #define PLD_EPPING_FILE              "epping.bin"
 #define PLD_EVICTED_FILE             ""
+#define PLD_MHI_STATE_L0	1
 
 #define TOTAL_DUMP_SIZE         0x00200000
 
@@ -719,6 +720,8 @@ int pld_ce_free_irq(struct device *dev, unsigned int ce_id, void *ctx);
 void pld_enable_irq(struct device *dev, unsigned int ce_id);
 void pld_disable_irq(struct device *dev, unsigned int ce_id);
 int pld_get_soc_info(struct device *dev, struct pld_soc_info *info);
+int pld_get_mhi_state(struct device *dev);
+int pld_is_pci_ep_awake(struct device *dev);
 int pld_get_ce_id(struct device *dev, int irq);
 int pld_get_irq(struct device *dev, int ce_id);
 void pld_lock_pm_sem(struct device *dev);

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

@@ -622,6 +622,16 @@ int pld_prevent_l1(struct device *dev)
 	case PLD_BUS_TYPE_PCIE:
 		ret = pld_pcie_prevent_l1(dev);
 		break;
+	case PLD_BUS_TYPE_PCIE_FW_SIM:
+	case PLD_BUS_TYPE_IPCI_FW_SIM:
+	case PLD_BUS_TYPE_SNOC_FW_SIM:
+	case PLD_BUS_TYPE_SNOC:
+	case PLD_BUS_TYPE_SDIO:
+	case PLD_BUS_TYPE_USB:
+		break;
+	case PLD_BUS_TYPE_IPCI:
+		ret = pld_ipci_prevent_l1(dev);
+		break;
 	default:
 		ret = -EINVAL;
 		pr_err("Invalid device type\n");
@@ -645,12 +655,53 @@ void pld_allow_l1(struct device *dev)
 	case PLD_BUS_TYPE_PCIE:
 		pld_pcie_allow_l1(dev);
 		break;
+	case PLD_BUS_TYPE_PCIE_FW_SIM:
+	case PLD_BUS_TYPE_IPCI_FW_SIM:
+	case PLD_BUS_TYPE_SNOC_FW_SIM:
+	case PLD_BUS_TYPE_SNOC:
+	case PLD_BUS_TYPE_SDIO:
+	case PLD_BUS_TYPE_USB:
+		break;
+	case PLD_BUS_TYPE_IPCI:
+		pld_ipci_allow_l1(dev);
+		break;
 	default:
 		pr_err("Invalid device type\n");
 		break;
 	}
 }
 
+/**
+ * pld_get_mhi_state() - Get MHI state Info
+ * @dev: device
+ *
+ * MHI state can be determined by reading this address.
+ *
+ * Return: MHI state
+ */
+int pld_get_mhi_state(struct device *dev)
+{
+	int ret = 0;
+
+	switch (pld_get_bus_type(dev)) {
+	case PLD_BUS_TYPE_PCIE:
+	case PLD_BUS_TYPE_PCIE_FW_SIM:
+	case PLD_BUS_TYPE_IPCI_FW_SIM:
+	case PLD_BUS_TYPE_SNOC_FW_SIM:
+	case PLD_BUS_TYPE_SNOC:
+	case PLD_BUS_TYPE_SDIO:
+	case PLD_BUS_TYPE_USB:
+		break;
+	case PLD_BUS_TYPE_IPCI:
+		ret = pld_ipci_mhi_state(dev);
+		break;
+	default:
+		pr_err("Invalid device type\n");
+		break;
+	}
+	return ret;
+}
+
 int pld_set_pcie_gen_speed(struct device *dev, u8 pcie_gen_speed)
 {
 	int ret = -EINVAL;
@@ -1319,6 +1370,40 @@ int pld_is_device_awake(struct device *dev)
 	return ret;
 }
 
+/**
+ * pld_is_pci_ep_awake() - Check if PCI EP is L0 state
+ * @dev: device
+ *
+ * Return: True for PCI EP awake
+ *         False for PCI EP not awake
+ *         Negative failure code for errors
+ */
+int pld_is_pci_ep_awake(struct device *dev)
+{
+	int ret = true;
+	enum pld_bus_type type = pld_get_bus_type(dev);
+
+	switch (type) {
+	case PLD_BUS_TYPE_PCIE:
+	case PLD_BUS_TYPE_PCIE_FW_SIM:
+	case PLD_BUS_TYPE_IPCI_FW_SIM:
+	case PLD_BUS_TYPE_SNOC_FW_SIM:
+	case PLD_BUS_TYPE_SNOC:
+	case PLD_BUS_TYPE_SDIO:
+	case PLD_BUS_TYPE_USB:
+		break;
+	case PLD_BUS_TYPE_IPCI:
+		ret = pld_ipci_is_pci_ep_awake(dev);
+		break;
+	default:
+		pr_err("Invalid device type %d\n", type);
+		ret = -EINVAL;
+		break;
+	}
+
+	return ret;
+}
+
 /**
  * pld_force_wake_release() - Release vote to assert WAKE register
  * @dev: device

+ 39 - 0
core/pld/src/pld_ipci.h

@@ -186,6 +186,25 @@ static inline int pld_ipci_exit_power_save(struct device *dev)
 {
 	return 0;
 }
+
+static inline int pld_ipci_prevent_l1(struct device *dev)
+{
+	return 0;
+}
+
+static inline void pld_ipci_allow_l1(struct device *dev)
+{
+}
+
+static inline int pld_ipci_mhi_state(struct device *dev)
+{
+	return 0;
+}
+
+static inline int pld_ipci_is_pci_ep_awake(struct device *dev)
+{
+	return 0;
+}
 #else
 int pld_ipci_register_driver(void);
 void pld_ipci_unregister_driver(void);
@@ -339,5 +358,25 @@ static inline int pld_ipci_exit_power_save(struct device *dev)
 {
 	return icnss_exit_power_save(dev);
 }
+
+static inline int pld_ipci_prevent_l1(struct device *dev)
+{
+	return icnss_prevent_l1(dev);
+}
+
+static inline void pld_ipci_allow_l1(struct device *dev)
+{
+	icnss_allow_l1(dev);
+}
+
+static inline int pld_ipci_is_pci_ep_awake(struct device *dev)
+{
+	return icnss_is_pci_ep_awake(dev);
+}
+
+static inline int pld_ipci_mhi_state(struct device *dev)
+{
+	return icnss_get_mhi_state(dev);
+}
 #endif
 #endif