drivers/clocksource/timer-milbeaut.c
Source file repositories/reference/linux-study-clean/drivers/clocksource/timer-milbeaut.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/clocksource/timer-milbeaut.c- Extension
.c- Size
- 5220 bytes
- Lines
- 190
- 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/interrupt.hlinux/irq.hlinux/irqreturn.hlinux/sched_clock.htimer-of.h
Detected Declarations
function Copyrightfunction mlb_evt_timer_startfunction mlb_evt_timer_stopfunction mlb_evt_timer_register_countfunction mlb_set_state_periodicfunction mlb_set_state_oneshotfunction mlb_set_state_shutdownfunction mlb_clkevt_next_eventfunction mlb_config_clock_sourcefunction mlb_config_clock_eventfunction mlb_timer_sched_readfunction mlb_timer_init
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (C) 2018 Socionext Inc.
*/
#include <linux/clk.h>
#include <linux/interrupt.h>
#include <linux/irq.h>
#include <linux/irqreturn.h>
#include <linux/sched_clock.h>
#include "timer-of.h"
#define MLB_TMR_TMCSR_OFS 0x0
#define MLB_TMR_TMR_OFS 0x4
#define MLB_TMR_TMRLR1_OFS 0x8
#define MLB_TMR_TMRLR2_OFS 0xc
#define MLB_TMR_REGSZPCH 0x10
#define MLB_TMR_TMCSR_OUTL BIT(5)
#define MLB_TMR_TMCSR_RELD BIT(4)
#define MLB_TMR_TMCSR_INTE BIT(3)
#define MLB_TMR_TMCSR_UF BIT(2)
#define MLB_TMR_TMCSR_CNTE BIT(1)
#define MLB_TMR_TMCSR_TRG BIT(0)
#define MLB_TMR_TMCSR_CSL_DIV2 0
#define MLB_TMR_DIV_CNT 2
#define MLB_TMR_SRC_CH 1
#define MLB_TMR_EVT_CH 0
#define MLB_TMR_SRC_CH_OFS (MLB_TMR_REGSZPCH * MLB_TMR_SRC_CH)
#define MLB_TMR_EVT_CH_OFS (MLB_TMR_REGSZPCH * MLB_TMR_EVT_CH)
#define MLB_TMR_SRC_TMCSR_OFS (MLB_TMR_SRC_CH_OFS + MLB_TMR_TMCSR_OFS)
#define MLB_TMR_SRC_TMR_OFS (MLB_TMR_SRC_CH_OFS + MLB_TMR_TMR_OFS)
#define MLB_TMR_SRC_TMRLR1_OFS (MLB_TMR_SRC_CH_OFS + MLB_TMR_TMRLR1_OFS)
#define MLB_TMR_SRC_TMRLR2_OFS (MLB_TMR_SRC_CH_OFS + MLB_TMR_TMRLR2_OFS)
#define MLB_TMR_EVT_TMCSR_OFS (MLB_TMR_EVT_CH_OFS + MLB_TMR_TMCSR_OFS)
#define MLB_TMR_EVT_TMR_OFS (MLB_TMR_EVT_CH_OFS + MLB_TMR_TMR_OFS)
#define MLB_TMR_EVT_TMRLR1_OFS (MLB_TMR_EVT_CH_OFS + MLB_TMR_TMRLR1_OFS)
#define MLB_TMR_EVT_TMRLR2_OFS (MLB_TMR_EVT_CH_OFS + MLB_TMR_TMRLR2_OFS)
#define MLB_TIMER_RATING 500
#define MLB_TIMER_ONESHOT 0
#define MLB_TIMER_PERIODIC 1
static irqreturn_t mlb_timer_interrupt(int irq, void *dev_id)
{
struct clock_event_device *clk = dev_id;
struct timer_of *to = to_timer_of(clk);
u32 val;
val = readl_relaxed(timer_of_base(to) + MLB_TMR_EVT_TMCSR_OFS);
val &= ~MLB_TMR_TMCSR_UF;
writel_relaxed(val, timer_of_base(to) + MLB_TMR_EVT_TMCSR_OFS);
clk->event_handler(clk);
return IRQ_HANDLED;
}
static void mlb_evt_timer_start(struct timer_of *to, bool periodic)
{
u32 val = MLB_TMR_TMCSR_CSL_DIV2;
val |= MLB_TMR_TMCSR_CNTE | MLB_TMR_TMCSR_TRG | MLB_TMR_TMCSR_INTE;
if (periodic)
val |= MLB_TMR_TMCSR_RELD;
writel_relaxed(val, timer_of_base(to) + MLB_TMR_EVT_TMCSR_OFS);
}
static void mlb_evt_timer_stop(struct timer_of *to)
{
u32 val = readl_relaxed(timer_of_base(to) + MLB_TMR_EVT_TMCSR_OFS);
val &= ~MLB_TMR_TMCSR_CNTE;
writel_relaxed(val, timer_of_base(to) + MLB_TMR_EVT_TMCSR_OFS);
}
static void mlb_evt_timer_register_count(struct timer_of *to, unsigned long cnt)
{
writel_relaxed(cnt, timer_of_base(to) + MLB_TMR_EVT_TMRLR1_OFS);
}
static int mlb_set_state_periodic(struct clock_event_device *clk)
{
struct timer_of *to = to_timer_of(clk);
Annotation
- Immediate include surface: `linux/clk.h`, `linux/interrupt.h`, `linux/irq.h`, `linux/irqreturn.h`, `linux/sched_clock.h`, `timer-of.h`.
- Detected declarations: `function Copyright`, `function mlb_evt_timer_start`, `function mlb_evt_timer_stop`, `function mlb_evt_timer_register_count`, `function mlb_set_state_periodic`, `function mlb_set_state_oneshot`, `function mlb_set_state_shutdown`, `function mlb_clkevt_next_event`, `function mlb_config_clock_source`, `function mlb_config_clock_event`.
- 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.