@@ -56,19 +56,11 @@ struct mpfs_cfg_hw_clock {
5656 u32 reg_offset ;
5757};
5858
59- struct mpfs_periph_clock {
60- void __iomem * reg ;
61- u8 shift ;
62- };
63-
6459struct mpfs_periph_hw_clock {
65- struct mpfs_periph_clock periph ;
66- struct clk_hw hw ;
60+ struct clk_gate periph ;
6761 unsigned int id ;
6862};
6963
70- #define to_mpfs_periph_clk (_hw ) container_of(_hw, struct mpfs_periph_hw_clock, hw)
71-
7264/*
7365 * mpfs_clk_lock prevents anything else from writing to the
7466 * mpfs clk block while a software locked register is being written.
@@ -276,64 +268,12 @@ static int mpfs_clk_register_cfgs(struct device *dev, struct mpfs_cfg_hw_clock *
276268 * peripheral clocks - devices connected to axi or ahb buses.
277269 */
278270
279- static int mpfs_periph_clk_enable (struct clk_hw * hw )
280- {
281- struct mpfs_periph_hw_clock * periph_hw = to_mpfs_periph_clk (hw );
282- struct mpfs_periph_clock * periph = & periph_hw -> periph ;
283- u32 reg , val ;
284- unsigned long flags ;
285-
286- spin_lock_irqsave (& mpfs_clk_lock , flags );
287-
288- reg = readl_relaxed (periph -> reg );
289- val = reg | (1u << periph -> shift );
290- writel_relaxed (val , periph -> reg );
291-
292- spin_unlock_irqrestore (& mpfs_clk_lock , flags );
293-
294- return 0 ;
295- }
296-
297- static void mpfs_periph_clk_disable (struct clk_hw * hw )
298- {
299- struct mpfs_periph_hw_clock * periph_hw = to_mpfs_periph_clk (hw );
300- struct mpfs_periph_clock * periph = & periph_hw -> periph ;
301- u32 reg , val ;
302- unsigned long flags ;
303-
304- spin_lock_irqsave (& mpfs_clk_lock , flags );
305-
306- reg = readl_relaxed (periph -> reg );
307- val = reg & ~(1u << periph -> shift );
308- writel_relaxed (val , periph -> reg );
309-
310- spin_unlock_irqrestore (& mpfs_clk_lock , flags );
311- }
312-
313- static int mpfs_periph_clk_is_enabled (struct clk_hw * hw )
314- {
315- struct mpfs_periph_hw_clock * periph_hw = to_mpfs_periph_clk (hw );
316- struct mpfs_periph_clock * periph = & periph_hw -> periph ;
317- u32 reg ;
318-
319- reg = readl_relaxed (periph -> reg );
320- if (reg & (1u << periph -> shift ))
321- return 1 ;
322-
323- return 0 ;
324- }
325-
326- static const struct clk_ops mpfs_periph_clk_ops = {
327- .enable = mpfs_periph_clk_enable ,
328- .disable = mpfs_periph_clk_disable ,
329- .is_enabled = mpfs_periph_clk_is_enabled ,
330- };
331-
332271#define CLK_PERIPH (_id , _name , _parent , _shift , _flags ) { \
333272 .id = _id, \
334- .periph.shift = _shift, \
335- .hw.init = CLK_HW_INIT_HW(_name, _parent, &mpfs_periph_clk_ops , \
273+ .periph.bit_idx = _shift, \
274+ .periph. hw.init = CLK_HW_INIT_HW(_name, _parent, &clk_gate_ops , \
336275 _flags), \
276+ .periph.lock = &mpfs_clk_lock, \
337277}
338278
339279#define PARENT_CLK (PARENT ) (&mpfs_cfg_clks[CLK_##PARENT##_OFFSET].cfg.hw)
@@ -394,13 +334,13 @@ static int mpfs_clk_register_periphs(struct device *dev, struct mpfs_periph_hw_c
394334 struct mpfs_periph_hw_clock * periph_hw = & periph_hws [i ];
395335
396336 periph_hw -> periph .reg = data -> base + REG_SUBBLK_CLOCK_CR ;
397- ret = devm_clk_hw_register (dev , & periph_hw -> hw );
337+ ret = devm_clk_hw_register (dev , & periph_hw -> periph . hw );
398338 if (ret )
399339 return dev_err_probe (dev , ret , "failed to register clock id: %d\n" ,
400340 periph_hw -> id );
401341
402342 id = periph_hws [i ].id ;
403- data -> hw_data .hws [id ] = & periph_hw -> hw ;
343+ data -> hw_data .hws [id ] = & periph_hw -> periph . hw ;
404344 }
405345
406346 return 0 ;
0 commit comments