@@ -49,24 +49,13 @@ struct mpfs_msspll_hw_clock {
49
49
50
50
#define to_mpfs_msspll_clk (_hw ) container_of(_hw, struct mpfs_msspll_hw_clock, hw)
51
51
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
-
60
52
struct mpfs_cfg_hw_clock {
61
- struct mpfs_cfg_clock cfg ;
62
- struct clk_hw hw ;
53
+ struct clk_divider cfg ;
63
54
struct clk_init_data init ;
64
55
unsigned int id ;
65
56
u32 reg_offset ;
66
57
};
67
58
68
- #define to_mpfs_cfg_clk (_hw ) container_of(_hw, struct mpfs_cfg_hw_clock, hw)
69
-
70
59
struct mpfs_periph_clock {
71
60
void __iomem * reg ;
72
61
u8 shift ;
@@ -226,64 +215,15 @@ static int mpfs_clk_register_mssplls(struct device *dev, struct mpfs_msspll_hw_c
226
215
* "CFG" clocks
227
216
*/
228
217
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
-
279
218
#define CLK_CFG (_id , _name , _parent , _shift , _width , _table , _flags , _offset ) { \
280
219
.id = _id, \
281
220
.cfg.shift = _shift, \
282
221
.cfg.width = _width, \
283
222
.cfg.table = _table, \
284
223
.reg_offset = _offset, \
285
224
.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, \
287
227
}
288
228
289
229
#define CLK_CPU_OFFSET 0u
@@ -305,8 +245,8 @@ static struct mpfs_cfg_hw_clock mpfs_cfg_clks[] = {
305
245
.cfg .table = mpfs_div_rtcref_table ,
306
246
.reg_offset = REG_RTC_CLOCK_CR ,
307
247
.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 ),
310
250
}
311
251
};
312
252
@@ -320,13 +260,13 @@ static int mpfs_clk_register_cfgs(struct device *dev, struct mpfs_cfg_hw_clock *
320
260
struct mpfs_cfg_hw_clock * cfg_hw = & cfg_hws [i ];
321
261
322
262
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 );
324
264
if (ret )
325
265
return dev_err_probe (dev , ret , "failed to register clock id: %d\n" ,
326
266
cfg_hw -> id );
327
267
328
268
id = cfg_hw -> id ;
329
- data -> hw_data .hws [id ] = & cfg_hw -> hw ;
269
+ data -> hw_data .hws [id ] = & cfg_hw -> cfg . hw ;
330
270
}
331
271
332
272
return 0 ;
@@ -396,7 +336,7 @@ static const struct clk_ops mpfs_periph_clk_ops = {
396
336
_flags), \
397
337
}
398
338
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)
400
340
401
341
/*
402
342
* Critical clocks:
0 commit comments