From patchwork Wed Feb 1 18:36:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konrad Dybcio X-Patchwork-Id: 51511 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp442967wrn; Wed, 1 Feb 2023 10:37:49 -0800 (PST) X-Google-Smtp-Source: AK7set8ErZruttenRTJEVV3U61aR3aqVJiFgMzzbJwGkNXnH4/H2rlHesMgQ2Htm7jnMtOURo5c/ X-Received: by 2002:a05:6a20:8b20:b0:bf:5459:cc70 with SMTP id l32-20020a056a208b2000b000bf5459cc70mr1988845pzh.41.1675276669503; Wed, 01 Feb 2023 10:37:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675276669; cv=none; d=google.com; s=arc-20160816; b=1C9PbPLLz+HRfhC7NwYzzarJZDjd2M3I6CCKg9ZMbG521cVlaY+AzGsdSLvDXD83L5 VmKBjNAYePkMXxSfTO3y0vay1LvNzITnQoLVby9RIuu4PkvysvKrM5VmW07GzfgSKSm0 ns2A196q6J7QdLEYePw5fPxtG1hrNYj832yEg7trbeaPTNUNK+smGd2g3QW6vYlbavTz rqeq9FuHQDBkVLm39wT5yyZaf5NYBE9LBRCmlVupKGGqNqoiGwv3Hpw3QMIo9zSYc+hy Trpjxv7CKLAXXwcMJ6Rq9Wyc+s7IjIycpD+rvx16CP/gpbpSqOwfXYSxp+8QHHAkjiRX ETYg== 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=pDicGkl+5x/PXSx3Dad29Z0zKYmJ8UAe01LZn9BX9P0=; b=tkCI3dg1pz2HVkvj+fhp3LoSyQ2ra2pA0EBC7OaHEAjQm6J5nTXMSxYu47x1gsMoXt AMkFnjya22l4LGVgUEeZ7hKxyvuN5eUeBkF0rmU/7nYjcOwvjVZnpTfTNZzQZTzhebrV jdJrVqDX/v1/pklQWNFBAE/QbP6qBuTE3BFXGBMIajywcSVhI3n460cnE6cOcCuBw0LP fRiTgzlhaPAbMyxC5ISFHBV3siMuthMZP2xaMzHwb7xTzjcV0f9erjlALsmxZNpw1lN4 GiO2ytG1NmeS/veVGRz6lczZhloYXjxftzFDVe5ZZaZPYXkFuLEy+du2ZdpsHuVM9fWw 04jQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lgatjYCV; 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=linaro.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z5-20020a63b045000000b004f1b4633a46si74849pgo.413.2023.02.01.10.37.37; Wed, 01 Feb 2023 10:37:49 -0800 (PST) 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=@linaro.org header.s=google header.b=lgatjYCV; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230375AbjBAShH (ORCPT + 99 others); Wed, 1 Feb 2023 13:37:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231357AbjBAShF (ORCPT ); Wed, 1 Feb 2023 13:37:05 -0500 Received: from mail-ed1-x52d.google.com (mail-ed1-x52d.google.com [IPv6:2a00:1450:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A06AF80146 for ; Wed, 1 Feb 2023 10:36:33 -0800 (PST) Received: by mail-ed1-x52d.google.com with SMTP id n6so16003463edo.9 for ; Wed, 01 Feb 2023 10:36:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=pDicGkl+5x/PXSx3Dad29Z0zKYmJ8UAe01LZn9BX9P0=; b=lgatjYCVYPzRwVfKLWY0TbmS/6NaTm3qJxDaz+9esYJTY2atIDNJW5P+PvnrBmkuoP PJIjR6y5RscfxilsEijJ5S6XK/ozSce/dShr0Z1cdxBus5mtmVxe8reJwdkYQbEj7Uhs irGlD9UO2FEm2YJUriY6EnY7tqRJmerb2hdXKFppLyhIqfh5/CVABupPoOUXGAfvwhKR Qqb0jTbVarpsIwGeA/Ga7X4ttifcAmmlXFcF5BQJQ1+6mtbIgtV4jLalogay5i5UODtB ziKBng7yJfNtFh5VDjxCGMqGhQDsiX3dRc2j5OAot2bDYG3GMWd4wjmSGdR2Mvyu4qA8 QJdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pDicGkl+5x/PXSx3Dad29Z0zKYmJ8UAe01LZn9BX9P0=; b=8NiBhd6eoANlbEktFa3M9k5549oxJ9zqCY/R3IwaN2vZmzYNXDoEW7k6zYmee0d9u1 8AGKkL38EhpZt1nL3ozQ26sJj/Cbax7ip4SiX/myJ0C6JWHP96+uQPg/GhqFlkUn9mVC ca2zo63/f8xRSuoW+H2n/CgBenJ/nW5qLOK7MVMLy3XU0igqQvIwHN2RghTfj1keacZ1 I110wHtDFCybQtJ7DyPk0/ECqr4CfV3MM9IGAn42d+QmiwmRV4Ysiegb4EPCGITzGWDt 8rP/n/IWNbxzDIMfdgmVzPfso+OEH3gpISSLflQc6u9fhvPrSfLE8ukSv4bPWjFL8QvI B18g== X-Gm-Message-State: AO0yUKVsvelx7vJlhmgA/l0ZXywnxri0Om14xeAsAd4bJjo5drjWFJ8C QERIJ35IoRM4CKgrQY5JO/WWAA== X-Received: by 2002:a05:6402:1bcc:b0:499:b672:ee30 with SMTP id ch12-20020a0564021bcc00b00499b672ee30mr3154277edb.11.1675276591697; Wed, 01 Feb 2023 10:36:31 -0800 (PST) Received: from localhost.localdomain (abyl20.neoplus.adsl.tpnet.pl. [83.9.31.20]) by smtp.gmail.com with ESMTPSA id t13-20020a50d70d000000b00458b41d9460sm10297508edi.92.2023.02.01.10.36.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Feb 2023 10:36:31 -0800 (PST) From: Konrad Dybcio To: linux-arm-msm@vger.kernel.org, andersson@kernel.org, agross@kernel.org, krzysztof.kozlowski@linaro.org Cc: marijn.suijten@somainline.org, Konrad Dybcio , Michael Turquette , Stephen Boyd , linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 01/10] clk: qcom: branch: Add helper functions for setting retain bits Date: Wed, 1 Feb 2023 19:36:17 +0100 Message-Id: <20230201183626.351211-2-konrad.dybcio@linaro.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230201183626.351211-1-konrad.dybcio@linaro.org> References: <20230201183626.351211-1-konrad.dybcio@linaro.org> MIME-Version: 1.0 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_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756654909107310509?= X-GMAIL-MSGID: =?utf-8?q?1756654909107310509?= Most Qualcomm branch clocks come with a pretty usual set of bits that can enable memory retention by means of not turning off parts of the memory logic. Add them to the common header file and introduce helper functions for setting them instead of using magic writes. Signed-off-by: Konrad Dybcio --- v4 -> v5: - Make the helpers accept clk_branch instead of u64 reg drivers/clk/qcom/clk-branch.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/drivers/clk/qcom/clk-branch.h b/drivers/clk/qcom/clk-branch.h index 17a58119165e..55b3a2c3afed 100644 --- a/drivers/clk/qcom/clk-branch.h +++ b/drivers/clk/qcom/clk-branch.h @@ -37,6 +37,32 @@ struct clk_branch { struct clk_regmap clkr; }; +/* Branch clock common bits for HLOS-owned clocks */ +#define CBCR_FORCE_MEM_CORE_ON BIT(14) +#define CBCR_FORCE_MEM_PERIPH_ON BIT(13) +#define CBCR_FORCE_MEM_PERIPH_OFF BIT(12) + +static inline void qcom_branch_set_force_mem_core(struct regmap *regmap, + struct clk_branch clk, bool on) +{ + regmap_update_bits(regmap, clk.halt_reg, CBCR_FORCE_MEM_CORE_ON, + on ? CBCR_FORCE_MEM_CORE_ON : 0); +} + +static inline void qcom_branch_set_force_periph_on(struct regmap *regmap, + struct clk_branch clk, bool on) +{ + regmap_update_bits(regmap, clk.halt_reg, CBCR_FORCE_MEM_PERIPH_ON, + on ? CBCR_FORCE_MEM_PERIPH_ON : 0); +} + +static inline void qcom_branch_set_force_periph_off(struct regmap *regmap, + struct clk_branch clk, bool on) +{ + regmap_update_bits(regmap, clk.halt_reg, CBCR_FORCE_MEM_PERIPH_OFF, + on ? CBCR_FORCE_MEM_PERIPH_OFF : 0); +} + 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;