| 1 |
|
| 2 |
|
| 3 |
#include <arch/hpet.h> |
| 4 |
#include <southbridge/intel/common/rcba.h> |
| 5 |
#include <stdint.h> |
| 6 |
|
| 7 |
#include "hpet.h" |
| 8 |
|
| 9 |
#define HPTC 0x3404 |
| 10 |
|
| 11 |
#define HPET32(x) (*((volatile u32 *)(HPET_BASE_ADDRESS + (x)))) |
| 12 |
|
| 13 |
void enable_hpet(void) |
| 14 |
{ |
| 15 |
u32 reg32; |
| 16 |
reg32 = RCBA32(HPTC); |
| 17 |
reg32 &= ~0x03; |
| 18 |
reg32 |= (1 << 7); |
| 19 |
RCBA32(HPTC) = reg32; |
| 20 |
|
| 21 |
RCBA32(HPTC); |
| 22 |
HPET32(0x10) = HPET32(0x10) | 1; |
| 23 |
} |
| 24 |
|
| 25 |
void hpet_udelay(u32 delay) |
| 26 |
{ |
| 27 |
u32 start, finish, now; |
| 28 |
|
| 29 |
delay *= 15; |
| 30 |
|
| 31 |
start = HPET32(0xf0); |
| 32 |
finish = start + delay; |
| 33 |
while (1) { |
| 34 |
now = HPET32(0xf0); |
| 35 |
if (finish > start) { |
| 36 |
if (now >= finish) |
| 37 |
break; |
| 38 |
} else { |
| 39 |
if ((now < start) && (now >= finish)) |
| 40 |
break; |
| 41 |
} |
| 42 |
} |
| 43 |
} |