• Home
  • Raw
  • Download

Lines Matching +full:reg +full:- +full:init

1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (C) 2010-2011 Canonical Ltd <jeremy.kerr@canonical.com>
4 * Copyright (C) 2011-2012 Mike Turquette, Linaro Ltd <mturquette@linaro.org>
9 #include <linux/clk-provider.h>
22 * prepare - clk_(un)prepare only ensures parent is (un)prepared
23 * enable - clk_enable and clk_disable are functional & control gating
24 * rate - inherits rate from parent. No clk_set_rate support
25 * parent - fixed parent. No clk_set_parent support
30 void __iomem *reg; member
43 u32 reg; in clk_gate2_enable() local
47 spin_lock_irqsave(gate->lock, flags); in clk_gate2_enable()
49 if (gate->share_count && (*gate->share_count)++ > 0) in clk_gate2_enable()
52 if (gate->flags & IMX_CLK_GATE2_SINGLE_BIT) { in clk_gate2_enable()
55 reg = readl(gate->reg); in clk_gate2_enable()
56 reg &= ~(3 << gate->bit_idx); in clk_gate2_enable()
57 reg |= gate->cgr_val << gate->bit_idx; in clk_gate2_enable()
58 writel(reg, gate->reg); in clk_gate2_enable()
62 spin_unlock_irqrestore(gate->lock, flags); in clk_gate2_enable()
70 u32 reg; in clk_gate2_disable() local
73 spin_lock_irqsave(gate->lock, flags); in clk_gate2_disable()
75 if (gate->share_count) { in clk_gate2_disable()
76 if (WARN_ON(*gate->share_count == 0)) in clk_gate2_disable()
78 else if (--(*gate->share_count) > 0) in clk_gate2_disable()
82 if (gate->flags & IMX_CLK_GATE2_SINGLE_BIT) { in clk_gate2_disable()
85 reg = readl(gate->reg); in clk_gate2_disable()
86 reg &= ~(3 << gate->bit_idx); in clk_gate2_disable()
87 writel(reg, gate->reg); in clk_gate2_disable()
91 spin_unlock_irqrestore(gate->lock, flags); in clk_gate2_disable()
94 static int clk_gate2_reg_is_enabled(void __iomem *reg, u8 bit_idx) in clk_gate2_reg_is_enabled() argument
96 u32 val = readl(reg); in clk_gate2_reg_is_enabled()
108 if (gate->flags & IMX_CLK_GATE2_SINGLE_BIT) in clk_gate2_is_enabled()
111 return clk_gate2_reg_is_enabled(gate->reg, gate->bit_idx); in clk_gate2_is_enabled()
118 u32 reg; in clk_gate2_disable_unused() local
120 if (gate->flags & IMX_CLK_GATE2_SINGLE_BIT) in clk_gate2_disable_unused()
123 spin_lock_irqsave(gate->lock, flags); in clk_gate2_disable_unused()
125 if (!gate->share_count || *gate->share_count == 0) { in clk_gate2_disable_unused()
126 reg = readl(gate->reg); in clk_gate2_disable_unused()
127 reg &= ~(3 << gate->bit_idx); in clk_gate2_disable_unused()
128 writel(reg, gate->reg); in clk_gate2_disable_unused()
131 spin_unlock_irqrestore(gate->lock, flags); in clk_gate2_disable_unused()
143 void __iomem *reg, u8 bit_idx, u8 cgr_val, in clk_hw_register_gate2() argument
149 struct clk_init_data init; in clk_hw_register_gate2() local
154 return ERR_PTR(-ENOMEM); in clk_hw_register_gate2()
157 gate->reg = reg; in clk_hw_register_gate2()
158 gate->bit_idx = bit_idx; in clk_hw_register_gate2()
159 gate->cgr_val = cgr_val; in clk_hw_register_gate2()
160 gate->flags = clk_gate2_flags; in clk_hw_register_gate2()
161 gate->lock = lock; in clk_hw_register_gate2()
162 gate->share_count = share_count; in clk_hw_register_gate2()
164 init.name = name; in clk_hw_register_gate2()
165 init.ops = &clk_gate2_ops; in clk_hw_register_gate2()
166 init.flags = flags; in clk_hw_register_gate2()
167 init.parent_names = parent_name ? &parent_name : NULL; in clk_hw_register_gate2()
168 init.num_parents = parent_name ? 1 : 0; in clk_hw_register_gate2()
170 gate->hw.init = &init; in clk_hw_register_gate2()
171 hw = &gate->hw; in clk_hw_register_gate2()