Lines Matching full:fd

53 static inline u32 clk_fd_readl(struct clk_fractional_divider *fd)  in clk_fd_readl()  argument
55 if (fd->flags & CLK_FRAC_DIVIDER_BIG_ENDIAN) in clk_fd_readl()
56 return ioread32be(fd->reg); in clk_fd_readl()
58 return readl(fd->reg); in clk_fd_readl()
61 static inline void clk_fd_writel(struct clk_fractional_divider *fd, u32 val) in clk_fd_writel() argument
63 if (fd->flags & CLK_FRAC_DIVIDER_BIG_ENDIAN) in clk_fd_writel()
64 iowrite32be(val, fd->reg); in clk_fd_writel()
66 writel(val, fd->reg); in clk_fd_writel()
71 struct clk_fractional_divider *fd = to_clk_fd(hw); in clk_fd_get_div() local
77 if (fd->lock) in clk_fd_get_div()
78 spin_lock_irqsave(fd->lock, flags); in clk_fd_get_div()
80 __acquire(fd->lock); in clk_fd_get_div()
82 val = clk_fd_readl(fd); in clk_fd_get_div()
84 if (fd->lock) in clk_fd_get_div()
85 spin_unlock_irqrestore(fd->lock, flags); in clk_fd_get_div()
87 __release(fd->lock); in clk_fd_get_div()
89 mmask = GENMASK(fd->mwidth - 1, 0) << fd->mshift; in clk_fd_get_div()
90 nmask = GENMASK(fd->nwidth - 1, 0) << fd->nshift; in clk_fd_get_div()
92 m = (val & mmask) >> fd->mshift; in clk_fd_get_div()
93 n = (val & nmask) >> fd->nshift; in clk_fd_get_div()
95 if (fd->flags & CLK_FRAC_DIVIDER_ZERO_BASED) { in clk_fd_get_div()
125 struct clk_fractional_divider *fd = to_clk_fd(hw); in clk_fractional_divider_general_approximation() local
131 * by (scale - fd->nwidth) bits. in clk_fractional_divider_general_approximation()
135 if (fd->flags & CLK_FRAC_DIVIDER_POWER_OF_TWO_PS) { in clk_fractional_divider_general_approximation()
138 if (scale > fd->nwidth) in clk_fractional_divider_general_approximation()
139 rate <<= scale - fd->nwidth; in clk_fractional_divider_general_approximation()
142 if (fd->flags & CLK_FRAC_DIVIDER_ZERO_BASED) { in clk_fractional_divider_general_approximation()
143 max_m = BIT(fd->mwidth); in clk_fractional_divider_general_approximation()
144 max_n = BIT(fd->nwidth); in clk_fractional_divider_general_approximation()
146 max_m = GENMASK(fd->mwidth - 1, 0); in clk_fractional_divider_general_approximation()
147 max_n = GENMASK(fd->nwidth - 1, 0); in clk_fractional_divider_general_approximation()
157 struct clk_fractional_divider *fd = to_clk_fd(hw); in clk_fd_round_rate() local
164 if (fd->approximation) in clk_fd_round_rate()
165 fd->approximation(hw, rate, parent_rate, &m, &n); in clk_fd_round_rate()
178 struct clk_fractional_divider *fd = to_clk_fd(hw); in clk_fd_set_rate() local
184 if (fd->flags & CLK_FRAC_DIVIDER_ZERO_BASED) { in clk_fd_set_rate()
185 max_m = BIT(fd->mwidth); in clk_fd_set_rate()
186 max_n = BIT(fd->nwidth); in clk_fd_set_rate()
188 max_m = GENMASK(fd->mwidth - 1, 0); in clk_fd_set_rate()
189 max_n = GENMASK(fd->nwidth - 1, 0); in clk_fd_set_rate()
193 if (fd->flags & CLK_FRAC_DIVIDER_ZERO_BASED) { in clk_fd_set_rate()
198 mmask = GENMASK(fd->mwidth - 1, 0) << fd->mshift; in clk_fd_set_rate()
199 nmask = GENMASK(fd->nwidth - 1, 0) << fd->nshift; in clk_fd_set_rate()
201 if (fd->lock) in clk_fd_set_rate()
202 spin_lock_irqsave(fd->lock, flags); in clk_fd_set_rate()
204 __acquire(fd->lock); in clk_fd_set_rate()
206 val = clk_fd_readl(fd); in clk_fd_set_rate()
208 val |= (m << fd->mshift) | (n << fd->nshift); in clk_fd_set_rate()
209 clk_fd_writel(fd, val); in clk_fd_set_rate()
211 if (fd->lock) in clk_fd_set_rate()
212 spin_unlock_irqrestore(fd->lock, flags); in clk_fd_set_rate()
214 __release(fd->lock); in clk_fd_set_rate()
266 struct clk_fractional_divider *fd; in clk_hw_register_fractional_divider() local
271 fd = kzalloc(sizeof(*fd), GFP_KERNEL); in clk_hw_register_fractional_divider()
272 if (!fd) in clk_hw_register_fractional_divider()
281 fd->reg = reg; in clk_hw_register_fractional_divider()
282 fd->mshift = mshift; in clk_hw_register_fractional_divider()
283 fd->mwidth = mwidth; in clk_hw_register_fractional_divider()
284 fd->nshift = nshift; in clk_hw_register_fractional_divider()
285 fd->nwidth = nwidth; in clk_hw_register_fractional_divider()
286 fd->flags = clk_divider_flags; in clk_hw_register_fractional_divider()
287 fd->lock = lock; in clk_hw_register_fractional_divider()
288 fd->hw.init = &init; in clk_hw_register_fractional_divider()
290 hw = &fd->hw; in clk_hw_register_fractional_divider()
293 kfree(fd); in clk_hw_register_fractional_divider()
319 struct clk_fractional_divider *fd; in clk_hw_unregister_fractional_divider() local
321 fd = to_clk_fd(hw); in clk_hw_unregister_fractional_divider()
324 kfree(fd); in clk_hw_unregister_fractional_divider()