Lines Matching refs:main_cfg

187 static int of_get_clk_cfg(const void *blob, struct mainpll_cfg *main_cfg,  in of_get_clk_cfg()  argument
212 ARRAY_SIZE(mainpll_cfg_tab), main_cfg)) in of_get_clk_cfg()
220 ARRAY_SIZE(alteragrp_cfg_tab), main_cfg)) in of_get_clk_cfg()
239 (struct mainpll_cfg *main_cfg) in cm_calc_handoff_main_vco_clk_hz() argument
244 switch (main_cfg->vco0_psrc) { in cm_calc_handoff_main_vco_clk_hz()
259 clk_hz /= 1 + main_cfg->vco1_denom; in cm_calc_handoff_main_vco_clk_hz()
260 clk_hz *= 1 + main_cfg->vco1_numer; in cm_calc_handoff_main_vco_clk_hz()
267 struct mainpll_cfg *main_cfg, struct perpll_cfg *per_cfg) in cm_calc_handoff_periph_vco_clk_hz() argument
283 clk_hz = cm_calc_handoff_main_vco_clk_hz(main_cfg); in cm_calc_handoff_periph_vco_clk_hz()
284 clk_hz /= main_cfg->cntr15clk_cnt; in cm_calc_handoff_periph_vco_clk_hz()
298 static unsigned int cm_calc_handoff_mpu_clk_hz(struct mainpll_cfg *main_cfg, in cm_calc_handoff_mpu_clk_hz() argument
304 switch (main_cfg->mpuclk_src) { in cm_calc_handoff_mpu_clk_hz()
306 clk_hz = cm_calc_handoff_main_vco_clk_hz(main_cfg); in cm_calc_handoff_mpu_clk_hz()
307 clk_hz /= (main_cfg->mpuclk & CLKMGR_MAINPLL_MPUCLK_CNT_MSK) in cm_calc_handoff_mpu_clk_hz()
311 clk_hz = cm_calc_handoff_periph_vco_clk_hz(main_cfg, per_cfg); in cm_calc_handoff_mpu_clk_hz()
312 clk_hz /= ((main_cfg->mpuclk >> in cm_calc_handoff_mpu_clk_hz()
329 clk_hz /= main_cfg->mpuclk_cnt + 1; in cm_calc_handoff_mpu_clk_hz()
334 static unsigned int cm_calc_handoff_noc_clk_hz(struct mainpll_cfg *main_cfg, in cm_calc_handoff_noc_clk_hz() argument
340 switch (main_cfg->nocclk_src) { in cm_calc_handoff_noc_clk_hz()
342 clk_hz = cm_calc_handoff_main_vco_clk_hz(main_cfg); in cm_calc_handoff_noc_clk_hz()
343 clk_hz /= (main_cfg->nocclk & CLKMGR_MAINPLL_NOCCLK_CNT_MSK) in cm_calc_handoff_noc_clk_hz()
347 clk_hz = cm_calc_handoff_periph_vco_clk_hz(main_cfg, per_cfg); in cm_calc_handoff_noc_clk_hz()
348 clk_hz /= ((main_cfg->nocclk >> in cm_calc_handoff_noc_clk_hz()
365 clk_hz /= main_cfg->nocclk_cnt + 1; in cm_calc_handoff_noc_clk_hz()
371 struct mainpll_cfg *main_cfg, in cm_is_pll_ramp_required() argument
380 if (main_cfg->mpuclk_src != CLKMGR_MAINPLL_MPUCLK_SRC_MAIN && in cm_is_pll_ramp_required()
381 main_cfg->nocclk_src != CLKMGR_MAINPLL_NOCCLK_SRC_MAIN) in cm_is_pll_ramp_required()
388 if (main_cfg->mpuclk_src == CLKMGR_MAINPLL_MPUCLK_SRC_MAIN && in cm_is_pll_ramp_required()
389 (cm_calc_handoff_mpu_clk_hz(main_cfg, per_cfg) > in cm_is_pll_ramp_required()
397 if (main_cfg->nocclk_src == CLKMGR_MAINPLL_NOCCLK_SRC_MAIN && in cm_is_pll_ramp_required()
398 (cm_calc_handoff_noc_clk_hz(main_cfg, per_cfg) > in cm_is_pll_ramp_required()
407 if (main_cfg->mpuclk_src != CLKMGR_MAINPLL_MPUCLK_SRC_PERI && in cm_is_pll_ramp_required()
408 main_cfg->nocclk_src != CLKMGR_MAINPLL_NOCCLK_SRC_PERI) in cm_is_pll_ramp_required()
415 if (main_cfg->mpuclk_src == CLKMGR_MAINPLL_MPUCLK_SRC_PERI && in cm_is_pll_ramp_required()
416 (cm_calc_handoff_mpu_clk_hz(main_cfg, per_cfg) > in cm_is_pll_ramp_required()
424 if (main_cfg->nocclk_src == CLKMGR_MAINPLL_NOCCLK_SRC_PERI && in cm_is_pll_ramp_required()
425 (cm_calc_handoff_noc_clk_hz(main_cfg, per_cfg) > in cm_is_pll_ramp_required()
433 static u32 cm_calculate_numer(struct mainpll_cfg *main_cfg, in cm_calculate_numer() argument
443 if (main_cfg->mpuclk_src == CLKMGR_MAINPLL_MPUCLK_SRC_MAIN) { in cm_calculate_numer()
444 cnt = main_cfg->mpuclk_cnt; in cm_calculate_numer()
445 clk = main_cfg->mpuclk; in cm_calculate_numer()
448 denom = main_cfg->vco1_denom; in cm_calculate_numer()
449 } else if (main_cfg->nocclk_src == CLKMGR_MAINPLL_NOCCLK_SRC_MAIN) { in cm_calculate_numer()
450 cnt = main_cfg->nocclk_cnt; in cm_calculate_numer()
451 clk = main_cfg->nocclk; in cm_calculate_numer()
454 denom = main_cfg->vco1_denom; in cm_calculate_numer()
455 } else if (main_cfg->mpuclk_src == CLKMGR_MAINPLL_MPUCLK_SRC_PERI) { in cm_calculate_numer()
456 cnt = main_cfg->mpuclk_cnt; in cm_calculate_numer()
457 clk = main_cfg->mpuclk; in cm_calculate_numer()
461 } else if (main_cfg->nocclk_src == CLKMGR_MAINPLL_NOCCLK_SRC_PERI) { in cm_calculate_numer()
462 cnt = main_cfg->nocclk_cnt; in cm_calculate_numer()
463 clk = main_cfg->nocclk; in cm_calculate_numer()
484 struct mainpll_cfg *main_cfg, in cm_calc_safe_pll_numer() argument
493 switch (main_cfg->vco0_psrc) { in cm_calc_safe_pll_numer()
519 clk_hz = cm_calc_handoff_main_vco_clk_hz(main_cfg); in cm_calc_safe_pll_numer()
520 clk_hz /= main_cfg->cntr15clk_cnt; in cm_calc_safe_pll_numer()
529 return cm_calculate_numer(main_cfg, per_cfg, safe_hz, clk_hz); in cm_calc_safe_pll_numer()
533 static void cm_pll_ramp_main(struct mainpll_cfg *main_cfg, in cm_pll_ramp_main() argument
540 if (main_cfg->mpuclk_src == CLKMGR_MAINPLL_MPUCLK_SRC_MAIN) { in cm_pll_ramp_main()
542 clk_final_hz = cm_calc_handoff_mpu_clk_hz(main_cfg, per_cfg); in cm_pll_ramp_main()
543 } else if (main_cfg->nocclk_src == CLKMGR_MAINPLL_NOCCLK_SRC_MAIN) { in cm_pll_ramp_main()
545 clk_final_hz = cm_calc_handoff_noc_clk_hz(main_cfg, per_cfg); in cm_pll_ramp_main()
551 writel((main_cfg->vco1_denom << in cm_pll_ramp_main()
553 cm_calc_safe_pll_numer(0, main_cfg, per_cfg, clk_hz), in cm_pll_ramp_main()
558 writel((main_cfg->vco1_denom << CLKMGR_MAINPLL_VCO1_DENOM_LSB) | in cm_pll_ramp_main()
559 main_cfg->vco1_numer, &clock_manager_base->main_pll.vco1); in cm_pll_ramp_main()
565 static void cm_pll_ramp_periph(struct mainpll_cfg *main_cfg, in cm_pll_ramp_periph() argument
572 if (main_cfg->mpuclk_src == CLKMGR_MAINPLL_MPUCLK_SRC_PERI) { in cm_pll_ramp_periph()
574 clk_final_hz = cm_calc_handoff_mpu_clk_hz(main_cfg, per_cfg); in cm_pll_ramp_periph()
575 } else if (main_cfg->nocclk_src == CLKMGR_MAINPLL_NOCCLK_SRC_PERI) { in cm_pll_ramp_periph()
577 clk_final_hz = cm_calc_handoff_noc_clk_hz(main_cfg, per_cfg); in cm_pll_ramp_periph()
583 cm_calc_safe_pll_numer(1, main_cfg, per_cfg, clk_hz), in cm_pll_ramp_periph()
633 static int cm_full_cfg(struct mainpll_cfg *main_cfg, struct perpll_cfg *per_cfg) in cm_full_cfg() argument
659 (main_cfg->vco0_psrc << CLKMGR_MAINPLL_VCO0_PSRC_LSB), in cm_full_cfg()
682 ramp_required = cm_is_pll_ramp_required(0, main_cfg, per_cfg); in cm_full_cfg()
690 writel((main_cfg->vco1_denom << CLKMGR_MAINPLL_VCO1_DENOM_LSB) | in cm_full_cfg()
691 cm_calc_safe_pll_numer(0, main_cfg, per_cfg, in cm_full_cfg()
695 writel((main_cfg->vco1_denom << CLKMGR_MAINPLL_VCO1_DENOM_LSB) | in cm_full_cfg()
696 main_cfg->vco1_numer, in cm_full_cfg()
700 ramp_required = cm_is_pll_ramp_required(1, main_cfg, per_cfg); in cm_full_cfg()
711 cm_calc_safe_pll_numer(1, main_cfg, per_cfg, in cm_full_cfg()
744 writel(main_cfg->nocclk, in cm_full_cfg()
746 writel(main_cfg->mpuclk, in cm_full_cfg()
750 writel(main_cfg->cntr2clk_cnt, &clock_manager_base->main_pll.cntr2clk); in cm_full_cfg()
752 writel(main_cfg->cntr3clk_cnt, &clock_manager_base->main_pll.cntr3clk); in cm_full_cfg()
754 writel(main_cfg->cntr4clk_cnt, &clock_manager_base->main_pll.cntr4clk); in cm_full_cfg()
756 writel(main_cfg->cntr5clk_cnt, &clock_manager_base->main_pll.cntr5clk); in cm_full_cfg()
758 writel(main_cfg->cntr6clk_cnt, &clock_manager_base->main_pll.cntr6clk); in cm_full_cfg()
760 writel(main_cfg->cntr7clk_cnt | in cm_full_cfg()
761 (main_cfg->cntr7clk_src << CLKMGR_MAINPLL_CNTR7CLK_SRC_LSB), in cm_full_cfg()
764 writel(main_cfg->cntr8clk_cnt, &clock_manager_base->main_pll.cntr8clk); in cm_full_cfg()
766 writel(main_cfg->cntr9clk_cnt | in cm_full_cfg()
767 (main_cfg->cntr9clk_src << CLKMGR_MAINPLL_CNTR9CLK_SRC_LSB), in cm_full_cfg()
770 writel(main_cfg->cntr15clk_cnt, in cm_full_cfg()
805 writel(main_cfg->mpuclk_cnt | in cm_full_cfg()
806 (main_cfg->mpuclk_src << CLKMGR_MAINPLL_MPUCLK_SRC_LSB), in cm_full_cfg()
809 writel(main_cfg->nocclk_cnt | in cm_full_cfg()
810 (main_cfg->nocclk_src << CLKMGR_MAINPLL_NOCCLK_SRC_LSB), in cm_full_cfg()
813 writel(main_cfg->nocdiv_l4mainclk | in cm_full_cfg()
814 (main_cfg->nocdiv_l4mpclk << in cm_full_cfg()
816 (main_cfg->nocdiv_l4spclk << in cm_full_cfg()
818 (main_cfg->nocdiv_csatclk << in cm_full_cfg()
820 (main_cfg->nocdiv_cstraceclk << in cm_full_cfg()
822 (main_cfg->nocdiv_cspdbclk << in cm_full_cfg()
879 cm_pll_ramp_main(main_cfg, per_cfg, pll_ramp_main_hz); in cm_full_cfg()
881 cm_pll_ramp_periph(main_cfg, per_cfg, pll_ramp_periph_hz); in cm_full_cfg()
910 struct mainpll_cfg main_cfg; in cm_basic_init() local
915 memset(&main_cfg, 0, sizeof(main_cfg)); in cm_basic_init()
918 rval = of_get_clk_cfg(blob, &main_cfg, &per_cfg); in cm_basic_init()
924 return cm_full_cfg(&main_cfg, &per_cfg); in cm_basic_init()