Lines Matching +full:delta +full:- +full:sigma
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright (C) 2017 Chen-Yu Tsai <wens@csie.org>
6 #include <linux/clk-provider.h>
15 if (!(common->features & CCU_FEATURE_SIGMA_DELTA_MOD)) in ccu_sdm_helper_is_enabled()
18 if (sdm->enable && !(readl(common->base + common->reg) & sdm->enable)) in ccu_sdm_helper_is_enabled()
21 return !!(readl(common->base + sdm->tuning_reg) & sdm->tuning_enable); in ccu_sdm_helper_is_enabled()
32 if (!(common->features & CCU_FEATURE_SIGMA_DELTA_MOD)) in ccu_sdm_helper_enable()
36 for (i = 0; i < sdm->table_size; i++) in ccu_sdm_helper_enable()
37 if (sdm->table[i].rate == rate) in ccu_sdm_helper_enable()
38 writel(sdm->table[i].pattern, in ccu_sdm_helper_enable()
39 common->base + sdm->tuning_reg); in ccu_sdm_helper_enable()
42 spin_lock_irqsave(common->lock, flags); in ccu_sdm_helper_enable()
43 reg = readl(common->base + sdm->tuning_reg); in ccu_sdm_helper_enable()
44 writel(reg | sdm->tuning_enable, common->base + sdm->tuning_reg); in ccu_sdm_helper_enable()
45 spin_unlock_irqrestore(common->lock, flags); in ccu_sdm_helper_enable()
47 spin_lock_irqsave(common->lock, flags); in ccu_sdm_helper_enable()
48 reg = readl(common->base + common->reg); in ccu_sdm_helper_enable()
49 writel(reg | sdm->enable, common->base + common->reg); in ccu_sdm_helper_enable()
50 spin_unlock_irqrestore(common->lock, flags); in ccu_sdm_helper_enable()
59 if (!(common->features & CCU_FEATURE_SIGMA_DELTA_MOD)) in ccu_sdm_helper_disable()
62 spin_lock_irqsave(common->lock, flags); in ccu_sdm_helper_disable()
63 reg = readl(common->base + common->reg); in ccu_sdm_helper_disable()
64 writel(reg & ~sdm->enable, common->base + common->reg); in ccu_sdm_helper_disable()
65 spin_unlock_irqrestore(common->lock, flags); in ccu_sdm_helper_disable()
67 spin_lock_irqsave(common->lock, flags); in ccu_sdm_helper_disable()
68 reg = readl(common->base + sdm->tuning_reg); in ccu_sdm_helper_disable()
69 writel(reg & ~sdm->tuning_enable, common->base + sdm->tuning_reg); in ccu_sdm_helper_disable()
70 spin_unlock_irqrestore(common->lock, flags); in ccu_sdm_helper_disable()
74 * Sigma delta modulation provides a way to do fractional-N frequency
96 if (!(common->features & CCU_FEATURE_SIGMA_DELTA_MOD)) in ccu_sdm_helper_has_rate()
99 for (i = 0; i < sdm->table_size; i++) in ccu_sdm_helper_has_rate()
100 if (sdm->table[i].rate == rate) in ccu_sdm_helper_has_rate()
113 pr_debug("%s: Read sigma-delta modulation setting\n", in ccu_sdm_helper_read_rate()
114 clk_hw_get_name(&common->hw)); in ccu_sdm_helper_read_rate()
116 if (!(common->features & CCU_FEATURE_SIGMA_DELTA_MOD)) in ccu_sdm_helper_read_rate()
119 pr_debug("%s: clock is sigma-delta modulated\n", in ccu_sdm_helper_read_rate()
120 clk_hw_get_name(&common->hw)); in ccu_sdm_helper_read_rate()
122 reg = readl(common->base + sdm->tuning_reg); in ccu_sdm_helper_read_rate()
125 clk_hw_get_name(&common->hw), reg); in ccu_sdm_helper_read_rate()
127 for (i = 0; i < sdm->table_size; i++) in ccu_sdm_helper_read_rate()
128 if (sdm->table[i].pattern == reg && in ccu_sdm_helper_read_rate()
129 sdm->table[i].m == m && sdm->table[i].n == n) in ccu_sdm_helper_read_rate()
130 return sdm->table[i].rate; in ccu_sdm_helper_read_rate()
143 if (!(common->features & CCU_FEATURE_SIGMA_DELTA_MOD)) in ccu_sdm_helper_get_factors()
144 return -EINVAL; in ccu_sdm_helper_get_factors()
146 for (i = 0; i < sdm->table_size; i++) in ccu_sdm_helper_get_factors()
147 if (sdm->table[i].rate == rate) { in ccu_sdm_helper_get_factors()
148 *m = sdm->table[i].m; in ccu_sdm_helper_get_factors()
149 *n = sdm->table[i].n; in ccu_sdm_helper_get_factors()
154 return -EINVAL; in ccu_sdm_helper_get_factors()