drivers/clk/clk-wm831x.c
Source file repositories/reference/linux-study-clean/drivers/clk/clk-wm831x.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/clk/clk-wm831x.c- Extension
.c- Size
- 9585 bytes
- Lines
- 402
- 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/delay.hlinux/module.hlinux/slab.hlinux/platform_device.hlinux/mfd/wm831x/core.h
Detected Declarations
struct wm831x_clkfunction wm831x_xtal_is_preparedfunction wm831x_xtal_recalc_ratefunction wm831x_fll_is_preparedfunction wm831x_fll_preparefunction wm831x_fll_unpreparefunction wm831x_fll_recalc_ratefunction wm831x_fll_determine_ratefunction wm831x_fll_set_ratefunction wm831x_fll_get_parentfunction wm831x_clkout_is_preparedfunction wm831x_clkout_preparefunction wm831x_clkout_unpreparefunction wm831x_clkout_get_parentfunction wm831x_clkout_set_parentfunction wm831x_clk_probe
Annotated Snippet
struct wm831x_clk {
struct wm831x *wm831x;
struct clk_hw xtal_hw;
struct clk_hw fll_hw;
struct clk_hw clkout_hw;
bool xtal_ena;
};
static int wm831x_xtal_is_prepared(struct clk_hw *hw)
{
struct wm831x_clk *clkdata = container_of(hw, struct wm831x_clk,
xtal_hw);
return clkdata->xtal_ena;
}
static unsigned long wm831x_xtal_recalc_rate(struct clk_hw *hw,
unsigned long parent_rate)
{
struct wm831x_clk *clkdata = container_of(hw, struct wm831x_clk,
xtal_hw);
if (clkdata->xtal_ena)
return 32768;
else
return 0;
}
static const struct clk_ops wm831x_xtal_ops = {
.is_prepared = wm831x_xtal_is_prepared,
.recalc_rate = wm831x_xtal_recalc_rate,
};
static const struct clk_init_data wm831x_xtal_init = {
.name = "xtal",
.ops = &wm831x_xtal_ops,
};
static const unsigned long wm831x_fll_auto_rates[] = {
2048000,
11289600,
12000000,
12288000,
19200000,
22579600,
24000000,
24576000,
};
static int wm831x_fll_is_prepared(struct clk_hw *hw)
{
struct wm831x_clk *clkdata = container_of(hw, struct wm831x_clk,
fll_hw);
struct wm831x *wm831x = clkdata->wm831x;
int ret;
ret = wm831x_reg_read(wm831x, WM831X_FLL_CONTROL_1);
if (ret < 0) {
dev_err(wm831x->dev, "Unable to read FLL_CONTROL_1: %d\n",
ret);
return true;
}
return (ret & WM831X_FLL_ENA) != 0;
}
static int wm831x_fll_prepare(struct clk_hw *hw)
{
struct wm831x_clk *clkdata = container_of(hw, struct wm831x_clk,
fll_hw);
struct wm831x *wm831x = clkdata->wm831x;
int ret;
ret = wm831x_set_bits(wm831x, WM831X_FLL_CONTROL_1,
WM831X_FLL_ENA, WM831X_FLL_ENA);
if (ret != 0)
dev_crit(wm831x->dev, "Failed to enable FLL: %d\n", ret);
/* wait 2-3 ms for new frequency taking effect */
usleep_range(2000, 3000);
return ret;
}
static void wm831x_fll_unprepare(struct clk_hw *hw)
{
struct wm831x_clk *clkdata = container_of(hw, struct wm831x_clk,
fll_hw);
struct wm831x *wm831x = clkdata->wm831x;
int ret;
Annotation
- Immediate include surface: `linux/clk-provider.h`, `linux/delay.h`, `linux/module.h`, `linux/slab.h`, `linux/platform_device.h`, `linux/mfd/wm831x/core.h`.
- Detected declarations: `struct wm831x_clk`, `function wm831x_xtal_is_prepared`, `function wm831x_xtal_recalc_rate`, `function wm831x_fll_is_prepared`, `function wm831x_fll_prepare`, `function wm831x_fll_unprepare`, `function wm831x_fll_recalc_rate`, `function wm831x_fll_determine_rate`, `function wm831x_fll_set_rate`, `function wm831x_fll_get_parent`.
- 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.