Intel E7501 P64H2 ICH5R support
[coreboot.git] / src / cpu / p6 / apic_timer.c
1 #include <stdint.h>
2 #include <delay.h>
3 #include <cpu/p6/msr.h>
4 #include <cpu/p6/apic.h>
5
6 void init_timer(void)
7 {
8         /* Set the apic timer to no interrupts and periodic mode */
9         apic_write(APIC_LVTT, (1 << 17)|(1<< 16)|(0 << 12)|(0 << 0));
10         /* Set the divider to 1, no divider */
11         apic_write(APIC_TDCR, APIC_TDR_DIV_1);
12         /* Set the initial counter to 0xffffffff */
13         apic_write(APIC_TMICT, 0xffffffff);
14 }
15
16 void udelay(unsigned usecs)
17 {
18         uint32_t start, value, ticks;
19         /* Calculate the number of ticks to run, our FSB runs a 200Mhz */
20         ticks = usecs * 200;
21         start = apic_read(APIC_TMCCT);
22         do {
23                 value = apic_read(APIC_TMCCT);
24         } while((start - value) < ticks);
25         
26 }