drivers/clocksource/timer-fttmr010.c
Source file repositories/reference/linux-study-clean/drivers/clocksource/timer-fttmr010.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/clocksource/timer-fttmr010.c- Extension
.c- Size
- 12333 bytes
- Lines
- 460
- 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/interrupt.hlinux/io.hlinux/of.hlinux/of_address.hlinux/of_irq.hlinux/clockchips.hlinux/clocksource.hlinux/sched_clock.hlinux/clk.hlinux/slab.hlinux/bitops.hlinux/delay.h
Detected Declarations
struct fttmr010function fttmr010_read_current_timer_upfunction fttmr010_read_current_timer_downfunction fttmr010_read_sched_clock_upfunction fttmr010_read_sched_clock_downfunction fttmr010_timer_set_next_eventfunction ast2600_timer_shutdownfunction fttmr010_timer_shutdownfunction fttmr010_timer_set_oneshotfunction fttmr010_timer_set_periodicfunction fttmr010_timer_interruptfunction ast2600_timer_interruptfunction fttmr010_common_initfunction ast2600_timer_initfunction aspeed_timer_initfunction fttmr010_timer_init
Annotated Snippet
struct fttmr010 {
void __iomem *base;
unsigned int tick_rate;
bool is_aspeed;
u32 t1_enable_val;
struct clock_event_device clkevt;
int (*timer_shutdown)(struct clock_event_device *evt);
#ifdef CONFIG_ARM
struct delay_timer delay_timer;
#endif
};
/*
* A local singleton used by sched_clock and delay timer reads, which are
* fast and stateless
*/
static struct fttmr010 *local_fttmr;
static inline struct fttmr010 *to_fttmr010(struct clock_event_device *evt)
{
return container_of(evt, struct fttmr010, clkevt);
}
static unsigned long fttmr010_read_current_timer_up(void)
{
return readl(local_fttmr->base + TIMER2_COUNT);
}
static unsigned long fttmr010_read_current_timer_down(void)
{
return ~readl(local_fttmr->base + TIMER2_COUNT);
}
static u64 notrace fttmr010_read_sched_clock_up(void)
{
return fttmr010_read_current_timer_up();
}
static u64 notrace fttmr010_read_sched_clock_down(void)
{
return fttmr010_read_current_timer_down();
}
static int fttmr010_timer_set_next_event(unsigned long cycles,
struct clock_event_device *evt)
{
struct fttmr010 *fttmr010 = to_fttmr010(evt);
u32 cr;
/* Stop */
fttmr010->timer_shutdown(evt);
if (fttmr010->is_aspeed) {
/*
* ASPEED Timer Controller will load TIMER1_LOAD register
* into TIMER1_COUNT register when the timer is re-enabled.
*/
writel(cycles, fttmr010->base + TIMER1_LOAD);
} else {
/* Setup the match register forward in time */
cr = readl(fttmr010->base + TIMER1_COUNT);
writel(cr + cycles, fttmr010->base + TIMER1_MATCH1);
}
/* Start */
cr = readl(fttmr010->base + TIMER_CR);
cr |= fttmr010->t1_enable_val;
writel(cr, fttmr010->base + TIMER_CR);
return 0;
}
static int ast2600_timer_shutdown(struct clock_event_device *evt)
{
struct fttmr010 *fttmr010 = to_fttmr010(evt);
/* Stop */
writel(fttmr010->t1_enable_val, fttmr010->base + AST2600_TIMER_CR_CLR);
return 0;
}
static int fttmr010_timer_shutdown(struct clock_event_device *evt)
{
struct fttmr010 *fttmr010 = to_fttmr010(evt);
u32 cr;
/* Stop */
cr = readl(fttmr010->base + TIMER_CR);
cr &= ~fttmr010->t1_enable_val;
Annotation
- Immediate include surface: `linux/interrupt.h`, `linux/io.h`, `linux/of.h`, `linux/of_address.h`, `linux/of_irq.h`, `linux/clockchips.h`, `linux/clocksource.h`, `linux/sched_clock.h`.
- Detected declarations: `struct fttmr010`, `function fttmr010_read_current_timer_up`, `function fttmr010_read_current_timer_down`, `function fttmr010_read_sched_clock_up`, `function fttmr010_read_sched_clock_down`, `function fttmr010_timer_set_next_event`, `function ast2600_timer_shutdown`, `function fttmr010_timer_shutdown`, `function fttmr010_timer_set_oneshot`, `function fttmr010_timer_set_periodic`.
- 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.