2009-11-17 01:32:59 +08:00
|
|
|
/*
|
2015-07-08 02:56:04 +08:00
|
|
|
* Copyright (C) 2006 - 2008 Lemote Inc. & Institute of Computing Technology
|
2009-11-17 01:32:59 +08:00
|
|
|
* Author: Yanhua, yanh@lemote.com
|
|
|
|
*
|
|
|
|
* This file is subject to the terms and conditions of the GNU General Public
|
|
|
|
* License. See the file "COPYING" in the main directory of this archive
|
|
|
|
* for more details.
|
|
|
|
*/
|
|
|
|
#include <linux/cpufreq.h>
|
2012-08-01 23:15:32 +08:00
|
|
|
#include <linux/errno.h>
|
|
|
|
#include <linux/export.h>
|
2009-11-17 01:32:59 +08:00
|
|
|
|
2019-10-20 22:43:14 +08:00
|
|
|
#include <asm/mach-loongson2ef/loongson.h>
|
2009-11-17 01:32:59 +08:00
|
|
|
|
|
|
|
enum {
|
|
|
|
DC_ZERO, DC_25PT = 2, DC_37PT, DC_50PT, DC_62PT, DC_75PT,
|
|
|
|
DC_87PT, DC_DISABLE, DC_RESV
|
|
|
|
};
|
|
|
|
|
|
|
|
struct cpufreq_frequency_table loongson2_clockmod_table[] = {
|
2014-03-28 21:41:47 +08:00
|
|
|
{0, DC_RESV, CPUFREQ_ENTRY_INVALID},
|
|
|
|
{0, DC_ZERO, CPUFREQ_ENTRY_INVALID},
|
|
|
|
{0, DC_25PT, 0},
|
|
|
|
{0, DC_37PT, 0},
|
|
|
|
{0, DC_50PT, 0},
|
|
|
|
{0, DC_62PT, 0},
|
|
|
|
{0, DC_75PT, 0},
|
|
|
|
{0, DC_87PT, 0},
|
|
|
|
{0, DC_DISABLE, 0},
|
|
|
|
{0, DC_RESV, CPUFREQ_TABLE_END},
|
2009-11-17 01:32:59 +08:00
|
|
|
};
|
|
|
|
EXPORT_SYMBOL_GPL(loongson2_clockmod_table);
|
|
|
|
|
2020-04-09 17:02:28 +08:00
|
|
|
int loongson2_cpu_set_rate(unsigned long rate_khz)
|
2009-11-17 01:32:59 +08:00
|
|
|
{
|
2014-04-26 04:16:25 +08:00
|
|
|
struct cpufreq_frequency_table *pos;
|
2009-11-17 01:32:59 +08:00
|
|
|
int regval;
|
|
|
|
|
2014-04-26 04:16:25 +08:00
|
|
|
cpufreq_for_each_valid_entry(pos, loongson2_clockmod_table)
|
2014-09-21 20:38:43 +08:00
|
|
|
if (rate_khz == pos->frequency)
|
2009-11-17 01:32:59 +08:00
|
|
|
break;
|
2014-09-21 20:38:43 +08:00
|
|
|
if (rate_khz != pos->frequency)
|
2009-11-17 01:32:59 +08:00
|
|
|
return -ENOTSUPP;
|
|
|
|
|
2019-10-20 22:43:15 +08:00
|
|
|
regval = readl(LOONGSON_CHIPCFG);
|
2014-04-26 04:16:25 +08:00
|
|
|
regval = (regval & ~0x7) | (pos->driver_data - 1);
|
2019-10-20 22:43:15 +08:00
|
|
|
writel(regval, LOONGSON_CHIPCFG);
|
2009-11-17 01:32:59 +08:00
|
|
|
|
2020-04-09 17:02:28 +08:00
|
|
|
return 0;
|
2009-11-17 01:32:59 +08:00
|
|
|
}
|
2020-04-09 17:02:28 +08:00
|
|
|
EXPORT_SYMBOL_GPL(loongson2_cpu_set_rate);
|