aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/cadence/at91_ether.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/ethernet/cadence/at91_ether.c')
-rw-r--r--drivers/net/ethernet/cadence/at91_ether.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/drivers/net/ethernet/cadence/at91_ether.c b/drivers/net/ethernet/cadence/at91_ether.c
index dfeb46cb3f74..1a5b6efa0120 100644
--- a/drivers/net/ethernet/cadence/at91_ether.c
+++ b/drivers/net/ethernet/cadence/at91_ether.c
@@ -256,8 +256,7 @@ static void enable_phyirq(struct net_device *dev)
256 unsigned int dsintr, irq_number; 256 unsigned int dsintr, irq_number;
257 int status; 257 int status;
258 258
259 irq_number = lp->board_data.phy_irq_pin; 259 if (!gpio_is_valid(lp->board_data.phy_irq_pin)) {
260 if (!irq_number) {
261 /* 260 /*
262 * PHY doesn't have an IRQ pin (RTL8201, DP83847, AC101L), 261 * PHY doesn't have an IRQ pin (RTL8201, DP83847, AC101L),
263 * or board does not have it connected. 262 * or board does not have it connected.
@@ -266,6 +265,7 @@ static void enable_phyirq(struct net_device *dev)
266 return; 265 return;
267 } 266 }
268 267
268 irq_number = lp->board_data.phy_irq_pin;
269 status = request_irq(irq_number, at91ether_phy_interrupt, 0, dev->name, dev); 269 status = request_irq(irq_number, at91ether_phy_interrupt, 0, dev->name, dev);
270 if (status) { 270 if (status) {
271 printk(KERN_ERR "at91_ether: PHY IRQ %d request failed - status %d!\n", irq_number, status); 271 printk(KERN_ERR "at91_ether: PHY IRQ %d request failed - status %d!\n", irq_number, status);
@@ -320,8 +320,7 @@ static void disable_phyirq(struct net_device *dev)
320 unsigned int dsintr; 320 unsigned int dsintr;
321 unsigned int irq_number; 321 unsigned int irq_number;
322 322
323 irq_number = lp->board_data.phy_irq_pin; 323 if (!gpio_is_valid(lp->board_data.phy_irq_pin)) {
324 if (!irq_number) {
325 del_timer_sync(&lp->check_timer); 324 del_timer_sync(&lp->check_timer);
326 return; 325 return;
327 } 326 }
@@ -366,6 +365,7 @@ static void disable_phyirq(struct net_device *dev)
366 disable_mdi(); 365 disable_mdi();
367 spin_unlock_irq(&lp->lock); 366 spin_unlock_irq(&lp->lock);
368 367
368 irq_number = lp->board_data.phy_irq_pin;
369 free_irq(irq_number, dev); /* Free interrupt handler */ 369 free_irq(irq_number, dev); /* Free interrupt handler */
370} 370}
371 371
@@ -1078,7 +1078,7 @@ static int __init at91ether_setup(unsigned long phy_type, unsigned short phy_add
1078 netif_carrier_off(dev); /* will be enabled in open() */ 1078 netif_carrier_off(dev); /* will be enabled in open() */
1079 1079
1080 /* If board has no PHY IRQ, use a timer to poll the PHY */ 1080 /* If board has no PHY IRQ, use a timer to poll the PHY */
1081 if (!lp->board_data.phy_irq_pin) { 1081 if (!gpio_is_valid(lp->board_data.phy_irq_pin)) {
1082 init_timer(&lp->check_timer); 1082 init_timer(&lp->check_timer);
1083 lp->check_timer.data = (unsigned long)dev; 1083 lp->check_timer.data = (unsigned long)dev;
1084 lp->check_timer.function = at91ether_check_link; 1084 lp->check_timer.function = at91ether_check_link;
@@ -1170,7 +1170,8 @@ static int __devexit at91ether_remove(struct platform_device *pdev)
1170 struct net_device *dev = platform_get_drvdata(pdev); 1170 struct net_device *dev = platform_get_drvdata(pdev);
1171 struct at91_private *lp = netdev_priv(dev); 1171 struct at91_private *lp = netdev_priv(dev);
1172 1172
1173 if (lp->board_data.phy_irq_pin >= 32) 1173 if (gpio_is_valid(lp->board_data.phy_irq_pin) &&
1174 lp->board_data.phy_irq_pin >= 32)
1174 gpio_free(lp->board_data.phy_irq_pin); 1175 gpio_free(lp->board_data.phy_irq_pin);
1175 1176
1176 unregister_netdev(dev); 1177 unregister_netdev(dev);
@@ -1189,11 +1190,12 @@ static int at91ether_suspend(struct platform_device *pdev, pm_message_t mesg)
1189{ 1190{
1190 struct net_device *net_dev = platform_get_drvdata(pdev); 1191 struct net_device *net_dev = platform_get_drvdata(pdev);
1191 struct at91_private *lp = netdev_priv(net_dev); 1192 struct at91_private *lp = netdev_priv(net_dev);
1192 int phy_irq = lp->board_data.phy_irq_pin;
1193 1193
1194 if (netif_running(net_dev)) { 1194 if (netif_running(net_dev)) {
1195 if (phy_irq) 1195 if (gpio_is_valid(lp->board_data.phy_irq_pin)) {
1196 int phy_irq = lp->board_data.phy_irq_pin;
1196 disable_irq(phy_irq); 1197 disable_irq(phy_irq);
1198 }
1197 1199
1198 netif_stop_queue(net_dev); 1200 netif_stop_queue(net_dev);
1199 netif_device_detach(net_dev); 1201 netif_device_detach(net_dev);
@@ -1207,7 +1209,6 @@ static int at91ether_resume(struct platform_device *pdev)
1207{ 1209{
1208 struct net_device *net_dev = platform_get_drvdata(pdev); 1210 struct net_device *net_dev = platform_get_drvdata(pdev);
1209 struct at91_private *lp = netdev_priv(net_dev); 1211 struct at91_private *lp = netdev_priv(net_dev);
1210 int phy_irq = lp->board_data.phy_irq_pin;
1211 1212
1212 if (netif_running(net_dev)) { 1213 if (netif_running(net_dev)) {
1213 clk_enable(lp->ether_clk); 1214 clk_enable(lp->ether_clk);
@@ -1215,8 +1216,10 @@ static int at91ether_resume(struct platform_device *pdev)
1215 netif_device_attach(net_dev); 1216 netif_device_attach(net_dev);
1216 netif_start_queue(net_dev); 1217 netif_start_queue(net_dev);
1217 1218
1218 if (phy_irq) 1219 if (gpio_is_valid(lp->board_data.phy_irq_pin)) {
1220 int phy_irq = lp->board_data.phy_irq_pin;
1219 enable_irq(phy_irq); 1221 enable_irq(phy_irq);
1222 }
1220 } 1223 }
1221 return 0; 1224 return 0;
1222} 1225}