3 #include <reg-82801b.h>
5 static uint16_t _get_PMBASE()
7 static long pmbase = -1;
9 if (pmbase == -1) /* Memoize it so that we don't have to hit PCI so often. */
10 pmbase = pci_read32(ICH2_LPC_BUS, ICH2_LPC_DEV, ICH2_LPC_FN, ICH2_LPC_PCI_PMBASE) & ICH2_PMBASE_MASK;
15 static unsigned long _curtmr()
17 return inl(_get_PMBASE() + ICH2_PMBASE_PM1_TMR) & 0xFFFFFF;
20 /* This is kind of a heuristic, since we can't get interrupts. */
21 static unsigned long starttmr = 0, endtmr = 0;
23 void oneshot_start_ms(unsigned long milliseconds)
26 endtmr = (starttmr + milliseconds*(ICH2_PM1_TMR_FREQ/1000)) & 0xFFFFFF;
29 int oneshot_running(void)
31 unsigned long time = _curtmr();
33 if (endtmr == 0 && starttmr == 0)
35 if ((endtmr < starttmr) && ((time > starttmr) || (time < endtmr)))
37 else if ((time < endtmr) && (time > starttmr))
39 endtmr = starttmr = 0;