From nobody Mon Feb 9 12:42:54 2026 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 54B1C30FC0B for ; Wed, 31 Dec 2025 04:56:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767156998; cv=none; b=g14wl6LXmghCJScTMNyssf6sNURNeicDbicJkYgT34VSjOJK+lSVPiK3D8/3FpyTs4621tSqjx0PFllBR//h/AmhpCS+Ej1fe7YtG3Pdgt1YlAkOIT6h7r+Sliu15V2+VfJsDAWOYkuM0UtXE/HlzmJfcbvO7gDRozwdnkyn5ag= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767156998; c=relaxed/simple; bh=D1O+si2Yt1LHRX9ttPtLSW9kr0/xClDgoku245+GvJk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=dj5uWoqK/M71fzc1pCh0Oi8tl43F2rN+RhQwTIorVl6/gP9PisLqnW+kgOn5PRCN1yd8gWQPehbU43MP6BATxoX2OBjTQLBFJm1Q5VXrtuv/StsUR089GmStd7fjydpkSkuvij1wVKuanuxp16kEI3T6v1H9yFUalABuKi1O/nQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=ncwQE9x+; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=VhThdok2; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="ncwQE9x+"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="VhThdok2" Received: from pps.filterd (m0279863.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 5BV1vK153971212 for ; Wed, 31 Dec 2025 04:56:35 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=qcppdkim1; bh=09GkqJKtIHi QNekPzoYMiNgzGedCPpCvBabWAf+0JyA=; b=ncwQE9x+LRdHyEhfxarpEX/n/FW ZzRNOOOaELV2g+BUKlqc5hhhQ8fjEcB+BiDWZkTMin3HWiSa7wFUHLDCxuMyNAPz RBJofHNUY9nmRxqOxJ/C3z+G49Igjy7w5mFvRul1r1zZBUcwrvIrXxnX2q5IG/3a jzfZd/T45y60yiVveI3SwJlIarlCuqPvce7j4P00Emudgr2neyihBeePbo56Yv8d mvD4St0syjGy//IhjJo7tUqyODDcqbnFSqEQyAWR95cuVd5NIKIOMzJrpGYbIDzO m1S4psHOh0ElDsT7xKJ72KvjT2q2Qk7KiNHfdeVPKsWUOHJPvpbKUlQLwvw== Received: from mail-pj1-f71.google.com (mail-pj1-f71.google.com [209.85.216.71]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4bcdky1wca-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Wed, 31 Dec 2025 04:56:35 +0000 (GMT) Received: by mail-pj1-f71.google.com with SMTP id 98e67ed59e1d1-34c2f670a06so13506394a91.3 for ; Tue, 30 Dec 2025 20:56:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1767156995; x=1767761795; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=09GkqJKtIHiQNekPzoYMiNgzGedCPpCvBabWAf+0JyA=; b=VhThdok2jZkshmSDmNPAfmlBJ/2xP3YRAfqcOjksFncWS7N3O3zTPLZ6pevDy3Da53 jvKWDDbqSHBcFAX/rPfXIzzEycFpeN08Thk01YLjILPdfeztN9zy2Oirxiu3AkDTt8JZ ak+2XUYEXmNnWVEyF08McoSCVfZMNrxDHiRFdViKyJQh51P+qGLI/qE40R51FNxN1Cab G7n2/8dMokQjMJjnr/AurEicMSn98OkSUqD0mXYn4d4GLrm6iyo4YYvLQ7/Z9rvgZLay 8Dmin5I1VPjT/nsnihx1MqWSCHosIFSNFo0SNOay+MqSKcnmh7n+pD86bRcOLpTeD2H+ BYfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767156995; x=1767761795; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=09GkqJKtIHiQNekPzoYMiNgzGedCPpCvBabWAf+0JyA=; b=tUsTCnxFpjleaHfaScwNGuWmpr60pQQ57qY7vwV+qMlnsfvBTXzUPqvwUkedJqtfZW 0PU1EhuUXcUUstR9P1fkWulf4FV/+Ss8jg2RjgzR58r8vLXVLCIfSZAMnEvuUskkXVeA Ddqiv2gRkwVKiwgMywvdo9uM+WdHjmQW8FEGMyd8Uv/8VZvra3OB0GMdf8OEAY8RCvw9 0UXsq6RdW12ZwqLQwjUQpGnG62AFVQJ/+lWB++bsOn9qKSoKdD4Bpx/Wvutc8ixKYlHn e0Ll9eSygIEXIAfsi7cB8yWg91HdhpHtVuMQTwE4E1K4cX/7qN1dsp4dK+Aac94Pflnz i/tQ== X-Forwarded-Encrypted: i=1; AJvYcCXl/oLgnsQEd7+tkq+GqM0CW3ohCKV8BE0dLVEFj0714GPJ1KA75tLm2LER1aQ72H/O/uVv8LCxGokAkN4=@vger.kernel.org X-Gm-Message-State: AOJu0Yz+DWDsvrUHRbDg7GS91ZkBKZujZNb9jVR6UD4zvxGpgXAIYJAP n+O48LGGpfOkksG10e8zlzVYxS48XQ7BSwH+eFN/dVrCKAMuAgp5WUUfhIug+J3p845rUTSBkuI ZzAN3FVRWUJZWuzTFm967Bmsw6LERYI18aLM2qY/aPfGczGau1JPxHi7VoXxmKvmhkIY= X-Gm-Gg: AY/fxX5fVnGW3ljNHmBfnSLXnb2ZdH3m9LnV6YMuhFcaZ56IEIzQjWRAI9sbRDehT9k D8rP4q/p36jMVoGRaJGqjCK71rENvw2jE4MrIRyCMgLb+XjCgcwCXW1o/f35vImwzodX6htffTx K54RFRlkAdH2BolBBokBkQJ+osLvFOict46GF2sHoe5wFaoXzvSDMzUjWyQiNnqJN6FloC2Aw/j G0Y5nX+FWWqzkwn2kLDYP0QURit6+AIy3fEIVrSGwKwtluFbntzwvzMWNfGhX4cclSGeyMFion+ 6mUaFeykENxn/2wpoPJhbD90lgGfC4OstmvONxXKtM3ffSKnKPbHl7FPWDmij8cvvIMHdRs7LX4 Q9GIFI52CHgEQKejZOOSBj4uFC3qjCoa7SB3GdQmq X-Received: by 2002:a17:90b:1f89:b0:340:6f07:fefa with SMTP id 98e67ed59e1d1-34e921af98amr31649621a91.20.1767156994899; Tue, 30 Dec 2025 20:56:34 -0800 (PST) X-Google-Smtp-Source: AGHT+IFPPklYGJKPHXvfbOG+LeQT6y471CntsLmLLEInh4Km4O3Wovsq7fcPsnxKQlHGWy69xSmyHQ== X-Received: by 2002:a17:90b:1f89:b0:340:6f07:fefa with SMTP id 98e67ed59e1d1-34e921af98amr31649597a91.20.1767156994398; Tue, 30 Dec 2025 20:56:34 -0800 (PST) Received: from hu-rdwivedi-hyd.qualcomm.com ([202.46.22.19]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-34e70d4f7d3sm34547697a91.4.2025.12.30.20.56.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Dec 2025 20:56:33 -0800 (PST) From: Ram Kumar Dwivedi To: mani@kernel.org, alim.akhtar@samsung.com, avri.altman@wdc.com, bvanassche@acm.org, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, James.Bottomley@HansenPartnership.com, martin.petersen@oracle.com, ram.dwivedi@oss.qualcomm.com, anjana.hari@oss.qualcomm.com Cc: linux-arm-msm@vger.kernel.org, linux-scsi@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Shazad Hussain Subject: [PATCH V3 4/4] ufs: ufs-qcom: Add support for firmware-managed resource abstraction Date: Wed, 31 Dec 2025 10:25:53 +0530 Message-Id: <20251231045553.622611-5-ram.dwivedi@oss.qualcomm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251231045553.622611-1-ram.dwivedi@oss.qualcomm.com> References: <20251231045553.622611-1-ram.dwivedi@oss.qualcomm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMjMxMDAzOSBTYWx0ZWRfXyt/cBILFFJ3R ccZ9DArJ3TlvxFmIuHL1hsLfBfBP5cWiEQI0wXyTTJRSIidWhmZuQBb7Ab9sS2qYKM9YmRDPW70 7pPWYv9ifivpwK4ZYnttzxOtRyHdYCWw0dnm6NEowKrrlz8T4QkdanLUHd3ttLp2QwHgIT6g59s G4bQbjUIOwxF+EDsFcp0KR9OrVI/RhNTkSM8yBp4MA3i+RuxBIGTo08w5PpHKDKmiu+mg7HTc5t SciB8SuuowvRCVn0VmNJJt8K24PMvq+gW0hr8U9LFsn87msW/zAFUQESZMY20TPtX79cXrUUhWV BOgPGgsJQaQ889wCRIRWNsMhVmmyxQyfW0DY6jE/RYhssP3vvlprAv40Tz18cZBGZve4uF1FBdp 6ttGGuNaNuSA00Dk4xv/ErfVkM12XTx+aIMIfyIILxQUVF2yNZWZidktnSn6krRMJ1mQVLgrhgl UaVNw8H9V+DCC6BFNJg== X-Authority-Analysis: v=2.4 cv=Wskm8Nfv c=1 sm=1 tr=0 ts=6954ad03 cx=c_pps a=UNFcQwm+pnOIJct1K4W+Mw==:117 a=fChuTYTh2wq5r3m49p7fHw==:17 a=wP3pNCr1ah4A:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=EUspDBNiAAAA:8 a=YNeBtJC1tzGph8_Y4V8A:9 a=uKXjsCUrEbL0IQVhDsJ9:22 X-Proofpoint-GUID: KZF_LGER3avB0Nuoc-nrY4I_Qk46tT10 X-Proofpoint-ORIG-GUID: KZF_LGER3avB0Nuoc-nrY4I_Qk46tT10 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2025-12-31_01,2025-12-31_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 spamscore=0 lowpriorityscore=0 priorityscore=1501 impostorscore=0 clxscore=1015 adultscore=0 bulkscore=0 phishscore=0 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2512120000 definitions=main-2512310039 Content-Type: text/plain; charset="utf-8" Add a compatible string for SA8255p platforms where resources such as PHY, clocks, regulators, and resets are managed by firmware through an SCMI server. Use the SCMI power protocol to abstract these resources and invoke power operations via runtime PM APIs (pm_runtime_get/put_sync). Introduce vendor operations (vops) for SA8255p targets to enable SCMI- based resource control. In this model, capabilities like clock scaling and gating are not yet supported; these will be added incrementally. Co-developed-by: Anjana Hari Signed-off-by: Anjana Hari Co-developed-by: Shazad Hussain Signed-off-by: Shazad Hussain Signed-off-by: Ram Kumar Dwivedi --- drivers/ufs/host/ufs-qcom.c | 164 +++++++++++++++++++++++++++++++++++- drivers/ufs/host/ufs-qcom.h | 1 + 2 files changed, 164 insertions(+), 1 deletion(-) diff --git a/drivers/ufs/host/ufs-qcom.c b/drivers/ufs/host/ufs-qcom.c index 8ebee0cc5313..ddca7b344642 100644 --- a/drivers/ufs/host/ufs-qcom.c +++ b/drivers/ufs/host/ufs-qcom.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -619,6 +620,27 @@ static int ufs_qcom_hce_enable_notify(struct ufs_hba *= hba, return err; } =20 +static int ufs_qcom_fw_managed_hce_enable_notify(struct ufs_hba *hba, + enum ufs_notify_change_status status) +{ + struct ufs_qcom_host *host =3D ufshcd_get_variant(hba); + + switch (status) { + case PRE_CHANGE: + ufs_qcom_select_unipro_mode(host); + break; + case POST_CHANGE: + ufs_qcom_enable_hw_clk_gating(hba); + ufs_qcom_ice_enable(host); + break; + default: + dev_err(hba->dev, "Invalid status %d\n", status); + return -EINVAL; + } + + return 0; +} + /** * ufs_qcom_cfg_timers - Configure ufs qcom cfg timers * @@ -789,6 +811,38 @@ static int ufs_qcom_resume(struct ufs_hba *hba, enum u= fs_pm_op pm_op) return ufs_qcom_ice_resume(host); } =20 +static int ufs_qcom_fw_managed_suspend(struct ufs_hba *hba, enum ufs_pm_op= pm_op, + enum ufs_notify_change_status status) +{ + struct ufs_qcom_host *host =3D ufshcd_get_variant(hba); + + if (status =3D=3D PRE_CHANGE) + return 0; + + if (hba->spm_lvl !=3D UFS_PM_LVL_5) { + dev_err(hba->dev, "Unsupported spm level %d\n", hba->spm_lvl); + return -EINVAL; + } + + pm_runtime_put_sync(hba->dev); + + return ufs_qcom_ice_suspend(host); +} + +static int ufs_qcom_fw_managed_resume(struct ufs_hba *hba, enum ufs_pm_op = pm_op) +{ + struct ufs_qcom_host *host =3D ufshcd_get_variant(hba); + int err; + + err =3D pm_runtime_resume_and_get(hba->dev); + if (err) { + dev_err(hba->dev, "PM runtime resume failed: %d\n", err); + return err; + } + + return ufs_qcom_ice_resume(host); +} + static void ufs_qcom_dev_ref_clk_ctrl(struct ufs_qcom_host *host, bool ena= ble) { if (host->dev_ref_clk_ctrl_mmio && @@ -1421,6 +1475,55 @@ static void ufs_qcom_exit(struct ufs_hba *hba) phy_exit(host->generic_phy); } =20 +static int ufs_qcom_fw_managed_init(struct ufs_hba *hba) +{ + struct device *dev =3D hba->dev; + struct ufs_qcom_host *host; + int err; + + host =3D devm_kzalloc(dev, sizeof(*host), GFP_KERNEL); + if (!host) + return -ENOMEM; + + host->hba =3D hba; + ufshcd_set_variant(hba, host); + + ufs_qcom_get_controller_revision(hba, &host->hw_ver.major, + &host->hw_ver.minor, &host->hw_ver.step); + + err =3D ufs_qcom_ice_init(host); + if (err) + goto out_variant_clear; + + ufs_qcom_get_default_testbus_cfg(host); + err =3D ufs_qcom_testbus_config(host); + if (err) + /* Failure is non-fatal */ + dev_warn(dev, "Failed to configure the testbus %d\n", err); + + hba->caps |=3D UFSHCD_CAP_WB_EN; + + ufs_qcom_advertise_quirks(hba); + host->hba->quirks &=3D ~UFSHCD_QUIRK_REINIT_AFTER_MAX_GEAR_SWITCH; + + hba->pm_lvl_min =3D UFS_PM_LVL_5; + hba->spm_lvl =3D hba->rpm_lvl =3D hba->pm_lvl_min; + + ufs_qcom_set_host_params(hba); + ufs_qcom_parse_gear_limits(hba); + + return 0; + +out_variant_clear: + ufshcd_set_variant(hba, NULL); + return err; +} + +static void ufs_qcom_fw_managed_exit(struct ufs_hba *hba) +{ + pm_runtime_put_sync(hba->dev); +} + /** * ufs_qcom_set_clk_40ns_cycles - Configure 40ns clk cycles * @@ -1950,6 +2053,39 @@ static int ufs_qcom_device_reset(struct ufs_hba *hba) return 0; } =20 +/** + * ufs_qcom_fw_managed_device_reset - Reset UFS device under FW-managed de= sign + * @hba: pointer to UFS host bus adapter + * + * In the firmware-managed reset model, cold boot power-on is handled + * automatically by the PM domain framework during SCMI protocol init, + * before ufshcd_device_reset() is reached. For subsequent resets + * (such as suspend/resume or recovery), the UFS driver must explicitly + * invoke PM runtime operations to reset the subsystem. + * + * Return: 0 on success or a negative error code on failure. + */ +static int ufs_qcom_fw_managed_device_reset(struct ufs_hba *hba) +{ + static bool is_boot =3D true; + int err; + + /* Skip reset on cold boot; perform it on subsequent calls */ + if (is_boot) { + is_boot =3D false; + return 0; + } + + pm_runtime_put_sync(hba->dev); + err =3D pm_runtime_resume_and_get(hba->dev); + if (err < 0) { + dev_err(hba->dev, "PM runtime resume failed: %d\n", err); + return err; + } + + return 0; +} + static void ufs_qcom_config_scaling_param(struct ufs_hba *hba, struct devfreq_dev_profile *p, struct devfreq_simple_ondemand_data *d) @@ -2229,6 +2365,20 @@ static const struct ufs_hba_variant_ops ufs_hba_qcom= _vops =3D { .freq_to_gear_speed =3D ufs_qcom_freq_to_gear_speed, }; =20 +static const struct ufs_hba_variant_ops ufs_hba_qcom_sa8255p_vops =3D { + .name =3D "qcom-sa8255p", + .init =3D ufs_qcom_fw_managed_init, + .exit =3D ufs_qcom_fw_managed_exit, + .hce_enable_notify =3D ufs_qcom_fw_managed_hce_enable_notify, + .pwr_change_notify =3D ufs_qcom_pwr_change_notify, + .apply_dev_quirks =3D ufs_qcom_apply_dev_quirks, + .fixup_dev_quirks =3D ufs_qcom_fixup_dev_quirks, + .suspend =3D ufs_qcom_fw_managed_suspend, + .resume =3D ufs_qcom_fw_managed_resume, + .dbg_register_dump =3D ufs_qcom_dump_dbg_regs, + .device_reset =3D ufs_qcom_fw_managed_device_reset, +}; + /** * ufs_qcom_probe - probe routine of the driver * @pdev: pointer to Platform device handle @@ -2239,9 +2389,16 @@ static int ufs_qcom_probe(struct platform_device *pd= ev) { int err; struct device *dev =3D &pdev->dev; + const struct ufs_hba_variant_ops *vops; + const struct ufs_qcom_drvdata *drvdata =3D device_get_match_data(dev); + + if (drvdata && drvdata->vops) + vops =3D drvdata->vops; + else + vops =3D &ufs_hba_qcom_vops; =20 /* Perform generic probe */ - err =3D ufshcd_pltfrm_init(pdev, &ufs_hba_qcom_vops); + err =3D ufshcd_pltfrm_init(pdev, vops); if (err) return dev_err_probe(dev, err, "ufshcd_pltfrm_init() failed\n"); =20 @@ -2269,10 +2426,15 @@ static const struct ufs_qcom_drvdata ufs_qcom_sm855= 0_drvdata =3D { .no_phy_retention =3D true, }; =20 +static const struct ufs_qcom_drvdata ufs_qcom_sa8255p_drvdata =3D { + .vops =3D &ufs_hba_qcom_sa8255p_vops +}; + static const struct of_device_id ufs_qcom_of_match[] __maybe_unused =3D { { .compatible =3D "qcom,ufshc" }, { .compatible =3D "qcom,sm8550-ufshc", .data =3D &ufs_qcom_sm8550_drvdata= }, { .compatible =3D "qcom,sm8650-ufshc", .data =3D &ufs_qcom_sm8550_drvdata= }, + { .compatible =3D "qcom,sa8255p-ufshc", .data =3D &ufs_qcom_sa8255p_drvda= ta }, {}, }; MODULE_DEVICE_TABLE(of, ufs_qcom_of_match); diff --git a/drivers/ufs/host/ufs-qcom.h b/drivers/ufs/host/ufs-qcom.h index 380d02333d38..1111ab34da01 100644 --- a/drivers/ufs/host/ufs-qcom.h +++ b/drivers/ufs/host/ufs-qcom.h @@ -313,6 +313,7 @@ struct ufs_qcom_host { struct ufs_qcom_drvdata { enum ufshcd_quirks quirks; bool no_phy_retention; + const struct ufs_hba_variant_ops *vops; }; =20 static inline u32 --=20 2.34.1