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()
33 if (!(common->features & CCU_FEATURE_SIGMA_DELTA_MOD)) in ccu_sdm_helper_enable()
37 for (i = 0; i < sdm->table_size; i++) in ccu_sdm_helper_enable()
38 if (sdm->table[i].rate == rate) in ccu_sdm_helper_enable()
39 writel(sdm->table[i].pattern, in ccu_sdm_helper_enable()
40 common->base + sdm->tuning_reg); in ccu_sdm_helper_enable()
43 spin_lock_irqsave(common->lock, flags); in ccu_sdm_helper_enable()
44 reg = readl(common->base + sdm->tuning_reg); in ccu_sdm_helper_enable()
45 writel(reg | sdm->tuning_enable, common->base + sdm->tuning_reg); in ccu_sdm_helper_enable()
46 spin_unlock_irqrestore(common->lock, flags); in ccu_sdm_helper_enable()
48 spin_lock_irqsave(common->lock, flags); in ccu_sdm_helper_enable()
49 reg = readl(common->base + common->reg); in ccu_sdm_helper_enable()
50 writel(reg | sdm->enable, common->base + common->reg); in ccu_sdm_helper_enable()
51 spin_unlock_irqrestore(common->lock, flags); in ccu_sdm_helper_enable()
61 if (!(common->features & CCU_FEATURE_SIGMA_DELTA_MOD)) in ccu_sdm_helper_disable()
64 spin_lock_irqsave(common->lock, flags); in ccu_sdm_helper_disable()
65 reg = readl(common->base + common->reg); in ccu_sdm_helper_disable()
66 writel(reg & ~sdm->enable, common->base + common->reg); in ccu_sdm_helper_disable()
67 spin_unlock_irqrestore(common->lock, flags); in ccu_sdm_helper_disable()
69 spin_lock_irqsave(common->lock, flags); in ccu_sdm_helper_disable()
70 reg = readl(common->base + sdm->tuning_reg); in ccu_sdm_helper_disable()
71 writel(reg & ~sdm->tuning_enable, common->base + sdm->tuning_reg); in ccu_sdm_helper_disable()
72 spin_unlock_irqrestore(common->lock, flags); in ccu_sdm_helper_disable()
77 * Sigma delta modulation provides a way to do fractional-N frequency
99 if (!(common->features & CCU_FEATURE_SIGMA_DELTA_MOD)) in ccu_sdm_helper_has_rate()
102 for (i = 0; i < sdm->table_size; i++) in ccu_sdm_helper_has_rate()
103 if (sdm->table[i].rate == rate) in ccu_sdm_helper_has_rate()
117 pr_debug("%s: Read sigma-delta modulation setting\n", in ccu_sdm_helper_read_rate()
118 clk_hw_get_name(&common->hw)); in ccu_sdm_helper_read_rate()
120 if (!(common->features & CCU_FEATURE_SIGMA_DELTA_MOD)) in ccu_sdm_helper_read_rate()
123 pr_debug("%s: clock is sigma-delta modulated\n", in ccu_sdm_helper_read_rate()
124 clk_hw_get_name(&common->hw)); in ccu_sdm_helper_read_rate()
126 reg = readl(common->base + sdm->tuning_reg); in ccu_sdm_helper_read_rate()
129 clk_hw_get_name(&common->hw), reg); in ccu_sdm_helper_read_rate()
131 for (i = 0; i < sdm->table_size; i++) in ccu_sdm_helper_read_rate()
132 if (sdm->table[i].pattern == reg && in ccu_sdm_helper_read_rate()
133 sdm->table[i].m == m && sdm->table[i].n == n) in ccu_sdm_helper_read_rate()
134 return sdm->table[i].rate; in ccu_sdm_helper_read_rate()
148 if (!(common->features & CCU_FEATURE_SIGMA_DELTA_MOD)) in ccu_sdm_helper_get_factors()
149 return -EINVAL; in ccu_sdm_helper_get_factors()
151 for (i = 0; i < sdm->table_size; i++) in ccu_sdm_helper_get_factors()
152 if (sdm->table[i].rate == rate) { in ccu_sdm_helper_get_factors()
153 *m = sdm->table[i].m; in ccu_sdm_helper_get_factors()
154 *n = sdm->table[i].n; in ccu_sdm_helper_get_factors()
159 return -EINVAL; in ccu_sdm_helper_get_factors()