Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp939695pxb; Fri, 28 Jan 2022 13:43:44 -0800 (PST) X-Google-Smtp-Source: ABdhPJyDCY4r6ibH7o4oXhpbmY+FmOvpZF2KE/1CcNvyNASd2RIBzhnaOJgg7+GjGmSvWfTt6tB3 X-Received: by 2002:a05:6402:27c7:: with SMTP id c7mr10049215ede.276.1643406224355; Fri, 28 Jan 2022 13:43:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643406224; cv=none; d=google.com; s=arc-20160816; b=dZSqsKLqT1Yp9FAMCqF5Sa+nyJR4z6M8SQcBCG9uWOtzagWhMWB8s/GTTCFQCY8PZS YvTI7fH/sklYC2qD9esXyUgwwUsjryPtI3Y4NGEo80VsDDjQoMfn814yCSEIt6GFJ6F1 ff0CTjxZjphTJZLR/VUWQrxIDylhJc2IktKzdX/I7m+vfRCjBsFyCccK5eJzvkhwJBjP L2pMcdw2vQZA+tayCUNoeCwQVJuFP6HEnFBscj1kS14hhJjS8x06E9yvBtN+xC7U5qlx 6Ft3LMiEXf40GMdn1BPf5F4/l25TVOSvkAFT/yhvq05nqMuw8xlP3op6rXSI8vUofOnn MK+A== 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=P0joUK/pdUbQ+tkRTC3slVsYBufXst0qResCEw1GAIA=; b=n+FkJ3iLsQFBphv2kHQx1fJAFyXE8plZyVuGs6skX73ye7cDL3h9vYJHHkoCkP8PzE LpxFZQUBY7diiAqHEKJ+yVxaKKOPJ39PdrvJtzbo8NEBDnCSm7MbbKXnF9gT2wwkxBjM kP98WaT8Mqi3b4kmdgO4QLLa4w1NoQ1eZOtct0PogpSlMf0uG9qEJIJ4zR1OisWPLem1 ghkJJPi5e3CV+BwJIRpcGQdrxebpl1kplEjTmueri2nIpw9D9dwAXCYdDskeQ0kPlDgE woma+OtqRW7B99DtqZsb83I5efqi4O1bYczYt0yy0rDMlzL4OciFBQI2paZhe2vPHjQ8 lXzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="BnDRXk0/"; 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 nb42si4016573ejc.842.2022.01.28.13.43.17; Fri, 28 Jan 2022 13:43:44 -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="BnDRXk0/"; 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 S1344357AbiA0XIw (ORCPT + 99 others); Thu, 27 Jan 2022 18:08:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58004 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344260AbiA0XIn (ORCPT ); Thu, 27 Jan 2022 18:08:43 -0500 Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 28283C06175E for ; Thu, 27 Jan 2022 15:08:40 -0800 (PST) Received: by mail-pl1-x629.google.com with SMTP id i1so4185178pla.9 for ; Thu, 27 Jan 2022 15:08:40 -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=P0joUK/pdUbQ+tkRTC3slVsYBufXst0qResCEw1GAIA=; b=BnDRXk0/6EBRLVuizHHpYzMVT205phm4z1vtVYFekaSNBBGlmSe7dnC89KkP+OZt1G siu7id/3fNo2OQJWUz2DUH2Qqu3hNfEMPvBy0PFOSDsE0iX3SBC8JOdtXPCvtW9Er8p0 4nBNdSrt4WvJktSG23xNKi00oMJoBAbhFo92w= 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=P0joUK/pdUbQ+tkRTC3slVsYBufXst0qResCEw1GAIA=; b=4Pmt7U0vnMC5E7wmLeJjnN8DeURBJdc1m/qrVPJdXyde+NpARPRHOmnz+cQ/JyHuuE kDb46vJCt8xK/KZD0Fu06NyB/rioSKyBVI0/6CWLD8PDx8KUPxM/MSupnVRqqNXulB7j A9xJhZCo+ivXBXVXO928rpb6fYJgrHovoFhoYA/aiI9L1vuvySuGGKrfWRHCrDa9J3Ga o0M2mDRzIV/eBgnt28N11bBbQZQx09UdBY1V8bbOq44I2xsoVcFYWFVD3Ma7Ag/tt/DS 2QcKcagYKPumiGcqToD6PNxgOy7Wtm7+FfsWfL1ovDPrayuo7rURnQj82GYjch8DKDXT WYdA== X-Gm-Message-State: AOAM530Xt/KCYAnncb8QPgVSI8guOXoXdaqQPCimaeFJe6wDfvjVP1Q5 KoRfBl9FQ3AAIVNO/gNax4FLnP05Ofzuww== X-Received: by 2002:a17:90b:4b83:: with SMTP id lr3mr16431459pjb.42.1643324919686; Thu, 27 Jan 2022 15:08:39 -0800 (PST) Received: from localhost ([2620:15c:202:201:723d:38a9:9e7f:3435]) by smtp.gmail.com with UTF8SMTPSA id s6sm369704pjg.22.2022.01.27.15.08.38 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 27 Jan 2022 15:08:39 -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 08/15] PM / devfreq: rk3399_dmc: Use bitfield macro definitions for ODT_PD Date: Thu, 27 Jan 2022 15:07:19 -0800 Message-Id: <20220127150615.v2.8.I0f36da588afd01d0dc9ce5866240efa34bd91e21@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 We're going to add new usages, and it's cleaner to work with macros instead of comments and magic numbers. Signed-off-by: Brian Norris --- (no changes since v1) drivers/devfreq/rk3399_dmc.c | 43 ++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/drivers/devfreq/rk3399_dmc.c b/drivers/devfreq/rk3399_dmc.c index 8f447217303f..c4efbc15cbb1 100644 --- a/drivers/devfreq/rk3399_dmc.c +++ b/drivers/devfreq/rk3399_dmc.c @@ -5,6 +5,7 @@ */ #include +#include #include #include #include @@ -23,6 +24,15 @@ #include #include +#define RK3399_SET_ODT_PD_0_SR_IDLE GENMASK(7, 0) +#define RK3399_SET_ODT_PD_0_SR_MC_GATE_IDLE GENMASK(15, 8) +#define RK3399_SET_ODT_PD_0_STANDBY_IDLE GENMASK(31, 16) + +#define RK3399_SET_ODT_PD_1_PD_IDLE GENMASK(11, 0) +#define RK3399_SET_ODT_PD_1_SRPD_LITE_IDLE GENMASK(27, 16) + +#define RK3399_SET_ODT_PD_2_ODT_ENABLE BIT(0) + struct rk3399_dmcfreq { struct device *dev; struct devfreq *devfreq; @@ -55,7 +65,6 @@ static int rk3399_dmcfreq_target(struct device *dev, unsigned long *freq, unsigned long old_clk_rate = dmcfreq->rate; unsigned long target_volt, target_rate; struct arm_smccc_res res; - bool odt_enable = false; int err; opp = devfreq_recommended_opp(dev, freq, flags); @@ -72,8 +81,10 @@ static int rk3399_dmcfreq_target(struct device *dev, unsigned long *freq, mutex_lock(&dmcfreq->lock); if (dmcfreq->regmap_pmu) { + unsigned int odt_pd_arg2 = 0; + if (target_rate >= dmcfreq->odt_dis_freq) - odt_enable = true; + odt_pd_arg2 |= RK3399_SET_ODT_PD_2_ODT_ENABLE; /* * This makes a SMC call to the TF-A to set the DDR PD @@ -83,7 +94,7 @@ static int rk3399_dmcfreq_target(struct device *dev, unsigned long *freq, arm_smccc_smc(ROCKCHIP_SIP_DRAM_FREQ, dmcfreq->odt_pd_arg0, dmcfreq->odt_pd_arg1, ROCKCHIP_SIP_CONFIG_DRAM_SET_ODT_PD, - odt_enable, 0, 0, 0, &res); + odt_pd_arg2, 0, 0, 0, &res); } /* @@ -316,23 +327,17 @@ static int rk3399_dmcfreq_probe(struct platform_device *pdev) /* * In TF-A there is a platform SIP call to set the PD (power-down) * timings and to enable or disable the ODT (on-die termination). - * This call needs three arguments as follows: - * - * arg0: - * bit[0-7] : sr_idle - * bit[8-15] : sr_mc_gate_idle - * bit[16-31] : standby idle - * arg1: - * bit[0-11] : pd_idle - * bit[16-27] : srpd_lite_idle - * arg2: - * bit[0] : odt enable */ - data->odt_pd_arg0 = (data->sr_idle & 0xff) | - ((data->sr_mc_gate_idle & 0xff) << 8) | - ((data->standby_idle & 0xffff) << 16); - data->odt_pd_arg1 = (data->pd_idle & 0xfff) | - ((data->srpd_lite_idle & 0xfff) << 16); + data->odt_pd_arg0 = + FIELD_PREP(RK3399_SET_ODT_PD_0_SR_IDLE, data->sr_idle) | + FIELD_PREP(RK3399_SET_ODT_PD_0_SR_MC_GATE_IDLE, + data->sr_mc_gate_idle) | + FIELD_PREP(RK3399_SET_ODT_PD_0_STANDBY_IDLE, + data->standby_idle); + data->odt_pd_arg1 = + FIELD_PREP(RK3399_SET_ODT_PD_1_PD_IDLE, data->pd_idle) | + FIELD_PREP(RK3399_SET_ODT_PD_1_SRPD_LITE_IDLE, + data->srpd_lite_idle); /* * We add a devfreq driver to our parent since it has a device tree node -- 2.35.0.rc0.227.g00780c9af4-goog