Lines Matching refs:pci_priv
931 static int cnss_pci_update_fw_name(struct cnss_pci_data *pci_priv);
934 static void cnss_pci_update_link_event(struct cnss_pci_data *pci_priv,
939 static void cnss_mhi_debug_reg_dump(struct cnss_pci_data *pci_priv) in cnss_mhi_debug_reg_dump() argument
941 mhi_debug_reg_dump(pci_priv->mhi_ctrl); in cnss_mhi_debug_reg_dump()
944 static void cnss_mhi_dump_sfr(struct cnss_pci_data *pci_priv) in cnss_mhi_dump_sfr() argument
946 mhi_dump_sfr(pci_priv->mhi_ctrl); in cnss_mhi_dump_sfr()
949 static bool cnss_mhi_scan_rddm_cookie(struct cnss_pci_data *pci_priv, in cnss_mhi_scan_rddm_cookie() argument
952 return mhi_scan_rddm_cookie(pci_priv->mhi_ctrl, cookie); in cnss_mhi_scan_rddm_cookie()
955 static int cnss_mhi_pm_fast_suspend(struct cnss_pci_data *pci_priv, in cnss_mhi_pm_fast_suspend() argument
958 return mhi_pm_fast_suspend(pci_priv->mhi_ctrl, notify_clients); in cnss_mhi_pm_fast_suspend()
961 static int cnss_mhi_pm_fast_resume(struct cnss_pci_data *pci_priv, in cnss_mhi_pm_fast_resume() argument
964 return mhi_pm_fast_resume(pci_priv->mhi_ctrl, notify_clients); in cnss_mhi_pm_fast_resume()
967 static void cnss_mhi_set_m2_timeout_ms(struct cnss_pci_data *pci_priv, in cnss_mhi_set_m2_timeout_ms() argument
970 return mhi_set_m2_timeout_ms(pci_priv->mhi_ctrl, timeout); in cnss_mhi_set_m2_timeout_ms()
973 static int cnss_mhi_device_get_sync_atomic(struct cnss_pci_data *pci_priv, in cnss_mhi_device_get_sync_atomic() argument
976 return mhi_device_get_sync_atomic(pci_priv->mhi_ctrl->mhi_dev, in cnss_mhi_device_get_sync_atomic()
981 static int cnss_mhi_host_notify_db_disable_trace(struct cnss_pci_data *pci_priv) in cnss_mhi_host_notify_db_disable_trace() argument
983 return mhi_host_notify_db_disable_trace(pci_priv->mhi_ctrl); in cnss_mhi_host_notify_db_disable_trace()
988 cnss_mhi_controller_set_bw_scale_cb(struct cnss_pci_data *pci_priv, in cnss_mhi_controller_set_bw_scale_cb() argument
992 mhi_controller_set_bw_scale_cb(pci_priv->mhi_ctrl, cb); in cnss_mhi_controller_set_bw_scale_cb()
995 static int cnss_mhi_force_reset(struct cnss_pci_data *pci_priv) in cnss_mhi_force_reset() argument
997 return mhi_force_reset(pci_priv->mhi_ctrl); in cnss_mhi_force_reset()
1000 void cnss_mhi_controller_set_base(struct cnss_pci_data *pci_priv, in cnss_mhi_controller_set_base() argument
1003 return mhi_controller_set_base(pci_priv->mhi_ctrl, base); in cnss_mhi_controller_set_base()
1006 static void cnss_mhi_debug_reg_dump(struct cnss_pci_data *pci_priv) in cnss_mhi_debug_reg_dump() argument
1010 static void cnss_mhi_dump_sfr(struct cnss_pci_data *pci_priv) in cnss_mhi_dump_sfr() argument
1014 static bool cnss_mhi_scan_rddm_cookie(struct cnss_pci_data *pci_priv, in cnss_mhi_scan_rddm_cookie() argument
1020 static int cnss_mhi_pm_fast_suspend(struct cnss_pci_data *pci_priv, in cnss_mhi_pm_fast_suspend() argument
1026 static int cnss_mhi_pm_fast_resume(struct cnss_pci_data *pci_priv, in cnss_mhi_pm_fast_resume() argument
1032 static void cnss_mhi_set_m2_timeout_ms(struct cnss_pci_data *pci_priv, in cnss_mhi_set_m2_timeout_ms() argument
1037 static int cnss_mhi_device_get_sync_atomic(struct cnss_pci_data *pci_priv, in cnss_mhi_device_get_sync_atomic() argument
1044 static int cnss_mhi_host_notify_db_disable_trace(struct cnss_pci_data *pci_priv) in cnss_mhi_host_notify_db_disable_trace() argument
1051 cnss_mhi_controller_set_bw_scale_cb(struct cnss_pci_data *pci_priv, in cnss_mhi_controller_set_bw_scale_cb() argument
1057 static int cnss_mhi_force_reset(struct cnss_pci_data *pci_priv) in cnss_mhi_force_reset() argument
1062 void cnss_mhi_controller_set_base(struct cnss_pci_data *pci_priv, in cnss_mhi_controller_set_base() argument
1071 static void cnss_record_smmu_fault_timestamp(struct cnss_pci_data *pci_priv, in cnss_record_smmu_fault_timestamp() argument
1077 pci_priv->smmu_fault_timestamp[id] = sched_clock(); in cnss_record_smmu_fault_timestamp()
1083 struct cnss_pci_data *pci_priv = handler_token; in cnss_pci_smmu_fault_handler_irq() local
1086 cnss_record_smmu_fault_timestamp(pci_priv, SMMU_CB_ENTRY); in cnss_pci_smmu_fault_handler_irq()
1087 ret = cnss_mhi_device_get_sync_atomic(pci_priv, in cnss_pci_smmu_fault_handler_irq()
1094 cnss_record_smmu_fault_timestamp(pci_priv, SMMU_CB_DOORBELL_RING); in cnss_pci_smmu_fault_handler_irq()
1095 ret = cnss_mhi_host_notify_db_disable_trace(pci_priv); in cnss_pci_smmu_fault_handler_irq()
1099 cnss_record_smmu_fault_timestamp(pci_priv, SMMU_CB_EXIT); in cnss_pci_smmu_fault_handler_irq()
1102 void cnss_register_iommu_fault_handler_irq(struct cnss_pci_data *pci_priv) in cnss_register_iommu_fault_handler_irq() argument
1104 qcom_iommu_set_fault_handler_irq(pci_priv->iommu_domain, in cnss_register_iommu_fault_handler_irq()
1105 cnss_pci_smmu_fault_handler_irq, pci_priv); in cnss_register_iommu_fault_handler_irq()
1108 void cnss_register_iommu_fault_handler_irq(struct cnss_pci_data *pci_priv) in cnss_register_iommu_fault_handler_irq() argument
1113 int cnss_pci_check_link_status(struct cnss_pci_data *pci_priv) in cnss_pci_check_link_status() argument
1117 if (pci_priv->pci_link_state == PCI_LINK_DOWN) { in cnss_pci_check_link_status()
1123 if (pci_priv->pci_link_down_ind) { in cnss_pci_check_link_status()
1128 pci_read_config_word(pci_priv->pci_dev, PCI_DEVICE_ID, &device_id); in cnss_pci_check_link_status()
1129 if (device_id != pci_priv->device_id) { in cnss_pci_check_link_status()
1132 pci_priv->device_id); in cnss_pci_check_link_status()
1139 static void cnss_pci_select_window(struct cnss_pci_data *pci_priv, u32 offset) in cnss_pci_select_window() argument
1141 struct cnss_plat_data *plat_priv = pci_priv->plat_priv; in cnss_pci_select_window()
1151 writel_relaxed(window_enable, pci_priv->bar + in cnss_pci_select_window()
1154 writel_relaxed(window_enable, pci_priv->bar + in cnss_pci_select_window()
1158 if (window != pci_priv->remap_window) { in cnss_pci_select_window()
1159 pci_priv->remap_window = window; in cnss_pci_select_window()
1166 val = readl_relaxed(pci_priv->bar + in cnss_pci_select_window()
1169 val = readl_relaxed(pci_priv->bar + in cnss_pci_select_window()
1175 if (!cnss_pci_check_link_status(pci_priv) && in cnss_pci_select_window()
1181 static int cnss_pci_reg_read(struct cnss_pci_data *pci_priv, in cnss_pci_reg_read() argument
1185 struct cnss_plat_data *plat_priv = pci_priv->plat_priv; in cnss_pci_reg_read()
1188 ret = cnss_pci_check_link_status(pci_priv); in cnss_pci_reg_read()
1193 if (pci_priv->pci_dev->device == QCA6174_DEVICE_ID || in cnss_pci_reg_read()
1195 *val = readl_relaxed(pci_priv->bar + offset); in cnss_pci_reg_read()
1204 cnss_pci_select_window(pci_priv, offset); in cnss_pci_reg_read()
1205 *val = readl_relaxed(pci_priv->bar + WINDOW_START + in cnss_pci_reg_read()
1209 cnss_pci_select_window(pci_priv, offset); in cnss_pci_reg_read()
1210 *val = readl_relaxed(pci_priv->bar + WINDOW_START + in cnss_pci_reg_read()
1218 static int cnss_pci_reg_write(struct cnss_pci_data *pci_priv, u32 offset, in cnss_pci_reg_write() argument
1222 struct cnss_plat_data *plat_priv = pci_priv->plat_priv; in cnss_pci_reg_write()
1225 ret = cnss_pci_check_link_status(pci_priv); in cnss_pci_reg_write()
1230 if (pci_priv->pci_dev->device == QCA6174_DEVICE_ID || in cnss_pci_reg_write()
1232 writel_relaxed(val, pci_priv->bar + offset); in cnss_pci_reg_write()
1238 cnss_pci_select_window(pci_priv, offset); in cnss_pci_reg_write()
1239 writel_relaxed(val, pci_priv->bar + WINDOW_START + in cnss_pci_reg_write()
1243 cnss_pci_select_window(pci_priv, offset); in cnss_pci_reg_write()
1244 writel_relaxed(val, pci_priv->bar + WINDOW_START + in cnss_pci_reg_write()
1252 static int cnss_pci_force_wake_get(struct cnss_pci_data *pci_priv) in cnss_pci_force_wake_get() argument
1254 struct device *dev = &pci_priv->pci_dev->dev; in cnss_pci_force_wake_get()
1275 static int cnss_pci_force_wake_put(struct cnss_pci_data *pci_priv) in cnss_pci_force_wake_put() argument
1277 struct device *dev = &pci_priv->pci_dev->dev; in cnss_pci_force_wake_put()
1357 int cnss_pci_debug_reg_read(struct cnss_pci_data *pci_priv, u32 offset, in cnss_pci_debug_reg_read() argument
1364 ret = cnss_pci_reg_read(pci_priv, offset, val); in cnss_pci_debug_reg_read()
1368 ret = cnss_pci_is_device_down(&pci_priv->pci_dev->dev); in cnss_pci_debug_reg_read()
1372 ret = cnss_pci_pm_runtime_get_sync(pci_priv, RTPM_ID_CNSS); in cnss_pci_debug_reg_read()
1376 ret = cnss_pci_force_wake_get(pci_priv); in cnss_pci_debug_reg_read()
1380 ret = cnss_pci_reg_read(pci_priv, offset, val); in cnss_pci_debug_reg_read()
1389 cnss_pci_force_wake_put(pci_priv); in cnss_pci_debug_reg_read()
1391 cnss_pci_pm_runtime_mark_last_busy(pci_priv); in cnss_pci_debug_reg_read()
1392 cnss_pci_pm_runtime_put_autosuspend(pci_priv, RTPM_ID_CNSS); in cnss_pci_debug_reg_read()
1397 int cnss_pci_debug_reg_write(struct cnss_pci_data *pci_priv, u32 offset, in cnss_pci_debug_reg_write() argument
1404 ret = cnss_pci_reg_write(pci_priv, offset, val); in cnss_pci_debug_reg_write()
1408 ret = cnss_pci_is_device_down(&pci_priv->pci_dev->dev); in cnss_pci_debug_reg_write()
1412 ret = cnss_pci_pm_runtime_get_sync(pci_priv, RTPM_ID_CNSS); in cnss_pci_debug_reg_write()
1416 ret = cnss_pci_force_wake_get(pci_priv); in cnss_pci_debug_reg_write()
1420 ret = cnss_pci_reg_write(pci_priv, offset, val); in cnss_pci_debug_reg_write()
1429 cnss_pci_force_wake_put(pci_priv); in cnss_pci_debug_reg_write()
1431 cnss_pci_pm_runtime_mark_last_busy(pci_priv); in cnss_pci_debug_reg_write()
1432 cnss_pci_pm_runtime_put_autosuspend(pci_priv, RTPM_ID_CNSS); in cnss_pci_debug_reg_write()
1437 static int cnss_set_pci_config_space(struct cnss_pci_data *pci_priv, bool save) in cnss_set_pci_config_space() argument
1439 struct pci_dev *pci_dev = pci_priv->pci_dev; in cnss_set_pci_config_space()
1440 struct cnss_plat_data *plat_priv = pci_priv->plat_priv; in cnss_set_pci_config_space()
1446 link_down_or_recovery = pci_priv->pci_link_down_ind || in cnss_set_pci_config_space()
1451 pci_priv->saved_state = NULL; in cnss_set_pci_config_space()
1454 pci_priv->saved_state = pci_store_saved_state(pci_dev); in cnss_set_pci_config_space()
1458 pci_load_saved_state(pci_dev, pci_priv->default_state); in cnss_set_pci_config_space()
1460 } else if (pci_priv->saved_state) { in cnss_set_pci_config_space()
1462 &pci_priv->saved_state); in cnss_set_pci_config_space()
1470 static int cnss_update_supported_link_info(struct cnss_pci_data *pci_priv) in cnss_update_supported_link_info() argument
1477 if (!pci_priv) in cnss_update_supported_link_info()
1480 if (pci_priv->device_id != KIWI_DEVICE_ID) in cnss_update_supported_link_info()
1483 plat_priv = pci_priv->plat_priv; in cnss_update_supported_link_info()
1484 root_port = pcie_find_root_port(pci_priv->pci_dev); in cnss_update_supported_link_info()
1506 static int cnss_pci_get_link_status(struct cnss_pci_data *pci_priv) in cnss_pci_get_link_status() argument
1511 ret = pcie_capability_read_word(pci_priv->pci_dev, PCI_EXP_LNKSTA, in cnss_pci_get_link_status()
1518 pci_priv->def_link_speed = link_status & PCI_EXP_LNKSTA_CLS; in cnss_pci_get_link_status()
1519 pci_priv->def_link_width = in cnss_pci_get_link_status()
1521 pci_priv->cur_link_speed = pci_priv->def_link_speed; in cnss_pci_get_link_status()
1524 pci_priv->def_link_speed, pci_priv->def_link_width); in cnss_pci_get_link_status()
1529 static void cnss_pci_soc_scratch_reg_dump(struct cnss_pci_data *pci_priv) in cnss_pci_soc_scratch_reg_dump() argument
1534 switch (pci_priv->device_id) { in cnss_pci_soc_scratch_reg_dump()
1548 if (cnss_pci_check_link_status(pci_priv)) in cnss_pci_soc_scratch_reg_dump()
1555 if (cnss_pci_reg_read(pci_priv, reg_offset, &val)) in cnss_pci_soc_scratch_reg_dump()
1562 static void cnss_pci_soc_reset_cause_reg_dump(struct cnss_pci_data *pci_priv) in cnss_pci_soc_reset_cause_reg_dump() argument
1566 switch (pci_priv->device_id) { in cnss_pci_soc_reset_cause_reg_dump()
1576 if (cnss_pci_check_link_status(pci_priv)) in cnss_pci_soc_reset_cause_reg_dump()
1581 if (cnss_pci_reg_read(pci_priv, WLAON_SOC_RESET_CAUSE_SHADOW_REG, in cnss_pci_soc_reset_cause_reg_dump()
1589 static void cnss_pci_bhi_debug_reg_dump(struct cnss_pci_data *pci_priv) in cnss_pci_bhi_debug_reg_dump() argument
1594 switch (pci_priv->device_id) { in cnss_pci_bhi_debug_reg_dump()
1601 if (cnss_pci_check_link_status(pci_priv)) in cnss_pci_bhi_debug_reg_dump()
1608 if (cnss_pci_reg_read(pci_priv, reg_offset, &val)) in cnss_pci_bhi_debug_reg_dump()
1615 int cnss_suspend_pci_link(struct cnss_pci_data *pci_priv) in cnss_suspend_pci_link() argument
1619 if (!pci_priv) in cnss_suspend_pci_link()
1622 if (pci_priv->pci_link_state == PCI_LINK_DOWN) { in cnss_suspend_pci_link()
1627 pci_clear_master(pci_priv->pci_dev); in cnss_suspend_pci_link()
1629 ret = cnss_set_pci_config_space(pci_priv, SAVE_PCI_CONFIG_SPACE); in cnss_suspend_pci_link()
1633 pci_disable_device(pci_priv->pci_dev); in cnss_suspend_pci_link()
1635 if (pci_priv->pci_dev->device != QCA6174_DEVICE_ID) { in cnss_suspend_pci_link()
1636 ret = pci_set_power_state(pci_priv->pci_dev, PCI_D3hot); in cnss_suspend_pci_link()
1642 pci_priv->drv_connected_last = 0; in cnss_suspend_pci_link()
1644 ret = cnss_set_pci_link(pci_priv, PCI_LINK_DOWN); in cnss_suspend_pci_link()
1648 pci_priv->pci_link_state = PCI_LINK_DOWN; in cnss_suspend_pci_link()
1655 int cnss_resume_pci_link(struct cnss_pci_data *pci_priv) in cnss_resume_pci_link() argument
1659 if (!pci_priv) in cnss_resume_pci_link()
1662 if (pci_priv->pci_link_state == PCI_LINK_UP) { in cnss_resume_pci_link()
1667 ret = cnss_set_pci_link(pci_priv, PCI_LINK_UP); in cnss_resume_pci_link()
1670 cnss_pci_update_link_event(pci_priv, in cnss_resume_pci_link()
1675 pci_priv->pci_link_state = PCI_LINK_UP; in cnss_resume_pci_link()
1677 if (pci_priv->pci_dev->device != QCA6174_DEVICE_ID) { in cnss_resume_pci_link()
1678 ret = pci_set_power_state(pci_priv->pci_dev, PCI_D0); in cnss_resume_pci_link()
1685 ret = cnss_set_pci_config_space(pci_priv, RESTORE_PCI_CONFIG_SPACE); in cnss_resume_pci_link()
1689 ret = pci_enable_device(pci_priv->pci_dev); in cnss_resume_pci_link()
1695 pci_set_master(pci_priv->pci_dev); in cnss_resume_pci_link()
1697 if (pci_priv->pci_link_down_ind) in cnss_resume_pci_link()
1698 pci_priv->pci_link_down_ind = false; in cnss_resume_pci_link()
1705 static void cnss_pci_update_link_event(struct cnss_pci_data *pci_priv, in cnss_pci_update_link_event() argument
1713 cnss_pci_call_driver_uevent(pci_priv, CNSS_BUS_EVENT, &bus_event); in cnss_pci_update_link_event()
1716 void cnss_pci_handle_linkdown(struct cnss_pci_data *pci_priv) in cnss_pci_handle_linkdown() argument
1718 struct cnss_plat_data *plat_priv = pci_priv->plat_priv; in cnss_pci_handle_linkdown()
1719 struct pci_dev *pci_dev = pci_priv->pci_dev; in cnss_pci_handle_linkdown()
1727 if (pci_priv->pci_link_down_ind) { in cnss_pci_handle_linkdown()
1732 pci_priv->pci_link_down_ind = true; in cnss_pci_handle_linkdown()
1735 if (pci_priv->mhi_ctrl) { in cnss_pci_handle_linkdown()
1737 mhi_report_error(pci_priv->mhi_ctrl); in cnss_pci_handle_linkdown()
1747 cnss_pci_update_link_event(pci_priv, BUS_EVENT_PCI_LINK_DOWN, NULL); in cnss_pci_handle_linkdown()
1750 reinit_completion(&pci_priv->wake_event_complete); in cnss_pci_handle_linkdown()
1757 struct cnss_pci_data *pci_priv = cnss_get_pci_priv(pci_dev); in cnss_pci_link_down() local
1761 if (!pci_priv) { in cnss_pci_link_down()
1766 plat_priv = pci_priv->plat_priv; in cnss_pci_link_down()
1772 if (pci_priv->pci_link_down_ind) { in cnss_pci_link_down()
1777 if (pci_priv->drv_connected_last && in cnss_pci_link_down()
1784 ret = cnss_pci_assert_perst(pci_priv); in cnss_pci_link_down()
1786 cnss_pci_handle_linkdown(pci_priv); in cnss_pci_link_down()
1795 struct cnss_pci_data *pci_priv = cnss_get_pci_priv(pci_dev); in cnss_pci_get_reg_dump() local
1797 if (!pci_priv) { in cnss_pci_get_reg_dump()
1802 if (pci_priv->pci_link_state == PCI_LINK_DOWN) { in cnss_pci_get_reg_dump()
1809 return _cnss_pci_get_reg_dump(pci_priv, buffer, len); in cnss_pci_get_reg_dump()
1813 int cnss_pcie_is_device_down(struct cnss_pci_data *pci_priv) in cnss_pcie_is_device_down() argument
1817 if (!pci_priv) { in cnss_pcie_is_device_down()
1822 plat_priv = pci_priv->plat_priv; in cnss_pcie_is_device_down()
1829 pci_priv->pci_link_down_ind; in cnss_pcie_is_device_down()
1834 struct cnss_pci_data *pci_priv = cnss_get_pci_priv(to_pci_dev(dev)); in cnss_pci_is_device_down() local
1836 return cnss_pcie_is_device_down(pci_priv); in cnss_pci_is_device_down()
1840 int cnss_pci_shutdown_cleanup(struct cnss_pci_data *pci_priv) in cnss_pci_shutdown_cleanup() argument
1844 if (!pci_priv) { in cnss_pci_shutdown_cleanup()
1849 ret = del_timer(&pci_priv->dev_rddm_timer); in cnss_pci_shutdown_cleanup()
1869 struct cnss_pci_data *pci_priv = cnss_get_pci_priv(pci_dev); in cnss_get_pci_slot() local
1872 if (!pci_priv) { in cnss_get_pci_slot()
1877 plat_priv = pci_priv->plat_priv; in cnss_get_pci_slot()
1896 static void cnss_pci_dump_bl_sram_mem(struct cnss_pci_data *pci_priv) in cnss_pci_dump_bl_sram_mem() argument
1908 cnss_pci_soc_reset_cause_reg_dump(pci_priv); in cnss_pci_dump_bl_sram_mem()
1910 switch (pci_priv->device_id) { in cnss_pci_dump_bl_sram_mem()
1943 if (cnss_pci_check_link_status(pci_priv)) in cnss_pci_dump_bl_sram_mem()
1946 cnss_pci_reg_read(pci_priv, TCSR_PBL_LOGGING_REG, &pbl_stage); in cnss_pci_dump_bl_sram_mem()
1947 cnss_pci_reg_read(pci_priv, PCIE_BHI_ERRDBG2_REG, &sbl_log_start); in cnss_pci_dump_bl_sram_mem()
1948 cnss_pci_reg_read(pci_priv, PCIE_BHI_ERRDBG3_REG, &sbl_log_size); in cnss_pci_dump_bl_sram_mem()
1949 cnss_pci_reg_read(pci_priv, PBL_WLAN_BOOT_CFG, &pbl_wlan_boot_cfg); in cnss_pci_dump_bl_sram_mem()
1950 cnss_pci_reg_read(pci_priv, pbl_bootstrap_status_reg, in cnss_pci_dump_bl_sram_mem()
1957 ee = mhi_get_exec_env(pci_priv->mhi_ctrl); in cnss_pci_dump_bl_sram_mem()
1966 if (cnss_pci_reg_read(pci_priv, mem_addr, &val)) in cnss_pci_dump_bl_sram_mem()
1980 ee = mhi_get_exec_env(pci_priv->mhi_ctrl); in cnss_pci_dump_bl_sram_mem()
1989 if (cnss_pci_reg_read(pci_priv, mem_addr, &val)) in cnss_pci_dump_bl_sram_mem()
1996 static void cnss_pci_dump_sram(struct cnss_pci_data *pci_priv) in cnss_pci_dump_sram() argument
2000 static void cnss_pci_dump_sram(struct cnss_pci_data *pci_priv) in cnss_pci_dump_sram() argument
2006 plat_priv = pci_priv->plat_priv; in cnss_pci_dump_sram()
2017 if (cnss_pci_check_link_status(pci_priv)) in cnss_pci_dump_sram()
2025 if (cnss_pci_reg_read(pci_priv, mem_addr, dump_ptr)) { in cnss_pci_dump_sram()
2036 static int cnss_pci_handle_mhi_poweron_timeout(struct cnss_pci_data *pci_priv) in cnss_pci_handle_mhi_poweron_timeout() argument
2038 struct cnss_plat_data *plat_priv = pci_priv->plat_priv; in cnss_pci_handle_mhi_poweron_timeout()
2042 if (cnss_mhi_scan_rddm_cookie(pci_priv, DEVICE_RDDM_COOKIE) || in cnss_pci_handle_mhi_poweron_timeout()
2049 !pci_priv->pci_link_down_ind) { in cnss_pci_handle_mhi_poweron_timeout()
2050 mod_timer(&pci_priv->dev_rddm_timer, in cnss_pci_handle_mhi_poweron_timeout()
2055 cnss_mhi_debug_reg_dump(pci_priv); in cnss_pci_handle_mhi_poweron_timeout()
2056 cnss_pci_bhi_debug_reg_dump(pci_priv); in cnss_pci_handle_mhi_poweron_timeout()
2057 cnss_pci_soc_scratch_reg_dump(pci_priv); in cnss_pci_handle_mhi_poweron_timeout()
2059 cnss_pci_dump_bl_sram_mem(pci_priv); in cnss_pci_handle_mhi_poweron_timeout()
2060 cnss_pci_dump_sram(pci_priv); in cnss_pci_handle_mhi_poweron_timeout()
2095 static int cnss_pci_check_mhi_state_bit(struct cnss_pci_data *pci_priv, in cnss_pci_check_mhi_state_bit() argument
2100 if (!test_bit(CNSS_MHI_INIT, &pci_priv->mhi_state)) in cnss_pci_check_mhi_state_bit()
2105 if (test_bit(CNSS_MHI_INIT, &pci_priv->mhi_state) && in cnss_pci_check_mhi_state_bit()
2106 !test_bit(CNSS_MHI_POWER_ON, &pci_priv->mhi_state)) in cnss_pci_check_mhi_state_bit()
2110 if (test_bit(CNSS_MHI_POWER_ON, &pci_priv->mhi_state)) in cnss_pci_check_mhi_state_bit()
2115 if (test_bit(CNSS_MHI_POWER_ON, &pci_priv->mhi_state) && in cnss_pci_check_mhi_state_bit()
2116 !test_bit(CNSS_MHI_SUSPEND, &pci_priv->mhi_state)) in cnss_pci_check_mhi_state_bit()
2120 if (test_bit(CNSS_MHI_SUSPEND, &pci_priv->mhi_state)) in cnss_pci_check_mhi_state_bit()
2124 if (test_bit(CNSS_MHI_POWER_ON, &pci_priv->mhi_state) && in cnss_pci_check_mhi_state_bit()
2125 !test_bit(CNSS_MHI_TRIGGER_RDDM, &pci_priv->mhi_state)) in cnss_pci_check_mhi_state_bit()
2137 pci_priv->mhi_state); in cnss_pci_check_mhi_state_bit()
2144 static int cnss_rddm_trigger_debug(struct cnss_pci_data *pci_priv) in cnss_rddm_trigger_debug() argument
2148 if (!pci_priv || pci_priv->device_id != QCA6490_DEVICE_ID) in cnss_rddm_trigger_debug()
2151 if (cnss_pci_check_link_status(pci_priv)) in cnss_rddm_trigger_debug()
2155 cnss_pci_reg_write(pci_priv, GCC_GCC_SPARE_REG_1, 0xACE55); in cnss_rddm_trigger_debug()
2156 ret = cnss_pci_reg_read(pci_priv, GCC_GCC_SPARE_REG_1, &read_val); in cnss_rddm_trigger_debug()
2158 ret = cnss_pci_reg_read(pci_priv, GCC_PRE_ARES_DEBUG_TIMER_VAL, in cnss_rddm_trigger_debug()
2164 static int cnss_rddm_trigger_check(struct cnss_pci_data *pci_priv) in cnss_rddm_trigger_check() argument
2169 if (!pci_priv || pci_priv->device_id != QCA6490_DEVICE_ID) in cnss_rddm_trigger_check()
2172 if (cnss_pci_check_link_status(pci_priv)) in cnss_rddm_trigger_check()
2175 ret = cnss_pci_reg_read(pci_priv, GCC_GCC_SPARE_REG_1, &read_val); in cnss_rddm_trigger_check()
2179 cnss_pci_reg_read(pci_priv, TCSR_PBL_LOGGING_REG, &pbl_stage); in cnss_rddm_trigger_check()
2180 cnss_pci_reg_read(pci_priv, PCIE_BHI_ERRDBG2_REG, &sbl_log_start); in cnss_rddm_trigger_check()
2181 cnss_pci_reg_read(pci_priv, PCIE_BHI_ERRDBG3_REG, &sbl_log_size); in cnss_rddm_trigger_check()
2182 cnss_pci_reg_read(pci_priv, PBL_WLAN_BOOT_CFG, &pbl_wlan_boot_cfg); in cnss_rddm_trigger_check()
2190 static void cnss_pci_set_mhi_state_bit(struct cnss_pci_data *pci_priv, in cnss_pci_set_mhi_state_bit() argument
2195 set_bit(CNSS_MHI_INIT, &pci_priv->mhi_state); in cnss_pci_set_mhi_state_bit()
2198 clear_bit(CNSS_MHI_INIT, &pci_priv->mhi_state); in cnss_pci_set_mhi_state_bit()
2201 set_bit(CNSS_MHI_POWER_ON, &pci_priv->mhi_state); in cnss_pci_set_mhi_state_bit()
2204 set_bit(CNSS_MHI_POWERING_OFF, &pci_priv->mhi_state); in cnss_pci_set_mhi_state_bit()
2208 clear_bit(CNSS_MHI_POWER_ON, &pci_priv->mhi_state); in cnss_pci_set_mhi_state_bit()
2209 clear_bit(CNSS_MHI_POWERING_OFF, &pci_priv->mhi_state); in cnss_pci_set_mhi_state_bit()
2210 clear_bit(CNSS_MHI_TRIGGER_RDDM, &pci_priv->mhi_state); in cnss_pci_set_mhi_state_bit()
2211 clear_bit(CNSS_MHI_RDDM_DONE, &pci_priv->mhi_state); in cnss_pci_set_mhi_state_bit()
2214 set_bit(CNSS_MHI_SUSPEND, &pci_priv->mhi_state); in cnss_pci_set_mhi_state_bit()
2217 clear_bit(CNSS_MHI_SUSPEND, &pci_priv->mhi_state); in cnss_pci_set_mhi_state_bit()
2220 set_bit(CNSS_MHI_TRIGGER_RDDM, &pci_priv->mhi_state); in cnss_pci_set_mhi_state_bit()
2223 set_bit(CNSS_MHI_RDDM_DONE, &pci_priv->mhi_state); in cnss_pci_set_mhi_state_bit()
2231 static int cnss_mhi_pm_force_resume(struct cnss_pci_data *pci_priv) in cnss_mhi_pm_force_resume() argument
2233 return mhi_pm_resume_force(pci_priv->mhi_ctrl); in cnss_mhi_pm_force_resume()
2236 static int cnss_mhi_pm_force_resume(struct cnss_pci_data *pci_priv) in cnss_mhi_pm_force_resume() argument
2238 return mhi_pm_resume(pci_priv->mhi_ctrl); in cnss_mhi_pm_force_resume()
2242 static int cnss_pci_set_mhi_state(struct cnss_pci_data *pci_priv, in cnss_pci_set_mhi_state() argument
2247 if (pci_priv->device_id == QCA6174_DEVICE_ID) in cnss_pci_set_mhi_state()
2255 ret = cnss_pci_check_mhi_state_bit(pci_priv, mhi_state); in cnss_pci_set_mhi_state()
2264 ret = mhi_prepare_for_power_up(pci_priv->mhi_ctrl); in cnss_pci_set_mhi_state()
2267 mhi_unprepare_after_power_down(pci_priv->mhi_ctrl); in cnss_pci_set_mhi_state()
2271 ret = mhi_sync_power_up(pci_priv->mhi_ctrl); in cnss_pci_set_mhi_state()
2274 if (!ret && !pci_priv->mhi_ctrl->img_pre_alloc) { in cnss_pci_set_mhi_state()
2276 pci_priv->mhi_ctrl->img_pre_alloc = true; in cnss_pci_set_mhi_state()
2281 mhi_power_down(pci_priv->mhi_ctrl, true); in cnss_pci_set_mhi_state()
2285 mhi_power_down(pci_priv->mhi_ctrl, false); in cnss_pci_set_mhi_state()
2290 mutex_lock(&pci_priv->mhi_ctrl->pm_mutex); in cnss_pci_set_mhi_state()
2291 if (pci_priv->drv_connected_last) in cnss_pci_set_mhi_state()
2292 ret = cnss_mhi_pm_fast_suspend(pci_priv, true); in cnss_pci_set_mhi_state()
2294 ret = mhi_pm_suspend(pci_priv->mhi_ctrl); in cnss_pci_set_mhi_state()
2295 mutex_unlock(&pci_priv->mhi_ctrl->pm_mutex); in cnss_pci_set_mhi_state()
2304 mutex_lock(&pci_priv->mhi_ctrl->pm_mutex); in cnss_pci_set_mhi_state()
2305 if (pci_priv->drv_connected_last) { in cnss_pci_set_mhi_state()
2306 ret = cnss_pci_prevent_l1(&pci_priv->pci_dev->dev); in cnss_pci_set_mhi_state()
2308 mutex_unlock(&pci_priv->mhi_ctrl->pm_mutex); in cnss_pci_set_mhi_state()
2311 ret = cnss_mhi_pm_fast_resume(pci_priv, true); in cnss_pci_set_mhi_state()
2312 cnss_pci_allow_l1(&pci_priv->pci_dev->dev); in cnss_pci_set_mhi_state()
2314 if (pci_priv->device_id == QCA6390_DEVICE_ID) in cnss_pci_set_mhi_state()
2315 ret = cnss_mhi_pm_force_resume(pci_priv); in cnss_pci_set_mhi_state()
2317 ret = mhi_pm_resume(pci_priv->mhi_ctrl); in cnss_pci_set_mhi_state()
2319 mutex_unlock(&pci_priv->mhi_ctrl->pm_mutex); in cnss_pci_set_mhi_state()
2322 cnss_rddm_trigger_debug(pci_priv); in cnss_pci_set_mhi_state()
2323 ret = mhi_force_rddm_mode(pci_priv->mhi_ctrl); in cnss_pci_set_mhi_state()
2326 cnss_rddm_trigger_check(pci_priv); in cnss_pci_set_mhi_state()
2339 cnss_pci_set_mhi_state_bit(pci_priv, mhi_state); in cnss_pci_set_mhi_state()
2349 static int cnss_pci_config_msi_addr(struct cnss_pci_data *pci_priv) in cnss_pci_config_msi_addr() argument
2352 struct pci_dev *pci_dev = pci_priv->pci_dev; in cnss_pci_config_msi_addr()
2361 plat_priv = pci_priv->plat_priv; in cnss_pci_config_msi_addr()
2369 &pci_priv->msix_addr); in cnss_pci_config_msi_addr()
2371 pci_priv->msix_addr); in cnss_pci_config_msi_addr()
2376 static int cnss_pci_config_msi_data(struct cnss_pci_data *pci_priv) in cnss_pci_config_msi_data() argument
2380 struct pci_dev *pci_dev = pci_priv->pci_dev; in cnss_pci_config_msi_data()
2382 msi_config = pci_priv->msi_config; in cnss_pci_config_msi_data()
2385 pci_priv->msi_ep_base_data = msi_config->users[0].base_vector; in cnss_pci_config_msi_data()
2387 pci_priv->msi_ep_base_data); in cnss_pci_config_msi_data()
2397 pci_priv->msi_ep_base_data = msi_desc->msg.data; in cnss_pci_config_msi_data()
2398 cnss_pr_dbg("MSI base data is %d\n", pci_priv->msi_ep_base_data); in cnss_pci_config_msi_data()
2411 struct cnss_pci_data *pci_priv; in cnss_get_plat_priv_by_driver_ops() local
2452 pci_priv = plat_env->bus_priv; in cnss_get_plat_priv_by_driver_ops()
2453 if (!pci_priv) { in cnss_get_plat_priv_by_driver_ops()
2458 if (driver_ops == pci_priv->driver_ops) in cnss_get_plat_priv_by_driver_ops()
2469 pci_priv = plat_env->bus_priv; in cnss_get_plat_priv_by_driver_ops()
2470 if (!pci_priv) { in cnss_get_plat_priv_by_driver_ops()
2475 if (!pci_priv->driver_ops) in cnss_get_plat_priv_by_driver_ops()
2482 static int cnss_pci_store_qrtr_node_id(struct cnss_pci_data *pci_priv) in cnss_pci_store_qrtr_node_id() argument
2488 if (!pci_priv) { in cnss_pci_store_qrtr_node_id()
2493 plat_priv = pci_priv->plat_priv; in cnss_pci_store_qrtr_node_id()
2514 ret = cnss_pci_reg_write(pci_priv, scratch, in cnss_pci_store_qrtr_node_id()
2522 ret = cnss_pci_reg_read(pci_priv, scratch, &val); in cnss_pci_store_qrtr_node_id()
2543 static int cnss_pci_store_qrtr_node_id(struct cnss_pci_data *pci_priv) in cnss_pci_store_qrtr_node_id() argument
2549 int cnss_pci_start_mhi(struct cnss_pci_data *pci_priv) in cnss_pci_start_mhi() argument
2556 if (!pci_priv) { in cnss_pci_start_mhi()
2561 plat_priv = pci_priv->plat_priv; in cnss_pci_start_mhi()
2566 pci_priv->mhi_ctrl->timeout_ms = MHI_TIMEOUT_OVERWRITE_MS; in cnss_pci_start_mhi()
2567 cnss_mhi_set_m2_timeout_ms(pci_priv, MHI_M2_TIMEOUT_MS); in cnss_pci_start_mhi()
2569 ret = cnss_pci_set_mhi_state(pci_priv, CNSS_MHI_INIT); in cnss_pci_start_mhi()
2573 timeout = pci_priv->mhi_ctrl->timeout_ms; in cnss_pci_start_mhi()
2576 pci_priv->mhi_ctrl->timeout_ms *= 6; in cnss_pci_start_mhi()
2578 pci_priv->mhi_ctrl->timeout_ms *= 3; in cnss_pci_start_mhi()
2581 ret = cnss_pci_store_qrtr_node_id(pci_priv); in cnss_pci_start_mhi()
2590 mod_timer(&pci_priv->boot_debug_timer, in cnss_pci_start_mhi()
2592 ret = cnss_pci_set_mhi_state(pci_priv, CNSS_MHI_POWER_ON); in cnss_pci_start_mhi()
2593 del_timer_sync(&pci_priv->boot_debug_timer); in cnss_pci_start_mhi()
2595 cnss_wlan_adsp_pc_enable(pci_priv, false); in cnss_pci_start_mhi()
2597 pci_priv->mhi_ctrl->timeout_ms = timeout; in cnss_pci_start_mhi()
2606 set_bit(CNSS_MHI_POWER_ON, &pci_priv->mhi_state); in cnss_pci_start_mhi()
2607 ret = cnss_pci_handle_mhi_poweron_timeout(pci_priv); in cnss_pci_start_mhi()
2614 if (cnss_pci_is_one_msi(pci_priv)) in cnss_pci_start_mhi()
2615 ret = cnss_pci_config_msi_data(pci_priv); in cnss_pci_start_mhi()
2621 static void cnss_pci_power_off_mhi(struct cnss_pci_data *pci_priv) in cnss_pci_power_off_mhi() argument
2623 struct cnss_plat_data *plat_priv = pci_priv->plat_priv; in cnss_pci_power_off_mhi()
2628 if (!test_bit(CNSS_MHI_POWER_ON, &pci_priv->mhi_state)) { in cnss_pci_power_off_mhi()
2632 cnss_wlan_adsp_pc_enable(pci_priv, true); in cnss_pci_power_off_mhi()
2633 cnss_pci_set_mhi_state_bit(pci_priv, CNSS_MHI_RESUME); in cnss_pci_power_off_mhi()
2634 cnss_pci_set_mhi_state_bit(pci_priv, CNSS_MHI_POWERING_OFF); in cnss_pci_power_off_mhi()
2636 if (!pci_priv->pci_link_down_ind) in cnss_pci_power_off_mhi()
2637 cnss_pci_set_mhi_state(pci_priv, CNSS_MHI_POWER_OFF); in cnss_pci_power_off_mhi()
2639 cnss_pci_set_mhi_state(pci_priv, CNSS_MHI_FORCE_POWER_OFF); in cnss_pci_power_off_mhi()
2642 static void cnss_pci_deinit_mhi(struct cnss_pci_data *pci_priv) in cnss_pci_deinit_mhi() argument
2644 struct cnss_plat_data *plat_priv = pci_priv->plat_priv; in cnss_pci_deinit_mhi()
2649 if (!test_bit(CNSS_MHI_INIT, &pci_priv->mhi_state)) { in cnss_pci_deinit_mhi()
2654 cnss_pci_set_mhi_state(pci_priv, CNSS_MHI_DEINIT); in cnss_pci_deinit_mhi()
2657 static void cnss_pci_set_wlaon_pwr_ctrl(struct cnss_pci_data *pci_priv, in cnss_pci_set_wlaon_pwr_ctrl() argument
2661 struct cnss_plat_data *plat_priv = pci_priv->plat_priv; in cnss_pci_set_wlaon_pwr_ctrl()
2668 if (pci_priv->pci_link_state == PCI_LINK_DOWN || in cnss_pci_set_wlaon_pwr_ctrl()
2669 pci_priv->pci_link_down_ind) in cnss_pci_set_wlaon_pwr_ctrl()
2673 if (cnss_pci_force_wake_get(pci_priv)) in cnss_pci_set_wlaon_pwr_ctrl()
2676 ret = cnss_pci_reg_read(pci_priv, WLAON_QFPROM_PWR_CTRL_REG, &val); in cnss_pci_set_wlaon_pwr_ctrl()
2696 ret = cnss_pci_reg_write(pci_priv, WLAON_QFPROM_PWR_CTRL_REG, val); in cnss_pci_set_wlaon_pwr_ctrl()
2712 cnss_pci_force_wake_put(pci_priv); in cnss_pci_set_wlaon_pwr_ctrl()
2715 static int cnss_pci_get_device_timestamp(struct cnss_pci_data *pci_priv, in cnss_pci_get_device_timestamp() argument
2718 struct cnss_plat_data *plat_priv = pci_priv->plat_priv; in cnss_pci_get_device_timestamp()
2727 switch (pci_priv->device_id) { in cnss_pci_get_device_timestamp()
2731 cnss_pci_reg_read(pci_priv, PCIE_MHI_TIME_LOW, &low); in cnss_pci_get_device_timestamp()
2732 cnss_pci_reg_read(pci_priv, PCIE_MHI_TIME_HIGH, &high); in cnss_pci_get_device_timestamp()
2735 cnss_pci_reg_read(pci_priv, WLAON_GLOBAL_COUNTER_CTRL3, &low); in cnss_pci_get_device_timestamp()
2736 cnss_pci_reg_read(pci_priv, WLAON_GLOBAL_COUNTER_CTRL4, &high); in cnss_pci_get_device_timestamp()
2747 static void cnss_pci_enable_time_sync_counter(struct cnss_pci_data *pci_priv) in cnss_pci_enable_time_sync_counter() argument
2749 switch (pci_priv->device_id) { in cnss_pci_enable_time_sync_counter()
2758 cnss_pci_reg_write(pci_priv, WLAON_GLOBAL_COUNTER_CTRL5, in cnss_pci_enable_time_sync_counter()
2762 static void cnss_pci_clear_time_sync_counter(struct cnss_pci_data *pci_priv) in cnss_pci_clear_time_sync_counter() argument
2764 switch (pci_priv->device_id) { in cnss_pci_clear_time_sync_counter()
2773 cnss_pci_reg_write(pci_priv, WLAON_GLOBAL_COUNTER_CTRL5, in cnss_pci_clear_time_sync_counter()
2778 static void cnss_pci_time_sync_reg_update(struct cnss_pci_data *pci_priv, in cnss_pci_time_sync_reg_update() argument
2784 switch (pci_priv->device_id) { in cnss_pci_time_sync_reg_update()
2790 (pci_priv->plat_priv->num_shadow_regs_v3 * in cnss_pci_time_sync_reg_update()
2800 cnss_pci_reg_write(pci_priv, time_reg_low, low); in cnss_pci_time_sync_reg_update()
2801 cnss_pci_reg_write(pci_priv, time_reg_high, high); in cnss_pci_time_sync_reg_update()
2803 cnss_pci_reg_read(pci_priv, time_reg_low, &low); in cnss_pci_time_sync_reg_update()
2804 cnss_pci_reg_read(pci_priv, time_reg_high, &high); in cnss_pci_time_sync_reg_update()
2810 static int cnss_pci_update_timestamp(struct cnss_pci_data *pci_priv) in cnss_pci_update_timestamp() argument
2812 struct cnss_plat_data *plat_priv = pci_priv->plat_priv; in cnss_pci_update_timestamp()
2813 struct device *dev = &pci_priv->pci_dev->dev; in cnss_pci_update_timestamp()
2823 ret = cnss_pci_force_wake_get(pci_priv); in cnss_pci_update_timestamp()
2828 cnss_pci_clear_time_sync_counter(pci_priv); in cnss_pci_update_timestamp()
2829 cnss_pci_enable_time_sync_counter(pci_priv); in cnss_pci_update_timestamp()
2831 ret = cnss_pci_get_device_timestamp(pci_priv, &device_time_us); in cnss_pci_update_timestamp()
2832 cnss_pci_clear_time_sync_counter(pci_priv); in cnss_pci_update_timestamp()
2851 cnss_pci_time_sync_reg_update(pci_priv, low, high); in cnss_pci_update_timestamp()
2854 cnss_pci_force_wake_put(pci_priv); in cnss_pci_update_timestamp()
2863 struct cnss_pci_data *pci_priv = in cnss_pci_time_sync_work_hdlr() local
2865 struct cnss_plat_data *plat_priv = pci_priv->plat_priv; in cnss_pci_time_sync_work_hdlr()
2879 if (cnss_pci_is_device_down(&pci_priv->pci_dev->dev)) in cnss_pci_time_sync_work_hdlr()
2882 if (cnss_pci_pm_runtime_get_sync(pci_priv, RTPM_ID_CNSS) < 0) in cnss_pci_time_sync_work_hdlr()
2885 mutex_lock(&pci_priv->bus_lock); in cnss_pci_time_sync_work_hdlr()
2886 cnss_pci_update_timestamp(pci_priv); in cnss_pci_time_sync_work_hdlr()
2887 mutex_unlock(&pci_priv->bus_lock); in cnss_pci_time_sync_work_hdlr()
2888 schedule_delayed_work(&pci_priv->time_sync_work, in cnss_pci_time_sync_work_hdlr()
2892 cnss_pci_pm_runtime_mark_last_busy(pci_priv); in cnss_pci_time_sync_work_hdlr()
2893 cnss_pci_pm_runtime_put_autosuspend(pci_priv, RTPM_ID_CNSS); in cnss_pci_time_sync_work_hdlr()
2896 static int cnss_pci_start_time_sync_update(struct cnss_pci_data *pci_priv) in cnss_pci_start_time_sync_update() argument
2898 struct cnss_plat_data *plat_priv = pci_priv->plat_priv; in cnss_pci_start_time_sync_update()
2900 switch (pci_priv->device_id) { in cnss_pci_start_time_sync_update()
2916 cnss_pci_time_sync_work_hdlr(&pci_priv->time_sync_work.work); in cnss_pci_start_time_sync_update()
2921 static void cnss_pci_stop_time_sync_update(struct cnss_pci_data *pci_priv) in cnss_pci_stop_time_sync_update() argument
2923 switch (pci_priv->device_id) { in cnss_pci_stop_time_sync_update()
2934 cancel_delayed_work_sync(&pci_priv->time_sync_work); in cnss_pci_stop_time_sync_update()
2937 int cnss_pci_set_therm_cdev_state(struct cnss_pci_data *pci_priv, in cnss_pci_set_therm_cdev_state() argument
2941 if (!pci_priv) { in cnss_pci_set_therm_cdev_state()
2946 if (!pci_priv->driver_ops || !pci_priv->driver_ops->set_therm_cdev_state) { in cnss_pci_set_therm_cdev_state()
2951 return pci_priv->driver_ops->set_therm_cdev_state(pci_priv->pci_dev, in cnss_pci_set_therm_cdev_state()
2956 int cnss_pci_update_time_sync_period(struct cnss_pci_data *pci_priv, in cnss_pci_update_time_sync_period() argument
2961 if (!pci_priv) in cnss_pci_update_time_sync_period()
2964 plat_priv = pci_priv->plat_priv; in cnss_pci_update_time_sync_period()
2966 cnss_pci_stop_time_sync_update(pci_priv); in cnss_pci_update_time_sync_period()
2968 cnss_pci_start_time_sync_update(pci_priv); in cnss_pci_update_time_sync_period()
2975 int cnss_pci_call_driver_probe(struct cnss_pci_data *pci_priv) in cnss_pci_call_driver_probe() argument
2980 if (!pci_priv) in cnss_pci_call_driver_probe()
2983 plat_priv = pci_priv->plat_priv; in cnss_pci_call_driver_probe()
2995 if (!pci_priv->driver_ops) { in cnss_pci_call_driver_probe()
3003 ret = pci_priv->driver_ops->reinit(pci_priv->pci_dev, in cnss_pci_call_driver_probe()
3004 pci_priv->pci_device_id); in cnss_pci_call_driver_probe()
3012 ret = pci_priv->driver_ops->probe(pci_priv->pci_dev, in cnss_pci_call_driver_probe()
3013 pci_priv->pci_device_id); in cnss_pci_call_driver_probe()
3022 cnss_pci_free_blob_mem(pci_priv); in cnss_pci_call_driver_probe()
3026 ret = pci_priv->driver_ops->idle_restart(pci_priv->pci_dev, in cnss_pci_call_driver_probe()
3027 pci_priv->pci_device_id); in cnss_pci_call_driver_probe()
3046 cnss_pci_start_time_sync_update(pci_priv); in cnss_pci_call_driver_probe()
3054 int cnss_pci_call_driver_remove(struct cnss_pci_data *pci_priv) in cnss_pci_call_driver_remove() argument
3059 if (!pci_priv) in cnss_pci_call_driver_remove()
3062 plat_priv = pci_priv->plat_priv; in cnss_pci_call_driver_remove()
3071 if (!pci_priv->driver_ops) { in cnss_pci_call_driver_remove()
3076 cnss_pci_stop_time_sync_update(pci_priv); in cnss_pci_call_driver_remove()
3081 pci_priv->driver_ops->shutdown(pci_priv->pci_dev); in cnss_pci_call_driver_remove()
3083 pci_priv->driver_ops->remove(pci_priv->pci_dev); in cnss_pci_call_driver_remove()
3087 ret = pci_priv->driver_ops->idle_shutdown(pci_priv->pci_dev); in cnss_pci_call_driver_remove()
3103 int cnss_pci_call_driver_modem_status(struct cnss_pci_data *pci_priv, in cnss_pci_call_driver_modem_status() argument
3108 if (!pci_priv) in cnss_pci_call_driver_modem_status()
3111 driver_ops = pci_priv->driver_ops; in cnss_pci_call_driver_modem_status()
3115 driver_ops->modem_status(pci_priv->pci_dev, modem_current_status); in cnss_pci_call_driver_modem_status()
3120 int cnss_pci_update_status(struct cnss_pci_data *pci_priv, in cnss_pci_update_status() argument
3125 if (!pci_priv) in cnss_pci_update_status()
3128 driver_ops = pci_priv->driver_ops; in cnss_pci_update_status()
3134 driver_ops->update_status(pci_priv->pci_dev, status); in cnss_pci_update_status()
3139 static void cnss_pci_misc_reg_dump(struct cnss_pci_data *pci_priv, in cnss_pci_misc_reg_dump() argument
3144 struct cnss_plat_data *plat_priv = pci_priv->plat_priv; in cnss_pci_misc_reg_dump()
3154 if (cnss_pci_check_link_status(pci_priv)) in cnss_pci_misc_reg_dump()
3157 if (cnss_pci_force_wake_get(pci_priv)) { in cnss_pci_misc_reg_dump()
3167 if (!test_bit(pci_priv->misc_reg_dev_mask, in cnss_pci_misc_reg_dump()
3178 if (cnss_pci_reg_write(pci_priv, in cnss_pci_misc_reg_dump()
3187 if (cnss_pci_reg_read(pci_priv, in cnss_pci_misc_reg_dump()
3196 cnss_pci_force_wake_put(pci_priv); in cnss_pci_misc_reg_dump()
3199 static void cnss_pci_dump_misc_reg(struct cnss_pci_data *pci_priv) in cnss_pci_dump_misc_reg() argument
3204 if (cnss_pci_check_link_status(pci_priv)) in cnss_pci_dump_misc_reg()
3207 cnss_pci_misc_reg_dump(pci_priv, pci_priv->wcss_reg, in cnss_pci_dump_misc_reg()
3209 cnss_pci_misc_reg_dump(pci_priv, pci_priv->pcie_reg, in cnss_pci_dump_misc_reg()
3211 cnss_pci_misc_reg_dump(pci_priv, pci_priv->wlaon_reg, in cnss_pci_dump_misc_reg()
3213 cnss_pci_misc_reg_dump(pci_priv, pci_priv->syspm_reg, in cnss_pci_dump_misc_reg()
3217 static void cnss_pci_dump_shadow_reg(struct cnss_pci_data *pci_priv) in cnss_pci_dump_shadow_reg() argument
3226 if (cnss_pci_check_link_status(pci_priv)) in cnss_pci_dump_shadow_reg()
3229 if (!pci_priv->debug_reg) { in cnss_pci_dump_shadow_reg()
3230 pci_priv->debug_reg = devm_kzalloc(&pci_priv->pci_dev->dev, in cnss_pci_dump_shadow_reg()
3231 sizeof(*pci_priv->debug_reg) in cnss_pci_dump_shadow_reg()
3233 if (!pci_priv->debug_reg) in cnss_pci_dump_shadow_reg()
3237 if (cnss_pci_force_wake_get(pci_priv)) in cnss_pci_dump_shadow_reg()
3244 pci_priv->debug_reg[j].offset = reg_offset; in cnss_pci_dump_shadow_reg()
3245 if (cnss_pci_reg_read(pci_priv, reg_offset, in cnss_pci_dump_shadow_reg()
3246 &pci_priv->debug_reg[j].val)) in cnss_pci_dump_shadow_reg()
3252 pci_priv->debug_reg[j].offset = reg_offset; in cnss_pci_dump_shadow_reg()
3253 if (cnss_pci_reg_read(pci_priv, reg_offset, in cnss_pci_dump_shadow_reg()
3254 &pci_priv->debug_reg[j].val)) in cnss_pci_dump_shadow_reg()
3260 cnss_pci_force_wake_put(pci_priv); in cnss_pci_dump_shadow_reg()
3263 static int cnss_qca6174_powerup(struct cnss_pci_data *pci_priv) in cnss_qca6174_powerup() argument
3266 struct cnss_plat_data *plat_priv = pci_priv->plat_priv; in cnss_qca6174_powerup()
3274 ret = cnss_resume_pci_link(pci_priv); in cnss_qca6174_powerup()
3280 ret = cnss_pci_call_driver_probe(pci_priv); in cnss_qca6174_powerup()
3286 cnss_suspend_pci_link(pci_priv); in cnss_qca6174_powerup()
3293 static int cnss_qca6174_shutdown(struct cnss_pci_data *pci_priv) in cnss_qca6174_shutdown() argument
3296 struct cnss_plat_data *plat_priv = pci_priv->plat_priv; in cnss_qca6174_shutdown()
3298 cnss_pci_pm_runtime_resume(pci_priv); in cnss_qca6174_shutdown()
3300 ret = cnss_pci_call_driver_remove(pci_priv); in cnss_qca6174_shutdown()
3306 cnss_pci_set_monitor_wake_intr(pci_priv, false); in cnss_qca6174_shutdown()
3307 cnss_pci_set_auto_suspended(pci_priv, 0); in cnss_qca6174_shutdown()
3309 ret = cnss_suspend_pci_link(pci_priv); in cnss_qca6174_shutdown()
3322 static void cnss_qca6174_crash_shutdown(struct cnss_pci_data *pci_priv) in cnss_qca6174_crash_shutdown() argument
3324 if (pci_priv->driver_ops && pci_priv->driver_ops->crash_shutdown) in cnss_qca6174_crash_shutdown()
3325 pci_priv->driver_ops->crash_shutdown(pci_priv->pci_dev); in cnss_qca6174_crash_shutdown()
3328 static int cnss_qca6174_ramdump(struct cnss_pci_data *pci_priv) in cnss_qca6174_ramdump() argument
3330 struct cnss_plat_data *plat_priv = pci_priv->plat_priv; in cnss_qca6174_ramdump()
3340 static int cnss_qca6290_powerup(struct cnss_pci_data *pci_priv) in cnss_qca6290_powerup() argument
3343 struct cnss_plat_data *plat_priv = pci_priv->plat_priv; in cnss_qca6290_powerup()
3349 cnss_pci_clear_dump_info(pci_priv); in cnss_qca6290_powerup()
3350 cnss_pci_power_off_mhi(pci_priv); in cnss_qca6290_powerup()
3351 cnss_suspend_pci_link(pci_priv); in cnss_qca6290_powerup()
3352 cnss_pci_deinit_mhi(pci_priv); in cnss_qca6290_powerup()
3357 pci_priv->qmi_send_usage_count = 0; in cnss_qca6290_powerup()
3367 ret = cnss_resume_pci_link(pci_priv); in cnss_qca6290_powerup()
3401 cnss_pci_set_wlaon_pwr_ctrl(pci_priv, false, false, false); in cnss_qca6290_powerup()
3404 ret = cnss_pci_start_mhi(pci_priv); in cnss_qca6290_powerup()
3408 !pci_priv->pci_link_down_ind && timeout) { in cnss_qca6290_powerup()
3410 cnss_schedule_recovery(&pci_priv->pci_dev->dev, in cnss_qca6290_powerup()
3425 ret = cnss_pci_call_driver_probe(pci_priv); in cnss_qca6290_powerup()
3440 cnss_pci_set_wlaon_pwr_ctrl(pci_priv, false, true, true); in cnss_qca6290_powerup()
3441 cnss_pci_power_off_mhi(pci_priv); in cnss_qca6290_powerup()
3442 cnss_suspend_pci_link(pci_priv); in cnss_qca6290_powerup()
3443 cnss_pci_deinit_mhi(pci_priv); in cnss_qca6290_powerup()
3450 static int cnss_qca6290_shutdown(struct cnss_pci_data *pci_priv) in cnss_qca6290_shutdown() argument
3453 struct cnss_plat_data *plat_priv = pci_priv->plat_priv; in cnss_qca6290_shutdown()
3456 cnss_pci_pm_runtime_resume(pci_priv); in cnss_qca6290_shutdown()
3458 ret = cnss_pci_call_driver_remove(pci_priv); in cnss_qca6290_shutdown()
3464 cnss_pci_set_monitor_wake_intr(pci_priv, false); in cnss_qca6290_shutdown()
3465 cnss_pci_set_auto_suspended(pci_priv, 0); in cnss_qca6290_shutdown()
3473 del_timer(&pci_priv->dev_rddm_timer); in cnss_qca6290_shutdown()
3474 cnss_pci_collect_dump_info(pci_priv, false); in cnss_qca6290_shutdown()
3487 cnss_pci_set_wlaon_pwr_ctrl(pci_priv, false, true, do_force_wake); in cnss_qca6290_shutdown()
3495 cnss_pci_power_off_mhi(pci_priv); in cnss_qca6290_shutdown()
3496 ret = cnss_suspend_pci_link(pci_priv); in cnss_qca6290_shutdown()
3499 cnss_pci_deinit_mhi(pci_priv); in cnss_qca6290_shutdown()
3503 pci_priv->remap_window = 0; in cnss_qca6290_shutdown()
3510 pci_priv->pci_link_down_ind = false; in cnss_qca6290_shutdown()
3520 static void cnss_qca6290_crash_shutdown(struct cnss_pci_data *pci_priv) in cnss_qca6290_crash_shutdown() argument
3522 struct cnss_plat_data *plat_priv = pci_priv->plat_priv; in cnss_qca6290_crash_shutdown()
3528 cnss_pci_collect_dump_info(pci_priv, true); in cnss_qca6290_crash_shutdown()
3532 static int cnss_qca6290_ramdump(struct cnss_pci_data *pci_priv) in cnss_qca6290_ramdump() argument
3534 struct cnss_plat_data *plat_priv = pci_priv->plat_priv; in cnss_qca6290_ramdump()
3546 cnss_pci_clear_dump_info(pci_priv); in cnss_qca6290_ramdump()
3547 cnss_pci_power_off_mhi(pci_priv); in cnss_qca6290_ramdump()
3548 cnss_suspend_pci_link(pci_priv); in cnss_qca6290_ramdump()
3549 cnss_pci_deinit_mhi(pci_priv); in cnss_qca6290_ramdump()
3555 int cnss_pci_dev_powerup(struct cnss_pci_data *pci_priv) in cnss_pci_dev_powerup() argument
3559 if (!pci_priv) { in cnss_pci_dev_powerup()
3564 switch (pci_priv->device_id) { in cnss_pci_dev_powerup()
3566 ret = cnss_qca6174_powerup(pci_priv); in cnss_pci_dev_powerup()
3575 ret = cnss_qca6290_powerup(pci_priv); in cnss_pci_dev_powerup()
3579 pci_priv->device_id); in cnss_pci_dev_powerup()
3586 int cnss_pci_dev_shutdown(struct cnss_pci_data *pci_priv) in cnss_pci_dev_shutdown() argument
3590 if (!pci_priv) { in cnss_pci_dev_shutdown()
3595 switch (pci_priv->device_id) { in cnss_pci_dev_shutdown()
3597 ret = cnss_qca6174_shutdown(pci_priv); in cnss_pci_dev_shutdown()
3606 ret = cnss_qca6290_shutdown(pci_priv); in cnss_pci_dev_shutdown()
3610 pci_priv->device_id); in cnss_pci_dev_shutdown()
3617 int cnss_pci_dev_crash_shutdown(struct cnss_pci_data *pci_priv) in cnss_pci_dev_crash_shutdown() argument
3621 if (!pci_priv) { in cnss_pci_dev_crash_shutdown()
3626 switch (pci_priv->device_id) { in cnss_pci_dev_crash_shutdown()
3628 cnss_qca6174_crash_shutdown(pci_priv); in cnss_pci_dev_crash_shutdown()
3637 cnss_qca6290_crash_shutdown(pci_priv); in cnss_pci_dev_crash_shutdown()
3641 pci_priv->device_id); in cnss_pci_dev_crash_shutdown()
3648 int cnss_pci_dev_ramdump(struct cnss_pci_data *pci_priv) in cnss_pci_dev_ramdump() argument
3652 if (!pci_priv) { in cnss_pci_dev_ramdump()
3657 switch (pci_priv->device_id) { in cnss_pci_dev_ramdump()
3659 ret = cnss_qca6174_ramdump(pci_priv); in cnss_pci_dev_ramdump()
3668 ret = cnss_qca6290_ramdump(pci_priv); in cnss_pci_dev_ramdump()
3672 pci_priv->device_id); in cnss_pci_dev_ramdump()
3681 struct cnss_pci_data *pci_priv = cnss_get_pci_priv(to_pci_dev(dev)); in cnss_pci_is_drv_connected() local
3683 if (!pci_priv) in cnss_pci_is_drv_connected()
3686 return pci_priv->drv_connected_last; in cnss_pci_is_drv_connected()
3694 struct cnss_pci_data *pci_priv = plat_priv->bus_priv; in cnss_wlan_reg_driver_work() local
3742 pci_priv->driver_ops); in cnss_wlan_reg_driver_work()
3749 struct cnss_pci_data *pci_priv; in cnss_wlan_register_driver() local
3765 pci_priv = plat_priv->bus_priv; in cnss_wlan_register_driver()
3810 pci_priv->device_id); in cnss_wlan_register_driver()
3827 pci_priv->driver_ops = driver_ops; in cnss_wlan_register_driver()
3901 int cnss_pci_register_driver_hdlr(struct cnss_pci_data *pci_priv, in cnss_pci_register_driver_hdlr() argument
3905 struct cnss_plat_data *plat_priv = pci_priv->plat_priv; in cnss_pci_register_driver_hdlr()
3913 pci_priv->driver_ops = data; in cnss_pci_register_driver_hdlr()
3915 ret = cnss_pci_dev_powerup(pci_priv); in cnss_pci_register_driver_hdlr()
3918 pci_priv->driver_ops = NULL; in cnss_pci_register_driver_hdlr()
3926 int cnss_pci_unregister_driver_hdlr(struct cnss_pci_data *pci_priv) in cnss_pci_unregister_driver_hdlr() argument
3930 if (!pci_priv) in cnss_pci_unregister_driver_hdlr()
3933 plat_priv = pci_priv->plat_priv; in cnss_pci_unregister_driver_hdlr()
3935 cnss_pci_dev_shutdown(pci_priv); in cnss_pci_unregister_driver_hdlr()
3936 pci_priv->driver_ops = NULL; in cnss_pci_unregister_driver_hdlr()
3942 static int cnss_pci_suspend_driver(struct cnss_pci_data *pci_priv) in cnss_pci_suspend_driver() argument
3944 struct pci_dev *pci_dev = pci_priv->pci_dev; in cnss_pci_suspend_driver()
3945 struct cnss_wlan_driver *driver_ops = pci_priv->driver_ops; in cnss_pci_suspend_driver()
3947 struct cnss_plat_data *plat_priv = pci_priv->plat_priv; in cnss_pci_suspend_driver()
3964 static int cnss_pci_resume_driver(struct cnss_pci_data *pci_priv) in cnss_pci_resume_driver() argument
3966 struct pci_dev *pci_dev = pci_priv->pci_dev; in cnss_pci_resume_driver()
3967 struct cnss_wlan_driver *driver_ops = pci_priv->driver_ops; in cnss_pci_resume_driver()
3969 struct cnss_plat_data *plat_priv = pci_priv->plat_priv; in cnss_pci_resume_driver()
3982 int cnss_pci_suspend_bus(struct cnss_pci_data *pci_priv) in cnss_pci_suspend_bus() argument
3984 struct pci_dev *pci_dev = pci_priv->pci_dev; in cnss_pci_suspend_bus()
3987 if (pci_priv->pci_link_state == PCI_LINK_DOWN) in cnss_pci_suspend_bus()
3990 if (cnss_pci_set_mhi_state(pci_priv, CNSS_MHI_SUSPEND)) { in cnss_pci_suspend_bus()
3995 if (pci_priv->drv_connected_last) in cnss_pci_suspend_bus()
3999 cnss_set_pci_config_space(pci_priv, SAVE_PCI_CONFIG_SPACE); in cnss_pci_suspend_bus()
4007 if (cnss_set_pci_link(pci_priv, PCI_LINK_DOWN)) { in cnss_pci_suspend_bus()
4011 pci_priv->pci_link_state = PCI_LINK_DOWN; in cnss_pci_suspend_bus()
4019 if (pci_priv->saved_state) in cnss_pci_suspend_bus()
4020 cnss_set_pci_config_space(pci_priv, RESTORE_PCI_CONFIG_SPACE); in cnss_pci_suspend_bus()
4022 cnss_pci_set_mhi_state(pci_priv, CNSS_MHI_RESUME); in cnss_pci_suspend_bus()
4027 int cnss_pci_resume_bus(struct cnss_pci_data *pci_priv) in cnss_pci_resume_bus() argument
4029 struct pci_dev *pci_dev = pci_priv->pci_dev; in cnss_pci_resume_bus()
4032 if (pci_priv->pci_link_state == PCI_LINK_UP) in cnss_pci_resume_bus()
4035 if (cnss_set_pci_link(pci_priv, PCI_LINK_UP)) { in cnss_pci_resume_bus()
4042 pci_priv->pci_link_state = PCI_LINK_UP; in cnss_pci_resume_bus()
4044 if (pci_priv->drv_connected_last) in cnss_pci_resume_bus()
4054 if (pci_priv->saved_state) in cnss_pci_resume_bus()
4055 cnss_set_pci_config_space(pci_priv, in cnss_pci_resume_bus()
4060 if (cnss_pci_set_mhi_state(pci_priv, CNSS_MHI_RESUME)) in cnss_pci_resume_bus()
4070 struct cnss_pci_data *pci_priv = cnss_get_pci_priv(pci_dev); in cnss_pci_suspend() local
4073 if (!pci_priv) in cnss_pci_suspend()
4076 plat_priv = pci_priv->plat_priv; in cnss_pci_suspend()
4086 if (pci_priv->mhi_state == CNSS_MHI_INIT) { in cnss_pci_suspend()
4093 ret = cnss_suspend_pci_link(pci_priv); in cnss_pci_suspend()
4103 pci_priv->drv_supported) { in cnss_pci_suspend()
4104 pci_priv->drv_connected_last = in cnss_pci_suspend()
4105 cnss_pci_get_drv_connected(pci_priv); in cnss_pci_suspend()
4106 if (!pci_priv->drv_connected_last) { in cnss_pci_suspend()
4115 ret = cnss_pci_suspend_driver(pci_priv); in cnss_pci_suspend()
4119 if (!pci_priv->disable_pc) { in cnss_pci_suspend()
4120 mutex_lock(&pci_priv->bus_lock); in cnss_pci_suspend()
4121 ret = cnss_pci_suspend_bus(pci_priv); in cnss_pci_suspend()
4122 mutex_unlock(&pci_priv->bus_lock); in cnss_pci_suspend()
4127 cnss_pci_set_monitor_wake_intr(pci_priv, false); in cnss_pci_suspend()
4132 cnss_pci_resume_driver(pci_priv); in cnss_pci_suspend()
4134 pci_priv->drv_connected_last = 0; in cnss_pci_suspend()
4144 struct cnss_pci_data *pci_priv = cnss_get_pci_priv(pci_dev); in cnss_pci_resume() local
4147 if (!pci_priv) in cnss_pci_resume()
4150 plat_priv = pci_priv->plat_priv; in cnss_pci_resume()
4154 if (pci_priv->pci_link_down_ind) in cnss_pci_resume()
4157 if (!cnss_is_device_powered_on(pci_priv->plat_priv)) in cnss_pci_resume()
4160 if (!pci_priv->disable_pc) { in cnss_pci_resume()
4161 mutex_lock(&pci_priv->bus_lock); in cnss_pci_resume()
4162 ret = cnss_pci_resume_bus(pci_priv); in cnss_pci_resume()
4163 mutex_unlock(&pci_priv->bus_lock); in cnss_pci_resume()
4168 ret = cnss_pci_resume_driver(pci_priv); in cnss_pci_resume()
4170 pci_priv->drv_connected_last = 0; in cnss_pci_resume()
4181 struct cnss_pci_data *pci_priv = cnss_get_pci_priv(pci_dev); in cnss_pci_suspend_noirq() local
4185 if (!pci_priv) in cnss_pci_suspend_noirq()
4188 if (!cnss_is_device_powered_on(pci_priv->plat_priv)) in cnss_pci_suspend_noirq()
4191 driver_ops = pci_priv->driver_ops; in cnss_pci_suspend_noirq()
4192 plat_priv = pci_priv->plat_priv; in cnss_pci_suspend_noirq()
4197 if (pci_priv->disable_pc && !pci_dev->state_saved && in cnss_pci_suspend_noirq()
4198 !pci_priv->plat_priv->use_pm_domain) in cnss_pci_suspend_noirq()
4209 struct cnss_pci_data *pci_priv = cnss_get_pci_priv(pci_dev); in cnss_pci_resume_noirq() local
4213 if (!pci_priv) in cnss_pci_resume_noirq()
4216 if (!cnss_is_device_powered_on(pci_priv->plat_priv)) in cnss_pci_resume_noirq()
4219 plat_priv = pci_priv->plat_priv; in cnss_pci_resume_noirq()
4220 driver_ops = pci_priv->driver_ops; in cnss_pci_resume_noirq()
4223 !pci_priv->pci_link_down_ind) in cnss_pci_resume_noirq()
4234 struct cnss_pci_data *pci_priv = cnss_get_pci_priv(pci_dev); in cnss_pci_runtime_suspend() local
4238 if (!pci_priv) in cnss_pci_runtime_suspend()
4241 plat_priv = pci_priv->plat_priv; in cnss_pci_runtime_suspend()
4245 if (!cnss_is_device_powered_on(pci_priv->plat_priv)) in cnss_pci_runtime_suspend()
4248 if (pci_priv->pci_link_down_ind) { in cnss_pci_runtime_suspend()
4254 pci_priv->drv_supported) { in cnss_pci_runtime_suspend()
4255 pci_priv->drv_connected_last = in cnss_pci_runtime_suspend()
4256 cnss_pci_get_drv_connected(pci_priv); in cnss_pci_runtime_suspend()
4257 if (!pci_priv->drv_connected_last) { in cnss_pci_runtime_suspend()
4265 driver_ops = pci_priv->driver_ops; in cnss_pci_runtime_suspend()
4273 pci_priv->drv_connected_last = 0; in cnss_pci_runtime_suspend()
4284 struct cnss_pci_data *pci_priv = cnss_get_pci_priv(pci_dev); in cnss_pci_runtime_resume() local
4287 if (!pci_priv) in cnss_pci_runtime_resume()
4290 if (!cnss_is_device_powered_on(pci_priv->plat_priv)) in cnss_pci_runtime_resume()
4293 if (pci_priv->pci_link_down_ind) { in cnss_pci_runtime_resume()
4300 driver_ops = pci_priv->driver_ops; in cnss_pci_runtime_resume()
4324 struct cnss_pci_data *pci_priv = cnss_get_pci_priv(pci_dev); in cnss_wlan_pm_control() local
4327 if (!pci_priv) in cnss_wlan_pm_control()
4330 ret = cnss_pci_disable_pc(pci_priv, vote); in cnss_wlan_pm_control()
4334 pci_priv->disable_pc = vote; in cnss_wlan_pm_control()
4341 static void cnss_pci_pm_runtime_get_record(struct cnss_pci_data *pci_priv, in cnss_pci_pm_runtime_get_record() argument
4347 atomic_inc(&pci_priv->pm_stats.runtime_get); in cnss_pci_pm_runtime_get_record()
4348 atomic_inc(&pci_priv->pm_stats.runtime_get_id[id]); in cnss_pci_pm_runtime_get_record()
4349 pci_priv->pm_stats.runtime_get_timestamp_id[id] = in cnss_pci_pm_runtime_get_record()
4350 cnss_get_host_timestamp(pci_priv->plat_priv); in cnss_pci_pm_runtime_get_record()
4353 static void cnss_pci_pm_runtime_put_record(struct cnss_pci_data *pci_priv, in cnss_pci_pm_runtime_put_record() argument
4359 atomic_inc(&pci_priv->pm_stats.runtime_put); in cnss_pci_pm_runtime_put_record()
4360 atomic_inc(&pci_priv->pm_stats.runtime_put_id[id]); in cnss_pci_pm_runtime_put_record()
4361 pci_priv->pm_stats.runtime_put_timestamp_id[id] = in cnss_pci_pm_runtime_put_record()
4362 cnss_get_host_timestamp(pci_priv->plat_priv); in cnss_pci_pm_runtime_put_record()
4365 void cnss_pci_pm_runtime_show_usage_count(struct cnss_pci_data *pci_priv) in cnss_pci_pm_runtime_show_usage_count() argument
4369 if (!pci_priv) in cnss_pci_pm_runtime_show_usage_count()
4372 dev = &pci_priv->pci_dev->dev; in cnss_pci_pm_runtime_show_usage_count()
4378 int cnss_pci_pm_request_resume(struct cnss_pci_data *pci_priv) in cnss_pci_pm_request_resume() argument
4383 if (!pci_priv) in cnss_pci_pm_request_resume()
4386 dev = &pci_priv->pci_dev->dev; in cnss_pci_pm_request_resume()
4396 int cnss_pci_pm_runtime_resume(struct cnss_pci_data *pci_priv) in cnss_pci_pm_runtime_resume() argument
4401 if (!pci_priv) in cnss_pci_pm_runtime_resume()
4404 dev = &pci_priv->pci_dev->dev; in cnss_pci_pm_runtime_resume()
4414 int cnss_pci_pm_runtime_get(struct cnss_pci_data *pci_priv, in cnss_pci_pm_runtime_get() argument
4420 if (!pci_priv) in cnss_pci_pm_runtime_get()
4423 dev = &pci_priv->pci_dev->dev; in cnss_pci_pm_runtime_get()
4430 cnss_pci_pm_runtime_get_record(pci_priv, id); in cnss_pci_pm_runtime_get()
4435 int cnss_pci_pm_runtime_get_sync(struct cnss_pci_data *pci_priv, in cnss_pci_pm_runtime_get_sync() argument
4441 if (!pci_priv) in cnss_pci_pm_runtime_get_sync()
4444 dev = &pci_priv->pci_dev->dev; in cnss_pci_pm_runtime_get_sync()
4451 cnss_pci_pm_runtime_get_record(pci_priv, id); in cnss_pci_pm_runtime_get_sync()
4456 void cnss_pci_pm_runtime_get_noresume(struct cnss_pci_data *pci_priv, in cnss_pci_pm_runtime_get_noresume() argument
4459 if (!pci_priv) in cnss_pci_pm_runtime_get_noresume()
4462 cnss_pci_pm_runtime_get_record(pci_priv, id); in cnss_pci_pm_runtime_get_noresume()
4463 pm_runtime_get_noresume(&pci_priv->pci_dev->dev); in cnss_pci_pm_runtime_get_noresume()
4466 int cnss_pci_pm_runtime_put_autosuspend(struct cnss_pci_data *pci_priv, in cnss_pci_pm_runtime_put_autosuspend() argument
4471 if (!pci_priv) in cnss_pci_pm_runtime_put_autosuspend()
4474 dev = &pci_priv->pci_dev->dev; in cnss_pci_pm_runtime_put_autosuspend()
4481 cnss_pci_pm_runtime_put_record(pci_priv, id); in cnss_pci_pm_runtime_put_autosuspend()
4483 return pm_runtime_put_autosuspend(&pci_priv->pci_dev->dev); in cnss_pci_pm_runtime_put_autosuspend()
4486 void cnss_pci_pm_runtime_put_noidle(struct cnss_pci_data *pci_priv, in cnss_pci_pm_runtime_put_noidle() argument
4491 if (!pci_priv) in cnss_pci_pm_runtime_put_noidle()
4494 dev = &pci_priv->pci_dev->dev; in cnss_pci_pm_runtime_put_noidle()
4501 cnss_pci_pm_runtime_put_record(pci_priv, id); in cnss_pci_pm_runtime_put_noidle()
4502 pm_runtime_put_noidle(&pci_priv->pci_dev->dev); in cnss_pci_pm_runtime_put_noidle()
4505 void cnss_pci_pm_runtime_mark_last_busy(struct cnss_pci_data *pci_priv) in cnss_pci_pm_runtime_mark_last_busy() argument
4507 if (!pci_priv) in cnss_pci_pm_runtime_mark_last_busy()
4510 pm_runtime_mark_last_busy(&pci_priv->pci_dev->dev); in cnss_pci_pm_runtime_mark_last_busy()
4517 struct cnss_pci_data *pci_priv = cnss_get_pci_priv(pci_dev); in cnss_auto_suspend() local
4520 if (!pci_priv) in cnss_auto_suspend()
4523 plat_priv = pci_priv->plat_priv; in cnss_auto_suspend()
4527 mutex_lock(&pci_priv->bus_lock); in cnss_auto_suspend()
4528 if (!pci_priv->qmi_send_usage_count) { in cnss_auto_suspend()
4529 ret = cnss_pci_suspend_bus(pci_priv); in cnss_auto_suspend()
4531 mutex_unlock(&pci_priv->bus_lock); in cnss_auto_suspend()
4536 cnss_pci_set_auto_suspended(pci_priv, 1); in cnss_auto_suspend()
4537 mutex_unlock(&pci_priv->bus_lock); in cnss_auto_suspend()
4539 cnss_pci_set_monitor_wake_intr(pci_priv, true); in cnss_auto_suspend()
4554 struct cnss_pci_data *pci_priv = cnss_get_pci_priv(pci_dev); in cnss_auto_resume() local
4557 if (!pci_priv) in cnss_auto_resume()
4560 plat_priv = pci_priv->plat_priv; in cnss_auto_resume()
4564 mutex_lock(&pci_priv->bus_lock); in cnss_auto_resume()
4565 ret = cnss_pci_resume_bus(pci_priv); in cnss_auto_resume()
4567 mutex_unlock(&pci_priv->bus_lock); in cnss_auto_resume()
4571 cnss_pci_set_auto_suspended(pci_priv, 0); in cnss_auto_resume()
4572 mutex_unlock(&pci_priv->bus_lock); in cnss_auto_resume()
4575 pci_priv->drv_connected_last = 0; in cnss_auto_resume()
4584 struct cnss_pci_data *pci_priv = cnss_get_pci_priv(pci_dev); in cnss_pci_force_wake_request_sync() local
4588 if (!pci_priv) in cnss_pci_force_wake_request_sync()
4591 switch (pci_priv->device_id) { in cnss_pci_force_wake_request_sync()
4602 mhi_ctrl = pci_priv->mhi_ctrl; in cnss_pci_force_wake_request_sync()
4606 plat_priv = pci_priv->plat_priv; in cnss_pci_force_wake_request_sync()
4615 return cnss_mhi_device_get_sync_atomic(pci_priv, in cnss_pci_force_wake_request_sync()
4627 struct cnss_pci_data *pci_priv = cnss_get_pci_priv(pci_dev); in cnss_pci_force_wake_request() local
4631 if (!pci_priv) in cnss_pci_force_wake_request()
4634 switch (pci_priv->device_id) { in cnss_pci_force_wake_request()
4645 mhi_ctrl = pci_priv->mhi_ctrl; in cnss_pci_force_wake_request()
4649 plat_priv = pci_priv->plat_priv; in cnss_pci_force_wake_request()
4665 struct cnss_pci_data *pci_priv = cnss_get_pci_priv(pci_dev); in cnss_pci_is_device_awake() local
4668 if (!pci_priv) in cnss_pci_is_device_awake()
4671 switch (pci_priv->device_id) { in cnss_pci_is_device_awake()
4682 mhi_ctrl = pci_priv->mhi_ctrl; in cnss_pci_is_device_awake()
4693 struct cnss_pci_data *pci_priv = cnss_get_pci_priv(pci_dev); in cnss_pci_force_wake_release() local
4697 if (!pci_priv) in cnss_pci_force_wake_release()
4700 switch (pci_priv->device_id) { in cnss_pci_force_wake_release()
4711 mhi_ctrl = pci_priv->mhi_ctrl; in cnss_pci_force_wake_release()
4715 plat_priv = pci_priv->plat_priv; in cnss_pci_force_wake_release()
4728 int cnss_pci_qmi_send_get(struct cnss_pci_data *pci_priv) in cnss_pci_qmi_send_get() argument
4732 if (!pci_priv) in cnss_pci_qmi_send_get()
4735 mutex_lock(&pci_priv->bus_lock); in cnss_pci_qmi_send_get()
4736 if (cnss_pci_get_auto_suspended(pci_priv) && in cnss_pci_qmi_send_get()
4737 !pci_priv->qmi_send_usage_count) in cnss_pci_qmi_send_get()
4738 ret = cnss_pci_resume_bus(pci_priv); in cnss_pci_qmi_send_get()
4739 pci_priv->qmi_send_usage_count++; in cnss_pci_qmi_send_get()
4741 pci_priv->qmi_send_usage_count); in cnss_pci_qmi_send_get()
4742 mutex_unlock(&pci_priv->bus_lock); in cnss_pci_qmi_send_get()
4747 int cnss_pci_qmi_send_put(struct cnss_pci_data *pci_priv) in cnss_pci_qmi_send_put() argument
4751 if (!pci_priv) in cnss_pci_qmi_send_put()
4754 mutex_lock(&pci_priv->bus_lock); in cnss_pci_qmi_send_put()
4755 if (pci_priv->qmi_send_usage_count) in cnss_pci_qmi_send_put()
4756 pci_priv->qmi_send_usage_count--; in cnss_pci_qmi_send_put()
4758 pci_priv->qmi_send_usage_count); in cnss_pci_qmi_send_put()
4759 if (cnss_pci_get_auto_suspended(pci_priv) && in cnss_pci_qmi_send_put()
4760 !pci_priv->qmi_send_usage_count && in cnss_pci_qmi_send_put()
4761 !cnss_pcie_is_device_down(pci_priv)) in cnss_pci_qmi_send_put()
4762 ret = cnss_pci_suspend_bus(pci_priv); in cnss_pci_qmi_send_put()
4763 mutex_unlock(&pci_priv->bus_lock); in cnss_pci_qmi_send_put()
4856 int cnss_pci_alloc_fw_mem(struct cnss_pci_data *pci_priv) in cnss_pci_alloc_fw_mem() argument
4858 struct cnss_plat_data *plat_priv = pci_priv->plat_priv; in cnss_pci_alloc_fw_mem()
4860 struct device *dev = &pci_priv->pci_dev->dev; in cnss_pci_alloc_fw_mem()
4892 static void cnss_pci_free_fw_mem(struct cnss_pci_data *pci_priv) in cnss_pci_free_fw_mem() argument
4894 struct cnss_plat_data *plat_priv = pci_priv->plat_priv; in cnss_pci_free_fw_mem()
4896 struct device *dev = &pci_priv->pci_dev->dev; in cnss_pci_free_fw_mem()
4917 int cnss_pci_alloc_qdss_mem(struct cnss_pci_data *pci_priv) in cnss_pci_alloc_qdss_mem() argument
4919 struct cnss_plat_data *plat_priv = pci_priv->plat_priv; in cnss_pci_alloc_qdss_mem()
4926 dma_alloc_coherent(&pci_priv->pci_dev->dev, in cnss_pci_alloc_qdss_mem()
4951 void cnss_pci_free_qdss_mem(struct cnss_pci_data *pci_priv) in cnss_pci_free_qdss_mem() argument
4953 struct cnss_plat_data *plat_priv = pci_priv->plat_priv; in cnss_pci_free_qdss_mem()
4962 dma_free_coherent(&pci_priv->pci_dev->dev, in cnss_pci_free_qdss_mem()
4974 int cnss_pci_load_tme_patch(struct cnss_pci_data *pci_priv) in cnss_pci_load_tme_patch() argument
4976 struct cnss_plat_data *plat_priv = pci_priv->plat_priv; in cnss_pci_load_tme_patch()
4983 switch (pci_priv->device_id) { in cnss_pci_load_tme_patch()
4998 pci_priv->device_id); in cnss_pci_load_tme_patch()
5006 &pci_priv->pci_dev->dev); in cnss_pci_load_tme_patch()
5013 tme_lite_mem->va = dma_alloc_coherent(&pci_priv->pci_dev->dev, in cnss_pci_load_tme_patch()
5031 static void cnss_pci_free_tme_lite_mem(struct cnss_pci_data *pci_priv) in cnss_pci_free_tme_lite_mem() argument
5033 struct cnss_plat_data *plat_priv = pci_priv->plat_priv; in cnss_pci_free_tme_lite_mem()
5039 dma_free_coherent(&pci_priv->pci_dev->dev, tme_lite_mem->size, in cnss_pci_free_tme_lite_mem()
5048 int cnss_pci_load_tme_opt_file(struct cnss_pci_data *pci_priv, in cnss_pci_load_tme_opt_file() argument
5051 struct cnss_plat_data *plat_priv = pci_priv->plat_priv; in cnss_pci_load_tme_opt_file()
5058 switch (pci_priv->device_id) { in cnss_pci_load_tme_opt_file()
5079 tme_opt_filename, pci_priv->device_id); in cnss_pci_load_tme_opt_file()
5087 cnss_pci_add_fw_prefix_name(pci_priv, filename, in cnss_pci_load_tme_opt_file()
5091 &pci_priv->pci_dev->dev); in cnss_pci_load_tme_opt_file()
5098 tme_lite_mem->va = dma_alloc_coherent(&pci_priv->pci_dev->dev, in cnss_pci_load_tme_opt_file()
5116 static void cnss_pci_free_tme_opt_file_mem(struct cnss_pci_data *pci_priv) in cnss_pci_free_tme_opt_file_mem() argument
5118 struct cnss_plat_data *plat_priv = pci_priv->plat_priv; in cnss_pci_free_tme_opt_file_mem()
5127 dma_free_coherent(&pci_priv->pci_dev->dev, tme_opt_file_mem[i].size, in cnss_pci_free_tme_opt_file_mem()
5136 int cnss_pci_load_m3(struct cnss_pci_data *pci_priv) in cnss_pci_load_m3() argument
5138 struct cnss_plat_data *plat_priv = pci_priv->plat_priv; in cnss_pci_load_m3()
5148 switch (pci_priv->device_id) { in cnss_pci_load_m3()
5151 pci_priv->device_id); in cnss_pci_load_m3()
5174 cnss_pci_add_fw_prefix_name(pci_priv, filename, in cnss_pci_load_m3()
5178 &pci_priv->pci_dev->dev); in cnss_pci_load_m3()
5184 m3_mem->va = dma_alloc_coherent(&pci_priv->pci_dev->dev, in cnss_pci_load_m3()
5202 static void cnss_pci_free_m3_mem(struct cnss_pci_data *pci_priv) in cnss_pci_free_m3_mem() argument
5204 struct cnss_plat_data *plat_priv = pci_priv->plat_priv; in cnss_pci_free_m3_mem()
5210 dma_free_coherent(&pci_priv->pci_dev->dev, m3_mem->size, in cnss_pci_free_m3_mem()
5220 void cnss_pci_free_blob_mem(struct cnss_pci_data *pci_priv) in cnss_pci_free_blob_mem() argument
5222 cnss_pci_free_m3_mem(pci_priv); in cnss_pci_free_blob_mem()
5225 void cnss_pci_free_blob_mem(struct cnss_pci_data *pci_priv) in cnss_pci_free_blob_mem() argument
5230 int cnss_pci_load_aux(struct cnss_pci_data *pci_priv) in cnss_pci_load_aux() argument
5232 struct cnss_plat_data *plat_priv = pci_priv->plat_priv; in cnss_pci_load_aux()
5240 cnss_pci_add_fw_prefix_name(pci_priv, filename, in cnss_pci_load_aux()
5244 &pci_priv->pci_dev->dev); in cnss_pci_load_aux()
5250 aux_mem->va = dma_alloc_coherent(&pci_priv->pci_dev->dev, in cnss_pci_load_aux()
5268 static void cnss_pci_free_aux_mem(struct cnss_pci_data *pci_priv) in cnss_pci_free_aux_mem() argument
5270 struct cnss_plat_data *plat_priv = pci_priv->plat_priv; in cnss_pci_free_aux_mem()
5276 dma_free_coherent(&pci_priv->pci_dev->dev, aux_mem->size, in cnss_pci_free_aux_mem()
5285 void cnss_pci_fw_boot_timeout_hdlr(struct cnss_pci_data *pci_priv) in cnss_pci_fw_boot_timeout_hdlr() argument
5289 if (!pci_priv) in cnss_pci_fw_boot_timeout_hdlr()
5294 plat_priv = pci_priv->plat_priv; in cnss_pci_fw_boot_timeout_hdlr()
5303 cnss_schedule_recovery(&pci_priv->pci_dev->dev, in cnss_pci_fw_boot_timeout_hdlr()
5307 static void cnss_pci_deinit_smmu(struct cnss_pci_data *pci_priv) in cnss_pci_deinit_smmu() argument
5309 pci_priv->iommu_domain = NULL; in cnss_pci_deinit_smmu()
5312 int cnss_pci_get_iova(struct cnss_pci_data *pci_priv, u64 *addr, u64 *size) in cnss_pci_get_iova() argument
5314 if (!pci_priv) in cnss_pci_get_iova()
5317 if (!pci_priv->smmu_iova_len) in cnss_pci_get_iova()
5320 *addr = pci_priv->smmu_iova_start; in cnss_pci_get_iova()
5321 *size = pci_priv->smmu_iova_len; in cnss_pci_get_iova()
5326 int cnss_pci_get_iova_ipa(struct cnss_pci_data *pci_priv, u64 *addr, u64 *size) in cnss_pci_get_iova_ipa() argument
5328 if (!pci_priv) in cnss_pci_get_iova_ipa()
5331 if (!pci_priv->smmu_iova_ipa_len) in cnss_pci_get_iova_ipa()
5334 *addr = pci_priv->smmu_iova_ipa_start; in cnss_pci_get_iova_ipa()
5335 *size = pci_priv->smmu_iova_ipa_len; in cnss_pci_get_iova_ipa()
5340 bool cnss_pci_is_smmu_s1_enabled(struct cnss_pci_data *pci_priv) in cnss_pci_is_smmu_s1_enabled() argument
5342 if (pci_priv) in cnss_pci_is_smmu_s1_enabled()
5343 return pci_priv->smmu_s1_enable; in cnss_pci_is_smmu_s1_enabled()
5349 struct cnss_pci_data *pci_priv = cnss_get_pci_priv(to_pci_dev(dev)); in cnss_smmu_get_domain() local
5351 if (!pci_priv) in cnss_smmu_get_domain()
5354 return pci_priv->iommu_domain; in cnss_smmu_get_domain()
5361 struct cnss_pci_data *pci_priv = cnss_get_pci_priv(to_pci_dev(dev)); in cnss_smmu_map() local
5371 if (!pci_priv) in cnss_smmu_map()
5380 plat_priv = pci_priv->plat_priv; in cnss_smmu_map()
5383 iova = roundup(pci_priv->smmu_iova_ipa_current, PAGE_SIZE); in cnss_smmu_map()
5385 if (pci_priv->iommu_geometry && in cnss_smmu_map()
5386 iova >= pci_priv->smmu_iova_ipa_start + in cnss_smmu_map()
5387 pci_priv->smmu_iova_ipa_len) { in cnss_smmu_map()
5390 &pci_priv->smmu_iova_ipa_start, in cnss_smmu_map()
5391 pci_priv->smmu_iova_ipa_len); in cnss_smmu_map()
5397 root_port = pcie_find_root_port(pci_priv->pci_dev); in cnss_smmu_map()
5416 ret = cnss_iommu_map(pci_priv->iommu_domain, iova, in cnss_smmu_map()
5423 pci_priv->smmu_iova_ipa_current = iova + len; in cnss_smmu_map()
5433 struct cnss_pci_data *pci_priv = cnss_get_pci_priv(to_pci_dev(dev)); in cnss_smmu_unmap() local
5438 if (!pci_priv) in cnss_smmu_unmap()
5444 if (iova >= pci_priv->smmu_iova_ipa_start + in cnss_smmu_unmap()
5445 pci_priv->smmu_iova_ipa_len) { in cnss_smmu_unmap()
5448 &pci_priv->smmu_iova_ipa_start, in cnss_smmu_unmap()
5449 pci_priv->smmu_iova_ipa_len); in cnss_smmu_unmap()
5455 unmapped = iommu_unmap(pci_priv->iommu_domain, iova, len); in cnss_smmu_unmap()
5462 pci_priv->smmu_iova_ipa_current = iova; in cnss_smmu_unmap()
5469 struct cnss_pci_data *pci_priv = cnss_get_pci_priv(to_pci_dev(dev)); in cnss_get_soc_info() local
5472 if (!pci_priv) in cnss_get_soc_info()
5475 plat_priv = pci_priv->plat_priv; in cnss_get_soc_info()
5479 info->va = pci_priv->bar; in cnss_get_soc_info()
5480 info->pa = pci_resource_start(pci_priv->pci_dev, PCI_BAR_NUM); in cnss_get_soc_info()
5500 int cnss_pci_get_user_msi_assignment(struct cnss_pci_data *pci_priv, in cnss_pci_get_user_msi_assignment() argument
5506 return cnss_get_user_msi_assignment(&pci_priv->pci_dev->dev, in cnss_pci_get_user_msi_assignment()
5513 static int cnss_pci_irq_set_affinity_hint(struct cnss_pci_data *pci_priv, in cnss_pci_irq_set_affinity_hint() argument
5518 struct pci_dev *pci_dev = pci_priv->pci_dev; in cnss_pci_irq_set_affinity_hint()
5526 static int cnss_pci_enable_msi(struct cnss_pci_data *pci_priv) in cnss_pci_enable_msi() argument
5529 struct pci_dev *pci_dev = pci_priv->pci_dev; in cnss_pci_enable_msi()
5533 if (pci_priv->device_id == QCA6174_DEVICE_ID) in cnss_pci_enable_msi()
5536 if (cnss_pci_is_force_one_msi(pci_priv)) { in cnss_pci_enable_msi()
5537 ret = cnss_pci_get_one_msi_assignment(pci_priv); in cnss_pci_enable_msi()
5540 ret = cnss_pci_get_msi_assignment(pci_priv); in cnss_pci_enable_msi()
5547 msi_config = pci_priv->msi_config; in cnss_pci_enable_msi()
5559 !cnss_pci_fallback_one_msi(pci_priv, &num_vectors)) { in cnss_pci_enable_msi()
5575 if (cnss_pci_is_one_msi(pci_priv)) { in cnss_pci_enable_msi()
5576 ret = cnss_pci_irq_set_affinity_hint(pci_priv, in cnss_pci_enable_msi()
5585 if (cnss_pci_config_msi_addr(pci_priv)) { in cnss_pci_enable_msi()
5590 if (cnss_pci_config_msi_data(pci_priv)) { in cnss_pci_enable_msi()
5598 if (cnss_pci_is_one_msi(pci_priv)) in cnss_pci_enable_msi()
5599 cnss_pci_irq_set_affinity_hint(pci_priv, 0, NULL); in cnss_pci_enable_msi()
5600 pci_free_irq_vectors(pci_priv->pci_dev); in cnss_pci_enable_msi()
5602 pci_priv->msi_config = NULL; in cnss_pci_enable_msi()
5607 static void cnss_pci_disable_msi(struct cnss_pci_data *pci_priv) in cnss_pci_disable_msi() argument
5609 if (pci_priv->device_id == QCA6174_DEVICE_ID) in cnss_pci_disable_msi()
5612 if (cnss_pci_is_one_msi(pci_priv)) in cnss_pci_disable_msi()
5613 cnss_pci_irq_set_affinity_hint(pci_priv, 0, NULL); in cnss_pci_disable_msi()
5615 pci_free_irq_vectors(pci_priv->pci_dev); in cnss_pci_disable_msi()
5622 struct cnss_pci_data *pci_priv = cnss_get_pci_priv(to_pci_dev(dev)); in cnss_get_user_msi_assignment() local
5626 if (!pci_priv) in cnss_get_user_msi_assignment()
5629 msi_config = pci_priv->msi_config; in cnss_get_user_msi_assignment()
5639 + pci_priv->msi_ep_base_data; in cnss_get_user_msi_assignment()
5673 struct cnss_pci_data *pci_priv = cnss_get_pci_priv(to_pci_dev(dev)); in cnss_is_one_msi() local
5675 if (!pci_priv) in cnss_is_one_msi()
5678 return cnss_pci_is_one_msi(pci_priv); in cnss_is_one_msi()
5686 struct cnss_pci_data *pci_priv; in cnss_get_msi_address() local
5692 pci_priv = cnss_get_pci_priv(pci_dev); in cnss_get_msi_address()
5693 if (!pci_priv) in cnss_get_msi_address()
5697 *msi_addr_low = pci_priv->msix_addr; in cnss_get_msi_address()
5723 u32 cnss_pci_get_wake_msi(struct cnss_pci_data *pci_priv) in cnss_pci_get_wake_msi() argument
5728 if (!pci_priv) in cnss_pci_get_wake_msi()
5731 ret = cnss_get_user_msi_assignment(&pci_priv->pci_dev->dev, in cnss_pci_get_wake_msi()
5766 static int cnss_pci_enable_bus(struct cnss_pci_data *pci_priv) in cnss_pci_enable_bus() argument
5769 struct pci_dev *pci_dev = pci_priv->pci_dev; in cnss_pci_enable_bus()
5773 if (device_id != pci_priv->pci_device_id->device) { in cnss_pci_enable_bus()
5775 device_id, pci_priv->pci_device_id->device); in cnss_pci_enable_bus()
5801 pci_priv->dma_bit_mask = PCI_DMA_MASK_32_BIT; in cnss_pci_enable_bus()
5808 pci_priv->dma_bit_mask = PCI_DMA_MASK_36_BIT; in cnss_pci_enable_bus()
5811 pci_priv->dma_bit_mask = PCI_DMA_MASK_32_BIT; in cnss_pci_enable_bus()
5815 cnss_pr_dbg("Set PCI DMA MASK (0x%llx)\n", pci_priv->dma_bit_mask); in cnss_pci_enable_bus()
5817 ret = cnss_pci_set_dma_mask(pci_dev, pci_priv->dma_bit_mask); in cnss_pci_enable_bus()
5823 ret = cnss_pci_set_coherent_dma_mask(pci_dev, pci_priv->dma_bit_mask); in cnss_pci_enable_bus()
5830 pci_priv->bar = pci_iomap(pci_dev, PCI_BAR_NUM, 0); in cnss_pci_enable_bus()
5831 if (!pci_priv->bar) { in cnss_pci_enable_bus()
5839 pci_priv->default_state = pci_store_saved_state(pci_dev); in cnss_pci_enable_bus()
5853 static void cnss_pci_disable_bus(struct cnss_pci_data *pci_priv) in cnss_pci_disable_bus() argument
5855 struct pci_dev *pci_dev = pci_priv->pci_dev; in cnss_pci_disable_bus()
5858 pci_load_and_free_saved_state(pci_dev, &pci_priv->saved_state); in cnss_pci_disable_bus()
5859 pci_load_and_free_saved_state(pci_dev, &pci_priv->default_state); in cnss_pci_disable_bus()
5861 if (pci_priv->bar) { in cnss_pci_disable_bus()
5862 pci_iounmap(pci_dev, pci_priv->bar); in cnss_pci_disable_bus()
5863 pci_priv->bar = NULL; in cnss_pci_disable_bus()
5871 static void cnss_pci_dump_qdss_reg(struct cnss_pci_data *pci_priv) in cnss_pci_dump_qdss_reg() argument
5873 struct cnss_plat_data *plat_priv = pci_priv->plat_priv; in cnss_pci_dump_qdss_reg()
5882 plat_priv->qdss_reg = devm_kzalloc(&pci_priv->pci_dev->dev, in cnss_pci_dump_qdss_reg()
5893 if (cnss_pci_reg_read(pci_priv, reg_offset, in cnss_pci_dump_qdss_reg()
5901 static void cnss_pci_dump_ce_reg(struct cnss_pci_data *pci_priv, in cnss_pci_dump_ce_reg() argument
5908 switch (pci_priv->device_id) { in cnss_pci_dump_ce_reg()
5928 if (cnss_pci_reg_read(pci_priv, reg_offset, &val)) in cnss_pci_dump_ce_reg()
5936 if (cnss_pci_reg_read(pci_priv, reg_offset, &val)) in cnss_pci_dump_ce_reg()
5945 if (cnss_pci_reg_read(pci_priv, reg_offset, &val)) in cnss_pci_dump_ce_reg()
5956 static void cnss_pci_dump_debug_reg(struct cnss_pci_data *pci_priv) in cnss_pci_dump_debug_reg() argument
5958 if (cnss_pci_check_link_status(pci_priv)) in cnss_pci_dump_debug_reg()
5963 cnss_mhi_debug_reg_dump(pci_priv); in cnss_pci_dump_debug_reg()
5964 cnss_pci_bhi_debug_reg_dump(pci_priv); in cnss_pci_dump_debug_reg()
5965 cnss_pci_soc_scratch_reg_dump(pci_priv); in cnss_pci_dump_debug_reg()
5966 cnss_pci_dump_ce_reg(pci_priv, CNSS_CE_COMMON); in cnss_pci_dump_debug_reg()
5967 cnss_pci_dump_ce_reg(pci_priv, CNSS_CE_09); in cnss_pci_dump_debug_reg()
5968 cnss_pci_dump_ce_reg(pci_priv, CNSS_CE_10); in cnss_pci_dump_debug_reg()
5971 static int cnss_pci_assert_host_sol(struct cnss_pci_data *pci_priv) in cnss_pci_assert_host_sol() argument
5975 ret = cnss_get_host_sol_value(pci_priv->plat_priv); in cnss_pci_assert_host_sol()
5993 cnss_set_host_sol_value(pci_priv->plat_priv, 1); in cnss_pci_assert_host_sol()
5998 static void cnss_pci_mhi_reg_dump(struct cnss_pci_data *pci_priv) in cnss_pci_mhi_reg_dump() argument
6000 if (!cnss_pci_check_link_status(pci_priv)) in cnss_pci_mhi_reg_dump()
6001 cnss_mhi_debug_reg_dump(pci_priv); in cnss_pci_mhi_reg_dump()
6003 cnss_pci_bhi_debug_reg_dump(pci_priv); in cnss_pci_mhi_reg_dump()
6004 cnss_pci_soc_scratch_reg_dump(pci_priv); in cnss_pci_mhi_reg_dump()
6005 cnss_pci_dump_misc_reg(pci_priv); in cnss_pci_mhi_reg_dump()
6006 cnss_pci_dump_shadow_reg(pci_priv); in cnss_pci_mhi_reg_dump()
6009 int cnss_pci_recover_link_down(struct cnss_pci_data *pci_priv) in cnss_pci_recover_link_down() argument
6015 switch (pci_priv->device_id) { in cnss_pci_recover_link_down()
6029 ret = wait_for_completion_timeout(&pci_priv->wake_event_complete, in cnss_pci_recover_link_down()
6034 ret = cnss_suspend_pci_link(pci_priv); in cnss_pci_recover_link_down()
6038 ret = cnss_resume_pci_link(pci_priv); in cnss_pci_recover_link_down()
6041 del_timer(&pci_priv->dev_rddm_timer); in cnss_pci_recover_link_down()
6051 mhi_ee = mhi_get_exec_env(pci_priv->mhi_ctrl); in cnss_pci_recover_link_down()
6053 del_timer(&pci_priv->dev_rddm_timer); in cnss_pci_recover_link_down()
6055 cnss_schedule_recovery(&pci_priv->pci_dev->dev, in cnss_pci_recover_link_down()
6064 if (!cnss_pci_assert_host_sol(pci_priv)) in cnss_pci_recover_link_down()
6066 cnss_mhi_debug_reg_dump(pci_priv); in cnss_pci_recover_link_down()
6067 cnss_pci_bhi_debug_reg_dump(pci_priv); in cnss_pci_recover_link_down()
6068 cnss_pci_soc_scratch_reg_dump(pci_priv); in cnss_pci_recover_link_down()
6069 cnss_schedule_recovery(&pci_priv->pci_dev->dev, in cnss_pci_recover_link_down()
6074 int cnss_pci_force_fw_assert_hdlr(struct cnss_pci_data *pci_priv) in cnss_pci_force_fw_assert_hdlr() argument
6079 if (!pci_priv) in cnss_pci_force_fw_assert_hdlr()
6082 plat_priv = pci_priv->plat_priv; in cnss_pci_force_fw_assert_hdlr()
6086 if (!test_bit(CNSS_MHI_POWER_ON, &pci_priv->mhi_state) || in cnss_pci_force_fw_assert_hdlr()
6087 test_bit(CNSS_MHI_POWERING_OFF, &pci_priv->mhi_state)) in cnss_pci_force_fw_assert_hdlr()
6093 ret = cnss_pci_pm_runtime_get_sync(pci_priv, RTPM_ID_CNSS); in cnss_pci_force_fw_assert_hdlr()
6100 cnss_auto_resume(&pci_priv->pci_dev->dev); in cnss_pci_force_fw_assert_hdlr()
6102 if (!pci_priv->is_smmu_fault) in cnss_pci_force_fw_assert_hdlr()
6103 cnss_pci_mhi_reg_dump(pci_priv); in cnss_pci_force_fw_assert_hdlr()
6106 ret = cnss_pci_check_link_status(pci_priv); in cnss_pci_force_fw_assert_hdlr()
6108 cnss_pci_link_down(&pci_priv->pci_dev->dev); in cnss_pci_force_fw_assert_hdlr()
6109 cnss_pci_pm_runtime_mark_last_busy(pci_priv); in cnss_pci_force_fw_assert_hdlr()
6110 cnss_pci_pm_runtime_put_autosuspend(pci_priv, RTPM_ID_CNSS); in cnss_pci_force_fw_assert_hdlr()
6119 ret = cnss_pci_set_mhi_state(pci_priv, CNSS_MHI_TRIGGER_RDDM); in cnss_pci_force_fw_assert_hdlr()
6121 if (pci_priv->is_smmu_fault) { in cnss_pci_force_fw_assert_hdlr()
6122 cnss_pci_mhi_reg_dump(pci_priv); in cnss_pci_force_fw_assert_hdlr()
6123 pci_priv->is_smmu_fault = false; in cnss_pci_force_fw_assert_hdlr()
6125 if (!test_bit(CNSS_MHI_POWER_ON, &pci_priv->mhi_state) || in cnss_pci_force_fw_assert_hdlr()
6126 test_bit(CNSS_MHI_POWERING_OFF, &pci_priv->mhi_state)) { in cnss_pci_force_fw_assert_hdlr()
6128 cnss_pci_pm_runtime_mark_last_busy(pci_priv); in cnss_pci_force_fw_assert_hdlr()
6129 cnss_pci_pm_runtime_put_autosuspend(pci_priv, RTPM_ID_CNSS); in cnss_pci_force_fw_assert_hdlr()
6133 if (!cnss_pci_assert_host_sol(pci_priv)) { in cnss_pci_force_fw_assert_hdlr()
6134 cnss_pci_pm_runtime_mark_last_busy(pci_priv); in cnss_pci_force_fw_assert_hdlr()
6135 cnss_pci_pm_runtime_put_autosuspend(pci_priv, RTPM_ID_CNSS); in cnss_pci_force_fw_assert_hdlr()
6140 if (!cnss_mhi_force_reset(pci_priv)) { in cnss_pci_force_fw_assert_hdlr()
6145 cnss_pci_dump_debug_reg(pci_priv); in cnss_pci_force_fw_assert_hdlr()
6146 cnss_schedule_recovery(&pci_priv->pci_dev->dev, in cnss_pci_force_fw_assert_hdlr()
6153 if (pci_priv->is_smmu_fault) { in cnss_pci_force_fw_assert_hdlr()
6154 cnss_pci_mhi_reg_dump(pci_priv); in cnss_pci_force_fw_assert_hdlr()
6155 pci_priv->is_smmu_fault = false; in cnss_pci_force_fw_assert_hdlr()
6159 mod_timer(&pci_priv->dev_rddm_timer, in cnss_pci_force_fw_assert_hdlr()
6164 cnss_pci_pm_runtime_mark_last_busy(pci_priv); in cnss_pci_force_fw_assert_hdlr()
6165 cnss_pci_pm_runtime_put_autosuspend(pci_priv, RTPM_ID_CNSS); in cnss_pci_force_fw_assert_hdlr()
6169 static void cnss_pci_add_dump_seg(struct cnss_pci_data *pci_priv, in cnss_pci_add_dump_seg() argument
6174 struct cnss_plat_data *plat_priv = pci_priv->plat_priv; in cnss_pci_add_dump_seg()
6175 struct device *dev = &pci_priv->pci_dev->dev; in cnss_pci_add_dump_seg()
6192 static void cnss_pci_remove_dump_seg(struct cnss_pci_data *pci_priv, in cnss_pci_remove_dump_seg() argument
6197 struct cnss_plat_data *plat_priv = pci_priv->plat_priv; in cnss_pci_remove_dump_seg()
6198 struct device *dev = &pci_priv->pci_dev->dev; in cnss_pci_remove_dump_seg()
6205 int cnss_pci_call_driver_uevent(struct cnss_pci_data *pci_priv, in cnss_pci_call_driver_uevent() argument
6211 driver_ops = pci_priv->driver_ops; in cnss_pci_call_driver_uevent()
6222 return driver_ops->update_event(pci_priv->pci_dev, &uevent_data); in cnss_pci_call_driver_uevent()
6225 static void cnss_pci_send_hang_event(struct cnss_pci_data *pci_priv) in cnss_pci_send_hang_event() argument
6227 struct cnss_plat_data *plat_priv = pci_priv->plat_priv; in cnss_pci_send_hang_event()
6239 switch (pci_priv->device_id) { in cnss_pci_send_hang_event()
6269 pci_priv->device_id); in cnss_pci_send_hang_event()
6293 cnss_pci_call_driver_uevent(pci_priv, CNSS_HANG_EVENT, &hang_event); in cnss_pci_send_hang_event()
6305 void cnss_pci_collect_host_dump_info(struct cnss_pci_data *pci_priv) in cnss_pci_collect_host_dump_info() argument
6308 struct cnss_plat_data *plat_priv = pci_priv->plat_priv; in cnss_pci_collect_host_dump_info()
6319 if (pci_priv->driver_ops && in cnss_pci_collect_host_dump_info()
6320 pci_priv->driver_ops->collect_driver_dump) { in cnss_pci_collect_host_dump_info()
6321 ret = pci_priv->driver_ops->collect_driver_dump(pci_priv->pci_dev, in cnss_pci_collect_host_dump_info()
6343 void cnss_pci_collect_dump_info(struct cnss_pci_data *pci_priv, bool in_panic) in cnss_pci_collect_dump_info() argument
6345 struct cnss_plat_data *plat_priv = pci_priv->plat_priv; in cnss_pci_collect_dump_info()
6356 cnss_pci_send_hang_event(pci_priv); in cnss_pci_collect_dump_info()
6358 if (test_bit(CNSS_MHI_RDDM_DONE, &pci_priv->mhi_state)) { in cnss_pci_collect_dump_info()
6369 mutex_lock(&pci_priv->bus_lock); in cnss_pci_collect_dump_info()
6370 ret = cnss_pci_check_link_status(pci_priv); in cnss_pci_collect_dump_info()
6373 mutex_unlock(&pci_priv->bus_lock); in cnss_pci_collect_dump_info()
6376 if (cnss_pci_resume_bus(pci_priv)) { in cnss_pci_collect_dump_info()
6377 mutex_unlock(&pci_priv->bus_lock); in cnss_pci_collect_dump_info()
6381 mutex_unlock(&pci_priv->bus_lock); in cnss_pci_collect_dump_info()
6383 if (cnss_pci_check_link_status(pci_priv)) in cnss_pci_collect_dump_info()
6388 pci_priv->mhi_ctrl->timeout_ms /= 2; in cnss_pci_collect_dump_info()
6391 cnss_mhi_debug_reg_dump(pci_priv); in cnss_pci_collect_dump_info()
6392 cnss_pci_bhi_debug_reg_dump(pci_priv); in cnss_pci_collect_dump_info()
6393 cnss_pci_soc_scratch_reg_dump(pci_priv); in cnss_pci_collect_dump_info()
6394 cnss_pci_dump_misc_reg(pci_priv); in cnss_pci_collect_dump_info()
6395 cnss_rddm_trigger_debug(pci_priv); in cnss_pci_collect_dump_info()
6396 ret = mhi_download_rddm_image(pci_priv->mhi_ctrl, in_panic); in cnss_pci_collect_dump_info()
6400 if (!cnss_pci_assert_host_sol(pci_priv)) in cnss_pci_collect_dump_info()
6402 cnss_rddm_trigger_check(pci_priv); in cnss_pci_collect_dump_info()
6403 cnss_pci_dump_debug_reg(pci_priv); in cnss_pci_collect_dump_info()
6406 cnss_rddm_trigger_check(pci_priv); in cnss_pci_collect_dump_info()
6407 fw_image = pci_priv->mhi_ctrl->fbc_image; in cnss_pci_collect_dump_info()
6408 rddm_image = pci_priv->mhi_ctrl->rddm_image; in cnss_pci_collect_dump_info()
6412 cnss_pci_dump_qdss_reg(pci_priv); in cnss_pci_collect_dump_info()
6413 cnss_mhi_dump_sfr(pci_priv); in cnss_pci_collect_dump_info()
6424 cnss_pci_add_dump_seg(pci_priv, dump_seg, CNSS_FW_IMAGE, i, in cnss_pci_collect_dump_info()
6437 cnss_pci_add_dump_seg(pci_priv, dump_seg, CNSS_FW_RDDM, i, in cnss_pci_collect_dump_info()
6450 cnss_pci_add_dump_seg(pci_priv, dump_seg, in cnss_pci_collect_dump_info()
6463 cnss_pci_add_dump_seg(pci_priv, dump_seg, in cnss_pci_collect_dump_info()
6477 cnss_pci_set_mhi_state(pci_priv, CNSS_MHI_RDDM_DONE); in cnss_pci_collect_dump_info()
6483 void cnss_pci_clear_dump_info(struct cnss_pci_data *pci_priv) in cnss_pci_clear_dump_info() argument
6485 struct cnss_plat_data *plat_priv = pci_priv->plat_priv; in cnss_pci_clear_dump_info()
6495 fw_image = pci_priv->mhi_ctrl->fbc_image; in cnss_pci_clear_dump_info()
6496 rddm_image = pci_priv->mhi_ctrl->rddm_image; in cnss_pci_clear_dump_info()
6499 cnss_pci_remove_dump_seg(pci_priv, dump_seg, CNSS_FW_IMAGE, i, in cnss_pci_clear_dump_info()
6507 cnss_pci_remove_dump_seg(pci_priv, dump_seg, CNSS_FW_RDDM, i, in cnss_pci_clear_dump_info()
6517 cnss_pci_remove_dump_seg(pci_priv, dump_seg, in cnss_pci_clear_dump_info()
6524 cnss_pci_remove_dump_seg(pci_priv, dump_seg, in cnss_pci_clear_dump_info()
6537 void cnss_pci_device_crashed(struct cnss_pci_data *pci_priv) in cnss_pci_device_crashed() argument
6541 if (!pci_priv) { in cnss_pci_device_crashed()
6546 plat_priv = pci_priv->plat_priv; in cnss_pci_device_crashed()
6553 cnss_pci_collect_host_dump_info(pci_priv); in cnss_pci_device_crashed()
6565 struct cnss_pci_data *pci_priv = dev_get_drvdata(mhi_ctrl->cntrl_dev); in cnss_mhi_pm_runtime_get() local
6567 return cnss_pci_pm_runtime_get(pci_priv, RTPM_ID_MHI); in cnss_mhi_pm_runtime_get()
6572 struct cnss_pci_data *pci_priv = dev_get_drvdata(mhi_ctrl->cntrl_dev); in cnss_mhi_pm_runtime_put_noidle() local
6574 cnss_pci_pm_runtime_put_noidle(pci_priv, RTPM_ID_MHI); in cnss_mhi_pm_runtime_put_noidle()
6577 void cnss_pci_add_fw_prefix_name(struct cnss_pci_data *pci_priv, in cnss_pci_add_fw_prefix_name() argument
6582 if (!pci_priv) in cnss_pci_add_fw_prefix_name()
6585 plat_priv = pci_priv->plat_priv; in cnss_pci_add_fw_prefix_name()
6592 switch (pci_priv->device_id) { in cnss_pci_add_fw_prefix_name()
6625 static int cnss_pci_update_fw_name(struct cnss_pci_data *pci_priv) in cnss_pci_update_fw_name() argument
6627 struct cnss_plat_data *plat_priv = pci_priv->plat_priv; in cnss_pci_update_fw_name()
6629 switch (pci_priv->device_id) { in cnss_pci_update_fw_name()
6633 pci_priv->device_id, in cnss_pci_update_fw_name()
6637 cnss_pci_add_fw_prefix_name(pci_priv, plat_priv->firmware_name, in cnss_pci_update_fw_name()
6648 cnss_pci_add_fw_prefix_name(pci_priv, in cnss_pci_update_fw_name()
6656 cnss_pci_add_fw_prefix_name(pci_priv, in cnss_pci_update_fw_name()
6666 cnss_pci_add_fw_prefix_name(pci_priv, plat_priv->firmware_name, in cnss_pci_update_fw_name()
6704 struct cnss_pci_data *pci_priv = in cnss_dev_rddm_timeout_hdlr() local
6705 from_timer(pci_priv, t, dev_rddm_timer); in cnss_dev_rddm_timeout_hdlr()
6708 if (!pci_priv) in cnss_dev_rddm_timeout_hdlr()
6713 mhi_ee = mhi_get_exec_env(pci_priv->mhi_ctrl); in cnss_dev_rddm_timeout_hdlr()
6719 cnss_schedule_recovery(&pci_priv->pci_dev->dev, in cnss_dev_rddm_timeout_hdlr()
6722 if (!cnss_pci_assert_host_sol(pci_priv)) in cnss_dev_rddm_timeout_hdlr()
6724 cnss_mhi_debug_reg_dump(pci_priv); in cnss_dev_rddm_timeout_hdlr()
6725 cnss_pci_bhi_debug_reg_dump(pci_priv); in cnss_dev_rddm_timeout_hdlr()
6726 cnss_pci_soc_scratch_reg_dump(pci_priv); in cnss_dev_rddm_timeout_hdlr()
6727 cnss_schedule_recovery(&pci_priv->pci_dev->dev, in cnss_dev_rddm_timeout_hdlr()
6734 struct cnss_pci_data *pci_priv = in cnss_boot_debug_timeout_hdlr() local
6735 from_timer(pci_priv, t, boot_debug_timer); in cnss_boot_debug_timeout_hdlr()
6737 if (!pci_priv) in cnss_boot_debug_timeout_hdlr()
6740 if (cnss_pci_check_link_status(pci_priv)) in cnss_boot_debug_timeout_hdlr()
6743 if (cnss_pci_is_device_down(&pci_priv->pci_dev->dev)) in cnss_boot_debug_timeout_hdlr()
6746 if (test_bit(CNSS_MHI_POWER_ON, &pci_priv->mhi_state)) in cnss_boot_debug_timeout_hdlr()
6749 if (cnss_mhi_scan_rddm_cookie(pci_priv, DEVICE_RDDM_COOKIE)) in cnss_boot_debug_timeout_hdlr()
6754 cnss_mhi_debug_reg_dump(pci_priv); in cnss_boot_debug_timeout_hdlr()
6755 cnss_pci_bhi_debug_reg_dump(pci_priv); in cnss_boot_debug_timeout_hdlr()
6756 cnss_pci_soc_scratch_reg_dump(pci_priv); in cnss_boot_debug_timeout_hdlr()
6757 cnss_pci_dump_bl_sram_mem(pci_priv); in cnss_boot_debug_timeout_hdlr()
6759 mod_timer(&pci_priv->boot_debug_timer, in cnss_boot_debug_timeout_hdlr()
6763 static int cnss_pci_handle_mhi_sys_err(struct cnss_pci_data *pci_priv) in cnss_pci_handle_mhi_sys_err() argument
6765 struct cnss_plat_data *plat_priv = pci_priv->plat_priv; in cnss_pci_handle_mhi_sys_err()
6770 reinit_completion(&pci_priv->wake_event_complete); in cnss_pci_handle_mhi_sys_err()
6771 mod_timer(&pci_priv->dev_rddm_timer, in cnss_pci_handle_mhi_sys_err()
6773 cnss_pci_update_status(pci_priv, CNSS_FW_DOWN); in cnss_pci_handle_mhi_sys_err()
6778 int cnss_pci_handle_dev_sol_irq(struct cnss_pci_data *pci_priv) in cnss_pci_handle_dev_sol_irq() argument
6780 return cnss_pci_handle_mhi_sys_err(pci_priv); in cnss_pci_handle_dev_sol_irq()
6786 struct cnss_pci_data *pci_priv = dev_get_drvdata(mhi_ctrl->cntrl_dev); in cnss_mhi_notify_status() local
6790 if (!pci_priv) { in cnss_mhi_notify_status()
6795 plat_priv = pci_priv->plat_priv; in cnss_mhi_notify_status()
6809 cnss_pci_update_status(pci_priv, CNSS_FW_DOWN); in cnss_mhi_notify_status()
6813 cnss_pci_handle_mhi_sys_err(pci_priv); in cnss_mhi_notify_status()
6819 del_timer(&pci_priv->dev_rddm_timer); in cnss_mhi_notify_status()
6820 cnss_pci_update_status(pci_priv, CNSS_FW_DOWN); in cnss_mhi_notify_status()
6827 cnss_pci_update_fw_name(pci_priv); in cnss_mhi_notify_status()
6836 cnss_schedule_recovery(&pci_priv->pci_dev->dev, cnss_reason); in cnss_mhi_notify_status()
6839 static int cnss_pci_get_mhi_msi(struct cnss_pci_data *pci_priv) in cnss_pci_get_mhi_msi() argument
6847 ret = cnss_get_user_msi_assignment(&pci_priv->pci_dev->dev, in cnss_pci_get_mhi_msi()
6853 if (cnss_pci_is_one_msi(pci_priv)) { in cnss_pci_get_mhi_msi()
6855 num_vectors = cnss_pci_get_one_msi_mhi_irq_array_size(pci_priv); in cnss_pci_get_mhi_msi()
6868 irq[i] = cnss_get_msi_irq(&pci_priv->pci_dev->dev, msi_data); in cnss_pci_get_mhi_msi()
6871 pci_priv->mhi_ctrl->irq = irq; in cnss_pci_get_mhi_msi()
6872 pci_priv->mhi_ctrl->nr_irqs = num_vectors; in cnss_pci_get_mhi_msi()
6880 struct cnss_pci_data *pci_priv = dev_get_drvdata(mhi_ctrl->cntrl_dev); in cnss_mhi_bw_scale() local
6881 struct cnss_plat_data *plat_priv = pci_priv->plat_priv; in cnss_mhi_bw_scale()
6893 ret = cnss_pci_set_max_link_speed(pci_priv, plat_priv->rc_num, in cnss_mhi_bw_scale()
6899 ret = cnss_pci_set_link_bandwidth(pci_priv, in cnss_mhi_bw_scale()
6908 pci_priv->def_link_speed = link_info->target_link_speed; in cnss_mhi_bw_scale()
6909 pci_priv->def_link_width = link_info->target_link_width; in cnss_mhi_bw_scale()
6917 struct cnss_pci_data *pci_priv = dev_get_drvdata(mhi_ctrl->cntrl_dev); in cnss_mhi_read_reg() local
6923 cnss_pci_check_link_status(pci_priv)) in cnss_mhi_read_reg()
7011 static bool cnss_is_tme_supported(struct cnss_pci_data *pci_priv) in cnss_is_tme_supported() argument
7013 if (!pci_priv) { in cnss_is_tme_supported()
7018 switch (pci_priv->device_id) { in cnss_is_tme_supported()
7026 static int cnss_pci_register_mhi(struct cnss_pci_data *pci_priv) in cnss_pci_register_mhi() argument
7029 struct cnss_plat_data *plat_priv = pci_priv->plat_priv; in cnss_pci_register_mhi()
7030 struct pci_dev *pci_dev = pci_priv->pci_dev; in cnss_pci_register_mhi()
7040 if (pci_priv->device_id == QCA6174_DEVICE_ID) in cnss_pci_register_mhi()
7049 pci_priv->mhi_ctrl = mhi_ctrl; in cnss_pci_register_mhi()
7058 mhi_ctrl->regs = pci_priv->bar; in cnss_pci_register_mhi()
7059 mhi_ctrl->reg_len = pci_resource_len(pci_priv->pci_dev, PCI_BAR_NUM); in cnss_pci_register_mhi()
7060 bar_start = pci_resource_start(pci_priv->pci_dev, PCI_BAR_NUM); in cnss_pci_register_mhi()
7064 ret = cnss_pci_get_mhi_msi(pci_priv); in cnss_pci_register_mhi()
7070 if (cnss_pci_is_one_msi(pci_priv)) in cnss_pci_register_mhi()
7073 if (pci_priv->smmu_s1_enable) { in cnss_pci_register_mhi()
7074 mhi_ctrl->iova_start = pci_priv->smmu_iova_start; in cnss_pci_register_mhi()
7075 mhi_ctrl->iova_stop = pci_priv->smmu_iova_start + in cnss_pci_register_mhi()
7076 pci_priv->smmu_iova_len; in cnss_pci_register_mhi()
7079 mhi_ctrl->iova_stop = pci_priv->dma_bit_mask; in cnss_pci_register_mhi()
7088 mhi_ctrl->rddm_size = pci_priv->plat_priv->ramdump_info_v2.ramdump_size; in cnss_pci_register_mhi()
7119 mhi_ctrl->tme_supported_image = cnss_is_tme_supported(pci_priv); in cnss_pci_register_mhi()
7128 if (cnss_pci_get_drv_supported(pci_priv)) in cnss_pci_register_mhi()
7129 cnss_mhi_controller_set_base(pci_priv, bar_start); in cnss_pci_register_mhi()
7136 cnss_mhi_controller_set_bw_scale_cb(pci_priv, in cnss_pci_register_mhi()
7139 ret = cnss_pci_update_fw_name(pci_priv); in cnss_pci_register_mhi()
7155 static void cnss_pci_unregister_mhi(struct cnss_pci_data *pci_priv) in cnss_pci_unregister_mhi() argument
7157 struct mhi_controller *mhi_ctrl = pci_priv->mhi_ctrl; in cnss_pci_unregister_mhi()
7159 if (pci_priv->device_id == QCA6174_DEVICE_ID) in cnss_pci_unregister_mhi()
7166 pci_priv->mhi_ctrl = NULL; in cnss_pci_unregister_mhi()
7169 static void cnss_pci_config_regs(struct cnss_pci_data *pci_priv) in cnss_pci_config_regs() argument
7171 switch (pci_priv->device_id) { in cnss_pci_config_regs()
7173 pci_priv->misc_reg_dev_mask = REG_MASK_QCA6390; in cnss_pci_config_regs()
7174 pci_priv->wcss_reg = wcss_reg_access_seq; in cnss_pci_config_regs()
7175 pci_priv->pcie_reg = pcie_reg_access_seq; in cnss_pci_config_regs()
7176 pci_priv->wlaon_reg = wlaon_reg_access_seq; in cnss_pci_config_regs()
7177 pci_priv->syspm_reg = syspm_reg_access_seq; in cnss_pci_config_regs()
7184 (pci_priv, in cnss_pci_config_regs()
7189 pci_priv->misc_reg_dev_mask = REG_MASK_QCA6490; in cnss_pci_config_regs()
7190 pci_priv->wlaon_reg = wlaon_reg_access_seq; in cnss_pci_config_regs()
7198 static int cnss_pci_of_reserved_mem_device_init(struct cnss_pci_data *pci_priv) in cnss_pci_of_reserved_mem_device_init() argument
7205 struct cnss_pci_data *pci_priv = data; in cnss_pci_wake_handler() local
7206 struct cnss_plat_data *plat_priv = pci_priv->plat_priv; in cnss_pci_wake_handler()
7210 pci_priv->wake_counter++; in cnss_pci_wake_handler()
7212 pci_priv->wake_irq, pci_priv->wake_counter); in cnss_pci_wake_handler()
7224 dev = &pci_priv->pci_dev->dev; in cnss_pci_wake_handler()
7227 if ((cnss_pci_get_monitor_wake_intr(pci_priv) && in cnss_pci_wake_handler()
7228 cnss_pci_get_auto_suspended(pci_priv)) || in cnss_pci_wake_handler()
7230 cnss_pci_set_monitor_wake_intr(pci_priv, false); in cnss_pci_wake_handler()
7231 cnss_pci_pm_request_resume(pci_priv); in cnss_pci_wake_handler()
7247 static int cnss_pci_wake_gpio_init(struct cnss_pci_data *pci_priv) in cnss_pci_wake_gpio_init() argument
7249 struct cnss_plat_data *plat_priv = pci_priv->plat_priv; in cnss_pci_wake_gpio_init()
7253 pci_priv->wake_gpio = of_get_named_gpio(dev->of_node, in cnss_pci_wake_gpio_init()
7255 if (pci_priv->wake_gpio < 0) in cnss_pci_wake_gpio_init()
7259 pci_priv->wake_gpio); in cnss_pci_wake_gpio_init()
7261 ret = gpio_request(pci_priv->wake_gpio, "wlan_pci_wake_gpio"); in cnss_pci_wake_gpio_init()
7268 gpio_direction_input(pci_priv->wake_gpio); in cnss_pci_wake_gpio_init()
7269 pci_priv->wake_irq = gpio_to_irq(pci_priv->wake_gpio); in cnss_pci_wake_gpio_init()
7271 ret = request_irq(pci_priv->wake_irq, cnss_pci_wake_handler, in cnss_pci_wake_gpio_init()
7272 IRQF_TRIGGER_FALLING, "wlan_pci_wake_irq", pci_priv); in cnss_pci_wake_gpio_init()
7278 ret = enable_irq_wake(pci_priv->wake_irq); in cnss_pci_wake_gpio_init()
7287 free_irq(pci_priv->wake_irq, pci_priv); in cnss_pci_wake_gpio_init()
7289 gpio_free(pci_priv->wake_gpio); in cnss_pci_wake_gpio_init()
7294 static void cnss_pci_wake_gpio_deinit(struct cnss_pci_data *pci_priv) in cnss_pci_wake_gpio_deinit() argument
7296 if (pci_priv->wake_gpio < 0) in cnss_pci_wake_gpio_deinit()
7299 disable_irq_wake(pci_priv->wake_irq); in cnss_pci_wake_gpio_deinit()
7300 free_irq(pci_priv->wake_irq, pci_priv); in cnss_pci_wake_gpio_deinit()
7301 gpio_free(pci_priv->wake_gpio); in cnss_pci_wake_gpio_deinit()
7328 struct cnss_pci_data *pci_priv = plat_priv->bus_priv; in cnss_try_suspend() local
7329 struct pci_dev *pci_dev = pci_priv->pci_dev; in cnss_try_suspend()
7333 cnss_pci_set_wlaon_pwr_ctrl(pci_priv, in cnss_try_suspend()
7455 cnss_pci_restore_rc_speed(struct cnss_pci_data *pci_priv) in cnss_pci_restore_rc_speed() argument
7459 struct cnss_plat_data *plat_priv = pci_priv->plat_priv; in cnss_pci_restore_rc_speed()
7461 switch (pci_priv->device_id) { in cnss_pci_restore_rc_speed()
7475 ret = cnss_pci_set_max_link_speed(pci_priv, plat_priv->rc_num, link_speed); in cnss_pci_restore_rc_speed()
7482 cnss_pci_link_retrain_trigger(struct cnss_pci_data *pci_priv) in cnss_pci_link_retrain_trigger() argument
7487 ret = cnss_suspend_pci_link(pci_priv); in cnss_pci_link_retrain_trigger()
7491 ret = cnss_resume_pci_link(pci_priv); in cnss_pci_link_retrain_trigger()
7495 cnss_pci_get_link_status(pci_priv); in cnss_pci_link_retrain_trigger()
7504 cnss_pci_restore_rc_speed(struct cnss_pci_data *pci_priv) in cnss_pci_restore_rc_speed() argument
7509 cnss_pci_link_retrain_trigger(struct cnss_pci_data *pci_priv) in cnss_pci_link_retrain_trigger() argument
7516 struct cnss_pci_data *pci_priv = cnss_get_pci_priv(pci_dev); in cnss_pci_suspend_pwroff() local
7525 ret = cnss_suspend_pci_link(pci_priv); in cnss_pci_suspend_pwroff()
7533 cnss_pci_link_retrain_trigger(pci_priv); in cnss_pci_suspend_pwroff()
7541 struct cnss_pci_data *pci_priv; in cnss_pci_probe() local
7554 pci_priv = devm_kzalloc(dev, sizeof(*pci_priv), GFP_KERNEL); in cnss_pci_probe()
7555 if (!pci_priv) { in cnss_pci_probe()
7560 pci_priv->pci_link_state = PCI_LINK_UP; in cnss_pci_probe()
7561 pci_priv->plat_priv = plat_priv; in cnss_pci_probe()
7562 pci_priv->pci_dev = pci_dev; in cnss_pci_probe()
7563 pci_priv->pci_device_id = id; in cnss_pci_probe()
7564 pci_priv->device_id = pci_dev->device; in cnss_pci_probe()
7565 cnss_set_pci_priv(pci_dev, pci_priv); in cnss_pci_probe()
7567 plat_priv->bus_priv = pci_priv; in cnss_pci_probe()
7568 mutex_init(&pci_priv->bus_lock); in cnss_pci_probe()
7572 cnss_pci_restore_rc_speed(pci_priv); in cnss_pci_probe()
7586 cnss_pci_of_reserved_mem_device_init(pci_priv); in cnss_pci_probe()
7596 ret = cnss_pci_init_smmu(pci_priv); in cnss_pci_probe()
7601 cnss_pci_update_drv_supported(pci_priv); in cnss_pci_probe()
7603 cnss_update_supported_link_info(pci_priv); in cnss_pci_probe()
7605 init_completion(&pci_priv->wake_event_complete); in cnss_pci_probe()
7607 ret = cnss_reg_pci_event(pci_priv); in cnss_pci_probe()
7613 ret = cnss_pci_enable_bus(pci_priv); in cnss_pci_probe()
7617 ret = cnss_pci_enable_msi(pci_priv); in cnss_pci_probe()
7621 ret = cnss_pci_register_mhi(pci_priv); in cnss_pci_probe()
7628 &pci_priv->revision_id); in cnss_pci_probe()
7639 cnss_pci_set_wlaon_pwr_ctrl(pci_priv, false, false, in cnss_pci_probe()
7642 timer_setup(&pci_priv->dev_rddm_timer, in cnss_pci_probe()
7644 timer_setup(&pci_priv->boot_debug_timer, in cnss_pci_probe()
7646 INIT_DELAYED_WORK(&pci_priv->time_sync_work, in cnss_pci_probe()
7648 cnss_pci_get_link_status(pci_priv); in cnss_pci_probe()
7649 cnss_pci_set_wlaon_pwr_ctrl(pci_priv, false, true, false); in cnss_pci_probe()
7650 cnss_pci_wake_gpio_init(pci_priv); in cnss_pci_probe()
7659 cnss_pci_config_regs(pci_priv); in cnss_pci_probe()
7672 cnss_pci_unregister_mhi(pci_priv); in cnss_pci_probe()
7674 cnss_pci_disable_msi(pci_priv); in cnss_pci_probe()
7676 cnss_pci_disable_bus(pci_priv); in cnss_pci_probe()
7678 cnss_dereg_pci_event(pci_priv); in cnss_pci_probe()
7680 cnss_pci_deinit_smmu(pci_priv); in cnss_pci_probe()
7693 struct cnss_pci_data *pci_priv = cnss_get_pci_priv(pci_dev); in cnss_pci_remove() local
7698 cnss_pci_unregister_driver_hdlr(pci_priv); in cnss_pci_remove()
7699 cnss_pci_free_aux_mem(pci_priv); in cnss_pci_remove()
7700 cnss_pci_free_tme_lite_mem(pci_priv); in cnss_pci_remove()
7701 cnss_pci_free_tme_opt_file_mem(pci_priv); in cnss_pci_remove()
7702 cnss_pci_free_m3_mem(pci_priv); in cnss_pci_remove()
7703 cnss_pci_free_fw_mem(pci_priv); in cnss_pci_remove()
7704 cnss_pci_free_qdss_mem(pci_priv); in cnss_pci_remove()
7714 cnss_pci_wake_gpio_deinit(pci_priv); in cnss_pci_remove()
7715 del_timer(&pci_priv->boot_debug_timer); in cnss_pci_remove()
7716 del_timer(&pci_priv->dev_rddm_timer); in cnss_pci_remove()
7722 cnss_pci_unregister_mhi(pci_priv); in cnss_pci_remove()
7723 cnss_pci_disable_msi(pci_priv); in cnss_pci_remove()
7724 cnss_pci_disable_bus(pci_priv); in cnss_pci_remove()
7725 cnss_dereg_pci_event(pci_priv); in cnss_pci_remove()
7726 cnss_pci_deinit_smmu(pci_priv); in cnss_pci_remove()