aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/fec_mpc52xx.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2009-04-03 00:05:30 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2009-04-03 00:05:30 -0400
commitef8a97bbc92ec07e3a07a81cc011dc549f8c7a23 (patch)
tree82a95f16d9236bc35a4cfd42ba8cab61981efda8 /drivers/net/fec_mpc52xx.c
parent4f032ac4122a77dbabf7a24b2739b2790448180f (diff)
parent6c8ad3b07f7d9efdc41396db6da0aed906922701 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6: (54 commits) glge: remove unused #include <version.h> dnet: remove unused #include <version.h> tcp: miscounts due to tcp_fragment pcount reset tcp: add helper for counter tweaking due mid-wq change hso: fix for the 'invalid frame length' messages hso: fix for crash when unplugging the device fsl_pq_mdio: Fix compile failure fsl_pq_mdio: Revive UCC MDIO support ucc_geth: Pass proper device to DMA routines, otherwise oops happens i.MX31: Fixing cs89x0 network building to i.MX31ADS tc35815: Fix build error if NAPI enabled hso: add Vendor/Product ID's for new devices ucc_geth: Remove unused header gianfar: Remove unused header kaweth: Fix locking to be SMP-safe net: allow multiple dev per napi with GRO r8169: reset IntrStatus after chip reset ixgbe: Fix potential memory leak/driver panic issue while setting up Tx & Rx ring parameters ixgbe: fix ethtool -A|a behavior ixgbe: Patch to fix driver panic while freeing up tx & rx resources ...
Diffstat (limited to 'drivers/net/fec_mpc52xx.c')
-rw-r--r--drivers/net/fec_mpc52xx.c77
1 files changed, 44 insertions, 33 deletions
diff --git a/drivers/net/fec_mpc52xx.c b/drivers/net/fec_mpc52xx.c
index 049b0a7e01f3..8bbe7f617994 100644
--- a/drivers/net/fec_mpc52xx.c
+++ b/drivers/net/fec_mpc52xx.c
@@ -129,7 +129,8 @@ static void mpc52xx_fec_free_rx_buffers(struct net_device *dev, struct bcom_task
129 struct sk_buff *skb; 129 struct sk_buff *skb;
130 130
131 skb = bcom_retrieve_buffer(s, NULL, (struct bcom_bd **)&bd); 131 skb = bcom_retrieve_buffer(s, NULL, (struct bcom_bd **)&bd);
132 dma_unmap_single(&dev->dev, bd->skb_pa, skb->len, DMA_FROM_DEVICE); 132 dma_unmap_single(dev->dev.parent, bd->skb_pa, skb->len,
133 DMA_FROM_DEVICE);
133 kfree_skb(skb); 134 kfree_skb(skb);
134 } 135 }
135} 136}
@@ -150,7 +151,7 @@ static int mpc52xx_fec_alloc_rx_buffers(struct net_device *dev, struct bcom_task
150 bd = (struct bcom_fec_bd *)bcom_prepare_next_buffer(rxtsk); 151 bd = (struct bcom_fec_bd *)bcom_prepare_next_buffer(rxtsk);
151 152
152 bd->status = FEC_RX_BUFFER_SIZE; 153 bd->status = FEC_RX_BUFFER_SIZE;
153 bd->skb_pa = dma_map_single(&dev->dev, skb->data, 154 bd->skb_pa = dma_map_single(dev->dev.parent, skb->data,
154 FEC_RX_BUFFER_SIZE, DMA_FROM_DEVICE); 155 FEC_RX_BUFFER_SIZE, DMA_FROM_DEVICE);
155 156
156 bcom_submit_next_buffer(rxtsk, skb); 157 bcom_submit_next_buffer(rxtsk, skb);
@@ -270,15 +271,6 @@ static void mpc52xx_fec_phy_stop(struct net_device *dev)
270 phy_write(priv->phydev, MII_BMCR, BMCR_PDOWN); 271 phy_write(priv->phydev, MII_BMCR, BMCR_PDOWN);
271} 272}
272 273
273static int mpc52xx_fec_phy_mii_ioctl(struct mpc52xx_fec_priv *priv,
274 struct mii_ioctl_data *mii_data, int cmd)
275{
276 if (!priv->phydev)
277 return -ENOTSUPP;
278
279 return phy_mii_ioctl(priv->phydev, mii_data, cmd);
280}
281
282static void mpc52xx_fec_phy_hw_init(struct mpc52xx_fec_priv *priv) 274static void mpc52xx_fec_phy_hw_init(struct mpc52xx_fec_priv *priv)
283{ 275{
284 struct mpc52xx_fec __iomem *fec = priv->fec; 276 struct mpc52xx_fec __iomem *fec = priv->fec;
@@ -370,7 +362,7 @@ static int mpc52xx_fec_close(struct net_device *dev)
370 * invariant will hold if you make sure that the netif_*_queue() 362 * invariant will hold if you make sure that the netif_*_queue()
371 * calls are done at the proper times. 363 * calls are done at the proper times.
372 */ 364 */
373static int mpc52xx_fec_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) 365static int mpc52xx_fec_start_xmit(struct sk_buff *skb, struct net_device *dev)
374{ 366{
375 struct mpc52xx_fec_priv *priv = netdev_priv(dev); 367 struct mpc52xx_fec_priv *priv = netdev_priv(dev);
376 struct bcom_fec_bd *bd; 368 struct bcom_fec_bd *bd;
@@ -378,7 +370,7 @@ static int mpc52xx_fec_hard_start_xmit(struct sk_buff *skb, struct net_device *d
378 if (bcom_queue_full(priv->tx_dmatsk)) { 370 if (bcom_queue_full(priv->tx_dmatsk)) {
379 if (net_ratelimit()) 371 if (net_ratelimit())
380 dev_err(&dev->dev, "transmit queue overrun\n"); 372 dev_err(&dev->dev, "transmit queue overrun\n");
381 return 1; 373 return NETDEV_TX_BUSY;
382 } 374 }
383 375
384 spin_lock_irq(&priv->lock); 376 spin_lock_irq(&priv->lock);
@@ -388,7 +380,8 @@ static int mpc52xx_fec_hard_start_xmit(struct sk_buff *skb, struct net_device *d
388 bcom_prepare_next_buffer(priv->tx_dmatsk); 380 bcom_prepare_next_buffer(priv->tx_dmatsk);
389 381
390 bd->status = skb->len | BCOM_FEC_TX_BD_TFD | BCOM_FEC_TX_BD_TC; 382 bd->status = skb->len | BCOM_FEC_TX_BD_TFD | BCOM_FEC_TX_BD_TC;
391 bd->skb_pa = dma_map_single(&dev->dev, skb->data, skb->len, DMA_TO_DEVICE); 383 bd->skb_pa = dma_map_single(dev->dev.parent, skb->data, skb->len,
384 DMA_TO_DEVICE);
392 385
393 bcom_submit_next_buffer(priv->tx_dmatsk, skb); 386 bcom_submit_next_buffer(priv->tx_dmatsk, skb);
394 387
@@ -398,7 +391,7 @@ static int mpc52xx_fec_hard_start_xmit(struct sk_buff *skb, struct net_device *d
398 391
399 spin_unlock_irq(&priv->lock); 392 spin_unlock_irq(&priv->lock);
400 393
401 return 0; 394 return NETDEV_TX_OK;
402} 395}
403 396
404#ifdef CONFIG_NET_POLL_CONTROLLER 397#ifdef CONFIG_NET_POLL_CONTROLLER
@@ -430,7 +423,8 @@ static irqreturn_t mpc52xx_fec_tx_interrupt(int irq, void *dev_id)
430 struct bcom_fec_bd *bd; 423 struct bcom_fec_bd *bd;
431 skb = bcom_retrieve_buffer(priv->tx_dmatsk, NULL, 424 skb = bcom_retrieve_buffer(priv->tx_dmatsk, NULL,
432 (struct bcom_bd **)&bd); 425 (struct bcom_bd **)&bd);
433 dma_unmap_single(&dev->dev, bd->skb_pa, skb->len, DMA_TO_DEVICE); 426 dma_unmap_single(dev->dev.parent, bd->skb_pa, skb->len,
427 DMA_TO_DEVICE);
434 428
435 dev_kfree_skb_irq(skb); 429 dev_kfree_skb_irq(skb);
436 } 430 }
@@ -455,7 +449,8 @@ static irqreturn_t mpc52xx_fec_rx_interrupt(int irq, void *dev_id)
455 449
456 rskb = bcom_retrieve_buffer(priv->rx_dmatsk, &status, 450 rskb = bcom_retrieve_buffer(priv->rx_dmatsk, &status,
457 (struct bcom_bd **)&bd); 451 (struct bcom_bd **)&bd);
458 dma_unmap_single(&dev->dev, bd->skb_pa, rskb->len, DMA_FROM_DEVICE); 452 dma_unmap_single(dev->dev.parent, bd->skb_pa, rskb->len,
453 DMA_FROM_DEVICE);
459 454
460 /* Test for errors in received frame */ 455 /* Test for errors in received frame */
461 if (status & BCOM_FEC_RX_BD_ERRORS) { 456 if (status & BCOM_FEC_RX_BD_ERRORS) {
@@ -464,7 +459,8 @@ static irqreturn_t mpc52xx_fec_rx_interrupt(int irq, void *dev_id)
464 bcom_prepare_next_buffer(priv->rx_dmatsk); 459 bcom_prepare_next_buffer(priv->rx_dmatsk);
465 460
466 bd->status = FEC_RX_BUFFER_SIZE; 461 bd->status = FEC_RX_BUFFER_SIZE;
467 bd->skb_pa = dma_map_single(&dev->dev, rskb->data, 462 bd->skb_pa = dma_map_single(dev->dev.parent,
463 rskb->data,
468 FEC_RX_BUFFER_SIZE, DMA_FROM_DEVICE); 464 FEC_RX_BUFFER_SIZE, DMA_FROM_DEVICE);
469 465
470 bcom_submit_next_buffer(priv->rx_dmatsk, rskb); 466 bcom_submit_next_buffer(priv->rx_dmatsk, rskb);
@@ -499,7 +495,7 @@ static irqreturn_t mpc52xx_fec_rx_interrupt(int irq, void *dev_id)
499 bcom_prepare_next_buffer(priv->rx_dmatsk); 495 bcom_prepare_next_buffer(priv->rx_dmatsk);
500 496
501 bd->status = FEC_RX_BUFFER_SIZE; 497 bd->status = FEC_RX_BUFFER_SIZE;
502 bd->skb_pa = dma_map_single(&dev->dev, skb->data, 498 bd->skb_pa = dma_map_single(dev->dev.parent, skb->data,
503 FEC_RX_BUFFER_SIZE, DMA_FROM_DEVICE); 499 FEC_RX_BUFFER_SIZE, DMA_FROM_DEVICE);
504 500
505 bcom_submit_next_buffer(priv->rx_dmatsk, skb); 501 bcom_submit_next_buffer(priv->rx_dmatsk, skb);
@@ -847,12 +843,20 @@ static void mpc52xx_fec_get_drvinfo(struct net_device *dev,
847static int mpc52xx_fec_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) 843static int mpc52xx_fec_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
848{ 844{
849 struct mpc52xx_fec_priv *priv = netdev_priv(dev); 845 struct mpc52xx_fec_priv *priv = netdev_priv(dev);
846
847 if (!priv->phydev)
848 return -ENODEV;
849
850 return phy_ethtool_gset(priv->phydev, cmd); 850 return phy_ethtool_gset(priv->phydev, cmd);
851} 851}
852 852
853static int mpc52xx_fec_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) 853static int mpc52xx_fec_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
854{ 854{
855 struct mpc52xx_fec_priv *priv = netdev_priv(dev); 855 struct mpc52xx_fec_priv *priv = netdev_priv(dev);
856
857 if (!priv->phydev)
858 return -ENODEV;
859
856 return phy_ethtool_sset(priv->phydev, cmd); 860 return phy_ethtool_sset(priv->phydev, cmd);
857} 861}
858 862
@@ -882,9 +886,28 @@ static int mpc52xx_fec_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
882{ 886{
883 struct mpc52xx_fec_priv *priv = netdev_priv(dev); 887 struct mpc52xx_fec_priv *priv = netdev_priv(dev);
884 888
885 return mpc52xx_fec_phy_mii_ioctl(priv, if_mii(rq), cmd); 889 if (!priv->phydev)
890 return -ENOTSUPP;
891
892 return phy_mii_ioctl(priv->phydev, if_mii(rq), cmd);
886} 893}
887 894
895static const struct net_device_ops mpc52xx_fec_netdev_ops = {
896 .ndo_open = mpc52xx_fec_open,
897 .ndo_stop = mpc52xx_fec_close,
898 .ndo_start_xmit = mpc52xx_fec_start_xmit,
899 .ndo_set_multicast_list = mpc52xx_fec_set_multicast_list,
900 .ndo_set_mac_address = mpc52xx_fec_set_mac_address,
901 .ndo_validate_addr = eth_validate_addr,
902 .ndo_do_ioctl = mpc52xx_fec_ioctl,
903 .ndo_change_mtu = eth_change_mtu,
904 .ndo_tx_timeout = mpc52xx_fec_tx_timeout,
905 .ndo_get_stats = mpc52xx_fec_get_stats,
906#ifdef CONFIG_NET_POLL_CONTROLLER
907 .ndo_poll_controller = mpc52xx_fec_poll_controller,
908#endif
909};
910
888/* ======================================================================== */ 911/* ======================================================================== */
889/* OF Driver */ 912/* OF Driver */
890/* ======================================================================== */ 913/* ======================================================================== */
@@ -929,22 +952,10 @@ mpc52xx_fec_probe(struct of_device *op, const struct of_device_id *match)
929 return -EBUSY; 952 return -EBUSY;
930 953
931 /* Init ether ndev with what we have */ 954 /* Init ether ndev with what we have */
932 ndev->open = mpc52xx_fec_open; 955 ndev->netdev_ops = &mpc52xx_fec_netdev_ops;
933 ndev->stop = mpc52xx_fec_close;
934 ndev->hard_start_xmit = mpc52xx_fec_hard_start_xmit;
935 ndev->do_ioctl = mpc52xx_fec_ioctl;
936 ndev->ethtool_ops = &mpc52xx_fec_ethtool_ops; 956 ndev->ethtool_ops = &mpc52xx_fec_ethtool_ops;
937 ndev->get_stats = mpc52xx_fec_get_stats;
938 ndev->set_mac_address = mpc52xx_fec_set_mac_address;
939 ndev->set_multicast_list = mpc52xx_fec_set_multicast_list;
940 ndev->tx_timeout = mpc52xx_fec_tx_timeout;
941 ndev->watchdog_timeo = FEC_WATCHDOG_TIMEOUT; 957 ndev->watchdog_timeo = FEC_WATCHDOG_TIMEOUT;
942 ndev->base_addr = mem.start; 958 ndev->base_addr = mem.start;
943#ifdef CONFIG_NET_POLL_CONTROLLER
944 ndev->poll_controller = mpc52xx_fec_poll_controller;
945#endif
946
947 priv->t_irq = priv->r_irq = ndev->irq = NO_IRQ; /* IRQ are free for now */
948 959
949 spin_lock_init(&priv->lock); 960 spin_lock_init(&priv->lock);
950 961