2 * Copyright (C) 2006 - 2008 Lemote Inc. & Institute of Computing Technology
3 * Author: Yanhua, yanh@lemote.com
5 * This file is subject to the terms and conditions of the GNU General Public
6 * License. See the file "COPYING" in the main directory of this archive
9 #include <linux/cpufreq.h>
10 #include <linux/errno.h>
11 #include <linux/export.h>
13 #include <asm/mach-loongson2ef/loongson.h>
16 DC_ZERO
, DC_25PT
= 2, DC_37PT
, DC_50PT
, DC_62PT
, DC_75PT
,
17 DC_87PT
, DC_DISABLE
, DC_RESV
20 struct cpufreq_frequency_table loongson2_clockmod_table
[] = {
21 {0, DC_RESV
, CPUFREQ_ENTRY_INVALID
},
22 {0, DC_ZERO
, CPUFREQ_ENTRY_INVALID
},
30 {0, DC_RESV
, CPUFREQ_TABLE_END
},
32 EXPORT_SYMBOL_GPL(loongson2_clockmod_table
);
34 int loongson2_cpu_set_rate(unsigned long rate_khz
)
36 struct cpufreq_frequency_table
*pos
;
39 cpufreq_for_each_valid_entry(pos
, loongson2_clockmod_table
)
40 if (rate_khz
== pos
->frequency
)
42 if (rate_khz
!= pos
->frequency
)
45 regval
= readl(LOONGSON_CHIPCFG
);
46 regval
= (regval
& ~0x7) | (pos
->driver_data
- 1);
47 writel(regval
, LOONGSON_CHIPCFG
);
51 EXPORT_SYMBOL_GPL(loongson2_cpu_set_rate
);