mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-04 04:06:26 +00:00
cpufreq: qoriq: enhance bus frequency calculation
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 <andy.tang@nxp.com> Acked-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
This commit is contained in:
parent
cf9a243825
commit
b51d3388e2
@ -52,17 +52,27 @@ static u32 get_bus_freq(void)
|
|||||||
{
|
{
|
||||||
struct device_node *soc;
|
struct device_node *soc;
|
||||||
u32 sysfreq;
|
u32 sysfreq;
|
||||||
|
struct clk *pltclk;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
/* get platform freq by searching bus-frequency property */
|
||||||
soc = of_find_node_by_type(NULL, "soc");
|
soc = of_find_node_by_type(NULL, "soc");
|
||||||
if (!soc)
|
if (soc) {
|
||||||
return 0;
|
ret = of_property_read_u32(soc, "bus-frequency", &sysfreq);
|
||||||
|
of_node_put(soc);
|
||||||
|
if (!ret)
|
||||||
|
return sysfreq;
|
||||||
|
}
|
||||||
|
|
||||||
if (of_property_read_u32(soc, "bus-frequency", &sysfreq))
|
/* get platform freq by its clock name */
|
||||||
sysfreq = 0;
|
pltclk = clk_get(NULL, "cg-pll0-div1");
|
||||||
|
if (IS_ERR(pltclk)) {
|
||||||
|
pr_err("%s: can't get bus frequency %ld\n",
|
||||||
|
__func__, PTR_ERR(pltclk));
|
||||||
|
return PTR_ERR(pltclk);
|
||||||
|
}
|
||||||
|
|
||||||
of_node_put(soc);
|
return clk_get_rate(pltclk);
|
||||||
|
|
||||||
return sysfreq;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct clk *cpu_to_clk(int cpu)
|
static struct clk *cpu_to_clk(int cpu)
|
||||||
|
Loading…
Reference in New Issue
Block a user