Lines Matching +full:fractional +full:- +full:n
1 // SPDX-License-Identifier: GPL-2.0-or-later
4 * Maxime Ripard <maxime.ripard@free-electrons.com>
7 #include <linux/clk-provider.h>
16 if (!(common->features & CCU_FEATURE_FRACTIONAL)) in ccu_frac_helper_is_enabled()
19 return !(readl(common->base + common->reg) & cf->enable); in ccu_frac_helper_is_enabled()
29 if (!(common->features & CCU_FEATURE_FRACTIONAL)) in ccu_frac_helper_enable()
32 spin_lock_irqsave(common->lock, flags); in ccu_frac_helper_enable()
33 reg = readl(common->base + common->reg); in ccu_frac_helper_enable()
34 writel(reg & ~cf->enable, common->base + common->reg); in ccu_frac_helper_enable()
35 spin_unlock_irqrestore(common->lock, flags); in ccu_frac_helper_enable()
45 if (!(common->features & CCU_FEATURE_FRACTIONAL)) in ccu_frac_helper_disable()
48 spin_lock_irqsave(common->lock, flags); in ccu_frac_helper_disable()
49 reg = readl(common->base + common->reg); in ccu_frac_helper_disable()
50 writel(reg | cf->enable, common->base + common->reg); in ccu_frac_helper_disable()
51 spin_unlock_irqrestore(common->lock, flags); in ccu_frac_helper_disable()
59 if (!(common->features & CCU_FEATURE_FRACTIONAL)) in ccu_frac_helper_has_rate()
62 return (cf->rates[0] == rate) || (cf->rates[1] == rate); in ccu_frac_helper_has_rate()
71 pr_debug("%s: Read fractional\n", clk_hw_get_name(&common->hw)); in ccu_frac_helper_read_rate()
73 if (!(common->features & CCU_FEATURE_FRACTIONAL)) in ccu_frac_helper_read_rate()
76 pr_debug("%s: clock is fractional (rates %lu and %lu)\n", in ccu_frac_helper_read_rate()
77 clk_hw_get_name(&common->hw), cf->rates[0], cf->rates[1]); in ccu_frac_helper_read_rate()
79 reg = readl(common->base + common->reg); in ccu_frac_helper_read_rate()
81 pr_debug("%s: clock reg is 0x%x (select is 0x%x)\n", in ccu_frac_helper_read_rate()
82 clk_hw_get_name(&common->hw), reg, cf->select); in ccu_frac_helper_read_rate()
84 return (reg & cf->select) ? cf->rates[1] : cf->rates[0]; in ccu_frac_helper_read_rate()
95 if (!(common->features & CCU_FEATURE_FRACTIONAL)) in ccu_frac_helper_set_rate()
96 return -EINVAL; in ccu_frac_helper_set_rate()
98 if (cf->rates[0] == rate) in ccu_frac_helper_set_rate()
100 else if (cf->rates[1] == rate) in ccu_frac_helper_set_rate()
101 sel = cf->select; in ccu_frac_helper_set_rate()
103 return -EINVAL; in ccu_frac_helper_set_rate()
105 spin_lock_irqsave(common->lock, flags); in ccu_frac_helper_set_rate()
106 reg = readl(common->base + common->reg); in ccu_frac_helper_set_rate()
107 reg &= ~cf->select; in ccu_frac_helper_set_rate()
108 writel(reg | sel, common->base + common->reg); in ccu_frac_helper_set_rate()
109 spin_unlock_irqrestore(common->lock, flags); in ccu_frac_helper_set_rate()