aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/renesas/sh_eth.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/ethernet/renesas/sh_eth.c')
-rw-r--r--drivers/net/ethernet/renesas/sh_eth.c38
1 files changed, 28 insertions, 10 deletions
diff --git a/drivers/net/ethernet/renesas/sh_eth.c b/drivers/net/ethernet/renesas/sh_eth.c
index 33e96176e4d8..6ed333fe5c04 100644
--- a/drivers/net/ethernet/renesas/sh_eth.c
+++ b/drivers/net/ethernet/renesas/sh_eth.c
@@ -1216,10 +1216,7 @@ static void sh_eth_error(struct net_device *ndev, int intr_status)
1216 if (felic_stat & ECSR_LCHNG) { 1216 if (felic_stat & ECSR_LCHNG) {
1217 /* Link Changed */ 1217 /* Link Changed */
1218 if (mdp->cd->no_psr || mdp->no_ether_link) { 1218 if (mdp->cd->no_psr || mdp->no_ether_link) {
1219 if (mdp->link == PHY_DOWN) 1219 goto ignore_link;
1220 link_stat = 0;
1221 else
1222 link_stat = PHY_ST_LINK;
1223 } else { 1220 } else {
1224 link_stat = (sh_eth_read(ndev, PSR)); 1221 link_stat = (sh_eth_read(ndev, PSR));
1225 if (mdp->ether_link_active_low) 1222 if (mdp->ether_link_active_low)
@@ -1242,6 +1239,7 @@ static void sh_eth_error(struct net_device *ndev, int intr_status)
1242 } 1239 }
1243 } 1240 }
1244 1241
1242ignore_link:
1245 if (intr_status & EESR_TWB) { 1243 if (intr_status & EESR_TWB) {
1246 /* Write buck end. unused write back interrupt */ 1244 /* Write buck end. unused write back interrupt */
1247 if (intr_status & EESR_TABT) /* Transmit Abort int */ 1245 if (intr_status & EESR_TABT) /* Transmit Abort int */
@@ -1326,12 +1324,18 @@ static irqreturn_t sh_eth_interrupt(int irq, void *netdev)
1326 struct sh_eth_private *mdp = netdev_priv(ndev); 1324 struct sh_eth_private *mdp = netdev_priv(ndev);
1327 struct sh_eth_cpu_data *cd = mdp->cd; 1325 struct sh_eth_cpu_data *cd = mdp->cd;
1328 irqreturn_t ret = IRQ_NONE; 1326 irqreturn_t ret = IRQ_NONE;
1329 u32 intr_status = 0; 1327 unsigned long intr_status;
1330 1328
1331 spin_lock(&mdp->lock); 1329 spin_lock(&mdp->lock);
1332 1330
1333 /* Get interrpt stat */ 1331 /* Get interrupt status */
1334 intr_status = sh_eth_read(ndev, EESR); 1332 intr_status = sh_eth_read(ndev, EESR);
1333 /* Mask it with the interrupt mask, forcing ECI interrupt to be always
1334 * enabled since it's the one that comes thru regardless of the mask,
1335 * and we need to fully handle it in sh_eth_error() in order to quench
1336 * it as it doesn't get cleared by just writing 1 to the ECI bit...
1337 */
1338 intr_status &= sh_eth_read(ndev, EESIPR) | DMAC_M_ECI;
1335 /* Clear interrupt */ 1339 /* Clear interrupt */
1336 if (intr_status & (EESR_FRC | EESR_RMAF | EESR_RRF | 1340 if (intr_status & (EESR_FRC | EESR_RMAF | EESR_RRF |
1337 EESR_RTLF | EESR_RTSF | EESR_PRE | EESR_CERF | 1341 EESR_RTLF | EESR_RTSF | EESR_PRE | EESR_CERF |
@@ -1373,7 +1377,7 @@ static void sh_eth_adjust_link(struct net_device *ndev)
1373 struct phy_device *phydev = mdp->phydev; 1377 struct phy_device *phydev = mdp->phydev;
1374 int new_state = 0; 1378 int new_state = 0;
1375 1379
1376 if (phydev->link != PHY_DOWN) { 1380 if (phydev->link) {
1377 if (phydev->duplex != mdp->duplex) { 1381 if (phydev->duplex != mdp->duplex) {
1378 new_state = 1; 1382 new_state = 1;
1379 mdp->duplex = phydev->duplex; 1383 mdp->duplex = phydev->duplex;
@@ -1387,17 +1391,21 @@ static void sh_eth_adjust_link(struct net_device *ndev)
1387 if (mdp->cd->set_rate) 1391 if (mdp->cd->set_rate)
1388 mdp->cd->set_rate(ndev); 1392 mdp->cd->set_rate(ndev);
1389 } 1393 }
1390 if (mdp->link == PHY_DOWN) { 1394 if (!mdp->link) {
1391 sh_eth_write(ndev, 1395 sh_eth_write(ndev,
1392 (sh_eth_read(ndev, ECMR) & ~ECMR_TXF), ECMR); 1396 (sh_eth_read(ndev, ECMR) & ~ECMR_TXF), ECMR);
1393 new_state = 1; 1397 new_state = 1;
1394 mdp->link = phydev->link; 1398 mdp->link = phydev->link;
1399 if (mdp->cd->no_psr || mdp->no_ether_link)
1400 sh_eth_rcv_snd_enable(ndev);
1395 } 1401 }
1396 } else if (mdp->link) { 1402 } else if (mdp->link) {
1397 new_state = 1; 1403 new_state = 1;
1398 mdp->link = PHY_DOWN; 1404 mdp->link = 0;
1399 mdp->speed = 0; 1405 mdp->speed = 0;
1400 mdp->duplex = -1; 1406 mdp->duplex = -1;
1407 if (mdp->cd->no_psr || mdp->no_ether_link)
1408 sh_eth_rcv_snd_disable(ndev);
1401 } 1409 }
1402 1410
1403 if (new_state && netif_msg_link(mdp)) 1411 if (new_state && netif_msg_link(mdp))
@@ -1414,7 +1422,7 @@ static int sh_eth_phy_init(struct net_device *ndev)
1414 snprintf(phy_id, sizeof(phy_id), PHY_ID_FMT, 1422 snprintf(phy_id, sizeof(phy_id), PHY_ID_FMT,
1415 mdp->mii_bus->id , mdp->phy_id); 1423 mdp->mii_bus->id , mdp->phy_id);
1416 1424
1417 mdp->link = PHY_DOWN; 1425 mdp->link = 0;
1418 mdp->speed = 0; 1426 mdp->speed = 0;
1419 mdp->duplex = -1; 1427 mdp->duplex = -1;
1420 1428
@@ -2220,6 +2228,7 @@ static void sh_eth_tsu_init(struct sh_eth_private *mdp)
2220/* MDIO bus release function */ 2228/* MDIO bus release function */
2221static int sh_mdio_release(struct net_device *ndev) 2229static int sh_mdio_release(struct net_device *ndev)
2222{ 2230{
2231 struct sh_eth_private *mdp = netdev_priv(ndev);
2223 struct mii_bus *bus = dev_get_drvdata(&ndev->dev); 2232 struct mii_bus *bus = dev_get_drvdata(&ndev->dev);
2224 2233
2225 /* unregister mdio bus */ 2234 /* unregister mdio bus */
@@ -2234,6 +2243,9 @@ static int sh_mdio_release(struct net_device *ndev)
2234 /* free bitbang info */ 2243 /* free bitbang info */
2235 free_mdio_bitbang(bus); 2244 free_mdio_bitbang(bus);
2236 2245
2246 /* free bitbang memory */
2247 kfree(mdp->bitbang);
2248
2237 return 0; 2249 return 0;
2238} 2250}
2239 2251
@@ -2262,6 +2274,7 @@ static int sh_mdio_init(struct net_device *ndev, int id,
2262 bitbang->ctrl.ops = &bb_ops; 2274 bitbang->ctrl.ops = &bb_ops;
2263 2275
2264 /* MII controller setting */ 2276 /* MII controller setting */
2277 mdp->bitbang = bitbang;
2265 mdp->mii_bus = alloc_mdio_bitbang(&bitbang->ctrl); 2278 mdp->mii_bus = alloc_mdio_bitbang(&bitbang->ctrl);
2266 if (!mdp->mii_bus) { 2279 if (!mdp->mii_bus) {
2267 ret = -ENOMEM; 2280 ret = -ENOMEM;
@@ -2441,6 +2454,11 @@ static int sh_eth_drv_probe(struct platform_device *pdev)
2441 } 2454 }
2442 mdp->tsu_addr = ioremap(rtsu->start, 2455 mdp->tsu_addr = ioremap(rtsu->start,
2443 resource_size(rtsu)); 2456 resource_size(rtsu));
2457 if (mdp->tsu_addr == NULL) {
2458 ret = -ENOMEM;
2459 dev_err(&pdev->dev, "TSU ioremap failed.\n");
2460 goto out_release;
2461 }
2444 mdp->port = devno % 2; 2462 mdp->port = devno % 2;
2445 ndev->features = NETIF_F_HW_VLAN_FILTER; 2463 ndev->features = NETIF_F_HW_VLAN_FILTER;
2446 } 2464 }