Lines Matching +full:1 +full:br +full:- +full:10

1 // SPDX-License-Identifier: GPL-2.0
12 #include <linux/clk-provider.h>
15 #include "clk-branch.h"
17 static bool clk_branch_in_hwcg_mode(const struct clk_branch *br) in clk_branch_in_hwcg_mode() argument
21 if (!br->hwcg_reg) in clk_branch_in_hwcg_mode()
24 regmap_read(br->clkr.regmap, br->hwcg_reg, &val); in clk_branch_in_hwcg_mode()
26 return !!(val & BIT(br->hwcg_bit)); in clk_branch_in_hwcg_mode()
29 static bool clk_branch_check_halt(const struct clk_branch *br, bool enabling) in clk_branch_check_halt() argument
31 bool invert = (br->halt_check == BRANCH_HALT_ENABLE); in clk_branch_check_halt()
34 regmap_read(br->clkr.regmap, br->halt_reg, &val); in clk_branch_check_halt()
36 val &= BIT(br->halt_bit); in clk_branch_check_halt()
43 static bool clk_branch2_check_halt(const struct clk_branch *br, bool enabling) in clk_branch2_check_halt() argument
47 bool invert = (br->halt_check == BRANCH_HALT_ENABLE); in clk_branch2_check_halt()
52 regmap_read(br->clkr.regmap, br->halt_reg, &val); in clk_branch2_check_halt()
62 static int clk_branch_wait(const struct clk_branch *br, bool enabling, in clk_branch_wait() argument
65 bool voted = br->halt_check & BRANCH_VOTED; in clk_branch_wait()
66 const char *name = clk_hw_get_name(&br->clkr.hw); in clk_branch_wait()
72 if (br->halt_check == BRANCH_HALT_SKIP || clk_branch_in_hwcg_mode(br)) in clk_branch_wait()
75 if (br->halt_check == BRANCH_HALT_DELAY || (!enabling && voted)) { in clk_branch_wait()
76 udelay(10); in clk_branch_wait()
77 } else if (br->halt_check == BRANCH_HALT_ENABLE || in clk_branch_wait()
78 br->halt_check == BRANCH_HALT || in clk_branch_wait()
82 while (count-- > 0) { in clk_branch_wait()
83 if (check_halt(br, enabling)) in clk_branch_wait()
85 udelay(1); in clk_branch_wait()
87 WARN(1, "%s status stuck at 'o%s'", name, in clk_branch_wait()
89 return -EBUSY; in clk_branch_wait()
97 struct clk_branch *br = to_clk_branch(hw); in clk_branch_toggle() local
108 return clk_branch_wait(br, en, check_halt); in clk_branch_toggle()
141 struct clk_branch branch = mem_br->branch; in clk_branch2_mem_enable()
145 regmap_update_bits(branch.clkr.regmap, mem_br->mem_enable_reg, in clk_branch2_mem_enable()
146 mem_br->mem_enable_ack_mask, mem_br->mem_enable_ack_mask); in clk_branch2_mem_enable()
148 ret = regmap_read_poll_timeout(branch.clkr.regmap, mem_br->mem_ack_reg, in clk_branch2_mem_enable()
149 val, val & mem_br->mem_enable_ack_mask, 0, 200); in clk_branch2_mem_enable()
151 WARN(1, "%s mem enable failed\n", clk_hw_get_name(&branch.clkr.hw)); in clk_branch2_mem_enable()
162 regmap_update_bits(mem_br->branch.clkr.regmap, mem_br->mem_enable_reg, in clk_branch2_mem_disable()
163 mem_br->mem_enable_ack_mask, 0); in clk_branch2_mem_disable()