@@ -78,7 +78,8 @@ struct en_clk_soc_data {
78
78
const u16 * idx_map ;
79
79
u16 idx_map_nr ;
80
80
} 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 );
82
83
};
83
84
84
85
static const u32 gsw_base [] = { 400000000 , 500000000 };
@@ -406,20 +407,6 @@ static void en7581_pci_disable(struct clk_hw *hw)
406
407
usleep_range (1000 , 2000 );
407
408
}
408
409
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
-
423
410
static void en7523_register_clocks (struct device * dev , struct clk_hw_onecell_data * clk_data ,
424
411
void __iomem * base , void __iomem * np_base )
425
412
{
@@ -449,6 +436,49 @@ static void en7523_register_clocks(struct device *dev, struct clk_hw_onecell_dat
449
436
clk_data -> num = EN7523_NUM_CLOCKS ;
450
437
}
451
438
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
+
452
482
static int en7523_reset_update (struct reset_controller_dev * rcdev ,
453
483
unsigned long id , bool assert )
454
484
{
@@ -543,31 +573,18 @@ static int en7523_clk_probe(struct platform_device *pdev)
543
573
struct device_node * node = pdev -> dev .of_node ;
544
574
const struct en_clk_soc_data * soc_data ;
545
575
struct clk_hw_onecell_data * clk_data ;
546
- void __iomem * base , * np_base ;
547
576
int r ;
548
577
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
-
564
578
clk_data = devm_kzalloc (& pdev -> dev ,
565
579
struct_size (clk_data , hws , EN7523_NUM_CLOCKS ),
566
580
GFP_KERNEL );
567
581
if (!clk_data )
568
582
return - ENOMEM ;
569
583
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 ;
571
588
572
589
r = of_clk_add_hw_provider (node , of_clk_hw_onecell_get , clk_data );
573
590
if (r )
@@ -590,6 +607,7 @@ static const struct en_clk_soc_data en7523_data = {
590
607
.prepare = en7523_pci_prepare ,
591
608
.unprepare = en7523_pci_unprepare ,
592
609
},
610
+ .hw_init = en7523_clk_hw_init ,
593
611
};
594
612
595
613
static const struct en_clk_soc_data en7581_data = {
0 commit comments