Lines Matching refs:periph
59 struct clk_peripheral *periph = to_clk_peripheral(hw); in clk_peripheral_enable() local
61 u32 id = periph->id; in clk_peripheral_enable()
67 regmap_write(periph->regmap, offset, PERIPHERAL_MASK(id)); in clk_peripheral_enable()
74 struct clk_peripheral *periph = to_clk_peripheral(hw); in clk_peripheral_disable() local
76 u32 id = periph->id; in clk_peripheral_disable()
82 regmap_write(periph->regmap, offset, PERIPHERAL_MASK(id)); in clk_peripheral_disable()
87 struct clk_peripheral *periph = to_clk_peripheral(hw); in clk_peripheral_is_enabled() local
90 u32 id = periph->id; in clk_peripheral_is_enabled()
96 regmap_read(periph->regmap, offset, &status); in clk_peripheral_is_enabled()
111 struct clk_peripheral *periph; in at91_clk_register_peripheral() local
119 periph = kzalloc(sizeof(*periph), GFP_KERNEL); in at91_clk_register_peripheral()
120 if (!periph) in at91_clk_register_peripheral()
129 periph->id = id; in at91_clk_register_peripheral()
130 periph->hw.init = &init; in at91_clk_register_peripheral()
131 periph->regmap = regmap; in at91_clk_register_peripheral()
133 hw = &periph->hw; in at91_clk_register_peripheral()
134 ret = clk_hw_register(NULL, &periph->hw); in at91_clk_register_peripheral()
136 kfree(periph); in at91_clk_register_peripheral()
143 static void clk_sam9x5_peripheral_autodiv(struct clk_sam9x5_peripheral *periph) in clk_sam9x5_peripheral_autodiv() argument
149 if (!periph->auto_div) in clk_sam9x5_peripheral_autodiv()
152 if (periph->range.max) { in clk_sam9x5_peripheral_autodiv()
153 parent = clk_hw_get_parent_by_index(&periph->hw, 0); in clk_sam9x5_peripheral_autodiv()
159 if (parent_rate >> shift <= periph->range.max) in clk_sam9x5_peripheral_autodiv()
164 periph->auto_div = false; in clk_sam9x5_peripheral_autodiv()
165 periph->div = shift; in clk_sam9x5_peripheral_autodiv()
170 struct clk_sam9x5_peripheral *periph = to_clk_sam9x5_peripheral(hw); in clk_sam9x5_peripheral_enable() local
173 if (periph->id < PERIPHERAL_ID_MIN) in clk_sam9x5_peripheral_enable()
176 spin_lock_irqsave(periph->lock, flags); in clk_sam9x5_peripheral_enable()
177 regmap_write(periph->regmap, AT91_PMC_PCR, in clk_sam9x5_peripheral_enable()
178 (periph->id & AT91_PMC_PCR_PID_MASK)); in clk_sam9x5_peripheral_enable()
179 regmap_update_bits(periph->regmap, AT91_PMC_PCR, in clk_sam9x5_peripheral_enable()
182 AT91_PMC_PCR_DIV(periph->div) | in clk_sam9x5_peripheral_enable()
185 spin_unlock_irqrestore(periph->lock, flags); in clk_sam9x5_peripheral_enable()
192 struct clk_sam9x5_peripheral *periph = to_clk_sam9x5_peripheral(hw); in clk_sam9x5_peripheral_disable() local
195 if (periph->id < PERIPHERAL_ID_MIN) in clk_sam9x5_peripheral_disable()
198 spin_lock_irqsave(periph->lock, flags); in clk_sam9x5_peripheral_disable()
199 regmap_write(periph->regmap, AT91_PMC_PCR, in clk_sam9x5_peripheral_disable()
200 (periph->id & AT91_PMC_PCR_PID_MASK)); in clk_sam9x5_peripheral_disable()
201 regmap_update_bits(periph->regmap, AT91_PMC_PCR, in clk_sam9x5_peripheral_disable()
204 spin_unlock_irqrestore(periph->lock, flags); in clk_sam9x5_peripheral_disable()
209 struct clk_sam9x5_peripheral *periph = to_clk_sam9x5_peripheral(hw); in clk_sam9x5_peripheral_is_enabled() local
213 if (periph->id < PERIPHERAL_ID_MIN) in clk_sam9x5_peripheral_is_enabled()
216 spin_lock_irqsave(periph->lock, flags); in clk_sam9x5_peripheral_is_enabled()
217 regmap_write(periph->regmap, AT91_PMC_PCR, in clk_sam9x5_peripheral_is_enabled()
218 (periph->id & AT91_PMC_PCR_PID_MASK)); in clk_sam9x5_peripheral_is_enabled()
219 regmap_read(periph->regmap, AT91_PMC_PCR, &status); in clk_sam9x5_peripheral_is_enabled()
220 spin_unlock_irqrestore(periph->lock, flags); in clk_sam9x5_peripheral_is_enabled()
229 struct clk_sam9x5_peripheral *periph = to_clk_sam9x5_peripheral(hw); in clk_sam9x5_peripheral_recalc_rate() local
233 if (periph->id < PERIPHERAL_ID_MIN) in clk_sam9x5_peripheral_recalc_rate()
236 spin_lock_irqsave(periph->lock, flags); in clk_sam9x5_peripheral_recalc_rate()
237 regmap_write(periph->regmap, AT91_PMC_PCR, in clk_sam9x5_peripheral_recalc_rate()
238 (periph->id & AT91_PMC_PCR_PID_MASK)); in clk_sam9x5_peripheral_recalc_rate()
239 regmap_read(periph->regmap, AT91_PMC_PCR, &status); in clk_sam9x5_peripheral_recalc_rate()
240 spin_unlock_irqrestore(periph->lock, flags); in clk_sam9x5_peripheral_recalc_rate()
243 periph->div = PERIPHERAL_RSHIFT(status); in clk_sam9x5_peripheral_recalc_rate()
244 periph->auto_div = false; in clk_sam9x5_peripheral_recalc_rate()
246 clk_sam9x5_peripheral_autodiv(periph); in clk_sam9x5_peripheral_recalc_rate()
249 return parent_rate >> periph->div; in clk_sam9x5_peripheral_recalc_rate()
261 struct clk_sam9x5_peripheral *periph = to_clk_sam9x5_peripheral(hw); in clk_sam9x5_peripheral_round_rate() local
263 if (periph->id < PERIPHERAL_ID_MIN || !periph->range.max) in clk_sam9x5_peripheral_round_rate()
266 if (periph->range.max) { in clk_sam9x5_peripheral_round_rate()
269 if (cur_rate <= periph->range.max) in clk_sam9x5_peripheral_round_rate()
303 struct clk_sam9x5_peripheral *periph = to_clk_sam9x5_peripheral(hw); in clk_sam9x5_peripheral_set_rate() local
304 if (periph->id < PERIPHERAL_ID_MIN || !periph->range.max) { in clk_sam9x5_peripheral_set_rate()
311 if (periph->range.max && rate > periph->range.max) in clk_sam9x5_peripheral_set_rate()
316 periph->auto_div = false; in clk_sam9x5_peripheral_set_rate()
317 periph->div = shift; in clk_sam9x5_peripheral_set_rate()
339 struct clk_sam9x5_peripheral *periph; in at91_clk_register_sam9x5_peripheral() local
347 periph = kzalloc(sizeof(*periph), GFP_KERNEL); in at91_clk_register_sam9x5_peripheral()
348 if (!periph) in at91_clk_register_sam9x5_peripheral()
357 periph->id = id; in at91_clk_register_sam9x5_peripheral()
358 periph->hw.init = &init; in at91_clk_register_sam9x5_peripheral()
359 periph->div = 0; in at91_clk_register_sam9x5_peripheral()
360 periph->regmap = regmap; in at91_clk_register_sam9x5_peripheral()
361 periph->lock = lock; in at91_clk_register_sam9x5_peripheral()
362 periph->auto_div = true; in at91_clk_register_sam9x5_peripheral()
363 periph->range = *range; in at91_clk_register_sam9x5_peripheral()
365 hw = &periph->hw; in at91_clk_register_sam9x5_peripheral()
366 ret = clk_hw_register(NULL, &periph->hw); in at91_clk_register_sam9x5_peripheral()
368 kfree(periph); in at91_clk_register_sam9x5_peripheral()
371 clk_sam9x5_peripheral_autodiv(periph); in at91_clk_register_sam9x5_peripheral()