arch/sparc/kernel/leon_pmc.c
Source file repositories/reference/linux-study-clean/arch/sparc/kernel/leon_pmc.c
File Facts
- System
- Linux kernel
- Corpus path
arch/sparc/kernel/leon_pmc.c- Extension
.c- Size
- 2310 bytes
- Lines
- 99
- Domain
- Architecture Layer
- Bucket
- arch/sparc
- 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.
Dependency Surface
linux/init.hlinux/pm.hasm/leon_amba.hasm/cpu_type.hasm/leon.hasm/processor.h
Detected Declarations
function pmc_leon_need_fixupfunction pmc_leon_idle_fixupfunction pmc_leon_idlefunction leon_pmc_install
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
/* leon_pmc.c: LEON Power-down cpu_idle() handler
*
* Copyright (C) 2011 Daniel Hellstrom (daniel@gaisler.com) Aeroflex Gaisler AB
*/
#include <linux/init.h>
#include <linux/pm.h>
#include <asm/leon_amba.h>
#include <asm/cpu_type.h>
#include <asm/leon.h>
#include <asm/processor.h>
/* List of Systems that need fixup instructions around power-down instruction */
static unsigned int pmc_leon_fixup_ids[] = {
AEROFLEX_UT699,
GAISLER_GR712RC,
LEON4_NEXTREME1,
0
};
static int pmc_leon_need_fixup(void)
{
unsigned int systemid = amba_system_id >> 16;
unsigned int *id;
id = &pmc_leon_fixup_ids[0];
while (*id != 0) {
if (*id == systemid)
return 1;
id++;
}
return 0;
}
/*
* CPU idle callback function for systems that need some extra handling
* See .../arch/sparc/kernel/process.c
*/
static void pmc_leon_idle_fixup(void)
{
/* Prepare an address to a non-cachable region. APB is always
* none-cachable. One instruction is executed after the Sleep
* instruction, we make sure to read the bus and throw away the
* value by accessing a non-cachable area, also we make sure the
* MMU does not get a TLB miss here by using the MMU BYPASS ASI.
*/
register unsigned int address = (unsigned int)leon3_irqctrl_regs;
/* Interrupts need to be enabled to not hang the CPU */
raw_local_irq_enable();
__asm__ __volatile__ (
"wr %%g0, %%asr19\n"
"lda [%0] %1, %%g0\n"
:
: "r"(address), "i"(ASI_LEON_BYPASS));
raw_local_irq_disable();
}
/*
* CPU idle callback function
* See .../arch/sparc/kernel/process.c
*/
static void pmc_leon_idle(void)
{
/* Interrupts need to be enabled to not hang the CPU */
raw_local_irq_enable();
/* For systems without power-down, this will be no-op */
__asm__ __volatile__ ("wr %g0, %asr19\n\t");
raw_local_irq_disable();
}
/* Install LEON Power Down function */
static int __init leon_pmc_install(void)
{
if (sparc_cpu_model == sparc_leon) {
/* Assign power management IDLE handler */
if (pmc_leon_need_fixup())
sparc_idle = pmc_leon_idle_fixup;
else
sparc_idle = pmc_leon_idle;
printk(KERN_INFO "leon: power management initialized\n");
}
Annotation
- Immediate include surface: `linux/init.h`, `linux/pm.h`, `asm/leon_amba.h`, `asm/cpu_type.h`, `asm/leon.h`, `asm/processor.h`.
- Detected declarations: `function pmc_leon_need_fixup`, `function pmc_leon_idle_fixup`, `function pmc_leon_idle`, `function leon_pmc_install`.
- Atlas domain: Architecture Layer / arch/sparc.
- 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.