diff options
author | Michal Simek <michal.simek@xilinx.com> | 2013-12-18 11:18:48 -0500 |
---|---|---|
committer | Michal Simek <michal.simek@xilinx.com> | 2014-01-27 05:24:55 -0500 |
commit | c1120542b99a67a620cd8a298975d76dca5a13f0 (patch) | |
tree | 942aaf1e8d3d0c08a3cdbee5316f14dd4a901083 /arch/microblaze | |
parent | 21ecc1f1d2e01ddbd75c3db208236628474a43e1 (diff) |
microblaze: Add support for CCF
Add support for CCF for Microblaze.
Old binding:
system_timer: system-timer@41c00000 {
clock-frequency = <75000000>;
...
}
New binding:
system_timer: system-timer@41c00000 {
clocks = <&clk_bus>;
...
}
Both should be supported for a while
Microblaze clock binding:
clocks {
#address-cells = <1>;
#size-cells = <0>;
clk_bus: bus {
#clock-cells = <0>;
clock-frequency = <75000000>;
clock-output-names = "bus";
compatible = "fixed-clock";
reg = <1>;
} ;
clk_cpu: cpu {
#clock-cells = <0>;
clock-frequency = <75000000>;
clock-output-names = "cpu";
compatible = "fixed-clock";
reg = <0>;
} ;
} ;
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Diffstat (limited to 'arch/microblaze')
-rw-r--r-- | arch/microblaze/Kconfig | 1 | ||||
-rw-r--r-- | arch/microblaze/include/asm/cpuinfo.h | 1 | ||||
-rw-r--r-- | arch/microblaze/kernel/cpu/cpuinfo-pvr-full.c | 3 | ||||
-rw-r--r-- | arch/microblaze/kernel/cpu/cpuinfo-static.c | 2 | ||||
-rw-r--r-- | arch/microblaze/kernel/cpu/cpuinfo.c | 23 | ||||
-rw-r--r-- | arch/microblaze/kernel/setup.c | 3 | ||||
-rw-r--r-- | arch/microblaze/kernel/timer.c | 18 |
7 files changed, 40 insertions, 11 deletions
diff --git a/arch/microblaze/Kconfig b/arch/microblaze/Kconfig index e23cccde9c27..a715eeaf9959 100644 --- a/arch/microblaze/Kconfig +++ b/arch/microblaze/Kconfig | |||
@@ -26,6 +26,7 @@ config MICROBLAZE | |||
26 | select GENERIC_CPU_DEVICES | 26 | select GENERIC_CPU_DEVICES |
27 | select GENERIC_ATOMIC64 | 27 | select GENERIC_ATOMIC64 |
28 | select GENERIC_CLOCKEVENTS | 28 | select GENERIC_CLOCKEVENTS |
29 | select COMMON_CLK | ||
29 | select GENERIC_IDLE_POLL_SETUP | 30 | select GENERIC_IDLE_POLL_SETUP |
30 | select MODULES_USE_ELF_RELA | 31 | select MODULES_USE_ELF_RELA |
31 | select CLONE_BACKWARDS3 | 32 | select CLONE_BACKWARDS3 |
diff --git a/arch/microblaze/include/asm/cpuinfo.h b/arch/microblaze/include/asm/cpuinfo.h index 7161fb575861..3337417fcdca 100644 --- a/arch/microblaze/include/asm/cpuinfo.h +++ b/arch/microblaze/include/asm/cpuinfo.h | |||
@@ -91,6 +91,7 @@ extern struct cpuinfo cpuinfo; | |||
91 | 91 | ||
92 | /* fwd declarations of the various CPUinfo populators */ | 92 | /* fwd declarations of the various CPUinfo populators */ |
93 | void setup_cpuinfo(void); | 93 | void setup_cpuinfo(void); |
94 | void setup_cpuinfo_clk(void); | ||
94 | 95 | ||
95 | void set_cpuinfo_static(struct cpuinfo *ci, struct device_node *cpu); | 96 | void set_cpuinfo_static(struct cpuinfo *ci, struct device_node *cpu); |
96 | void set_cpuinfo_pvr_full(struct cpuinfo *ci, struct device_node *cpu); | 97 | void set_cpuinfo_pvr_full(struct cpuinfo *ci, struct device_node *cpu); |
diff --git a/arch/microblaze/kernel/cpu/cpuinfo-pvr-full.c b/arch/microblaze/kernel/cpu/cpuinfo-pvr-full.c index ee4689415410..93c26cf50de5 100644 --- a/arch/microblaze/kernel/cpu/cpuinfo-pvr-full.c +++ b/arch/microblaze/kernel/cpu/cpuinfo-pvr-full.c | |||
@@ -112,7 +112,4 @@ void set_cpuinfo_pvr_full(struct cpuinfo *ci, struct device_node *cpu) | |||
112 | CI(num_wr_brk, NUMBER_OF_WR_ADDR_BRK); | 112 | CI(num_wr_brk, NUMBER_OF_WR_ADDR_BRK); |
113 | 113 | ||
114 | CI(fpga_family_code, TARGET_FAMILY); | 114 | CI(fpga_family_code, TARGET_FAMILY); |
115 | |||
116 | /* take timebase-frequency from DTS */ | ||
117 | ci->cpu_clock_freq = fcpu(cpu, "timebase-frequency"); | ||
118 | } | 115 | } |
diff --git a/arch/microblaze/kernel/cpu/cpuinfo-static.c b/arch/microblaze/kernel/cpu/cpuinfo-static.c index 592bb2e838c4..4854285b26e7 100644 --- a/arch/microblaze/kernel/cpu/cpuinfo-static.c +++ b/arch/microblaze/kernel/cpu/cpuinfo-static.c | |||
@@ -113,8 +113,6 @@ void __init set_cpuinfo_static(struct cpuinfo *ci, struct device_node *cpu) | |||
113 | ci->num_rd_brk = fcpu(cpu, "xlnx,number-of-rd-addr-brk"); | 113 | ci->num_rd_brk = fcpu(cpu, "xlnx,number-of-rd-addr-brk"); |
114 | ci->num_wr_brk = fcpu(cpu, "xlnx,number-of-wr-addr-brk"); | 114 | ci->num_wr_brk = fcpu(cpu, "xlnx,number-of-wr-addr-brk"); |
115 | 115 | ||
116 | ci->cpu_clock_freq = fcpu(cpu, "timebase-frequency"); | ||
117 | |||
118 | ci->pvr_user1 = fcpu(cpu, "xlnx,pvr-user1"); | 116 | ci->pvr_user1 = fcpu(cpu, "xlnx,pvr-user1"); |
119 | ci->pvr_user2 = fcpu(cpu, "xlnx,pvr-user2"); | 117 | ci->pvr_user2 = fcpu(cpu, "xlnx,pvr-user2"); |
120 | 118 | ||
diff --git a/arch/microblaze/kernel/cpu/cpuinfo.c b/arch/microblaze/kernel/cpu/cpuinfo.c index c9203b1007aa..ce1cfed731ea 100644 --- a/arch/microblaze/kernel/cpu/cpuinfo.c +++ b/arch/microblaze/kernel/cpu/cpuinfo.c | |||
@@ -8,6 +8,7 @@ | |||
8 | * for more details. | 8 | * for more details. |
9 | */ | 9 | */ |
10 | 10 | ||
11 | #include <linux/clk.h> | ||
11 | #include <linux/init.h> | 12 | #include <linux/init.h> |
12 | #include <asm/cpuinfo.h> | 13 | #include <asm/cpuinfo.h> |
13 | #include <asm/pvr.h> | 14 | #include <asm/pvr.h> |
@@ -68,11 +69,10 @@ const struct family_string_key family_string_lookup[] = { | |||
68 | }; | 69 | }; |
69 | 70 | ||
70 | struct cpuinfo cpuinfo; | 71 | struct cpuinfo cpuinfo; |
72 | static struct device_node *cpu; | ||
71 | 73 | ||
72 | void __init setup_cpuinfo(void) | 74 | void __init setup_cpuinfo(void) |
73 | { | 75 | { |
74 | struct device_node *cpu = NULL; | ||
75 | |||
76 | cpu = (struct device_node *) of_find_node_by_type(NULL, "cpu"); | 76 | cpu = (struct device_node *) of_find_node_by_type(NULL, "cpu"); |
77 | if (!cpu) | 77 | if (!cpu) |
78 | pr_err("You don't have cpu!!!\n"); | 78 | pr_err("You don't have cpu!!!\n"); |
@@ -102,3 +102,22 @@ void __init setup_cpuinfo(void) | |||
102 | pr_warn("%s: Stream instructions enabled" | 102 | pr_warn("%s: Stream instructions enabled" |
103 | " - USERSPACE CAN LOCK THIS KERNEL!\n", __func__); | 103 | " - USERSPACE CAN LOCK THIS KERNEL!\n", __func__); |
104 | } | 104 | } |
105 | |||
106 | void __init setup_cpuinfo_clk(void) | ||
107 | { | ||
108 | struct clk *clk; | ||
109 | |||
110 | clk = of_clk_get(cpu, 0); | ||
111 | if (IS_ERR(clk)) { | ||
112 | pr_err("ERROR: CPU CCF input clock not found\n"); | ||
113 | /* take timebase-frequency from DTS */ | ||
114 | cpuinfo.cpu_clock_freq = fcpu(cpu, "timebase-frequency"); | ||
115 | } else { | ||
116 | cpuinfo.cpu_clock_freq = clk_get_rate(clk); | ||
117 | } | ||
118 | |||
119 | if (!cpuinfo.cpu_clock_freq) { | ||
120 | pr_err("ERROR: CPU clock frequency not setup\n"); | ||
121 | BUG(); | ||
122 | } | ||
123 | } | ||
diff --git a/arch/microblaze/kernel/setup.c b/arch/microblaze/kernel/setup.c index 603e22fec6d5..9d972d2bd924 100644 --- a/arch/microblaze/kernel/setup.c +++ b/arch/microblaze/kernel/setup.c | |||
@@ -9,6 +9,7 @@ | |||
9 | */ | 9 | */ |
10 | 10 | ||
11 | #include <linux/init.h> | 11 | #include <linux/init.h> |
12 | #include <linux/clk-provider.h> | ||
12 | #include <linux/clocksource.h> | 13 | #include <linux/clocksource.h> |
13 | #include <linux/string.h> | 14 | #include <linux/string.h> |
14 | #include <linux/seq_file.h> | 15 | #include <linux/seq_file.h> |
@@ -195,6 +196,8 @@ void __init machine_early_init(const char *cmdline, unsigned int ram, | |||
195 | 196 | ||
196 | void __init time_init(void) | 197 | void __init time_init(void) |
197 | { | 198 | { |
199 | of_clk_init(NULL); | ||
200 | setup_cpuinfo_clk(); | ||
198 | clocksource_of_init(); | 201 | clocksource_of_init(); |
199 | } | 202 | } |
200 | 203 | ||
diff --git a/arch/microblaze/kernel/timer.c b/arch/microblaze/kernel/timer.c index 3e39b1082fdf..55b19400951f 100644 --- a/arch/microblaze/kernel/timer.c +++ b/arch/microblaze/kernel/timer.c | |||
@@ -230,9 +230,9 @@ static int timer_initialized; | |||
230 | 230 | ||
231 | static void __init xilinx_timer_init(struct device_node *timer) | 231 | static void __init xilinx_timer_init(struct device_node *timer) |
232 | { | 232 | { |
233 | struct clk *clk; | ||
233 | u32 irq; | 234 | u32 irq; |
234 | u32 timer_num = 1; | 235 | u32 timer_num = 1; |
235 | int ret; | ||
236 | 236 | ||
237 | timer_baseaddr = of_iomap(timer, 0); | 237 | timer_baseaddr = of_iomap(timer, 0); |
238 | if (!timer_baseaddr) { | 238 | if (!timer_baseaddr) { |
@@ -250,10 +250,20 @@ static void __init xilinx_timer_init(struct device_node *timer) | |||
250 | 250 | ||
251 | pr_info("%s: irq=%d\n", timer->full_name, irq); | 251 | pr_info("%s: irq=%d\n", timer->full_name, irq); |
252 | 252 | ||
253 | /* If there is clock-frequency property than use it */ | 253 | clk = of_clk_get(timer, 0); |
254 | ret = of_property_read_u32(timer, "clock-frequency", &timer_clock_freq); | 254 | if (IS_ERR(clk)) { |
255 | if (ret < 0) | 255 | pr_err("ERROR: timer CCF input clock not found\n"); |
256 | /* If there is clock-frequency property than use it */ | ||
257 | of_property_read_u32(timer, "clock-frequency", | ||
258 | &timer_clock_freq); | ||
259 | } else { | ||
260 | timer_clock_freq = clk_get_rate(clk); | ||
261 | } | ||
262 | |||
263 | if (!timer_clock_freq) { | ||
264 | pr_err("ERROR: Using CPU clock frequency\n"); | ||
256 | timer_clock_freq = cpuinfo.cpu_clock_freq; | 265 | timer_clock_freq = cpuinfo.cpu_clock_freq; |
266 | } | ||
257 | 267 | ||
258 | freq_div_hz = timer_clock_freq / HZ; | 268 | freq_div_hz = timer_clock_freq / HZ; |
259 | 269 | ||