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;
};
struct platform_device *pdev;
spinlock_t lock; int initialized;
} cs5535_mfgpt_chip;
int cs5535_mfgpt_toggle_event(struct cs5535_mfgpt_timer *timer, int cmp, int event, int enable)
{
uint32_t msr, mask, value, dummy; int shift = (cmp == MFGPT_CMP1) ? 0 : 8;
if (!timer) {
WARN_ON(1); return -EIO;
}
/* * The register maps for these are described in sections 6.17.1.x of * the AMD Geode CS5536 Companion Device Data Book.
*/ switch (event) { case MFGPT_EVENT_RESET: /* * XXX: According to the docs, we cannot reset timers above * 6; that is, resets for 7 and 8 will be ignored. Is this * a problem? -dilinger
*/
msr = MSR_MFGPT_NR;
mask = 1 << (timer->nr + 24); break;
int cs5535_mfgpt_set_irq(struct cs5535_mfgpt_timer *timer, int cmp, int *irq, int enable)
{
uint32_t zsel, lpc, dummy; int shift;
if (!timer) {
WARN_ON(1); return -EIO;
}
/* * Unfortunately, MFGPTs come in pairs sharing their IRQ lines. If VSA * is using the same CMP of the timer's Siamese twin, the IRQ is set to * 2, and we mustn't use nor change it. * XXX: Likewise, 2 Linux drivers might clash if the 2nd overwrites the * IRQ of the 1st. This can only happen if forcing an IRQ, calling this * with *irq==0 is safe. Currently there _are_ no 2 drivers.
*/
rdmsr(MSR_PIC_ZSEL_LOW, zsel, dummy);
shift = ((cmp == MFGPT_CMP1 ? 0 : 4) + timer->nr % 4) * 4; if (((zsel >> shift) & 0xF) == 2) return -EIO;
/* 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);
/* * XXX: This frees the timer memory, but never resets the actual hardware * timer. The old geode_mfgpt code did this; it would be good to figure * out a way to actually release the hardware timer. See comments below.
*/ void cs5535_mfgpt_free_timer(struct cs5535_mfgpt_timer *timer)
{ unsignedlong flags;
uint16_t val;
/* 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);
}
/* * This is a sledgehammer that resets all MFGPT timers. This is required by * some broken BIOSes which leave the system in an unstable state * (TinyBIOS 0.98, for example; fixed in 0.99). It's uncertain as to * whether or not this secret MSR can be used to release individual timers. * Jordan tells me that he and Mitch once played w/ it, but it's unclear * what the results of that were (and they experienced some instability).
*/ staticvoid reset_all_timers(void)
{
uint32_t val, dummy;
/* The following undocumented bit resets the MFGPT timers */
val = 0xFF; dummy = 0;
wrmsr(MSR_MFGPT_SETUP, val, dummy);
}
/* * This is another sledgehammer to reset all MFGPT timers. * Instead of using the undocumented bit method it clears * IRQ, NMI and RESET settings.
*/ staticvoid soft_reset(void)
{ int i; struct cs5535_mfgpt_timer t;
for (i = 0; i < MFGPT_MAX_TIMERS; i++) {
t.nr = i;
/* * Check whether any MFGPTs are available for the kernel to use. In most * cases, firmware that uses AMD's VSA code will claim all timers during * bootup; we certainly don't want to take them if they're already in use. * In other cases (such as with VSAless OpenFirmware), the system firmware * leaves timers available for us to use.
*/ staticint scan_timers(struct cs5535_mfgpt_chip *mfgpt)
{ struct cs5535_mfgpt_timer timer = { .chip = mfgpt }; unsignedlong flags; int timers = 0;
uint16_t val; int i;
/* 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 * fetching it from MSR_LBAR_MFGPT, the other is by reading the * PCI BAR info. The latter method is easier (especially across * different architectures), so we'll stick with that for now. If * it turns out to be unreliable in the face of crappy BIOSes, 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;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.