drivers/clocksource/armv7m_systick.c

Source file repositories/reference/linux-study-clean/drivers/clocksource/armv7m_systick.c

File Facts

System
Linux kernel
Corpus path
drivers/clocksource/armv7m_systick.c
Extension
.c
Size
1782 bytes
Lines
87
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.

Dependency Surface

Detected Declarations

Annotated Snippet

if (IS_ERR(clk)) {
			ret = PTR_ERR(clk);
			goto out_unmap;
		}

		ret = clk_prepare_enable(clk);
		if (ret)
			goto out_clk_put;

		rate = clk_get_rate(clk);
		if (!rate) {
			ret = -EINVAL;
			goto out_clk_disable;
		}
	}

	writel_relaxed(SYSTICK_LOAD_RELOAD_MASK, base + SYST_RVR);
	writel_relaxed(SYST_CSR_ENABLE, base + SYST_CSR);

	ret = clocksource_mmio_init(base + SYST_CVR, "arm_system_timer", rate,
			200, 24, clocksource_mmio_readl_down);
	if (ret) {
		pr_err("failed to init clocksource (%d)\n", ret);
		if (clk)
			goto out_clk_disable;
		else
			goto out_unmap;
	}

	pr_info("ARM System timer initialized as clocksource\n");

	return 0;

out_clk_disable:
	clk_disable_unprepare(clk);
out_clk_put:
	clk_put(clk);
out_unmap:
	iounmap(base);
	pr_warn("ARM System timer register failed (%d)\n", ret);

	return ret;
}

TIMER_OF_DECLARE(arm_systick, "arm,armv7m-systick",
			system_timer_of_register);

Annotation

Implementation Notes