3434#define CCU_DIV_CTL_CLKDIV_MASK (_width ) \
3535 GENMASK((_width) + CCU_DIV_CTL_CLKDIV_FLD - 1, CCU_DIV_CTL_CLKDIV_FLD)
3636#define CCU_DIV_CTL_LOCK_SHIFTED BIT(27)
37+ #define CCU_DIV_CTL_GATE_REF_BUF BIT(28)
3738#define CCU_DIV_CTL_LOCK_NORMAL BIT(31)
3839
39- #define CCU_DIV_RST_DELAY_US 1
4040#define CCU_DIV_LOCK_CHECK_RETRIES 50
4141
4242#define CCU_DIV_CLKDIV_MIN 0
@@ -170,6 +170,40 @@ static int ccu_div_gate_is_enabled(struct clk_hw *hw)
170170 return !!(val & CCU_DIV_CTL_EN );
171171}
172172
173+ static int ccu_div_buf_enable (struct clk_hw * hw )
174+ {
175+ struct ccu_div * div = to_ccu_div (hw );
176+ unsigned long flags ;
177+
178+ spin_lock_irqsave (& div -> lock , flags );
179+ regmap_update_bits (div -> sys_regs , div -> reg_ctl ,
180+ CCU_DIV_CTL_GATE_REF_BUF , 0 );
181+ spin_unlock_irqrestore (& div -> lock , flags );
182+
183+ return 0 ;
184+ }
185+
186+ static void ccu_div_buf_disable (struct clk_hw * hw )
187+ {
188+ struct ccu_div * div = to_ccu_div (hw );
189+ unsigned long flags ;
190+
191+ spin_lock_irqsave (& div -> lock , flags );
192+ regmap_update_bits (div -> sys_regs , div -> reg_ctl ,
193+ CCU_DIV_CTL_GATE_REF_BUF , CCU_DIV_CTL_GATE_REF_BUF );
194+ spin_unlock_irqrestore (& div -> lock , flags );
195+ }
196+
197+ static int ccu_div_buf_is_enabled (struct clk_hw * hw )
198+ {
199+ struct ccu_div * div = to_ccu_div (hw );
200+ u32 val = 0 ;
201+
202+ regmap_read (div -> sys_regs , div -> reg_ctl , & val );
203+
204+ return !(val & CCU_DIV_CTL_GATE_REF_BUF );
205+ }
206+
173207static unsigned long ccu_div_var_recalc_rate (struct clk_hw * hw ,
174208 unsigned long parent_rate )
175209{
@@ -288,24 +322,6 @@ static int ccu_div_fixed_set_rate(struct clk_hw *hw, unsigned long rate,
288322 return 0 ;
289323}
290324
291- int ccu_div_reset_domain (struct ccu_div * div )
292- {
293- unsigned long flags ;
294-
295- if (!div || !(div -> features & CCU_DIV_RESET_DOMAIN ))
296- return - EINVAL ;
297-
298- spin_lock_irqsave (& div -> lock , flags );
299- regmap_update_bits (div -> sys_regs , div -> reg_ctl ,
300- CCU_DIV_CTL_RST , CCU_DIV_CTL_RST );
301- spin_unlock_irqrestore (& div -> lock , flags );
302-
303- /* The next delay must be enough to cover all the resets. */
304- udelay (CCU_DIV_RST_DELAY_US );
305-
306- return 0 ;
307- }
308-
309325#ifdef CONFIG_DEBUG_FS
310326
311327struct ccu_div_dbgfs_bit {
@@ -323,6 +339,7 @@ static const struct ccu_div_dbgfs_bit ccu_div_bits[] = {
323339 CCU_DIV_DBGFS_BIT_ATTR ("div_en" , CCU_DIV_CTL_EN ),
324340 CCU_DIV_DBGFS_BIT_ATTR ("div_rst" , CCU_DIV_CTL_RST ),
325341 CCU_DIV_DBGFS_BIT_ATTR ("div_bypass" , CCU_DIV_CTL_SET_CLKDIV ),
342+ CCU_DIV_DBGFS_BIT_ATTR ("div_buf" , CCU_DIV_CTL_GATE_REF_BUF ),
326343 CCU_DIV_DBGFS_BIT_ATTR ("div_lock" , CCU_DIV_CTL_LOCK_NORMAL )
327344};
328345
@@ -441,6 +458,9 @@ static void ccu_div_var_debug_init(struct clk_hw *hw, struct dentry *dentry)
441458 continue ;
442459 }
443460
461+ if (!strcmp ("div_buf" , name ))
462+ continue ;
463+
444464 bits [didx ] = ccu_div_bits [bidx ];
445465 bits [didx ].div = div ;
446466
@@ -477,6 +497,21 @@ static void ccu_div_gate_debug_init(struct clk_hw *hw, struct dentry *dentry)
477497 & ccu_div_dbgfs_fixed_clkdiv_fops );
478498}
479499
500+ static void ccu_div_buf_debug_init (struct clk_hw * hw , struct dentry * dentry )
501+ {
502+ struct ccu_div * div = to_ccu_div (hw );
503+ struct ccu_div_dbgfs_bit * bit ;
504+
505+ bit = kmalloc (sizeof (* bit ), GFP_KERNEL );
506+ if (!bit )
507+ return ;
508+
509+ * bit = ccu_div_bits [3 ];
510+ bit -> div = div ;
511+ debugfs_create_file_unsafe (bit -> name , ccu_div_dbgfs_mode , dentry , bit ,
512+ & ccu_div_dbgfs_bit_fops );
513+ }
514+
480515static void ccu_div_fixed_debug_init (struct clk_hw * hw , struct dentry * dentry )
481516{
482517 struct ccu_div * div = to_ccu_div (hw );
@@ -489,6 +524,7 @@ static void ccu_div_fixed_debug_init(struct clk_hw *hw, struct dentry *dentry)
489524
490525#define ccu_div_var_debug_init NULL
491526#define ccu_div_gate_debug_init NULL
527+ #define ccu_div_buf_debug_init NULL
492528#define ccu_div_fixed_debug_init NULL
493529
494530#endif /* !CONFIG_DEBUG_FS */
@@ -520,6 +556,13 @@ static const struct clk_ops ccu_div_gate_ops = {
520556 .debug_init = ccu_div_gate_debug_init
521557};
522558
559+ static const struct clk_ops ccu_div_buf_ops = {
560+ .enable = ccu_div_buf_enable ,
561+ .disable = ccu_div_buf_disable ,
562+ .is_enabled = ccu_div_buf_is_enabled ,
563+ .debug_init = ccu_div_buf_debug_init
564+ };
565+
523566static const struct clk_ops ccu_div_fixed_ops = {
524567 .recalc_rate = ccu_div_fixed_recalc_rate ,
525568 .round_rate = ccu_div_fixed_round_rate ,
@@ -566,6 +609,8 @@ struct ccu_div *ccu_div_hw_register(const struct ccu_div_init_data *div_init)
566609 } else if (div_init -> type == CCU_DIV_GATE ) {
567610 hw_init .ops = & ccu_div_gate_ops ;
568611 div -> divider = div_init -> divider ;
612+ } else if (div_init -> type == CCU_DIV_BUF ) {
613+ hw_init .ops = & ccu_div_buf_ops ;
569614 } else if (div_init -> type == CCU_DIV_FIXED ) {
570615 hw_init .ops = & ccu_div_fixed_ops ;
571616 div -> divider = div_init -> divider ;
@@ -579,6 +624,7 @@ struct ccu_div *ccu_div_hw_register(const struct ccu_div_init_data *div_init)
579624 goto err_free_div ;
580625 }
581626 parent_data .fw_name = div_init -> parent_name ;
627+ parent_data .name = div_init -> parent_name ;
582628 hw_init .parent_data = & parent_data ;
583629 hw_init .num_parents = 1 ;
584630
0 commit comments