arch/sh/kernel/cpu/shmobile/cpuidle.c
Source file repositories/reference/linux-study-clean/arch/sh/kernel/cpu/shmobile/cpuidle.c
File Facts
- System
- Linux kernel
- Corpus path
arch/sh/kernel/cpu/shmobile/cpuidle.c- Extension
.c- Size
- 2318 bytes
- Lines
- 96
- Domain
- Architecture Layer
- Bucket
- arch/sh
- 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/init.hlinux/kernel.hlinux/io.hlinux/suspend.hlinux/cpuidle.hlinux/export.hasm/suspend.hlinux/uaccess.h
Detected Declarations
function cpuidle_sleep_enterfunction sh_mobile_setup_cpuidle
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
/*
* arch/sh/kernel/cpu/shmobile/cpuidle.c
*
* Cpuidle support code for SuperH Mobile
*
* Copyright (C) 2009 Magnus Damm
*/
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/io.h>
#include <linux/suspend.h>
#include <linux/cpuidle.h>
#include <linux/export.h>
#include <asm/suspend.h>
#include <linux/uaccess.h>
static unsigned long cpuidle_mode[] = {
SUSP_SH_SLEEP, /* regular sleep mode */
SUSP_SH_SLEEP | SUSP_SH_SF, /* sleep mode + self refresh */
SUSP_SH_STANDBY | SUSP_SH_SF, /* software standby mode + self refresh */
};
static int cpuidle_sleep_enter(struct cpuidle_device *dev,
struct cpuidle_driver *drv,
int index)
{
unsigned long allowed_mode = SUSP_SH_SLEEP;
int requested_state = index;
int allowed_state;
int k;
/* convert allowed mode to allowed state */
for (k = ARRAY_SIZE(cpuidle_mode) - 1; k > 0; k--)
if (cpuidle_mode[k] == allowed_mode)
break;
allowed_state = k;
/* take the following into account for sleep mode selection:
* - allowed_state: best mode allowed by hardware (clock deps)
* - requested_state: best mode allowed by software (latencies)
*/
k = min_t(int, allowed_state, requested_state);
sh_mobile_call_standby(cpuidle_mode[k]);
return k;
}
static struct cpuidle_driver cpuidle_driver = {
.name = "sh_idle",
.owner = THIS_MODULE,
.states = {
{
.exit_latency = 1,
.target_residency = 1 * 2,
.power_usage = 3,
.enter = cpuidle_sleep_enter,
.name = "C1",
.desc = "SuperH Sleep Mode",
},
{
.exit_latency = 100,
.target_residency = 1 * 2,
.power_usage = 1,
.enter = cpuidle_sleep_enter,
.name = "C2",
.desc = "SuperH Sleep Mode [SF]",
.flags = CPUIDLE_FLAG_UNUSABLE,
},
{
.exit_latency = 2300,
.target_residency = 1 * 2,
.power_usage = 1,
.enter = cpuidle_sleep_enter,
.name = "C3",
.desc = "SuperH Mobile Standby Mode [SF]",
.flags = CPUIDLE_FLAG_UNUSABLE,
},
},
.safe_state_index = 0,
.state_count = 3,
};
int __init sh_mobile_setup_cpuidle(void)
{
if (sh_mobile_sleep_supported & SUSP_SH_SF)
cpuidle_driver.states[1].flags = CPUIDLE_FLAG_NONE;
Annotation
- Immediate include surface: `linux/init.h`, `linux/kernel.h`, `linux/io.h`, `linux/suspend.h`, `linux/cpuidle.h`, `linux/export.h`, `asm/suspend.h`, `linux/uaccess.h`.
- Detected declarations: `function cpuidle_sleep_enter`, `function sh_mobile_setup_cpuidle`.
- Atlas domain: Architecture Layer / arch/sh.
- 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.