Lines Matching refs:priv
135 static void icnss_set_plat_priv(struct icnss_priv *priv) in icnss_set_plat_priv() argument
137 penv = priv; in icnss_set_plat_priv()
145 static inline void icnss_wpss_unload(struct icnss_priv *priv) in icnss_wpss_unload() argument
147 if (priv && priv->rproc) { in icnss_wpss_unload()
148 rproc_shutdown(priv->rproc); in icnss_wpss_unload()
149 rproc_put(priv->rproc); in icnss_wpss_unload()
150 priv->rproc = NULL; in icnss_wpss_unload()
158 struct icnss_priv *priv = icnss_get_plat_priv(); in icnss_sysfs_store() local
160 if (!priv) in icnss_sysfs_store()
165 atomic_set(&priv->is_shutdown, true); in icnss_sysfs_store()
166 if ((priv->wpss_supported || priv->rproc_fw_download) && in icnss_sysfs_store()
167 priv->device_id == ADRASTEA_DEVICE_ID) in icnss_sysfs_store()
168 icnss_wpss_unload(priv); in icnss_sysfs_store()
175 static void icnss_pm_stay_awake(struct icnss_priv *priv) in icnss_pm_stay_awake() argument
177 if (atomic_inc_return(&priv->pm_count) != 1) in icnss_pm_stay_awake()
180 icnss_pr_vdbg("PM stay awake, state: 0x%lx, count: %d\n", priv->state, in icnss_pm_stay_awake()
181 atomic_read(&priv->pm_count)); in icnss_pm_stay_awake()
183 pm_stay_awake(&priv->pdev->dev); in icnss_pm_stay_awake()
185 priv->stats.pm_stay_awake++; in icnss_pm_stay_awake()
188 static void icnss_pm_relax(struct icnss_priv *priv) in icnss_pm_relax() argument
190 int r = atomic_dec_return(&priv->pm_count); in icnss_pm_relax()
197 icnss_pr_vdbg("PM relax, state: 0x%lx, count: %d\n", priv->state, in icnss_pm_relax()
198 atomic_read(&priv->pm_count)); in icnss_pm_relax()
200 pm_relax(&priv->pdev->dev); in icnss_pm_relax()
201 priv->stats.pm_relax++; in icnss_pm_relax()
264 int icnss_driver_event_post(struct icnss_priv *priv, in icnss_driver_event_post() argument
273 if (!priv) in icnss_driver_event_post()
278 flags, priv->state); in icnss_driver_event_post()
292 icnss_pm_stay_awake(priv); in icnss_driver_event_post()
300 spin_lock_irqsave(&priv->event_lock, irq_flags); in icnss_driver_event_post()
301 list_add_tail(&event->list, &priv->event_list); in icnss_driver_event_post()
302 spin_unlock_irqrestore(&priv->event_lock, irq_flags); in icnss_driver_event_post()
304 priv->stats.events[type].posted++; in icnss_driver_event_post()
305 queue_work(priv->event_wq, &priv->event_work); in icnss_driver_event_post()
316 icnss_driver_event_to_str(type), type, priv->state, ret, in icnss_driver_event_post()
319 spin_lock_irqsave(&priv->event_lock, irq_flags); in icnss_driver_event_post()
322 spin_unlock_irqrestore(&priv->event_lock, irq_flags); in icnss_driver_event_post()
326 spin_unlock_irqrestore(&priv->event_lock, irq_flags); in icnss_driver_event_post()
332 icnss_pm_relax(priv); in icnss_driver_event_post()
336 int icnss_soc_wake_event_post(struct icnss_priv *priv, in icnss_soc_wake_event_post() argument
345 if (!priv) in icnss_soc_wake_event_post()
350 type, current->comm, flags, priv->state); in icnss_soc_wake_event_post()
364 icnss_pm_stay_awake(priv); in icnss_soc_wake_event_post()
372 spin_lock_irqsave(&priv->soc_wake_msg_lock, irq_flags); in icnss_soc_wake_event_post()
373 list_add_tail(&event->list, &priv->soc_wake_msg_list); in icnss_soc_wake_event_post()
374 spin_unlock_irqrestore(&priv->soc_wake_msg_lock, irq_flags); in icnss_soc_wake_event_post()
376 priv->stats.soc_wake_events[type].posted++; in icnss_soc_wake_event_post()
377 queue_work(priv->soc_wake_wq, &priv->soc_wake_msg_work); in icnss_soc_wake_event_post()
389 type, priv->state, ret, event->ret); in icnss_soc_wake_event_post()
391 spin_lock_irqsave(&priv->soc_wake_msg_lock, irq_flags); in icnss_soc_wake_event_post()
394 spin_unlock_irqrestore(&priv->soc_wake_msg_lock, irq_flags); in icnss_soc_wake_event_post()
398 spin_unlock_irqrestore(&priv->soc_wake_msg_lock, irq_flags); in icnss_soc_wake_event_post()
404 icnss_pm_relax(priv); in icnss_soc_wake_event_post()
435 struct icnss_priv *priv = icnss_get_plat_priv(); in icnss_is_fw_down() local
437 if (!priv) in icnss_is_fw_down()
440 return test_bit(ICNSS_FW_DOWN, &priv->state) || in icnss_is_fw_down()
441 test_bit(ICNSS_PD_RESTART, &priv->state) || in icnss_is_fw_down()
442 test_bit(ICNSS_REJUVENATE, &priv->state); in icnss_is_fw_down()
448 struct icnss_priv *priv = icnss_get_plat_priv(); in icnss_get_device_config() local
450 if (!priv) in icnss_get_device_config()
453 return priv->device_config; in icnss_get_device_config()
475 static bool icnss_is_smp2p_valid(struct icnss_priv *priv, in icnss_is_smp2p_valid() argument
478 if (priv->device_id == WCN6750_DEVICE_ID || in icnss_is_smp2p_valid()
479 priv->device_id == WCN6450_DEVICE_ID || in icnss_is_smp2p_valid()
480 priv->wpss_supported) in icnss_is_smp2p_valid()
481 return IS_ERR_OR_NULL(priv->smp2p_info[smp2p_entry].smem_state); in icnss_is_smp2p_valid()
486 static int icnss_send_smp2p(struct icnss_priv *priv, in icnss_send_smp2p() argument
493 if (!priv || icnss_is_smp2p_valid(priv, smp2p_entry)) in icnss_send_smp2p()
498 priv->smp2p_info[smp2p_entry].seq = 0; in icnss_send_smp2p()
500 priv->smp2p_info[smp2p_entry].smem_state, in icnss_send_smp2p()
510 if (test_bit(ICNSS_FW_DOWN, &priv->state) || in icnss_send_smp2p()
511 !test_bit(ICNSS_FW_READY, &priv->state)) { in icnss_send_smp2p()
513 priv->state); in icnss_send_smp2p()
517 value |= priv->smp2p_info[smp2p_entry].seq++; in icnss_send_smp2p()
527 priv->smp2p_info[smp2p_entry].smem_state, in icnss_send_smp2p()
537 &priv->smp2p_soc_wake_wait, in icnss_send_smp2p()
541 if (!test_bit(ICNSS_FW_DOWN, &priv->state)) in icnss_send_smp2p()
561 struct icnss_priv *priv = ctx; in fw_error_fatal_handler() local
563 if (priv) in fw_error_fatal_handler()
564 priv->force_err_fatal = true; in fw_error_fatal_handler()
573 struct icnss_priv *priv = ctx; in fw_crash_indication_handler() local
578 if (priv) { in fw_crash_indication_handler()
579 if (priv->wpss_self_recovery_enabled) in fw_crash_indication_handler()
580 mod_timer(&priv->wpss_ssr_timer, in fw_crash_indication_handler()
583 set_bit(ICNSS_FW_DOWN, &priv->state); in fw_crash_indication_handler()
586 if (test_bit(ICNSS_FW_READY, &priv->state)) { in fw_crash_indication_handler()
587 clear_bit(ICNSS_FW_READY, &priv->state); in fw_crash_indication_handler()
589 icnss_call_driver_uevent(priv, ICNSS_UEVENT_FW_DOWN, in fw_crash_indication_handler()
594 icnss_driver_event_post(priv, ICNSS_DRIVER_EVENT_FW_EARLY_CRASH_IND, in fw_crash_indication_handler()
602 struct icnss_priv *priv = dev_get_drvdata(dev); in register_fw_error_notifications() local
606 if (!priv) in register_fw_error_notifications()
629 "wlanfw-err", priv); in register_fw_error_notifications()
636 priv->fw_error_fatal_irq = irq; in register_fw_error_notifications()
641 struct icnss_priv *priv = dev_get_drvdata(dev); in register_early_crash_notifications() local
645 if (!priv) in register_early_crash_notifications()
669 "wlanfw-early-crash-ind", priv); in register_early_crash_notifications()
676 priv->fw_early_crash_irq = irq; in register_early_crash_notifications()
679 static int icnss_get_temperature(struct icnss_priv *priv, int *temp) in icnss_get_temperature() argument
685 ret = of_property_read_string(priv->pdev->dev.of_node, in icnss_get_temperature()
708 struct icnss_priv *priv = ctx; in fw_soc_wake_ack_handler() local
710 if (priv) in fw_soc_wake_ack_handler()
711 complete(&priv->smp2p_soc_wake_wait); in fw_soc_wake_ack_handler()
718 struct icnss_priv *priv = dev_get_drvdata(dev); in register_soc_wake_notif() local
722 if (!priv) in register_soc_wake_notif()
747 "wlanfw-soc-wake-ack", priv); in register_soc_wake_notif()
754 priv->fw_soc_wake_ack_irq = irq; in register_soc_wake_notif()
758 int icnss_call_driver_uevent(struct icnss_priv *priv, in icnss_call_driver_uevent() argument
763 if (!priv->ops || !priv->ops->uevent) in icnss_call_driver_uevent()
767 priv->state, uevent); in icnss_call_driver_uevent()
772 return priv->ops->uevent(&priv->pdev->dev, &uevent_data); in icnss_call_driver_uevent()
775 static int icnss_setup_dms_mac(struct icnss_priv *priv) in icnss_setup_dms_mac() argument
780 ret = icnss_qmi_get_dms_mac(priv); in icnss_setup_dms_mac()
781 if (ret == 0 && priv->dms.mac_valid) in icnss_setup_dms_mac()
787 if (priv->use_nv_mac) { in icnss_setup_dms_mac()
789 if (priv->dms.mac_valid) in icnss_setup_dms_mac()
792 ret = icnss_qmi_get_dms_mac(priv); in icnss_setup_dms_mac()
797 if (!priv->dms.nv_mac_not_prov && !priv->dms.mac_valid) { in icnss_setup_dms_mac()
804 if (priv->dms.mac_valid) in icnss_setup_dms_mac()
806 icnss_wlfw_wlan_mac_req_send_sync(priv, priv->dms.mac, in icnss_setup_dms_mac()
807 ARRAY_SIZE(priv->dms.mac)); in icnss_setup_dms_mac()
811 static void icnss_get_smp2p_info(struct icnss_priv *priv, in icnss_get_smp2p_info() argument
817 if (priv->smp2p_info[smp2p_entry].smem_state) in icnss_get_smp2p_info()
820 priv->smp2p_info[smp2p_entry].smem_state = in icnss_get_smp2p_info()
821 qcom_smem_state_get(&priv->pdev->dev, in icnss_get_smp2p_info()
823 &priv->smp2p_info[smp2p_entry].smem_bit); in icnss_get_smp2p_info()
824 if (icnss_is_smp2p_valid(priv, smp2p_entry)) { in icnss_get_smp2p_info()
826 error = PTR_ERR(priv->smp2p_info[smp2p_entry].smem_state); in icnss_get_smp2p_info()
840 void icnss_set_wlan_en_delay(struct icnss_priv *priv) in icnss_set_wlan_en_delay() argument
842 if (priv->wlan_en_delay_ms_user > WLAN_EN_DELAY) { in icnss_set_wlan_en_delay()
843 priv->wlan_en_delay_ms = priv->wlan_en_delay_ms_user; in icnss_set_wlan_en_delay()
845 priv->wlan_en_delay_ms = WLAN_EN_DELAY; in icnss_set_wlan_en_delay()
874 static int icnss_wait_for_slate_complete(struct icnss_priv *priv) in icnss_wait_for_slate_complete() argument
876 if (!test_bit(ICNSS_SLATE_UP, &priv->state)) { in icnss_wait_for_slate_complete()
877 reinit_completion(&priv->slate_boot_complete); in icnss_wait_for_slate_complete()
879 priv->state); in icnss_wait_for_slate_complete()
880 wait_for_completion(&priv->slate_boot_complete); in icnss_wait_for_slate_complete()
883 if (!test_bit(ICNSS_SLATE_UP, &priv->state)) in icnss_wait_for_slate_complete()
895 static int icnss_wait_for_slate_complete(struct icnss_priv *priv) in icnss_wait_for_slate_complete() argument
901 static int icnss_driver_event_server_arrive(struct icnss_priv *priv, in icnss_driver_event_server_arrive() argument
909 if (!priv) in icnss_driver_event_server_arrive()
912 set_bit(ICNSS_WLFW_EXISTS, &priv->state); in icnss_driver_event_server_arrive()
913 clear_bit(ICNSS_FW_DOWN, &priv->state); in icnss_driver_event_server_arrive()
914 clear_bit(ICNSS_FW_READY, &priv->state); in icnss_driver_event_server_arrive()
916 if (priv->is_slate_rfa) { in icnss_driver_event_server_arrive()
917 ret = icnss_wait_for_slate_complete(priv); in icnss_driver_event_server_arrive()
926 if (test_bit(ICNSS_WLFW_CONNECTED, &priv->state)) { in icnss_driver_event_server_arrive()
931 ret = icnss_connect_to_fw_server(priv, data); in icnss_driver_event_server_arrive()
935 set_bit(ICNSS_WLFW_CONNECTED, &priv->state); in icnss_driver_event_server_arrive()
937 if (priv->device_id == ADRASTEA_DEVICE_ID) { in icnss_driver_event_server_arrive()
938 ret = icnss_hw_power_on(priv); in icnss_driver_event_server_arrive()
943 ret = wlfw_ind_register_send_sync_msg(priv); in icnss_driver_event_server_arrive()
953 if (priv->is_rf_subtype_valid) { in icnss_driver_event_server_arrive()
954 rf_subtype = icnss_rf_subtype_value_to_type(priv->rf_subtype); in icnss_driver_event_server_arrive()
956 ret = wlfw_wlan_hw_init_cfg_msg(priv, rf_subtype); in icnss_driver_event_server_arrive()
962 priv->rf_subtype); in icnss_driver_event_server_arrive()
966 if (priv->device_id == WCN6750_DEVICE_ID || in icnss_driver_event_server_arrive()
967 priv->device_id == WCN6450_DEVICE_ID) { in icnss_driver_event_server_arrive()
968 if (!icnss_get_temperature(priv, &temp)) { in icnss_driver_event_server_arrive()
971 icnss_set_wlan_en_delay(priv); in icnss_driver_event_server_arrive()
974 ret = wlfw_host_cap_send_sync(priv); in icnss_driver_event_server_arrive()
979 if (priv->device_id == ADRASTEA_DEVICE_ID) { in icnss_driver_event_server_arrive()
980 if (!priv->msa_va) { in icnss_driver_event_server_arrive()
986 ret = wlfw_msa_mem_info_send_sync_msg(priv); in icnss_driver_event_server_arrive()
992 ret = wlfw_msa_ready_send_sync_msg(priv); in icnss_driver_event_server_arrive()
999 if (priv->device_id == WCN6450_DEVICE_ID) in icnss_driver_event_server_arrive()
1000 icnss_hw_power_off(priv); in icnss_driver_event_server_arrive()
1002 ret = wlfw_cap_send_sync_msg(priv); in icnss_driver_event_server_arrive()
1008 if (priv->device_id == ADRASTEA_DEVICE_ID && priv->is_chain1_supported) { in icnss_driver_event_server_arrive()
1009 ret = icnss_power_on_chain1_reg(priv); in icnss_driver_event_server_arrive()
1016 if (priv->device_id == WCN6750_DEVICE_ID || in icnss_driver_event_server_arrive()
1017 priv->device_id == WCN6450_DEVICE_ID) { in icnss_driver_event_server_arrive()
1018 ret = icnss_hw_power_on(priv); in icnss_driver_event_server_arrive()
1022 ret = wlfw_device_info_send_msg(priv); in icnss_driver_event_server_arrive()
1028 priv->mem_base_va = devm_ioremap(&priv->pdev->dev, in icnss_driver_event_server_arrive()
1029 priv->mem_base_pa, in icnss_driver_event_server_arrive()
1030 priv->mem_base_size); in icnss_driver_event_server_arrive()
1031 if (!priv->mem_base_va) { in icnss_driver_event_server_arrive()
1037 &priv->mem_base_pa, in icnss_driver_event_server_arrive()
1038 priv->mem_base_va); in icnss_driver_event_server_arrive()
1040 if (priv->mhi_state_info_pa) in icnss_driver_event_server_arrive()
1041 priv->mhi_state_info_va = devm_ioremap(&priv->pdev->dev, in icnss_driver_event_server_arrive()
1042 priv->mhi_state_info_pa, in icnss_driver_event_server_arrive()
1044 if (!priv->mhi_state_info_va) in icnss_driver_event_server_arrive()
1048 &priv->mhi_state_info_pa, in icnss_driver_event_server_arrive()
1049 priv->mhi_state_info_va); in icnss_driver_event_server_arrive()
1052 if (priv->bdf_download_support) { in icnss_driver_event_server_arrive()
1053 icnss_wlfw_bdf_dnld_send_sync(priv, ICNSS_BDF_REGDB); in icnss_driver_event_server_arrive()
1055 ret = icnss_wlfw_bdf_dnld_send_sync(priv, in icnss_driver_event_server_arrive()
1056 priv->ctrl_params.bdf_type); in icnss_driver_event_server_arrive()
1061 if (priv->device_id == WCN6450_DEVICE_ID) { in icnss_driver_event_server_arrive()
1062 ret = icnss_wlfw_qdss_dnld_send_sync(priv); in icnss_driver_event_server_arrive()
1068 if (priv->device_id == WCN6750_DEVICE_ID || in icnss_driver_event_server_arrive()
1069 priv->device_id == WCN6450_DEVICE_ID) { in icnss_driver_event_server_arrive()
1070 if (!priv->fw_soc_wake_ack_irq) in icnss_driver_event_server_arrive()
1071 register_soc_wake_notif(&priv->pdev->dev); in icnss_driver_event_server_arrive()
1073 icnss_get_smp2p_info(priv, ICNSS_SMP2P_OUT_SOC_WAKE); in icnss_driver_event_server_arrive()
1074 icnss_get_smp2p_info(priv, ICNSS_SMP2P_OUT_EP_POWER_SAVE); in icnss_driver_event_server_arrive()
1077 if (priv->wpss_supported) in icnss_driver_event_server_arrive()
1078 icnss_get_smp2p_info(priv, ICNSS_SMP2P_OUT_POWER_SAVE); in icnss_driver_event_server_arrive()
1080 if (priv->device_id == ADRASTEA_DEVICE_ID) { in icnss_driver_event_server_arrive()
1081 if (priv->bdf_download_support) { in icnss_driver_event_server_arrive()
1082 ret = wlfw_cal_report_req(priv); in icnss_driver_event_server_arrive()
1087 wlfw_dynamic_feature_mask_send_sync_msg(priv, in icnss_driver_event_server_arrive()
1091 if (!priv->fw_error_fatal_irq) in icnss_driver_event_server_arrive()
1092 register_fw_error_notifications(&priv->pdev->dev); in icnss_driver_event_server_arrive()
1094 if (!priv->fw_early_crash_irq) in icnss_driver_event_server_arrive()
1095 register_early_crash_notifications(&priv->pdev->dev); in icnss_driver_event_server_arrive()
1097 if (priv->psf_supported) in icnss_driver_event_server_arrive()
1098 queue_work(priv->soc_update_wq, &priv->soc_update_work); in icnss_driver_event_server_arrive()
1103 icnss_hw_power_off(priv); in icnss_driver_event_server_arrive()
1110 static int icnss_driver_event_server_exit(struct icnss_priv *priv) in icnss_driver_event_server_exit() argument
1112 if (!priv) in icnss_driver_event_server_exit()
1115 icnss_pr_info("WLAN FW Service Disconnected: 0x%lx\n", priv->state); in icnss_driver_event_server_exit()
1117 icnss_clear_server(priv); in icnss_driver_event_server_exit()
1119 if (priv->psf_supported) in icnss_driver_event_server_exit()
1120 priv->last_updated_voltage = 0; in icnss_driver_event_server_exit()
1125 static int icnss_call_driver_probe(struct icnss_priv *priv) in icnss_call_driver_probe() argument
1130 if (!priv->ops || !priv->ops->probe) in icnss_call_driver_probe()
1133 if (test_bit(ICNSS_DRIVER_PROBED, &priv->state)) in icnss_call_driver_probe()
1136 icnss_pr_dbg("Calling driver probe state: 0x%lx\n", priv->state); in icnss_call_driver_probe()
1138 icnss_hw_power_on(priv); in icnss_call_driver_probe()
1142 ret = priv->ops->probe(&priv->pdev->dev); in icnss_call_driver_probe()
1149 ret, priv->state, probe_cnt); in icnss_call_driver_probe()
1155 set_bit(ICNSS_DRIVER_PROBED, &priv->state); in icnss_call_driver_probe()
1160 icnss_hw_power_off(priv); in icnss_call_driver_probe()
1164 static int icnss_call_driver_shutdown(struct icnss_priv *priv) in icnss_call_driver_shutdown() argument
1166 if (!test_bit(ICNSS_DRIVER_PROBED, &priv->state)) in icnss_call_driver_shutdown()
1169 if (!priv->ops || !priv->ops->shutdown) in icnss_call_driver_shutdown()
1172 if (test_bit(ICNSS_SHUTDOWN_DONE, &priv->state)) in icnss_call_driver_shutdown()
1175 icnss_pr_dbg("Calling driver shutdown state: 0x%lx\n", priv->state); in icnss_call_driver_shutdown()
1177 priv->ops->shutdown(&priv->pdev->dev); in icnss_call_driver_shutdown()
1178 set_bit(ICNSS_SHUTDOWN_DONE, &priv->state); in icnss_call_driver_shutdown()
1184 static int icnss_pd_restart_complete(struct icnss_priv *priv) in icnss_pd_restart_complete() argument
1188 icnss_pm_relax(priv); in icnss_pd_restart_complete()
1190 icnss_call_driver_shutdown(priv); in icnss_pd_restart_complete()
1192 clear_bit(ICNSS_PDR, &priv->state); in icnss_pd_restart_complete()
1193 clear_bit(ICNSS_REJUVENATE, &priv->state); in icnss_pd_restart_complete()
1194 clear_bit(ICNSS_PD_RESTART, &priv->state); in icnss_pd_restart_complete()
1195 clear_bit(ICNSS_LOW_POWER, &priv->state); in icnss_pd_restart_complete()
1196 priv->early_crash_ind = false; in icnss_pd_restart_complete()
1197 priv->is_ssr = false; in icnss_pd_restart_complete()
1199 if (!priv->ops || !priv->ops->reinit) in icnss_pd_restart_complete()
1202 if (test_bit(ICNSS_FW_DOWN, &priv->state)) { in icnss_pd_restart_complete()
1204 priv->state); in icnss_pd_restart_complete()
1208 if (!test_bit(ICNSS_DRIVER_PROBED, &priv->state)) in icnss_pd_restart_complete()
1211 icnss_pr_dbg("Calling driver reinit state: 0x%lx\n", priv->state); in icnss_pd_restart_complete()
1213 icnss_hw_power_on(priv); in icnss_pd_restart_complete()
1217 ret = priv->ops->reinit(&priv->pdev->dev); in icnss_pd_restart_complete()
1220 ret, priv->state); in icnss_pd_restart_complete()
1221 if (!priv->allow_recursive_recovery) in icnss_pd_restart_complete()
1228 clear_bit(ICNSS_SHUTDOWN_DONE, &priv->state); in icnss_pd_restart_complete()
1232 return icnss_call_driver_probe(priv); in icnss_pd_restart_complete()
1235 icnss_hw_power_off(priv); in icnss_pd_restart_complete()
1242 static int icnss_driver_event_fw_ready_ind(struct icnss_priv *priv, void *data) in icnss_driver_event_fw_ready_ind() argument
1246 if (!priv) in icnss_driver_event_fw_ready_ind()
1249 del_timer(&priv->recovery_timer); in icnss_driver_event_fw_ready_ind()
1250 set_bit(ICNSS_FW_READY, &priv->state); in icnss_driver_event_fw_ready_ind()
1251 clear_bit(ICNSS_MODE_ON, &priv->state); in icnss_driver_event_fw_ready_ind()
1252 atomic_set(&priv->soc_wake_ref_count, 0); in icnss_driver_event_fw_ready_ind()
1254 if (priv->device_id == WCN6750_DEVICE_ID || in icnss_driver_event_fw_ready_ind()
1255 priv->device_id == WCN6450_DEVICE_ID) in icnss_driver_event_fw_ready_ind()
1256 icnss_free_qdss_mem(priv); in icnss_driver_event_fw_ready_ind()
1258 icnss_pr_info("WLAN FW is ready: 0x%lx\n", priv->state); in icnss_driver_event_fw_ready_ind()
1260 icnss_hw_power_off(priv); in icnss_driver_event_fw_ready_ind()
1262 if (!priv->pdev) { in icnss_driver_event_fw_ready_ind()
1268 if (priv->is_slate_rfa && test_bit(ICNSS_SLATE_UP, &priv->state)) in icnss_driver_event_fw_ready_ind()
1271 if (test_bit(ICNSS_PD_RESTART, &priv->state)) { in icnss_driver_event_fw_ready_ind()
1272 ret = icnss_pd_restart_complete(priv); in icnss_driver_event_fw_ready_ind()
1274 if (priv->wpss_supported) in icnss_driver_event_fw_ready_ind()
1275 icnss_setup_dms_mac(priv); in icnss_driver_event_fw_ready_ind()
1276 ret = icnss_call_driver_probe(priv); in icnss_driver_event_fw_ready_ind()
1279 icnss_vreg_unvote(priv); in icnss_driver_event_fw_ready_ind()
1285 static int icnss_driver_event_fw_init_done(struct icnss_priv *priv, void *data) in icnss_driver_event_fw_init_done() argument
1289 if (!priv) in icnss_driver_event_fw_init_done()
1292 icnss_pr_info("WLAN FW Initialization done: 0x%lx\n", priv->state); in icnss_driver_event_fw_init_done()
1294 if (priv->device_id == WCN6750_DEVICE_ID) { in icnss_driver_event_fw_init_done()
1295 ret = icnss_wlfw_qdss_dnld_send_sync(priv); in icnss_driver_event_fw_init_done()
1301 if (test_bit(ICNSS_COLD_BOOT_CAL, &priv->state)) { in icnss_driver_event_fw_init_done()
1302 mod_timer(&priv->recovery_timer, in icnss_driver_event_fw_init_done()
1304 ret = wlfw_wlan_mode_send_sync_msg(priv, in icnss_driver_event_fw_init_done()
1307 icnss_driver_event_fw_ready_ind(priv, NULL); in icnss_driver_event_fw_init_done()
1313 int icnss_alloc_qdss_mem(struct icnss_priv *priv) in icnss_alloc_qdss_mem() argument
1315 struct platform_device *pdev = priv->pdev; in icnss_alloc_qdss_mem()
1316 struct icnss_fw_mem *qdss_mem = priv->qdss_mem; in icnss_alloc_qdss_mem()
1319 for (i = 0; i < priv->qdss_mem_seg_len; i++) { in icnss_alloc_qdss_mem()
1336 if (i < priv->qdss_mem_seg_len) { in icnss_alloc_qdss_mem()
1337 for (j = i; j < priv->qdss_mem_seg_len; j++) { in icnss_alloc_qdss_mem()
1341 priv->qdss_mem_seg_len = i; in icnss_alloc_qdss_mem()
1347 void icnss_free_qdss_mem(struct icnss_priv *priv) in icnss_free_qdss_mem() argument
1349 struct platform_device *pdev = priv->pdev; in icnss_free_qdss_mem()
1350 struct icnss_fw_mem *qdss_mem = priv->qdss_mem; in icnss_free_qdss_mem()
1353 for (i = 0; i < priv->qdss_mem_seg_len; i++) { in icnss_free_qdss_mem()
1367 priv->qdss_mem_seg_len = 0; in icnss_free_qdss_mem()
1370 static int icnss_qdss_trace_req_mem_hdlr(struct icnss_priv *priv) in icnss_qdss_trace_req_mem_hdlr() argument
1374 ret = icnss_alloc_qdss_mem(priv); in icnss_qdss_trace_req_mem_hdlr()
1378 return wlfw_qdss_trace_mem_info_send_sync(priv); in icnss_qdss_trace_req_mem_hdlr()
1381 static void *icnss_qdss_trace_pa_to_va(struct icnss_priv *priv, in icnss_qdss_trace_pa_to_va() argument
1385 struct icnss_fw_mem *qdss_mem = priv->qdss_mem; in icnss_qdss_trace_pa_to_va()
1391 for (i = 0; i < priv->qdss_mem_seg_len; i++) { in icnss_qdss_trace_pa_to_va()
1411 static int icnss_qdss_trace_save_hdlr(struct icnss_priv *priv, in icnss_qdss_trace_save_hdlr() argument
1415 struct icnss_fw_mem *qdss_mem = priv->qdss_mem; in icnss_qdss_trace_save_hdlr()
1423 if (!priv->qdss_mem_seg_len) { in icnss_qdss_trace_save_hdlr()
1429 for (i = 0; i < priv->qdss_mem_seg_len; i++) { in icnss_qdss_trace_save_hdlr()
1444 va = icnss_qdss_trace_pa_to_va(priv, pa, in icnss_qdss_trace_save_hdlr()
1479 static int icnss_qdss_trace_req_data_hdlr(struct icnss_priv *priv, in icnss_qdss_trace_req_data_hdlr() argument
1485 if (!priv) in icnss_qdss_trace_req_data_hdlr()
1491 ret = icnss_wlfw_qdss_data_send_sync(priv, event_data->file_name, in icnss_qdss_trace_req_data_hdlr()
1498 static int icnss_event_soc_wake_request(struct icnss_priv *priv, void *data) in icnss_event_soc_wake_request() argument
1502 if (!priv) in icnss_event_soc_wake_request()
1505 if (atomic_inc_not_zero(&priv->soc_wake_ref_count)) { in icnss_event_soc_wake_request()
1507 atomic_read(&priv->soc_wake_ref_count)); in icnss_event_soc_wake_request()
1511 ret = icnss_send_smp2p(priv, ICNSS_SOC_WAKE_REQ, in icnss_event_soc_wake_request()
1514 atomic_inc(&priv->soc_wake_ref_count); in icnss_event_soc_wake_request()
1519 static int icnss_event_soc_wake_release(struct icnss_priv *priv, void *data) in icnss_event_soc_wake_release() argument
1523 if (!priv) in icnss_event_soc_wake_release()
1526 if (atomic_dec_if_positive(&priv->soc_wake_ref_count)) { in icnss_event_soc_wake_release()
1528 priv->soc_wake_ref_count); in icnss_event_soc_wake_release()
1532 ret = icnss_send_smp2p(priv, ICNSS_SOC_WAKE_REL, in icnss_event_soc_wake_release()
1537 static int icnss_driver_event_register_driver(struct icnss_priv *priv, in icnss_driver_event_register_driver() argument
1543 if (priv->ops) in icnss_driver_event_register_driver()
1546 priv->ops = data; in icnss_driver_event_register_driver()
1548 if (test_bit(SKIP_QMI, &priv->ctrl_params.quirks)) in icnss_driver_event_register_driver()
1549 set_bit(ICNSS_FW_READY, &priv->state); in icnss_driver_event_register_driver()
1551 if (test_bit(ICNSS_FW_DOWN, &priv->state)) { in icnss_driver_event_register_driver()
1553 priv->state); in icnss_driver_event_register_driver()
1557 if (!test_bit(ICNSS_FW_READY, &priv->state)) { in icnss_driver_event_register_driver()
1559 priv->state); in icnss_driver_event_register_driver()
1563 ret = icnss_hw_power_on(priv); in icnss_driver_event_register_driver()
1569 ret = priv->ops->probe(&priv->pdev->dev); in icnss_driver_event_register_driver()
1576 ret, priv->state, probe_cnt); in icnss_driver_event_register_driver()
1582 set_bit(ICNSS_DRIVER_PROBED, &priv->state); in icnss_driver_event_register_driver()
1587 icnss_hw_power_off(priv); in icnss_driver_event_register_driver()
1592 static int icnss_driver_event_unregister_driver(struct icnss_priv *priv, in icnss_driver_event_unregister_driver() argument
1595 if (!test_bit(ICNSS_DRIVER_PROBED, &priv->state)) { in icnss_driver_event_unregister_driver()
1596 priv->ops = NULL; in icnss_driver_event_unregister_driver()
1600 set_bit(ICNSS_DRIVER_UNLOADING, &priv->state); in icnss_driver_event_unregister_driver()
1604 if (priv->ops) in icnss_driver_event_unregister_driver()
1605 priv->ops->remove(&priv->pdev->dev); in icnss_driver_event_unregister_driver()
1609 clear_bit(ICNSS_DRIVER_UNLOADING, &priv->state); in icnss_driver_event_unregister_driver()
1610 clear_bit(ICNSS_DRIVER_PROBED, &priv->state); in icnss_driver_event_unregister_driver()
1612 priv->ops = NULL; in icnss_driver_event_unregister_driver()
1614 icnss_hw_power_off(priv); in icnss_driver_event_unregister_driver()
1620 static int icnss_fw_crashed(struct icnss_priv *priv, in icnss_fw_crashed() argument
1625 icnss_pr_dbg("FW crashed, state: 0x%lx\n", priv->state); in icnss_fw_crashed()
1627 set_bit(ICNSS_PD_RESTART, &priv->state); in icnss_fw_crashed()
1629 icnss_pm_stay_awake(priv); in icnss_fw_crashed()
1631 if (test_bit(ICNSS_DRIVER_PROBED, &priv->state) && in icnss_fw_crashed()
1632 test_bit(ICNSS_FW_READY, &priv->state)) { in icnss_fw_crashed()
1633 clear_bit(ICNSS_FW_READY, &priv->state); in icnss_fw_crashed()
1635 icnss_call_driver_uevent(priv, in icnss_fw_crashed()
1641 wlfw_rejuvenate_ack_send_sync_msg(priv); in icnss_fw_crashed()
1646 int icnss_update_hang_event_data(struct icnss_priv *priv, in icnss_update_hang_event_data() argument
1649 if (!priv->hang_event_data_va) in icnss_update_hang_event_data()
1652 priv->hang_event_data = kmemdup(priv->hang_event_data_va, in icnss_update_hang_event_data()
1653 priv->hang_event_data_len, in icnss_update_hang_event_data()
1655 if (!priv->hang_event_data) in icnss_update_hang_event_data()
1659 hang_data->hang_event_data = priv->hang_event_data; in icnss_update_hang_event_data()
1660 hang_data->hang_event_data_len = priv->hang_event_data_len; in icnss_update_hang_event_data()
1665 int icnss_send_hang_event_data(struct icnss_priv *priv) in icnss_send_hang_event_data() argument
1670 if (priv->early_crash_ind) { in icnss_send_hang_event_data()
1671 ret = icnss_update_hang_event_data(priv, &hang_data); in icnss_send_hang_event_data()
1675 icnss_call_driver_uevent(priv, ICNSS_UEVENT_HANG_DATA, in icnss_send_hang_event_data()
1679 kfree(priv->hang_event_data); in icnss_send_hang_event_data()
1680 priv->hang_event_data = NULL; in icnss_send_hang_event_data()
1686 static int icnss_driver_event_pd_service_down(struct icnss_priv *priv, in icnss_driver_event_pd_service_down() argument
1691 if (!test_bit(ICNSS_WLFW_EXISTS, &priv->state)) { in icnss_driver_event_pd_service_down()
1696 if (priv->force_err_fatal) in icnss_driver_event_pd_service_down()
1699 if (priv->device_id == WCN6750_DEVICE_ID || in icnss_driver_event_pd_service_down()
1700 priv->device_id == WCN6450_DEVICE_ID) { in icnss_driver_event_pd_service_down()
1701 icnss_send_smp2p(priv, ICNSS_RESET_MSG, in icnss_driver_event_pd_service_down()
1703 icnss_send_smp2p(priv, ICNSS_RESET_MSG, in icnss_driver_event_pd_service_down()
1707 if (priv->wpss_supported) in icnss_driver_event_pd_service_down()
1708 icnss_send_smp2p(priv, ICNSS_RESET_MSG, in icnss_driver_event_pd_service_down()
1711 icnss_send_hang_event_data(priv); in icnss_driver_event_pd_service_down()
1713 if (priv->early_crash_ind) { in icnss_driver_event_pd_service_down()
1715 event_data->crashed, priv->state); in icnss_driver_event_pd_service_down()
1719 if (test_bit(ICNSS_PD_RESTART, &priv->state) && event_data->crashed) { in icnss_driver_event_pd_service_down()
1721 event_data->crashed, priv->state); in icnss_driver_event_pd_service_down()
1722 if (!priv->allow_recursive_recovery) in icnss_driver_event_pd_service_down()
1727 if (!test_bit(ICNSS_PD_RESTART, &priv->state)) in icnss_driver_event_pd_service_down()
1728 icnss_fw_crashed(priv, event_data); in icnss_driver_event_pd_service_down()
1736 static int icnss_driver_event_early_crash_ind(struct icnss_priv *priv, in icnss_driver_event_early_crash_ind() argument
1739 if (!test_bit(ICNSS_WLFW_EXISTS, &priv->state)) { in icnss_driver_event_early_crash_ind()
1744 priv->early_crash_ind = true; in icnss_driver_event_early_crash_ind()
1745 icnss_fw_crashed(priv, NULL); in icnss_driver_event_early_crash_ind()
1753 static int icnss_driver_event_idle_shutdown(struct icnss_priv *priv, in icnss_driver_event_idle_shutdown() argument
1758 if (!priv->ops || !priv->ops->idle_shutdown) in icnss_driver_event_idle_shutdown()
1761 if (priv->is_ssr || test_bit(ICNSS_PDR, &priv->state) || in icnss_driver_event_idle_shutdown()
1762 test_bit(ICNSS_REJUVENATE, &priv->state)) { in icnss_driver_event_idle_shutdown()
1767 priv->state); in icnss_driver_event_idle_shutdown()
1769 ret = priv->ops->idle_shutdown(&priv->pdev->dev); in icnss_driver_event_idle_shutdown()
1776 static int icnss_driver_event_idle_restart(struct icnss_priv *priv, in icnss_driver_event_idle_restart() argument
1781 if (!priv->ops || !priv->ops->idle_restart) in icnss_driver_event_idle_restart()
1784 if (priv->is_ssr || test_bit(ICNSS_PDR, &priv->state) || in icnss_driver_event_idle_restart()
1785 test_bit(ICNSS_REJUVENATE, &priv->state)) { in icnss_driver_event_idle_restart()
1790 priv->state); in icnss_driver_event_idle_restart()
1792 ret = priv->ops->idle_restart(&priv->pdev->dev); in icnss_driver_event_idle_restart()
1799 static int icnss_qdss_trace_free_hdlr(struct icnss_priv *priv) in icnss_qdss_trace_free_hdlr() argument
1801 icnss_free_qdss_mem(priv); in icnss_qdss_trace_free_hdlr()
1806 static int icnss_m3_dump_upload_req_hdlr(struct icnss_priv *priv, in icnss_m3_dump_upload_req_hdlr() argument
1819 if (IS_ERR_OR_NULL(priv->m3_dump_phyareg) || in icnss_m3_dump_upload_req_hdlr()
1820 IS_ERR_OR_NULL(priv->m3_dump_phydbg) || in icnss_m3_dump_upload_req_hdlr()
1821 IS_ERR_OR_NULL(priv->m3_dump_wmac0reg) || in icnss_m3_dump_upload_req_hdlr()
1822 IS_ERR_OR_NULL(priv->m3_dump_wcssdbg) || in icnss_m3_dump_upload_req_hdlr()
1823 IS_ERR_OR_NULL(priv->m3_dump_phyapdmem)) in icnss_m3_dump_upload_req_hdlr()
1831 segment.va = devm_ioremap(&priv->pdev->dev, in icnss_m3_dump_upload_req_hdlr()
1848 ret = qcom_dump(&head, priv->m3_dump_phyareg->dev); in icnss_m3_dump_upload_req_hdlr()
1851 ret = qcom_dump(&head, priv->m3_dump_phydbg->dev); in icnss_m3_dump_upload_req_hdlr()
1854 ret = qcom_dump(&head, priv->m3_dump_wmac0reg->dev); in icnss_m3_dump_upload_req_hdlr()
1857 ret = qcom_dump(&head, priv->m3_dump_wcssdbg->dev); in icnss_m3_dump_upload_req_hdlr()
1860 ret = qcom_dump(&head, priv->m3_dump_phyapdmem->dev); in icnss_m3_dump_upload_req_hdlr()
1875 icnss_wlfw_m3_dump_upload_done_send_sync(priv, event_data->pdev_id, in icnss_m3_dump_upload_req_hdlr()
1881 static int icnss_subsys_restart_level(struct icnss_priv *priv, void *data) in icnss_subsys_restart_level() argument
1886 if (!priv) in icnss_subsys_restart_level()
1892 ret = wlfw_subsys_restart_level_msg(priv, event_data->restart_level); in icnss_subsys_restart_level()
1902 struct icnss_priv *priv = icnss_get_plat_priv(); in icnss_wpss_self_recovery() local
1904 rproc_shutdown(priv->rproc); in icnss_wpss_self_recovery()
1905 ret = rproc_boot(priv->rproc); in icnss_wpss_self_recovery()
1908 rproc_put(priv->rproc); in icnss_wpss_self_recovery()
1914 struct icnss_priv *priv = in icnss_driver_event_work() local
1920 icnss_pm_stay_awake(priv); in icnss_driver_event_work()
1922 spin_lock_irqsave(&priv->event_lock, flags); in icnss_driver_event_work()
1924 while (!list_empty(&priv->event_list)) { in icnss_driver_event_work()
1925 event = list_first_entry(&priv->event_list, in icnss_driver_event_work()
1928 spin_unlock_irqrestore(&priv->event_lock, flags); in icnss_driver_event_work()
1933 priv->state); in icnss_driver_event_work()
1937 ret = icnss_driver_event_server_arrive(priv, in icnss_driver_event_work()
1941 ret = icnss_driver_event_server_exit(priv); in icnss_driver_event_work()
1944 ret = icnss_driver_event_fw_ready_ind(priv, in icnss_driver_event_work()
1948 ret = icnss_driver_event_register_driver(priv, in icnss_driver_event_work()
1952 ret = icnss_driver_event_unregister_driver(priv, in icnss_driver_event_work()
1956 ret = icnss_driver_event_pd_service_down(priv, in icnss_driver_event_work()
1960 ret = icnss_driver_event_early_crash_ind(priv, in icnss_driver_event_work()
1964 ret = icnss_driver_event_idle_shutdown(priv, in icnss_driver_event_work()
1968 ret = icnss_driver_event_idle_restart(priv, in icnss_driver_event_work()
1972 ret = icnss_driver_event_fw_init_done(priv, in icnss_driver_event_work()
1976 ret = icnss_qdss_trace_req_mem_hdlr(priv); in icnss_driver_event_work()
1979 ret = icnss_qdss_trace_save_hdlr(priv, in icnss_driver_event_work()
1983 ret = icnss_qdss_trace_free_hdlr(priv); in icnss_driver_event_work()
1986 ret = icnss_m3_dump_upload_req_hdlr(priv, event->data); in icnss_driver_event_work()
1989 ret = icnss_qdss_trace_req_data_hdlr(priv, in icnss_driver_event_work()
1993 ret = icnss_subsys_restart_level(priv, event->data); in icnss_driver_event_work()
1996 ret = icnss_process_wfc_call_ind_event(priv, in icnss_driver_event_work()
2000 ret = icnss_process_twt_cfg_ind_event(priv, in icnss_driver_event_work()
2009 priv->stats.events[event->type].processed++; in icnss_driver_event_work()
2014 priv->state); in icnss_driver_event_work()
2016 spin_lock_irqsave(&priv->event_lock, flags); in icnss_driver_event_work()
2022 spin_unlock_irqrestore(&priv->event_lock, flags); in icnss_driver_event_work()
2026 spin_lock_irqsave(&priv->event_lock, flags); in icnss_driver_event_work()
2028 spin_unlock_irqrestore(&priv->event_lock, flags); in icnss_driver_event_work()
2030 icnss_pm_relax(priv); in icnss_driver_event_work()
2035 struct icnss_priv *priv = in icnss_soc_wake_msg_work() local
2041 icnss_pm_stay_awake(priv); in icnss_soc_wake_msg_work()
2043 spin_lock_irqsave(&priv->soc_wake_msg_lock, flags); in icnss_soc_wake_msg_work()
2045 while (!list_empty(&priv->soc_wake_msg_list)) { in icnss_soc_wake_msg_work()
2046 event = list_first_entry(&priv->soc_wake_msg_list, in icnss_soc_wake_msg_work()
2049 spin_unlock_irqrestore(&priv->soc_wake_msg_lock, flags); in icnss_soc_wake_msg_work()
2054 priv->state); in icnss_soc_wake_msg_work()
2058 ret = icnss_event_soc_wake_request(priv, in icnss_soc_wake_msg_work()
2062 ret = icnss_event_soc_wake_release(priv, in icnss_soc_wake_msg_work()
2071 priv->stats.soc_wake_events[event->type].processed++; in icnss_soc_wake_msg_work()
2076 priv->state); in icnss_soc_wake_msg_work()
2078 spin_lock_irqsave(&priv->soc_wake_msg_lock, flags); in icnss_soc_wake_msg_work()
2084 spin_unlock_irqrestore(&priv->soc_wake_msg_lock, flags); in icnss_soc_wake_msg_work()
2088 spin_lock_irqsave(&priv->soc_wake_msg_lock, flags); in icnss_soc_wake_msg_work()
2090 spin_unlock_irqrestore(&priv->soc_wake_msg_lock, flags); in icnss_soc_wake_msg_work()
2092 icnss_pm_relax(priv); in icnss_soc_wake_msg_work()
2095 static int icnss_msa0_ramdump(struct icnss_priv *priv) in icnss_msa0_ramdump() argument
2099 struct icnss_ramdump_info *msa0_dump_dev = priv->msa0_dump_dev; in icnss_msa0_ramdump()
2114 segment.va = priv->msa_va; in icnss_msa0_ramdump()
2115 segment.size = priv->msa_mem_size; in icnss_msa0_ramdump()
2134 static void icnss_update_state_send_modem_shutdown(struct icnss_priv *priv, in icnss_update_state_send_modem_shutdown() argument
2141 if (atomic_read(&priv->is_shutdown)) { in icnss_update_state_send_modem_shutdown()
2142 atomic_set(&priv->is_shutdown, false); in icnss_update_state_send_modem_shutdown()
2143 if (!test_bit(ICNSS_PD_RESTART, &priv->state) && in icnss_update_state_send_modem_shutdown()
2144 !test_bit(ICNSS_SHUTDOWN_DONE, &priv->state) && in icnss_update_state_send_modem_shutdown()
2145 !test_bit(ICNSS_BLOCK_SHUTDOWN, &priv->state)) { in icnss_update_state_send_modem_shutdown()
2146 clear_bit(ICNSS_FW_READY, &priv->state); in icnss_update_state_send_modem_shutdown()
2147 icnss_driver_event_post(priv, in icnss_update_state_send_modem_shutdown()
2154 if (test_bit(ICNSS_BLOCK_SHUTDOWN, &priv->state)) { in icnss_update_state_send_modem_shutdown()
2156 &priv->unblock_shutdown, in icnss_update_state_send_modem_shutdown()
2161 ret = wlfw_send_modem_shutdown_msg(priv); in icnss_update_state_send_modem_shutdown()
2188 struct icnss_priv *priv = container_of(nb, struct icnss_priv, in icnss_wpss_early_notifier_nb() local
2195 set_bit(ICNSS_FW_DOWN, &priv->state); in icnss_wpss_early_notifier_nb()
2208 struct icnss_priv *priv = container_of(nb, struct icnss_priv, in icnss_wpss_notifier_nb() local
2222 icnss_msa0_ramdump(priv); in icnss_wpss_notifier_nb()
2230 if (priv->wpss_self_recovery_enabled) in icnss_wpss_notifier_nb()
2231 del_timer(&priv->wpss_ssr_timer); in icnss_wpss_notifier_nb()
2233 priv->is_ssr = true; in icnss_wpss_notifier_nb()
2236 priv->state, notif->crashed); in icnss_wpss_notifier_nb()
2238 if (priv->device_id == ADRASTEA_DEVICE_ID) in icnss_wpss_notifier_nb()
2239 icnss_update_state_send_modem_shutdown(priv, data); in icnss_wpss_notifier_nb()
2241 set_bit(ICNSS_FW_DOWN, &priv->state); in icnss_wpss_notifier_nb()
2245 priv->stats.recovery.root_pd_crash++; in icnss_wpss_notifier_nb()
2247 priv->stats.recovery.root_pd_shutdown++; in icnss_wpss_notifier_nb()
2257 if (test_bit(ICNSS_FW_READY, &priv->state)) { in icnss_wpss_notifier_nb()
2258 clear_bit(ICNSS_FW_READY, &priv->state); in icnss_wpss_notifier_nb()
2260 icnss_call_driver_uevent(priv, in icnss_wpss_notifier_nb()
2264 icnss_driver_event_post(priv, ICNSS_DRIVER_EVENT_PD_SERVICE_DOWN, in icnss_wpss_notifier_nb()
2268 mod_timer(&priv->recovery_timer, in icnss_wpss_notifier_nb()
2271 icnss_pr_vdbg("Exit %s,state: 0x%lx\n", __func__, priv->state); in icnss_wpss_notifier_nb()
2281 struct icnss_priv *priv = container_of(nb, struct icnss_priv, in icnss_modem_notifier_nb() local
2290 if (priv->is_slate_rfa) in icnss_modem_notifier_nb()
2291 complete(&priv->slate_boot_complete); in icnss_modem_notifier_nb()
2294 priv->low_power_support) { /* Hibernate */ in icnss_modem_notifier_nb()
2295 if (test_bit(ICNSS_MODE_ON, &priv->state)) in icnss_modem_notifier_nb()
2297 priv, ICNSS_DRIVER_EVENT_IDLE_SHUTDOWN, in icnss_modem_notifier_nb()
2299 set_bit(ICNSS_LOW_POWER, &priv->state); in icnss_modem_notifier_nb()
2306 icnss_msa0_ramdump(priv); in icnss_modem_notifier_nb()
2314 priv->is_ssr = true; in icnss_modem_notifier_nb()
2317 priv->stats.recovery.root_pd_crash++; in icnss_modem_notifier_nb()
2318 priv->root_pd_shutdown = false; in icnss_modem_notifier_nb()
2320 priv->stats.recovery.root_pd_shutdown++; in icnss_modem_notifier_nb()
2321 priv->root_pd_shutdown = true; in icnss_modem_notifier_nb()
2324 icnss_update_state_send_modem_shutdown(priv, data); in icnss_modem_notifier_nb()
2326 if (test_bit(ICNSS_PDR_REGISTERED, &priv->state)) { in icnss_modem_notifier_nb()
2327 set_bit(ICNSS_FW_DOWN, &priv->state); in icnss_modem_notifier_nb()
2330 if (test_bit(ICNSS_FW_READY, &priv->state)) { in icnss_modem_notifier_nb()
2331 clear_bit(ICNSS_FW_READY, &priv->state); in icnss_modem_notifier_nb()
2333 icnss_call_driver_uevent(priv, in icnss_modem_notifier_nb()
2341 priv->state, notif->crashed); in icnss_modem_notifier_nb()
2343 set_bit(ICNSS_FW_DOWN, &priv->state); in icnss_modem_notifier_nb()
2355 if (test_bit(ICNSS_FW_READY, &priv->state)) { in icnss_modem_notifier_nb()
2356 clear_bit(ICNSS_FW_READY, &priv->state); in icnss_modem_notifier_nb()
2358 icnss_call_driver_uevent(priv, in icnss_modem_notifier_nb()
2362 icnss_driver_event_post(priv, ICNSS_DRIVER_EVENT_PD_SERVICE_DOWN, in icnss_modem_notifier_nb()
2366 mod_timer(&priv->recovery_timer, in icnss_modem_notifier_nb()
2369 icnss_pr_vdbg("Exit %s,state: 0x%lx\n", __func__, priv->state); in icnss_modem_notifier_nb()
2373 static int icnss_wpss_early_ssr_register_notifier(struct icnss_priv *priv) in icnss_wpss_early_ssr_register_notifier() argument
2377 priv->wpss_early_ssr_nb.notifier_call = icnss_wpss_early_notifier_nb; in icnss_wpss_early_ssr_register_notifier()
2379 priv->wpss_early_notify_handler = in icnss_wpss_early_ssr_register_notifier()
2381 &priv->wpss_early_ssr_nb); in icnss_wpss_early_ssr_register_notifier()
2383 if (IS_ERR_OR_NULL(priv->wpss_early_notify_handler)) { in icnss_wpss_early_ssr_register_notifier()
2384 ret = PTR_ERR(priv->wpss_early_notify_handler); in icnss_wpss_early_ssr_register_notifier()
2391 static int icnss_wpss_ssr_register_notifier(struct icnss_priv *priv) in icnss_wpss_ssr_register_notifier() argument
2395 priv->wpss_ssr_nb.notifier_call = icnss_wpss_notifier_nb; in icnss_wpss_ssr_register_notifier()
2400 priv->wpss_ssr_nb.priority = 1; in icnss_wpss_ssr_register_notifier()
2402 priv->wpss_notify_handler = in icnss_wpss_ssr_register_notifier()
2403 qcom_register_ssr_notifier("wpss", &priv->wpss_ssr_nb); in icnss_wpss_ssr_register_notifier()
2405 if (IS_ERR_OR_NULL(priv->wpss_notify_handler)) { in icnss_wpss_ssr_register_notifier()
2406 ret = PTR_ERR(priv->wpss_notify_handler); in icnss_wpss_ssr_register_notifier()
2410 set_bit(ICNSS_SSR_REGISTERED, &priv->state); in icnss_wpss_ssr_register_notifier()
2422 struct icnss_priv *priv = container_of(nb, struct icnss_priv, in icnss_slate_event_notifier_nb() local
2428 priv->state); in icnss_slate_event_notifier_nb()
2429 set_bit(ICNSS_SLATE_READY, &priv->state); in icnss_slate_event_notifier_nb()
2430 set_bit(ICNSS_SLATE_UP, &priv->state); in icnss_slate_event_notifier_nb()
2431 complete(&priv->slate_boot_complete); in icnss_slate_event_notifier_nb()
2438 static int icnss_register_slate_event_notifier(struct icnss_priv *priv) in icnss_register_slate_event_notifier() argument
2442 priv->seb_nb.notifier_call = icnss_slate_event_notifier_nb; in icnss_register_slate_event_notifier()
2444 priv->seb_handle = seb_register_for_slate_event(SLATE_STATUS, in icnss_register_slate_event_notifier()
2445 &priv->seb_nb); in icnss_register_slate_event_notifier()
2446 if (IS_ERR_OR_NULL(priv->seb_handle)) { in icnss_register_slate_event_notifier()
2447 ret = priv->seb_handle ? PTR_ERR(priv->seb_handle) : -EINVAL; in icnss_register_slate_event_notifier()
2455 static int icnss_unregister_slate_event_notifier(struct icnss_priv *priv) in icnss_unregister_slate_event_notifier() argument
2459 ret = seb_unregister_for_slate_event(priv->seb_handle, &priv->seb_nb); in icnss_unregister_slate_event_notifier()
2470 struct icnss_priv *priv = container_of(nb, struct icnss_priv, in icnss_slate_notifier_nb() local
2477 test_bit(ICNSS_SLATE_READY, &priv->state)) { in icnss_slate_notifier_nb()
2478 set_bit(ICNSS_SLATE_UP, &priv->state); in icnss_slate_notifier_nb()
2479 complete(&priv->slate_boot_complete); in icnss_slate_notifier_nb()
2481 priv->state); in icnss_slate_notifier_nb()
2483 test_bit(ICNSS_SLATE_UP, &priv->state)) { in icnss_slate_notifier_nb()
2484 clear_bit(ICNSS_SLATE_UP, &priv->state); in icnss_slate_notifier_nb()
2485 if (test_bit(ICNSS_PD_RESTART, &priv->state)) { in icnss_slate_notifier_nb()
2487 priv->state); in icnss_slate_notifier_nb()
2491 icnss_pr_dbg("Initiating PDR 0x%lx\n", priv->state); in icnss_slate_notifier_nb()
2492 ret = icnss_trigger_recovery(&priv->pdev->dev); in icnss_slate_notifier_nb()
2495 ret, priv->state); in icnss_slate_notifier_nb()
2504 static int icnss_slate_ssr_register_notifier(struct icnss_priv *priv) in icnss_slate_ssr_register_notifier() argument
2508 priv->slate_ssr_nb.notifier_call = icnss_slate_notifier_nb; in icnss_slate_ssr_register_notifier()
2510 priv->slate_notify_handler = in icnss_slate_ssr_register_notifier()
2511 qcom_register_ssr_notifier("slatefw", &priv->slate_ssr_nb); in icnss_slate_ssr_register_notifier()
2513 if (IS_ERR_OR_NULL(priv->slate_notify_handler)) { in icnss_slate_ssr_register_notifier()
2514 ret = PTR_ERR(priv->slate_notify_handler); in icnss_slate_ssr_register_notifier()
2518 set_bit(ICNSS_SLATE_SSR_REGISTERED, &priv->state); in icnss_slate_ssr_register_notifier()
2523 static int icnss_slate_ssr_unregister_notifier(struct icnss_priv *priv) in icnss_slate_ssr_unregister_notifier() argument
2525 if (!test_and_clear_bit(ICNSS_SLATE_SSR_REGISTERED, &priv->state)) in icnss_slate_ssr_unregister_notifier()
2528 qcom_unregister_ssr_notifier(priv->slate_notify_handler, in icnss_slate_ssr_unregister_notifier()
2529 &priv->slate_ssr_nb); in icnss_slate_ssr_unregister_notifier()
2530 priv->slate_notify_handler = NULL; in icnss_slate_ssr_unregister_notifier()
2535 static int icnss_register_slate_event_notifier(struct icnss_priv *priv) in icnss_register_slate_event_notifier() argument
2540 static int icnss_unregister_slate_event_notifier(struct icnss_priv *priv) in icnss_unregister_slate_event_notifier() argument
2545 static int icnss_slate_ssr_register_notifier(struct icnss_priv *priv) in icnss_slate_ssr_register_notifier() argument
2550 static int icnss_slate_ssr_unregister_notifier(struct icnss_priv *priv) in icnss_slate_ssr_unregister_notifier() argument
2556 static int icnss_modem_ssr_register_notifier(struct icnss_priv *priv) in icnss_modem_ssr_register_notifier() argument
2560 priv->modem_ssr_nb.notifier_call = icnss_modem_notifier_nb; in icnss_modem_ssr_register_notifier()
2565 priv->modem_ssr_nb.priority = 1; in icnss_modem_ssr_register_notifier()
2567 priv->modem_notify_handler = in icnss_modem_ssr_register_notifier()
2568 qcom_register_ssr_notifier("mpss", &priv->modem_ssr_nb); in icnss_modem_ssr_register_notifier()
2570 if (IS_ERR_OR_NULL(priv->modem_notify_handler)) { in icnss_modem_ssr_register_notifier()
2571 ret = PTR_ERR(priv->modem_notify_handler); in icnss_modem_ssr_register_notifier()
2575 set_bit(ICNSS_SSR_REGISTERED, &priv->state); in icnss_modem_ssr_register_notifier()
2580 static void icnss_wpss_early_ssr_unregister_notifier(struct icnss_priv *priv) in icnss_wpss_early_ssr_unregister_notifier() argument
2582 if (IS_ERR_OR_NULL(priv->wpss_early_notify_handler)) in icnss_wpss_early_ssr_unregister_notifier()
2585 qcom_unregister_early_ssr_notifier(priv->wpss_early_notify_handler, in icnss_wpss_early_ssr_unregister_notifier()
2586 &priv->wpss_early_ssr_nb); in icnss_wpss_early_ssr_unregister_notifier()
2587 priv->wpss_early_notify_handler = NULL; in icnss_wpss_early_ssr_unregister_notifier()
2590 static int icnss_wpss_ssr_unregister_notifier(struct icnss_priv *priv) in icnss_wpss_ssr_unregister_notifier() argument
2592 if (!test_and_clear_bit(ICNSS_SSR_REGISTERED, &priv->state)) in icnss_wpss_ssr_unregister_notifier()
2595 qcom_unregister_ssr_notifier(priv->wpss_notify_handler, in icnss_wpss_ssr_unregister_notifier()
2596 &priv->wpss_ssr_nb); in icnss_wpss_ssr_unregister_notifier()
2597 priv->wpss_notify_handler = NULL; in icnss_wpss_ssr_unregister_notifier()
2602 static int icnss_modem_ssr_unregister_notifier(struct icnss_priv *priv) in icnss_modem_ssr_unregister_notifier() argument
2604 if (!test_and_clear_bit(ICNSS_SSR_REGISTERED, &priv->state)) in icnss_modem_ssr_unregister_notifier()
2607 qcom_unregister_ssr_notifier(priv->modem_notify_handler, in icnss_modem_ssr_unregister_notifier()
2608 &priv->modem_ssr_nb); in icnss_modem_ssr_unregister_notifier()
2609 priv->modem_notify_handler = NULL; in icnss_modem_ssr_unregister_notifier()
2616 struct icnss_priv *priv = priv_cb; in icnss_pdr_notifier_cb() local
2621 if (!priv) in icnss_pdr_notifier_cb()
2625 state, priv->state); in icnss_pdr_notifier_cb()
2636 if (!priv->is_ssr) { in icnss_pdr_notifier_cb()
2638 if (test_bit(ICNSS_HOST_TRIGGERED_PDR, &priv->state)) { in icnss_pdr_notifier_cb()
2640 priv->stats.recovery.pdr_host_error++; in icnss_pdr_notifier_cb()
2643 priv->stats.recovery.pdr_fw_crash++; in icnss_pdr_notifier_cb()
2645 } else if (priv->root_pd_shutdown) { in icnss_pdr_notifier_cb()
2651 priv->state, icnss_pdr_cause[cause]); in icnss_pdr_notifier_cb()
2653 if (!test_bit(ICNSS_FW_DOWN, &priv->state)) { in icnss_pdr_notifier_cb()
2654 set_bit(ICNSS_FW_DOWN, &priv->state); in icnss_pdr_notifier_cb()
2657 if (test_bit(ICNSS_FW_READY, &priv->state)) { in icnss_pdr_notifier_cb()
2658 clear_bit(ICNSS_FW_READY, &priv->state); in icnss_pdr_notifier_cb()
2660 icnss_call_driver_uevent(priv, in icnss_pdr_notifier_cb()
2665 clear_bit(ICNSS_HOST_TRIGGERED_PDR, &priv->state); in icnss_pdr_notifier_cb()
2668 mod_timer(&priv->recovery_timer, in icnss_pdr_notifier_cb()
2672 icnss_driver_event_post(priv, ICNSS_DRIVER_EVENT_PD_SERVICE_DOWN, in icnss_pdr_notifier_cb()
2676 clear_bit(ICNSS_FW_DOWN, &priv->state); in icnss_pdr_notifier_cb()
2684 static int icnss_pd_restart_enable(struct icnss_priv *priv) in icnss_pd_restart_enable() argument
2690 handle = pdr_handle_alloc(icnss_pdr_notifier_cb, priv); in icnss_pd_restart_enable()
2702 priv->pdr_handle = handle; in icnss_pd_restart_enable()
2703 priv->pdr_service = service; in icnss_pd_restart_enable()
2704 set_bit(ICNSS_PDR_REGISTERED, &priv->state); in icnss_pd_restart_enable()
2711 static void icnss_pdr_unregister_notifier(struct icnss_priv *priv) in icnss_pdr_unregister_notifier() argument
2713 if (!test_and_clear_bit(ICNSS_PDR_REGISTERED, &priv->state)) in icnss_pdr_unregister_notifier()
2716 pdr_handle_release(priv->pdr_handle); in icnss_pdr_unregister_notifier()
2719 static int icnss_ramdump_devnode_init(struct icnss_priv *priv) in icnss_ramdump_devnode_init() argument
2724 priv->icnss_ramdump_class = class_create(THIS_MODULE, ICNSS_RAMDUMP_NAME); in icnss_ramdump_devnode_init()
2726 priv->icnss_ramdump_class = class_create(ICNSS_RAMDUMP_NAME); in icnss_ramdump_devnode_init()
2728 if (IS_ERR_OR_NULL(priv->icnss_ramdump_class)) { in icnss_ramdump_devnode_init()
2729 ret = PTR_ERR(priv->icnss_ramdump_class); in icnss_ramdump_devnode_init()
2734 ret = alloc_chrdev_region(&priv->icnss_ramdump_dev, 0, RAMDUMP_NUM_DEVICES, in icnss_ramdump_devnode_init()
2743 class_destroy(priv->icnss_ramdump_class); in icnss_ramdump_devnode_init()
2747 void *icnss_create_ramdump_device(struct icnss_priv *priv, const char *dev_name) in icnss_create_ramdump_device() argument
2771 ramdump_info->dev = device_create(priv->icnss_ramdump_class, NULL, in icnss_create_ramdump_device()
2772 MKDEV(MAJOR(priv->icnss_ramdump_dev), in icnss_create_ramdump_device()
2790 static int icnss_register_ramdump_devices(struct icnss_priv *priv) in icnss_register_ramdump_devices() argument
2794 if (!priv || !priv->pdev) { in icnss_register_ramdump_devices()
2799 ret = icnss_ramdump_devnode_init(priv); in icnss_register_ramdump_devices()
2803 priv->msa0_dump_dev = icnss_create_ramdump_device(priv, "wcss_msa0"); in icnss_register_ramdump_devices()
2805 if (IS_ERR_OR_NULL(priv->msa0_dump_dev) || !priv->msa0_dump_dev->dev) { in icnss_register_ramdump_devices()
2810 if (priv->device_id == WCN6750_DEVICE_ID || in icnss_register_ramdump_devices()
2811 priv->device_id == WCN6450_DEVICE_ID) { in icnss_register_ramdump_devices()
2812 priv->m3_dump_phyareg = icnss_create_ramdump_device(priv, in icnss_register_ramdump_devices()
2816 if (IS_ERR_OR_NULL(priv->m3_dump_phyareg) || in icnss_register_ramdump_devices()
2817 !priv->m3_dump_phyareg->dev) { in icnss_register_ramdump_devices()
2822 priv->m3_dump_phydbg = icnss_create_ramdump_device(priv, in icnss_register_ramdump_devices()
2826 if (IS_ERR_OR_NULL(priv->m3_dump_phydbg) || in icnss_register_ramdump_devices()
2827 !priv->m3_dump_phydbg->dev) { in icnss_register_ramdump_devices()
2832 priv->m3_dump_wmac0reg = icnss_create_ramdump_device(priv, in icnss_register_ramdump_devices()
2836 if (IS_ERR_OR_NULL(priv->m3_dump_wmac0reg) || in icnss_register_ramdump_devices()
2837 !priv->m3_dump_wmac0reg->dev) { in icnss_register_ramdump_devices()
2842 priv->m3_dump_wcssdbg = icnss_create_ramdump_device(priv, in icnss_register_ramdump_devices()
2846 if (IS_ERR_OR_NULL(priv->m3_dump_wcssdbg) || in icnss_register_ramdump_devices()
2847 !priv->m3_dump_wcssdbg->dev) { in icnss_register_ramdump_devices()
2852 priv->m3_dump_phyapdmem = icnss_create_ramdump_device(priv, in icnss_register_ramdump_devices()
2856 if (IS_ERR_OR_NULL(priv->m3_dump_phyapdmem) || in icnss_register_ramdump_devices()
2857 !priv->m3_dump_phyapdmem->dev) { in icnss_register_ramdump_devices()
2866 static int icnss_enable_recovery(struct icnss_priv *priv) in icnss_enable_recovery() argument
2870 if (test_bit(RECOVERY_DISABLE, &priv->ctrl_params.quirks)) { in icnss_enable_recovery()
2875 if (test_bit(PDR_ONLY, &priv->ctrl_params.quirks)) { in icnss_enable_recovery()
2880 ret = icnss_register_ramdump_devices(priv); in icnss_enable_recovery()
2884 if (priv->wpss_supported) { in icnss_enable_recovery()
2885 icnss_wpss_early_ssr_register_notifier(priv); in icnss_enable_recovery()
2886 icnss_wpss_ssr_register_notifier(priv); in icnss_enable_recovery()
2890 if (!(priv->rproc_fw_download)) in icnss_enable_recovery()
2891 icnss_modem_ssr_register_notifier(priv); in icnss_enable_recovery()
2893 if (priv->is_slate_rfa) { in icnss_enable_recovery()
2894 icnss_slate_ssr_register_notifier(priv); in icnss_enable_recovery()
2895 icnss_register_slate_event_notifier(priv); in icnss_enable_recovery()
2898 if (test_bit(SSR_ONLY, &priv->ctrl_params.quirks)) { in icnss_enable_recovery()
2904 ret = icnss_pd_restart_enable(priv); in icnss_enable_recovery()
2912 static int icnss_dev_id_match(struct icnss_priv *priv, in icnss_dev_id_match() argument
2916 if (priv->device_id == dev_info->device_id) in icnss_dev_id_match()
2984 struct icnss_priv *priv = dev_get_drvdata(dev); in icnss_thermal_cdev_register() local
3021 &priv->icnss_tcdev_list); in icnss_thermal_cdev_register()
3034 struct icnss_priv *priv = dev_get_drvdata(dev); in icnss_thermal_cdev_unregister() local
3037 while (!list_empty(&priv->icnss_tcdev_list)) { in icnss_thermal_cdev_unregister()
3038 icnss_tcdev = list_first_entry(&priv->icnss_tcdev_list, in icnss_thermal_cdev_unregister()
3052 struct icnss_priv *priv = dev_get_drvdata(dev); in icnss_get_curr_therm_cdev_state() local
3055 mutex_lock(&priv->tcdev_lock); in icnss_get_curr_therm_cdev_state()
3056 list_for_each_entry(icnss_tcdev, &priv->icnss_tcdev_list, tcdev_list) { in icnss_get_curr_therm_cdev_state()
3061 mutex_unlock(&priv->tcdev_lock); in icnss_get_curr_therm_cdev_state()
3066 mutex_unlock(&priv->tcdev_lock); in icnss_get_curr_therm_cdev_state()
3076 struct icnss_priv *priv = icnss_get_plat_priv(); in icnss_qmi_send() local
3079 if (!priv) in icnss_qmi_send()
3082 if (!test_bit(ICNSS_WLFW_CONNECTED, &priv->state)) in icnss_qmi_send()
3085 priv->get_info_cb = cb; in icnss_qmi_send()
3086 priv->get_info_cb_ctx = cb_ctx; in icnss_qmi_send()
3088 ret = icnss_wlfw_get_info_send_sync(priv, type, cmd, cmd_len); in icnss_qmi_send()
3090 priv->get_info_cb = NULL; in icnss_qmi_send()
3091 priv->get_info_cb_ctx = NULL; in icnss_qmi_send()
3102 struct icnss_priv *priv = icnss_get_plat_priv(); in __icnss_register_driver() local
3104 if (!priv || !priv->pdev) { in __icnss_register_driver()
3109 icnss_pr_dbg("Registering driver, state: 0x%lx\n", priv->state); in __icnss_register_driver()
3111 if (priv->ops) { in __icnss_register_driver()
3122 if (!icnss_dev_id_match(priv, ops->dev_info)) { in __icnss_register_driver()
3133 ret = icnss_driver_event_post(priv, ICNSS_DRIVER_EVENT_REGISTER_DRIVER, in __icnss_register_driver()
3147 struct icnss_priv *priv = icnss_get_plat_priv(); in icnss_unregister_driver() local
3149 if (!priv || !priv->pdev) { in icnss_unregister_driver()
3154 icnss_pr_dbg("Unregistering driver, state: 0x%lx\n", priv->state); in icnss_unregister_driver()
3156 if (!priv->ops) { in icnss_unregister_driver()
3162 ret = icnss_driver_event_post(priv, in icnss_unregister_driver()
3188 static int icnss_get_msi_assignment(struct icnss_priv *priv) in icnss_get_msi_assignment() argument
3190 if (priv->device_id == WCN6750_DEVICE_ID) in icnss_get_msi_assignment()
3191 priv->msi_config = &msi_config_wcn6750; in icnss_get_msi_assignment()
3193 priv->msi_config = &msi_config_wcn6450; in icnss_get_msi_assignment()
3202 struct icnss_priv *priv = dev_get_drvdata(dev); in icnss_get_user_msi_assignment() local
3206 if (!priv) in icnss_get_user_msi_assignment()
3209 msi_config = priv->msi_config; in icnss_get_user_msi_assignment()
3219 + priv->msi_base_data; in icnss_get_user_msi_assignment()
3238 struct icnss_priv *priv = dev_get_drvdata(dev); in icnss_get_msi_irq() local
3241 irq_num = priv->srng_irqs[vector]; in icnss_get_msi_irq()
3252 struct icnss_priv *priv = dev_get_drvdata(dev); in icnss_get_msi_address() local
3254 *msi_addr_low = lower_32_bits(priv->msi_addr_iova); in icnss_get_msi_address()
3255 *msi_addr_high = upper_32_bits(priv->msi_addr_iova); in icnss_get_msi_address()
3267 struct icnss_priv *priv = dev_get_drvdata(dev); in icnss_ce_request_irq() local
3269 if (!priv || !priv->pdev) { in icnss_ce_request_irq()
3274 icnss_pr_vdbg("CE request IRQ: %d, state: 0x%lx\n", ce_id, priv->state); in icnss_ce_request_irq()
3281 irq = priv->ce_irqs[ce_id]; in icnss_ce_request_irq()
3282 irq_entry = &priv->ce_irq_list[ce_id]; in icnss_ce_request_irq()
3396 struct icnss_priv *priv = dev_get_drvdata(dev); in icnss_get_soc_info() local
3398 if (!priv) { in icnss_get_soc_info()
3403 info->v_addr = priv->mem_base_va; in icnss_get_soc_info()
3404 info->p_addr = priv->mem_base_pa; in icnss_get_soc_info()
3405 info->chip_id = priv->chip_info.chip_id; in icnss_get_soc_info()
3406 info->chip_family = priv->chip_info.chip_family; in icnss_get_soc_info()
3407 info->board_id = priv->board_id; in icnss_get_soc_info()
3408 info->soc_id = priv->soc_id; in icnss_get_soc_info()
3409 info->fw_version = priv->fw_version_info.fw_version; in icnss_get_soc_info()
3410 fw_build_timestamp = priv->fw_version_info.fw_build_timestamp; in icnss_get_soc_info()
3413 priv->fw_version_info.fw_build_timestamp, in icnss_get_soc_info()
3415 strlcpy(info->fw_build_id, priv->fw_build_id, in icnss_get_soc_info()
3417 info->rd_card_chain_cap = priv->rd_card_chain_cap; in icnss_get_soc_info()
3418 info->phy_he_channel_width_cap = priv->phy_he_channel_width_cap; in icnss_get_soc_info()
3419 info->phy_qam_cap = priv->phy_qam_cap; in icnss_get_soc_info()
3420 memcpy(&info->dev_mem_info, &priv->dev_mem_info, in icnss_get_soc_info()
3429 struct icnss_priv *priv = dev_get_drvdata(dev); in icnss_get_mhi_state() local
3431 if (!priv) { in icnss_get_mhi_state()
3436 if (!priv->mhi_state_info_va) in icnss_get_mhi_state()
3439 return ioread32(priv->mhi_state_info_va); in icnss_get_mhi_state()
3446 struct icnss_priv *priv; in icnss_set_fw_log_mode() local
3451 priv = dev_get_drvdata(dev); in icnss_set_fw_log_mode()
3453 if (!priv) { in icnss_set_fw_log_mode()
3461 priv->state); in icnss_set_fw_log_mode()
3467 ret = wlfw_ini_send_sync_msg(priv, fw_log_mode); in icnss_set_fw_log_mode()
3477 struct icnss_priv *priv; in icnss_force_wake_request() local
3482 priv = dev_get_drvdata(dev); in icnss_force_wake_request()
3484 if (!priv) { in icnss_force_wake_request()
3489 if (test_bit(ICNSS_FW_DOWN, &priv->state) || in icnss_force_wake_request()
3490 !test_bit(ICNSS_FW_READY, &priv->state)) { in icnss_force_wake_request()
3492 priv->state); in icnss_force_wake_request()
3496 if (atomic_inc_not_zero(&priv->soc_wake_ref_count)) { in icnss_force_wake_request()
3498 atomic_read(&priv->soc_wake_ref_count)); in icnss_force_wake_request()
3504 icnss_soc_wake_event_post(priv, ICNSS_SOC_WAKE_REQUEST_EVENT, in icnss_force_wake_request()
3513 struct icnss_priv *priv; in icnss_force_wake_release() local
3518 priv = dev_get_drvdata(dev); in icnss_force_wake_release()
3520 if (!priv) { in icnss_force_wake_release()
3525 if (test_bit(ICNSS_FW_DOWN, &priv->state) || in icnss_force_wake_release()
3526 !test_bit(ICNSS_FW_READY, &priv->state)) { in icnss_force_wake_release()
3528 priv->state); in icnss_force_wake_release()
3534 if (atomic_read(&priv->soc_wake_ref_count) && in icnss_force_wake_release()
3535 icnss_atomic_dec_if_greater_one(&priv->soc_wake_ref_count)) { in icnss_force_wake_release()
3537 atomic_read(&priv->soc_wake_ref_count)); in icnss_force_wake_release()
3541 icnss_soc_wake_event_post(priv, ICNSS_SOC_WAKE_RELEASE_EVENT, in icnss_force_wake_release()
3550 struct icnss_priv *priv = dev_get_drvdata(dev); in icnss_is_device_awake() local
3552 if (!priv) { in icnss_is_device_awake()
3557 return atomic_read(&priv->soc_wake_ref_count); in icnss_is_device_awake()
3563 struct icnss_priv *priv = dev_get_drvdata(dev); in icnss_is_pci_ep_awake() local
3565 if (!priv) { in icnss_is_pci_ep_awake()
3570 if (!priv->mhi_state_info_va) in icnss_is_pci_ep_awake()
3573 return ioread32(priv->mhi_state_info_va + ICNSS_PCI_EP_WAKE_OFFSET); in icnss_is_pci_ep_awake()
3582 struct icnss_priv *priv = dev_get_drvdata(dev); in icnss_athdiag_read() local
3584 if (priv->magic != ICNSS_MAGIC) { in icnss_athdiag_read()
3586 dev, priv, priv->magic); in icnss_athdiag_read()
3598 if (!test_bit(ICNSS_FW_READY, &priv->state) || in icnss_athdiag_read()
3599 !test_bit(ICNSS_POWER_ON, &priv->state)) { in icnss_athdiag_read()
3601 priv->state); in icnss_athdiag_read()
3606 ret = wlfw_athdiag_read_send_sync_msg(priv, offset, mem_type, in icnss_athdiag_read()
3618 struct icnss_priv *priv = dev_get_drvdata(dev); in icnss_athdiag_write() local
3620 if (priv->magic != ICNSS_MAGIC) { in icnss_athdiag_write()
3622 dev, priv, priv->magic); in icnss_athdiag_write()
3634 if (!test_bit(ICNSS_FW_READY, &priv->state) || in icnss_athdiag_write()
3635 !test_bit(ICNSS_POWER_ON, &priv->state)) { in icnss_athdiag_write()
3637 priv->state); in icnss_athdiag_write()
3642 ret = wlfw_athdiag_write_send_sync_msg(priv, offset, mem_type, in icnss_athdiag_write()
3653 struct icnss_priv *priv = dev_get_drvdata(dev); in icnss_wlan_enable() local
3656 if (test_bit(ICNSS_FW_DOWN, &priv->state) || in icnss_wlan_enable()
3657 !test_bit(ICNSS_FW_READY, &priv->state)) { in icnss_wlan_enable()
3659 priv->state); in icnss_wlan_enable()
3663 if (test_bit(ICNSS_MODE_ON, &priv->state)) { in icnss_wlan_enable()
3665 priv->state); in icnss_wlan_enable()
3669 if (priv->wpss_supported && in icnss_wlan_enable()
3670 !priv->dms.nv_mac_not_prov && !priv->dms.mac_valid) in icnss_wlan_enable()
3671 icnss_setup_dms_mac(priv); in icnss_wlan_enable()
3673 if (priv->device_id == WCN6750_DEVICE_ID) { in icnss_wlan_enable()
3674 if (!icnss_get_temperature(priv, &temp)) { in icnss_wlan_enable()
3677 icnss_set_wlan_en_delay(priv); in icnss_wlan_enable()
3681 if (priv->device_id == WCN6450_DEVICE_ID) in icnss_wlan_enable()
3682 icnss_hw_power_off(priv); in icnss_wlan_enable()
3684 ret = icnss_send_wlan_enable_to_fw(priv, config, mode, host_version); in icnss_wlan_enable()
3686 if (priv->device_id == WCN6450_DEVICE_ID) in icnss_wlan_enable()
3687 icnss_hw_power_on(priv); in icnss_wlan_enable()
3695 struct icnss_priv *priv = dev_get_drvdata(dev); in icnss_wlan_disable() local
3697 if (test_bit(ICNSS_FW_DOWN, &priv->state)) { in icnss_wlan_disable()
3699 priv->state); in icnss_wlan_disable()
3703 return icnss_send_wlan_disable_to_fw(priv); in icnss_wlan_disable()
3749 struct icnss_priv *priv = dev_get_drvdata(dev); in icnss_smmu_get_domain() local
3751 if (!priv) { in icnss_smmu_get_domain()
3755 return priv->iommu_domain; in icnss_smmu_get_domain()
3776 struct icnss_priv *priv = dev_get_drvdata(dev); in icnss_smmu_map() local
3784 if (!priv) { in icnss_smmu_map()
3786 dev, priv); in icnss_smmu_map()
3797 iova = roundup(priv->smmu_iova_ipa_current, PAGE_SIZE); in icnss_smmu_map()
3800 iova >= priv->smmu_iova_ipa_start + priv->smmu_iova_ipa_len) { in icnss_smmu_map()
3803 &priv->smmu_iova_ipa_start, in icnss_smmu_map()
3804 priv->smmu_iova_ipa_len); in icnss_smmu_map()
3816 ret = icnss_iommu_map(priv->iommu_domain, iova, in icnss_smmu_map()
3824 priv->smmu_iova_ipa_current = iova + len; in icnss_smmu_map()
3835 struct icnss_priv *priv = dev_get_drvdata(dev); in icnss_smmu_unmap() local
3839 if (!priv) { in icnss_smmu_unmap()
3841 dev, priv); in icnss_smmu_unmap()
3855 if (iova >= priv->smmu_iova_ipa_start + priv->smmu_iova_ipa_len) { in icnss_smmu_unmap()
3858 &priv->smmu_iova_ipa_start, in icnss_smmu_unmap()
3859 priv->smmu_iova_ipa_len); in icnss_smmu_unmap()
3866 unmapped_len = iommu_unmap(priv->iommu_domain, iova, len); in icnss_smmu_unmap()
3872 priv->smmu_iova_ipa_current = iova; in icnss_smmu_unmap()
3886 struct icnss_priv *priv = dev_get_drvdata(dev); in icnss_trigger_recovery() local
3888 if (priv->magic != ICNSS_MAGIC) { in icnss_trigger_recovery()
3889 icnss_pr_err("Invalid drvdata: magic 0x%x\n", priv->magic); in icnss_trigger_recovery()
3894 if (test_bit(ICNSS_PD_RESTART, &priv->state)) { in icnss_trigger_recovery()
3896 priv->state); in icnss_trigger_recovery()
3901 if (priv->wpss_supported) { in icnss_trigger_recovery()
3903 ret = icnss_send_smp2p(priv, ICNSS_TRIGGER_SSR, in icnss_trigger_recovery()
3906 set_bit(ICNSS_HOST_TRIGGERED_PDR, &priv->state); in icnss_trigger_recovery()
3910 if (!test_bit(ICNSS_PDR_REGISTERED, &priv->state)) { in icnss_trigger_recovery()
3912 priv->state); in icnss_trigger_recovery()
3918 priv->state); in icnss_trigger_recovery()
3920 ret = pdr_restart_pd(priv->pdr_handle, priv->pdr_service); in icnss_trigger_recovery()
3923 set_bit(ICNSS_HOST_TRIGGERED_PDR, &priv->state); in icnss_trigger_recovery()
3932 struct icnss_priv *priv = dev_get_drvdata(dev); in icnss_idle_shutdown() local
3934 if (!priv) { in icnss_idle_shutdown()
3939 if (priv->is_ssr || test_bit(ICNSS_PDR, &priv->state) || in icnss_idle_shutdown()
3940 test_bit(ICNSS_REJUVENATE, &priv->state)) { in icnss_idle_shutdown()
3945 return icnss_driver_event_post(priv, ICNSS_DRIVER_EVENT_IDLE_SHUTDOWN, in icnss_idle_shutdown()
3952 struct icnss_priv *priv = dev_get_drvdata(dev); in icnss_idle_restart() local
3954 if (!priv) { in icnss_idle_restart()
3959 if (priv->is_ssr || test_bit(ICNSS_PDR, &priv->state) || in icnss_idle_restart()
3960 test_bit(ICNSS_REJUVENATE, &priv->state)) { in icnss_idle_restart()
3965 return icnss_driver_event_post(priv, ICNSS_DRIVER_EVENT_IDLE_RESTART, in icnss_idle_restart()
3972 struct icnss_priv *priv = dev_get_drvdata(dev); in icnss_exit_power_save() local
3976 if (test_bit(ICNSS_PD_RESTART, &priv->state) || in icnss_exit_power_save()
3977 !test_bit(ICNSS_MODE_ON, &priv->state)) in icnss_exit_power_save()
3980 return icnss_send_smp2p(priv, ICNSS_POWER_SAVE_EXIT, in icnss_exit_power_save()
3987 struct icnss_priv *priv = dev_get_drvdata(dev); in icnss_prevent_l1() local
3989 if (test_bit(ICNSS_PD_RESTART, &priv->state) || in icnss_prevent_l1()
3990 !test_bit(ICNSS_MODE_ON, &priv->state)) in icnss_prevent_l1()
3993 return icnss_send_smp2p(priv, ICNSS_PCI_EP_POWER_SAVE_EXIT, in icnss_prevent_l1()
4000 struct icnss_priv *priv = dev_get_drvdata(dev); in icnss_allow_l1() local
4002 if (test_bit(ICNSS_PD_RESTART, &priv->state) || in icnss_allow_l1()
4003 !test_bit(ICNSS_MODE_ON, &priv->state)) in icnss_allow_l1()
4006 icnss_send_smp2p(priv, ICNSS_PCI_EP_POWER_SAVE_ENTER, in icnss_allow_l1()
4013 struct icnss_priv *priv = dev_get_drvdata(dev); in icnss_allow_recursive_recovery() local
4015 priv->allow_recursive_recovery = true; in icnss_allow_recursive_recovery()
4022 struct icnss_priv *priv = dev_get_drvdata(dev); in icnss_disallow_recursive_recovery() local
4024 priv->allow_recursive_recovery = false; in icnss_disallow_recursive_recovery()
4029 static int icnss_create_shutdown_sysfs(struct icnss_priv *priv) in icnss_create_shutdown_sysfs() argument
4034 atomic_set(&priv->is_shutdown, false); in icnss_create_shutdown_sysfs()
4042 priv->icnss_kobject = icnss_kobject; in icnss_create_shutdown_sysfs()
4053 static void icnss_destroy_shutdown_sysfs(struct icnss_priv *priv) in icnss_destroy_shutdown_sysfs() argument
4057 icnss_kobject = priv->icnss_kobject; in icnss_destroy_shutdown_sysfs()
4066 struct icnss_priv *priv = dev_get_drvdata(dev); in qdss_tr_start_store() local
4068 wlfw_qdss_trace_start(priv); in qdss_tr_start_store()
4077 struct icnss_priv *priv = dev_get_drvdata(dev); in qdss_tr_stop_store() local
4083 wlfw_qdss_trace_stop(priv, option); in qdss_tr_stop_store()
4092 struct icnss_priv *priv = dev_get_drvdata(dev); in qdss_conf_download_store() local
4094 icnss_wlfw_qdss_dnld_send_sync(priv); in qdss_conf_download_store()
4103 struct icnss_priv *priv = dev_get_drvdata(dev); in hw_trc_override_store() local
4109 priv->hw_trc_override = tmp; in hw_trc_override_store()
4116 struct icnss_priv *priv = icnss_get_plat_priv(); in icnss_wpss_load() local
4120 if (of_property_read_u32(priv->pdev->dev.of_node, "qcom,rproc-handle", in icnss_wpss_load()
4126 priv->rproc = rproc_get_by_phandle(rproc_phandle); in icnss_wpss_load()
4127 if (IS_ERR_OR_NULL(priv->rproc)) { in icnss_wpss_load()
4132 ret = rproc_boot(priv->rproc); in icnss_wpss_load()
4135 rproc_put(priv->rproc); in icnss_wpss_load()
4143 struct icnss_priv *priv = dev_get_drvdata(dev); in wpss_boot_store() local
4146 if (!priv->wpss_supported && !priv->rproc_fw_download) in wpss_boot_store()
4159 icnss_wpss_unload(priv); in wpss_boot_store()
4168 struct icnss_priv *priv = dev_get_drvdata(dev); in wlan_en_delay_store() local
4171 if (priv->device_id == ADRASTEA_DEVICE_ID) in wlan_en_delay_store()
4180 priv->wlan_en_delay_ms_user = wlan_en_delay; in wlan_en_delay_store()
4206 static int icnss_create_sysfs_link(struct icnss_priv *priv) in icnss_create_sysfs_link() argument
4208 struct device *dev = &priv->pdev->dev; in icnss_create_sysfs_link()
4223 static void icnss_remove_sysfs_link(struct icnss_priv *priv) in icnss_remove_sysfs_link() argument
4248 static void icnss_devm_device_remove_group(struct icnss_priv *priv) in icnss_devm_device_remove_group() argument
4250 WARN_ON(devres_release(&priv->pdev->dev, in icnss_devm_device_remove_group()
4255 static void icnss_devm_device_remove_group(struct icnss_priv *priv) in icnss_devm_device_remove_group() argument
4257 devm_device_remove_group(&priv->pdev->dev, &icnss_attr_group); in icnss_devm_device_remove_group()
4261 static int icnss_sysfs_create(struct icnss_priv *priv) in icnss_sysfs_create() argument
4265 ret = devm_device_add_group(&priv->pdev->dev, in icnss_sysfs_create()
4273 icnss_create_sysfs_link(priv); in icnss_sysfs_create()
4275 ret = icnss_create_shutdown_sysfs(priv); in icnss_sysfs_create()
4281 icnss_devm_device_remove_group(priv); in icnss_sysfs_create()
4286 static void icnss_sysfs_destroy(struct icnss_priv *priv) in icnss_sysfs_destroy() argument
4288 icnss_destroy_shutdown_sysfs(priv); in icnss_sysfs_destroy()
4289 icnss_remove_sysfs_link(priv); in icnss_sysfs_destroy()
4290 icnss_devm_device_remove_group(priv); in icnss_sysfs_destroy()
4293 static int icnss_resource_parse(struct icnss_priv *priv) in icnss_resource_parse() argument
4296 struct platform_device *pdev = priv->pdev; in icnss_resource_parse()
4301 ret = icnss_get_vreg(priv); in icnss_resource_parse()
4307 ret = icnss_get_clk(priv); in icnss_resource_parse()
4314 ret = icnss_get_psf_info(priv); in icnss_resource_parse()
4317 priv->psf_supported = true; in icnss_resource_parse()
4320 if (priv->device_id == ADRASTEA_DEVICE_ID) { in icnss_resource_parse()
4329 priv->mem_base_pa = res->start; in icnss_resource_parse()
4330 priv->mem_base_va = devm_ioremap(dev, priv->mem_base_pa, in icnss_resource_parse()
4332 if (!priv->mem_base_va) { in icnss_resource_parse()
4334 &priv->mem_base_pa); in icnss_resource_parse()
4339 &priv->mem_base_pa, in icnss_resource_parse()
4340 priv->mem_base_va); in icnss_resource_parse()
4349 priv->ce_irqs[i] = irq; in icnss_resource_parse()
4355 priv->low_power_support = true; in icnss_resource_parse()
4360 &priv->rf_subtype) == 0) { in icnss_resource_parse()
4361 priv->is_rf_subtype_valid = true; in icnss_resource_parse()
4362 icnss_pr_dbg("RF subtype 0x%x\n", priv->rf_subtype); in icnss_resource_parse()
4367 priv->is_slate_rfa = true; in icnss_resource_parse()
4370 } else if (priv->device_id == WCN6750_DEVICE_ID || in icnss_resource_parse()
4371 priv->device_id == WCN6450_DEVICE_ID) { in icnss_resource_parse()
4380 priv->msi_addr_pa = res->start; in icnss_resource_parse()
4381 priv->msi_addr_iova = dma_map_resource(dev, priv->msi_addr_pa, in icnss_resource_parse()
4384 if (dma_mapping_error(dev, priv->msi_addr_iova)) { in icnss_resource_parse()
4386 priv->msi_addr_iova = 0; in icnss_resource_parse()
4391 &priv->msi_addr_pa, in icnss_resource_parse()
4392 priv->msi_addr_iova); in icnss_resource_parse()
4403 priv->msi_base_data = int_prop + 32; in icnss_resource_parse()
4405 priv->msi_base_data, int_prop); in icnss_resource_parse()
4407 icnss_get_msi_assignment(priv); in icnss_resource_parse()
4408 for (i = 0; i < priv->msi_config->total_vectors; i++) { in icnss_resource_parse()
4409 irq = platform_get_irq(priv->pdev, i); in icnss_resource_parse()
4415 priv->srng_irqs[i] = irq; in icnss_resource_parse()
4423 icnss_put_clk(priv); in icnss_resource_parse()
4425 icnss_put_vreg(priv); in icnss_resource_parse()
4430 static int icnss_msa_dt_parse(struct icnss_priv *priv) in icnss_msa_dt_parse() argument
4433 struct platform_device *pdev = priv->pdev; in icnss_msa_dt_parse()
4450 priv->msa_pa = of_translate_address(np, addrp); in icnss_msa_dt_parse()
4451 if (priv->msa_pa == OF_BAD_ADDR) { in icnss_msa_dt_parse()
4460 priv->msa_va = memremap(priv->msa_pa, in icnss_msa_dt_parse()
4462 if (!priv->msa_va) { in icnss_msa_dt_parse()
4464 &priv->msa_pa); in icnss_msa_dt_parse()
4468 priv->msa_mem_size = prop_size; in icnss_msa_dt_parse()
4471 &priv->msa_mem_size); in icnss_msa_dt_parse()
4472 if (ret || priv->msa_mem_size == 0) { in icnss_msa_dt_parse()
4474 priv->msa_mem_size, ret); in icnss_msa_dt_parse()
4478 priv->msa_va = dmam_alloc_coherent(&pdev->dev, in icnss_msa_dt_parse()
4479 priv->msa_mem_size, &priv->msa_pa, GFP_KERNEL); in icnss_msa_dt_parse()
4481 if (!priv->msa_va) { in icnss_msa_dt_parse()
4489 &priv->msa_pa, (void *)priv->msa_va, priv->msa_mem_size); in icnss_msa_dt_parse()
4491 priv->use_prefix_path = of_property_read_bool(priv->pdev->dev.of_node, in icnss_msa_dt_parse()
4503 struct icnss_priv *priv = handler_token; in icnss_smmu_fault_handler() local
4508 if (!priv) { in icnss_smmu_fault_handler()
4513 if (test_bit(ICNSS_FW_READY, &priv->state)) { in icnss_smmu_fault_handler()
4515 icnss_call_driver_uevent(priv, ICNSS_UEVENT_SMMU_FAULT, in icnss_smmu_fault_handler()
4517 icnss_call_driver_uevent(priv, ICNSS_UEVENT_FW_DOWN, in icnss_smmu_fault_handler()
4521 icnss_trigger_recovery(&priv->pdev->dev); in icnss_smmu_fault_handler()
4527 static int icnss_smmu_dt_parse(struct icnss_priv *priv) in icnss_smmu_dt_parse() argument
4530 struct platform_device *pdev = priv->pdev; in icnss_smmu_dt_parse()
4544 priv->smmu_iova_start = addr_win[0]; in icnss_smmu_dt_parse()
4545 priv->smmu_iova_len = addr_win[1]; in icnss_smmu_dt_parse()
4547 &priv->smmu_iova_start, in icnss_smmu_dt_parse()
4548 priv->smmu_iova_len); in icnss_smmu_dt_parse()
4550 priv->iommu_domain = in icnss_smmu_dt_parse()
4557 priv->smmu_s1_enable = true; in icnss_smmu_dt_parse()
4558 if (priv->device_id == WCN6750_DEVICE_ID || in icnss_smmu_dt_parse()
4559 priv->device_id == WCN6450_DEVICE_ID) in icnss_smmu_dt_parse()
4560 iommu_set_fault_handler(priv->iommu_domain, in icnss_smmu_dt_parse()
4562 priv); in icnss_smmu_dt_parse()
4571 priv->smmu_iova_ipa_start = res->start; in icnss_smmu_dt_parse()
4572 priv->smmu_iova_ipa_current = res->start; in icnss_smmu_dt_parse()
4573 priv->smmu_iova_ipa_len = resource_size(res); in icnss_smmu_dt_parse()
4575 &priv->smmu_iova_ipa_start, in icnss_smmu_dt_parse()
4576 priv->smmu_iova_ipa_len); in icnss_smmu_dt_parse()
4583 int icnss_get_iova(struct icnss_priv *priv, u64 *addr, u64 *size) in icnss_get_iova() argument
4585 if (!priv) in icnss_get_iova()
4588 if (!priv->smmu_iova_len) in icnss_get_iova()
4591 *addr = priv->smmu_iova_start; in icnss_get_iova()
4592 *size = priv->smmu_iova_len; in icnss_get_iova()
4597 int icnss_get_iova_ipa(struct icnss_priv *priv, u64 *addr, u64 *size) in icnss_get_iova_ipa() argument
4599 if (!priv) in icnss_get_iova_ipa()
4602 if (!priv->smmu_iova_ipa_len) in icnss_get_iova_ipa()
4605 *addr = priv->smmu_iova_ipa_start; in icnss_get_iova_ipa()
4606 *size = priv->smmu_iova_ipa_len; in icnss_get_iova_ipa()
4611 void icnss_add_fw_prefix_name(struct icnss_priv *priv, char *prefix_name, in icnss_add_fw_prefix_name() argument
4614 if (!priv) in icnss_add_fw_prefix_name()
4617 if (!priv->use_prefix_path) { in icnss_add_fw_prefix_name()
4622 if (priv->device_id == ADRASTEA_DEVICE_ID) in icnss_add_fw_prefix_name()
4625 else if (priv->device_id == WCN6750_DEVICE_ID) in icnss_add_fw_prefix_name()
4628 else if (priv->device_id == WCN6450_DEVICE_ID) in icnss_add_fw_prefix_name()
4656 static void icnss_init_control_params(struct icnss_priv *priv) in icnss_init_control_params() argument
4658 priv->ctrl_params.qmi_timeout = WLFW_TIMEOUT; in icnss_init_control_params()
4659 priv->ctrl_params.quirks = ICNSS_QUIRKS_DEFAULT; in icnss_init_control_params()
4660 priv->ctrl_params.bdf_type = ICNSS_BDF_TYPE_DEFAULT; in icnss_init_control_params()
4662 if (priv->device_id == WCN6750_DEVICE_ID || in icnss_init_control_params()
4663 priv->device_id == WCN6450_DEVICE_ID || in icnss_init_control_params()
4664 of_property_read_bool(priv->pdev->dev.of_node, in icnss_init_control_params()
4666 priv->wpss_supported = true; in icnss_init_control_params()
4668 if (of_property_read_bool(priv->pdev->dev.of_node, in icnss_init_control_params()
4670 priv->bdf_download_support = true; in icnss_init_control_params()
4672 if (of_property_read_bool(priv->pdev->dev.of_node, in icnss_init_control_params()
4674 priv->rproc_fw_download = true; in icnss_init_control_params()
4676 if (priv->bdf_download_support && priv->device_id == ADRASTEA_DEVICE_ID) in icnss_init_control_params()
4677 priv->ctrl_params.bdf_type = ICNSS_BDF_BIN; in icnss_init_control_params()
4680 static void icnss_read_device_configs(struct icnss_priv *priv) in icnss_read_device_configs() argument
4682 if (of_property_read_bool(priv->pdev->dev.of_node, in icnss_read_device_configs()
4684 set_bit(ICNSS_IPA_DISABLED, &priv->device_config); in icnss_read_device_configs()
4687 if (of_property_read_bool(priv->pdev->dev.of_node, in icnss_read_device_configs()
4689 priv->wpss_self_recovery_enabled = true; in icnss_read_device_configs()
4692 static inline void icnss_runtime_pm_init(struct icnss_priv *priv) in icnss_runtime_pm_init() argument
4694 pm_runtime_get_sync(&priv->pdev->dev); in icnss_runtime_pm_init()
4695 pm_runtime_forbid(&priv->pdev->dev); in icnss_runtime_pm_init()
4696 pm_runtime_set_active(&priv->pdev->dev); in icnss_runtime_pm_init()
4697 pm_runtime_enable(&priv->pdev->dev); in icnss_runtime_pm_init()
4700 static inline void icnss_runtime_pm_deinit(struct icnss_priv *priv) in icnss_runtime_pm_deinit() argument
4702 pm_runtime_disable(&priv->pdev->dev); in icnss_runtime_pm_deinit()
4703 pm_runtime_allow(&priv->pdev->dev); in icnss_runtime_pm_deinit()
4704 pm_runtime_put_sync(&priv->pdev->dev); in icnss_runtime_pm_deinit()
4707 static inline bool icnss_use_nv_mac(struct icnss_priv *priv) in icnss_use_nv_mac() argument
4709 return of_property_read_bool(priv->pdev->dev.of_node, in icnss_use_nv_mac()
4767 struct icnss_priv *priv; in icnss_probe() local
4787 priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); in icnss_probe()
4788 if (!priv) in icnss_probe()
4791 priv->magic = ICNSS_MAGIC; in icnss_probe()
4792 dev_set_drvdata(dev, priv); in icnss_probe()
4794 priv->pdev = pdev; in icnss_probe()
4795 priv->device_id = device_id->driver_data; in icnss_probe()
4796 priv->is_chain1_supported = true; in icnss_probe()
4797 INIT_LIST_HEAD(&priv->vreg_list); in icnss_probe()
4798 INIT_LIST_HEAD(&priv->clk_list); in icnss_probe()
4801 icnss_initialize_mem_pool(priv->device_id); in icnss_probe()
4803 icnss_init_control_params(priv); in icnss_probe()
4805 icnss_read_device_configs(priv); in icnss_probe()
4807 ret = icnss_resource_parse(priv); in icnss_probe()
4811 ret = icnss_msa_dt_parse(priv); in icnss_probe()
4815 ret = icnss_smmu_dt_parse(priv); in icnss_probe()
4819 spin_lock_init(&priv->event_lock); in icnss_probe()
4820 spin_lock_init(&priv->on_off_lock); in icnss_probe()
4821 spin_lock_init(&priv->soc_wake_msg_lock); in icnss_probe()
4822 mutex_init(&priv->dev_lock); in icnss_probe()
4823 mutex_init(&priv->tcdev_lock); in icnss_probe()
4825 priv->event_wq = alloc_workqueue("icnss_driver_event", WQ_UNBOUND, 1); in icnss_probe()
4826 if (!priv->event_wq) { in icnss_probe()
4832 INIT_WORK(&priv->event_work, icnss_driver_event_work); in icnss_probe()
4833 INIT_LIST_HEAD(&priv->event_list); in icnss_probe()
4835 if (priv->is_slate_rfa) in icnss_probe()
4836 init_completion(&priv->slate_boot_complete); in icnss_probe()
4838 ret = icnss_register_fw_service(priv); in icnss_probe()
4843 icnss_power_misc_params_init(priv); in icnss_probe()
4845 icnss_enable_recovery(priv); in icnss_probe()
4847 icnss_debugfs_create(priv); in icnss_probe()
4849 icnss_sysfs_create(priv); in icnss_probe()
4851 ret = device_init_wakeup(&priv->pdev->dev, true); in icnss_probe()
4856 icnss_set_plat_priv(priv); in icnss_probe()
4858 init_completion(&priv->unblock_shutdown); in icnss_probe()
4860 if (priv->device_id == WCN6750_DEVICE_ID || in icnss_probe()
4861 priv->device_id == WCN6450_DEVICE_ID) { in icnss_probe()
4862 priv->soc_wake_wq = alloc_workqueue("icnss_soc_wake_event", in icnss_probe()
4864 if (!priv->soc_wake_wq) { in icnss_probe()
4870 INIT_WORK(&priv->soc_wake_msg_work, icnss_soc_wake_msg_work); in icnss_probe()
4871 INIT_LIST_HEAD(&priv->soc_wake_msg_list); in icnss_probe()
4877 init_completion(&priv->smp2p_soc_wake_wait); in icnss_probe()
4878 icnss_runtime_pm_init(priv); in icnss_probe()
4879 icnss_aop_interface_init(priv); in icnss_probe()
4880 set_bit(ICNSS_COLD_BOOT_CAL, &priv->state); in icnss_probe()
4881 priv->bdf_download_support = true; in icnss_probe()
4885 if (priv->wpss_supported) { in icnss_probe()
4886 ret = icnss_dms_init(priv); in icnss_probe()
4889 priv->use_nv_mac = icnss_use_nv_mac(priv); in icnss_probe()
4891 priv->use_nv_mac ? "Mandatory":"Not Mandatory"); in icnss_probe()
4894 if (priv->wpss_supported || priv->rproc_fw_download) in icnss_probe()
4897 timer_setup(&priv->recovery_timer, in icnss_probe()
4900 if (priv->wpss_self_recovery_enabled) { in icnss_probe()
4902 timer_setup(&priv->wpss_ssr_timer, in icnss_probe()
4906 icnss_register_ims_service(priv); in icnss_probe()
4907 INIT_LIST_HEAD(&priv->icnss_tcdev_list); in icnss_probe()
4914 icnss_unregister_fw_service(priv); in icnss_probe()
4916 destroy_workqueue(priv->event_wq); in icnss_probe()
4918 priv->iommu_domain = NULL; in icnss_probe()
4920 icnss_put_resources(priv); in icnss_probe()
4940 static void icnss_unregister_power_supply_notifier(struct icnss_priv *priv) in icnss_unregister_power_supply_notifier() argument
4942 if (priv->batt_psy) in icnss_unregister_power_supply_notifier()
4945 if (priv->psf_supported) { in icnss_unregister_power_supply_notifier()
4946 flush_workqueue(priv->soc_update_wq); in icnss_unregister_power_supply_notifier()
4947 destroy_workqueue(priv->soc_update_wq); in icnss_unregister_power_supply_notifier()
4948 power_supply_unreg_notifier(&priv->psf_nb); in icnss_unregister_power_supply_notifier()
4954 struct icnss_priv *priv = dev_get_drvdata(&pdev->dev); in icnss_remove() local
4956 icnss_pr_info("Removing driver: state: 0x%lx\n", priv->state); in icnss_remove()
4958 del_timer(&priv->recovery_timer); in icnss_remove()
4960 if (priv->wpss_self_recovery_enabled) in icnss_remove()
4961 del_timer(&priv->wpss_ssr_timer); in icnss_remove()
4963 device_init_wakeup(&priv->pdev->dev, false); in icnss_remove()
4965 icnss_unregister_ims_service(priv); in icnss_remove()
4967 icnss_debugfs_destroy(priv); in icnss_remove()
4971 icnss_sysfs_destroy(priv); in icnss_remove()
4973 complete_all(&priv->unblock_shutdown); in icnss_remove()
4975 if (priv->is_slate_rfa) { in icnss_remove()
4976 complete(&priv->slate_boot_complete); in icnss_remove()
4977 icnss_slate_ssr_unregister_notifier(priv); in icnss_remove()
4978 icnss_unregister_slate_event_notifier(priv); in icnss_remove()
4981 icnss_destroy_ramdump_device(priv->msa0_dump_dev); in icnss_remove()
4983 if (priv->wpss_supported) { in icnss_remove()
4984 icnss_dms_deinit(priv); in icnss_remove()
4985 icnss_wpss_early_ssr_unregister_notifier(priv); in icnss_remove()
4986 icnss_wpss_ssr_unregister_notifier(priv); in icnss_remove()
4988 icnss_modem_ssr_unregister_notifier(priv); in icnss_remove()
4989 icnss_pdr_unregister_notifier(priv); in icnss_remove()
4992 if (priv->device_id == WCN6750_DEVICE_ID || in icnss_remove()
4993 priv->device_id == WCN6450_DEVICE_ID) { in icnss_remove()
4995 icnss_runtime_pm_deinit(priv); in icnss_remove()
4997 complete_all(&priv->smp2p_soc_wake_wait); in icnss_remove()
4998 icnss_destroy_ramdump_device(priv->m3_dump_phyareg); in icnss_remove()
4999 icnss_destroy_ramdump_device(priv->m3_dump_phydbg); in icnss_remove()
5000 icnss_destroy_ramdump_device(priv->m3_dump_wmac0reg); in icnss_remove()
5001 icnss_destroy_ramdump_device(priv->m3_dump_wcssdbg); in icnss_remove()
5002 icnss_destroy_ramdump_device(priv->m3_dump_phyapdmem); in icnss_remove()
5003 if (priv->soc_wake_wq) in icnss_remove()
5004 destroy_workqueue(priv->soc_wake_wq); in icnss_remove()
5005 icnss_aop_interface_deinit(priv); in icnss_remove()
5008 class_destroy(priv->icnss_ramdump_class); in icnss_remove()
5009 unregister_chrdev_region(priv->icnss_ramdump_dev, RAMDUMP_NUM_DEVICES); in icnss_remove()
5011 icnss_unregister_fw_service(priv); in icnss_remove()
5012 if (priv->event_wq) in icnss_remove()
5013 destroy_workqueue(priv->event_wq); in icnss_remove()
5015 priv->iommu_domain = NULL; in icnss_remove()
5017 icnss_hw_power_off(priv); in icnss_remove()
5019 icnss_put_resources(priv); in icnss_remove()
5030 struct icnss_priv *priv = from_timer(priv, t, recovery_timer); in icnss_recovery_timeout_hdlr() local
5033 if (priv->is_slate_rfa && !test_bit(ICNSS_SLATE_UP, &priv->state)) in icnss_recovery_timeout_hdlr()
5036 icnss_pr_err("Timeout waiting for FW Ready 0x%lx\n", priv->state); in icnss_recovery_timeout_hdlr()
5042 struct icnss_priv *priv = from_timer(priv, t, wpss_ssr_timer); in icnss_wpss_ssr_timeout_hdlr() local
5045 priv->state); in icnss_wpss_ssr_timeout_hdlr()
5052 struct icnss_priv *priv = dev_get_drvdata(dev); in icnss_pm_suspend() local
5055 if (priv->magic != ICNSS_MAGIC) { in icnss_pm_suspend()
5057 dev, priv, priv->magic); in icnss_pm_suspend()
5061 icnss_pr_vdbg("PM Suspend, state: 0x%lx\n", priv->state); in icnss_pm_suspend()
5063 if (!priv->ops || !priv->ops->pm_suspend || in icnss_pm_suspend()
5064 icnss_is_smp2p_valid(priv, ICNSS_SMP2P_OUT_POWER_SAVE) || in icnss_pm_suspend()
5065 !test_bit(ICNSS_DRIVER_PROBED, &priv->state)) in icnss_pm_suspend()
5068 ret = priv->ops->pm_suspend(dev); in icnss_pm_suspend()
5071 if (priv->device_id == WCN6750_DEVICE_ID || in icnss_pm_suspend()
5072 priv->device_id == WCN6450_DEVICE_ID) { in icnss_pm_suspend()
5073 if (test_bit(ICNSS_PD_RESTART, &priv->state) || in icnss_pm_suspend()
5074 !test_bit(ICNSS_MODE_ON, &priv->state)) in icnss_pm_suspend()
5077 ret = icnss_send_smp2p(priv, ICNSS_POWER_SAVE_ENTER, in icnss_pm_suspend()
5080 priv->stats.pm_suspend++; in icnss_pm_suspend()
5081 set_bit(ICNSS_PM_SUSPEND, &priv->state); in icnss_pm_suspend()
5083 priv->stats.pm_suspend_err++; in icnss_pm_suspend()
5090 struct icnss_priv *priv = dev_get_drvdata(dev); in icnss_pm_resume() local
5093 if (priv->magic != ICNSS_MAGIC) { in icnss_pm_resume()
5095 dev, priv, priv->magic); in icnss_pm_resume()
5099 icnss_pr_vdbg("PM resume, state: 0x%lx\n", priv->state); in icnss_pm_resume()
5101 if (!priv->ops || !priv->ops->pm_resume || in icnss_pm_resume()
5102 icnss_is_smp2p_valid(priv, ICNSS_SMP2P_OUT_POWER_SAVE) || in icnss_pm_resume()
5103 !test_bit(ICNSS_DRIVER_PROBED, &priv->state)) in icnss_pm_resume()
5106 ret = priv->ops->pm_resume(dev); in icnss_pm_resume()
5110 priv->stats.pm_resume++; in icnss_pm_resume()
5111 clear_bit(ICNSS_PM_SUSPEND, &priv->state); in icnss_pm_resume()
5113 priv->stats.pm_resume_err++; in icnss_pm_resume()
5120 struct icnss_priv *priv = dev_get_drvdata(dev); in icnss_pm_suspend_noirq() local
5123 if (priv->magic != ICNSS_MAGIC) { in icnss_pm_suspend_noirq()
5125 dev, priv, priv->magic); in icnss_pm_suspend_noirq()
5129 icnss_pr_vdbg("PM suspend_noirq, state: 0x%lx\n", priv->state); in icnss_pm_suspend_noirq()
5131 if (!priv->ops || !priv->ops->suspend_noirq || in icnss_pm_suspend_noirq()
5132 !test_bit(ICNSS_DRIVER_PROBED, &priv->state)) in icnss_pm_suspend_noirq()
5135 ret = priv->ops->suspend_noirq(dev); in icnss_pm_suspend_noirq()
5139 priv->stats.pm_suspend_noirq++; in icnss_pm_suspend_noirq()
5140 set_bit(ICNSS_PM_SUSPEND_NOIRQ, &priv->state); in icnss_pm_suspend_noirq()
5142 priv->stats.pm_suspend_noirq_err++; in icnss_pm_suspend_noirq()
5149 struct icnss_priv *priv = dev_get_drvdata(dev); in icnss_pm_resume_noirq() local
5152 if (priv->magic != ICNSS_MAGIC) { in icnss_pm_resume_noirq()
5154 dev, priv, priv->magic); in icnss_pm_resume_noirq()
5158 icnss_pr_vdbg("PM resume_noirq, state: 0x%lx\n", priv->state); in icnss_pm_resume_noirq()
5160 if (!priv->ops || !priv->ops->resume_noirq || in icnss_pm_resume_noirq()
5161 !test_bit(ICNSS_DRIVER_PROBED, &priv->state)) in icnss_pm_resume_noirq()
5164 ret = priv->ops->resume_noirq(dev); in icnss_pm_resume_noirq()
5168 priv->stats.pm_resume_noirq++; in icnss_pm_resume_noirq()
5169 clear_bit(ICNSS_PM_SUSPEND_NOIRQ, &priv->state); in icnss_pm_resume_noirq()
5171 priv->stats.pm_resume_noirq_err++; in icnss_pm_resume_noirq()
5178 struct icnss_priv *priv = dev_get_drvdata(dev); in icnss_pm_runtime_suspend() local
5181 if (priv->device_id == ADRASTEA_DEVICE_ID) { in icnss_pm_runtime_suspend()
5186 if (priv->magic != ICNSS_MAGIC) { in icnss_pm_runtime_suspend()
5188 dev, priv, priv->magic); in icnss_pm_runtime_suspend()
5192 if (!priv->ops || !priv->ops->runtime_suspend || in icnss_pm_runtime_suspend()
5193 icnss_is_smp2p_valid(priv, ICNSS_SMP2P_OUT_POWER_SAVE)) in icnss_pm_runtime_suspend()
5197 ret = priv->ops->runtime_suspend(dev); in icnss_pm_runtime_suspend()
5199 if (test_bit(ICNSS_PD_RESTART, &priv->state) || in icnss_pm_runtime_suspend()
5200 !test_bit(ICNSS_MODE_ON, &priv->state)) in icnss_pm_runtime_suspend()
5203 ret = icnss_send_smp2p(priv, ICNSS_POWER_SAVE_ENTER, in icnss_pm_runtime_suspend()
5212 struct icnss_priv *priv = dev_get_drvdata(dev); in icnss_pm_runtime_resume() local
5215 if (priv->device_id == ADRASTEA_DEVICE_ID) { in icnss_pm_runtime_resume()
5220 if (priv->magic != ICNSS_MAGIC) { in icnss_pm_runtime_resume()
5222 dev, priv, priv->magic); in icnss_pm_runtime_resume()
5226 if (!priv->ops || !priv->ops->runtime_resume || in icnss_pm_runtime_resume()
5227 icnss_is_smp2p_valid(priv, ICNSS_SMP2P_OUT_POWER_SAVE)) in icnss_pm_runtime_resume()
5230 icnss_pr_vdbg("Runtime resume, state: 0x%lx\n", priv->state); in icnss_pm_runtime_resume()
5232 ret = priv->ops->runtime_resume(dev); in icnss_pm_runtime_resume()
5240 struct icnss_priv *priv = dev_get_drvdata(dev); in icnss_pm_runtime_idle() local
5242 if (priv->device_id == ADRASTEA_DEVICE_ID) { in icnss_pm_runtime_idle()