arch/arm/mach-mmp/time.c
Source file repositories/reference/linux-study-clean/arch/arm/mach-mmp/time.c
File Facts
- System
- Linux kernel
- Corpus path
arch/arm/mach-mmp/time.c- Extension
.c- Size
- 5071 bytes
- Lines
- 222
- Domain
- Architecture Layer
- Bucket
- arch/arm
- 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.
- 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/init.hlinux/kernel.hlinux/interrupt.hlinux/clockchips.hlinux/clk.hlinux/io.hlinux/irq.hlinux/of.hlinux/of_address.hlinux/of_irq.hlinux/sched_clock.hasm/mach/time.hregs-timers.hlinux/soc/mmp/cputype.h
Detected Declarations
function timer_readfunction mmp_read_sched_clockfunction timer_interruptfunction timer_set_next_eventfunction timer_set_shutdownfunction clksrc_readfunction timer_configfunction mmp_timer_initfunction mmp_dt_init_timer
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
/*
* linux/arch/arm/mach-mmp/time.c
*
* Support for clocksource and clockevents
*
* Copyright (C) 2008 Marvell International Ltd.
* All rights reserved.
*
* 2008-04-11: Jason Chagas <Jason.chagas@marvell.com>
* 2008-10-08: Bin Yang <bin.yang@marvell.com>
*
* The timers module actually includes three timers, each timer with up to
* three match comparators. Timer #0 is used here in free-running mode as
* the clock source, and match comparator #1 used as clock event device.
*/
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/interrupt.h>
#include <linux/clockchips.h>
#include <linux/clk.h>
#include <linux/io.h>
#include <linux/irq.h>
#include <linux/of.h>
#include <linux/of_address.h>
#include <linux/of_irq.h>
#include <linux/sched_clock.h>
#include <asm/mach/time.h>
#include "regs-timers.h"
#include <linux/soc/mmp/cputype.h>
#define MAX_DELTA (0xfffffffe)
#define MIN_DELTA (16)
static void __iomem *mmp_timer_base;
/*
* Read the timer through the CVWR register. Delay is required after requesting
* a read. The CR register cannot be directly read due to metastability issues
* documented in the PXA168 software manual.
*/
static inline uint32_t timer_read(void)
{
uint32_t val;
int delay = 3;
__raw_writel(1, mmp_timer_base + TMR_CVWR(1));
while (delay--)
val = __raw_readl(mmp_timer_base + TMR_CVWR(1));
return val;
}
static u64 notrace mmp_read_sched_clock(void)
{
return timer_read();
}
static irqreturn_t timer_interrupt(int irq, void *dev_id)
{
struct clock_event_device *c = dev_id;
/*
* Clear pending interrupt status.
*/
__raw_writel(0x01, mmp_timer_base + TMR_ICR(0));
/*
* Disable timer 0.
*/
__raw_writel(0x02, mmp_timer_base + TMR_CER);
c->event_handler(c);
return IRQ_HANDLED;
}
static int timer_set_next_event(unsigned long delta,
struct clock_event_device *dev)
{
unsigned long flags;
local_irq_save(flags);
/*
* Disable timer 0.
Annotation
- Immediate include surface: `linux/init.h`, `linux/kernel.h`, `linux/interrupt.h`, `linux/clockchips.h`, `linux/clk.h`, `linux/io.h`, `linux/irq.h`, `linux/of.h`.
- Detected declarations: `function timer_read`, `function mmp_read_sched_clock`, `function timer_interrupt`, `function timer_set_next_event`, `function timer_set_shutdown`, `function clksrc_read`, `function timer_config`, `function mmp_timer_init`, `function mmp_dt_init_timer`.
- Atlas domain: Architecture Layer / arch/arm.
- 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.