Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

clk: fixed-factor: Allow for a few clocks to change the parent rate

The only way for a fixed factor clock to change its rate would be to change
its parent rate.

Since passing blindly CLK_SET_RATE_PARENT might break a lot of platforms
that were relying on the fact that the parent rate wouldn't change,
introduce a compatible-based whitelist that will allow clocks to opt-in
that flag.

Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>

authored by

Maxime Ripard and committed by
Stephen Boyd
e6cbf998 6db8c762

+14 -1
+4
Documentation/devicetree/bindings/clock/fixed-factor-clock.txt
··· 14 14 Optional properties: 15 15 - clock-output-names : From common clock binding. 16 16 17 + Some clocks that require special treatments are also handled by that 18 + driver, with the compatibles: 19 + - allwinner,sun4i-a10-pll3-2x-clk 20 + 17 21 Example: 18 22 clock { 19 23 compatible = "fixed-factor-clock";
+10 -1
drivers/clk/clk-fixed-factor.c
··· 142 142 EXPORT_SYMBOL_GPL(clk_hw_unregister_fixed_factor); 143 143 144 144 #ifdef CONFIG_OF 145 + static const struct of_device_id set_rate_parent_matches[] = { 146 + { .compatible = "allwinner,sun4i-a10-pll3-2x-clk" }, 147 + { /* Sentinel */ }, 148 + }; 149 + 145 150 /** 146 151 * of_fixed_factor_clk_setup() - Setup function for simple fixed factor clock 147 152 */ ··· 155 150 struct clk *clk; 156 151 const char *clk_name = node->name; 157 152 const char *parent_name; 153 + unsigned long flags = 0; 158 154 u32 div, mult; 159 155 160 156 if (of_property_read_u32(node, "clock-div", &div)) { ··· 173 167 of_property_read_string(node, "clock-output-names", &clk_name); 174 168 parent_name = of_clk_get_parent_name(node, 0); 175 169 176 - clk = clk_register_fixed_factor(NULL, clk_name, parent_name, 0, 170 + if (of_match_node(set_rate_parent_matches, node)) 171 + flags |= CLK_SET_RATE_PARENT; 172 + 173 + clk = clk_register_fixed_factor(NULL, clk_name, parent_name, flags, 177 174 mult, div); 178 175 if (!IS_ERR(clk)) 179 176 of_clk_add_provider(node, of_clk_src_simple_get, clk);