@@ -266,6 +266,8 @@ static struct rockchip_pll_rate_table rk3588_pll_rates[] = {
266
266
}, \
267
267
}
268
268
269
+ static struct rockchip_clk_provider * early_ctx ;
270
+
269
271
static struct rockchip_cpuclk_rate_table rk3588_cpub0clk_rates [] __initdata = {
270
272
RK3588_CPUB01CLK_RATE (2496000000 , 1 ),
271
273
RK3588_CPUB01CLK_RATE (2400000000 , 1 ),
@@ -694,7 +696,7 @@ static struct rockchip_pll_clock rk3588_pll_clks[] __initdata = {
694
696
RK3588_MODE_CON0 , 10 , 15 , 0 , rk3588_pll_rates ),
695
697
};
696
698
697
- static struct rockchip_clk_branch rk3588_clk_branches [] __initdata = {
699
+ static struct rockchip_clk_branch rk3588_early_clk_branches [] __initdata = {
698
700
/*
699
701
* CRU Clock-Architecture
700
702
*/
@@ -2428,7 +2430,9 @@ static struct rockchip_clk_branch rk3588_clk_branches[] __initdata = {
2428
2430
RK3588_CLKGATE_CON (68 ), 5 , GFLAGS ),
2429
2431
GATE (ACLK_AV1 , "aclk_av1" , "aclk_av1_pre" , 0 ,
2430
2432
RK3588_CLKGATE_CON (68 ), 2 , GFLAGS ),
2433
+ };
2431
2434
2435
+ static struct rockchip_clk_branch rk3588_clk_branches [] = {
2432
2436
GATE_LINK (ACLK_ISP1_PRE , "aclk_isp1_pre" , "aclk_isp1_root" , ACLK_VI_ROOT , 0 , RK3588_CLKGATE_CON (26 ), 6 , GFLAGS ),
2433
2437
GATE_LINK (HCLK_ISP1_PRE , "hclk_isp1_pre" , "hclk_isp1_root" , HCLK_VI_ROOT , 0 , RK3588_CLKGATE_CON (26 ), 8 , GFLAGS ),
2434
2438
GATE_LINK (HCLK_NVM , "hclk_nvm" , "hclk_nvm_root" , ACLK_NVM_ROOT , RK3588_LINKED_CLK , RK3588_CLKGATE_CON (31 ), 2 , GFLAGS ),
@@ -2453,26 +2457,31 @@ static struct rockchip_clk_branch rk3588_clk_branches[] __initdata = {
2453
2457
GATE_LINK (PCLK_VO1GRF , "pclk_vo1grf" , "pclk_vo1_root" , HCLK_VO1 , CLK_IGNORE_UNUSED , RK3588_CLKGATE_CON (59 ), 12 , GFLAGS ),
2454
2458
};
2455
2459
2456
- static void __init rk3588_clk_init (struct device_node * np )
2460
+ static void __init rk3588_clk_early_init (struct device_node * np )
2457
2461
{
2458
2462
struct rockchip_clk_provider * ctx ;
2459
- unsigned long clk_nr_clks ;
2463
+ unsigned long clk_nr_clks , max_clk_id1 , max_clk_id2 ;
2460
2464
void __iomem * reg_base ;
2461
2465
2462
- clk_nr_clks = rockchip_clk_find_max_clk_id (rk3588_clk_branches ,
2463
- ARRAY_SIZE (rk3588_clk_branches )) + 1 ;
2466
+ max_clk_id1 = rockchip_clk_find_max_clk_id (rk3588_clk_branches ,
2467
+ ARRAY_SIZE (rk3588_clk_branches ));
2468
+ max_clk_id2 = rockchip_clk_find_max_clk_id (rk3588_early_clk_branches ,
2469
+ ARRAY_SIZE (rk3588_early_clk_branches ));
2470
+ clk_nr_clks = max (max_clk_id1 , max_clk_id2 ) + 1 ;
2471
+
2464
2472
reg_base = of_iomap (np , 0 );
2465
2473
if (!reg_base ) {
2466
2474
pr_err ("%s: could not map cru region\n" , __func__ );
2467
2475
return ;
2468
2476
}
2469
2477
2470
- ctx = rockchip_clk_init (np , reg_base , clk_nr_clks );
2478
+ ctx = rockchip_clk_init_early (np , reg_base , clk_nr_clks );
2471
2479
if (IS_ERR (ctx )) {
2472
2480
pr_err ("%s: rockchip clk init failed\n" , __func__ );
2473
2481
iounmap (reg_base );
2474
2482
return ;
2475
2483
}
2484
+ early_ctx = ctx ;
2476
2485
2477
2486
rockchip_clk_register_plls (ctx , rk3588_pll_clks ,
2478
2487
ARRAY_SIZE (rk3588_pll_clks ),
@@ -2491,14 +2500,55 @@ static void __init rk3588_clk_init(struct device_node *np)
2491
2500
& rk3588_cpub1clk_data , rk3588_cpub1clk_rates ,
2492
2501
ARRAY_SIZE (rk3588_cpub1clk_rates ));
2493
2502
2503
+ rockchip_clk_register_branches (ctx , rk3588_early_clk_branches ,
2504
+ ARRAY_SIZE (rk3588_early_clk_branches ));
2505
+
2506
+ rockchip_clk_of_add_provider (np , ctx );
2507
+ }
2508
+ CLK_OF_DECLARE_DRIVER (rk3588_cru , "rockchip,rk3588-cru" , rk3588_clk_early_init );
2509
+
2510
+ static int clk_rk3588_probe (struct platform_device * pdev )
2511
+ {
2512
+ struct rockchip_clk_provider * ctx = early_ctx ;
2513
+ struct device * dev = & pdev -> dev ;
2514
+ struct device_node * np = dev -> of_node ;
2515
+
2494
2516
rockchip_clk_register_branches (ctx , rk3588_clk_branches ,
2495
2517
ARRAY_SIZE (rk3588_clk_branches ));
2496
2518
2497
- rk3588_rst_init ( np , reg_base );
2519
+ rockchip_clk_finalize ( ctx );
2498
2520
2521
+ rk3588_rst_init (np , ctx -> reg_base );
2499
2522
rockchip_register_restart_notifier (ctx , RK3588_GLB_SRST_FST , NULL );
2500
2523
2524
+ /*
2525
+ * Re-add clock provider, so that the newly added clocks are also
2526
+ * re-parented and get their defaults configured.
2527
+ */
2528
+ of_clk_del_provider (np );
2501
2529
rockchip_clk_of_add_provider (np , ctx );
2530
+
2531
+ return 0 ;
2502
2532
}
2503
2533
2504
- CLK_OF_DECLARE (rk3588_cru , "rockchip,rk3588-cru" , rk3588_clk_init );
2534
+ static const struct of_device_id clk_rk3588_match_table [] = {
2535
+ {
2536
+ .compatible = "rockchip,rk3588-cru" ,
2537
+ },
2538
+ { }
2539
+ };
2540
+
2541
+ static struct platform_driver clk_rk3588_driver = {
2542
+ .probe = clk_rk3588_probe ,
2543
+ .driver = {
2544
+ .name = "clk-rk3588" ,
2545
+ .of_match_table = clk_rk3588_match_table ,
2546
+ .suppress_bind_attrs = true,
2547
+ },
2548
+ };
2549
+
2550
+ static int __init rockchip_clk_rk3588_drv_register (void )
2551
+ {
2552
+ return platform_driver_register (& clk_rk3588_driver );
2553
+ }
2554
+ core_initcall (rockchip_clk_rk3588_drv_register );
0 commit comments