15 #include <linux/kernel.h>
18 #include <linux/module.h>
21 #include <linux/slab.h>
23 #define DRV_NAME "cs5535-mfgpt"
25 static int mfgpt_reset_timers;
28 "required by some broken BIOSes (ie, TinyBIOS < 0.99).");
31 struct cs5535_mfgpt_chip *
chip;
35 static struct cs5535_mfgpt_chip {
67 mask = 1 << (timer->
nr + 24);
72 mask = 1 << (timer->
nr + shift);
77 mask = 1 << (timer->
nr + shift);
84 rdmsr(msr, value, dummy);
91 wrmsr(msr, value, dummy);
116 shift = ((cmp ==
MFGPT_CMP1 ? 0 : 4) + timer->
nr % 4) * 4;
117 if (((zsel >> shift) & 0xF) == 2)
122 *irq = (zsel >> shift) & 0xF;
124 *irq = CONFIG_CS5535_MFGPT_DEFAULT_IRQ;
127 if (*irq < 1 || *irq == 2 || *irq > 15)
130 if (lpc & (1 << *irq))
137 zsel = (zsel & ~(0xF << shift)) | (*irq << shift);
147 struct cs5535_mfgpt_chip *mfgpt = &cs5535_mfgpt_chip;
152 if (!mfgpt->initialized)
161 if (timer_nr >= max) {
174 timer_nr = t < max ? (
int) t : -1;
177 if (!
test_bit(timer_nr, mfgpt->avail))
184 spin_unlock_irqrestore(&mfgpt->lock, flags);
194 spin_unlock_irqrestore(&mfgpt->lock, flags);
198 timer->
nr = timer_nr;
199 dev_info(&mfgpt->pdev->dev,
"registered timer %d\n", timer_nr);
221 spin_unlock_irqrestore(&timer->
chip->lock, flags);
230 return inw(timer->
chip->base + reg + (timer->
nr * 8));
237 outw(value, timer->
chip->base + reg + (timer->
nr * 8));
249 static void __devinit reset_all_timers(
void)
254 val = 0xFF; dummy = 0;
265 static int __devinit scan_timers(
struct cs5535_mfgpt_chip *mfgpt)
274 if (mfgpt_reset_timers)
287 spin_unlock_irqrestore(&mfgpt->lock, flags);
306 dev_err(&pdev->
dev,
"can't fetch device resource info\n");
311 dev_err(&pdev->
dev,
"can't request region\n");
316 cs5535_mfgpt_chip.base = res->
start;
317 cs5535_mfgpt_chip.pdev = pdev;
320 dev_info(&pdev->
dev,
"reserved resource region %pR\n", res);
323 t = scan_timers(&cs5535_mfgpt_chip);
324 dev_info(&pdev->
dev,
"%d MFGPT timers available\n", t);
325 cs5535_mfgpt_chip.initialized = 1;
337 .probe = cs5535_mfgpt_probe,
341 static int __init cs5535_mfgpt_init(
void)