Lines Matching refs:factor
30 struct mmp_clk_factor *factor = to_clk_factor(hw); in clk_factor_round_rate() local
34 for (i = 0; i < factor->ftbl_cnt; i++) { in clk_factor_round_rate()
37 rate *= factor->ftbl[i].den; in clk_factor_round_rate()
38 do_div(rate, factor->ftbl[i].num * factor->masks->factor); in clk_factor_round_rate()
43 if ((i == 0) || (i == factor->ftbl_cnt)) { in clk_factor_round_rate()
56 struct mmp_clk_factor *factor = to_clk_factor(hw); in clk_factor_recalc_rate() local
57 struct mmp_clk_factor_masks *masks = factor->masks; in clk_factor_recalc_rate()
61 val = readl_relaxed(factor->base); in clk_factor_recalc_rate()
74 do_div(rate, num * factor->masks->factor); in clk_factor_recalc_rate()
83 struct mmp_clk_factor *factor = to_clk_factor(hw); in clk_factor_set_rate() local
84 struct mmp_clk_factor_masks *masks = factor->masks; in clk_factor_set_rate()
90 for (i = 0; i < factor->ftbl_cnt; i++) { in clk_factor_set_rate()
92 rate *= factor->ftbl[i].den; in clk_factor_set_rate()
93 do_div(rate, factor->ftbl[i].num * factor->masks->factor); in clk_factor_set_rate()
101 if (factor->lock) in clk_factor_set_rate()
102 spin_lock_irqsave(factor->lock, flags); in clk_factor_set_rate()
104 val = readl_relaxed(factor->base); in clk_factor_set_rate()
107 val |= (factor->ftbl[i].num & masks->num_mask) << masks->num_shift; in clk_factor_set_rate()
110 val |= (factor->ftbl[i].den & masks->den_mask) << masks->den_shift; in clk_factor_set_rate()
112 writel_relaxed(val, factor->base); in clk_factor_set_rate()
114 if (factor->lock) in clk_factor_set_rate()
115 spin_unlock_irqrestore(factor->lock, flags); in clk_factor_set_rate()
122 struct mmp_clk_factor *factor = to_clk_factor(hw); in clk_factor_init() local
123 struct mmp_clk_factor_masks *masks = factor->masks; in clk_factor_init()
128 if (factor->lock) in clk_factor_init()
129 spin_lock_irqsave(factor->lock, flags); in clk_factor_init()
131 val = readl(factor->base); in clk_factor_init()
139 for (i = 0; i < factor->ftbl_cnt; i++) in clk_factor_init()
140 if (den == factor->ftbl[i].den && num == factor->ftbl[i].num) in clk_factor_init()
143 if (i >= factor->ftbl_cnt) { in clk_factor_init()
145 val |= (factor->ftbl[0].num & masks->num_mask) << in clk_factor_init()
149 val |= (factor->ftbl[0].den & masks->den_mask) << in clk_factor_init()
153 if (!(val & masks->enable_mask) || i >= factor->ftbl_cnt) { in clk_factor_init()
155 writel(val, factor->base); in clk_factor_init()
158 if (factor->lock) in clk_factor_init()
159 spin_unlock_irqrestore(factor->lock, flags); in clk_factor_init()
177 struct mmp_clk_factor *factor; in mmp_clk_register_factor() local
186 factor = kzalloc(sizeof(*factor), GFP_KERNEL); in mmp_clk_register_factor()
187 if (!factor) in mmp_clk_register_factor()
191 factor->base = base; in mmp_clk_register_factor()
192 factor->masks = masks; in mmp_clk_register_factor()
193 factor->ftbl = ftbl; in mmp_clk_register_factor()
194 factor->ftbl_cnt = ftbl_cnt; in mmp_clk_register_factor()
195 factor->hw.init = &init; in mmp_clk_register_factor()
196 factor->lock = lock; in mmp_clk_register_factor()
204 clk = clk_register(NULL, &factor->hw); in mmp_clk_register_factor()
206 kfree(factor); in mmp_clk_register_factor()