Lines Matching defs:nm

31 				      unsigned long rate, struct _ccu_nm *nm)
37 for (_n = nm->min_n; _n <= nm->max_n; _n++) {
38 for (_m = nm->min_m; _m <= nm->max_m; _m++) {
50 nm->n = best_n;
51 nm->m = best_m;
58 struct ccu_nm *nm = hw_to_ccu_nm(hw);
60 return ccu_gate_helper_disable(&nm->common, nm->enable);
65 struct ccu_nm *nm = hw_to_ccu_nm(hw);
67 return ccu_gate_helper_enable(&nm->common, nm->enable);
72 struct ccu_nm *nm = hw_to_ccu_nm(hw);
74 return ccu_gate_helper_is_enabled(&nm->common, nm->enable);
80 struct ccu_nm *nm = hw_to_ccu_nm(hw);
85 if (ccu_frac_helper_is_enabled(&nm->common, &nm->frac)) {
86 rate = ccu_frac_helper_read_rate(&nm->common, &nm->frac);
88 if (nm->common.features & CCU_FEATURE_FIXED_POSTDIV)
89 rate /= nm->fixed_post_div;
94 reg = readl(nm->common.base + nm->common.reg);
96 n = reg >> nm->n.shift;
97 n &= (1 << nm->n.width) - 1;
98 n += nm->n.offset;
102 m = reg >> nm->m.shift;
103 m &= (1 << nm->m.width) - 1;
104 m += nm->m.offset;
108 if (ccu_sdm_helper_is_enabled(&nm->common, &nm->sdm))
109 rate = ccu_sdm_helper_read_rate(&nm->common, &nm->sdm, m, n);
113 if (nm->common.features & CCU_FEATURE_FIXED_POSTDIV)
114 rate /= nm->fixed_post_div;
122 struct ccu_nm *nm = hw_to_ccu_nm(hw);
125 if (nm->common.features & CCU_FEATURE_FIXED_POSTDIV)
126 rate *= nm->fixed_post_div;
128 if (rate < nm->min_rate) {
129 rate = nm->min_rate;
130 if (nm->common.features & CCU_FEATURE_FIXED_POSTDIV)
131 rate /= nm->fixed_post_div;
135 if (nm->max_rate && rate > nm->max_rate) {
136 rate = nm->max_rate;
137 if (nm->common.features & CCU_FEATURE_FIXED_POSTDIV)
138 rate /= nm->fixed_post_div;
142 if (ccu_frac_helper_has_rate(&nm->common, &nm->frac, rate)) {
143 if (nm->common.features & CCU_FEATURE_FIXED_POSTDIV)
144 rate /= nm->fixed_post_div;
148 if (ccu_sdm_helper_has_rate(&nm->common, &nm->sdm, rate)) {
149 if (nm->common.features & CCU_FEATURE_FIXED_POSTDIV)
150 rate /= nm->fixed_post_div;
154 _nm.min_n = nm->n.min ?: 1;
155 _nm.max_n = nm->n.max ?: 1 << nm->n.width;
157 _nm.max_m = nm->m.max ?: 1 << nm->m.width;
159 rate = ccu_nm_find_best(&nm->common, *parent_rate, rate, &_nm);
161 if (nm->common.features & CCU_FEATURE_FIXED_POSTDIV)
162 rate /= nm->fixed_post_div;
170 struct ccu_nm *nm = hw_to_ccu_nm(hw);
176 if (nm->common.features & CCU_FEATURE_FIXED_POSTDIV)
177 rate = rate * nm->fixed_post_div;
179 if (ccu_frac_helper_has_rate(&nm->common, &nm->frac, rate)) {
180 spin_lock_irqsave(nm->common.lock, flags);
183 reg = readl(nm->common.base + nm->common.reg);
184 reg &= ~GENMASK(nm->m.width + nm->m.shift - 1, nm->m.shift);
185 writel(reg, nm->common.base + nm->common.reg);
187 spin_unlock_irqrestore(nm->common.lock, flags);
189 ccu_frac_helper_enable(&nm->common, &nm->frac);
191 return ccu_frac_helper_set_rate(&nm->common, &nm->frac,
192 rate, nm->lock);
194 ccu_frac_helper_disable(&nm->common, &nm->frac);
197 _nm.min_n = nm->n.min ?: 1;
198 _nm.max_n = nm->n.max ?: 1 << nm->n.width;
200 _nm.max_m = nm->m.max ?: 1 << nm->m.width;
202 if (ccu_sdm_helper_has_rate(&nm->common, &nm->sdm, rate)) {
203 ccu_sdm_helper_enable(&nm->common, &nm->sdm, rate);
206 ccu_sdm_helper_get_factors(&nm->common, &nm->sdm, rate,
209 ccu_sdm_helper_disable(&nm->common, &nm->sdm);
210 ccu_nm_find_best(&nm->common, parent_rate, rate, &_nm);
213 spin_lock_irqsave(nm->common.lock, flags);
215 reg = readl(nm->common.base + nm->common.reg);
216 reg &= ~GENMASK(nm->n.width + nm->n.shift - 1, nm->n.shift);
217 reg &= ~GENMASK(nm->m.width + nm->m.shift - 1, nm->m.shift);
219 reg |= (_nm.n - nm->n.offset) << nm->n.shift;
220 reg |= (_nm.m - nm->m.offset) << nm->m.shift;
221 writel(reg, nm->common.base + nm->common.reg);
223 spin_unlock_irqrestore(nm->common.lock, flags);
225 ccu_helper_wait_for_lock(&nm->common, nm->lock);