netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: netdev@vger.kernel.org
Cc: Greg Ungerer <gerg@snapgear.com>, Sascha Hauer <s.hauer@pengutronix.de>
Subject: [PATCH 07/12] fec: refactor init function
Date: Wed, 15 Apr 2009 13:32:20 +0200	[thread overview]
Message-ID: <1239795145-27558-8-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1239795145-27558-7-git-send-email-s.hauer@pengutronix.de>

fec_enet_init() does the hardware initialisation and then calls
fec_restart() which does the same initialisation again, so we
can safely remove the initialisation from fec_enet_init().

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/net/fec.c |   39 ++++-----------------------------------
 1 files changed, 4 insertions(+), 35 deletions(-)

diff --git a/drivers/net/fec.c b/drivers/net/fec.c
index b72df48..a3037ab 100644
--- a/drivers/net/fec.c
+++ b/drivers/net/fec.c
@@ -1616,10 +1616,6 @@ int __init fec_enet_init(struct net_device *dev, int index)
 	fep->hwp = (void __iomem *)dev->base_addr;
 	fep->netdev = dev;
 
-	/* Whack a reset.  We should wait for this. */
-	writel(1, fep->hwp + FEC_ECNTRL);
-	udelay(10);
-
 	/* Set the Ethernet address */
 #ifdef CONFIG_M5272
 	fec_get_mac(dev);
@@ -1641,11 +1637,6 @@ int __init fec_enet_init(struct net_device *dev, int index)
 	fep->rx_bd_base = cbd_base;
 	fep->tx_bd_base = cbd_base + RX_RING_SIZE;
 
