From: Wolfram Sang <w.sang@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 2/5] net: fec_imx: refactor R_CNTRL setup
Date: Tue, 24 Jan 2012 14:53:48 +0100 [thread overview]
Message-ID: <1327413231-17495-3-git-send-email-w.sang@pengutronix.de> (raw)
In-Reply-To: <1327413231-17495-1-git-send-email-w.sang@pengutronix.de>
Introduce a variable which gets updated when needed and only written
once. Will make further additions easier.
Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
---
drivers/net/fec_imx.c | 23 +++++++----------------
1 files changed, 7 insertions(+), 16 deletions(-)
diff --git a/drivers/net/fec_imx.c b/drivers/net/fec_imx.c
index 1101dad..15c7a4a 100644
--- a/drivers/net/fec_imx.c
+++ b/drivers/net/fec_imx.c
@@ -274,6 +274,7 @@ static int fec_set_hwaddr(struct eth_device *dev, unsigned char *mac)
static int fec_init(struct eth_device *dev)
{
struct fec_priv *fec = (struct fec_priv *)dev->priv;
+ u32 rcntl;
/*
* Clear FEC-Lite interrupt event register(IEVENT)
@@ -288,17 +289,9 @@ static int fec_init(struct eth_device *dev)
/*
* Set FEC-Lite receive control register(R_CNTRL):
*/
- if (fec->xcv_type == SEVENWIRE) {
- /*
- * Frame length=1518; 7-wire mode
- */
- writel(FEC_R_CNTRL_MAX_FL(1518), fec->regs + FEC_R_CNTRL);
- } else {
- /*
- * Frame length=1518; MII mode;
- */
- writel(FEC_R_CNTRL_MAX_FL(1518) | FEC_R_CNTRL_MII_MODE,
- fec->regs + FEC_R_CNTRL);
+ rcntl = FEC_R_CNTRL_MAX_FL(1518);
+ if (fec->xcv_type != SEVENWIRE) {
+ rcntl |= FEC_R_CNTRL_MII_MODE;
/*
* Set MII_SPEED = (1/(mii_speed * 2)) * System Clock
* and do not drop the Preamble.
@@ -309,13 +302,10 @@ static int fec_init(struct eth_device *dev)
if (fec->xcv_type == RMII) {
if (cpu_is_mx28()) {
- /* just another way to enable RMII */
- uint32_t reg = readl(fec->regs + FEC_R_CNTRL);
- writel(reg | FEC_R_CNTRL_RMII_MODE
+ rcntl |= FEC_R_CNTRL_RMII_MODE;
/* the linux driver add these bits, why not we? */
/* | FEC_R_CNTRL_FCE | */
- /* FEC_R_CNTRL_NO_LGTH_CHECK */,
- fec->regs + FEC_R_CNTRL);
+ /* FEC_R_CNTRL_NO_LGTH_CHECK */
} else {
/* disable the gasket and wait */
writel(0, fec->regs + FEC_MIIGSK_ENR);
@@ -329,6 +319,7 @@ static int fec_init(struct eth_device *dev)
writel(FEC_MIIGSK_ENR_EN, fec->regs + FEC_MIIGSK_ENR);
}
}
+ writel(rcntl, fec->regs + FEC_R_CNTRL);
/*
* Set Opcode/Pause Duration Register
--
1.7.8.3
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2012-01-24 13:54 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-24 13:53 [PATCH 0/5] fec_imx & miidev: support for 10 MBit connections Wolfram Sang
2012-01-24 13:53 ` [PATCH 1/5] net: fec_imx: small cleanups Wolfram Sang
2012-01-24 13:53 ` Wolfram Sang [this message]
2012-01-24 13:53 ` [PATCH 3/5] net: fec_imx: enable payload length check and pause frames Wolfram Sang
2012-01-24 13:53 ` [PATCH 4/5] net: miidev: factor out miidev_get_status() Wolfram Sang
2012-01-24 13:53 ` [PATCH 5/5] net: fec_imx: configure FEC for 10Mbit when necessary Wolfram Sang
2012-01-24 15:38 ` Eric Bénard
2012-01-24 15:40 ` Wolfram Sang
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=1327413231-17495-3-git-send-email-w.sang@pengutronix.de \
--to=w.sang@pengutronix.de \
--cc=barebox@lists.infradead.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