Lines Matching refs:nkm

22 	struct ccu_nkm *nkm = container_of(common, struct ccu_nkm, common);  in ccu_nkm_is_valid_rate()  local
24 if (nkm->max_m_n_ratio && (m > nkm->max_m_n_ratio * n)) in ccu_nkm_is_valid_rate()
27 if (nkm->min_parent_m_ratio && (parent < nkm->min_parent_m_ratio * m)) in ccu_nkm_is_valid_rate()
36 struct _ccu_nkm *nkm) in ccu_nkm_find_best_with_parent_adj() argument
42 for (_k = nkm->min_k; _k <= nkm->max_k; _k++) { in ccu_nkm_find_best_with_parent_adj()
43 for (_n = nkm->min_n; _n <= nkm->max_n; _n++) { in ccu_nkm_find_best_with_parent_adj()
44 for (_m = nkm->min_m; _m <= nkm->max_m; _m++) { in ccu_nkm_find_best_with_parent_adj()
66 nkm->n = best_n; in ccu_nkm_find_best_with_parent_adj()
67 nkm->k = best_k; in ccu_nkm_find_best_with_parent_adj()
68 nkm->m = best_m; in ccu_nkm_find_best_with_parent_adj()
76 struct _ccu_nkm *nkm, struct ccu_common *common) in ccu_nkm_find_best() argument
82 for (_k = nkm->min_k; _k <= nkm->max_k; _k++) { in ccu_nkm_find_best()
83 for (_n = nkm->min_n; _n <= nkm->max_n; _n++) { in ccu_nkm_find_best()
84 for (_m = nkm->min_m; _m <= nkm->max_m; _m++) { in ccu_nkm_find_best()
102 nkm->n = best_n; in ccu_nkm_find_best()
103 nkm->k = best_k; in ccu_nkm_find_best()
104 nkm->m = best_m; in ccu_nkm_find_best()
111 struct ccu_nkm *nkm = hw_to_ccu_nkm(hw); in ccu_nkm_disable() local
113 return ccu_gate_helper_disable(&nkm->common, nkm->enable); in ccu_nkm_disable()
118 struct ccu_nkm *nkm = hw_to_ccu_nkm(hw); in ccu_nkm_enable() local
120 return ccu_gate_helper_enable(&nkm->common, nkm->enable); in ccu_nkm_enable()
125 struct ccu_nkm *nkm = hw_to_ccu_nkm(hw); in ccu_nkm_is_enabled() local
127 return ccu_gate_helper_is_enabled(&nkm->common, nkm->enable); in ccu_nkm_is_enabled()
133 struct ccu_nkm *nkm = hw_to_ccu_nkm(hw); in ccu_nkm_recalc_rate() local
137 reg = readl(nkm->common.base + nkm->common.reg); in ccu_nkm_recalc_rate()
139 n = reg >> nkm->n.shift; in ccu_nkm_recalc_rate()
140 n &= (1 << nkm->n.width) - 1; in ccu_nkm_recalc_rate()
141 n += nkm->n.offset; in ccu_nkm_recalc_rate()
145 k = reg >> nkm->k.shift; in ccu_nkm_recalc_rate()
146 k &= (1 << nkm->k.width) - 1; in ccu_nkm_recalc_rate()
147 k += nkm->k.offset; in ccu_nkm_recalc_rate()
151 m = reg >> nkm->m.shift; in ccu_nkm_recalc_rate()
152 m &= (1 << nkm->m.width) - 1; in ccu_nkm_recalc_rate()
153 m += nkm->m.offset; in ccu_nkm_recalc_rate()
159 if (nkm->common.features & CCU_FEATURE_FIXED_POSTDIV) in ccu_nkm_recalc_rate()
160 rate /= nkm->fixed_post_div; in ccu_nkm_recalc_rate()
171 struct ccu_nkm *nkm = data; in ccu_nkm_round_rate() local
174 _nkm.min_n = nkm->n.min ?: 1; in ccu_nkm_round_rate()
175 _nkm.max_n = nkm->n.max ?: 1 << nkm->n.width; in ccu_nkm_round_rate()
176 _nkm.min_k = nkm->k.min ?: 1; in ccu_nkm_round_rate()
177 _nkm.max_k = nkm->k.max ?: 1 << nkm->k.width; in ccu_nkm_round_rate()
179 _nkm.max_m = nkm->m.max ?: 1 << nkm->m.width; in ccu_nkm_round_rate()
181 if (nkm->common.features & CCU_FEATURE_FIXED_POSTDIV) in ccu_nkm_round_rate()
182 rate *= nkm->fixed_post_div; in ccu_nkm_round_rate()
184 if (!clk_hw_can_set_rate_parent(&nkm->common.hw)) in ccu_nkm_round_rate()
185 rate = ccu_nkm_find_best(*parent_rate, rate, &_nkm, &nkm->common); in ccu_nkm_round_rate()
187 rate = ccu_nkm_find_best_with_parent_adj(&nkm->common, parent_hw, parent_rate, rate, in ccu_nkm_round_rate()
190 if (nkm->common.features & CCU_FEATURE_FIXED_POSTDIV) in ccu_nkm_round_rate()
191 rate /= nkm->fixed_post_div; in ccu_nkm_round_rate()
199 struct ccu_nkm *nkm = hw_to_ccu_nkm(hw); in ccu_nkm_determine_rate() local
201 return ccu_mux_helper_determine_rate(&nkm->common, &nkm->mux, in ccu_nkm_determine_rate()
202 req, ccu_nkm_round_rate, nkm); in ccu_nkm_determine_rate()
208 struct ccu_nkm *nkm = hw_to_ccu_nkm(hw); in ccu_nkm_set_rate() local
213 if (nkm->common.features & CCU_FEATURE_FIXED_POSTDIV) in ccu_nkm_set_rate()
214 rate *= nkm->fixed_post_div; in ccu_nkm_set_rate()
216 _nkm.min_n = nkm->n.min ?: 1; in ccu_nkm_set_rate()
217 _nkm.max_n = nkm->n.max ?: 1 << nkm->n.width; in ccu_nkm_set_rate()
218 _nkm.min_k = nkm->k.min ?: 1; in ccu_nkm_set_rate()
219 _nkm.max_k = nkm->k.max ?: 1 << nkm->k.width; in ccu_nkm_set_rate()
221 _nkm.max_m = nkm->m.max ?: 1 << nkm->m.width; in ccu_nkm_set_rate()
223 ccu_nkm_find_best(parent_rate, rate, &_nkm, &nkm->common); in ccu_nkm_set_rate()
225 spin_lock_irqsave(nkm->common.lock, flags); in ccu_nkm_set_rate()
227 reg = readl(nkm->common.base + nkm->common.reg); in ccu_nkm_set_rate()
228 reg &= ~GENMASK(nkm->n.width + nkm->n.shift - 1, nkm->n.shift); in ccu_nkm_set_rate()
229 reg &= ~GENMASK(nkm->k.width + nkm->k.shift - 1, nkm->k.shift); in ccu_nkm_set_rate()
230 reg &= ~GENMASK(nkm->m.width + nkm->m.shift - 1, nkm->m.shift); in ccu_nkm_set_rate()
232 reg |= (_nkm.n - nkm->n.offset) << nkm->n.shift; in ccu_nkm_set_rate()
233 reg |= (_nkm.k - nkm->k.offset) << nkm->k.shift; in ccu_nkm_set_rate()
234 reg |= (_nkm.m - nkm->m.offset) << nkm->m.shift; in ccu_nkm_set_rate()
235 writel(reg, nkm->common.base + nkm->common.reg); in ccu_nkm_set_rate()
237 spin_unlock_irqrestore(nkm->common.lock, flags); in ccu_nkm_set_rate()
239 ccu_helper_wait_for_lock(&nkm->common, nkm->lock); in ccu_nkm_set_rate()
246 struct ccu_nkm *nkm = hw_to_ccu_nkm(hw); in ccu_nkm_get_parent() local
248 return ccu_mux_helper_get_parent(&nkm->common, &nkm->mux); in ccu_nkm_get_parent()
253 struct ccu_nkm *nkm = hw_to_ccu_nkm(hw); in ccu_nkm_set_parent() local
255 return ccu_mux_helper_set_parent(&nkm->common, &nkm->mux, index); in ccu_nkm_set_parent()