Lines Matching refs:periph
48 struct clk_peripheral *periph = to_clk_peripheral(hw); in clk_peripheral_enable() local
50 u32 id = periph->id; in clk_peripheral_enable()
56 regmap_write(periph->regmap, offset, PERIPHERAL_MASK(id)); in clk_peripheral_enable()
63 struct clk_peripheral *periph = to_clk_peripheral(hw); in clk_peripheral_disable() local
65 u32 id = periph->id; in clk_peripheral_disable()
71 regmap_write(periph->regmap, offset, PERIPHERAL_MASK(id)); in clk_peripheral_disable()
76 struct clk_peripheral *periph = to_clk_peripheral(hw); in clk_peripheral_is_enabled() local
79 u32 id = periph->id; in clk_peripheral_is_enabled()
85 regmap_read(periph->regmap, offset, &status); in clk_peripheral_is_enabled()
100 struct clk_peripheral *periph; in at91_clk_register_peripheral() local
108 periph = kzalloc(sizeof(*periph), GFP_KERNEL); in at91_clk_register_peripheral()
109 if (!periph) in at91_clk_register_peripheral()
118 periph->id = id; in at91_clk_register_peripheral()
119 periph->hw.init = &init; in at91_clk_register_peripheral()
120 periph->regmap = regmap; in at91_clk_register_peripheral()
122 hw = &periph->hw; in at91_clk_register_peripheral()
123 ret = clk_hw_register(NULL, &periph->hw); in at91_clk_register_peripheral()
125 kfree(periph); in at91_clk_register_peripheral()
132 static void clk_sam9x5_peripheral_autodiv(struct clk_sam9x5_peripheral *periph) in clk_sam9x5_peripheral_autodiv() argument
138 if (!periph->auto_div) in clk_sam9x5_peripheral_autodiv()
141 if (periph->range.max) { in clk_sam9x5_peripheral_autodiv()
142 parent = clk_hw_get_parent_by_index(&periph->hw, 0); in clk_sam9x5_peripheral_autodiv()
148 if (parent_rate >> shift <= periph->range.max) in clk_sam9x5_peripheral_autodiv()
153 periph->auto_div = false; in clk_sam9x5_peripheral_autodiv()
154 periph->div = shift; in clk_sam9x5_peripheral_autodiv()
159 struct clk_sam9x5_peripheral *periph = to_clk_sam9x5_peripheral(hw); in clk_sam9x5_peripheral_enable() local
162 if (periph->id < PERIPHERAL_ID_MIN) in clk_sam9x5_peripheral_enable()
165 spin_lock_irqsave(periph->lock, flags); in clk_sam9x5_peripheral_enable()
166 regmap_write(periph->regmap, periph->layout->offset, in clk_sam9x5_peripheral_enable()
167 (periph->id & periph->layout->pid_mask)); in clk_sam9x5_peripheral_enable()
168 regmap_update_bits(periph->regmap, periph->layout->offset, in clk_sam9x5_peripheral_enable()
169 periph->layout->div_mask | periph->layout->cmd | in clk_sam9x5_peripheral_enable()
171 field_prep(periph->layout->div_mask, periph->div) | in clk_sam9x5_peripheral_enable()
172 periph->layout->cmd | in clk_sam9x5_peripheral_enable()
174 spin_unlock_irqrestore(periph->lock, flags); in clk_sam9x5_peripheral_enable()
181 struct clk_sam9x5_peripheral *periph = to_clk_sam9x5_peripheral(hw); in clk_sam9x5_peripheral_disable() local
184 if (periph->id < PERIPHERAL_ID_MIN) in clk_sam9x5_peripheral_disable()
187 spin_lock_irqsave(periph->lock, flags); in clk_sam9x5_peripheral_disable()
188 regmap_write(periph->regmap, periph->layout->offset, in clk_sam9x5_peripheral_disable()
189 (periph->id & periph->layout->pid_mask)); in clk_sam9x5_peripheral_disable()
190 regmap_update_bits(periph->regmap, periph->layout->offset, in clk_sam9x5_peripheral_disable()
191 AT91_PMC_PCR_EN | periph->layout->cmd, in clk_sam9x5_peripheral_disable()
192 periph->layout->cmd); in clk_sam9x5_peripheral_disable()
193 spin_unlock_irqrestore(periph->lock, flags); in clk_sam9x5_peripheral_disable()
198 struct clk_sam9x5_peripheral *periph = to_clk_sam9x5_peripheral(hw); in clk_sam9x5_peripheral_is_enabled() local
202 if (periph->id < PERIPHERAL_ID_MIN) in clk_sam9x5_peripheral_is_enabled()
205 spin_lock_irqsave(periph->lock, flags); in clk_sam9x5_peripheral_is_enabled()
206 regmap_write(periph->regmap, periph->layout->offset, in clk_sam9x5_peripheral_is_enabled()
207 (periph->id & periph->layout->pid_mask)); in clk_sam9x5_peripheral_is_enabled()
208 regmap_read(periph->regmap, periph->layout->offset, &status); in clk_sam9x5_peripheral_is_enabled()
209 spin_unlock_irqrestore(periph->lock, flags); in clk_sam9x5_peripheral_is_enabled()
218 struct clk_sam9x5_peripheral *periph = to_clk_sam9x5_peripheral(hw); in clk_sam9x5_peripheral_recalc_rate() local
222 if (periph->id < PERIPHERAL_ID_MIN) in clk_sam9x5_peripheral_recalc_rate()
225 spin_lock_irqsave(periph->lock, flags); in clk_sam9x5_peripheral_recalc_rate()
226 regmap_write(periph->regmap, periph->layout->offset, in clk_sam9x5_peripheral_recalc_rate()
227 (periph->id & periph->layout->pid_mask)); in clk_sam9x5_peripheral_recalc_rate()
228 regmap_read(periph->regmap, periph->layout->offset, &status); in clk_sam9x5_peripheral_recalc_rate()
229 spin_unlock_irqrestore(periph->lock, flags); in clk_sam9x5_peripheral_recalc_rate()
232 periph->div = field_get(periph->layout->div_mask, status); in clk_sam9x5_peripheral_recalc_rate()
233 periph->auto_div = false; in clk_sam9x5_peripheral_recalc_rate()
235 clk_sam9x5_peripheral_autodiv(periph); in clk_sam9x5_peripheral_recalc_rate()
238 return parent_rate >> periph->div; in clk_sam9x5_peripheral_recalc_rate()
250 struct clk_sam9x5_peripheral *periph = to_clk_sam9x5_peripheral(hw); in clk_sam9x5_peripheral_round_rate() local
252 if (periph->id < PERIPHERAL_ID_MIN || !periph->range.max) in clk_sam9x5_peripheral_round_rate()
255 if (periph->range.max) { in clk_sam9x5_peripheral_round_rate()
258 if (cur_rate <= periph->range.max) in clk_sam9x5_peripheral_round_rate()
292 struct clk_sam9x5_peripheral *periph = to_clk_sam9x5_peripheral(hw); in clk_sam9x5_peripheral_set_rate() local
293 if (periph->id < PERIPHERAL_ID_MIN || !periph->range.max) { in clk_sam9x5_peripheral_set_rate()
300 if (periph->range.max && rate > periph->range.max) in clk_sam9x5_peripheral_set_rate()
305 periph->auto_div = false; in clk_sam9x5_peripheral_set_rate()
306 periph->div = shift; in clk_sam9x5_peripheral_set_rate()
329 struct clk_sam9x5_peripheral *periph; in at91_clk_register_sam9x5_peripheral() local
337 periph = kzalloc(sizeof(*periph), GFP_KERNEL); in at91_clk_register_sam9x5_peripheral()
338 if (!periph) in at91_clk_register_sam9x5_peripheral()
347 periph->id = id; in at91_clk_register_sam9x5_peripheral()
348 periph->hw.init = &init; in at91_clk_register_sam9x5_peripheral()
349 periph->div = 0; in at91_clk_register_sam9x5_peripheral()
350 periph->regmap = regmap; in at91_clk_register_sam9x5_peripheral()
351 periph->lock = lock; in at91_clk_register_sam9x5_peripheral()
353 periph->auto_div = true; in at91_clk_register_sam9x5_peripheral()
354 periph->layout = layout; in at91_clk_register_sam9x5_peripheral()
355 periph->range = *range; in at91_clk_register_sam9x5_peripheral()
357 hw = &periph->hw; in at91_clk_register_sam9x5_peripheral()
358 ret = clk_hw_register(NULL, &periph->hw); in at91_clk_register_sam9x5_peripheral()
360 kfree(periph); in at91_clk_register_sam9x5_peripheral()
363 clk_sam9x5_peripheral_autodiv(periph); in at91_clk_register_sam9x5_peripheral()