@@ -78,7 +78,8 @@ struct en_clk_soc_data {
7878 const u16 * idx_map ;
7979 u16 idx_map_nr ;
8080 } reset ;
81- int (* hw_init )(struct platform_device * pdev , void __iomem * np_base );
81+ int (* hw_init )(struct platform_device * pdev ,
82+ struct clk_hw_onecell_data * clk_data );
8283};
8384
8485static const u32 gsw_base [] = { 400000000 , 500000000 };
@@ -406,20 +407,6 @@ static void en7581_pci_disable(struct clk_hw *hw)
406407 usleep_range (1000 , 2000 );
407408}
408409
409- static int en7581_clk_hw_init (struct platform_device * pdev ,
410- void __iomem * np_base )
411- {
412- u32 val ;
413-
414- val = readl (np_base + REG_NP_SCU_SSTR );
415- val &= ~(REG_PCIE_XSI0_SEL_MASK | REG_PCIE_XSI1_SEL_MASK );
416- writel (val , np_base + REG_NP_SCU_SSTR );
417- val = readl (np_base + REG_NP_SCU_PCIC );
418- writel (val | 3 , np_base + REG_NP_SCU_PCIC );
419-
420- return 0 ;
421- }
422-
423410static void en7523_register_clocks (struct device * dev , struct clk_hw_onecell_data * clk_data ,
424411 void __iomem * base , void __iomem * np_base )
425412{
@@ -449,6 +436,49 @@ static void en7523_register_clocks(struct device *dev, struct clk_hw_onecell_dat
449436 clk_data -> num = EN7523_NUM_CLOCKS ;
450437}
451438
439+ static int en7523_clk_hw_init (struct platform_device * pdev ,
440+ struct clk_hw_onecell_data * clk_data )
441+ {
442+ void __iomem * base , * np_base ;
443+
444+ base = devm_platform_ioremap_resource (pdev , 0 );
445+ if (IS_ERR (base ))
446+ return PTR_ERR (base );
447+
448+ np_base = devm_platform_ioremap_resource (pdev , 1 );
449+ if (IS_ERR (np_base ))
450+ return PTR_ERR (np_base );
451+
452+ en7523_register_clocks (& pdev -> dev , clk_data , base , np_base );
453+
454+ return 0 ;
455+ }
456+
457+ static int en7581_clk_hw_init (struct platform_device * pdev ,
458+ struct clk_hw_onecell_data * clk_data )
459+ {
460+ void __iomem * base , * np_base ;
461+ u32 val ;
462+
463+ base = devm_platform_ioremap_resource (pdev , 0 );
464+ if (IS_ERR (base ))
465+ return PTR_ERR (base );
466+
467+ np_base = devm_platform_ioremap_resource (pdev , 1 );
468+ if (IS_ERR (np_base ))
469+ return PTR_ERR (np_base );
470+
471+ en7523_register_clocks (& pdev -> dev , clk_data , base , np_base );
472+
473+ val = readl (np_base + REG_NP_SCU_SSTR );
474+ val &= ~(REG_PCIE_XSI0_SEL_MASK | REG_PCIE_XSI1_SEL_MASK );
475+ writel (val , np_base + REG_NP_SCU_SSTR );
476+ val = readl (np_base + REG_NP_SCU_PCIC );
477+ writel (val | 3 , np_base + REG_NP_SCU_PCIC );
478+
479+ return 0 ;
480+ }
481+
452482static int en7523_reset_update (struct reset_controller_dev * rcdev ,
453483 unsigned long id , bool assert )
454484{
@@ -543,31 +573,18 @@ static int en7523_clk_probe(struct platform_device *pdev)
543573 struct device_node * node = pdev -> dev .of_node ;
544574 const struct en_clk_soc_data * soc_data ;
545575 struct clk_hw_onecell_data * clk_data ;
546- void __iomem * base , * np_base ;
547576 int r ;
548577
549- base = devm_platform_ioremap_resource (pdev , 0 );
550- if (IS_ERR (base ))
551- return PTR_ERR (base );
552-
553- np_base = devm_platform_ioremap_resource (pdev , 1 );
554- if (IS_ERR (np_base ))
555- return PTR_ERR (np_base );
556-
557- soc_data = device_get_match_data (& pdev -> dev );
558- if (soc_data -> hw_init ) {
559- r = soc_data -> hw_init (pdev , np_base );
560- if (r )
561- return r ;
562- }
563-
564578 clk_data = devm_kzalloc (& pdev -> dev ,
565579 struct_size (clk_data , hws , EN7523_NUM_CLOCKS ),
566580 GFP_KERNEL );
567581 if (!clk_data )
568582 return - ENOMEM ;
569583
570- en7523_register_clocks (& pdev -> dev , clk_data , base , np_base );
584+ soc_data = device_get_match_data (& pdev -> dev );
585+ r = soc_data -> hw_init (pdev , clk_data );
586+ if (r )
587+ return r ;
571588
572589 r = of_clk_add_hw_provider (node , of_clk_hw_onecell_get , clk_data );
573590 if (r )
@@ -590,6 +607,7 @@ static const struct en_clk_soc_data en7523_data = {
590607 .prepare = en7523_pci_prepare ,
591608 .unprepare = en7523_pci_unprepare ,
592609 },
610+ .hw_init = en7523_clk_hw_init ,
593611};
594612
595613static const struct en_clk_soc_data en7581_data = {
0 commit comments