@@ -61,13 +61,10 @@ struct mpfs_msspll_hw_clock {
6161
6262struct mpfs_msspll_out_hw_clock {
6363 void __iomem * base ;
64- struct clk_hw hw ;
64+ struct clk_divider output ;
6565 struct clk_init_data init ;
6666 unsigned int id ;
6767 u32 reg_offset ;
68- u32 shift ;
69- u32 width ;
70- u32 flags ;
7168};
7269
7370#define to_mpfs_msspll_out_clk (_hw ) container_of(_hw, struct mpfs_msspll_out_hw_clock, hw)
@@ -177,75 +174,25 @@ static int mpfs_clk_register_mssplls(struct device *dev, struct mpfs_msspll_hw_c
177174 * MSS PLL output clocks
178175 */
179176
180- static unsigned long mpfs_clk_msspll_out_recalc_rate (struct clk_hw * hw , unsigned long prate )
181- {
182- struct mpfs_msspll_out_hw_clock * msspll_out_hw = to_mpfs_msspll_out_clk (hw );
183- void __iomem * postdiv_addr = msspll_out_hw -> base + msspll_out_hw -> reg_offset ;
184- u32 postdiv ;
185-
186- postdiv = readl_relaxed (postdiv_addr ) >> msspll_out_hw -> shift ;
187- postdiv &= clk_div_mask (msspll_out_hw -> width );
188-
189- return prate / postdiv ;
190- }
191-
192- static long mpfs_clk_msspll_out_round_rate (struct clk_hw * hw , unsigned long rate ,
193- unsigned long * prate )
194- {
195- struct mpfs_msspll_out_hw_clock * msspll_out_hw = to_mpfs_msspll_out_clk (hw );
196-
197- return divider_round_rate (hw , rate , prate , NULL , msspll_out_hw -> width ,
198- msspll_out_hw -> flags );
199- }
200-
201- static int mpfs_clk_msspll_out_set_rate (struct clk_hw * hw , unsigned long rate , unsigned long prate )
202- {
203- struct mpfs_msspll_out_hw_clock * msspll_out_hw = to_mpfs_msspll_out_clk (hw );
204- void __iomem * postdiv_addr = msspll_out_hw -> base + msspll_out_hw -> reg_offset ;
205- u32 postdiv ;
206- int divider_setting ;
207- unsigned long flags ;
208-
209- divider_setting = divider_get_val (rate , prate , NULL , msspll_out_hw -> width ,
210- msspll_out_hw -> flags );
211-
212- if (divider_setting < 0 )
213- return divider_setting ;
214-
215- spin_lock_irqsave (& mpfs_clk_lock , flags );
216-
217- postdiv = readl_relaxed (postdiv_addr );
218- postdiv &= ~(clk_div_mask (msspll_out_hw -> width ) << msspll_out_hw -> shift );
219- writel_relaxed (postdiv , postdiv_addr );
220-
221- spin_unlock_irqrestore (& mpfs_clk_lock , flags );
222-
223- return 0 ;
224- }
225-
226- static const struct clk_ops mpfs_clk_msspll_out_ops = {
227- .recalc_rate = mpfs_clk_msspll_out_recalc_rate ,
228- .round_rate = mpfs_clk_msspll_out_round_rate ,
229- .set_rate = mpfs_clk_msspll_out_set_rate ,
230- };
231-
232177#define CLK_PLL_OUT (_id , _name , _parent , _flags , _shift , _width , _offset ) { \
233178 .id = _id, \
234- .shift = _shift, \
235- .width = _width, \
179+ .output.shift = _shift, \
180+ .output.width = _width, \
181+ .output.table = NULL, \
236182 .reg_offset = _offset, \
237- .flags = _flags, \
238- .hw.init = CLK_HW_INIT(_name, _parent, &mpfs_clk_msspll_out_ops, 0), \
183+ .output.flags = _flags, \
184+ .output.hw.init = CLK_HW_INIT(_name, _parent, &clk_divider_ops, 0), \
185+ .output.lock = &mpfs_clk_lock, \
239186}
240187
241188static struct mpfs_msspll_out_hw_clock mpfs_msspll_out_clks [] = {
242- CLK_PLL_OUT (CLK_MSSPLL0 , "clk_msspll" , "clk_msspll_internal" , 0 ,
189+ CLK_PLL_OUT (CLK_MSSPLL0 , "clk_msspll" , "clk_msspll_internal" , CLK_DIVIDER_ONE_BASED ,
243190 MSSPLL_POSTDIV02_SHIFT , MSSPLL_POSTDIV_WIDTH , REG_MSSPLL_POSTDIV01_CR ),
244- CLK_PLL_OUT (CLK_MSSPLL1 , "clk_msspll1" , "clk_msspll_internal" , 0 ,
191+ CLK_PLL_OUT (CLK_MSSPLL1 , "clk_msspll1" , "clk_msspll_internal" , CLK_DIVIDER_ONE_BASED ,
245192 MSSPLL_POSTDIV13_SHIFT , MSSPLL_POSTDIV_WIDTH , REG_MSSPLL_POSTDIV01_CR ),
246- CLK_PLL_OUT (CLK_MSSPLL2 , "clk_msspll2" , "clk_msspll_internal" , 0 ,
193+ CLK_PLL_OUT (CLK_MSSPLL2 , "clk_msspll2" , "clk_msspll_internal" , CLK_DIVIDER_ONE_BASED ,
247194 MSSPLL_POSTDIV02_SHIFT , MSSPLL_POSTDIV_WIDTH , REG_MSSPLL_POSTDIV23_CR ),
248- CLK_PLL_OUT (CLK_MSSPLL3 , "clk_msspll3" , "clk_msspll_internal" , 0 ,
195+ CLK_PLL_OUT (CLK_MSSPLL3 , "clk_msspll3" , "clk_msspll_internal" , CLK_DIVIDER_ONE_BASED ,
249196 MSSPLL_POSTDIV13_SHIFT , MSSPLL_POSTDIV_WIDTH , REG_MSSPLL_POSTDIV23_CR ),
250197};
251198
@@ -259,13 +206,13 @@ static int mpfs_clk_register_msspll_outs(struct device *dev,
259206 for (i = 0 ; i < num_clks ; i ++ ) {
260207 struct mpfs_msspll_out_hw_clock * msspll_out_hw = & msspll_out_hws [i ];
261208
262- msspll_out_hw -> base = data -> msspll_base ;
263- ret = devm_clk_hw_register (dev , & msspll_out_hw -> hw );
209+ msspll_out_hw -> output . reg = data -> msspll_base + msspll_out_hw -> reg_offset ;
210+ ret = devm_clk_hw_register (dev , & msspll_out_hw -> output . hw );
264211 if (ret )
265212 return dev_err_probe (dev , ret , "failed to register msspll out id: %d\n" ,
266213 msspll_out_hw -> id );
267214
268- data -> hw_data .hws [msspll_out_hw -> id ] = & msspll_out_hw -> hw ;
215+ data -> hw_data .hws [msspll_out_hw -> id ] = & msspll_out_hw -> output . hw ;
269216 }
270217
271218 return 0 ;
0 commit comments