From nobody Tue Dec 2 01:26:46 2025 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.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 0ACD82BEFE0 for ; Sat, 22 Nov 2025 05:01:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763787677; cv=none; b=UiMafOgBpIxsNjgdKS0AYfL0acgpI1J9Ylnmwo/et7bSic5F5slcRIjfHFjCnV+BPH16z8OpDlUA9Uf5E5N59dMbiABvH3T9VIn8Nf4n+MRI2eVio0Af3eDaX85Hs+au+81GjY88ZiGTEJDxVgzHnzmniZbh4rZiw7P5mV4zk34= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763787677; c=relaxed/simple; bh=sK6XaW/k9ZaxCDlbgWVWFCP1NGxYDP2lPv4LzeW4fDw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=DcGyTBKAwKN2K+5H4JAWBmVN7FebbHuNuPPFTMu8L+02ewiTKepKRuZuFCL7zpvFMWniqN6gZ2bqyEHKJqr4+1GYXHOV3zTMB2PkDBpLCfX3n4SXSHKg4Fk39VZM1J4z+NhYkDvHPm5iWK0ugT930rBhKTC8m1F1Yrj1pnro88w= 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=eDuI3xSo; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=cyO+XAWt; arc=none smtp.client-ip=205.220.180.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="eDuI3xSo"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="cyO+XAWt" Received: from pps.filterd (m0279871.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 5AM4m1JI1949900 for ; Sat, 22 Nov 2025 05:01:15 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=zTkqjG69O6X OIlKcqlqk2XhnP8nX431WPafAy0gUQM4=; b=eDuI3xSo69u574bnJ8T13iUAIQF wHEK3sFXBZM45YEbZBOjLfm7nAb+D4TXHWWC4Qg0wudcspY6J1Chg5kN2t5KddVI YCLlvPKSww1rkzCo4MchqaQH3KmdMBxXEjq6+L5U8iLjXKcTlnzfzf40AO+CM4Er zSElcBdDcU6oSAIt58AZEJJAJ75lhU1dsvJ8y/m6spkWoHM2+YjCQm6LHhp4vPbl c+cn18bGWmtZXCWUoOpBaUulvrYWZg0n3nQxBifOaouOs2V+FlybMY3n4V47DJ2+ fjU+8+NKRGN1KCsd/mc+36/sIL5Trh5kiiBziynGb0I+dC4xOLSNOsjTAcg== Received: from mail-pl1-f200.google.com (mail-pl1-f200.google.com [209.85.214.200]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4ak6ff80mq-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Sat, 22 Nov 2025 05:01:14 +0000 (GMT) Received: by mail-pl1-f200.google.com with SMTP id d9443c01a7336-297f3710070so67398535ad.2 for ; Fri, 21 Nov 2025 21:01:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1763787673; x=1764392473; 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=zTkqjG69O6XOIlKcqlqk2XhnP8nX431WPafAy0gUQM4=; b=cyO+XAWtH/KV+sIVqtrziaazzVhp8AWN4YG0O/EtFpff/EkdvjzFNfzpO08WPaOwyI f7UBVy+NQ6Hbp2JS0r6Dnr1Kq3JMTI62sFK8V3e42VHI1ucGUPXBT8hd5SkDSpI8pWVj tNCg7KXYb1KtybFZz453EWXUdw0IYB5LGt/ByI/aZd3EkPOc6HexSJibh2gmTPPu1ZXo 6PHzwQJ55QYbFJQX+QN+1kXJgAe2hVAWoh2DD8ZACvMIGLPZBAiwOq2X5Q2JAq6lrmnS RTTEGO2JgytPIVgzb4NG3zmgE+lO5oooyEg6CP14taEaF6/DtsI0CPoiGlw77XBFj/0g RG7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763787673; x=1764392473; 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=zTkqjG69O6XOIlKcqlqk2XhnP8nX431WPafAy0gUQM4=; b=bQEF1KvRZLBfDn/53KlCAz0ZtddN+aAAsgB3vKh1nv55RkoHD1qMw7ifSFvQO1i/T1 hlhf3QgLvgYUmo/oG/xTknSeNMgkIIXPGFVYVnz5eod/MvOJk8HUF3kLOEIsnSCbEeVP 2yEXgabMkhXhE4tkVGCE+9FvwuOf/UvOxaKcbh2aOoAjrwLzZOmdstxeRwlcumGTEgjl iTxo0VqsKRxPDmzOZlDkrjRoL5pBTQ8GHWE5vobemyATLcaqdUdOo4xt5gKaGkqtp8sR GsLt/Ua6k1puKmA5NN/ZzzsQBseHd0uC8nAQbo898h0REyf7YSbvkUlY1MifKVmRgxCF GeNw== X-Forwarded-Encrypted: i=1; AJvYcCVDwzkDzi/NqdYs0yDioLTwNC/CKZy61nyD0ZAhqp8Jiv/acYQRQypsACWilLZ5A08AINtfm2lgkzr1nXY=@vger.kernel.org X-Gm-Message-State: AOJu0Yy8jlg+4d/bPExDsH83zSoRdUx7BQHZf2rxN6Oi/pjHfb/9Ywr7 nJLQGlJwmdXxu1WqMvw6iKlf3bito3JdivH72+hju93Kg8C/HfXZU5l4YuPPKykvzg1KBIu+n/C HvdpQAWtQ4Z8iOyLwlvWI4fsAq2v9YxiRNT4nwJPrjJRd14UpfsFpgV/XC8HCR/a2z20= X-Gm-Gg: ASbGncvnECLGNpf6BYVeuFx64yirXfzTwPuRamRi89+A6rv7+JP0X0MU7y5MMHv83ZR tvSzZL5ojX3CaZ6U1/sz3nsb5SITHLBcpzITtxhPwXY4jac4PDtR5xkdq7vPiAQk0RqbO8QvlbM uqBXLjPim9SEcYZwSQjrIDpcD0Qm/mpETlgcwDbKqiNHUz+fy1avpqUexehxdJRxUmclXnRTxP5 Ged/9JnQ++lim39ZCvYHpwpm8HL4ZiXNiv9gkhtIDj4m6IkROBAZWrMpPD9VaNIQNQkt95rBZgK 8B/XTGFKODrSWg1A627KNsyTg+H8m4qul/HChCFlXE3OlSSgIXtOIPz+wBV2we+3nvWZcdZ5I+y F0mc0XSwX0SS+VNMLgyRDkXkpsZwtBqp5he0RLkhh11s= X-Received: by 2002:a17:902:f706:b0:297:c889:ba37 with SMTP id d9443c01a7336-29b6c6a4a1fmr53069825ad.41.1763787673441; Fri, 21 Nov 2025 21:01:13 -0800 (PST) X-Google-Smtp-Source: AGHT+IFZ0RoRjWzpRX7f/7wrrm6o9a/zKalm16NuLlRAP24ZnpVfbAe1bUNnw6cUjpQSbL2g3JKMGg== X-Received: by 2002:a17:902:f706:b0:297:c889:ba37 with SMTP id d9443c01a7336-29b6c6a4a1fmr53069485ad.41.1763787672866; Fri, 21 Nov 2025 21:01:12 -0800 (PST) Received: from hu-ptalari-hyd.qualcomm.com ([202.46.22.19]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-29b5b138c08sm70688725ad.25.2025.11.21.21.01.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Nov 2025 21:01:12 -0800 (PST) From: Praveen Talari To: Andi Shyti , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Mukesh Kumar Savaliya , Viken Dadhaniya , Bjorn Andersson , Konrad Dybcio , Praveen Talari , linux-arm-msm@vger.kernel.org, linux-i2c@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: psodagud@quicinc.com, djaggi@quicinc.com, quic_msavaliy@quicinc.com, quic_vtanuku@quicinc.com, quic_arandive@quicinc.com, quic_shazhuss@quicinc.com Subject: [PATCH v1 06/12] soc: qcom: geni-se: Introduce helper APIs for performance control Date: Sat, 22 Nov 2025 10:30:12 +0530 Message-Id: <20251122050018.283669-7-praveen.talari@oss.qualcomm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251122050018.283669-1-praveen.talari@oss.qualcomm.com> References: <20251122050018.283669-1-praveen.talari@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-GUID: psTinXSRfAefjTVInfBJGF5Hj5QgrqGL X-Proofpoint-ORIG-GUID: psTinXSRfAefjTVInfBJGF5Hj5QgrqGL X-Authority-Analysis: v=2.4 cv=OsxCCi/t c=1 sm=1 tr=0 ts=6921439a cx=c_pps a=IZJwPbhc+fLeJZngyXXI0A==:117 a=fChuTYTh2wq5r3m49p7fHw==:17 a=6UeiqGixMTsA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=EUspDBNiAAAA:8 a=NwCh5GMA9Nt760FYQHkA:9 a=uG9DUKGECoFWVXl0Dc02:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMTIyMDAzNyBTYWx0ZWRfXwscjeJWbBxEv 52xBppNItVjlqJej9L1v01UwxLzPcQu8G6cW+0tT2Pm86iPi960wvhsvSW1O8rjIiUK3Hj05BLV nguIzQpkzcIdOOzAxhFqVcobEH3/lN+nFG67Azlxr0RV1lGwWfbwfKP6uYny5Yi0UKGZnxbJuzs gz0Ox7aZfwP7fSCe5NsCoLilrH57yODl/DUP7JzK0gCs2D5bj2vNQ/WZE7HR9XROUdwk+37AQGT wNyWEUNtR5ecIl4PJ3oO8uFMryBxtTpv1VlEezq3YrBEUyLsBNPg29vSIkrjdieRa5GqEiMRNBh 7rG+Cjpxc4injx9hyIipYsDKBHWycPpPP2tTN3+7mxSezXSoDqA9UK3hqJcapfJ7e00r5frkBpG gFG8GCL3b3epOQtxW9SrbObJlC0Miw== 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-11-22_01,2025-11-21_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 clxscore=1015 suspectscore=0 adultscore=0 bulkscore=0 malwarescore=0 phishscore=0 lowpriorityscore=0 impostorscore=0 spamscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2510240001 definitions=main-2511220037 Content-Type: text/plain; charset="utf-8" The GENI Serial Engine (SE) drivers (I2C, SPI, and SERIAL) currently manage performance levels and operating points directly. This resulting in code duplication across drivers. such as configuring a specific level or find and apply an OPP based on a clock frequency. Introduce two new helper APIs, geni_se_set_perf_level() and geni_se_set_perf_opp(), addresses this issue by providing a streamlined method for the GENI Serial Engine (SE) drivers to find and set the OPP based on the desired performance level, thereby eliminating redundancy. Signed-off-by: Praveen Talari --- drivers/soc/qcom/qcom-geni-se.c | 50 ++++++++++++++++++++++++++++++++ include/linux/soc/qcom/geni-se.h | 4 +++ 2 files changed, 54 insertions(+) diff --git a/drivers/soc/qcom/qcom-geni-se.c b/drivers/soc/qcom/qcom-geni-s= e.c index 30b58f2f2e5d..292afa18b86c 100644 --- a/drivers/soc/qcom/qcom-geni-se.c +++ b/drivers/soc/qcom/qcom-geni-se.c @@ -282,6 +282,12 @@ struct se_fw_hdr { #define geni_setbits32(_addr, _v) writel(readl(_addr) | (_v), _addr) #define geni_clrbits32(_addr, _v) writel(readl(_addr) & ~(_v), _addr) =20 +enum domain_idx { + DOMAIN_IDX_POWER, + DOMAIN_IDX_PERF, + DOMAIN_IDX_MAX +}; + /** * geni_se_get_qup_hw_version() - Read the QUP wrapper Hardware version * @se: Pointer to the corresponding serial engine. @@ -1075,6 +1081,50 @@ int geni_se_resources_state(struct geni_se *se, bool= power_on) } EXPORT_SYMBOL_GPL(geni_se_resources_state); =20 +/** + * geni_se_set_perf_level() - Set performance level for GENI SE. + * @se: Pointer to the struct geni_se instance. + * @level: The desired performance level. + * + * Sets the performance level by directly calling dev_pm_opp_set_level + * on the performance device associated with the SE. + * + * Return: 0 on success, or a negative error code on failure. + */ +int geni_se_set_perf_level(struct geni_se *se, unsigned long level) +{ + return dev_pm_opp_set_level(se->pd_list->pd_devs[DOMAIN_IDX_PERF], level); +} +EXPORT_SYMBOL_GPL(geni_se_set_perf_level); + +/** + * geni_se_set_perf_opp() - Set performance OPP for GENI SE by frequency. + * @se: Pointer to the struct geni_se instance. + * @clk_freq: The requested clock frequency. + * + * Finds the nearest operating performance point (OPP) for the given + * clock frequency and applies it to the SE's performance device. + * + * Return: 0 on success, or a negative error code on failure. + */ +int geni_se_set_perf_opp(struct geni_se *se, unsigned long clk_freq) +{ + struct device *perf_dev =3D se->pd_list->pd_devs[DOMAIN_IDX_PERF]; + struct dev_pm_opp *opp; + int ret; + + opp =3D dev_pm_opp_find_freq_floor(perf_dev, &clk_freq); + if (IS_ERR(opp)) { + dev_err(se->dev, "failed to find opp for freq %lu\n", clk_freq); + return PTR_ERR(opp); + } + + ret =3D dev_pm_opp_set_opp(perf_dev, opp); + dev_pm_opp_put(opp); + return ret; +} +EXPORT_SYMBOL_GPL(geni_se_set_perf_opp); + /** * geni_se_domain_attach() - Attach power domains to a GENI SE device. * @se: Pointer to the geni_se structure representing the GENI SE device. diff --git a/include/linux/soc/qcom/geni-se.h b/include/linux/soc/qcom/geni= -se.h index 8c9b847aaf20..cac999d6ca31 100644 --- a/include/linux/soc/qcom/geni-se.h +++ b/include/linux/soc/qcom/geni-se.h @@ -548,5 +548,9 @@ int geni_se_resources_state(struct geni_se *se, bool po= wer_on); int geni_load_se_firmware(struct geni_se *se, enum geni_se_protocol_type p= rotocol); =20 int geni_se_domain_attach(struct geni_se *se); + +int geni_se_set_perf_level(struct geni_se *se, unsigned long level); + +int geni_se_set_perf_opp(struct geni_se *se, unsigned long clk_freq); #endif #endif --=20 2.34.1