Lines Matching refs:gate
350 __is_clk_gate_enabled(struct ccu_data *ccu, struct bcm_clk_gate *gate) in __is_clk_gate_enabled() argument
356 if (!gate_exists(gate)) in __is_clk_gate_enabled()
359 bit_mask = 1 << gate->status_bit; in __is_clk_gate_enabled()
360 reg_val = __ccu_read(ccu, gate->offset); in __is_clk_gate_enabled()
367 is_clk_gate_enabled(struct ccu_data *ccu, struct bcm_clk_gate *gate) in is_clk_gate_enabled() argument
373 if (!gate_exists(gate)) in is_clk_gate_enabled()
377 ret = __is_clk_gate_enabled(ccu, gate); in is_clk_gate_enabled()
388 __gate_commit(struct ccu_data *ccu, struct bcm_clk_gate *gate) in __gate_commit() argument
394 BUG_ON(!gate_exists(gate)); in __gate_commit()
395 if (!gate_is_sw_controllable(gate)) in __gate_commit()
398 reg_val = __ccu_read(ccu, gate->offset); in __gate_commit()
401 if (gate_is_hw_controllable(gate)) { in __gate_commit()
402 mask = (u32)1 << gate->hw_sw_sel_bit; in __gate_commit()
403 if (gate_is_sw_managed(gate)) in __gate_commit()
416 mask = (u32)1 << gate->en_bit; in __gate_commit()
417 if (gate_is_sw_managed(gate) && (enabled = gate_is_enabled(gate)) && in __gate_commit()
418 !gate_is_no_disable(gate)) in __gate_commit()
423 __ccu_write(ccu, gate->offset, reg_val); in __gate_commit()
426 if (!gate_is_sw_managed(gate)) in __gate_commit()
430 return __ccu_wait_bit(ccu, gate->offset, gate->status_bit, enabled); in __gate_commit()
439 static bool gate_init(struct ccu_data *ccu, struct bcm_clk_gate *gate) in gate_init() argument
441 if (!gate_exists(gate)) in gate_init()
443 return __gate_commit(ccu, gate); in gate_init()
453 __clk_gate(struct ccu_data *ccu, struct bcm_clk_gate *gate, bool enable) in __clk_gate() argument
457 if (!gate_exists(gate) || !gate_is_sw_managed(gate)) in __clk_gate()
460 if (!enable && gate_is_no_disable(gate)) { in __clk_gate()
466 if (enable == gate_is_enabled(gate)) in __clk_gate()
469 gate_flip_enabled(gate); in __clk_gate()
470 ret = __gate_commit(ccu, gate); in __clk_gate()
472 gate_flip_enabled(gate); /* Revert the change */ in __clk_gate()
479 struct bcm_clk_gate *gate, bool enable) in clk_gate() argument
488 if (!gate_exists(gate) || !gate_is_sw_managed(gate)) in clk_gate()
490 if (!enable && gate_is_no_disable(gate)) in clk_gate()
496 success = __clk_gate(ccu, gate, enable); in clk_gate()
583 static int __div_commit(struct ccu_data *ccu, struct bcm_clk_gate *gate, in __div_commit() argument
611 enabled = __is_clk_gate_enabled(ccu, gate); in __div_commit()
612 if (!enabled && !__clk_gate(ccu, gate, true)) { in __div_commit()
628 if (!enabled && !__clk_gate(ccu, gate, false)) in __div_commit()
639 static bool div_init(struct ccu_data *ccu, struct bcm_clk_gate *gate, in div_init() argument
644 return !__div_commit(ccu, gate, div, trig); in div_init()
647 static int divider_write(struct ccu_data *ccu, struct bcm_clk_gate *gate, in divider_write() argument
666 ret = __div_commit(ccu, gate, div, trig); in divider_write()
866 __sel_commit(struct ccu_data *ccu, struct bcm_clk_gate *gate, in __sel_commit() argument
898 enabled = __is_clk_gate_enabled(ccu, gate); in __sel_commit()
899 if (!enabled && !__clk_gate(ccu, gate, true)) in __sel_commit()
912 if (!enabled && !__clk_gate(ccu, gate, false)) in __sel_commit()
923 static bool sel_init(struct ccu_data *ccu, struct bcm_clk_gate *gate, in sel_init() argument
928 return !__sel_commit(ccu, gate, sel, trig); in sel_init()
936 static int selector_write(struct ccu_data *ccu, struct bcm_clk_gate *gate, in selector_write() argument
953 ret = __sel_commit(ccu, gate, sel, trig); in selector_write()
969 struct bcm_clk_gate *gate = &bcm_clk->u.peri->gate; in kona_peri_clk_enable() local
971 return clk_gate(bcm_clk->ccu, bcm_clk->init_data.name, gate, true); in kona_peri_clk_enable()
977 struct bcm_clk_gate *gate = &bcm_clk->u.peri->gate; in kona_peri_clk_disable() local
979 (void)clk_gate(bcm_clk->ccu, bcm_clk->init_data.name, gate, false); in kona_peri_clk_disable()
985 struct bcm_clk_gate *gate = &bcm_clk->u.peri->gate; in kona_peri_clk_is_enabled() local
987 return is_clk_gate_enabled(bcm_clk->ccu, gate) ? 1 : 0; in kona_peri_clk_is_enabled()
1096 ret = selector_write(bcm_clk->ccu, &data->gate, sel, trig, index); in kona_peri_clk_set_parent()
1160 ret = divider_write(bcm_clk->ccu, &data->gate, &data->div, in kona_peri_clk_set_rate()
1200 if (!gate_init(ccu, &peri->gate)) { in __peri_clk_init()
1208 if (!div_init(ccu, &peri->gate, &peri->div, &peri->trig)) { in __peri_clk_init()
1221 if (!div_init(ccu, &peri->gate, &peri->pre_div, trig)) { in __peri_clk_init()
1227 if (!sel_init(ccu, &peri->gate, &peri->sel, trig)) { in __peri_clk_init()