Lines Matching refs:div

61 						  unsigned long div)  in ccu_div_lock_delay_ns()  argument
63 u64 ns = 4ULL * (div ?: 1) * NSEC_PER_SEC; in ccu_div_lock_delay_ns()
71 unsigned long div) in ccu_div_calc_freq() argument
73 return ref_clk / (div ?: 1); in ccu_div_calc_freq()
76 static int ccu_div_var_update_clkdiv(struct ccu_div *div, in ccu_div_var_update_clkdiv() argument
87 if (div->features & CCU_DIV_LOCK_SHIFTED) in ccu_div_var_update_clkdiv()
92 regmap_update_bits(div->sys_regs, div->reg_ctl, in ccu_div_var_update_clkdiv()
102 regmap_read(div->sys_regs, div->reg_ctl, &val); in ccu_div_var_update_clkdiv()
113 struct ccu_div *div = to_ccu_div(hw); in ccu_div_var_enable() local
123 regmap_read(div->sys_regs, div->reg_ctl, &val); in ccu_div_var_enable()
127 spin_lock_irqsave(&div->lock, flags); in ccu_div_var_enable()
128 ret = ccu_div_var_update_clkdiv(div, clk_hw_get_rate(parent_hw), in ccu_div_var_enable()
129 ccu_div_get(div->mask, val)); in ccu_div_var_enable()
131 regmap_update_bits(div->sys_regs, div->reg_ctl, in ccu_div_var_enable()
133 spin_unlock_irqrestore(&div->lock, flags); in ccu_div_var_enable()
142 struct ccu_div *div = to_ccu_div(hw); in ccu_div_gate_enable() local
145 spin_lock_irqsave(&div->lock, flags); in ccu_div_gate_enable()
146 regmap_update_bits(div->sys_regs, div->reg_ctl, in ccu_div_gate_enable()
148 spin_unlock_irqrestore(&div->lock, flags); in ccu_div_gate_enable()
155 struct ccu_div *div = to_ccu_div(hw); in ccu_div_gate_disable() local
158 spin_lock_irqsave(&div->lock, flags); in ccu_div_gate_disable()
159 regmap_update_bits(div->sys_regs, div->reg_ctl, CCU_DIV_CTL_EN, 0); in ccu_div_gate_disable()
160 spin_unlock_irqrestore(&div->lock, flags); in ccu_div_gate_disable()
165 struct ccu_div *div = to_ccu_div(hw); in ccu_div_gate_is_enabled() local
168 regmap_read(div->sys_regs, div->reg_ctl, &val); in ccu_div_gate_is_enabled()
175 struct ccu_div *div = to_ccu_div(hw); in ccu_div_buf_enable() local
178 spin_lock_irqsave(&div->lock, flags); in ccu_div_buf_enable()
179 regmap_update_bits(div->sys_regs, div->reg_ctl, in ccu_div_buf_enable()
181 spin_unlock_irqrestore(&div->lock, flags); in ccu_div_buf_enable()
188 struct ccu_div *div = to_ccu_div(hw); in ccu_div_buf_disable() local
191 spin_lock_irqsave(&div->lock, flags); in ccu_div_buf_disable()
192 regmap_update_bits(div->sys_regs, div->reg_ctl, in ccu_div_buf_disable()
194 spin_unlock_irqrestore(&div->lock, flags); in ccu_div_buf_disable()
199 struct ccu_div *div = to_ccu_div(hw); in ccu_div_buf_is_enabled() local
202 regmap_read(div->sys_regs, div->reg_ctl, &val); in ccu_div_buf_is_enabled()
210 struct ccu_div *div = to_ccu_div(hw); in ccu_div_var_recalc_rate() local
214 regmap_read(div->sys_regs, div->reg_ctl, &val); in ccu_div_var_recalc_rate()
215 divider = ccu_div_get(div->mask, val); in ccu_div_var_recalc_rate()
234 struct ccu_div *div = to_ccu_div(hw); in ccu_div_var_round_rate() local
237 divider = ccu_div_var_calc_divider(rate, *parent_rate, div->mask); in ccu_div_var_round_rate()
250 struct ccu_div *div = to_ccu_div(hw); in ccu_div_var_set_rate_slow() local
255 divider = ccu_div_var_calc_divider(rate, parent_rate, div->mask); in ccu_div_var_set_rate_slow()
256 if (divider == 1 && div->features & CCU_DIV_SKIP_ONE) { in ccu_div_var_set_rate_slow()
258 } else if (div->features & CCU_DIV_SKIP_ONE_TO_THREE) { in ccu_div_var_set_rate_slow()
265 val = ccu_div_prep(div->mask, divider); in ccu_div_var_set_rate_slow()
267 spin_lock_irqsave(&div->lock, flags); in ccu_div_var_set_rate_slow()
268 regmap_update_bits(div->sys_regs, div->reg_ctl, div->mask, val); in ccu_div_var_set_rate_slow()
269 ret = ccu_div_var_update_clkdiv(div, parent_rate, divider); in ccu_div_var_set_rate_slow()
270 spin_unlock_irqrestore(&div->lock, flags); in ccu_div_var_set_rate_slow()
284 struct ccu_div *div = to_ccu_div(hw); in ccu_div_var_set_rate_fast() local
288 divider = ccu_div_var_calc_divider(rate, parent_rate, div->mask); in ccu_div_var_set_rate_fast()
289 val = ccu_div_prep(div->mask, divider); in ccu_div_var_set_rate_fast()
295 spin_lock_irqsave(&div->lock, flags); in ccu_div_var_set_rate_fast()
296 regmap_update_bits(div->sys_regs, div->reg_ctl, in ccu_div_var_set_rate_fast()
297 div->mask | CCU_DIV_CTL_EN, val); in ccu_div_var_set_rate_fast()
298 spin_unlock_irqrestore(&div->lock, flags); in ccu_div_var_set_rate_fast()
306 struct ccu_div *div = to_ccu_div(hw); in ccu_div_fixed_recalc_rate() local
308 return ccu_div_calc_freq(parent_rate, div->divider); in ccu_div_fixed_recalc_rate()
314 struct ccu_div *div = to_ccu_div(hw); in ccu_div_fixed_round_rate() local
316 return ccu_div_calc_freq(*parent_rate, div->divider); in ccu_div_fixed_round_rate()
328 struct ccu_div *div; member
359 struct ccu_div *div = bit->div; in ccu_div_dbgfs_bit_set() local
362 spin_lock_irqsave(&div->lock, flags); in ccu_div_dbgfs_bit_set()
363 regmap_update_bits(div->sys_regs, div->reg_ctl, in ccu_div_dbgfs_bit_set()
365 spin_unlock_irqrestore(&div->lock, flags); in ccu_div_dbgfs_bit_set()
372 struct ccu_div *div = priv; in ccu_div_dbgfs_var_clkdiv_set() local
377 CCU_DIV_CLKDIV_MAX(div->mask)); in ccu_div_dbgfs_var_clkdiv_set()
378 data = ccu_div_prep(div->mask, val); in ccu_div_dbgfs_var_clkdiv_set()
380 spin_lock_irqsave(&div->lock, flags); in ccu_div_dbgfs_var_clkdiv_set()
381 regmap_update_bits(div->sys_regs, div->reg_ctl, div->mask, data); in ccu_div_dbgfs_var_clkdiv_set()
382 spin_unlock_irqrestore(&div->lock, flags); in ccu_div_dbgfs_var_clkdiv_set()
400 struct ccu_div *div = bit->div; in ccu_div_dbgfs_bit_get() local
403 regmap_read(div->sys_regs, div->reg_ctl, &data); in ccu_div_dbgfs_bit_get()
413 struct ccu_div *div = priv; in ccu_div_dbgfs_var_clkdiv_get() local
416 regmap_read(div->sys_regs, div->reg_ctl, &data); in ccu_div_dbgfs_var_clkdiv_get()
417 *val = ccu_div_get(div->mask, data); in ccu_div_dbgfs_var_clkdiv_get()
426 struct ccu_div *div = priv; in ccu_div_dbgfs_fixed_clkdiv_get() local
428 *val = div->divider; in ccu_div_dbgfs_fixed_clkdiv_get()
437 struct ccu_div *div = to_ccu_div(hw); in ccu_div_var_debug_init() local
442 num += !!(div->flags & CLK_SET_RATE_GATE) + in ccu_div_var_debug_init()
443 !!(div->features & CCU_DIV_RESET_DOMAIN); in ccu_div_var_debug_init()
451 if (!(div->flags & CLK_SET_RATE_GATE) && in ccu_div_var_debug_init()
456 if (!(div->features & CCU_DIV_RESET_DOMAIN) && in ccu_div_var_debug_init()
465 bits[didx].div = div; in ccu_div_var_debug_init()
467 if (div->features & CCU_DIV_LOCK_SHIFTED && in ccu_div_var_debug_init()
479 div, &ccu_div_dbgfs_var_clkdiv_fops); in ccu_div_var_debug_init()
484 struct ccu_div *div = to_ccu_div(hw); in ccu_div_gate_debug_init() local
492 bit->div = div; in ccu_div_gate_debug_init()
496 debugfs_create_file_unsafe("div_clkdiv", 0400, dentry, div, in ccu_div_gate_debug_init()
502 struct ccu_div *div = to_ccu_div(hw); in ccu_div_buf_debug_init() local
510 bit->div = div; in ccu_div_buf_debug_init()
517 struct ccu_div *div = to_ccu_div(hw); in ccu_div_fixed_debug_init() local
519 debugfs_create_file_unsafe("div_clkdiv", 0400, dentry, div, in ccu_div_fixed_debug_init()
577 struct ccu_div *div; in ccu_div_hw_register() local
583 div = kzalloc(sizeof(*div), GFP_KERNEL); in ccu_div_hw_register()
584 if (!div) in ccu_div_hw_register()
592 div->hw.init = &hw_init; in ccu_div_hw_register()
593 div->id = div_init->id; in ccu_div_hw_register()
594 div->reg_ctl = div_init->base + CCU_DIV_CTL; in ccu_div_hw_register()
595 div->sys_regs = div_init->sys_regs; in ccu_div_hw_register()
596 div->flags = div_init->flags; in ccu_div_hw_register()
597 div->features = div_init->features; in ccu_div_hw_register()
598 spin_lock_init(&div->lock); in ccu_div_hw_register()
608 div->mask = CCU_DIV_CTL_CLKDIV_MASK(div_init->width); in ccu_div_hw_register()
611 div->divider = div_init->divider; in ccu_div_hw_register()
616 div->divider = div_init->divider; in ccu_div_hw_register()
631 ret = of_clk_hw_register(div_init->np, &div->hw); in ccu_div_hw_register()
635 return div; in ccu_div_hw_register()
638 kfree(div); in ccu_div_hw_register()
643 void ccu_div_hw_unregister(struct ccu_div *div) in ccu_div_hw_unregister() argument
645 clk_hw_unregister(&div->hw); in ccu_div_hw_unregister()
647 kfree(div); in ccu_div_hw_unregister()