drivers/clocksource/timer-imx-gpt.c
Source file repositories/reference/linux-study-clean/drivers/clocksource/timer-imx-gpt.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/clocksource/timer-imx-gpt.c- Extension
.c- Size
- 13168 bytes
- Lines
- 512
- 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/irq.hlinux/clockchips.hlinux/clk.hlinux/delay.hlinux/err.hlinux/sched_clock.hlinux/slab.hlinux/of.hlinux/of_address.hlinux/of_irq.h
Detected Declarations
struct imx_timerstruct imx_gpt_dataenum imx_gpt_typefunction imx1_gpt_irq_disablefunction imx31_gpt_irq_disablefunction imx1_gpt_irq_enablefunction imx31_gpt_irq_enablefunction imx1_gpt_irq_acknowledgefunction imx21_gpt_irq_acknowledgefunction imx31_gpt_irq_acknowledgefunction mxc_read_sched_clockfunction imx_read_current_timerfunction mxc_clocksource_initfunction mx1_2_set_next_eventfunction v2_set_next_eventfunction mxc_shutdownfunction mxc_set_oneshotfunction mxc_timer_interruptfunction mxc_clockevent_initfunction imx1_gpt_setup_tctlfunction imx31_gpt_setup_tctlfunction imx6dl_gpt_setup_tctlfunction _mxc_timer_initfunction mxc_timer_init_dtfunction imx1_timer_init_dtfunction imx21_timer_init_dtfunction imx31_timer_init_dtfunction imx6dl_timer_init_dt
Annotated Snippet
struct imx_timer {
enum imx_gpt_type type;
void __iomem *base;
int irq;
struct clk *clk_per;
struct clk *clk_ipg;
const struct imx_gpt_data *gpt;
struct clock_event_device ced;
};
struct imx_gpt_data {
int reg_tstat;
int reg_tcn;
int reg_tcmp;
void (*gpt_setup_tctl)(struct imx_timer *imxtm);
void (*gpt_irq_enable)(struct imx_timer *imxtm);
void (*gpt_irq_disable)(struct imx_timer *imxtm);
void (*gpt_irq_acknowledge)(struct imx_timer *imxtm);
int (*set_next_event)(unsigned long evt,
struct clock_event_device *ced);
};
static inline struct imx_timer *to_imx_timer(struct clock_event_device *ced)
{
return container_of(ced, struct imx_timer, ced);
}
static void imx1_gpt_irq_disable(struct imx_timer *imxtm)
{
unsigned int tmp;
tmp = readl_relaxed(imxtm->base + MXC_TCTL);
writel_relaxed(tmp & ~MX1_2_TCTL_IRQEN, imxtm->base + MXC_TCTL);
}
static void imx31_gpt_irq_disable(struct imx_timer *imxtm)
{
writel_relaxed(0, imxtm->base + V2_IR);
}
static void imx1_gpt_irq_enable(struct imx_timer *imxtm)
{
unsigned int tmp;
tmp = readl_relaxed(imxtm->base + MXC_TCTL);
writel_relaxed(tmp | MX1_2_TCTL_IRQEN, imxtm->base + MXC_TCTL);
}
static void imx31_gpt_irq_enable(struct imx_timer *imxtm)
{
writel_relaxed(1<<0, imxtm->base + V2_IR);
}
static void imx1_gpt_irq_acknowledge(struct imx_timer *imxtm)
{
writel_relaxed(0, imxtm->base + MX1_2_TSTAT);
}
static void imx21_gpt_irq_acknowledge(struct imx_timer *imxtm)
{
writel_relaxed(MX2_TSTAT_CAPT | MX2_TSTAT_COMP,
imxtm->base + MX1_2_TSTAT);
}
static void imx31_gpt_irq_acknowledge(struct imx_timer *imxtm)
{
writel_relaxed(V2_TSTAT_OF1, imxtm->base + V2_TSTAT);
}
static void __iomem *sched_clock_reg;
static u64 notrace mxc_read_sched_clock(void)
{
return sched_clock_reg ? readl_relaxed(sched_clock_reg) : 0;
}
#if defined(CONFIG_ARM)
static struct delay_timer imx_delay_timer;
static unsigned long imx_read_current_timer(void)
{
return readl_relaxed(sched_clock_reg);
}
#endif
static int __init mxc_clocksource_init(struct imx_timer *imxtm)
{
unsigned int c = clk_get_rate(imxtm->clk_per);
void __iomem *reg = imxtm->base + imxtm->gpt->reg_tcn;
Annotation
- Immediate include surface: `linux/interrupt.h`, `linux/irq.h`, `linux/clockchips.h`, `linux/clk.h`, `linux/delay.h`, `linux/err.h`, `linux/sched_clock.h`, `linux/slab.h`.
- Detected declarations: `struct imx_timer`, `struct imx_gpt_data`, `enum imx_gpt_type`, `function imx1_gpt_irq_disable`, `function imx31_gpt_irq_disable`, `function imx1_gpt_irq_enable`, `function imx31_gpt_irq_enable`, `function imx1_gpt_irq_acknowledge`, `function imx21_gpt_irq_acknowledge`, `function imx31_gpt_irq_acknowledge`.
- 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.