Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp942595pxb; Fri, 28 Jan 2022 13:48:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJz/Ga0GNoQ41PDZMccAWnbM44z4CIOG6FwDmQdDVHyglzstgsd3ca7zPtOz3/X7RxQdP9M1 X-Received: by 2002:a17:902:9a02:: with SMTP id v2mr10761355plp.138.1643406517871; Fri, 28 Jan 2022 13:48:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643406517; cv=none; d=google.com; s=arc-20160816; b=nQCUGEQ6SStEz52up7Lb91wb5J1QnWIlwwwcx22nwFnGEyNmUbm1UtK/zjit0ojx86 Ca17Tkcepa5tzi5TSH5/RH1JcH2Y4dWbzLhjzLWdSDxRI0o0cVlB2TulKFAyCTlGCElT WlX8QPBvs3gNMdmrFyeVr/nPYjRR19Dtl0MaTR3tQz1J2M5ig7gunot/gO7Cwrebq27g 4Wv7IjjxizRhPhQuvUZdYVB+CXw2yy1qvQmhlNmiphyHl3Gd+KucoTB1l15psEa5bhfq GvsTEswTUWgAz6IRaQhwWQnHxLWAPnwKMXZCmFRMgo2pzBwRrmYCQ/RSNZL9TKUZ4PYs UEBQ== 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=2CpJvXPo2f7MRYObSqB2TPJqiUKrFA3vxItu5+XYK4E=; b=Rpd0TwAy+4cAaf+k4a3WpYBuHKZigtGTlBwr/VYH0vJWE7OjZPSj0xOEUb7hCaoSvA bNp8EE84vxCSOnBwKRxQG5zC5cRTvvuKq8bNZO9WjOKeWxaoyWz2445EMRcnc21LcwF2 +FGR860Tr0tBZvgIxR6FnqX/bOjqPYj9IFI5ghO66FXgkz7tiVOYZ47rgTbxWlJdWIe1 OZcYLppEBR9iaptqFWNxFkwSEgs80vlHum22p0OSfLC6SVLzeBjW/gdzg969PFzjR7Fl F9e29pwYuAwKYlrXpo6v/D2dfThb3J4oJJrXuuZbgaIhVqQBHZOT34MwH7v3qwkAi4Jv MriQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=RMywaGeG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u16si6067762plq.488.2022.01.28.13.48.26; Fri, 28 Jan 2022 13:48:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=RMywaGeG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344548AbiA0XJL (ORCPT + 99 others); Thu, 27 Jan 2022 18:09:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58008 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344303AbiA0XIn (ORCPT ); Thu, 27 Jan 2022 18:08:43 -0500 Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2E64CC061749 for ; Thu, 27 Jan 2022 15:08:42 -0800 (PST) Received: by mail-pj1-x1030.google.com with SMTP id l24-20020a17090aec1800b001b55738f633so6043025pjy.1 for ; Thu, 27 Jan 2022 15:08:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2CpJvXPo2f7MRYObSqB2TPJqiUKrFA3vxItu5+XYK4E=; b=RMywaGeGSUmwaERdUZXc9MuVTXOPqFgSFhHBitMJ8rd4ASs7kZQ022V1CUjjIYErrP 1+LuIQdQlFuLiG+S0snlh+YJwpNbeCQv9GxVu8jX9W/6cq9Tx5JKPMsE5HDiBxywBrkn +LKU1Wi7Afnuc9KbFJYSnjvTkkmfduZqVbbW0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2CpJvXPo2f7MRYObSqB2TPJqiUKrFA3vxItu5+XYK4E=; b=02fRmD2nppB1B+c0tQstJwUIbYKCvSXPAikguLPFcBeJnqUkXV3dAW67NFrBWw1LK5 FNmMpMEVsy94a4kZTJfbiCEFrWFWdZUHBvzPn2C/p+lqjjgBX+QkWl8ihoQ2YsPyaGO1 t3QoPD6WV5Tkkg6wTq0A630fDPHo45Azf4ed6sSl5LDDLwjVGiyG7mN+RzK4N38o435r a28/wzeRaayQwlH3xIqFMxnagirDuxND0xuVwqAlkbOkgGFBrWTg0HOUeevAWP0+xjgd bYIHSUJ68/KRxyTcp27q/1RGxAAJptnxZ2yJPZrHCb0pM8G5cZxWAnqwiBsHMecQzX2k Da0w== X-Gm-Message-State: AOAM531W+0gBKyb1qyAB7p5ufGmsu+bLrY8zETPDiSsB6b4i/GnClQPA 4Ohv1JolOzScPfLr/+QEDftotA== X-Received: by 2002:a17:90a:de98:: with SMTP id n24mr6656488pjv.87.1643324921749; Thu, 27 Jan 2022 15:08:41 -0800 (PST) Received: from localhost ([2620:15c:202:201:723d:38a9:9e7f:3435]) by smtp.gmail.com with UTF8SMTPSA id ck21sm338858pjb.51.2022.01.27.15.08.40 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 27 Jan 2022 15:08:41 -0800 (PST) From: Brian Norris To: MyungJoo Ham , Kyungmin Park , Chanwoo Choi , Rob Herring Cc: linux-kernel@vger.kernel.org, linux-rockchip@lists.infradead.org, Lin Huang , linux-arm-kernel@lists.infradead.org, Derek Basehore , devicetree@vger.kernel.org, linux-pm@vger.kernel.org, Heiko Stuebner , Brian Norris Subject: [PATCH v2 09/15] PM / devfreq: rk3399_dmc: Support new disable-freq properties Date: Thu, 27 Jan 2022 15:07:20 -0800 Message-Id: <20220127150615.v2.9.I08d654522b8a1ae92ecb8d2e2a74511f778f61e5@changeid> X-Mailer: git-send-email 2.35.0.rc0.227.g00780c9af4-goog In-Reply-To: <20220127230727.3369358-1-briannorris@chromium.org> References: <20220127230727.3369358-1-briannorris@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Implement the newly-defined properties to allow disabling certain power-saving-at-idle features at higher frequencies. This is a rewritten version of work by Lin Huang . Signed-off-by: Brian Norris --- (no changes since v1) drivers/devfreq/rk3399_dmc.c | 51 +++++++++++++++++++++++++++++++++--- 1 file changed, 47 insertions(+), 4 deletions(-) diff --git a/drivers/devfreq/rk3399_dmc.c b/drivers/devfreq/rk3399_dmc.c index c4efbc15cbb1..fc740c1f6747 100644 --- a/drivers/devfreq/rk3399_dmc.c +++ b/drivers/devfreq/rk3399_dmc.c @@ -55,6 +55,12 @@ struct rk3399_dmcfreq { unsigned int ddr3_odt_dis_freq; unsigned int lpddr3_odt_dis_freq; unsigned int lpddr4_odt_dis_freq; + + unsigned int pd_idle_dis_freq; + unsigned int sr_idle_dis_freq; + unsigned int sr_mc_gate_idle_dis_freq; + unsigned int srpd_lite_idle_dis_freq; + unsigned int standby_idle_dis_freq; }; static int rk3399_dmcfreq_target(struct device *dev, unsigned long *freq, @@ -81,8 +87,25 @@ static int rk3399_dmcfreq_target(struct device *dev, unsigned long *freq, mutex_lock(&dmcfreq->lock); if (dmcfreq->regmap_pmu) { + unsigned int odt_pd_arg0 = dmcfreq->odt_pd_arg0; + unsigned int odt_pd_arg1 = dmcfreq->odt_pd_arg1; unsigned int odt_pd_arg2 = 0; + if (target_rate >= dmcfreq->sr_idle_dis_freq) + odt_pd_arg0 &= ~RK3399_SET_ODT_PD_0_SR_IDLE; + + if (target_rate >= dmcfreq->sr_mc_gate_idle_dis_freq) + odt_pd_arg0 &= ~RK3399_SET_ODT_PD_0_SR_MC_GATE_IDLE; + + if (target_rate >= dmcfreq->standby_idle_dis_freq) + odt_pd_arg0 &= ~RK3399_SET_ODT_PD_0_STANDBY_IDLE; + + if (target_rate >= dmcfreq->pd_idle_dis_freq) + odt_pd_arg1 &= ~RK3399_SET_ODT_PD_1_PD_IDLE; + + if (target_rate >= dmcfreq->srpd_lite_idle_dis_freq) + odt_pd_arg1 &= ~RK3399_SET_ODT_PD_1_SRPD_LITE_IDLE; + if (target_rate >= dmcfreq->odt_dis_freq) odt_pd_arg2 |= RK3399_SET_ODT_PD_2_ODT_ENABLE; @@ -91,10 +114,9 @@ static int rk3399_dmcfreq_target(struct device *dev, unsigned long *freq, * (power-down) timings and to enable or disable the * ODT (on-die termination) resistors. */ - arm_smccc_smc(ROCKCHIP_SIP_DRAM_FREQ, dmcfreq->odt_pd_arg0, - dmcfreq->odt_pd_arg1, - ROCKCHIP_SIP_CONFIG_DRAM_SET_ODT_PD, - odt_pd_arg2, 0, 0, 0, &res); + arm_smccc_smc(ROCKCHIP_SIP_DRAM_FREQ, odt_pd_arg0, odt_pd_arg1, + ROCKCHIP_SIP_CONFIG_DRAM_SET_ODT_PD, odt_pd_arg2, + 0, 0, 0, &res); } /* @@ -230,6 +252,16 @@ static int rk3399_dmcfreq_of_props(struct rk3399_dmcfreq *data, { int ret = 0; + /* + * These are all optional, and serve as minimum bounds. Give them large + * (i.e., never "disabled") values if the DT doesn't specify one. + */ + data->pd_idle_dis_freq = + data->sr_idle_dis_freq = + data->sr_mc_gate_idle_dis_freq = + data->srpd_lite_idle_dis_freq = + data->standby_idle_dis_freq = UINT_MAX; + ret |= of_property_read_u32(np, "rockchip,pd_idle", &data->pd_idle); ret |= of_property_read_u32(np, "rockchip,sr_idle", @@ -247,6 +279,17 @@ static int rk3399_dmcfreq_of_props(struct rk3399_dmcfreq *data, ret |= of_property_read_u32(np, "rockchip,lpddr4_odt_dis_freq", &data->lpddr4_odt_dis_freq); + ret |= of_property_read_u32(np, "rockchip,pd-idle-dis-freq-hz", + &data->pd_idle_dis_freq); + ret |= of_property_read_u32(np, "rockchip,sr-idle-dis-freq-hz", + &data->sr_idle_dis_freq); + ret |= of_property_read_u32(np, "rockchip,sr-mc-gate-idle-dis-freq-hz", + &data->sr_mc_gate_idle_dis_freq); + ret |= of_property_read_u32(np, "rockchip,srpd-lite-idle-dis-freq-hz", + &data->srpd_lite_idle_dis_freq); + ret |= of_property_read_u32(np, "rockchip,standby-idle-dis-freq-hz", + &data->standby_idle_dis_freq); + return ret; } -- 2.35.0.rc0.227.g00780c9af4-goog