@@ -4928,6 +4928,7 @@ static void mux_poll(struct work_struct *work)
49284928 unsigned int new_channel ;
49294929 int sfp_present ;
49304930
4931+ //dev_info(eth->dev, "ethernet mux: %s:%d\n",__func__,__LINE__);
49314932 if (IS_ERR (mux -> mod_def0_gpio ) || IS_ERR (mux -> chan_sel_gpio ))
49324933 goto reschedule ;
49334934
@@ -4937,6 +4938,7 @@ static void mux_poll(struct work_struct *work)
49374938 if (mux -> channel == new_channel || !netif_running (dev ))
49384939 goto reschedule ;
49394940
4941+ dev_info (eth -> dev , "ethernet mux: line:%d new channel:%d,sfp:%d\n" ,__LINE__ , new_channel ,sfp_present );
49404942 rtnl_lock ();
49414943
49424944 mtk_stop (dev );
@@ -4948,6 +4950,8 @@ static void mux_poll(struct work_struct *work)
49484950
49494951 gpiod_set_value_cansleep (mux -> chan_sel_gpio , new_channel );
49504952
4953+ usleep_range (100000 ,200000 );
4954+
49514955 mtk_open (dev );
49524956
49534957 rtnl_unlock ();
@@ -5000,6 +5004,7 @@ static int mtk_add_mux_channel(struct mtk_mux *mux, struct device_node *np)
50005004 goto err_free_data ;
50015005 }
50025006
5007+ dev_info (eth -> dev , "ethernet mux: line:%d added new channel:%d\n" ,__LINE__ ,id );
50035008 data -> of_node = np ;
50045009 data -> phylink = phylink ;
50055010 mux -> data [id ] = data ;
@@ -5072,7 +5077,7 @@ static int mtk_add_mux(struct mtk_eth *eth, struct device_node *np)
50725077
50735078 eth -> mux [id ] = mux ;
50745079 mux -> mac = eth -> mac [id ];
5075- mux -> channel = 0 ;
5080+ mux -> channel = 0 ;//more than channels, just to make current channel invalid for switching the first time the gpio is read
50765081
50775082 mux -> mod_def0_gpio = fwnode_gpiod_get_index (of_fwnode_handle (np ),
50785083 "mod-def0" , 0 , GPIOD_IN |
@@ -5103,8 +5108,12 @@ static int mtk_add_mux(struct mtk_eth *eth, struct device_node *np)
51035108 of_node_put (child );
51045109 goto err_put_chan_sel ;
51055110 }
5111+ //should set initial mux->channel be set if ! mux->sfp_present_channel?
51065112 }
51075113
5114+ gpiod_set_value_cansleep (mux -> chan_sel_gpio , mux -> sfp_present_channel ? 0 : 1 );
5115+
5116+ dev_info (eth -> dev , "ethernet mux: line:%d added new mux\n" ,__LINE__ );
51085117 INIT_DELAYED_WORK (& mux -> poll , mux_poll );
51095118 mod_delayed_work (system_wq , & mux -> poll , msecs_to_jiffies (3000 ));
51105119
0 commit comments