Lines Matching refs:periph
50 struct clk_peripheral *periph = to_clk_peripheral(hw); in clk_peripheral_enable() local
52 u32 id = periph->id; in clk_peripheral_enable()
58 regmap_write(periph->regmap, offset, PERIPHERAL_MASK(id)); in clk_peripheral_enable()
65 struct clk_peripheral *periph = to_clk_peripheral(hw); in clk_peripheral_disable() local
67 u32 id = periph->id; in clk_peripheral_disable()
73 regmap_write(periph->regmap, offset, PERIPHERAL_MASK(id)); in clk_peripheral_disable()
78 struct clk_peripheral *periph = to_clk_peripheral(hw); in clk_peripheral_is_enabled() local
81 u32 id = periph->id; in clk_peripheral_is_enabled()
87 regmap_read(periph->regmap, offset, &status); in clk_peripheral_is_enabled()
103 struct clk_peripheral *periph; in at91_clk_register_peripheral() local
111 periph = kzalloc(sizeof(*periph), GFP_KERNEL); in at91_clk_register_peripheral()
112 if (!periph) in at91_clk_register_peripheral()
124 periph->id = id; in at91_clk_register_peripheral()
125 periph->hw.init = &init; in at91_clk_register_peripheral()
126 periph->regmap = regmap; in at91_clk_register_peripheral()
128 hw = &periph->hw; in at91_clk_register_peripheral()
129 ret = clk_hw_register(NULL, &periph->hw); in at91_clk_register_peripheral()
131 kfree(periph); in at91_clk_register_peripheral()
138 static void clk_sam9x5_peripheral_autodiv(struct clk_sam9x5_peripheral *periph) in clk_sam9x5_peripheral_autodiv() argument
144 if (!periph->auto_div) in clk_sam9x5_peripheral_autodiv()
147 if (periph->range.max) { in clk_sam9x5_peripheral_autodiv()
148 parent = clk_hw_get_parent_by_index(&periph->hw, 0); in clk_sam9x5_peripheral_autodiv()
154 if (parent_rate >> shift <= periph->range.max) in clk_sam9x5_peripheral_autodiv()
159 periph->auto_div = false; in clk_sam9x5_peripheral_autodiv()
160 periph->div = shift; in clk_sam9x5_peripheral_autodiv()
163 static int clk_sam9x5_peripheral_set(struct clk_sam9x5_peripheral *periph, in clk_sam9x5_peripheral_set() argument
169 if (periph->id < PERIPHERAL_ID_MIN) in clk_sam9x5_peripheral_set()
172 spin_lock_irqsave(periph->lock, flags); in clk_sam9x5_peripheral_set()
173 regmap_write(periph->regmap, periph->layout->offset, in clk_sam9x5_peripheral_set()
174 (periph->id & periph->layout->pid_mask)); in clk_sam9x5_peripheral_set()
175 regmap_update_bits(periph->regmap, periph->layout->offset, in clk_sam9x5_peripheral_set()
176 periph->layout->div_mask | periph->layout->cmd | in clk_sam9x5_peripheral_set()
178 field_prep(periph->layout->div_mask, periph->div) | in clk_sam9x5_peripheral_set()
179 periph->layout->cmd | enable); in clk_sam9x5_peripheral_set()
180 spin_unlock_irqrestore(periph->lock, flags); in clk_sam9x5_peripheral_set()
187 struct clk_sam9x5_peripheral *periph = to_clk_sam9x5_peripheral(hw); in clk_sam9x5_peripheral_enable() local
189 return clk_sam9x5_peripheral_set(periph, 1); in clk_sam9x5_peripheral_enable()
194 struct clk_sam9x5_peripheral *periph = to_clk_sam9x5_peripheral(hw); in clk_sam9x5_peripheral_disable() local
197 if (periph->id < PERIPHERAL_ID_MIN) in clk_sam9x5_peripheral_disable()
200 spin_lock_irqsave(periph->lock, flags); in clk_sam9x5_peripheral_disable()
201 regmap_write(periph->regmap, periph->layout->offset, in clk_sam9x5_peripheral_disable()
202 (periph->id & periph->layout->pid_mask)); in clk_sam9x5_peripheral_disable()
203 regmap_update_bits(periph->regmap, periph->layout->offset, in clk_sam9x5_peripheral_disable()
204 AT91_PMC_PCR_EN | periph->layout->cmd, in clk_sam9x5_peripheral_disable()
205 periph->layout->cmd); in clk_sam9x5_peripheral_disable()
206 spin_unlock_irqrestore(periph->lock, flags); in clk_sam9x5_peripheral_disable()
211 struct clk_sam9x5_peripheral *periph = to_clk_sam9x5_peripheral(hw); in clk_sam9x5_peripheral_is_enabled() local
215 if (periph->id < PERIPHERAL_ID_MIN) in clk_sam9x5_peripheral_is_enabled()
218 spin_lock_irqsave(periph->lock, flags); in clk_sam9x5_peripheral_is_enabled()
219 regmap_write(periph->regmap, periph->layout->offset, in clk_sam9x5_peripheral_is_enabled()
220 (periph->id & periph->layout->pid_mask)); in clk_sam9x5_peripheral_is_enabled()
221 regmap_read(periph->regmap, periph->layout->offset, &status); in clk_sam9x5_peripheral_is_enabled()
222 spin_unlock_irqrestore(periph->lock, flags); in clk_sam9x5_peripheral_is_enabled()
231 struct clk_sam9x5_peripheral *periph = to_clk_sam9x5_peripheral(hw); in clk_sam9x5_peripheral_recalc_rate() local
235 if (periph->id < PERIPHERAL_ID_MIN) in clk_sam9x5_peripheral_recalc_rate()
238 spin_lock_irqsave(periph->lock, flags); in clk_sam9x5_peripheral_recalc_rate()
239 regmap_write(periph->regmap, periph->layout->offset, in clk_sam9x5_peripheral_recalc_rate()
240 (periph->id & periph->layout->pid_mask)); in clk_sam9x5_peripheral_recalc_rate()
241 regmap_read(periph->regmap, periph->layout->offset, &status); in clk_sam9x5_peripheral_recalc_rate()
242 spin_unlock_irqrestore(periph->lock, flags); in clk_sam9x5_peripheral_recalc_rate()
245 periph->div = field_get(periph->layout->div_mask, status); in clk_sam9x5_peripheral_recalc_rate()
246 periph->auto_div = false; in clk_sam9x5_peripheral_recalc_rate()
248 clk_sam9x5_peripheral_autodiv(periph); in clk_sam9x5_peripheral_recalc_rate()
251 return parent_rate >> periph->div; in clk_sam9x5_peripheral_recalc_rate()
274 struct clk_sam9x5_peripheral *periph = to_clk_sam9x5_peripheral(hw); in clk_sam9x5_peripheral_determine_rate() local
282 if (periph->id < PERIPHERAL_ID_MIN || !periph->range.max) in clk_sam9x5_peripheral_determine_rate()
289 if (periph->range.max && tmp_rate > periph->range.max) in clk_sam9x5_peripheral_determine_rate()
299 if (periph->chg_pid < 0) in clk_sam9x5_peripheral_determine_rate()
303 parent = clk_hw_get_parent_by_index(hw, periph->chg_pid); in clk_sam9x5_peripheral_determine_rate()
322 (periph->range.max && best_rate > periph->range.max)) in clk_sam9x5_peripheral_determine_rate()
344 struct clk_sam9x5_peripheral *periph = to_clk_sam9x5_peripheral(hw); in clk_sam9x5_peripheral_round_rate() local
346 if (periph->id < PERIPHERAL_ID_MIN || !periph->range.max) in clk_sam9x5_peripheral_round_rate()
349 if (periph->range.max) { in clk_sam9x5_peripheral_round_rate()
352 if (cur_rate <= periph->range.max) in clk_sam9x5_peripheral_round_rate()
386 struct clk_sam9x5_peripheral *periph = to_clk_sam9x5_peripheral(hw); in clk_sam9x5_peripheral_set_rate() local
387 if (periph->id < PERIPHERAL_ID_MIN || !periph->range.max) { in clk_sam9x5_peripheral_set_rate()
394 if (periph->range.max && rate > periph->range.max) in clk_sam9x5_peripheral_set_rate()
399 periph->auto_div = false; in clk_sam9x5_peripheral_set_rate()
400 periph->div = shift; in clk_sam9x5_peripheral_set_rate()
410 struct clk_sam9x5_peripheral *periph = to_clk_sam9x5_peripheral(hw); in clk_sam9x5_peripheral_save_context() local
412 periph->pms.status = clk_sam9x5_peripheral_is_enabled(hw); in clk_sam9x5_peripheral_save_context()
419 struct clk_sam9x5_peripheral *periph = to_clk_sam9x5_peripheral(hw); in clk_sam9x5_peripheral_restore_context() local
421 if (periph->pms.status) in clk_sam9x5_peripheral_restore_context()
422 clk_sam9x5_peripheral_set(periph, periph->pms.status); in clk_sam9x5_peripheral_restore_context()
455 struct clk_sam9x5_peripheral *periph; in at91_clk_register_sam9x5_peripheral() local
463 periph = kzalloc(sizeof(*periph), GFP_KERNEL); in at91_clk_register_sam9x5_peripheral()
464 if (!periph) in at91_clk_register_sam9x5_peripheral()
482 periph->id = id; in at91_clk_register_sam9x5_peripheral()
483 periph->hw.init = &init; in at91_clk_register_sam9x5_peripheral()
484 periph->div = 0; in at91_clk_register_sam9x5_peripheral()
485 periph->regmap = regmap; in at91_clk_register_sam9x5_peripheral()
486 periph->lock = lock; in at91_clk_register_sam9x5_peripheral()
488 periph->auto_div = true; in at91_clk_register_sam9x5_peripheral()
489 periph->layout = layout; in at91_clk_register_sam9x5_peripheral()
490 periph->range = *range; in at91_clk_register_sam9x5_peripheral()
491 periph->chg_pid = chg_pid; in at91_clk_register_sam9x5_peripheral()
493 hw = &periph->hw; in at91_clk_register_sam9x5_peripheral()
494 ret = clk_hw_register(NULL, &periph->hw); in at91_clk_register_sam9x5_peripheral()
496 kfree(periph); in at91_clk_register_sam9x5_peripheral()
499 clk_sam9x5_peripheral_autodiv(periph); in at91_clk_register_sam9x5_peripheral()