arch/mips/ath79/clock.c
Source file repositories/reference/linux-study-clean/arch/mips/ath79/clock.c
File Facts
- System
- Linux kernel
- Corpus path
arch/mips/ath79/clock.c- Extension
.c- Size
- 20853 bytes
- Lines
- 674
- 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/io.hlinux/err.hlinux/clk.hlinux/clkdev.hlinux/clk-provider.hlinux/of.hlinux/of_address.hdt-bindings/clock/ath79-clk.hasm/div64.hasm/mach-ath79/ath79.hasm/mach-ath79/ar71xx_regs.hcommon.h
Detected Declarations
function ath79_clk_namefunction __ath79_set_clkfunction ath79_set_clkfunction ath79_set_ff_clkfunction ath79_setup_ref_clkfunction ar71xx_clocks_initfunction ar724x_clocks_initfunction ar933x_clocks_initfunction ar934x_get_pll_freqfunction ar934x_clocks_initfunction qca953x_clocks_initfunction qca955x_clocks_initfunction qca956x_clocks_initfunction ath79_clocks_init_dt
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
/*
* Atheros AR71XX/AR724X/AR913X common routines
*
* Copyright (C) 2010-2011 Jaiganesh Narayanan <jnarayanan@atheros.com>
* Copyright (C) 2011 Gabor Juhos <juhosg@openwrt.org>
*
* Parts of this file are based on Atheros' 2.6.15/2.6.31 BSP
*/
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/io.h>
#include <linux/err.h>
#include <linux/clk.h>
#include <linux/clkdev.h>
#include <linux/clk-provider.h>
#include <linux/of.h>
#include <linux/of_address.h>
#include <dt-bindings/clock/ath79-clk.h>
#include <asm/div64.h>
#include <asm/mach-ath79/ath79.h>
#include <asm/mach-ath79/ar71xx_regs.h>
#include "common.h"
#define AR71XX_BASE_FREQ 40000000
#define AR724X_BASE_FREQ 40000000
static struct clk *clks[ATH79_CLK_END];
static struct clk_onecell_data clk_data = {
.clks = clks,
.clk_num = ARRAY_SIZE(clks),
};
static const char * const clk_names[ATH79_CLK_END] = {
[ATH79_CLK_CPU] = "cpu",
[ATH79_CLK_DDR] = "ddr",
[ATH79_CLK_AHB] = "ahb",
[ATH79_CLK_REF] = "ref",
[ATH79_CLK_MDIO] = "mdio",
};
static const char * __init ath79_clk_name(int type)
{
BUG_ON(type >= ARRAY_SIZE(clk_names) || !clk_names[type]);
return clk_names[type];
}
static void __init __ath79_set_clk(int type, const char *name, struct clk *clk)
{
if (IS_ERR(clk))
panic("failed to allocate %s clock structure", clk_names[type]);
clks[type] = clk;
clk_register_clkdev(clk, name, NULL);
}
static struct clk * __init ath79_set_clk(int type, unsigned long rate)
{
const char *name = ath79_clk_name(type);
struct clk *clk;
clk = clk_register_fixed_rate(NULL, name, NULL, 0, rate);
__ath79_set_clk(type, name, clk);
return clk;
}
static struct clk * __init ath79_set_ff_clk(int type, const char *parent,
unsigned int mult, unsigned int div)
{
const char *name = ath79_clk_name(type);
struct clk *clk;
clk = clk_register_fixed_factor(NULL, name, parent, 0, mult, div);
__ath79_set_clk(type, name, clk);
return clk;
}
static unsigned long __init ath79_setup_ref_clk(unsigned long rate)
{
struct clk *clk = clks[ATH79_CLK_REF];
if (clk)
rate = clk_get_rate(clk);
else
clk = ath79_set_clk(ATH79_CLK_REF, rate);
return rate;
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/init.h`, `linux/io.h`, `linux/err.h`, `linux/clk.h`, `linux/clkdev.h`, `linux/clk-provider.h`, `linux/of.h`.
- Detected declarations: `function ath79_clk_name`, `function __ath79_set_clk`, `function ath79_set_clk`, `function ath79_set_ff_clk`, `function ath79_setup_ref_clk`, `function ar71xx_clocks_init`, `function ar724x_clocks_init`, `function ar933x_clocks_init`, `function ar934x_get_pll_freq`, `function ar934x_clocks_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.