Skip to content

Commit

Permalink
x86: apic - unify __setup_APIC_LVTT
Browse files Browse the repository at this point in the history
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
  • Loading branch information
Cyrill Gorcunov authored and Ingo Molnar committed Aug 19, 2008
1 parent c43da2f commit c40aaec
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
10 changes: 7 additions & 3 deletions arch/x86/kernel/apic_32.c
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,12 @@ int lapic_get_maxlvt(void)
* Local APIC timer
*/

/* Clock divisor is set to 16 */
/* Clock divisor */
#ifdef CONFG_X86_64
#define APIC_DIVISOR 1
#else
#define APIC_DIVISOR 16
#endif

/*
* This function sets up the local APIC timer, with a timeout of
Expand Down Expand Up @@ -281,8 +285,8 @@ static void __setup_APIC_LVTT(unsigned int clocks, int oneshot, int irqen)
*/
tmp_value = apic_read(APIC_TDCR);
apic_write(APIC_TDCR,
(tmp_value & ~(APIC_TDR_DIV_1 | APIC_TDR_DIV_TMBASE)) |
APIC_TDR_DIV_16);
(tmp_value & ~(APIC_TDR_DIV_1 | APIC_TDR_DIV_TMBASE)) |
APIC_TDR_DIV_16);

if (!oneshot)
apic_write(APIC_TMICT, clocks / APIC_DIVISOR);
Expand Down
12 changes: 8 additions & 4 deletions arch/x86/kernel/apic_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,12 @@ int lapic_get_maxlvt(void)
* Local APIC timer
*/

/* Clock divisor is set to 1 */
/* Clock divisor */
#ifdef CONFG_X86_64
#define APIC_DIVISOR 1
#else
#define APIC_DIVISOR 16
#endif

/*
* This function sets up the local APIC timer, with a timeout of
Expand Down Expand Up @@ -291,9 +295,9 @@ static void __setup_APIC_LVTT(unsigned int clocks, int oneshot, int irqen)
* Divide PICLK by 16
*/
tmp_value = apic_read(APIC_TDCR);
apic_write(APIC_TDCR, (tmp_value
& ~(APIC_TDR_DIV_1 | APIC_TDR_DIV_TMBASE))
| APIC_TDR_DIV_16);
apic_write(APIC_TDCR,
(tmp_value & ~(APIC_TDR_DIV_1 | APIC_TDR_DIV_TMBASE)) |
APIC_TDR_DIV_16);

if (!oneshot)
apic_write(APIC_TMICT, clocks / APIC_DIVISOR);
Expand Down

0 comments on commit c40aaec

Please sign in to comment.