arch/mips/bcm63xx/clk.c
Source file repositories/reference/linux-study-clean/arch/mips/bcm63xx/clk.c
File Facts
- System
- Linux kernel
- Corpus path
arch/mips/bcm63xx/clk.c- Extension
.c- Size
- 12981 bytes
- Lines
- 580
- 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.
- CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/init.hlinux/export.hlinux/mutex.hlinux/err.hlinux/clk.hlinux/clkdev.hlinux/delay.hbcm63xx_cpu.hbcm63xx_io.hbcm63xx_regs.hbcm63xx_reset.h
Detected Declarations
struct clkfunction clk_enable_unlockedfunction clk_disable_unlockedfunction bcm_hwclock_setfunction enet_misc_setfunction enetx_setfunction ephy_setfunction swpkt_sar_setfunction swpkt_usb_setfunction enetsw_setfunction pcm_setfunction usbh_setfunction usbd_setfunction spi_setfunction hsspi_setfunction xtm_setfunction ipsec_setfunction pcie_setfunction clk_enablefunction clk_disablefunction clk_set_parentfunction clk_get_ratefunction clk_set_ratefunction clk_round_ratefunction bcm63xx_clk_initexport clk_enableexport clk_disableexport clk_get_parentexport clk_set_parentexport clk_get_rateexport clk_set_rateexport clk_round_rate
Annotated Snippet
struct clk {
void (*set)(struct clk *, int);
unsigned int rate;
unsigned int usage;
int id;
};
static DEFINE_MUTEX(clocks_mutex);
static void clk_enable_unlocked(struct clk *clk)
{
if (clk->set && (clk->usage++) == 0)
clk->set(clk, 1);
}
static void clk_disable_unlocked(struct clk *clk)
{
if (clk->set && (--clk->usage) == 0)
clk->set(clk, 0);
}
static void bcm_hwclock_set(u32 mask, int enable)
{
u32 reg;
reg = bcm_perf_readl(PERF_CKCTL_REG);
if (enable)
reg |= mask;
else
reg &= ~mask;
bcm_perf_writel(reg, PERF_CKCTL_REG);
}
/*
* Ethernet MAC "misc" clock: dma clocks and main clock on 6348
*/
static void enet_misc_set(struct clk *clk, int enable)
{
u32 mask;
if (BCMCPU_IS_6338())
mask = CKCTL_6338_ENET_EN;
else if (BCMCPU_IS_6345())
mask = CKCTL_6345_ENET_EN;
else if (BCMCPU_IS_6348())
mask = CKCTL_6348_ENET_EN;
else
/* BCMCPU_IS_6358 */
mask = CKCTL_6358_EMUSB_EN;
bcm_hwclock_set(mask, enable);
}
static struct clk clk_enet_misc = {
.set = enet_misc_set,
};
/*
* Ethernet MAC clocks: only relevant on 6358, silently enable misc
* clocks
*/
static void enetx_set(struct clk *clk, int enable)
{
if (enable)
clk_enable_unlocked(&clk_enet_misc);
else
clk_disable_unlocked(&clk_enet_misc);
if (BCMCPU_IS_3368() || BCMCPU_IS_6358()) {
u32 mask;
if (clk->id == 0)
mask = CKCTL_6358_ENET0_EN;
else
mask = CKCTL_6358_ENET1_EN;
bcm_hwclock_set(mask, enable);
}
}
static struct clk clk_enet0 = {
.id = 0,
.set = enetx_set,
};
static struct clk clk_enet1 = {
.id = 1,
.set = enetx_set,
};
/*
Annotation
- Immediate include surface: `linux/init.h`, `linux/export.h`, `linux/mutex.h`, `linux/err.h`, `linux/clk.h`, `linux/clkdev.h`, `linux/delay.h`, `bcm63xx_cpu.h`.
- Detected declarations: `struct clk`, `function clk_enable_unlocked`, `function clk_disable_unlocked`, `function bcm_hwclock_set`, `function enet_misc_set`, `function enetx_set`, `function ephy_set`, `function swpkt_sar_set`, `function swpkt_usb_set`, `function enetsw_set`.
- Atlas domain: Architecture Layer / arch/mips.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.