From: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
To: barebox@lists.infradead.org
Subject: [PATCH] dm9000: read the mac address from the register if none are specified
Date: Wed, 23 Feb 2011 18:03:58 +0100 [thread overview]
Message-ID: <1298480638-8522-1-git-send-email-plagnioj@jcrosoft.com> (raw)
as barebox can be run as a second stage the first stage may have init it
before so re-used it
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
drivers/net/dm9000.c | 18 ++++++++++++------
1 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/drivers/net/dm9000.c b/drivers/net/dm9000.c
index b0e8822..c8d8517 100644
--- a/drivers/net/dm9000.c
+++ b/drivers/net/dm9000.c
@@ -169,6 +169,7 @@ struct dm9000_priv {
void __iomem *iodata;
struct mii_device miidev;
int buswidth;
+ int srom;
};
#ifdef CONFIG_DM9000_DEBUG
@@ -433,12 +434,17 @@ static u16 read_srom_word(struct dm9000_priv *priv, int offset)
static int dm9000_get_ethaddr(struct eth_device *edev, unsigned char *adr)
{
struct dm9000_priv *priv = (struct dm9000_priv *)edev->priv;
- int i;
+ int i, oft;
- for (i = 0; i < 3; i++)
- ((u16 *) adr)[i] = read_srom_word(priv, i);
+ if (priv->srom) {
+ for (i = 0; i < 3; i++)
+ ((u16 *) adr)[i] = read_srom_word(priv, i);
+ } else {
+ for (i = 0, oft = 0x10; i < 6; i++, oft++)
+ adr[i] = DM9000_ior(priv, oft);
+ }
- return 0;
+ return 0;
}
static int dm9000_set_ethaddr(struct eth_device *edev, unsigned char *adr)
@@ -491,6 +497,7 @@ static int dm9000_probe(struct device_d *dev)
priv->buswidth = pdata->buswidth;
priv->iodata = (void *)pdata->iodata;
priv->iobase = (void *)pdata->iobase;
+ priv->srom = pdata->srom;
edev->init = dm9000_init_dev;
edev->open = dm9000_eth_open;
@@ -498,8 +505,7 @@ static int dm9000_probe(struct device_d *dev)
edev->recv = dm9000_eth_rx;
edev->halt = dm9000_eth_halt;
edev->set_ethaddr = dm9000_set_ethaddr;
- if (pdata->srom)
- edev->get_ethaddr = dm9000_get_ethaddr;
+ edev->get_ethaddr = dm9000_get_ethaddr;
/* RESET device */
dm9000_reset(priv);
--
1.7.2.3
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
reply other threads:[~2011-02-23 17:08 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=1298480638-8522-1-git-send-email-plagnioj@jcrosoft.com \
--to=plagnioj@jcrosoft.com \
--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