Skip to content

Commit c112054

Browse files
author
Michal Simek
committed
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>
1 parent 21ecc1f commit c112054

7 files changed

Lines changed: 40 additions & 11 deletions

File tree

‎arch/microblaze/Kconfig‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ config MICROBLAZE
2626
select GENERIC_CPU_DEVICES
2727
select GENERIC_ATOMIC64
2828
select GENERIC_CLOCKEVENTS
29+
select COMMON_CLK
2930
select GENERIC_IDLE_POLL_SETUP
3031
select MODULES_USE_ELF_RELA
3132
select CLONE_BACKWARDS3

‎arch/microblaze/include/asm/cpuinfo.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ extern struct cpuinfo cpuinfo;
9191

9292
/* fwd declarations of the various CPUinfo populators */
9393
void setup_cpuinfo(void);
94+
void setup_cpuinfo_clk(void);
9495

9596
void set_cpuinfo_static(struct cpuinfo *ci, struct device_node *cpu);
9697
void set_cpuinfo_pvr_full(struct cpuinfo *ci, struct device_node *cpu);

‎arch/microblaze/kernel/cpu/cpuinfo-pvr-full.c‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,4 @@ void set_cpuinfo_pvr_full(struct cpuinfo *ci, struct device_node *cpu)
112112
CI(num_wr_brk, NUMBER_OF_WR_ADDR_BRK);
113113

114114
CI(fpga_family_code, TARGET_FAMILY);
115-
116-
/* take timebase-frequency from DTS */
117-
ci->cpu_clock_freq = fcpu(cpu, "timebase-frequency");
118115
}

‎arch/microblaze/kernel/cpu/cpuinfo-static.c‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,6 @@ void __init set_cpuinfo_static(struct cpuinfo *ci, struct device_node *cpu)
113113
ci->num_rd_brk = fcpu(cpu, "xlnx,number-of-rd-addr-brk");
114114
ci->num_wr_brk = fcpu(cpu, "xlnx,number-of-wr-addr-brk");
115115

116-
ci->cpu_clock_freq = fcpu(cpu, "timebase-frequency");
117-
118116
ci->pvr_user1 = fcpu(cpu, "xlnx,pvr-user1");
119117
ci->pvr_user2 = fcpu(cpu, "xlnx,pvr-user2");
120118

‎arch/microblaze/kernel/cpu/cpuinfo.c‎

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
* for more details.
99
*/
1010

11+
#include <linux/clk.h>
1112
#include <linux/init.h>
1213
#include <asm/cpuinfo.h>
1314
#include <asm/pvr.h>
@@ -68,11 +69,10 @@ const struct family_string_key family_string_lookup[] = {
6869
};
6970

7071
struct cpuinfo cpuinfo;
72+
static struct device_node *cpu;
7173

7274
void __init setup_cpuinfo(void)
7375
{
74-
struct device_node *cpu = NULL;
75-
7676
cpu = (struct device_node *) of_find_node_by_type(NULL, "cpu");
7777
if (!cpu)
7878
pr_err("You don't have cpu!!!\n");
@@ -102,3 +102,22 @@ void __init setup_cpuinfo(void)
102102
pr_warn("%s: Stream instructions enabled"
103103
" - USERSPACE CAN LOCK THIS KERNEL!\n", __func__);
104104
}
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+
}

‎arch/microblaze/kernel/setup.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
*/
1010

1111
#include <linux/init.h>
12+
#include <linux/clk-provider.h>
1213
#include <linux/clocksource.h>
1314
#include <linux/string.h>
1415
#include <linux/seq_file.h>
@@ -195,6 +196,8 @@ void __init machine_early_init(const char *cmdline, unsigned int ram,
195196

196197
void __init time_init(void)
197198
{
199+
of_clk_init(NULL);
200+
setup_cpuinfo_clk();
198201
clocksource_of_init();
199202
}
200203

‎arch/microblaze/kernel/timer.c‎

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -230,9 +230,9 @@ static int timer_initialized;
230230

231231
static void __init xilinx_timer_init(struct device_node *timer)
232232
{
233+
struct clk *clk;
233234
u32 irq;
234235
u32 timer_num = 1;
235-
int ret;
236236

237237
timer_baseaddr = of_iomap(timer, 0);
238238
if (!timer_baseaddr) {
@@ -250,10 +250,20 @@ static void __init xilinx_timer_init(struct device_node *timer)
250250

251251
pr_info("%s: irq=%d\n", timer->full_name, irq);
252252

253-
/* If there is clock-frequency property than use it */
254-
ret = of_property_read_u32(timer, "clock-frequency", &timer_clock_freq);
255-
if (ret < 0)
253+
clk = of_clk_get(timer, 0);
254+
if (IS_ERR(clk)) {
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");
256265
timer_clock_freq = cpuinfo.cpu_clock_freq;
266+
}
257267

258268
freq_div_hz = timer_clock_freq / HZ;
259269

0 commit comments

Comments
 (0)