@@ -835,6 +835,55 @@ static int rcvr_extended(int argc, char **argv)
835835 return 0 ;
836836}
837837
838+ #define CMD_DESC_REF_CLK "Enable or disable the output reference clock of a port"
839+
840+ static int refclk (int argc , char * * argv )
841+ {
842+ int ret ;
843+
844+ static struct {
845+ struct switchtec_dev * dev ;
846+ int port_id ;
847+ int enable ;
848+ int disable ;
849+ } cfg = {
850+ .port_id = -1
851+ };
852+ const struct argconfig_options opts [] = {
853+ DEVICE_OPTION ,
854+ {"disable" , 'd' , "" , CFG_NONE , & cfg .disable , no_argument ,
855+ "disable the rfclk output" },
856+ {"enable" , 'e' , "" , CFG_NONE , & cfg .enable , no_argument ,
857+ "enable the rfclk output" },
858+ {"port" , 'p' , "NUM" , CFG_NONNEGATIVE , & cfg .port_id ,
859+ required_argument , "port to operate on" },
860+ {NULL }};
861+
862+ argconfig_parse (argc , argv , CMD_DESC_REF_CLK , opts , & cfg ,
863+ sizeof (cfg ));
864+
865+ if (cfg .enable == cfg .disable ) {
866+ fprintf (stderr , "Must set either --enable or --disable but not both\n" );
867+ return -1 ;
868+ }
869+
870+ if (cfg .port_id == -1 ) {
871+ fprintf (stderr , "Must specify port ID using --port or -p\n" );
872+ return -1 ;
873+ }
874+
875+ ret = switchtec_diag_refclk_ctl (cfg .dev , cfg .port_id , cfg .enable );
876+ if (ret ) {
877+ switchtec_perror ("refclk_ctl" );
878+ return -1 ;
879+ }
880+
881+ printf ("REFCLK Output %s for Port %d\n" ,
882+ cfg .enable ? "Enabled" : "Disabled" , cfg .port_id );
883+
884+ return 0 ;
885+ }
886+
838887static const struct cmd commands [] = {
839888 CMD (w2h , CMD_DESC_EYE_W2H ),
840889 CMD (eye , CMD_DESC_EYE ),
@@ -846,6 +895,7 @@ static const struct cmd commands[] = {
846895 CMD (port_eq_txtable , CMD_DESC_PORT_EQ_TXTABLE ),
847896 CMD (rcvr_extended , CMD_DESC_RCVR_EXTENDED ),
848897 CMD (rcvr_obj , CMD_DESC_RCVR_OBJ ),
898+ CMD (refclk , CMD_DESC_REF_CLK ),
849899 CMD (ltssm_log , CMD_DESC_LTSSM_LOG ),
850900 {}
851901};
0 commit comments