arch/mips/ralink/clk.c
Source file repositories/reference/linux-study-clean/arch/mips/ralink/clk.c
File Facts
- System
- Linux kernel
- Corpus path
arch/mips/ralink/clk.c- Extension
.c- Size
- 1910 bytes
- Lines
- 87
- Domain
- Architecture Layer
- Bucket
- arch/mips
- Inferred role
- Architecture Layer: implementation source
- Status
- source 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.
- CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kernel.hlinux/init.hlinux/export.hlinux/clkdev.hlinux/clk.hlinux/clk-provider.hasm/mach-ralink/ralink_regs.hasm/time.hcommon.h
Detected Declarations
function Copyrightfunction plat_time_init
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
/*
*
* Copyright (C) 2011 Gabor Juhos <juhosg@openwrt.org>
* Copyright (C) 2013 John Crispin <john@phrozen.org>
*/
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/export.h>
#include <linux/clkdev.h>
#include <linux/clk.h>
#include <linux/clk-provider.h>
#include <asm/mach-ralink/ralink_regs.h>
#include <asm/time.h>
#include "common.h"
static const char *clk_cpu(int *idx)
{
switch (ralink_soc) {
case RT2880_SOC:
*idx = 1;
return "ralink,rt2880-sysc";
case RT3883_SOC:
*idx = 1;
return "ralink,rt3883-sysc";
case RT305X_SOC_RT3050:
*idx = 1;
return "ralink,rt3050-sysc";
case RT305X_SOC_RT3052:
*idx = 1;
return "ralink,rt3052-sysc";
case RT305X_SOC_RT3350:
*idx = 1;
return "ralink,rt3350-sysc";
case RT305X_SOC_RT3352:
*idx = 1;
return "ralink,rt3352-sysc";
case RT305X_SOC_RT5350:
*idx = 1;
return "ralink,rt5350-sysc";
case MT762X_SOC_MT7620A:
*idx = 2;
return "ralink,mt7620-sysc";
case MT762X_SOC_MT7620N:
*idx = 2;
return "ralink,mt7620-sysc";
case MT762X_SOC_MT7628AN:
*idx = 1;
return "ralink,mt7628-sysc";
case MT762X_SOC_MT7688:
*idx = 1;
return "ralink,mt7688-sysc";
default:
*idx = -1;
return "invalid";
}
}
void __init plat_time_init(void)
{
struct of_phandle_args clkspec;
const char *compatible;
struct clk *clk;
int cpu_clk_idx;
ralink_of_remap();
compatible = clk_cpu(&cpu_clk_idx);
if (cpu_clk_idx == -1)
panic("unable to get CPU clock index");
of_clk_init(NULL);
clkspec.np = of_find_compatible_node(NULL, NULL, compatible);
clkspec.args_count = 1;
clkspec.args[0] = cpu_clk_idx;
clk = of_clk_get_from_provider(&clkspec);
if (IS_ERR(clk))
panic("unable to get CPU clock, err=%ld", PTR_ERR(clk));
pr_info("CPU Clock: %ldMHz\n", clk_get_rate(clk) / 1000000);
mips_hpt_frequency = clk_get_rate(clk) / 2;
clk_put(clk);
timer_probe();
}
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/init.h`, `linux/export.h`, `linux/clkdev.h`, `linux/clk.h`, `linux/clk-provider.h`, `asm/mach-ralink/ralink_regs.h`, `asm/time.h`.
- Detected declarations: `function Copyright`, `function plat_time_init`.
- Atlas domain: Architecture Layer / arch/mips.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.