summaryrefslogtreecommitdiff
path: root/board/netstar
diff options
context:
space:
mode:
Diffstat (limited to 'board/netstar')
-rw-r--r--board/netstar/eeprom.c57
-rw-r--r--board/netstar/netstar.c12
2 files changed, 42 insertions, 27 deletions
diff --git a/board/netstar/eeprom.c b/board/netstar/eeprom.c
index 5806128..1366457 100644
--- a/board/netstar/eeprom.c
+++ b/board/netstar/eeprom.c
@@ -27,43 +27,42 @@
#include <common.h>
#include <exports.h>
#include <timestamp.h>
+#include <net.h>
#include "../drivers/net/smc91111.h"
-#define SMC_BASE_ADDRESS CONFIG_SMC91111_BASE
-
-static u16 read_eeprom_reg(u16 reg)
+static u16 read_eeprom_reg(struct eth_device *dev, u16 reg)
{
int timeout;
- SMC_SELECT_BANK(2);
- SMC_outw(reg, PTR_REG);
+ SMC_SELECT_BANK(dev, 2);
+ SMC_outw(dev, reg, PTR_REG);
- SMC_SELECT_BANK(1);
- SMC_outw(SMC_inw (CTL_REG) | CTL_EEPROM_SELECT | CTL_RELOAD,
+ SMC_SELECT_BANK(dev, 1);
+ SMC_outw(dev, SMC_inw (dev, CTL_REG) | CTL_EEPROM_SELECT | CTL_RELOAD,
CTL_REG);
timeout = 100;
- while((SMC_inw (CTL_REG) & CTL_RELOAD) && --timeout)
+ while((SMC_inw (dev, CTL_REG) & CTL_RELOAD) && --timeout)
udelay(100);
if (timeout == 0) {
printf("Timeout Reading EEPROM register %02x\n", reg);
return 0;
}
- return SMC_inw (GP_REG);
+ return SMC_inw (dev, GP_REG);
}
-static int write_eeprom_reg(u16 value, u16 reg)
+static int write_eeprom_reg(struct eth_device *dev, u16 value, u16 reg)
{
int timeout;
- SMC_SELECT_BANK(2);
- SMC_outw(reg, PTR_REG);
+ SMC_SELECT_BANK(dev, 2);
+ SMC_outw(dev, reg, PTR_REG);
- SMC_SELECT_BANK(1);
- SMC_outw(value, GP_REG);
- SMC_outw(SMC_inw (CTL_REG) | CTL_EEPROM_SELECT | CTL_STORE, CTL_REG);
+ SMC_SELECT_BANK(dev, 1);
+ SMC_outw(dev, value, GP_REG);
+ SMC_outw(dev, SMC_inw (dev, CTL_REG) | CTL_EEPROM_SELECT | CTL_STORE, CTL_REG);
timeout = 100;
- while ((SMC_inw(CTL_REG) & CTL_STORE) && --timeout)
+ while ((SMC_inw(dev, CTL_REG) & CTL_STORE) && --timeout)
udelay (100);
if (timeout == 0) {
printf("Timeout Writing EEPROM register %02x\n", reg);
@@ -73,17 +72,17 @@ static int write_eeprom_reg(u16 value, u16 reg)
return 1;
}
-static int write_data(u16 *buf, int len)
+static int write_data(struct eth_device *dev, u16 *buf, int len)
{
u16 reg = 0x23;
while (len--)
- write_eeprom_reg(*buf++, reg++);
+ write_eeprom_reg(dev, *buf++, reg++);
return 0;
}
-static int verify_macaddr(char *s)
+static int verify_macaddr(struct eth_device *dev, char *s)
{
u16 reg;
int i, err = 0;
@@ -91,7 +90,7 @@ static int verify_macaddr(char *s)
printf("MAC Address: ");
err = i = 0;
for (i = 0; i < 3; i++) {
- reg = read_eeprom_reg(0x20 + i);
+ reg = read_eeprom_reg(dev, 0x20 + i);
printf("%02x:%02x%c", reg & 0xff, reg >> 8, i != 2 ? ':' : '\n');
if (s)
err |= reg != ((u16 *)s)[i];
@@ -100,7 +99,7 @@ static int verify_macaddr(char *s)
return err ? 0 : 1;
}
-static int set_mac(char *s)
+static int set_mac(struct eth_device *dev, char *s)
{
int i;
char *e, eaddr[6];
@@ -112,7 +111,7 @@ static int set_mac(char *s)
}
for (i = 0; i < 3; i++)
- write_eeprom_reg(*(((u16 *)eaddr) + i), 0x20 + i);
+ write_eeprom_reg(dev, *(((u16 *)eaddr) + i), 0x20 + i);
return 0;
}
@@ -150,6 +149,10 @@ int eeprom(int argc, char *argv[])
int i, len, ret;
unsigned char buf[58], *p;
+ struct eth_device dev = {
+ .iobase = CONFIG_SMC91111_BASE
+ };
+
app_startup(argv);
if (get_version() != XF_VERSION) {
printf("Wrong XF_VERSION.\n");
@@ -160,14 +163,14 @@ int eeprom(int argc, char *argv[])
return crcek();
- if ((SMC_inw (BANK_SELECT) & 0xFF00) != 0x3300) {
+ if ((SMC_inw (&dev, BANK_SELECT) & 0xFF00) != 0x3300) {
printf("SMSC91111 not found.\n");
return 2;
}
/* Called without parameters - print MAC address */
if (argc < 2) {
- verify_macaddr(NULL);
+ verify_macaddr(&dev, NULL);
return 0;
}
@@ -201,8 +204,8 @@ int eeprom(int argc, char *argv[])
}
/* First argument (MAC) is mandatory */
- set_mac(argv[1]);
- if (verify_macaddr(argv[1])) {
+ set_mac(&dev, argv[1]);
+ if (verify_macaddr(&dev, argv[1])) {
printf("*** MAC address does not match! ***\n");
return 4;
}
@@ -210,7 +213,7 @@ int eeprom(int argc, char *argv[])
while (len--)
*p++ = 0;
- write_data((u16 *)buf, sizeof(buf) >> 1);
+ write_data(&dev, (u16 *)buf, sizeof(buf) >> 1);
return 0;
}
diff --git a/board/netstar/netstar.c b/board/netstar/netstar.c
index ffd60bf..df1704b 100644
--- a/board/netstar/netstar.c
+++ b/board/netstar/netstar.c
@@ -21,6 +21,7 @@
*/
#include <common.h>
+#include <netdev.h>
#include <i2c.h>
#include <flash.h>
#include <nand.h>
@@ -115,3 +116,14 @@ int board_nand_init(struct nand_chip *nand)
return 0;
}
#endif
+
+#ifdef CONFIG_CMD_NET
+int board_eth_init(bd_t *bis)
+{
+ int rc = 0;
+#ifdef CONFIG_SMC91111
+ rc = smc91111_initialize(0, CONFIG_SMC91111_BASE);
+#endif
+ return rc;
+}
+#endif