staticint mfgpt_reset_timers;
module_param_named(mfgptfix, mfgpt_reset_timers, int, 0644);
MODULE_PARM_DESC(mfgptfix, "Try to reset the MFGPT timers during init; " "required by some broken BIOSes (ie, TinyBIOS < 0.99) or kexec " "(1 = reset the MFGPT using an undocumented bit, " "2 = perform a soft reset by unconfiguring all timers); " "use what works best for you.");
struct cs5535_mfgpt_timer { struct cs5535_mfgpt_chip *chip; int nr;
};
/* Choose IRQ: if none supplied, keep IRQ already set or use default */ if (!*irq)
*irq = (zsel >> shift) & 0xF; if (!*irq)
*irq = CONFIG_CS5535_MFGPT_DEFAULT_IRQ;
/* Can't use IRQ if it's 0 (=disabled), 2, or routed to LPC */ if (*irq < 1 || *irq == 2 || *irq > 15) return -EIO;
rdmsr(MSR_PIC_IRQM_LPC, lpc, dummy); if (lpc & (1 << *irq)) return -EIO;
/* All chosen and checked - go for it */ if (cs5535_mfgpt_toggle_event(timer, cmp, MFGPT_EVENT_IRQ, enable)) return -EIO; if (enable) {
zsel = (zsel & ~(0xF << shift)) | (*irq << shift);
wrmsr(MSR_PIC_ZSEL_LOW, zsel, dummy);
}
spin_lock_irqsave(&mfgpt->lock, flags); if (timer_nr < 0) { unsignedlong t;
/* try to find any available timer */
t = find_first_bit(mfgpt->avail, max); /* set timer_nr to -1 if no timers available */
timer_nr = t < max ? (int) t : -1;
} else { /* check if the requested timer's available */ if (!test_bit(timer_nr, mfgpt->avail))
timer_nr = -1;
}
if (timer_nr >= 0) /* if timer_nr is not -1, it's an available timer */
__clear_bit(timer_nr, mfgpt->avail);
spin_unlock_irqrestore(&mfgpt->lock, flags);
/* timer can be made available again only if never set up */
val = cs5535_mfgpt_read(timer, MFGPT_REG_SETUP); if (!(val & MFGPT_SETUP_SETUP)) {
spin_lock_irqsave(&timer->chip->lock, flags);
__set_bit(timer->nr, timer->chip->avail);
spin_unlock_irqrestore(&timer->chip->lock, flags);
}
/* just to be safe, protect this section w/ lock */
spin_lock_irqsave(&mfgpt->lock, flags); for (i = 0; i < MFGPT_MAX_TIMERS; i++) {
timer.nr = i;
val = cs5535_mfgpt_read(&timer, MFGPT_REG_SETUP); if (!(val & MFGPT_SETUP_SETUP) || mfgpt_reset_timers == 2) {
__set_bit(i, mfgpt->avail);
timers++;
}
}
spin_unlock_irqrestore(&mfgpt->lock, flags);
/* There are two ways to get the MFGPT base address; one is by *fetchingitfromMSR_LBAR_MFGPT,theotherisbyreadingthe *PCIBARinfo.Thelattermethodiseasier(especiallyacross *differentarchitectures),sowe'llstickwiththatfornow.If *itturnsouttobeunreliableinthefaceofcrappyBIOSes,we
* can always go back to using MSRs.. */
res = platform_get_resource(pdev, IORESOURCE_IO, 0); if (!res) {
dev_err(&pdev->dev, "can't fetch device resource info\n"); goto done;
}