19 #define LOONGSON2_CPU_TYPE "mips/loongson2"
21 #define LOONGSON2_PERFCNT_OVERFLOW (1ULL << 31)
23 #define LOONGSON2_PERFCTRL_EXL (1UL << 0)
24 #define LOONGSON2_PERFCTRL_KERNEL (1UL << 1)
25 #define LOONGSON2_PERFCTRL_SUPERVISOR (1UL << 2)
26 #define LOONGSON2_PERFCTRL_USER (1UL << 3)
27 #define LOONGSON2_PERFCTRL_ENABLE (1UL << 4)
28 #define LOONGSON2_PERFCTRL_EVENT(idx, event) \
29 (((event) & 0x0f) << ((idx) ? 9 : 5))
31 #define read_c0_perfctrl() __read_64bit_c0_register($24, 0)
32 #define write_c0_perfctrl(val) __write_64bit_c0_register($24, 0, val)
33 #define read_c0_perfcnt() __read_64bit_c0_register($25, 0)
34 #define write_c0_perfcnt(val) __write_64bit_c0_register($25, 0, val)
36 static struct loongson2_register_config {
38 unsigned long long reset_counter1;
39 unsigned long long reset_counter2;
40 int cnt1_enabled, cnt2_enabled;
43 static char *oprofid =
"LoongsonPerf";
46 static void reset_counters(
void *
arg)
54 unsigned int ctrl = 0;
56 reg.reset_counter1 = 0;
57 reg.reset_counter2 = 0;
65 reg.reset_counter1 = 0x80000000ULL - cfg[0].
count;
70 reg.reset_counter2 = 0x80000000ULL - cfg[1].
count;
73 if (cfg[0].enabled || cfg[1].enabled) {
75 if (cfg[0].kernel || cfg[1].kernel)
87 static void loongson2_cpu_setup(
void *args)
92 static void loongson2_cpu_start(
void *args)
95 if (
reg.cnt1_enabled ||
reg.cnt2_enabled)
99 static void loongson2_cpu_stop(
void *args)
116 enabled =
reg.cnt1_enabled |
reg.cnt2_enabled;
121 counter1 = counter & 0xffffffff;
122 counter2 = counter >> 32;
125 if (
reg.cnt1_enabled)
127 counter1 =
reg.reset_counter1;
129 if (counter2 & LOONGSON2_PERFCNT_OVERFLOW) {
130 if (
reg.cnt2_enabled)
132 counter2 =
reg.reset_counter2;
140 static int __init loongson2_init(
void)
146 static void loongson2_exit(
void)
148 reset_counters(
NULL);
153 .reg_setup = loongson2_reg_setup,
154 .cpu_setup = loongson2_cpu_setup,
155 .init = loongson2_init,
156 .exit = loongson2_exit,
157 .cpu_start = loongson2_cpu_start,
158 .cpu_stop = loongson2_cpu_stop,