-	fep->dirty_tx = fep->cur_tx = fep->tx_bd_base;
-	fep->cur_rx = fep->rx_bd_base;
-
-	fep->skb_cur = fep->skb_dirty = 0;
-
 	/* Initialize the receive buffer descriptors. */
 	bdp = fep->rx_bd_base;
 	for (i=0; i<FEC_ENET_RX_PAGES; i++) {
@@ -1689,25 +1680,9 @@ int __init fec_enet_init(struct net_device *dev, int index)
 	bdp--;
 	bdp->cbd_sc |= BD_SC_WRAP;
 
-	/* Set receive and transmit descriptor base */
-	writel(fep->bd_dma, fep->hwp + FEC_R_DES_START);
-	writel((unsigned long)fep->bd_dma + sizeof(struct bufdesc) * RX_RING_SIZE,
-			fep->hwp + FEC_X_DES_START);
-
 #ifdef HAVE_mii_link_interrupt
 	fec_request_mii_intr(dev);
 #endif
-
-	writel(0, fep->hwp + FEC_GRP_HASH_TABLE_HIGH);
-	writel(0, fep->hwp + FEC_GRP_HASH_TABLE_LOW);
-	writel(PKT_MAXBLR_SIZE, fep->hwp + FEC_R_BUFF_SIZE);
-	writel(2, fep->hwp + FEC_ECNTRL);
-	writel(0, fep->hwp + FEC_R_DES_ACTIVE);
-#ifndef CONFIG_M5272
-	writel(0, fep->hwp + FEC_HASH_TABLE_HIGH);
-	writel(0, fep->hwp + FEC_HASH_TABLE_LOW);
-#endif
-
 	/* The FEC Ethernet specific entries in the device structure */
 	dev->open = fec_enet_open;
 	dev->hard_start_xmit = fec_enet_start_xmit;
@@ -1720,21 +1695,11 @@ int __init fec_enet_init(struct net_device *dev, int index)
 		mii_cmds[i].mii_next = &mii_cmds[i+1];
 	mii_free = mii_cmds;
 
-	/* setup MII interface */
-	writel(OPT_FRAME_SIZE | 0x04, fep->hwp + FEC_R_CNTRL);
-	writel(0, fep->hwp + FEC_X_CNTRL);
-
 	/* Set MII speed to 2.5 MHz */
 	fep->phy_speed = ((((clk_get_rate(fep->clk) / 2 + 4999999)
 					/ 2500000) / 2) & 0x3F) << 1;
-	writel(fep->phy_speed, fep->hwp + FEC_MII_SPEED);
 	fec_restart(dev, 0);
 
-	/* Clear and enable interrupts */
-	writel(0xffc00000, fep->hwp + FEC_IEVENT);
-	writel(FEC_ENET_TXF | FEC_ENET_RXF | FEC_ENET_MII,
-			fep->hwp + FEC_IMASK);
-
 	/* Queue up command to detect the PHY and initialize the
 	 * remainder of the interface.
 	 */
@@ -1769,6 +1734,10 @@ fec_restart(struct net_device *dev, int duplex)
 	/* Reset all multicast.	*/
 	writel(0, fep->hwp + FEC_GRP_HASH_TABLE_HIGH);
 	writel(0, fep->hwp + FEC_GRP_HASH_TABLE_LOW);
+#ifndef CONFIG_M5272
+	writel(0, fep->hwp + FEC_HASH_TABLE_HIGH);
+	writel(0, fep->hwp + FEC_HASH_TABLE_LOW);
+#endif
 
 	/* Set maximum receive buffer size. */
 	writel(PKT_MAXBLR_SIZE, fep->hwp + FEC_R_BUFF_SIZE);
-- 
1.6.2.1


  reply	other threads:[~2009-04-15 11:36 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-15 11:32 [PATCH] FEC driver: patches for -next Sascha Hauer
2009-04-15 11:32 ` [PATCH 01/12] fec: remove unused ifdef Sascha Hauer
2009-04-15 11:32   ` [PATCH 02/12] fec: switch to writel/readl Sascha Hauer
2009-04-15 11:32     ` [PATCH 03/12] fec: do not typedef struct types Sascha Hauer
2009-04-15 11:32       ` [PATCH 04/12] fec: remove unnecessary cast Sascha Hauer
2009-04-15 11:32         ` [PATCH 05/12] fec: Codingstyle cleanups Sascha Hauer
2009-04-15 11:32           ` [PATCH 06/12] fec: refactor set_multicast_list() to make it more readable Sascha Hauer
2009-04-15 11:32             ` Sascha Hauer [this message]
2009-04-15 11:32               ` [PATCH 08/12] fec: align receive packets Sascha Hauer
2009-04-15 11:32                 ` [PATCH 09/12] fec: remove debugging printks Sascha Hauer
2009-04-15 11:32                   ` [PATCH 10/12] fec: switch to net_device_ops Sascha Hauer
2009-04-15 11:32                     ` [PATCH 11/12] FEC Buffer rework Sascha Hauer
2009-04-15 11:32                       ` [PATCH 12/12] fec: call fec_restart() in fec_open() Sascha Hauer
2009-04-16  9:38                         ` David Miller
2009-04-16  9:38                       ` [PATCH 11/12] FEC Buffer rework David Miller
2009-04-17 10:07                       ` Greg Ungerer
2009-04-17 10:12                         ` Sascha Hauer
2009-04-16  9:37                     ` [PATCH 10/12] fec: switch to net_device_ops David Miller
2009-04-16  9:37                   ` [PATCH 09/12] fec: remove debugging printks David Miller
2009-04-16  9:37                 ` [PATCH 08/12] fec: align receive packets David Miller
2009-04-16  9:37               ` [PATCH 07/12] fec: refactor init function David Miller
2009-04-16  9:37             ` [PATCH 06/12] fec: refactor set_multicast_list() to make it more readable David Miller
2009-04-16  9:36           ` [PATCH 05/12] fec: Codingstyle cleanups David Miller
2009-04-16  9:36         ` [PATCH 04/12] fec: remove unnecessary cast David Miller
2009-04-16  9:36       ` [PATCH 03/12] fec: do not typedef struct types David Miller
2009-04-15 13:11     ` [PATCH 02/12] fec: switch to writel/readl Sascha Hauer
2009-04-16  9:36       ` David Miller
2009-04-15 12:12 ` [PATCH] FEC driver: patches for -next Greg Ungerer
2009-04-15 12:55   ` Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1239795145-27558-8-git-send-email-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=gerg@snapgear.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).