drivers/clk/at91/sckc.c
Source file repositories/reference/linux-study-clean/drivers/clk/at91/sckc.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/clk/at91/sckc.c- Extension
.c- Size
- 15337 bytes
- Lines
- 658
- Domain
- Driver Families
- Bucket
- drivers/clk
- 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.
- 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/clk-provider.hlinux/clkdev.hlinux/delay.hlinux/of.hlinux/of_address.hlinux/io.hdt-bindings/clock/at91.h
Detected Declarations
struct clk_slow_bitsstruct clk_slow_oscstruct clk_sama5d4_slow_oscstruct clk_slow_rc_oscstruct clk_sam9x5_slowfunction clk_slow_osc_preparefunction clk_slow_osc_unpreparefunction clk_slow_osc_is_preparedfunction at91_clk_register_slow_oscfunction at91_clk_unregister_slow_oscfunction clk_slow_rc_osc_recalc_ratefunction clk_slow_rc_osc_recalc_accuracyfunction clk_slow_rc_osc_preparefunction clk_slow_rc_osc_unpreparefunction clk_slow_rc_osc_is_preparedfunction at91_clk_register_slow_rc_oscfunction at91_clk_unregister_slow_rc_oscfunction clk_sam9x5_slow_set_parentfunction clk_sam9x5_slow_get_parentfunction at91_clk_register_sam9x5_slowfunction at91_clk_unregister_sam9x5_slowfunction at91sam9x5_sckc_registerfunction of_at91sam9x5_sckc_setupfunction of_sama5d3_sckc_setupfunction of_sam9x60_sckc_setupfunction clk_sama5d4_slow_osc_preparefunction selectedfunction clk_sama5d4_slow_osc_is_preparedfunction of_sama5d4_sckc_setup
Annotated Snippet
struct clk_slow_bits {
u32 cr_rcen;
u32 cr_osc32en;
u32 cr_osc32byp;
u32 cr_oscsel;
};
struct clk_slow_osc {
struct clk_hw hw;
void __iomem *sckcr;
const struct clk_slow_bits *bits;
unsigned long startup_usec;
};
#define to_clk_slow_osc(hw) container_of(hw, struct clk_slow_osc, hw)
struct clk_sama5d4_slow_osc {
struct clk_hw hw;
void __iomem *sckcr;
const struct clk_slow_bits *bits;
unsigned long startup_usec;
bool prepared;
};
#define to_clk_sama5d4_slow_osc(hw) container_of(hw, struct clk_sama5d4_slow_osc, hw)
struct clk_slow_rc_osc {
struct clk_hw hw;
void __iomem *sckcr;
const struct clk_slow_bits *bits;
unsigned long frequency;
unsigned long accuracy;
unsigned long startup_usec;
};
#define to_clk_slow_rc_osc(hw) container_of(hw, struct clk_slow_rc_osc, hw)
struct clk_sam9x5_slow {
struct clk_hw hw;
void __iomem *sckcr;
const struct clk_slow_bits *bits;
u8 parent;
};
#define to_clk_sam9x5_slow(hw) container_of(hw, struct clk_sam9x5_slow, hw)
static int clk_slow_osc_prepare(struct clk_hw *hw)
{
struct clk_slow_osc *osc = to_clk_slow_osc(hw);
void __iomem *sckcr = osc->sckcr;
u32 tmp = readl(sckcr);
if (tmp & (osc->bits->cr_osc32byp | osc->bits->cr_osc32en))
return 0;
writel(tmp | osc->bits->cr_osc32en, sckcr);
if (system_state < SYSTEM_RUNNING)
udelay(osc->startup_usec);
else
usleep_range(osc->startup_usec, osc->startup_usec + 1);
return 0;
}
static void clk_slow_osc_unprepare(struct clk_hw *hw)
{
struct clk_slow_osc *osc = to_clk_slow_osc(hw);
void __iomem *sckcr = osc->sckcr;
u32 tmp = readl(sckcr);
if (tmp & osc->bits->cr_osc32byp)
return;
writel(tmp & ~osc->bits->cr_osc32en, sckcr);
}
static int clk_slow_osc_is_prepared(struct clk_hw *hw)
{
struct clk_slow_osc *osc = to_clk_slow_osc(hw);
void __iomem *sckcr = osc->sckcr;
u32 tmp = readl(sckcr);
if (tmp & osc->bits->cr_osc32byp)
return 1;
return !!(tmp & osc->bits->cr_osc32en);
}
static const struct clk_ops slow_osc_ops = {
Annotation
- Immediate include surface: `linux/clk-provider.h`, `linux/clkdev.h`, `linux/delay.h`, `linux/of.h`, `linux/of_address.h`, `linux/io.h`, `dt-bindings/clock/at91.h`.
- Detected declarations: `struct clk_slow_bits`, `struct clk_slow_osc`, `struct clk_sama5d4_slow_osc`, `struct clk_slow_rc_osc`, `struct clk_sam9x5_slow`, `function clk_slow_osc_prepare`, `function clk_slow_osc_unprepare`, `function clk_slow_osc_is_prepared`, `function at91_clk_register_slow_osc`, `function at91_clk_unregister_slow_osc`.
- Atlas domain: Driver Families / drivers/clk.
- Implementation status: source implementation candidate.
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.