Received: by 2002:a05:6359:6284:b0:131:369:b2a3 with SMTP id se4csp4590890rwb; Tue, 8 Aug 2023 10:35:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEeQOzcIkRUwMJpWebFSL3P5GQoL2dr3hDBFwXpH76+qHdl1ZnfhJYECJj8ik8pLpcbvJ5T X-Received: by 2002:a05:6402:7d7:b0:523:a09:c092 with SMTP id u23-20020a05640207d700b005230a09c092mr362767edy.24.1691516157120; Tue, 08 Aug 2023 10:35:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691516157; cv=none; d=google.com; s=arc-20160816; b=04cL1ZcskDsTRkX5t4XBFhNR+dxhId4gx+cMfH6ePRt+HI9DX9qFWFdJ4I+qYqNsP1 2UD1Ki5EVt1+10g8ybc269LGSddsOrwGMpHtJPlbbwVrjR15gIWQJ83jSPtaWsIDeqC7 t0i+XwEMklfYuSf+9lxOuMroVOsTAvp6xb9OkwSq+meE90RcQ2JRHvbc81AuH/MKI1o8 t+jj68XJDjgqXd+VtoTJ7fho25J6djInbbKN2Nebsh9CZdWoHN4jMLRSi+B0EhRFL4/v 9gRsjI1Q98Ho78mVedsnk7MbRExxUhuA48wIxy/KSoDw/0hb4twH/04u3Ztvch2CVEMv zRjg== 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=hhulJ2B+UKcn+t6Xuu7g05iIQSJ7dI3YjiyAFc3/tQ0=; fh=y1+X/pRjxdzQRgGjrF+FODoiAKnWkMgYUFzqjpRKFOk=; b=SxMT8UQ2BWShCJ5L/2+WlNdyFun+Jwr343aePissQlBCuKTVJEypoh9EuOS43rgDji R2bhkHeKFg1faTJ4BceqcE6wn4BUdMhuBugm6PzXkr2f+HB2TmKi8ebdGzFuNiAv5xy/ cYR4eWzIIrELl+GmqdvYom8S9h98V5NkmbMTLRcqchW67GIsu4ESwR7imKHhwojcsDLd kqMtDtm5w40aFLGftkbsGfWsMEt7BqX2lQoEOdvdDXrojJ1ZpS4YaeyvwZB4KFfdHV6Q kSDVsAmW5WtgEJnvyDY+GU63J01Hj9pJM0n1PP0ySjEjZ/qEQd+AcCrJhA00dhJdp6V4 t26A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b="EXHZ/CG/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bc18-20020a056402205200b005233ff6dfc3si2266775edb.642.2023.08.08.10.35.32; Tue, 08 Aug 2023 10:35:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b="EXHZ/CG/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231283AbjHHQjZ (ORCPT + 99 others); Tue, 8 Aug 2023 12:39:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56368 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232910AbjHHQio (ORCPT ); Tue, 8 Aug 2023 12:38:44 -0400 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 21B423A4D4; Tue, 8 Aug 2023 08:54:05 -0700 (PDT) Received: from pps.filterd (m0279864.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3783gSnl003039; Tue, 8 Aug 2023 05:14:58 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=hhulJ2B+UKcn+t6Xuu7g05iIQSJ7dI3YjiyAFc3/tQ0=; b=EXHZ/CG/MwUkzJtNaZ65srpw1AJ7InJeFCBh6NuAL9kks1LeDywOAueXAzunJkAfBN/1 sy/TDMHu4NydEkDhqq8tdK0kEiwRKZciwXutn+binMd5foGZ3XNCbTd1oVJzYkYjwcvP xlqOLDgBXr9NjNUBUk0ty34jUhAS7BG4B7T6gI7mKLHIlYIArN4aG01mHyjeTZlUylZF JTUFBOIPdjhAvyjwDWnRQgfLJswSiFX3r5VYBLx3vkLOzX6JSgmADeVrDuAFKWROSd5b kfgNe1J4a3TO64UJ+PLoE+Q6+OUpu+13dg5QKkXgfdU/MhyEtkYRqqV+fyArmOJEOnwf ow== Received: from nasanppmta03.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3sbcacra0t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 08 Aug 2023 05:14:58 +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 3785EwBr026459 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 8 Aug 2023 05:14:58 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.30; Mon, 7 Aug 2023 22:14:53 -0700 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 2/4] clk: qcom: branch: Add mem ops support for branch2 clocks Date: Tue, 8 Aug 2023 10:44:05 +0530 Message-ID: <20230808051407.647395-3-quic_imrashai@quicinc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230808051407.647395-1-quic_imrashai@quicinc.com> References: <20230808051407.647395-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: 7VFvVykTlM4aO3g2PJ0GZYL7x06iTa_L X-Proofpoint-ORIG-GUID: 7VFvVykTlM4aO3g2PJ0GZYL7x06iTa_L X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-08-08_03,2023-08-03_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 clxscore=1015 priorityscore=1501 impostorscore=0 mlxscore=0 adultscore=0 malwarescore=0 mlxlogscore=999 bulkscore=0 lowpriorityscore=0 phishscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2308080046 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,URIBL_BLOCKED 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 From: Taniya Das Clock CBCRs with memories need an update for memory before enable/disable of the clock. 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 | 38 +++++++++++++++++++++++++++++++++++ drivers/clk/qcom/clk-branch.h | 4 ++++ 2 files changed, 42 insertions(+) diff --git a/drivers/clk/qcom/clk-branch.c b/drivers/clk/qcom/clk-branch.c index fc4735f74f0f..95ffcd380039 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,43 @@ 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_branch *br = to_clk_branch(hw); + u32 val; + int count = 200; + + regmap_update_bits(br->clkr.regmap, br->mem_enable_reg, + br->mem_enable_ack_bit, br->mem_enable_ack_bit); + + regmap_read(br->clkr.regmap, br->mem_ack_reg, &val); + + while (count-- > 0) { + if (val & br->mem_enable_ack_bit) + return clk_branch2_enable(hw); + udelay(1); + regmap_read(br->clkr.regmap, br->mem_ack_reg, &val); + } + + return -EBUSY; +} + +static void clk_branch2_mem_disable(struct clk_hw *hw) +{ + struct clk_branch *br = to_clk_branch(hw); + + regmap_update_bits(br->clkr.regmap, br->mem_enable_reg, + br->mem_enable_ack_bit, 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(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..0ffda6bef00e 100644 --- a/drivers/clk/qcom/clk-branch.h +++ b/drivers/clk/qcom/clk-branch.h @@ -24,8 +24,11 @@ struct clk_branch { u32 hwcg_reg; u32 halt_reg; + u32 mem_enable_reg; + u32 mem_ack_reg; u8 hwcg_bit; u8 halt_bit; + u8 mem_enable_ack_bit; u8 halt_check; #define BRANCH_VOTED BIT(7) /* Delay on disable */ #define BRANCH_HALT 0 /* pol: 1 = halt */ @@ -85,6 +88,7 @@ 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) -- 2.25.1