Lines Matching +full:dclk +full:- +full:div

1 // SPDX-License-Identifier: GPL-2.0-or-later
6 * Maxime Ripard <maxime.ripard@free-electrons.com>
9 #include <linux/clk-provider.h>
28 struct sun4i_dclk *dclk = hw_to_dclk(hw); in sun4i_dclk_disable() local
30 regmap_update_bits(dclk->regmap, SUN4I_TCON0_DCLK_REG, in sun4i_dclk_disable()
36 struct sun4i_dclk *dclk = hw_to_dclk(hw); in sun4i_dclk_enable() local
38 return regmap_update_bits(dclk->regmap, SUN4I_TCON0_DCLK_REG, in sun4i_dclk_enable()
45 struct sun4i_dclk *dclk = hw_to_dclk(hw); in sun4i_dclk_is_enabled() local
48 regmap_read(dclk->regmap, SUN4I_TCON0_DCLK_REG, &val); in sun4i_dclk_is_enabled()
56 struct sun4i_dclk *dclk = hw_to_dclk(hw); in sun4i_dclk_recalc_rate() local
59 regmap_read(dclk->regmap, SUN4I_TCON0_DCLK_REG, &val); in sun4i_dclk_recalc_rate()
62 val &= (1 << SUN4I_TCON0_DCLK_DIV_WIDTH) - 1; in sun4i_dclk_recalc_rate()
73 struct sun4i_dclk *dclk = hw_to_dclk(hw); in sun4i_dclk_round_rate() local
74 struct sun4i_tcon *tcon = dclk->tcon; in sun4i_dclk_round_rate()
79 for (i = tcon->dclk_min_div; i <= tcon->dclk_max_div; i++) { in sun4i_dclk_round_rate()
102 if (abs(rate - rounded / i) < in sun4i_dclk_round_rate()
103 abs(rate - best_parent / best_div)) { in sun4i_dclk_round_rate()
118 struct sun4i_dclk *dclk = hw_to_dclk(hw); in sun4i_dclk_set_rate() local
119 u8 div = parent_rate / rate; in sun4i_dclk_set_rate() local
121 return regmap_update_bits(dclk->regmap, SUN4I_TCON0_DCLK_REG, in sun4i_dclk_set_rate()
122 GENMASK(6, 0), div); in sun4i_dclk_set_rate()
127 struct sun4i_dclk *dclk = hw_to_dclk(hw); in sun4i_dclk_get_phase() local
130 regmap_read(dclk->regmap, SUN4I_TCON0_IO_POL_REG, &val); in sun4i_dclk_get_phase()
140 struct sun4i_dclk *dclk = hw_to_dclk(hw); in sun4i_dclk_set_phase() local
145 regmap_update_bits(dclk->regmap, SUN4I_TCON0_IO_POL_REG, in sun4i_dclk_set_phase()
169 struct sun4i_dclk *dclk; in sun4i_dclk_create() local
172 parent_name = __clk_get_name(tcon->sclk0); in sun4i_dclk_create()
173 ret = of_property_read_string_index(dev->of_node, in sun4i_dclk_create()
174 "clock-output-names", 0, in sun4i_dclk_create()
179 dclk = devm_kzalloc(dev, sizeof(*dclk), GFP_KERNEL); in sun4i_dclk_create()
180 if (!dclk) in sun4i_dclk_create()
181 return -ENOMEM; in sun4i_dclk_create()
182 dclk->tcon = tcon; in sun4i_dclk_create()
190 dclk->regmap = tcon->regs; in sun4i_dclk_create()
191 dclk->hw.init = &init; in sun4i_dclk_create()
193 tcon->dclk = clk_register(dev, &dclk->hw); in sun4i_dclk_create()
194 if (IS_ERR(tcon->dclk)) in sun4i_dclk_create()
195 return PTR_ERR(tcon->dclk); in sun4i_dclk_create()
203 clk_unregister(tcon->dclk); in sun4i_dclk_free()