20
20
#include <linux/phy.h>
21
21
#include <linux/phy_fixed.h>
22
22
#include <net/dsa.h>
23
+ #include <linux/clk.h>
23
24
#include <net/ip.h>
24
25
#include <net/ipv6.h>
25
26
@@ -186,6 +187,11 @@ static int bcm_sysport_set_features(struct net_device *dev,
186
187
netdev_features_t features )
187
188
{
188
189
struct bcm_sysport_priv * priv = netdev_priv (dev );
190
+ int ret ;
191
+
192
+ ret = clk_prepare_enable (priv -> clk );
193
+ if (ret )
194
+ return ret ;
189
195
190
196
/* Read CRC forward */
191
197
if (!priv -> is_lite )
@@ -197,6 +203,8 @@ static int bcm_sysport_set_features(struct net_device *dev,
197
203
bcm_sysport_set_rx_csum (dev , features );
198
204
bcm_sysport_set_tx_csum (dev , features );
199
205
206
+ clk_disable_unprepare (priv -> clk );
207
+
200
208
return 0 ;
201
209
}
202
210
@@ -1940,6 +1948,8 @@ static int bcm_sysport_open(struct net_device *dev)
1940
1948
unsigned int i ;
1941
1949
int ret ;
1942
1950
1951
+ clk_prepare_enable (priv -> clk );
1952
+
1943
1953
/* Reset UniMAC */
1944
1954
umac_reset (priv );
1945
1955
@@ -1970,7 +1980,8 @@ static int bcm_sysport_open(struct net_device *dev)
1970
1980
0 , priv -> phy_interface );
1971
1981
if (!phydev ) {
1972
1982
netdev_err (dev , "could not attach to PHY\n" );
1973
- return - ENODEV ;
1983
+ ret = - ENODEV ;
1984
+ goto out_clk_disable ;
1974
1985
}
1975
1986
1976
1987
/* Reset house keeping link status */
@@ -2048,6 +2059,8 @@ static int bcm_sysport_open(struct net_device *dev)
2048
2059
free_irq (priv -> irq0 , dev );
2049
2060
out_phy_disconnect :
2050
2061
phy_disconnect (phydev );
2062
+ out_clk_disable :
2063
+ clk_disable_unprepare (priv -> clk );
2051
2064
return ret ;
2052
2065
}
2053
2066
@@ -2106,6 +2119,8 @@ static int bcm_sysport_stop(struct net_device *dev)
2106
2119
/* Disconnect from PHY */
2107
2120
phy_disconnect (dev -> phydev );
2108
2121
2122
+ clk_disable_unprepare (priv -> clk );
2123
+
2109
2124
return 0 ;
2110
2125
}
2111
2126
@@ -2487,6 +2502,10 @@ static int bcm_sysport_probe(struct platform_device *pdev)
2487
2502
/* Initialize private members */
2488
2503
priv = netdev_priv (dev );
2489
2504
2505
+ priv -> clk = devm_clk_get_optional (& pdev -> dev , "sw_sysport" );
2506
+ if (IS_ERR (priv -> clk ))
2507
+ return PTR_ERR (priv -> clk );
2508
+
2490
2509
/* Allocate number of TX rings */
2491
2510
priv -> tx_rings = devm_kcalloc (& pdev -> dev , txq ,
2492
2511
sizeof (struct bcm_sysport_tx_ring ),
@@ -2588,6 +2607,8 @@ static int bcm_sysport_probe(struct platform_device *pdev)
2588
2607
goto err_deregister_notifier ;
2589
2608
}
2590
2609
2610
+ clk_prepare_enable (priv -> clk );
2611
+
2591
2612
priv -> rev = topctrl_readl (priv , REV_CNTL ) & REV_MASK ;
2592
2613
dev_info (& pdev -> dev ,
2593
2614
"Broadcom SYSTEMPORT%s " REV_FMT
@@ -2596,6 +2617,8 @@ static int bcm_sysport_probe(struct platform_device *pdev)
2596
2617
(priv -> rev >> 8 ) & 0xff , priv -> rev & 0xff ,
2597
2618
priv -> irq0 , priv -> irq1 , txq , rxq );
2598
2619
2620
+ clk_disable_unprepare (priv -> clk );
2621
+
2599
2622
return 0 ;
2600
2623
2601
2624
err_deregister_notifier :
@@ -2752,6 +2775,8 @@ static int __maybe_unused bcm_sysport_suspend(struct device *d)
2752
2775
if (device_may_wakeup (d ) && priv -> wolopts )
2753
2776
ret = bcm_sysport_suspend_to_wol (priv );
2754
2777
2778
+ clk_disable_unprepare (priv -> clk );
2779
+
2755
2780
return ret ;
2756
2781
}
2757
2782
@@ -2765,6 +2790,8 @@ static int __maybe_unused bcm_sysport_resume(struct device *d)
2765
2790
if (!netif_running (dev ))
2766
2791
return 0 ;
2767
2792
2793
+ clk_prepare_enable (priv -> clk );
2794
+
2768
2795
umac_reset (priv );
2769
2796
2770
2797
/* Disable the UniMAC RX/TX */
@@ -2844,6 +2871,7 @@ static int __maybe_unused bcm_sysport_resume(struct device *d)
2844
2871
out_free_tx_rings :
2845
2872
for (i = 0 ; i < dev -> num_tx_queues ; i ++ )
2846
2873
bcm_sysport_fini_tx_ring (priv , i );
2874
+ clk_disable_unprepare (priv -> clk );
2847
2875
return ret ;
2848
2876
}
2849
2877
0 commit comments