Lines Matching refs:id
59 struct clk_oscillator_data *clk_oscillator_get_data(struct stm32_clk_priv *priv, int id)
61 const struct clk_stm32 *clk = _clk_get(priv, id);
68 void clk_oscillator_set_bypass(struct stm32_clk_priv *priv, int id, bool digbyp, bool bypass)
70 struct clk_oscillator_data *osc_data = clk_oscillator_get_data(priv, id);
90 void clk_oscillator_set_css(struct stm32_clk_priv *priv, int id, bool css)
92 struct clk_oscillator_data *osc_data = clk_oscillator_get_data(priv, id);
108 void clk_oscillator_set_drive(struct stm32_clk_priv *priv, int id, uint8_t lsedrv)
110 struct clk_oscillator_data *osc_data = clk_oscillator_get_data(priv, id);
142 int clk_oscillator_wait_ready(struct stm32_clk_priv *priv, int id, bool ready_on)
144 struct clk_oscillator_data *osc_data = clk_oscillator_get_data(priv, id);
149 int clk_oscillator_wait_ready_on(struct stm32_clk_priv *priv, int id)
151 return clk_oscillator_wait_ready(priv, id, true);
154 int clk_oscillator_wait_ready_off(struct stm32_clk_priv *priv, int id)
156 return clk_oscillator_wait_ready(priv, id, false);
159 static int clk_gate_enable(struct stm32_clk_priv *priv, int id)
161 const struct clk_stm32 *clk = _clk_get(priv, id);
169 static void clk_gate_disable(struct stm32_clk_priv *priv, int id)
171 const struct clk_stm32 *clk = _clk_get(priv, id);
177 static bool clk_gate_is_enabled(struct stm32_clk_priv *priv, int id)
179 const struct clk_stm32 *clk = _clk_get(priv, id);
218 const struct clk_stm32 *_clk_get(struct stm32_clk_priv *priv, int id)
220 if ((unsigned int)id < priv->num) {
221 return &priv->clks[id];
465 unsigned long _clk_stm32_get_rate(struct stm32_clk_priv *priv, int id)
467 const struct clk_stm32 *clk = _clk_get(priv, id);
470 if ((unsigned int)id >= priv->num) {
474 parent = _clk_stm32_get_parent(priv, id);
486 return clk->ops->recalc_rate(priv, id, prate);
496 unsigned long _clk_stm32_get_parent_rate(struct stm32_clk_priv *priv, int id)
498 int parent_id = _clk_stm32_get_parent(priv, id);
507 static uint8_t _stm32_clk_get_flags(struct stm32_clk_priv *priv, int id)
509 return priv->clks[id].flags;
512 bool _stm32_clk_is_flags(struct stm32_clk_priv *priv, int id, uint8_t flag)
514 if ((_stm32_clk_get_flags(priv, id) & flag) != 0U) {
521 int clk_stm32_enable_call_ops(struct stm32_clk_priv *priv, uint16_t id)
523 const struct clk_stm32 *clk = _clk_get(priv, id);
526 clk->ops->enable(priv, id);
532 static int _clk_stm32_enable_core(struct stm32_clk_priv *priv, int id)
537 if (priv->gate_refcounts[id] == 0U) {
538 parent = _clk_stm32_get_parent(priv, id);
548 clk_stm32_enable_call_ops(priv, id);
551 priv->gate_refcounts[id]++;
553 if (priv->gate_refcounts[id] == UINT_MAX) {
554 ERROR("%s: %d max enable count !", __func__, id);
561 int _clk_stm32_enable(struct stm32_clk_priv *priv, int id)
566 ret = _clk_stm32_enable_core(priv, id);
572 void clk_stm32_disable_call_ops(struct stm32_clk_priv *priv, uint16_t id)
574 const struct clk_stm32 *clk = _clk_get(priv, id);
577 clk->ops->disable(priv, id);
581 static void _clk_stm32_disable_core(struct stm32_clk_priv *priv, int id)
585 if ((priv->gate_refcounts[id] == 1U) && _stm32_clk_is_flags(priv, id, CLK_IS_CRITICAL)) {
589 if (priv->gate_refcounts[id] == 0U) {
591 if (_clk_stm32_is_enabled(priv, id)) {
592 clk_stm32_disable_call_ops(priv, id);
595 VERBOSE("%s: %d already disabled !\n\n", __func__, id);
599 if (--priv->gate_refcounts[id] > 0U) {
603 clk_stm32_disable_call_ops(priv, id);
605 parent = _clk_stm32_get_parent(priv, id);
611 void _clk_stm32_disable(struct stm32_clk_priv *priv, int id)
615 _clk_stm32_disable_core(priv, id);
620 bool _clk_stm32_is_enabled(struct stm32_clk_priv *priv, int id)
622 const struct clk_stm32 *clk = _clk_get(priv, id);
625 return clk->ops->is_enabled(priv, id);
628 return priv->gate_refcounts[id];
634 int id;
636 id = clk_get_index(priv, binding_id);
637 if (id == -EINVAL) {
638 return id;
641 return _clk_stm32_enable(priv, id);
647 int id;
649 id = clk_get_index(priv, binding_id);
650 if (id != -EINVAL) {
651 _clk_stm32_disable(priv, id);
658 int id;
660 id = clk_get_index(priv, binding_id);
661 if (id == -EINVAL) {
665 return _clk_stm32_is_enabled(priv, id);
671 int id;
673 id = clk_get_index(priv, binding_id);
674 if (id == -EINVAL) {
678 return _clk_stm32_get_rate(priv, id);
684 int id;
686 id = clk_get_index(priv, binding_id);
687 if (id == -EINVAL) {
688 return id;
691 return _clk_stm32_get_parent(priv, id);
746 unsigned long clk_stm32_divider_recalc(struct stm32_clk_priv *priv, int id,
749 const struct clk_stm32 *clk = _clk_get(priv, id);
752 return _clk_stm32_divider_recalc(priv, div_cfg->id, prate);
822 int clk_stm32_gate_enable(struct stm32_clk_priv *priv, int id)
824 const struct clk_stm32 *clk = _clk_get(priv, id);
826 const struct gate_cfg *gate = &priv->gates[cfg->id];
839 void clk_stm32_gate_disable(struct stm32_clk_priv *priv, int id)
841 const struct clk_stm32 *clk = _clk_get(priv, id);
843 const struct gate_cfg *gate = &priv->gates[cfg->id];
864 bool clk_stm32_gate_is_enabled(struct stm32_clk_priv *priv, int id)
866 const struct clk_stm32 *clk = _clk_get(priv, id);
869 return _clk_stm32_gate_is_enabled(priv, cfg->id);
883 int id, unsigned long prate)
885 const struct clk_stm32 *clk = _clk_get(priv, id);
903 int id, unsigned long prate)
905 const struct clk_stm32 *clk = _clk_get(priv, id);
927 static unsigned long clk_fixed_rate_recalc(struct stm32_clk_priv *priv, int id,
930 const struct clk_stm32 *clk = _clk_get(priv, id);
941 int id, unsigned long prate)
943 struct clk_oscillator_data *osc_data = clk_oscillator_get_data(priv, id);
948 bool clk_stm32_osc_gate_is_enabled(struct stm32_clk_priv *priv, int id)
950 struct clk_oscillator_data *osc_data = clk_oscillator_get_data(priv, id);
956 int clk_stm32_osc_gate_enable(struct stm32_clk_priv *priv, int id)
958 struct clk_oscillator_data *osc_data = clk_oscillator_get_data(priv, id);
970 void clk_stm32_osc_gate_disable(struct stm32_clk_priv *priv, int id)
972 struct clk_oscillator_data *osc_data = clk_oscillator_get_data(priv, id);
1023 void clk_stm32_osc_init(struct stm32_clk_priv *priv, int id)
1025 struct clk_oscillator_data *osc_data = clk_oscillator_get_data(priv, id);