STRUCT CLK_FRACTIONAL_DIVIDER(9)
๐ struct clk_fractional_divider(9) โ the Kernel API Manual, bestie edition ๐
okay so this is the struct clk_fractional_divider page from the Kernel API Manual, and it's literally the blueprint for an adjustable fractional divider clock. it's giving "I divide clocks by fractions and I do it fabulously" โจ
๐ธ NAME ๐ธ
struct clk_fractional_divider โ an adjustable fractional divider clock ๐
โจ SYNOPSIS โจ
here's the whole vibe, no cap:
struct clk_fractional_divider {
struct clk_hw hw;
void __iomem *reg;
u8 mshift;
u8 mwidth;
u8 nshift;
u8 nwidth;
u8 flags;
void (*approximation)(struct clk_hw *hw, unsigned long rate,
unsigned long *parent_rate, unsigned long *m, unsigned long *n);
spinlock_t *lock;
};
๐ฆ Members ๐ฆ
okay so every field, let's go, in order, periodt:
hwโ the handle between the common interfaces and the hardware-specific ones ๐ซถregโ the register that contains the dividermshiftโ the shift to the numerator bit fieldmwidthโ how wide the numerator bit field isnshiftโ the shift to the denominator bit fieldnwidthโ how wide the denominator bit field isflagsโ the little personality settings, and there are three, iykyk:CLK_FRAC_DIVIDER_ZERO_BASEDโ by default the numerator and denominator are just the value read from the register. ifCLK_FRAC_DIVIDER_ZERO_BASEDis set, then the numerator and denominator are both the value read plus one. she adds one, that's her whole thing ๐CLK_FRAC_DIVIDER_BIG_ENDIANโ by default little endian register accesses are used for the divider register. setting this flag makes the register accesses big endian. switching teams, iconic ๐CLK_FRAC_DIVIDER_POWER_OF_TWO_PSโ by default the resulting fraction might be saturated and the caller will get quite far from the good enough approximation ๐ญ instead the caller may require, by setting this flag, to shift left by a few bits in case, when the asked one is quite small to satisfy the desired range of denominator. it assumes that on the caller's side the power-of-two capable prescaler exists. so yeah โ prescaler better be there, fr fr ๐
approximationโ the clk driver's callback for calculating the divider clock. this is where the driver does its math homework ๐งฎlockโ the register lock ๐
๐ฅ Description ๐ฅ
a clock with an adjustable fractional divider that affects its output frequency. that's it, that's the whole concept, and honestly? obsessed. ๐โจ
๐ SEE ALSO ๐
the whole friend group, in order, and yes we're listing all of them because nobody gets left out at this table ๐ซถ:
Kernel file ./include/linux/clk-provider.h, clk framework flags(9), struct clk_rate_request(9), struct clk_duty(9), struct clk_spread_spectrum(9), struct clk_ops(9), struct clk_parent_data(9), struct clk_init_data(9), struct clk_hw(9), struct clk_fixed_rate(9), clk_hw_register_fixed_rate(9), devm_clk_hw_register_fixed_rate(9), devm_clk_hw_register_fixed_rate_parent_data(9), clk_hw_register_fixed_rate_parent_hw(9), clk_hw_register_fixed_rate_parent_data(9), clk_hw_register_fixed_rate_with_accuracy(9), clk_hw_register_fixed_rate_with_accuracy_parent_hw(9), clk_hw_register_fixed_rate_with_accuracy_parent_data(9), clk_hw_register_fixed_rate_parent_accuracy(9), struct clk_gate(9), clk_hw_register_gate(9), clk_hw_register_gate_parent_hw(9), clk_hw_register_gate_parent_data(9), devm_clk_hw_register_gate(9), devm_clk_hw_register_gate_parent_hw(9), devm_clk_hw_register_gate_parent_data(9), struct clk_divider(9), clk_register_divider(9), clk_hw_register_divider(9), clk_hw_register_divider_parent_hw(9), clk_hw_register_divider_parent_data(9), clk_hw_register_divider_table(9), clk_hw_register_divider_table_parent_hw(9), clk_hw_register_divider_table_parent_data(9), devm_clk_hw_register_divider(9), devm_clk_hw_register_divider_parent_hw(9), devm_clk_hw_register_divider_parent_data(9), devm_clk_hw_register_divider_table(9), struct clk_mux(9), struct clk_fixed_factor(9), devm_clk_hw_register_fixed_factor_parent_hw(9), struct clk_multiplier(9), clk_hw_get_dev(9), clk_hw_get_of_node(9) ๐
ngl bestie, this struct is all about bit fields and flags โ mess up a shift or a width and your clock rate is gonna be giving chaos ๐ญ double-check thosemshift/mwidth/nshift/nwidthvalues before you ship, okay? ๐ซถ
and that's the page!! ๐ this lil rewrite came from the source path ./include/linux, dated October 2026 โ so yeah, that's the version energy we're working with. mwah, go divide some fractions divinely ๐
๐๐ฆ
๐ฆ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms