From patchwork Mon Jun 12 18:24:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konrad Dybcio X-Patchwork-Id: 106752 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp57621vqr; Mon, 12 Jun 2023 11:29:36 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4jIzmozmx/1iXiUQwS6bKyztF3NkUKkOQV9UsVH8yH9R3Tu9xEXt9T9llFwt+w95q4a4/I X-Received: by 2002:a17:903:244d:b0:1b0:56cf:b8c0 with SMTP id l13-20020a170903244d00b001b056cfb8c0mr8550187pls.13.1686594576430; Mon, 12 Jun 2023 11:29:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686594576; cv=none; d=google.com; s=arc-20160816; b=ssHG/MypPb2olXPfUvb3msPs3H0GPZncxQm/s6c6xWmxXOwOzL71F/JRDTFpHyuZ8R BS9sjmanT8yQjEX7ZnDSCENSQiXYHxK2QY2aHeRTwZA6Zk83ap+Pbvk8mJ2PscIR2GT3 hrkILNyOzpC+s5Dm7mYLHXFhM6+hVmJN/kjiqcI9LBPxP1GrnUjGvNkiGwcJ4JZbRV5s An3n88wObnEibucnNhApheJv3hp1/tDPSfyBZ9R/2kiRqLQifLlW2lVhI7xYwxUnjUfv UtnxqZG4RhkuOBX21PLyANle6mkuKRSu6g1WWw34UNhvCEHj4CzBW74uQT4uApHSeYKa XWHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=qoVwErVMHDjHjayDKUron2vfQdiFrlJxkN0o/O5bBtA=; b=A5+ByU8MLzs65kuUsQpyFoV2c4UhT9b44OsjCahQwOoD66XNMS+KAFSQQahmAaiype TRlCcC9zOxEvjHKXJOotZ8JJKcFKcqm5tV0pG+k2rqvUswQ249LaYQIIDVAxk5R1jt6/ h6GOsZC3UoZZFYih95EVZOK5QjPlUBn32PrnAauQzdeozM4mH96BAhkfBLZ3tKXiqZoi LsyiKEngJi6AA/rwDl7xhtxvIGEiGiEdh2fvFG5tQKVigTmtO53cYu2wmxblebMbpJxh 8B/iJnAqFIzMsc5gtfPODF4+pDa43smspPZJBrelmWige4QyFzbtqPoZwCCjtQlWAQCd rP/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qXRITVAt; 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 q21-20020a170902b11500b001b3c274fa2csi2442400plr.187.2023.06.12.11.29.23; Mon, 12 Jun 2023 11:29:36 -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=@linaro.org header.s=google header.b=qXRITVAt; 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 S238144AbjFLS0G (ORCPT + 99 others); Mon, 12 Jun 2023 14:26:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44754 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237761AbjFLSYx (ORCPT ); Mon, 12 Jun 2023 14:24:53 -0400 Received: from mail-lf1-x12f.google.com (mail-lf1-x12f.google.com [IPv6:2a00:1450:4864:20::12f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3682E113 for ; Mon, 12 Jun 2023 11:24:52 -0700 (PDT) Received: by mail-lf1-x12f.google.com with SMTP id 2adb3069b0e04-4f004cc54f4so5580732e87.3 for ; Mon, 12 Jun 2023 11:24:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1686594290; x=1689186290; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=qoVwErVMHDjHjayDKUron2vfQdiFrlJxkN0o/O5bBtA=; b=qXRITVAtc1dn+CSZ4LgYXqwiWtNcR9mM4H2dFeg2jwOiGmILmjhh9sOyoG9fN5rCmp WLYDkWb5McIecYyfKkI69ZqYiLz5SGzxRpDPGg4lk/5GFXMklr7T2H1jtr8HLvPkTJyt xZAALrjt+tnR+90+QknVaEAGd+A3NQo7TxDQyDzrEGLCT+5l/oqfs5pU3gCpZcBweaXS fsTalvBFG3SQs+djzENhPESI5/lCFktIy0OSAE05yT6V3LxjInpFAMS7uj6tB9VmZ+BU pMxJ+wiD4EJ+qcLUq/xIvhfe+ne+1KP+1WgB4R8+EqNSehSgLOcf5ptXcB842i4PThoV 6kKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686594290; x=1689186290; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qoVwErVMHDjHjayDKUron2vfQdiFrlJxkN0o/O5bBtA=; b=cwYK0+uK2PeY38mkRIfEwBLAmbgqX2sPBlu9BiTvKwzBvkQJZv/0Vkfj9yZ4kK16Qa kWWeHoayVhWgL8LET6wy9rL+EnwKIIux/2OgA90lSBmABM2Vrc5jtvDZEE8Gzbi1dNb2 ZQVmmXnUg/5aQoyvIM6RXKUulqRDQfmzaExv6re9viGg6wghTClEhpug+uIjt7dVMydc Af5OrRpSWkUpRDtgK6HmjJUueBlckA1r/IzH3bG2WKAVWlUg0rmcJM3CmKw3dMdCAbzY J+9zb8VVof/rvUIYUacDMjPvCT7V1HJGoW51uQZRalh/lr0JRvuM0eQiEy7AjHlE3ir+ KU4Q== X-Gm-Message-State: AC+VfDwHg+byqzlFj91rFExgQmHkC3K+8/w84vvK7xEYmd1lOhyQyHp2 Cmib84W3bWmeXMhw647rgCJbT/kOhNgPlRsLDeM= X-Received: by 2002:ac2:4da7:0:b0:4f6:54c2:35bd with SMTP id h7-20020ac24da7000000b004f654c235bdmr4391451lfe.11.1686594290517; Mon, 12 Jun 2023 11:24:50 -0700 (PDT) Received: from [192.168.1.101] (abyj190.neoplus.adsl.tpnet.pl. [83.9.29.190]) by smtp.gmail.com with ESMTPSA id v24-20020ac25938000000b004f64073a252sm1502035lfi.96.2023.06.12.11.24.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Jun 2023 11:24:50 -0700 (PDT) From: Konrad Dybcio Date: Mon, 12 Jun 2023 20:24:26 +0200 Subject: [PATCH v3 09/23] interconnect: qcom: smd-rpm: Add rpmcc handling skeleton code MIME-Version: 1.0 Message-Id: <20230526-topic-smd_icc-v3-9-5fb7d39b874f@linaro.org> References: <20230526-topic-smd_icc-v3-0-5fb7d39b874f@linaro.org> In-Reply-To: <20230526-topic-smd_icc-v3-0-5fb7d39b874f@linaro.org> To: Andy Gross , Bjorn Andersson , Michael Turquette , Stephen Boyd , Georgi Djakov , Leo Yan , Evan Green , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: Marijn Suijten , linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, Konrad Dybcio X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1686594276; l=3554; i=konrad.dybcio@linaro.org; s=20230215; h=from:subject:message-id; bh=CbTTRxJto8qrm6plde8cKMqpaBb1rdIRss/XEaPuhyo=; b=V8ybrcxkJtmQI9Y0OyQAx8gGXhOVsVAWAmYQeFQkAko3KQzznKBDzT0BSCz3JdRdcGbYuLwET JS0y1CmqbY2C6HAx8dSeEQJLyW8lRPvW8sLXe5nSdgeM03lyxl5a3/L X-Developer-Key: i=konrad.dybcio@linaro.org; a=ed25519; pk=iclgkYvtl2w05SSXO5EjjSYlhFKsJ+5OSZBjOkQuEms= 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,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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768522594559159053?= X-GMAIL-MSGID: =?utf-8?q?1768522594559159053?= Introduce qcom_icc_rpm_set_bus_rate() in preparation for handling RPM clock resources within the interconnect framework. This lets us greatly simplify all of the code handling, as setting the rate comes down to: u32 rate_khz = max(clk.sleep_rate, clk.active_rate, clk_a.active_rate) write_to_rpm(clock.description, rate_khz); Signed-off-by: Konrad Dybcio --- drivers/interconnect/qcom/icc-rpm.h | 15 +++++++++++++++ drivers/interconnect/qcom/smd-rpm.c | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/drivers/interconnect/qcom/icc-rpm.h b/drivers/interconnect/qcom/icc-rpm.h index 9b4ea4e39b9f..aec192321411 100644 --- a/drivers/interconnect/qcom/icc-rpm.h +++ b/drivers/interconnect/qcom/icc-rpm.h @@ -22,6 +22,18 @@ enum qcom_icc_type { QCOM_ICC_QNOC, }; +/** + * struct rpm_clk_resource - RPM bus clock resource + * @resource_type: RPM resource type of the clock resource + * @clock_id: index of the clock resource of a specific resource type + * @branch: whether the resource represents a branch clock +*/ +struct rpm_clk_resource { + u32 resource_type; + u32 clock_id; + bool branch; +}; + #define NUM_BUS_CLKS 2 /** @@ -47,6 +59,7 @@ struct qcom_icc_provider { int qos_offset; u64 bus_clk_rate[NUM_BUS_CLKS]; struct clk_bulk_data bus_clks[NUM_BUS_CLKS]; + const struct rpm_clk_resource *bus_clk_desc; struct clk_bulk_data *intf_clks; bool keep_alive; bool is_on; @@ -104,6 +117,7 @@ struct qcom_icc_desc { struct qcom_icc_node * const *nodes; size_t num_nodes; const char * const *bus_clocks; + const struct rpm_clk_resource *bus_clk_desc; const char * const *intf_clocks; size_t num_intf_clocks; bool keep_alive; @@ -125,5 +139,6 @@ int qnoc_remove(struct platform_device *pdev); bool qcom_icc_rpm_smd_available(void); int qcom_icc_rpm_smd_send(int ctx, int rsc_type, int id, u32 val); +int qcom_icc_rpm_set_bus_rate(const struct rpm_clk_resource *clk, u32 active_rate, u32 sleep_rate); #endif diff --git a/drivers/interconnect/qcom/smd-rpm.c b/drivers/interconnect/qcom/smd-rpm.c index b0183262ba66..433276f1e671 100644 --- a/drivers/interconnect/qcom/smd-rpm.c +++ b/drivers/interconnect/qcom/smd-rpm.c @@ -16,6 +16,7 @@ #include "icc-rpm.h" #define RPM_KEY_BW 0x00007762 +#define QCOM_RPM_SMD_KEY_RATE 0x007a484b static struct qcom_smd_rpm *icc_smd_rpm; @@ -44,6 +45,38 @@ int qcom_icc_rpm_smd_send(int ctx, int rsc_type, int id, u32 val) } EXPORT_SYMBOL_GPL(qcom_icc_rpm_smd_send); +int qcom_icc_rpm_set_bus_rate(const struct rpm_clk_resource *clk, u32 active_rate, u32 sleep_rate) +{ + struct clk_smd_rpm_req req = { + .key = cpu_to_le32(QCOM_RPM_SMD_KEY_RATE), + .nbytes = cpu_to_le32(sizeof(u32)), + }; + int ret; + + /* Branch clocks are only on/off */ + if (clk->branch) { + active_rate = !!active_rate; + sleep_rate = !!sleep_rate; + } + + req.value = cpu_to_le32(active_rate); + ret = qcom_rpm_smd_write(icc_smd_rpm, + QCOM_SMD_RPM_ACTIVE_STATE, + clk->resource_type, + clk->clock_id, + &req, sizeof(req)); + if (ret) + return ret; + + req.value = cpu_to_le32(sleep_rate); + return qcom_rpm_smd_write(icc_smd_rpm, + QCOM_SMD_RPM_SLEEP_STATE, + clk->resource_type, + clk->clock_id, + &req, sizeof(req)); +} +EXPORT_SYMBOL_GPL(qcom_icc_rpm_set_bus_rate); + static int qcom_icc_rpm_smd_remove(struct platform_device *pdev) { icc_smd_rpm = NULL;