5959#define MHZ 1000000
6060#define FVCO_MIN (1500U * MHZ)
6161#define FVCO_MAX (3000U * MHZ)
62- #define DIVISOR_MIN 0
63- #define DIVISOR_MAX 63
64- #define FRAC 100
65- #define LIMIT (10 * MHZ)
6662
6763/**
6864 * struct xvcu_device - Xilinx VCU init device structure
@@ -482,111 +478,6 @@ static struct clk_hw *xvcu_register_pll(struct device *dev,
482478 return hw ;
483479}
484480
485- /**
486- * xvcu_set_vcu_pll_info - Set the VCU PLL info
487- * @xvcu: Pointer to the xvcu_device structure
488- *
489- * Programming the VCU PLL based on the user configuration
490- * (ref clock freq, core clock freq, mcu clock freq).
491- * Core clock frequency has higher priority than mcu clock frequency
492- * Errors in following cases
493- * - When mcu or clock clock get from logicoreIP is 0
494- * - When VCU PLL DIV related bits value other than 1
495- * - When proper data not found for given data
496- * - When sis570_1 clocksource related operation failed
497- *
498- * Return: Returns status, either success or error+reason
499- */
500- static int xvcu_set_vcu_pll_info (struct xvcu_device * xvcu )
501- {
502- u32 refclk , coreclk , mcuclk , inte , deci ;
503- u32 divisor_mcu , divisor_core , fvco ;
504- u32 pll_clk ;
505- u32 mod ;
506- int i ;
507- const struct xvcu_pll_cfg * found = NULL ;
508-
509- regmap_read (xvcu -> logicore_reg_ba , VCU_PLL_CLK , & inte );
510- regmap_read (xvcu -> logicore_reg_ba , VCU_PLL_CLK_DEC , & deci );
511- regmap_read (xvcu -> logicore_reg_ba , VCU_CORE_CLK , & coreclk );
512- coreclk *= MHZ ;
513- regmap_read (xvcu -> logicore_reg_ba , VCU_MCU_CLK , & mcuclk );
514- mcuclk *= MHZ ;
515- if (!mcuclk || !coreclk ) {
516- dev_err (xvcu -> dev , "Invalid mcu and core clock data\n" );
517- return - EINVAL ;
518- }
519-
520- refclk = (inte * MHZ ) + (deci * (MHZ / FRAC ));
521- dev_dbg (xvcu -> dev , "Ref clock from logicoreIP is %uHz\n" , refclk );
522- dev_dbg (xvcu -> dev , "Core clock from logicoreIP is %uHz\n" , coreclk );
523- dev_dbg (xvcu -> dev , "Mcu clock from logicoreIP is %uHz\n" , mcuclk );
524-
525- for (i = ARRAY_SIZE (xvcu_pll_cfg ) - 1 ; i >= 0 ; i -- ) {
526- const struct xvcu_pll_cfg * cfg = & xvcu_pll_cfg [i ];
527-
528- fvco = cfg -> fbdiv * refclk ;
529- if (fvco >= FVCO_MIN && fvco <= FVCO_MAX ) {
530- pll_clk = fvco / VCU_PLL_DIV2 ;
531- if (fvco % VCU_PLL_DIV2 != 0 )
532- pll_clk ++ ;
533- mod = pll_clk % coreclk ;
534- if (mod < LIMIT ) {
535- divisor_core = pll_clk / coreclk ;
536- } else if (coreclk - mod < LIMIT ) {
537- divisor_core = pll_clk / coreclk ;
538- divisor_core ++ ;
539- } else {
540- continue ;
541- }
542- if (divisor_core >= DIVISOR_MIN &&
543- divisor_core <= DIVISOR_MAX ) {
544- found = cfg ;
545- divisor_mcu = pll_clk / mcuclk ;
546- mod = pll_clk % mcuclk ;
547- if (mcuclk - mod < LIMIT )
548- divisor_mcu ++ ;
549- break ;
550- }
551- }
552- }
553-
554- if (!found ) {
555- dev_err (xvcu -> dev , "Invalid clock combination.\n" );
556- return - EINVAL ;
557- }
558-
559- coreclk = pll_clk / divisor_core ;
560- mcuclk = pll_clk / divisor_mcu ;
561- dev_dbg (xvcu -> dev , "Actual Ref clock freq is %uHz\n" , refclk );
562- dev_dbg (xvcu -> dev , "Actual Core clock freq is %uHz\n" , coreclk );
563- dev_dbg (xvcu -> dev , "Actual Mcu clock freq is %uHz\n" , mcuclk );
564-
565- return 0 ;
566- }
567-
568- /**
569- * xvcu_set_pll - PLL init sequence
570- * @xvcu: Pointer to the xvcu_device structure
571- *
572- * Call the api to set the PLL info and once that is done then
573- * init the PLL sequence to make the PLL stable.
574- *
575- * Return: Returns status, either success or error+reason
576- */
577- static int xvcu_set_pll (struct xvcu_device * xvcu )
578- {
579- int ret ;
580-
581- ret = xvcu_set_vcu_pll_info (xvcu );
582- if (ret ) {
583- dev_err (xvcu -> dev , "failed to set pll info\n" );
584- return ret ;
585- }
586-
587- return 0 ;
588- }
589-
590481static struct clk_hw * xvcu_clk_hw_register_leaf (struct device * dev ,
591482 const char * name ,
592483 const struct clk_parent_data * parent_data ,
@@ -834,13 +725,6 @@ static int xvcu_probe(struct platform_device *pdev)
834725 */
835726 regmap_write (xvcu -> logicore_reg_ba , VCU_GASKET_INIT , VCU_GASKET_VALUE );
836727
837- /* Do the PLL Settings based on the ref clk,core and mcu clk freq */
838- ret = xvcu_set_pll (xvcu );
839- if (ret ) {
840- dev_err (& pdev -> dev , "Failed to set the pll\n" );
841- goto error_pll_ref ;
842- }
843-
844728 ret = xvcu_register_clock_provider (xvcu );
845729 if (ret ) {
846730 dev_err (& pdev -> dev , "failed to register clock provider\n" );
@@ -853,7 +737,6 @@ static int xvcu_probe(struct platform_device *pdev)
853737
854738error_clk_provider :
855739 xvcu_unregister_clock_provider (xvcu );
856- error_pll_ref :
857740 clk_disable_unprepare (xvcu -> aclk );
858741 return ret ;
859742}
0 commit comments