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()
102 struct clk_peripheral *periph; in at91_clk_register_peripheral() local
110 periph = kzalloc(sizeof(*periph), GFP_KERNEL); in at91_clk_register_peripheral()
111 if (!periph) in at91_clk_register_peripheral()
120 periph->id = id; in at91_clk_register_peripheral()
121 periph->hw.init = &init; in at91_clk_register_peripheral()
122 periph->regmap = regmap; in at91_clk_register_peripheral()
124 hw = &periph->hw; in at91_clk_register_peripheral()
125 ret = clk_hw_register(NULL, &periph->hw); in at91_clk_register_peripheral()
127 kfree(periph); in at91_clk_register_peripheral()
134 static void clk_sam9x5_peripheral_autodiv(struct clk_sam9x5_peripheral *periph) in clk_sam9x5_peripheral_autodiv() argument
140 if (!periph->auto_div) in clk_sam9x5_peripheral_autodiv()
143 if (periph->range.max) { in clk_sam9x5_peripheral_autodiv()
144 parent = clk_hw_get_parent_by_index(&periph->hw, 0); in clk_sam9x5_peripheral_autodiv()
150 if (parent_rate >> shift <= periph->range.max) in clk_sam9x5_peripheral_autodiv()
155 periph->auto_div = false; in clk_sam9x5_peripheral_autodiv()
156 periph->div = shift; in clk_sam9x5_peripheral_autodiv()
159 static int clk_sam9x5_peripheral_set(struct clk_sam9x5_peripheral *periph, in clk_sam9x5_peripheral_set() argument
165 if (periph->id < PERIPHERAL_ID_MIN) in clk_sam9x5_peripheral_set()
168 spin_lock_irqsave(periph->lock, flags); in clk_sam9x5_peripheral_set()
169 regmap_write(periph->regmap, periph->layout->offset, in clk_sam9x5_peripheral_set()
170 (periph->id & periph->layout->pid_mask)); in clk_sam9x5_peripheral_set()
171 regmap_update_bits(periph->regmap, periph->layout->offset, in clk_sam9x5_peripheral_set()
172 periph->layout->div_mask | periph->layout->cmd | in clk_sam9x5_peripheral_set()
174 field_prep(periph->layout->div_mask, periph->div) | in clk_sam9x5_peripheral_set()
175 periph->layout->cmd | enable); in clk_sam9x5_peripheral_set()
176 spin_unlock_irqrestore(periph->lock, flags); in clk_sam9x5_peripheral_set()
183 struct clk_sam9x5_peripheral *periph = to_clk_sam9x5_peripheral(hw); in clk_sam9x5_peripheral_enable() local
185 return clk_sam9x5_peripheral_set(periph, 1); in clk_sam9x5_peripheral_enable()
190 struct clk_sam9x5_peripheral *periph = to_clk_sam9x5_peripheral(hw); in clk_sam9x5_peripheral_disable() local
193 if (periph->id < PERIPHERAL_ID_MIN) in clk_sam9x5_peripheral_disable()
196 spin_lock_irqsave(periph->lock, flags); in clk_sam9x5_peripheral_disable()
197 regmap_write(periph->regmap, periph->layout->offset, in clk_sam9x5_peripheral_disable()
198 (periph->id & periph->layout->pid_mask)); in clk_sam9x5_peripheral_disable()
199 regmap_update_bits(periph->regmap, periph->layout->offset, in clk_sam9x5_peripheral_disable()
200 AT91_PMC_PCR_EN | periph->layout->cmd, in clk_sam9x5_peripheral_disable()
201 periph->layout->cmd); in clk_sam9x5_peripheral_disable()
202 spin_unlock_irqrestore(periph->lock, flags); in clk_sam9x5_peripheral_disable()
207 struct clk_sam9x5_peripheral *periph = to_clk_sam9x5_peripheral(hw); in clk_sam9x5_peripheral_is_enabled() local
211 if (periph->id < PERIPHERAL_ID_MIN) in clk_sam9x5_peripheral_is_enabled()
214 spin_lock_irqsave(periph->lock, flags); in clk_sam9x5_peripheral_is_enabled()
215 regmap_write(periph->regmap, periph->layout->offset, in clk_sam9x5_peripheral_is_enabled()
216 (periph->id & periph->layout->pid_mask)); in clk_sam9x5_peripheral_is_enabled()
217 regmap_read(periph->regmap, periph->layout->offset, &status); in clk_sam9x5_peripheral_is_enabled()
218 spin_unlock_irqrestore(periph->lock, flags); in clk_sam9x5_peripheral_is_enabled()
227 struct clk_sam9x5_peripheral *periph = to_clk_sam9x5_peripheral(hw); in clk_sam9x5_peripheral_recalc_rate() local
231 if (periph->id < PERIPHERAL_ID_MIN) in clk_sam9x5_peripheral_recalc_rate()
234 spin_lock_irqsave(periph->lock, flags); in clk_sam9x5_peripheral_recalc_rate()
235 regmap_write(periph->regmap, periph->layout->offset, in clk_sam9x5_peripheral_recalc_rate()
236 (periph->id & periph->layout->pid_mask)); in clk_sam9x5_peripheral_recalc_rate()
237 regmap_read(periph->regmap, periph->layout->offset, &status); in clk_sam9x5_peripheral_recalc_rate()
238 spin_unlock_irqrestore(periph->lock, flags); in clk_sam9x5_peripheral_recalc_rate()
241 periph->div = field_get(periph->layout->div_mask, status); in clk_sam9x5_peripheral_recalc_rate()
242 periph->auto_div = false; in clk_sam9x5_peripheral_recalc_rate()
244 clk_sam9x5_peripheral_autodiv(periph); in clk_sam9x5_peripheral_recalc_rate()
247 return parent_rate >> periph->div; in clk_sam9x5_peripheral_recalc_rate()
270 struct clk_sam9x5_peripheral *periph = to_clk_sam9x5_peripheral(hw); in clk_sam9x5_peripheral_determine_rate() local
279 if (periph->id < PERIPHERAL_ID_MIN || !periph->range.max) in clk_sam9x5_peripheral_determine_rate()
286 if (periph->range.max && tmp_rate > periph->range.max) in clk_sam9x5_peripheral_determine_rate()
296 if (periph->chg_pid < 0) in clk_sam9x5_peripheral_determine_rate()
300 parent = clk_hw_get_parent_by_index(hw, periph->chg_pid); in clk_sam9x5_peripheral_determine_rate()
318 (periph->range.max && best_rate > periph->range.max)) in clk_sam9x5_peripheral_determine_rate()
340 struct clk_sam9x5_peripheral *periph = to_clk_sam9x5_peripheral(hw); in clk_sam9x5_peripheral_round_rate() local
342 if (periph->id < PERIPHERAL_ID_MIN || !periph->range.max) in clk_sam9x5_peripheral_round_rate()
345 if (periph->range.max) { in clk_sam9x5_peripheral_round_rate()
348 if (cur_rate <= periph->range.max) in clk_sam9x5_peripheral_round_rate()
382 struct clk_sam9x5_peripheral *periph = to_clk_sam9x5_peripheral(hw); in clk_sam9x5_peripheral_set_rate() local
383 if (periph->id < PERIPHERAL_ID_MIN || !periph->range.max) { in clk_sam9x5_peripheral_set_rate()
390 if (periph->range.max && rate > periph->range.max) in clk_sam9x5_peripheral_set_rate()
395 periph->auto_div = false; in clk_sam9x5_peripheral_set_rate()
396 periph->div = shift; in clk_sam9x5_peripheral_set_rate()
406 struct clk_sam9x5_peripheral *periph = to_clk_sam9x5_peripheral(hw); in clk_sam9x5_peripheral_save_context() local
408 periph->pms.status = clk_sam9x5_peripheral_is_enabled(hw); in clk_sam9x5_peripheral_save_context()
415 struct clk_sam9x5_peripheral *periph = to_clk_sam9x5_peripheral(hw); in clk_sam9x5_peripheral_restore_context() local
417 if (periph->pms.status) in clk_sam9x5_peripheral_restore_context()
418 clk_sam9x5_peripheral_set(periph, periph->pms.status); in clk_sam9x5_peripheral_restore_context()
450 struct clk_sam9x5_peripheral *periph; in at91_clk_register_sam9x5_peripheral() local
458 periph = kzalloc(sizeof(*periph), GFP_KERNEL); in at91_clk_register_sam9x5_peripheral()
459 if (!periph) in at91_clk_register_sam9x5_peripheral()
474 periph->id = id; in at91_clk_register_sam9x5_peripheral()
475 periph->hw.init = &init; in at91_clk_register_sam9x5_peripheral()
476 periph->div = 0; in at91_clk_register_sam9x5_peripheral()
477 periph->regmap = regmap; in at91_clk_register_sam9x5_peripheral()
478 periph->lock = lock; in at91_clk_register_sam9x5_peripheral()
480 periph->auto_div = true; in at91_clk_register_sam9x5_peripheral()
481 periph->layout = layout; in at91_clk_register_sam9x5_peripheral()
482 periph->range = *range; in at91_clk_register_sam9x5_peripheral()
483 periph->chg_pid = chg_pid; in at91_clk_register_sam9x5_peripheral()
485 hw = &periph->hw; in at91_clk_register_sam9x5_peripheral()
486 ret = clk_hw_register(NULL, &periph->hw); in at91_clk_register_sam9x5_peripheral()
488 kfree(periph); in at91_clk_register_sam9x5_peripheral()
491 clk_sam9x5_peripheral_autodiv(periph); in at91_clk_register_sam9x5_peripheral()