Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+40 -11
+1
arch/microblaze/Kconfig
··· 26 26 select GENERIC_CPU_DEVICES 27 27 select GENERIC_ATOMIC64 28 28 select GENERIC_CLOCKEVENTS 29 + select COMMON_CLK 29 30 select GENERIC_IDLE_POLL_SETUP 30 31 select MODULES_USE_ELF_RELA 31 32 select CLONE_BACKWARDS3
+1
arch/microblaze/include/asm/cpuinfo.h
··· 91 91 92 92 /* fwd declarations of the various CPUinfo populators */ 93 93 void setup_cpuinfo(void); 94 + void setup_cpuinfo_clk(void); 94 95 95 96 void set_cpuinfo_static(struct cpuinfo *ci, struct device_node *cpu); 96 97 void set_cpuinfo_pvr_full(struct cpuinfo *ci, struct device_node *cpu);
-3
arch/microblaze/kernel/cpu/cpuinfo-pvr-full.c
··· 112 112 CI(num_wr_brk, NUMBER_OF_WR_ADDR_BRK); 113 113 114 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 }
-2
arch/microblaze/kernel/cpu/cpuinfo-static.c
··· 113 113 ci->num_rd_brk = fcpu(cpu, "xlnx,number-of-rd-addr-brk"); 114 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 116 ci->pvr_user1 = fcpu(cpu, "xlnx,pvr-user1"); 119 117 ci->pvr_user2 = fcpu(cpu, "xlnx,pvr-user2"); 120 118
+21 -2
arch/microblaze/kernel/cpu/cpuinfo.c
··· 8 8 * for more details. 9 9 */ 10 10 11 + #include <linux/clk.h> 11 12 #include <linux/init.h> 12 13 #include <asm/cpuinfo.h> 13 14 #include <asm/pvr.h> ··· 69 68 }; 70 69 71 70 struct cpuinfo cpuinfo; 71 + static struct device_node *cpu; 72 72 73 73 void __init setup_cpuinfo(void) 74 74 { 75 - struct device_node *cpu = NULL; 76 - 77 75 cpu = (struct device_node *) of_find_node_by_type(NULL, "cpu"); 78 76 if (!cpu) 79 77 pr_err("You don't have cpu!!!\n"); ··· 101 101 if (cpuinfo.mmu_privins) 102 102 pr_warn("%s: Stream instructions enabled" 103 103 " - USERSPACE CAN LOCK THIS KERNEL!\n", __func__); 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 + } 104 123 }
+3
arch/microblaze/kernel/setup.c
··· 9 9 */ 10 10 11 11 #include <linux/init.h> 12 + #include <linux/clk-provider.h> 12 13 #include <linux/clocksource.h> 13 14 #include <linux/string.h> 14 15 #include <linux/seq_file.h> ··· 196 195 197 196 void __init time_init(void) 198 197 { 198 + of_clk_init(NULL); 199 + setup_cpuinfo_clk(); 199 200 clocksource_of_init(); 200 201 } 201 202
+14 -4
arch/microblaze/kernel/timer.c
··· 230 230 231 231 static void __init xilinx_timer_init(struct device_node *timer) 232 232 { 233 + struct clk *clk; 233 234 u32 irq; 234 235 u32 timer_num = 1; 235 - int ret; 236 236 237 237 timer_baseaddr = of_iomap(timer, 0); 238 238 if (!timer_baseaddr) { ··· 250 250 251 251 pr_info("%s: irq=%d\n", timer->full_name, irq); 252 252 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"); 256 265 timer_clock_freq = cpuinfo.cpu_clock_freq; 266 + } 257 267 258 268 freq_div_hz = timer_clock_freq / HZ; 259 269