Received: by 2002:a05:7412:8521:b0:e2:908c:2ebd with SMTP id t33csp2027738rdf; Mon, 6 Nov 2023 02:32:22 -0800 (PST) X-Google-Smtp-Source: AGHT+IHZIc/M87L1Ewy4GL4PY3P1YT5/NBrXu8yjETlQfFyzJ6UC/3NLZkeQ1hLoiIRFqU2eHowr X-Received: by 2002:a17:902:c951:b0:1cc:5cbf:50d2 with SMTP id i17-20020a170902c95100b001cc5cbf50d2mr22207633pla.59.1699266741759; Mon, 06 Nov 2023 02:32:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699266741; cv=none; d=google.com; s=arc-20160816; b=bwqJk6KJ23GpDn9cqKnfbcnyWTc9eS5eyXFUlFdxdbG0XLj/ivh/CzbXzZRE6EvNc2 NhlvakomfqERXYSuZjWW9HxvncBC4t8oRbGs7eIALwibCBs0BQb1tT7RWxSTLoSf7Mm2 wOjOevVMEooP2V7D6jOaNztjnPHb79NNByYLWKir2JNvtwdKOWW9vhEdm57xLtSHBq40 XGPq45cWy8SPwmQ/xLHumfSNovF25qoU9UnO7IcEjtMeKuYRY2gMV4j3XLDymO2bUx5F T5V7WtM5nF0otJZD+PGxtjeojql3CRiHm2dvnGYvP9M3cpGbb8h36PpKq5HF5sUcHCp8 Kg7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ui0TpnDxm/PD0ICcBgQgSuY/u4cUR2raymATdRzjfng=; fh=v6VUKEElNlboLIHsQt1UYRxfm9qYNjqoB+TW2MThS9w=; b=cyl/4uZi8BdPqneqk8f7w9INlvTsNT1osmLDVECel7GXDAotGQnyYXVBBN/0Pb8UBd iue1VfEOHepAbGp3qyHxa62AVDTwGsG2Zs4dORIMeietlNcfNtVBUcoraGTfIoq81UAV 9TXykvgI8q2jJSjvDoqf6XtLV274bgs/pyB7Hw0f7YwX1UsbcOQlP+NIoKloSa/cHg5g sJQtndyKeHwu2Bgeg/awj4T5IJCuu9T/qREXIYrWojbcG6Ff2x48oQhng8I+DN+1eOSh 6bCknGLJ9ag7SEj0a9NUAoJCTxWWH2F1B/scA41cfS/qXMM7CYZKyncblZ915KGJNa+O Kq1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=FXMq7xX4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id z8-20020a170902d54800b001ca30930567si8057100plf.373.2023.11.06.02.32.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Nov 2023 02:32:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=FXMq7xX4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id A04078069F3C; Mon, 6 Nov 2023 02:31:28 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231230AbjKFKbO (ORCPT + 99 others); Mon, 6 Nov 2023 05:31:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34600 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231377AbjKFKbG (ORCPT ); Mon, 6 Nov 2023 05:31:06 -0500 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6CE0D76; Mon, 6 Nov 2023 02:31:00 -0800 (PST) Received: from pps.filterd (m0279867.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3A6AT8hl005917; Mon, 6 Nov 2023 10:30:57 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=qcppdkim1; bh=ui0TpnDxm/PD0ICcBgQgSuY/u4cUR2raymATdRzjfng=; b=FXMq7xX4tVFwynOgG67UFoOz/rQKUDDTyn+hF0vtCVvZgbicOCWdm9mdxHduJw++fnhq Jjd6cnHq/IUAgVesGpQzjrM0m7/dUUjfxv9ZCvTyyunD80qvscEeC0rJ6/ahn/u+VKHq BqZ/Ak4vi+JwLxME9I8yaNW+oxn0QDYVgHN1jS6zroivPxbuUGfce2p6ZamZrr5HhwPW +7ZvstWDSVkCOoHIQ4v48Sj8l8mhZK1HOrmFJbqeZNYAcPV2RQt8ffwaEVGoT6aJ6vuu ZgT3SiltAvz+mAGCtm+tEc/dcrGzrteDoMEZcZ5y4ZYGcxkCmZuDIw2aHYVobicErPeP Xw== Received: from nasanppmta03.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3u6xdu806r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 06 Nov 2023 10:30:57 +0000 Received: from nasanex01a.na.qualcomm.com (nasanex01a.na.qualcomm.com [10.52.223.231]) by NASANPPMTA03.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 3A6AUu3E007848 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 6 Nov 2023 10:30:56 GMT Received: from hu-imrashai-hyd.qualcomm.com (10.80.80.8) by nasanex01a.na.qualcomm.com (10.52.223.231) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.39; Mon, 6 Nov 2023 02:30:51 -0800 From: Imran Shaik To: Andy Gross , Konrad Dybcio , Michael Turquette , Stephen Boyd , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Bjorn Andersson CC: Taniya Das , Imran Shaik , , , , , Ajit Pandey , Jagadeesh Kona Subject: [PATCH V3 2/4] clk: qcom: branch: Add mem ops support for branch2 clocks Date: Mon, 6 Nov 2023 16:00:25 +0530 Message-ID: <20231106103027.3988871-3-quic_imrashai@quicinc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231106103027.3988871-1-quic_imrashai@quicinc.com> References: <20231106103027.3988871-1-quic_imrashai@quicinc.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nasanex01a.na.qualcomm.com (10.52.223.231) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: 4gvZTFpkkUmhGVkov1VJO46lonNShc6N X-Proofpoint-ORIG-GUID: 4gvZTFpkkUmhGVkov1VJO46lonNShc6N X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-06_08,2023-11-02_03,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 lowpriorityscore=0 suspectscore=0 mlxlogscore=999 priorityscore=1501 spamscore=0 impostorscore=0 mlxscore=0 malwarescore=0 clxscore=1015 bulkscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2310240000 definitions=main-2311060087 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 06 Nov 2023 02:31:28 -0800 (PST) From: Taniya Das Clock CBCRs with memories need an update for memory before enable/disable of the clock, which helps retain the respective block's register contents. Add support for the mem ops to handle this sequence. Signed-off-by: Taniya Das Signed-off-by: Imran Shaik --- drivers/clk/qcom/clk-branch.c | 39 +++++++++++++++++++++++++++++++++++ drivers/clk/qcom/clk-branch.h | 21 +++++++++++++++++++ 2 files changed, 60 insertions(+) diff --git a/drivers/clk/qcom/clk-branch.c b/drivers/clk/qcom/clk-branch.c index fc4735f74f0f..61bdd2147bed 100644 --- a/drivers/clk/qcom/clk-branch.c +++ b/drivers/clk/qcom/clk-branch.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 /* * Copyright (c) 2013, The Linux Foundation. All rights reserved. + * Copyright (c) 2023, Qualcomm Innovation Center, Inc. All rights reserved. */ #include @@ -134,6 +135,44 @@ static void clk_branch2_disable(struct clk_hw *hw) clk_branch_toggle(hw, false, clk_branch2_check_halt); } +static int clk_branch2_mem_enable(struct clk_hw *hw) +{ + struct clk_mem_branch *mem_br = to_clk_mem_branch(hw); + struct clk_branch branch = mem_br->branch; + const char *name = clk_hw_get_name(&branch.clkr.hw); + u32 val; + int ret; + + regmap_update_bits(branch.clkr.regmap, mem_br->mem_enable_reg, + mem_br->mem_enable_ack_mask, mem_br->mem_enable_ack_mask); + + ret = regmap_read_poll_timeout(branch.clkr.regmap, mem_br->mem_ack_reg, + val, val & mem_br->mem_enable_ack_mask, 0, 200); + if (ret) { + WARN(1, "%s mem enable failed\n", name); + return ret; + } + + return clk_branch2_enable(hw); +} + +static void clk_branch2_mem_disable(struct clk_hw *hw) +{ + struct clk_mem_branch *mem_br = to_clk_mem_branch(hw); + + regmap_update_bits(mem_br->branch.clkr.regmap, mem_br->mem_enable_reg, + mem_br->mem_enable_ack_mask, 0); + + return clk_branch2_disable(hw); +} + +const struct clk_ops clk_branch2_mem_ops = { + .enable = clk_branch2_mem_enable, + .disable = clk_branch2_mem_disable, + .is_enabled = clk_is_enabled_regmap, +}; +EXPORT_SYMBOL_GPL(clk_branch2_mem_ops); + const struct clk_ops clk_branch2_ops = { .enable = clk_branch2_enable, .disable = clk_branch2_disable, diff --git a/drivers/clk/qcom/clk-branch.h b/drivers/clk/qcom/clk-branch.h index 0cf800b9d08d..8ffed603c050 100644 --- a/drivers/clk/qcom/clk-branch.h +++ b/drivers/clk/qcom/clk-branch.h @@ -38,6 +38,23 @@ struct clk_branch { struct clk_regmap clkr; }; +/** + * struct clk_mem_branch - gating clock which are associated with memories + * + * @mem_enable_reg: branch clock memory gating register + * @mem_ack_reg: branch clock memory ack register + * @mem_enable_ack_mask: branch clock memory enable and ack field in @mem_ack_reg + * @branch: branch clock gating handle + * + * Clock which can gate its memories. + */ +struct clk_mem_branch { + u32 mem_enable_reg; + u32 mem_ack_reg; + u32 mem_enable_ack_mask; + struct clk_branch branch; +}; + /* Branch clock common bits for HLOS-owned clocks */ #define CBCR_CLK_OFF BIT(31) #define CBCR_NOC_FSM_STATUS GENMASK(30, 28) @@ -85,8 +102,12 @@ extern const struct clk_ops clk_branch_ops; extern const struct clk_ops clk_branch2_ops; extern const struct clk_ops clk_branch_simple_ops; extern const struct clk_ops clk_branch2_aon_ops; +extern const struct clk_ops clk_branch2_mem_ops; #define to_clk_branch(_hw) \ container_of(to_clk_regmap(_hw), struct clk_branch, clkr) +#define to_clk_mem_branch(_hw) \ + container_of(to_clk_branch(_hw), struct clk_mem_branch, branch) + #endif -- 2.25.1