arch/microblaze/kernel/timer.c
Source file repositories/reference/linux-study-clean/arch/microblaze/kernel/timer.c
File Facts
- System
- Linux kernel
- Corpus path
arch/microblaze/kernel/timer.c- Extension
.c- Size
- 7806 bytes
- Lines
- 331
- Domain
- Architecture Layer
- Bucket
- arch/microblaze
- 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/interrupt.hlinux/delay.hlinux/sched.hlinux/sched/clock.hlinux/sched_clock.hlinux/clk.hlinux/clockchips.hlinux/of_address.hlinux/of_irq.hlinux/timecounter.hasm/cpuinfo.h
Detected Declarations
function timer_write32function timer_read32function timer_write32_befunction timer_read32_befunction xilinx_timer0_stopfunction xilinx_timer0_start_periodicfunction xilinx_timer0_start_oneshotfunction xilinx_timer_set_next_eventfunction xilinx_timer_shutdownfunction xilinx_timer_set_periodicfunction timer_ackfunction timer_interruptfunction xilinx_clockevent_initfunction xilinx_clock_readfunction xilinx_readfunction xilinx_cc_readfunction init_xilinx_timecounterfunction xilinx_clocksource_initfunction xilinx_timer_init
Annotated Snippet
#include <linux/interrupt.h>
#include <linux/delay.h>
#include <linux/sched.h>
#include <linux/sched/clock.h>
#include <linux/sched_clock.h>
#include <linux/clk.h>
#include <linux/clockchips.h>
#include <linux/of_address.h>
#include <linux/of_irq.h>
#include <linux/timecounter.h>
#include <asm/cpuinfo.h>
static void __iomem *timer_baseaddr;
static unsigned int freq_div_hz;
static unsigned int timer_clock_freq;
#define TCSR0 (0x00)
#define TLR0 (0x04)
#define TCR0 (0x08)
#define TCSR1 (0x10)
#define TLR1 (0x14)
#define TCR1 (0x18)
#define TCSR_MDT (1<<0)
#define TCSR_UDT (1<<1)
#define TCSR_GENT (1<<2)
#define TCSR_CAPT (1<<3)
#define TCSR_ARHT (1<<4)
#define TCSR_LOAD (1<<5)
#define TCSR_ENIT (1<<6)
#define TCSR_ENT (1<<7)
#define TCSR_TINT (1<<8)
#define TCSR_PWMA (1<<9)
#define TCSR_ENALL (1<<10)
static unsigned int (*read_fn)(void __iomem *);
static void (*write_fn)(u32, void __iomem *);
static void timer_write32(u32 val, void __iomem *addr)
{
iowrite32(val, addr);
}
static unsigned int timer_read32(void __iomem *addr)
{
return ioread32(addr);
}
static void timer_write32_be(u32 val, void __iomem *addr)
{
iowrite32be(val, addr);
}
static unsigned int timer_read32_be(void __iomem *addr)
{
return ioread32be(addr);
}
static inline void xilinx_timer0_stop(void)
{
write_fn(read_fn(timer_baseaddr + TCSR0) & ~TCSR_ENT,
timer_baseaddr + TCSR0);
}
static inline void xilinx_timer0_start_periodic(unsigned long load_val)
{
if (!load_val)
load_val = 1;
/* loading value to timer reg */
write_fn(load_val, timer_baseaddr + TLR0);
/* load the initial value */
write_fn(TCSR_LOAD, timer_baseaddr + TCSR0);
/* see timer data sheet for detail
* !ENALL - don't enable 'em all
* !PWMA - disable pwm
* TINT - clear interrupt status
* ENT- enable timer itself
* ENIT - enable interrupt
* !LOAD - clear the bit to let go
* ARHT - auto reload
* !CAPT - no external trigger
* !GENT - no external signal
* UDT - set the timer as down counter
* !MDT0 - generate mode
*/
write_fn(TCSR_TINT|TCSR_ENIT|TCSR_ENT|TCSR_ARHT|TCSR_UDT,
timer_baseaddr + TCSR0);
Annotation
- Immediate include surface: `linux/interrupt.h`, `linux/delay.h`, `linux/sched.h`, `linux/sched/clock.h`, `linux/sched_clock.h`, `linux/clk.h`, `linux/clockchips.h`, `linux/of_address.h`.
- Detected declarations: `function timer_write32`, `function timer_read32`, `function timer_write32_be`, `function timer_read32_be`, `function xilinx_timer0_stop`, `function xilinx_timer0_start_periodic`, `function xilinx_timer0_start_oneshot`, `function xilinx_timer_set_next_event`, `function xilinx_timer_shutdown`, `function xilinx_timer_set_periodic`.
- Atlas domain: Architecture Layer / arch/microblaze.
- 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.