From d7e098285a2cbd59c19c35c8e4cf301fc62f7d4f Mon Sep 17 00:00:00 2001 From: Yoshinori Sato Date: Sat, 10 Jan 2015 18:44:53 +0900 Subject: [PATCH] Clock framework support --- arch/h8300/Kconfig | 1 + arch/h8300/include/asm/Kbuild | 1 + arch/h8300/include/asm/clk.h | 10 +++++++++ arch/h8300/kernel/Makefile | 2 +- arch/h8300/kernel/clk.c | 52 +++++++++++++++++++++++++++++++++++++++++++ arch/h8300/kernel/setup.c | 22 +++++++++--------- 6 files changed, 77 insertions(+), 11 deletions(-) create mode 100644 arch/h8300/include/asm/clk.h create mode 100644 arch/h8300/kernel/clk.c diff --git a/arch/h8300/Kconfig b/arch/h8300/Kconfig index 3b61b05f5485..ab65cd372dcd 100644 --- a/arch/h8300/Kconfig +++ b/arch/h8300/Kconfig @@ -11,6 +11,7 @@ config H8300 select GENERIC_CPU_DEVICES select MODULES_USE_ELF_RELA select GENERIC_CLOCKEVENTS + select CLKDEV_LOOKUP config MMU bool diff --git a/arch/h8300/include/asm/Kbuild b/arch/h8300/include/asm/Kbuild index d5731e393cae..c8a2cd85e030 100644 --- a/arch/h8300/include/asm/Kbuild +++ b/arch/h8300/include/asm/Kbuild @@ -1,5 +1,6 @@ generic-y += barrier.h generic-y += bitsperlong.h +generic-y += clkdev.h generic-y += cputime.h generic-y += current.h generic-y += delay.h diff --git a/arch/h8300/include/asm/clk.h b/arch/h8300/include/asm/clk.h new file mode 100644 index 000000000000..576b8f01789f --- /dev/null +++ b/arch/h8300/include/asm/clk.h @@ -0,0 +1,10 @@ +#ifndef __H8300_CLK_H +#define __H8300_CLK_H + +struct clk { + struct clk *parent; + unsigned long rate; + unsigned long flags; +}; + +#endif diff --git a/arch/h8300/kernel/Makefile b/arch/h8300/kernel/Makefile index a26fcaf3109d..3ac72ecd2bfa 100644 --- a/arch/h8300/kernel/Makefile +++ b/arch/h8300/kernel/Makefile @@ -7,7 +7,7 @@ extra-y := vmlinux.lds obj-y := process.o traps.o ptrace.o \ sys_h8300.o time.o signal.o \ setup.o syscalls.o irq.o \ - entry.o timer/ + entry.o clk.o timer/ obj-$(CONFIG_ROMKERNEL) += head_rom.o obj-$(CONFIG_RAMKERNEL) += head_ram.o diff --git a/arch/h8300/kernel/clk.c b/arch/h8300/kernel/clk.c new file mode 100644 index 000000000000..4d0da5fae5f6 --- /dev/null +++ b/arch/h8300/kernel/clk.c @@ -0,0 +1,52 @@ +/* + * linux/arch/h8300/kernel/clk.c + * + * Copyright 2015 Yoshinori Sato + */ + +#include +#include +#include +#include +#include + +unsigned long clk_get_rate(struct clk *clk) +{ + return clk->parent->rate; +} +EXPORT_SYMBOL(clk_get_rate) + +int clk_enable(struct clk *clk) +{ + return 0; +} +EXPORT_SYMBOL(clk_enable) + +void clk_disable(struct clk *clk) +{ +} +EXPORT_SYMBOL(clk_disable) + +static struct clk master_clk; + +static struct clk peripheral_clk = { + .parent = &master_clk, +}; + +static struct clk_lookup lookups[] = { + { + .con_id = "master_clk", + .clk = &master_clk, + } , + { + .con_id = "peripheral_clk", + .clk = &peripheral_clk, + }, +}; + +int __init h8300_clk_init(unsigned long hz) +{ + master_clk.rate = hz; + clkdev_add_table(lookups, ARRAY_SIZE(lookups)); + return 0; +} diff --git a/arch/h8300/kernel/setup.c b/arch/h8300/kernel/setup.c index ae4af35854d2..8eaae17c0149 100644 --- a/arch/h8300/kernel/setup.c +++ b/arch/h8300/kernel/setup.c @@ -45,6 +45,7 @@ char __initdata command_line[COMMAND_LINE_SIZE]; extern unsigned long _ramend; void sim_console_register(void); +int h8300_clk_init(unsigned long hz); void __init __attribute__((weak)) early_device_init(void) { @@ -93,6 +94,7 @@ void __init setup_arch(char **cmdline_p) free_bootmem(memory_start, memory_end - memory_start); reserve_bootmem(memory_start, bootmap_size, BOOTMEM_DEFAULT); + h8300_clk_init(bootparams.clock_freq); early_device_init(); #if defined(CONFIG_H8300H_SIM) || defined(CONFIG_H8S_SIM) sim_console_register(); @@ -110,22 +112,22 @@ void __init setup_arch(char **cmdline_p) static int show_cpuinfo(struct seq_file *m, void *v) { - char *cpu; - u_long clockfreq; + char *cpu; + u_long clockfreq; - cpu = CPU; - clockfreq = bootparams.clock_freq; + cpu = CPU; + clockfreq = bootparams.clock_freq; - seq_printf(m, "CPU:\t\t%s\n" + seq_printf(m, "CPU:\t\t%s\n" "Clock:\t\t%lu.%1luMHz\n" "BogoMips:\t%lu.%02lu\n" "Calibration:\t%lu loops\n", - cpu, - clockfreq/1000,clockfreq%1000, - (loops_per_jiffy*HZ)/500000,((loops_per_jiffy*HZ)/5000)%100, - (loops_per_jiffy*HZ)); + cpu, + clockfreq/1000,clockfreq%1000, + (loops_per_jiffy*HZ)/500000,((loops_per_jiffy*HZ)/5000)%100, + (loops_per_jiffy*HZ)); - return 0; + return 0; } static void *c_start(struct seq_file *m, loff_t *pos) -- 2.11.0