wifi: ath12k: Power down userPD
authorSowmiya Sree Elavalagan <quic_ssreeela@quicinc.com>
Fri, 21 Mar 2025 10:52:49 +0000 (16:22 +0530)
committerJeff Johnson <jeff.johnson@oss.qualcomm.com>
Tue, 25 Mar 2025 14:55:45 +0000 (07:55 -0700)
Set the stop bit in SMEM to power down the userPD. Wait for stop-ack IRQ
to indicate power down completion. Release the userPD firmware using its
peripheral ID.

Tested-on: IPQ5332 hw1.0 AHB WLAN.WBE.1.3.1-00130-QCAHKSWPL_SILICONZ-1

Signed-off-by: Sowmiya Sree Elavalagan <quic_ssreeela@quicinc.com>
Reviewed-by: Vasanthakumar Thiagarajan <vasanthakumar.thiagarajan@oss.qualcomm.com>
Signed-off-by: Raj Kumar Bhagat <quic_rajkbhag@quicinc.com>
Link: https://patch.msgid.link/20250321-ath12k-ahb-v12-12-bb389ed76ae5@quicinc.com
Signed-off-by: Jeff Johnson <jeff.johnson@oss.qualcomm.com>
drivers/net/wireless/ath/ath12k/ahb.c

index 212e689e05fa4bb3ce09d45f2a04238498d836e8..1c2171e2bb73a17369e481da94b03b7a4ea30cce 100644 (file)
@@ -463,6 +463,34 @@ err_fw:
        return ret;
 }
 
+static void ath12k_ahb_power_down(struct ath12k_base *ab, bool is_suspend)
+{
+       struct ath12k_ahb *ab_ahb = ath12k_ab_to_ahb(ab);
+       unsigned long time_left;
+       u32 pasid;
+       int ret;
+
+       qcom_smem_state_update_bits(ab_ahb->stop_state, BIT(ab_ahb->stop_bit),
+                                   BIT(ab_ahb->stop_bit));
+
+       time_left = wait_for_completion_timeout(&ab_ahb->userpd_stopped,
+                                               ATH12K_USERPD_STOP_TIMEOUT);
+       if (!time_left) {
+               ath12k_err(ab, "UserPD stop wait timed out\n");
+               return;
+       }
+
+       qcom_smem_state_update_bits(ab_ahb->stop_state, BIT(ab_ahb->stop_bit), 0);
+
+       pasid = (u32_encode_bits(ab_ahb->userpd_id, ATH12K_USERPD_ID_MASK)) |
+               ATH12K_AHB_UPD_SWID;
+       /* Release the firmware */
+       ret = qcom_scm_pas_shutdown(pasid);
+       if (ret)
+               ath12k_err(ab, "scm pas shutdown failed for userPD%d: %d\n",
+                          ab_ahb->userpd_id, ret);
+}
+
 static void ath12k_ahb_init_qmi_ce_config(struct ath12k_base *ab)
 {
        struct ath12k_qmi_ce_cfg *cfg = &ab->qmi.ce_cfg;
@@ -679,6 +707,7 @@ static const struct ath12k_hif_ops ath12k_ahb_hif_ops_ipq5332 = {
        .irq_disable = ath12k_ahb_ext_irq_disable,
        .map_service_to_pipe = ath12k_ahb_map_service_to_pipe,
        .power_up = ath12k_ahb_power_up,
+       .power_down = ath12k_ahb_power_down,
 };
 
 static irqreturn_t ath12k_userpd_irq_handler(int irq, void *data)
@@ -1095,6 +1124,7 @@ static void ath12k_ahb_remove(struct platform_device *pdev)
        struct ath12k_base *ab = platform_get_drvdata(pdev);
 
        if (test_bit(ATH12K_FLAG_QMI_FAIL, &ab->dev_flags)) {
+               ath12k_ahb_power_down(ab, false);
                ath12k_qmi_deinit_service(ab);
                goto qmi_fail;
        }