Skip to content

Commit ad38c17

Browse files
parakatsbogend
authored andcommitted
mips: ralink: get cpu rate from new driver code
At very early stage on boot, there is a need to set 'mips_hpt_frequency'. This timer frequency is a half of the CPU frequency. To get clocks properly set we need to call to 'of_clk_init()' and properly get cpu clock frequency afterwards. Depending on the SoC, CPU clock index and compatible differs, so use them to get the proper clock frm the clock provider. Hence, adapt code to be aligned with new clock driver. Signed-off-by: Sergio Paracuellos <[email protected]> Signed-off-by: Thomas Bogendoerfer <[email protected]>
1 parent 201ddc0 commit ad38c17

File tree

1 file changed

+52
-9
lines changed

1 file changed

+52
-9
lines changed

arch/mips/ralink/clk.c

Lines changed: 52 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,29 +11,72 @@
1111
#include <linux/clkdev.h>
1212
#include <linux/clk.h>
1313
#include <linux/clk-provider.h>
14+
#include <asm/mach-ralink/ralink_regs.h>
1415

1516
#include <asm/time.h>
1617

1718
#include "common.h"
1819

19-
void ralink_clk_add(const char *dev, unsigned long rate)
20+
static const char *clk_cpu(int *idx)
2021
{
21-
struct clk *clk = clk_register_fixed_rate(NULL, dev, NULL, 0, rate);
22-
23-
if (!clk)
24-
panic("failed to add clock");
25-
26-
clkdev_create(clk, NULL, "%s", dev);
22+
switch (ralink_soc) {
23+
case RT2880_SOC:
24+
*idx = 0;
25+
return "ralink,rt2880-sysc";
26+
case RT3883_SOC:
27+
*idx = 0;
28+
return "ralink,rt3883-sysc";
29+
case RT305X_SOC_RT3050:
30+
*idx = 0;
31+
return "ralink,rt3050-sysc";
32+
case RT305X_SOC_RT3052:
33+
*idx = 0;
34+
return "ralink,rt3052-sysc";
35+
case RT305X_SOC_RT3350:
36+
*idx = 1;
37+
return "ralink,rt3350-sysc";
38+
case RT305X_SOC_RT3352:
39+
*idx = 1;
40+
return "ralink,rt3352-sysc";
41+
case RT305X_SOC_RT5350:
42+
*idx = 1;
43+
return "ralink,rt5350-sysc";
44+
case MT762X_SOC_MT7620A:
45+
*idx = 2;
46+
return "ralink,mt7620-sysc";
47+
case MT762X_SOC_MT7620N:
48+
*idx = 2;
49+
return "ralink,mt7620-sysc";
50+
case MT762X_SOC_MT7628AN:
51+
*idx = 1;
52+
return "ralink,mt7628-sysc";
53+
case MT762X_SOC_MT7688:
54+
*idx = 1;
55+
return "ralink,mt7688-sysc";
56+
default:
57+
*idx = -1;
58+
return "invalid";
59+
}
2760
}
2861

2962
void __init plat_time_init(void)
3063
{
64+
struct of_phandle_args clkspec;
65+
const char *compatible;
3166
struct clk *clk;
67+
int cpu_clk_idx;
3268

3369
ralink_of_remap();
3470

35-
ralink_clk_init();
36-
clk = clk_get_sys("cpu", NULL);
71+
compatible = clk_cpu(&cpu_clk_idx);
72+
if (cpu_clk_idx == -1)
73+
panic("unable to get CPU clock index");
74+
75+
of_clk_init(NULL);
76+
clkspec.np = of_find_compatible_node(NULL, NULL, compatible);
77+
clkspec.args_count = 1;
78+
clkspec.args[0] = cpu_clk_idx;
79+
clk = of_clk_get_from_provider(&clkspec);
3780
if (IS_ERR(clk))
3881
panic("unable to get CPU clock, err=%ld", PTR_ERR(clk));
3982
pr_info("CPU Clock: %ldMHz\n", clk_get_rate(clk) / 1000000);

0 commit comments

Comments
 (0)