2 * This file is part of the LinuxBIOS project.
4 * Copyright (C) 2007 Advanced Micro Devices, Inc.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 #include <cpu/x86/msr.h>
23 #include <cpu/x86/lapic.h>
25 /* NOTE: We use the APIC TIMER register is to hold flags for AP init during
26 * pre-memory init (ROMCC). Don't use init_timer() and udelay is redirected
33 /* Set the apic timer to no interrupts and periodic mode */
34 lapic_write(LAPIC_LVTT, (1 << 17)|(1<< 16)|(0 << 12)|(0 << 0));
36 /* Set the divider to 1, no divider */
37 lapic_write(LAPIC_TDCR, LAPIC_TDR_DIV_1);
39 /* Set the initial counter to 0xffffffff */
40 lapic_write(LAPIC_TMICT, 0xffffffff);
45 void udelay(u32 usecs)
47 u32 start, value, ticks;
48 /* Calculate the number of ticks to run, our FSB runs a 200Mhz */
50 start = lapic_read(LAPIC_TMCCT);
52 value = lapic_read(LAPIC_TMCCT);
53 } while((start - value) < ticks);