Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp48787img; Tue, 19 Mar 2019 17:34:47 -0700 (PDT) X-Google-Smtp-Source: APXvYqxWpWnnHmdoaJdXajBVzjnFEZYmZHqM5yAnwnxgut4LalJjapbYI+2wy4iw8eY+cNoiXACn X-Received: by 2002:aa7:9289:: with SMTP id j9mr4720343pfa.130.1553042087439; Tue, 19 Mar 2019 17:34:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553042087; cv=none; d=google.com; s=arc-20160816; b=LfqrMsMnnPwThU5J8VWmnGol7UvO1CXpdQS/W8QFUqslzANA/Gtb368p7wUSvnHnVh pmIyhMIdTEBmiRw57Zi15On+HKmiZmbbZiYBCPgfCAxjA+A/FEZixAbV4la4R//BeWw+ LFV8KlyrhFQUXsqWRLrb7aCW+RlxyWVW/y8b2FsbzW2xa7elNcT88Sx3BTVvEYvzu7GZ YdabAQIV0VTnZ6zbG8fotQEUsXR5XoaWaNCaSF4gEdvVNQj1szCQjHdvsSgew12RGOgC /gQD5AJjgFfy1QyixIu9VmW9fRySV7bmV/3TS1gDbLQN8YZjQ1ViiEbSkdxanw8Dt5Y8 egsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=pIAmozdrbTOLwLNGIyetO2St2qeMD1RsIRur82uuJek=; b=NsVgribW8jTgOrXtttyR9R+ihxNwwSDriW1iSCYczeQGN0n7m3mhRMKAB2D4soFYl1 AvL+yV6MViE4sLPiqrvsczOhkGgOdvAex8gg0tw1Q9TuUz8Vza+EUvppT5RhWdiNjzmJ qGPQSLW8PnpOkIjX4f5vc3bfaRJybi0Gs8aIzn0IRMpXmnwWP2Ikp8lu5SVWFW1L4Mph E2R1qAhlz0JuHtb1imKb+VSEKiCGquapcGs7qjSMm7mLStHRJAXtJqjgs0u4uWCIOoyS CffJQjDdkMrSmCrZU3YOg1ZD+kI0M2IgnwZ4ixEN8BdUMLHgIiHpKBAkLtVmcE3YLmgn TsMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="OixlN/PX"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id u6si202557pga.430.2019.03.19.17.34.31; Tue, 19 Mar 2019 17:34:47 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="OixlN/PX"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1727079AbfCTAdz (ORCPT + 99 others); Tue, 19 Mar 2019 20:33:55 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:46004 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726824AbfCTAdy (ORCPT ); Tue, 19 Mar 2019 20:33:54 -0400 Received: by mail-pg1-f193.google.com with SMTP id y3so372900pgk.12 for ; Tue, 19 Mar 2019 17:33:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=pIAmozdrbTOLwLNGIyetO2St2qeMD1RsIRur82uuJek=; b=OixlN/PXRwQFCJpfng9mAz+ykI8+BrgxciXQKA2qqI40KgUxB1ta/9IYGKVJVgmgVj bRt5LIhFdpdZJsHlRJTNEBBT4zf+7FyYP5kr7bZsuY28b3xh9NDZxw81XTHaTnnG5tlc wpMQwz+nxJdj7dTo+kiMxK/FQaKjOdZmx0R2k= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=pIAmozdrbTOLwLNGIyetO2St2qeMD1RsIRur82uuJek=; b=MZACr9ek3VJeeFpRyp/sJm22b2L9ycsPzxT63iHoWHG2lHv4qhwI4OIqU9/RwCPOEM TXfzlzqL6XFrCGVXZaBmt/yjqX3NDUmHNyk4M9cGWVYNZX1yIjaQtAsiE5KxJBMAcS6I jW1f0wbhMCtfVwFva1Ucg9aHK577+pXWj/qduKliwNYX3WIRPHgwiFn/palXlRizG/eA 2+Qgy4bI6/zxQDnkapXCBtlWOTsz+xLhQmjLcRZLvNTR96bt0q33SSzHovErfD6MCiXJ DuZBMCqAm5x3Enuw6HiuN4yhIPDOQPgRe4yQ0HMrgqv31UL7XXxbVvk6P9EX1GeGTOtH wQGg== X-Gm-Message-State: APjAAAUTtrv+WJW5URLHS6TkiD/pGUxpvqJ5ibxDxDFC8AMNCOdsToEM 1Np+DosX1SpXvaA5WW/bPY/xPQ== X-Received: by 2002:a17:902:6949:: with SMTP id k9mr4679354plt.275.1553042033947; Tue, 19 Mar 2019 17:33:53 -0700 (PDT) Received: from localhost ([2620:15c:202:1:75a:3f6e:21d:9374]) by smtp.gmail.com with ESMTPSA id p14sm216333pgn.34.2019.03.19.17.33.53 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 19 Mar 2019 17:33:53 -0700 (PDT) Date: Tue, 19 Mar 2019 17:33:52 -0700 From: Matthias Kaehlcke To: =?utf-8?B?R2HDq2w=?= PORTAY Cc: MyungJoo Ham , Kyungmin Park , Chanwoo Choi , Rob Herring , Heiko Stuebner , Enric Balletbo i Serra , Lin Huang , Brian Norris , Douglas Anderson , Klaus Goger , Derek Basehore , Randy Li , linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, Mark Rutland , kernel@collabora.com Subject: Re: [PATCH v2 3/5] devfreq: rk3399_dmc: Pass ODT and auto power down parameters to TF-A. Message-ID: <20190320003352.GN112750@google.com> References: <20190319181323.22804-1-gael.portay@collabora.com> <20190319181323.22804-4-gael.portay@collabora.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20190319181323.22804-4-gael.portay@collabora.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Gaël, On Tue, Mar 19, 2019 at 02:13:21PM -0400, Gaël PORTAY wrote: > From: Enric Balletbo i Serra > > Trusted Firmware-A (TF-A) for rk3399 implements a SiP call to get the > on-die termination (ODT) and auto power down parameters from kernel, > this patch adds the functionality to do this. Also, if DDR clock > frequency is lower than the on-die termination (ODT) disable frequency > this driver should disable the DDR ODT. > > Signed-off-by: Enric Balletbo i Serra > Reviewed-by: Chanwoo Choi > --- > > Changes in v2: None > > Changes in v1: > - [RFC 3/10] Add an explanation for platform SIP calls. > - [RFC 3/10] Change if statement for a switch. > - [RFC 3/10] Rename ddr_flag to odt_enable to be more clear. > > drivers/devfreq/rk3399_dmc.c | 74 ++++++++++++++++++++++++++++- > include/soc/rockchip/rockchip_sip.h | 1 + > 2 files changed, 74 insertions(+), 1 deletion(-) > > diff --git a/drivers/devfreq/rk3399_dmc.c b/drivers/devfreq/rk3399_dmc.c > ... > static int rk3399_dmcfreq_target(struct device *dev, unsigned long *freq, > @@ -80,6 +86,8 @@ static int rk3399_dmcfreq_target(struct device *dev, unsigned long *freq, > struct dev_pm_opp *opp; > 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); > @@ -95,6 +103,19 @@ static int rk3399_dmcfreq_target(struct device *dev, unsigned long *freq, > > mutex_lock(&dmcfreq->lock); > > + if (target_rate >= dmcfreq->odt_dis_freq) > + odt_enable = true; > + > + /* > + * This makes a SMC call to the TF-A to set the DDR PD (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_enable, 0, 0, 0, &res); Is it necessary/desirable to make this call for every frequency change? IIUC it should be only needed when odt_enable changes and the driver could track the state. If the DDR frequency doesn't change too often and the overhead of the call is small it shouldn't be really important though. > @@ -294,11 +315,13 @@ static int rk3399_dmcfreq_probe(struct platform_device *pdev) > { > struct arm_smccc_res res; > struct device *dev = &pdev->dev; > - struct device_node *np = pdev->dev.of_node; > + struct device_node *np = pdev->dev.of_node, *node; > struct rk3399_dmcfreq *data; > int ret, index, size; > uint32_t *timing; > struct dev_pm_opp *opp; > + u32 ddr_type; > + u32 val; > > data = devm_kzalloc(dev, sizeof(struct rk3399_dmcfreq), GFP_KERNEL); > if (!data) > @@ -334,6 +357,34 @@ static int rk3399_dmcfreq_probe(struct platform_device *pdev) > return ret; > } > > + /* Try to find the optional reference to the pmu syscon */ > + node = of_parse_phandle(np, "rockchip,pmu", 0); > + if (node) { The 'optional' part doesn't seem to be accurate: according to the binding (https://lore.kernel.org/patchwork/patch/1052322/) the property is required and the code below assumes that data->regmap_pmu is set. > + data->regmap_pmu = syscon_node_to_regmap(node); > + if (IS_ERR(data->regmap_pmu)) > + return PTR_ERR(data->regmap_pmu); > + } > + > + /* Get DDR type */ nit: the comment doesn't add much value, thanks to good variable naming this is evident from the code. > + regmap_read(data->regmap_pmu, RK3399_PMUGRF_OS_REG2, &val); > + ddr_type = (val >> RK3399_PMUGRF_DDRTYPE_SHIFT) & > + RK3399_PMUGRF_DDRTYPE_MASK; > + > + /* Get the odt_dis_freq parameter in function of the DDR type */ nit: ditto (if you prefer to keep these comments I'm not opposed to keeping them, but I don't think they are needed) Cheers Matthias