@@ -916,6 +916,93 @@ static int ra_set_mux_rate(struct cmucal_clk * clk, unsigned int rate) {
916916 return (unsigned int )-1 ;
917917 }
918918
919+ void ra_dump_pll_debug (struct cmucal_clk * clk )
920+ {
921+ struct cmucal_pll * pll ;
922+ unsigned int pll_con0 = 0 , pll_con1 = 0 ;
923+ unsigned int mdiv = 0 , pdiv = 0 , sdiv = 0 , kdiv = 0 ;
924+ int i ;
925+
926+ pr_info ("RA: ra_dump_pll_debug: enter clk=%p\n" , clk );
927+
928+ if (!clk ) {
929+ pr_info ("RA: ra_dump_pll_debug: clk NULL -> return\n" );
930+ return ;
931+ }
932+
933+ if (GET_TYPE (clk -> id ) != PLL_TYPE ) {
934+ pr_info ("RA: ra_dump_pll_debug: unsupported type id=0x%x type=0x%x\n" ,
935+ clk -> id , GET_TYPE (clk -> id ));
936+ return ;
937+ }
938+
939+ pll = to_pll_clk (clk );
940+ pr_info ("RA: ra_dump_pll_debug: clk name=%s pid=%u pll=%p rate_table=%p "
941+ "rate_count=%d\n" ,
942+ clk -> name , clk -> pid , pll , pll ? pll -> rate_table : NULL ,
943+ pll ? pll -> rate_count : -1 );
944+
945+ pr_info ("RA: ra_dump_pll_debug: idx(offset/enable/status)=%u/%u/%u "
946+ "m/p/s/k idx=%u/%u/%u/%u\n" ,
947+ clk -> offset_idx , clk -> enable_idx , clk -> status_idx ,
948+ pll ? pll -> m_idx : 0 , pll ? pll -> p_idx : 0 ,
949+ pll ? pll -> s_idx : 0 , pll ? pll -> k_idx : 0 );
950+
951+ pr_info ("RA: ra_dump_pll_debug: addr lock=%p pll_con0=%p pll_con1=%p "
952+ "shift width (lock=%u/%u status=%u/%u enable=%u/%u m=%u/%u p=%u/%u "
953+ "s=%u/%u k=%u/%u)\n" ,
954+ clk -> lock , clk -> pll_con0 , clk -> pll_con1 , clk -> shift , clk -> width ,
955+ clk -> s_shift , clk -> s_width , clk -> e_shift , clk -> e_width ,
956+ pll ? pll -> m_shift : 0 , pll ? pll -> m_width : 0 ,
957+ pll ? pll -> p_shift : 0 , pll ? pll -> p_width : 0 ,
958+ pll ? pll -> s_shift : 0 , pll ? pll -> s_width : 0 ,
959+ pll ? pll -> k_shift : 0 , pll ? pll -> k_width : 0 );
960+
961+ if (clk -> lock )
962+ pr_info ("RA: ra_dump_pll_debug: lock@%p = 0x%08x\n" ,
963+ clk -> lock , readl (clk -> lock ));
964+
965+ if (clk -> enable )
966+ pr_info ("RA: ra_dump_pll_debug: enable@%p = 0x%08x\n" ,
967+ clk -> enable , readl (clk -> enable ));
968+
969+ if (clk -> status )
970+ pr_info ("RA: ra_dump_pll_debug: status@%p = 0x%08x\n" ,
971+ clk -> status , readl (clk -> status ));
972+
973+ if (clk -> pll_con0 ) {
974+ pll_con0 = readl (clk -> pll_con0 );
975+ if (pll ) {
976+ mdiv = (pll_con0 >> pll -> m_shift ) & width_to_mask (pll -> m_width );
977+ pdiv = (pll_con0 >> pll -> p_shift ) & width_to_mask (pll -> p_width );
978+ sdiv = (pll_con0 >> pll -> s_shift ) & width_to_mask (pll -> s_width );
979+ }
980+
981+ pr_info ("RA: ra_dump_pll_debug: pll_con0@%p = 0x%08x -> m/p/s=%u/%u/%u\n" ,
982+ clk -> pll_con0 , pll_con0 , mdiv , pdiv , sdiv );
983+ }
984+
985+ if (pll && clk -> pll_con1 ) {
986+ pll_con1 = readl (clk -> pll_con1 );
987+ kdiv = (pll_con1 >> pll -> k_shift ) & width_to_mask (pll -> k_width );
988+
989+ pr_info ("RA: ra_dump_pll_debug: pll_con1@%p = 0x%08x -> k=%u\n" ,
990+ clk -> pll_con1 , pll_con1 , kdiv );
991+ }
992+
993+ if (pll && pll -> rate_table && pll -> rate_count > 0 ) {
994+ for (i = 0 ; i < pll -> rate_count ; i ++ )
995+ pr_info ("RA: ra_dump_pll_debug: rate_table[%d]=%p rate=%lu "
996+ "m/p/s/k=%u/%u/%u/%d\n" ,
997+ i , & pll -> rate_table [i ], pll -> rate_table [i ].rate ,
998+ pll -> rate_table [i ].mdiv , pll -> rate_table [i ].pdiv ,
999+ pll -> rate_table [i ].sdiv , pll -> rate_table [i ].kdiv );
1000+ }
1001+
1002+ pr_info ("RA: ra_dump_pll_debug: exit name=%s\n" , clk -> name );
1003+ }
1004+ EXPORT_SYMBOL_GPL (ra_dump_pll_debug );
1005+
9191006 static int ra_set_gate (struct cmucal_clk * clk , unsigned int pass ) {
9201007 unsigned int reg ;
9211008
@@ -2125,6 +2212,8 @@ static int ra_set_mux_rate(struct cmucal_clk * clk, unsigned int rate) {
21252212 else
21262213 clk -> enable = NULL ;
21272214 }
2215+
2216+ ra_dump_pll_debug (clk );
21282217
21292218 return 0 ;
21302219 }
0 commit comments