1 /* Driver/API for AMD Geode Multi-Function General Purpose Timers (MFGPT)
2 *
3 * Copyright (C) 2006, Advanced Micro Devices, Inc.
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version
8 * 2 of the License, or (at your option) any later version.
9 *
10 */
11
12 #ifndef MFGPT_GEODE_H_
13 #define MFGPT_GEODE_H_
14
15 #define MFGPT_TIMER_ANY -1
16
17 #define MFGPT_DOMAIN_WORKING 1
18 #define MFGPT_DOMAIN_STANDBY 2
19 #define MFGPT_DOMAIN_ANY (MFGPT_DOMAIN_WORKING | MFGPT_DOMAIN_STANDBY)
20
21 #define MSR_MFGPT_IRQ 0x51400028
22 #define MSR_MFGPT_NR 0x51400029
23 #define MSR_MFGPT_SETUP 0x5140002B
24
25 #define MFGPT_MAX_TIMERS 8
26 #define MFGPT_PCI_BAR 2
27
28 #define MFGPT_CMP1 0
29 #define MFGPT_CMP2 1
30
31 #define MFGPT_EVENT_IRQ 0
32 #define MFGPT_EVENT_NMI 1
33 #define MFGPT_EVENT_RESET 3
34
35 #define MFGPT_REG_CMP1 0
36 #define MFGPT_REG_CMP2 2
37 #define MFGPT_REG_COUNTER 4
38 #define MFGPT_REG_SETUP 6
39
40 #define MFGPT_SETUP_CNTEN (1 << 15)
41 #define MFGPT_SETUP_CMP2 (1 << 14)
42 #define MFGPT_SETUP_CMP1 (1 << 13)
43 #define MFGPT_SETUP_SETUP (1 << 12)
44 #define MFGPT_SETUP_STOPEN (1 << 11)
45 #define MFGPT_SETUP_EXTEN (1 << 10)
46 #define MFGPT_SETUP_REVEN (1 << 5)
47 #define MFGPT_SETUP_CLKSEL (1 << 4)
48
49 extern int geode_mfgpt_toggle_event(int, int, int, int);
50
51 #define geode_mfgpt_set_event(t,c,e) geode_mfgpt_toggle_event(t,c,e,1)
52 #define geode_mfgpt_clear_event(t,c,e) geode_mfgpt_toggle_event(t,c,e,0)
53
54 extern void geode_mfgpt_set_irq(int, int, int, int);
55
56 #define geode_mfgpt_setup_irq(t, c, i) geode_mfgpt_set_irq(t,c,i,1)
57 #define geode_mfgpt_release_irq(t, c, i) geode_mfgpt_set_irq(t,c,i,0)
58
59 extern void geode_mfgpt_write(int, u16, u16);
60 extern u16 geode_mfgpt_read(int, u16);
61
62 extern int geode_mfgpt_alloc_timer(int, int);
63
64 /* Specific geode tests */
65
is_geode_gx(void)66 static inline int is_geode_gx(void)
67 {
68 return ((boot_cpu_data.x86_vendor == X86_VENDOR_NSC) &&
69 (boot_cpu_data.x86 == 5) &&
70 (boot_cpu_data.x86_model == 5));
71 }
72
is_geode_lx(void)73 static inline int is_geode_lx(void)
74 {
75 return ((boot_cpu_data.x86_vendor == X86_VENDOR_AMD) &&
76 (boot_cpu_data.x86 == 5) &&
77 (boot_cpu_data.x86_model == 10));
78 }
79
is_geode(void)80 static inline int is_geode(void)
81 {
82 return (is_geode_gx() || is_geode_lx());
83 }
84
85 #endif
86