@@ -35,6 +35,16 @@ struct tegra_eqos {
3535 struct gpio_desc * reset ;
3636};
3737
38+ static struct clk * dwc_eth_find_clk (struct plat_stmmacenet_data * plat_dat ,
39+ const char * name )
40+ {
41+ for (int i = 0 ; i < plat_dat -> num_clks ; i ++ )
42+ if (strcmp (plat_dat -> clks [i ].id , name ) == 0 )
43+ return plat_dat -> clks [i ].clk ;
44+
45+ return NULL ;
46+ }
47+
3848static int dwc_eth_dwmac_config_dt (struct platform_device * pdev ,
3949 struct plat_stmmacenet_data * plat_dat )
4050{
@@ -121,12 +131,7 @@ static int dwc_qos_probe(struct platform_device *pdev,
121131 struct plat_stmmacenet_data * plat_dat ,
122132 struct stmmac_resources * stmmac_res )
123133{
124- for (int i = 0 ; i < plat_dat -> num_clks ; i ++ ) {
125- if (strcmp (plat_dat -> clks [i ].id , "apb_pclk" ) == 0 )
126- plat_dat -> stmmac_clk = plat_dat -> clks [i ].clk ;
127- else if (strcmp (plat_dat -> clks [i ].id , "phy_ref_clk" ) == 0 )
128- plat_dat -> pclk = plat_dat -> clks [i ].clk ;
129- }
134+ plat_dat -> pclk = dwc_eth_find_clk (plat_dat , "phy_ref_clk" );
130135
131136 return 0 ;
132137}
@@ -224,7 +229,7 @@ static int tegra_eqos_init(struct platform_device *pdev, void *priv)
224229}
225230
226231static int tegra_eqos_probe (struct platform_device * pdev ,
227- struct plat_stmmacenet_data * data ,
232+ struct plat_stmmacenet_data * plat_dat ,
228233 struct stmmac_resources * res )
229234{
230235 struct device * dev = & pdev -> dev ;
@@ -237,18 +242,12 @@ static int tegra_eqos_probe(struct platform_device *pdev,
237242
238243 eqos -> dev = & pdev -> dev ;
239244 eqos -> regs = res -> addr ;
245+ eqos -> clk_slave = plat_dat -> stmmac_clk ;
240246
241247 if (!is_of_node (dev -> fwnode ))
242248 goto bypass_clk_reset_gpio ;
243249
244- for (int i = 0 ; i < data -> num_clks ; i ++ ) {
245- if (strcmp (data -> clks [i ].id , "slave_bus" ) == 0 ) {
246- eqos -> clk_slave = data -> clks [i ].clk ;
247- data -> stmmac_clk = eqos -> clk_slave ;
248- } else if (strcmp (data -> clks [i ].id , "tx" ) == 0 ) {
249- eqos -> clk_tx = data -> clks [i ].clk ;
250- }
251- }
250+ eqos -> clk_tx = dwc_eth_find_clk (plat_dat , "tx" );
252251
253252 eqos -> reset = devm_gpiod_get (& pdev -> dev , "phy-reset" , GPIOD_OUT_HIGH );
254253 if (IS_ERR (eqos -> reset )) {
@@ -260,7 +259,7 @@ static int tegra_eqos_probe(struct platform_device *pdev,
260259 gpiod_set_value (eqos -> reset , 0 );
261260
262261 /* MDIO bus was already reset just above */
263- data -> mdio_bus_data -> needs_reset = false;
262+ plat_dat -> mdio_bus_data -> needs_reset = false;
264263
265264 eqos -> rst = devm_reset_control_get (& pdev -> dev , "eqos" );
266265 if (IS_ERR (eqos -> rst )) {
@@ -281,10 +280,10 @@ static int tegra_eqos_probe(struct platform_device *pdev,
281280 usleep_range (2000 , 4000 );
282281
283282bypass_clk_reset_gpio :
284- data -> fix_mac_speed = tegra_eqos_fix_speed ;
285- data -> init = tegra_eqos_init ;
286- data -> bsp_priv = eqos ;
287- data -> flags |= STMMAC_FLAG_SPH_DISABLE ;
283+ plat_dat -> fix_mac_speed = tegra_eqos_fix_speed ;
284+ plat_dat -> init = tegra_eqos_init ;
285+ plat_dat -> bsp_priv = eqos ;
286+ plat_dat -> flags |= STMMAC_FLAG_SPH_DISABLE ;
288287
289288 err = tegra_eqos_init (pdev , eqos );
290289 if (err < 0 )
@@ -309,18 +308,21 @@ static void tegra_eqos_remove(struct platform_device *pdev)
309308
310309struct dwc_eth_dwmac_data {
311310 int (* probe )(struct platform_device * pdev ,
312- struct plat_stmmacenet_data * data ,
311+ struct plat_stmmacenet_data * plat_dat ,
313312 struct stmmac_resources * res );
314313 void (* remove )(struct platform_device * pdev );
314+ const char * stmmac_clk_name ;
315315};
316316
317317static const struct dwc_eth_dwmac_data dwc_qos_data = {
318318 .probe = dwc_qos_probe ,
319+ .stmmac_clk_name = "apb_pclk" ,
319320};
320321
321322static const struct dwc_eth_dwmac_data tegra_eqos_data = {
322323 .probe = tegra_eqos_probe ,
323324 .remove = tegra_eqos_remove ,
325+ .stmmac_clk_name = "slave_bus" ,
324326};
325327
326328static int dwc_eth_dwmac_probe (struct platform_device * pdev )
@@ -360,6 +362,9 @@ static int dwc_eth_dwmac_probe(struct platform_device *pdev)
360362 if (ret )
361363 return dev_err_probe (& pdev -> dev , ret , "Failed to enable clocks\n" );
362364
365+ plat_dat -> stmmac_clk = dwc_eth_find_clk (plat_dat ,
366+ data -> stmmac_clk_name );
367+
363368 ret = data -> probe (pdev , plat_dat , & stmmac_res );
364369 if (ret < 0 ) {
365370 dev_err_probe (& pdev -> dev , ret , "failed to probe subdriver\n" );
@@ -387,15 +392,15 @@ static int dwc_eth_dwmac_probe(struct platform_device *pdev)
387392static void dwc_eth_dwmac_remove (struct platform_device * pdev )
388393{
389394 const struct dwc_eth_dwmac_data * data = device_get_match_data (& pdev -> dev );
390- struct plat_stmmacenet_data * plat_data = dev_get_platdata (& pdev -> dev );
395+ struct plat_stmmacenet_data * plat_dat = dev_get_platdata (& pdev -> dev );
391396
392397 stmmac_dvr_remove (& pdev -> dev );
393398
394399 if (data -> remove )
395400 data -> remove (pdev );
396401
397- if (plat_data )
398- clk_bulk_disable_unprepare (plat_data -> num_clks , plat_data -> clks );
402+ if (plat_dat )
403+ clk_bulk_disable_unprepare (plat_dat -> num_clks , plat_dat -> clks );
399404}
400405
401406static const struct of_device_id dwc_eth_dwmac_match [] = {
0 commit comments