Lines Matching refs:div

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