arch/mips/loongson2ef/lemote-2f/clock.c

Source file repositories/reference/linux-study-clean/arch/mips/loongson2ef/lemote-2f/clock.c

File Facts

System
Linux kernel
Corpus path
arch/mips/loongson2ef/lemote-2f/clock.c
Extension
.c
Size
1311 bytes
Lines
52
Domain
Architecture Layer
Bucket
arch/mips
Inferred role
Architecture Layer: exported/initcall integration point
Status
integration implementation candidate

Why This File Exists

CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.

Dependency Surface

Detected Declarations

Annotated Snippet

#include <linux/cpufreq.h>
#include <linux/errno.h>
#include <linux/export.h>

#include <asm/mach-loongson2ef/loongson.h>

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[] = {
	{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},
};
EXPORT_SYMBOL_GPL(loongson2_clockmod_table);

int loongson2_cpu_set_rate(unsigned long rate_khz)
{
	struct cpufreq_frequency_table *pos;
	int regval;

	cpufreq_for_each_valid_entry(pos, loongson2_clockmod_table)
		if (rate_khz == pos->frequency)
			break;
	if (rate_khz != pos->frequency)
		return -ENOTSUPP;

	regval = readl(LOONGSON_CHIPCFG);
	regval = (regval & ~0x7) | (pos->driver_data - 1);
	writel(regval, LOONGSON_CHIPCFG);

	return 0;
}
EXPORT_SYMBOL_GPL(loongson2_cpu_set_rate);

Annotation

Implementation Notes