OSDN Git Service

Clock framework support
authorYoshinori Sato <ysato@users.sourceforge.jp>
Sat, 10 Jan 2015 09:44:53 +0000 (18:44 +0900)
committerYoshinori Sato <ysato@users.sourceforge.jp>
Sat, 10 Jan 2015 09:44:53 +0000 (18:44 +0900)
arch/h8300/Kconfig
arch/h8300/include/asm/Kbuild
arch/h8300/include/asm/clk.h [new file with mode: 0644]
arch/h8300/kernel/Makefile
arch/h8300/kernel/clk.c [new file with mode: 0644]
arch/h8300/kernel/setup.c

index 3b61b05..ab65cd3 100644 (file)
@@ -11,6 +11,7 @@ config H8300
        select GENERIC_CPU_DEVICES
        select MODULES_USE_ELF_RELA
        select GENERIC_CLOCKEVENTS
+       select CLKDEV_LOOKUP
 
 config MMU
        bool
index d5731e3..c8a2cd8 100644 (file)
@@ -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 (file)
index 0000000..576b8f0
--- /dev/null
@@ -0,0 +1,10 @@
+#ifndef __H8300_CLK_H
+#define __H8300_CLK_H
+
+struct clk {
+       struct clk              *parent;
+       unsigned long           rate;
+       unsigned long           flags;
+};
+
+#endif
index a26fcaf..3ac72ec 100644 (file)
@@ -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 (file)
index 0000000..4d0da5f
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * linux/arch/h8300/kernel/clk.c
+ *
+ * Copyright 2015 Yoshinori Sato <ysato@users.sourceforge.jp>
+ */
+
+#include <linux/clk.h>
+#include <linux/module.h>
+#include <linux/compiler.h>
+#include <linux/clkdev.h>
+#include <asm/clk.h>
+
+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;
+}
index ae4af35..8eaae17 100644 (file)
@@ -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)