From mboxrd@z Thu Jan 1 00:00:00 1970 From: Viresh Kumar Subject: Re: [PATCH] cpufreq: qoriq: enhance bus frequency calculation Date: Thu, 9 Mar 2017 15:09:17 +0530 Message-ID: <20170309093917.GB3341@vireshk-i7> References: <1489047306-31818-1-git-send-email-andy.tang@nxp.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Content-Disposition: inline In-Reply-To: <1489047306-31818-1-git-send-email-andy.tang@nxp.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=m.gmane.org@lists.infradead.org To: YuanTian Tang Cc: Tang Yuantian , rjw@rjwysocki.net, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org List-Id: linux-pm@vger.kernel.org On 09-03-17, 16:15, YuanTian Tang wrote: > From: Tang Yuantian > > On some platforms, property device-type may be missed in soc node > in dts which caused the bus-frequency can not be obtained correctly. > > This patch enhanced the bus-frequency calculation. When property > device-type is missed in dts, bus-frequency will be obtained by > looking up clock table to get platform clock and hence get its > frequency. > > Signed-off-by: Tang Yuantian > --- > drivers/cpufreq/qoriq-cpufreq.c | 24 +++++++++++++++++------- > 1 file changed, 17 insertions(+), 7 deletions(-) > > diff --git a/drivers/cpufreq/qoriq-cpufreq.c b/drivers/cpufreq/qoriq-cpufreq.c > index bfec1bc..0f22e40 100644 > --- a/drivers/cpufreq/qoriq-cpufreq.c > +++ b/drivers/cpufreq/qoriq-cpufreq.c > @@ -52,17 +52,27 @@ static u32 get_bus_freq(void) > { > struct device_node *soc; > u32 sysfreq; > + struct clk *pltclk; > + int ret; > > + /* get platform freq by searching bus-frequency property */ > soc = of_find_node_by_type(NULL, "soc"); > - if (!soc) > - return 0; > - > - if (of_property_read_u32(soc, "bus-frequency", &sysfreq)) > - sysfreq = 0; > + if (soc) { > + ret = of_property_read_u32(soc, "bus-frequency", &sysfreq); > + of_node_put(soc); > + if (!ret) > + return sysfreq; > + } > > - of_node_put(soc); > + /* get platform freq by its clock name */ > + pltclk = clk_get(NULL, "cg-pll0-div1"); Will this always work? If yes, then what about dropping the code parsing DT completely ? That is, just rely on clk_get_rate() in all cases. > + if (IS_ERR(pltclk)) { > + pr_err("%s: can't get bus frequency %ld\n", > + __func__, PTR_ERR(pltclk)); You need to properly align this. Try running checkpatch over this patch or: checkpatch --strict > + return PTR_ERR(pltclk); > + } > > - return sysfreq; > + return clk_get_rate(pltclk); > } > > static struct clk *cpu_to_clk(int cpu) > -- > 2.1.0.27.g96db324 -- viresh