Lines Matching +full:composite +full:- +full:divider +full:- +full:clock
1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (C) 2015 Chen-Yu Tsai
5 * Chen-Yu Tsai <wens@csie.org>
7 * Allwinner A80 CPUS clock driver
12 #include <linux/clk-provider.h>
57 reg = readl(cpus->reg); in sun9i_a80_cpus_clk_recalc_rate()
59 /* apply pre-divider first if parent is pll4 */ in sun9i_a80_cpus_clk_recalc_rate()
63 /* clk divider */ in sun9i_a80_cpus_clk_recalc_rate()
75 * clock can only divide, so we will never be able to achieve in sun9i_a80_cpus_clk_round()
83 /* calculate pre-divider if parent is pll4 */ in sun9i_a80_cpus_clk_round()
85 /* pre-divider is 1 ~ 32 */ in sun9i_a80_cpus_clk_round()
101 /* we were asked to pass back divider values */ in sun9i_a80_cpus_clk_round()
103 *divp = div - 1; in sun9i_a80_cpus_clk_round()
104 *pre_divp = pre_div - 1; in sun9i_a80_cpus_clk_round()
116 unsigned long rate = req->rate; in sun9i_a80_cpus_clk_determine_rate()
140 return -EINVAL; in sun9i_a80_cpus_clk_determine_rate()
142 req->best_parent_hw = best_parent; in sun9i_a80_cpus_clk_determine_rate()
143 req->best_parent_rate = best; in sun9i_a80_cpus_clk_determine_rate()
144 req->rate = best_child_rate; in sun9i_a80_cpus_clk_determine_rate()
159 reg = readl(cpus->reg); in sun9i_a80_cpus_clk_set_rate()
161 /* need to know which parent is used to apply pre-divider */ in sun9i_a80_cpus_clk_set_rate()
167 writel(reg, cpus->reg); in sun9i_a80_cpus_clk_set_rate()
181 * sun9i_a80_cpus_setup() - Setup function for a80 cpus composite clk
182 * @node: &struct device_node for the clock
186 const char *clk_name = node->name; in sun9i_a80_cpus_setup()
198 cpus->reg = of_io_request_and_map(node, 0, of_node_full_name(node)); in sun9i_a80_cpus_setup()
199 if (IS_ERR(cpus->reg)) in sun9i_a80_cpus_setup()
202 of_property_read_string(node, "clock-output-names", &clk_name); in sun9i_a80_cpus_setup()
211 /* set up clock properties */ in sun9i_a80_cpus_setup()
212 mux->reg = cpus->reg; in sun9i_a80_cpus_setup()
213 mux->shift = SUN9I_CPUS_MUX_SHIFT; in sun9i_a80_cpus_setup()
214 /* un-shifted mask is what mux_clk expects */ in sun9i_a80_cpus_setup()
215 mux->mask = SUN9I_CPUS_MUX_MASK >> SUN9I_CPUS_MUX_SHIFT; in sun9i_a80_cpus_setup()
216 mux->lock = &sun9i_a80_cpus_lock; in sun9i_a80_cpus_setup()
219 &mux->hw, &clk_mux_ops, in sun9i_a80_cpus_setup()
220 &cpus->hw, &sun9i_a80_cpus_clk_ops, in sun9i_a80_cpus_setup()
236 iounmap(cpus->reg); in sun9i_a80_cpus_setup()
242 CLK_OF_DECLARE(sun9i_a80_cpus, "allwinner,sun9i-a80-cpus-clk",