diff options
author | Greg Ungerer <gerg@uclinux.org> | 2011-03-21 23:39:27 -0400 |
---|---|---|
committer | Greg Ungerer <gerg@uclinux.org> | 2011-03-25 00:05:13 -0400 |
commit | 66d857b08b8c3ed5c72c361f863cce77d2a978d7 (patch) | |
tree | 47222d86f4d78dc0da31baf64188bd2e4b38ac1e /arch/m68k/platform/coldfire/sltimers.c | |
parent | d39dd11c3e6a7af5c20bfac40594db36cf270f42 (diff) |
m68k: merge m68k and m68knommu arch directories
There is a lot of common code that could be shared between the m68k
and m68knommu arch branches. It makes sense to merge the two branches
into a single directory structure so that we can more easily share
that common code.
This is a brute force merge, based on a script from Stephen King
<sfking@fdwdc.com>, which was originally written by Arnd Bergmann
<arnd@arndb.de>.
> The script was inspired by the script Sam Ravnborg used to merge the
> includes from m68knommu. For those files common to both arches but
> differing in content, the m68k version of the file is renamed to
> <file>_mm.<ext> and the m68knommu version of the file is moved into the
> corresponding m68k directory and renamed <file>_no.<ext> and a small
> wrapper file <file>.<ext> is used to select between the two version. Files
> that are common to both but don't differ are removed from the m68knommu
> tree and files and directories that are unique to the m68knommu tree are
> moved to the m68k tree. Finally, the arch/m68knommu tree is removed.
>
> To select between the the versions of the files, the wrapper uses
>
> #ifdef CONFIG_MMU
> #include <file>_mm.<ext>
> #else
> #include <file>_no.<ext>
> #endif
On top of this file merge I have done a simplistic merge of m68k and
m68knommu Kconfig, which primarily attempts to keep existing options and
menus in place. Other than a handful of options being moved it produces
identical .config outputs on m68k and m68knommu targets I tested it on.
With this in place there is now quite a bit of scope for merge cleanups
in future patches.
Signed-off-by: Greg Ungerer <gerg@uclinux.org>
Diffstat (limited to 'arch/m68k/platform/coldfire/sltimers.c')
-rw-r--r-- | arch/m68k/platform/coldfire/sltimers.c | 145 |
1 files changed, 145 insertions, 0 deletions
diff --git a/arch/m68k/platform/coldfire/sltimers.c b/arch/m68k/platform/coldfire/sltimers.c new file mode 100644 index 00000000000..0a1b937c3e1 --- /dev/null +++ b/arch/m68k/platform/coldfire/sltimers.c | |||
@@ -0,0 +1,145 @@ | |||
1 | /***************************************************************************/ | ||
2 | |||
3 | /* | ||
4 | * sltimers.c -- generic ColdFire slice timer support. | ||
5 | * | ||
6 | * Copyright (C) 2009-2010, Philippe De Muyter <phdm@macqel.be> | ||
7 | * based on | ||
8 | * timers.c -- generic ColdFire hardware timer support. | ||
9 | * Copyright (C) 1999-2008, Greg Ungerer <gerg@snapgear.com> | ||
10 | */ | ||
11 | |||
12 | /***************************************************************************/ | ||
13 | |||
14 | #include <linux/kernel.h> | ||
15 | #include <linux/init.h> | ||
16 | #include <linux/sched.h> | ||
17 | #include <linux/interrupt.h> | ||
18 | #include <linux/irq.h> | ||
19 | #include <linux/profile.h> | ||
20 | #include <linux/clocksource.h> | ||
21 | #include <asm/io.h> | ||
22 | #include <asm/traps.h> | ||
23 | #include <asm/machdep.h> | ||
24 | #include <asm/coldfire.h> | ||
25 | #include <asm/mcfslt.h> | ||
26 | #include <asm/mcfsim.h> | ||
27 | |||
28 | /***************************************************************************/ | ||
29 | |||
30 | #ifdef CONFIG_HIGHPROFILE | ||
31 | |||
32 | /* | ||
33 | * By default use Slice Timer 1 as the profiler clock timer. | ||
34 | */ | ||
35 | #define PA(a) (MCF_MBAR + MCFSLT_TIMER1 + (a)) | ||
36 | |||
37 | /* | ||
38 | * Choose a reasonably fast profile timer. Make it an odd value to | ||
39 | * try and get good coverage of kernel operations. | ||
40 | */ | ||
41 | #define PROFILEHZ 1013 | ||
42 | |||
43 | irqreturn_t mcfslt_profile_tick(int irq, void *dummy) | ||
44 | { | ||
45 | /* Reset Slice Timer 1 */ | ||
46 | __raw_writel(MCFSLT_SSR_BE | MCFSLT_SSR_TE, PA(MCFSLT_SSR)); | ||
47 | if (current->pid) | ||
48 | profile_tick(CPU_PROFILING); | ||
49 | return IRQ_HANDLED; | ||
50 | } | ||
51 | |||
52 | static struct irqaction mcfslt_profile_irq = { | ||
53 | .name = "profile timer", | ||
54 | .flags = IRQF_DISABLED | IRQF_TIMER, | ||
55 | .handler = mcfslt_profile_tick, | ||
56 | }; | ||
57 | |||
58 | void mcfslt_profile_init(void) | ||
59 | { | ||
60 | printk(KERN_INFO "PROFILE: lodging TIMER 1 @ %dHz as profile timer\n", | ||
61 | PROFILEHZ); | ||
62 | |||
63 | setup_irq(MCF_IRQ_PROFILER, &mcfslt_profile_irq); | ||
64 | |||
65 | /* Set up TIMER 2 as high speed profile clock */ | ||
66 | __raw_writel(MCF_BUSCLK / PROFILEHZ - 1, PA(MCFSLT_STCNT)); | ||
67 | __raw_writel(MCFSLT_SCR_RUN | MCFSLT_SCR_IEN | MCFSLT_SCR_TEN, | ||
68 | PA(MCFSLT_SCR)); | ||
69 | |||
70 | } | ||
71 | |||
72 | #endif /* CONFIG_HIGHPROFILE */ | ||
73 | |||
74 | /***************************************************************************/ | ||
75 | |||
76 | /* | ||
77 | * By default use Slice Timer 0 as the system clock timer. | ||
78 | */ | ||
79 | #define TA(a) (MCF_MBAR + MCFSLT_TIMER0 + (a)) | ||
80 | |||
81 | static u32 mcfslt_cycles_per_jiffy; | ||
82 | static u32 mcfslt_cnt; | ||
83 | |||
84 | static irqreturn_t mcfslt_tick(int irq, void *dummy) | ||
85 | { | ||
86 | /* Reset Slice Timer 0 */ | ||
87 | __raw_writel(MCFSLT_SSR_BE | MCFSLT_SSR_TE, TA(MCFSLT_SSR)); | ||
88 | mcfslt_cnt += mcfslt_cycles_per_jiffy; | ||
89 | return arch_timer_interrupt(irq, dummy); | ||
90 | } | ||
91 | |||
92 | static struct irqaction mcfslt_timer_irq = { | ||
93 | .name = "timer", | ||
94 | .flags = IRQF_DISABLED | IRQF_TIMER, | ||
95 | .handler = mcfslt_tick, | ||
96 | }; | ||
97 | |||
98 | static cycle_t mcfslt_read_clk(struct clocksource *cs) | ||
99 | { | ||
100 | unsigned long flags; | ||
101 | u32 cycles; | ||
102 | u16 scnt; | ||
103 | |||
104 | local_irq_save(flags); | ||
105 | scnt = __raw_readl(TA(MCFSLT_SCNT)); | ||
106 | cycles = mcfslt_cnt; | ||
107 | local_irq_restore(flags); | ||
108 | |||
109 | /* substract because slice timers count down */ | ||
110 | return cycles - scnt; | ||
111 | } | ||
112 | |||
113 | static struct clocksource mcfslt_clk = { | ||
114 | .name = "slt", | ||
115 | .rating = 250, | ||
116 | .read = mcfslt_read_clk, | ||
117 | .shift = 20, | ||
118 | .mask = CLOCKSOURCE_MASK(32), | ||
119 | .flags = CLOCK_SOURCE_IS_CONTINUOUS, | ||
120 | }; | ||
121 | |||
122 | void hw_timer_init(void) | ||
123 | { | ||
124 | mcfslt_cycles_per_jiffy = MCF_BUSCLK / HZ; | ||
125 | /* | ||
126 | * The coldfire slice timer (SLT) runs from STCNT to 0 included, | ||
127 | * then STCNT again and so on. It counts thus actually | ||
128 | * STCNT + 1 steps for 1 tick, not STCNT. So if you want | ||
129 | * n cycles, initialize STCNT with n - 1. | ||
130 | */ | ||
131 | __raw_writel(mcfslt_cycles_per_jiffy - 1, TA(MCFSLT_STCNT)); | ||
132 | __raw_writel(MCFSLT_SCR_RUN | MCFSLT_SCR_IEN | MCFSLT_SCR_TEN, | ||
133 | TA(MCFSLT_SCR)); | ||
134 | /* initialize mcfslt_cnt knowing that slice timers count down */ | ||
135 | mcfslt_cnt = mcfslt_cycles_per_jiffy; | ||
136 | |||
137 | setup_irq(MCF_IRQ_TIMER, &mcfslt_timer_irq); | ||
138 | |||
139 | mcfslt_clk.mult = clocksource_hz2mult(MCF_BUSCLK, mcfslt_clk.shift); | ||
140 | clocksource_register(&mcfslt_clk); | ||
141 | |||
142 | #ifdef CONFIG_HIGHPROFILE | ||
143 | mcfslt_profile_init(); | ||
144 | #endif | ||
145 | } | ||