@@ -196,6 +196,17 @@ static const struct stratix10_pll_clock agilex_pll_clks[] = {
196196 0 , 0x9c },
197197};
198198
199+ static const struct n5x_perip_c_clock n5x_main_perip_c_clks [] = {
200+ { AGILEX_MAIN_PLL_C0_CLK , "main_pll_c0" , "main_pll" , NULL , 1 , 0 , 0x54 , 0 },
201+ { AGILEX_MAIN_PLL_C1_CLK , "main_pll_c1" , "main_pll" , NULL , 1 , 0 , 0x54 , 8 },
202+ { AGILEX_MAIN_PLL_C2_CLK , "main_pll_c2" , "main_pll" , NULL , 1 , 0 , 0x54 , 16 },
203+ { AGILEX_MAIN_PLL_C3_CLK , "main_pll_c3" , "main_pll" , NULL , 1 , 0 , 0x54 , 24 },
204+ { AGILEX_PERIPH_PLL_C0_CLK , "peri_pll_c0" , "periph_pll" , NULL , 1 , 0 , 0xA8 , 0 },
205+ { AGILEX_PERIPH_PLL_C1_CLK , "peri_pll_c1" , "periph_pll" , NULL , 1 , 0 , 0xA8 , 8 },
206+ { AGILEX_PERIPH_PLL_C2_CLK , "peri_pll_c2" , "periph_pll" , NULL , 1 , 0 , 0xA8 , 16 },
207+ { AGILEX_PERIPH_PLL_C3_CLK , "peri_pll_c3" , "periph_pll" , NULL , 1 , 0 , 0xA8 , 24 },
208+ };
209+
199210static const struct stratix10_perip_c_clock agilex_main_perip_c_clks [] = {
200211 { AGILEX_MAIN_PLL_C0_CLK , "main_pll_c0" , "main_pll" , NULL , 1 , 0 , 0x58 },
201212 { AGILEX_MAIN_PLL_C1_CLK , "main_pll_c1" , "main_pll" , NULL , 1 , 0 , 0x5C },
@@ -289,6 +300,25 @@ static const struct stratix10_gate_clock agilex_gate_clks[] = {
289300 10 , 0 , 0 , 0 , 0 , 0 , 4 },
290301};
291302
303+ static int n5x_clk_register_c_perip (const struct n5x_perip_c_clock * clks ,
304+ int nums , struct stratix10_clock_data * data )
305+ {
306+ struct clk * clk ;
307+ void __iomem * base = data -> base ;
308+ int i ;
309+
310+ for (i = 0 ; i < nums ; i ++ ) {
311+ clk = n5x_register_periph (& clks [i ], base );
312+ if (IS_ERR (clk )) {
313+ pr_err ("%s: failed to register clock %s\n" ,
314+ __func__ , clks [i ].name );
315+ continue ;
316+ }
317+ data -> clk_data .clks [clks [i ].id ] = clk ;
318+ }
319+ return 0 ;
320+ }
321+
292322static int agilex_clk_register_c_perip (const struct stratix10_perip_c_clock * clks ,
293323 int nums , struct stratix10_clock_data * data )
294324{
@@ -367,6 +397,26 @@ static int agilex_clk_register_pll(const struct stratix10_pll_clock *clks,
367397 return 0 ;
368398}
369399
400+ static int n5x_clk_register_pll (const struct stratix10_pll_clock * clks ,
401+ int nums , struct stratix10_clock_data * data )
402+ {
403+ struct clk * clk ;
404+ void __iomem * base = data -> base ;
405+ int i ;
406+
407+ for (i = 0 ; i < nums ; i ++ ) {
408+ clk = n5x_register_pll (& clks [i ], base );
409+ if (IS_ERR (clk )) {
410+ pr_err ("%s: failed to register clock %s\n" ,
411+ __func__ , clks [i ].name );
412+ continue ;
413+ }
414+ data -> clk_data .clks [clks [i ].id ] = clk ;
415+ }
416+
417+ return 0 ;
418+ }
419+
370420static struct stratix10_clock_data * __socfpga_agilex_clk_init (struct platform_device * pdev ,
371421 int nr_clks )
372422{
@@ -401,7 +451,7 @@ static struct stratix10_clock_data *__socfpga_agilex_clk_init(struct platform_de
401451 return clk_data ;
402452}
403453
404- static int agilex_clkmgr_probe (struct platform_device * pdev )
454+ static int agilex_clkmgr_init (struct platform_device * pdev )
405455{
406456 struct stratix10_clock_data * clk_data ;
407457
@@ -423,9 +473,43 @@ static int agilex_clkmgr_probe(struct platform_device *pdev)
423473 return 0 ;
424474}
425475
476+ static int n5x_clkmgr_init (struct platform_device * pdev )
477+ {
478+ struct stratix10_clock_data * clk_data ;
479+
480+ clk_data = __socfpga_agilex_clk_init (pdev , AGILEX_NUM_CLKS );
481+ if (IS_ERR (clk_data ))
482+ return PTR_ERR (clk_data );
483+
484+ n5x_clk_register_pll (agilex_pll_clks , ARRAY_SIZE (agilex_pll_clks ), clk_data );
485+
486+ n5x_clk_register_c_perip (n5x_main_perip_c_clks ,
487+ ARRAY_SIZE (n5x_main_perip_c_clks ), clk_data );
488+
489+ agilex_clk_register_cnt_perip (agilex_main_perip_cnt_clks ,
490+ ARRAY_SIZE (agilex_main_perip_cnt_clks ),
491+ clk_data );
492+
493+ agilex_clk_register_gate (agilex_gate_clks , ARRAY_SIZE (agilex_gate_clks ),
494+ clk_data );
495+ return 0 ;
496+ }
497+
498+ static int agilex_clkmgr_probe (struct platform_device * pdev )
499+ {
500+ int (* probe_func )(struct platform_device * init_func );
501+
502+ probe_func = of_device_get_match_data (& pdev -> dev );
503+ if (!probe_func )
504+ return - ENODEV ;
505+ return probe_func (pdev );
506+ }
507+
426508static const struct of_device_id agilex_clkmgr_match_table [] = {
427509 { .compatible = "intel,agilex-clkmgr" ,
428- .data = agilex_clkmgr_probe },
510+ .data = agilex_clkmgr_init },
511+ { .compatible = "intel,easic-n5x-clkmgr" ,
512+ .data = n5x_clkmgr_init },
429513 { }
430514};
431515
0 commit comments