From: Marek Vasut <marex@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 01/13] FEC: Abstract out register setup
Date: Tue, 1 May 2012 23:03:40 +0200 [thread overview]
Message-ID: <1335906232-24549-2-git-send-email-marex@denx.de> (raw)
In-Reply-To: <1335906232-24549-1-git-send-email-marex@denx.de>
Abstract out common register setup. This also configured r_cntrl
to correct value at registration time.
Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Detlev Zundel <dzu@denx.de>
Cc: Fabio Estevam <fabio.estevam@freescale.com>
Cc: Stefano Babic <sbabic@denxde>
Cc: Wolfgang Denk <wd@denx.de>
---
drivers/net/fec_mxc.c | 84 ++++++++++++++++++++++---------------------------
1 file changed, 38 insertions(+), 46 deletions(-)
diff --git a/drivers/net/fec_mxc.c b/drivers/net/fec_mxc.c
index d8db9f0..04750c5 100644
--- a/drivers/net/fec_mxc.c
+++ b/drivers/net/fec_mxc.c
@@ -398,6 +398,42 @@ static void fec_eth_phy_config(struct eth_device *dev)
#endif
}
+/*
+ * Do initial configuration of the FEC registers
+ */
+static void fec_reg_setup(struct fec_priv *fec)
+{
+ uint32_t rcntrl;
+
+ /*
+ * Set interrupt mask register
+ */
+ writel(0x00000000, &fec->eth->imask);
+
+ /*
+ * Clear FEC-Lite interrupt event register(IEVENT)
+ */
+ writel(0xffffffff, &fec->eth->ievent);
+
+
+ /*
+ * Set FEC-Lite receive control register(R_CNTRL):
+ */
+
+ /* Start with frame length = 1518, common for all modes. */
+ rcntrl = PKTSIZE << FEC_RCNTRL_MAX_FL_SHIFT;
+ if (fec->xcv_type == SEVENWIRE)
+ rcntrl |= FEC_RCNTRL_FCE;
+ else if (fec->xcv_type == RGMII)
+ rcntrl |= FEC_RCNTRL_RGMII;
+ else if (fec->xcv_type == RMII)
+ rcntrl |= FEC_RCNTRL_RMII;
+ else /* MII mode */
+ rcntrl |= FEC_RCNTRL_FCE | FEC_RCNTRL_MII_MODE;
+
+ writel(rcntrl, &fec->eth->r_cntrl);
+}
+
/**
* Start the FEC engine
* @param[in] dev Our device to handle
@@ -512,7 +548,6 @@ static int fec_init(struct eth_device *dev, bd_t* bd)
{
struct fec_priv *fec = (struct fec_priv *)dev->priv;
uint32_t mib_ptr = (uint32_t)&fec->eth->rmon_t_drop;
- uint32_t rcntrl;
uint32_t size;
int i, ret;
@@ -560,33 +595,7 @@ static int fec_init(struct eth_device *dev, bd_t* bd)
(unsigned)fec->rbd_base + size);
}
- /*
- * Set interrupt mask register
- */
- writel(0x00000000, &fec->eth->imask);
-
- /*
- * Clear FEC-Lite interrupt event register(IEVENT)
- */
- writel(0xffffffff, &fec->eth->ievent);
-
-
- /*
- * Set FEC-Lite receive control register(R_CNTRL):
- */
-
- /* Start with frame length = 1518, common for all modes. */
- rcntrl = PKTSIZE << FEC_RCNTRL_MAX_FL_SHIFT;
- if (fec->xcv_type == SEVENWIRE)
- rcntrl |= FEC_RCNTRL_FCE;
- else if (fec->xcv_type == RGMII)
- rcntrl |= FEC_RCNTRL_RGMII;
- else if (fec->xcv_type == RMII)
- rcntrl |= FEC_RCNTRL_RMII;
- else /* MII mode */
- rcntrl |= FEC_RCNTRL_FCE | FEC_RCNTRL_MII_MODE;
-
- writel(rcntrl, &fec->eth->r_cntrl);
+ fec_reg_setup(fec);
if (fec->xcv_type == MII10 || fec->xcv_type == MII100)
fec_mii_setspeed(fec);
@@ -933,24 +942,7 @@ static int fec_probe(bd_t *bd, int dev_id, int phy_id, uint32_t base_addr)
udelay(10);
}
- /*
- * Set interrupt mask register
- */
- writel(0x00000000, &fec->eth->imask);
-
- /*
- * Clear FEC-Lite interrupt event register(IEVENT)
- */
- writel(0xffffffff, &fec->eth->ievent);
-
- /*
- * Set FEC-Lite receive control register(R_CNTRL):
- */
- /*
- * Frame length=1518; MII mode;
- */
- writel((PKTSIZE << FEC_RCNTRL_MAX_FL_SHIFT) | FEC_RCNTRL_FCE |
- FEC_RCNTRL_MII_MODE, &fec->eth->r_cntrl);
+ fec_reg_setup(fec);
fec_mii_setspeed(fec);
if (dev_id == -1) {
--
1.7.10
next prev parent reply other threads:[~2012-05-01 21:03 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-01 21:03 [U-Boot] [PATCH 00/13] M28EVK/i.MX28 improvements Marek Vasut
2012-05-01 21:03 ` Marek Vasut [this message]
2012-05-01 21:03 ` [U-Boot] [PATCH 02/13] M28EVK: Implement support for new board V2.0 Marek Vasut
2012-05-01 21:03 ` [U-Boot] [PATCH 03/13] M28EVK: Add SD update command Marek Vasut
2012-05-01 21:03 ` [U-Boot] [PATCH 04/13] i.MX28: Improve passing of data from SPL to U-Boot Marek Vasut
2012-05-01 21:03 ` [U-Boot] [PATCH 05/13] i.MX28: Implement boot pads sampling and reporting Marek Vasut
2012-05-01 21:03 ` [U-Boot] [PATCH 06/13] i.MX28: Add LCDIF register definitions Marek Vasut
2012-05-01 21:03 ` [U-Boot] [PATCH 07/13] i.MX28: Shut down the LCD controller before reset Marek Vasut
2012-05-01 21:03 ` [U-Boot] [PATCH 08/13] i.MX28: Add LRADC register definitions Marek Vasut
2012-05-01 21:03 ` [U-Boot] [PATCH 09/13] i.MX28: Add LRADC init to i.MX28 SPL Marek Vasut
2012-05-01 21:03 ` [U-Boot] [PATCH 10/13] i.MX28: Reorder battery status functions in SPL Marek Vasut
2012-05-01 21:03 ` [U-Boot] [PATCH 11/13] i.MX28: Add battery boot components to SPL Marek Vasut
2012-05-01 21:03 ` [U-Boot] [PATCH 12/13] i.MX28: Check if WP detection is implemented at all Marek Vasut
2012-05-01 21:03 ` [U-Boot] [PATCH 13/13] i.MX28: Avoid redefining serial_put[cs]() Marek Vasut
2012-05-01 21:05 ` [U-Boot] [PATCH 00/13] M28EVK/i.MX28 improvements Marek Vasut
-- strict thread matches above, loose matches on Subject: below --
2012-05-01 21:09 Marek Vasut
2012-05-01 21:09 ` [U-Boot] [PATCH 01/13] FEC: Abstract out register setup Marek Vasut
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=1335906232-24549-2-git-send-email-marex@denx.de \
--to=marex@denx.de \
--cc=u-boot@lists.denx.de \
/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