drivers/clocksource/timer-microchip-pit64b.c
Source file repositories/reference/linux-study-clean/drivers/clocksource/timer-microchip-pit64b.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/clocksource/timer-microchip-pit64b.c- Extension
.c- Size
- 13803 bytes
- Lines
- 509
- 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.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/clk.hlinux/clockchips.hlinux/delay.hlinux/interrupt.hlinux/of_address.hlinux/of_irq.hlinux/sched_clock.hlinux/slab.h
Detected Declarations
struct mchp_pit64b_timerstruct mchp_pit64b_clkevtstruct mchp_pit64b_clksrcfunction mchp_pit64b_cnt_readfunction mchp_pit64b_resetfunction mchp_pit64b_suspendfunction mchp_pit64b_resumefunction mchp_pit64b_clksrc_suspendfunction mchp_pit64b_clksrc_resumefunction mchp_pit64b_clksrc_readfunction mchp_pit64b_sched_read_clkfunction mchp_pit64b_dt_readfunction mchp_pit64b_clkevt_shutdownfunction mchp_pit64b_clkevt_set_periodicfunction mchp_pit64b_clkevt_set_oneshotfunction mchp_pit64b_clkevt_set_next_eventfunction mchp_pit64b_interruptfunction mchp_pit64b_pres_computefunction mchp_pit64b_init_modefunction mchp_pit64b_init_clksrcfunction mchp_pit64b_init_clkevtfunction mchp_pit64b_dt_init_timerfunction mchp_pit64b_dt_init
Annotated Snippet
struct mchp_pit64b_timer {
void __iomem *base;
struct clk *pclk;
struct clk *gclk;
u32 mode;
};
/**
* struct mchp_pit64b_clkevt - PIT64B clockevent data structure
* @timer: PIT64B timer
* @clkevt: clockevent
*/
struct mchp_pit64b_clkevt {
struct mchp_pit64b_timer timer;
struct clock_event_device clkevt;
};
#define clkevt_to_mchp_pit64b_timer(x) \
((struct mchp_pit64b_timer *)container_of(x,\
struct mchp_pit64b_clkevt, clkevt))
/**
* struct mchp_pit64b_clksrc - PIT64B clocksource data structure
* @timer: PIT64B timer
* @clksrc: clocksource
*/
struct mchp_pit64b_clksrc {
struct mchp_pit64b_timer timer;
struct clocksource clksrc;
};
#define clksrc_to_mchp_pit64b_timer(x) \
((struct mchp_pit64b_timer *)container_of(x,\
struct mchp_pit64b_clksrc, clksrc))
/* Base address for clocksource timer. */
static void __iomem *mchp_pit64b_cs_base;
/* Default cycles for clockevent timer. */
static u64 mchp_pit64b_ce_cycles;
/* Delay timer. */
static struct delay_timer mchp_pit64b_dt;
static inline u64 mchp_pit64b_cnt_read(void __iomem *base)
{
unsigned long flags;
u32 low, high;
raw_local_irq_save(flags);
/*
* When using a 64 bit period TLSB must be read first, followed by the
* read of TMSB. This sequence generates an atomic read of the 64 bit
* timer value whatever the lapse of time between the accesses.
*/
low = readl_relaxed(base + MCHP_PIT64B_TLSBR);
high = readl_relaxed(base + MCHP_PIT64B_TMSBR);
raw_local_irq_restore(flags);
return (((u64)high << 32) | low);
}
static inline void mchp_pit64b_reset(struct mchp_pit64b_timer *timer,
u64 cycles, u32 mode, u32 irqs)
{
u32 low, high;
low = cycles & MCHP_PIT64B_LSBMASK;
high = cycles >> 32;
writel_relaxed(MCHP_PIT64B_CR_SWRST, timer->base + MCHP_PIT64B_CR);
writel_relaxed(mode | timer->mode, timer->base + MCHP_PIT64B_MR);
writel_relaxed(high, timer->base + MCHP_PIT64B_MSB_PR);
writel_relaxed(low, timer->base + MCHP_PIT64B_LSB_PR);
writel_relaxed(irqs, timer->base + MCHP_PIT64B_IER);
writel_relaxed(MCHP_PIT64B_CR_START, timer->base + MCHP_PIT64B_CR);
}
static void mchp_pit64b_suspend(struct mchp_pit64b_timer *timer)
{
writel_relaxed(MCHP_PIT64B_CR_SWRST, timer->base + MCHP_PIT64B_CR);
if (timer->mode & MCHP_PIT64B_MR_SGCLK)
clk_disable_unprepare(timer->gclk);
clk_disable_unprepare(timer->pclk);
}
static void mchp_pit64b_resume(struct mchp_pit64b_timer *timer)
{
clk_prepare_enable(timer->pclk);
if (timer->mode & MCHP_PIT64B_MR_SGCLK)
Annotation
- Immediate include surface: `linux/clk.h`, `linux/clockchips.h`, `linux/delay.h`, `linux/interrupt.h`, `linux/of_address.h`, `linux/of_irq.h`, `linux/sched_clock.h`, `linux/slab.h`.
- Detected declarations: `struct mchp_pit64b_timer`, `struct mchp_pit64b_clkevt`, `struct mchp_pit64b_clksrc`, `function mchp_pit64b_cnt_read`, `function mchp_pit64b_reset`, `function mchp_pit64b_suspend`, `function mchp_pit64b_resume`, `function mchp_pit64b_clksrc_suspend`, `function mchp_pit64b_clksrc_resume`, `function mchp_pit64b_clksrc_read`.
- 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.