diff options
author | Thomas Chou <thomas@wytron.com.tw> | 2010-10-06 09:16:10 +0800 |
---|---|---|
committer | Ben Warren <biggerbadderben@gmail.com> | 2010-10-11 23:07:28 -0700 |
commit | 1ca6d0df3ecb028e989f3489b95d021f4497477b (patch) | |
tree | 5b875d32cd00368c205e007e367e3ff2cd990a26 | |
parent | 7b37a27e14975f32528552deed453b56a4149818 (diff) | |
download | u-boot-imx-1ca6d0df3ecb028e989f3489b95d021f4497477b.zip u-boot-imx-1ca6d0df3ecb028e989f3489b95d021f4497477b.tar.gz u-boot-imx-1ca6d0df3ecb028e989f3489b95d021f4497477b.tar.bz2 |
smc91111: add write_hwaddr
Add smc_write_hwaddr() to set mac address.
Clear dev before use.
Signed-off-by: Thomas Chou <thomas@wytron.com.tw>
Acked-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Ben Warren <biggerbadderben@gmail.com>
-rw-r--r-- | drivers/net/smc91111.c | 40 |
1 files changed, 24 insertions, 16 deletions
diff --git a/drivers/net/smc91111.c b/drivers/net/smc91111.c index 54a1bfb..ba9c67e 100644 --- a/drivers/net/smc91111.c +++ b/drivers/net/smc91111.c @@ -654,6 +654,28 @@ again: return length; } +static int smc_write_hwaddr(struct eth_device *dev) +{ + int i; + + swap_to(ETHERNET); + SMC_SELECT_BANK (dev, 1); +#ifdef USE_32_BIT + for (i = 0; i < 6; i += 2) { + word address; + + address = dev->enetaddr[i + 1] << 8; + address |= dev->enetaddr[i]; + SMC_outw(dev, address, (ADDR0_REG + i)); + } +#else + for (i = 0; i < 6; i++) + SMC_outb(dev, dev->enetaddr[i], (ADDR0_REG + i)); +#endif + swap_to(FLASH); + return 0; +} + /* * Open and Initialize the board * @@ -662,8 +684,6 @@ again: */ static int smc_init(struct eth_device *dev, bd_t *bd) { - int i; - swap_to(ETHERNET); PRINTK2 ("%s: smc_init\n", SMC_DEV_NAME); @@ -680,20 +700,6 @@ static int smc_init(struct eth_device *dev, bd_t *bd) /* conservative setting (10Mbps, HalfDuplex, no AutoNeg.) */ /* SMC_SELECT_BANK(dev, 0); */ /* SMC_outw(dev, 0, RPC_REG); */ - SMC_SELECT_BANK (dev, 1); - -#ifdef USE_32_BIT - for (i = 0; i < 6; i += 2) { - word address; - - address = dev->enetaddr[i + 1] << 8; - address |= dev->enetaddr[i]; - SMC_outw(dev, address, (ADDR0_REG + i)); - } -#else - for (i = 0; i < 6; i++) - SMC_outb(dev, dev->enetaddr[i], (ADDR0_REG + i)); -#endif printf(SMC_DEV_NAME ": MAC %pM\n", dev->enetaddr); @@ -1360,6 +1366,7 @@ int smc91111_initialize(u8 dev_num, int base_addr) return 0; } + memset(dev, 0, sizeof(*dev)); priv->dev_num = dev_num; dev->priv = priv; dev->iobase = base_addr; @@ -1374,6 +1381,7 @@ int smc91111_initialize(u8 dev_num, int base_addr) dev->halt = smc_halt; dev->send = smc_send; dev->recv = smc_rcv; + dev->write_hwaddr = smc_write_hwaddr; sprintf(dev->name, "%s-%hu", SMC_DEV_NAME, dev_num); eth_register(dev); |