drivers/clocksource/timer-tegra186.c
Source file repositories/reference/linux-study-clean/drivers/clocksource/timer-tegra186.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/clocksource/timer-tegra186.c- Extension
.c- Size
- 15885 bytes
- Lines
- 627
- 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/bitfield.hlinux/clocksource.hlinux/module.hlinux/interrupt.hlinux/io.hlinux/of.hlinux/platform_device.hlinux/pm.hlinux/watchdog.h
Detected Declarations
struct tegra186_timer_socstruct tegra186_tmrstruct tegra186_wdtstruct tegra186_timerfunction tmr_writelfunction wdt_writelfunction wdt_readlfunction tegra186_wdt_disablefunction tegra186_wdt_enablefunction tegra186_wdt_startfunction tegra186_wdt_stopfunction tegra186_wdt_pingfunction tegra186_wdt_irqfunction tegra186_wdt_set_timeoutfunction tegra186_wdt_get_timeleftfunction tegra186_wdt_is_accessiblefunction tegra186_timer_tsc_readfunction tegra186_timer_tsc_initfunction tegra186_timer_osc_readfunction tegra186_timer_osc_initfunction tegra186_timer_usec_readfunction tegra186_timer_usec_initfunction tegra186_timer_probefunction tegra186_timer_removefunction tegra186_timer_suspendfunction tegra186_timer_resume
Annotated Snippet
struct tegra186_timer_soc {
unsigned int num_timers;
unsigned int num_wdts;
};
struct tegra186_tmr {
struct tegra186_timer *parent;
void __iomem *regs;
unsigned int index;
unsigned int hwirq;
};
struct tegra186_wdt {
struct watchdog_device base;
void __iomem *regs;
unsigned int index;
bool locked;
bool is_kernel_wdt;
struct tegra186_tmr *tmr;
};
static inline struct tegra186_wdt *to_tegra186_wdt(struct watchdog_device *wdd)
{
return container_of(wdd, struct tegra186_wdt, base);
}
struct tegra186_timer {
const struct tegra186_timer_soc *soc;
struct device *dev;
void __iomem *regs;
struct tegra186_wdt **wdts;
struct clocksource usec;
struct clocksource tsc;
struct clocksource osc;
};
static void tmr_writel(struct tegra186_tmr *tmr, u32 value, unsigned int offset)
{
writel_relaxed(value, tmr->regs + offset);
}
static void wdt_writel(struct tegra186_wdt *wdt, u32 value, unsigned int offset)
{
writel_relaxed(value, wdt->regs + offset);
}
static u32 wdt_readl(struct tegra186_wdt *wdt, unsigned int offset)
{
return readl_relaxed(wdt->regs + offset);
}
static struct tegra186_tmr *tegra186_tmr_create(struct tegra186_timer *tegra,
unsigned int index)
{
unsigned int offset = 0x10000 + index * 0x10000;
struct tegra186_tmr *tmr;
tmr = devm_kzalloc(tegra->dev, sizeof(*tmr), GFP_KERNEL);
if (!tmr)
return ERR_PTR(-ENOMEM);
tmr->parent = tegra;
tmr->regs = tegra->regs + offset;
tmr->index = index;
tmr->hwirq = 0;
return tmr;
}
static const struct watchdog_info tegra186_wdt_info = {
.options = WDIOF_SETTIMEOUT | WDIOF_MAGICCLOSE | WDIOF_KEEPALIVEPING,
.identity = "NVIDIA Tegra186 WDT",
};
static void tegra186_wdt_disable(struct tegra186_wdt *wdt)
{
/* unlock and disable the watchdog */
wdt_writel(wdt, WDTUR_UNLOCK_PATTERN, WDTUR);
wdt_writel(wdt, WDTCMDR_DISABLE_COUNTER, WDTCMDR);
/* disable timer */
tmr_writel(wdt->tmr, 0, TMRCR);
}
static void tegra186_wdt_enable(struct tegra186_wdt *wdt)
{
struct tegra186_timer *tegra = wdt->tmr->parent;
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/clocksource.h`, `linux/module.h`, `linux/interrupt.h`, `linux/io.h`, `linux/of.h`, `linux/platform_device.h`, `linux/pm.h`.
- Detected declarations: `struct tegra186_timer_soc`, `struct tegra186_tmr`, `struct tegra186_wdt`, `struct tegra186_timer`, `function tmr_writel`, `function wdt_writel`, `function wdt_readl`, `function tegra186_wdt_disable`, `function tegra186_wdt_enable`, `function tegra186_wdt_start`.
- 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.