drivers/clocksource/mips-gic-timer.c
Source file repositories/reference/linux-study-clean/drivers/clocksource/mips-gic-timer.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/clocksource/mips-gic-timer.c- Extension
.c- Size
- 7263 bytes
- Lines
- 307
- Domain
- Driver Families
- Bucket
- drivers/clocksource
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/clk.hlinux/clockchips.hlinux/cpu.hlinux/init.hlinux/interrupt.hlinux/notifier.hlinux/of_irq.hlinux/percpu.hlinux/sched_clock.hlinux/smp.hlinux/time.hasm/mips-cps.h
Detected Declarations
function gic_read_count_2x32function gic_read_count_64function gic_read_countfunction gic_next_eventfunction gic_compare_interruptfunction gic_clockevent_cpu_initfunction gic_clockevent_cpu_exitfunction gic_update_frequencyfunction gic_starting_cpufunction gic_clk_notifierfunction gic_dying_cpufunction gic_clockevent_initfunction gic_hpt_readfunction gic_hpt_read_multiclusterfunction gic_clocksource_unstablefunction __gic_clocksource_initfunction gic_clocksource_of_init
Annotated Snippet
if (ret < 0) {
pr_err("Failed to enable clock\n");
clk_put(clk);
return ret;
}
gic_frequency = clk_get_rate(clk);
} else if (of_property_read_u32(node, "clock-frequency",
&gic_frequency)) {
pr_err("Frequency not specified\n");
return -EINVAL;
}
gic_timer_irq = irq_of_parse_and_map(node, 0);
if (!gic_timer_irq) {
pr_err("IRQ not specified\n");
return -EINVAL;
}
ret = __gic_clocksource_init();
if (ret)
return ret;
ret = gic_clockevent_init();
if (!ret && !IS_ERR(clk)) {
if (clk_notifier_register(clk, &gic_clk_nb) < 0)
pr_warn("Unable to register clock notifier\n");
}
/*
* It's safe to use the MIPS GIC timer as a sched clock source only if
* its ticks are stable, which is true on either the platforms with
* stable CPU frequency or on the platforms with CM3 and CPU frequency
* change performed by the CPC core clocks divider.
*/
if ((mips_cm_revision() >= CM_REV_CM3 || !IS_ENABLED(CONFIG_CPU_FREQ)) &&
!mips_cps_multicluster_cpus()) {
sched_clock_register(mips_cm_is64 ?
gic_read_count_64 : gic_read_count_2x32,
gic_count_width, gic_frequency);
}
return 0;
}
TIMER_OF_DECLARE(mips_gic_timer, "mti,gic-timer",
gic_clocksource_of_init);
Annotation
- Immediate include surface: `linux/clk.h`, `linux/clockchips.h`, `linux/cpu.h`, `linux/init.h`, `linux/interrupt.h`, `linux/notifier.h`, `linux/of_irq.h`, `linux/percpu.h`.
- Detected declarations: `function gic_read_count_2x32`, `function gic_read_count_64`, `function gic_read_count`, `function gic_next_event`, `function gic_compare_interrupt`, `function gic_clockevent_cpu_init`, `function gic_clockevent_cpu_exit`, `function gic_update_frequency`, `function gic_starting_cpu`, `function gic_clk_notifier`.
- Atlas domain: Driver Families / drivers/clocksource.
- Implementation status: source implementation candidate.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.