Lines Matching +full:init +full:- +full:delay
1 // SPDX-License-Identifier: GPL-2.0-only
9 #include <linux/clk-provider.h>
13 #include <linux/delay.h>
31 if (gate->lock) in mmp_clk_gate_enable()
32 spin_lock_irqsave(gate->lock, flags); in mmp_clk_gate_enable()
34 tmp = readl(gate->reg); in mmp_clk_gate_enable()
35 tmp &= ~gate->mask; in mmp_clk_gate_enable()
36 tmp |= gate->val_enable; in mmp_clk_gate_enable()
37 writel(tmp, gate->reg); in mmp_clk_gate_enable()
39 if (gate->lock) in mmp_clk_gate_enable()
40 spin_unlock_irqrestore(gate->lock, flags); in mmp_clk_gate_enable()
42 if (gate->flags & MMP_CLK_GATE_NEED_DELAY) { in mmp_clk_gate_enable()
44 /* Need delay 2 cycles. */ in mmp_clk_gate_enable()
57 if (gate->lock) in mmp_clk_gate_disable()
58 spin_lock_irqsave(gate->lock, flags); in mmp_clk_gate_disable()
60 tmp = readl(gate->reg); in mmp_clk_gate_disable()
61 tmp &= ~gate->mask; in mmp_clk_gate_disable()
62 tmp |= gate->val_disable; in mmp_clk_gate_disable()
63 writel(tmp, gate->reg); in mmp_clk_gate_disable()
65 if (gate->lock) in mmp_clk_gate_disable()
66 spin_unlock_irqrestore(gate->lock, flags); in mmp_clk_gate_disable()
75 if (gate->lock) in mmp_clk_gate_is_enabled()
76 spin_lock_irqsave(gate->lock, flags); in mmp_clk_gate_is_enabled()
78 tmp = readl(gate->reg); in mmp_clk_gate_is_enabled()
80 if (gate->lock) in mmp_clk_gate_is_enabled()
81 spin_unlock_irqrestore(gate->lock, flags); in mmp_clk_gate_is_enabled()
83 return (tmp & gate->mask) == gate->val_enable; in mmp_clk_gate_is_enabled()
99 struct clk_init_data init; in mmp_clk_register_gate() local
104 return ERR_PTR(-ENOMEM); in mmp_clk_register_gate()
106 init.name = name; in mmp_clk_register_gate()
107 init.ops = &mmp_clk_gate_ops; in mmp_clk_register_gate()
108 init.flags = flags; in mmp_clk_register_gate()
109 init.parent_names = (parent_name ? &parent_name : NULL); in mmp_clk_register_gate()
110 init.num_parents = (parent_name ? 1 : 0); in mmp_clk_register_gate()
113 gate->reg = reg; in mmp_clk_register_gate()
114 gate->mask = mask; in mmp_clk_register_gate()
115 gate->val_enable = val_enable; in mmp_clk_register_gate()
116 gate->val_disable = val_disable; in mmp_clk_register_gate()
117 gate->flags = gate_flags; in mmp_clk_register_gate()
118 gate->lock = lock; in mmp_clk_register_gate()
119 gate->hw.init = &init; in mmp_clk_register_gate()
121 clk = clk_register(dev, &gate->hw); in mmp_clk_register_gate()