drivers/clocksource/timer-ralink.c
Source file repositories/reference/linux-study-clean/drivers/clocksource/timer-ralink.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/clocksource/timer-ralink.c- Extension
.c- Size
- 3876 bytes
- Lines
- 158
- 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/clockchips.hlinux/clocksource.hlinux/interrupt.hlinux/reset.hlinux/init.hlinux/time.hlinux/of.hlinux/of_irq.hlinux/of_address.h
Detected Declarations
struct systick_devicefunction systick_next_eventfunction systick_event_handlerfunction systick_shutdownfunction systick_set_oneshotfunction ralink_systick_init
Annotated Snippet
struct systick_device {
void __iomem *membase;
struct clock_event_device dev;
int irq_requested;
int freq_scale;
};
static int systick_set_oneshot(struct clock_event_device *evt);
static int systick_shutdown(struct clock_event_device *evt);
static int systick_next_event(unsigned long delta,
struct clock_event_device *evt)
{
struct systick_device *sdev;
u32 count;
sdev = container_of(evt, struct systick_device, dev);
count = ioread32(sdev->membase + SYSTICK_COUNT);
count = (count + delta) % SYSTICK_FREQ;
iowrite32(count, sdev->membase + SYSTICK_COMPARE);
return 0;
}
static void systick_event_handler(struct clock_event_device *dev)
{
/* noting to do here */
}
static irqreturn_t systick_interrupt(int irq, void *dev_id)
{
struct clock_event_device *dev = (struct clock_event_device *)dev_id;
dev->event_handler(dev);
return IRQ_HANDLED;
}
static struct systick_device systick = {
.dev = {
/*
* cevt-r4k uses 300, make sure systick
* gets used if available
*/
.rating = 310,
.features = CLOCK_EVT_FEAT_ONESHOT,
.set_next_event = systick_next_event,
.set_state_shutdown = systick_shutdown,
.set_state_oneshot = systick_set_oneshot,
.event_handler = systick_event_handler,
},
};
static int systick_shutdown(struct clock_event_device *evt)
{
struct systick_device *sdev;
sdev = container_of(evt, struct systick_device, dev);
if (sdev->irq_requested)
free_irq(systick.dev.irq, &systick.dev);
sdev->irq_requested = 0;
iowrite32(0, systick.membase + SYSTICK_CONFIG);
return 0;
}
static int systick_set_oneshot(struct clock_event_device *evt)
{
const char *name = systick.dev.name;
struct systick_device *sdev;
int irq = systick.dev.irq;
sdev = container_of(evt, struct systick_device, dev);
if (!sdev->irq_requested) {
if (request_irq(irq, systick_interrupt,
IRQF_PERCPU | IRQF_TIMER, name, &systick.dev))
pr_err("Failed to request irq %d (%s)\n", irq, name);
}
sdev->irq_requested = 1;
iowrite32(CFG_EXT_STK_EN | CFG_CNT_EN,
systick.membase + SYSTICK_CONFIG);
return 0;
}
static int __init ralink_systick_init(struct device_node *np)
{
int ret;
Annotation
- Immediate include surface: `linux/clockchips.h`, `linux/clocksource.h`, `linux/interrupt.h`, `linux/reset.h`, `linux/init.h`, `linux/time.h`, `linux/of.h`, `linux/of_irq.h`.
- Detected declarations: `struct systick_device`, `function systick_next_event`, `function systick_event_handler`, `function systick_shutdown`, `function systick_set_oneshot`, `function ralink_systick_init`.
- 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.