drivers/clk/nxp/clk-lpc18xx-creg.c
Source file repositories/reference/linux-study-clean/drivers/clk/nxp/clk-lpc18xx-creg.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/clk/nxp/clk-lpc18xx-creg.c- Extension
.c- Size
- 5588 bytes
- Lines
- 226
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/clk-provider.hlinux/delay.hlinux/kernel.hlinux/mfd/syscon.hlinux/of.hlinux/platform_device.hlinux/regmap.h
Detected Declarations
struct clk_creg_datafunction clk_creg_32k_preparefunction clk_creg_32k_unpreparefunction clk_creg_32k_is_preparedfunction clk_creg_1k_recalc_ratefunction clk_creg_enablefunction clk_creg_disablefunction clk_creg_is_enabledfunction lpc18xx_creg_clk_initfunction lpc18xx_creg_clk_probe
Annotated Snippet
struct clk_creg_data {
struct clk_hw hw;
const char *name;
struct regmap *reg;
unsigned int en_mask;
const struct clk_ops *ops;
};
#define CREG_CLK(_name, _emask, _ops) \
{ \
.name = _name, \
.en_mask = LPC18XX_CREG_CREG0_##_emask, \
.ops = &_ops, \
}
static int clk_creg_32k_prepare(struct clk_hw *hw)
{
struct clk_creg_data *creg = to_clk_creg(hw);
int ret;
ret = regmap_update_bits(creg->reg, LPC18XX_CREG_CREG0,
LPC18XX_CREG_CREG0_PD32KHZ |
LPC18XX_CREG_CREG0_RESET32KHZ, 0);
/*
* Powering up the 32k oscillator takes a long while
* and sadly there aren't any status bit to poll.
*/
msleep(2500);
return ret;
}
static void clk_creg_32k_unprepare(struct clk_hw *hw)
{
struct clk_creg_data *creg = to_clk_creg(hw);
regmap_update_bits(creg->reg, LPC18XX_CREG_CREG0,
LPC18XX_CREG_CREG0_PD32KHZ,
LPC18XX_CREG_CREG0_PD32KHZ);
}
static int clk_creg_32k_is_prepared(struct clk_hw *hw)
{
struct clk_creg_data *creg = to_clk_creg(hw);
u32 reg;
regmap_read(creg->reg, LPC18XX_CREG_CREG0, ®);
return !(reg & LPC18XX_CREG_CREG0_PD32KHZ) &&
!(reg & LPC18XX_CREG_CREG0_RESET32KHZ);
}
static unsigned long clk_creg_1k_recalc_rate(struct clk_hw *hw,
unsigned long parent_rate)
{
return parent_rate / 32;
}
static int clk_creg_enable(struct clk_hw *hw)
{
struct clk_creg_data *creg = to_clk_creg(hw);
return regmap_update_bits(creg->reg, LPC18XX_CREG_CREG0,
creg->en_mask, creg->en_mask);
}
static void clk_creg_disable(struct clk_hw *hw)
{
struct clk_creg_data *creg = to_clk_creg(hw);
regmap_update_bits(creg->reg, LPC18XX_CREG_CREG0,
creg->en_mask, 0);
}
static int clk_creg_is_enabled(struct clk_hw *hw)
{
struct clk_creg_data *creg = to_clk_creg(hw);
u32 reg;
regmap_read(creg->reg, LPC18XX_CREG_CREG0, ®);
return !!(reg & creg->en_mask);
}
static const struct clk_ops clk_creg_32k = {
.enable = clk_creg_enable,
.disable = clk_creg_disable,
.is_enabled = clk_creg_is_enabled,
.prepare = clk_creg_32k_prepare,
Annotation
- Immediate include surface: `linux/clk-provider.h`, `linux/delay.h`, `linux/kernel.h`, `linux/mfd/syscon.h`, `linux/of.h`, `linux/platform_device.h`, `linux/regmap.h`.
- Detected declarations: `struct clk_creg_data`, `function clk_creg_32k_prepare`, `function clk_creg_32k_unprepare`, `function clk_creg_32k_is_prepared`, `function clk_creg_1k_recalc_rate`, `function clk_creg_enable`, `function clk_creg_disable`, `function clk_creg_is_enabled`, `function lpc18xx_creg_clk_init`, `function lpc18xx_creg_clk_probe`.
- 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.