@@ -49,24 +49,13 @@ struct mpfs_msspll_hw_clock {
4949
5050#define to_mpfs_msspll_clk (_hw ) container_of(_hw, struct mpfs_msspll_hw_clock, hw)
5151
52- struct mpfs_cfg_clock {
53- void __iomem * reg ;
54- const struct clk_div_table * table ;
55- u8 shift ;
56- u8 width ;
57- u8 flags ;
58- };
59-
6052struct mpfs_cfg_hw_clock {
61- struct mpfs_cfg_clock cfg ;
62- struct clk_hw hw ;
53+ struct clk_divider cfg ;
6354 struct clk_init_data init ;
6455 unsigned int id ;
6556 u32 reg_offset ;
6657};
6758
68- #define to_mpfs_cfg_clk (_hw ) container_of(_hw, struct mpfs_cfg_hw_clock, hw)
69-
7059struct mpfs_periph_clock {
7160 void __iomem * reg ;
7261 u8 shift ;
@@ -226,64 +215,15 @@ static int mpfs_clk_register_mssplls(struct device *dev, struct mpfs_msspll_hw_c
226215 * "CFG" clocks
227216 */
228217
229- static unsigned long mpfs_cfg_clk_recalc_rate (struct clk_hw * hw , unsigned long prate )
230- {
231- struct mpfs_cfg_hw_clock * cfg_hw = to_mpfs_cfg_clk (hw );
232- struct mpfs_cfg_clock * cfg = & cfg_hw -> cfg ;
233- u32 val ;
234-
235- val = readl_relaxed (cfg -> reg ) >> cfg -> shift ;
236- val &= clk_div_mask (cfg -> width );
237-
238- return divider_recalc_rate (hw , prate , val , cfg -> table , cfg -> flags , cfg -> width );
239- }
240-
241- static long mpfs_cfg_clk_round_rate (struct clk_hw * hw , unsigned long rate , unsigned long * prate )
242- {
243- struct mpfs_cfg_hw_clock * cfg_hw = to_mpfs_cfg_clk (hw );
244- struct mpfs_cfg_clock * cfg = & cfg_hw -> cfg ;
245-
246- return divider_round_rate (hw , rate , prate , cfg -> table , cfg -> width , 0 );
247- }
248-
249- static int mpfs_cfg_clk_set_rate (struct clk_hw * hw , unsigned long rate , unsigned long prate )
250- {
251- struct mpfs_cfg_hw_clock * cfg_hw = to_mpfs_cfg_clk (hw );
252- struct mpfs_cfg_clock * cfg = & cfg_hw -> cfg ;
253- unsigned long flags ;
254- u32 val ;
255- int divider_setting ;
256-
257- divider_setting = divider_get_val (rate , prate , cfg -> table , cfg -> width , 0 );
258-
259- if (divider_setting < 0 )
260- return divider_setting ;
261-
262- spin_lock_irqsave (& mpfs_clk_lock , flags );
263- val = readl_relaxed (cfg -> reg );
264- val &= ~(clk_div_mask (cfg -> width ) << cfg_hw -> cfg .shift );
265- val |= divider_setting << cfg -> shift ;
266- writel_relaxed (val , cfg -> reg );
267-
268- spin_unlock_irqrestore (& mpfs_clk_lock , flags );
269-
270- return 0 ;
271- }
272-
273- static const struct clk_ops mpfs_clk_cfg_ops = {
274- .recalc_rate = mpfs_cfg_clk_recalc_rate ,
275- .round_rate = mpfs_cfg_clk_round_rate ,
276- .set_rate = mpfs_cfg_clk_set_rate ,
277- };
278-
279218#define CLK_CFG (_id , _name , _parent , _shift , _width , _table , _flags , _offset ) { \
280219 .id = _id, \
281220 .cfg.shift = _shift, \
282221 .cfg.width = _width, \
283222 .cfg.table = _table, \
284223 .reg_offset = _offset, \
285224 .cfg.flags = _flags, \
286- .hw.init = CLK_HW_INIT(_name, _parent, &mpfs_clk_cfg_ops, 0), \
225+ .cfg.hw.init = CLK_HW_INIT(_name, _parent, &clk_divider_ops, 0), \
226+ .cfg.lock = &mpfs_clk_lock, \
287227}
288228
289229#define CLK_CPU_OFFSET 0u
@@ -305,8 +245,8 @@ static struct mpfs_cfg_hw_clock mpfs_cfg_clks[] = {
305245 .cfg .table = mpfs_div_rtcref_table ,
306246 .reg_offset = REG_RTC_CLOCK_CR ,
307247 .cfg .flags = CLK_DIVIDER_ONE_BASED ,
308- .hw .init =
309- CLK_HW_INIT_PARENTS_DATA ("clk_rtcref" , mpfs_ext_ref , & mpfs_clk_cfg_ops , 0 ),
248+ .cfg . hw .init =
249+ CLK_HW_INIT_PARENTS_DATA ("clk_rtcref" , mpfs_ext_ref , & clk_divider_ops , 0 ),
310250 }
311251};
312252
@@ -320,13 +260,13 @@ static int mpfs_clk_register_cfgs(struct device *dev, struct mpfs_cfg_hw_clock *
320260 struct mpfs_cfg_hw_clock * cfg_hw = & cfg_hws [i ];
321261
322262 cfg_hw -> cfg .reg = data -> base + cfg_hw -> reg_offset ;
323- ret = devm_clk_hw_register (dev , & cfg_hw -> hw );
263+ ret = devm_clk_hw_register (dev , & cfg_hw -> cfg . hw );
324264 if (ret )
325265 return dev_err_probe (dev , ret , "failed to register clock id: %d\n" ,
326266 cfg_hw -> id );
327267
328268 id = cfg_hw -> id ;
329- data -> hw_data .hws [id ] = & cfg_hw -> hw ;
269+ data -> hw_data .hws [id ] = & cfg_hw -> cfg . hw ;
330270 }
331271
332272 return 0 ;
@@ -396,7 +336,7 @@ static const struct clk_ops mpfs_periph_clk_ops = {
396336 _flags), \
397337}
398338
399- #define PARENT_CLK (PARENT ) (&mpfs_cfg_clks[CLK_##PARENT##_OFFSET].hw)
339+ #define PARENT_CLK (PARENT ) (&mpfs_cfg_clks[CLK_##PARENT##_OFFSET].cfg. hw)
400340
401341/*
402342 * Critical clocks:
0 commit comments