diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2011-07-22 19:51:56 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-07-22 19:51:56 -0400 |
commit | a99a7d1436f9375662f35ccac8f1a1e1b0302a11 (patch) | |
tree | 0b3f411f6b1c4256063cf1d53773110f5a5f7482 /drivers | |
parent | bdc7ccfc0631797636837b10df7f87bc1e2e4ae3 (diff) | |
parent | ded7c1ee9799fe0ca725b459f151402e3ca4d12b (diff) |
Merge branch 'timers-cleanup-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip
* 'timers-cleanup-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip:
mips: Fix i8253 clockevent fallout
i8253: Cleanup outb/inb magic
arm: Footbridge: Use common i8253 clockevent
mips: Use common i8253 clockevent
x86: Use common i8253 clockevent
i8253: Create common clockevent implementation
i8253: Export i8253_lock unconditionally
pcpskr: MIPS: Make config dependencies finer grained
pcspkr: Cleanup Kconfig dependencies
i8253: Move remaining content and delete asm/i8253.h
i8253: Consolidate definitions of PIT_LATCH
x86: i8253: Consolidate definitions of global_clock_event
i8253: Alpha, PowerPC: Remove unused asm/8253pit.h
alpha: i8253: Cleanup remaining users of i8253pit.h
i8253: Remove I8253_LOCK config
i8253: Make pcsp sound driver use the shared i8253_lock
i8253: Make pcspkr input driver use the shared i8253_lock
i8253: Consolidate all kernel definitions of i8253_lock
i8253: Unify all kernel declarations of i8253_lock
i8253: Create linux/i8253.h and use it in all 8253 related files
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/block/hd.c | 2 | ||||
-rw-r--r-- | drivers/clocksource/Kconfig | 9 | ||||
-rw-r--r-- | drivers/clocksource/Makefile | 2 | ||||
-rw-r--r-- | drivers/clocksource/i8253.c | 114 | ||||
-rw-r--r-- | drivers/input/gameport/gameport.c | 2 | ||||
-rw-r--r-- | drivers/input/joystick/analog.c | 2 | ||||
-rw-r--r-- | drivers/input/misc/pcspkr.c | 9 |
7 files changed, 120 insertions, 20 deletions
diff --git a/drivers/block/hd.c b/drivers/block/hd.c index 007c630904c1..b52c9ca146fc 100644 --- a/drivers/block/hd.c +++ b/drivers/block/hd.c | |||
@@ -155,7 +155,7 @@ else \ | |||
155 | 155 | ||
156 | #if (HD_DELAY > 0) | 156 | #if (HD_DELAY > 0) |
157 | 157 | ||
158 | #include <asm/i8253.h> | 158 | #include <linux/i8253.h> |
159 | 159 | ||
160 | unsigned long last_req; | 160 | unsigned long last_req; |
161 | 161 | ||
diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig index 96c921910469..d8d3e02b912c 100644 --- a/drivers/clocksource/Kconfig +++ b/drivers/clocksource/Kconfig | |||
@@ -1,5 +1,14 @@ | |||
1 | config CLKSRC_I8253 | 1 | config CLKSRC_I8253 |
2 | bool | 2 | bool |
3 | 3 | ||
4 | config CLKEVT_I8253 | ||
5 | bool | ||
6 | |||
7 | config I8253_LOCK | ||
8 | bool | ||
9 | |||
10 | config CLKBLD_I8253 | ||
11 | def_bool y if CLKSRC_I8253 || CLKEVT_I8253 || I8253_LOCK | ||
12 | |||
4 | config CLKSRC_MMIO | 13 | config CLKSRC_MMIO |
5 | bool | 14 | bool |
diff --git a/drivers/clocksource/Makefile b/drivers/clocksource/Makefile index b995942a5060..7922a0cfc99f 100644 --- a/drivers/clocksource/Makefile +++ b/drivers/clocksource/Makefile | |||
@@ -6,5 +6,5 @@ obj-$(CONFIG_CS5535_CLOCK_EVENT_SRC) += cs5535-clockevt.o | |||
6 | obj-$(CONFIG_SH_TIMER_CMT) += sh_cmt.o | 6 | obj-$(CONFIG_SH_TIMER_CMT) += sh_cmt.o |
7 | obj-$(CONFIG_SH_TIMER_MTU2) += sh_mtu2.o | 7 | obj-$(CONFIG_SH_TIMER_MTU2) += sh_mtu2.o |
8 | obj-$(CONFIG_SH_TIMER_TMU) += sh_tmu.o | 8 | obj-$(CONFIG_SH_TIMER_TMU) += sh_tmu.o |
9 | obj-$(CONFIG_CLKSRC_I8253) += i8253.o | 9 | obj-$(CONFIG_CLKBLD_I8253) += i8253.o |
10 | obj-$(CONFIG_CLKSRC_MMIO) += mmio.o | 10 | obj-$(CONFIG_CLKSRC_MMIO) += mmio.o |
diff --git a/drivers/clocksource/i8253.c b/drivers/clocksource/i8253.c index 225c1761b372..27c49e60b7d6 100644 --- a/drivers/clocksource/i8253.c +++ b/drivers/clocksource/i8253.c | |||
@@ -1,14 +1,25 @@ | |||
1 | /* | 1 | /* |
2 | * i8253 PIT clocksource | 2 | * i8253 PIT clocksource |
3 | */ | 3 | */ |
4 | #include <linux/clocksource.h> | 4 | #include <linux/clockchips.h> |
5 | #include <linux/init.h> | 5 | #include <linux/init.h> |
6 | #include <linux/io.h> | 6 | #include <linux/io.h> |
7 | #include <linux/spinlock.h> | 7 | #include <linux/spinlock.h> |
8 | #include <linux/timex.h> | 8 | #include <linux/timex.h> |
9 | #include <linux/module.h> | ||
10 | #include <linux/i8253.h> | ||
11 | #include <linux/smp.h> | ||
9 | 12 | ||
10 | #include <asm/i8253.h> | 13 | /* |
14 | * Protects access to I/O ports | ||
15 | * | ||
16 | * 0040-0043 : timer0, i8253 / i8254 | ||
17 | * 0061-0061 : NMI Control Register which contains two speaker control bits. | ||
18 | */ | ||
19 | DEFINE_RAW_SPINLOCK(i8253_lock); | ||
20 | EXPORT_SYMBOL(i8253_lock); | ||
11 | 21 | ||
22 | #ifdef CONFIG_CLKSRC_I8253 | ||
12 | /* | 23 | /* |
13 | * Since the PIT overflows every tick, its not very useful | 24 | * Since the PIT overflows every tick, its not very useful |
14 | * to just read by itself. So use jiffies to emulate a free | 25 | * to just read by itself. So use jiffies to emulate a free |
@@ -37,15 +48,15 @@ static cycle_t i8253_read(struct clocksource *cs) | |||
37 | * count), it cannot be newer. | 48 | * count), it cannot be newer. |
38 | */ | 49 | */ |
39 | jifs = jiffies; | 50 | jifs = jiffies; |
40 | outb_pit(0x00, PIT_MODE); /* latch the count ASAP */ | 51 | outb_p(0x00, PIT_MODE); /* latch the count ASAP */ |
41 | count = inb_pit(PIT_CH0); /* read the latched count */ | 52 | count = inb_p(PIT_CH0); /* read the latched count */ |
42 | count |= inb_pit(PIT_CH0) << 8; | 53 | count |= inb_p(PIT_CH0) << 8; |
43 | 54 | ||
44 | /* VIA686a test code... reset the latch if count > max + 1 */ | 55 | /* VIA686a test code... reset the latch if count > max + 1 */ |
45 | if (count > LATCH) { | 56 | if (count > LATCH) { |
46 | outb_pit(0x34, PIT_MODE); | 57 | outb_p(0x34, PIT_MODE); |
47 | outb_pit(PIT_LATCH & 0xff, PIT_CH0); | 58 | outb_p(PIT_LATCH & 0xff, PIT_CH0); |
48 | outb_pit(PIT_LATCH >> 8, PIT_CH0); | 59 | outb_p(PIT_LATCH >> 8, PIT_CH0); |
49 | count = PIT_LATCH - 1; | 60 | count = PIT_LATCH - 1; |
50 | } | 61 | } |
51 | 62 | ||
@@ -86,3 +97,90 @@ int __init clocksource_i8253_init(void) | |||
86 | { | 97 | { |
87 | return clocksource_register_hz(&i8253_cs, PIT_TICK_RATE); | 98 | return clocksource_register_hz(&i8253_cs, PIT_TICK_RATE); |
88 | } | 99 | } |
100 | #endif | ||
101 | |||
102 | #ifdef CONFIG_CLKEVT_I8253 | ||
103 | /* | ||
104 | * Initialize the PIT timer. | ||
105 | * | ||
106 | * This is also called after resume to bring the PIT into operation again. | ||
107 | */ | ||
108 | static void init_pit_timer(enum clock_event_mode mode, | ||
109 | struct clock_event_device *evt) | ||
110 | { | ||
111 | raw_spin_lock(&i8253_lock); | ||
112 | |||
113 | switch (mode) { | ||
114 | case CLOCK_EVT_MODE_PERIODIC: | ||
115 | /* binary, mode 2, LSB/MSB, ch 0 */ | ||
116 | outb_p(0x34, PIT_MODE); | ||
117 | outb_p(LATCH & 0xff , PIT_CH0); /* LSB */ | ||
118 | outb_p(LATCH >> 8 , PIT_CH0); /* MSB */ | ||
119 | break; | ||
120 | |||
121 | case CLOCK_EVT_MODE_SHUTDOWN: | ||
122 | case CLOCK_EVT_MODE_UNUSED: | ||
123 | if (evt->mode == CLOCK_EVT_MODE_PERIODIC || | ||
124 | evt->mode == CLOCK_EVT_MODE_ONESHOT) { | ||
125 | outb_p(0x30, PIT_MODE); | ||
126 | outb_p(0, PIT_CH0); | ||
127 | outb_p(0, PIT_CH0); | ||
128 | } | ||
129 | break; | ||
130 | |||
131 | case CLOCK_EVT_MODE_ONESHOT: | ||
132 | /* One shot setup */ | ||
133 | outb_p(0x38, PIT_MODE); | ||
134 | break; | ||
135 | |||
136 | case CLOCK_EVT_MODE_RESUME: | ||
137 | /* Nothing to do here */ | ||
138 | break; | ||
139 | } | ||
140 | raw_spin_unlock(&i8253_lock); | ||
141 | } | ||
142 | |||
143 | /* | ||
144 | * Program the next event in oneshot mode | ||
145 | * | ||
146 | * Delta is given in PIT ticks | ||
147 | */ | ||
148 | static int pit_next_event(unsigned long delta, struct clock_event_device *evt) | ||
149 | { | ||
150 | raw_spin_lock(&i8253_lock); | ||
151 | outb_p(delta & 0xff , PIT_CH0); /* LSB */ | ||
152 | outb_p(delta >> 8 , PIT_CH0); /* MSB */ | ||
153 | raw_spin_unlock(&i8253_lock); | ||
154 | |||
155 | return 0; | ||
156 | } | ||
157 | |||
158 | /* | ||
159 | * On UP the PIT can serve all of the possible timer functions. On SMP systems | ||
160 | * it can be solely used for the global tick. | ||
161 | */ | ||
162 | struct clock_event_device i8253_clockevent = { | ||
163 | .name = "pit", | ||
164 | .features = CLOCK_EVT_FEAT_PERIODIC, | ||
165 | .set_mode = init_pit_timer, | ||
166 | .set_next_event = pit_next_event, | ||
167 | }; | ||
168 | |||
169 | /* | ||
170 | * Initialize the conversion factor and the min/max deltas of the clock event | ||
171 | * structure and register the clock event source with the framework. | ||
172 | */ | ||
173 | void __init clockevent_i8253_init(bool oneshot) | ||
174 | { | ||
175 | if (oneshot) | ||
176 | i8253_clockevent.features |= CLOCK_EVT_FEAT_ONESHOT; | ||
177 | /* | ||
178 | * Start pit with the boot cpu mask. x86 might make it global | ||
179 | * when it is used as broadcast device later. | ||
180 | */ | ||
181 | i8253_clockevent.cpumask = cpumask_of(smp_processor_id()); | ||
182 | |||
183 | clockevents_config_and_register(&i8253_clockevent, PIT_TICK_RATE, | ||
184 | 0xF, 0x7FFF); | ||
185 | } | ||
186 | #endif | ||
diff --git a/drivers/input/gameport/gameport.c b/drivers/input/gameport/gameport.c index 5b8f59d6c3e8..c351aa421f8f 100644 --- a/drivers/input/gameport/gameport.c +++ b/drivers/input/gameport/gameport.c | |||
@@ -47,7 +47,7 @@ static void gameport_disconnect_port(struct gameport *gameport); | |||
47 | 47 | ||
48 | #if defined(__i386__) | 48 | #if defined(__i386__) |
49 | 49 | ||
50 | #include <asm/i8253.h> | 50 | #include <linux/i8253.h> |
51 | 51 | ||
52 | #define DELTA(x,y) ((y)-(x)+((y)<(x)?1193182/HZ:0)) | 52 | #define DELTA(x,y) ((y)-(x)+((y)<(x)?1193182/HZ:0)) |
53 | #define GET_TIME(x) do { x = get_time_pit(); } while (0) | 53 | #define GET_TIME(x) do { x = get_time_pit(); } while (0) |
diff --git a/drivers/input/joystick/analog.c b/drivers/input/joystick/analog.c index 4afe0a3b4884..9882971827e6 100644 --- a/drivers/input/joystick/analog.c +++ b/drivers/input/joystick/analog.c | |||
@@ -136,7 +136,7 @@ struct analog_port { | |||
136 | 136 | ||
137 | #ifdef __i386__ | 137 | #ifdef __i386__ |
138 | 138 | ||
139 | #include <asm/i8253.h> | 139 | #include <linux/i8253.h> |
140 | 140 | ||
141 | #define GET_TIME(x) do { if (cpu_has_tsc) rdtscl(x); else x = get_time_pit(); } while (0) | 141 | #define GET_TIME(x) do { if (cpu_has_tsc) rdtscl(x); else x = get_time_pit(); } while (0) |
142 | #define DELTA(x,y) (cpu_has_tsc ? ((y) - (x)) : ((x) - (y) + ((x) < (y) ? CLOCK_TICK_RATE / HZ : 0))) | 142 | #define DELTA(x,y) (cpu_has_tsc ? ((y) - (x)) : ((x) - (y) + ((x) < (y) ? CLOCK_TICK_RATE / HZ : 0))) |
diff --git a/drivers/input/misc/pcspkr.c b/drivers/input/misc/pcspkr.c index f080dd31499b..34f4d2e0f50f 100644 --- a/drivers/input/misc/pcspkr.c +++ b/drivers/input/misc/pcspkr.c | |||
@@ -14,6 +14,7 @@ | |||
14 | 14 | ||
15 | #include <linux/kernel.h> | 15 | #include <linux/kernel.h> |
16 | #include <linux/module.h> | 16 | #include <linux/module.h> |
17 | #include <linux/i8253.h> | ||
17 | #include <linux/init.h> | 18 | #include <linux/init.h> |
18 | #include <linux/input.h> | 19 | #include <linux/input.h> |
19 | #include <linux/platform_device.h> | 20 | #include <linux/platform_device.h> |
@@ -25,14 +26,6 @@ MODULE_DESCRIPTION("PC Speaker beeper driver"); | |||
25 | MODULE_LICENSE("GPL"); | 26 | MODULE_LICENSE("GPL"); |
26 | MODULE_ALIAS("platform:pcspkr"); | 27 | MODULE_ALIAS("platform:pcspkr"); |
27 | 28 | ||
28 | #if defined(CONFIG_MIPS) || defined(CONFIG_X86) | ||
29 | /* Use the global PIT lock ! */ | ||
30 | #include <asm/i8253.h> | ||
31 | #else | ||
32 | #include <asm/8253pit.h> | ||
33 | static DEFINE_RAW_SPINLOCK(i8253_lock); | ||
34 | #endif | ||
35 | |||
36 | static int pcspkr_event(struct input_dev *dev, unsigned int type, unsigned int code, int value) | 29 | static int pcspkr_event(struct input_dev *dev, unsigned int type, unsigned int code, int value) |
37 | { | 30 | { |
38 | unsigned int count = 0; | 31 | unsigned int count = 0; |