Path: blob/master/arch/mips/loongson2ef/lemote-2f/clock.c
26490 views
/*1* Copyright (C) 2006 - 2008 Lemote Inc. & Institute of Computing Technology2* Author: Yanhua, [email protected]3*4* This file is subject to the terms and conditions of the GNU General Public5* License. See the file "COPYING" in the main directory of this archive6* for more details.7*/8#include <linux/cpufreq.h>9#include <linux/errno.h>10#include <linux/export.h>1112#include <asm/mach-loongson2ef/loongson.h>1314enum {15DC_ZERO, DC_25PT = 2, DC_37PT, DC_50PT, DC_62PT, DC_75PT,16DC_87PT, DC_DISABLE, DC_RESV17};1819struct cpufreq_frequency_table loongson2_clockmod_table[] = {20{0, DC_RESV, CPUFREQ_ENTRY_INVALID},21{0, DC_ZERO, CPUFREQ_ENTRY_INVALID},22{0, DC_25PT, 0},23{0, DC_37PT, 0},24{0, DC_50PT, 0},25{0, DC_62PT, 0},26{0, DC_75PT, 0},27{0, DC_87PT, 0},28{0, DC_DISABLE, 0},29{0, DC_RESV, CPUFREQ_TABLE_END},30};31EXPORT_SYMBOL_GPL(loongson2_clockmod_table);3233int loongson2_cpu_set_rate(unsigned long rate_khz)34{35struct cpufreq_frequency_table *pos;36int regval;3738cpufreq_for_each_valid_entry(pos, loongson2_clockmod_table)39if (rate_khz == pos->frequency)40break;41if (rate_khz != pos->frequency)42return -ENOTSUPP;4344regval = readl(LOONGSON_CHIPCFG);45regval = (regval & ~0x7) | (pos->driver_data - 1);46writel(regval, LOONGSON_CHIPCFG);4748return 0;49}50EXPORT_SYMBOL_GPL(loongson2_cpu_set_rate);515253